@s_s/harmonia 1.2.0 → 1.4.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 (180) hide show
  1. package/README.md +140 -392
  2. package/build/cli/setup.d.ts +4 -2
  3. package/build/cli/setup.js +44 -18
  4. package/build/cli/setup.js.map +1 -1
  5. package/build/core/action-registry.d.ts +36 -0
  6. package/build/core/action-registry.js +53 -0
  7. package/build/core/action-registry.js.map +1 -0
  8. package/build/core/artifacts.d.ts +66 -0
  9. package/build/core/artifacts.js +178 -0
  10. package/build/core/artifacts.js.map +1 -0
  11. package/build/core/dispatch.d.ts +18 -11
  12. package/build/core/dispatch.js +43 -33
  13. package/build/core/dispatch.js.map +1 -1
  14. package/build/core/issues.d.ts +37 -0
  15. package/build/core/issues.js +100 -0
  16. package/build/core/issues.js.map +1 -0
  17. package/build/core/overrides.d.ts +19 -26
  18. package/build/core/overrides.js +32 -98
  19. package/build/core/overrides.js.map +1 -1
  20. package/build/core/plugin.d.ts +86 -0
  21. package/build/core/plugin.js +332 -0
  22. package/build/core/plugin.js.map +1 -0
  23. package/build/core/registry.d.ts +36 -3
  24. package/build/core/registry.js +63 -5
  25. package/build/core/registry.js.map +1 -1
  26. package/build/core/reviews.d.ts +13 -13
  27. package/build/core/reviews.js +31 -32
  28. package/build/core/reviews.js.map +1 -1
  29. package/build/core/schema.d.ts +43 -15
  30. package/build/core/schema.js +124 -20
  31. package/build/core/schema.js.map +1 -1
  32. package/build/core/state.d.ts +29 -22
  33. package/build/core/state.js +49 -81
  34. package/build/core/state.js.map +1 -1
  35. package/build/core/steps.d.ts +15 -15
  36. package/build/core/steps.js +32 -33
  37. package/build/core/steps.js.map +1 -1
  38. package/build/core/tree-utils.d.ts +52 -0
  39. package/build/core/tree-utils.js +226 -0
  40. package/build/core/tree-utils.js.map +1 -0
  41. package/build/core/types.d.ts +417 -117
  42. package/build/core/types.js +15 -1
  43. package/build/core/types.js.map +1 -1
  44. package/build/core/workflow-engine.d.ts +68 -0
  45. package/build/core/workflow-engine.js +821 -0
  46. package/build/core/workflow-engine.js.map +1 -0
  47. package/build/core/workflow-validator.d.ts +22 -0
  48. package/build/core/workflow-validator.js +489 -0
  49. package/build/core/workflow-validator.js.map +1 -0
  50. package/build/index.js +28 -25
  51. package/build/index.js.map +1 -1
  52. package/build/setup/inject.d.ts +4 -4
  53. package/build/setup/inject.js +6 -6
  54. package/build/setup/inject.js.map +1 -1
  55. package/build/setup/templates.d.ts +9 -7
  56. package/build/setup/templates.js +68 -103
  57. package/build/setup/templates.js.map +1 -1
  58. package/build/tools/artifact-approve.d.ts +8 -0
  59. package/build/tools/artifact-approve.js +94 -0
  60. package/build/tools/artifact-approve.js.map +1 -0
  61. package/build/tools/artifact-schema.d.ts +12 -0
  62. package/build/tools/artifact-schema.js +148 -0
  63. package/build/tools/artifact-schema.js.map +1 -0
  64. package/build/tools/artifact-tools.d.ts +18 -0
  65. package/build/tools/artifact-tools.js +465 -0
  66. package/build/tools/artifact-tools.js.map +1 -0
  67. package/build/tools/{report-dispatch.d.ts → dispatch-report.d.ts} +7 -3
  68. package/build/tools/dispatch-report.js +261 -0
  69. package/build/tools/dispatch-report.js.map +1 -0
  70. package/build/tools/engine-helpers.d.ts +41 -0
  71. package/build/tools/engine-helpers.js +182 -0
  72. package/build/tools/engine-helpers.js.map +1 -0
  73. package/build/tools/get-project-status.d.ts +6 -4
  74. package/build/tools/get-project-status.js +308 -246
  75. package/build/tools/get-project-status.js.map +1 -1
  76. package/build/tools/get-role-prompt.d.ts +1 -1
  77. package/build/tools/get-role-prompt.js +7 -41
  78. package/build/tools/get-role-prompt.js.map +1 -1
  79. package/build/tools/issue-tools.d.ts +10 -0
  80. package/build/tools/issue-tools.js +169 -0
  81. package/build/tools/issue-tools.js.map +1 -0
  82. package/build/tools/iteration-start.d.ts +7 -4
  83. package/build/tools/iteration-start.js +51 -20
  84. package/build/tools/iteration-start.js.map +1 -1
  85. package/build/tools/loop-done.d.ts +11 -0
  86. package/build/tools/loop-done.js +109 -0
  87. package/build/tools/loop-done.js.map +1 -0
  88. package/build/tools/patch-start.d.ts +16 -0
  89. package/build/tools/patch-start.js +122 -0
  90. package/build/tools/patch-start.js.map +1 -0
  91. package/build/tools/project-init.d.ts +5 -5
  92. package/build/tools/project-init.js +47 -18
  93. package/build/tools/project-init.js.map +1 -1
  94. package/build/tools/role-dispatch.d.ts +55 -0
  95. package/build/tools/role-dispatch.js +508 -0
  96. package/build/tools/role-dispatch.js.map +1 -0
  97. package/build/tools/utils.d.ts +40 -0
  98. package/build/tools/utils.js +97 -0
  99. package/build/tools/utils.js.map +1 -0
  100. package/package.json +1 -1
  101. package/{build/hooks/claude-code.js → workflows/dev/hooks/claude.js} +34 -23
  102. package/{build → workflows/dev}/hooks/content.js +27 -18
  103. package/workflows/dev/hooks/index.js +52 -0
  104. package/{build → workflows/dev}/hooks/openclaw.js +31 -20
  105. package/{build → workflows/dev}/hooks/opencode.js +31 -20
  106. package/workflows/dev/roles/architect.md +68 -28
  107. package/workflows/dev/roles/coordinator.md +103 -0
  108. package/workflows/dev/roles/developer.md +5 -5
  109. package/workflows/dev/roles/tester.md +19 -19
  110. package/workflows/dev/schemas/api-contract.json +42 -0
  111. package/workflows/dev/schemas/api-design.json +30 -13
  112. package/workflows/dev/schemas/data-model.json +20 -7
  113. package/workflows/dev/schemas/prd.completeness-check.json +6 -5
  114. package/workflows/dev/schemas/prd.draft.json +13 -5
  115. package/workflows/dev/schemas/prd.final.json +34 -11
  116. package/workflows/dev/schemas/prd.json +29 -11
  117. package/workflows/dev/schemas/prd.requirements.json +6 -5
  118. package/workflows/dev/schemas/prototype.json +6 -2
  119. package/workflows/dev/schemas/task-breakdown.coarse.json +4 -3
  120. package/workflows/dev/schemas/task-breakdown.dependencies.json +5 -4
  121. package/workflows/dev/schemas/task-breakdown.detailed.json +8 -3
  122. package/workflows/dev/schemas/task-breakdown.final.json +8 -3
  123. package/workflows/dev/schemas/task-breakdown.json +8 -3
  124. package/workflows/dev/schemas/tech-design.analysis.json +6 -5
  125. package/workflows/dev/schemas/tech-design.draft.json +14 -5
  126. package/workflows/dev/schemas/tech-design.final.json +39 -13
  127. package/workflows/dev/schemas/tech-design.json +34 -13
  128. package/workflows/dev/schemas/tech-design.research.json +21 -0
  129. package/workflows/dev/schemas/test-plan.json +17 -7
  130. package/workflows/dev/schemas/test-report.json +26 -9
  131. package/workflows/dev/schemas/user-stories.json +7 -3
  132. package/workflows/dev/tools/index.js +23 -0
  133. package/workflows/dev/workflow.json +234 -101
  134. package/build/core/docs.d.ts +0 -32
  135. package/build/core/docs.js +0 -91
  136. package/build/core/docs.js.map +0 -1
  137. package/build/core/workflow.d.ts +0 -33
  138. package/build/core/workflow.js +0 -140
  139. package/build/core/workflow.js.map +0 -1
  140. package/build/hooks/claude-code.d.ts +0 -20
  141. package/build/hooks/claude-code.js.map +0 -1
  142. package/build/hooks/content.d.ts +0 -43
  143. package/build/hooks/content.js.map +0 -1
  144. package/build/hooks/install.d.ts +0 -40
  145. package/build/hooks/install.js +0 -63
  146. package/build/hooks/install.js.map +0 -1
  147. package/build/hooks/openclaw.d.ts +0 -24
  148. package/build/hooks/openclaw.js.map +0 -1
  149. package/build/hooks/opencode.d.ts +0 -29
  150. package/build/hooks/opencode.js.map +0 -1
  151. package/build/tools/approve-doc.d.ts +0 -6
  152. package/build/tools/approve-doc.js +0 -108
  153. package/build/tools/approve-doc.js.map +0 -1
  154. package/build/tools/dispatch-role.d.ts +0 -16
  155. package/build/tools/dispatch-role.js +0 -277
  156. package/build/tools/dispatch-role.js.map +0 -1
  157. package/build/tools/doc-tools.d.ts +0 -16
  158. package/build/tools/doc-tools.js +0 -389
  159. package/build/tools/doc-tools.js.map +0 -1
  160. package/build/tools/override-tools.d.ts +0 -6
  161. package/build/tools/override-tools.js +0 -129
  162. package/build/tools/override-tools.js.map +0 -1
  163. package/build/tools/report-dispatch.js +0 -194
  164. package/build/tools/report-dispatch.js.map +0 -1
  165. package/build/tools/set-scale.d.ts +0 -6
  166. package/build/tools/set-scale.js +0 -107
  167. package/build/tools/set-scale.js.map +0 -1
  168. package/build/tools/setup-project.d.ts +0 -8
  169. package/build/tools/setup-project.js +0 -116
  170. package/build/tools/setup-project.js.map +0 -1
  171. package/build/tools/update-phase.d.ts +0 -12
  172. package/build/tools/update-phase.js +0 -159
  173. package/build/tools/update-phase.js.map +0 -1
  174. package/workflows/dev/roles/pm.md +0 -99
  175. package/workflows/dev/schemas/deploy.json +0 -20
  176. package/workflows/dev/schemas/fsd.json +0 -25
  177. package/workflows/dev/schemas/project-plan.json +0 -20
  178. package/workflows/dev/schemas/retrospective.json +0 -20
  179. package/workflows/dev/schemas/risk-assessment.json +0 -15
  180. package/workflows/dev/schemas/tech-design.api-contract.json +0 -20
@@ -1,140 +0,0 @@
1
- /**
2
- * Workflow loader — two-layer resolution for workflow definitions.
3
- *
4
- * Lookup priority:
5
- * 1. <data_dir>/.workflows/<name>/ (user custom — can override built-in)
6
- * 2. <package>/workflows/<name>/ (built-in fallback)
7
- */
8
- import { readFile, readdir, access } from 'node:fs/promises';
9
- import { join, parse } from 'node:path';
10
- import YAML from 'yaml';
11
- // ─── Errors ───
12
- export class WorkflowNotFoundError extends Error {
13
- constructor(name, searched) {
14
- const dirs = searched.map((d) => ` - ${d}`).join('\n');
15
- super(`工作流 "${name}" 不存在。已搜索:\n${dirs}`);
16
- this.name = 'WorkflowNotFoundError';
17
- }
18
- }
19
- // ─── Internal helpers ───
20
- /**
21
- * Check if a file exists (async, no throw).
22
- */
23
- async function fileExists(path) {
24
- try {
25
- await access(path);
26
- return true;
27
- }
28
- catch {
29
- return false;
30
- }
31
- }
32
- /**
33
- * Resolve the actual directory for a workflow name.
34
- * Custom dir takes priority over built-in dir.
35
- * Returns the resolved directory path.
36
- */
37
- export async function resolveWorkflowDir(builtinDir, customDir, name) {
38
- const customPath = join(customDir, name, 'workflow.json');
39
- if (await fileExists(customPath)) {
40
- return join(customDir, name);
41
- }
42
- const builtinPath = join(builtinDir, name, 'workflow.json');
43
- if (await fileExists(builtinPath)) {
44
- return join(builtinDir, name);
45
- }
46
- throw new WorkflowNotFoundError(name, [join(customDir, name), join(builtinDir, name)]);
47
- }
48
- /**
49
- * Parse a role markdown file.
50
- * Format: YAML frontmatter (---\n...\n---) followed by markdown prompt.
51
- */
52
- function parseRoleFile(id, content) {
53
- const fmRegex = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;
54
- const match = content.match(fmRegex);
55
- if (!match) {
56
- return {
57
- id,
58
- frontmatter: { model: 'medium', session: 'none', parallel: false },
59
- prompt: content.trim(),
60
- };
61
- }
62
- const yamlBlock = match[1];
63
- const prompt = match[2].trim();
64
- const parsed = YAML.parse(yamlBlock);
65
- const fm = parsed ?? {};
66
- const capabilities = Array.isArray(fm.capabilities) ? fm.capabilities : undefined;
67
- const frontmatter = {
68
- model: fm.model ?? 'medium',
69
- session: fm.session ?? 'none',
70
- parallel: fm.parallel ?? false,
71
- ...(capabilities ? { capabilities } : {}),
72
- };
73
- return { id, frontmatter, prompt };
74
- }
75
- // ─── Public API ───
76
- /**
77
- * Load a single workflow by name using two-layer resolution.
78
- *
79
- * @param builtinDir - Package built-in workflows directory
80
- * @param customDir - User custom workflows directory (<data_dir>/.workflows)
81
- * @param name - Workflow name (directory name)
82
- */
83
- export async function loadWorkflow(builtinDir, customDir, name) {
84
- const workflowDir = await resolveWorkflowDir(builtinDir, customDir, name);
85
- // Load workflow.json
86
- const workflowJson = await readFile(join(workflowDir, 'workflow.json'), 'utf-8');
87
- const definition = JSON.parse(workflowJson);
88
- // Load roles
89
- const rolesDir = join(workflowDir, 'roles');
90
- let roleFiles = [];
91
- try {
92
- roleFiles = await readdir(rolesDir);
93
- }
94
- catch {
95
- // roles/ directory is optional for custom workflows
96
- }
97
- const roles = {};
98
- for (const file of roleFiles) {
99
- if (!file.endsWith('.md'))
100
- continue;
101
- const roleId = parse(file).name;
102
- const content = await readFile(join(rolesDir, file), 'utf-8');
103
- roles[roleId] = parseRoleFile(roleId, content);
104
- }
105
- return { definition, roles };
106
- }
107
- /**
108
- * List all available workflow names, merging custom and built-in.
109
- * Custom workflows override built-in ones with the same name.
110
- *
111
- * @param builtinDir - Package built-in workflows directory
112
- * @param customDir - User custom workflows directory (<data_dir>/.workflows)
113
- */
114
- export async function listWorkflows(builtinDir, customDir) {
115
- const names = new Set();
116
- // Built-in workflows
117
- try {
118
- const entries = await readdir(builtinDir, { withFileTypes: true });
119
- for (const e of entries) {
120
- if (e.isDirectory())
121
- names.add(e.name);
122
- }
123
- }
124
- catch {
125
- // built-in dir missing is unexpected but not fatal
126
- }
127
- // Custom workflows (can add new or override built-in)
128
- try {
129
- const entries = await readdir(customDir, { withFileTypes: true });
130
- for (const e of entries) {
131
- if (e.isDirectory())
132
- names.add(e.name);
133
- }
134
- }
135
- catch {
136
- // custom dir doesn't exist yet — that's fine
137
- }
138
- return [...names].sort();
139
- }
140
- //# sourceMappingURL=workflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/core/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,iBAAiB;AAEjB,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5C,YAAY,IAAY,EAAE,QAAkB;QACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxD,KAAK,CAAC,QAAQ,IAAI,eAAe,IAAI,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACxC,CAAC;CAC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AAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,WAAW,EAAE;gBAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,6CAA6C;IACjD,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Claude Code / Codex hook definitions.
3
- *
4
- * Claude Code hooks are shell scripts that receive JSON via stdin.
5
- * They can block tool calls via exit code 2 or JSON { decision: "block" }.
6
- * UserPromptSubmit stdout is injected as context visible to Claude.
7
- *
8
- * Hooks:
9
- * 1. PreToolUse — boundary guard: block code edits and dev commands
10
- * 2. UserPromptSubmit — proactive reminders: dispatch timeout, idle phase, pending reviews
11
- *
12
- * Project-agnostic: no project name/dir baked in.
13
- * - Boundary guard uses tool names + code file extensions only
14
- * - Reminders scan all projects under DATA_DIR
15
- */
16
- import type { HookParams } from './content.js';
17
- /**
18
- * Create Claude Code hook definitions using agent-kit's defineHooks.
19
- */
20
- export declare function createClaudeCodeHooks(params: HookParams): import("@s_s/agent-kit").HookSet<"claude-code">;
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/hooks/claude-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GACjC,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,SAAS,wBAAwB,CAAC,OAAmB;IACjD,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,oBAAoB,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5G,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8BH,eAAe;;;;;;;;;;;;;;;;;;EAkBrB,iBAAiB;;;;;;;;;;;CAWlB,CAAC;AACF,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,8BAA8B,CAAC,MAAkB;IACtD,OAAO;;;;;YAKC,MAAM,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCA+BU,wBAAwB;;;;;;;;;;;;;;;;;;;oCAmBxB,8BAA8B;;;;;;;;kEAQA,8BAA8B;;;;;;;;;;;;;;iCAc/D,0BAA0B;;;;;;;;;;;;;;;;;;;;;CAqB1D,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAkB;IACpD,OAAO,WAAW,CAAC,aAAa,EAAE;QAC9B;YACI,MAAM,EAAE,CAAC,YAAY,CAAC;YACtB,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC;SAC5C;QACD;YACI,MAAM,EAAE,CAAC,kBAAkB,CAAC;YAC5B,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC;SAClD;KACJ,CAAC,CAAC;AACP,CAAC"}
@@ -1,43 +0,0 @@
1
- /**
2
- * Hook content generation — shared configuration and rule definitions.
3
- *
4
- * Hook scripts run on the agent side (shell scripts for Claude Code,
5
- * TS plugins for OpenCode, handlers for OpenClaw). They need to know:
6
- * - HARMONIA_DATA_DIR: where to read dispatches.json, state.json, etc.
7
- *
8
- * Project-specific info (name, dir) is NOT baked in — hooks are project-agnostic.
9
- * Boundary guards work on tool names + code file extensions only.
10
- * Proactive reminders scan all projects under the data directory.
11
- */
12
- /**
13
- * Parameters needed to generate hook content.
14
- * Passed at install time and embedded into the generated scripts.
15
- */
16
- export interface HookParams {
17
- /** Harmonia data directory (absolute path) */
18
- dataDir: string;
19
- }
20
- /**
21
- * Tool names that PM should not call directly (code modification tools).
22
- * These are the standard agent tool names across different platforms.
23
- */
24
- export declare const BLOCKED_TOOLS: readonly ["Write", "Edit", "MultiEdit", "write", "edit", "Bash", "bash", "Terminal", "terminal"];
25
- /**
26
- * Shell commands that indicate development work (PM should not run these).
27
- */
28
- export declare const BLOCKED_COMMANDS: readonly ["npm run", "npm test", "npm start", "npm run build", "npx ", "yarn ", "pnpm ", "bun ", "node ", "deno ", "python ", "cargo ", "go run", "go test", "make ", "gcc ", "g++ ", "javac ", "mvn ", "gradle "];
29
- /**
30
- * File extensions that indicate source code (PM should not modify these).
31
- */
32
- export declare const CODE_EXTENSIONS: readonly [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rs", ".go", ".java", ".c", ".cpp", ".h", ".hpp", ".cs", ".rb", ".php", ".swift", ".kt", ".vue", ".svelte"];
33
- /**
34
- * Harmonia MCP tool names — these are always allowed since PM uses them
35
- * through Harmonia's own tool system.
36
- */
37
- export declare const HARMONIA_TOOLS: readonly ["project_init", "project_set_scale", "project_status", "phase_update", "role_dispatch", "dispatch_report", "doc_write", "doc_read", "doc_list", "doc_approve", "reject_doc", "guard_set", "guard_get", "review_set_rule", "review_list"];
38
- /** Dispatch running timeout — warn after this many minutes */
39
- export declare const DISPATCH_TIMEOUT_MINUTES = 30;
40
- /** Phase idle timeout — warn after this many minutes with no tool calls */
41
- export declare const PHASE_IDLE_TIMEOUT_MINUTES = 15;
42
- /** Review pending timeout — warn after this many minutes */
43
- export declare const REVIEW_PENDING_TIMEOUT_MINUTES = 10;
@@ -1 +0,0 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/hooks/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,yBAAyB;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,qBAAqB;IACrB,OAAO;IACP,MAAM;IACN,WAAW;IACX,OAAO;IACP,MAAM;IACN,mBAAmB;IACnB,MAAM;IACN,MAAM;IACN,UAAU;IACV,UAAU;CACJ,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,SAAS;IACT,UAAU;IACV,WAAW;IACX,eAAe;IACf,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,QAAQ;IACR,MAAM;IACN,SAAS;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,SAAS;CACH,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,cAAc;IACd,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,UAAU;IACV,UAAU;IACV,aAAa;IACb,YAAY;IACZ,WAAW;IACX,WAAW;IACX,iBAAiB;IACjB,aAAa;CACP,CAAC;AAEX,uCAAuC;AAEvC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Hook installation — entry point for installing/uninstalling agent hooks.
3
- *
4
- * Detects the host agent type and installs the appropriate hook definitions
5
- * using agent-kit's installHooks API. Hook content is generated with baked-in
6
- * data directory path. Hooks are project-agnostic.
7
- */
8
- import { type AgentType, type HookInstallResult } from '@s_s/agent-kit';
9
- import type { HookParams } from './content.js';
10
- /**
11
- * Install Harmonia hooks for the detected agent.
12
- *
13
- * Generates agent-specific hook content with baked-in data directory,
14
- * then delegates to agent-kit for file writing and config merging.
15
- *
16
- * @param agentType - The host agent type (detected or user-specified)
17
- * @param params - Parameters to bake into hook content (dataDir only)
18
- * @returns Installation result from agent-kit
19
- */
20
- export declare function installHooks(agentType: AgentType, params: HookParams): Promise<HookInstallResult>;
21
- /**
22
- * Uninstall Harmonia hooks for the given agent.
23
- *
24
- * Removes hook files and config entries installed by Harmonia.
25
- */
26
- export declare function uninstallHooks(agentType: AgentType): Promise<{
27
- success: boolean;
28
- removed: string[];
29
- error?: string;
30
- }>;
31
- /**
32
- * Check if Harmonia hooks are installed for the given agent.
33
- */
34
- export declare function hasHooksInstalled(agentType: AgentType): Promise<boolean>;
35
- /**
36
- * Create hook definitions for a specific agent type.
37
- *
38
- * @internal — exposed for testing
39
- */
40
- export declare function createHooksForAgent(agentType: AgentType, params: HookParams): import("@s_s/agent-kit").HookSet<"claude-code"> | import("@s_s/agent-kit").HookSet<"opencode"> | import("@s_s/agent-kit").HookSet<"openclaw">;
@@ -1,63 +0,0 @@
1
- /**
2
- * Hook installation — entry point for installing/uninstalling agent hooks.
3
- *
4
- * Detects the host agent type and installs the appropriate hook definitions
5
- * using agent-kit's installHooks API. Hook content is generated with baked-in
6
- * data directory path. Hooks are project-agnostic.
7
- */
8
- import { createKit } from '@s_s/agent-kit';
9
- import { createClaudeCodeHooks } from './claude-code.js';
10
- import { createOpenCodeHooks } from './opencode.js';
11
- import { createOpenClawHooks } from './openclaw.js';
12
- /** Shared kit instance for hook management */
13
- const kit = createKit('harmonia');
14
- /**
15
- * Install Harmonia hooks for the detected agent.
16
- *
17
- * Generates agent-specific hook content with baked-in data directory,
18
- * then delegates to agent-kit for file writing and config merging.
19
- *
20
- * @param agentType - The host agent type (detected or user-specified)
21
- * @param params - Parameters to bake into hook content (dataDir only)
22
- * @returns Installation result from agent-kit
23
- */
24
- export async function installHooks(agentType, params) {
25
- const hooks = createHooksForAgent(agentType, params);
26
- return kit.installHooks(agentType, hooks);
27
- }
28
- /**
29
- * Uninstall Harmonia hooks for the given agent.
30
- *
31
- * Removes hook files and config entries installed by Harmonia.
32
- */
33
- export async function uninstallHooks(agentType) {
34
- return kit.uninstallHooks(agentType);
35
- }
36
- /**
37
- * Check if Harmonia hooks are installed for the given agent.
38
- */
39
- export async function hasHooksInstalled(agentType) {
40
- return kit.hasHooksInstalled(agentType);
41
- }
42
- /**
43
- * Create hook definitions for a specific agent type.
44
- *
45
- * @internal — exposed for testing
46
- */
47
- export function createHooksForAgent(agentType, params) {
48
- switch (agentType) {
49
- case 'claude-code':
50
- case 'codex':
51
- return createClaudeCodeHooks(params);
52
- case 'opencode':
53
- return createOpenCodeHooks(params);
54
- case 'openclaw':
55
- return createOpenClawHooks(params);
56
- default: {
57
- // Exhaustive check — should never reach here
58
- const _exhaustive = agentType;
59
- throw new Error(`Unsupported agent type: ${_exhaustive}`);
60
- }
61
- }
62
- }
63
- //# sourceMappingURL=install.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/hooks/install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAA0C,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAoB,EAAE,MAAkB;IACvE,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,SAAoB;IAEpB,OAAO,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAoB;IACxD,OAAO,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAoB,EAAE,MAAkB;IACxE,QAAQ,SAAS,EAAE,CAAC;QAChB,KAAK,aAAa,CAAC;QACnB,KAAK,OAAO;YACR,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACzC,KAAK,UAAU;YACX,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACvC,KAAK,UAAU;YACX,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,CAAC,CAAC,CAAC;YACN,6CAA6C;YAC7C,MAAM,WAAW,GAAU,SAAS,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * OpenClaw hook definitions.
3
- *
4
- * OpenClaw hooks use HOOK.md (YAML frontmatter) + handler.ts.
5
- * agent-kit generates HOOK.md from events/description, user provides handler.ts content.
6
- *
7
- * Key capabilities:
8
- * - `before_tool_call` — can BLOCK tool calls (return { block: true, reason })
9
- * - `message_received` — fires on each user message (return { inject: '...' } for reminders)
10
- *
11
- * OpenClaw only supports a single HookDefinition (array takes first only),
12
- * so we combine both events into one handler.
13
- *
14
- * Project-agnostic: no project name/dir baked in.
15
- * - Boundary guard uses tool names + code file extensions only
16
- * - Reminders scan all projects under DATA_DIR
17
- */
18
- import type { HookParams } from './content.js';
19
- /**
20
- * Create OpenClaw hook definitions using agent-kit's defineHooks.
21
- *
22
- * Single definition with two events (OpenClaw only supports one HookDefinition).
23
- */
24
- export declare function createOpenClawHooks(params: HookParams): import("@s_s/agent-kit").HookSet<"openclaw">;
@@ -1 +0,0 @@
1
- {"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/hooks/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GACjC,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,MAAkB;IAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEzD,OAAO;;;;mBAIQ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;;6CAEJ,YAAY;8CACX,eAAe;mCAC1B,wBAAwB;qCACtB,0BAA0B;yCACtB,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKtE,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAkB;IAClD,OAAO,WAAW,CAAC,UAAU,EAAE;QAC3B,MAAM,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;QAChD,OAAO,EAAE,uBAAuB,CAAC,MAAM,CAAC;QACxC,WAAW,EAAE,uBAAuB;KACvC,CAAC,CAAC;AACP,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * OpenCode hook definitions.
3
- *
4
- * OpenCode hooks are TypeScript plugins installed to ~/.config/opencode/plugins/.
5
- * They export a Plugin object with hooks keyed by event name.
6
- *
7
- * Limitations vs Claude Code:
8
- * - `tool.execute.before` can modify args but CANNOT block tool calls.
9
- * - No true blocking mechanism (permission.ask is too coarse).
10
- *
11
- * Strategy: "soft interception + reminder injection"
12
- * 1. tool.execute.before — detect boundary violations, replace args to neutralize
13
- * the operation (e.g., prepend echo to bash commands, empty write content)
14
- * and inject a warning message.
15
- * 2. experimental.chat.messages.transform — read Harmonia data files, inject
16
- * reminders about dispatch timeouts, idle phases, pending reviews.
17
- *
18
- * Project-agnostic: no project name/dir baked in.
19
- * - Boundary guard uses tool names + code file extensions only
20
- * - Reminders scan all projects under DATA_DIR
21
- */
22
- import type { HookParams } from './content.js';
23
- /**
24
- * Create OpenCode hook definitions using agent-kit's defineHooks.
25
- *
26
- * Produces a single plugin file with both tool.execute.before and
27
- * experimental.chat.messages.transform hooks.
28
- */
29
- export declare function createOpenCodeHooks(params: HookParams): import("@s_s/agent-kit").HookSet<"opencode">;
@@ -1 +0,0 @@
1
- {"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/hooks/opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GACjC,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,MAAkB;IAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEzD,0EAA0E;IAC1E,+CAA+C;IAC/C,OAAO;;;;;mBAKQ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;;6CAEJ,YAAY;8CACX,eAAe;mCAC1B,wBAAwB;qCACtB,0BAA0B;yCACtB,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKtE,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAkB;IAClD,OAAO,WAAW,CAAC,UAAU,EAAE;QAC3B,MAAM,EAAE,CAAC,qBAAqB,EAAE,sCAAsC,CAAC;QACvE,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC;KAC1C,CAAC,CAAC;AACP,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * MCP Tool: doc_approve / review_list
3
- * Approve or reject a document that is pending review.
4
- */
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- export declare function registerApproveDoc(server: McpServer): void;
@@ -1,108 +0,0 @@
1
- /**
2
- * MCP Tool: doc_approve / review_list
3
- * Approve or reject a document that is pending review.
4
- */
5
- import { z } from 'zod';
6
- import { resolveReview, getPendingReviews } from '../core/reviews.js';
7
- import { getProject } from '../core/registry.js';
8
- export function registerApproveDoc(server) {
9
- server.tool('doc_approve', 'Approve or reject a document pending review. Call this after the user has reviewed the document and confirmed (or requested changes).', {
10
- project_name: z.string().describe('Project name'),
11
- doc_id: z.string().describe('Document ID to approve/reject'),
12
- approved: z.boolean().describe('true = approved, false = rejected (needs revision)'),
13
- comment: z.string().optional().describe('Optional comment — user feedback or reason for rejection'),
14
- }, async ({ project_name, doc_id, approved, comment }) => {
15
- try {
16
- // Resolve current iteration
17
- const entry = await getProject(project_name);
18
- if (!entry || entry.currentIteration === 0) {
19
- return {
20
- content: [
21
- {
22
- type: 'text',
23
- text: `项目 "${project_name}" 未找到或尚未开始迭代。`,
24
- },
25
- ],
26
- isError: true,
27
- };
28
- }
29
- const iteration = entry.currentIteration;
30
- const status = approved ? 'approved' : 'rejected';
31
- const review = await resolveReview(project_name, iteration, doc_id, status, comment);
32
- if (approved) {
33
- return {
34
- content: [
35
- {
36
- type: 'text',
37
- text: `Document "${doc_id}" approved. You may proceed with the workflow.`,
38
- },
39
- ],
40
- };
41
- }
42
- else {
43
- return {
44
- content: [
45
- {
46
- type: 'text',
47
- text: [
48
- `Document "${doc_id}" rejected.`,
49
- comment ? `User feedback: ${comment}` : '',
50
- `Please revise the document based on the feedback and call doc_write again.`,
51
- ].join('\n'),
52
- },
53
- ],
54
- };
55
- }
56
- }
57
- catch (err) {
58
- return {
59
- content: [
60
- {
61
- type: 'text',
62
- text: `Error: ${err instanceof Error ? err.message : String(err)}`,
63
- },
64
- ],
65
- isError: true,
66
- };
67
- }
68
- });
69
- server.tool('review_list', 'List all documents currently pending user review.', {
70
- project_name: z.string().describe('Project name'),
71
- }, async ({ project_name }) => {
72
- // Resolve current iteration
73
- const entry = await getProject(project_name);
74
- if (!entry || entry.currentIteration === 0) {
75
- return {
76
- content: [
77
- {
78
- type: 'text',
79
- text: `项目 "${project_name}" 未找到或尚未开始迭代。`,
80
- },
81
- ],
82
- isError: true,
83
- };
84
- }
85
- const iteration = entry.currentIteration;
86
- const pending = await getPendingReviews(project_name, iteration);
87
- if (pending.length === 0) {
88
- return {
89
- content: [
90
- {
91
- type: 'text',
92
- text: 'No documents pending review.',
93
- },
94
- ],
95
- };
96
- }
97
- const list = pending.map((r) => `- ${r.docId} (submitted: ${r.submittedAt})`).join('\n');
98
- return {
99
- content: [
100
- {
101
- type: 'text',
102
- text: `Documents pending review:\n${list}`,
103
- },
104
- ],
105
- };
106
- });
107
- }
108
- //# sourceMappingURL=approve-doc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approve-doc.js","sourceRoot":"","sources":["../../src/tools/approve-doc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAChD,MAAM,CAAC,IAAI,CACP,aAAa,EACb,uIAAuI,EACvI;QACI,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;QACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QAC5D,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;QACpF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;KACtG,EACD,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAClD,IAAI,CAAC;YACD,4BAA4B;YAC5B,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,gBAAgB,KAAK,CAAC,EAAE,CAAC;gBACzC,OAAO;oBACH,OAAO,EAAE;wBACL;4BACI,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,OAAO,YAAY,eAAe;yBAC3C;qBACJ;oBACD,OAAO,EAAE,IAAI;iBAChB,CAAC;YACN,CAAC;YACD,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,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IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,gBAAgB,KAAK,CAAC,EAAE,CAAC;YACzC,OAAO;gBACH,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,OAAO,YAAY,eAAe;qBAC3C;iBACJ;gBACD,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAEzC,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAEjE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO;gBACH,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,8BAA8B;qBACvC;iBACJ;aACJ,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzF,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,8BAA8B,IAAI,EAAE;iBAC7C;aACJ;SACJ,CAAC;IACN,CAAC,CACJ,CAAC;AACN,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * MCP Tool: role_dispatch
3
- *
4
- * Prepare all data needed to hand off a task to a team member role.
5
- * Returns: role prompt (with overrides injected), frontmatter config,
6
- * input documents, task brief, and dispatch tracking info.
7
- *
8
- * Automatically:
9
- * - Creates a dispatch record for tracking
10
- * - Searches for reusable idle sessions and provides guidance
11
- *
12
- * This tool does NOT launch agents — it only prepares the data.
13
- * The host agent (PM) decides how to pass this to the team member.
14
- */
15
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
16
- export declare function registerDispatchRole(server: McpServer, builtinDir: string, customDir: string): void;