app

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 86 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSession

func ResolveSession(sessionID string, resume bool, repo *session.Repository, currentCWD string, w io.Writer) (resolvedSession, error)

ResolveSession determines the session ref to use and, for resumed sessions, returns the stored working directory when available.

func Run

func Run() (exitCode int)

Run executes the luban-code application and returns the process exit code. The command entrypoint is the sole owner of process termination.

func RunPrintMode

func RunPrintMode(eng engine.Engine, r presentation.Renderer, cfg PrintModeConfig) int

RunPrintMode executes a single query in the already-resolved startup session, streams output, and returns an exit code.

func RunScreenReaderREPL

func RunScreenReaderREPL(ctx context.Context, cfg TUIREPLConfig, renderer *ui.ScreenReaderRenderer, sigHandler *SignalHandler) (runErr error)

func RunTUIREPL

func RunTUIREPL(ctx context.Context, cfg TUIREPLConfig, sigHandler *SignalHandler) error

RunTUIREPL runs the default interactive loop using go-tui. The CLI now enters this full-screen TUI by default for interactive sessions.

Types

type PrintModeConfig

type PrintModeConfig struct {
	SessionID         string
	SessionProjectDir string
	ProjectRoot       string
	CWD               string
	Query             string
	Verbose           bool
	Resume            bool
}

PrintModeConfig binds a one-shot query to the exact startup session and workspace identity already published to the tool runtime.

type RegistryDeps

type RegistryDeps struct {
	Registry              *registry.Registry
	AgentTool             *agentruntime.AgentTool
	TaskCreateTool        *tooltasks.TaskCreateTool
	TaskUpdateTool        *tooltasks.TaskUpdateTool
	GetGoalTool           *goaltool.GetGoalTool
	CreateGoalTool        *goaltool.CreateGoalTool
	UpdateGoalTool        *goaltool.UpdateGoalTool
	TeamManager           *toolcollaboration.TeamManager
	Schedule              *toolschedule.Service
	SkillManager          *skills.Manager // shared skill manager (used by SkillTool and skill listing injection)
	SkillTool             *toolskill.SkillTool
	SkillOverrideStore    *skills.FileOverrideStore
	SkillSessionOverrides *skills.MemorySessionOverrideLayer
	PlanState             *toolinteraction.PlanState // shared plan state (used by TUI mode switching)
	AskUserQuestionTool   *toolinteraction.AskUserQuestionTool
	RuntimeScope          *runtimescope.RuntimeScope
	BashTool              *toolshell.BashTool
	RunTool               *toolshell.RunTool
	InspectTool           *toolinspect.Tool
	PowerShellTool        *toolshell.PowerShellTool
	FileReadTool          *toolfile.FileReadTool
	FileWriteTool         *toolfile.FileWriteTool
	FileEditTool          *toolfile.FileEditTool
	ApplyPatchTool        *toolfile.ApplyPatchTool
	NotebookEditTool      *toolfile.NotebookEditTool
	WebFetchTool          *toolweb.WebFetchTool
	WebSearchTool         *toolweb.WebSearchTool
	WebFetchCache         *toolweb.WebFetchCache
	BackgroundTasks       *agentruntime.BackgroundTaskManager
	ServiceMCP            *mcpmanager.Manager
	EnterWorktreeTool     *toolworktree.EnterWorktreeTool
	ExitWorktreeTool      *toolworktree.ExitWorktreeTool
	WorktreeManager       *toolworktree.WorktreeManager
	WorktreeRuntime       *toolworktree.WorktreeRuntime
	// contains filtered or unexported fields
}

RegistryDeps holds shared objects created during tool registration.

func SetupRegistry

func SetupRegistry(pRef *provider.ProviderRef, cwd string, allowedDirs []string, sb sandbox.Backend, webDomains *WebDomainConfig, interactiveOpt ...bool) *RegistryDeps

SetupRegistry creates the tool registry with all built-in tools. AgentTool.System is not set here; the caller wires the system prompt after construction. pRef is a ProviderRef (implements Provider interface) so that sub-agents automatically use the latest provider after a runtime Swap(). sb may be nil (or sandbox.NoopBackend{}) when sandboxing is disabled. webDomains may be nil when no domain restrictions are needed.

func (*RegistryDeps) ApplySessionRuntime

func (d *RegistryDeps) ApplySessionRuntime(sessionID, cwd string, allowedDirs []string, system string, runner *hooks.Runner) error

ApplySessionRuntime publishes the already-resumed target workspace to all registry-owned consumers. Agent and Team inherit prompt/hooks from one snapshot, so their reads cannot observe a mixed workspace pair.

func (*RegistryDeps) BindSessionIdentity

func (d *RegistryDeps) BindSessionIdentity(sessionID string)

BindSessionIdentity moves tool-side session resolution away from entrypoint string closures and onto a synchronized owner before the first live switch.

func (*RegistryDeps) ClearWebFetchCache

func (d *RegistryDeps) ClearWebFetchCache()

ClearWebFetchCache is the session clear-cache lifecycle hook. It clears both raw URL content and allowed domain-info verdicts without stopping the registry-owned cache.

func (*RegistryDeps) CurrentSessionID

func (d *RegistryDeps) CurrentSessionID() string

func (*RegistryDeps) PostCompactMCPServers

func (d *RegistryDeps) PostCompactMCPServers() []compact.MCPServerSnapshot

func (*RegistryDeps) PrepareSessionContext

func (d *RegistryDeps) PrepareSessionContext(cwd string) (*preparedRegistrySessionContext, error)

func (*RegistryDeps) PublishSessionID

func (d *RegistryDeps) PublishSessionID(sessionID string)

PublishSessionID advances identity for a new conversation in the current workspace while preserving the already-published runtime snapshot.

func (*RegistryDeps) SetGoalRuntime

func (d *RegistryDeps) SetGoalRuntime(runtime goaltool.GoalRuntime)

SetGoalRuntime connects every model-facing goal tool to the same session-scoped persistence adapter used by slash commands and the query loop.

func (*RegistryDeps) SetHookRunner

func (d *RegistryDeps) SetHookRunner(runner *hooks.Runner)

SetHookRunner atomically retargets every registry-owned hook consumer. Both initial bootstrap and session switching use this path so TaskCreate cannot retain hooks from the previous workspace.

func (*RegistryDeps) ShutdownLSP

func (d *RegistryDeps) ShutdownLSP(ctx context.Context) error

ShutdownLSP stops and reaps every language server owned by this registry. The caller owns the lifecycle deadline so LSP teardown can participate in a shared, context-bounded application shutdown.

func (*RegistryDeps) StartSchedule

func (d *RegistryDeps) StartSchedule(ctx context.Context) error

StartSchedule begins delivery only after Agent's system prompt, hooks, and permission handler have been installed by the application composition root.

func (*RegistryDeps) StopMCPRuntimeBridge

func (d *RegistryDeps) StopMCPRuntimeBridge(ctx context.Context) error

StopMCPRuntimeBridge unregisters manager lifecycle callbacks, breaks the manager/bridge closure cycle, and stops MCP transports. The caller owns the shutdown deadline and the returned error.

func (*RegistryDeps) StopSchedule

func (d *RegistryDeps) StopSchedule(ctx context.Context) error

StopSchedule releases schedule leadership and waits for context-aware executor calls during application and test teardown. The caller owns the shutdown deadline and the returned error.

func (*RegistryDeps) StopWebFetchCache

func (d *RegistryDeps) StopWebFetchCache()

StopWebFetchCache releases the cache purge goroutine during application shutdown. It is idempotent.

func (*RegistryDeps) UpdateSessionContext

func (d *RegistryDeps) UpdateSessionContext(cwd string, allowedDirs []string) error

type SignalHandler

type SignalHandler struct {
	// contains filtered or unexported fields
}

SignalHandler manages the two-tier signal handling:

  • SIGINT during a query → cancel just that query
  • SIGINT at the prompt (no query) → exit the program
  • SIGTERM → always exit the program

func NewSignalHandler

func NewSignalHandler(globalCancel context.CancelFunc) *SignalHandler

NewSignalHandler creates a signal handler that calls globalCancel for program exit.

func (*SignalHandler) ClearQueryCancel

func (s *SignalHandler) ClearQueryCancel()

ClearQueryCancel clears the query cancel function (called when a query finishes).

func (*SignalHandler) SetQueryCancel

func (s *SignalHandler) SetQueryCancel(fn context.CancelFunc)

SetQueryCancel sets the cancel function for the currently running query.

func (*SignalHandler) Start

func (s *SignalHandler) Start(ctx context.Context, sigCh <-chan os.Signal)

Start begins processing signals and binds the listener to ctx. StopAndWait is the matching owner-side teardown operation.

func (*SignalHandler) StopAndWait

func (s *SignalHandler) StopAndWait()

StopAndWait releases the listener and waits for its goroutine to finish.

type TUIREPLConfig

type TUIREPLConfig struct {
	Engine              engine.Engine
	Repo                *session.Repository
	SessionID           *string
	SessionProjectDir   *string
	CWD                 *string
	HookRunnerRef       **hooks.Runner
	SwitchSession       func(context.Context, commands.SessionListEntry) error
	PublishSessionID    func(string)
	OpenSessionTerminal func(context.Context, string, string, string, string) error
	CurrentModel        func() string
	MCPBackend          commands.MCPBackend
	SkillManager        commands.SkillsBackend
	SkillInvoker        commands.SkillInvoker
	SkillsMenuLauncher  tui.SkillsMenuLauncher
	ReasoningEffort     string
	BuildDiagnostic     func(string) buildinfo.Diagnostic

	// Provider support (Phase 4)
	ProviderRef              *provider.ProviderRef
	ProviderRegistry         *provider.ProviderRegistry
	CredentialStore          *provider.CredentialStore
	ProviderRuntimeOverrides provider.RuntimeOverrides

	// Mode switching support (Shift+Tab)
	PermChecker         *permissions.Checker
	PlanState           *toolinteraction.PlanState
	AskUserQuestionTool *toolinteraction.AskUserQuestionTool
	RuntimeScope        *runtimescope.RuntimeScope
	TaskCreateTool      *tooltasks.TaskCreateTool
	AgentTool           tuiAgentProgressSource
	BackgroundTasks     tuiBackgroundTaskPresentation
	RestoreSessionUsage func(tui.SessionUsage)
	FailClosed          func(error)

	SessionTransitionMu *sync.Mutex
	CommandMu           *sync.Mutex
}

TUIREPLConfig holds everything the TUI-based REPL loop needs.

type WebDomainConfig

type WebDomainConfig struct {
	AllowedDomains        []string // nil = all allowed
	DisallowedDomains     []string // these domains always blocked
	SkipWebFetchPreflight bool     // enterprise setting equivalent to TS skipWebFetchPreflight
}

WebDomainConfig holds domain restriction settings for web tools (Task 7).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL