@devcxl/opencode-cabbage 1.3.0 → 2.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.
Files changed (89) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/README.md +35 -23
  3. package/README.zh.md +22 -15
  4. package/assets/agents/dev-lifecycle.md +6 -0
  5. package/assets/prompts/bootstrap.md +4 -0
  6. package/assets/skills/flow-change/SKILL.md +109 -0
  7. package/assets/skills/flow-design/SKILL.md +15 -0
  8. package/assets/skills/flow-docs/SKILL.md +112 -0
  9. package/assets/skills/flow-incident/SKILL.md +98 -0
  10. package/assets/skills/flow-research/SKILL.md +9 -0
  11. package/assets/skills/flow-setup/SKILL.md +13 -0
  12. package/codex-skills/agent-dev-lifecycle/SKILL.md +2 -0
  13. package/codex-skills/flow-change/SKILL.md +109 -0
  14. package/codex-skills/flow-design/SKILL.md +18 -3
  15. package/codex-skills/flow-docs/SKILL.md +112 -0
  16. package/codex-skills/flow-incident/SKILL.md +98 -0
  17. package/codex-skills/flow-research/SKILL.md +12 -3
  18. package/codex-skills/flow-setup/SKILL.md +13 -0
  19. package/dist/index.d.ts +2 -5
  20. package/dist/index.js +1 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/plugin/agents.d.ts +20 -0
  23. package/dist/plugin/agents.js +79 -0
  24. package/dist/plugin/agents.js.map +1 -1
  25. package/dist/plugin/cabbage-cli.d.ts +28 -0
  26. package/dist/plugin/cabbage-cli.js +92 -0
  27. package/dist/plugin/cabbage-cli.js.map +1 -0
  28. package/dist/plugin/cabbage-tool.d.ts +103 -0
  29. package/dist/plugin/cabbage-tool.js +169 -0
  30. package/dist/plugin/cabbage-tool.js.map +1 -0
  31. package/dist/plugin/commands.d.ts +10 -0
  32. package/dist/plugin/commands.js +1 -1
  33. package/dist/plugin/commands.js.map +1 -1
  34. package/dist/plugin/continuation.d.ts +22 -0
  35. package/dist/plugin/continuation.js +233 -0
  36. package/dist/plugin/continuation.js.map +1 -0
  37. package/dist/plugin/goal-store.d.ts +42 -49
  38. package/dist/plugin/goal-store.js +35 -32
  39. package/dist/plugin/goal-store.js.map +1 -1
  40. package/dist/plugin/goal.d.ts +92 -28
  41. package/dist/plugin/goal.js +201 -158
  42. package/dist/plugin/goal.js.map +1 -1
  43. package/dist/plugin/install-dir.d.ts +13 -0
  44. package/dist/plugin/install-dir.js +46 -0
  45. package/dist/plugin/install-dir.js.map +1 -0
  46. package/dist/plugin/server.d.ts +4 -13
  47. package/dist/plugin/server.js +278 -423
  48. package/dist/plugin/server.js.map +1 -1
  49. package/dist/plugin/session-abort.d.ts +5 -0
  50. package/dist/plugin/session-abort.js +26 -0
  51. package/dist/plugin/session-abort.js.map +1 -0
  52. package/dist/plugin/skills.d.ts +15 -0
  53. package/dist/plugin/skills.js +47 -50
  54. package/dist/plugin/skills.js.map +1 -1
  55. package/dist/plugin.d.ts +2 -2
  56. package/dist/plugin.js +6 -2
  57. package/dist/plugin.js.map +1 -1
  58. package/dist/util/paths.d.ts +0 -6
  59. package/dist/util/paths.js +0 -15
  60. package/dist/util/paths.js.map +1 -1
  61. package/package.json +4 -7
  62. package/vendor/cabbage/MANIFEST.json +8 -0
  63. package/vendor/cabbage/cabbage_cli/__init__.py +1 -0
  64. package/vendor/cabbage/cabbage_cli/__main__.py +2 -0
  65. package/vendor/cabbage/cabbage_cli/assets/docs-site/.vitepress/config.ts +78 -0
  66. package/vendor/cabbage/cabbage_cli/assets/docs-site/README.md +31 -0
  67. package/vendor/cabbage/cabbage_cli/assets/docs-site/package.json +16 -0
  68. package/vendor/cabbage/cabbage_cli/assets/docs-site/pnpm-lock.yaml +2504 -0
  69. package/vendor/cabbage/cabbage_cli/assets/integrations/cabbage.yml +127 -0
  70. package/vendor/cabbage/cabbage_cli/assets/templates/adr.md +47 -0
  71. package/vendor/cabbage/cabbage_cli/assets/templates/api-design.md +45 -0
  72. package/vendor/cabbage/cabbage_cli/assets/templates/change-record.md +21 -0
  73. package/vendor/cabbage/cabbage_cli/assets/templates/database-design.md +37 -0
  74. package/vendor/cabbage/cabbage_cli/assets/templates/generic.md +20 -0
  75. package/vendor/cabbage/cabbage_cli/assets/templates/impact.md +41 -0
  76. package/vendor/cabbage/cabbage_cli/assets/templates/incident.md +48 -0
  77. package/vendor/cabbage/cabbage_cli/assets/templates/postmortem.md +43 -0
  78. package/vendor/cabbage/cabbage_cli/assets/templates/prd.md +71 -0
  79. package/vendor/cabbage/cabbage_cli/assets/templates/release-plan.md +45 -0
  80. package/vendor/cabbage/cabbage_cli/assets/templates/rfc.md +44 -0
  81. package/vendor/cabbage/cabbage_cli/assets/templates/security-review.md +35 -0
  82. package/vendor/cabbage/cabbage_cli/assets/templates/tasks.md +62 -0
  83. package/vendor/cabbage/cabbage_cli/assets/templates/tech-spec.md +87 -0
  84. package/vendor/cabbage/cabbage_cli/assets/templates/test-plan.md +44 -0
  85. package/vendor/cabbage/cabbage_cli/assets/workflows/change.yaml +11 -0
  86. package/vendor/cabbage/cabbage_cli/assets/workflows/incident.yaml +4 -0
  87. package/vendor/cabbage/cabbage_cli/cli.py +283 -0
  88. package/vendor/cabbage/cabbage_cli/core.py +606 -0
  89. package/vendor/cabbage/cabbage_cli/scaffold.py +313 -0
@@ -0,0 +1,92 @@
1
+ import { execFile } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import { ensureInstalledDir } from "./install-dir.js";
7
+ const execFileAsync = promisify(execFile);
8
+ /** CLI 释放目录(按插件版本隔离);env CABBAGE_CLI_DIR 可覆盖,方便测试。 */
9
+ function resolveCliDir(version) {
10
+ if (process.env.CABBAGE_CLI_DIR) {
11
+ return path.join(process.env.CABBAGE_CLI_DIR, `cli@${version}`);
12
+ }
13
+ return path.join(homedir(), ".config", "opencode", "cabbage", `cli@${version}`);
14
+ }
15
+ /** 探测可用的 Python 解释器(python3 优先);均不可用返回 null。 */
16
+ export async function detectPython() {
17
+ for (const candidate of ["python3", "python"]) {
18
+ try {
19
+ await execFileAsync(candidate, ["--version"], { timeout: 5_000 });
20
+ return candidate;
21
+ }
22
+ catch {
23
+ // 尝试下一个候选
24
+ }
25
+ }
26
+ return null;
27
+ }
28
+ function errorMessage(err) {
29
+ return err?.message ?? String(err);
30
+ }
31
+ export async function setupCabbageCli(packageRoot, version) {
32
+ const sourceDir = path.join(packageRoot, "vendor", "cabbage", "cabbage_cli");
33
+ const python = await detectPython();
34
+ if (!python) {
35
+ return {
36
+ available: false,
37
+ python: null,
38
+ dir: null,
39
+ version: null,
40
+ reason: "Python 3.10+ not found on PATH; install Python or the bundled cabbage engine cannot run",
41
+ };
42
+ }
43
+ const dir = resolveCliDir(version);
44
+ try {
45
+ // Python 包必须位于 <dir>/cabbage_cli(PYTHONPATH=<dir> 时可按包名导入)
46
+ await ensureInstalledDir({
47
+ sourceDir,
48
+ destDir: path.join(dir, "cabbage_cli"),
49
+ isComplete: async (d) => existsSync(path.join(d, "__main__.py")),
50
+ });
51
+ }
52
+ catch (err) {
53
+ return { available: false, python, dir: null, version: null, reason: `failed to install the bundled cabbage CLI: ${errorMessage(err)}` };
54
+ }
55
+ try {
56
+ const { stdout } = await execFileAsync(python, ["-m", "cabbage_cli", "--version"], {
57
+ cwd: dir,
58
+ env: { ...process.env, PYTHONPATH: dir },
59
+ timeout: 15_000,
60
+ });
61
+ return { available: true, python, dir, version: stdout.trim(), reason: null };
62
+ }
63
+ catch (err) {
64
+ return { available: false, python, dir, version: null, reason: `bundled cabbage CLI failed to run: ${errorMessage(err)}` };
65
+ }
66
+ }
67
+ /**
68
+ * 执行一次 cabbage 子命令。非零退出以结果返回(code/stdout/stderr),
69
+ * 仅进程无法启动(如解释器消失)才抛错——调用方按 CLI 语义处理退出码。
70
+ */
71
+ export async function runCabbage(cli, args, cwd) {
72
+ if (!cli.available || !cli.python || !cli.dir) {
73
+ throw new Error(cli.reason ?? "cabbage CLI unavailable");
74
+ }
75
+ try {
76
+ const { stdout, stderr } = await execFileAsync(cli.python, ["-m", "cabbage_cli", ...args], {
77
+ cwd,
78
+ env: { ...process.env, PYTHONPATH: cli.dir },
79
+ timeout: 120_000,
80
+ maxBuffer: 4 * 1024 * 1024,
81
+ });
82
+ return { code: 0, stdout: stdout.toString(), stderr: stderr.toString() };
83
+ }
84
+ catch (err) {
85
+ const e = err;
86
+ if (typeof e.code === "number") {
87
+ return { code: e.code, stdout: String(e.stdout ?? ""), stderr: String(e.stderr ?? "") };
88
+ }
89
+ throw err;
90
+ }
91
+ }
92
+ //# sourceMappingURL=cabbage-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cabbage-cli.js","sourceRoot":"","sources":["../../src/plugin/cabbage-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAyBzC,sDAAsD;AACtD,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,OAAO,EAAE,CAAC,CAAA;IACjE,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,OAAO,EAAE,CAAC,CAAA;AACjF,CAAC;AAED,gDAAgD;AAChD,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,KAAK,MAA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,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,GAAG,EAAE;YAC5C,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;SAC3B,CAAC,CAAA;QACF,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC1E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,GAAG,GAA6D,CAAA;QACvE,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAA;QACzF,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,103 @@
1
+ import type { CabbageCliRuntime } from "./cabbage-cli.js";
2
+ /**
3
+ * `cabbage` 工具:把内置 Cabbage 引擎(变更记录 / 任务与文档 / 验证与归档)暴露为
4
+ * 一等工具。与 goal 工具相同的双层门控:权限规则层(agent permissions)隐藏/放行,
5
+ * 工具内自检兜底(仅 dev-lifecycle 编排器可用)。
6
+ */
7
+ export declare const CABBAGE_ALLOWED_AGENTS: Set<string>;
8
+ export interface CabbageToolInput {
9
+ op: "init" | "new" | "status" | "next" | "impact" | "validate" | "verify" | "gate" | "sync" | "archive" | "tasks" | "discard" | "adopt";
10
+ change?: string;
11
+ stage?: string;
12
+ target?: string;
13
+ type?: "change" | "incident";
14
+ impact?: string[];
15
+ }
16
+ export interface CabbageToolContext {
17
+ sessionID: string;
18
+ agent?: string;
19
+ }
20
+ export interface CabbageToolResult {
21
+ content: string;
22
+ }
23
+ export declare const CABBAGE_TOOL_INPUT_SCHEMA: {
24
+ readonly type: "object";
25
+ readonly properties: {
26
+ readonly op: {
27
+ readonly type: "string";
28
+ readonly enum: readonly ["init", "new", "status", "next", "impact", "validate", "verify", "gate", "sync", "archive", "tasks", "discard", "adopt"];
29
+ readonly description: "Cabbage operation";
30
+ };
31
+ readonly change: {
32
+ readonly type: "string";
33
+ readonly description: "Change id in kebab-case (required by new/next/impact/verify/gate/sync/archive/tasks/discard; optional for status/validate)";
34
+ };
35
+ readonly stage: {
36
+ readonly type: "string";
37
+ readonly description: "Stage id for verify — use the stage ids that `next` reports (new projects: `tasks`)";
38
+ };
39
+ readonly target: {
40
+ readonly type: "string";
41
+ readonly description: "Gate target for gate: a stage id (checks the stages before it), or `merge` / `archive`";
42
+ };
43
+ readonly type: {
44
+ readonly type: "string";
45
+ readonly enum: readonly ["change", "incident"];
46
+ readonly description: "Change type for new (default: change)";
47
+ };
48
+ readonly impact: {
49
+ readonly type: "array";
50
+ readonly items: {
51
+ readonly type: "string";
52
+ };
53
+ readonly description: "Impact entries for impact, e.g. [\"api=true\", \"design=true\"] — design/rfc/adr/api/database/security/deployment open specialist documents";
54
+ };
55
+ };
56
+ readonly required: readonly ["op"];
57
+ readonly additionalProperties: false;
58
+ };
59
+ export declare const CABBAGE_TOOL_DESCRIPTION = "Manage this project's Cabbage change records \u2014 the built-in tasks-and-docs workflow (the engine is bundled; Python 3.10+ required).\n\nOps:\n- init: scaffold .cabbage/ (workflows, docs skeleton, CI template, vendored CLI) \u2014 run once per project\n- adopt: inventory existing markdown outside the docs tree and write .cabbage/adoption-report.md (advisory; moves stay manual)\n- new: create a record (type: change|incident; change: kebab-case id)\n- status: list active records and per-stage state (change optional)\n- next: show ready and blocked stages for a record\n- impact: declare risks, e.g. impact:[\"api=true\",\"design=true\"] \u2014 opens specialist docs (design/rfc/adr/api/database/security/release)\n- verify: verify one stage artifact (stage required; use ids from next)\n- gate: check a milestone (target: stage id | merge | archive)\n- validate: structural checks (all records when change omitted)\n- sync: copy mapped documents into docs/\n- archive: gate, sync, and move the record to .cabbage/archive/ (only after the merge is confirmed)\n- tasks: read-only task checklist view\n- discard: delete an abandoned record\n\nLight path: new \u2192 fill tasks.md (Goal/Design/Tasks/Verification) \u2192 verify tasks \u2192 gate merge \u2192 archive after merge. Records live in .cabbage/changes/<id>/; state.json and change.yaml are CLI-owned \u2014 never edit them by hand.";
60
+ export declare function buildCabbageTool(cli: CabbageCliRuntime, projectDir: string): {
61
+ name: string;
62
+ description: string;
63
+ input: {
64
+ readonly type: "object";
65
+ readonly properties: {
66
+ readonly op: {
67
+ readonly type: "string";
68
+ readonly enum: readonly ["init", "new", "status", "next", "impact", "validate", "verify", "gate", "sync", "archive", "tasks", "discard", "adopt"];
69
+ readonly description: "Cabbage operation";
70
+ };
71
+ readonly change: {
72
+ readonly type: "string";
73
+ readonly description: "Change id in kebab-case (required by new/next/impact/verify/gate/sync/archive/tasks/discard; optional for status/validate)";
74
+ };
75
+ readonly stage: {
76
+ readonly type: "string";
77
+ readonly description: "Stage id for verify — use the stage ids that `next` reports (new projects: `tasks`)";
78
+ };
79
+ readonly target: {
80
+ readonly type: "string";
81
+ readonly description: "Gate target for gate: a stage id (checks the stages before it), or `merge` / `archive`";
82
+ };
83
+ readonly type: {
84
+ readonly type: "string";
85
+ readonly enum: readonly ["change", "incident"];
86
+ readonly description: "Change type for new (default: change)";
87
+ };
88
+ readonly impact: {
89
+ readonly type: "array";
90
+ readonly items: {
91
+ readonly type: "string";
92
+ };
93
+ readonly description: "Impact entries for impact, e.g. [\"api=true\", \"design=true\"] — design/rfc/adr/api/database/security/deployment open specialist documents";
94
+ };
95
+ };
96
+ readonly required: readonly ["op"];
97
+ readonly additionalProperties: false;
98
+ };
99
+ options: {
100
+ permission: string;
101
+ };
102
+ execute(input: CabbageToolInput, context: CabbageToolContext): Promise<CabbageToolResult>;
103
+ };
@@ -0,0 +1,169 @@
1
+ import { runCabbage } from "./cabbage-cli.js";
2
+ /**
3
+ * `cabbage` 工具:把内置 Cabbage 引擎(变更记录 / 任务与文档 / 验证与归档)暴露为
4
+ * 一等工具。与 goal 工具相同的双层门控:权限规则层(agent permissions)隐藏/放行,
5
+ * 工具内自检兜底(仅 dev-lifecycle 编排器可用)。
6
+ */
7
+ export const CABBAGE_ALLOWED_AGENTS = new Set(["dev-lifecycle"]);
8
+ const OPS = ["init", "new", "status", "next", "impact", "validate", "verify", "gate", "sync", "archive", "tasks", "discard", "adopt"];
9
+ export const CABBAGE_TOOL_INPUT_SCHEMA = {
10
+ type: "object",
11
+ properties: {
12
+ op: {
13
+ type: "string",
14
+ enum: [...OPS],
15
+ description: "Cabbage operation",
16
+ },
17
+ change: {
18
+ type: "string",
19
+ description: "Change id in kebab-case (required by new/next/impact/verify/gate/sync/archive/tasks/discard; optional for status/validate)",
20
+ },
21
+ stage: {
22
+ type: "string",
23
+ description: "Stage id for verify — use the stage ids that `next` reports (new projects: `tasks`)",
24
+ },
25
+ target: {
26
+ type: "string",
27
+ description: "Gate target for gate: a stage id (checks the stages before it), or `merge` / `archive`",
28
+ },
29
+ type: {
30
+ type: "string",
31
+ enum: ["change", "incident"],
32
+ description: "Change type for new (default: change)",
33
+ },
34
+ impact: {
35
+ type: "array",
36
+ items: { type: "string" },
37
+ description: "Impact entries for impact, e.g. [\"api=true\", \"design=true\"] — design/rfc/adr/api/database/security/deployment open specialist documents",
38
+ },
39
+ },
40
+ required: ["op"],
41
+ additionalProperties: false,
42
+ };
43
+ export const CABBAGE_TOOL_DESCRIPTION = `Manage this project's Cabbage change records — the built-in tasks-and-docs workflow (the engine is bundled; Python 3.10+ required).
44
+
45
+ Ops:
46
+ - init: scaffold .cabbage/ (workflows, docs skeleton, CI template, vendored CLI) — run once per project
47
+ - adopt: inventory existing markdown outside the docs tree and write .cabbage/adoption-report.md (advisory; moves stay manual)
48
+ - new: create a record (type: change|incident; change: kebab-case id)
49
+ - status: list active records and per-stage state (change optional)
50
+ - next: show ready and blocked stages for a record
51
+ - impact: declare risks, e.g. impact:["api=true","design=true"] — opens specialist docs (design/rfc/adr/api/database/security/release)
52
+ - verify: verify one stage artifact (stage required; use ids from next)
53
+ - gate: check a milestone (target: stage id | merge | archive)
54
+ - validate: structural checks (all records when change omitted)
55
+ - sync: copy mapped documents into docs/
56
+ - archive: gate, sync, and move the record to .cabbage/archive/ (only after the merge is confirmed)
57
+ - tasks: read-only task checklist view
58
+ - discard: delete an abandoned record
59
+
60
+ Light path: new → fill tasks.md (Goal/Design/Tasks/Verification) → verify tasks → gate merge → archive after merge. Records live in .cabbage/changes/<id>/; state.json and change.yaml are CLI-owned — never edit them by hand.`;
61
+ function buildArgs(input) {
62
+ const change = input.change?.trim();
63
+ const requireChange = (op) => change ?? { error: `Error: op \`${op}\` requires \`change\`.` };
64
+ switch (input.op) {
65
+ case "init":
66
+ return ["init"];
67
+ case "adopt":
68
+ return ["adopt"];
69
+ case "new": {
70
+ if (!change || typeof change !== "string")
71
+ return { error: "Error: op `new` requires `change` (kebab-case id)." };
72
+ return ["new", input.type ?? "change", change];
73
+ }
74
+ case "status":
75
+ return change ? ["status", change] : ["status"];
76
+ case "next": {
77
+ const c = requireChange("next");
78
+ if (typeof c !== "string")
79
+ return c;
80
+ return ["next", c];
81
+ }
82
+ case "impact": {
83
+ const c = requireChange("impact");
84
+ if (typeof c !== "string")
85
+ return c;
86
+ const entries = (input.impact ?? []).filter((x) => typeof x === "string" && x.trim() !== "");
87
+ if (entries.length === 0)
88
+ return { error: "Error: op `impact` requires a non-empty `impact` array, e.g. [\"api=true\"]." };
89
+ return ["impact", c, ...entries.flatMap((entry) => ["--set", entry.trim()])];
90
+ }
91
+ case "validate":
92
+ return change ? ["validate", change] : ["validate", "--all"];
93
+ case "verify": {
94
+ const c = requireChange("verify");
95
+ if (typeof c !== "string")
96
+ return c;
97
+ const stage = input.stage?.trim();
98
+ if (!stage)
99
+ return { error: "Error: op `verify` requires `stage` (use the ids from `next`)." };
100
+ return ["verify", c, stage];
101
+ }
102
+ case "gate": {
103
+ const c = requireChange("gate");
104
+ if (typeof c !== "string")
105
+ return c;
106
+ const target = input.target?.trim();
107
+ if (!target)
108
+ return { error: "Error: op `gate` requires `target` (a stage id, `merge`, or `archive`)." };
109
+ return ["gate", c, target];
110
+ }
111
+ case "sync": {
112
+ const c = requireChange("sync");
113
+ if (typeof c !== "string")
114
+ return c;
115
+ return ["sync", c];
116
+ }
117
+ case "archive": {
118
+ const c = requireChange("archive");
119
+ if (typeof c !== "string")
120
+ return c;
121
+ return ["archive", c];
122
+ }
123
+ case "tasks": {
124
+ const c = requireChange("tasks");
125
+ if (typeof c !== "string")
126
+ return c;
127
+ return ["tasks", c];
128
+ }
129
+ case "discard": {
130
+ const c = requireChange("discard");
131
+ if (typeof c !== "string")
132
+ return c;
133
+ return ["discard", c];
134
+ }
135
+ default:
136
+ return { error: `Error: unknown op \`${String(input.op)}\`.` };
137
+ }
138
+ }
139
+ export function buildCabbageTool(cli, projectDir) {
140
+ return {
141
+ name: "cabbage",
142
+ description: CABBAGE_TOOL_DESCRIPTION,
143
+ input: CABBAGE_TOOL_INPUT_SCHEMA,
144
+ options: { permission: "cabbage" },
145
+ async execute(input, context) {
146
+ if (!context.agent || !CABBAGE_ALLOWED_AGENTS.has(context.agent)) {
147
+ return { content: `Error: the cabbage tool is restricted to the dev-lifecycle orchestrator. Agent "${context.agent ?? "unknown"}" is not authorized.` };
148
+ }
149
+ if (!cli.available) {
150
+ return { content: `Error: cabbage CLI unavailable: ${cli.reason ?? "unknown reason"}. The bundled engine needs Python 3.10+; install it and restart.` };
151
+ }
152
+ const built = buildArgs(input);
153
+ if ("error" in built)
154
+ return { content: built.error };
155
+ try {
156
+ const result = await runCabbage(cli, built, projectDir);
157
+ const parts = [result.stdout.trim()];
158
+ if (result.stderr.trim())
159
+ parts.push(`[stderr]\n${result.stderr.trim()}`);
160
+ parts.push(`exit=${result.code}`);
161
+ return { content: parts.filter(Boolean).join("\n") };
162
+ }
163
+ catch (err) {
164
+ return { content: `Error: failed to run cabbage ${built.join(" ")}: ${err?.message ?? err}` };
165
+ }
166
+ },
167
+ };
168
+ }
169
+ //# sourceMappingURL=cabbage-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cabbage-tool.js","sourceRoot":"","sources":["../../src/plugin/cabbage-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C;;;;GAIG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC,CAAA;AAoBhE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAU,CAAA;AAE9I,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC;YACd,WAAW,EAAE,mBAAmB;SACjC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4HAA4H;SAC1I;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qFAAqF;SACnG;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wFAAwF;SACtG;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;YAC5B,WAAW,EAAE,uCAAuC;SACrD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,WAAW,EAAE,6IAA6I;SAC3J;K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AG,CAAC,KAAM,GAAoB,EAAE,OAAO,IAAI,GAAG,EAAE,EAAE,CAAA;YACjH,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * 解析并剥离 Markdown 文件的 frontmatter
3
+ *
4
+ * Frontmatter 是位于文件开头的 --- 包裹的 YAML 格式元数据,
5
+ * 例如:---\ntitle: foo\n---\n正文内容
6
+ */
7
+ export declare function extractAndStripFrontmatter(content: string): {
8
+ frontmatter: Record<string, string>;
9
+ content: string;
10
+ };
1
11
  /** 解析后的 slash command 结构 */
2
12
  export interface ParsedCommand {
3
13
  name: string;
@@ -6,7 +6,7 @@ import path from "node:path";
6
6
  * Frontmatter 是位于文件开头的 --- 包裹的 YAML 格式元数据,
7
7
  * 例如:---\ntitle: foo\n---\n正文内容
8
8
  */
9
- function extractAndStripFrontmatter(content) {
9
+ export function extractAndStripFrontmatter(content) {
10
10
  const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
11
11
  if (!match)
12
12
  return { frontmatter: {}, content };
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/plugin/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B;;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,OAAe;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,WAAW,EAAE,EAA4B,EAAE,OAAO,EAAE,CAAA;IAEzE,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB,MAAM,WAAW,GAA2B,EAAE,CAAA;IAE9C,KAAK,MAAM,IAA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AAE,SAAQ;QAEnC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACvC,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;QAC9D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAA;QAEhE,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,mBAAmB,EAAE,GAAG,SAAS,GAAG,CAAC,CAAA;QAEhF,MAAM,CAAC,IAAI,CAAC;YACV,IAAI;YACJ,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,OAAO,EAAE,WAAW,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACpG,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,cAAc,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IACjD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Plugin } from "@opencode/plugin";
2
+ import type { GoalStore } from "./goal-store.js";
3
+ type Context = Plugin.Context;
4
+ /**
5
+ * 子会话活动跟踪(V2 无 session.list/children 查询 API,改用事件溯源):
6
+ * - session.created(带 parentID)建立父子关系
7
+ * - execution.started / retry.scheduled → busy;execution.succeeded/failed/interrupted → idle
8
+ *
9
+ * 局限:重启后内存清空,重启瞬间仍在运行且未再发事件的子会话不被识别(窗口小,可接受;
10
+ * 子代理结果注入父会话会重新触发事件流)。V1 依赖实时查询,此为 V2 的降级替代。
11
+ */
12
+ export declare class SessionActivityTracker {
13
+ private parentOf;
14
+ private busy;
15
+ onCreated(sessionID: string, parentID?: string): void;
16
+ onBusy(sessionID: string): void;
17
+ onIdle(sessionID: string): void;
18
+ hasWorkingChildren(sessionID: string): boolean;
19
+ }
20
+ export declare function queueContinuation(ctx: Context, store: GoalStore, sessionID: string, projectDir: string, tracker: SessionActivityTracker): Promise<void>;
21
+ export declare function autoResume(ctx: Context, store: GoalStore, projectDir: string): Promise<void>;
22
+ export {};