agent-enderun 1.10.4 → 1.11.1

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 (210) hide show
  1. package/README.md +34 -45
  2. package/dist/framework-mcp/tests/tools/quality/check_lint.test.js +1 -1
  3. package/dist/framework-mcp/tests/tools/quality/check_lint.test.js.map +1 -1
  4. package/dist/src/cli/adapters/core.d.ts +1 -1
  5. package/dist/src/cli/adapters/core.js +0 -1
  6. package/dist/src/cli/adapters/core.js.map +1 -1
  7. package/dist/src/cli/adapters/index.d.ts +1 -0
  8. package/dist/src/cli/adapters/index.js +1 -0
  9. package/dist/src/cli/adapters/index.js.map +1 -1
  10. package/dist/src/cli/adapters/scaffold.d.ts +1 -1
  11. package/dist/src/cli/adapters/scaffold.js +13 -7
  12. package/dist/src/cli/adapters/scaffold.js.map +1 -1
  13. package/dist/src/cli/commands/init/scaffold-core.d.ts +5 -2
  14. package/dist/src/cli/commands/init/scaffold-core.js +28 -6
  15. package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
  16. package/dist/src/cli/commands/init.js +31 -4
  17. package/dist/src/cli/commands/init.js.map +1 -1
  18. package/dist/src/cli/commands/orchestrate.d.ts +9 -7
  19. package/dist/src/cli/commands/orchestrate.js +40 -4
  20. package/dist/src/cli/commands/orchestrate.js.map +1 -1
  21. package/dist/src/cli/commands/plan.d.ts +3 -1
  22. package/dist/src/cli/commands/plan.js +79 -22
  23. package/dist/src/cli/commands/plan.js.map +1 -1
  24. package/dist/src/cli/index.js +11 -15
  25. package/dist/src/cli/index.js.map +1 -1
  26. package/dist/src/cli/utils/compliance.js +0 -1
  27. package/dist/src/cli/utils/compliance.js.map +1 -1
  28. package/dist/src/cli/utils/config-schema.d.ts +7 -7
  29. package/dist/src/cli/utils/pkg.d.ts +19 -0
  30. package/dist/src/cli/utils/pkg.js +29 -5
  31. package/dist/src/cli/utils/pkg.js.map +1 -1
  32. package/dist/src/modules/adapters/definitions.js +1 -1
  33. package/dist/src/modules/adapters/definitions.js.map +1 -1
  34. package/dist/src/modules/adapters/shared.js +7 -4
  35. package/dist/src/modules/adapters/shared.js.map +1 -1
  36. package/dist/src/modules/agents/definitions.d.ts +1 -1
  37. package/dist/src/modules/agents/definitions.js +129 -69
  38. package/dist/src/modules/agents/definitions.js.map +1 -1
  39. package/dist/src/modules/agents/registry/analyst.js +5 -1
  40. package/dist/src/modules/agents/registry/analyst.js.map +1 -1
  41. package/dist/src/modules/agents/registry/backend.js +5 -4
  42. package/dist/src/modules/agents/registry/backend.js.map +1 -1
  43. package/dist/src/modules/agents/registry/database.js +2 -1
  44. package/dist/src/modules/agents/registry/database.js.map +1 -1
  45. package/dist/src/modules/agents/registry/devops.js +2 -0
  46. package/dist/src/modules/agents/registry/devops.js.map +1 -1
  47. package/dist/src/modules/agents/registry/explorer.js +1 -0
  48. package/dist/src/modules/agents/registry/explorer.js.map +1 -1
  49. package/dist/src/modules/agents/registry/git.js +3 -1
  50. package/dist/src/modules/agents/registry/git.js.map +1 -1
  51. package/dist/src/modules/agents/registry/manager.js +8 -2
  52. package/dist/src/modules/agents/registry/manager.js.map +1 -1
  53. package/dist/src/modules/agents/registry/native.js +5 -1
  54. package/dist/src/modules/agents/registry/native.js.map +1 -1
  55. package/dist/src/modules/agents/registry/security.js +1 -0
  56. package/dist/src/modules/agents/registry/security.js.map +1 -1
  57. package/dist/src/shared/constants.d.ts +1 -1
  58. package/dist/src/shared/constants.js +10 -9
  59. package/dist/src/shared/constants.js.map +1 -1
  60. package/dist/tests/approve.test.js +4 -9
  61. package/dist/tests/approve.test.js.map +1 -1
  62. package/dist/tests/integration/agent_flow.test.js +2 -2
  63. package/dist/tests/integration/agent_flow.test.js.map +1 -1
  64. package/dist/tests/orchestrate.test.js +2 -7
  65. package/dist/tests/orchestrate.test.js.map +1 -1
  66. package/framework-mcp/dist/constants.js +64 -0
  67. package/framework-mcp/dist/index.js +109 -0
  68. package/framework-mcp/dist/tools/control_plane/locking.js +64 -0
  69. package/framework-mcp/dist/tools/control_plane/registry.js +34 -0
  70. package/framework-mcp/dist/tools/dashboard/start_dashboard.js +29 -0
  71. package/framework-mcp/dist/tools/definitions.js +300 -0
  72. package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +59 -0
  73. package/framework-mcp/dist/tools/file_system/patch_file.js +25 -0
  74. package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
  75. package/framework-mcp/dist/tools/file_system/replace_text.js +43 -0
  76. package/framework-mcp/dist/tools/file_system/write_file.js +38 -0
  77. package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
  78. package/framework-mcp/dist/tools/framework/get_status.js +5 -0
  79. package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
  80. package/framework-mcp/dist/tools/framework/run_tests.js +25 -0
  81. package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
  82. package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
  83. package/framework-mcp/dist/tools/index.js +62 -0
  84. package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
  85. package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
  86. package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
  87. package/framework-mcp/dist/tools/messaging/send_message.js +87 -0
  88. package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
  89. package/framework-mcp/dist/tools/observability/get_health.js +19 -0
  90. package/framework-mcp/dist/tools/quality/check_lint.js +28 -0
  91. package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
  92. package/framework-mcp/dist/tools/search/get_map.js +43 -0
  93. package/framework-mcp/dist/tools/search/grep_search.js +76 -0
  94. package/framework-mcp/dist/tools/search/list_dir.js +28 -0
  95. package/framework-mcp/dist/tools/shell/run_command.js +46 -0
  96. package/framework-mcp/dist/tools/types.js +1 -0
  97. package/framework-mcp/dist/utils/cli.js +20 -0
  98. package/framework-mcp/dist/utils/compliance.js +29 -0
  99. package/framework-mcp/dist/utils/fs.js +44 -0
  100. package/framework-mcp/dist/utils/metrics.js +56 -0
  101. package/framework-mcp/dist/utils/security.js +60 -0
  102. package/framework-mcp/package.json +19 -0
  103. package/framework-mcp/src/constants.ts +78 -0
  104. package/framework-mcp/src/declarations.d.ts +17 -0
  105. package/framework-mcp/src/index.ts +132 -0
  106. package/framework-mcp/src/tools/control_plane/locking.ts +71 -0
  107. package/framework-mcp/src/tools/control_plane/registry.ts +38 -0
  108. package/framework-mcp/src/tools/dashboard/start_dashboard.ts +33 -0
  109. package/framework-mcp/src/tools/definitions.ts +302 -0
  110. package/framework-mcp/src/tools/file_system/batch_surgical_edit.ts +79 -0
  111. package/framework-mcp/src/tools/file_system/patch_file.ts +33 -0
  112. package/framework-mcp/src/tools/file_system/read_file.ts +58 -0
  113. package/framework-mcp/src/tools/file_system/replace_text.ts +52 -0
  114. package/framework-mcp/src/tools/file_system/write_file.ts +45 -0
  115. package/framework-mcp/src/tools/framework/audit_deps.ts +49 -0
  116. package/framework-mcp/src/tools/framework/get_status.ts +7 -0
  117. package/framework-mcp/src/tools/framework/orchestrate.ts +7 -0
  118. package/framework-mcp/src/tools/framework/run_tests.ts +28 -0
  119. package/framework-mcp/src/tools/framework/update_contract_hash.ts +7 -0
  120. package/framework-mcp/src/tools/framework/update_memory.ts +10 -0
  121. package/framework-mcp/src/tools/index.ts +66 -0
  122. package/framework-mcp/src/tools/memory/get_insights.ts +41 -0
  123. package/framework-mcp/src/tools/memory/read_memory.ts +31 -0
  124. package/framework-mcp/src/tools/messaging/log_action.ts +28 -0
  125. package/framework-mcp/src/tools/messaging/send_message.ts +89 -0
  126. package/framework-mcp/src/tools/observability/check_ports.ts +30 -0
  127. package/framework-mcp/src/tools/observability/get_health.ts +24 -0
  128. package/framework-mcp/src/tools/quality/check_lint.ts +33 -0
  129. package/framework-mcp/src/tools/search/get_gaps.ts +54 -0
  130. package/framework-mcp/src/tools/search/get_map.ts +48 -0
  131. package/framework-mcp/src/tools/search/grep_search.ts +76 -0
  132. package/framework-mcp/src/tools/search/list_dir.ts +34 -0
  133. package/framework-mcp/src/tools/shell/run_command.ts +56 -0
  134. package/framework-mcp/src/tools/types.ts +89 -0
  135. package/framework-mcp/src/utils/cli.ts +20 -0
  136. package/framework-mcp/src/utils/compliance.ts +37 -0
  137. package/framework-mcp/src/utils/fs.ts +45 -0
  138. package/framework-mcp/src/utils/metrics.ts +73 -0
  139. package/framework-mcp/src/utils/security.ts +66 -0
  140. package/framework-mcp/tests/tools/file_system/file_system_tools.test.ts +212 -0
  141. package/framework-mcp/tests/tools/messaging/send_message.test.ts +136 -0
  142. package/framework-mcp/tests/tools/quality/check_lint.test.ts +46 -0
  143. package/framework-mcp/tests/tools/shell/run_command.test.ts +55 -0
  144. package/framework-mcp/tsconfig.json +14 -0
  145. package/package.json +5 -3
  146. package/src/cli/adapters/core.ts +2 -3
  147. package/src/cli/adapters/index.ts +1 -0
  148. package/src/cli/adapters/scaffold.ts +20 -7
  149. package/src/cli/commands/init/scaffold-core.ts +45 -6
  150. package/src/cli/commands/init.ts +31 -2
  151. package/src/cli/commands/orchestrate.ts +41 -4
  152. package/src/cli/commands/plan.ts +89 -23
  153. package/src/cli/index.ts +14 -19
  154. package/src/cli/utils/compliance.ts +8 -9
  155. package/src/cli/utils/pkg.ts +42 -13
  156. package/src/modules/adapters/definitions.ts +1 -1
  157. package/src/modules/adapters/shared.ts +7 -4
  158. package/src/modules/agents/definitions.ts +140 -73
  159. package/src/modules/agents/registry/analyst.ts +5 -1
  160. package/src/modules/agents/registry/backend.ts +5 -4
  161. package/src/modules/agents/registry/database.ts +2 -1
  162. package/src/modules/agents/registry/devops.ts +2 -0
  163. package/src/modules/agents/registry/explorer.ts +1 -0
  164. package/src/modules/agents/registry/git.ts +3 -1
  165. package/src/modules/agents/registry/manager.ts +8 -2
  166. package/src/modules/agents/registry/native.ts +5 -1
  167. package/src/modules/agents/registry/security.ts +1 -0
  168. package/src/shared/constants.ts +14 -13
  169. package/templates/prompts/bug-fix-recipe.md +20 -0
  170. package/templates/prompts/contract-design-recipe.md +21 -0
  171. package/templates/prompts/db-management-recipe.md +25 -0
  172. package/templates/prompts/deployment-recipe.md +23 -0
  173. package/templates/prompts/new-feature-recipe.md +19 -0
  174. package/templates/prompts/performance-optimization-recipe.md +23 -0
  175. package/templates/prompts/pull-request-template.md +21 -0
  176. package/templates/prompts/refactoring-recipe.md +21 -0
  177. package/templates/prompts/security-audit-recipe.md +20 -0
  178. package/templates/standards/architecture-standards.md +23 -0
  179. package/templates/standards/auth-standards.md +125 -0
  180. package/templates/standards/crud-governance.md +21 -0
  181. package/templates/standards/deployment-standards.md +21 -0
  182. package/templates/standards/frontend-standards.md +37 -0
  183. package/templates/standards/github-actions-standards.md +43 -0
  184. package/templates/standards/i18n-standards.md +17 -0
  185. package/templates/standards/kysely-standards.md +47 -0
  186. package/templates/standards/llm-governance.md +15 -0
  187. package/templates/standards/logging-and-secrets.md +34 -0
  188. package/templates/standards/mobile-standards.md +23 -0
  189. package/templates/standards/observability-standards.md +15 -0
  190. package/templates/standards/performance-standards.md +15 -0
  191. package/templates/standards/pino-standards.md +46 -0
  192. package/templates/standards/playwright-standards.md +54 -0
  193. package/templates/standards/quality-standards.md +31 -0
  194. package/templates/standards/react-query-standards.md +72 -0
  195. package/templates/standards/react-router-standards.md +62 -0
  196. package/templates/standards/security-audit-standards.md +16 -0
  197. package/templates/standards/security-standards.md +21 -0
  198. package/templates/standards/swagger-standards.md +50 -0
  199. package/templates/standards/tailwind-standards.md +20 -0
  200. package/templates/standards/testing-standards.md +31 -0
  201. package/templates/standards/typeorm-standards.md +49 -0
  202. package/templates/standards/vitest-standards.md +110 -0
  203. package/src/cli/commands/app.ts +0 -56
  204. package/src/cli/utils/app-backend.ts +0 -257
  205. package/src/cli/utils/app-docs.ts +0 -83
  206. package/src/cli/utils/app-frontend.ts +0 -263
  207. package/src/cli/utils/app-inferrer.ts +0 -63
  208. package/src/cli/utils/app-mobile.ts +0 -113
  209. package/src/cli/utils/app-types.ts +0 -248
  210. package/src/cli/utils/app.ts +0 -6
@@ -1,12 +1,24 @@
1
1
  // ─────────────────────────────────────────────────────────────────────────────
2
2
  // Enderun Army — Agent Registry
3
3
  // Enderun Order v2 · Structured AgentDefinition schema
4
+ //
5
+ // VALID FRONTMATTER FIELDS per platform:
6
+ // ┌───────────────┬────────────────────────────────────────────────────────────┐
7
+ // │ gemini-cli │ name, description, model, tools (YAML list) │
8
+ // │ claude-code │ name, description, model, tools (inline array), color │
9
+ // │ cursor │ description, globs, alwaysApply │
10
+ // │ codex-cli │ agent-type, display-name, when-to-use, model, allowed-tools│
11
+ // │ antigravity │ JSON — customAgentSpec schema │
12
+ // └───────────────┴────────────────────────────────────────────────────────────┘
13
+ // Custom fields (capability, tags, tier) are Enderun-internal metadata and
14
+ // must NOT appear in any platform frontmatter.
4
15
  // ─────────────────────────────────────────────────────────────────────────────
5
16
 
6
17
  import fs from "fs";
7
18
  import path from "path";
8
19
  import { AgentDefinition } from "./types.js";
9
20
  import { getPackageRoot } from "../../cli/utils/pkg.js";
21
+ import { CURSOR_AGENT_GLOBS } from "../../shared/constants.js";
10
22
 
11
23
  // Import individual agent definitions
12
24
  import { manager } from "./registry/manager.js";
@@ -40,15 +52,13 @@ export const ALL_AGENTS: AgentDefinition[] = [
40
52
  ];
41
53
 
42
54
  // ─────────────────────────────────────────────────────────────────────────────
43
- // Multi-Platform Agent Exporter
44
- // Supported targets:
45
- // claude-code → .claude/agents/{name}.md (YAML frontmatter + system prompt)
46
- // gemini-cli → .gemini/agents/{name}.md (same format, Gemini field names)
47
- // antigravity → .agents/{name}/agent.json (JSON, customAgent schema)
48
- // codex-cli → .agents/{name}.md (YAML frontmatter, AGENTS.md style)
55
+ // Tool Maps — Internal tool names → platform-native tool identifiers
49
56
  // ─────────────────────────────────────────────────────────────────────────────
50
57
 
51
- /** Map our internal tool names → Claude Code's built-in tool identifiers */
58
+ /**
59
+ * Claude Code built-in tool names (case-sensitive).
60
+ * Reference: https://docs.anthropic.com/en/docs/claude-code/sub-agents
61
+ */
52
62
  const CLAUDE_TOOL_MAP: Record<string, string> = {
53
63
  read_file: "Read",
54
64
  write_file: "Write",
@@ -62,7 +72,6 @@ const CLAUDE_TOOL_MAP: Record<string, string> = {
62
72
  run_tests: "Bash",
63
73
  log_agent_action: "Write",
64
74
  send_agent_message: "Task",
65
- // Enderun-custom tools pass through as-is (MCP or custom tools)
66
75
  orchestrate_loop: "Task",
67
76
  get_project_map: "Bash",
68
77
  get_project_gaps: "Bash",
@@ -75,17 +84,24 @@ const CLAUDE_TOOL_MAP: Record<string, string> = {
75
84
  check_active_ports: "Bash",
76
85
  start_dashboard: "Bash",
77
86
  update_contract_hash: "Write",
87
+ acquire_lock: "Write",
88
+ release_lock: "Write",
89
+ register_agent: "Write",
90
+ check_lint: "Bash",
78
91
  };
79
92
 
80
- /** Map our internal tool names → Gemini CLI tool identifiers */
93
+ /**
94
+ * Gemini CLI built-in tool names.
95
+ * Reference: https://ai.google.dev/gemini-api/docs/function-calling
96
+ */
81
97
  const GEMINI_TOOL_MAP: Record<string, string> = {
82
98
  read_file: "read_file",
83
99
  write_file: "write_file",
84
- replace_text: "replace",
85
- batch_surgical_edit: "replace",
86
- patch_file: "replace",
100
+ replace_text: "replace_in_file",
101
+ batch_surgical_edit: "replace_in_file",
102
+ patch_file: "replace_in_file",
87
103
  list_dir: "list_directory",
88
- grep_search: "grep_search",
104
+ grep_search: "search_file_content",
89
105
  run_shell_command: "run_shell_command",
90
106
  view_file: "read_file",
91
107
  run_tests: "run_shell_command",
@@ -103,77 +119,122 @@ const GEMINI_TOOL_MAP: Record<string, string> = {
103
119
  check_active_ports: "run_shell_command",
104
120
  start_dashboard: "run_shell_command",
105
121
  update_contract_hash: "write_file",
122
+ acquire_lock: "write_file",
123
+ release_lock: "write_file",
124
+ register_agent: "write_file",
125
+ check_lint: "run_shell_command",
106
126
  };
107
127
 
108
- /** Strategy: which model to assign based on capability score */
128
+ // ─────────────────────────────────────────────────────────────────────────────
129
+ // Model Resolution
130
+ // ─────────────────────────────────────────────────────────────────────────────
131
+
132
+ /**
133
+ * Assigns the appropriate model based on capability score.
134
+ * Only valid, real model identifiers are used here.
135
+ */
109
136
  function resolveModel(
110
137
  cap: number,
111
138
  platform: "claude-code" | "gemini-cli" | "antigravity" | "codex-cli"
112
139
  ): string {
113
140
  if (platform === "claude-code") {
114
- return cap === 10 ? "claude-opus-4-8"
115
- : cap === 9 ? "claude-sonnet-4-6"
116
- : "claude-haiku-4-5";
141
+ // Verified Claude model names as of 2025-06
142
+ return cap === 10 ? "claude-opus-4-5"
143
+ : cap === 9 ? "claude-sonnet-4-5"
144
+ : "claude-haiku-3-5";
117
145
  }
118
146
  if (platform === "gemini-cli" || platform === "antigravity") {
147
+ // Verified Gemini model names as of 2025-06
119
148
  return cap === 10 ? "gemini-2.5-pro"
120
149
  : cap === 9 ? "gemini-2.5-flash"
121
- : "gemini-2.5-flash-8b";
150
+ : "gemini-2.5-flash-lite";
122
151
  }
123
- // codex-cli
124
- return cap === 10 ? "codex-1" : "o4-mini";
152
+ // codex-cli / OpenAI
153
+ return cap === 10 ? "o3" : "o4-mini";
125
154
  }
126
155
 
127
- /** Build a flat system prompt string from structured instructions */
128
- function buildSystemPrompt(ag: AgentDefinition, baseKnowledgeDir: string = path.join(getPackageRoot(), "templates/standards")): string {
156
+ // ─────────────────────────────────────────────────────────────────────────────
157
+ // System Prompt Builder
158
+ // ─────────────────────────────────────────────────────────────────────────────
159
+
160
+ /**
161
+ * Builds a rich, enterprise-grade system prompt from structured instructions.
162
+ * Embeds governance document contents inline for agents that have knowledgeFiles.
163
+ */
164
+ function buildSystemPrompt(
165
+ ag: AgentDefinition,
166
+ baseKnowledgeDir: string = path.join(getPackageRoot(), "templates/standards")
167
+ ): string {
129
168
  const lines: string[] = [
130
- "# Identity",
169
+ `# 🎖️ ${ag.displayName} — Agent Enderun`,
170
+ "",
171
+ "## Identity",
131
172
  ag.instructions.identity,
132
173
  "",
133
- "# Mission",
174
+ "## Mission",
134
175
  ag.instructions.mission,
135
176
  "",
136
- "# Chain of Thought Protocol",
177
+ "## Role Scope",
178
+ `**Primary Role:** ${ag.role}`,
179
+ `**Authority Tier:** ${ag.tier} (Capability: ${ag.capability}/10)`,
180
+ "",
181
+ "## Chain of Thought Protocol",
182
+ "> Follow these steps in strict order for every task:",
183
+ "",
137
184
  ag.instructions.chainOfThought,
138
185
  "",
139
- "# Discipline rules",
140
- ...ag.instructions.rules.map(r => `- ${r}`),
186
+ "## Discipline Rules",
187
+ "> These are **non-negotiable** governance mandates. Violating any rule triggers an immediate task freeze.",
188
+ "",
189
+ ...ag.instructions.rules.map((r: string, i: number) => `${i + 1}. ${r}`),
190
+ "",
191
+ "## Enterprise Context",
192
+ "You are operating within a **multi-agent enterprise system** governed by the Agent Enderun framework.",
193
+ "All actions are traced, logged, and auditable. Every decision must be defensible and reversible.",
194
+ "- Always read PROJECT_MEMORY.md at session start for full context.",
195
+ "- Always pass the active **Trace ID** in all agent-to-agent messages.",
196
+ "- Never perform irreversible operations (schema drops, bulk deletes) without @manager approval.",
197
+ "- Prefer surgical edits (`replace_text`, `patch_file`) over full file rewrites.",
198
+ "- Escalate ambiguity to @manager instead of guessing.",
141
199
  ];
142
-
200
+
143
201
  if (ag.instructions.knowledgeFiles?.length) {
144
- lines.push("", "# Required reading (Standards Enforced)");
145
- ag.instructions.knowledgeFiles.forEach(f => {
202
+ lines.push("", "## Governance Standards (Required Reading)");
203
+ lines.push("> Read and internalize the following standards before acting on any task.");
204
+ ag.instructions.knowledgeFiles.forEach((f: string) => {
146
205
  const filePath = path.join(baseKnowledgeDir, f);
147
206
  if (fs.existsSync(filePath)) {
148
- lines.push(`\n## Content of ${f}:\n`, fs.readFileSync(filePath, "utf8"));
207
+ lines.push("", `### 📘 ${f}`, "", fs.readFileSync(filePath, "utf8").trim());
149
208
  } else {
150
- lines.push(`- ${f} (File not found)`);
209
+ lines.push("", `### 📘 ${f}`, `> ⚠️ File not found at \`${filePath}\`. Run \`agent-enderun init\` to scaffold standards.`);
151
210
  }
152
211
  });
153
212
  }
213
+
154
214
  return lines.join("\n");
155
215
  }
156
216
 
157
217
  // ─────────────────────────────────────────────────────────────────────────────
158
218
  // CLAUDE CODE → .claude/agents/{name}.md
219
+ // Valid fields: name, description, model, tools, color
220
+ // Ref: https://docs.anthropic.com/en/docs/claude-code/sub-agents
159
221
  // ─────────────────────────────────────────────────────────────────────────────
160
222
 
161
223
  export function toClaudeCodeMd(ag: AgentDefinition, baseKnowledgeDir?: string): string {
162
- const tools = [...new Set(ag.tools.map(t => CLAUDE_TOOL_MAP[t] ?? t))];
224
+ const tools = [...new Set(ag.tools.map((t: string) => CLAUDE_TOOL_MAP[t] ?? t))];
163
225
  const model = resolveModel(ag.capability, "claude-code");
164
226
  const color = ag.tier === "supreme" ? "purple"
165
227
  : ag.tier === "recon" ? "gray"
166
228
  : "blue";
167
229
 
230
+ // Only officially supported frontmatter fields
168
231
  const frontmatter = [
169
232
  "---",
170
233
  `name: ${ag.name}`,
171
234
  "description: >-",
172
- ` ${ag.description} Use proactively for ${ag.role.toLowerCase()} tasks.`,
235
+ ` ${ag.description} Invoke proactively for ${ag.role.toLowerCase()} tasks in enterprise monorepo projects.`,
173
236
  `model: ${model}`,
174
237
  `tools: [${tools.map(t => `"${t}"`).join(", ")}]`,
175
- `capability: ${ag.capability}`,
176
- `tags: [${ag.tags.map(t => `"${t}"`).join(", ")}]`,
177
238
  `color: ${color}`,
178
239
  "---",
179
240
  ].join("\n");
@@ -183,20 +244,21 @@ export function toClaudeCodeMd(ag: AgentDefinition, baseKnowledgeDir?: string):
183
244
 
184
245
  // ─────────────────────────────────────────────────────────────────────────────
185
246
  // GEMINI CLI → .gemini/agents/{name}.md
247
+ // Valid fields: name, description, model, tools (YAML list)
248
+ // Ref: https://ai.google.dev/gemini-api/docs/agents
186
249
  // ─────────────────────────────────────────────────────────────────────────────
187
250
 
188
251
  export function toGeminiCliMd(ag: AgentDefinition, baseKnowledgeDir?: string): string {
189
- const tools = [...new Set(ag.tools.map(t => GEMINI_TOOL_MAP[t] ?? t))];
252
+ const tools = [...new Set(ag.tools.map((t: string) => GEMINI_TOOL_MAP[t] ?? t))];
190
253
  const model = resolveModel(ag.capability, "gemini-cli");
191
254
 
255
+ // Only officially supported frontmatter fields — no capability, no tags
192
256
  const frontmatter = [
193
257
  "---",
194
258
  `name: ${ag.name}`,
195
259
  "description: >-",
196
- ` ${ag.description}`,
260
+ ` ${ag.description} Use for ${ag.role.toLowerCase()} tasks.`,
197
261
  `model: ${model}`,
198
- `capability: ${ag.capability}`,
199
- `tags: [${ag.tags.map(t => `"${t}"`).join(", ")}]`,
200
262
  "tools:",
201
263
  ...tools.map(t => ` - ${t}`),
202
264
  "---",
@@ -207,9 +269,21 @@ export function toGeminiCliMd(ag: AgentDefinition, baseKnowledgeDir?: string): s
207
269
 
208
270
  // ─────────────────────────────────────────────────────────────────────────────
209
271
  // ANTIGRAVITY CLI → .agents/{name}/agent.json
272
+ // Spec: Antigravity customAgentSpec JSON schema
210
273
  // ─────────────────────────────────────────────────────────────────────────────
211
274
 
212
- export function toAntigravityJson(ag: AgentDefinition): string {
275
+ export function toAntigravityJson(ag: AgentDefinition, baseKnowledgeDir?: string): string {
276
+ const knowledgeBase = baseKnowledgeDir ?? path.join(getPackageRoot(), "templates/standards");
277
+
278
+ // Embed actual file contents so the agent can read governance docs
279
+ const knowledgeSections = (ag.instructions.knowledgeFiles ?? []).map((f: string) => {
280
+ const filePath = path.join(knowledgeBase, f);
281
+ const content = fs.existsSync(filePath)
282
+ ? fs.readFileSync(filePath, "utf8").trim()
283
+ : `(${f} — file not found at build time)`;
284
+ return { title: `Required Reading — ${f}`, content };
285
+ });
286
+
213
287
  const payload = {
214
288
  name: ag.name,
215
289
  displayName: ag.displayName,
@@ -220,7 +294,7 @@ export function toAntigravityJson(ag: AgentDefinition): string {
220
294
  systemPromptSections: [
221
295
  {
222
296
  title: "Identity & Mission",
223
- content: `${ag.instructions.identity}\n\n${ag.instructions.mission}`,
297
+ content: `${ag.instructions.identity}\n\n**Mission:** ${ag.instructions.mission}`,
224
298
  },
225
299
  {
226
300
  title: "Chain of Thought Protocol",
@@ -228,14 +302,19 @@ export function toAntigravityJson(ag: AgentDefinition): string {
228
302
  },
229
303
  {
230
304
  title: "Discipline Rules",
231
- content: ag.instructions.rules.join("\n"),
305
+ content: ag.instructions.rules.map((r: string, i: number) => `${i + 1}. ${r}`).join("\n"),
306
+ },
307
+ {
308
+ title: "Enterprise Context",
309
+ content: [
310
+ "You are part of a multi-agent enterprise governance system.",
311
+ "- Always include active Trace ID in all messages.",
312
+ "- Read PROJECT_MEMORY.md at session start.",
313
+ "- Prefer surgical edits over full file rewrites.",
314
+ "- Escalate high-risk operations to @manager.",
315
+ ].join("\n"),
232
316
  },
233
- ...(ag.instructions.knowledgeFiles?.length
234
- ? [{
235
- title: "Required Reading",
236
- content: ag.instructions.knowledgeFiles.join("\n"),
237
- }]
238
- : []),
317
+ ...knowledgeSections,
239
318
  ],
240
319
  toolNames: ag.tools,
241
320
  },
@@ -249,26 +328,26 @@ export const buildAgentJson = toAntigravityJson;
249
328
 
250
329
  // ─────────────────────────────────────────────────────────────────────────────
251
330
  // CODEX CLI (OpenAI) → .agents/{name}.md
331
+ // Valid fields: agent-type, display-name, when-to-use, model, allowed-tools
252
332
  // ─────────────────────────────────────────────────────────────────────────────
253
333
 
254
334
  export function toCodexMd(ag: AgentDefinition, baseKnowledgeDir?: string): string {
255
335
  const model = resolveModel(ag.capability, "codex-cli");
256
- const tools = [...new Set(ag.tools.map(t => {
257
- if (["read_file","view_file","list_dir","grep_search","get_memory_insights","read_project_memory"].includes(t)) return "read";
258
- if (["write_file","replace_text","batch_surgical_edit","patch_file","update_project_memory","log_agent_action"].includes(t)) return "write";
259
- return "shell";
336
+ const tools = [...new Set(ag.tools.map((t: string) => {
337
+ if (["read_file","view_file","list_dir","grep_search","get_memory_insights","read_project_memory","get_project_map","get_project_gaps","get_framework_status"].includes(t)) return "read";
338
+ if (["write_file","replace_text","batch_surgical_edit","patch_file","update_project_memory","log_agent_action","acquire_lock","release_lock","register_agent","update_contract_hash"].includes(t)) return "write";
339
+ return "shell";
260
340
  }))];
261
341
 
342
+ // Only officially supported Codex CLI frontmatter fields — no tier, no capability
262
343
  const frontmatter = [
263
344
  "---",
264
345
  `agent-type: "${ag.name}"`,
265
346
  `display-name: "${ag.displayName}"`,
266
347
  "when-to-use: >-",
267
- ` Use for ${ag.role.toLowerCase()}. ${ag.description}`,
348
+ ` Invoke for ${ag.role.toLowerCase()} tasks. ${ag.description}`,
268
349
  `model: ${model}`,
269
350
  `allowed-tools: [${tools.map(t => `"${t}"`).join(", ")}]`,
270
- `tier: ${ag.tier}`,
271
- `capability: ${ag.capability}`,
272
351
  "---",
273
352
  ].join("\n");
274
353
 
@@ -277,28 +356,16 @@ export function toCodexMd(ag: AgentDefinition, baseKnowledgeDir?: string): strin
277
356
 
278
357
  // ─────────────────────────────────────────────────────────────────────────────
279
358
  // CURSOR IDE → .cursor/rules/{name}.mdc
359
+ // Valid fields: description, globs, alwaysApply
360
+ // Ref: https://docs.cursor.com/context/rules
280
361
  // ─────────────────────────────────────────────────────────────────────────────
281
362
 
282
- const GLOB_MAP: Record<string, string> = {
283
- backend: "apps/backend/**/*",
284
- frontend: "apps/web/**/*",
285
- database: "apps/backend/src/database/**/*",
286
- mobile: "apps/mobile/**/*",
287
- native: "apps/native/**/*",
288
- quality: "*",
289
- security: "*",
290
- devops: "*",
291
- explorer: "*",
292
- git: "*",
293
- analyst: "*",
294
- manager: "*",
295
- };
296
-
297
363
  export function toCursorMdc(ag: AgentDefinition, baseKnowledgeDir?: string): string {
298
- const glob = GLOB_MAP[ag.name] || "**/*";
364
+ const glob = CURSOR_AGENT_GLOBS[ag.name] || "**/*";
365
+ // Only officially supported Cursor MDC frontmatter fields
299
366
  const frontmatter = [
300
367
  "---",
301
- `description: Agent Enderun — @${ag.name} rules for ${ag.displayName}. ${ag.description.slice(0, 100)}`,
368
+ `description: "${ag.displayName} ${ag.description.slice(0, 120).replace(/"/g, "'")}"`,
302
369
  `globs: ${glob}`,
303
370
  "alwaysApply: false",
304
371
  "---",
@@ -10,7 +10,7 @@ export const analyst: AgentDefinition = {
10
10
  "Specs verification and Contract Audit specialist. " +
11
11
  "Audits truth and contracts within the Army.",
12
12
  capability: 9,
13
- tier: "core",
13
+ tier: "recon",
14
14
  tags: ["core", "strategy"],
15
15
  stateMachine: STATE_MACHINE,
16
16
  tools: [
@@ -18,8 +18,11 @@ export const analyst: AgentDefinition = {
18
18
  "list_dir",
19
19
  "grep_search",
20
20
  "get_project_map",
21
+ "get_project_gaps",
21
22
  "read_project_memory",
22
23
  "get_memory_insights",
24
+ "send_agent_message",
25
+ "update_contract_hash",
23
26
  ],
24
27
  instructions: {
25
28
  identity: "Strategy Analyst and Contract-First Compliance Auditor",
@@ -36,5 +39,6 @@ export const analyst: AgentDefinition = {
36
39
  "VERSIONING INTEGRITY: Validate that all API versioning changes are correctly registered in 'contract.version.json'.",
37
40
  "LIVE AUDIT: Continuously audit business rules against the live implementation for drift.",
38
41
  ],
42
+ knowledgeFiles: ["architecture-standards.md", "crud-governance.md"],
39
43
  },
40
44
  };
@@ -28,20 +28,21 @@ export const backend: AgentDefinition = {
28
28
  instructions: {
29
29
  identity: "Backend Domain Engineer and Database Management Owner",
30
30
  mission:
31
- "Deliver reliable, type-safe server logic that upholds Kysley-only " +
31
+ "Deliver reliable, type-safe server logic that upholds Kysely/TypeORM " +
32
32
  "data access and strict repository/service separation.",
33
33
  chainOfThought: "1. Analyze: Read the task, context, and relevant governance documents.\n" +
34
34
  "2. Validate: Cross-reference with project rules, contracts, and architecture standards.\n" +
35
35
  "3. Plan: Break down the task into small, atomic, and verifiable steps.\n" +
36
36
  "4. Execute: Perform the task using approved tools, adhering to quality and security constraints.",
37
37
  rules: [
38
- "BRANDED TYPES: Use branded types for all domain IDs never raw string or number.",
39
- "KYSELY ONLY: All database access via Kysely — raw SQL strings are unconditionally forbidden.",
38
+ "STRICT BRANDED TYPES: Absolute enforcement of branded types for ALL domain IDs (e.g., UserId, ProjectId). Raw 'string' or 'number' for IDs is a Nizam violation and will cause task rejection.",
39
+ "KYSELY ONLY: All database access via Kysely — raw SQL strings are unconditionally forbidden. No exceptions.",
40
40
  "LAYER SEPARATION: Isolate queries in repository/service layers — direct DB calls in controllers are forbidden.",
41
41
  "ERROR HANDLING: Wrap all async logic in robust try/catch blocks with typed error responses.",
42
+ "PII PROTECTION: Never log or store real user data. Use anonymized hashes for debugging tasks.",
42
43
  "HIGH-RISK OPS: Refuse User/Role management, bulk deletes, schema alterations, and billing changes autonomously. " +
43
44
  "Return a standard refusal, send a managerApproval request to @manager, and shift to WAITING status.",
44
45
  ],
45
- knowledgeFiles: ["crud-governance.md"],
46
+ knowledgeFiles: ["crud-governance.md", "kysely-standards.md", "typeorm-standards.md"],
46
47
  },
47
48
  };
@@ -21,6 +21,7 @@ export const database: AgentDefinition = {
21
21
  "list_dir",
22
22
  "grep_search",
23
23
  "read_project_memory",
24
+ "send_agent_message",
24
25
  ],
25
26
  instructions: {
26
27
  identity: "Database Architect and Migration Integrity Owner",
@@ -37,6 +38,6 @@ export const database: AgentDefinition = {
37
38
  "DETERMINISTIC MIGRATIONS: Every migration must be reversible and produce identical results across environments.",
38
39
  "PERFORMANCE FIRST: Design indexes proactively — never retroactively after a performance incident.",
39
40
  ],
40
- knowledgeFiles: ["performance-standards.md", "quality-standards.md"],
41
+ knowledgeFiles: ["kysely-standards.md", "typeorm-standards.md", "quality-standards.md"],
41
42
  },
42
43
  };
@@ -16,11 +16,13 @@ export const devops: AgentDefinition = {
16
16
  tools: [
17
17
  "run_shell_command",
18
18
  "read_file",
19
+ "write_file",
19
20
  "list_dir",
20
21
  "get_system_health",
21
22
  "check_active_ports",
22
23
  "read_project_memory",
23
24
  "send_agent_message",
25
+ "log_agent_action",
24
26
  ],
25
27
  instructions: {
26
28
  identity: "Infrastructure Engineer and Environment Integrity Guardian",
@@ -36,5 +36,6 @@ export const explorer: AgentDefinition = {
36
36
  "DEPENDENCY MAP: Map all file dependencies and surface them to @manager in a structured report.",
37
37
  "RECON FIRST: No specialist should act on an unexplored codebase — flag absence of ADP as a phase blocker.",
38
38
  ],
39
+ knowledgeFiles: ["architecture-standards.md"],
39
40
  },
40
41
  };
@@ -10,11 +10,12 @@ export const git: AgentDefinition = {
10
10
  "Git flow, Branching, and Atomic Commit master. " +
11
11
  "Manages the scrolls of history.",
12
12
  capability: 9,
13
- tier: "core",
13
+ tier: "recon",
14
14
  tags: ["core", "logistics"],
15
15
  stateMachine: STATE_MACHINE,
16
16
  tools: [
17
17
  "run_shell_command",
18
+ "read_file",
18
19
  "list_dir",
19
20
  "grep_search",
20
21
  "read_project_memory",
@@ -35,5 +36,6 @@ export const git: AgentDefinition = {
35
36
  "NO FORCE PUSH: Force-pushing to any shared branch is unconditionally forbidden.",
36
37
  "GIT FLOW: Strictly follow git-flow branching conventions — feature, hotfix, release naming enforced.",
37
38
  ],
39
+ knowledgeFiles: ["logging-and-secrets.md"],
38
40
  },
39
41
  };
@@ -19,6 +19,9 @@ export const manager: AgentDefinition = {
19
19
  "read_project_memory",
20
20
  "get_memory_insights",
21
21
  "update_project_memory",
22
+ "acquire_lock",
23
+ "release_lock",
24
+ "log_agent_action",
22
25
  "get_project_gaps",
23
26
  "get_project_map",
24
27
  "audit_dependencies",
@@ -40,14 +43,17 @@ export const manager: AgentDefinition = {
40
43
  "4. Execute: Delegate sub-tasks to appropriate specialists and verify compliance at each step.",
41
44
  rules: [
42
45
  "ABSOLUTE COMPLIANCE: Freeze project and block task on any Nizam violation " +
43
- "(e.g. 'any' type, 'console.log', file overwrite). No further action until breach is purged.",
44
- "PHASE WALL: Gate every phase transition reject if even one TODO or lint error exists in scope.",
46
+ "(e.g. 'any' type, 'console.log', PII leakage, or raw ID usage). No further action until breach is purged.",
47
+ "PII AUDIT: Proactively scan all specialist logs and memories for PII (Emails, Names). Purge immediately if detected.",
48
+ "PHASE WALL: Gate every phase transition — reject if even one TODO, lint error, or unbranded ID exists in scope.",
45
49
  "ORCHESTRATION AUDIT: Audit every specialist message for constitutional compliance before delegating next sub-task.",
46
50
  "STRATEGIC RECIPES: Direct specialists to '.enderun/prompts/' for all refactor, bug-fix, or feature tasks.",
47
51
  "SURGICAL PRECISION: Reject any full-file overwrite proposal unless the file is under 50 lines.",
48
52
  "GAP ANALYSIS: Run 'get_project_gaps' after each phase — unfinished logic is a breach of discipline.",
49
53
  "SYSTEM OBSERVABILITY: Periodically invoke 'get_system_health' and 'check_active_ports' to verify environment stability.",
50
54
  "MEMORY INTEGRITY: Synchronize 'PROJECT_MEMORY.md' after every single turn. Memory drift is treason.",
55
+ "LOCKING PROTOCOL: Always acquire a lock via 'acquire_lock' on 'memory' resource before writing to PROJECT_MEMORY.md. Release immediately after write.",
51
56
  ],
57
+ knowledgeFiles: ["governance-standards.md"],
52
58
  },
53
59
  };
@@ -10,7 +10,7 @@ export const native: AgentDefinition = {
10
10
  "Desktop apps and system-level logic specialist. " +
11
11
  "Handles OS deep layers with paramount security.",
12
12
  capability: 9,
13
- tier: "core",
13
+ tier: "recon",
14
14
  tags: ["core", "native"],
15
15
  stateMachine: STATE_MACHINE,
16
16
  tools: [
@@ -21,6 +21,8 @@ export const native: AgentDefinition = {
21
21
  "grep_search",
22
22
  "read_project_memory",
23
23
  "run_shell_command",
24
+ "send_agent_message",
25
+ "log_agent_action",
24
26
  ],
25
27
  instructions: {
26
28
  identity: "Native Integration Engineer and OS-Layer Security Enforcer",
@@ -35,6 +37,8 @@ export const native: AgentDefinition = {
35
37
  "SECURITY PARAMOUNT: Handle all OS-layer operations with rigorous input validation.",
36
38
  "PLATFORM ISOLATION: Strictly separate platform-specific code from shared business logic.",
37
39
  "SYSTEM CALL AUDITING: Validate all native module inputs and log elevated-privilege operations.",
40
+ "ESCALATION PROTOCOL: Any destructive or elevated-privilege operation requires prior @manager approval via send_agent_message.",
38
41
  ],
42
+ knowledgeFiles: ["security-standards.md", "logging-and-secrets.md"],
39
43
  },
40
44
  };
@@ -17,6 +17,7 @@ export const security: AgentDefinition = {
17
17
  "read_file",
18
18
  "replace_text",
19
19
  "grep_search",
20
+ "send_agent_message",
20
21
  "read_project_memory",
21
22
  "get_memory_insights",
22
23
  "log_agent_action",
@@ -134,20 +134,21 @@ export const DEFAULT_MONOREPO_PATHS = {
134
134
  tests: "tests",
135
135
  } as const;
136
136
 
137
- /** Cursor rule globs per agent role (monorepo layout). */
137
+ /** Cursor rule globs per agent role (enterprise monorepo layout). */
138
138
  export const CURSOR_AGENT_GLOBS: Record<string, string> = {
139
- backend: `${DEFAULT_MONOREPO_PATHS.backend}/**/*`,
140
- frontend: `${DEFAULT_MONOREPO_PATHS.frontend}/**/*`,
141
- database: `${DEFAULT_MONOREPO_PATHS.backend}/src/database/**/*`,
142
- mobile: `${DEFAULT_MONOREPO_PATHS.mobile}/**/*`,
143
- native: "apps/native/**/*",
144
- quality: "*",
145
- security: "*",
146
- devops: "*",
147
- explorer: "*",
148
- git: "*",
149
- analyst: "*",
150
- manager: "*",
139
+ manager: "**/*",
140
+ security: "**/*",
141
+ architect: "**/*",
142
+ backend: `${DEFAULT_MONOREPO_PATHS.backend}/**/*`,
143
+ frontend: `${DEFAULT_MONOREPO_PATHS.frontend}/**/*`,
144
+ mobile: `${DEFAULT_MONOREPO_PATHS.mobile}/**/*`,
145
+ native: "apps/native/**/*",
146
+ database: `${DEFAULT_MONOREPO_PATHS.backend}/src/database/**/*`,
147
+ devops: "{.github,docker,infra,scripts,*.yml,*.yaml,Dockerfile*}",
148
+ quality: "**/*",
149
+ analyst: "{docs,specs,contracts}/**/*",
150
+ explorer: "**/*",
151
+ git: "**/*",
151
152
  };
152
153
 
153
154
  // ─── MCP & environment ──────────────────────────────────────────────────────
@@ -0,0 +1,20 @@
1
+ # 🐞 Scientific Debugging (Bug-Fix) Recipe
2
+
3
+ This recipe defines how to autonomously detect and permanently resolve a bug.
4
+
5
+ ## 1. Reproduction
6
+ - Analyze the logs (`audit_log.md`) that reported the error.
7
+ - Write the smallest test case (failing test) that triggers the error.
8
+
9
+ ## 2. Root Cause Analysis
10
+ - Check system resources with `get_system_health`.
11
+ - Verify the status of services with `check_active_ports`.
12
+ - Examine relevant code blocks line by line using `read_file`.
13
+
14
+ ## 3. Surgical Fix
15
+ - Perform only the surgical intervention that will fix the error.
16
+ - Check if there is a missing variable in ".env".
17
+
18
+ ## 4. Permanent Solution
19
+ - Verify that the test you wrote passes.
20
+ - If `quality-standards.md` needs to be updated to prevent similar errors, submit a proposal.