zelari-code 0.7.5 → 0.7.8
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/bin/zelari-code.js +1 -1
- package/dist/agents/councilApi.js +7 -7
- package/dist/agents/councilApi.js.map +1 -1
- package/dist/agents/councilDirectives.js +3 -3
- package/dist/agents/promoteMember.js +2 -2
- package/dist/agents/roles.js +32 -50
- package/dist/agents/roles.js.map +1 -1
- package/dist/agents/skills/builtin/debugging.js +4 -4
- package/dist/agents/skills/builtin/debugging.js.map +1 -1
- package/dist/agents/skills/builtin/docs.js +13 -23
- package/dist/agents/skills/builtin/docs.js.map +1 -1
- package/dist/agents/skills/builtin/git-ops.js +3 -3
- package/dist/agents/skills/builtin/git-ops.js.map +1 -1
- package/dist/agents/skills/builtin/planning.js +4 -4
- package/dist/agents/skills/builtin/planning.js.map +1 -1
- package/dist/agents/skills/builtin/refactoring.js +3 -3
- package/dist/agents/skills/builtin/refactoring.js.map +1 -1
- package/dist/agents/skills/builtin/review.js +9 -9
- package/dist/agents/skills/builtin/review.js.map +1 -1
- package/dist/agents/skills/builtin/testing.js +3 -3
- package/dist/agents/skills/builtin/testing.js.map +1 -1
- package/dist/agents/tools.js +9 -2
- package/dist/agents/tools.js.map +1 -1
- package/dist/cli/app.js +2 -1
- package/dist/cli/app.js.map +1 -1
- package/dist/cli/components/CollapsibleToolOutput.js +26 -8
- package/dist/cli/components/CollapsibleToolOutput.js.map +1 -1
- package/dist/cli/components/Header.js +18 -6
- package/dist/cli/components/Header.js.map +1 -1
- package/dist/cli/components/Sidebar.js +31 -33
- package/dist/cli/components/Sidebar.js.map +1 -1
- package/dist/cli/components/SplashScreen.js +158 -0
- package/dist/cli/components/SplashScreen.js.map +1 -0
- package/dist/cli/councilDispatcher.js +20 -0
- package/dist/cli/councilDispatcher.js.map +1 -1
- package/dist/cli/main.bundled.js +983 -171
- package/dist/cli/main.bundled.js.map +4 -4
- package/dist/cli/main.js +9 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/mcp/mcpClient.js +1 -1
- package/dist/cli/oauthCallbackServer.js +207 -0
- package/dist/cli/oauthCallbackServer.js.map +1 -0
- package/dist/cli/wizard/index.js +1 -1
- package/dist/cli/wizard/index.js.map +1 -1
- package/dist/cli/workspace/completeDesign.js +128 -0
- package/dist/cli/workspace/completeDesign.js.map +1 -0
- package/dist/cli/workspace/postCouncilHook.js +146 -20
- package/dist/cli/workspace/postCouncilHook.js.map +1 -1
- package/dist/cli/workspace/stubs.js +231 -95
- package/dist/cli/workspace/stubs.js.map +1 -1
- package/dist/main/core/AgentHarness.js +7 -36
- package/dist/main/core/AgentHarness.js.map +1 -1
- package/dist/main/core/tools/builtin/_walk.js +129 -0
- package/dist/main/core/tools/builtin/_walk.js.map +1 -0
- package/dist/main/core/tools/builtin/diff.js +477 -0
- package/dist/main/core/tools/builtin/diff.js.map +1 -0
- package/dist/main/core/tools/builtin/listFiles.js +5 -43
- package/dist/main/core/tools/builtin/listFiles.js.map +1 -1
- package/dist/main/core/tools/builtin/search.js +120 -28
- package/dist/main/core/tools/builtin/search.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentHarness.js","sourceRoot":"","sources":["../../../src/main/core/AgentHarness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,gBAAgB,GAUjB,MAAM,wBAAwB,CAAC;AAoGhC,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAAqB;IAC3B,QAAQ,CAAuB;IAC/B,SAAS,CAAS;IAClB,mBAAmB,CAAS;IACrC,SAAS,GAAG,KAAK,CAAC;IAClB,gBAAgB,GAA2B,IAAI,CAAC;IAChD,KAAK,GAAa,EAAE,CAAC;IAE7B,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC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AG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE;gBACzD,QAAQ,EAAE,aAAa;gBACvB,OAAO,EAAE,YAAY;aACtB,CAAC,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpB,MAAM,QAAQ,CAAC;QACjB,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,KAAiB;QAC5B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC;gBACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const REGEX_ESCAPE = /[.+^${}()|[\]\\]/g;
|
|
4
|
+
function escapeRegex(p) {
|
|
5
|
+
return p.replace(REGEX_ESCAPE, '\\$&');
|
|
6
|
+
}
|
|
7
|
+
function globToRegex(glob) {
|
|
8
|
+
// Convert glob pattern to anchored RegExp.
|
|
9
|
+
// Semantics:
|
|
10
|
+
// - `*` → any chars except `/` (one segment)
|
|
11
|
+
// - `**` → any chars including `/` (zero or more segments)
|
|
12
|
+
// - `**/` → zero or more dirs (must be followed by something or end)
|
|
13
|
+
// - `?` → any single char except `/`
|
|
14
|
+
// - `[abc]` → char class
|
|
15
|
+
// - everything else is literal (regex special chars auto-escaped)
|
|
16
|
+
let re = '';
|
|
17
|
+
for (let i = 0; i < glob.length; i++) {
|
|
18
|
+
const c = glob[i];
|
|
19
|
+
if (c === '*') {
|
|
20
|
+
if (glob[i + 1] === '*') {
|
|
21
|
+
if (glob[i + 2] === '/') {
|
|
22
|
+
// **/ → zero or more dirs. Skip both stars AND the slash.
|
|
23
|
+
re += '(?:.*/)?';
|
|
24
|
+
i += 2; // skip second * AND trailing /
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// ** at end (or **<not-slash>) → match anything
|
|
28
|
+
re += '.*';
|
|
29
|
+
i++; // skip second *
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// single * → match within one segment
|
|
34
|
+
re += '[^/]*';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (c === '?') {
|
|
38
|
+
re += '[^/]';
|
|
39
|
+
}
|
|
40
|
+
else if (c === '[') {
|
|
41
|
+
const end = glob.indexOf(']', i);
|
|
42
|
+
if (end === -1) {
|
|
43
|
+
re += escapeRegex(c);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
re += glob.slice(i, end + 1);
|
|
47
|
+
i = end;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
re += escapeRegex(c);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new RegExp('^' + re + '$');
|
|
55
|
+
}
|
|
56
|
+
export function matchesAny(name, patterns) {
|
|
57
|
+
for (const p of patterns) {
|
|
58
|
+
const re = globToRegex(p);
|
|
59
|
+
if (re.test(name))
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
export const DEFAULT_EXCLUDES = [
|
|
65
|
+
'node_modules',
|
|
66
|
+
'.git',
|
|
67
|
+
'dist',
|
|
68
|
+
'build',
|
|
69
|
+
'.next',
|
|
70
|
+
'__pycache__',
|
|
71
|
+
'.cache',
|
|
72
|
+
'.zelari', // v3-W workspace storage (never inspect)
|
|
73
|
+
'.venv',
|
|
74
|
+
'coverage',
|
|
75
|
+
'.nyc_output',
|
|
76
|
+
];
|
|
77
|
+
/**
|
|
78
|
+
* Walk a directory tree, collecting file/dir entries.
|
|
79
|
+
* Mutates {@link entries} in place (avoids large array allocations on deep trees).
|
|
80
|
+
*
|
|
81
|
+
* Depth semantics: depth=0 means "do NOT descend into subdirectories" (root
|
|
82
|
+
* entries only). depth=N means "descend at most N levels below root".
|
|
83
|
+
*
|
|
84
|
+
* The root directory itself is NOT added as an entry.
|
|
85
|
+
*/
|
|
86
|
+
export async function walk(dir, baseRel, depth, maxDepth, exclude, entries, signal) {
|
|
87
|
+
if (depth > maxDepth)
|
|
88
|
+
return;
|
|
89
|
+
if (signal?.aborted)
|
|
90
|
+
return;
|
|
91
|
+
let dirents;
|
|
92
|
+
try {
|
|
93
|
+
dirents = await fs.readdir(dir, { withFileTypes: true });
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return; // unreadable subdirectory — skip silently
|
|
97
|
+
}
|
|
98
|
+
if (signal?.aborted)
|
|
99
|
+
return;
|
|
100
|
+
for (const dirent of dirents) {
|
|
101
|
+
if (matchesAny(dirent.name, exclude))
|
|
102
|
+
continue;
|
|
103
|
+
const rel = baseRel ? `${baseRel}/${dirent.name}` : dirent.name;
|
|
104
|
+
const isDir = dirent.isDirectory();
|
|
105
|
+
entries.push({
|
|
106
|
+
name: rel,
|
|
107
|
+
type: isDir ? 'directory' : dirent.isFile() ? 'file' : 'other',
|
|
108
|
+
});
|
|
109
|
+
if (isDir && depth < maxDepth) {
|
|
110
|
+
await walk(path.join(dir, dirent.name), rel, depth + 1, maxDepth, exclude, entries, signal);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Filter a flat list of FileEntry to those whose relative path matches at
|
|
116
|
+
* least one of {@link include} globs (matched against forward-slash paths).
|
|
117
|
+
*/
|
|
118
|
+
export function filterByInclude(entries, include) {
|
|
119
|
+
if (include.length === 0 || (include.length === 1 && include[0] === '*')) {
|
|
120
|
+
return entries.filter(e => e.type === 'file');
|
|
121
|
+
}
|
|
122
|
+
const regexes = include.map(globToRegex);
|
|
123
|
+
return entries.filter(e => {
|
|
124
|
+
if (e.type !== 'file')
|
|
125
|
+
return false;
|
|
126
|
+
return regexes.some(re => re.test(e.name));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=_walk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_walk.js","sourceRoot":"","sources":["../../../../../src/main/core/tools/builtin/_walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AA0B7B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,2CAA2C;IAC3C,aAAa;IACb,sDAAsD;IACtD,mEAAmE;IACnE,4EAA4E;IAC5E,8CAA8C;IAC9C,8BAA8B;IAC9B,oEAAoE;IACpE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACd,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACxB,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBACxB,0DAA0D;oBAC1D,EAAE,IAAI,UAAU,CAAC;oBACjB,CAAC,IAAI,CAAC,CAAC,CAAC,+BAA+B;gBACzC,CAAC;qBAAM,CAAC;oBACN,gDAAgD;oBA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AE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB,EAAE,OAAiB;IACrE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QACzE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QACxB,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC;QACpC,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { typedOk, typedErr } from '../toolTypes.js';
|
|
5
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
// LCS-based diff (simplified Myers)
|
|
7
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
function lcsTable(a, b) {
|
|
9
|
+
const m = a.length;
|
|
10
|
+
const n = b.length;
|
|
11
|
+
const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
12
|
+
for (let i = 1; i <= m; i++) {
|
|
13
|
+
for (let j = 1; j <= n; j++) {
|
|
14
|
+
if (a[i - 1] === b[j - 1]) {
|
|
15
|
+
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return dp;
|
|
23
|
+
}
|
|
24
|
+
function buildHunks(a, b) {
|
|
25
|
+
const dp = lcsTable(a, b);
|
|
26
|
+
const ops = [];
|
|
27
|
+
let i = a.length;
|
|
28
|
+
let j = b.length;
|
|
29
|
+
while (i > 0 && j > 0) {
|
|
30
|
+
if (a[i - 1] === b[j - 1]) {
|
|
31
|
+
ops.push({ kind: ' ', text: a[i - 1] });
|
|
32
|
+
i--;
|
|
33
|
+
j--;
|
|
34
|
+
}
|
|
35
|
+
else if (dp[i - 1][j] >= dp[i][j - 1]) {
|
|
36
|
+
ops.push({ kind: '-', text: a[i - 1] });
|
|
37
|
+
i--;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
ops.push({ kind: '+', text: b[j - 1] });
|
|
41
|
+
j--;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
while (i > 0) {
|
|
45
|
+
ops.push({ kind: '-', text: a[i - 1] });
|
|
46
|
+
i--;
|
|
47
|
+
}
|
|
48
|
+
while (j > 0) {
|
|
49
|
+
ops.push({ kind: '+', text: b[j - 1] });
|
|
50
|
+
j--;
|
|
51
|
+
}
|
|
52
|
+
ops.reverse();
|
|
53
|
+
return groupIntoHunks(ops);
|
|
54
|
+
}
|
|
55
|
+
function groupIntoHunks(ops) {
|
|
56
|
+
const CONTEXT = 3;
|
|
57
|
+
const hunks = [];
|
|
58
|
+
let i = 0;
|
|
59
|
+
while (i < ops.length) {
|
|
60
|
+
// Skip leading context that's not adjacent to a change
|
|
61
|
+
while (i < ops.length && ops[i].kind === ' ')
|
|
62
|
+
i++;
|
|
63
|
+
if (i >= ops.length)
|
|
64
|
+
break;
|
|
65
|
+
// Found a change at index i. Walk back CONTEXT lines for leading context.
|
|
66
|
+
const start = Math.max(0, i - CONTEXT);
|
|
67
|
+
let oldStart = 0, newStart = 0;
|
|
68
|
+
// Compute line numbers
|
|
69
|
+
{
|
|
70
|
+
let ol = 0, nl = 0;
|
|
71
|
+
for (let k = 0; k < start; k++) {
|
|
72
|
+
if (ops[k].kind !== '+')
|
|
73
|
+
ol++;
|
|
74
|
+
if (ops[k].kind !== '-')
|
|
75
|
+
nl++;
|
|
76
|
+
}
|
|
77
|
+
oldStart = ol + 1; // 1-indexed
|
|
78
|
+
newStart = nl + 1;
|
|
79
|
+
}
|
|
80
|
+
const hunkOps = [];
|
|
81
|
+
// Leading context
|
|
82
|
+
for (let k = start; k < i; k++)
|
|
83
|
+
hunkOps.push(ops[k]);
|
|
84
|
+
// Body: consume changes + trailing CONTEXT, but stop if we hit 2*CONTEXT
|
|
85
|
+
// non-change lines (forces a new hunk).
|
|
86
|
+
let nonChangeStreak = 0;
|
|
87
|
+
while (i < ops.length) {
|
|
88
|
+
const op = ops[i];
|
|
89
|
+
hunkOps.push(op);
|
|
90
|
+
if (op.kind === ' ') {
|
|
91
|
+
nonChangeStreak++;
|
|
92
|
+
if (nonChangeStreak > 2 * CONTEXT) {
|
|
93
|
+
// Trim trailing CONTEXT and break
|
|
94
|
+
hunkOps.splice(hunkOps.length - CONTEXT, CONTEXT);
|
|
95
|
+
i++;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
nonChangeStreak = 0;
|
|
101
|
+
}
|
|
102
|
+
i++;
|
|
103
|
+
}
|
|
104
|
+
// Compute hunk line counts
|
|
105
|
+
let oldLines = 0, newLines = 0;
|
|
106
|
+
for (const op of hunkOps) {
|
|
107
|
+
if (op.kind !== '+')
|
|
108
|
+
oldLines++;
|
|
109
|
+
if (op.kind !== '-')
|
|
110
|
+
newLines++;
|
|
111
|
+
}
|
|
112
|
+
hunks.push({ oldStart, oldLines, newStart, newLines, ops: hunkOps });
|
|
113
|
+
}
|
|
114
|
+
return hunks;
|
|
115
|
+
}
|
|
116
|
+
function formatUnified(hunks, oldLabel, newLabel) {
|
|
117
|
+
const lines = [`--- ${oldLabel}`, `+++ ${newLabel}`];
|
|
118
|
+
for (const h of hunks) {
|
|
119
|
+
lines.push(`@@ -${h.oldStart},${h.oldLines} +${h.newStart},${h.newLines} @@`);
|
|
120
|
+
for (const op of h.ops) {
|
|
121
|
+
lines.push(op.kind + op.text);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return lines.join('\n');
|
|
125
|
+
}
|
|
126
|
+
function parseUnified(raw) {
|
|
127
|
+
const lines = raw.split('\n');
|
|
128
|
+
if (lines.length < 2 || !lines[0].startsWith('--- ') || !lines[1].startsWith('+++ ')) {
|
|
129
|
+
throw new Error('Invalid unified diff: missing --- / +++ headers');
|
|
130
|
+
}
|
|
131
|
+
const oldLabel = lines[0].slice(4).trim();
|
|
132
|
+
const newLabel = lines[1].slice(4).trim();
|
|
133
|
+
const hunks = [];
|
|
134
|
+
let i = 2;
|
|
135
|
+
while (i < lines.length) {
|
|
136
|
+
const m = lines[i].match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
137
|
+
if (!m) {
|
|
138
|
+
i++;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const oldStart = parseInt(m[1], 10);
|
|
142
|
+
const oldLines = m[2] === undefined ? 1 : parseInt(m[2], 10);
|
|
143
|
+
const newStart = parseInt(m[3], 10);
|
|
144
|
+
const newLines = m[4] === undefined ? 1 : parseInt(m[4], 10);
|
|
145
|
+
i++;
|
|
146
|
+
const ops = [];
|
|
147
|
+
let consumedOld = 0, consumedNew = 0;
|
|
148
|
+
while (i < lines.length && (consumedOld < oldLines || consumedNew < newLines)) {
|
|
149
|
+
const ln = lines[i];
|
|
150
|
+
if (ln.length === 0) {
|
|
151
|
+
ops.push({ kind: ' ', text: '' });
|
|
152
|
+
consumedOld++;
|
|
153
|
+
consumedNew++;
|
|
154
|
+
i++;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const c = ln[0];
|
|
158
|
+
const text = ln.slice(1);
|
|
159
|
+
if (c === ' ') {
|
|
160
|
+
ops.push({ kind: ' ', text });
|
|
161
|
+
consumedOld++;
|
|
162
|
+
consumedNew++;
|
|
163
|
+
i++;
|
|
164
|
+
}
|
|
165
|
+
else if (c === '-') {
|
|
166
|
+
ops.push({ kind: '-', text });
|
|
167
|
+
consumedOld++;
|
|
168
|
+
i++;
|
|
169
|
+
}
|
|
170
|
+
else if (c === '+') {
|
|
171
|
+
ops.push({ kind: '+', text });
|
|
172
|
+
consumedNew++;
|
|
173
|
+
i++;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Malformed hunk body
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
hunks.push({ oldStart, oldLines, newStart, newLines, ops });
|
|
181
|
+
}
|
|
182
|
+
return { oldLabel, newLabel, hunks };
|
|
183
|
+
}
|
|
184
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
185
|
+
// Patch application (with optional fuzzy whitespace match)
|
|
186
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
187
|
+
function normalizeWhitespace(s) {
|
|
188
|
+
return s.replace(/\s+/g, ' ').trim();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Apply ALL hunks to the original file lines in a single pass.
|
|
192
|
+
*
|
|
193
|
+
* Correct algorithm: each hunk's oldStart refers to the ORIGINAL file, not the
|
|
194
|
+
* post-previous-hunk state. We walk the file once, copying unmodified prefix
|
|
195
|
+
* and rewriting per-hunk regions. Atomic: if ANY hunk fails, no commits happen.
|
|
196
|
+
*/
|
|
197
|
+
function applyAllHunks(originalLines, hunks, fuzzy) {
|
|
198
|
+
const out = [];
|
|
199
|
+
let fileIdx = 0; // pointer into originalLines
|
|
200
|
+
let hunksApplied = 0;
|
|
201
|
+
let hunksSkipped = 0;
|
|
202
|
+
let lastReason;
|
|
203
|
+
for (const hunk of hunks) {
|
|
204
|
+
const startIdx = hunk.oldStart - 1; // 0-indexed
|
|
205
|
+
if (startIdx < 0) {
|
|
206
|
+
hunksSkipped++;
|
|
207
|
+
lastReason = `oldStart ${hunk.oldStart} out of range (must be >= 1)`;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (startIdx > originalLines.length) {
|
|
211
|
+
hunksSkipped++;
|
|
212
|
+
lastReason = `oldStart ${hunk.oldStart} beyond file end (length ${originalLines.length})`;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
// Copy unmodified prefix
|
|
216
|
+
while (fileIdx < startIdx) {
|
|
217
|
+
out.push(originalLines[fileIdx]);
|
|
218
|
+
fileIdx++;
|
|
219
|
+
}
|
|
220
|
+
// Walk hunk ops against original file
|
|
221
|
+
let hunkFileIdx = fileIdx;
|
|
222
|
+
let hunkIdx = 0;
|
|
223
|
+
const hunkOut = [];
|
|
224
|
+
let hunkOk = true;
|
|
225
|
+
while (hunkIdx < hunk.ops.length) {
|
|
226
|
+
const op = hunk.ops[hunkIdx];
|
|
227
|
+
if (op.kind === ' ') {
|
|
228
|
+
const fileLine = originalLines[hunkFileIdx] ?? '';
|
|
229
|
+
if (fileLine === op.text || (fuzzy && normalizeWhitespace(fileLine) === normalizeWhitespace(op.text))) {
|
|
230
|
+
hunkOut.push(fileLine);
|
|
231
|
+
hunkFileIdx++;
|
|
232
|
+
hunkIdx++;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
lastReason = `Context mismatch at line ${hunkFileIdx + 1}: expected "${op.text.slice(0, 60)}", got "${fileLine.slice(0, 60)}"`;
|
|
236
|
+
hunkOk = false;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (op.kind === '-') {
|
|
241
|
+
const fileLine = originalLines[hunkFileIdx] ?? '';
|
|
242
|
+
if (fileLine === op.text || (fuzzy && normalizeWhitespace(fileLine) === normalizeWhitespace(op.text))) {
|
|
243
|
+
hunkFileIdx++;
|
|
244
|
+
hunkIdx++;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
lastReason = `Delete mismatch at line ${hunkFileIdx + 1}: expected "${op.text.slice(0, 60)}", got "${fileLine.slice(0, 60)}"`;
|
|
248
|
+
hunkOk = false;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// '+'
|
|
254
|
+
hunkOut.push(op.text);
|
|
255
|
+
hunkIdx++;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (!hunkOk) {
|
|
259
|
+
hunksSkipped++;
|
|
260
|
+
break; // atomic: stop on first failure
|
|
261
|
+
}
|
|
262
|
+
out.push(...hunkOut);
|
|
263
|
+
fileIdx = hunkFileIdx;
|
|
264
|
+
hunksApplied++;
|
|
265
|
+
}
|
|
266
|
+
// Copy remaining unmodified tail
|
|
267
|
+
while (fileIdx < originalLines.length) {
|
|
268
|
+
out.push(originalLines[fileIdx]);
|
|
269
|
+
fileIdx++;
|
|
270
|
+
}
|
|
271
|
+
return { lines: out, hunksApplied, hunksSkipped, lastReason };
|
|
272
|
+
}
|
|
273
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
274
|
+
// show_diff tool
|
|
275
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
276
|
+
const ShowDiffArgsSchema = z.object({
|
|
277
|
+
path: z.string().min(1),
|
|
278
|
+
proposedContent: z.string(),
|
|
279
|
+
contextLines: z.number().int().nonnegative().default(3),
|
|
280
|
+
});
|
|
281
|
+
export { ShowDiffArgsSchema };
|
|
282
|
+
export const showDiffTool = {
|
|
283
|
+
name: 'show_diff',
|
|
284
|
+
description: 'Show unified diff between current file content and proposed content. ' +
|
|
285
|
+
'Read-only — does NOT modify the file. Use this to preview edits before applying ' +
|
|
286
|
+
'with edit_file or apply_diff.',
|
|
287
|
+
permissions: ['read'],
|
|
288
|
+
timeoutMs: 15000,
|
|
289
|
+
inputSchema: ShowDiffArgsSchema,
|
|
290
|
+
execute: async (args, ctx) => {
|
|
291
|
+
try {
|
|
292
|
+
const absPath = path.isAbsolute(args.path) ? args.path : path.join(ctx.cwd, args.path);
|
|
293
|
+
let current = '';
|
|
294
|
+
try {
|
|
295
|
+
current = await fs.readFile(absPath, 'utf-8');
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
if (err.code !== 'ENOENT') {
|
|
299
|
+
return typedErr(err instanceof Error ? err.message : String(err));
|
|
300
|
+
}
|
|
301
|
+
// ENOENT → treat as empty file (creating new)
|
|
302
|
+
}
|
|
303
|
+
const a = current.split('\n');
|
|
304
|
+
const b = args.proposedContent.split('\n');
|
|
305
|
+
// Re-implement groupIntoHunks with custom CONTEXT for show_diff
|
|
306
|
+
const CONTEXT = args.contextLines;
|
|
307
|
+
const rawOps = [];
|
|
308
|
+
// Inline LCS — duplicated to honor custom CONTEXT (groupIntoHunks hard-codes 3).
|
|
309
|
+
const dp = lcsTable(a, b);
|
|
310
|
+
let i = a.length, j = b.length;
|
|
311
|
+
while (i > 0 && j > 0) {
|
|
312
|
+
if (a[i - 1] === b[j - 1]) {
|
|
313
|
+
rawOps.push({ kind: ' ', text: a[i - 1] });
|
|
314
|
+
i--;
|
|
315
|
+
j--;
|
|
316
|
+
}
|
|
317
|
+
else if (dp[i - 1][j] >= dp[i][j - 1]) {
|
|
318
|
+
rawOps.push({ kind: '-', text: a[i - 1] });
|
|
319
|
+
i--;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
rawOps.push({ kind: '+', text: b[j - 1] });
|
|
323
|
+
j--;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
while (i > 0) {
|
|
327
|
+
rawOps.push({ kind: '-', text: a[i - 1] });
|
|
328
|
+
i--;
|
|
329
|
+
}
|
|
330
|
+
while (j > 0) {
|
|
331
|
+
rawOps.push({ kind: '+', text: b[j - 1] });
|
|
332
|
+
j--;
|
|
333
|
+
}
|
|
334
|
+
rawOps.reverse();
|
|
335
|
+
// Group with custom CONTEXT
|
|
336
|
+
const hunks = [];
|
|
337
|
+
let k = 0;
|
|
338
|
+
while (k < rawOps.length) {
|
|
339
|
+
while (k < rawOps.length && rawOps[k].kind === ' ')
|
|
340
|
+
k++;
|
|
341
|
+
if (k >= rawOps.length)
|
|
342
|
+
break;
|
|
343
|
+
const start = Math.max(0, k - CONTEXT);
|
|
344
|
+
let oldStart = 0, newStart = 0;
|
|
345
|
+
{
|
|
346
|
+
let ol = 0, nl = 0;
|
|
347
|
+
for (let q = 0; q < start; q++) {
|
|
348
|
+
if (rawOps[q].kind !== '+')
|
|
349
|
+
ol++;
|
|
350
|
+
if (rawOps[q].kind !== '-')
|
|
351
|
+
nl++;
|
|
352
|
+
}
|
|
353
|
+
oldStart = ol + 1;
|
|
354
|
+
newStart = nl + 1;
|
|
355
|
+
}
|
|
356
|
+
const hunkOps = [];
|
|
357
|
+
for (let q = start; q < k; q++)
|
|
358
|
+
hunkOps.push(rawOps[q]);
|
|
359
|
+
let nonChangeStreak = 0;
|
|
360
|
+
while (k < rawOps.length) {
|
|
361
|
+
const op = rawOps[k];
|
|
362
|
+
hunkOps.push(op);
|
|
363
|
+
if (op.kind === ' ') {
|
|
364
|
+
nonChangeStreak++;
|
|
365
|
+
if (nonChangeStreak > 2 * CONTEXT) {
|
|
366
|
+
hunkOps.splice(hunkOps.length - CONTEXT, CONTEXT);
|
|
367
|
+
k++;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
nonChangeStreak = 0;
|
|
373
|
+
}
|
|
374
|
+
k++;
|
|
375
|
+
}
|
|
376
|
+
let oldLines = 0, newLines = 0;
|
|
377
|
+
for (const op of hunkOps) {
|
|
378
|
+
if (op.kind !== '+')
|
|
379
|
+
oldLines++;
|
|
380
|
+
if (op.kind !== '-')
|
|
381
|
+
newLines++;
|
|
382
|
+
}
|
|
383
|
+
hunks.push({ oldStart, oldLines, newStart, newLines, ops: hunkOps });
|
|
384
|
+
}
|
|
385
|
+
const diff = formatUnified(hunks, absPath, args.path);
|
|
386
|
+
const summaries = hunks.map(h => ({
|
|
387
|
+
oldStart: h.oldStart,
|
|
388
|
+
oldLines: h.oldLines,
|
|
389
|
+
newStart: h.newStart,
|
|
390
|
+
newLines: h.newLines,
|
|
391
|
+
added: h.ops.filter(o => o.kind === '+').length,
|
|
392
|
+
removed: h.ops.filter(o => o.kind === '-').length,
|
|
393
|
+
}));
|
|
394
|
+
const added = summaries.reduce((s, h) => s + h.added, 0);
|
|
395
|
+
const removed = summaries.reduce((s, h) => s + h.removed, 0);
|
|
396
|
+
return typedOk({
|
|
397
|
+
path: absPath,
|
|
398
|
+
diff,
|
|
399
|
+
hunks: summaries,
|
|
400
|
+
added,
|
|
401
|
+
removed,
|
|
402
|
+
unchanged: added === 0 && removed === 0,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
catch (err) {
|
|
406
|
+
return typedErr(err instanceof Error ? err.message : String(err));
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
411
|
+
// apply_diff tool
|
|
412
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
413
|
+
const ApplyDiffArgsSchema = z.object({
|
|
414
|
+
path: z.string().min(1),
|
|
415
|
+
diff: z.string().min(1),
|
|
416
|
+
fuzzyMatch: z.boolean().default(false),
|
|
417
|
+
dryRun: z.boolean().default(false),
|
|
418
|
+
});
|
|
419
|
+
export { ApplyDiffArgsSchema };
|
|
420
|
+
export const applyDiffTool = {
|
|
421
|
+
name: 'apply_diff',
|
|
422
|
+
description: 'Apply a unified diff patch to a file. Parses ---/+++/@@ headers and applies each ' +
|
|
423
|
+
'hunk sequentially. With fuzzyMatch=true, tolerates whitespace differences. ' +
|
|
424
|
+
'With dryRun=true, returns the final content without writing. ' +
|
|
425
|
+
'Atomic: if any hunk fails, no partial write occurs.',
|
|
426
|
+
permissions: ['write'],
|
|
427
|
+
timeoutMs: 15000,
|
|
428
|
+
inputSchema: ApplyDiffArgsSchema,
|
|
429
|
+
execute: async (args, ctx) => {
|
|
430
|
+
try {
|
|
431
|
+
const absPath = path.isAbsolute(args.path) ? args.path : path.join(ctx.cwd, args.path);
|
|
432
|
+
let current = '';
|
|
433
|
+
try {
|
|
434
|
+
current = await fs.readFile(absPath, 'utf-8');
|
|
435
|
+
}
|
|
436
|
+
catch (err) {
|
|
437
|
+
if (err.code !== 'ENOENT') {
|
|
438
|
+
return typedErr(err instanceof Error ? err.message : String(err));
|
|
439
|
+
}
|
|
440
|
+
// ENOENT → empty file
|
|
441
|
+
}
|
|
442
|
+
let parsed;
|
|
443
|
+
try {
|
|
444
|
+
parsed = parseUnified(args.diff);
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
return typedErr(`Parse failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
448
|
+
}
|
|
449
|
+
if (parsed.hunks.length === 0) {
|
|
450
|
+
return typedErr('No hunks found in diff');
|
|
451
|
+
}
|
|
452
|
+
// Apply ALL hunks atomically against the ORIGINAL file. Each hunk's
|
|
453
|
+
// oldStart refers to the original file, not the post-previous-hunk state.
|
|
454
|
+
const originalLines = current.split('\n');
|
|
455
|
+
const result = applyAllHunks(originalLines, parsed.hunks, args.fuzzyMatch);
|
|
456
|
+
const finalContent = result.lines.join('\n');
|
|
457
|
+
const ok = result.hunksSkipped === 0;
|
|
458
|
+
if (ok && !args.dryRun) {
|
|
459
|
+
await fs.mkdir(path.dirname(absPath), { recursive: true });
|
|
460
|
+
await fs.writeFile(absPath, finalContent, 'utf-8');
|
|
461
|
+
}
|
|
462
|
+
return typedOk({
|
|
463
|
+
path: absPath,
|
|
464
|
+
applied: ok,
|
|
465
|
+
hunksApplied: result.hunksApplied,
|
|
466
|
+
hunksSkipped: result.hunksSkipped,
|
|
467
|
+
finalContent: args.dryRun || !ok ? '' : finalContent, // omit content on dryRun/skip to save tokens
|
|
468
|
+
dryRun: args.dryRun,
|
|
469
|
+
reason: ok ? undefined : result.lastReason,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
catch (err) {
|
|
473
|
+
return typedErr(err instanceof Error ? err.message : String(err));
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
//# sourceMappingURL=diff.js.map
|