swarmdo 1.13.0 → 1.15.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.
@@ -515,7 +515,7 @@ function getCostFromStdin() {
515
515
  // misses, the displayed version is meaningful (matches what the user
516
516
  // installed), not a stale hard-coded string.
517
517
  function getPkgVersion() {
518
- let ver = '1.13.0';
518
+ let ver = '1.15.0';
519
519
  try {
520
520
  const home = os.homedir();
521
521
  const pkgPaths = [
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![swarmdo](swarmdo/assets/brand/logo-full.svg)](https://swarmdo.com)
4
4
 
5
- [![npm version (swarmdo)](https://img.shields.io/badge/npx%20swarmdo-v1.13.0-cb3837?style=for-the-badge&logo=npm&logoColor=white)](https://github.com/SwarmDo/swarmdo/releases)
5
+ [![npm version (swarmdo)](https://img.shields.io/badge/npx%20swarmdo-v1.15.0-cb3837?style=for-the-badge&logo=npm&logoColor=white)](https://github.com/SwarmDo/swarmdo/releases)
6
6
  [![MIT License](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge)](https://github.com/SwarmDo/swarmdo/blob/main/LICENSE)
7
7
  [![Website](https://img.shields.io/badge/swarmdo.com-e2a33c?style=for-the-badge&logoColor=black)](https://swarmdo.com)
8
8
  [![Star on GitHub](https://img.shields.io/github/stars/SwarmDo/swarmdo?style=for-the-badge&logo=github&color=gold)](https://github.com/SwarmDo/swarmdo)
@@ -282,6 +282,8 @@ The recent release train added a full day-to-day operations layer around the swa
282
282
  | `swarmdo pack` | **Bundle a repo into one AI-context blob** — walk the tree (respects `.gitignore` + glob `--include`/`--exclude`, skips binaries/node_modules), emit markdown/xml/json/plain with a directory tree and per-file + total token estimates. `swarmdo pack --tokens` for a budget breakdown; `--redact` masks secrets first. Deterministic |
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
+ | `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 |
285
287
  | `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) |
286
288
  | 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 |
287
289
  | `swarmdo changelog` (alias `notes`) | **Release notes from conventional commits** — `--out NOTES.md` feeds `gh release create --notes-file` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swarmdo",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "description": "Swarmdo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -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,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,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,118 @@
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
+ const fuzz = typeof ctx.flags.fuzz === 'string' ? parseInt(ctx.flags.fuzz, 10) : 2;
36
+ // Read the patch: a file arg, or stdin.
37
+ let patchText;
38
+ if (ctx.args[0]) {
39
+ try {
40
+ patchText = fs.readFileSync(path.resolve(root, ctx.args[0]), 'utf8');
41
+ }
42
+ catch {
43
+ output.printError(`could not read patch file ${ctx.args[0]}`);
44
+ return { success: false, exitCode: 1 };
45
+ }
46
+ }
47
+ else {
48
+ if (process.stdin.isTTY) {
49
+ output.writeln(output.error('Usage: swarmdo apply <patch-file> OR <patch> | swarmdo apply'));
50
+ return { success: false, exitCode: 1 };
51
+ }
52
+ patchText = await readStdin();
53
+ }
54
+ const patches = parsePatch(patchText);
55
+ if (patches.length === 0) {
56
+ output.printError('no file patches found — is this a unified diff?');
57
+ return { success: false, exitCode: 1 };
58
+ }
59
+ let totalApplied = 0;
60
+ let totalRejected = 0;
61
+ const writes = [];
62
+ for (const fp of patches) {
63
+ const file = targetFile(root, fp);
64
+ const rel = path.relative(root, file);
65
+ let source;
66
+ try {
67
+ source = fs.readFileSync(file, 'utf8');
68
+ }
69
+ catch {
70
+ // New-file patch (--- /dev/null): treat missing source as empty.
71
+ if (fp.oldPath === '/dev/null' || !fs.existsSync(file))
72
+ source = '';
73
+ else {
74
+ output.printError(`cannot read ${rel}`);
75
+ totalRejected += fp.hunks.length;
76
+ continue;
77
+ }
78
+ }
79
+ const res = applyPatch(source, fp, { fuzz });
80
+ const applied = res.hunks.filter((h) => h.applied).length;
81
+ const rejected = res.hunks.length - applied;
82
+ totalApplied += applied;
83
+ totalRejected += rejected;
84
+ const fuzzy = res.hunks.filter((h) => h.applied && (h.fuzzUsed ?? 0) > 0).length;
85
+ const tag = rejected === 0 ? output.dim('ok') : output.bold(`${rejected} rejected`);
86
+ output.writeln(`${rel} ${applied}/${res.hunks.length} hunks${fuzzy ? output.dim(` (${fuzzy} fuzzy)`) : ''} ${tag}`);
87
+ if (rejected === 0 || partial) {
88
+ if (res.result !== source)
89
+ writes.push({ file, content: res.result });
90
+ }
91
+ }
92
+ if (!dryRun) {
93
+ for (const w of writes)
94
+ fs.writeFileSync(w.file, w.content);
95
+ }
96
+ const verb = dryRun ? 'would apply' : 'applied';
97
+ output.writeln(output.dim(`${verb} ${totalApplied} hunks, ${totalRejected} rejected${dryRun ? ' (dry run)' : ''}`));
98
+ // Exit 1 if anything was rejected — a CI/agent can branch on it.
99
+ const code = totalRejected > 0 ? 1 : 0;
100
+ return { success: code === 0, exitCode: code };
101
+ }
102
+ export const applyCommand = {
103
+ name: 'apply',
104
+ description: 'Apply a unified diff to the working tree with fuzzy context matching — a forgiving `git apply` for agent-produced patches',
105
+ options: [
106
+ { name: 'dry-run', description: 'report what would apply/reject without writing', type: 'boolean' },
107
+ { name: 'fuzz', description: 'max context lines to drop when matching a drifted hunk (default 2)', type: 'string' },
108
+ { name: 'partial', description: 'write files even when some of their hunks are rejected', type: 'boolean' },
109
+ ],
110
+ examples: [
111
+ { command: 'swarmdo apply changes.patch', description: 'Apply a patch file' },
112
+ { command: 'cat out.diff | swarmdo apply --dry-run', description: 'Preview a patch from stdin' },
113
+ { command: 'swarmdo apply --fuzz 3 changes.patch', description: 'Tolerate more context drift' },
114
+ ],
115
+ action: run,
116
+ };
117
+ export default applyCommand;
118
+ //# sourceMappingURL=apply.js.map
@@ -13,6 +13,7 @@
13
13
  import { spawnSync } from 'node:child_process';
14
14
  import { output } from '../output.js';
15
15
  import { compactOutput, formatSavings } from '../compact/compact.js';
16
+ import { writeStdout } from '../util/stdout.js';
16
17
  /**
17
18
  * Read all of stdin as UTF-8. A stream read (not readFileSync(0)) — the
18
19
  * synchronous form throws EAGAIN on a non-blocking pipe on macOS/Linux.
@@ -61,7 +62,7 @@ async function run(ctx) {
61
62
  }
62
63
  const combined = (r.stdout || '') + (r.stderr || '');
63
64
  const { text, stats } = compactOutput(combined, opts);
64
- process.stdout.write(text);
65
+ await writeStdout(text);
65
66
  if (!quiet)
66
67
  process.stderr.write(formatSavings(stats) + '\n');
67
68
  // Propagate the wrapped command's exit code verbatim.
@@ -81,7 +82,7 @@ async function run(ctx) {
81
82
  else if (!quiet) {
82
83
  process.stderr.write(formatSavings(stats) + '\n');
83
84
  }
84
- process.stdout.write(text);
85
+ await writeStdout(text);
85
86
  return { success: true, exitCode: 0 };
86
87
  }
87
88
  export const compactCommand = {
@@ -35,6 +35,12 @@ const commandLoaders = {
35
35
  // GPL/unknown licenses in the tree, fail CI on a forbidden one.
36
36
  license: () => import('./license.js'),
37
37
  licenses: () => import('./license.js'), // alias via loader key
38
+ // Software Bill of Materials from the lockfile (syft/cyclonedx demand) —
39
+ // CycloneDX/SPDX JSON; completes the env/license/sbom supply-chain trio.
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'),
38
44
  // Queryable exported-symbol index (codegraph demand) — where things are
39
45
  // defined without grep+read round-trips.
40
46
  codegraph: () => import('./codegraph.js'),
@@ -268,7 +274,7 @@ export async function getCommandsByCategory() {
268
274
  // three slots from 'statusline' onward (completionsCmd received the
269
275
  // statusline module, analyzeCmd received completions, …), scrambling the
270
276
  // categorized help. Every load now has a named slot.
271
- 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,] = await Promise.all([
277
+ 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,] = await Promise.all([
272
278
  loadCommand('daemon'), loadCommand('doctor'), loadCommand('embeddings'), loadCommand('neural'),
273
279
  loadCommand('performance'), loadCommand('security'), loadCommand('swarmvector'), loadCommand('hive-mind'),
274
280
  loadCommand('config'), loadCommand('statusline'), loadCommand('compress'), loadCommand('efficiency'),
@@ -276,7 +282,7 @@ export async function getCommandsByCategory() {
276
282
  loadCommand('analyze'), loadCommand('route'), loadCommand('progress'), loadCommand('providers'),
277
283
  loadCommand('plugins'), loadCommand('deployment'), loadCommand('claims'), loadCommand('issues'),
278
284
  loadCommand('update'), loadCommand('process'), loadCommand('guidance'), loadCommand('appliance'),
279
- loadCommand('cleanup'), loadCommand('autopilot'), loadCommand('demo'), loadCommand('usage'), loadCommand('repair'), loadCommand('hud'), loadCommand('compact'), loadCommand('codegraph'), loadCommand('redact'), loadCommand('pack'), loadCommand('env'), loadCommand('license'),
285
+ 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'),
280
286
  ]);
281
287
  return {
282
288
  primary: [
@@ -292,7 +298,7 @@ export async function getCommandsByCategory() {
292
298
  utility: [
293
299
  configCmd, doctorCmd, daemonCmd, completionsCmd,
294
300
  migrateCmd, workflowCmd, demoCmd,
295
- statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, envCmd, licenseCmd, efficiencyCmd,
301
+ statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, envCmd, licenseCmd, sbomCmd, applyCmd, efficiencyCmd,
296
302
  ].filter(Boolean),
297
303
  analysis: [
298
304
  analyzeCmd, routeCmd, progressCmd, usageCmd, hudCmd, codegraphCmd,
@@ -17,6 +17,7 @@ import * as path from 'node:path';
17
17
  import { output } from '../output.js';
18
18
  import { packFiles, makeIgnoreMatcher } from '../pack/pack.js';
19
19
  import { redactText } from '../redact/redact.js';
20
+ import { writeStdout } from '../util/stdout.js';
20
21
  const SKIP_DIRS = new Set([
21
22
  'node_modules', '.git', '.swarm', 'dist', 'dist-standalone', 'build',
22
23
  'coverage', '.next', '.turbo', 'out', 'vendor', '.cache',
@@ -151,8 +152,7 @@ async function run(ctx) {
151
152
  output.printSuccess(`packed ${stats.files} files (~${stats.tokens} tokens) → ${outFile}`);
152
153
  }
153
154
  else {
154
- process.stdout.write(bundle);
155
- if (!process.stdout.isTTY) { /* piped: keep stdout clean */ }
155
+ await writeStdout(bundle);
156
156
  process.stderr.write(output.dim(`packed ${stats.files} files (~${stats.tokens} tokens)\n`));
157
157
  }
158
158
  return { success: true, exitCode: 0 };
@@ -15,6 +15,7 @@
15
15
  import { spawnSync } from 'node:child_process';
16
16
  import { output } from '../output.js';
17
17
  import { redactText, scanText, formatFindingsSummary } from '../redact/redact.js';
18
+ import { writeStdout } from '../util/stdout.js';
18
19
  function readStdin() {
19
20
  return new Promise((resolve) => {
20
21
  const chunks = [];
@@ -93,7 +94,7 @@ async function run(ctx) {
93
94
  }
94
95
  // Redact mode: rewrite and emit.
95
96
  const { output: redacted, findings } = redactText(input, opts);
96
- process.stdout.write(redacted);
97
+ await writeStdout(redacted);
97
98
  if (asJson) {
98
99
  process.stderr.write(JSON.stringify({ count: findings.length, findings }, null, 2) + '\n');
99
100
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `swarmdo sbom` — emit a Software Bill of Materials from the npm lockfile.
3
+ *
4
+ * swarmdo sbom # CycloneDX JSON → stdout
5
+ * swarmdo sbom -f spdx -o sbom.json # SPDX 2.3 JSON → file
6
+ * swarmdo sbom --production # exclude dev-only dependencies
7
+ *
8
+ * Completes the supply-chain trio (env / license / sbom). Engine
9
+ * (../sbom/sbom.ts) is pure + tested; this reads package-lock.json.
10
+ */
11
+ import type { Command } from '../types.js';
12
+ export declare const sbomCommand: Command;
13
+ export default sbomCommand;
14
+ //# sourceMappingURL=sbom.d.ts.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * `swarmdo sbom` — emit a Software Bill of Materials from the npm lockfile.
3
+ *
4
+ * swarmdo sbom # CycloneDX JSON → stdout
5
+ * swarmdo sbom -f spdx -o sbom.json # SPDX 2.3 JSON → file
6
+ * swarmdo sbom --production # exclude dev-only dependencies
7
+ *
8
+ * Completes the supply-chain trio (env / license / sbom). Engine
9
+ * (../sbom/sbom.ts) is pure + tested; this reads package-lock.json.
10
+ */
11
+ import * as fs from 'node:fs';
12
+ import * as path from 'node:path';
13
+ import { output } from '../output.js';
14
+ import { componentsFromNpmLock, buildSbom } from '../sbom/sbom.js';
15
+ import { writeStdout } from '../util/stdout.js';
16
+ async function run(ctx) {
17
+ const repoRoot = ctx.cwd || process.cwd();
18
+ const lockPath = path.resolve(repoRoot, ctx.args[0] ?? (typeof ctx.flags.lockfile === 'string' ? ctx.flags.lockfile : 'package-lock.json'));
19
+ let lock;
20
+ try {
21
+ lock = JSON.parse(fs.readFileSync(lockPath, 'utf8'));
22
+ }
23
+ catch {
24
+ output.printError(`could not read a JSON lockfile at ${path.relative(repoRoot, lockPath) || lockPath} (npm package-lock.json; pnpm/yaml unsupported)`);
25
+ return { success: false, exitCode: 1 };
26
+ }
27
+ if (!lock.packages) {
28
+ output.printError('lockfile has no `packages` map — needs npm lockfileVersion 2 or 3');
29
+ return { success: false, exitCode: 1 };
30
+ }
31
+ // NB: use --spec, not --format — the global --format flag is choices-validated
32
+ // to text|json|table and rejects 'spdx'/'cyclonedx' before this command runs.
33
+ const raw = typeof ctx.flags.spec === 'string' ? ctx.flags.spec : 'cyclonedx';
34
+ if (raw !== 'cyclonedx' && raw !== 'spdx') {
35
+ output.printError(`unknown --spec '${raw}' (use cyclonedx|spdx)`);
36
+ return { success: false, exitCode: 1 };
37
+ }
38
+ const format = raw;
39
+ const components = componentsFromNpmLock(lock, {
40
+ productionOnly: ctx.flags.production === true,
41
+ });
42
+ // Prefer the lockfile's own project name/version; fall back to the repo dir.
43
+ const meta = { name: lock.name ?? path.basename(repoRoot), version: lock.version ?? '0.0.0' };
44
+ const bom = buildSbom(components, meta, format);
45
+ const serialized = JSON.stringify(bom, null, 2);
46
+ const outFile = (typeof ctx.flags.output === 'string' && ctx.flags.output) || (typeof ctx.flags.o === 'string' && ctx.flags.o);
47
+ if (outFile) {
48
+ fs.writeFileSync(path.resolve(repoRoot, outFile), serialized + '\n');
49
+ output.printSuccess(`${format} SBOM: ${components.length} components → ${outFile}`);
50
+ }
51
+ else {
52
+ await writeStdout(serialized + '\n');
53
+ process.stderr.write(output.dim(`${format} SBOM: ${components.length} components\n`));
54
+ }
55
+ return { success: true, exitCode: 0 };
56
+ }
57
+ export const sbomCommand = {
58
+ name: 'sbom',
59
+ description: 'Generate a Software Bill of Materials (CycloneDX or SPDX JSON) from the npm lockfile',
60
+ options: [
61
+ { name: 'spec', description: 'BOM spec: cyclonedx (default) or spdx', type: 'string' },
62
+ { name: 'output', short: 'o', description: 'write the SBOM to a file instead of stdout', type: 'string' },
63
+ { name: 'lockfile', description: 'path to the lockfile (default package-lock.json)', type: 'string' },
64
+ { name: 'production', description: 'exclude dev-only dependencies', type: 'boolean' },
65
+ ],
66
+ examples: [
67
+ { command: 'swarmdo sbom -o sbom.json', description: 'Write a CycloneDX SBOM' },
68
+ { command: 'swarmdo sbom --spec spdx --production', description: 'SPDX SBOM, production deps only' },
69
+ ],
70
+ action: run,
71
+ };
72
+ export default sbomCommand;
73
+ //# sourceMappingURL=sbom.js.map
@@ -23,6 +23,7 @@ import { codegraphTools } from './mcp-tools/codegraph-tools.js';
23
23
  import { redactTools } from './mcp-tools/redact-tools.js';
24
24
  import { envTools } from './mcp-tools/env-tools.js';
25
25
  import { licenseTools } from './mcp-tools/license-tools.js';
26
+ import { applyTools } from './mcp-tools/apply-tools.js';
26
27
  import { progressTools } from './mcp-tools/progress-tools.js';
27
28
  import { embeddingsTools } from './mcp-tools/embeddings-tools.js';
28
29
  import { claimsTools } from './mcp-tools/claims-tools.js';
@@ -110,6 +111,7 @@ const TOOL_GROUPS = {
110
111
  redact: () => redactTools,
111
112
  env: () => envTools,
112
113
  license: () => licenseTools,
114
+ apply: () => applyTools,
113
115
  progress: () => progressTools,
114
116
  embeddings: () => embeddingsTools,
115
117
  claims: () => claimsTools,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Apply MCP Tool
3
+ *
4
+ * Let an agent apply its own unified diff to a piece of source with fuzzy
5
+ * context matching — landing hunks even when line numbers drift — and get back
6
+ * the patched text plus exactly which hunks were rejected. String-in/string-out
7
+ * and deterministic; shares the pure engine in ../apply/apply.ts with the CLI.
8
+ */
9
+ import type { MCPTool } from './types.js';
10
+ export declare const applyTools: MCPTool[];
11
+ //# sourceMappingURL=apply-tools.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Apply MCP Tool
3
+ *
4
+ * Let an agent apply its own unified diff to a piece of source with fuzzy
5
+ * context matching — landing hunks even when line numbers drift — and get back
6
+ * the patched text plus exactly which hunks were rejected. String-in/string-out
7
+ * and deterministic; shares the pure engine in ../apply/apply.ts with the CLI.
8
+ */
9
+ import { parsePatch, applyPatch } from '../apply/apply.js';
10
+ const applyPatchTool = {
11
+ name: 'apply_patch',
12
+ description: 'Apply a unified diff to a source string with fuzzy context matching (a forgiving `git apply`). Returns the patched text and per-hunk results — use this when a diff you produced might have drifted line numbers or slightly-off context, instead of hand-editing. Deterministic; pass the file content and the diff for a single file.',
13
+ category: 'apply',
14
+ tags: ['patch', 'diff', 'apply', 'edit'],
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ source: { type: 'string', description: 'the current file content the diff applies to' },
19
+ patch: { type: 'string', description: 'a unified diff (one file); a/ b/ prefixes are tolerated' },
20
+ fuzz: { type: 'number', description: 'max context lines to drop when matching a drifted hunk (default 2)', default: 2 },
21
+ },
22
+ required: ['source', 'patch'],
23
+ },
24
+ handler: async (params) => {
25
+ if (typeof params.source !== 'string')
26
+ return { error: true, message: 'source (string) is required' };
27
+ if (typeof params.patch !== 'string')
28
+ return { error: true, message: 'patch (string) is required' };
29
+ const patches = parsePatch(params.patch);
30
+ if (patches.length === 0)
31
+ return { error: true, message: 'no file patch found — is this a unified diff?' };
32
+ const fuzz = typeof params.fuzz === 'number' ? params.fuzz : 2;
33
+ const res = applyPatch(params.source, patches[0], { fuzz });
34
+ return {
35
+ ok: res.ok,
36
+ result: res.result,
37
+ applied: res.hunks.filter((h) => h.applied).length,
38
+ rejected: res.hunks.filter((h) => !h.applied).length,
39
+ hunks: res.hunks.map((h) => ({ applied: h.applied, at: h.at, fuzzUsed: h.fuzzUsed, oldStart: h.hunk.oldStart })),
40
+ };
41
+ },
42
+ };
43
+ export const applyTools = [applyPatchTool];
44
+ //# sourceMappingURL=apply-tools.js.map
@@ -19,6 +19,7 @@ export { codegraphTools } from './codegraph-tools.js';
19
19
  export { redactTools } from './redact-tools.js';
20
20
  export { envTools } from './env-tools.js';
21
21
  export { licenseTools } from './license-tools.js';
22
+ export { applyTools } from './apply-tools.js';
22
23
  export { progressTools } from './progress-tools.js';
23
24
  export { transferTools } from './transfer-tools.js';
24
25
  export { securityTools } from './security-tools.js';
@@ -18,6 +18,7 @@ export { codegraphTools } from './codegraph-tools.js';
18
18
  export { redactTools } from './redact-tools.js';
19
19
  export { envTools } from './env-tools.js';
20
20
  export { licenseTools } from './license-tools.js';
21
+ export { applyTools } from './apply-tools.js';
21
22
  export { progressTools } from './progress-tools.js';
22
23
  export { transferTools } from './transfer-tools.js';
23
24
  export { securityTools } from './security-tools.js';
@@ -25,6 +25,7 @@ const LEAN_GROUPS = [
25
25
  'codegraph', // codegraph_query / file / index — "where is X defined?"
26
26
  'redact', // redact_text / redact_scan — secret guard on the data path
27
27
  'env', // env_check — env-var drift (missing/unused/undocumented)
28
+ 'apply', // apply_patch — fuzzy unified-diff applier for agent edits
28
29
  ];
29
30
  /** Balanced = lean + orchestration/session/system the average user reaches for. */
30
31
  const BALANCED_EXTRA = [
@@ -0,0 +1,64 @@
1
+ /**
2
+ * sbom.ts — generate a Software Bill of Materials from an npm lockfile.
3
+ *
4
+ * Completes the supply-chain trio with `env` (config drift) and `license`
5
+ * (license policy): `sbom` emits the standardized dependency manifest —
6
+ * CycloneDX or SPDX JSON — that compliance, vuln scanners, and regulators
7
+ * (US EO 14028, EU CRA) consume. Distinct from `pack` (repo→AI-context prose)
8
+ * and `license` (policy gate): this is a machine artifact, not a check.
9
+ *
10
+ * Pure + deterministic (lockfile object → BOM object, no timestamps/IO), so
11
+ * output is golden-testable. The file read lives in ../commands/sbom.ts.
12
+ */
13
+ export interface Component {
14
+ name: string;
15
+ version: string;
16
+ purl: string;
17
+ license?: string;
18
+ /** hex-encoded integrity, with its algorithm */
19
+ hash?: {
20
+ alg: string;
21
+ content: string;
22
+ };
23
+ dev?: boolean;
24
+ }
25
+ interface NpmLockEntry {
26
+ version?: string;
27
+ resolved?: string;
28
+ integrity?: string;
29
+ license?: unknown;
30
+ dev?: boolean;
31
+ optional?: boolean;
32
+ }
33
+ interface NpmLock {
34
+ name?: string;
35
+ version?: string;
36
+ lockfileVersion?: number;
37
+ packages?: Record<string, NpmLockEntry>;
38
+ }
39
+ /** Package URL for an npm component. Scope `@` is percent-encoded per the purl spec. */
40
+ export declare function purlFor(name: string, version: string): string;
41
+ /** Convert an SRI integrity string (`sha512-<base64>`) to `{alg, content(hex)}`. Deterministic. */
42
+ export declare function integrityToHash(integrity: string): {
43
+ alg: string;
44
+ content: string;
45
+ } | undefined;
46
+ export interface ComponentOptions {
47
+ /** exclude dev-only dependencies */
48
+ productionOnly?: boolean;
49
+ }
50
+ /** Extract components from a parsed npm lockfile (v2/v3 `packages` map). Pure. */
51
+ export declare function componentsFromNpmLock(lock: NpmLock, opts?: ComponentOptions): Component[];
52
+ export interface BomMeta {
53
+ name: string;
54
+ version: string;
55
+ }
56
+ /** Build a CycloneDX 1.5 BOM object (no timestamp → deterministic). Pure. */
57
+ export declare function buildCycloneDX(components: Component[], meta: BomMeta): Record<string, unknown>;
58
+ /** Build a minimal SPDX 2.3 JSON document (no created timestamp → deterministic). Pure. */
59
+ export declare function buildSpdx(components: Component[], meta: BomMeta): Record<string, unknown>;
60
+ export type SbomFormat = 'cyclonedx' | 'spdx';
61
+ /** Build a BOM in the requested format. Pure. */
62
+ export declare function buildSbom(components: Component[], meta: BomMeta, format: SbomFormat): Record<string, unknown>;
63
+ export {};
64
+ //# sourceMappingURL=sbom.d.ts.map
@@ -0,0 +1,130 @@
1
+ /**
2
+ * sbom.ts — generate a Software Bill of Materials from an npm lockfile.
3
+ *
4
+ * Completes the supply-chain trio with `env` (config drift) and `license`
5
+ * (license policy): `sbom` emits the standardized dependency manifest —
6
+ * CycloneDX or SPDX JSON — that compliance, vuln scanners, and regulators
7
+ * (US EO 14028, EU CRA) consume. Distinct from `pack` (repo→AI-context prose)
8
+ * and `license` (policy gate): this is a machine artifact, not a check.
9
+ *
10
+ * Pure + deterministic (lockfile object → BOM object, no timestamps/IO), so
11
+ * output is golden-testable. The file read lives in ../commands/sbom.ts.
12
+ */
13
+ /** Derive the package name from a lockfile `packages` key (last node_modules segment, scope-aware). */
14
+ function nameFromKey(key) {
15
+ const idx = key.lastIndexOf('node_modules/');
16
+ const tail = idx >= 0 ? key.slice(idx + 'node_modules/'.length) : key;
17
+ return tail; // already includes @scope/name because we split on the LAST node_modules/
18
+ }
19
+ /** Package URL for an npm component. Scope `@` is percent-encoded per the purl spec. */
20
+ export function purlFor(name, version) {
21
+ const enc = name.startsWith('@') ? '%40' + name.slice(1) : name;
22
+ return `pkg:npm/${enc}@${version}`;
23
+ }
24
+ /** Convert an SRI integrity string (`sha512-<base64>`) to `{alg, content(hex)}`. Deterministic. */
25
+ export function integrityToHash(integrity) {
26
+ const m = integrity.match(/^(sha\d+)-(.+)$/);
27
+ if (!m)
28
+ return undefined;
29
+ const algMap = { sha1: 'SHA-1', sha256: 'SHA-256', sha384: 'SHA-384', sha512: 'SHA-512' };
30
+ const alg = algMap[m[1]];
31
+ if (!alg)
32
+ return undefined;
33
+ let hex;
34
+ try {
35
+ // base64 → hex, dependency-free and deterministic
36
+ hex = Buffer.from(m[2], 'base64').toString('hex');
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ return { alg, content: hex };
42
+ }
43
+ function licenseOf(entry) {
44
+ const l = entry.license;
45
+ if (typeof l === 'string' && l.trim())
46
+ return l.trim();
47
+ if (l && typeof l === 'object' && typeof l.type === 'string')
48
+ return l.type;
49
+ return undefined;
50
+ }
51
+ /** Extract components from a parsed npm lockfile (v2/v3 `packages` map). Pure. */
52
+ export function componentsFromNpmLock(lock, opts = {}) {
53
+ const packages = lock.packages ?? {};
54
+ const out = [];
55
+ const seen = new Set();
56
+ for (const [key, entry] of Object.entries(packages)) {
57
+ if (!key)
58
+ continue; // the root project entry
59
+ if (!key.includes('node_modules/'))
60
+ continue;
61
+ if (opts.productionOnly && entry.dev)
62
+ continue;
63
+ const name = nameFromKey(key);
64
+ const version = entry.version ?? '0.0.0';
65
+ const id = `${name}@${version}`;
66
+ if (seen.has(id))
67
+ continue;
68
+ seen.add(id);
69
+ const comp = { name, version, purl: purlFor(name, version) };
70
+ const license = licenseOf(entry);
71
+ if (license)
72
+ comp.license = license;
73
+ if (entry.integrity) {
74
+ const h = integrityToHash(entry.integrity);
75
+ if (h)
76
+ comp.hash = h;
77
+ }
78
+ if (entry.dev)
79
+ comp.dev = true;
80
+ out.push(comp);
81
+ }
82
+ out.sort((a, b) => (a.name === b.name ? a.version.localeCompare(b.version) : a.name.localeCompare(b.name)));
83
+ return out;
84
+ }
85
+ /** Build a CycloneDX 1.5 BOM object (no timestamp → deterministic). Pure. */
86
+ export function buildCycloneDX(components, meta) {
87
+ return {
88
+ bomFormat: 'CycloneDX',
89
+ specVersion: '1.5',
90
+ version: 1,
91
+ metadata: {
92
+ component: { type: 'application', name: meta.name, version: meta.version },
93
+ },
94
+ components: components.map((c) => {
95
+ const comp = { type: 'library', name: c.name, version: c.version, purl: c.purl };
96
+ if (c.hash)
97
+ comp.hashes = [{ alg: c.hash.alg, content: c.hash.content }];
98
+ if (c.license)
99
+ comp.licenses = [{ license: { id: c.license } }];
100
+ return comp;
101
+ }),
102
+ };
103
+ }
104
+ /** Build a minimal SPDX 2.3 JSON document (no created timestamp → deterministic). Pure. */
105
+ export function buildSpdx(components, meta) {
106
+ const safe = (s) => s.replace(/[^A-Za-z0-9.-]/g, '-');
107
+ return {
108
+ spdxVersion: 'SPDX-2.3',
109
+ dataLicense: 'CC0-1.0',
110
+ SPDXID: 'SPDXRef-DOCUMENT',
111
+ name: meta.name,
112
+ documentNamespace: `https://swarmdo/spdx/${safe(meta.name)}-${meta.version}`,
113
+ packages: [
114
+ { SPDXID: 'SPDXRef-Package-root', name: meta.name, versionInfo: meta.version, downloadLocation: 'NOASSERTION' },
115
+ ...components.map((c) => ({
116
+ SPDXID: `SPDXRef-Package-${safe(c.name)}-${safe(c.version)}`,
117
+ name: c.name,
118
+ versionInfo: c.version,
119
+ downloadLocation: 'NOASSERTION',
120
+ licenseConcluded: c.license ?? 'NOASSERTION',
121
+ externalRefs: [{ referenceCategory: 'PACKAGE-MANAGER', referenceType: 'purl', referenceLocator: c.purl }],
122
+ })),
123
+ ],
124
+ };
125
+ }
126
+ /** Build a BOM in the requested format. Pure. */
127
+ export function buildSbom(components, meta, format) {
128
+ return format === 'spdx' ? buildSpdx(components, meta) : buildCycloneDX(components, meta);
129
+ }
130
+ //# sourceMappingURL=sbom.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * writeStdout — write to stdout and RESOLVE ONLY WHEN THE CHUNK IS FLUSHED.
3
+ *
4
+ * process.stdout on a pipe is asynchronous: write() buffers in JS and returns
5
+ * immediately. If the command then returns and the CLI harness calls
6
+ * process.exit(), any unflushed bytes are discarded — large piped output
7
+ * (`swarmdo sbom | …`, `pack`, `compact`, `redact`) truncates at the ~64 KiB
8
+ * pipe buffer. Awaiting the write callback guarantees the data reached the OS
9
+ * before we hand control back. For a TTY (synchronous) this is a no-op await.
10
+ */
11
+ export declare function writeStdout(data: string): Promise<void>;
12
+ //# sourceMappingURL=stdout.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * writeStdout — write to stdout and RESOLVE ONLY WHEN THE CHUNK IS FLUSHED.
3
+ *
4
+ * process.stdout on a pipe is asynchronous: write() buffers in JS and returns
5
+ * immediately. If the command then returns and the CLI harness calls
6
+ * process.exit(), any unflushed bytes are discarded — large piped output
7
+ * (`swarmdo sbom | …`, `pack`, `compact`, `redact`) truncates at the ~64 KiB
8
+ * pipe buffer. Awaiting the write callback guarantees the data reached the OS
9
+ * before we hand control back. For a TTY (synchronous) this is a no-op await.
10
+ */
11
+ export function writeStdout(data) {
12
+ return new Promise((resolve, reject) => {
13
+ process.stdout.write(data, (err) => (err ? reject(err) : resolve()));
14
+ });
15
+ }
16
+ //# sourceMappingURL=stdout.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarmdo/cli",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "type": "module",
5
5
  "description": "Swarmdo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",