@kernel.chat/kbot 2.7.0 → 2.9.0
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/dist/agent-protocol.d.ts +97 -0
- package/dist/agent-protocol.d.ts.map +1 -0
- package/dist/agent-protocol.js +618 -0
- package/dist/agent-protocol.js.map +1 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +25 -1
- package/dist/agent.js.map +1 -1
- package/dist/architect.d.ts +44 -0
- package/dist/architect.d.ts.map +1 -0
- package/dist/architect.js +403 -0
- package/dist/architect.js.map +1 -0
- package/dist/cli.js +210 -2
- package/dist/cli.js.map +1 -1
- package/dist/confidence.d.ts +102 -0
- package/dist/confidence.d.ts.map +1 -0
- package/dist/confidence.js +693 -0
- package/dist/confidence.js.map +1 -0
- package/dist/graph-memory.d.ts +98 -0
- package/dist/graph-memory.d.ts.map +1 -0
- package/dist/graph-memory.js +926 -0
- package/dist/graph-memory.js.map +1 -0
- package/dist/ide/acp-server.js +2 -2
- package/dist/ide/acp-server.js.map +1 -1
- package/dist/intentionality.d.ts +139 -0
- package/dist/intentionality.d.ts.map +1 -0
- package/dist/intentionality.js +1092 -0
- package/dist/intentionality.js.map +1 -0
- package/dist/lsp-client.d.ts +167 -0
- package/dist/lsp-client.d.ts.map +1 -0
- package/dist/lsp-client.js +679 -0
- package/dist/lsp-client.js.map +1 -0
- package/dist/mcp-plugins.d.ts +62 -0
- package/dist/mcp-plugins.d.ts.map +1 -0
- package/dist/mcp-plugins.js +551 -0
- package/dist/mcp-plugins.js.map +1 -0
- package/dist/reasoning.d.ts +100 -0
- package/dist/reasoning.d.ts.map +1 -0
- package/dist/reasoning.js +1292 -0
- package/dist/reasoning.js.map +1 -0
- package/dist/temporal.d.ts +133 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +778 -0
- package/dist/temporal.js.map +1 -0
- package/dist/tools/e2b-sandbox.d.ts +2 -0
- package/dist/tools/e2b-sandbox.d.ts.map +1 -0
- package/dist/tools/e2b-sandbox.js +460 -0
- package/dist/tools/e2b-sandbox.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +19 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lsp-tools.d.ts +2 -0
- package/dist/tools/lsp-tools.d.ts.map +1 -0
- package/dist/tools/lsp-tools.js +268 -0
- package/dist/tools/lsp-tools.js.map +1 -0
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
// K:BOT Architect Mode — Dual-Agent Plan-Review-Implement Loop
|
|
2
|
+
//
|
|
3
|
+
// Splits complex tasks between two roles:
|
|
4
|
+
// Architect: plans, reviews, approves/rejects
|
|
5
|
+
// Editor: implements one step at a time using tools
|
|
6
|
+
//
|
|
7
|
+
// Similar to Aider's architect mode. The architect never writes code directly;
|
|
8
|
+
// the editor never makes architectural decisions.
|
|
9
|
+
//
|
|
10
|
+
// Activation (to be wired in cli.ts):
|
|
11
|
+
// $ kbot --architect "refactor the auth system"
|
|
12
|
+
// > /architect refactor the auth system
|
|
13
|
+
import { runAgent } from './agent.js';
|
|
14
|
+
import { gatherContext, formatContextForPrompt } from './context.js';
|
|
15
|
+
import { getRepoMapForContext } from './repo-map.js';
|
|
16
|
+
import { createSpinner, printInfo, printSuccess, printError, printWarn } from './ui.js';
|
|
17
|
+
import chalk from 'chalk';
|
|
18
|
+
const AMETHYST = chalk.hex('#6B5B95');
|
|
19
|
+
// ── Safety Limits ──
|
|
20
|
+
const MAX_PLAN_STEPS = 10;
|
|
21
|
+
const MAX_RETRIES_PER_STEP = 2;
|
|
22
|
+
// ── System Prompts ──
|
|
23
|
+
const ARCHITECT_PLAN_PROMPT = `You are the Architect in a dual-agent coding system. Your job is to PLAN, not implement.
|
|
24
|
+
|
|
25
|
+
Given a task and project context, produce a structured JSON plan. You must output ONLY valid JSON matching this schema:
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
"summary": "One-sentence summary of the overall change",
|
|
29
|
+
"files_to_modify": ["list of existing files that will be edited"],
|
|
30
|
+
"files_to_create": ["list of new files to create"],
|
|
31
|
+
"steps": [
|
|
32
|
+
{
|
|
33
|
+
"description": "Precise description of what to do in this step",
|
|
34
|
+
"file": "path/to/file.ts",
|
|
35
|
+
"action": "create | edit | delete"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"constraints": [
|
|
39
|
+
"Things the editor must NOT do (e.g., 'do not change the public API', 'preserve backward compatibility')"
|
|
40
|
+
],
|
|
41
|
+
"test_strategy": "How to verify the changes work (e.g., 'run npx tsc --noEmit', 'run npm test')"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Rules:
|
|
45
|
+
- Maximum ${MAX_PLAN_STEPS} steps. Break large changes into focused, atomic steps.
|
|
46
|
+
- Each step targets exactly ONE file with ONE action.
|
|
47
|
+
- Order steps by dependency — if step 3 depends on step 1, step 1 comes first.
|
|
48
|
+
- For edits, describe WHAT to change specifically (function names, line ranges, logic changes).
|
|
49
|
+
- For creates, describe the full purpose, exports, and structure of the new file.
|
|
50
|
+
- Include constraints that prevent the editor from making unintended changes.
|
|
51
|
+
- The test_strategy should be a concrete command, not a vague suggestion.
|
|
52
|
+
- Output ONLY the JSON object. No markdown fences, no explanation.`;
|
|
53
|
+
const ARCHITECT_REVIEW_PROMPT = `You are the Architect reviewing an Editor's implementation of one step in your plan.
|
|
54
|
+
|
|
55
|
+
You will see:
|
|
56
|
+
1. The original step description
|
|
57
|
+
2. The file and action
|
|
58
|
+
3. The editor's output (what they did)
|
|
59
|
+
|
|
60
|
+
Evaluate whether the implementation:
|
|
61
|
+
- Correctly implements the step as described
|
|
62
|
+
- Does not violate any constraints
|
|
63
|
+
- Does not introduce bugs, type errors, or security issues
|
|
64
|
+
- Is clean, idiomatic code
|
|
65
|
+
|
|
66
|
+
Respond with ONLY valid JSON:
|
|
67
|
+
{
|
|
68
|
+
"approved": true | false,
|
|
69
|
+
"feedback": "If rejected: specific, actionable feedback for the editor to fix. If approved: brief confirmation."
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Be strict but fair. Approve good-enough work. Reject only if there are real problems.`;
|
|
73
|
+
const EDITOR_SYSTEM_PROMPT = `You are the Editor in a dual-agent coding system. You IMPLEMENT, you do not plan.
|
|
74
|
+
|
|
75
|
+
You receive a single step to execute. Use your tools to implement it precisely.
|
|
76
|
+
|
|
77
|
+
Rules:
|
|
78
|
+
- Follow the step description exactly. Do not add unrequested features.
|
|
79
|
+
- Do not make architectural decisions. If something is ambiguous, implement the simplest version.
|
|
80
|
+
- Use edit_file for existing files, write_file for new files, bash for commands.
|
|
81
|
+
- After implementing, briefly describe what you did (1-2 sentences).
|
|
82
|
+
- If the Architect gave you feedback on a previous attempt, address ALL of the feedback points.
|
|
83
|
+
- Do not modify files outside the scope of your current step.`;
|
|
84
|
+
// ── Utility: chatOnce ──
|
|
85
|
+
// A simplified single-turn call. Uses runAgent under the hood but with a
|
|
86
|
+
// specific system prompt injected via the agent message itself (since runAgent
|
|
87
|
+
// builds its own system context, we prepend our role instructions).
|
|
88
|
+
async function chatOnce(systemPrompt, userMessage, agentOpts) {
|
|
89
|
+
// Combine our role-specific system prompt with the user message so
|
|
90
|
+
// runAgent processes it through the full provider pipeline (including tools
|
|
91
|
+
// for the editor). The system prompt goes first as context framing.
|
|
92
|
+
const combined = `${systemPrompt}\n\n---\n\n${userMessage}`;
|
|
93
|
+
const response = await runAgent(combined, {
|
|
94
|
+
...agentOpts,
|
|
95
|
+
agent: agentOpts.agent || 'coder',
|
|
96
|
+
});
|
|
97
|
+
return response.content;
|
|
98
|
+
}
|
|
99
|
+
// ── Phase 1: Architect Creates Plan ──
|
|
100
|
+
async function createPlan(task, agentOpts) {
|
|
101
|
+
const spinner = createSpinner('Architect analyzing task...');
|
|
102
|
+
spinner.start();
|
|
103
|
+
// Gather project context and repo map for the architect
|
|
104
|
+
let contextStr = '';
|
|
105
|
+
try {
|
|
106
|
+
const context = gatherContext();
|
|
107
|
+
contextStr = formatContextForPrompt(context);
|
|
108
|
+
}
|
|
109
|
+
catch { /* context is non-critical */ }
|
|
110
|
+
let repoMap = '';
|
|
111
|
+
try {
|
|
112
|
+
repoMap = await getRepoMapForContext();
|
|
113
|
+
}
|
|
114
|
+
catch { /* repo map is non-critical */ }
|
|
115
|
+
const userMessage = `Project context:
|
|
116
|
+
${contextStr}
|
|
117
|
+
|
|
118
|
+
Repository structure:
|
|
119
|
+
${repoMap || '(unavailable)'}
|
|
120
|
+
|
|
121
|
+
Task: ${task}
|
|
122
|
+
|
|
123
|
+
Output your plan as JSON:`;
|
|
124
|
+
spinner.stop();
|
|
125
|
+
const raw = await chatOnce(ARCHITECT_PLAN_PROMPT, userMessage, agentOpts);
|
|
126
|
+
// Parse the JSON plan from the response
|
|
127
|
+
let plan;
|
|
128
|
+
try {
|
|
129
|
+
// Extract JSON — AI might wrap it in markdown fences
|
|
130
|
+
const jsonMatch = raw.match(/\{[\s\S]*\}/);
|
|
131
|
+
if (!jsonMatch)
|
|
132
|
+
throw new Error('No JSON found in architect response');
|
|
133
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
134
|
+
plan = {
|
|
135
|
+
summary: parsed.summary || task,
|
|
136
|
+
files_to_modify: parsed.files_to_modify || [],
|
|
137
|
+
files_to_create: parsed.files_to_create || [],
|
|
138
|
+
steps: (parsed.steps || []).slice(0, MAX_PLAN_STEPS).map((s) => ({
|
|
139
|
+
description: s.description || '',
|
|
140
|
+
file: s.file || '',
|
|
141
|
+
action: (['create', 'edit', 'delete'].includes(s.action) ? s.action : 'edit'),
|
|
142
|
+
})),
|
|
143
|
+
constraints: parsed.constraints || [],
|
|
144
|
+
test_strategy: parsed.test_strategy || 'npx tsc --noEmit',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Fallback: single-step plan if AI didn't return valid JSON
|
|
149
|
+
plan = {
|
|
150
|
+
summary: task,
|
|
151
|
+
files_to_modify: [],
|
|
152
|
+
files_to_create: [],
|
|
153
|
+
steps: [{
|
|
154
|
+
description: task,
|
|
155
|
+
file: '',
|
|
156
|
+
action: 'edit',
|
|
157
|
+
}],
|
|
158
|
+
constraints: [],
|
|
159
|
+
test_strategy: 'npx tsc --noEmit',
|
|
160
|
+
};
|
|
161
|
+
printWarn('Architect produced non-JSON response. Using simplified plan.');
|
|
162
|
+
}
|
|
163
|
+
// Safety: enforce step limit
|
|
164
|
+
if (plan.steps.length > MAX_PLAN_STEPS) {
|
|
165
|
+
plan.steps = plan.steps.slice(0, MAX_PLAN_STEPS);
|
|
166
|
+
printWarn(`Plan truncated to ${MAX_PLAN_STEPS} steps (safety limit).`);
|
|
167
|
+
}
|
|
168
|
+
return plan;
|
|
169
|
+
}
|
|
170
|
+
// ── Phase 2: Editor Implements a Step ──
|
|
171
|
+
async function editorImplement(step, stepIndex, totalSteps, plan, feedback, agentOpts) {
|
|
172
|
+
const feedbackSection = feedback
|
|
173
|
+
? `\n\nPREVIOUS ATTEMPT REJECTED. Architect feedback:\n${feedback}\n\nAddress ALL feedback points in this attempt.`
|
|
174
|
+
: '';
|
|
175
|
+
const constraintsSection = plan.constraints.length > 0
|
|
176
|
+
? `\nConstraints (do NOT violate these):\n${plan.constraints.map(c => `- ${c}`).join('\n')}`
|
|
177
|
+
: '';
|
|
178
|
+
const userMessage = `Step ${stepIndex + 1} of ${totalSteps}:
|
|
179
|
+
|
|
180
|
+
Action: ${step.action.toUpperCase()} file: ${step.file}
|
|
181
|
+
Description: ${step.description}
|
|
182
|
+
${constraintsSection}
|
|
183
|
+
${feedbackSection}
|
|
184
|
+
|
|
185
|
+
Implement this step now using your tools. Be precise.`;
|
|
186
|
+
return chatOnce(EDITOR_SYSTEM_PROMPT, userMessage, agentOpts);
|
|
187
|
+
}
|
|
188
|
+
// ── Phase 3: Architect Reviews Editor Output ──
|
|
189
|
+
async function architectReview(step, editorOutput, plan, agentOpts) {
|
|
190
|
+
const constraintsSection = plan.constraints.length > 0
|
|
191
|
+
? `\nConstraints that must be respected:\n${plan.constraints.map(c => `- ${c}`).join('\n')}`
|
|
192
|
+
: '';
|
|
193
|
+
const userMessage = `Step under review:
|
|
194
|
+
Action: ${step.action.toUpperCase()} file: ${step.file}
|
|
195
|
+
Description: ${step.description}
|
|
196
|
+
${constraintsSection}
|
|
197
|
+
|
|
198
|
+
Editor's output:
|
|
199
|
+
${editorOutput.slice(0, 4000)}
|
|
200
|
+
|
|
201
|
+
Evaluate and respond with JSON (approved: true/false, feedback: string):`;
|
|
202
|
+
const raw = await chatOnce(ARCHITECT_REVIEW_PROMPT, userMessage, agentOpts);
|
|
203
|
+
try {
|
|
204
|
+
const jsonMatch = raw.match(/\{[\s\S]*\}/);
|
|
205
|
+
if (!jsonMatch)
|
|
206
|
+
throw new Error('No JSON in review');
|
|
207
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
208
|
+
return {
|
|
209
|
+
approved: !!parsed.approved,
|
|
210
|
+
feedback: parsed.feedback || '',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// If review parsing fails, approve by default to avoid blocking
|
|
215
|
+
printWarn('Architect review returned non-JSON. Auto-approving step.');
|
|
216
|
+
return { approved: true, feedback: 'Auto-approved (review parse failure).' };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// ── Phase 4: Verification ──
|
|
220
|
+
async function runVerification(plan, agentOpts) {
|
|
221
|
+
const spinner = createSpinner('Running verification...');
|
|
222
|
+
spinner.start();
|
|
223
|
+
try {
|
|
224
|
+
// Use the editor agent to run the test strategy command
|
|
225
|
+
const verifyMessage = `Run this verification command and report the results:\n\n${plan.test_strategy}\n\nIf there are errors, list them. If everything passes, say so.`;
|
|
226
|
+
const result = await chatOnce(EDITOR_SYSTEM_PROMPT, verifyMessage, agentOpts);
|
|
227
|
+
spinner.stop();
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
spinner.stop();
|
|
232
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
233
|
+
return `Verification failed: ${errMsg}`;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// ── Display Helpers ──
|
|
237
|
+
function displayPlan(plan) {
|
|
238
|
+
console.log();
|
|
239
|
+
console.log(` ${AMETHYST('◆ Architect Plan')}: ${plan.summary}`);
|
|
240
|
+
console.log(` ${chalk.dim('─'.repeat(60))}`);
|
|
241
|
+
console.log();
|
|
242
|
+
if (plan.files_to_modify.length > 0) {
|
|
243
|
+
console.log(` ${chalk.dim('Modify:')} ${plan.files_to_modify.join(', ')}`);
|
|
244
|
+
}
|
|
245
|
+
if (plan.files_to_create.length > 0) {
|
|
246
|
+
console.log(` ${chalk.dim('Create:')} ${plan.files_to_create.join(', ')}`);
|
|
247
|
+
}
|
|
248
|
+
if (plan.files_to_modify.length > 0 || plan.files_to_create.length > 0) {
|
|
249
|
+
console.log();
|
|
250
|
+
}
|
|
251
|
+
for (let i = 0; i < plan.steps.length; i++) {
|
|
252
|
+
const step = plan.steps[i];
|
|
253
|
+
const actionIcon = { create: chalk.green('+'), edit: chalk.yellow('~'), delete: chalk.red('-') }[step.action];
|
|
254
|
+
console.log(` ${chalk.dim(`${i + 1}.`)} ${actionIcon} ${chalk.cyan(step.file)} ${chalk.dim('—')} ${step.description}`);
|
|
255
|
+
}
|
|
256
|
+
if (plan.constraints.length > 0) {
|
|
257
|
+
console.log();
|
|
258
|
+
console.log(` ${chalk.dim('Constraints:')}`);
|
|
259
|
+
for (const c of plan.constraints) {
|
|
260
|
+
console.log(` ${chalk.red('!')} ${c}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
console.log();
|
|
264
|
+
console.log(` ${chalk.dim('Verify:')} ${plan.test_strategy}`);
|
|
265
|
+
console.log(` ${chalk.dim(`${plan.steps.length} steps`)}`);
|
|
266
|
+
console.log();
|
|
267
|
+
}
|
|
268
|
+
function displayStepResult(stepIndex, total, step, approved, attempt) {
|
|
269
|
+
const prefix = `Step ${stepIndex + 1}/${total}`;
|
|
270
|
+
if (approved) {
|
|
271
|
+
printSuccess(`${prefix}: ${step.description}`);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
printWarn(`${prefix}: rejected (attempt ${attempt}/${MAX_RETRIES_PER_STEP + 1})`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function displayReport(report) {
|
|
278
|
+
console.log();
|
|
279
|
+
console.log(` ${AMETHYST('◆ Architect Report')}`);
|
|
280
|
+
console.log(` ${chalk.dim('─'.repeat(60))}`);
|
|
281
|
+
console.log();
|
|
282
|
+
console.log(` ${chalk.dim('Summary:')} ${report.plan.summary}`);
|
|
283
|
+
console.log(` ${chalk.dim('Status:')} ${report.status === 'completed' ? chalk.green(report.status) : report.status === 'partial' ? chalk.yellow(report.status) : chalk.red(report.status)}`);
|
|
284
|
+
console.log();
|
|
285
|
+
for (const outcome of report.outcomes) {
|
|
286
|
+
const icon = outcome.status === 'approved' ? chalk.green('✓') : chalk.red('✗');
|
|
287
|
+
const retries = outcome.attempts > 1 ? chalk.dim(` (${outcome.attempts} attempts)`) : '';
|
|
288
|
+
console.log(` ${icon} ${outcome.step.description}${retries}`);
|
|
289
|
+
if (outcome.status === 'failed' && outcome.reviewFeedback) {
|
|
290
|
+
console.log(` ${chalk.dim('Last feedback:')} ${outcome.reviewFeedback.slice(0, 120)}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (report.verification) {
|
|
294
|
+
console.log();
|
|
295
|
+
console.log(` ${chalk.dim('Verification:')}`);
|
|
296
|
+
// Show first few lines of verification output
|
|
297
|
+
const lines = report.verification.split('\n').slice(0, 8);
|
|
298
|
+
for (const line of lines) {
|
|
299
|
+
console.log(` ${line}`);
|
|
300
|
+
}
|
|
301
|
+
if (report.verification.split('\n').length > 8) {
|
|
302
|
+
console.log(` ${chalk.dim(`... (${report.verification.split('\n').length - 8} more lines)`)}`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
console.log();
|
|
306
|
+
}
|
|
307
|
+
// ── Main Entry Point ──
|
|
308
|
+
/**
|
|
309
|
+
* Run architect mode: a dual-agent loop where the Architect plans and reviews
|
|
310
|
+
* while the Editor implements each step.
|
|
311
|
+
*
|
|
312
|
+
* Flow:
|
|
313
|
+
* 1. Architect analyzes the task and creates a structured plan
|
|
314
|
+
* 2. For each step: Editor implements -> Architect reviews -> approve or redo
|
|
315
|
+
* 3. After all steps: Architect runs verification (type check, tests)
|
|
316
|
+
* 4. Returns a full report
|
|
317
|
+
*
|
|
318
|
+
* @param task - The user's task description
|
|
319
|
+
* @param options - Agent options (model, streaming, etc.)
|
|
320
|
+
* @returns Full report of the architect session
|
|
321
|
+
*/
|
|
322
|
+
export async function runArchitectMode(task, options = {}) {
|
|
323
|
+
printInfo('Entering architect mode...');
|
|
324
|
+
console.log();
|
|
325
|
+
// Phase 1: Architect creates plan
|
|
326
|
+
printInfo('Phase 1: Architect planning...');
|
|
327
|
+
const plan = await createPlan(task, options);
|
|
328
|
+
displayPlan(plan);
|
|
329
|
+
// Phase 2: Editor implements each step with architect review
|
|
330
|
+
printInfo('Phase 2: Editor implementing...');
|
|
331
|
+
console.log();
|
|
332
|
+
const outcomes = [];
|
|
333
|
+
for (let i = 0; i < plan.steps.length; i++) {
|
|
334
|
+
const step = plan.steps[i];
|
|
335
|
+
let approved = false;
|
|
336
|
+
let attempts = 0;
|
|
337
|
+
let lastEditorOutput = '';
|
|
338
|
+
let lastFeedback = null;
|
|
339
|
+
while (!approved && attempts <= MAX_RETRIES_PER_STEP) {
|
|
340
|
+
attempts++;
|
|
341
|
+
// Editor implements
|
|
342
|
+
const spinner = createSpinner(`Step ${i + 1}/${plan.steps.length}: ${step.description}`);
|
|
343
|
+
spinner.start();
|
|
344
|
+
try {
|
|
345
|
+
lastEditorOutput = await editorImplement(step, i, plan.steps.length, plan, lastFeedback, options);
|
|
346
|
+
spinner.stop();
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
spinner.stop();
|
|
350
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
351
|
+
printError(`Editor failed on step ${i + 1}: ${errMsg}`);
|
|
352
|
+
lastEditorOutput = `Error: ${errMsg}`;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
// Architect reviews
|
|
356
|
+
const review = await architectReview(step, lastEditorOutput, plan, options);
|
|
357
|
+
approved = review.approved;
|
|
358
|
+
lastFeedback = review.feedback;
|
|
359
|
+
displayStepResult(i, plan.steps.length, step, approved, attempts);
|
|
360
|
+
if (!approved && attempts <= MAX_RETRIES_PER_STEP) {
|
|
361
|
+
printInfo(`Architect feedback: ${review.feedback.slice(0, 200)}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
outcomes.push({
|
|
365
|
+
step,
|
|
366
|
+
status: approved ? 'approved' : 'failed',
|
|
367
|
+
attempts,
|
|
368
|
+
editorOutput: lastEditorOutput,
|
|
369
|
+
reviewFeedback: lastFeedback || undefined,
|
|
370
|
+
});
|
|
371
|
+
// If a step fails after all retries, continue with remaining steps
|
|
372
|
+
// (the architect plan may have independent steps that can still succeed)
|
|
373
|
+
if (!approved) {
|
|
374
|
+
printWarn(`Step ${i + 1} failed after ${attempts} attempts. Continuing with remaining steps.`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// Phase 3: Verification
|
|
378
|
+
const approvedCount = outcomes.filter(o => o.status === 'approved').length;
|
|
379
|
+
let verification = null;
|
|
380
|
+
if (approvedCount > 0) {
|
|
381
|
+
printInfo('Phase 3: Running verification...');
|
|
382
|
+
verification = await runVerification(plan, options);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
printWarn('All steps failed. Skipping verification.');
|
|
386
|
+
}
|
|
387
|
+
// Determine overall status
|
|
388
|
+
const failedCount = outcomes.filter(o => o.status === 'failed').length;
|
|
389
|
+
let status;
|
|
390
|
+
if (failedCount === 0) {
|
|
391
|
+
status = 'completed';
|
|
392
|
+
}
|
|
393
|
+
else if (approvedCount > 0) {
|
|
394
|
+
status = 'partial';
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
status = 'failed';
|
|
398
|
+
}
|
|
399
|
+
const report = { plan, outcomes, verification, status };
|
|
400
|
+
displayReport(report);
|
|
401
|
+
return report;
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=architect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"architect.js","sourceRoot":"","sources":["../src/architect.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,0CAA0C;AAC1C,gDAAgD;AAChD,yDAAyD;AACzD,EAAE;AACF,+EAA+E;AAC/E,kDAAkD;AAClD,EAAE;AACF,sCAAsC;AACtC,kDAAkD;AAClD,0CAA0C;AAE1C,OAAO,EAAE,QAAQ,EAAyC,MAAM,YAAY,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACvF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;AAErC,sBAAsB;AAEtB,MAAM,cAAc,GAAG,EAAE,CAAA;AACzB,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAkC9B,uBAAuB;AAEvB,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;YAsBlB,cAAc;;;;;;;mEAOyC,CAAA;AAEnE,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;sFAmBsD,CAAA;AAEtF,MAAM,oBAAoB,GAAG;;;;;;;;;;8DAUiC,CAA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AAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAA;IACtE,IAAI,MAAiC,CAAA;IACrC,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,WAAW,CAAA;IACtB,CAAC;SAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,GAAG,SAAS,CAAA;IACpB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,QAAQ,CAAA;IACnB,CAAC;IAED,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,CAAA;IACxE,aAAa,CAAC,MAAM,CAAC,CAAA;IAErB,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import { banner, bannerCompact, bannerAuth, prompt as kbotPrompt, printError, pr
|
|
|
22
22
|
import { checkForUpdate, selfUpdate } from './updater.js';
|
|
23
23
|
import { syncOnStartup, schedulePush, flushCloudSync, isCloudSyncEnabled, setCloudToken, getCloudToken } from './cloud-sync.js';
|
|
24
24
|
import chalk from 'chalk';
|
|
25
|
-
const VERSION = '2.
|
|
25
|
+
const VERSION = '2.9.0';
|
|
26
26
|
async function main() {
|
|
27
27
|
const program = new Command();
|
|
28
28
|
program
|
|
@@ -41,6 +41,7 @@ async function main() {
|
|
|
41
41
|
.option('-t, --thinking', 'Show AI reasoning steps')
|
|
42
42
|
.option('--thinking-budget <tokens>', 'Thinking token budget (default: 10000)')
|
|
43
43
|
.option('--self-eval', 'Enable self-evaluation loop (score and retry low-quality responses)')
|
|
44
|
+
.option('--architect', 'Architect mode — plan-review-implement with dual agents')
|
|
44
45
|
.option('--safe', 'Confirm destructive operations')
|
|
45
46
|
.option('--strict', 'Confirm ALL operations')
|
|
46
47
|
.argument('[prompt...]', 'One-shot prompt')
|
|
@@ -371,7 +372,7 @@ async function main() {
|
|
|
371
372
|
});
|
|
372
373
|
program
|
|
373
374
|
.command('serve')
|
|
374
|
-
.description('Start HTTP server — expose all
|
|
375
|
+
.description('Start HTTP server — expose all 151 tools for kernel.chat or any client')
|
|
375
376
|
.option('-p, --port <port>', 'Port to listen on', '7437')
|
|
376
377
|
.option('--token <token>', 'Require auth token for all requests')
|
|
377
378
|
.option('--computer-use', 'Enable computer use tools')
|
|
@@ -700,6 +701,12 @@ async function main() {
|
|
|
700
701
|
}) + '\n');
|
|
701
702
|
return;
|
|
702
703
|
}
|
|
704
|
+
// Architect mode: plan-review-implement with dual agents
|
|
705
|
+
if (opts.architect) {
|
|
706
|
+
const { runArchitectMode } = await import('./architect.js');
|
|
707
|
+
await runArchitectMode(message, agentOpts);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
703
710
|
agentOpts.stream = true; // Force streaming for faster one-shot
|
|
704
711
|
await runAndPrint(message, agentOpts);
|
|
705
712
|
return;
|
|
@@ -1425,6 +1432,207 @@ async function handleSlashCommand(input, opts, rl) {
|
|
|
1425
1432
|
}
|
|
1426
1433
|
break;
|
|
1427
1434
|
}
|
|
1435
|
+
case 'confidence': {
|
|
1436
|
+
const task = args.join(' ') || 'general task';
|
|
1437
|
+
const { estimateConfidence, reportConfidence } = await import('./confidence.js');
|
|
1438
|
+
const score = estimateConfidence(task, process.cwd());
|
|
1439
|
+
printInfo(reportConfidence(score));
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
case 'skills': {
|
|
1443
|
+
const { getSkillProfile } = await import('./confidence.js');
|
|
1444
|
+
const profile = getSkillProfile();
|
|
1445
|
+
printInfo('Strengths:');
|
|
1446
|
+
for (const s of profile.strengths.slice(0, 5))
|
|
1447
|
+
printInfo(` ✓ ${s.domain} (${Math.round(s.successRate * 100)}% success, ${s.sampleSize} tasks)`);
|
|
1448
|
+
if (profile.weaknesses.length > 0) {
|
|
1449
|
+
printInfo('Weaknesses:');
|
|
1450
|
+
for (const w of profile.weaknesses.slice(0, 5))
|
|
1451
|
+
printInfo(` ✗ ${w.domain} (${Math.round(w.successRate * 100)}% success)`);
|
|
1452
|
+
}
|
|
1453
|
+
if (profile.unknown.length > 0)
|
|
1454
|
+
printInfo(`Unknown: ${profile.unknown.join(', ')}`);
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
case 'effort': {
|
|
1458
|
+
const task = args.join(' ');
|
|
1459
|
+
if (!task) {
|
|
1460
|
+
printError('Usage: /effort <task description>');
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
const { estimateEffort } = await import('./confidence.js');
|
|
1464
|
+
const est = estimateEffort(task);
|
|
1465
|
+
printInfo(`Complexity: ${est.complexity}`);
|
|
1466
|
+
printInfo(`Tool calls: ${est.toolCalls.min}-${est.toolCalls.max} (expected: ${est.toolCalls.expected})`);
|
|
1467
|
+
printInfo(`Cost: $${est.estimatedCostUsd.min.toFixed(3)}-$${est.estimatedCostUsd.max.toFixed(3)}`);
|
|
1468
|
+
printInfo(`Breakdown: ${est.breakdown}`);
|
|
1469
|
+
break;
|
|
1470
|
+
}
|
|
1471
|
+
case 'handoff': {
|
|
1472
|
+
const { getActiveHandoffs } = await import('./agent-protocol.js');
|
|
1473
|
+
const handoffs = getActiveHandoffs();
|
|
1474
|
+
if (handoffs.length === 0)
|
|
1475
|
+
printInfo('No active handoffs.');
|
|
1476
|
+
else
|
|
1477
|
+
for (const h of handoffs)
|
|
1478
|
+
printInfo(` [${h.priority}] ${h.from} → ${h.to}: ${h.reason}`);
|
|
1479
|
+
break;
|
|
1480
|
+
}
|
|
1481
|
+
case 'blackboard': {
|
|
1482
|
+
const { blackboardQuery } = await import('./agent-protocol.js');
|
|
1483
|
+
const entries = blackboardQuery();
|
|
1484
|
+
if (entries.length === 0)
|
|
1485
|
+
printInfo('Blackboard is empty.');
|
|
1486
|
+
else
|
|
1487
|
+
for (const e of entries)
|
|
1488
|
+
printInfo(` [${e.type}] ${e.key} = ${JSON.stringify(e.value).slice(0, 60)} (by ${e.author})`);
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
case 'trust': {
|
|
1492
|
+
const { getTrustReport } = await import('./agent-protocol.js');
|
|
1493
|
+
const report = getTrustReport();
|
|
1494
|
+
printInfo(report);
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
case 'checkpoint': {
|
|
1498
|
+
const desc = args.join(' ');
|
|
1499
|
+
if (desc) {
|
|
1500
|
+
const { createCheckpoint } = await import('./temporal.js');
|
|
1501
|
+
createCheckpoint(desc, { filesModified: [], toolsUsed: [], decisions: [] });
|
|
1502
|
+
printSuccess(`Checkpoint saved: ${desc}`);
|
|
1503
|
+
}
|
|
1504
|
+
else {
|
|
1505
|
+
const { getCheckpoints } = await import('./temporal.js');
|
|
1506
|
+
const cps = getCheckpoints();
|
|
1507
|
+
if (cps.length === 0)
|
|
1508
|
+
printInfo('No checkpoints.');
|
|
1509
|
+
else
|
|
1510
|
+
for (const cp of cps)
|
|
1511
|
+
printInfo(` [${cp.id}] step ${cp.step}: ${cp.description}`);
|
|
1512
|
+
}
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
case 'anticipate': {
|
|
1516
|
+
const { anticipateNext } = await import('./temporal.js');
|
|
1517
|
+
const predictions = anticipateNext([], args.join(' ') || 'general');
|
|
1518
|
+
if (predictions.length === 0)
|
|
1519
|
+
printInfo('No predictions.');
|
|
1520
|
+
else
|
|
1521
|
+
for (const p of predictions)
|
|
1522
|
+
printInfo(` ${Math.round(p.confidence * 100)}% — ${p.prediction}`);
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
case 'identity': {
|
|
1526
|
+
const { getIdentity, getPersonalitySummary } = await import('./temporal.js');
|
|
1527
|
+
const id = getIdentity();
|
|
1528
|
+
printInfo(`Sessions: ${id.totalSessions} · Messages: ${id.totalMessages} · Tools: ${id.totalToolCalls}`);
|
|
1529
|
+
printInfo(getPersonalitySummary());
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
case 'hypothesize': {
|
|
1533
|
+
const obs = args.join(' ');
|
|
1534
|
+
if (!obs) {
|
|
1535
|
+
printError('Usage: /hypothesize <error or observation>');
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
const { generateHypotheses } = await import('./reasoning.js');
|
|
1539
|
+
const result = generateHypotheses(obs, process.cwd());
|
|
1540
|
+
for (const h of result.hypotheses.slice(0, 5)) {
|
|
1541
|
+
printInfo(` ${Math.round(h.likelihood * 100)}% — ${h.explanation}`);
|
|
1542
|
+
if (h.testAction)
|
|
1543
|
+
printInfo(` Test: ${h.testAction}`);
|
|
1544
|
+
}
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
case 'counterfactual': {
|
|
1548
|
+
const parts = args.join(' ').split(' vs ');
|
|
1549
|
+
if (parts.length < 2) {
|
|
1550
|
+
printError('Usage: /counterfactual <approach A> vs <approach B>');
|
|
1551
|
+
break;
|
|
1552
|
+
}
|
|
1553
|
+
const { exploreCounterfactual } = await import('./reasoning.js');
|
|
1554
|
+
const cf = exploreCounterfactual(parts[0].trim(), parts[1].trim(), process.cwd());
|
|
1555
|
+
printInfo(`Recommendation: ${cf.recommendation}`);
|
|
1556
|
+
printInfo(`Benefits: ${cf.tradeoffs.benefits.join(', ')}`);
|
|
1557
|
+
printInfo(`Risks: ${cf.tradeoffs.risks.join(', ')}`);
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
case 'strategy': {
|
|
1561
|
+
const task = args.join(' ');
|
|
1562
|
+
if (!task) {
|
|
1563
|
+
printError('Usage: /strategy <task description>');
|
|
1564
|
+
break;
|
|
1565
|
+
}
|
|
1566
|
+
const { selectStrategy } = await import('./reasoning.js');
|
|
1567
|
+
const result = selectStrategy(task, process.cwd());
|
|
1568
|
+
printInfo(`Strategy: ${result.chosenStrategy}`);
|
|
1569
|
+
printInfo(`Reasoning: ${result.reasoning}`);
|
|
1570
|
+
if (result.adaptations.length > 0)
|
|
1571
|
+
printInfo(`Adaptations: ${result.adaptations.join(', ')}`);
|
|
1572
|
+
printInfo(`Fallback: ${result.fallbackStrategy}`);
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
case 'drives': {
|
|
1576
|
+
const { getDriveState } = await import('./intentionality.js');
|
|
1577
|
+
const state = getDriveState();
|
|
1578
|
+
for (const d of state.drives) {
|
|
1579
|
+
const bar = '█'.repeat(Math.round(d.currentSatisfaction * 10)) + '░'.repeat(10 - Math.round(d.currentSatisfaction * 10));
|
|
1580
|
+
printInfo(` ${d.name}: ${bar} ${Math.round(d.currentSatisfaction * 100)}% (weight: ${d.weight.toFixed(1)})`);
|
|
1581
|
+
}
|
|
1582
|
+
if (state.frustrated)
|
|
1583
|
+
printInfo(' ⚠ Frustrated — multiple drives below threshold');
|
|
1584
|
+
if (state.motivated)
|
|
1585
|
+
printInfo(' ✓ Motivated — all drives healthy');
|
|
1586
|
+
break;
|
|
1587
|
+
}
|
|
1588
|
+
case 'motivation': {
|
|
1589
|
+
const { getMotivation, getMotivationSummary, suggestFromMotivation } = await import('./intentionality.js');
|
|
1590
|
+
printInfo(getMotivationSummary());
|
|
1591
|
+
const suggestions = suggestFromMotivation();
|
|
1592
|
+
if (suggestions.length > 0) {
|
|
1593
|
+
printInfo('Suggestions:');
|
|
1594
|
+
for (const s of suggestions)
|
|
1595
|
+
printInfo(` → ${s}`);
|
|
1596
|
+
}
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
case 'architect': {
|
|
1600
|
+
const archTask = args.join(' ');
|
|
1601
|
+
if (!archTask) {
|
|
1602
|
+
printError('Usage: /architect <task description>');
|
|
1603
|
+
printInfo('Example: /architect refactor the auth system to use JWT');
|
|
1604
|
+
}
|
|
1605
|
+
else {
|
|
1606
|
+
const { runArchitectMode } = await import('./architect.js');
|
|
1607
|
+
await runArchitectMode(archTask, opts);
|
|
1608
|
+
}
|
|
1609
|
+
break;
|
|
1610
|
+
}
|
|
1611
|
+
case 'graph': {
|
|
1612
|
+
const graphArgs = args.join(' ');
|
|
1613
|
+
if (!graphArgs) {
|
|
1614
|
+
const { getGraph } = await import('./graph-memory.js');
|
|
1615
|
+
const graph = getGraph();
|
|
1616
|
+
printInfo(`Graph: ${graph.nodes.size} nodes, ${graph.edges.length} edges`);
|
|
1617
|
+
if (graph.nodes.size > 0) {
|
|
1618
|
+
const { toContext } = await import('./graph-memory.js');
|
|
1619
|
+
printInfo(toContext(500));
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
else {
|
|
1623
|
+
const { findNode } = await import('./graph-memory.js');
|
|
1624
|
+
const results = findNode(graphArgs);
|
|
1625
|
+
if (results.length === 0) {
|
|
1626
|
+
printInfo('No matching nodes found.');
|
|
1627
|
+
}
|
|
1628
|
+
else {
|
|
1629
|
+
for (const n of results.slice(0, 10)) {
|
|
1630
|
+
printInfo(` [${n.type}:${n.name}] (${n.accessCount} accesses)`);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
break;
|
|
1635
|
+
}
|
|
1428
1636
|
case 'plan': {
|
|
1429
1637
|
const planTask = args.join(' ');
|
|
1430
1638
|
if (!planTask) {
|