atabey 0.0.9 → 0.0.11

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 (163) hide show
  1. package/README.md +1 -1
  2. package/dist/framework-mcp/src/tools/file_system/read_file.js +7 -7
  3. package/dist/framework-mcp/src/tools/file_system/read_file.js.map +1 -1
  4. package/dist/framework-mcp/src/tools/file_system/write_file.js +12 -0
  5. package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
  6. package/dist/framework-mcp/src/tools/memory/get_insights.d.ts +2 -2
  7. package/dist/framework-mcp/src/tools/memory/get_insights.js +9 -21
  8. package/dist/framework-mcp/src/tools/memory/get_insights.js.map +1 -1
  9. package/dist/src/cli/commands/init.js +49 -0
  10. package/dist/src/cli/commands/init.js.map +1 -1
  11. package/dist/src/cli/utils/pkg.js +1 -1
  12. package/dist/src/cli/utils/pkg.js.map +1 -1
  13. package/dist/src/modules/agents/registry/analyst.js +0 -1
  14. package/dist/src/modules/agents/registry/analyst.js.map +1 -1
  15. package/dist/src/modules/agents/registry/architect.js +0 -1
  16. package/dist/src/modules/agents/registry/architect.js.map +1 -1
  17. package/dist/src/modules/agents/registry/backend.js +0 -1
  18. package/dist/src/modules/agents/registry/backend.js.map +1 -1
  19. package/dist/src/modules/agents/registry/database.js +1 -1
  20. package/dist/src/modules/agents/registry/database.js.map +1 -1
  21. package/dist/src/modules/agents/registry/devops.js +1 -1
  22. package/dist/src/modules/agents/registry/devops.js.map +1 -1
  23. package/dist/src/modules/agents/registry/explorer.js +0 -1
  24. package/dist/src/modules/agents/registry/explorer.js.map +1 -1
  25. package/dist/src/modules/agents/registry/frontend.js +0 -1
  26. package/dist/src/modules/agents/registry/frontend.js.map +1 -1
  27. package/dist/src/modules/agents/registry/git.js +1 -1
  28. package/dist/src/modules/agents/registry/git.js.map +1 -1
  29. package/dist/src/modules/agents/registry/manager.js +0 -1
  30. package/dist/src/modules/agents/registry/manager.js.map +1 -1
  31. package/dist/src/modules/agents/registry/mobile.js +1 -1
  32. package/dist/src/modules/agents/registry/native.js +1 -1
  33. package/dist/src/modules/agents/registry/native.js.map +1 -1
  34. package/dist/src/modules/agents/registry/quality.js +0 -1
  35. package/dist/src/modules/agents/registry/quality.js.map +1 -1
  36. package/dist/src/modules/agents/registry/security.js +0 -1
  37. package/dist/src/modules/agents/registry/security.js.map +1 -1
  38. package/framework-mcp/README.md +48 -0
  39. package/framework-mcp/dist/index.js +0 -0
  40. package/framework-mcp/dist/resources/index.js +2 -2
  41. package/framework-mcp/dist/tools/file_system/read_file.js +7 -7
  42. package/framework-mcp/dist/tools/file_system/write_file.js +12 -0
  43. package/framework-mcp/dist/tools/memory/get_insights.js +9 -21
  44. package/framework-mcp/package.json +1 -1
  45. package/package.json +2 -2
  46. package/framework-mcp/dist/framework-mcp/src/constants.js +0 -64
  47. package/framework-mcp/dist/framework-mcp/src/index.js +0 -144
  48. package/framework-mcp/dist/framework-mcp/src/resources/index.js +0 -58
  49. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/locking.js +0 -82
  50. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/registry.js +0 -35
  51. package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +0 -322
  52. package/framework-mcp/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +0 -64
  53. package/framework-mcp/dist/framework-mcp/src/tools/file_system/patch_file.js +0 -34
  54. package/framework-mcp/dist/framework-mcp/src/tools/file_system/read_file.js +0 -51
  55. package/framework-mcp/dist/framework-mcp/src/tools/file_system/replace_text.js +0 -50
  56. package/framework-mcp/dist/framework-mcp/src/tools/file_system/write_file.js +0 -43
  57. package/framework-mcp/dist/framework-mcp/src/tools/framework/audit_deps.js +0 -41
  58. package/framework-mcp/dist/framework-mcp/src/tools/framework/get_status.js +0 -5
  59. package/framework-mcp/dist/framework-mcp/src/tools/framework/orchestrate.js +0 -5
  60. package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +0 -27
  61. package/framework-mcp/dist/framework-mcp/src/tools/framework/submit_plan.js +0 -13
  62. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_contract_hash.js +0 -5
  63. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_memory.js +0 -8
  64. package/framework-mcp/dist/framework-mcp/src/tools/index.js +0 -62
  65. package/framework-mcp/dist/framework-mcp/src/tools/memory/get_insights.js +0 -34
  66. package/framework-mcp/dist/framework-mcp/src/tools/memory/read_memory.js +0 -28
  67. package/framework-mcp/dist/framework-mcp/src/tools/messaging/log_action.js +0 -22
  68. package/framework-mcp/dist/framework-mcp/src/tools/messaging/send_message.js +0 -94
  69. package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +0 -26
  70. package/framework-mcp/dist/framework-mcp/src/tools/observability/get_health.js +0 -19
  71. package/framework-mcp/dist/framework-mcp/src/tools/quality/check_lint.js +0 -30
  72. package/framework-mcp/dist/framework-mcp/src/tools/search/get_gaps.js +0 -48
  73. package/framework-mcp/dist/framework-mcp/src/tools/search/get_map.js +0 -43
  74. package/framework-mcp/dist/framework-mcp/src/tools/search/grep_search.js +0 -75
  75. package/framework-mcp/dist/framework-mcp/src/tools/search/list_dir.js +0 -28
  76. package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +0 -56
  77. package/framework-mcp/dist/framework-mcp/src/tools/types.js +0 -1
  78. package/framework-mcp/dist/framework-mcp/src/utils/cli.js +0 -59
  79. package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +0 -231
  80. package/framework-mcp/dist/framework-mcp/src/utils/fs.js +0 -44
  81. package/framework-mcp/dist/framework-mcp/src/utils/metrics.js +0 -56
  82. package/framework-mcp/dist/framework-mcp/src/utils/permissions.js +0 -71
  83. package/framework-mcp/dist/framework-mcp/src/utils/security.js +0 -60
  84. package/framework-mcp/dist/src/cli/adapters/core.js +0 -71
  85. package/framework-mcp/dist/src/cli/adapters/index.js +0 -5
  86. package/framework-mcp/dist/src/cli/adapters/paths.js +0 -101
  87. package/framework-mcp/dist/src/cli/adapters/scaffold.js +0 -71
  88. package/framework-mcp/dist/src/cli/adapters/utils.js +0 -75
  89. package/framework-mcp/dist/src/cli/commands/approve.js +0 -63
  90. package/framework-mcp/dist/src/cli/commands/check.js +0 -181
  91. package/framework-mcp/dist/src/cli/commands/compliance.js +0 -50
  92. package/framework-mcp/dist/src/cli/commands/contract.js +0 -50
  93. package/framework-mcp/dist/src/cli/commands/dashboard.js +0 -123
  94. package/framework-mcp/dist/src/cli/commands/explorer.js +0 -42
  95. package/framework-mcp/dist/src/cli/commands/git.js +0 -40
  96. package/framework-mcp/dist/src/cli/commands/init/create-agent.js +0 -58
  97. package/framework-mcp/dist/src/cli/commands/init/scaffold-core.js +0 -112
  98. package/framework-mcp/dist/src/cli/commands/init/scaffold-docs.js +0 -34
  99. package/framework-mcp/dist/src/cli/commands/init/scaffold-ops.js +0 -80
  100. package/framework-mcp/dist/src/cli/commands/init/scaffold-standards.js +0 -67
  101. package/framework-mcp/dist/src/cli/commands/init.js +0 -167
  102. package/framework-mcp/dist/src/cli/commands/knowledge.js +0 -42
  103. package/framework-mcp/dist/src/cli/commands/lint.js +0 -22
  104. package/framework-mcp/dist/src/cli/commands/log.js +0 -10
  105. package/framework-mcp/dist/src/cli/commands/memory.js +0 -4
  106. package/framework-mcp/dist/src/cli/commands/orchestrate.js +0 -159
  107. package/framework-mcp/dist/src/cli/commands/plan.js +0 -117
  108. package/framework-mcp/dist/src/cli/commands/script.js +0 -19
  109. package/framework-mcp/dist/src/cli/commands/security.js +0 -36
  110. package/framework-mcp/dist/src/cli/commands/status.js +0 -97
  111. package/framework-mcp/dist/src/cli/commands/trace.js +0 -109
  112. package/framework-mcp/dist/src/cli/index.js +0 -338
  113. package/framework-mcp/dist/src/cli/shims.js +0 -66
  114. package/framework-mcp/dist/src/cli/utils/claude.js +0 -56
  115. package/framework-mcp/dist/src/cli/utils/compliance.js +0 -173
  116. package/framework-mcp/dist/src/cli/utils/config-schema.js +0 -42
  117. package/framework-mcp/dist/src/cli/utils/fs.js +0 -137
  118. package/framework-mcp/dist/src/cli/utils/i18n.js +0 -30
  119. package/framework-mcp/dist/src/cli/utils/memory.js +0 -276
  120. package/framework-mcp/dist/src/cli/utils/pkg.js +0 -282
  121. package/framework-mcp/dist/src/cli/utils/schemas.js +0 -19
  122. package/framework-mcp/dist/src/cli/utils/string.js +0 -49
  123. package/framework-mcp/dist/src/cli/utils/time.js +0 -27
  124. package/framework-mcp/dist/src/cli/utils/ui.js +0 -58
  125. package/framework-mcp/dist/src/contracts/index.js +0 -1
  126. package/framework-mcp/dist/src/contracts/tasks.js +0 -20
  127. package/framework-mcp/dist/src/dashboard/vite.config.js +0 -15
  128. package/framework-mcp/dist/src/modules/adapters/definitions.js +0 -140
  129. package/framework-mcp/dist/src/modules/adapters/registry.js +0 -18
  130. package/framework-mcp/dist/src/modules/adapters/shared.js +0 -104
  131. package/framework-mcp/dist/src/modules/adapters/types.js +0 -1
  132. package/framework-mcp/dist/src/modules/agents/definitions.js +0 -457
  133. package/framework-mcp/dist/src/modules/agents/registry/analyst.js +0 -39
  134. package/framework-mcp/dist/src/modules/agents/registry/architect.js +0 -42
  135. package/framework-mcp/dist/src/modules/agents/registry/backend.js +0 -49
  136. package/framework-mcp/dist/src/modules/agents/registry/database.js +0 -45
  137. package/framework-mcp/dist/src/modules/agents/registry/devops.js +0 -45
  138. package/framework-mcp/dist/src/modules/agents/registry/explorer.js +0 -36
  139. package/framework-mcp/dist/src/modules/agents/registry/frontend.js +0 -51
  140. package/framework-mcp/dist/src/modules/agents/registry/git.js +0 -36
  141. package/framework-mcp/dist/src/modules/agents/registry/manager.js +0 -53
  142. package/framework-mcp/dist/src/modules/agents/registry/mobile.js +0 -39
  143. package/framework-mcp/dist/src/modules/agents/registry/native.js +0 -39
  144. package/framework-mcp/dist/src/modules/agents/registry/quality.js +0 -41
  145. package/framework-mcp/dist/src/modules/agents/registry/security.js +0 -43
  146. package/framework-mcp/dist/src/modules/agents/types.js +0 -1
  147. package/framework-mcp/dist/src/modules/engines/evaluation-engine.js +0 -102
  148. package/framework-mcp/dist/src/modules/engines/health-engine.js +0 -49
  149. package/framework-mcp/dist/src/modules/engines/planning-engine.js +0 -78
  150. package/framework-mcp/dist/src/modules/engines/risk-engine.js +0 -105
  151. package/framework-mcp/dist/src/modules/engines/routing-engine.js +0 -73
  152. package/framework-mcp/dist/src/modules/engines/types.js +0 -1
  153. package/framework-mcp/dist/src/modules/skills/definitions.js +0 -70
  154. package/framework-mcp/dist/src/shared/constants.js +0 -187
  155. package/framework-mcp/dist/src/shared/errors.js +0 -68
  156. package/framework-mcp/dist/src/shared/fs.js +0 -51
  157. package/framework-mcp/dist/src/shared/logger.js +0 -116
  158. package/framework-mcp/dist/src/shared/storage.js +0 -207
  159. package/framework-mcp/dist/src/shared/types.js +0 -12
  160. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/errors.js +0 -0
  161. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/memory.js +0 -0
  162. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/storage.js +0 -0
  163. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/types.js +0 -0
@@ -0,0 +1,48 @@
1
+ # Agent Atabey — MCP Server (`atabey-mcp`)
2
+
3
+ [![Version](https://img.shields.io/npm/v/atabey-mcp.svg)](https://npmjs.com/package/atabey-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ The **Model Context Protocol (MCP)** server for [Agent Atabey](https://npmjs.com/package/atabey).
7
+
8
+ This package acts as the bridge between AI Assistants (like Claude Desktop, Cursor, or Antigravity CLI) and your local project environment. It provides a highly governed, type-safe set of tools that allow AI agents to interact with your codebase securely.
9
+
10
+ ## 🚀 Features
11
+
12
+ - **Strict Governance:** Enforces Zero Type Hole and Zero Console policies via AST parsing.
13
+ - **Surgical Edits:** Uses `patch_file` and `replace_text` instead of full-file rewrites to save tokens and prevent context loss.
14
+ - **Hermes Message Broker:** Facilitates asynchronous communication between specialized agents (`@manager`, `@architect`, `@security`, etc.).
15
+ - **Memory Insights:** Provides agents with targeted, pruned context (last 5 actions, active trace) instead of dumping the entire project history.
16
+ - **Risk Engine:** Automatically blocks or requires human approval for high-risk operations (e.g., deleting databases, touching `.env` files).
17
+
18
+ ## đŸ“Ļ Installation
19
+
20
+ Typically, you do not need to install this package manually. It is automatically installed and configured when you initialize an Atabey project:
21
+
22
+ ```bash
23
+ npx atabey init
24
+ ```
25
+
26
+ However, you can install it globally or locally if needed:
27
+
28
+ ```bash
29
+ npm install atabey-mcp
30
+ ```
31
+
32
+ ## đŸ› ī¸ Provided Tools
33
+
34
+ The `atabey-mcp` server exposes over 25 specialized tools grouped into the following domains:
35
+
36
+ - **File System:** `read_file`, `write_file`, `replace_text`, `patch_file`, `batch_surgical_edit`
37
+ - **Control Plane:** `acquire_lock`, `release_lock`, `register_agent`
38
+ - **Framework & Orchestration:** `submit_plan`, `orchestrate_loop`, `update_project_memory`, `audit_dependencies`
39
+ - **Search & Map:** `grep_search`, `list_dir`, `get_architectural_map`, `get_knowledge_gaps`
40
+ - **Quality & Observability:** `check_lint`, `run_tests`, `get_system_health`, `check_ports`
41
+ - **Messaging:** `send_agent_message`, `log_agent_action`
42
+
43
+ ## 📖 Learn More
44
+
45
+ For full documentation, architecture details, and enterprise inquiries, please visit the main [Agent Atabey Repository](https://github.com/ysf-bkr/atabey).
46
+
47
+ ---
48
+ *Developed by Yusuf BEKAR*
File without changes
@@ -1,4 +1,4 @@
1
- import { Storage } from "../../../src/shared/storage.js";
1
+ import { Storage } from "../utils/storage.js";
2
2
  /**
3
3
  * [DATA] MCP Resource Definitions
4
4
  */
@@ -43,7 +43,7 @@ export async function handleReadResource(uri) {
43
43
  if (uri === "atabey://memory/project") {
44
44
  const fs = await import("fs");
45
45
  const path = await import("path");
46
- const { getFrameworkDir } = await import("../../../src/cli/utils/memory.js");
46
+ const { getFrameworkDir } = await import("../utils/memory.js");
47
47
  const projectRoot = process.env.ATABEY_PROJECT_ROOT || process.cwd();
48
48
  const fwDir = getFrameworkDir();
49
49
  const p = path.isAbsolute(fwDir)
@@ -26,16 +26,16 @@ export function handleReadFile(projectRoot, args) {
26
26
  Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path}`, tokens);
27
27
  return { content: [{ type: "text", text: sliced }] };
28
28
  }
29
- // Default protection limit: 1000 lines
30
- const DEFAULT_MAX_LINES = 1000;
31
- if (lines.length > DEFAULT_MAX_LINES) {
32
- const sliced = lines.slice(0, DEFAULT_MAX_LINES).join("\n");
33
- const tokens = Metrics.estimateTokens(sliced);
34
- Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path} (truncated)`, tokens);
29
+ // ENFORCE TOKEN ECONOMY: Hard Limit for large files
30
+ const HARD_LIMIT_LINES = 500;
31
+ if (lines.length > HARD_LIMIT_LINES && (startLine === undefined || endLine === undefined)) {
32
+ const errMsg = `[TOKEN ECONOMY GUARD] File '${args.path}' is too large (${lines.length} lines). To prevent context overflow and token waste, you MUST provide both 'startLine' and 'endLine' parameters to read specific sections of this file.`;
33
+ Metrics.logError(projectRoot, "@mcp", `read_file: ${args.path} (blocked)`, errMsg);
35
34
  return {
35
+ isError: true,
36
36
  content: [{
37
37
  type: "text",
38
- text: `${sliced}\n\n... [TRUNCATED - File is too long (${lines.length} lines). Only the first ${DEFAULT_MAX_LINES} lines are shown. Use startLine and endLine parameters to read other parts of the file.]`
38
+ text: `[ERROR] ${errMsg}`
39
39
  }]
40
40
  };
41
41
  }
@@ -13,6 +13,18 @@ export async function handleWriteFile(projectRoot, args) {
13
13
  }
14
14
  try {
15
15
  const filePath = safePath(projectRoot, args.path);
16
+ // ENFORCE TOKEN ECONOMY: Prevent full-file rewrites of existing files
17
+ if (fs.existsSync(filePath)) {
18
+ const errMsg = `[TOKEN ECONOMY GUARD] The file '${args.path}' already exists. Overwriting entire existing files is FORBIDDEN to save tokens and prevent context drift. You MUST use 'patch_file' or 'replace_text' tools to make surgical edits.`;
19
+ Metrics.logError(projectRoot, "@mcp", `write_file: ${args.path} (blocked)`, errMsg);
20
+ return {
21
+ isError: true,
22
+ content: [{
23
+ type: "text",
24
+ text: `[ERROR] ${errMsg}`
25
+ }]
26
+ };
27
+ }
16
28
  const content = args.content;
17
29
  // ENFORCE PERMISSION MATRIX
18
30
  verifyWritePermission(projectRoot, args.path);
@@ -1,29 +1,17 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { resolveFrameworkDir } from "../../utils/security.js";
1
+ import { Storage } from "../../utils/storage.js";
4
2
  /**
5
- * Extracts key insights from the project memory to minimize token usage.
3
+ * Extracts key insights from the SQLite database to minimize token usage.
6
4
  * Returns only the active phase, trace, and the last 5 decisions/tasks.
7
5
  */
8
- export function handleGetMemoryInsights(projectRoot, _args) {
6
+ export function handleGetMemoryInsights(_projectRoot, _args) {
9
7
  try {
10
- const frameworkDir = resolveFrameworkDir(projectRoot);
11
- const memoryPath = path.join(projectRoot, frameworkDir, "memory/PROJECT_MEMORY.md");
12
- if (!fs.existsSync(memoryPath)) {
13
- return { content: [{ type: "text", text: "New project: No history available." }] };
14
- }
15
- const content = fs.readFileSync(memoryPath, "utf8");
16
- const lines = content.split("\n");
17
- const activePhase = lines.find(l => l.includes("**Phase:**"))?.split("**Phase:**")[1]?.trim() || "Unknown";
18
- const activeTrace = lines.find(l => l.includes("**Trace ID:**"))?.split("**Trace ID:**")[1]?.trim() || "None";
19
- // Find the last 5 history items (heuristic)
20
- const historyStartIndex = lines.findIndex(l => l.toUpperCase().includes("HISTORY"));
8
+ const activePhase = Storage.getMetadata("phase") || "PHASE_0";
9
+ const activeTrace = Storage.getMetadata("traceId") || "None";
10
+ // Get the last 5 logs from SQLite
11
+ const recentLogs = Storage.getLogs().slice(0, 5);
21
12
  let recentHistory = "No history found.";
22
- if (historyStartIndex !== -1) {
23
- recentHistory = lines.slice(historyStartIndex + 1)
24
- .filter(l => l.trim().startsWith("-"))
25
- .slice(-5)
26
- .join("\n");
13
+ if (recentLogs.length > 0) {
14
+ recentHistory = recentLogs.map(log => `- [${log.agent}] ${log.action}: ${log.summary}`).join("\n");
27
15
  }
28
16
  const insights = `[MEMORY] **Memory Insights**\n- **Phase:** ${activePhase}\n- **Trace:** ${activeTrace}\n\n**Recent Actions:**\n${recentHistory}`;
29
17
  return { content: [{ type: "text", text: insights }] };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey-mcp",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Agent Atabey Model Context Protocol (MCP) Server",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "The Supreme AI Governance & Autonomous Orchestration Framework for Enterprise Development. Supports Polyglot Backends (Go, Java, Python, .NET, Node.js) and Multi-Language Communication (TR/EN).",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "atabey-mcp": "^0.0.9",
71
+ "atabey-mcp": "^0.0.11",
72
72
  "@modelcontextprotocol/sdk": "^1.29.0",
73
73
  "better-sqlite3": "^12.10.1",
74
74
  "chalk": "^5.6.2",
@@ -1,64 +0,0 @@
1
- import path from "path";
2
- /**
3
- * Agent Atabey — Single Source of Truth for framework constants.
4
- * Import from here instead of hardcoding paths, phases, or directory names.
5
- */
6
- // ─── Framework identity ───────────────────────────────────────────────────
7
- export const FRAMEWORK = {
8
- NAME: "Agent Atabey",
9
- CORE_DIR: ".atabey",
10
- // This is the hub for unified adapter layouts (e.g. .agents/gemini, .agents/claude)
11
- UNIFIED_HUB_DIR: ".agents",
12
- // This is the default directory to scaffold new apps into
13
- APPS_DIR: "apps",
14
- // This is where all skills are stored
15
- SKILLS_DIR: "skills",
16
- };
17
- export const FRAMEWORK_SUBDIRS = {
18
- AGENTS: "agents",
19
- SKILLS: "skills",
20
- KNOWLEDGE: "knowledge",
21
- MESSAGES: "messages",
22
- MEMORY: "memory",
23
- MEMORY_GRAPH: "memory-graph",
24
- LOGS: "logs",
25
- CONFIG: "config",
26
- };
27
- export const ROOT_CONFIG_FILES = {
28
- MCP: "mcp.json",
29
- NATIVE_MODULES: "native-modules.json",
30
- TSCONFIG: "tsconfig.json",
31
- ESLINT: "eslint.config.js",
32
- };
33
- export const MCP = {
34
- // Environment variable used by MCP to identify project root
35
- PROJECT_ROOT_ENV: "ATABEY_PROJECT_ROOT",
36
- // Environment variable for test mode
37
- TEST_DIR_ENV: "ATABEY_TEST_DIR",
38
- };
39
- export const MEMORY_FILES = {
40
- STATE: "state.json",
41
- SHARED_FACTS: "shared_facts.json",
42
- };
43
- export const NATIVE_AGENT_PATHS = {
44
- gemini: ".gemini/agents",
45
- claude: ".claude/agents",
46
- cursor: ".cursor/rules",
47
- codex: ".agents/instructions",
48
- grok: ".grok",
49
- "antigravity-cli": ".agents/agents",
50
- };
51
- // ─── Backward-compatible aliases ──────────────────────────────────────────
52
- export const CORE_FRAMEWORK_DIR = FRAMEWORK.CORE_DIR;
53
- export const UNIFIED_HUB_DIR = FRAMEWORK.UNIFIED_HUB_DIR;
54
- export const SKILLS_HUB_PATH = pathJoin(UNIFIED_HUB_DIR, FRAMEWORK_SUBDIRS.SKILLS);
55
- // ─── Path Helpers ─────────────────────────────────────────────────────────
56
- function pathJoin(...args) {
57
- return path.join(...args);
58
- }
59
- function corePath(subdir, filename) {
60
- return pathJoin(FRAMEWORK.CORE_DIR, subdir, filename);
61
- }
62
- export function knowledgePath(filename) {
63
- return corePath(FRAMEWORK_SUBDIRS.KNOWLEDGE, filename);
64
- }
@@ -1,144 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from "fs";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
6
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
- import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
8
- import { TOOLS, toolHandlers } from "./tools/index.js";
9
- import { RESOURCES, handleReadResource } from "./resources/index.js";
10
- // ─── Server Setup ─────────────────────────────────────────────────
11
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
- // Robustly find package.json by walking up from __dirname
13
- function findPackageJson(startDir) {
14
- let currentDir = startDir;
15
- while (currentDir !== path.parse(currentDir).root) {
16
- const pkgPath = path.join(currentDir, "package.json");
17
- if (fs.existsSync(pkgPath))
18
- return pkgPath;
19
- currentDir = path.dirname(currentDir);
20
- }
21
- throw new Error("Could not find package.json for atabey-mcp");
22
- }
23
- const pkgPath = findPackageJson(__dirname);
24
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
25
- const serverVersion = pkg.version;
26
- const server = new Server({
27
- name: "atabey-mcp",
28
- version: serverVersion,
29
- }, {
30
- capabilities: {
31
- tools: {},
32
- resources: {},
33
- },
34
- });
35
- // Basic Schema Validator for Required Fields
36
- function validateArgs(toolName, args) {
37
- const definition = TOOLS.find(t => t.name === toolName);
38
- if (!definition)
39
- return `Unknown tool: ${toolName}`;
40
- const required = definition.inputSchema.required || [];
41
- for (const field of required) {
42
- if (args[field] === undefined || args[field] === null || args[field] === "") {
43
- return `Missing required argument: '${field}' for tool '${toolName}'`;
44
- }
45
- }
46
- return null;
47
- }
48
- server.setRequestHandler(ListToolsRequestSchema, async (request) => {
49
- // 2026 Stateless Spec: Log client info from metadata if available
50
- const meta = request._meta;
51
- if (meta) {
52
- process.stderr.write(`[MCP] Stateless ListTools from ${meta.client?.name || "unknown"} v${meta.client?.version || "?.?"}\n`);
53
- }
54
- return { tools: TOOLS };
55
- });
56
- server.setRequestHandler(ListResourcesRequestSchema, async () => {
57
- return { resources: RESOURCES };
58
- });
59
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
60
- const uri = request.params.uri;
61
- try {
62
- const content = await handleReadResource(uri);
63
- return {
64
- contents: [
65
- {
66
- uri,
67
- mimeType: "text/markdown",
68
- text: content,
69
- },
70
- ],
71
- };
72
- }
73
- catch (error) {
74
- const message = error instanceof Error ? error.message : String(error);
75
- throw new Error(`Failed to read resource: ${message}`, { cause: error });
76
- }
77
- });
78
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
79
- const req = request;
80
- const { name, arguments: args } = req.params;
81
- const meta = request._meta;
82
- // 2026 Stateless Spec: Prioritize metadata-driven context
83
- if (meta) {
84
- process.stderr.write(`[MCP] Stateless CallTool: ${name} (Client: ${meta.client?.name || "unknown"})\n`);
85
- }
86
- const projectRoot = process.env.ATABEY_PROJECT_ROOT || process.cwd();
87
- try {
88
- const handler = toolHandlers[name];
89
- if (!handler) {
90
- return {
91
- isError: true,
92
- content: [{ type: "text", text: `[ERROR] Unknown tool: ${name}` }],
93
- };
94
- }
95
- // [SECURITY] Runtime Validation
96
- const validationError = validateArgs(name, args || {});
97
- if (validationError) {
98
- return {
99
- isError: true,
100
- content: [{ type: "text", text: `[ERROR] Validation Error: ${validationError}` }],
101
- };
102
- }
103
- return await handler(projectRoot, args || {});
104
- }
105
- catch (error) {
106
- const message = error instanceof Error ? error.message : "Unknown error occurred";
107
- return {
108
- isError: true,
109
- content: [{ type: "text", text: `[ERROR] Execution failed: ${message}` }],
110
- };
111
- }
112
- });
113
- // ─── Graceful Startup & Shutdown ──────────────────────────────────
114
- async function run() {
115
- const transport = new StdioServerTransport();
116
- // Prevent unhandled errors from crashing the MCP stream
117
- process.on("uncaughtException", (error) => {
118
- process.stderr.write(`[atabey-mcp] Uncaught exception: ${error.message}
119
- `);
120
- });
121
- process.on("unhandledRejection", (reason) => {
122
- const message = reason instanceof Error ? reason.message : String(reason);
123
- process.stderr.write(`[atabey-mcp] Unhandled rejection: ${message}
124
- `);
125
- });
126
- // Graceful shutdown on SIGINT/SIGTERM
127
- const shutdown = async () => {
128
- try {
129
- await server.close();
130
- }
131
- catch {
132
- // Already closed or failed — safe to ignore
133
- }
134
- process.exit(0);
135
- };
136
- process.on("SIGINT", shutdown);
137
- process.on("SIGTERM", shutdown);
138
- await server.connect(transport);
139
- }
140
- run().catch((error) => {
141
- process.stderr.write(`[atabey-mcp] Fatal startup error: ${error.message}
142
- `);
143
- process.exit(1);
144
- });
@@ -1,58 +0,0 @@
1
- import { Storage } from "../utils/storage.js";
2
- /**
3
- * [DATA] MCP Resource Definitions
4
- */
5
- export const RESOURCES = [
6
- {
7
- uri: "atabey://army/status",
8
- name: "Agent Army Status",
9
- description: "Real-time state and active tasks of all specialized agents.",
10
- mimeType: "text/markdown"
11
- },
12
- {
13
- uri: "atabey://plan/active",
14
- name: "Active Execution Plan",
15
- description: "The current DAG of tasks and their completion status.",
16
- mimeType: "text/markdown"
17
- },
18
- {
19
- uri: "atabey://memory/project",
20
- name: "Project Memory",
21
- description: "The central source of truth for project context (PROJECT_MEMORY.md).",
22
- mimeType: "text/markdown"
23
- }
24
- ];
25
- export async function handleReadResource(uri) {
26
- if (uri === "atabey://army/status") {
27
- const agents = Storage.getAllAgents();
28
- let md = "# [AI] Agent Army Status\n\n| Agent | State | Active Task | Last Updated |\n| :--- | :--- | :--- | :--- |\n";
29
- agents.forEach((a) => {
30
- md += `| @${a.name} | ${a.state} | ${a.task} | ${a.last_updated} |\n`;
31
- });
32
- return md;
33
- }
34
- if (uri === "atabey://plan/active") {
35
- const tasks = Storage.getTasks();
36
- let md = "# 📋 Active Execution Plan\n\n| ID | Task | Agent | Status | Dependencies |\n| :--- | :--- | :--- | :--- | :--- |\n";
37
- tasks.forEach((t) => {
38
- const deps = t.dependencies.join(", ") || "-";
39
- md += `| ${t.id} | ${t.description} | ${t.agent} | ${t.status} | ${deps} |\n`;
40
- });
41
- return md;
42
- }
43
- if (uri === "atabey://memory/project") {
44
- const fs = await import("fs");
45
- const path = await import("path");
46
- const { getFrameworkDir } = await import("../utils/memory.js");
47
- const projectRoot = process.env.ATABEY_PROJECT_ROOT || process.cwd();
48
- const fwDir = getFrameworkDir();
49
- const p = path.isAbsolute(fwDir)
50
- ? path.join(fwDir, "memory", "PROJECT_MEMORY.md")
51
- : path.join(projectRoot, fwDir, "memory", "PROJECT_MEMORY.md");
52
- if (fs.existsSync(p)) {
53
- return fs.readFileSync(p, "utf8");
54
- }
55
- return "Project memory not found. Run 'atabey init' first.";
56
- }
57
- throw new Error(`Unknown resource URI: ${uri}`);
58
- }
@@ -1,82 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { resolveFrameworkDir } from "../../utils/security.js";
4
- /**
5
- * Handles acquiring a stateful lock on a resource.
6
- */
7
- export async function handleAcquireLock(projectRoot, args) {
8
- const { resource, agent, ttl = 60 } = args;
9
- const frameworkDir = resolveFrameworkDir(projectRoot);
10
- const lockDir = path.join(projectRoot, frameworkDir, "locks");
11
- const lockPath = path.join(lockDir, `${resource}.lock`);
12
- try {
13
- if (!fs.existsSync(lockDir))
14
- fs.mkdirSync(lockDir, { recursive: true });
15
- // Check for stale lock first
16
- if (fs.existsSync(lockPath)) {
17
- const stat = fs.statSync(lockPath);
18
- const now = new Date().getTime();
19
- const age = (now - stat.mtimeMs) / 1000;
20
- if (age < ttl) {
21
- return {
22
- isError: true,
23
- content: [{ type: "text", text: `Resource '${resource}' is currently locked by another agent.` }]
24
- };
25
- }
26
- // Lock expired, safe to override by renaming first (POSIX atomic operation)
27
- const tempLockPath = `${lockPath}.${Math.random().toString(36).substring(2)}.old`;
28
- try {
29
- fs.renameSync(lockPath, tempLockPath);
30
- fs.unlinkSync(tempLockPath);
31
- }
32
- catch {
33
- // If rename failed, it means another agent already evicting/deleting it.
34
- // Do not delete anything else; proceed and let writeFileSync (wx flag) fail if a new lock exists.
35
- }
36
- }
37
- // Use 'wx' flag for atomic file creation
38
- const lockData = JSON.stringify({ agent, timestamp: new Date().toISOString() });
39
- fs.writeFileSync(lockPath, lockData, { flag: "wx" });
40
- return {
41
- content: [{ type: "text", text: `[OK] Lock acquired for resource '${resource}' by ${agent}.` }]
42
- };
43
- }
44
- catch (e) {
45
- const error = e;
46
- if (error.code === "EEXIST") {
47
- return {
48
- isError: true,
49
- content: [{ type: "text", text: `Resource '${resource}' was just acquired by another agent.` }]
50
- };
51
- }
52
- return {
53
- isError: true,
54
- content: [{ type: "text", text: `Failed to acquire lock: ${String(e)}` }]
55
- };
56
- }
57
- }
58
- /**
59
- * Handles releasing a lock.
60
- */
61
- export async function handleReleaseLock(projectRoot, args) {
62
- const { resource, agent } = args;
63
- const frameworkDir = resolveFrameworkDir(projectRoot);
64
- const lockPath = path.join(projectRoot, frameworkDir, "locks", `${resource}.lock`);
65
- try {
66
- if (!fs.existsSync(lockPath)) {
67
- return { content: [{ type: "text", text: `â„šī¸ No lock found for resource '${resource}'.` }] };
68
- }
69
- const lockData = JSON.parse(fs.readFileSync(lockPath, "utf8"));
70
- if (lockData.agent !== agent) {
71
- return {
72
- isError: true,
73
- content: [{ type: "text", text: `[ERROR] Denied: You do not own the lock for '${resource}'. Owned by ${lockData.agent}.` }]
74
- };
75
- }
76
- fs.unlinkSync(lockPath);
77
- return { content: [{ type: "text", text: `[OK] Lock released for resource '${resource}' by ${agent}.` }] };
78
- }
79
- catch (e) {
80
- return { isError: true, content: [{ type: "text", text: `Failed to release lock: ${String(e)}` }] };
81
- }
82
- }
@@ -1,35 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { resolveFrameworkDir } from "../../utils/security.js";
4
- /**
5
- * Handles agent registration with the Control Plane.
6
- * This can be used to validate permissions and active status.
7
- */
8
- export async function handleRegisterAgent(projectRoot, args) {
9
- const { agent, role, capability = 5, specialties } = args;
10
- const frameworkDir = resolveFrameworkDir(projectRoot);
11
- const registryDir = path.join(projectRoot, frameworkDir, "registry");
12
- const agentFile = path.join(registryDir, `${agent.replace("@", "")}_active.json`);
13
- try {
14
- if (!fs.existsSync(registryDir))
15
- fs.mkdirSync(registryDir, { recursive: true });
16
- const agentData = {
17
- agent,
18
- role,
19
- capability,
20
- specialties,
21
- last_seen: new Date().toISOString(),
22
- status: "ACTIVE"
23
- };
24
- fs.writeFileSync(agentFile, JSON.stringify(agentData, null, 2));
25
- return {
26
- content: [{ type: "text", text: `[ATABEY] Agent ${agent} (${role}) registered successfully in the Atabey Control Plane.` }]
27
- };
28
- }
29
- catch (e) {
30
- return {
31
- isError: true,
32
- content: [{ type: "text", text: `Failed to register agent: ${String(e)}` }]
33
- };
34
- }
35
- }