cohorte 3.0.0-dev.8 → 3.1.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/CHANGELOG.md +1637 -0
- package/README.md +322 -62
- package/bin/cli.js +213 -0
- package/bin/report.js +141 -0
- package/core/agents/cohorte-profile-reader.md +40 -0
- package/core/agents/cohorte-release.md +61 -0
- package/core/agents/cohorte-review.md +200 -0
- package/core/agents/implementer.template.md +154 -0
- package/core/commands/cohorte-align-ds.md +33 -0
- package/core/commands/cohorte-audit.md +74 -0
- package/core/commands/cohorte-brainstorm.md +73 -0
- package/core/commands/cohorte-build.md +248 -0
- package/core/commands/cohorte-doctor.md +135 -0
- package/core/commands/cohorte-fix.md +80 -0
- package/core/commands/cohorte-fleet.md +111 -0
- package/core/commands/cohorte-init-pipeline.md +30 -0
- package/core/commands/cohorte-intake.md +92 -0
- package/core/commands/cohorte-patch.md +118 -0
- package/core/commands/cohorte-refactor.md +122 -0
- package/core/commands/cohorte-retro.md +85 -0
- package/core/commands/cohorte-revert.md +104 -0
- package/core/commands/cohorte-review.md +239 -0
- package/core/commands/cohorte-ship.md +167 -0
- package/core/commands/cohorte-spec.md +114 -0
- package/core/commands/cohorte-update-pipeline.md +119 -0
- package/core/commands/cohorte-verify.md +106 -0
- package/core/hooks/gate.py +3236 -0
- package/core/templates/agent-handoff.md +34 -0
- package/core/templates/brainstorm-return.md +42 -0
- package/core/templates/decisions.template.md +42 -0
- package/core/templates/design-brief.md +37 -0
- package/core/templates/patch.template.md +95 -0
- package/core/templates/pr-body.md +25 -0
- package/core/templates/review-feedback.md +46 -0
- package/core/templates/spec.template.md +109 -0
- package/core/templates/steps/init-pipeline/01-detect-stack.md +53 -0
- package/core/templates/steps/init-pipeline/02-interview-gaps.md +78 -0
- package/core/templates/steps/init-pipeline/03-draft-profile.md +10 -0
- package/core/templates/steps/init-pipeline/04-write-render.md +95 -0
- package/core/templates/steps/init-pipeline/05-report.md +11 -0
- package/core/templates/steps/review-pr/01-pr-mode.md +54 -0
- package/core/workflows/audit.js +311 -0
- package/core/workflows/loop.js +692 -0
- package/core/workflows/refactor.js +398 -0
- package/core/workflows/review.js +505 -0
- package/install.ps1 +72 -0
- package/install.sh +69 -0
- package/lib/doctor.js +506 -0
- package/lib/install.js +386 -0
- package/lib/project.js +359 -0
- package/lib/render.js +121 -0
- package/lib/versions.js +145 -0
- package/lib/yaml.js +183 -0
- package/package.json +36 -17
- package/profile/PIPELINE.template.md +288 -0
- package/profile/SCHEMA.md +30 -0
- package/profile/cohorte.config.template.yaml +43 -0
- package/profile/schema/dead-agents.md +29 -0
- package/profile/schema/decisions.md +23 -0
- package/profile/schema/deferred.md +22 -0
- package/profile/schema/feature-diff.md +20 -0
- package/profile/schema/kanban.md +95 -0
- package/profile/schema/metrics.md +23 -0
- package/profile/schema/output-discipline.md +21 -0
- package/profile/schema/preflight.md +81 -0
- package/profile/schema/profile-block.md +103 -0
- package/profile/schema/project-kinds.md +89 -0
- package/profile/schema/readiness.md +17 -0
- package/profile/schema/reconcile.md +64 -0
- package/profile/schema/release-notes.md +29 -0
- package/profile/schema/rendering.md +48 -0
- package/profile/schema/retrieval.md +58 -0
- package/profile/schema/spec-status.md +79 -0
- package/profile/schema/specialization.md +41 -0
- package/profile/schema/verify.md +115 -0
- package/profile/schema/workflows.md +78 -0
- package/scripts/feature-diff.sh +118 -0
- package/scripts/kanban-move.sh +349 -0
- package/scripts/metrics/collect.mjs +542 -0
- package/scripts/metrics/prices.json +42 -0
- package/scripts/new-feature.sh.template +122 -0
- package/scripts/preflight.sh +114 -0
- package/scripts/remove-feature.sh.template +56 -0
- package/scripts/verify-run.sh +509 -0
- package/assets/manifest.json +0 -203
- package/assets/migrations/config/README.md +0 -12
- package/assets/migrations/state/0001_init.sql +0 -154
- package/assets/prompts/README.md +0 -11
- package/assets/prompts/agents/brainstormer.md +0 -3
- package/assets/prompts/agents/fixer.md +0 -7
- package/assets/prompts/agents/implementer.md +0 -12
- package/assets/prompts/agents/reviewer.md +0 -8
- package/assets/prompts/agents/security-reviewer.md +0 -7
- package/assets/prompts/agents/spec-author.md +0 -3
- package/assets/prompts/phases/build.md +0 -5
- package/assets/prompts/phases/review.md +0 -5
- package/assets/prompts/phases/test.md +0 -5
- package/assets/prompts/system.md +0 -11
- package/assets/schemas/agent-output.schema.json +0 -225
- package/assets/schemas/auth-status.schema.json +0 -87
- package/assets/schemas/command-result.schema.json +0 -192
- package/assets/schemas/commands.schema.json +0 -959
- package/assets/schemas/config.schema.json +0 -2281
- package/assets/schemas/doctor-report.schema.json +0 -104
- package/assets/schemas/events.schema.json +0 -8514
- package/assets/schemas/fake-script.schema.json +0 -549
- package/assets/schemas/inspect.schema.json +0 -3133
- package/assets/schemas/manifest.schema.json +0 -79
- package/assets/schemas/ownership.schema.json +0 -52
- package/assets/schemas/policy-verdict.schema.json +0 -282
- package/assets/schemas/project-model.schema.json +0 -783
- package/assets/schemas/project-status.schema.json +0 -217
- package/assets/schemas/reconcile-plan.schema.json +0 -154
- package/assets/schemas/run-diff.schema.json +0 -177
- package/assets/schemas/run-snapshot-manifest.schema.json +0 -2104
- package/assets/schemas/run-state.schema.json +0 -1755
- package/assets/schemas/runtime-capabilities.schema.json +0 -1545
- package/assets/schemas/sandbox-capabilities.schema.json +0 -116
- package/assets/schemas/skill.schema.json +0 -87
- package/assets/schemas/spec.schema.json +0 -202
- package/assets/schemas/tool-catalogue.schema.json +0 -655
- package/assets/schemas/trust-record.schema.json +0 -38
- package/assets/skills/README.md +0 -9
- package/assets/skills/inspect-surface.md +0 -4
- package/dist/agent-host.mjs +0 -2187
- package/dist/agent-host.mjs.map +0 -1
- package/dist/bundle-manifest.json +0 -128
- package/dist/chunks/__host-DgGPyco9.mjs +0 -18
- package/dist/chunks/__host-DgGPyco9.mjs.map +0 -1
- package/dist/chunks/align-ds-r_X_1aQ_.mjs +0 -93
- package/dist/chunks/align-ds-r_X_1aQ_.mjs.map +0 -1
- package/dist/chunks/approve-Cv135UqI.mjs +0 -19
- package/dist/chunks/approve-Cv135UqI.mjs.map +0 -1
- package/dist/chunks/audit-B4ZWQ_DI.mjs +0 -179
- package/dist/chunks/audit-B4ZWQ_DI.mjs.map +0 -1
- package/dist/chunks/auth-BT5oVp76.mjs +0 -132
- package/dist/chunks/auth-BT5oVp76.mjs.map +0 -1
- package/dist/chunks/auth-Dnlksuo5.mjs +0 -141
- package/dist/chunks/auth-Dnlksuo5.mjs.map +0 -1
- package/dist/chunks/brainstorm-SJwOIEif.mjs +0 -123
- package/dist/chunks/brainstorm-SJwOIEif.mjs.map +0 -1
- package/dist/chunks/build-C_-mbZfD.mjs +0 -19
- package/dist/chunks/build-C_-mbZfD.mjs.map +0 -1
- package/dist/chunks/cancel-KV_cpsqS.mjs +0 -15
- package/dist/chunks/cancel-KV_cpsqS.mjs.map +0 -1
- package/dist/chunks/canonical-C8UxeEmB.mjs +0 -57
- package/dist/chunks/canonical-C8UxeEmB.mjs.map +0 -1
- package/dist/chunks/catalogue-IaCJdfB8.mjs +0 -1549
- package/dist/chunks/catalogue-IaCJdfB8.mjs.map +0 -1
- package/dist/chunks/compose-DRKjQcn0.mjs +0 -7333
- package/dist/chunks/compose-DRKjQcn0.mjs.map +0 -1
- package/dist/chunks/config-Cqu5XQoP.mjs +0 -96
- package/dist/chunks/config-Cqu5XQoP.mjs.map +0 -1
- package/dist/chunks/contract-DjssDPpS.mjs +0 -335
- package/dist/chunks/contract-DjssDPpS.mjs.map +0 -1
- package/dist/chunks/contract-bQ9FJl4N.mjs +0 -123
- package/dist/chunks/contract-bQ9FJl4N.mjs.map +0 -1
- package/dist/chunks/deny-ClTxSvHJ.mjs +0 -15
- package/dist/chunks/deny-ClTxSvHJ.mjs.map +0 -1
- package/dist/chunks/diff-Qw0II0sj.mjs +0 -101
- package/dist/chunks/diff-Qw0II0sj.mjs.map +0 -1
- package/dist/chunks/discover-BZPolSZG.mjs +0 -21
- package/dist/chunks/discover-BZPolSZG.mjs.map +0 -1
- package/dist/chunks/doctor-DcDFPvQM.mjs +0 -222
- package/dist/chunks/doctor-DcDFPvQM.mjs.map +0 -1
- package/dist/chunks/fix-C9roGiQz.mjs +0 -82
- package/dist/chunks/fix-C9roGiQz.mjs.map +0 -1
- package/dist/chunks/fleet-yWHQY2ya.mjs +0 -297
- package/dist/chunks/fleet-yWHQY2ya.mjs.map +0 -1
- package/dist/chunks/gc-BBXlBF5w.mjs +0 -161
- package/dist/chunks/gc-BBXlBF5w.mjs.map +0 -1
- package/dist/chunks/init--FxxkrcT.mjs +0 -63
- package/dist/chunks/init--FxxkrcT.mjs.map +0 -1
- package/dist/chunks/inspect-Buby4cQD.mjs +0 -22
- package/dist/chunks/inspect-Buby4cQD.mjs.map +0 -1
- package/dist/chunks/intake-C1pesxCJ.mjs +0 -12
- package/dist/chunks/intake-C1pesxCJ.mjs.map +0 -1
- package/dist/chunks/logs-Giq5sUau.mjs +0 -25
- package/dist/chunks/logs-Giq5sUau.mjs.map +0 -1
- package/dist/chunks/loop-BWsUpyus.mjs +0 -212
- package/dist/chunks/loop-BWsUpyus.mjs.map +0 -1
- package/dist/chunks/migrate-DuYCAbE3.mjs +0 -33
- package/dist/chunks/migrate-DuYCAbE3.mjs.map +0 -1
- package/dist/chunks/models-Btp6X2YZ.mjs +0 -24
- package/dist/chunks/models-Btp6X2YZ.mjs.map +0 -1
- package/dist/chunks/obsidian-BHLkXx_H.mjs +0 -235
- package/dist/chunks/obsidian-BHLkXx_H.mjs.map +0 -1
- package/dist/chunks/patch-sAgVqjpx.mjs +0 -50
- package/dist/chunks/patch-sAgVqjpx.mjs.map +0 -1
- package/dist/chunks/pause-BASBfKLO.mjs +0 -16
- package/dist/chunks/pause-BASBfKLO.mjs.map +0 -1
- package/dist/chunks/policy-Du7WVBFX.mjs +0 -139
- package/dist/chunks/policy-Du7WVBFX.mjs.map +0 -1
- package/dist/chunks/providers-Dx78imKj.mjs +0 -19
- package/dist/chunks/providers-Dx78imKj.mjs.map +0 -1
- package/dist/chunks/reconcile-BHn66X3C.mjs +0 -50
- package/dist/chunks/reconcile-BHn66X3C.mjs.map +0 -1
- package/dist/chunks/refactor-DV3RfGjk.mjs +0 -153
- package/dist/chunks/refactor-DV3RfGjk.mjs.map +0 -1
- package/dist/chunks/render-DyZr5Lgi.mjs +0 -53
- package/dist/chunks/render-DyZr5Lgi.mjs.map +0 -1
- package/dist/chunks/resume-GJQRb2Eb.mjs +0 -15
- package/dist/chunks/resume-GJQRb2Eb.mjs.map +0 -1
- package/dist/chunks/retro-Dr-2RTNN.mjs +0 -78
- package/dist/chunks/retro-Dr-2RTNN.mjs.map +0 -1
- package/dist/chunks/retry-CLrUem1H.mjs +0 -15
- package/dist/chunks/retry-CLrUem1H.mjs.map +0 -1
- package/dist/chunks/review-ZsBqp3vZ.mjs +0 -35
- package/dist/chunks/review-ZsBqp3vZ.mjs.map +0 -1
- package/dist/chunks/run-BGabwbDL.mjs +0 -109
- package/dist/chunks/run-BGabwbDL.mjs.map +0 -1
- package/dist/chunks/run-tool-C3rAv4XF.mjs +0 -26
- package/dist/chunks/run-tool-C3rAv4XF.mjs.map +0 -1
- package/dist/chunks/scan-C5uDr7Yq.mjs +0 -167
- package/dist/chunks/scan-C5uDr7Yq.mjs.map +0 -1
- package/dist/chunks/schema-Bq9qtgsd.mjs +0 -583
- package/dist/chunks/schema-Bq9qtgsd.mjs.map +0 -1
- package/dist/chunks/send-BdnJ85Nz.mjs +0 -19
- package/dist/chunks/send-BdnJ85Nz.mjs.map +0 -1
- package/dist/chunks/ship-BizfUe62.mjs +0 -140
- package/dist/chunks/ship-BizfUe62.mjs.map +0 -1
- package/dist/chunks/shutdown-BM92Iyv2.mjs +0 -15
- package/dist/chunks/shutdown-BM92Iyv2.mjs.map +0 -1
- package/dist/chunks/skip-DZG5kpcH.mjs +0 -18
- package/dist/chunks/skip-DZG5kpcH.mjs.map +0 -1
- package/dist/chunks/spec-C2h3U64g.mjs +0 -65
- package/dist/chunks/spec-C2h3U64g.mjs.map +0 -1
- package/dist/chunks/spec-path-tptqR7W8.mjs +0 -10
- package/dist/chunks/spec-path-tptqR7W8.mjs.map +0 -1
- package/dist/chunks/src-Bfr1yzsn.mjs +0 -1689
- package/dist/chunks/src-Bfr1yzsn.mjs.map +0 -1
- package/dist/chunks/src-CPW2_Ons.mjs +0 -5487
- package/dist/chunks/src-CPW2_Ons.mjs.map +0 -1
- package/dist/chunks/src-Cu3TxNob.mjs +0 -783
- package/dist/chunks/src-Cu3TxNob.mjs.map +0 -1
- package/dist/chunks/src-DNsLSxgm.mjs +0 -928
- package/dist/chunks/src-DNsLSxgm.mjs.map +0 -1
- package/dist/chunks/src-DbS9gkJy.mjs +0 -117
- package/dist/chunks/src-DbS9gkJy.mjs.map +0 -1
- package/dist/chunks/src-yi5whv3n.mjs +0 -2118
- package/dist/chunks/src-yi5whv3n.mjs.map +0 -1
- package/dist/chunks/status-SMjiOMYy.mjs +0 -29
- package/dist/chunks/status-SMjiOMYy.mjs.map +0 -1
- package/dist/chunks/tail-BuhT-2PH.mjs +0 -25
- package/dist/chunks/tail-BuhT-2PH.mjs.map +0 -1
- package/dist/chunks/update-BXIppsbi.mjs +0 -16
- package/dist/chunks/update-BXIppsbi.mjs.map +0 -1
- package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs +0 -56
- package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs.map +0 -1
- package/dist/cli.mjs +0 -186
- package/dist/cli.mjs.map +0 -1
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { parse } from "yaml";
|
|
4
|
-
import { execFile } from "node:child_process";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
//#region src/commands/fleet/index.ts
|
|
7
|
-
const exec = promisify(execFile);
|
|
8
|
-
const exists = async (path) => {
|
|
9
|
-
try {
|
|
10
|
-
await access(path);
|
|
11
|
-
return true;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const specText = async (cwd, id) => {
|
|
17
|
-
for (const path of [join(cwd, "specs", `${id}.md`), join(cwd, ".cohorte", "specs", `${id}.yaml`)]) try {
|
|
18
|
-
return await readFile(path, "utf8");
|
|
19
|
-
} catch {}
|
|
20
|
-
};
|
|
21
|
-
const frozen = async (cwd, id) => {
|
|
22
|
-
const text = await specText(cwd, id);
|
|
23
|
-
return text !== void 0 && (/^status:\s*frozen\s*$/mu.test(text.slice(0, 1500)) || /status:\s*frozen/u.test(text));
|
|
24
|
-
};
|
|
25
|
-
const specSurfaces = async (cwd, id, known) => {
|
|
26
|
-
const text = await specText(cwd, id);
|
|
27
|
-
if (!text) return {
|
|
28
|
-
keys: [...known],
|
|
29
|
-
inferred: true
|
|
30
|
-
};
|
|
31
|
-
const listed = known.filter((key) => new RegExp(`(?:^|[\\s"'])${key.replaceAll("-", "[^A-Za-z0-9]?")}([\\s"']|$)`, "mu").test(text));
|
|
32
|
-
return {
|
|
33
|
-
keys: listed.length ? listed : [...known],
|
|
34
|
-
inferred: listed.length === 0
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const specDependencies = async (cwd, id, candidates) => {
|
|
38
|
-
const text = await specText(cwd, id);
|
|
39
|
-
if (!text) return [];
|
|
40
|
-
const declared = /* @__PURE__ */ new Set();
|
|
41
|
-
const matches = [...text.matchAll(/(?:^|\n)\s*(?:dependsOn|depends-on|depends on)\s*:\s*([^\n]+)/giu), ...text.matchAll(/(?:dependsOn|depends-on|depends on)\s+([^\n]+)/giu)];
|
|
42
|
-
for (const match of matches) for (const value of (match[1] ?? "").split(/[,\s[\]"']/u)) if (candidates.includes(value) && value !== id) declared.add(value);
|
|
43
|
-
return [...declared].sort();
|
|
44
|
-
};
|
|
45
|
-
function dependencyOrder(ids, dependencies) {
|
|
46
|
-
const result = [];
|
|
47
|
-
const visiting = /* @__PURE__ */ new Set();
|
|
48
|
-
const visited = /* @__PURE__ */ new Set();
|
|
49
|
-
const visit = (id) => {
|
|
50
|
-
if (visited.has(id)) return;
|
|
51
|
-
if (visiting.has(id)) return;
|
|
52
|
-
visiting.add(id);
|
|
53
|
-
for (const dependency of dependencies.get(id) ?? []) visit(dependency);
|
|
54
|
-
visiting.delete(id);
|
|
55
|
-
visited.add(id);
|
|
56
|
-
result.push(id);
|
|
57
|
-
};
|
|
58
|
-
for (const id of ids) visit(id);
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
const statusOf = async (cwd, id) => {
|
|
62
|
-
try {
|
|
63
|
-
const text = await readFile(join(cwd, "specs", `${id}.md`), "utf8");
|
|
64
|
-
return /^status:\s*(\S+)/mu.exec(text.slice(0, 1500))?.[1] ?? "unknown";
|
|
65
|
-
} catch {
|
|
66
|
-
return "missing";
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const surfaces = async (cwd) => {
|
|
70
|
-
try {
|
|
71
|
-
const text = await readFile(join(cwd, "PIPELINE.md"), "utf8");
|
|
72
|
-
const match = /```yaml pipeline-profile\s*\n([\s\S]*?)\n```/u.exec(text);
|
|
73
|
-
const profile = match?.[1] ? parse(match[1]) : {};
|
|
74
|
-
return (Array.isArray(profile.surfaces) ? profile.surfaces : []).flatMap((x) => x && typeof x === "object" && "key" in x && typeof x.key === "string" ? [x.key] : []);
|
|
75
|
-
} catch {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const fleet = {
|
|
80
|
-
verb: "fleet",
|
|
81
|
-
async run(ctx, args) {
|
|
82
|
-
const mode = args.subVerb ?? args.positionals[0];
|
|
83
|
-
const ids = args.positionals.filter((value) => !value.startsWith("--") && value !== mode);
|
|
84
|
-
const file = join(ctx.cwd, "specs", "reports", "fleet.json");
|
|
85
|
-
if (mode === "plan") {
|
|
86
|
-
if (ids.length < 2) return 2;
|
|
87
|
-
const invalid = [];
|
|
88
|
-
for (const id of ids) if (!await frozen(ctx.cwd, id)) invalid.push(id);
|
|
89
|
-
if (invalid.length) {
|
|
90
|
-
ctx.stdio.stderr.write(`fleet requires frozen specs: ${invalid.join(", ")}\n`);
|
|
91
|
-
return 11;
|
|
92
|
-
}
|
|
93
|
-
const keys = await surfaces(ctx.cwd);
|
|
94
|
-
const dependencyMap = /* @__PURE__ */ new Map();
|
|
95
|
-
const featureData = Object.fromEntries(await Promise.all(ids.map(async (id) => {
|
|
96
|
-
const ownership = await specSurfaces(ctx.cwd, id, keys);
|
|
97
|
-
const dependsOn = await specDependencies(ctx.cwd, id, ids);
|
|
98
|
-
dependencyMap.set(id, dependsOn);
|
|
99
|
-
return [id, {
|
|
100
|
-
dependsOn,
|
|
101
|
-
overlap: ownership.keys,
|
|
102
|
-
overlapInferred: ownership.inferred,
|
|
103
|
-
worktree: null
|
|
104
|
-
}];
|
|
105
|
-
})));
|
|
106
|
-
const order = dependencyOrder(ids, dependencyMap);
|
|
107
|
-
const plan = {
|
|
108
|
-
documentVersion: 1,
|
|
109
|
-
generatedAt: ctx.clock.now(),
|
|
110
|
-
order,
|
|
111
|
-
surfaces: keys,
|
|
112
|
-
features: featureData,
|
|
113
|
-
status: "planned"
|
|
114
|
-
};
|
|
115
|
-
if (args.positionals.includes("--apply")) {
|
|
116
|
-
await mkdir(join(ctx.cwd, "specs", "reports"), { recursive: true });
|
|
117
|
-
if (await exists(join(ctx.cwd, ".git"))) {
|
|
118
|
-
const worktreeRoot = resolve(ctx.cwd, ".cohorte", "worktrees");
|
|
119
|
-
await mkdir(worktreeRoot, { recursive: true });
|
|
120
|
-
for (const id of ids) {
|
|
121
|
-
const worktree = resolve(worktreeRoot, id);
|
|
122
|
-
if (!await exists(worktree)) await exec("git", [
|
|
123
|
-
"worktree",
|
|
124
|
-
"add",
|
|
125
|
-
"-b",
|
|
126
|
-
`cohorte/${id}`,
|
|
127
|
-
worktree,
|
|
128
|
-
"HEAD"
|
|
129
|
-
], { cwd: ctx.cwd });
|
|
130
|
-
plan.features[id].worktree = worktree;
|
|
131
|
-
plan.features[id].branch = `cohorte/${id}`;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
await writeFile(file, `${JSON.stringify(plan, null, 2)}\n`, "utf8");
|
|
135
|
-
}
|
|
136
|
-
ctx.stdio.stdout.write(`${args.json ? JSON.stringify(plan) : `${ids.length} feature(s) planned in order: ${ids.join(" → ")}${args.positionals.includes("--apply") ? `\nwritten ${file}` : "\nre-run with --apply to persist the plan"}`}\n`);
|
|
137
|
-
return 0;
|
|
138
|
-
}
|
|
139
|
-
if (mode === "status") try {
|
|
140
|
-
const plan = JSON.parse(await readFile(file, "utf8"));
|
|
141
|
-
const defaultBranch = "main";
|
|
142
|
-
const rows = [];
|
|
143
|
-
for (const id of plan.order ?? []) {
|
|
144
|
-
const worktree = plan.features?.[id]?.worktree ?? null;
|
|
145
|
-
const root = worktree ?? ctx.cwd;
|
|
146
|
-
const status = await statusOf(root, id);
|
|
147
|
-
let loop = {};
|
|
148
|
-
let verdict = {};
|
|
149
|
-
try {
|
|
150
|
-
loop = JSON.parse(await readFile(join(root, "specs", "reports", `${id}.loop.json`), "utf8"));
|
|
151
|
-
} catch {}
|
|
152
|
-
try {
|
|
153
|
-
verdict = JSON.parse(await readFile(join(root, "specs", "reports", `${id}.verdict.json`), "utf8"));
|
|
154
|
-
} catch {}
|
|
155
|
-
let ahead = 0;
|
|
156
|
-
let behind = 0;
|
|
157
|
-
try {
|
|
158
|
-
await exec("git", [
|
|
159
|
-
"-C",
|
|
160
|
-
root,
|
|
161
|
-
"fetch",
|
|
162
|
-
"--quiet",
|
|
163
|
-
"origin",
|
|
164
|
-
defaultBranch
|
|
165
|
-
]);
|
|
166
|
-
const { stdout } = await exec("git", [
|
|
167
|
-
"-C",
|
|
168
|
-
root,
|
|
169
|
-
"rev-list",
|
|
170
|
-
"--left-right",
|
|
171
|
-
"--count",
|
|
172
|
-
`origin/${defaultBranch}...HEAD`
|
|
173
|
-
]);
|
|
174
|
-
const counts = stdout.trim().split(/\s+/u).map(Number);
|
|
175
|
-
behind = counts[0] ?? 0;
|
|
176
|
-
ahead = counts[1] ?? 0;
|
|
177
|
-
} catch {}
|
|
178
|
-
rows.push({
|
|
179
|
-
id,
|
|
180
|
-
status,
|
|
181
|
-
worktree,
|
|
182
|
-
loop: {
|
|
183
|
-
phase: loop.phase ?? null,
|
|
184
|
-
round: loop.round ?? null,
|
|
185
|
-
outcome: loop.outcome ?? null
|
|
186
|
-
},
|
|
187
|
-
blocking: verdict.blocking ?? null,
|
|
188
|
-
ahead,
|
|
189
|
-
behind
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
ctx.stdio.stdout.write(`${args.json ? JSON.stringify({ rows }) : rows.map((x) => `${x.id} · ${x.status} · ${x.worktree ?? "no worktree"}`).join("\n")}\n`);
|
|
193
|
-
return 0;
|
|
194
|
-
} catch {
|
|
195
|
-
ctx.stdio.stderr.write("fleet plan not found; run cohorte fleet plan <id> <id> --apply\n");
|
|
196
|
-
return 1;
|
|
197
|
-
}
|
|
198
|
-
if (mode === "sync") try {
|
|
199
|
-
const plan = JSON.parse(await readFile(file, "utf8"));
|
|
200
|
-
const defaultBranch = "main";
|
|
201
|
-
const requestedShipped = args.positionals.find((value) => value !== mode && !value.startsWith("--"));
|
|
202
|
-
const mergedBranches = await exec("git", [
|
|
203
|
-
"branch",
|
|
204
|
-
"--merged",
|
|
205
|
-
defaultBranch
|
|
206
|
-
], { cwd: ctx.cwd }).then(({ stdout }) => stdout).catch(() => "");
|
|
207
|
-
const detectedShipped = (requestedShipped && (plan.order ?? []).includes(requestedShipped) ? requestedShipped : void 0) ?? (plan.order ?? []).find((id) => {
|
|
208
|
-
const branch = plan.features?.[id]?.branch;
|
|
209
|
-
return branch ? mergedBranches.split(/\r?\n/u).some((line) => line.replace(/^\*?\s*/u, "") === branch) : false;
|
|
210
|
-
});
|
|
211
|
-
if (detectedShipped) {
|
|
212
|
-
plan.order = (plan.order ?? []).filter((id) => id !== detectedShipped);
|
|
213
|
-
if (plan.features) delete plan.features[detectedShipped];
|
|
214
|
-
await writeFile(file, `${JSON.stringify(plan, null, 2)}\n`, "utf8");
|
|
215
|
-
}
|
|
216
|
-
const rows = detectedShipped ? [{
|
|
217
|
-
id: detectedShipped,
|
|
218
|
-
action: "shipped: removed from fleet plan"
|
|
219
|
-
}] : [];
|
|
220
|
-
for (const id of plan.order ?? []) {
|
|
221
|
-
const worktree = plan.features?.[id]?.worktree;
|
|
222
|
-
if (!worktree) {
|
|
223
|
-
rows.push({
|
|
224
|
-
id,
|
|
225
|
-
action: "no worktree"
|
|
226
|
-
});
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
await exec("git", [
|
|
231
|
-
"-C",
|
|
232
|
-
worktree,
|
|
233
|
-
"fetch",
|
|
234
|
-
"--quiet",
|
|
235
|
-
"origin",
|
|
236
|
-
defaultBranch
|
|
237
|
-
]);
|
|
238
|
-
const loopPath = join(worktree, "specs", "reports", `${id}.loop.json`);
|
|
239
|
-
let loop = {};
|
|
240
|
-
try {
|
|
241
|
-
loop = JSON.parse(await readFile(loopPath, "utf8"));
|
|
242
|
-
} catch {}
|
|
243
|
-
const { stdout } = await exec("git", [
|
|
244
|
-
"-C",
|
|
245
|
-
worktree,
|
|
246
|
-
"status",
|
|
247
|
-
"--porcelain"
|
|
248
|
-
]);
|
|
249
|
-
if (stdout.trim()) rows.push({
|
|
250
|
-
id,
|
|
251
|
-
action: "rebase needed: dirty worktree",
|
|
252
|
-
worktree
|
|
253
|
-
});
|
|
254
|
-
else if (!loop.outcome) rows.push({
|
|
255
|
-
id,
|
|
256
|
-
action: "rebase needed: loop in flight",
|
|
257
|
-
worktree
|
|
258
|
-
});
|
|
259
|
-
else try {
|
|
260
|
-
await exec("git", [
|
|
261
|
-
"-C",
|
|
262
|
-
worktree,
|
|
263
|
-
"rebase",
|
|
264
|
-
`origin/${defaultBranch}`
|
|
265
|
-
]);
|
|
266
|
-
rows.push({
|
|
267
|
-
id,
|
|
268
|
-
action: "rebased; fresh review required",
|
|
269
|
-
worktree
|
|
270
|
-
});
|
|
271
|
-
} catch (error) {
|
|
272
|
-
rows.push({
|
|
273
|
-
id,
|
|
274
|
-
action: `rebase conflict: ${error instanceof Error ? error.message : String(error)}`,
|
|
275
|
-
worktree
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
} catch {
|
|
279
|
-
rows.push({
|
|
280
|
-
id,
|
|
281
|
-
action: "worktree missing",
|
|
282
|
-
worktree
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
ctx.stdio.stdout.write(`${args.json ? JSON.stringify({ rows }) : rows.map((x) => `${x.id} · ${x.action}`).join("\n")}\n`);
|
|
287
|
-
return 0;
|
|
288
|
-
} catch {
|
|
289
|
-
return 1;
|
|
290
|
-
}
|
|
291
|
-
return 2;
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
//#endregion
|
|
295
|
-
export { fleet as default };
|
|
296
|
-
|
|
297
|
-
//# sourceMappingURL=fleet-yWHQY2ya.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-yWHQY2ya.mjs","names":[],"sources":["../../../../apps/cli/src/commands/fleet/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { access, mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { promisify } from 'node:util';\nimport { parse } from 'yaml';\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst exec = promisify(execFile);\nconst exists = async (path: string) => {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n};\nconst specText = async (cwd: string, id: string): Promise<string | undefined> => {\n for (const path of [join(cwd, 'specs', `${id}.md`), join(cwd, '.cohorte', 'specs', `${id}.yaml`)]) {\n try {\n return await readFile(path, 'utf8');\n } catch {}\n }\n return undefined;\n};\nconst frozen = async (cwd: string, id: string) => {\n const text = await specText(cwd, id);\n return text !== undefined && (/^status:\\s*frozen\\s*$/mu.test(text.slice(0, 1500)) || /status:\\s*frozen/u.test(text));\n};\nconst specSurfaces = async (cwd: string, id: string, known: readonly string[]) => {\n const text = await specText(cwd, id);\n if (!text) return { keys: [...known], inferred: true };\n const listed = known.filter((key) =>\n new RegExp(`(?:^|[\\\\s\"'])${key.replaceAll('-', '[^A-Za-z0-9]?')}([\\\\s\"']|$)`, 'mu').test(text),\n );\n return { keys: listed.length ? listed : [...known], inferred: listed.length === 0 };\n};\nconst specDependencies = async (cwd: string, id: string, candidates: readonly string[]): Promise<string[]> => {\n const text = await specText(cwd, id);\n if (!text) return [];\n const declared = new Set<string>();\n const matches = [\n ...text.matchAll(/(?:^|\\n)\\s*(?:dependsOn|depends-on|depends on)\\s*:\\s*([^\\n]+)/giu),\n ...text.matchAll(/(?:dependsOn|depends-on|depends on)\\s+([^\\n]+)/giu),\n ];\n for (const match of matches) {\n for (const value of (match[1] ?? '').split(/[,\\s[\\]\"']/u)) {\n if (candidates.includes(value) && value !== id) declared.add(value);\n }\n }\n return [...declared].sort();\n};\nfunction dependencyOrder(ids: readonly string[], dependencies: ReadonlyMap<string, readonly string[]>): string[] {\n const result: string[] = [];\n const visiting = new Set<string>();\n const visited = new Set<string>();\n const visit = (id: string): void => {\n if (visited.has(id)) return;\n if (visiting.has(id)) return;\n visiting.add(id);\n for (const dependency of dependencies.get(id) ?? []) visit(dependency);\n visiting.delete(id);\n visited.add(id);\n result.push(id);\n };\n for (const id of ids) visit(id);\n return result;\n}\nconst statusOf = async (cwd: string, id: string) => {\n try {\n const text = await readFile(join(cwd, 'specs', `${id}.md`), 'utf8');\n return /^status:\\s*(\\S+)/mu.exec(text.slice(0, 1500))?.[1] ?? 'unknown';\n } catch {\n return 'missing';\n }\n};\nconst surfaces = async (cwd: string): Promise<string[]> => {\n try {\n const text = await readFile(join(cwd, 'PIPELINE.md'), 'utf8');\n const match = /```yaml pipeline-profile\\s*\\n([\\s\\S]*?)\\n```/u.exec(text);\n const profile = match?.[1] ? (parse(match[1]) as Record<string, unknown>) : {};\n return (Array.isArray(profile.surfaces) ? profile.surfaces : []).flatMap((x) =>\n x && typeof x === 'object' && 'key' in x && typeof x.key === 'string' ? [x.key] : [],\n );\n } catch {\n return [];\n }\n};\nconst fleet: CommandModule = {\n verb: 'fleet',\n async run(ctx, args) {\n const mode = args.subVerb ?? args.positionals[0];\n const ids = args.positionals.filter((value) => !value.startsWith('--') && value !== mode);\n const file = join(ctx.cwd, 'specs', 'reports', 'fleet.json');\n if (mode === 'plan') {\n if (ids.length < 2) return 2;\n const invalid = [];\n for (const id of ids) if (!(await frozen(ctx.cwd, id))) invalid.push(id);\n if (invalid.length) {\n ctx.stdio.stderr.write(`fleet requires frozen specs: ${invalid.join(', ')}\\n`);\n return 11;\n }\n const keys = await surfaces(ctx.cwd);\n const dependencyMap = new Map<string, string[]>();\n const featureData = Object.fromEntries(\n await Promise.all(\n ids.map(async (id) => {\n const ownership = await specSurfaces(ctx.cwd, id, keys);\n const dependsOn = await specDependencies(ctx.cwd, id, ids);\n dependencyMap.set(id, dependsOn);\n return [id, { dependsOn, overlap: ownership.keys, overlapInferred: ownership.inferred, worktree: null }];\n }),\n ),\n );\n const order = dependencyOrder(ids, dependencyMap);\n const plan = {\n documentVersion: 1,\n generatedAt: ctx.clock.now(),\n order,\n surfaces: keys,\n features: featureData,\n status: 'planned',\n };\n if (args.positionals.includes('--apply')) {\n await mkdir(join(ctx.cwd, 'specs', 'reports'), { recursive: true });\n if (await exists(join(ctx.cwd, '.git'))) {\n const worktreeRoot = resolve(ctx.cwd, '.cohorte', 'worktrees');\n await mkdir(worktreeRoot, { recursive: true });\n for (const id of ids) {\n const worktree = resolve(worktreeRoot, id);\n if (!(await exists(worktree))) {\n await exec('git', ['worktree', 'add', '-b', `cohorte/${id}`, worktree, 'HEAD'], { cwd: ctx.cwd });\n }\n (plan.features[id] as { worktree: string; branch: string }).worktree = worktree;\n (plan.features[id] as { branch: string }).branch = `cohorte/${id}`;\n }\n }\n await writeFile(file, `${JSON.stringify(plan, null, 2)}\\n`, 'utf8');\n }\n ctx.stdio.stdout.write(\n `${args.json ? JSON.stringify(plan) : `${ids.length} feature(s) planned in order: ${ids.join(' → ')}${args.positionals.includes('--apply') ? `\\nwritten ${file}` : '\\nre-run with --apply to persist the plan'}`}\\n`,\n );\n return 0;\n }\n if (mode === 'status') {\n try {\n const plan = JSON.parse(await readFile(file, 'utf8')) as {\n order?: string[];\n features?: Record<string, { worktree?: string }>;\n };\n const defaultBranch = 'main';\n const rows = [];\n for (const id of plan.order ?? []) {\n const worktree = plan.features?.[id]?.worktree ?? null;\n const root = worktree ?? ctx.cwd;\n const status = await statusOf(root, id);\n let loop: Record<string, unknown> = {};\n let verdict: Record<string, unknown> = {};\n try {\n loop = JSON.parse(await readFile(join(root, 'specs', 'reports', `${id}.loop.json`), 'utf8'));\n } catch {}\n try {\n verdict = JSON.parse(await readFile(join(root, 'specs', 'reports', `${id}.verdict.json`), 'utf8'));\n } catch {}\n let ahead = 0;\n let behind = 0;\n try {\n await exec('git', ['-C', root, 'fetch', '--quiet', 'origin', defaultBranch]);\n const { stdout } = await exec('git', [\n '-C',\n root,\n 'rev-list',\n '--left-right',\n '--count',\n `origin/${defaultBranch}...HEAD`,\n ]);\n const counts = stdout.trim().split(/\\s+/u).map(Number);\n behind = counts[0] ?? 0;\n ahead = counts[1] ?? 0;\n } catch {}\n rows.push({\n id,\n status,\n worktree,\n loop: { phase: loop.phase ?? null, round: loop.round ?? null, outcome: loop.outcome ?? null },\n blocking: verdict.blocking ?? null,\n ahead,\n behind,\n });\n }\n ctx.stdio.stdout.write(\n `${args.json ? JSON.stringify({ rows }) : rows.map((x) => `${x.id} · ${x.status} · ${x.worktree ?? 'no worktree'}`).join('\\n')}\\n`,\n );\n return 0;\n } catch {\n ctx.stdio.stderr.write('fleet plan not found; run cohorte fleet plan <id> <id> --apply\\n');\n return 1;\n }\n }\n if (mode === 'sync') {\n try {\n const plan = JSON.parse(await readFile(file, 'utf8')) as {\n order?: string[];\n features?: Record<string, { worktree?: string; branch?: string }>;\n };\n const defaultBranch = 'main';\n const requestedShipped = args.positionals.find((value) => value !== mode && !value.startsWith('--'));\n const mergedBranches = await exec('git', ['branch', '--merged', defaultBranch], { cwd: ctx.cwd })\n .then(({ stdout }) => stdout)\n .catch(() => '');\n const requested =\n requestedShipped && (plan.order ?? []).includes(requestedShipped) ? requestedShipped : undefined;\n const detectedShipped =\n requested ??\n (plan.order ?? []).find((id) => {\n const branch = plan.features?.[id]?.branch;\n return branch\n ? mergedBranches.split(/\\r?\\n/u).some((line) => line.replace(/^\\*?\\s*/u, '') === branch)\n : false;\n });\n if (detectedShipped) {\n plan.order = (plan.order ?? []).filter((id) => id !== detectedShipped);\n if (plan.features) delete plan.features[detectedShipped];\n await writeFile(file, `${JSON.stringify(plan, null, 2)}\\n`, 'utf8');\n }\n const rows: Array<{ id: string; action: string; worktree?: string }> = detectedShipped\n ? [{ id: detectedShipped, action: 'shipped: removed from fleet plan' }]\n : [];\n for (const id of plan.order ?? []) {\n const worktree = plan.features?.[id]?.worktree;\n if (!worktree) {\n rows.push({ id, action: 'no worktree' });\n continue;\n }\n try {\n await exec('git', ['-C', worktree, 'fetch', '--quiet', 'origin', defaultBranch]);\n const loopPath = join(worktree, 'specs', 'reports', `${id}.loop.json`);\n let loop: { outcome?: string } = {};\n try {\n loop = JSON.parse(await readFile(loopPath, 'utf8')) as { outcome?: string };\n } catch {}\n const { stdout } = await exec('git', ['-C', worktree, 'status', '--porcelain']);\n if (stdout.trim()) {\n rows.push({ id, action: 'rebase needed: dirty worktree', worktree });\n } else if (!loop.outcome) {\n rows.push({ id, action: 'rebase needed: loop in flight', worktree });\n } else {\n try {\n await exec('git', ['-C', worktree, 'rebase', `origin/${defaultBranch}`]);\n rows.push({ id, action: 'rebased; fresh review required', worktree });\n } catch (error) {\n rows.push({\n id,\n action: `rebase conflict: ${error instanceof Error ? error.message : String(error)}`,\n worktree,\n });\n }\n }\n } catch {\n rows.push({ id, action: 'worktree missing', worktree });\n }\n }\n ctx.stdio.stdout.write(\n `${args.json ? JSON.stringify({ rows }) : rows.map((x) => `${x.id} · ${x.action}`).join('\\n')}\\n`,\n );\n return 0;\n } catch {\n return 1;\n }\n }\n return 2;\n },\n};\nexport default fleet;\n"],"mappings":";;;;;;AAOA,MAAM,OAAO,UAAU,QAAQ;AAC/B,MAAM,SAAS,OAAO,SAAiB;CACrC,IAAI;EACF,MAAM,OAAO,IAAI;EACjB,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,WAAW,OAAO,KAAa,OAA4C;CAC/E,KAAK,MAAM,QAAQ,CAAC,KAAK,KAAK,SAAS,GAAG,GAAG,IAAI,GAAG,KAAK,KAAK,YAAY,SAAS,GAAG,GAAG,MAAM,CAAC,GAC9F,IAAI;EACF,OAAO,MAAM,SAAS,MAAM,MAAM;CACpC,QAAQ,CAAC;AAGb;AACA,MAAM,SAAS,OAAO,KAAa,OAAe;CAChD,MAAM,OAAO,MAAM,SAAS,KAAK,EAAE;CACnC,OAAO,SAAS,KAAA,MAAc,0BAA0B,KAAK,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,oBAAoB,KAAK,IAAI;AACpH;AACA,MAAM,eAAe,OAAO,KAAa,IAAY,UAA6B;CAChF,MAAM,OAAO,MAAM,SAAS,KAAK,EAAE;CACnC,IAAI,CAAC,MAAM,OAAO;EAAE,MAAM,CAAC,GAAG,KAAK;EAAG,UAAU;CAAK;CACrD,MAAM,SAAS,MAAM,QAAQ,QAC3B,IAAI,OAAO,gBAAgB,IAAI,WAAW,KAAK,eAAe,EAAE,cAAc,IAAI,CAAC,CAAC,KAAK,IAAI,CAC/F;CACA,OAAO;EAAE,MAAM,OAAO,SAAS,SAAS,CAAC,GAAG,KAAK;EAAG,UAAU,OAAO,WAAW;CAAE;AACpF;AACA,MAAM,mBAAmB,OAAO,KAAa,IAAY,eAAqD;CAC5G,MAAM,OAAO,MAAM,SAAS,KAAK,EAAE;CACn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,OAAO,KAAK,MAAM,MAAM,SAAS,UAAU,MAAM,CAAC;KACpD,QAAQ,CAAC;KACT,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;MAAC;MAAM;MAAU;MAAU;KAAa,CAAC;KAC9E,IAAI,OAAO,KAAK,GACd,KAAK,KAAK;MAAE;MAAI,QAAQ;MAAiC;KAAS,CAAC;UAC9D,IAAI,CAAC,KAAK,SACf,KAAK,KAAK;MAAE;MAAI,QAAQ;MAAiC;KAAS,CAAC;UAEnE,IAAI;MACF,MAAM,KAAK,OAAO;OAAC;OAAM;OAAU;OAAU,UAAU;MAAe,CAAC;MACvE,KAAK,KAAK;OAAE;OAAI,QAAQ;OAAkC;MAAS,CAAC;KACtE,SAAS,OAAO;MACd,KAAK,KAAK;OACR;OACA,QAAQ,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;OACjF;MACF,CAAC;KACH;IAEJ,QAAQ;KACN,KAAK,KAAK;MAAE;MAAI,QAAQ;MAAoB;KAAS,CAAC;IACxD;GACF;GACA,IAAI,MAAM,OAAO,MACf,GAAG,KAAK,OAAO,KAAK,UAAU,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,MAAM,GAAG,EAAE,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,GAChG;GACA,OAAO;EACT,QAAQ;GACN,OAAO;EACT;EAEF,OAAO;CACT;AACF"}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { parse } from "yaml";
|
|
4
|
-
import { promisify } from "node:util";
|
|
5
|
-
import { gzip } from "node:zlib";
|
|
6
|
-
//#region src/commands/gc/index.ts
|
|
7
|
-
const gzipAsync = promisify(gzip);
|
|
8
|
-
const TERMINAL = /* @__PURE__ */ new Set(["COMPLETED", "CANCELLED"]);
|
|
9
|
-
const DEFAULT_RETENTION = {
|
|
10
|
-
transcriptsDays: 30,
|
|
11
|
-
artifactsDays: 90,
|
|
12
|
-
compressAfterDays: 7
|
|
13
|
-
};
|
|
14
|
-
async function filesUnder(root) {
|
|
15
|
-
const result = [];
|
|
16
|
-
async function visit(directory) {
|
|
17
|
-
let entries;
|
|
18
|
-
try {
|
|
19
|
-
entries = await readdir(directory, { withFileTypes: true });
|
|
20
|
-
} catch (error) {
|
|
21
|
-
if (error.code === "ENOENT") return;
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
const path = join(directory, entry.name);
|
|
26
|
-
if (entry.isDirectory()) await visit(path);
|
|
27
|
-
else if (entry.isFile()) result.push(path);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
await visit(root);
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
function classify(path) {
|
|
34
|
-
const normalized = path.replaceAll("\\", "/").toLowerCase();
|
|
35
|
-
if (normalized.endsWith(".gz")) return void 0;
|
|
36
|
-
if (normalized.includes("/sensitive/") || normalized.endsWith(".sensitive") || normalized.endsWith(".sensitive.json")) return "sensitive";
|
|
37
|
-
if (normalized.includes("/transcripts/") || normalized.includes("/wire/") || normalized.includes("/logs/")) return "transcript";
|
|
38
|
-
if (normalized.includes("/artifacts/")) return "artifact";
|
|
39
|
-
if (normalized.includes("/spool/") || normalized.includes("/stream/")) return "spool";
|
|
40
|
-
}
|
|
41
|
-
async function readRetention(cwd) {
|
|
42
|
-
try {
|
|
43
|
-
const value = parse(await readFile(join(cwd, ".cohorte", "config.yaml"), "utf8"));
|
|
44
|
-
return {
|
|
45
|
-
...DEFAULT_RETENTION,
|
|
46
|
-
...value.retention ?? {}
|
|
47
|
-
};
|
|
48
|
-
} catch {
|
|
49
|
-
return DEFAULT_RETENTION;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const CAS_ADDRESS = /^[a-f0-9]{64}$/;
|
|
53
|
-
async function referencedCasAddresses(runs, casRoot) {
|
|
54
|
-
const retained = /* @__PURE__ */ new Set();
|
|
55
|
-
for (const run of runs) {
|
|
56
|
-
const digest = run.snapshotDigest;
|
|
57
|
-
if (!digest || !CAS_ADDRESS.test(digest)) continue;
|
|
58
|
-
retained.add(digest);
|
|
59
|
-
const path = join(casRoot, digest.slice(0, 2), digest);
|
|
60
|
-
try {
|
|
61
|
-
const text = (await readFile(path, "utf8")).toString();
|
|
62
|
-
for (const address of text.match(/[a-f0-9]{64}/g) ?? []) retained.add(address);
|
|
63
|
-
} catch {}
|
|
64
|
-
}
|
|
65
|
-
return retained;
|
|
66
|
-
}
|
|
67
|
-
async function planGc(ctx) {
|
|
68
|
-
const store = await ctx.openStore();
|
|
69
|
-
try {
|
|
70
|
-
const runs = await store.listRuns({
|
|
71
|
-
limit: 1e5,
|
|
72
|
-
offset: 0
|
|
73
|
-
});
|
|
74
|
-
const retention = await readRetention(ctx.cwd);
|
|
75
|
-
const root = join(ctx.cwd, ".cohorte", "state", "runs");
|
|
76
|
-
const casRoot = join(ctx.cwd, ".cohorte", "state", "cas");
|
|
77
|
-
const now = Date.parse(ctx.clock.now());
|
|
78
|
-
const actions = [];
|
|
79
|
-
for (const run of runs) {
|
|
80
|
-
if (!TERMINAL.has(run.state)) continue;
|
|
81
|
-
if (run.purgeable && typeof store.purgeEvents === "function") actions.push({
|
|
82
|
-
kind: "purge-events",
|
|
83
|
-
path: `.cohorte/state/events/${run.runId}`,
|
|
84
|
-
runId: run.runId
|
|
85
|
-
});
|
|
86
|
-
for (const path of await filesUnder(join(root, run.runId))) {
|
|
87
|
-
const kind = classify(path);
|
|
88
|
-
if (!kind) continue;
|
|
89
|
-
const age = Math.max(0, now - (await stat(path)).mtimeMs);
|
|
90
|
-
if (kind === "sensitive" && age >= retention.compressAfterDays * 864e5) actions.push({
|
|
91
|
-
kind: "compress",
|
|
92
|
-
path,
|
|
93
|
-
runId: run.runId
|
|
94
|
-
});
|
|
95
|
-
else if (kind === "transcript" && age >= retention.transcriptsDays * 864e5) actions.push({
|
|
96
|
-
kind: "delete",
|
|
97
|
-
path,
|
|
98
|
-
runId: run.runId
|
|
99
|
-
});
|
|
100
|
-
else if (kind === "artifact" && age >= retention.artifactsDays * 864e5) actions.push({
|
|
101
|
-
kind: "delete",
|
|
102
|
-
path,
|
|
103
|
-
runId: run.runId
|
|
104
|
-
});
|
|
105
|
-
else if (kind === "spool" && age >= 864e5) actions.push({
|
|
106
|
-
kind: "delete",
|
|
107
|
-
path,
|
|
108
|
-
runId: run.runId
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const retainedCas = await referencedCasAddresses(runs, casRoot);
|
|
113
|
-
for (const path of await filesUnder(casRoot)) {
|
|
114
|
-
const address = path.split("/").at(-1) ?? "";
|
|
115
|
-
if (CAS_ADDRESS.test(address) && !retainedCas.has(address)) actions.push({
|
|
116
|
-
kind: "delete-cas",
|
|
117
|
-
path,
|
|
118
|
-
runId: "cas"
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return actions.sort((a, b) => a.path.localeCompare(b.path));
|
|
122
|
-
} finally {
|
|
123
|
-
await store.close();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async function applyAction(action, store) {
|
|
127
|
-
if (action.kind === "purge-events") {
|
|
128
|
-
await store.purgeEvents?.(action.runId);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (action.kind === "delete" || action.kind === "delete-cas") return rm(action.path, { force: true });
|
|
132
|
-
const compressed = await gzipAsync(await readFile(action.path));
|
|
133
|
-
await writeFile(`${action.path}.gz`, compressed, { mode: 384 });
|
|
134
|
-
await rm(action.path, { force: true });
|
|
135
|
-
}
|
|
136
|
-
const gc = {
|
|
137
|
-
verb: "gc",
|
|
138
|
-
async run(ctx, args) {
|
|
139
|
-
const dryRun = args.positionals.includes("--dry-run");
|
|
140
|
-
const apply = args.positionals.includes("--apply");
|
|
141
|
-
if (dryRun === apply) return 2;
|
|
142
|
-
const actions = await planGc(ctx);
|
|
143
|
-
if (apply) {
|
|
144
|
-
const store = await ctx.openStore();
|
|
145
|
-
try {
|
|
146
|
-
for (const action of actions) await applyAction(action, store);
|
|
147
|
-
} finally {
|
|
148
|
-
await store.close();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
ctx.stdio.stdout.write(`${JSON.stringify({
|
|
152
|
-
mode: dryRun ? "dry-run" : "apply",
|
|
153
|
-
actions
|
|
154
|
-
})}\n`);
|
|
155
|
-
return 0;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
//#endregion
|
|
159
|
-
export { gc as default };
|
|
160
|
-
|
|
161
|
-
//# sourceMappingURL=gc-BBXlBF5w.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gc-BBXlBF5w.mjs","names":[],"sources":["../../../../apps/cli/src/commands/gc/index.ts"],"sourcesContent":["// apps/cli/src/commands/gc/index.ts — DESIGN §9 verb `gc` (PLAN §3 rule 3 \"later units fill\n// stub files that lie inside their owned paths; they never edit ... the registry\"). Wave-0 stub: exits with the\n// documented not-available error (spec 24 `configuration/phase-not-available`); filled by the Wave-4/5\n// unit that owns `apps/cli/src/commands/gc/**`.\nimport type { Dirent } from 'node:fs';\nimport { readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { gzip } from 'node:zlib';\nimport type { PipelineState } from '@cohorte/protocol';\nimport { parse } from 'yaml';\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst gzipAsync = promisify(gzip);\nconst TERMINAL = new Set<PipelineState>(['COMPLETED', 'CANCELLED']);\nconst DEFAULT_RETENTION = { transcriptsDays: 30, artifactsDays: 90, compressAfterDays: 7 };\ntype Action =\n | { kind: 'compress' | 'delete' | 'delete-cas'; path: string; runId: string }\n | { kind: 'purge-events'; path: string; runId: string };\n\ntype RetentionStore = Awaited<ReturnType<Parameters<CommandModule['run']>[0]['openStore']>> & {\n purgeEvents?: (runId: string) => Promise<number>;\n};\n\nasync function filesUnder(root: string): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n let entries: Dirent[];\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw error;\n }\n for (const entry of entries) {\n const path = join(directory, entry.name);\n if (entry.isDirectory()) await visit(path);\n else if (entry.isFile()) result.push(path);\n }\n }\n await visit(root);\n return result;\n}\n\nfunction classify(path: string): 'sensitive' | 'transcript' | 'artifact' | 'spool' | undefined {\n const normalized = path.replaceAll('\\\\', '/').toLowerCase();\n if (normalized.endsWith('.gz')) return undefined;\n if (normalized.includes('/sensitive/') || normalized.endsWith('.sensitive') || normalized.endsWith('.sensitive.json'))\n return 'sensitive';\n if (normalized.includes('/transcripts/') || normalized.includes('/wire/') || normalized.includes('/logs/'))\n return 'transcript';\n if (normalized.includes('/artifacts/')) return 'artifact';\n if (normalized.includes('/spool/') || normalized.includes('/stream/')) return 'spool';\n return undefined;\n}\n\nasync function readRetention(cwd: string): Promise<typeof DEFAULT_RETENTION> {\n try {\n const value = parse(await readFile(join(cwd, '.cohorte', 'config.yaml'), 'utf8')) as {\n retention?: Partial<typeof DEFAULT_RETENTION>;\n };\n return { ...DEFAULT_RETENTION, ...(value.retention ?? {}) };\n } catch {\n return DEFAULT_RETENTION;\n }\n}\n\nconst CAS_ADDRESS = /^[a-f0-9]{64}$/;\n\nasync function referencedCasAddresses(\n runs: Awaited<ReturnType<RetentionStore['listRuns']>>,\n casRoot: string,\n): Promise<Set<string>> {\n const retained = new Set<string>();\n for (const run of runs) {\n const digest = run.snapshotDigest;\n if (!digest || !CAS_ADDRESS.test(digest)) continue;\n retained.add(digest);\n const path = join(casRoot, digest.slice(0, 2), digest);\n try {\n const text = (await readFile(path, 'utf8')).toString();\n for (const address of text.match(/[a-f0-9]{64}/g) ?? []) retained.add(address);\n } catch {\n // A missing snapshot is reported by resume/doctor; GC must not fail or invent a reference.\n }\n }\n return retained;\n}\n\nasync function planGc(ctx: Parameters<CommandModule['run']>[0]): Promise<Action[]> {\n const store = (await ctx.openStore()) as RetentionStore;\n try {\n const runs = await store.listRuns({ limit: 100_000, offset: 0 });\n const retention = await readRetention(ctx.cwd);\n const root = join(ctx.cwd, '.cohorte', 'state', 'runs');\n const casRoot = join(ctx.cwd, '.cohorte', 'state', 'cas');\n const now = Date.parse(ctx.clock.now());\n const actions: Action[] = [];\n for (const run of runs) {\n if (!TERMINAL.has(run.state)) continue;\n if (run.purgeable && typeof store.purgeEvents === 'function') {\n actions.push({ kind: 'purge-events', path: `.cohorte/state/events/${run.runId}`, runId: run.runId });\n }\n for (const path of await filesUnder(join(root, run.runId))) {\n const kind = classify(path);\n if (!kind) continue;\n const age = Math.max(0, now - (await stat(path)).mtimeMs);\n if (kind === 'sensitive' && age >= retention.compressAfterDays * 86_400_000)\n actions.push({ kind: 'compress', path, runId: run.runId });\n else if (kind === 'transcript' && age >= retention.transcriptsDays * 86_400_000)\n actions.push({ kind: 'delete', path, runId: run.runId });\n else if (kind === 'artifact' && age >= retention.artifactsDays * 86_400_000)\n actions.push({ kind: 'delete', path, runId: run.runId });\n else if (kind === 'spool' && age >= 86_400_000) actions.push({ kind: 'delete', path, runId: run.runId });\n }\n }\n const retainedCas = await referencedCasAddresses(runs, casRoot);\n for (const path of await filesUnder(casRoot)) {\n const address = path.split('/').at(-1) ?? '';\n if (CAS_ADDRESS.test(address) && !retainedCas.has(address))\n actions.push({ kind: 'delete-cas', path, runId: 'cas' });\n }\n return actions.sort((a, b) => a.path.localeCompare(b.path));\n } finally {\n await store.close();\n }\n}\n\nasync function applyAction(action: Action, store: RetentionStore): Promise<void> {\n if (action.kind === 'purge-events') {\n await store.purgeEvents?.(action.runId);\n return;\n }\n if (action.kind === 'delete' || action.kind === 'delete-cas') return rm(action.path, { force: true });\n const compressed = await gzipAsync(await readFile(action.path));\n await writeFile(`${action.path}.gz`, compressed, { mode: 0o600 });\n await rm(action.path, { force: true });\n}\n\nconst gc: CommandModule = {\n verb: 'gc',\n async run(ctx, args) {\n const dryRun = args.positionals.includes('--dry-run');\n const apply = args.positionals.includes('--apply');\n if (dryRun === apply) return 2;\n const actions = await planGc(ctx);\n if (apply) {\n const store = (await ctx.openStore()) as RetentionStore;\n try {\n for (const action of actions) await applyAction(action, store);\n } finally {\n await store.close();\n }\n }\n ctx.stdio.stdout.write(`${JSON.stringify({ mode: dryRun ? 'dry-run' : 'apply', actions })}\\n`);\n return 0;\n },\n};\n\nexport default gc;\n"],"mappings":";;;;;;AAaA,MAAM,YAAY,UAAU,IAAI;AAChC,MAAM,2BAAW,IAAI,IAAmB,CAAC,aAAa,WAAW,CAAC;AAClE,MAAM,oBAAoB;CAAE,iBAAiB;CAAI,eAAe;CAAI,mBAAmB;AAAE;AASzF,eAAe,WAAW,MAAiC;CACzD,MAAM,SAAmB,CAAC;CAC1B,eAAe,MAAM,WAAkC;EACrD,IAAI;EACJ,IAAI;GACF,UAAU,MAAM,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC;EAC5D,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,UAAU;GACxD,MAAM;EACR;EACA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,OAAO,KAAK,WAAW,MAAM,IAAI;GACvC,IAAI,MAAM,YAAY,GAAG,MAAM,MAAM,IAAI;QACpC,IAAI,MAAM,OAAO,GAAG,OAAO,KAAK,IAAI;EAC3C;CACF;CACA,MAAM,MAAM,IAAI;CAChB,OAAO;AACT;AAEA,SAAS,SAAS,MAA6E;CAC7F,MAAM,aAAa,KAAK,WAAW,MAAM,GAAG,CAAC,CAAC,YAAY;CAC1D,IAAI,WAAW,SAAS,KAAK,GAAG,OAAO,KAAA;CACvC,IAAI,WAAW,SAAS,aAAa,KAAK,WAAW,SAAS,YAAY,KAAK,WAAW,SAAS,iBAAiB,GAClH,OAAO;CACT,IAAI,WAAW,SAAS,eAAe,KAAK,WAAW,SAAS,QA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;EACR,MAAM,MAAM,MAAM;CACpB;AACF;AAEA,eAAe,YAAY,QAAgB,OAAsC;CAC/E,IAAI,OAAO,SAAS,gBAAgB;EAClC,MAAM,MAAM,cAAc,OAAO,KAAK;EACtC;CACF;CACA,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,cAAc,OAAO,GAAG,OAAO,MAAM,EAAE,OAAO,KAAK,CAAC;CACpG,MAAM,aAAa,MAAM,UAAU,MAAM,SAAS,OAAO,IAAI,CAAC;CAC9D,MAAM,UAAU,GAAG,OAAO,KAAK,MAAM,YAAY,EAAE,MAAM,IAAM,CAAC;CAChE,MAAM,GAAG,OAAO,MAAM,EAAE,OAAO,KAAK,CAAC;AACvC;AAEA,MAAM,KAAoB;CACxB,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,SAAS,KAAK,YAAY,SAAS,WAAW;EACpD,MAAM,QAAQ,KAAK,YAAY,SAAS,SAAS;EACjD,IAAI,WAAW,OAAO,OAAO;EAC7B,MAAM,UAAU,MAAM,OAAO,GAAG;EAChC,IAAI,OAAO;GACT,MAAM,QAAS,MAAM,IAAI,UAAU;GACnC,IAAI;IACF,KAAK,MAAM,UAAU,SAAS,MAAM,YAAY,QAAQ,KAAK;GAC/D,UAAU;IACR,MAAM,MAAM,MAAM;GACpB;EACF;EACA,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU;GAAE,MAAM,SAAS,YAAY;GAAS;EAAQ,CAAC,EAAE,GAAG;EAC7F,OAAO;CACT;AACF"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { a as applyV2Import, i as planInit, o as exportV2, r as applyInit, s as planV2Import } from "./src-DNsLSxgm.mjs";
|
|
2
|
-
import { t as scanRepository } from "./scan-C5uDr7Yq.mjs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
//#region src/commands/init/index.ts
|
|
5
|
-
const init = {
|
|
6
|
-
verb: "init",
|
|
7
|
-
async run(ctx, args) {
|
|
8
|
-
const fromV2 = args.positionals.indexOf("--from-v2");
|
|
9
|
-
const exportV2At = args.positionals.indexOf("--export-v2");
|
|
10
|
-
const optionValues = new Set([fromV2, exportV2At].filter((index) => index !== -1).map((index) => args.positionals[index + 1]).filter((value) => value !== void 0));
|
|
11
|
-
const requestedRoot = args.positionals.find((value) => !value.startsWith("--") && !optionValues.has(value));
|
|
12
|
-
const root = requestedRoot === void 0 ? ctx.cwd : resolve(ctx.cwd, requestedRoot);
|
|
13
|
-
if (fromV2 !== -1) {
|
|
14
|
-
const bundle = args.positionals[fromV2 + 1];
|
|
15
|
-
if (!bundle) throw new Error("configuration/import-invalid: init --from-v2 requires a bundle directory");
|
|
16
|
-
const model = await scanRepository(root, {
|
|
17
|
-
clock: ctx.clock,
|
|
18
|
-
toolVersion: "3.0.0-v2-import"
|
|
19
|
-
});
|
|
20
|
-
const plan = await planV2Import(resolve(ctx.cwd, bundle), root, { model });
|
|
21
|
-
if (!args.positionals.includes("--yes")) {
|
|
22
|
-
ctx.stdio.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
|
|
23
|
-
return plan.conflicts.length ? 3 : 0;
|
|
24
|
-
}
|
|
25
|
-
const result = await applyV2Import(plan, {
|
|
26
|
-
confirm: args.positionals.includes("--yes"),
|
|
27
|
-
backupRoot: resolve(root, "..", ".cohorte-migration-backups")
|
|
28
|
-
});
|
|
29
|
-
ctx.stdio.stdout.write(`${JSON.stringify(result)}\n`);
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
if (exportV2At !== -1) {
|
|
33
|
-
const destination = args.positionals[exportV2At + 1];
|
|
34
|
-
if (!destination) throw new Error("configuration/import-invalid: init --export-v2 requires a destination");
|
|
35
|
-
const result = await exportV2({
|
|
36
|
-
root,
|
|
37
|
-
destination: resolve(ctx.cwd, destination)
|
|
38
|
-
});
|
|
39
|
-
ctx.stdio.stdout.write(`${JSON.stringify(result)}\n`);
|
|
40
|
-
return result.manifest.warnings.some((item) => item.blocking) ? 3 : 0;
|
|
41
|
-
}
|
|
42
|
-
const model = await scanRepository(root, {
|
|
43
|
-
clock: ctx.clock,
|
|
44
|
-
toolVersion: "3.0.0"
|
|
45
|
-
});
|
|
46
|
-
const plan = await planInit({
|
|
47
|
-
root,
|
|
48
|
-
model,
|
|
49
|
-
cohorteVersion: "3.0.0"
|
|
50
|
-
});
|
|
51
|
-
if (args.positionals.includes("--plan") || args.json) {
|
|
52
|
-
ctx.stdio.stdout.write(`${JSON.stringify(plan)}\n`);
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
const result = await applyInit(plan);
|
|
56
|
-
ctx.stdio.stdout.write(`written: ${result.written.join(", ") || "none"}\n`);
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
61
|
-
export { init as default };
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=init--FxxkrcT.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init--FxxkrcT.mjs","names":[],"sources":["../../../../apps/cli/src/commands/init/index.ts"],"sourcesContent":["// apps/cli/src/commands/init/index.ts — DESIGN §9 verb `init` (PLAN §3 rule 3 \"later units fill\n// stub files that lie inside their owned paths; they never edit ... the registry\"). Wave-0 stub: exits with the\n// documented not-available error (spec 24 `configuration/phase-not-available`); filled by the Wave-4/5\n// unit that owns `apps/cli/src/commands/init/**`.\nimport { resolve } from 'node:path';\nimport { applyInit, applyV2Import, exportV2, planInit, planV2Import, scanRepository } from '@cohorte/project-model';\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst init: CommandModule = {\n verb: 'init',\n async run(ctx, args) {\n const fromV2 = args.positionals.indexOf('--from-v2');\n const exportV2At = args.positionals.indexOf('--export-v2');\n const optionValues = new Set(\n [fromV2, exportV2At]\n .filter((index) => index !== -1)\n .map((index) => args.positionals[index + 1])\n .filter((value): value is string => value !== undefined),\n );\n const requestedRoot = args.positionals.find((value) => !value.startsWith('--') && !optionValues.has(value));\n const root = requestedRoot === undefined ? ctx.cwd : resolve(ctx.cwd, requestedRoot);\n if (fromV2 !== -1) {\n const bundle = args.positionals[fromV2 + 1];\n if (!bundle) throw new Error('configuration/import-invalid: init --from-v2 requires a bundle directory');\n const model = await scanRepository(root, { clock: ctx.clock, toolVersion: '3.0.0-v2-import' });\n const plan = await planV2Import(resolve(ctx.cwd, bundle), root, { model });\n if (!args.positionals.includes('--yes')) {\n ctx.stdio.stdout.write(`${JSON.stringify(plan, null, 2)}\\n`);\n return plan.conflicts.length ? 3 : 0;\n }\n const result = await applyV2Import(plan, {\n confirm: args.positionals.includes('--yes'),\n backupRoot: resolve(root, '..', '.cohorte-migration-backups'),\n });\n ctx.stdio.stdout.write(`${JSON.stringify(result)}\\n`);\n return 0;\n }\n if (exportV2At !== -1) {\n const destination = args.positionals[exportV2At + 1];\n if (!destination) throw new Error('configuration/import-invalid: init --export-v2 requires a destination');\n const result = await exportV2({ root, destination: resolve(ctx.cwd, destination) });\n ctx.stdio.stdout.write(`${JSON.stringify(result)}\\n`);\n return result.manifest.warnings.some((item) => item.blocking) ? 3 : 0;\n }\n const model = await scanRepository(root, { clock: ctx.clock, toolVersion: '3.0.0' });\n const plan = await planInit({ root, model, cohorteVersion: '3.0.0' });\n if (args.positionals.includes('--plan') || args.json) {\n ctx.stdio.stdout.write(`${JSON.stringify(plan)}\\n`);\n return 0;\n }\n const result = await applyInit(plan);\n ctx.stdio.stdout.write(`written: ${result.written.join(', ') || 'none'}\\n`);\n return 0;\n },\n};\n\nexport default init;\n"],"mappings":";;;;AAQA,MAAM,OAAsB;CAC1B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,SAAS,KAAK,YAAY,QAAQ,WAAW;EACnD,MAAM,aAAa,KAAK,YAAY,QAAQ,aAAa;EACzD,MAAM,eAAe,IAAI,IACvB,CAAC,QAAQ,UAAU,CAAC,CACjB,QAAQ,UAAU,UAAU,EAAE,CAAC,CAC/B,KAAK,UAAU,KAAK,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AAI;EACtE;EACA,MAAM,QAAQ,MAAM,eAAe,MAAM;GAAE,OAAO,IAAI;GAAO,aAAa;EAAQ,CAAC;EACnF,MAAM,OAAO,MAAM,SAAS;GAAE;GAAM;GAAO,gBAAgB;EAAQ,CAAC;EACpE,IAAI,KAAK,YAAY,SAAS,QAAQ,KAAK,KAAK,MAAM;GACpD,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,IAAI,EAAE,GAAG;GAClD,OAAO;EACT;EACA,MAAM,SAAS,MAAM,UAAU,IAAI;EACnC,IAAI,MAAM,OAAO,MAAM,YAAY,OAAO,QAAQ,KAAK,IAAI,KAAK,OAAO,GAAG;EAC1E,OAAO;CACT;AACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { n as writeHuman } from "./render-DyZr5Lgi.mjs";
|
|
2
|
-
//#region src/commands/inspect/index.ts
|
|
3
|
-
const inspect = {
|
|
4
|
-
verb: "inspect",
|
|
5
|
-
async run(ctx, args) {
|
|
6
|
-
const runId = args.positionals[0];
|
|
7
|
-
if (!runId) return 2;
|
|
8
|
-
const store = await ctx.openStore();
|
|
9
|
-
const value = await store.readRunTree(runId);
|
|
10
|
-
try {
|
|
11
|
-
if (args.json) ctx.stdio.stdout.write(`${JSON.stringify(value)}\n`);
|
|
12
|
-
else writeHuman(ctx, JSON.stringify(value, null, 2));
|
|
13
|
-
return 0;
|
|
14
|
-
} finally {
|
|
15
|
-
await store.close();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { inspect as default };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=inspect-Buby4cQD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-Buby4cQD.mjs","names":[],"sources":["../../../../apps/cli/src/commands/inspect/index.ts"],"sourcesContent":["// apps/cli/src/commands/inspect/index.ts — DESIGN §9 verb `inspect` (PLAN §3 rule 3 \"later units fill\n// stub files that lie inside their owned paths; they never edit ... the registry\"). Wave-0 stub: exits with the\n// documented not-available error (spec 24 `configuration/phase-not-available`); filled by the Wave-4/5\n// unit that owns `apps/cli/src/commands/inspect/**`.\nimport type { CommandModule } from '../../contract/index.ts';\nimport { writeHuman } from '../../render/index.ts';\n\nconst inspect: CommandModule = {\n verb: 'inspect',\n async run(ctx, args) {\n const runId = args.positionals[0];\n if (!runId) return 2;\n const store = await ctx.openStore();\n const value = await store.readRunTree(runId as never);\n try {\n if (args.json) ctx.stdio.stdout.write(`${JSON.stringify(value)}\\n`);\n else writeHuman(ctx, JSON.stringify(value, null, 2));\n return 0;\n } finally {\n await store.close();\n }\n },\n};\n\nexport default inspect;\n"],"mappings":";;AAOA,MAAM,UAAyB;CAC7B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,QAAQ,KAAK,YAAY;EAC/B,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,QAAQ,MAAM,IAAI,UAAU;EAClC,MAAM,QAAQ,MAAM,MAAM,YAAY,KAAc;EACpD,IAAI;GACF,IAAI,KAAK,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,KAAK,EAAE,GAAG;QAC7D,WAAW,KAAK,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;GACnD,OAAO;EACT,UAAU;GACR,MAAM,MAAM,MAAM;EACpB;CACF;AACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import brainstorm from "./brainstorm-SJwOIEif.mjs";
|
|
2
|
-
//#region src/commands/intake/index.ts
|
|
3
|
-
const intake = {
|
|
4
|
-
verb: "intake",
|
|
5
|
-
async run(ctx, args) {
|
|
6
|
-
return brainstorm.run(ctx, args);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
10
|
-
export { intake as default };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=intake-C1pesxCJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intake-C1pesxCJ.mjs","names":[],"sources":["../../../../apps/cli/src/commands/intake/index.ts"],"sourcesContent":["import type { CommandModule } from '../../contract/index.ts';\nimport brainstorm from '../brainstorm/index.ts';\n\nconst intake: CommandModule = {\n verb: 'intake',\n async run(ctx, args) {\n return brainstorm.run(ctx, args);\n },\n};\n\nexport default intake;\n"],"mappings":";;AAGA,MAAM,SAAwB;CAC5B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,OAAO,WAAW,IAAI,KAAK,IAAI;CACjC;AACF"}
|