MCPcopy Index your code
hub / github.com/dagger/dagger / Prompt

Method Prompt

cmd/dagger/shell.go:437–475  ·  view source on GitHub ↗
(ctx context.Context, out idtui.TermOutput, fg termenv.Color)

Source from the content-addressed store, hash-verified

435}
436
437func (h *shellCallHandler) Prompt(ctx context.Context, out idtui.TermOutput, fg termenv.Color) (string, func()) {
438 sb := new(strings.Builder)
439
440 sb.WriteString(termenv.CSI + termenv.ResetSeq + "m") // clear background
441
442 var init func()
443
444 switch h.mode {
445 case modeShell:
446 if def := h.GetDef(nil); def.HasModule() {
447 sb.WriteString(out.String(def.Name).Bold().Foreground(termenv.ANSICyan).String())
448 sb.WriteString(out.String(" ").String())
449 }
450
451 sb.WriteString(out.String(idtui.ShellPrompt).Bold().Foreground(fg).String())
452 sb.WriteString(out.String(out.String(" ").String()).String())
453 case modePrompt:
454 // initialize LLM session if not already initialized
455 llm, err := h.llmMaybe()
456 if err != nil {
457 sb.WriteString(out.String("error").Bold().Foreground(termenv.ANSIRed).String())
458 sb.WriteString(out.String(" ").String())
459 fg = termenv.ANSIRed
460 } else if llm != nil {
461 sb.WriteString(out.String(llm.model).Bold().Foreground(termenv.ANSICyan).String())
462 sb.WriteString(out.String(" ").String())
463 } else {
464 sb.WriteString(out.String("loading...").Bold().Foreground(termenv.ANSIYellow).String())
465 sb.WriteString(out.String(" ").String())
466 init = func() {
467 h.llm(ctx) //nolint:errcheck
468 }
469 }
470 sb.WriteString(out.String(idtui.LLMPrompt).Bold().Foreground(fg).String())
471 sb.WriteString(out.String(out.String(" ").String()).String())
472 }
473
474 return sb.String(), init
475}
476
477func (*shellCallHandler) Print(ctx context.Context, args ...any) error {
478 hc := interp.HandlerCtx(ctx)

Callers

nothing calls this directly

Calls 5

GetDefMethod · 0.95
llmMaybeMethod · 0.95
llmMethod · 0.95
HasModuleMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected