@kinqs/brainrouter-cli 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -52
- package/agents/architect.json +18 -0
- package/agents/explorer.json +18 -0
- package/agents/reviewer.json +18 -0
- package/agents/verifier.json +18 -0
- package/agents/worker.json +18 -0
- package/bin/cli.cjs +71 -0
- package/dist/agent/agent.d.ts +224 -3
- package/dist/agent/agent.js +561 -55
- package/dist/cli/banner.d.ts +80 -0
- package/dist/cli/banner.js +232 -0
- package/dist/cli/cliPrompt.d.ts +106 -0
- package/dist/cli/cliPrompt.js +314 -0
- package/dist/cli/commands/_context.d.ts +3 -1
- package/dist/cli/commands/_helpers.d.ts +1 -1
- package/dist/cli/commands/_helpers.js +6 -6
- package/dist/cli/commands/config.d.ts +46 -0
- package/dist/cli/commands/config.js +1042 -0
- package/dist/cli/commands/guard.js +75 -10
- package/dist/cli/commands/init.d.ts +20 -0
- package/dist/cli/commands/init.js +64 -0
- package/dist/cli/commands/login.d.ts +13 -0
- package/dist/cli/commands/login.js +179 -0
- package/dist/cli/commands/mcp.d.ts +19 -0
- package/dist/cli/commands/mcp.js +286 -0
- package/dist/cli/commands/memory.js +2 -2
- package/dist/cli/commands/obs.js +22 -22
- package/dist/cli/commands/orchestration.js +18 -0
- package/dist/cli/commands/session.js +13 -5
- package/dist/cli/commands/ui.js +202 -91
- package/dist/cli/commands/workflow.d.ts +20 -0
- package/dist/cli/commands/workflow.js +368 -51
- package/dist/cli/ink/ChatApp.d.ts +206 -0
- package/dist/cli/ink/ChatApp.js +493 -0
- package/dist/cli/ink/Frame.d.ts +26 -0
- package/dist/cli/ink/Frame.js +5 -0
- package/dist/cli/ink/Picker.d.ts +65 -0
- package/dist/cli/ink/Picker.js +133 -0
- package/dist/cli/ink/SlashPalette.d.ts +51 -0
- package/dist/cli/ink/SlashPalette.js +136 -0
- package/dist/cli/ink/TextField.d.ts +34 -0
- package/dist/cli/ink/TextField.js +47 -0
- package/dist/cli/ink/WizardApp.d.ts +7 -0
- package/dist/cli/ink/WizardApp.js +422 -0
- package/dist/cli/ink/ambientChat.d.ts +34 -0
- package/dist/cli/ink/ambientChat.js +7 -0
- package/dist/cli/ink/consoleCapture.d.ts +11 -0
- package/dist/cli/ink/consoleCapture.js +33 -0
- package/dist/cli/ink/markdownRender.d.ts +41 -0
- package/dist/cli/ink/markdownRender.js +278 -0
- package/dist/cli/ink/renderWithResizeClear.d.ts +14 -0
- package/dist/cli/ink/renderWithResizeClear.js +33 -0
- package/dist/cli/ink/runChat.d.ts +34 -0
- package/dist/cli/ink/runChat.js +571 -0
- package/dist/cli/ink/runPicker.d.ts +31 -0
- package/dist/cli/ink/runPicker.js +139 -0
- package/dist/cli/ink/runSlashPalette.d.ts +23 -0
- package/dist/cli/ink/runSlashPalette.js +33 -0
- package/dist/cli/ink/runWizard.d.ts +22 -0
- package/dist/cli/ink/runWizard.js +133 -0
- package/dist/cli/ink/stdinHandoff.d.ts +51 -0
- package/dist/cli/ink/stdinHandoff.js +78 -0
- package/dist/cli/ink/toolFormat.d.ts +73 -0
- package/dist/cli/ink/toolFormat.js +180 -0
- package/dist/cli/ink/useTerminalSize.d.ts +35 -0
- package/dist/cli/ink/useTerminalSize.js +26 -0
- package/dist/cli/repl.d.ts +25 -3
- package/dist/cli/repl.js +64 -646
- package/dist/cli/slashSuggest.d.ts +32 -0
- package/dist/cli/slashSuggest.js +146 -0
- package/dist/cli/spinner.d.ts +34 -0
- package/dist/cli/spinner.js +36 -0
- package/dist/cli/statusline.d.ts +67 -0
- package/dist/cli/statusline.js +204 -0
- package/dist/cli/theme.d.ts +79 -0
- package/dist/cli/theme.js +106 -0
- package/dist/cli/whereView.d.ts +81 -0
- package/dist/cli/whereView.js +245 -0
- package/dist/cli/wizard/modelsApi.d.ts +72 -0
- package/dist/cli/wizard/modelsApi.js +166 -0
- package/dist/cli/wizard/picker.d.ts +202 -0
- package/dist/cli/wizard/picker.js +547 -0
- package/dist/cli/wizard/providers.d.ts +86 -0
- package/dist/cli/wizard/providers.js +190 -0
- package/dist/cli/wizard/runner.d.ts +13 -0
- package/dist/cli/wizard/runner.js +488 -0
- package/dist/cli/wizard/types.d.ts +122 -0
- package/dist/cli/wizard/types.js +109 -0
- package/dist/config/config.d.ts +52 -0
- package/dist/config/config.js +89 -75
- package/dist/index.js +215 -206
- package/dist/memory/briefing.d.ts +11 -1
- package/dist/memory/briefing.js +69 -1
- package/dist/memory/consolidation.d.ts +1 -1
- package/dist/orchestration/agentRegistry.d.ts +36 -0
- package/dist/orchestration/agentRegistry.js +64 -0
- package/dist/orchestration/orchestrator.d.ts +7 -0
- package/dist/orchestration/orchestrator.js +2 -0
- package/dist/orchestration/tools.d.ts +10 -1
- package/dist/orchestration/tools.js +48 -4
- package/dist/prompt/breadthHint.d.ts +5 -0
- package/dist/prompt/breadthHint.js +44 -0
- package/dist/prompt/skillCatalog.d.ts +11 -0
- package/dist/prompt/skillCatalog.js +134 -0
- package/dist/prompt/skillRunner.d.ts +2 -2
- package/dist/prompt/skillRunner.js +2 -31
- package/dist/prompt/systemPrompt.d.ts +34 -0
- package/dist/prompt/systemPrompt.js +128 -108
- package/dist/runtime/dangerousCommand.d.ts +53 -0
- package/dist/runtime/dangerousCommand.js +105 -0
- package/dist/runtime/mcpClient.d.ts +38 -1
- package/dist/runtime/mcpClient.js +104 -13
- package/dist/runtime/mcpPool.d.ts +162 -0
- package/dist/runtime/mcpPool.js +423 -0
- package/dist/runtime/mcpUtils.d.ts +3 -1
- package/dist/state/goalStore.d.ts +98 -17
- package/dist/state/goalStore.js +132 -42
- package/dist/state/preferencesStore.d.ts +67 -3
- package/dist/state/preferencesStore.js +84 -1
- package/dist/state/workflowArtifacts.d.ts +63 -2
- package/dist/state/workflowArtifacts.js +120 -8
- package/dist/tests/_helpers.d.ts +31 -0
- package/dist/tests/_helpers.js +91 -0
- package/package.json +12 -5
- package/.env.example +0 -109
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SlashCommandDef } from './SlashPalette.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ink-based chat REPL — replaces the readline-based `startREPL` shell.
|
|
5
|
+
*
|
|
6
|
+
* Layout (matches claude-code's chrome):
|
|
7
|
+
*
|
|
8
|
+
* ┌─────────────────────────────────────────────────────────────┐
|
|
9
|
+
* │ banner (one-time, at top of scrollback) │
|
|
10
|
+
* │ ⏺ assistant turn 1 │
|
|
11
|
+
* │ ⎿ tool call result │
|
|
12
|
+
* │ ❯ user: what about X? │
|
|
13
|
+
* │ ⏺ assistant turn 2 │
|
|
14
|
+
* │ ... │
|
|
15
|
+
* │ │
|
|
16
|
+
* ├──────────────────────────────────────────────────────────────┤
|
|
17
|
+
* │ ❯ <input cursor here> │ ← composer
|
|
18
|
+
* ├──────────────────────────────────────────────────────────────┤
|
|
19
|
+
* │ model · session · ◉ effort ? for shortcuts │ ← footer
|
|
20
|
+
* └──────────────────────────────────────────────────────────────┘
|
|
21
|
+
*
|
|
22
|
+
* Scrollback stays in Ink's normal render tree. It is tempting to use
|
|
23
|
+
* `<Static>` for finished entries, but a chat shell has a permanently
|
|
24
|
+
* live composer below it; on terminal resize, the Static/dynamic split
|
|
25
|
+
* can leave old composer frames behind because the resize clear only
|
|
26
|
+
* applies to Ink's live region. Keeping the full frame diffable makes
|
|
27
|
+
* resize redraw exactly one prompt block.
|
|
28
|
+
*
|
|
29
|
+
* Slash palette is a child component: when the input buffer becomes
|
|
30
|
+
* `/`, the palette renders BELOW the composer with the filtered
|
|
31
|
+
* command list. No more readline detach/Ink mount cycle — Ink owns
|
|
32
|
+
* stdin for the entire REPL lifetime.
|
|
33
|
+
*
|
|
34
|
+
* State machine:
|
|
35
|
+
* - phase: 'idle' | 'turn-running' | 'side-conversation'
|
|
36
|
+
* - scrollback: ScrollbackEntry[] — completed entries (banner, turns, slash output)
|
|
37
|
+
* - composerValue: string — current input buffer
|
|
38
|
+
* - palette: 'closed' | 'open' — visible when value starts with `/`
|
|
39
|
+
*/
|
|
40
|
+
export interface ChatAppProps {
|
|
41
|
+
initialBanner: string;
|
|
42
|
+
initialOfflineWarning?: string;
|
|
43
|
+
initialHint: string;
|
|
44
|
+
/** Static description of the slash commands the user can run. */
|
|
45
|
+
slashCommands: SlashCommandDef[];
|
|
46
|
+
/** Initial prompt label, e.g. "brainrouter[effort:low]". */
|
|
47
|
+
promptLabel: string;
|
|
48
|
+
/** Accent color (hex) for chrome. */
|
|
49
|
+
accentColor?: string;
|
|
50
|
+
/** Called when the user submits a line (slash command OR free-form prompt). */
|
|
51
|
+
onSubmit: (text: string, push: PushScrollback) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Imperative hook — invoked once during mount with a controller object the
|
|
54
|
+
* orchestrator can use to push scrollback / footer updates from outside the
|
|
55
|
+
* React tree (e.g. when the parent-turn closure wants to print a side-channel
|
|
56
|
+
* message after `agent.runTurn` resolved but before the next prompt cycle).
|
|
57
|
+
*/
|
|
58
|
+
onReady?: (controller: ChatController) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Cycle the access mode (read → write → shell → read). Returned label is
|
|
61
|
+
* appended to the footer pill. Called when the user presses Shift+Tab.
|
|
62
|
+
*/
|
|
63
|
+
onAccessModeCycle?: () => string;
|
|
64
|
+
/**
|
|
65
|
+
* Initial access mode for the footer pill — kept in sync via
|
|
66
|
+
* `controller.setFooter({ accessMode })`. Defaults to 'read'.
|
|
67
|
+
*/
|
|
68
|
+
initialAccessMode?: 'read' | 'write' | 'shell';
|
|
69
|
+
/**
|
|
70
|
+
* Initial extra footer segments (model, session, effort, branch). Updated
|
|
71
|
+
* after each turn via `controller.setFooter`.
|
|
72
|
+
*/
|
|
73
|
+
initialFooter?: FooterState;
|
|
74
|
+
}
|
|
75
|
+
export interface FooterState {
|
|
76
|
+
/** e.g. "gpt-4o-mini". */
|
|
77
|
+
model?: string;
|
|
78
|
+
/** e.g. "rep-2026-…-abc123". Truncated for display. */
|
|
79
|
+
session?: string;
|
|
80
|
+
/** e.g. "main". */
|
|
81
|
+
branch?: string;
|
|
82
|
+
/** "low" | "medium" | "high". Rendered as a pill. */
|
|
83
|
+
effort?: string;
|
|
84
|
+
/** Free-form right-side text (statusline segments). */
|
|
85
|
+
rightExtra?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ChatController {
|
|
88
|
+
/** Push entries from outside the React tree (e.g. after the parent turn ended). */
|
|
89
|
+
push: PushScrollback;
|
|
90
|
+
/** Replace the startup banner row without clearing the chat scrollback. */
|
|
91
|
+
replaceBanner: (text: string) => void;
|
|
92
|
+
/** Update the footer status row (model, session, access mode, effort, etc.). */
|
|
93
|
+
setFooter: (patch: Partial<FooterState & {
|
|
94
|
+
accessMode: 'read' | 'write' | 'shell';
|
|
95
|
+
}>) => void;
|
|
96
|
+
/** Programmatically inject text into the composer (e.g. workflow.ts loop tick). */
|
|
97
|
+
setComposer: (text: string) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Render `node` as an overlay above the chat composer. The composer
|
|
100
|
+
* hides while the overlay is active so the overlay's own useInput
|
|
101
|
+
* handlers own keystrokes. Used by `runPicker` / `runTextField` to
|
|
102
|
+
* show /config, /login, /init pickers WITHOUT mounting a second Ink
|
|
103
|
+
* instance (which would race the chat for stdin and terminal state).
|
|
104
|
+
* Promise resolves when `clearOverlay()` is called.
|
|
105
|
+
*/
|
|
106
|
+
showOverlay: (node: React.ReactElement) => Promise<void>;
|
|
107
|
+
/** Remove whatever overlay is currently shown; safe to call when none is set. */
|
|
108
|
+
clearOverlay: () => void;
|
|
109
|
+
/** Exit the chat app gracefully. */
|
|
110
|
+
exit: () => void;
|
|
111
|
+
}
|
|
112
|
+
export type ScrollbackEntry = {
|
|
113
|
+
id: number;
|
|
114
|
+
kind: 'raw';
|
|
115
|
+
text: string;
|
|
116
|
+
noWrap?: boolean;
|
|
117
|
+
} | {
|
|
118
|
+
id: number;
|
|
119
|
+
kind: 'user';
|
|
120
|
+
text: string;
|
|
121
|
+
} | {
|
|
122
|
+
id: number;
|
|
123
|
+
kind: 'assistant';
|
|
124
|
+
text: string;
|
|
125
|
+
raw?: boolean;
|
|
126
|
+
durationMs?: number;
|
|
127
|
+
tokensIn?: number;
|
|
128
|
+
tokensOut?: number;
|
|
129
|
+
calls?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Tool call result row — claude-code style:
|
|
133
|
+
* ⏺ Read(src/foo.ts) (green ⏺ when ok, red when failed)
|
|
134
|
+
* ⎿ <preview line 1> (if preview present, with ⎿ connector)
|
|
135
|
+
* <preview line 2> (continuation lines plain indent)
|
|
136
|
+
* (+N more lines hidden) (truncation hint)
|
|
137
|
+
* `header` is the formatToolCall'd string. `kind` of preview rendering
|
|
138
|
+
* is derived: if the preview looks like a diff, lines colored +green/-red.
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
id: number;
|
|
142
|
+
kind: 'tool';
|
|
143
|
+
header: string;
|
|
144
|
+
ok: boolean;
|
|
145
|
+
durationMs?: number;
|
|
146
|
+
preview?: string;
|
|
147
|
+
} | {
|
|
148
|
+
id: number;
|
|
149
|
+
kind: 'memory';
|
|
150
|
+
level: 'info' | 'warn';
|
|
151
|
+
text: string;
|
|
152
|
+
}
|
|
153
|
+
/** Plan rendering: optional `explanation` renders above the checklist as a dim line. */
|
|
154
|
+
| {
|
|
155
|
+
id: number;
|
|
156
|
+
kind: 'plan';
|
|
157
|
+
items: {
|
|
158
|
+
step: string;
|
|
159
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
160
|
+
}[];
|
|
161
|
+
explanation?: string;
|
|
162
|
+
}
|
|
163
|
+
/** Notice severity: info → gray dim · warn → yellow · error → red bold. */
|
|
164
|
+
| {
|
|
165
|
+
id: number;
|
|
166
|
+
kind: 'notice';
|
|
167
|
+
text: string;
|
|
168
|
+
level?: 'info' | 'warn' | 'error';
|
|
169
|
+
};
|
|
170
|
+
export interface PushScrollback {
|
|
171
|
+
raw(text: string, opts?: {
|
|
172
|
+
noWrap?: boolean;
|
|
173
|
+
}): void;
|
|
174
|
+
user(text: string): void;
|
|
175
|
+
/** `raw: true` skips marked-terminal rendering (use when caller already pre-rendered or user wants raw scrollback). */
|
|
176
|
+
assistant(text: string, meta?: {
|
|
177
|
+
raw?: boolean;
|
|
178
|
+
durationMs?: number;
|
|
179
|
+
tokensIn?: number;
|
|
180
|
+
tokensOut?: number;
|
|
181
|
+
calls?: number;
|
|
182
|
+
}): void;
|
|
183
|
+
/**
|
|
184
|
+
* `header` is the formatted call (e.g. `Read(src/foo.ts)` from
|
|
185
|
+
* `formatToolCall` in toolFormat.ts), NOT the raw tool name. Pass the
|
|
186
|
+
* full result preview unmodified — the renderer applies diff coloring
|
|
187
|
+
* + truncation hints.
|
|
188
|
+
*/
|
|
189
|
+
tool(header: string, ok: boolean, opts?: {
|
|
190
|
+
preview?: string;
|
|
191
|
+
durationMs?: number;
|
|
192
|
+
}): void;
|
|
193
|
+
memory(level: 'info' | 'warn', text: string): void;
|
|
194
|
+
plan(items: {
|
|
195
|
+
step: string;
|
|
196
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
197
|
+
}[], explanation?: string): void;
|
|
198
|
+
/** Severity defaults to 'info' when omitted (back-compat). */
|
|
199
|
+
notice(text: string, level?: 'info' | 'warn' | 'error'): void;
|
|
200
|
+
/** Update the live spinner label (e.g. "Thinking 5s 1.2k↑ 0.4k↓"). */
|
|
201
|
+
setStatus(label: string): void;
|
|
202
|
+
/** Show / hide the spinner without pushing a scrollback entry. */
|
|
203
|
+
setPhase(phase: 'idle' | 'turn-running'): void;
|
|
204
|
+
}
|
|
205
|
+
export declare function ChatApp({ initialBanner, initialOfflineWarning, initialHint, slashCommands, promptLabel, accentColor, onSubmit, onReady, onAccessModeCycle, initialAccessMode, initialFooter, }: ChatAppProps): import("react/jsx-runtime").JSX.Element;
|
|
206
|
+
export declare function filterPaletteCommands(commands: SlashCommandDef[], query: string): SlashCommandDef[];
|