@swarmdo/cli 1.14.0 → 1.16.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 +3 -1
- package/dist/src/apply/apply.d.ts +50 -0
- package/dist/src/apply/apply.d.ts.map +1 -0
- package/dist/src/apply/apply.js +186 -0
- package/dist/src/apply/apply.js.map +1 -0
- package/dist/src/commands/apply.d.ts +18 -0
- package/dist/src/commands/apply.d.ts.map +1 -0
- package/dist/src/commands/apply.js +121 -0
- package/dist/src/commands/apply.js.map +1 -0
- package/dist/src/commands/hotspots.d.ts +17 -0
- package/dist/src/commands/hotspots.d.ts.map +1 -0
- package/dist/src/commands/hotspots.js +80 -0
- package/dist/src/commands/hotspots.js.map +1 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +9 -3
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/hotspots/hotspots.d.ts +54 -0
- package/dist/src/hotspots/hotspots.d.ts.map +1 -0
- package/dist/src/hotspots/hotspots.js +122 -0
- package/dist/src/hotspots/hotspots.js.map +1 -0
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +4 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/apply-tools.d.ts +11 -0
- package/dist/src/mcp-tools/apply-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/apply-tools.js +44 -0
- package/dist/src/mcp-tools/apply-tools.js.map +1 -0
- package/dist/src/mcp-tools/hotspots-tools.d.ts +12 -0
- package/dist/src/mcp-tools/hotspots-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hotspots-tools.js +51 -0
- package/dist/src/mcp-tools/hotspots-tools.js.map +1 -0
- package/dist/src/mcp-tools/index.d.ts +2 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/profiles.d.ts.map +1 -1
- package/dist/src/mcp-tools/profiles.js +2 -0
- package/dist/src/mcp-tools/profiles.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://swarmdo.com)
|
|
4
4
|
|
|
5
|
-
[](https://img.shields.io/badge/npx%20swarmdo-v1.16.0-cb3837?style=for-the-badge&logo=npm&logoColor=white)](https://github.com/SwarmDo/swarmdo/releases)
|
|
6
6
|
[](https://github.com/SwarmDo/swarmdo/blob/main/LICENSE)
|
|
7
7
|
[](https://swarmdo.com)
|
|
8
8
|
[](https://github.com/SwarmDo/swarmdo)
|
|
@@ -283,6 +283,8 @@ The recent release train added a full day-to-day operations layer around the swa
|
|
|
283
283
|
| `swarmdo env` | **Catch env-var drift before deploy** — statically scan code for `process.env.X` / `import.meta.env.X` / `Deno.env.get` / `os.getenv` references and reconcile against `.env` and `.env.example`: reports **missing** (used but undeclared), **unused**, and **undocumented**. `--ci` exits 1 on missing vars. Also an MCP tool (`env_check`). Deterministic |
|
|
284
284
|
| `swarmdo license` | **Audit dependency licenses** — walk `node_modules`, resolve each package's SPDX license, and gate on an allow/deny policy so a GPL or unknown license can't slip into a permissive tree. `--allow MIT,Apache-2.0 --ci` fails the build; distinct from `security` (CVEs). Also an MCP tool (`license_check`). Deterministic |
|
|
285
285
|
| `swarmdo sbom` | **Software Bill of Materials from the lockfile** — emit a CycloneDX (default) or SPDX JSON manifest of every dependency with version, purl, license, and integrity hash, for compliance/vuln tooling. `--spec spdx`, `-o sbom.json`, `--production`. Completes the env/license/sbom supply-chain trio. Deterministic |
|
|
286
|
+
| `swarmdo apply` | **A forgiving `git apply`** — apply a unified diff with fuzzy context matching, so an agent's patch lands even when line numbers have drifted or a context line is slightly off, and reports exactly which hunks couldn't. `--dry-run` to preview, `--fuzz N` to tolerate more drift. Also an MCP tool (`apply_patch`). Deterministic |
|
|
287
|
+
| `swarmdo hotspots` | **Change-risk hotspots from git history** — rank files by churn × recency × author-spread to surface the technical debt worth refactoring or testing, answered from data instead of a guess. `--since 90d`, `--by risk\|churn\|commits\|authors`, `--top N`, `--format json`. Pairs with `codegraph`; also an MCP tool (`hotspots`). Deterministic |
|
|
286
288
|
| `swarmdo integrations` (alias `integrate`) | **Use swarmdo from Codex CLI, GitHub Copilot CLI, and pi** — one command wires AGENTS.md + each CLI's MCP config (idempotent, dry-run first, never touches your Claude Code setup) |
|
|
287
289
|
| OpenRouter model pool | **Let swarms pick from any models you configure** — declare tier-mapped OpenRouter models in `swarmdo.config.json`; the router Thompson-samples among them per task and the execution layer dispatches the winner |
|
|
288
290
|
| `swarmdo changelog` (alias `notes`) | **Release notes from conventional commits** — `--out NOTES.md` feeds `gh release create --notes-file` |
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apply.ts — apply a unified diff to source text with FUZZY context matching.
|
|
3
|
+
*
|
|
4
|
+
* LLM/agent-produced diffs frequently fail `git apply`: the model's context
|
|
5
|
+
* lines drift by a few lines, or whitespace differs, and git rejects the whole
|
|
6
|
+
* patch. This applier locates each hunk by searching for its context near the
|
|
7
|
+
* declared line (not only AT it), tolerates leading/trailing context drift up
|
|
8
|
+
* to a fuzz factor, and reports precisely which hunks couldn't land — instead
|
|
9
|
+
* of an all-or-nothing failure.
|
|
10
|
+
*
|
|
11
|
+
* Pure + deterministic: text in, text (or rejects) out. The fs read/write lives
|
|
12
|
+
* in ../commands/apply.ts.
|
|
13
|
+
*/
|
|
14
|
+
export interface HunkLine {
|
|
15
|
+
/** ' ' context, '-' removal, '+' addition */
|
|
16
|
+
type: ' ' | '-' | '+';
|
|
17
|
+
content: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Hunk {
|
|
20
|
+
oldStart: number;
|
|
21
|
+
newStart: number;
|
|
22
|
+
lines: HunkLine[];
|
|
23
|
+
}
|
|
24
|
+
export interface FilePatch {
|
|
25
|
+
oldPath: string;
|
|
26
|
+
newPath: string;
|
|
27
|
+
hunks: Hunk[];
|
|
28
|
+
}
|
|
29
|
+
/** Parse a unified diff into per-file patches. Pure. Tolerates `a/`+`b/` prefixes. */
|
|
30
|
+
export declare function parsePatch(text: string): FilePatch[];
|
|
31
|
+
export interface ApplyOptions {
|
|
32
|
+
/** max leading/trailing context lines to drop when the full block won't match (default 2) */
|
|
33
|
+
fuzz?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface HunkResult {
|
|
36
|
+
hunk: Hunk;
|
|
37
|
+
applied: boolean;
|
|
38
|
+
/** 0-based line where it landed (if applied) */
|
|
39
|
+
at?: number;
|
|
40
|
+
/** how many context lines were trimmed to make it fit */
|
|
41
|
+
fuzzUsed?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ApplyResult {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
result: string;
|
|
46
|
+
hunks: HunkResult[];
|
|
47
|
+
}
|
|
48
|
+
/** Apply one file's hunks to `source`. Pure. Hunks are applied top-to-bottom with offset tracking. */
|
|
49
|
+
export declare function applyPatch(source: string, patch: FilePatch, opts?: ApplyOptions): ApplyResult;
|
|
50
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/apply/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,QAAQ;IACvB,6CAA6C;IAC7C,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CA+CpD;AAsCD,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE,YAAiB,GAAG,WAAW,CA6CjG"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apply.ts — apply a unified diff to source text with FUZZY context matching.
|
|
3
|
+
*
|
|
4
|
+
* LLM/agent-produced diffs frequently fail `git apply`: the model's context
|
|
5
|
+
* lines drift by a few lines, or whitespace differs, and git rejects the whole
|
|
6
|
+
* patch. This applier locates each hunk by searching for its context near the
|
|
7
|
+
* declared line (not only AT it), tolerates leading/trailing context drift up
|
|
8
|
+
* to a fuzz factor, and reports precisely which hunks couldn't land — instead
|
|
9
|
+
* of an all-or-nothing failure.
|
|
10
|
+
*
|
|
11
|
+
* Pure + deterministic: text in, text (or rejects) out. The fs read/write lives
|
|
12
|
+
* in ../commands/apply.ts.
|
|
13
|
+
*/
|
|
14
|
+
/** Parse a unified diff into per-file patches. Pure. Tolerates `a/`+`b/` prefixes. */
|
|
15
|
+
export function parsePatch(text) {
|
|
16
|
+
const files = [];
|
|
17
|
+
const lines = text.split('\n');
|
|
18
|
+
let cur = null;
|
|
19
|
+
let hunk = null;
|
|
20
|
+
const stripPrefix = (p) => p.replace(/^[ab]\//, '').replace(/\t.*$/, '').trim();
|
|
21
|
+
for (let i = 0; i < lines.length; i++) {
|
|
22
|
+
const line = lines[i];
|
|
23
|
+
if (line.startsWith('diff --git')) {
|
|
24
|
+
cur = null;
|
|
25
|
+
hunk = null;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (line.startsWith('--- ')) {
|
|
29
|
+
const old = stripPrefix(line.slice(4));
|
|
30
|
+
const next = lines[i + 1] ?? '';
|
|
31
|
+
const neu = next.startsWith('+++ ') ? stripPrefix(next.slice(4)) : old;
|
|
32
|
+
cur = { oldPath: old === '/dev/null' ? neu : old, newPath: neu === '/dev/null' ? old : neu, hunks: [] };
|
|
33
|
+
files.push(cur);
|
|
34
|
+
hunk = null;
|
|
35
|
+
i++; // consume the +++ line
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (line.startsWith('@@')) {
|
|
39
|
+
const m = line.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
|
|
40
|
+
if (m && cur) {
|
|
41
|
+
hunk = { oldStart: parseInt(m[1], 10), newStart: parseInt(m[2], 10), lines: [] };
|
|
42
|
+
cur.hunks.push(hunk);
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (hunk) {
|
|
47
|
+
if (line === '' && i === lines.length - 1)
|
|
48
|
+
continue; // trailing newline artifact
|
|
49
|
+
const t = line[0];
|
|
50
|
+
if (t === ' ' || t === '+' || t === '-') {
|
|
51
|
+
hunk.lines.push({ type: t, content: line.slice(1) });
|
|
52
|
+
}
|
|
53
|
+
else if (line === '') {
|
|
54
|
+
hunk.lines.push({ type: ' ', content: '' }); // blank context line written without the leading space
|
|
55
|
+
}
|
|
56
|
+
else if (line.startsWith('\\')) {
|
|
57
|
+
// "" — ignore
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
hunk = null; // end of hunk block
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return files;
|
|
65
|
+
}
|
|
66
|
+
/** The lines a hunk expects to find (context + removals), and produces (context + additions). */
|
|
67
|
+
function hunkBlocks(hunk) {
|
|
68
|
+
const oldBlock = [];
|
|
69
|
+
const newBlock = [];
|
|
70
|
+
for (const l of hunk.lines) {
|
|
71
|
+
if (l.type === ' ') {
|
|
72
|
+
oldBlock.push(l.content);
|
|
73
|
+
newBlock.push(l.content);
|
|
74
|
+
}
|
|
75
|
+
else if (l.type === '-')
|
|
76
|
+
oldBlock.push(l.content);
|
|
77
|
+
else
|
|
78
|
+
newBlock.push(l.content);
|
|
79
|
+
}
|
|
80
|
+
return { oldBlock, newBlock };
|
|
81
|
+
}
|
|
82
|
+
function blockMatchesAt(source, at, block) {
|
|
83
|
+
if (at < 0 || at + block.length > source.length)
|
|
84
|
+
return false;
|
|
85
|
+
for (let i = 0; i < block.length; i++)
|
|
86
|
+
if (source[at + i] !== block[i])
|
|
87
|
+
return false;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Find where `block` occurs in `source`, preferring the position nearest
|
|
92
|
+
* `expected` (0-based). Returns -1 if not found. Deterministic: on ties the
|
|
93
|
+
* lower index wins.
|
|
94
|
+
*/
|
|
95
|
+
function findBlock(source, block, expected) {
|
|
96
|
+
if (block.length === 0)
|
|
97
|
+
return Math.max(0, Math.min(expected, source.length));
|
|
98
|
+
if (blockMatchesAt(source, expected, block))
|
|
99
|
+
return expected;
|
|
100
|
+
let best = -1;
|
|
101
|
+
let bestDist = Infinity;
|
|
102
|
+
for (let i = 0; i + block.length <= source.length; i++) {
|
|
103
|
+
if (!blockMatchesAt(source, i, block))
|
|
104
|
+
continue;
|
|
105
|
+
const dist = Math.abs(i - expected);
|
|
106
|
+
if (dist < bestDist) {
|
|
107
|
+
bestDist = dist;
|
|
108
|
+
best = i;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return best;
|
|
112
|
+
}
|
|
113
|
+
/** Apply one file's hunks to `source`. Pure. Hunks are applied top-to-bottom with offset tracking. */
|
|
114
|
+
export function applyPatch(source, patch, opts = {}) {
|
|
115
|
+
const fuzz = opts.fuzz ?? 2;
|
|
116
|
+
const trailingNewline = source.endsWith('\n');
|
|
117
|
+
const lines = source.split('\n');
|
|
118
|
+
if (trailingNewline)
|
|
119
|
+
lines.pop(); // drop the empty element from a trailing \n
|
|
120
|
+
let offset = 0;
|
|
121
|
+
const results = [];
|
|
122
|
+
for (const hunk of patch.hunks) {
|
|
123
|
+
const { oldBlock, newBlock } = hunkBlocks(hunk);
|
|
124
|
+
const expected = hunk.oldStart - 1 + offset;
|
|
125
|
+
// Try the full block, then progressively trim up to `fuzz` context lines
|
|
126
|
+
// off each end (patch fuzz) to tolerate drift.
|
|
127
|
+
let placed = -1;
|
|
128
|
+
let usedFuzz = 0;
|
|
129
|
+
let trimLead = 0;
|
|
130
|
+
let trimTail = 0;
|
|
131
|
+
outer: for (let f = 0; f <= fuzz; f++) {
|
|
132
|
+
for (let lead = 0; lead <= f; lead++) {
|
|
133
|
+
const tail = f - lead;
|
|
134
|
+
const leadTrimmable = countLeadingContext(hunk);
|
|
135
|
+
const tailTrimmable = countTrailingContext(hunk);
|
|
136
|
+
if (lead > leadTrimmable || tail > tailTrimmable)
|
|
137
|
+
continue;
|
|
138
|
+
const trimmed = oldBlock.slice(lead, oldBlock.length - tail);
|
|
139
|
+
const at = findBlock(lines, trimmed, expected + lead);
|
|
140
|
+
if (at >= 0) {
|
|
141
|
+
placed = at - lead;
|
|
142
|
+
usedFuzz = f;
|
|
143
|
+
trimLead = lead;
|
|
144
|
+
trimTail = tail;
|
|
145
|
+
break outer;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (placed < 0) {
|
|
150
|
+
results.push({ hunk, applied: false });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
// Splice: remove oldBlock.length lines at `placed`, insert newBlock.
|
|
154
|
+
// (trimLead/trimTail only affected *matching*, not what we replace.)
|
|
155
|
+
void trimLead;
|
|
156
|
+
void trimTail;
|
|
157
|
+
lines.splice(placed, oldBlock.length, ...newBlock);
|
|
158
|
+
offset += newBlock.length - oldBlock.length;
|
|
159
|
+
results.push({ hunk, applied: true, at: placed, fuzzUsed: usedFuzz });
|
|
160
|
+
}
|
|
161
|
+
let result = lines.join('\n');
|
|
162
|
+
if (trailingNewline)
|
|
163
|
+
result += '\n';
|
|
164
|
+
return { ok: results.every((r) => r.applied), result, hunks: results };
|
|
165
|
+
}
|
|
166
|
+
function countLeadingContext(hunk) {
|
|
167
|
+
let n = 0;
|
|
168
|
+
for (const l of hunk.lines) {
|
|
169
|
+
if (l.type === ' ')
|
|
170
|
+
n++;
|
|
171
|
+
else
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
return n;
|
|
175
|
+
}
|
|
176
|
+
function countTrailingContext(hunk) {
|
|
177
|
+
let n = 0;
|
|
178
|
+
for (let i = hunk.lines.length - 1; i >= 0; i--) {
|
|
179
|
+
if (hunk.lines[i].type === ' ')
|
|
180
|
+
n++;
|
|
181
|
+
else
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
return n;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/apply/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoBH,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,GAAG,GAAqB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAgB,IAAI,CAAC;IAE7B,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AG;YAAE,CAAC,EAAE,CAAC;;YAAM,MAAM;IAAC,CAAC;IACrG,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `swarmdo apply` — apply a unified diff to the working tree with fuzzy context
|
|
3
|
+
* matching. The forgiving counterpart to `git apply`: when an agent's diff has
|
|
4
|
+
* drifted line numbers or a slightly-off context line, this still lands the
|
|
5
|
+
* hunks it can and reports exactly which it couldn't, instead of rejecting the
|
|
6
|
+
* whole patch.
|
|
7
|
+
*
|
|
8
|
+
* swarmdo apply changes.patch # apply a patch file
|
|
9
|
+
* agent-output | swarmdo apply # apply a patch from stdin
|
|
10
|
+
* swarmdo apply --dry-run changes.patch # preview: what would apply/reject
|
|
11
|
+
* swarmdo apply --fuzz 3 changes.patch # tolerate more context drift
|
|
12
|
+
*
|
|
13
|
+
* Engine (../apply/apply.ts) is pure + tested; this reads/writes files.
|
|
14
|
+
*/
|
|
15
|
+
import type { Command } from '../types.js';
|
|
16
|
+
export declare const applyCommand: Command;
|
|
17
|
+
export default applyCommand;
|
|
18
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/commands/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAwF1E,eAAO,MAAM,YAAY,EAAE,OAc1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `swarmdo apply` — apply a unified diff to the working tree with fuzzy context
|
|
3
|
+
* matching. The forgiving counterpart to `git apply`: when an agent's diff has
|
|
4
|
+
* drifted line numbers or a slightly-off context line, this still lands the
|
|
5
|
+
* hunks it can and reports exactly which it couldn't, instead of rejecting the
|
|
6
|
+
* whole patch.
|
|
7
|
+
*
|
|
8
|
+
* swarmdo apply changes.patch # apply a patch file
|
|
9
|
+
* agent-output | swarmdo apply # apply a patch from stdin
|
|
10
|
+
* swarmdo apply --dry-run changes.patch # preview: what would apply/reject
|
|
11
|
+
* swarmdo apply --fuzz 3 changes.patch # tolerate more context drift
|
|
12
|
+
*
|
|
13
|
+
* Engine (../apply/apply.ts) is pure + tested; this reads/writes files.
|
|
14
|
+
*/
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import { output } from '../output.js';
|
|
18
|
+
import { parsePatch, applyPatch } from '../apply/apply.js';
|
|
19
|
+
function readStdin() {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
const chunks = [];
|
|
22
|
+
process.stdin.on('data', (c) => chunks.push(Buffer.from(c)));
|
|
23
|
+
process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
24
|
+
process.stdin.on('error', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Resolve the file a patch targets, preferring the new path, then the old. */
|
|
28
|
+
function targetFile(root, fp) {
|
|
29
|
+
return path.resolve(root, fp.newPath && fp.newPath !== '/dev/null' ? fp.newPath : fp.oldPath);
|
|
30
|
+
}
|
|
31
|
+
async function run(ctx) {
|
|
32
|
+
const root = ctx.cwd || process.cwd();
|
|
33
|
+
const dryRun = ctx.flags['dry-run'] === true;
|
|
34
|
+
const partial = ctx.flags.partial === true;
|
|
35
|
+
// The parser may deliver --fuzz as a number or a string; accept both.
|
|
36
|
+
const fuzz = typeof ctx.flags.fuzz === 'number' ? ctx.flags.fuzz
|
|
37
|
+
: typeof ctx.flags.fuzz === 'string' ? parseInt(ctx.flags.fuzz, 10)
|
|
38
|
+
: 2;
|
|
39
|
+
// Read the patch: a file arg, or stdin.
|
|
40
|
+
let patchText;
|
|
41
|
+
if (ctx.args[0]) {
|
|
42
|
+
try {
|
|
43
|
+
patchText = fs.readFileSync(path.resolve(root, ctx.args[0]), 'utf8');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
output.printError(`could not read patch file ${ctx.args[0]}`);
|
|
47
|
+
return { success: false, exitCode: 1 };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (process.stdin.isTTY) {
|
|
52
|
+
output.writeln(output.error('Usage: swarmdo apply <patch-file> OR <patch> | swarmdo apply'));
|
|
53
|
+
return { success: false, exitCode: 1 };
|
|
54
|
+
}
|
|
55
|
+
patchText = await readStdin();
|
|
56
|
+
}
|
|
57
|
+
const patches = parsePatch(patchText);
|
|
58
|
+
if (patches.length === 0) {
|
|
59
|
+
output.printError('no file patches found — is this a unified diff?');
|
|
60
|
+
return { success: false, exitCode: 1 };
|
|
61
|
+
}
|
|
62
|
+
let totalApplied = 0;
|
|
63
|
+
let totalRejected = 0;
|
|
64
|
+
const writes = [];
|
|
65
|
+
for (const fp of patches) {
|
|
66
|
+
const file = targetFile(root, fp);
|
|
67
|
+
const rel = path.relative(root, file);
|
|
68
|
+
let source;
|
|
69
|
+
try {
|
|
70
|
+
source = fs.readFileSync(file, 'utf8');
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// New-file patch (--- /dev/null): treat missing source as empty.
|
|
74
|
+
if (fp.oldPath === '/dev/null' || !fs.existsSync(file))
|
|
75
|
+
source = '';
|
|
76
|
+
else {
|
|
77
|
+
output.printError(`cannot read ${rel}`);
|
|
78
|
+
totalRejected += fp.hunks.length;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const res = applyPatch(source, fp, { fuzz });
|
|
83
|
+
const applied = res.hunks.filter((h) => h.applied).length;
|
|
84
|
+
const rejected = res.hunks.length - applied;
|
|
85
|
+
totalApplied += applied;
|
|
86
|
+
totalRejected += rejected;
|
|
87
|
+
const fuzzy = res.hunks.filter((h) => h.applied && (h.fuzzUsed ?? 0) > 0).length;
|
|
88
|
+
const tag = rejected === 0 ? output.dim('ok') : output.bold(`${rejected} rejected`);
|
|
89
|
+
output.writeln(`${rel} ${applied}/${res.hunks.length} hunks${fuzzy ? output.dim(` (${fuzzy} fuzzy)`) : ''} ${tag}`);
|
|
90
|
+
if (rejected === 0 || partial) {
|
|
91
|
+
if (res.result !== source)
|
|
92
|
+
writes.push({ file, content: res.result });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!dryRun) {
|
|
96
|
+
for (const w of writes)
|
|
97
|
+
fs.writeFileSync(w.file, w.content);
|
|
98
|
+
}
|
|
99
|
+
const verb = dryRun ? 'would apply' : 'applied';
|
|
100
|
+
output.writeln(output.dim(`${verb} ${totalApplied} hunks, ${totalRejected} rejected${dryRun ? ' (dry run)' : ''}`));
|
|
101
|
+
// Exit 1 if anything was rejected — a CI/agent can branch on it.
|
|
102
|
+
const code = totalRejected > 0 ? 1 : 0;
|
|
103
|
+
return { success: code === 0, exitCode: code };
|
|
104
|
+
}
|
|
105
|
+
export const applyCommand = {
|
|
106
|
+
name: 'apply',
|
|
107
|
+
description: 'Apply a unified diff to the working tree with fuzzy context matching — a forgiving `git apply` for agent-produced patches',
|
|
108
|
+
options: [
|
|
109
|
+
{ name: 'dry-run', description: 'report what would apply/reject without writing', type: 'boolean' },
|
|
110
|
+
{ name: 'fuzz', description: 'max context lines to drop when matching a drifted hunk (default 2)', type: 'string' },
|
|
111
|
+
{ name: 'partial', description: 'write files even when some of their hunks are rejected', type: 'boolean' },
|
|
112
|
+
],
|
|
113
|
+
examples: [
|
|
114
|
+
{ command: 'swarmdo apply changes.patch', description: 'Apply a patch file' },
|
|
115
|
+
{ command: 'cat out.diff | swarmdo apply --dry-run', description: 'Preview a patch from stdin' },
|
|
116
|
+
{ command: 'swarmdo apply --fuzz 3 changes.patch', description: 'Tolerate more context drift' },
|
|
117
|
+
],
|
|
118
|
+
action: run,
|
|
119
|
+
};
|
|
120
|
+
export default applyCommand;
|
|
121
|
+
//# sour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
* swarmdo hotspots # top risk files in the repo
|
|
5
|
+
* swarmdo hotspots src --since 90d # scope to a path + window
|
|
6
|
+
* swarmdo hotspots --by churn --top 10 # sort/limit
|
|
7
|
+
* swarmdo hotspots --format json # machine-readable
|
|
8
|
+
*
|
|
9
|
+
* "Where is the technical debt?" answered from data: files that change often,
|
|
10
|
+
* churn heavily, are touched by many hands, and were edited recently. Pairs
|
|
11
|
+
* with `codegraph`. Engine (../hotspots/hotspots.ts) is pure + tested; this
|
|
12
|
+
* captures the git log.
|
|
13
|
+
*/
|
|
14
|
+
import type { Command } from '../types.js';
|
|
15
|
+
export declare const hotspotsCommand: Command;
|
|
16
|
+
export default hotspotsCommand;
|
|
17
|
+
//# sourceMappingURL=hotspots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotspots.d.ts","sourceRoot":"","sources":["../../../src/commands/hotspots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAqD1E,eAAO,MAAM,eAAe,EAAE,OAc7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `swarmdo hotspots` — rank files by change-risk mined from git history.
|
|
3
|
+
*
|
|
4
|
+
* swarmdo hotspots # top risk files in the repo
|
|
5
|
+
* swarmdo hotspots src --since 90d # scope to a path + window
|
|
6
|
+
* swarmdo hotspots --by churn --top 10 # sort/limit
|
|
7
|
+
* swarmdo hotspots --format json # machine-readable
|
|
8
|
+
*
|
|
9
|
+
* "Where is the technical debt?" answered from data: files that change often,
|
|
10
|
+
* churn heavily, are touched by many hands, and were edited recently. Pairs
|
|
11
|
+
* with `codegraph`. Engine (../hotspots/hotspots.ts) is pure + tested; this
|
|
12
|
+
* captures the git log.
|
|
13
|
+
*/
|
|
14
|
+
import { execFileSync } from 'node:child_process';
|
|
15
|
+
import { output } from '../output.js';
|
|
16
|
+
import { parseGitLog, computeHotspots, formatHotspots } from '../hotspots/hotspots.js';
|
|
17
|
+
const SORT_KEYS = ['risk', 'churn', 'commits', 'authors'];
|
|
18
|
+
/** Read a numeric flag that the parser may deliver as a number OR a string. */
|
|
19
|
+
function numFlag(v, def) {
|
|
20
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? parseInt(v, 10) : NaN;
|
|
21
|
+
return Number.isFinite(n) ? n : def;
|
|
22
|
+
}
|
|
23
|
+
async function run(ctx) {
|
|
24
|
+
const root = ctx.cwd || process.cwd();
|
|
25
|
+
const pathArg = ctx.args[0];
|
|
26
|
+
const since = typeof ctx.flags.since === 'string' ? ctx.flags.since : '1 year ago';
|
|
27
|
+
const top = numFlag(ctx.flags.top, 20);
|
|
28
|
+
const minCommits = numFlag(ctx.flags['min-commits'], 1);
|
|
29
|
+
const by = (typeof ctx.flags.by === 'string' ? ctx.flags.by : 'risk');
|
|
30
|
+
if (!SORT_KEYS.includes(by)) {
|
|
31
|
+
output.printError(`unknown --by '${by}' (use ${SORT_KEYS.join('|')})`);
|
|
32
|
+
return { success: false, exitCode: 1 };
|
|
33
|
+
}
|
|
34
|
+
// Global --format (text|json|table); text and table both render the table.
|
|
35
|
+
const asJson = ctx.flags.format === 'json';
|
|
36
|
+
// Capture history: SOH-delimited header + numstat, no merges.
|
|
37
|
+
const args = ['log', '--no-merges', '--numstat', `--since=${since}`, '--format=format:%x01%H%x1f%an%x1f%aI'];
|
|
38
|
+
if (pathArg)
|
|
39
|
+
args.push('--', pathArg);
|
|
40
|
+
let raw;
|
|
41
|
+
try {
|
|
42
|
+
raw = execFileSync('git', args, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 128 * 1024 * 1024 });
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
output.printError('git log failed — is this a git repository?');
|
|
46
|
+
return { success: false, exitCode: 1 };
|
|
47
|
+
}
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
const spots = computeHotspots(parseGitLog(raw), now, { by, top: top > 0 ? top : undefined, minCommits });
|
|
50
|
+
if (asJson) {
|
|
51
|
+
process.stdout.write(JSON.stringify({ generated: new Date(now).toISOString(), by, count: spots.length, hotspots: spots }, null, 2) + '\n');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (spots.length === 0) {
|
|
55
|
+
output.writeln(output.dim('no hotspots found — no matching git history in the window'));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
output.writeln(output.bold(`Change-risk hotspots (by ${by}, since ${since})`));
|
|
59
|
+
output.writeln(formatHotspots(spots, now));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { success: true, exitCode: 0 };
|
|
63
|
+
}
|
|
64
|
+
export const hotspotsCommand = {
|
|
65
|
+
name: 'hotspots',
|
|
66
|
+
description: 'Rank files by change-risk mined from git history (churn × recency × author-spread) — find the technical debt worth refactoring or testing',
|
|
67
|
+
options: [
|
|
68
|
+
{ name: 'since', description: 'history window, e.g. 90d or "3 months ago" (default 1 year)', type: 'string' },
|
|
69
|
+
{ name: 'top', description: 'keep only the top N files (default 20; 0 = all)', type: 'string' },
|
|
70
|
+
{ name: 'min-commits', description: 'drop files with fewer than N commits (default 1)', type: 'string' },
|
|
71
|
+
{ name: 'by', description: `sort key: ${SORT_KEYS.join('|')} (default risk)`, type: 'string' },
|
|
72
|
+
],
|
|
73
|
+
examples: [
|
|
74
|
+
{ command: 'swarmdo hotspots src --since 90d', description: 'Risk hotspots under src/ in the last 90 days' },
|
|
75
|
+
{ command: 'swarmdo hotspots --by churn --top 10 --format json', description: 'Top-10 by churn as JSON' },
|
|
76
|
+
],
|
|
77
|
+
action: run,
|
|
78
|
+
};
|
|
79
|
+
export default hotspotsCommand;
|
|
80
|
+
//# sourceMappingURL=hotspots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotspots.js","sourceRoot":"","sources":["../../../src/commands/h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AAE,WAAW,EAAE,kDAAkD,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC/F;IACD,QAAQ,EAAE;QACR,EAAE,OAAO,EAAE,kCAAkC,EAAE,WAAW,EAAE,8CAA8C,EAAE;QAC5G,EAAE,OAAO,EAAE,oDAAoD,EAAE,WAAW,EAAE,yBAAyB,EAAE;KAC1G;IACD,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA0M3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA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;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAWhF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAO1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,EAAE,CAE7C;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAa1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,GAAG,IAAI,CAI5E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9F"}
|
|
@@ -38,6 +38,12 @@ const commandLoaders = {
|
|
|
38
38
|
// Software Bill of Materials from the lockfile (syft/cyclonedx demand) —
|
|
39
39
|
// CycloneDX/SPDX JSON; completes the env/license/sbom supply-chain trio.
|
|
40
40
|
sbom: () => import('./sbom.js'),
|
|
41
|
+
// Fuzzy unified-diff applier (agent-diff pain) — a forgiving `git apply` that
|
|
42
|
+
// lands hunks despite context drift and reports what it couldn't.
|
|
43
|
+
apply: () => import('./apply.js'),
|
|
44
|
+
// Change-risk hotspots from git history (code-maat demand) — rank files by
|
|
45
|
+
// churn × recency × author-spread; "where is the tech debt?" from data.
|
|
46
|
+
hotspots: () => import('./hotspots.js'),
|
|
41
47
|
// Queryable exported-symbol index (codegraph demand) — where things are
|
|
42
48
|
// defined without grep+read round-trips.
|
|
43
49
|
codegraph: () => import('./codegraph.js'),
|
|
@@ -271,7 +277,7 @@ export async function getCommandsByCategory() {
|
|
|
271
277
|
// three slots from 'statusline' onward (completionsCmd received the
|
|
272
278
|
// statusline module, analyzeCmd received completions, …), scrambling the
|
|
273
279
|
// categorized help. Every load now has a named slot.
|
|
274
|
-
const [daemonCmd, doctorCmd, embeddingsCmd, neuralCmd, performanceCmd, securityCmd, swarmvectorCmd, hiveMindCmd, configCmd, statuslineCmd, compressCmd, efficiencyCmd, completionsCmd, migrateCmd, workflowCmd, analyzeCmd, routeCmd, progressCmd, providersCmd, pluginsCmd, deploymentCmd, claimsCmd, issuesCmd, updateCmd, processCmd, guidanceCmd, applianceCmd, cleanupCmd, autopilotCmd, demoCmd, usageCmd, repairCmd, hudCmd, compactCmd, codegraphCmd, redactCmd, packCmd, envCmd, licenseCmd, sbomCmd,] = await Promise.all([
|
|
280
|
+
const [daemonCmd, doctorCmd, embeddingsCmd, neuralCmd, performanceCmd, securityCmd, swarmvectorCmd, hiveMindCmd, configCmd, statuslineCmd, compressCmd, efficiencyCmd, completionsCmd, migrateCmd, workflowCmd, analyzeCmd, routeCmd, progressCmd, providersCmd, pluginsCmd, deploymentCmd, claimsCmd, issuesCmd, updateCmd, processCmd, guidanceCmd, applianceCmd, cleanupCmd, autopilotCmd, demoCmd, usageCmd, repairCmd, hudCmd, compactCmd, codegraphCmd, redactCmd, packCmd, envCmd, licenseCmd, sbomCmd, applyCmd, hotspotsCmd,] = await Promise.all([
|
|
275
281
|
loadCommand('daemon'), loadCommand('doctor'), loadCommand('embeddings'), loadCommand('neural'),
|
|
276
282
|
loadCommand('performance'), loadCommand('security'), loadCommand('swarmvector'), loadCommand('hive-mind'),
|
|
277
283
|
loadCommand('config'), loadCommand('statusline'), loadCommand('compress'), loadCommand('efficiency'),
|
|
@@ -279,7 +285,7 @@ export async function getCommandsByCategory() {
|
|
|
279
285
|
loadCommand('analyze'), loadCommand('route'), loadCommand('progress'), loadCommand('providers'),
|
|
280
286
|
loadCommand('plugins'), loadCommand('deployment'), loadCommand('claims'), loadCommand('issues'),
|
|
281
287
|
loadCommand('update'), loadCommand('process'), loadCommand('guidance'), loadCommand('appliance'),
|
|
282
|
-
loadCommand('cleanup'), loadCommand('autopilot'), loadCommand('demo'), loadCommand('usage'), loadCommand('repair'), loadCommand('hud'), loadCommand('compact'), loadCommand('codegraph'), loadCommand('redact'), loadCommand('pack'), loadCommand('env'), loadCommand('license'), loadCommand('sbom'),
|
|
288
|
+
loadCommand('cleanup'), loadCommand('autopilot'), loadCommand('demo'), loadCommand('usage'), loadCommand('repair'), loadCommand('hud'), loadCommand('compact'), loadCommand('codegraph'), loadCommand('redact'), loadCommand('pack'), loadCommand('env'), loadCommand('license'), loadCommand('sbom'), loadCommand('apply'), loadCommand('hotspots'),
|
|
283
289
|
]);
|
|
284
290
|
return {
|
|
285
291
|
primary: [
|
|
@@ -295,7 +301,7 @@ export async function getCommandsByCategory() {
|
|
|
295
301
|
utility: [
|
|
296
302
|
configCmd, doctorCmd, daemonCmd, completionsCmd,
|
|
297
303
|
migrateCmd, workflowCmd, demoCmd,
|
|
298
|
-
statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, envCmd, licenseCmd, sbomCmd, efficiencyCmd,
|
|
304
|
+
statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, envCmd, licenseCmd, sbomCmd, applyCmd, hotspotsCmd, efficiencyCmd,
|
|
299
305
|
].filter(Boolean),
|
|
300
306
|
analysis: [
|
|
301
307
|
analyzeCmd, routeCmd, progressCmd, usageCmd, hudCmd, codegraphCmd,
|