@kernel.chat/kbot 2.13.0 → 2.14.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/README.md +55 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/emergent-swarm.d.ts +41 -0
- package/dist/emergent-swarm.d.ts.map +1 -0
- package/dist/emergent-swarm.js +246 -0
- package/dist/emergent-swarm.js.map +1 -0
- package/dist/entropy-context.d.ts +40 -0
- package/dist/entropy-context.d.ts.map +1 -0
- package/dist/entropy-context.js +144 -0
- package/dist/entropy-context.js.map +1 -0
- package/dist/error-correction.d.ts +37 -0
- package/dist/error-correction.d.ts.map +1 -0
- package/dist/error-correction.js +174 -0
- package/dist/error-correction.js.map +1 -0
- package/dist/godel-limits.d.ts +46 -0
- package/dist/godel-limits.d.ts.map +1 -0
- package/dist/godel-limits.js +251 -0
- package/dist/godel-limits.js.map +1 -0
- package/dist/ide/acp-server.js +1 -1
- package/dist/simulation.d.ts +50 -0
- package/dist/simulation.d.ts.map +1 -0
- package/dist/simulation.js +240 -0
- package/dist/simulation.js.map +1 -0
- package/package.json +19 -13
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Computational decidability detection — inspired by Gödel's incompleteness
|
|
2
|
+
// theorem and the UBC Okanagan research proving some problems can't be solved
|
|
3
|
+
// algorithmically. Detects when the agent is stuck and should hand off.
|
|
4
|
+
export var LoopPattern;
|
|
5
|
+
(function (LoopPattern) {
|
|
6
|
+
LoopPattern["tool_repetition"] = "tool_repetition";
|
|
7
|
+
LoopPattern["output_oscillation"] = "output_oscillation";
|
|
8
|
+
LoopPattern["cost_spiral"] = "cost_spiral";
|
|
9
|
+
LoopPattern["context_exhaustion"] = "context_exhaustion";
|
|
10
|
+
LoopPattern["semantic_stagnation"] = "semantic_stagnation";
|
|
11
|
+
LoopPattern["circular_reasoning"] = "circular_reasoning";
|
|
12
|
+
})(LoopPattern || (LoopPattern = {}));
|
|
13
|
+
const RECOMMENDATIONS = {
|
|
14
|
+
[LoopPattern.tool_repetition]: 'simplify',
|
|
15
|
+
[LoopPattern.output_oscillation]: 'handoff',
|
|
16
|
+
[LoopPattern.cost_spiral]: 'handoff',
|
|
17
|
+
[LoopPattern.context_exhaustion]: 'decompose',
|
|
18
|
+
[LoopPattern.semantic_stagnation]: 'simplify',
|
|
19
|
+
[LoopPattern.circular_reasoning]: 'handoff',
|
|
20
|
+
};
|
|
21
|
+
const EVIDENCE_MESSAGES = {
|
|
22
|
+
[LoopPattern.tool_repetition]: 'Same tool called repeatedly with similar arguments — try a different approach.',
|
|
23
|
+
[LoopPattern.output_oscillation]: 'Output alternating between two states — going back and forth without progress.',
|
|
24
|
+
[LoopPattern.cost_spiral]: 'Cost is accelerating without convergence — getting expensive without results.',
|
|
25
|
+
[LoopPattern.context_exhaustion]: 'Context window nearly full — too much information for one pass.',
|
|
26
|
+
[LoopPattern.semantic_stagnation]: 'Last several outputs are nearly identical — not making progress.',
|
|
27
|
+
[LoopPattern.circular_reasoning]: 'Tool results being fed back as inputs — reasoning in circles.',
|
|
28
|
+
};
|
|
29
|
+
export function jaccardSimilarity(a, b) {
|
|
30
|
+
const setA = new Set(a.toLowerCase().split(/\s+/).filter(w => w.length > 2));
|
|
31
|
+
const setB = new Set(b.toLowerCase().split(/\s+/).filter(w => w.length > 2));
|
|
32
|
+
if (setA.size === 0 && setB.size === 0)
|
|
33
|
+
return 1;
|
|
34
|
+
if (setA.size === 0 || setB.size === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
let intersection = 0;
|
|
37
|
+
for (const w of setA) {
|
|
38
|
+
if (setB.has(w))
|
|
39
|
+
intersection++;
|
|
40
|
+
}
|
|
41
|
+
const union = new Set([...setA, ...setB]).size;
|
|
42
|
+
return union === 0 ? 0 : intersection / union;
|
|
43
|
+
}
|
|
44
|
+
export function detectOscillation(outputs) {
|
|
45
|
+
if (outputs.length < 4)
|
|
46
|
+
return false;
|
|
47
|
+
const recent = outputs.slice(-6);
|
|
48
|
+
if (recent.length < 4)
|
|
49
|
+
return false;
|
|
50
|
+
// Check A-B-A-B pattern: compare [0] with [2] and [1] with [3]
|
|
51
|
+
for (let i = 0; i <= recent.length - 4; i++) {
|
|
52
|
+
const simAC = jaccardSimilarity(recent[i], recent[i + 2]);
|
|
53
|
+
const simBD = jaccardSimilarity(recent[i + 1], recent[i + 3]);
|
|
54
|
+
const simAB = jaccardSimilarity(recent[i], recent[i + 1]);
|
|
55
|
+
// A≈C and B≈D but A≠B → oscillation
|
|
56
|
+
if (simAC > 0.8 && simBD > 0.8 && simAB < 0.5)
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
export class LoopDetector {
|
|
62
|
+
toolHistory = [];
|
|
63
|
+
outputs = [];
|
|
64
|
+
totalCost = 0;
|
|
65
|
+
costHistory = [];
|
|
66
|
+
totalTokens = 0;
|
|
67
|
+
opts;
|
|
68
|
+
constructor(options) {
|
|
69
|
+
this.opts = {
|
|
70
|
+
maxToolRepeats: options?.maxToolRepeats ?? 5,
|
|
71
|
+
maxCostUsd: options?.maxCostUsd ?? 1.0,
|
|
72
|
+
maxTokens: options?.maxTokens ?? 50000,
|
|
73
|
+
similarityThreshold: options?.similarityThreshold ?? 0.85,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
recordToolCall(toolName, args, result) {
|
|
77
|
+
this.toolHistory.push({ name: toolName, args, result, timestamp: Date.now() });
|
|
78
|
+
}
|
|
79
|
+
recordOutput(output) {
|
|
80
|
+
this.outputs.push(output);
|
|
81
|
+
}
|
|
82
|
+
recordCost(costUsd) {
|
|
83
|
+
this.totalCost += costUsd;
|
|
84
|
+
this.costHistory.push(this.totalCost);
|
|
85
|
+
}
|
|
86
|
+
recordTokens(tokens) {
|
|
87
|
+
this.totalTokens += tokens;
|
|
88
|
+
}
|
|
89
|
+
check() {
|
|
90
|
+
const base = {
|
|
91
|
+
tokensBurned: this.totalTokens,
|
|
92
|
+
costBurned: this.totalCost,
|
|
93
|
+
};
|
|
94
|
+
// 1. Tool repetition
|
|
95
|
+
const repetition = this.checkToolRepetition();
|
|
96
|
+
if (repetition)
|
|
97
|
+
return { ...base, ...repetition };
|
|
98
|
+
// 2. Output oscillation
|
|
99
|
+
if (detectOscillation(this.outputs)) {
|
|
100
|
+
return {
|
|
101
|
+
...base,
|
|
102
|
+
decidable: false,
|
|
103
|
+
confidence: 0.85,
|
|
104
|
+
pattern: LoopPattern.output_oscillation,
|
|
105
|
+
evidence: EVIDENCE_MESSAGES[LoopPattern.output_oscillation],
|
|
106
|
+
recommendation: RECOMMENDATIONS[LoopPattern.output_oscillation],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// 3. Cost spiral
|
|
110
|
+
if (this.checkCostSpiral()) {
|
|
111
|
+
return {
|
|
112
|
+
...base,
|
|
113
|
+
decidable: false,
|
|
114
|
+
confidence: 0.9,
|
|
115
|
+
pattern: LoopPattern.cost_spiral,
|
|
116
|
+
evidence: `${EVIDENCE_MESSAGES[LoopPattern.cost_spiral]} ($${this.totalCost.toFixed(2)} spent)`,
|
|
117
|
+
recommendation: RECOMMENDATIONS[LoopPattern.cost_spiral],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// 4. Context exhaustion
|
|
121
|
+
if (this.totalTokens > this.opts.maxTokens) {
|
|
122
|
+
return {
|
|
123
|
+
...base,
|
|
124
|
+
decidable: false,
|
|
125
|
+
confidence: 0.95,
|
|
126
|
+
pattern: LoopPattern.context_exhaustion,
|
|
127
|
+
evidence: `${EVIDENCE_MESSAGES[LoopPattern.context_exhaustion]} (${this.totalTokens} tokens used)`,
|
|
128
|
+
recommendation: RECOMMENDATIONS[LoopPattern.context_exhaustion],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// 5. Semantic stagnation
|
|
132
|
+
if (this.checkSemanticStagnation()) {
|
|
133
|
+
return {
|
|
134
|
+
...base,
|
|
135
|
+
decidable: false,
|
|
136
|
+
confidence: 0.8,
|
|
137
|
+
pattern: LoopPattern.semantic_stagnation,
|
|
138
|
+
evidence: EVIDENCE_MESSAGES[LoopPattern.semantic_stagnation],
|
|
139
|
+
recommendation: RECOMMENDATIONS[LoopPattern.semantic_stagnation],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// 6. Circular reasoning
|
|
143
|
+
if (this.checkCircularReasoning()) {
|
|
144
|
+
return {
|
|
145
|
+
...base,
|
|
146
|
+
decidable: false,
|
|
147
|
+
confidence: 0.75,
|
|
148
|
+
pattern: LoopPattern.circular_reasoning,
|
|
149
|
+
evidence: EVIDENCE_MESSAGES[LoopPattern.circular_reasoning],
|
|
150
|
+
recommendation: RECOMMENDATIONS[LoopPattern.circular_reasoning],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// All clear
|
|
154
|
+
return {
|
|
155
|
+
...base,
|
|
156
|
+
decidable: true,
|
|
157
|
+
confidence: 1.0,
|
|
158
|
+
evidence: 'No loop patterns detected.',
|
|
159
|
+
recommendation: 'continue',
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
reset() {
|
|
163
|
+
this.toolHistory = [];
|
|
164
|
+
this.outputs = [];
|
|
165
|
+
this.totalCost = 0;
|
|
166
|
+
this.costHistory = [];
|
|
167
|
+
this.totalTokens = 0;
|
|
168
|
+
}
|
|
169
|
+
checkToolRepetition() {
|
|
170
|
+
if (this.toolHistory.length < this.opts.maxToolRepeats)
|
|
171
|
+
return null;
|
|
172
|
+
// Group recent calls by tool name
|
|
173
|
+
const recent = this.toolHistory.slice(-10);
|
|
174
|
+
const groups = new Map();
|
|
175
|
+
for (const record of recent) {
|
|
176
|
+
if (!groups.has(record.name))
|
|
177
|
+
groups.set(record.name, []);
|
|
178
|
+
groups.get(record.name).push(record);
|
|
179
|
+
}
|
|
180
|
+
for (const [name, calls] of groups) {
|
|
181
|
+
if (calls.length < this.opts.maxToolRepeats)
|
|
182
|
+
continue;
|
|
183
|
+
// Check if args are similar
|
|
184
|
+
let similarCount = 0;
|
|
185
|
+
for (let i = 1; i < calls.length; i++) {
|
|
186
|
+
if (jaccardSimilarity(calls[i].args, calls[0].args) > this.opts.similarityThreshold) {
|
|
187
|
+
similarCount++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (similarCount >= this.opts.maxToolRepeats - 1) {
|
|
191
|
+
return {
|
|
192
|
+
decidable: false,
|
|
193
|
+
confidence: 0.9,
|
|
194
|
+
pattern: LoopPattern.tool_repetition,
|
|
195
|
+
evidence: `${EVIDENCE_MESSAGES[LoopPattern.tool_repetition]} (${name} called ${calls.length}x)`,
|
|
196
|
+
recommendation: RECOMMENDATIONS[LoopPattern.tool_repetition],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
checkCostSpiral() {
|
|
203
|
+
if (this.totalCost < this.opts.maxCostUsd)
|
|
204
|
+
return false;
|
|
205
|
+
if (this.costHistory.length < 4)
|
|
206
|
+
return true; // Over budget with few steps = spiral
|
|
207
|
+
// Check if cost rate is accelerating
|
|
208
|
+
const recent = this.costHistory.slice(-4);
|
|
209
|
+
const deltas = [];
|
|
210
|
+
for (let i = 1; i < recent.length; i++) {
|
|
211
|
+
deltas.push(recent[i] - recent[i - 1]);
|
|
212
|
+
}
|
|
213
|
+
// Accelerating if each delta is larger than the previous
|
|
214
|
+
return deltas.length >= 2 && deltas[deltas.length - 1] > deltas[0];
|
|
215
|
+
}
|
|
216
|
+
checkSemanticStagnation() {
|
|
217
|
+
if (this.outputs.length < 3)
|
|
218
|
+
return false;
|
|
219
|
+
const recent = this.outputs.slice(-3);
|
|
220
|
+
for (let i = 1; i < recent.length; i++) {
|
|
221
|
+
if (jaccardSimilarity(recent[i], recent[0]) < 0.9)
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
checkCircularReasoning() {
|
|
227
|
+
if (this.toolHistory.length < 3)
|
|
228
|
+
return false;
|
|
229
|
+
const recent = this.toolHistory.slice(-5);
|
|
230
|
+
for (let i = 1; i < recent.length; i++) {
|
|
231
|
+
const prevResult = recent[i - 1].result;
|
|
232
|
+
const currArgs = recent[i].args;
|
|
233
|
+
// If >40% of words in current args appeared in previous result
|
|
234
|
+
if (prevResult.length > 20 && currArgs.length > 20) {
|
|
235
|
+
const resultWords = new Set(prevResult.toLowerCase().split(/\s+/).filter(w => w.length > 3));
|
|
236
|
+
const argWords = currArgs.toLowerCase().split(/\s+/).filter(w => w.length > 3);
|
|
237
|
+
if (argWords.length === 0)
|
|
238
|
+
continue;
|
|
239
|
+
let overlap = 0;
|
|
240
|
+
for (const w of argWords) {
|
|
241
|
+
if (resultWords.has(w))
|
|
242
|
+
overlap++;
|
|
243
|
+
}
|
|
244
|
+
if (overlap / argWords.length > 0.4)
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=godel-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"godel-limits.js","sourceRoot":"","sources":["../src/godel-limits.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,wEAAwE;AAExE,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,kDAAmC,CAAA;IACnC,wDAAyC,CAAA;IACzC,0CAA2B,CAAA;IAC3B,wDAAyC,CAAA;IACzC,0DAA2C,CAAA;IAC3C,wDAAyC,CAAA;AAC3C,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB;AA0BD,MAAM,eAAe,GAA2E;IAC9F,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,UAAU;IACzC,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,SAAS;IAC3C,CAAC,WAAW,CAAC,WA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7 @@ import { initBridge, chat, executeCommand, getStatus, getAgents, getContext, get
|
|
|
11
11
|
import { formatDiagnostics } from './lsp-bridge.js';
|
|
12
12
|
const AGENT_IDENTITY = {
|
|
13
13
|
name: 'K:BOT',
|
|
14
|
-
version: '2.13.
|
|
14
|
+
version: '2.13.1',
|
|
15
15
|
description: 'Open-source terminal AI agent — 39 specialists, 167 tools, 19 providers, local-first',
|
|
16
16
|
capabilities: ['chat', 'codeAction', 'diagnostics', 'tools'],
|
|
17
17
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface SimulationScenario {
|
|
2
|
+
description: string;
|
|
3
|
+
targetFiles: string[];
|
|
4
|
+
changeType: 'refactor' | 'add_feature' | 'delete' | 'migrate' | 'upgrade';
|
|
5
|
+
constraints?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface BreakingChange {
|
|
8
|
+
file: string;
|
|
9
|
+
line?: number;
|
|
10
|
+
description: string;
|
|
11
|
+
severity: 'warning' | 'error';
|
|
12
|
+
suggestedFix?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SimulationResult {
|
|
15
|
+
scenario: SimulationScenario;
|
|
16
|
+
predictedOutcome: string;
|
|
17
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
18
|
+
breakingChanges: BreakingChange[];
|
|
19
|
+
estimatedEffort: string;
|
|
20
|
+
confidence: number;
|
|
21
|
+
recommendations: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ComparisonResult {
|
|
24
|
+
scenarios: SimulationResult[];
|
|
25
|
+
recommended: number;
|
|
26
|
+
reasoning: string;
|
|
27
|
+
}
|
|
28
|
+
export interface FileNode {
|
|
29
|
+
path: string;
|
|
30
|
+
exports: string[];
|
|
31
|
+
imports: string[];
|
|
32
|
+
size: number;
|
|
33
|
+
}
|
|
34
|
+
export interface DependencyGraph {
|
|
35
|
+
nodes: Map<string, FileNode>;
|
|
36
|
+
edges: Map<string, string[]>;
|
|
37
|
+
}
|
|
38
|
+
export declare function buildDependencyGraph(rootDir: string): Promise<DependencyGraph>;
|
|
39
|
+
export declare function findImpactedFiles(graph: DependencyGraph, changedFiles: string[]): string[];
|
|
40
|
+
export declare function simulateChange(scenario: SimulationScenario, graph?: DependencyGraph): Promise<SimulationResult>;
|
|
41
|
+
export declare class Simulator {
|
|
42
|
+
private rootDir;
|
|
43
|
+
private graph;
|
|
44
|
+
constructor(rootDir?: string);
|
|
45
|
+
init(): Promise<void>;
|
|
46
|
+
simulate(scenario: SimulationScenario): Promise<SimulationResult>;
|
|
47
|
+
compareScenarios(scenarios: SimulationScenario[]): Promise<ComparisonResult>;
|
|
48
|
+
getGraph(): DependencyGraph | null;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=simulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IACzE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAA;IACjD,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB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ulation Agent — "what if" engine inspired by David Wolpert's
|
|
2
|
+
// mathematical framework for universe simulation. Models codebases
|
|
3
|
+
// and predicts outcomes of changes before executing them.
|
|
4
|
+
import { runAgent } from './agent.js';
|
|
5
|
+
import * as fs from 'node:fs';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
const IMPORT_RE = /(?:import\s+.*?from\s+['"](.+?)['"]|require\s*\(\s*['"](.+?)['"]\s*\))/g;
|
|
8
|
+
const EXPORT_RE = /export\s+(?:default\s+)?(?:function|class|const|let|var|interface|type|enum)\s+(\w+)/g;
|
|
9
|
+
const SIMULATE_PROMPT = `You are a codebase simulation engine. Predict the outcome of a proposed change.
|
|
10
|
+
|
|
11
|
+
SCENARIO: {description}
|
|
12
|
+
CHANGE TYPE: {changeType}
|
|
13
|
+
TARGET FILES: {targetFiles}
|
|
14
|
+
{constraints}
|
|
15
|
+
|
|
16
|
+
DEPENDENCY GRAPH (files impacted):
|
|
17
|
+
{impactedFiles}
|
|
18
|
+
|
|
19
|
+
FILE CONTENTS:
|
|
20
|
+
{fileContents}
|
|
21
|
+
|
|
22
|
+
Analyze this change and predict:
|
|
23
|
+
1. What will break?
|
|
24
|
+
2. What tests will fail?
|
|
25
|
+
3. What runtime behavior will change?
|
|
26
|
+
4. What edge cases could cause bugs?
|
|
27
|
+
|
|
28
|
+
Respond in JSON:
|
|
29
|
+
{
|
|
30
|
+
"predictedOutcome": "summary of what happens",
|
|
31
|
+
"riskLevel": "low|medium|high|critical",
|
|
32
|
+
"breakingChanges": [
|
|
33
|
+
{"file": "path", "line": null, "description": "what breaks", "severity": "warning|error", "suggestedFix": "how to fix"}
|
|
34
|
+
],
|
|
35
|
+
"estimatedEffort": "e.g. 1-2 hours",
|
|
36
|
+
"confidence": 0.0-1.0,
|
|
37
|
+
"recommendations": ["list", "of", "recommendations"]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Respond ONLY with the JSON object.`;
|
|
41
|
+
export async function buildDependencyGraph(rootDir) {
|
|
42
|
+
const nodes = new Map();
|
|
43
|
+
const edges = new Map(); // reverse deps: file -> files that import it
|
|
44
|
+
const files = walkDir(rootDir, ['.ts', '.tsx', '.js', '.jsx']);
|
|
45
|
+
for (const filePath of files) {
|
|
46
|
+
try {
|
|
47
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
48
|
+
const relPath = path.relative(rootDir, filePath);
|
|
49
|
+
// Extract exports
|
|
50
|
+
const exports = [];
|
|
51
|
+
let match;
|
|
52
|
+
const exportRe = new RegExp(EXPORT_RE.source, 'g');
|
|
53
|
+
while ((match = exportRe.exec(content)) !== null) {
|
|
54
|
+
if (match[1])
|
|
55
|
+
exports.push(match[1]);
|
|
56
|
+
}
|
|
57
|
+
// Extract imports
|
|
58
|
+
const imports = [];
|
|
59
|
+
const importRe = new RegExp(IMPORT_RE.source, 'g');
|
|
60
|
+
while ((match = importRe.exec(content)) !== null) {
|
|
61
|
+
const importPath = match[1] || match[2];
|
|
62
|
+
if (importPath && !importPath.startsWith('node_modules') && (importPath.startsWith('.') || importPath.startsWith('/'))) {
|
|
63
|
+
const resolved = resolveImport(filePath, importPath, rootDir);
|
|
64
|
+
if (resolved)
|
|
65
|
+
imports.push(resolved);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
nodes.set(relPath, {
|
|
69
|
+
path: relPath,
|
|
70
|
+
exports,
|
|
71
|
+
imports,
|
|
72
|
+
size: content.length,
|
|
73
|
+
});
|
|
74
|
+
// Build reverse edges
|
|
75
|
+
for (const imp of imports) {
|
|
76
|
+
if (!edges.has(imp))
|
|
77
|
+
edges.set(imp, []);
|
|
78
|
+
edges.get(imp).push(relPath);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch { /* skip unreadable files */ }
|
|
82
|
+
}
|
|
83
|
+
return { nodes, edges };
|
|
84
|
+
}
|
|
85
|
+
export function findImpactedFiles(graph, changedFiles) {
|
|
86
|
+
const impacted = new Set();
|
|
87
|
+
const queue = [...changedFiles];
|
|
88
|
+
while (queue.length > 0) {
|
|
89
|
+
const file = queue.pop();
|
|
90
|
+
if (impacted.has(file))
|
|
91
|
+
continue;
|
|
92
|
+
impacted.add(file);
|
|
93
|
+
// Find files that depend on this one
|
|
94
|
+
const dependents = graph.edges.get(file) || [];
|
|
95
|
+
for (const dep of dependents) {
|
|
96
|
+
if (!impacted.has(dep))
|
|
97
|
+
queue.push(dep);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [...impacted];
|
|
101
|
+
}
|
|
102
|
+
export async function simulateChange(scenario, graph) {
|
|
103
|
+
const rootDir = process.cwd();
|
|
104
|
+
const depGraph = graph || await buildDependencyGraph(rootDir);
|
|
105
|
+
const impacted = findImpactedFiles(depGraph, scenario.targetFiles);
|
|
106
|
+
const impactedSummary = impacted.slice(0, 20).join('\n');
|
|
107
|
+
// Read target + impacted files (limited to prevent token overflow)
|
|
108
|
+
const fileContents = [];
|
|
109
|
+
const filesToRead = [...new Set([...scenario.targetFiles, ...impacted.slice(0, 10)])];
|
|
110
|
+
for (const f of filesToRead) {
|
|
111
|
+
const fullPath = path.resolve(rootDir, f);
|
|
112
|
+
try {
|
|
113
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
114
|
+
fileContents.push(`### ${f}\n\`\`\`\n${content.slice(0, 2000)}\n\`\`\``);
|
|
115
|
+
}
|
|
116
|
+
catch { /* skip missing files */ }
|
|
117
|
+
}
|
|
118
|
+
const constraintText = scenario.constraints?.length
|
|
119
|
+
? `CONSTRAINTS:\n${scenario.constraints.map(c => `- ${c}`).join('\n')}`
|
|
120
|
+
: '';
|
|
121
|
+
const prompt = SIMULATE_PROMPT
|
|
122
|
+
.replace('{description}', scenario.description)
|
|
123
|
+
.replace('{changeType}', scenario.changeType)
|
|
124
|
+
.replace('{targetFiles}', scenario.targetFiles.join(', '))
|
|
125
|
+
.replace('{constraints}', constraintText)
|
|
126
|
+
.replace('{impactedFiles}', impactedSummary)
|
|
127
|
+
.replace('{fileContents}', fileContents.join('\n\n'));
|
|
128
|
+
try {
|
|
129
|
+
const result = await runAgent(prompt, {
|
|
130
|
+
agent: 'coder',
|
|
131
|
+
stream: false,
|
|
132
|
+
skipPlanner: true,
|
|
133
|
+
});
|
|
134
|
+
const match = result.content.match(/\{[\s\S]*\}/);
|
|
135
|
+
if (match) {
|
|
136
|
+
const parsed = JSON.parse(match[0]);
|
|
137
|
+
return {
|
|
138
|
+
scenario,
|
|
139
|
+
predictedOutcome: parsed.predictedOutcome || 'Unable to predict',
|
|
140
|
+
riskLevel: parsed.riskLevel || 'medium',
|
|
141
|
+
breakingChanges: parsed.breakingChanges || [],
|
|
142
|
+
estimatedEffort: parsed.estimatedEffort || 'unknown',
|
|
143
|
+
confidence: Math.max(0, Math.min(1, parsed.confidence || 0.5)),
|
|
144
|
+
recommendations: parsed.recommendations || [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch { /* fall through */ }
|
|
149
|
+
return {
|
|
150
|
+
scenario,
|
|
151
|
+
predictedOutcome: 'Simulation could not complete',
|
|
152
|
+
riskLevel: 'high',
|
|
153
|
+
breakingChanges: [],
|
|
154
|
+
estimatedEffort: 'unknown',
|
|
155
|
+
confidence: 0,
|
|
156
|
+
recommendations: ['Manual review recommended'],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export class Simulator {
|
|
160
|
+
rootDir;
|
|
161
|
+
graph = null;
|
|
162
|
+
constructor(rootDir) {
|
|
163
|
+
this.rootDir = rootDir || process.cwd();
|
|
164
|
+
}
|
|
165
|
+
async init() {
|
|
166
|
+
this.graph = await buildDependencyGraph(this.rootDir);
|
|
167
|
+
}
|
|
168
|
+
async simulate(scenario) {
|
|
169
|
+
if (!this.graph)
|
|
170
|
+
await this.init();
|
|
171
|
+
return simulateChange(scenario, this.graph);
|
|
172
|
+
}
|
|
173
|
+
async compareScenarios(scenarios) {
|
|
174
|
+
if (!this.graph)
|
|
175
|
+
await this.init();
|
|
176
|
+
const results = [];
|
|
177
|
+
for (const scenario of scenarios) {
|
|
178
|
+
results.push(await simulateChange(scenario, this.graph));
|
|
179
|
+
}
|
|
180
|
+
// Rank by lowest risk + highest confidence
|
|
181
|
+
const riskOrder = { low: 0, medium: 1, high: 2, critical: 3 };
|
|
182
|
+
let bestIdx = 0;
|
|
183
|
+
let bestScore = Infinity;
|
|
184
|
+
for (let i = 0; i < results.length; i++) {
|
|
185
|
+
const score = riskOrder[results[i].riskLevel] * 10
|
|
186
|
+
+ results[i].breakingChanges.length
|
|
187
|
+
- results[i].confidence * 5;
|
|
188
|
+
if (score < bestScore) {
|
|
189
|
+
bestScore = score;
|
|
190
|
+
bestIdx = i;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
scenarios: results,
|
|
195
|
+
recommended: bestIdx,
|
|
196
|
+
reasoning: `Scenario ${bestIdx + 1} has the lowest risk (${results[bestIdx].riskLevel}) with ${results[bestIdx].breakingChanges.length} breaking changes and ${(results[bestIdx].confidence * 100).toFixed(0)}% confidence.`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
getGraph() {
|
|
200
|
+
return this.graph;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
204
|
+
function walkDir(dir, extensions) {
|
|
205
|
+
const results = [];
|
|
206
|
+
const SKIP = new Set(['node_modules', '.git', 'dist', 'build', '.next', 'coverage']);
|
|
207
|
+
try {
|
|
208
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
209
|
+
for (const entry of entries) {
|
|
210
|
+
if (SKIP.has(entry.name))
|
|
211
|
+
continue;
|
|
212
|
+
const full = path.join(dir, entry.name);
|
|
213
|
+
if (entry.isDirectory()) {
|
|
214
|
+
results.push(...walkDir(full, extensions));
|
|
215
|
+
}
|
|
216
|
+
else if (extensions.some(ext => entry.name.endsWith(ext))) {
|
|
217
|
+
results.push(full);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch { /* skip unreadable dirs */ }
|
|
222
|
+
return results;
|
|
223
|
+
}
|
|
224
|
+
function resolveImport(from, importPath, rootDir) {
|
|
225
|
+
const dir = path.dirname(from);
|
|
226
|
+
const extensions = ['.ts', '.tsx', '.js', '.jsx', '/index.ts', '/index.js'];
|
|
227
|
+
for (const ext of extensions) {
|
|
228
|
+
const candidate = path.resolve(dir, importPath + ext);
|
|
229
|
+
if (fs.existsSync(candidate)) {
|
|
230
|
+
return path.relative(rootDir, candidate);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Try exact path
|
|
234
|
+
const exact = path.resolve(dir, importPath);
|
|
235
|
+
if (fs.existsSync(exact)) {
|
|
236
|
+
return path.relative(rootDir, exact);
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=simulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulation.js","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,mEAAmE;AACnE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AA6CjC,MAAM,SAAS,GAAG,yEAAyE,CAAA;AAC3F,MAAM,SAAS,GAAG,uFAAuF,CAAA;AAEzG,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA+BW,CAAA;AAEnC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAe;IACxD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAA;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAA,CAAC,6CAA6C;IAEvF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,M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AO,EAAE,SAAS,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAC3C,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kernel.chat/kbot",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.14.0",
|
|
4
|
+
"description": "Local-first AI agent for your terminal. 39 specialists, 172 tools, 19 providers. Self-evolving, learns your patterns, runs offline with Ollama. Open-source Claude Code alternative.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,20 +24,26 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
|
-
"ai",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
27
|
+
"ai-agent",
|
|
28
|
+
"local-ai",
|
|
29
|
+
"terminal-ai",
|
|
30
|
+
"cli-ai",
|
|
31
|
+
"code-generation",
|
|
32
|
+
"ai-coding-assistant",
|
|
33
|
+
"local-first",
|
|
32
34
|
"llm",
|
|
33
|
-
"
|
|
35
|
+
"automation",
|
|
36
|
+
"developer-tools",
|
|
34
37
|
"ollama",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
38
|
+
"claude",
|
|
39
|
+
"gpt",
|
|
40
|
+
"ai-terminal",
|
|
41
|
+
"code-review",
|
|
42
|
+
"self-evolving",
|
|
39
43
|
"multi-model",
|
|
40
|
-
"
|
|
44
|
+
"mcp",
|
|
45
|
+
"shell-assistant",
|
|
46
|
+
"open-source-ai"
|
|
41
47
|
],
|
|
42
48
|
"author": "kernel.chat group",
|
|
43
49
|
"license": "MIT",
|