atabey 0.0.7 → 0.0.8

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/src/cli/adapters/core.js +12 -19
  3. package/dist/src/cli/adapters/core.js.map +1 -1
  4. package/dist/src/shared/constants.d.ts +1 -0
  5. package/dist/src/shared/constants.js +1 -0
  6. package/dist/src/shared/constants.js.map +1 -1
  7. package/dist/tests/adapter.test.js +3 -2
  8. package/dist/tests/adapter.test.js.map +1 -1
  9. package/framework-mcp/dist/constants.js +64 -0
  10. package/framework-mcp/dist/framework-mcp/src/constants.js +64 -0
  11. package/framework-mcp/dist/framework-mcp/src/index.js +144 -0
  12. package/framework-mcp/dist/framework-mcp/src/resources/index.js +58 -0
  13. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/locking.js +82 -0
  14. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/registry.js +35 -0
  15. package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +322 -0
  16. package/framework-mcp/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +64 -0
  17. package/framework-mcp/dist/framework-mcp/src/tools/file_system/patch_file.js +34 -0
  18. package/framework-mcp/dist/framework-mcp/src/tools/file_system/read_file.js +51 -0
  19. package/framework-mcp/dist/framework-mcp/src/tools/file_system/replace_text.js +50 -0
  20. package/framework-mcp/dist/framework-mcp/src/tools/file_system/write_file.js +43 -0
  21. package/framework-mcp/dist/framework-mcp/src/tools/framework/audit_deps.js +41 -0
  22. package/framework-mcp/dist/framework-mcp/src/tools/framework/get_status.js +5 -0
  23. package/framework-mcp/dist/framework-mcp/src/tools/framework/orchestrate.js +5 -0
  24. package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +27 -0
  25. package/framework-mcp/dist/framework-mcp/src/tools/framework/submit_plan.js +13 -0
  26. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_contract_hash.js +5 -0
  27. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_memory.js +8 -0
  28. package/framework-mcp/dist/framework-mcp/src/tools/index.js +62 -0
  29. package/framework-mcp/dist/framework-mcp/src/tools/memory/get_insights.js +34 -0
  30. package/framework-mcp/dist/framework-mcp/src/tools/memory/read_memory.js +28 -0
  31. package/framework-mcp/dist/framework-mcp/src/tools/messaging/log_action.js +22 -0
  32. package/framework-mcp/dist/framework-mcp/src/tools/messaging/send_message.js +94 -0
  33. package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +26 -0
  34. package/framework-mcp/dist/framework-mcp/src/tools/observability/get_health.js +19 -0
  35. package/framework-mcp/dist/framework-mcp/src/tools/quality/check_lint.js +30 -0
  36. package/framework-mcp/dist/framework-mcp/src/tools/search/get_gaps.js +48 -0
  37. package/framework-mcp/dist/framework-mcp/src/tools/search/get_map.js +43 -0
  38. package/framework-mcp/dist/framework-mcp/src/tools/search/grep_search.js +75 -0
  39. package/framework-mcp/dist/framework-mcp/src/tools/search/list_dir.js +28 -0
  40. package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +56 -0
  41. package/framework-mcp/dist/framework-mcp/src/tools/types.js +1 -0
  42. package/framework-mcp/dist/framework-mcp/src/utils/cli.js +59 -0
  43. package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +231 -0
  44. package/framework-mcp/dist/framework-mcp/src/utils/fs.js +44 -0
  45. package/framework-mcp/dist/framework-mcp/src/utils/metrics.js +56 -0
  46. package/framework-mcp/dist/framework-mcp/src/utils/permissions.js +71 -0
  47. package/framework-mcp/dist/framework-mcp/src/utils/security.js +60 -0
  48. package/framework-mcp/dist/index.js +144 -0
  49. package/framework-mcp/dist/resources/index.js +58 -0
  50. package/framework-mcp/dist/src/cli/adapters/core.js +71 -0
  51. package/framework-mcp/dist/src/cli/adapters/index.js +5 -0
  52. package/framework-mcp/dist/src/cli/adapters/paths.js +101 -0
  53. package/framework-mcp/dist/src/cli/adapters/scaffold.js +71 -0
  54. package/framework-mcp/dist/src/cli/adapters/utils.js +75 -0
  55. package/framework-mcp/dist/src/cli/commands/approve.js +63 -0
  56. package/framework-mcp/dist/src/cli/commands/check.js +181 -0
  57. package/framework-mcp/dist/src/cli/commands/compliance.js +50 -0
  58. package/framework-mcp/dist/src/cli/commands/contract.js +50 -0
  59. package/framework-mcp/dist/src/cli/commands/dashboard.js +123 -0
  60. package/framework-mcp/dist/src/cli/commands/explorer.js +42 -0
  61. package/framework-mcp/dist/src/cli/commands/git.js +40 -0
  62. package/framework-mcp/dist/src/cli/commands/init/create-agent.js +58 -0
  63. package/framework-mcp/dist/src/cli/commands/init/scaffold-core.js +112 -0
  64. package/framework-mcp/dist/src/cli/commands/init/scaffold-docs.js +34 -0
  65. package/framework-mcp/dist/src/cli/commands/init/scaffold-ops.js +80 -0
  66. package/framework-mcp/dist/src/cli/commands/init/scaffold-standards.js +67 -0
  67. package/framework-mcp/dist/src/cli/commands/init.js +167 -0
  68. package/framework-mcp/dist/src/cli/commands/knowledge.js +42 -0
  69. package/framework-mcp/dist/src/cli/commands/lint.js +22 -0
  70. package/framework-mcp/dist/src/cli/commands/log.js +10 -0
  71. package/framework-mcp/dist/src/cli/commands/memory.js +4 -0
  72. package/framework-mcp/dist/src/cli/commands/orchestrate.js +159 -0
  73. package/framework-mcp/dist/src/cli/commands/plan.js +117 -0
  74. package/framework-mcp/dist/src/cli/commands/script.js +19 -0
  75. package/framework-mcp/dist/src/cli/commands/security.js +36 -0
  76. package/framework-mcp/dist/src/cli/commands/status.js +97 -0
  77. package/framework-mcp/dist/src/cli/commands/trace.js +109 -0
  78. package/framework-mcp/dist/src/cli/index.js +338 -0
  79. package/framework-mcp/dist/src/cli/shims.js +66 -0
  80. package/framework-mcp/dist/src/cli/utils/claude.js +56 -0
  81. package/framework-mcp/dist/src/cli/utils/compliance.js +173 -0
  82. package/framework-mcp/dist/src/cli/utils/config-schema.js +42 -0
  83. package/framework-mcp/dist/src/cli/utils/fs.js +137 -0
  84. package/framework-mcp/dist/src/cli/utils/i18n.js +30 -0
  85. package/framework-mcp/dist/src/cli/utils/memory.js +276 -0
  86. package/framework-mcp/dist/src/cli/utils/pkg.js +282 -0
  87. package/framework-mcp/dist/src/cli/utils/schemas.js +19 -0
  88. package/framework-mcp/dist/src/cli/utils/string.js +49 -0
  89. package/framework-mcp/dist/src/cli/utils/time.js +27 -0
  90. package/framework-mcp/dist/src/cli/utils/ui.js +58 -0
  91. package/framework-mcp/dist/src/contracts/index.js +1 -0
  92. package/framework-mcp/dist/src/contracts/tasks.js +20 -0
  93. package/framework-mcp/dist/src/dashboard/vite.config.js +15 -0
  94. package/framework-mcp/dist/src/modules/adapters/definitions.js +140 -0
  95. package/framework-mcp/dist/src/modules/adapters/registry.js +18 -0
  96. package/framework-mcp/dist/src/modules/adapters/shared.js +104 -0
  97. package/framework-mcp/dist/src/modules/adapters/types.js +1 -0
  98. package/framework-mcp/dist/src/modules/agents/definitions.js +457 -0
  99. package/framework-mcp/dist/src/modules/agents/registry/analyst.js +39 -0
  100. package/framework-mcp/dist/src/modules/agents/registry/architect.js +42 -0
  101. package/framework-mcp/dist/src/modules/agents/registry/backend.js +49 -0
  102. package/framework-mcp/dist/src/modules/agents/registry/database.js +45 -0
  103. package/framework-mcp/dist/src/modules/agents/registry/devops.js +45 -0
  104. package/framework-mcp/dist/src/modules/agents/registry/explorer.js +36 -0
  105. package/framework-mcp/dist/src/modules/agents/registry/frontend.js +51 -0
  106. package/framework-mcp/dist/src/modules/agents/registry/git.js +36 -0
  107. package/framework-mcp/dist/src/modules/agents/registry/manager.js +53 -0
  108. package/framework-mcp/dist/src/modules/agents/registry/mobile.js +39 -0
  109. package/framework-mcp/dist/src/modules/agents/registry/native.js +39 -0
  110. package/framework-mcp/dist/src/modules/agents/registry/quality.js +41 -0
  111. package/framework-mcp/dist/src/modules/agents/registry/security.js +43 -0
  112. package/framework-mcp/dist/src/modules/agents/types.js +1 -0
  113. package/framework-mcp/dist/src/modules/engines/evaluation-engine.js +102 -0
  114. package/framework-mcp/dist/src/modules/engines/health-engine.js +49 -0
  115. package/framework-mcp/dist/src/modules/engines/planning-engine.js +78 -0
  116. package/framework-mcp/dist/src/modules/engines/risk-engine.js +105 -0
  117. package/framework-mcp/dist/src/modules/engines/routing-engine.js +73 -0
  118. package/framework-mcp/dist/src/modules/engines/types.js +1 -0
  119. package/framework-mcp/dist/src/modules/skills/definitions.js +70 -0
  120. package/framework-mcp/dist/src/shared/constants.js +187 -0
  121. package/framework-mcp/dist/src/shared/errors.js +68 -0
  122. package/framework-mcp/dist/src/shared/fs.js +51 -0
  123. package/framework-mcp/dist/src/shared/logger.js +116 -0
  124. package/framework-mcp/dist/src/shared/storage.js +207 -0
  125. package/framework-mcp/dist/src/shared/types.js +12 -0
  126. package/framework-mcp/dist/tools/control_plane/locking.js +82 -0
  127. package/framework-mcp/dist/tools/control_plane/registry.js +35 -0
  128. package/framework-mcp/dist/tools/definitions.js +322 -0
  129. package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +64 -0
  130. package/framework-mcp/dist/tools/file_system/patch_file.js +34 -0
  131. package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
  132. package/framework-mcp/dist/tools/file_system/replace_text.js +50 -0
  133. package/framework-mcp/dist/tools/file_system/write_file.js +43 -0
  134. package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
  135. package/framework-mcp/dist/tools/framework/get_status.js +5 -0
  136. package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
  137. package/framework-mcp/dist/tools/framework/run_tests.js +27 -0
  138. package/framework-mcp/dist/tools/framework/submit_plan.js +13 -0
  139. package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
  140. package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
  141. package/framework-mcp/dist/tools/index.js +62 -0
  142. package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
  143. package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
  144. package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
  145. package/framework-mcp/dist/tools/messaging/send_message.js +94 -0
  146. package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
  147. package/framework-mcp/dist/tools/observability/get_health.js +19 -0
  148. package/framework-mcp/dist/tools/quality/check_lint.js +30 -0
  149. package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
  150. package/framework-mcp/dist/tools/search/get_map.js +43 -0
  151. package/framework-mcp/dist/tools/search/grep_search.js +75 -0
  152. package/framework-mcp/dist/tools/search/list_dir.js +28 -0
  153. package/framework-mcp/dist/tools/shell/run_command.js +56 -0
  154. package/framework-mcp/dist/tools/types.js +1 -0
  155. package/framework-mcp/dist/utils/cli.js +59 -0
  156. package/framework-mcp/dist/utils/compliance.js +231 -0
  157. package/framework-mcp/dist/utils/fs.js +44 -0
  158. package/framework-mcp/dist/utils/metrics.js +56 -0
  159. package/framework-mcp/dist/utils/permissions.js +71 -0
  160. package/framework-mcp/dist/utils/security.js +60 -0
  161. package/framework-mcp/package.json +35 -0
  162. package/mcp.json +1 -1
  163. package/package.json +6 -3
@@ -0,0 +1,50 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { collectFiles } from "../utils/fs.js";
4
+ const targetDir = process.cwd(); // Assuming targetDir is process.cwd() in the CLI context
5
+ export async function complianceCheckCommand(targetPath) {
6
+ console.warn(`📜 Checking Constitution Compliance: ${targetPath}...`);
7
+ const violations = [];
8
+ const forbidden = ["@shadcn", "mui", "@chakra-ui", "tailwindcss"];
9
+ // 1. package.json scan (Blind Spot 5)
10
+ const pkgJsonPath = path.join(targetDir, "package.json");
11
+ if (fs.existsSync(pkgJsonPath)) {
12
+ try {
13
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
14
+ const allDeps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
15
+ forbidden.forEach(lib => {
16
+ if (allDeps[lib] || Object.keys(allDeps).some(d => d.toLowerCase().includes(lib.toLowerCase()))) {
17
+ violations.push(`package.json: Forbidden library dependency '${lib}' found in package.json.`);
18
+ }
19
+ });
20
+ }
21
+ catch {
22
+ // ignore
23
+ }
24
+ }
25
+ // 2. Source files scan
26
+ const files = collectFiles(path.join(targetDir, targetPath), [".ts", ".tsx", ".js", ".jsx", ".md"]);
27
+ files.forEach(f => {
28
+ const isTypesFile = f.includes("brands.ts") || f.includes("brands.js") || f.includes("brands.tsx") || f.includes("src/types/brands");
29
+ const content = fs.readFileSync(f, "utf8");
30
+ forbidden.forEach(lib => {
31
+ if (content.includes(lib))
32
+ violations.push(`${path.relative(targetDir, f)}: Forbidden library '${lib}' found.`);
33
+ });
34
+ // Robust Branded Types validation (Blind Spot 4)
35
+ if ((f.endsWith(".ts") || f.endsWith(".tsx")) && !isTypesFile && content.includes("interface")) {
36
+ const plainIdMatches = content.match(/\b\w*(?:id|Id|ID)\??\s*:\s*(?:string|number)\b/g);
37
+ if (plainIdMatches) {
38
+ plainIdMatches.forEach(match => {
39
+ violations.push(`${path.relative(targetDir, f)}: Potential Branded Types violation (plain identifier '${match.trim()}' found inside interface).`);
40
+ });
41
+ }
42
+ }
43
+ });
44
+ if (violations.length === 0) {
45
+ console.warn("[OK] All systems compliant with ATABEY.md.");
46
+ }
47
+ else {
48
+ violations.forEach(v => console.warn(`[ERROR] ${v}`));
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { getConfiguredPaths } from "../utils/memory.js";
4
+ import { computeTypesHash, writeJsonFile } from "../utils/fs.js";
5
+ import { ValidationError } from "../../shared/errors.js";
6
+ /**
7
+ * Verify type safety between backend and frontend contracts.
8
+ */
9
+ export async function verifyApiContractCommand(options = {}) {
10
+ const projectRoot = process.cwd();
11
+ const pathsMap = getConfiguredPaths();
12
+ const sharedDir = path.join(projectRoot, pathsMap.backend, "src/types");
13
+ const contractPath = path.join(projectRoot, pathsMap.backend, "contract.version.json");
14
+ if (!fs.existsSync(sharedDir) || !fs.existsSync(contractPath)) {
15
+ if (options.silent)
16
+ return false;
17
+ throw new ValidationError("API types or contract version file missing.", null, "Ensure you have initialized the project and the backend directory is correctly configured in config.json.");
18
+ }
19
+ const currentHash = computeTypesHash(projectRoot, sharedDir);
20
+ const contract = JSON.parse(fs.readFileSync(contractPath, "utf8"));
21
+ if (contract.contract_hash === currentHash) {
22
+ if (!options.silent)
23
+ console.warn("[OK] Contract is valid and synchronized.");
24
+ return true;
25
+ }
26
+ else {
27
+ if (options.silent)
28
+ return false;
29
+ throw new ValidationError("Contract drift detected!", { stored: contract.contract_hash, actual: currentHash }, "Run 'npx atabey update-contract' to re-synchronize the API contracts.");
30
+ }
31
+ }
32
+ /**
33
+ * Update and synchronize type safety between backend and frontend contracts.
34
+ */
35
+ export async function updateApiContractCommand() {
36
+ const projectRoot = process.cwd();
37
+ const pathsMap = getConfiguredPaths();
38
+ const sharedDir = path.join(projectRoot, pathsMap.backend, "src/types");
39
+ const contractPath = path.join(projectRoot, pathsMap.backend, "contract.version.json");
40
+ if (!fs.existsSync(sharedDir)) {
41
+ throw new ValidationError("API types directory missing.", null, "The directory specified for backend types does not exist. Check your framework configuration.");
42
+ }
43
+ const currentHash = computeTypesHash(projectRoot, sharedDir);
44
+ const contractData = {
45
+ contract_hash: currentHash,
46
+ last_updated: new Date().toISOString()
47
+ };
48
+ writeJsonFile(contractPath, contractData);
49
+ console.warn(`[OK] Contract successfully synchronized. New hash: ${currentHash}`);
50
+ }
@@ -0,0 +1,123 @@
1
+ import http from "http";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { getFrameworkDir } from "../utils/memory.js";
6
+ import { UI } from "../utils/ui.js";
7
+ import { FRAMEWORK } from "../../shared/constants.js";
8
+ /**
9
+ * Serves a JSON file.
10
+ */
11
+ function serveJson(res, filePath) {
12
+ if (fs.existsSync(filePath)) {
13
+ try {
14
+ const content = fs.readFileSync(filePath, "utf8");
15
+ res.writeHead(200, { "Content-Type": "application/json" });
16
+ res.end(content);
17
+ }
18
+ catch (e) {
19
+ res.writeHead(500);
20
+ res.end(JSON.stringify({ error: "Read Error", message: e.message }));
21
+ }
22
+ }
23
+ else {
24
+ res.writeHead(404);
25
+ res.end(JSON.stringify({ error: "Not Found", path: filePath }));
26
+ }
27
+ }
28
+ /**
29
+ * Serves a file with specific content type.
30
+ */
31
+ function serveFile(res, filePath, contentType) {
32
+ if (fs.existsSync(filePath)) {
33
+ try {
34
+ const content = fs.readFileSync(filePath);
35
+ res.writeHead(200, { "Content-Type": contentType });
36
+ res.end(content);
37
+ }
38
+ catch (e) {
39
+ res.writeHead(500);
40
+ res.end(e.message);
41
+ }
42
+ }
43
+ else {
44
+ res.writeHead(404);
45
+ res.end("Not Found");
46
+ }
47
+ }
48
+ /**
49
+ * 🖥️ Hermes Visual Control Plane (Dashboard Server)
50
+ * Serves the framework state as a JSON API and the bundled Web UI.
51
+ */
52
+ export async function dashboardCommand(port = FRAMEWORK.DASHBOARD_PORT) {
53
+ const frameworkDir = getFrameworkDir();
54
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
55
+ const projectRoot = path.resolve(__dirname, "../../../");
56
+ const uiDistPath = path.join(projectRoot, "dist/ui");
57
+ const server = http.createServer((req, res) => {
58
+ // CORS Headers
59
+ res.setHeader("Access-Control-Allow-Origin", "*");
60
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
61
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
62
+ if (req.method === "OPTIONS") {
63
+ res.writeHead(204);
64
+ res.end();
65
+ return;
66
+ }
67
+ const url = req.url || "/";
68
+ // API Routes
69
+ if (url === "/api/status") {
70
+ const statusPath = path.join(frameworkDir, "memory", "status.json");
71
+ serveJson(res, statusPath);
72
+ return;
73
+ }
74
+ if (url === "/api/memory") {
75
+ const memoryPath = path.join(frameworkDir, "memory", "PROJECT_MEMORY.md");
76
+ serveFile(res, memoryPath, "text/markdown");
77
+ return;
78
+ }
79
+ if (url.startsWith("/api/logs/")) {
80
+ const agent = url.replace("/api/logs/", "");
81
+ const logPath = path.join(frameworkDir, "logs", `${agent}.json`);
82
+ serveJson(res, logPath);
83
+ return;
84
+ }
85
+ if (url === "/api/health") {
86
+ res.writeHead(200, { "Content-Type": "application/json" });
87
+ res.end(JSON.stringify({ status: "healthy", version: "0.0.6", frameworkDir }));
88
+ return;
89
+ }
90
+ // Static UI Serving
91
+ let filePath = path.join(uiDistPath, url === "/" ? "index.html" : url);
92
+ // Fallback to index.html for SPA routing if file not found
93
+ if (!fs.existsSync(filePath) && !url.startsWith("/api")) {
94
+ filePath = path.join(uiDistPath, "index.html");
95
+ }
96
+ if (fs.existsSync(filePath) && !fs.statSync(filePath).isDirectory()) {
97
+ const ext = path.extname(filePath).toLowerCase();
98
+ const mimeTypes = {
99
+ ".html": "text/html",
100
+ ".js": "application/javascript",
101
+ ".css": "text/css",
102
+ ".json": "application/json",
103
+ ".png": "image/png",
104
+ ".jpg": "image/jpg",
105
+ ".gif": "image/gif",
106
+ ".svg": "image/svg+xml",
107
+ ".ico": "image/x-icon",
108
+ };
109
+ const contentType = mimeTypes[ext] || "application/octet-stream";
110
+ serveFile(res, filePath, contentType);
111
+ }
112
+ else {
113
+ res.writeHead(404, { "Content-Type": "application/json" });
114
+ res.end(JSON.stringify({ error: "Not Found", message: "Route not found" }));
115
+ }
116
+ });
117
+ server.listen(port, () => {
118
+ UI.success("\n[START] Hermes Visual Control Plane is running!");
119
+ UI.success(`[INFO] Web UI: http://localhost:${port}`);
120
+ UI.success(`[DATA] API Base: http://localhost:${port}/api`);
121
+ UI.warning("\n(Press Ctrl+C to stop the server)\n");
122
+ });
123
+ }
@@ -0,0 +1,42 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { collectFiles } from "../utils/fs.js";
4
+ const targetDir = process.cwd();
5
+ export async function explorerGraphCommand(targetPath) {
6
+ console.warn(`🗺️ Generating Dependency Graph for: ${targetPath}...`);
7
+ const files = collectFiles(path.join(targetDir, targetPath), [".ts", ".tsx"]);
8
+ const edges = [];
9
+ files.forEach((f) => {
10
+ const content = fs.readFileSync(f, "utf8");
11
+ const name = path.basename(f, path.extname(f));
12
+ const imports = content.match(/from\s+['"]\.\.?\/[^'"]+['"]/g) || [];
13
+ imports.forEach((imp) => {
14
+ const target = path.basename(imp.split(/['"]/)[1]);
15
+ edges.push(`${name} --> ${target}`);
16
+ });
17
+ });
18
+ if (edges.length === 0) {
19
+ console.warn("ℹ️ No internal dependencies found.");
20
+ }
21
+ else {
22
+ console.warn("```mermaid\ngraph TD\n" + Array.from(new Set(edges)).join("\n") + "\n```");
23
+ }
24
+ }
25
+ export async function explorerAuditCommand(targetPath) {
26
+ console.warn(`[MEMORY] Codebase Intelligence Scan: ${targetPath}...`);
27
+ const files = collectFiles(path.join(targetDir, targetPath), [".ts", ".tsx"]);
28
+ const complexity = [];
29
+ files.forEach((f) => {
30
+ const content = fs.readFileSync(f, "utf8");
31
+ const lines = content.split("\n").length;
32
+ if (lines > 300)
33
+ complexity.push(`${path.relative(targetDir, f)} (${lines} lines)`);
34
+ });
35
+ if (complexity.length > 0) {
36
+ console.warn("\n[WARN] Complexity Spikes:");
37
+ complexity.forEach((c) => console.warn(`- ${c}`));
38
+ }
39
+ else {
40
+ console.warn("[OK] Codebase structure looks clean.");
41
+ }
42
+ }
@@ -0,0 +1,40 @@
1
+ import cp from "child_process";
2
+ import path from "path";
3
+ import { getConfiguredPaths } from "../utils/memory.js";
4
+ export async function gitCommitCommand(traceId) {
5
+ try {
6
+ const diff = cp.execSync("git diff --staged", { encoding: "utf8" });
7
+ if (!diff) {
8
+ console.warn("ℹ️ No staged changes found. Use 'git add' first.");
9
+ return;
10
+ }
11
+ const files = cp.execSync("git diff --staged --name-only", { encoding: "utf8" })
12
+ .split("\n")
13
+ .filter(Boolean);
14
+ const pathsMap = getConfiguredPaths();
15
+ const backendTypesPath = path.join(pathsMap.backend, "src/types");
16
+ let type = "feat";
17
+ const scope = "code";
18
+ if (files.some((f) => f.includes(".md")))
19
+ type = "docs";
20
+ else if (files.some((f) => f.includes(backendTypesPath)))
21
+ type = "arch";
22
+ else if (files.some((f) => f.includes("bin/cli.js")))
23
+ type = "fix";
24
+ const summary = files.length === 1 ? `update ${path.basename(files[0])}` : `update ${files.length} files`;
25
+ console.warn(`\n### SUGGESTED COMMIT MESSAGE ###\n\n[${traceId}] ${type}(${scope}): ${summary}\n`);
26
+ }
27
+ catch {
28
+ console.warn("[ERROR] Git command failed.");
29
+ }
30
+ }
31
+ export async function gitSyncCommand() {
32
+ console.warn("🔄 Syncing with remote repository...");
33
+ try {
34
+ cp.execSync("git pull origin main --rebase", { stdio: "inherit" });
35
+ console.warn("[OK] Successfully synced and rebased.");
36
+ }
37
+ catch {
38
+ console.warn("[ERROR] Sync failed. Please resolve conflicts manually.");
39
+ }
40
+ }
@@ -0,0 +1,58 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { UI } from "../../utils/ui.js";
4
+ import { writeTextFile } from "../../../shared/fs.js";
5
+ /**
6
+ * Plugin SDK: Creates a new custom agent template.
7
+ */
8
+ export async function createAgentCommand(name) {
9
+ const projectRoot = process.cwd();
10
+ const agentsDir = path.join(projectRoot, "src/modules/agents/registry");
11
+ if (!fs.existsSync(agentsDir)) {
12
+ UI.error("Ajan kayıt dizini bulunamadı. Lütfen Atabey geliştirme ortamında olduğunuzdan emin olun.");
13
+ return;
14
+ }
15
+ const filePath = path.join(agentsDir, `${name}.ts`);
16
+ if (fs.existsSync(filePath)) {
17
+ UI.error(`Ajan '${name}' zaten mevcut.`);
18
+ return;
19
+ }
20
+ const template = `import { AgentDefinition } from "../types.js";
21
+
22
+ const STATE_MACHINE = "../schema/agent-lifecycle-schema.json" as const;
23
+
24
+ export const ${name}: AgentDefinition = {
25
+ name: "${name}",
26
+ displayName: "${name.charAt(0).toUpperCase() + name.slice(1)} Specialist",
27
+ role: "Custom Specialty",
28
+ description: "Automatically generated custom agent for specific project needs.",
29
+ capability: 7,
30
+ tier: "core",
31
+ tags: ["custom"],
32
+ stateMachine: STATE_MACHINE,
33
+ tools: [
34
+ "read_file",
35
+ "write_file",
36
+ "replace_text",
37
+ "grep_search",
38
+ "send_agent_message",
39
+ ],
40
+ instructions: {
41
+ identity: "${name.toUpperCase()} Domain Expert",
42
+ mission: "Execute tasks related to ${name} with high precision and following Atabey standards.",
43
+ chainOfThought: "1. Analyze Task\\n2. Plan Steps\\n3. Execute\\n4. Verify",
44
+ rules: [
45
+ "Always maintain type safety.",
46
+ "Log all critical actions.",
47
+ ],
48
+ knowledgeFiles: [],
49
+ },
50
+ specialties: {
51
+ ${name}: 10,
52
+ },
53
+ };
54
+ `;
55
+ writeTextFile(filePath, template);
56
+ UI.success(`[OK] New agent '${name}' created at src/modules/agents/registry/${name}.ts`);
57
+ UI.warning("[INFO] Don't forget to register the agent in src/modules/agents/definitions.ts");
58
+ }
@@ -0,0 +1,112 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { remapFrameworkContent, ADAPTERS } from "../../adapters/index.js";
4
+ import { SHIM_TEMPLATES } from "../../shims.js";
5
+ import { writeJsonFile, writeTextFile } from "../../utils/fs.js";
6
+ import { getPackageRoot, getPackageVersion } from "../../utils/pkg.js";
7
+ import { ALL_AGENTS } from "../../../modules/agents/definitions.js";
8
+ import { TRANSLATIONS } from "../../utils/i18n.js";
9
+ const FRAMEWORK_NAME = "Agent Atabey";
10
+ const COLOR_PALETTES = {
11
+ "Modern Blue": { primary: "#0ea5e9", secondary: "#64748b", accent: "#f43f5e" },
12
+ "Enterprise Slate": { primary: "#334155", secondary: "#94a3b8", accent: "#10b981" },
13
+ "Deep Purple": { primary: "#8b5cf6", secondary: "#d8b4fe", accent: "#f59e0b" }
14
+ };
15
+ export function scaffoldConstitution(targetDir, frameworkDir, adapterId, dryRun, language = "tr") {
16
+ if (dryRun)
17
+ return;
18
+ const t = TRANSLATIONS[language];
19
+ let content = `# [ATABEY] ${t.constitution_title}\n\nDiscipline and Order.`;
20
+ let readSuccess = false;
21
+ try {
22
+ const templatePath = path.join(getPackageRoot(), "ATABEY.md");
23
+ if (fs.existsSync(templatePath)) {
24
+ content = fs.readFileSync(templatePath, "utf8");
25
+ readSuccess = true;
26
+ }
27
+ }
28
+ catch (e) {
29
+ console.warn(`[WARN] Failed to read global constitution template: ${e}`);
30
+ }
31
+ content = remapFrameworkContent(content, frameworkDir, adapterId);
32
+ const destPath = path.join(targetDir, frameworkDir, "ATABEY.md");
33
+ writeTextFile(destPath, content);
34
+ console.warn(`[OK] Constitution file created inside: ${frameworkDir}/ATABEY.md${readSuccess ? "" : " (default template)"}`);
35
+ }
36
+ export function scaffoldFrameworkConfigs(targetDir, fDir, adapter, dryRun, selectedPalette, options) {
37
+ if (dryRun)
38
+ return;
39
+ const frameworkDir = path.join(targetDir, fDir);
40
+ const palette = COLOR_PALETTES[selectedPalette] || COLOR_PALETTES["Modern Blue"];
41
+ const language = options?.language || "tr";
42
+ const t = TRANSLATIONS[language];
43
+ const config = {
44
+ name: FRAMEWORK_NAME,
45
+ version: getPackageVersion(),
46
+ unified: options?.unified || false,
47
+ adapters: options?.adapters || [adapter.id],
48
+ backendLanguage: options?.backendLanguage || "Node.js (TypeScript)",
49
+ frontendFramework: options?.frontendFramework || "Vite (React)",
50
+ language: language,
51
+ theme: {
52
+ palette: selectedPalette,
53
+ colors: palette
54
+ }
55
+ };
56
+ writeJsonFile(path.join(frameworkDir, "config.json"), config, dryRun);
57
+ // Scaffold shared-facts.json in memory-graph
58
+ const graphDir = path.join(frameworkDir, "memory-graph");
59
+ if (!fs.existsSync(graphDir))
60
+ fs.mkdirSync(graphDir, { recursive: true });
61
+ const sharedFactsPath = path.join(graphDir, "shared-facts.json");
62
+ if (!fs.existsSync(sharedFactsPath)) {
63
+ writeJsonFile(sharedFactsPath, {
64
+ project: FRAMEWORK_NAME,
65
+ initializedAt: new Date().toISOString(),
66
+ stack: [
67
+ options?.backendLanguage || "Node.js (TypeScript)",
68
+ options?.frontendFramework || "Vite (React)"
69
+ ],
70
+ language: language,
71
+ policies: []
72
+ }, dryRun);
73
+ }
74
+ let statusContent = `# [ATABEY] ${t.status_title}\n\n| Agent | State | Active Task | Last Updated | Notes | Extra | Backup |\n|---|---|---|---|---|---|---|\n`;
75
+ const activeAgents = ALL_AGENTS;
76
+ const initialStatusJson = {};
77
+ const now = new Date().toISOString();
78
+ for (const ag of activeAgents) {
79
+ statusContent += "| @" + ag.name + " | " + t.agent_ready + " | Idle | - | - | - | - |\n";
80
+ initialStatusJson[ag.name] = { state: "READY", task: "Idle", lastUpdated: now };
81
+ }
82
+ writeTextFile(path.join(frameworkDir, "STATUS.md"), statusContent);
83
+ // Populate initial status.json
84
+ const statusJsonPath = path.join(frameworkDir, "memory", "status.json");
85
+ if (!fs.existsSync(path.join(frameworkDir, "memory")))
86
+ fs.mkdirSync(path.join(frameworkDir, "memory"), { recursive: true });
87
+ writeJsonFile(statusJsonPath, initialStatusJson, dryRun);
88
+ }
89
+ export function scaffoldShims(projectRoot, coreDir, adapterId, adapter, dryRun, unified = false) {
90
+ for (const [name, content] of Object.entries(SHIM_TEMPLATES)) {
91
+ // Normalize: "antigravity-cli" template key needs exact match or prefix match
92
+ const isSelectedAdapter = name === adapterId ||
93
+ name.toLowerCase() === adapterId.split("-")[0].toLowerCase();
94
+ if (unified || isSelectedAdapter) {
95
+ const shimContent = remapFrameworkContent(content, coreDir, adapterId);
96
+ // In unified mode, each adapter writes its OWN shimFile name.
97
+ // In single-adapter mode, use selected adapter's shimFile.
98
+ const shimAdapter = ADAPTERS[name] || adapter;
99
+ const shimFileName = (unified && !isSelectedAdapter)
100
+ ? (shimAdapter.shimFile || `${name.toUpperCase()}.md`) // each adapter's own file
101
+ : (adapter.shimFile || `${name.toUpperCase()}.md`); // selected adapter's file
102
+ if (!dryRun)
103
+ writeTextFile(path.join(projectRoot, shimFileName), shimContent);
104
+ if (isSelectedAdapter) {
105
+ console.warn(`[OK] Platform shim created: ${shimFileName}`);
106
+ }
107
+ else if (unified) {
108
+ console.warn(`[OK] Unified platform shim added: ${shimFileName}`);
109
+ }
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,34 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { writeTextFile } from "../../utils/fs.js";
4
+ import { getPackageRoot } from "../../utils/pkg.js";
5
+ import { logger } from "../../../shared/logger.js";
6
+ export function scaffoldProjectDocs(projectRoot, options, dryRun) {
7
+ if (dryRun)
8
+ return;
9
+ const docsDir = path.join(projectRoot, "docs");
10
+ if (!fs.existsSync(docsDir))
11
+ fs.mkdirSync(docsDir, { recursive: true });
12
+ // Scaffold tech-stack.md with dynamic content
13
+ const techStackPath = path.join(docsDir, "tech-stack.md");
14
+ let techStackContent = "";
15
+ try {
16
+ const templatePath = path.join(getPackageRoot(), "docs/tech-stack.md");
17
+ if (fs.existsSync(templatePath)) {
18
+ techStackContent = fs.readFileSync(templatePath, "utf8");
19
+ // Replace the backend language in the template
20
+ const lang = options.backendLanguage;
21
+ const frontend = options.frontendFramework || "Vite (React)";
22
+ techStackContent = techStackContent.replace(/\| \*\*Geliştirme Ortamı\*\* \| .* \|/, `| **Geliştirme Ortamı** | ${lang} |`);
23
+ techStackContent = techStackContent.replace(/\| \*\*Frontend Altyapısı\*\* \| .* \|/, `| **Frontend Altyapısı** | ${frontend} |`);
24
+ }
25
+ }
26
+ catch (e) {
27
+ logger.debug("Failed to read tech-stack.md template", e);
28
+ }
29
+ if (!techStackContent) {
30
+ techStackContent = `# 🛠️ Project Tech Stack\n\n- **Backend Language:** ${options.backendLanguage}\n- **Frontend Framework:** ${options.frontendFramework || "Vite (React)"}\n`;
31
+ }
32
+ writeTextFile(techStackPath, techStackContent);
33
+ console.warn(`[OK] Project documentation updated: docs/tech-stack.md (Backend: ${options.backendLanguage}, Frontend: ${options.frontendFramework || "Vite (React)"})`);
34
+ }
@@ -0,0 +1,80 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { writeJsonFile, writeTextFile } from "../../utils/fs.js";
4
+ import { getPackageRoot } from "../../utils/pkg.js";
5
+ import { logger } from "../../../shared/logger.js";
6
+ export function scaffoldOps(frameworkDir, dryRun) {
7
+ if (dryRun)
8
+ return;
9
+ // Scaffold Prompt Recipes
10
+ const promptsPath = path.join(frameworkDir, "prompts");
11
+ if (!fs.existsSync(promptsPath))
12
+ fs.mkdirSync(promptsPath, { recursive: true });
13
+ const recipes = [
14
+ { file: "refactoring-recipe.md", template: "templates/prompts/refactoring-recipe.md" },
15
+ { file: "bug-fix-recipe.md", template: "templates/prompts/bug-fix-recipe.md" },
16
+ { file: "new-feature-recipe.md", template: "templates/prompts/new-feature-recipe.md" },
17
+ { file: "security-audit-recipe.md", template: "templates/prompts/security-audit-recipe.md" },
18
+ { file: "db-management-recipe.md", template: "templates/prompts/db-management-recipe.md" },
19
+ { file: "performance-optimization-recipe.md", template: "templates/prompts/performance-optimization-recipe.md" },
20
+ { file: "deployment-recipe.md", template: "templates/prompts/deployment-recipe.md" },
21
+ { file: "contract-design-recipe.md", template: "templates/prompts/contract-design-recipe.md" }
22
+ ];
23
+ for (const recipe of recipes) {
24
+ try {
25
+ const fullTemplatePath = path.join(getPackageRoot(), recipe.template);
26
+ if (fs.existsSync(fullTemplatePath)) {
27
+ const content = fs.readFileSync(fullTemplatePath, "utf8");
28
+ writeTextFile(path.join(promptsPath, recipe.file), content);
29
+ }
30
+ }
31
+ catch (e) {
32
+ logger.debug(`Failed to scaffold prompt recipe: ${recipe.file}`, e);
33
+ }
34
+ }
35
+ // Scaffold cli-commands.json
36
+ const cliCommands = {
37
+ commands: {
38
+ init: { agent: "manager", description: "Initialize Agent Atabey structure and AI configuration." },
39
+ check: { agent: "quality", description: "Verify framework files and code quality discipline." },
40
+ status: { agent: "manager", description: "Show the current status of the active project phase." },
41
+ "trace:new": { agent: "manager", description: "Generate a new Trace ID to start a task sequence." },
42
+ orchestrate: { agent: "manager", description: "Execute the Hermes message broker loop." },
43
+ "verify-contract": { agent: "architect", description: "Validate type contracts between backend and frontend." },
44
+ "update-contract": { agent: "architect", description: "Update the contract signature hash." }
45
+ }
46
+ };
47
+ writeJsonFile(path.join(frameworkDir, "cli-commands.json"), cliCommands, dryRun);
48
+ // Scaffold router/routing_rules.md
49
+ const routerDir = path.join(frameworkDir, "router");
50
+ if (!fs.existsSync(routerDir))
51
+ fs.mkdirSync(routerDir, { recursive: true });
52
+ writeTextFile(path.join(routerDir, "routing_rules.md"), "# [SIGNAL] Agent Atabey — Natural Language & Event Router\n\nRouting engine protocols defined here.");
53
+ // Scaffold registry/agent_registry.md
54
+ const registryDir = path.join(frameworkDir, "registry");
55
+ if (!fs.existsSync(registryDir))
56
+ fs.mkdirSync(registryDir, { recursive: true });
57
+ writeTextFile(path.join(registryDir, "agent_registry.md"), "# [ATABEY] Agent Atabey — Army Registry\n\nList of active agents.");
58
+ // Scaffold observability files
59
+ const obsDir = path.join(frameworkDir, "observability");
60
+ if (!fs.existsSync(obsDir))
61
+ fs.mkdirSync(obsDir, { recursive: true });
62
+ writeTextFile(path.join(obsDir, "audit_log.md"), "# [ATABEY] Agent Atabey — Audit Log\n\n| Timestamp | Agent | Action | Trace ID | Status |\n|---|---|---|---|---|\n");
63
+ writeJsonFile(path.join(obsDir, "metrics.json"), []);
64
+ // Scaffold .env.example
65
+ const envExamplePath = path.join(process.cwd(), ".env.example");
66
+ if (!fs.existsSync(envExamplePath)) {
67
+ writeTextFile(envExamplePath, "# Agent Atabey - Environment Variables\n\n# Core Settings\nPORT=5858\nNODE_ENV=development\n\n# AI Platform Keys (Fill these in your local .env)\nGEMINI_API_KEY=\nCLAUDE_API_KEY=\nGROK_API_KEY=\n");
68
+ }
69
+ // Scaffold rules
70
+ const rulesDir = path.join(frameworkDir, "rules");
71
+ if (!fs.existsSync(rulesDir))
72
+ fs.mkdirSync(rulesDir, { recursive: true });
73
+ writeTextFile(path.join(rulesDir, "global_rules.mdc"), `---
74
+ description: Global Rules for Agent Atabey Army
75
+ globs: **/*
76
+ ---
77
+
78
+ # [ATABEY] Agent Atabey — Global Army Rules
79
+ `);
80
+ }