cohorte 3.0.0-dev.8 → 3.0.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 +1532 -0
- package/README.md +316 -62
- package/bin/cli.js +212 -0
- package/bin/report.js +141 -0
- package/core/agents/cohorte-profile-reader.md +50 -0
- package/core/agents/cohorte-release.md +58 -0
- package/core/agents/cohorte-review.md +174 -0
- package/core/agents/implementer.template.md +146 -0
- package/core/commands/cohorte-align-ds.md +33 -0
- package/core/commands/cohorte-audit.md +67 -0
- package/core/commands/cohorte-brainstorm.md +73 -0
- package/core/commands/cohorte-build.md +241 -0
- package/core/commands/cohorte-doctor.md +133 -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 +57 -0
- package/core/commands/cohorte-retro.md +85 -0
- package/core/commands/cohorte-review.md +224 -0
- package/core/commands/cohorte-ship.md +155 -0
- package/core/commands/cohorte-spec.md +105 -0
- package/core/commands/cohorte-update-pipeline.md +115 -0
- package/core/hooks/gate.py +2931 -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 +86 -0
- package/core/templates/pr-body.md +25 -0
- package/core/templates/review-feedback.md +46 -0
- package/core/templates/spec.template.md +88 -0
- package/core/templates/steps/init-pipeline/01-detect-stack.md +44 -0
- package/core/templates/steps/init-pipeline/02-interview-gaps.md +55 -0
- package/core/templates/steps/init-pipeline/03-draft-profile.md +9 -0
- package/core/templates/steps/init-pipeline/04-write-render.md +91 -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 +306 -0
- package/core/workflows/loop.js +687 -0
- package/core/workflows/refactor.js +291 -0
- package/core/workflows/review.js +491 -0
- package/install.ps1 +72 -0
- package/install.sh +69 -0
- package/lib/doctor.js +472 -0
- package/lib/install.js +377 -0
- package/lib/project.js +322 -0
- package/lib/render.js +121 -0
- package/lib/versions.js +145 -0
- package/lib/yaml.js +174 -0
- package/package.json +36 -17
- package/profile/PIPELINE.template.md +250 -0
- package/profile/SCHEMA.md +749 -0
- package/profile/cohorte.config.template.yaml +43 -0
- package/scripts/feature-diff.sh +118 -0
- package/scripts/kanban-move.sh +307 -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/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,50 +0,0 @@
|
|
|
1
|
-
import { N as errorOf, j as CohorteError } from "./src-Cu3TxNob.mjs";
|
|
2
|
-
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
-
import { stringify } from "yaml";
|
|
5
|
-
//#region src/commands/patch/index.ts
|
|
6
|
-
function slugify(value) {
|
|
7
|
-
return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "patch";
|
|
8
|
-
}
|
|
9
|
-
function optionValue(args, flag) {
|
|
10
|
-
const index = args.indexOf(flag);
|
|
11
|
-
return index === -1 ? void 0 : args[index + 1];
|
|
12
|
-
}
|
|
13
|
-
const patch = {
|
|
14
|
-
verb: "patch",
|
|
15
|
-
async run(ctx, args) {
|
|
16
|
-
const input = args.positionals.find((value) => !value.startsWith("--"));
|
|
17
|
-
if (!input) return 2;
|
|
18
|
-
const id = slugify(optionValue(args.positionals, "--id") ?? input);
|
|
19
|
-
const output = resolve(ctx.cwd, optionValue(args.positionals, "--output") ?? join(".cohorte", "specs", `patch-${id}.yaml`));
|
|
20
|
-
const spec = {
|
|
21
|
-
id: `patch-${id}`,
|
|
22
|
-
kind: "patch",
|
|
23
|
-
status: "draft",
|
|
24
|
-
title: input,
|
|
25
|
-
acceptance: [`Add a regression test that reproduces and prevents: ${input}`],
|
|
26
|
-
surfaces: {},
|
|
27
|
-
openQuestions: ["What is the minimal reproducible failure?", "Which existing behavior must remain unchanged?"]
|
|
28
|
-
};
|
|
29
|
-
try {
|
|
30
|
-
await access(output);
|
|
31
|
-
throw new CohorteError(errorOf("conflict/unexpected", `refusing to overwrite existing spec ${output}`));
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (error.code !== "ENOENT") throw error;
|
|
34
|
-
}
|
|
35
|
-
await mkdir(dirname(output), { recursive: true });
|
|
36
|
-
await writeFile(output, stringify(spec), "utf8");
|
|
37
|
-
const result = {
|
|
38
|
-
id: spec.id,
|
|
39
|
-
status: spec.status,
|
|
40
|
-
path: output,
|
|
41
|
-
next: `cohorte spec freeze ${output}`
|
|
42
|
-
};
|
|
43
|
-
ctx.stdio.stdout.write(`${args.json ? JSON.stringify(result) : `created ${output}\nnext: ${result.next}`}\n`);
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { patch as default };
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=patch-sAgVqjpx.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patch-sAgVqjpx.mjs","names":[],"sources":["../../../../apps/cli/src/commands/patch/index.ts"],"sourcesContent":["import { access, mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport { CohorteError, errorOf } from '@cohorte/base';\nimport { stringify } from 'yaml';\nimport type { CommandModule } from '../../contract/index.ts';\n\nfunction slugify(value: string): string {\n return (\n value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64) || 'patch'\n );\n}\n\nfunction optionValue(args: readonly string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n return index === -1 ? undefined : args[index + 1];\n}\n\nconst patch: CommandModule = {\n verb: 'patch',\n async run(ctx, args) {\n const input = args.positionals.find((value) => !value.startsWith('--'));\n if (!input) return 2;\n const id = slugify(optionValue(args.positionals, '--id') ?? input);\n const output = resolve(\n ctx.cwd,\n optionValue(args.positionals, '--output') ?? join('.cohorte', 'specs', `patch-${id}.yaml`),\n );\n const spec = {\n id: `patch-${id}`,\n kind: 'patch' as const,\n status: 'draft' as const,\n title: input,\n acceptance: [`Add a regression test that reproduces and prevents: ${input}`],\n surfaces: {},\n openQuestions: ['What is the minimal reproducible failure?', 'Which existing behavior must remain unchanged?'],\n };\n try {\n await access(output);\n throw new CohorteError(errorOf('conflict/unexpected', `refusing to overwrite existing spec ${output}`));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n await mkdir(dirname(output), { recursive: true });\n await writeFile(output, stringify(spec), 'utf8');\n const result = { id: spec.id, status: spec.status, path: output, next: `cohorte spec freeze ${output}` };\n ctx.stdio.stdout.write(`${args.json ? JSON.stringify(result) : `created ${output}\\nnext: ${result.next}`}\\n`);\n return 0;\n },\n};\n\nexport default patch;\n"],"mappings":";;;;;AAMA,SAAS,QAAQ,OAAuB;CACtC,OACE,MACG,UAAU,MAAM,CAAC,CACjB,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE,CAAC,CACvB,MAAM,GAAG,EAAE,KAAK;AAEvB;AAEA,SAAS,YAAY,MAAyB,MAAkC;CAC9E,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC/B,OAAO,UAAU,KAAK,KAAA,IAAY,KAAK,QAAQ;AACjD;AAEA,MAAM,QAAuB;CAC3B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,QAAQ,KAAK,YAAY,MAAM,UAAU,CAAC,MAAM,WAAW,IAAI,CAAC;EACtE,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,KAAK,QAAQ,YAAY,KAAK,aAAa,MAAM,KAAK,KAAK;EACjE,MAAM,SAAS,QACb,IAAI,KACJ,YAAY,KAAK,aAAa,UAAU,KAAK,KAAK,YAAY,SAAS,SAAS,GAAG,MAAM,CAC3F;EACA,MAAM,OAAO;GACX,IAAI,SAAS;GACb,MAAM;GACN,QAAQ;GACR,OAAO;GACP,YAAY,CAAC,uDAAuD,OAAO;GAC3E,UAAU,CAAC;GACX,eAAe,CAAC,6CAA6C,gDAAgD;EAC/G;EACA,IAAI;GACF,MAAM,OAAO,MAAM;GACnB,MAAM,IAAI,aAAa,QAAQ,uBAAuB,uCAAuC,QAAQ,CAAC;EACxG,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,UAAU,MAAM;EAChE;EACA,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;EAChD,MAAM,UAAU,QAAQ,UAAU,IAAI,GAAG,MAAM;EAC/C,MAAM,SAAS;GAAE,IAAI,KAAK;GAAI,QAAQ,KAAK;GAAQ,MAAM;GAAQ,MAAM,uBAAuB;EAAS;EACvG,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,OAAO,KAAK,UAAU,MAAM,IAAI,WAAW,OAAO,UAAU,OAAO,OAAO,GAAG;EAC5G,OAAO;CACT;AACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/commands/pause/index.ts
|
|
2
|
-
const pause = {
|
|
3
|
-
verb: "pause",
|
|
4
|
-
async run(ctx, args) {
|
|
5
|
-
const runId = args.positionals[0];
|
|
6
|
-
if (!runId) return 2;
|
|
7
|
-
const reason = args.positionals.slice(1).join(" ");
|
|
8
|
-
const result = await ctx.controller.send("pause", reason ? { reason } : {}, { runId });
|
|
9
|
-
ctx.stdio.stdout.write(`${JSON.stringify(result)}\n`);
|
|
10
|
-
return result.status === "rejected" ? 3 : result.status === "pending" ? 4 : 0;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { pause as default };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=pause-BASBfKLO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pause-BASBfKLO.mjs","names":[],"sources":["../../../../apps/cli/src/commands/pause/index.ts"],"sourcesContent":["// apps/cli/src/commands/pause/index.ts — DESIGN §9 verb `pause` (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/pause/**`.\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst pause: CommandModule = {\n verb: 'pause',\n async run(ctx, args) {\n const runId = args.positionals[0];\n if (!runId) return 2;\n const reason = args.positionals.slice(1).join(' ');\n const result = await ctx.controller.send('pause', reason ? { reason } : {}, { runId });\n ctx.stdio.stdout.write(`${JSON.stringify(result)}\\n`);\n return result.status === 'rejected' ? 3 : result.status === 'pending' ? 4 : 0;\n },\n};\n\nexport default pause;\n"],"mappings":";AAMA,MAAM,QAAuB;CAC3B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,QAAQ,KAAK,YAAY;EAC/B,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,SAAS,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;EACjD,MAAM,SAAS,MAAM,IAAI,WAAW,KAAK,SAAS,SAAS,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;EACrF,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;EACpD,OAAO,OAAO,WAAW,aAAa,IAAI,OAAO,WAAW,YAAY,IAAI;CAC9E;AACF"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { n as sha256Hex, t as canonicalJson } from "./canonical-C8UxeEmB.mjs";
|
|
2
|
-
import { N as errorOf, j as CohorteError } from "./src-Cu3TxNob.mjs";
|
|
3
|
-
import { n as createKeyStore, r as createTrustStore } from "./auth-BT5oVp76.mjs";
|
|
4
|
-
import { i as resolveConfig, n as loadConfig } from "./src-DbS9gkJy.mjs";
|
|
5
|
-
import "./src-Bfr1yzsn.mjs";
|
|
6
|
-
import { a as buildPolicySnapshot, c as createCommandPolicy, i as createGlobMatcher, l as createProgramResolver, n as toolIntrospection, o as createPolicyEngine, r as createPathResolver, s as explainPolicy } from "./catalogue-IaCJdfB8.mjs";
|
|
7
|
-
import { join, resolve } from "node:path";
|
|
8
|
-
import { realpathSync } from "node:fs";
|
|
9
|
-
//#region src/commands/policy/index.ts
|
|
10
|
-
function canonical(path) {
|
|
11
|
-
const absolute = resolve(path);
|
|
12
|
-
try {
|
|
13
|
-
return realpathSync.native(absolute);
|
|
14
|
-
} catch {
|
|
15
|
-
return absolute;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function grantFor(root, argv) {
|
|
19
|
-
const tools = ["run_command"];
|
|
20
|
-
return {
|
|
21
|
-
agentId: "agt_policy_explain",
|
|
22
|
-
role: "policy-explain",
|
|
23
|
-
digest: sha256Hex(canonicalJson({
|
|
24
|
-
root,
|
|
25
|
-
argv: [...argv]
|
|
26
|
-
})),
|
|
27
|
-
tools,
|
|
28
|
-
roots: {
|
|
29
|
-
workspace: root,
|
|
30
|
-
readOnly: []
|
|
31
|
-
},
|
|
32
|
-
read: {
|
|
33
|
-
include: ["**"],
|
|
34
|
-
exclude: []
|
|
35
|
-
},
|
|
36
|
-
write: {
|
|
37
|
-
include: ["**"],
|
|
38
|
-
exclude: []
|
|
39
|
-
},
|
|
40
|
-
denyRead: {
|
|
41
|
-
include: ["**/.cohorte/**", "**/.git/**"],
|
|
42
|
-
exclude: []
|
|
43
|
-
},
|
|
44
|
-
denyWrite: {
|
|
45
|
-
include: ["**/.cohorte/**", "**/.git/**"],
|
|
46
|
-
exclude: []
|
|
47
|
-
},
|
|
48
|
-
commands: {
|
|
49
|
-
default: "deny",
|
|
50
|
-
rules: []
|
|
51
|
-
},
|
|
52
|
-
secrets: [],
|
|
53
|
-
temporary: [],
|
|
54
|
-
limits: {
|
|
55
|
-
maxToolCalls: 1,
|
|
56
|
-
maxCallsPerMinute: 1,
|
|
57
|
-
perTool: { run_command: {
|
|
58
|
-
timeoutMs: 12e4,
|
|
59
|
-
maxOutputBytes: 1048576
|
|
60
|
-
} }
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const policy = {
|
|
65
|
-
verb: "policy",
|
|
66
|
-
async run(ctx, args) {
|
|
67
|
-
if (args.subVerb !== "explain") return 2;
|
|
68
|
-
const argv = args.positionals.filter((value) => value !== "--");
|
|
69
|
-
if (argv.length === 0) return 2;
|
|
70
|
-
const home = ctx.env.HOME ?? ctx.cwd;
|
|
71
|
-
const projectKeyId = sha256Hex(ctx.cwd).slice(0, 24);
|
|
72
|
-
const keys = createKeyStore({ directory: join(home, ".cohorte", "keys") });
|
|
73
|
-
const trustStore = createTrustStore({
|
|
74
|
-
directory: join(home, ".cohorte", "trust"),
|
|
75
|
-
keys
|
|
76
|
-
});
|
|
77
|
-
const loaded = await loadConfig({
|
|
78
|
-
cwd: ctx.cwd,
|
|
79
|
-
home
|
|
80
|
-
});
|
|
81
|
-
const resolved = await resolveConfig(loaded, {
|
|
82
|
-
trustStore,
|
|
83
|
-
projectKeyId
|
|
84
|
-
});
|
|
85
|
-
if (resolved.status === "untrusted") throw new CohorteError(errorOf("security/project-policy-untrusted", `project policy is untrusted (${resolved.loosenedKeys.join(", ") || "unknown key"})`));
|
|
86
|
-
const root = canonical(loaded.projectRoot);
|
|
87
|
-
const pathResolver = createPathResolver({
|
|
88
|
-
roots: [root],
|
|
89
|
-
protectedRoots: [canonical(join(root, ".cohorte"))],
|
|
90
|
-
symlinks: resolved.config.policy.symlinks
|
|
91
|
-
});
|
|
92
|
-
const pathDirs = (ctx.env.PATH ?? "").split(":").filter(Boolean).map(canonical);
|
|
93
|
-
const programs = createProgramResolver({ pathDirs });
|
|
94
|
-
const branches = { branchOf: () => ({
|
|
95
|
-
kind: "detached-or-unknown",
|
|
96
|
-
protected: true
|
|
97
|
-
}) };
|
|
98
|
-
const commands = createCommandPolicy({
|
|
99
|
-
programs,
|
|
100
|
-
branches
|
|
101
|
-
});
|
|
102
|
-
const engine = createPolicyEngine({
|
|
103
|
-
tools: toolIntrospection,
|
|
104
|
-
globs: createGlobMatcher(),
|
|
105
|
-
commands
|
|
106
|
-
});
|
|
107
|
-
const policySnapshot = buildPolicySnapshot(resolved.config, loaded.ownership, { sandboxLevel: "L0-process" });
|
|
108
|
-
const ports = {
|
|
109
|
-
paths: pathResolver,
|
|
110
|
-
branches,
|
|
111
|
-
budgets: {
|
|
112
|
-
remaining: () => ({}),
|
|
113
|
-
callsInLastMinute: () => 0
|
|
114
|
-
},
|
|
115
|
-
programs,
|
|
116
|
-
clock: ctx.clock
|
|
117
|
-
};
|
|
118
|
-
const verdict = explainPolicy(engine, {
|
|
119
|
-
runId: "run_policy_explain",
|
|
120
|
-
agentId: "agt_policy_explain",
|
|
121
|
-
incarnation: 1,
|
|
122
|
-
toolCallId: "tool_policy_explain",
|
|
123
|
-
tool: "run_command",
|
|
124
|
-
input: {
|
|
125
|
-
argv,
|
|
126
|
-
cwd: root,
|
|
127
|
-
timeoutMs: 12e4
|
|
128
|
-
},
|
|
129
|
-
phase: "PREFLIGHT",
|
|
130
|
-
role: "policy-explain"
|
|
131
|
-
}, grantFor(root, argv), policySnapshot, ports);
|
|
132
|
-
ctx.stdio.stdout.write(`${JSON.stringify(verdict)}\n`);
|
|
133
|
-
return 0;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
//#endregion
|
|
137
|
-
export { policy as default };
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=policy-Du7WVBFX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy-Du7WVBFX.mjs","names":[],"sources":["../../../../apps/cli/src/commands/policy/index.ts"],"sourcesContent":["// apps/cli/src/commands/policy/index.ts — DESIGN §9 verb `policy` (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/policy/**`.\nimport { realpathSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { CohorteError, canonicalJson, errorOf, sha256Hex } from '@cohorte/base';\nimport { loadConfig, resolveConfig } from '@cohorte/config';\nimport {\n buildPolicySnapshot,\n createCommandPolicy,\n createGlobMatcher,\n createPathResolver,\n createPolicyEngine,\n createProgramResolver,\n explainPolicy,\n} from '@cohorte/security';\nimport { createKeyStore, createTrustStore } from '@cohorte/security/auth';\nimport type { AgentGrant, GateCall, PolicyPorts } from '@cohorte/security/contract';\nimport { toolIntrospection } from '@cohorte/tools/catalogue';\nimport type { CommandModule } from '../../contract/index.ts';\n\nfunction canonical(path: string): string {\n const absolute = resolve(path);\n try {\n return realpathSync.native(absolute);\n } catch {\n return absolute;\n }\n}\n\nfunction grantFor(root: string, argv: readonly string[]): AgentGrant {\n const tools = ['run_command'];\n const digest = sha256Hex(canonicalJson({ root, argv: [...argv] }));\n return {\n agentId: 'agt_policy_explain' as AgentGrant['agentId'],\n role: 'policy-explain',\n digest,\n tools,\n roots: { workspace: root as AgentGrant['roots']['workspace'], readOnly: [] },\n read: { include: ['**'], exclude: [] },\n write: { include: ['**'], exclude: [] },\n denyRead: { include: ['**/.cohorte/**', '**/.git/**'], exclude: [] },\n denyWrite: { include: ['**/.cohorte/**', '**/.git/**'], exclude: [] },\n commands: { default: 'deny', rules: [] },\n secrets: [],\n temporary: [],\n limits: {\n maxToolCalls: 1,\n maxCallsPerMinute: 1,\n perTool: { run_command: { timeoutMs: 120_000, maxOutputBytes: 1024 * 1024 } },\n },\n };\n}\n\nconst policy: CommandModule = {\n verb: 'policy',\n async run(ctx, args) {\n if (args.subVerb !== 'explain') return 2;\n const argv = args.positionals.filter((value) => value !== '--');\n if (argv.length === 0) return 2;\n\n const home = ctx.env.HOME ?? ctx.cwd;\n const projectKeyId = sha256Hex(ctx.cwd).slice(0, 24);\n const keys = createKeyStore({ directory: join(home, '.cohorte', 'keys') });\n const trustStore = createTrustStore({ directory: join(home, '.cohorte', 'trust'), keys });\n const loaded = await loadConfig({ cwd: ctx.cwd, home });\n const resolved = await resolveConfig(loaded, { trustStore, projectKeyId });\n if (resolved.status === 'untrusted') {\n throw new CohorteError(\n errorOf(\n 'security/project-policy-untrusted',\n `project policy is untrusted (${resolved.loosenedKeys.join(', ') || 'unknown key'})`,\n ),\n );\n }\n\n const root = canonical(loaded.projectRoot);\n const pathResolver = createPathResolver({\n roots: [root as never],\n protectedRoots: [canonical(join(root, '.cohorte')) as never],\n symlinks: resolved.config.policy.symlinks,\n });\n const pathDirs = (ctx.env.PATH ?? '').split(':').filter(Boolean).map(canonical);\n const programs = createProgramResolver({ pathDirs });\n const branches: PolicyPorts['branches'] = {\n branchOf: () => ({ kind: 'detached-or-unknown', protected: true }),\n };\n const commands = createCommandPolicy({ programs, branches });\n const engine = createPolicyEngine({ tools: toolIntrospection, globs: createGlobMatcher(), commands });\n const policySnapshot = buildPolicySnapshot(resolved.config, loaded.ownership, { sandboxLevel: 'L0-process' });\n const ports: PolicyPorts = {\n paths: pathResolver,\n branches,\n budgets: { remaining: () => ({}), callsInLastMinute: () => 0 },\n programs,\n clock: ctx.clock,\n };\n const call: GateCall = {\n runId: 'run_policy_explain' as GateCall['runId'],\n agentId: 'agt_policy_explain' as GateCall['agentId'],\n incarnation: 1,\n toolCallId: 'tool_policy_explain' as GateCall['toolCallId'],\n tool: 'run_command',\n input: { argv, cwd: root, timeoutMs: 120_000 },\n phase: 'PREFLIGHT',\n role: 'policy-explain',\n };\n const verdict = explainPolicy(engine, call, grantFor(root, argv), policySnapshot, ports);\n ctx.stdio.stdout.write(`${JSON.stringify(verdict)}\\n`);\n return 0;\n },\n};\n\nexport default policy;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I,GAAG,gBAAgB,KAAK;EACvF,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,OAAO,EAAE,GAAG;EACrD,OAAO;CACT;AACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/commands/providers/index.ts
|
|
2
|
-
const PROVIDERS = ["openai-codex", "anthropic"];
|
|
3
|
-
const providers = {
|
|
4
|
-
verb: "providers",
|
|
5
|
-
async run(ctx, args) {
|
|
6
|
-
if (args.subVerb !== "list" && args.subVerb !== "test" && args.subVerb !== void 0) return 10;
|
|
7
|
-
const statuses = await ctx.runtime.resolve().authStatus([...PROVIDERS]);
|
|
8
|
-
if (args.subVerb === "test") {
|
|
9
|
-
for (const status of statuses) ctx.stdio.stdout.write(`${status.provider}: ${status.state}\n`);
|
|
10
|
-
return statuses.every((status) => status.state !== "unknown-transient") ? 0 : 1;
|
|
11
|
-
}
|
|
12
|
-
for (const provider of PROVIDERS) ctx.stdio.stdout.write(`${provider}\n`);
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { providers as default };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=providers-Dx78imKj.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers-Dx78imKj.mjs","names":[],"sources":["../../../../apps/cli/src/commands/providers/index.ts"],"sourcesContent":["// apps/cli/src/commands/providers/index.ts — DESIGN §9 verb `providers` (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/providers/**`.\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst PROVIDERS = ['openai-codex', 'anthropic'] as const;\n\nconst providers: CommandModule = {\n verb: 'providers',\n async run(ctx, args) {\n if (args.subVerb !== 'list' && args.subVerb !== 'test' && args.subVerb !== undefined) return 10;\n const statuses = await ctx.runtime.resolve().authStatus([...PROVIDERS]);\n if (args.subVerb === 'test') {\n for (const status of statuses) ctx.stdio.stdout.write(`${status.provider}: ${status.state}\\n`);\n return statuses.every((status) => status.state !== 'unknown-transient') ? 0 : 1;\n }\n for (const provider of PROVIDERS) ctx.stdio.stdout.write(`${provider}\\n`);\n return 0;\n },\n};\n\nexport default providers;\n"],"mappings":";AAMA,MAAM,YAAY,CAAC,gBAAgB,WAAW;AAE9C,MAAM,YAA2B;CAC/B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,IAAI,KAAK,YAAY,UAAU,KAAK,YAAY,UAAU,KAAK,YAAY,KAAA,GAAW,OAAO;EAC7F,MAAM,WAAW,MAAM,IAAI,QAAQ,QAAQ,CAAC,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;EACtE,IAAI,KAAK,YAAY,QAAQ;GAC3B,KAAK,MAAM,UAAU,UAAU,IAAI,MAAM,OAAO,MAAM,GAAG,OAAO,SAAS,IAAI,OAAO,MAAM,GAAG;GAC7F,OAAO,SAAS,OAAO,WAAW,OAAO,UAAU,mBAAmB,IAAI,IAAI;EAChF;EACA,KAAK,MAAM,YAAY,WAAW,IAAI,MAAM,OAAO,MAAM,GAAG,SAAS,GAAG;EACxE,OAAO;CACT;AACF"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { s as DEFAULT_CONFIG } from "./schema-Bq9qtgsd.mjs";
|
|
2
|
-
import { l as deriveDesiredState, n as planReconcile, t as applyReconcile } from "./src-DNsLSxgm.mjs";
|
|
3
|
-
import { t as scanRepository } from "./scan-C5uDr7Yq.mjs";
|
|
4
|
-
//#region src/commands/reconcile/index.ts
|
|
5
|
-
const reconcile = {
|
|
6
|
-
verb: "reconcile",
|
|
7
|
-
async run(ctx, args) {
|
|
8
|
-
const model = await scanRepository(ctx.cwd, {
|
|
9
|
-
clock: ctx.clock,
|
|
10
|
-
toolVersion: "3.0.0"
|
|
11
|
-
});
|
|
12
|
-
const plan = await planReconcile({
|
|
13
|
-
root: ctx.cwd,
|
|
14
|
-
scan: (root) => scanRepository(root, {
|
|
15
|
-
clock: ctx.clock,
|
|
16
|
-
toolVersion: "3.0.0"
|
|
17
|
-
}),
|
|
18
|
-
cohorteVersion: "3.0.0",
|
|
19
|
-
clock: ctx.clock
|
|
20
|
-
});
|
|
21
|
-
if (args.positionals.includes("--apply")) {
|
|
22
|
-
const result = await applyReconcile({
|
|
23
|
-
root: ctx.cwd,
|
|
24
|
-
plan,
|
|
25
|
-
desired: deriveDesiredState({
|
|
26
|
-
model,
|
|
27
|
-
config: DEFAULT_CONFIG,
|
|
28
|
-
cohorteVersion: "3.0.0",
|
|
29
|
-
skills: {}
|
|
30
|
-
}),
|
|
31
|
-
backup: !args.positionals.includes("--no-backup"),
|
|
32
|
-
clock: ctx.clock
|
|
33
|
-
});
|
|
34
|
-
if (args.json) ctx.stdio.stdout.write(`${JSON.stringify({
|
|
35
|
-
plan,
|
|
36
|
-
result
|
|
37
|
-
})}\n`);
|
|
38
|
-
else ctx.stdio.stdout.write(`applied: ${result.applied.join(", ") || "none"}\n`);
|
|
39
|
-
return 0;
|
|
40
|
-
}
|
|
41
|
-
if (!args.positionals.includes("--plan")) return 2;
|
|
42
|
-
if (args.json) ctx.stdio.stdout.write(`${JSON.stringify(plan)}\n`);
|
|
43
|
-
else ctx.stdio.stdout.write(`${plan.operations.length} operation(s) planned\n`);
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { reconcile as default };
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=reconcile-BHn66X3C.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-BHn66X3C.mjs","names":[],"sources":["../../../../apps/cli/src/commands/reconcile/index.ts"],"sourcesContent":["import { DEFAULT_CONFIG } from '@cohorte/config/schema';\nimport { applyReconcile, deriveDesiredState, planReconcile, scanRepository } from '@cohorte/project-model';\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst reconcile: CommandModule = {\n verb: 'reconcile',\n async run(ctx, args) {\n const model = await scanRepository(ctx.cwd, { clock: ctx.clock, toolVersion: '3.0.0' });\n const plan = await planReconcile({\n root: ctx.cwd,\n scan: (root) => scanRepository(root, { clock: ctx.clock, toolVersion: '3.0.0' }),\n cohorteVersion: '3.0.0',\n clock: ctx.clock,\n });\n if (args.positionals.includes('--apply')) {\n const result = await applyReconcile({\n root: ctx.cwd,\n plan,\n desired: deriveDesiredState({ model, config: DEFAULT_CONFIG, cohorteVersion: '3.0.0', skills: {} }),\n backup: !args.positionals.includes('--no-backup'),\n clock: ctx.clock,\n });\n if (args.json) ctx.stdio.stdout.write(`${JSON.stringify({ plan, result })}\\n`);\n else ctx.stdio.stdout.write(`applied: ${result.applied.join(', ') || 'none'}\\n`);\n return 0;\n }\n if (!args.positionals.includes('--plan')) return 2;\n if (args.json) ctx.stdio.stdout.write(`${JSON.stringify(plan)}\\n`);\n else ctx.stdio.stdout.write(`${plan.operations.length} operation(s) planned\\n`);\n return 0;\n },\n};\n\nexport default reconcile;\n"],"mappings":";;;;AAIA,MAAM,YAA2B;CAC/B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,QAAQ,MAAM,eAAe,IAAI,KAAK;GAAE,OAAO,IAAI;GAAO,aAAa;EAAQ,CAAC;EACtF,MAAM,OAAO,MAAM,cAAc;GAC/B,MAAM,IAAI;GACV,OAAO,SAAS,eAAe,MAAM;IAAE,OAAO,IAAI;IAAO,aAAa;GAAQ,CAAC;GAC/E,gBAAgB;GAChB,OAAO,IAAI;EACb,CAAC;EACD,IAAI,KAAK,YAAY,SAAS,SAAS,GAAG;GACxC,MAAM,SAAS,MAAM,eAAe;IAClC,MAAM,IAAI;IACV;IACA,SAAS,mBAAmB;KAAE;KAAO,QAAQ;KAAgB,gBAAgB;KAAS,QAAQ,CAAC;IAAE,CAAC;IAClG,QAAQ,CAAC,KAAK,YAAY,SAAS,aAAa;IAChD,OAAO,IAAI;GACb,CAAC;GACD,IAAI,KAAK,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU;IAAE;IAAM;GAAO,CAAC,EAAE,GAAG;QACxE,IAAI,MAAM,OAAO,MAAM,YAAY,OAAO,QAAQ,KAAK,IAAI,KAAK,OAAO,GAAG;GAC/E,OAAO;EACT;EACA,IAAI,CAAC,KAAK,YAAY,SAAS,QAAQ,GAAG,OAAO;EACjD,IAAI,KAAK,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,IAAI,EAAE,GAAG;OAC5D,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,WAAW,OAAO,wBAAwB;EAC9E,OAAO;CACT;AACF"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { r as specContentSha256 } from "./schema-Bq9qtgsd.mjs";
|
|
2
|
-
import { t as run } from "./run-BGabwbDL.mjs";
|
|
3
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { parse, stringify } from "yaml";
|
|
6
|
-
import { execFile } from "node:child_process";
|
|
7
|
-
import { promisify } from "node:util";
|
|
8
|
-
//#region src/commands/refactor/index.ts
|
|
9
|
-
const exec = promisify(execFile);
|
|
10
|
-
async function configuredGates(root) {
|
|
11
|
-
try {
|
|
12
|
-
const source = await readFile(join(root, "PIPELINE.md"), "utf8");
|
|
13
|
-
const block = /```yaml pipeline-profile\s*\n([\s\S]*?)\n```/u.exec(source)?.[1];
|
|
14
|
-
const commands = block ? parse(block).commands : void 0;
|
|
15
|
-
if (!commands) return [];
|
|
16
|
-
return [
|
|
17
|
-
"format",
|
|
18
|
-
"lint",
|
|
19
|
-
"typecheck",
|
|
20
|
-
"test"
|
|
21
|
-
].map((key) => commands[key]).filter((value) => typeof value === "string" && value.length > 0 && !value.startsWith("<"));
|
|
22
|
-
} catch {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function verifyDomain(root, domain) {
|
|
27
|
-
const commands = await configuredGates(root);
|
|
28
|
-
if (!commands.length) return 0;
|
|
29
|
-
const results = [];
|
|
30
|
-
let status = 0;
|
|
31
|
-
for (const command of commands) try {
|
|
32
|
-
const result = await exec("sh", ["-lc", command], {
|
|
33
|
-
cwd: root,
|
|
34
|
-
maxBuffer: 2e6
|
|
35
|
-
});
|
|
36
|
-
results.push(`$ ${command}\n${result.stdout || "(no output)"}${result.stderr || ""}`);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
const failure = error;
|
|
39
|
-
results.push(`$ ${command}\n${failure.stdout ?? ""}${failure.stderr ?? failure.message ?? String(error)}`);
|
|
40
|
-
status = 15;
|
|
41
|
-
}
|
|
42
|
-
await mkdir(join(root, "specs", "reports"), { recursive: true });
|
|
43
|
-
await writeFile(join(root, "specs", "reports", `refactor-verify.${domain}.txt`), `${results.join("\n\n")}\n`, "utf8");
|
|
44
|
-
return status;
|
|
45
|
-
}
|
|
46
|
-
const refactor = {
|
|
47
|
-
verb: "refactor",
|
|
48
|
-
async run(ctx, args) {
|
|
49
|
-
const backlogPath = join(ctx.cwd, "specs", "refactor-backlog.md");
|
|
50
|
-
let source;
|
|
51
|
-
try {
|
|
52
|
-
source = await readFile(backlogPath, "utf8");
|
|
53
|
-
} catch {
|
|
54
|
-
ctx.stdio.stderr.write(`backlog not found: ${backlogPath}\n`);
|
|
55
|
-
return 1;
|
|
56
|
-
}
|
|
57
|
-
const requested = args.positionals.filter((value) => !value.startsWith("--"));
|
|
58
|
-
const headings = [...source.matchAll(/^##\s+([^\n]+)$/gmu)];
|
|
59
|
-
const domains = requested.includes("all") || requested.length === 0 ? headings.map((match) => match[1]?.trim()).filter((x) => Boolean(x)) : requested;
|
|
60
|
-
if (!domains.length) return 2;
|
|
61
|
-
const completed = [];
|
|
62
|
-
const outcomes = [];
|
|
63
|
-
await mkdir(join(ctx.cwd, "specs", "reports"), { recursive: true });
|
|
64
|
-
const runDomain = async (domain) => {
|
|
65
|
-
const start = headings.find((match) => match[1]?.trim() === domain)?.index ?? -1;
|
|
66
|
-
const next = start < 0 ? -1 : source.indexOf("\n## ", start + 1);
|
|
67
|
-
const tasks = (start < 0 ? "" : source.slice(start, next < 0 ? source.length : next)).split(/\r?\n/u).filter((line) => /^- \[ \]/u.test(line));
|
|
68
|
-
if (!tasks.length) return 0;
|
|
69
|
-
if (tasks.length < 5) {
|
|
70
|
-
outcomes.push({
|
|
71
|
-
domain,
|
|
72
|
-
tasks,
|
|
73
|
-
status: 0,
|
|
74
|
-
attempts: 0,
|
|
75
|
-
skipped: true,
|
|
76
|
-
reason: "small backlog: use the conversational refactor workflow"
|
|
77
|
-
});
|
|
78
|
-
return 0;
|
|
79
|
-
}
|
|
80
|
-
const id = `refactor-${domain.toLowerCase().replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "")}`;
|
|
81
|
-
const draft = {
|
|
82
|
-
id,
|
|
83
|
-
kind: "feature",
|
|
84
|
-
status: "draft",
|
|
85
|
-
title: `Refactor ${domain}`,
|
|
86
|
-
acceptance: tasks.map((task) => task.replace(/^- \[ \]\s*/u, "")),
|
|
87
|
-
surfaces: { [domain]: { tasks } },
|
|
88
|
-
openQuestions: []
|
|
89
|
-
};
|
|
90
|
-
const spec = {
|
|
91
|
-
...draft,
|
|
92
|
-
status: "frozen",
|
|
93
|
-
sha256: specContentSha256(draft)
|
|
94
|
-
};
|
|
95
|
-
const path = join(ctx.cwd, ".cohorte", "specs", `${id}.yaml`);
|
|
96
|
-
await mkdir(join(ctx.cwd, ".cohorte", "specs"), { recursive: true });
|
|
97
|
-
await writeFile(path, stringify(spec), "utf8");
|
|
98
|
-
const first = await run.run(ctx, {
|
|
99
|
-
...args,
|
|
100
|
-
positionals: [
|
|
101
|
-
path,
|
|
102
|
-
"--profile",
|
|
103
|
-
"feature",
|
|
104
|
-
"--phases",
|
|
105
|
-
"BUILD,TEST,REVIEW",
|
|
106
|
-
"--with-fix"
|
|
107
|
-
]
|
|
108
|
-
});
|
|
109
|
-
const firstGates = first === 0 ? await verifyDomain(ctx.cwd, domain) : 0;
|
|
110
|
-
const result = first === 3 || firstGates !== 0 ? await run.run(ctx, {
|
|
111
|
-
...args,
|
|
112
|
-
positionals: [
|
|
113
|
-
path,
|
|
114
|
-
"--profile",
|
|
115
|
-
"feature",
|
|
116
|
-
"--phases",
|
|
117
|
-
"BUILD,TEST,REVIEW",
|
|
118
|
-
"--with-fix"
|
|
119
|
-
]
|
|
120
|
-
}) : first;
|
|
121
|
-
const finalGates = result === 0 ? await verifyDomain(ctx.cwd, domain) : 0;
|
|
122
|
-
const status = finalGates !== 0 ? finalGates : result;
|
|
123
|
-
outcomes.push({
|
|
124
|
-
domain,
|
|
125
|
-
spec: path,
|
|
126
|
-
tasks,
|
|
127
|
-
status,
|
|
128
|
-
attempts: first === 3 || firstGates !== 0 ? 2 : 1
|
|
129
|
-
});
|
|
130
|
-
if (status === 0) completed.push({
|
|
131
|
-
domain,
|
|
132
|
-
tasks
|
|
133
|
-
});
|
|
134
|
-
return status;
|
|
135
|
-
};
|
|
136
|
-
const ordered = domains.includes("shared") ? ["shared", ...domains.filter((domain) => domain !== "shared")] : domains;
|
|
137
|
-
const sharedStatus = ordered[0] === "shared" ? await runDomain("shared") : 0;
|
|
138
|
-
const parallelDomains = ordered[0] === "shared" ? ordered.slice(1) : ordered;
|
|
139
|
-
const statuses = sharedStatus === 0 ? await Promise.all(parallelDomains.map((domain) => runDomain(domain))) : [];
|
|
140
|
-
for (const item of completed) source = source.split(/\r?\n/u).map((line) => line.startsWith("- [ ] ") && item.tasks.includes(line) ? line.replace("- [ ] ", "- [x] ") : line).join("\n");
|
|
141
|
-
await writeFile(backlogPath, `${source}\n`, "utf8");
|
|
142
|
-
await writeFile(join(ctx.cwd, "specs", "reports", "refactor.json"), `${JSON.stringify({
|
|
143
|
-
generatedAt: ctx.clock.now(),
|
|
144
|
-
domains,
|
|
145
|
-
outcomes
|
|
146
|
-
}, null, 2)}\n`, "utf8");
|
|
147
|
-
return Math.max(sharedStatus, ...statuses, 0);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
//#endregion
|
|
151
|
-
export { refactor as default };
|
|
152
|
-
|
|
153
|
-
//# sourceMappingURL=refactor-DV3RfGjk.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refactor-DV3RfGjk.mjs","names":[],"sources":["../../../../apps/cli/src/commands/refactor/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { specContentSha256 } from '@cohorte/config/schema';\nimport { parse, stringify } from 'yaml';\nimport type { CommandModule } from '../../contract/index.ts';\nimport run from '../run/index.ts';\n\nconst exec = promisify(execFile);\n\nasync function configuredGates(root: string): Promise<string[]> {\n try {\n const source = await readFile(join(root, 'PIPELINE.md'), 'utf8');\n const block = /```yaml pipeline-profile\\s*\\n([\\s\\S]*?)\\n```/u.exec(source)?.[1];\n const commands = block ? (parse(block) as { commands?: Record<string, unknown> }).commands : undefined;\n if (!commands) return [];\n return ['format', 'lint', 'typecheck', 'test']\n .map((key) => commands[key])\n .filter((value): value is string => typeof value === 'string' && value.length > 0 && !value.startsWith('<'));\n } catch {\n return [];\n }\n}\n\nasync function verifyDomain(root: string, domain: string): Promise<number> {\n const commands = await configuredGates(root);\n if (!commands.length) return 0;\n const results: string[] = [];\n let status = 0;\n for (const command of commands) {\n try {\n const result = await exec('sh', ['-lc', command], { cwd: root, maxBuffer: 2_000_000 });\n results.push(`$ ${command}\\n${result.stdout || '(no output)'}${result.stderr || ''}`);\n } catch (error) {\n const failure = error as { stdout?: string; stderr?: string; message?: string };\n results.push(`$ ${command}\\n${failure.stdout ?? ''}${failure.stderr ?? failure.message ?? String(error)}`);\n status = 15;\n }\n }\n await mkdir(join(root, 'specs', 'reports'), { recursive: true });\n await writeFile(join(root, 'specs', 'reports', `refactor-verify.${domain}.txt`), `${results.join('\\n\\n')}\\n`, 'utf8');\n return status;\n}\n\nconst refactor: CommandModule = {\n verb: 'refactor',\n async run(ctx, args) {\n const backlogPath = join(ctx.cwd, 'specs', 'refactor-backlog.md');\n let source: string;\n try {\n source = await readFile(backlogPath, 'utf8');\n } catch {\n ctx.stdio.stderr.write(`backlog not found: ${backlogPath}\\n`);\n return 1;\n }\n const requested = args.positionals.filter((value) => !value.startsWith('--'));\n const headings = [...source.matchAll(/^##\\s+([^\\n]+)$/gmu)];\n const domains =\n requested.includes('all') || requested.length === 0\n ? headings.map((match) => match[1]?.trim()).filter((x): x is string => Boolean(x))\n : requested;\n if (!domains.length) return 2;\n const completed: Array<{ domain: string; tasks: string[] }> = [];\n const outcomes: Array<{\n domain: string;\n spec?: string;\n tasks: string[];\n status: number;\n attempts: number;\n skipped?: boolean;\n reason?: string;\n }> = [];\n await mkdir(join(ctx.cwd, 'specs', 'reports'), { recursive: true });\n const runDomain = async (domain: string): Promise<number> => {\n const heading = headings.find((match) => match[1]?.trim() === domain);\n const start = heading?.index ?? -1;\n const next = start < 0 ? -1 : source.indexOf('\\n## ', start + 1);\n const block = start < 0 ? '' : source.slice(start, next < 0 ? source.length : next);\n const tasks = block.split(/\\r?\\n/u).filter((line) => /^- \\[ \\]/u.test(line));\n if (!tasks.length) return 0;\n if (tasks.length < 5) {\n outcomes.push({\n domain,\n tasks,\n status: 0,\n attempts: 0,\n skipped: true,\n reason: 'small backlog: use the conversational refactor workflow',\n });\n return 0;\n }\n const id = `refactor-${domain\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-|-$/gu, '')}`;\n const draft = {\n id,\n kind: 'feature' as const,\n status: 'draft' as const,\n title: `Refactor ${domain}`,\n acceptance: tasks.map((task) => task.replace(/^- \\[ \\]\\s*/u, '')),\n surfaces: { [domain]: { tasks } },\n openQuestions: [],\n };\n const spec = { ...draft, status: 'frozen' as const, sha256: specContentSha256(draft) };\n const path = join(ctx.cwd, '.cohorte', 'specs', `${id}.yaml`);\n await mkdir(join(ctx.cwd, '.cohorte', 'specs'), { recursive: true });\n await writeFile(path, stringify(spec), 'utf8');\n const first = await run.run(ctx, {\n ...args,\n positionals: [path, '--profile', 'feature', '--phases', 'BUILD,TEST,REVIEW', '--with-fix'],\n });\n const firstGates = first === 0 ? await verifyDomain(ctx.cwd, domain) : 0;\n const result =\n first === 3 || firstGates !== 0\n ? await run.run(ctx, {\n ...args,\n positionals: [path, '--profile', 'feature', '--phases', 'BUILD,TEST,REVIEW', '--with-fix'],\n })\n : first;\n const finalGates = result === 0 ? await verifyDomain(ctx.cwd, domain) : 0;\n const status = finalGates !== 0 ? finalGates : result;\n outcomes.push({ domain, spec: path, tasks, status, attempts: first === 3 || firstGates !== 0 ? 2 : 1 });\n if (status === 0) {\n completed.push({ domain, tasks });\n }\n return status;\n };\n\n // V2 deliberately serialises the shared contract slice, then fans out\n // disjoint surfaces. Keeping that ordering avoids parallel agents editing\n // the same contract while retaining the wall-clock win for independent\n // domains.\n const ordered = domains.includes('shared')\n ? ['shared', ...domains.filter((domain) => domain !== 'shared')]\n : domains;\n const sharedStatus = ordered[0] === 'shared' ? await runDomain('shared') : 0;\n const parallelDomains = ordered[0] === 'shared' ? ordered.slice(1) : ordered;\n const statuses = sharedStatus === 0 ? await Promise.all(parallelDomains.map((domain) => runDomain(domain))) : [];\n for (const item of completed) {\n source = source\n .split(/\\r?\\n/u)\n .map((line) =>\n line.startsWith('- [ ] ') && item.tasks.includes(line) ? line.replace('- [ ] ', '- [x] ') : line,\n )\n .join('\\n');\n }\n await writeFile(backlogPath, `${source}\\n`, 'utf8');\n await writeFile(\n join(ctx.cwd, 'specs', 'reports', 'refactor.json'),\n `${JSON.stringify({ generatedAt: ctx.clock.now(), domains, outcomes }, null, 2)}\\n`,\n 'utf8',\n );\n return Math.max(sharedStatus, ...statuses, 0);\n },\n};\n\nexport default refactor;\n"],"mappings":";;;;;;;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C,UAAU,GAAG,QAAQ,QAAQ,WAAW,WAAW,QAAQ,CAAC,IAC7D;EACJ,MAAM,eAAe,QAAQ,OAAO,WAAW,MAAM,UAAU,QAAQ,IAAI;EAC3E,MAAM,kBAAkB,QAAQ,OAAO,WAAW,QAAQ,MAAM,CAAC,IAAI;EACrE,MAAM,WAAW,iBAAiB,IAAI,MAAM,QAAQ,IAAI,gBAAgB,KAAK,WAAW,UAAU,MAAM,CAAC,CAAC,IAAI,CAAC;EAC/G,KAAK,MAAM,QAAQ,WACjB,SAAS,OACN,MAAM,QAAQ,CAAC,CACf,KAAK,SACJ,KAAK,WAAW,QAAQ,KAAK,KAAK,MAAM,SAAS,IAAI,IAAI,KAAK,QAAQ,UAAU,QAAQ,IAAI,IAC9F,CAAC,CACA,KAAK,IAAI;EAEd,MAAM,UAAU,aAAa,GAAG,OAAO,KAAK,MAAM;EAClD,MAAM,UACJ,KAAK,IAAI,KAAK,SAAS,WAAW,eAAe,GACjD,GAAG,KAAK,UAAU;GAAE,aAAa,IAAI,MAAM,IAAI;GAAG;GAAS;EAAS,GAAG,MAAM,CAAC,EAAE,KAChF,MACF;EACA,OAAO,KAAK,IAAI,cAAc,GAAG,UAAU,CAAC;CAC9C;AACF"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
//#region src/panels/index.ts
|
|
2
|
-
const PANELS = Object.freeze({ status: async (ctx) => {
|
|
3
|
-
const store = await ctx.openStore();
|
|
4
|
-
try {
|
|
5
|
-
const runs = await store.listRuns({
|
|
6
|
-
limit: 20,
|
|
7
|
-
offset: 0
|
|
8
|
-
});
|
|
9
|
-
for (const run of runs) ctx.stdio.stdout.write(`${run.runId} ${run.state}\n`);
|
|
10
|
-
return 0;
|
|
11
|
-
} finally {
|
|
12
|
-
await store.close();
|
|
13
|
-
}
|
|
14
|
-
} });
|
|
15
|
-
function resolvePanel(kind) {
|
|
16
|
-
const panel = PANELS[kind];
|
|
17
|
-
if (!panel) throw new RangeError(`unknown panel kind: ${kind}`);
|
|
18
|
-
return panel;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/render/sanitize.ts
|
|
22
|
-
/** Escape terminal control bytes for human-facing output. JSON is never passed here. */
|
|
23
|
-
function sanitizeHuman(value) {
|
|
24
|
-
let result = "";
|
|
25
|
-
for (const char of value) {
|
|
26
|
-
const code = char.codePointAt(0) ?? 0;
|
|
27
|
-
if (char === "\n" || char === " " || code >= 32 && code !== 127 && !(code >= 128 && code <= 159)) result += char;
|
|
28
|
-
else result += `\\x${code.toString(16).padStart(2, "0").toUpperCase()}`;
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/render/index.ts
|
|
34
|
-
function createRenderer() {
|
|
35
|
-
return {
|
|
36
|
-
json(value) {
|
|
37
|
-
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
38
|
-
},
|
|
39
|
-
line(text) {
|
|
40
|
-
process.stdout.write(`${sanitizeHuman(text)}\n`);
|
|
41
|
-
},
|
|
42
|
-
async panel(kind, ctx) {
|
|
43
|
-
return resolvePanel(kind)(ctx);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function writeHuman(ctx, text) {
|
|
48
|
-
ctx.stdio.stdout.write(`${sanitizeHuman(text)}\n`);
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { writeHuman as n, createRenderer as t };
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=render-DyZr5Lgi.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-DyZr5Lgi.mjs","names":[],"sources":["../../../../apps/cli/src/panels/index.ts","../../../../apps/cli/src/render/sanitize.ts","../../../../apps/cli/src/render/index.ts"],"sourcesContent":["// apps/cli/src/panels/index.ts — AREA barrel: the `--panel` interactive views (francois.md), one function per\n// panel kind, looked up by `render/index.ts`. Wave-0 stub: filled by `U4.04`, which owns `apps/cli/src/panels/**`.\nimport type { CliContext } from '../contract/index.ts';\n\nexport type Panel = (ctx: CliContext) => Promise<number>;\n\nexport const PANELS: Readonly<Record<string, Panel>> = Object.freeze({\n status: async (ctx) => {\n const store = await ctx.openStore();\n try {\n const runs = await store.listRuns({ limit: 20, offset: 0 });\n for (const run of runs) ctx.stdio.stdout.write(`${run.runId} ${run.state}\\n`);\n return 0;\n } finally {\n await store.close();\n }\n },\n});\n\nexport function resolvePanel(kind: string): Panel {\n const panel = PANELS[kind];\n if (!panel) throw new RangeError(`unknown panel kind: ${kind}`);\n return panel;\n}\n","/** Escape terminal control bytes for human-facing output. JSON is never passed here. */\nexport function sanitizeHuman(value: string): string {\n let result = '';\n for (const char of value) {\n const code = char.codePointAt(0) ?? 0;\n if (char === '\\n' || char === '\\t' || (code >= 0x20 && code !== 0x7f && !(code >= 0x80 && code <= 0x9f))) {\n result += char;\n } else {\n result += `\\\\x${code.toString(16).padStart(2, '0').toUpperCase()}`;\n }\n }\n return result;\n}\n","// apps/cli/src/render/index.ts — AREA barrel: the `Renderer` port (document / NDJSON-line / `--panel` output,\n// francois.md \"10 s / 4 MiB\" one-shot budget). Wave-0 stub: filled by `U4.04`, which owns `apps/cli/src/render/**`.\nimport type { Renderer } from '../contract/index.ts';\nimport { resolvePanel } from '../panels/index.ts';\nimport { sanitizeHuman } from './sanitize.ts';\n\nexport function createRenderer(): Renderer {\n return {\n json(value) {\n process.stdout.write(`${JSON.stringify(value)}\\n`);\n },\n line(text) {\n process.stdout.write(`${sanitizeHuman(text)}\\n`);\n },\n async panel(kind, ctx) {\n return resolvePanel(kind)(ctx);\n },\n };\n}\n\nexport function writeHuman(ctx: { readonly stdio: { readonly stdout: NodeJS.WritableStream } }, text: string): void {\n ctx.stdio.stdout.write(`${sanitizeHuman(text)}\\n`);\n}\n"],"mappings":";AAMA,MAAa,SAA0C,OAAO,OAAO,EACnE,QAAQ,OAAO,QAAQ;CACrB,MAAM,QAAQ,MAAM,IAAI,UA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-
const runId = args.positionals[0];
|
|
6
|
-
if (!runId) return 2;
|
|
7
|
-
const result = await ctx.controller.send("resume", {}, { runId });
|
|
8
|
-
ctx.stdio.stdout.write(`${JSON.stringify(result)}\n`);
|
|
9
|
-
return result.status === "rejected" ? 3 : result.status === "pending" ? 4 : 0;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { resume as default };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=resume-GJQRb2Eb.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resume-GJQRb2Eb.mjs","names":[],"sources":["../../../../apps/cli/src/commands/resume/index.ts"],"sourcesContent":["// apps/cli/src/commands/resume/index.ts — DESIGN §9 verb `resume` (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/resume/**`.\nimport type { CommandModule } from '../../contract/index.ts';\n\nconst resume: CommandModule = {\n verb: 'resume',\n async run(ctx, args) {\n const runId = args.positionals[0];\n if (!runId) return 2;\n const result = await ctx.controller.send('resume', {}, { runId });\n ctx.stdio.stdout.write(`${JSON.stringify(result)}\\n`);\n return result.status === 'rejected' ? 3 : result.status === 'pending' ? 4 : 0;\n },\n};\n\nexport default resume;\n"],"mappings":";AAMA,MAAM,SAAwB;CAC5B,MAAM;CACN,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,QAAQ,KAAK,YAAY;EAC/B,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,SAAS,MAAM,IAAI,WAAW,KAAK,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;EAChE,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;EACpD,OAAO,OAAO,WAAW,aAAa,IAAI,OAAO,WAAW,YAAY,IAAI;CAC9E;AACF"}
|