@swarmdo/cli 1.19.0 → 1.29.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/.claude/helpers/auto-memory-hook.mjs +5 -1
- package/README.md +10 -8
- package/bin/cli.js +38 -0
- package/dist/src/apply/apply.d.ts +8 -0
- package/dist/src/apply/apply.d.ts.map +1 -1
- package/dist/src/apply/apply.js +70 -10
- package/dist/src/apply/apply.js.map +1 -1
- package/dist/src/changelog/changelog.d.ts.map +1 -1
- package/dist/src/changelog/changelog.js +26 -3
- package/dist/src/changelog/changelog.js.map +1 -1
- package/dist/src/codegraph/codegraph.d.ts +26 -7
- package/dist/src/codegraph/codegraph.d.ts.map +1 -1
- package/dist/src/codegraph/codegraph.js +97 -13
- package/dist/src/codegraph/codegraph.js.map +1 -1
- package/dist/src/codegraph/store.d.ts +8 -1
- package/dist/src/codegraph/store.d.ts.map +1 -1
- package/dist/src/codegraph/store.js +78 -1
- package/dist/src/codegraph/store.js.map +1 -1
- package/dist/src/commands/apply.d.ts.map +1 -1
- package/dist/src/commands/apply.js +17 -4
- package/dist/src/commands/apply.js.map +1 -1
- package/dist/src/commands/compact-snapshot.d.ts +17 -0
- package/dist/src/commands/compact-snapshot.d.ts.map +1 -0
- package/dist/src/commands/compact-snapshot.js +133 -0
- package/dist/src/commands/compact-snapshot.js.map +1 -0
- package/dist/src/commands/cycles.d.ts.map +1 -1
- package/dist/src/commands/cycles.js +4 -1
- package/dist/src/commands/cycles.js.map +1 -1
- package/dist/src/commands/hotspots.d.ts.map +1 -1
- package/dist/src/commands/hotspots.js +5 -2
- package/dist/src/commands/hotspots.js.map +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -3
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/pack.d.ts +8 -0
- package/dist/src/commands/pack.d.ts.map +1 -1
- package/dist/src/commands/pack.js +28 -2
- package/dist/src/commands/pack.js.map +1 -1
- package/dist/src/commands/release.d.ts.map +1 -1
- package/dist/src/commands/release.js +5 -1
- package/dist/src/commands/release.js.map +1 -1
- package/dist/src/commands/testreport.d.ts.map +1 -1
- package/dist/src/commands/testreport.js +2 -1
- package/dist/src/commands/testreport.js.map +1 -1
- package/dist/src/compact/compact.d.ts.map +1 -1
- package/dist/src/compact/compact.js +17 -7
- package/dist/src/compact/compact.js.map +1 -1
- package/dist/src/compact-snapshot/compact-snapshot.d.ts +58 -0
- package/dist/src/compact-snapshot/compact-snapshot.d.ts.map +1 -0
- package/dist/src/compact-snapshot/compact-snapshot.js +104 -0
- package/dist/src/compact-snapshot/compact-snapshot.js.map +1 -0
- package/dist/src/config-lint/lint.d.ts.map +1 -1
- package/dist/src/config-lint/lint.js +16 -2
- package/dist/src/config-lint/lint.js.map +1 -1
- package/dist/src/cycles/cycles.d.ts +12 -2
- package/dist/src/cycles/cycles.d.ts.map +1 -1
- package/dist/src/cycles/cycles.js +5 -3
- package/dist/src/cycles/cycles.js.map +1 -1
- package/dist/src/env/env.d.ts +5 -2
- package/dist/src/env/env.d.ts.map +1 -1
- package/dist/src/env/env.js +24 -3
- package/dist/src/env/env.js.map +1 -1
- package/dist/src/hotspots/hotspots.d.ts +15 -0
- package/dist/src/hotspots/hotspots.d.ts.map +1 -1
- package/dist/src/hotspots/hotspots.js +33 -1
- package/dist/src/hotspots/hotspots.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +33 -3
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/license/license.d.ts +31 -2
- package/dist/src/license/license.d.ts.map +1 -1
- package/dist/src/license/license.js +133 -11
- package/dist/src/license/license.js.map +1 -1
- package/dist/src/pack/pack.d.ts +2 -3
- package/dist/src/pack/pack.d.ts.map +1 -1
- package/dist/src/pack/pack.js +68 -12
- package/dist/src/pack/pack.js.map +1 -1
- package/dist/src/redact/redact.d.ts.map +1 -1
- package/dist/src/redact/redact.js +14 -2
- package/dist/src/redact/redact.js.map +1 -1
- package/dist/src/sbom/sbom.d.ts +16 -0
- package/dist/src/sbom/sbom.d.ts.map +1 -1
- package/dist/src/sbom/sbom.js +33 -3
- package/dist/src/sbom/sbom.js.map +1 -1
- package/dist/src/swarmvector/model-prices.d.ts.map +1 -1
- package/dist/src/swarmvector/model-prices.js +12 -2
- package/dist/src/swarmvector/model-prices.js.map +1 -1
- package/dist/src/testreport/testreport.d.ts +14 -0
- package/dist/src/testreport/testreport.d.ts.map +1 -1
- package/dist/src/testreport/testreport.js +82 -9
- package/dist/src/testreport/testreport.js.map +1 -1
- package/dist/src/transcript/export.d.ts +5 -0
- package/dist/src/transcript/export.d.ts.map +1 -1
- package/dist/src/transcript/export.js +8 -1
- package/dist/src/transcript/export.js.map +1 -1
- package/dist/src/usage/claude-pricing.d.ts +12 -2
- package/dist/src/usage/claude-pricing.d.ts.map +1 -1
- package/dist/src/usage/claude-pricing.js +45 -13
- package/dist/src/usage/claude-pricing.js.map +1 -1
- package/dist/src/usage/transcript-usage.d.ts.map +1 -1
- package/dist/src/usage/transcript-usage.js +5 -2
- package/dist/src/usage/transcript-usage.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/swarmdo-metaharness/.claude-plugin/plugin.json +5 -2
|
@@ -99,7 +99,11 @@ class JsonFileBackend {
|
|
|
99
99
|
async query(opts) {
|
|
100
100
|
let results = [...this.entries.values()];
|
|
101
101
|
if (opts?.namespace) results = results.filter(e => e.namespace === opts.namespace);
|
|
102
|
-
|
|
102
|
+
// NOTE: opts.type is the QueryType search STRATEGY (semantic|keyword|hybrid|…),
|
|
103
|
+
// NOT an entry MemoryType. This JSON backend has no vector search, so the
|
|
104
|
+
// strategy is moot — filtering entries by it excluded everything (a 'hybrid'
|
|
105
|
+
// query matched no 'semantic' entries), which zeroed out the bridge's
|
|
106
|
+
// content-hash dedup and let the store bloat ~22x per re-import (#53).
|
|
103
107
|
if (opts?.limit) results = results.slice(0, opts.limit);
|
|
104
108
|
return results;
|
|
105
109
|
}
|
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.29.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)
|
|
@@ -47,17 +47,17 @@ There are **two different install paths** with very different surface areas. Pic
|
|
|
47
47
|
|
|
48
48
|
| | **Claude Code Plugin** | **CLI install (`npx swarmdo init`)** |
|
|
49
49
|
|---|---|---|
|
|
50
|
-
| What it gives you | Slash commands +
|
|
50
|
+
| What it gives you | Slash commands + skills + agent definitions per-plugin; `swarmdo-core` also registers the swarmdo MCP server | Full Swarmdo loop — 98 agents, 60+ commands, 30 skills, MCP server, hooks, daemon |
|
|
51
51
|
| Files in your workspace | **Zero** | `.claude/`, `.swarmdo/`, `CLAUDE.md`, helpers, settings |
|
|
52
|
-
| MCP server registered | **
|
|
52
|
+
| MCP server registered | **Yes with `swarmdo-core`** (via the plugin's `.mcp.json`); other plugins are commands/skills only | Yes |
|
|
53
53
|
| Hooks installed | No | Yes |
|
|
54
|
-
| Best for | Try
|
|
54
|
+
| Best for | Try Swarmdo without committing files to your workspace | Production use — everything works as documented |
|
|
55
55
|
|
|
56
|
-
### Path A — Claude Code Plugins (
|
|
56
|
+
### Path A — Claude Code Plugins (zero files in your repo)
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
# Add the marketplace
|
|
60
|
-
/plugin marketplace add
|
|
60
|
+
/plugin marketplace add SwarmDo/swarmdo
|
|
61
61
|
|
|
62
62
|
# Install core + any plugins you need
|
|
63
63
|
/plugin install swarmdo-core@swarmdo
|
|
@@ -66,7 +66,9 @@ There are **two different install paths** with very different surface areas. Pic
|
|
|
66
66
|
/plugin install swarmdo-neural-trader@swarmdo
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`swarmdo-core` registers the swarmdo MCP server (300+ tools) plus base agents and setup skills; the other plugins add their slash commands and agent definitions. Hooks and the daemon still require Path B.
|
|
70
|
+
|
|
71
|
+
> 📦 `swarmdo-core` has been submitted to Anthropic's Claude Code plugin directory (community marketplace). Once approved it will also be installable via `/plugin install swarmdo-core@claude-community` — no marketplace-add needed.
|
|
70
72
|
|
|
71
73
|
<details>
|
|
72
74
|
<summary><strong>🔌 All 35 plugins</strong></summary>
|
|
@@ -159,7 +161,7 @@ This adds slash commands and agent definitions only. The Swarmdo MCP server is N
|
|
|
159
161
|
|
|
160
162
|
```bash
|
|
161
163
|
# One-line install (POSIX shells only — see Windows note below)
|
|
162
|
-
curl -fsSL https://cdn.jsdelivr.net/gh/
|
|
164
|
+
curl -fsSL https://cdn.jsdelivr.net/gh/SwarmDo/swarmdo@main/scripts/install.sh | bash
|
|
163
165
|
```
|
|
164
166
|
|
|
165
167
|
**All platforms (including native Windows PowerShell / cmd):**
|
package/bin/cli.js
CHANGED
|
@@ -93,6 +93,20 @@ console.log = (...args) => {
|
|
|
93
93
|
_origLog.apply(console, args);
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
// Claude Code plugin hint (code.claude.com/docs/en/plugin-hints): when a
|
|
97
|
+
// session runs swarmdo through Claude Code's Bash tool, emit the one-line
|
|
98
|
+
// marker so Claude Code can offer to install our plugin. Emitted here in the
|
|
99
|
+
// bin shim — NOT in dist/src/index.js — so it also covers the #2256 fast
|
|
100
|
+
// paths below (--version/--help are exactly the probes Claude runs on an
|
|
101
|
+
// unfamiliar CLI). Claude Code strips the line from all output before it
|
|
102
|
+
// reaches the model and only prompts if/when swarmdo-core is listed in the
|
|
103
|
+
// official Anthropic marketplace; until then it is silently dropped.
|
|
104
|
+
if (process.env.CLAUDECODE) {
|
|
105
|
+
process.stderr.write(
|
|
106
|
+
'<claude-code-hint v="1" type="plugin" value="swarmdo-core@claude-plugins-official" />\n'
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
// #2256 fast path: --version / -V / --help / -h must NOT trigger heavy
|
|
97
111
|
// imports (agentic-flow, swarmvector ONNX, etc.) — those eagerly download a
|
|
98
112
|
// 23 MB ONNX model on cold cache, blocking 60+ s and causing SIGTERM
|
|
@@ -116,6 +130,30 @@ console.log = (...args) => {
|
|
|
116
130
|
// loading. The version short-circuit is the only one safe to inline.
|
|
117
131
|
}
|
|
118
132
|
|
|
133
|
+
// #45 fast path: `compact-snapshot` is wired to UserPromptSubmit (fires on
|
|
134
|
+
// EVERY prompt) and PreCompact, so it must not pay the full-CLI bootstrap
|
|
135
|
+
// (~0.6s incl. the 23 MB ONNX load). Its own module imports only fs/git/output
|
|
136
|
+
// + the pure engine, so dispatch it directly and exit before any heavy import.
|
|
137
|
+
// A bare `--help` still falls through to the rich help path below.
|
|
138
|
+
{
|
|
139
|
+
const _argv = process.argv.slice(2);
|
|
140
|
+
if (_argv[0] === 'compact-snapshot' && !_argv.includes('--help') && !_argv.includes('-h')) {
|
|
141
|
+
try {
|
|
142
|
+
const mod = await import('../dist/src/commands/compact-snapshot.js');
|
|
143
|
+
const cmd = mod.default ?? mod.compactSnapshotCommand;
|
|
144
|
+
const rest = _argv.slice(1);
|
|
145
|
+
const args = rest.filter((a) => !a.startsWith('-'));
|
|
146
|
+
const flags = {};
|
|
147
|
+
for (const a of rest) if (a.startsWith('--')) flags[a.replace(/^--/, '')] = true;
|
|
148
|
+
const res = await cmd.action({ cwd: process.cwd(), args, flags, rawArgs: rest });
|
|
149
|
+
process.exit(res && typeof res.exitCode === 'number' ? res.exitCode : 0);
|
|
150
|
+
} catch (e) {
|
|
151
|
+
// Best-effort: a failure here must never block a turn (it runs in hooks).
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
119
157
|
// Check if we should run in MCP server mode
|
|
120
158
|
// Conditions:
|
|
121
159
|
// 1. stdin is being piped AND no CLI arguments provided (auto-detect)
|
|
@@ -15,6 +15,8 @@ export interface HunkLine {
|
|
|
15
15
|
/** ' ' context, '-' removal, '+' addition */
|
|
16
16
|
type: ' ' | '-' | '+';
|
|
17
17
|
content: string;
|
|
18
|
+
/** true if a `` marker immediately followed this line */
|
|
19
|
+
noEol?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface Hunk {
|
|
20
22
|
oldStart: number;
|
|
@@ -39,6 +41,12 @@ export interface HunkResult {
|
|
|
39
41
|
at?: number;
|
|
40
42
|
/** how many context lines were trimmed to make it fit */
|
|
41
43
|
fuzzUsed?: number;
|
|
44
|
+
/**
|
|
45
|
+
* True when the matched block occurs at MORE THAN ONE position in the file —
|
|
46
|
+
* the hunk landed at the nearest, but a duplicate/boilerplate block elsewhere
|
|
47
|
+
* means it may have modified the wrong occurrence. Callers should verify.
|
|
48
|
+
*/
|
|
49
|
+
ambiguous?: boolean;
|
|
42
50
|
}
|
|
43
51
|
export interface ApplyResult {
|
|
44
52
|
ok: boolean;
|
|
@@ -1 +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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EAAE,SAAS,EAAE,IAAI,GAAE,YAAiB,GAAG,WAAW,CAyEjG"}
|
package/dist/src/apply/apply.js
CHANGED
|
@@ -19,7 +19,10 @@ export function parsePatch(text) {
|
|
|
19
19
|
let hunk = null;
|
|
20
20
|
const stripPrefix = (p) => p.replace(/^[ab]\//, '').replace(/\t.*$/, '').trim();
|
|
21
21
|
for (let i = 0; i < lines.length; i++) {
|
|
22
|
-
|
|
22
|
+
// CRLF tolerance (#9): a diff generated on/for CRLF files carries \r on
|
|
23
|
+
// every line; strip it so hunk content compares EOL-agnostically.
|
|
24
|
+
const raw = lines[i];
|
|
25
|
+
const line = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
|
|
23
26
|
if (line.startsWith('diff --git')) {
|
|
24
27
|
cur = null;
|
|
25
28
|
hunk = null;
|
|
@@ -54,7 +57,10 @@ export function parsePatch(text) {
|
|
|
54
57
|
hunk.lines.push({ type: ' ', content: '' }); // blank context line written without the leading space
|
|
55
58
|
}
|
|
56
59
|
else if (line.startsWith('\\')) {
|
|
57
|
-
// "" —
|
|
60
|
+
// "" — attaches to the preceding hunk line,
|
|
61
|
+
// recording that that side of the diff has no trailing newline.
|
|
62
|
+
if (hunk.lines.length)
|
|
63
|
+
hunk.lines[hunk.lines.length - 1].noEol = true;
|
|
58
64
|
}
|
|
59
65
|
else {
|
|
60
66
|
hunk = null; // end of hunk block
|
|
@@ -87,6 +93,16 @@ function blockMatchesAt(source, at, block) {
|
|
|
87
93
|
return false;
|
|
88
94
|
return true;
|
|
89
95
|
}
|
|
96
|
+
/** How many positions in `source` the `block` matches. Pure. */
|
|
97
|
+
function countMatches(source, block) {
|
|
98
|
+
if (block.length === 0)
|
|
99
|
+
return 0;
|
|
100
|
+
let n = 0;
|
|
101
|
+
for (let i = 0; i + block.length <= source.length; i++)
|
|
102
|
+
if (blockMatchesAt(source, i, block))
|
|
103
|
+
n++;
|
|
104
|
+
return n;
|
|
105
|
+
}
|
|
90
106
|
/**
|
|
91
107
|
* Find where `block` occurs in `source`, preferring the position nearest
|
|
92
108
|
* `expected` (0-based). Returns -1 if not found. Deterministic: on ties the
|
|
@@ -114,11 +130,24 @@ function findBlock(source, block, expected) {
|
|
|
114
130
|
export function applyPatch(source, patch, opts = {}) {
|
|
115
131
|
const fuzz = opts.fuzz ?? 2;
|
|
116
132
|
const trailingNewline = source.endsWith('\n');
|
|
133
|
+
// CRLF support (#9): match EOL-agnostically, then write inserted lines with
|
|
134
|
+
// the file's dominant EOL so CRLF sources stay CRLF. `lines` keeps each
|
|
135
|
+
// line's original bytes (untouched lines round-trip exactly); `matchLines`
|
|
136
|
+
// is the \r-stripped twin every comparison runs against. The two are spliced
|
|
137
|
+
// in lockstep so indices stay aligned.
|
|
138
|
+
const crlfCount = (source.match(/\r\n/g) ?? []).length;
|
|
139
|
+
const newlineCount = (source.match(/\n/g) ?? []).length;
|
|
140
|
+
const dominantCrlf = crlfCount > newlineCount - crlfCount;
|
|
117
141
|
const lines = source.split('\n');
|
|
118
142
|
if (trailingNewline)
|
|
119
143
|
lines.pop(); // drop the empty element from a trailing \n
|
|
144
|
+
const stripCr = (s) => (s.endsWith('\r') ? s.slice(0, -1) : s);
|
|
145
|
+
const matchLines = lines.map(stripCr);
|
|
120
146
|
let offset = 0;
|
|
121
147
|
const results = [];
|
|
148
|
+
// If a hunk that reaches EOF carries an explicit no-newline marker, it — not
|
|
149
|
+
// the source — decides the output's trailing newline. undefined = no marker.
|
|
150
|
+
let eofNoEol;
|
|
122
151
|
for (const hunk of patch.hunks) {
|
|
123
152
|
const { oldBlock, newBlock } = hunkBlocks(hunk);
|
|
124
153
|
const expected = hunk.oldStart - 1 + offset;
|
|
@@ -136,7 +165,7 @@ export function applyPatch(source, patch, opts = {}) {
|
|
|
136
165
|
if (lead > leadTrimmable || tail > tailTrimmable)
|
|
137
166
|
continue;
|
|
138
167
|
const trimmed = oldBlock.slice(lead, oldBlock.length - tail);
|
|
139
|
-
const at = findBlock(
|
|
168
|
+
const at = findBlock(matchLines, trimmed, expected + lead);
|
|
140
169
|
if (at >= 0) {
|
|
141
170
|
placed = at - lead;
|
|
142
171
|
usedFuzz = f;
|
|
@@ -150,19 +179,50 @@ export function applyPatch(source, patch, opts = {}) {
|
|
|
150
179
|
results.push({ hunk, applied: false });
|
|
151
180
|
continue;
|
|
152
181
|
}
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
// A hunk is AMBIGUOUS if the block it matched on occurs elsewhere too — the
|
|
183
|
+
// nearest-match tiebreak may have picked the wrong duplicate. Check the
|
|
184
|
+
// matched (trimmed) block against the current lines BEFORE splicing.
|
|
185
|
+
const matchedBlock = oldBlock.slice(trimLead, oldBlock.length - trimTail);
|
|
186
|
+
const ambiguous = countMatches(matchLines, matchedBlock) > 1;
|
|
187
|
+
// Splice: remove oldBlock.length lines at `placed`, insert newBlock —
|
|
188
|
+
// raw lines get the file's dominant EOL, the match twin stays stripped.
|
|
189
|
+
const insertRaw = dominantCrlf ? newBlock.map((l) => l + '\r') : newBlock;
|
|
190
|
+
lines.splice(placed, oldBlock.length, ...insertRaw);
|
|
191
|
+
matchLines.splice(placed, oldBlock.length, ...newBlock);
|
|
158
192
|
offset += newBlock.length - oldBlock.length;
|
|
159
|
-
results.push({ hunk, applied: true, at: placed, fuzzUsed: usedFuzz });
|
|
193
|
+
results.push({ hunk, applied: true, at: placed, fuzzUsed: usedFuzz, ...(ambiguous && { ambiguous: true }) });
|
|
194
|
+
// If this hunk's new content is now the tail of the file, its markers
|
|
195
|
+
// determine whether the file ends with a newline.
|
|
196
|
+
if (placed + newBlock.length === lines.length)
|
|
197
|
+
eofNoEol = newSideEndsNoEol(hunk);
|
|
160
198
|
}
|
|
161
199
|
let result = lines.join('\n');
|
|
162
|
-
|
|
200
|
+
// The patch's explicit EOF marker wins; absent one, keep the source's state.
|
|
201
|
+
const endWithNewline = eofNoEol === undefined ? trailingNewline : !eofNoEol;
|
|
202
|
+
if (endWithNewline)
|
|
163
203
|
result += '\n';
|
|
204
|
+
// An inserted line that became the no-trailing-newline tail carries the
|
|
205
|
+
// dominant-EOL \r it was given for joining — a bare CR at EOF is never
|
|
206
|
+
// meaningful, so drop it.
|
|
207
|
+
else if (result.endsWith('\r'))
|
|
208
|
+
result = result.slice(0, -1);
|
|
164
209
|
return { ok: results.every((r) => r.applied), result, hunks: results };
|
|
165
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether the NEW side of `hunk` ends without a trailing newline — read from the
|
|
213
|
+
* last context/addition line's marker. Returns undefined if the hunk carries no
|
|
214
|
+
* `\ No newline` marker at all (so the source's state should be kept). Pure.
|
|
215
|
+
*/
|
|
216
|
+
function newSideEndsNoEol(hunk) {
|
|
217
|
+
if (!hunk.lines.some((l) => l.noEol))
|
|
218
|
+
return undefined;
|
|
219
|
+
for (let i = hunk.lines.length - 1; i >= 0; i--) {
|
|
220
|
+
const l = hunk.lines[i];
|
|
221
|
+
if (l.type === ' ' || l.type === '+')
|
|
222
|
+
return !!l.noEol;
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
166
226
|
function countLeadingContext(hunk) {
|
|
167
227
|
let n = 0;
|
|
168
228
|
for (const l of hunk.lines) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/apply/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/apply/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsBH,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;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C;IACV,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAAC,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG;YAAE,CAAC,EAAE,CAAC;;YAAM,MAAM;IAAC,CAAC;IACpE,OAAO,CAAC,CAAC;AACX,CAAC;AACD,SAAS,oBAAoB,CAAC,IAAU;IACtC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG;YAAE,CAAC,EAAE,CAAC;;YAAM,MAAM;IAAC,CAAC;IACrG,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../../src/changelog/changelog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,iEAAiE;AACjE,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAY7E,CAAC;
|
|
1
|
+
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../../src/changelog/changelog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC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GAAG,MAAM,CA2BzF;AAID,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;AAEnD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAIpD;AAED,qDAAqD;AACrD,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAOrD;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ5D;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,YAAY,EAAE,CAG5E"}
|
|
@@ -24,18 +24,41 @@ export const SECTIONS = [
|
|
|
24
24
|
{ type: 'chore', label: 'Chores', hidden: true },
|
|
25
25
|
];
|
|
26
26
|
const SUBJECT_RE = /^(\w+)(?:\(([^)]+)\))?(!)?:\s+(.+)$/;
|
|
27
|
+
// git's default revert subject: `Revert "<original subject>"` (git-revert(1)).
|
|
28
|
+
// The conventional `revert:` type is handled by SUBJECT_RE; this catches the
|
|
29
|
+
// bare git form, which otherwise falls into the hidden `other` bucket.
|
|
30
|
+
const REVERT_RE = /^Revert\s+"(.+)"$/;
|
|
31
|
+
// Conventional Commits: a breaking-change footer MUST be the uppercase token
|
|
32
|
+
// `BREAKING CHANGE` (or `BREAKING-CHANGE`) at the start of a footer line,
|
|
33
|
+
// followed by `: `. Anchoring to a line start avoids a false positive when the
|
|
34
|
+
// phrase merely appears in prose ("this is not a BREAKING CHANGE, just …").
|
|
35
|
+
const BREAKING_RE = /^BREAKING[ -]CHANGE:\s/m;
|
|
27
36
|
/** Parse one conventional-commit subject (+ optional body for BREAKING CHANGE). */
|
|
28
37
|
export function parseCommit(hash, subject, body = '') {
|
|
29
|
-
const
|
|
38
|
+
const trimmed = subject.trim();
|
|
39
|
+
const rev = REVERT_RE.exec(trimmed);
|
|
40
|
+
if (rev) {
|
|
41
|
+
// Recurse into the quoted original subject to lift its scope/description.
|
|
42
|
+
const inner = SUBJECT_RE.exec(rev[1].trim());
|
|
43
|
+
return {
|
|
44
|
+
hash,
|
|
45
|
+
type: 'revert',
|
|
46
|
+
scope: inner ? inner[2] ?? null : null,
|
|
47
|
+
breaking: BREAKING_RE.test(body),
|
|
48
|
+
subject: inner ? inner[4].trim() : rev[1].trim(),
|
|
49
|
+
raw: trimmed,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const m = SUBJECT_RE.exec(trimmed);
|
|
30
53
|
if (!m) {
|
|
31
|
-
return { hash, type: null, scope: null, breaking:
|
|
54
|
+
return { hash, type: null, scope: null, breaking: BREAKING_RE.test(body), subject: subject.trim(), raw: subject.trim() };
|
|
32
55
|
}
|
|
33
56
|
const [, type, scope, bang, desc] = m;
|
|
34
57
|
return {
|
|
35
58
|
hash,
|
|
36
59
|
type: type.toLowerCase(),
|
|
37
60
|
scope: scope ?? null,
|
|
38
|
-
breaking: bang === '!' ||
|
|
61
|
+
breaking: bang === '!' || BREAKING_RE.test(body),
|
|
39
62
|
subject: desc.trim(),
|
|
40
63
|
raw: subject.trim(),
|
|
41
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../../src/changelog/changelog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAWlD,iEAAiE;AACjE,MAAM,CAAC,MAAM,QAAQ,GAA6D;IAChF,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE;IACnC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE;IACnC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE;IAC1C,EAAE,I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
|
line: number;
|
|
34
|
+
/**
|
|
35
|
+
* True for a TypeScript type-only import/export (`import type …`,
|
|
36
|
+
* `export type … from …`). These are erased at compile time (with
|
|
37
|
+
* isolatedModules/verbatimModuleSyntax) so they create NO runtime dependency
|
|
38
|
+
* — relevant to cycle detection, where a type-only "cycle" is benign.
|
|
39
|
+
*/
|
|
40
|
+
isTypeOnly?: boolean;
|
|
34
41
|
}
|
|
35
42
|
export interface CodeIndex {
|
|
36
43
|
/** Repo-relative file → symbols declared in it. */
|
|
@@ -46,19 +53,31 @@ export declare function extractImports(source: string, file: string): Array<{
|
|
|
46
53
|
from: string;
|
|
47
54
|
spec: string;
|
|
48
55
|
line: number;
|
|
56
|
+
isTypeOnly: boolean;
|
|
49
57
|
}>;
|
|
50
58
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
59
|
+
* A tsconfig `paths` / workspace alias: a bare-specifier pattern mapped to a
|
|
60
|
+
* repo-relative target (baseUrl already applied), each optionally containing a
|
|
61
|
+
* single star wildcard — e.g. pattern `@swarmdo/[star]` → target
|
|
62
|
+
* `v3/@swarmdo/[star]/src`, where `[star]` captures the remaining spec.
|
|
55
63
|
*/
|
|
56
|
-
export
|
|
57
|
-
|
|
64
|
+
export interface ImportAlias {
|
|
65
|
+
pattern: string;
|
|
66
|
+
target: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a spec to a repo-relative file in `fileSet`, or null. Relative specs
|
|
70
|
+
* (`.`/`..`) resolve against the importing file's dir. Bare specifiers resolve
|
|
71
|
+
* only if they match a tsconfig-`paths`/workspace `alias` — otherwise they're
|
|
72
|
+
* external (packages, `node:`) → null. Tries common extensions and `/index.*`,
|
|
73
|
+
* and rewrites a `.js` spec to its `.ts` sibling (TS ESM convention). Pure.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveImport(fromFile: string, spec: string, fileSet: Set<string>, aliases?: ImportAlias[]): string | null;
|
|
76
|
+
/** Build an index from already-read files. `aliases` resolve bare-specifier internal imports. Pure. */
|
|
58
77
|
export declare function buildIndex(files: Array<{
|
|
59
78
|
file: string;
|
|
60
79
|
source: string;
|
|
61
|
-
}
|
|
80
|
+
}>, aliases?: ImportAlias[]): CodeIndex;
|
|
62
81
|
export interface QueryOptions {
|
|
63
82
|
/** Substring/case-insensitive match instead of exact. */
|
|
64
83
|
fuzzy?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegraph.d.ts","sourceRoot":"","sources":["../../../src/codegraph/codegraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,OAAO,GACP,WAAW,GACX,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,8FAA8F;AAC9F,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"codegraph.d.ts","sourceRoot":"","sources":["../../../src/codegraph/codegraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,OAAO,GACP,WAAW,GACX,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EA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