atabey 0.0.7 → 0.0.9

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 (181) hide show
  1. package/README.md +1 -1
  2. package/dist/framework-mcp/src/resources/index.js +2 -2
  3. package/dist/framework-mcp/src/resources/index.js.map +1 -1
  4. package/dist/framework-mcp/src/utils/errors.d.ts +46 -0
  5. package/dist/framework-mcp/src/utils/errors.js +69 -0
  6. package/dist/framework-mcp/src/utils/errors.js.map +1 -0
  7. package/dist/framework-mcp/src/utils/memory.d.ts +3 -0
  8. package/dist/framework-mcp/src/utils/memory.js +75 -0
  9. package/dist/framework-mcp/src/utils/memory.js.map +1 -0
  10. package/dist/framework-mcp/src/utils/storage.d.ts +60 -0
  11. package/dist/framework-mcp/src/utils/storage.js +208 -0
  12. package/dist/framework-mcp/src/utils/storage.js.map +1 -0
  13. package/dist/framework-mcp/src/utils/types.d.ts +19 -0
  14. package/dist/framework-mcp/src/utils/types.js +13 -0
  15. package/dist/framework-mcp/src/utils/types.js.map +1 -0
  16. package/dist/src/cli/adapters/core.js +12 -19
  17. package/dist/src/cli/adapters/core.js.map +1 -1
  18. package/dist/src/shared/constants.d.ts +1 -0
  19. package/dist/src/shared/constants.js +1 -0
  20. package/dist/src/shared/constants.js.map +1 -1
  21. package/dist/tests/adapter.test.js +3 -2
  22. package/dist/tests/adapter.test.js.map +1 -1
  23. package/framework-mcp/dist/constants.js +64 -0
  24. package/framework-mcp/dist/framework-mcp/src/constants.js +64 -0
  25. package/framework-mcp/dist/framework-mcp/src/index.js +144 -0
  26. package/framework-mcp/dist/framework-mcp/src/resources/index.js +58 -0
  27. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/locking.js +82 -0
  28. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/registry.js +35 -0
  29. package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +322 -0
  30. package/framework-mcp/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +64 -0
  31. package/framework-mcp/dist/framework-mcp/src/tools/file_system/patch_file.js +34 -0
  32. package/framework-mcp/dist/framework-mcp/src/tools/file_system/read_file.js +51 -0
  33. package/framework-mcp/dist/framework-mcp/src/tools/file_system/replace_text.js +50 -0
  34. package/framework-mcp/dist/framework-mcp/src/tools/file_system/write_file.js +43 -0
  35. package/framework-mcp/dist/framework-mcp/src/tools/framework/audit_deps.js +41 -0
  36. package/framework-mcp/dist/framework-mcp/src/tools/framework/get_status.js +5 -0
  37. package/framework-mcp/dist/framework-mcp/src/tools/framework/orchestrate.js +5 -0
  38. package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +27 -0
  39. package/framework-mcp/dist/framework-mcp/src/tools/framework/submit_plan.js +13 -0
  40. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_contract_hash.js +5 -0
  41. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_memory.js +8 -0
  42. package/framework-mcp/dist/framework-mcp/src/tools/index.js +62 -0
  43. package/framework-mcp/dist/framework-mcp/src/tools/memory/get_insights.js +34 -0
  44. package/framework-mcp/dist/framework-mcp/src/tools/memory/read_memory.js +28 -0
  45. package/framework-mcp/dist/framework-mcp/src/tools/messaging/log_action.js +22 -0
  46. package/framework-mcp/dist/framework-mcp/src/tools/messaging/send_message.js +94 -0
  47. package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +26 -0
  48. package/framework-mcp/dist/framework-mcp/src/tools/observability/get_health.js +19 -0
  49. package/framework-mcp/dist/framework-mcp/src/tools/quality/check_lint.js +30 -0
  50. package/framework-mcp/dist/framework-mcp/src/tools/search/get_gaps.js +48 -0
  51. package/framework-mcp/dist/framework-mcp/src/tools/search/get_map.js +43 -0
  52. package/framework-mcp/dist/framework-mcp/src/tools/search/grep_search.js +75 -0
  53. package/framework-mcp/dist/framework-mcp/src/tools/search/list_dir.js +28 -0
  54. package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +56 -0
  55. package/framework-mcp/dist/framework-mcp/src/tools/types.js +1 -0
  56. package/framework-mcp/dist/framework-mcp/src/utils/cli.js +59 -0
  57. package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +231 -0
  58. package/framework-mcp/dist/framework-mcp/src/utils/errors.js +68 -0
  59. package/framework-mcp/dist/framework-mcp/src/utils/fs.js +44 -0
  60. package/framework-mcp/dist/framework-mcp/src/utils/memory.js +74 -0
  61. package/framework-mcp/dist/framework-mcp/src/utils/metrics.js +56 -0
  62. package/framework-mcp/dist/framework-mcp/src/utils/permissions.js +71 -0
  63. package/framework-mcp/dist/framework-mcp/src/utils/security.js +60 -0
  64. package/framework-mcp/dist/framework-mcp/src/utils/storage.js +207 -0
  65. package/framework-mcp/dist/framework-mcp/src/utils/types.js +12 -0
  66. package/framework-mcp/dist/index.js +144 -0
  67. package/framework-mcp/dist/resources/index.js +58 -0
  68. package/framework-mcp/dist/src/cli/adapters/core.js +71 -0
  69. package/framework-mcp/dist/src/cli/adapters/index.js +5 -0
  70. package/framework-mcp/dist/src/cli/adapters/paths.js +101 -0
  71. package/framework-mcp/dist/src/cli/adapters/scaffold.js +71 -0
  72. package/framework-mcp/dist/src/cli/adapters/utils.js +75 -0
  73. package/framework-mcp/dist/src/cli/commands/approve.js +63 -0
  74. package/framework-mcp/dist/src/cli/commands/check.js +181 -0
  75. package/framework-mcp/dist/src/cli/commands/compliance.js +50 -0
  76. package/framework-mcp/dist/src/cli/commands/contract.js +50 -0
  77. package/framework-mcp/dist/src/cli/commands/dashboard.js +123 -0
  78. package/framework-mcp/dist/src/cli/commands/explorer.js +42 -0
  79. package/framework-mcp/dist/src/cli/commands/git.js +40 -0
  80. package/framework-mcp/dist/src/cli/commands/init/create-agent.js +58 -0
  81. package/framework-mcp/dist/src/cli/commands/init/scaffold-core.js +112 -0
  82. package/framework-mcp/dist/src/cli/commands/init/scaffold-docs.js +34 -0
  83. package/framework-mcp/dist/src/cli/commands/init/scaffold-ops.js +80 -0
  84. package/framework-mcp/dist/src/cli/commands/init/scaffold-standards.js +67 -0
  85. package/framework-mcp/dist/src/cli/commands/init.js +167 -0
  86. package/framework-mcp/dist/src/cli/commands/knowledge.js +42 -0
  87. package/framework-mcp/dist/src/cli/commands/lint.js +22 -0
  88. package/framework-mcp/dist/src/cli/commands/log.js +10 -0
  89. package/framework-mcp/dist/src/cli/commands/memory.js +4 -0
  90. package/framework-mcp/dist/src/cli/commands/orchestrate.js +159 -0
  91. package/framework-mcp/dist/src/cli/commands/plan.js +117 -0
  92. package/framework-mcp/dist/src/cli/commands/script.js +19 -0
  93. package/framework-mcp/dist/src/cli/commands/security.js +36 -0
  94. package/framework-mcp/dist/src/cli/commands/status.js +97 -0
  95. package/framework-mcp/dist/src/cli/commands/trace.js +109 -0
  96. package/framework-mcp/dist/src/cli/index.js +338 -0
  97. package/framework-mcp/dist/src/cli/shims.js +66 -0
  98. package/framework-mcp/dist/src/cli/utils/claude.js +56 -0
  99. package/framework-mcp/dist/src/cli/utils/compliance.js +173 -0
  100. package/framework-mcp/dist/src/cli/utils/config-schema.js +42 -0
  101. package/framework-mcp/dist/src/cli/utils/fs.js +137 -0
  102. package/framework-mcp/dist/src/cli/utils/i18n.js +30 -0
  103. package/framework-mcp/dist/src/cli/utils/memory.js +276 -0
  104. package/framework-mcp/dist/src/cli/utils/pkg.js +282 -0
  105. package/framework-mcp/dist/src/cli/utils/schemas.js +19 -0
  106. package/framework-mcp/dist/src/cli/utils/string.js +49 -0
  107. package/framework-mcp/dist/src/cli/utils/time.js +27 -0
  108. package/framework-mcp/dist/src/cli/utils/ui.js +58 -0
  109. package/framework-mcp/dist/src/contracts/index.js +1 -0
  110. package/framework-mcp/dist/src/contracts/tasks.js +20 -0
  111. package/framework-mcp/dist/src/dashboard/vite.config.js +15 -0
  112. package/framework-mcp/dist/src/modules/adapters/definitions.js +140 -0
  113. package/framework-mcp/dist/src/modules/adapters/registry.js +18 -0
  114. package/framework-mcp/dist/src/modules/adapters/shared.js +104 -0
  115. package/framework-mcp/dist/src/modules/adapters/types.js +1 -0
  116. package/framework-mcp/dist/src/modules/agents/definitions.js +457 -0
  117. package/framework-mcp/dist/src/modules/agents/registry/analyst.js +39 -0
  118. package/framework-mcp/dist/src/modules/agents/registry/architect.js +42 -0
  119. package/framework-mcp/dist/src/modules/agents/registry/backend.js +49 -0
  120. package/framework-mcp/dist/src/modules/agents/registry/database.js +45 -0
  121. package/framework-mcp/dist/src/modules/agents/registry/devops.js +45 -0
  122. package/framework-mcp/dist/src/modules/agents/registry/explorer.js +36 -0
  123. package/framework-mcp/dist/src/modules/agents/registry/frontend.js +51 -0
  124. package/framework-mcp/dist/src/modules/agents/registry/git.js +36 -0
  125. package/framework-mcp/dist/src/modules/agents/registry/manager.js +53 -0
  126. package/framework-mcp/dist/src/modules/agents/registry/mobile.js +39 -0
  127. package/framework-mcp/dist/src/modules/agents/registry/native.js +39 -0
  128. package/framework-mcp/dist/src/modules/agents/registry/quality.js +41 -0
  129. package/framework-mcp/dist/src/modules/agents/registry/security.js +43 -0
  130. package/framework-mcp/dist/src/modules/agents/types.js +1 -0
  131. package/framework-mcp/dist/src/modules/engines/evaluation-engine.js +102 -0
  132. package/framework-mcp/dist/src/modules/engines/health-engine.js +49 -0
  133. package/framework-mcp/dist/src/modules/engines/planning-engine.js +78 -0
  134. package/framework-mcp/dist/src/modules/engines/risk-engine.js +105 -0
  135. package/framework-mcp/dist/src/modules/engines/routing-engine.js +73 -0
  136. package/framework-mcp/dist/src/modules/engines/types.js +1 -0
  137. package/framework-mcp/dist/src/modules/skills/definitions.js +70 -0
  138. package/framework-mcp/dist/src/shared/constants.js +187 -0
  139. package/framework-mcp/dist/src/shared/errors.js +68 -0
  140. package/framework-mcp/dist/src/shared/fs.js +51 -0
  141. package/framework-mcp/dist/src/shared/logger.js +116 -0
  142. package/framework-mcp/dist/src/shared/storage.js +207 -0
  143. package/framework-mcp/dist/src/shared/types.js +12 -0
  144. package/framework-mcp/dist/tools/control_plane/locking.js +82 -0
  145. package/framework-mcp/dist/tools/control_plane/registry.js +35 -0
  146. package/framework-mcp/dist/tools/definitions.js +322 -0
  147. package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +64 -0
  148. package/framework-mcp/dist/tools/file_system/patch_file.js +34 -0
  149. package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
  150. package/framework-mcp/dist/tools/file_system/replace_text.js +50 -0
  151. package/framework-mcp/dist/tools/file_system/write_file.js +43 -0
  152. package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
  153. package/framework-mcp/dist/tools/framework/get_status.js +5 -0
  154. package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
  155. package/framework-mcp/dist/tools/framework/run_tests.js +27 -0
  156. package/framework-mcp/dist/tools/framework/submit_plan.js +13 -0
  157. package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
  158. package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
  159. package/framework-mcp/dist/tools/index.js +62 -0
  160. package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
  161. package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
  162. package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
  163. package/framework-mcp/dist/tools/messaging/send_message.js +94 -0
  164. package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
  165. package/framework-mcp/dist/tools/observability/get_health.js +19 -0
  166. package/framework-mcp/dist/tools/quality/check_lint.js +30 -0
  167. package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
  168. package/framework-mcp/dist/tools/search/get_map.js +43 -0
  169. package/framework-mcp/dist/tools/search/grep_search.js +75 -0
  170. package/framework-mcp/dist/tools/search/list_dir.js +28 -0
  171. package/framework-mcp/dist/tools/shell/run_command.js +56 -0
  172. package/framework-mcp/dist/tools/types.js +1 -0
  173. package/framework-mcp/dist/utils/cli.js +59 -0
  174. package/framework-mcp/dist/utils/compliance.js +231 -0
  175. package/framework-mcp/dist/utils/fs.js +44 -0
  176. package/framework-mcp/dist/utils/metrics.js +56 -0
  177. package/framework-mcp/dist/utils/permissions.js +71 -0
  178. package/framework-mcp/dist/utils/security.js +60 -0
  179. package/framework-mcp/package.json +37 -0
  180. package/mcp.json +1 -1
  181. package/package.json +10 -5
@@ -0,0 +1,104 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import os from "os";
4
+ import { execSync } from "child_process";
5
+ import { writeJsonFile, writeTextFile } from "../../shared/fs.js";
6
+ import { ALL_AGENTS, toAntigravityJson } from "../agents/definitions.js";
7
+ import { CORE_SKILLS } from "../skills/definitions.js";
8
+ import { getPackageRoot } from "../../cli/utils/pkg.js";
9
+ import { logger } from "../../shared/logger.js";
10
+ export function registerGlobalAntigravityPlugins(mcpBlock) {
11
+ // Allow overriding via env var for different OS/Gemini CLI versions
12
+ const defaultGlobalDir = path.join(os.homedir(), ".gemini/antigravity-cli");
13
+ const customDir = process.env["ANTIGRAVITY_GLOBAL_DIR"];
14
+ const targets = [customDir ?? defaultGlobalDir];
15
+ const baseKnowledgeDir = path.join(getPackageRoot(), "templates/standards");
16
+ for (const globalDir of targets) {
17
+ try {
18
+ // Write directly under directory
19
+ fs.mkdirSync(globalDir, { recursive: true });
20
+ writeJsonFile(path.join(globalDir, "mcp.json"), mcpBlock);
21
+ writeJsonFile(path.join(globalDir, "mcp_config.json"), mcpBlock);
22
+ logger.info(`Antigravity MCP registered → ${globalDir}/`);
23
+ // Global Plugin configuration under plugins/atabey/
24
+ const globalPluginDir = path.join(globalDir, "plugins/atabey");
25
+ fs.mkdirSync(globalPluginDir, { recursive: true });
26
+ // plugin.json marker
27
+ writeJsonFile(path.join(globalPluginDir, "plugin.json"), {
28
+ name: "atabey",
29
+ version: "1.0.0",
30
+ description: "Agent Atabey AI Orchestration framework"
31
+ });
32
+ // MCP Server configs inside the plugin
33
+ writeJsonFile(path.join(globalPluginDir, "mcp.json"), mcpBlock);
34
+ writeJsonFile(path.join(globalPluginDir, "mcp_config.json"), mcpBlock);
35
+ // Scaffold 13 agents
36
+ const agentsBaseDir = path.join(globalPluginDir, "agents");
37
+ fs.mkdirSync(agentsBaseDir, { recursive: true });
38
+ // Also write directly to ~/.gemini/antigravity-cli/agents/ so the CLI's
39
+ // workspace/global agent discovery finds them without the plugins/ prefix.
40
+ const globalAgentsDir = path.join(globalDir, "agents");
41
+ fs.mkdirSync(globalAgentsDir, { recursive: true });
42
+ for (const ag of ALL_AGENTS) {
43
+ const agentJson = toAntigravityJson(ag, baseKnowledgeDir);
44
+ // 1. Nested format inside plugin: plugins/atabey/agents/{name}/agent.json
45
+ const nestedAgentDir = path.join(agentsBaseDir, ag.name);
46
+ fs.mkdirSync(nestedAgentDir, { recursive: true });
47
+ writeTextFile(path.join(nestedAgentDir, "agent.json"), agentJson);
48
+ // 2. Flat format inside plugin: plugins/atabey/agents/{name}.json
49
+ writeTextFile(path.join(agentsBaseDir, `${ag.name}.json`), agentJson);
50
+ // 3. Direct global agents root — THIS is what Antigravity CLI reads:
51
+ // ~/.gemini/antigravity-cli/agents/{name}/agent.json
52
+ const globalNestedDir = path.join(globalAgentsDir, ag.name);
53
+ fs.mkdirSync(globalNestedDir, { recursive: true });
54
+ writeTextFile(path.join(globalNestedDir, "agent.json"), agentJson);
55
+ // 4. Flat global format as fallback
56
+ writeTextFile(path.join(globalAgentsDir, `${ag.name}.json`), agentJson);
57
+ }
58
+ // Scaffold skills
59
+ const skillsDir = path.join(globalPluginDir, "skills");
60
+ fs.mkdirSync(skillsDir, { recursive: true });
61
+ for (const [key, skill] of Object.entries(CORE_SKILLS)) {
62
+ const skillContent = `# 🛠️ Skill — ${skill.name}\n\n${skill.mandates.join("\n")}\n`;
63
+ writeTextFile(path.join(skillsDir, `${key.toLowerCase()}.md`), skillContent);
64
+ }
65
+ // Scaffold rules
66
+ const rulesDir = path.join(globalPluginDir, "rules");
67
+ fs.mkdirSync(rulesDir, { recursive: true });
68
+ for (const ag of ALL_AGENTS) {
69
+ const ruleContent = `# [ATABEY] Agent Atabey — @${ag.name} (${ag.displayName})
70
+
71
+ You are the **${ag.displayName}** of the Agent Atabey Army.
72
+
73
+ ## [AI] Specialist Directive (Role: @${ag.name})
74
+ ${ag.instructions.identity}
75
+
76
+ ### [GOAL] Mission
77
+ ${ag.instructions.mission}
78
+
79
+ ### 📜 Discipline Rules
80
+ ${ag.instructions.rules.map(r => `- ${r}`).join("\n")}
81
+
82
+ ## [SECURITY] Core Mandates
83
+ - **Surgical Precision:** Enforce replace_text / replace_file_content for all code modifications.
84
+ - **Traceability:** Inherit and pass the active Trace ID across all delegations.
85
+ - **Approval Signature:** High-risk actions require manager approval signature.
86
+ `;
87
+ writeTextFile(path.join(rulesDir, `${ag.name}.md`), ruleContent);
88
+ }
89
+ // Scaffold optional empty hooks.json
90
+ writeJsonFile(path.join(globalPluginDir, "hooks.json"), {});
91
+ logger.info(`Antigravity Plugin registered → ${globalPluginDir}/`);
92
+ try {
93
+ execSync(`agy plugin install "${globalPluginDir}"`, { stdio: "ignore" });
94
+ logger.info("Antigravity Plugin installed in CLI.");
95
+ }
96
+ catch {
97
+ // Ignore if agy is not in PATH or fails
98
+ }
99
+ }
100
+ catch (e) {
101
+ logger.warn(`Failed to register plugin/MCP in ${globalDir}`, e);
102
+ }
103
+ }
104
+ }
@@ -0,0 +1 @@
1
+ export const ADAPTER_IDS = ["gemini", "claude", "grok", "cursor", "codex", "local", "antigravity-cli"];
@@ -0,0 +1,457 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // Atabey Army — Agent Registry
3
+ // Atabey 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 Atabey-internal metadata and
14
+ // must NOT appear in any platform frontmatter.
15
+ // ─────────────────────────────────────────────────────────────────────────────
16
+ import fs from "fs";
17
+ import path from "path";
18
+ import { getPackageRoot } from "../../cli/utils/pkg.js";
19
+ import { CURSOR_AGENT_GLOBS } from "../../shared/constants.js";
20
+ import { getFrameworkDir } from "../../cli/utils/memory.js";
21
+ // Import individual agent definitions
22
+ import { manager } from "./registry/manager.js";
23
+ import { security } from "./registry/security.js";
24
+ import { architect } from "./registry/architect.js";
25
+ import { backend } from "./registry/backend.js";
26
+ import { frontend } from "./registry/frontend.js";
27
+ import { mobile } from "./registry/mobile.js";
28
+ import { quality } from "./registry/quality.js";
29
+ import { database } from "./registry/database.js";
30
+ import { devops } from "./registry/devops.js";
31
+ import { analyst } from "./registry/analyst.js";
32
+ import { native } from "./registry/native.js";
33
+ import { explorer } from "./registry/explorer.js";
34
+ import { git } from "./registry/git.js";
35
+ /**
36
+ * Sanitizes description or displayName strings before embedding them into frontmatter.
37
+ * Replaces delimiters (like ---), strips newlines to avoid formatting breakage, and trims.
38
+ */
39
+ export function sanitizeFrontmatterText(text) {
40
+ if (!text)
41
+ return "";
42
+ return text
43
+ .replace(/---/g, "- - -") // Prevent frontmatter boundary injection
44
+ .replace(/\r?\n/g, " ") // Replace line breaks with spaces
45
+ .trim();
46
+ }
47
+ export const ALL_AGENTS = [
48
+ manager,
49
+ security,
50
+ architect,
51
+ backend,
52
+ frontend,
53
+ mobile,
54
+ quality,
55
+ database,
56
+ devops,
57
+ analyst,
58
+ native,
59
+ explorer,
60
+ git
61
+ ];
62
+ // ─────────────────────────────────────────────────────────────────────────────
63
+ // Tool Maps — Internal tool names → platform-native tool identifiers
64
+ // ─────────────────────────────────────────────────────────────────────────────
65
+ /**
66
+ * Claude Code built-in tool names (case-sensitive).
67
+ * Reference: https://docs.anthropic.com/en/docs/claude-code/sub-agents
68
+ */
69
+ export const CLAUDE_TOOL_MAP = {
70
+ read_file: "Read",
71
+ write_file: "Write",
72
+ replace_text: "Edit",
73
+ batch_surgical_edit: "MultiEdit",
74
+ patch_file: "Edit",
75
+ list_dir: "LS",
76
+ grep_search: "Grep",
77
+ run_shell_command: "Bash",
78
+ view_file: "Read",
79
+ run_tests: "Bash",
80
+ log_agent_action: "Write",
81
+ send_agent_message: "Task",
82
+ orchestrate_loop: "Task",
83
+ get_project_map: "Bash",
84
+ get_project_gaps: "Bash",
85
+ get_memory_insights: "Read",
86
+ read_project_memory: "Read",
87
+ update_project_memory: "Write",
88
+ audit_dependencies: "Bash",
89
+ get_framework_status: "Bash",
90
+ get_system_health: "Bash",
91
+ check_active_ports: "Bash",
92
+ update_contract_hash: "Write",
93
+ acquire_lock: "Write",
94
+ release_lock: "Write",
95
+ register_agent: "Write",
96
+ check_lint: "Bash",
97
+ };
98
+ /**
99
+ * Gemini CLI built-in tool names (canonical names validated by Gemini CLI agent schema).
100
+ * Reference: https://github.com/google-gemini/gemini-cli
101
+ *
102
+ * Valid Gemini CLI tool names:
103
+ * read_file, write_file, replace, grep_search, glob,
104
+ * list_directory, run_shell_command
105
+ */
106
+ export const GEMINI_TOOL_MAP = {
107
+ read_file: "read_file",
108
+ write_file: "write_file",
109
+ replace_text: "replace", // [OK] NOT replace_in_file
110
+ batch_surgical_edit: "replace", // [OK] NOT replace_in_file
111
+ patch_file: "replace", // [OK] NOT replace_in_file
112
+ list_dir: "list_directory",
113
+ grep_search: "grep_search", // [OK] NOT search_file_content
114
+ run_shell_command: "run_shell_command",
115
+ view_file: "read_file",
116
+ run_tests: "run_shell_command",
117
+ log_agent_action: "write_file",
118
+ send_agent_message: "run_shell_command",
119
+ orchestrate_loop: "run_shell_command",
120
+ get_project_map: "run_shell_command",
121
+ get_project_gaps: "run_shell_command",
122
+ get_memory_insights: "read_file",
123
+ read_project_memory: "read_file",
124
+ update_project_memory: "write_file",
125
+ audit_dependencies: "run_shell_command",
126
+ get_framework_status: "run_shell_command",
127
+ get_system_health: "run_shell_command",
128
+ check_active_ports: "run_shell_command",
129
+ update_contract_hash: "write_file",
130
+ acquire_lock: "write_file",
131
+ release_lock: "write_file",
132
+ register_agent: "write_file",
133
+ check_lint: "run_shell_command",
134
+ };
135
+ // ─────────────────────────────────────────────────────────────────────────────
136
+ // Model Resolution
137
+ // ─────────────────────────────────────────────────────────────────────────────
138
+ /**
139
+ * Assigns the appropriate model based on capability score.
140
+ * Only valid, real model identifiers are used here.
141
+ */
142
+ function resolveModel(cap, platform) {
143
+ if (platform === "claude-code") {
144
+ // Verified Claude model names as of 2025-06
145
+ return cap === 10 ? "claude-opus-4-5"
146
+ : cap === 9 ? "claude-sonnet-4-5"
147
+ : "claude-haiku-3-5";
148
+ }
149
+ if (platform === "gemini-cli" || platform === "antigravity") {
150
+ // Verified Gemini model names as of 2025-06
151
+ return cap === 10 ? "gemini-2.5-pro"
152
+ : cap === 9 ? "gemini-2.5-flash"
153
+ : "gemini-2.5-flash-lite";
154
+ }
155
+ // codex-cli / OpenAI
156
+ return cap === 10 ? "o3" : "o4-mini";
157
+ }
158
+ // ─────────────────────────────────────────────────────────────────────────────
159
+ // System Prompt Builder
160
+ // ─────────────────────────────────────────────────────────────────────────────
161
+ /**
162
+ * Builds a rich, enterprise-grade system prompt from structured instructions.
163
+ * Embeds governance document contents inline for agents that have knowledgeFiles.
164
+ *
165
+ * @param stripMetaComments - When true, skips the HTML meta-comment header block
166
+ * (name/capability/tags). Set to true for Gemini CLI and Grok, whose strict
167
+ * frontmatter validators may misinterpret HTML comments in the document body
168
+ * as unrecognized YAML keys and reject the agent file entirely.
169
+ */
170
+ function buildSystemPrompt(ag, baseKnowledgeDir = path.join(getPackageRoot(), "templates/standards"), stripMetaComments = false, paths = { backend: "apps/backend", frontend: "apps/web", mobile: "apps/mobile", docs: "docs" }, backendLanguage = "Node.js (TypeScript)") {
171
+ const metaHeader = stripMetaComments ? [] : [
172
+ `<!-- name: ${ag.name} -->`,
173
+ `<!-- capability: ${ag.capability} -->`,
174
+ `<!-- tags: ${JSON.stringify(ag.tags)} -->`,
175
+ "",
176
+ ];
177
+ const lines = [
178
+ ...metaHeader,
179
+ `# [ATABEY] ${ag.displayName} — Agent Atabey`,
180
+ "",
181
+ "## Identity",
182
+ ag.instructions.identity,
183
+ "",
184
+ "## Mission",
185
+ ag.instructions.mission,
186
+ "",
187
+ "## Role Scope",
188
+ `**Primary Role:** ${ag.role}`,
189
+ `**Authority Tier:** ${ag.tier} (Capability: ${ag.capability}/10)`,
190
+ "",
191
+ "## Project Structure & Technology",
192
+ "This project uses the following stack and directory structure:",
193
+ `- **Backend Language:** ${backendLanguage}`,
194
+ `- **Backend Path:** ${paths.backend}`,
195
+ `- **Frontend Path:** ${paths.frontend}`,
196
+ `- **Mobile Path:** ${paths.mobile}`,
197
+ `- **Documentation:** ${paths.docs}`,
198
+ "",
199
+ "## Chain of Thought Protocol",
200
+ "> Follow these steps in strict order for every task:",
201
+ "",
202
+ ag.instructions.chainOfThought,
203
+ "",
204
+ "## Discipline Rules",
205
+ "> These are **non-negotiable** governance mandates. Violating any rule triggers an immediate task freeze.",
206
+ "",
207
+ ...ag.instructions.rules.map((r, i) => `${i + 1}. ${r}`),
208
+ "",
209
+ "## Enterprise Context",
210
+ "You are operating within a **multi-agent enterprise system** governed by the Agent Atabey framework.",
211
+ "All actions are traced, logged, and auditable. Every decision must be defensible and reversible.",
212
+ `- You are a specialist in **${backendLanguage}** development for backend tasks.`,
213
+ "- Always read PROJECT_MEMORY.md at session start for full context.",
214
+ "- Always pass the active **Trace ID** in all agent-to-agent messages.",
215
+ "- Never perform irreversible operations (schema drops, bulk deletes) without @manager approval.",
216
+ "- Prefer surgical edits (replace_text, patch_file) over full file rewrites.",
217
+ "- Escalate ambiguity to @manager instead of guessing.",
218
+ `- Ensure all development happens exclusively inside ${paths.backend}, ${paths.frontend}, or ${paths.mobile}.`,
219
+ ];
220
+ if (ag.instructions.knowledgeFiles?.length) {
221
+ lines.push("", "## Governance Standards (Required Reading)");
222
+ lines.push("> Read and internalize the following standards before acting on any task.");
223
+ ag.instructions.knowledgeFiles.forEach((f) => {
224
+ const filePath = path.join(baseKnowledgeDir, f);
225
+ if (fs.existsSync(filePath)) {
226
+ lines.push("", `### 📘 ${f}`, "", fs.readFileSync(filePath, "utf8").trim());
227
+ }
228
+ else {
229
+ lines.push("", `### 📘 ${f}`, `> [WARN] File not found at ${filePath}. Run atabey init to scaffold standards.`);
230
+ }
231
+ });
232
+ }
233
+ // Read learned conventions from local memory if exist (Memory V2)
234
+ const fDir = getFrameworkDir();
235
+ const specialtyFile = path.join(fDir, "memory", "specialties", `${ag.name}.md`);
236
+ if (fs.existsSync(specialtyFile)) {
237
+ try {
238
+ const learnedContent = fs.readFileSync(specialtyFile, "utf8").trim();
239
+ if (learnedContent) {
240
+ lines.push("", "## Learned Conventions (Project-Specific Experience)", "> These are lessons learned from past task executions in this project. Adhere to them strictly.", "", learnedContent);
241
+ }
242
+ }
243
+ catch {
244
+ // ignore
245
+ }
246
+ }
247
+ return lines.join("\n");
248
+ }
249
+ // ─────────────────────────────────────────────────────────────────────────────
250
+ // CLAUDE CODE → .claude/agents/{name}.md
251
+ // Valid fields: name, description, model, tools, color
252
+ // Ref: https://docs.anthropic.com/en/docs/claude-code/sub-agents
253
+ // ─────────────────────────────────────────────────────────────────────────────
254
+ export function toClaudeCodeMd(ag, baseKnowledgeDir, paths, backendLanguage) {
255
+ const tools = [...new Set(ag.tools.map((t) => CLAUDE_TOOL_MAP[t] ?? t))];
256
+ const model = resolveModel(ag.capability, "claude-code");
257
+ const color = ag.tier === "supreme" ? "purple"
258
+ : ag.tier === "recon" ? "gray"
259
+ : "blue";
260
+ const cleanDesc = sanitizeFrontmatterText(ag.description);
261
+ // Only officially supported frontmatter fields
262
+ const frontmatter = [
263
+ "---",
264
+ `name: ${ag.name}`,
265
+ "description: >-",
266
+ ` ${cleanDesc} Invoke proactively for ${ag.role.toLowerCase()} tasks in enterprise monorepo projects.`,
267
+ `model: ${model}`,
268
+ `tools: [${tools.map(t => `"${t}"`).join(", ")}]`,
269
+ `color: ${color}`,
270
+ "---",
271
+ ].join("\n");
272
+ return `${frontmatter}\n\n${buildSystemPrompt(ag, baseKnowledgeDir, false, paths, backendLanguage)}`;
273
+ }
274
+ // ─────────────────────────────────────────────────────────────────────────────
275
+ // GEMINI CLI → .gemini/agents/{name}.md
276
+ // Valid fields: name, description, model, tools (YAML list)
277
+ // Ref: https://ai.google.dev/gemini-api/docs/agents
278
+ // ─────────────────────────────────────────────────────────────────────────────
279
+ export function toGeminiCliMd(ag, baseKnowledgeDir, paths, backendLanguage) {
280
+ const tools = [...new Set(ag.tools.map((t) => GEMINI_TOOL_MAP[t] ?? t))];
281
+ const model = resolveModel(ag.capability, "gemini-cli");
282
+ const cleanDesc = sanitizeFrontmatterText(ag.description);
283
+ const frontmatter = [
284
+ "---",
285
+ `name: ${ag.name}`,
286
+ "description: >-",
287
+ ` ${cleanDesc} Use for ${ag.role.toLowerCase()} tasks.`,
288
+ `model: ${model}`,
289
+ "tools:",
290
+ ...tools.map(t => ` - ${t}`),
291
+ "---",
292
+ ].join("\n");
293
+ const body = buildSystemPrompt(ag, baseKnowledgeDir, true, paths, backendLanguage);
294
+ const metaFooter = [
295
+ "",
296
+ `<!-- name: ${ag.name} -->`,
297
+ `<!-- capability: ${ag.capability} -->`,
298
+ `<!-- tags: ${JSON.stringify(ag.tags)} -->`,
299
+ ].join("\n");
300
+ return `${frontmatter}\n\n${body}${metaFooter}`;
301
+ }
302
+ // ─────────────────────────────────────────────────────────────────────────────
303
+ // ANTIGRAVITY CLI → .agents/{name}/agent.json
304
+ // Spec: Antigravity customAgentSpec JSON schema
305
+ // ─────────────────────────────────────────────────────────────────────────────
306
+ export function toAntigravityJson(ag, baseKnowledgeDir, paths, backendLanguage = "Node.js (TypeScript)") {
307
+ const knowledgeBase = baseKnowledgeDir ?? path.join(getPackageRoot(), "templates/standards");
308
+ // Embed actual file contents so the agent can read governance docs
309
+ const knowledgeSections = (ag.instructions.knowledgeFiles ?? []).map((f) => {
310
+ const filePath = path.join(knowledgeBase, f);
311
+ const content = fs.existsSync(filePath)
312
+ ? fs.readFileSync(filePath, "utf8").trim()
313
+ : `(${f} — file not found at build time)`;
314
+ return { title: `Required Reading — ${f}`, content };
315
+ });
316
+ // Read learned conventions from local memory if exist (Memory V2)
317
+ const fDir = getFrameworkDir();
318
+ const specialtyFile = path.join(fDir, "memory", "specialties", `${ag.name}.md`);
319
+ const specialtySections = [];
320
+ if (fs.existsSync(specialtyFile)) {
321
+ try {
322
+ const learnedContent = fs.readFileSync(specialtyFile, "utf8").trim();
323
+ if (learnedContent) {
324
+ specialtySections.push({
325
+ title: "Learned Conventions (Project-Specific Experience)",
326
+ content: learnedContent
327
+ });
328
+ }
329
+ }
330
+ catch {
331
+ // ignore
332
+ }
333
+ }
334
+ const payload = {
335
+ name: ag.name,
336
+ displayName: ag.displayName,
337
+ description: ag.description,
338
+ hidden: false,
339
+ schemaVersion: "2.0",
340
+ customAgentSpec: {
341
+ customAgent: {
342
+ systemPromptSections: [
343
+ {
344
+ title: "Identity & Mission",
345
+ content: `${ag.instructions.identity}\n\n**Mission:** ${ag.instructions.mission}`,
346
+ },
347
+ {
348
+ title: "Project Structure & Technology",
349
+ content: [
350
+ "This project uses the following stack and directory structure:",
351
+ `- Backend Language: ${backendLanguage}`,
352
+ `- Backend Path: ${paths?.backend || "apps/backend"}`,
353
+ `- Frontend Path: ${paths?.frontend || "apps/web"}`,
354
+ `- Mobile Path: ${paths?.mobile || "apps/mobile"}`,
355
+ `- Documentation: ${paths?.docs || "docs"}`,
356
+ ].join("\n"),
357
+ },
358
+ {
359
+ title: "Chain of Thought Protocol",
360
+ content: ag.instructions.chainOfThought,
361
+ },
362
+ {
363
+ title: "Discipline Rules",
364
+ content: ag.instructions.rules.map((r, i) => `${i + 1}. ${r}`).join("\n"),
365
+ },
366
+ {
367
+ title: "Enterprise Context",
368
+ content: [
369
+ "You are part of a multi-agent enterprise governance system.",
370
+ `- You are a specialist in **${backendLanguage}** development for backend tasks.`,
371
+ "- Always include active Trace ID in all messages.",
372
+ "- Read PROJECT_MEMORY.md at session start.",
373
+ "- Prefer surgical edits over full file rewrites.",
374
+ "- Escalate high-risk operations to @manager.",
375
+ `- Ensure development happens inside ${paths?.backend || "apps/backend"}, ${paths?.frontend || "apps/web"}, or ${paths?.mobile || "apps/mobile"}.`,
376
+ ].join("\n"),
377
+ },
378
+ ...knowledgeSections,
379
+ ...specialtySections,
380
+ ],
381
+ toolNames: ag.tools,
382
+ },
383
+ },
384
+ };
385
+ return JSON.stringify(payload, null, 2);
386
+ }
387
+ /** Alias for Antigravity JSON export used by CLI */
388
+ export const buildAgentJson = toAntigravityJson;
389
+ // ─────────────────────────────────────────────────────────────────────────────
390
+ // CODEX CLI (OpenAI) → .agents/{name}.md
391
+ // Valid fields: agent-type, display-name, when-to-use, model, allowed-tools
392
+ // ─────────────────────────────────────────────────────────────────────────────
393
+ export function toCodexMd(ag, baseKnowledgeDir, paths, backendLanguage) {
394
+ const model = resolveModel(ag.capability, "codex-cli");
395
+ const tools = [...new Set(ag.tools.map((t) => {
396
+ 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))
397
+ return "read";
398
+ 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))
399
+ return "write";
400
+ return "shell";
401
+ }))];
402
+ const cleanDesc = sanitizeFrontmatterText(ag.description);
403
+ const cleanDisplayName = sanitizeFrontmatterText(ag.displayName).replace(/"/g, "\\\"");
404
+ const frontmatter = [
405
+ "---",
406
+ `agent-type: "${ag.name}"`,
407
+ `display-name: "${cleanDisplayName}"`,
408
+ "when-to-use: >-",
409
+ ` Invoke for ${ag.role.toLowerCase()} tasks. ${cleanDesc}`,
410
+ `model: ${model}`,
411
+ `allowed-tools: [${tools.map(t => `"${t}"`).join(", ")}]`,
412
+ "---",
413
+ ].join("\n");
414
+ const body = buildSystemPrompt(ag, baseKnowledgeDir, true, paths, backendLanguage);
415
+ const metaFooter = [
416
+ "",
417
+ `<!-- name: ${ag.name} -->`,
418
+ `<!-- capability: ${ag.capability} -->`,
419
+ `<!-- tags: ${JSON.stringify(ag.tags)} -->`,
420
+ ].join("\n");
421
+ return `${frontmatter}\n\n${body}${metaFooter}`;
422
+ }
423
+ // ─────────────────────────────────────────────────────────────────────────────
424
+ // CURSOR IDE → .cursor/rules/{name}.mdc
425
+ // Valid fields: description, globs, alwaysApply
426
+ // Ref: https://docs.cursor.com/context/rules
427
+ // ─────────────────────────────────────────────────────────────────────────────
428
+ export function toCursorMdc(ag, baseKnowledgeDir, paths, backendLanguage) {
429
+ const glob = CURSOR_AGENT_GLOBS[ag.name] || "**/*";
430
+ const cleanDesc = sanitizeFrontmatterText(`${ag.displayName} — ${ag.description}`);
431
+ const safeDesc = cleanDesc.slice(0, 120).replace(/"/g, "\\\"");
432
+ // Only officially supported Cursor MDC frontmatter fields
433
+ const frontmatter = [
434
+ "---",
435
+ `description: "${safeDesc}"`,
436
+ `globs: "${glob}"`,
437
+ "alwaysApply: false",
438
+ "---",
439
+ ].join("\n");
440
+ return `${frontmatter}\n\n${buildSystemPrompt(ag, baseKnowledgeDir, false, paths, backendLanguage)}`;
441
+ }
442
+ export function exportAllAgents(target, paths, backendLanguage) {
443
+ return ALL_AGENTS.map(ag => {
444
+ switch (target) {
445
+ case "claude-code":
446
+ return { path: `.claude/agents/${ag.name}.md`, content: toClaudeCodeMd(ag, undefined, paths, backendLanguage) };
447
+ case "gemini-cli":
448
+ return { path: `.gemini/agents/${ag.name}.md`, content: toGeminiCliMd(ag, undefined, paths, backendLanguage) };
449
+ case "antigravity":
450
+ return { path: `.agents/${ag.name}/agent.json`, content: toAntigravityJson(ag, undefined, paths, backendLanguage) };
451
+ case "codex-cli":
452
+ return { path: `.agents/${ag.name}.md`, content: toCodexMd(ag, undefined, paths, backendLanguage) };
453
+ case "cursor":
454
+ return { path: `.cursor/rules/${ag.name}.mdc`, content: toCursorMdc(ag, undefined, paths, backendLanguage) };
455
+ }
456
+ });
457
+ }
@@ -0,0 +1,39 @@
1
+ const STATE_MACHINE = "../schema/agent-lifecycle-schema.json";
2
+ export const analyst = {
3
+ name: "analyst",
4
+ displayName: "Business Analyst",
5
+ role: "Strategy Analysis",
6
+ description: "Specs verification and Contract Audit specialist. " +
7
+ "Audits truth and contracts within the Army.",
8
+ capability: 9,
9
+ tier: "recon",
10
+ tags: ["core", "strategy"],
11
+ stateMachine: STATE_MACHINE,
12
+ tools: [
13
+ "read_file",
14
+ "list_dir",
15
+ "grep_search",
16
+ "get_project_map",
17
+ "get_project_gaps",
18
+ "read_project_memory",
19
+ "get_memory_insights",
20
+ "send_agent_message",
21
+ "update_contract_hash",
22
+ ],
23
+ instructions: {
24
+ identity: "Strategy Analyst and Contract-First Compliance Auditor",
25
+ mission: "Ensure every user requirement is accurately mapped to a typed API " +
26
+ "contract before a single line of application code is written.",
27
+ chainOfThought: "1. Analyze: Read the task, context, and relevant governance documents.\n" +
28
+ "2. Validate: Cross-reference with project rules, contracts, and architecture standards.\n" +
29
+ "3. Plan: Break down the task into small, atomic, and verifiable steps.\n" +
30
+ "4. Execute: Perform the task using approved tools, adhering to quality and security constraints.",
31
+ rules: [
32
+ "REQUIREMENTS MAPPING: Verify that all user requirements from docs/ correctly map to API schemas and types.",
33
+ "CONTRACT FIRST: Enforce the Contract-First model — no application code without a validated contract.",
34
+ "VERSIONING INTEGRITY: Validate that all API versioning changes are correctly registered in 'contract.version.json'.",
35
+ "LIVE AUDIT: Continuously audit business rules against the live implementation for drift.",
36
+ ],
37
+ knowledgeFiles: ["architecture-standards.md", "crud-governance.md", "governance-standards.md", "quality-standards.md"],
38
+ },
39
+ };
@@ -0,0 +1,42 @@
1
+ const STATE_MACHINE = "../schema/agent-lifecycle-schema.json";
2
+ export const architect = {
3
+ name: "architect",
4
+ displayName: "Lead Architect",
5
+ role: "System Design",
6
+ description: "System Design, Contracts, and Core Architecture specialist. " +
7
+ "Owns the Control Plane Governance & Locking discipline.",
8
+ capability: 9,
9
+ tier: "core",
10
+ tags: ["core", "design"],
11
+ stateMachine: STATE_MACHINE,
12
+ tools: [
13
+ "read_file",
14
+ "write_file",
15
+ "replace_text",
16
+ "batch_surgical_edit",
17
+ "list_dir",
18
+ "grep_search",
19
+ "update_contract_hash",
20
+ "read_project_memory",
21
+ "get_memory_insights",
22
+ "acquire_lock",
23
+ "release_lock",
24
+ "register_agent",
25
+ ],
26
+ instructions: {
27
+ identity: "System Architecture Designer and Contract Governance Owner",
28
+ mission: "Design a flawless, contract-first foundation that every other " +
29
+ "specialist can build on without ambiguity.",
30
+ chainOfThought: "1. Analyze: Read the task, context, and relevant governance documents.\n" +
31
+ "2. Validate: Cross-reference with project rules, contracts, and architecture standards.\n" +
32
+ "3. Plan: Break down the task into small, atomic, and verifiable steps.\n" +
33
+ "4. Execute: Perform the task using approved tools, adhering to quality and security constraints.",
34
+ rules: [
35
+ "CONTRACT FIRST: Read governance documents before designing any contract or interface.",
36
+ "TYPE SAFETY: Enforce strict typing across all boundaries — 'any' type is unconditionally forbidden.",
37
+ "CONTRACT STABILITY: Validate 'contract.version.json' consistency before and after every schema change.",
38
+ "GOVERNANCE READ: Always read architecture governance docs before making design decisions.",
39
+ ],
40
+ knowledgeFiles: ["architecture-standards.md", "governance-standards.md", "performance-standards.md"],
41
+ },
42
+ };