atabey 0.0.9 → 0.0.10

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 (125) hide show
  1. package/README.md +1 -1
  2. package/dist/src/cli/commands/init.js +49 -0
  3. package/dist/src/cli/commands/init.js.map +1 -1
  4. package/framework-mcp/README.md +48 -0
  5. package/framework-mcp/dist/resources/index.js +2 -2
  6. package/framework-mcp/package.json +1 -1
  7. package/package.json +2 -2
  8. package/framework-mcp/dist/framework-mcp/src/constants.js +0 -64
  9. package/framework-mcp/dist/framework-mcp/src/index.js +0 -144
  10. package/framework-mcp/dist/framework-mcp/src/resources/index.js +0 -58
  11. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/locking.js +0 -82
  12. package/framework-mcp/dist/framework-mcp/src/tools/control_plane/registry.js +0 -35
  13. package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +0 -322
  14. package/framework-mcp/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +0 -64
  15. package/framework-mcp/dist/framework-mcp/src/tools/file_system/patch_file.js +0 -34
  16. package/framework-mcp/dist/framework-mcp/src/tools/file_system/read_file.js +0 -51
  17. package/framework-mcp/dist/framework-mcp/src/tools/file_system/replace_text.js +0 -50
  18. package/framework-mcp/dist/framework-mcp/src/tools/file_system/write_file.js +0 -43
  19. package/framework-mcp/dist/framework-mcp/src/tools/framework/audit_deps.js +0 -41
  20. package/framework-mcp/dist/framework-mcp/src/tools/framework/get_status.js +0 -5
  21. package/framework-mcp/dist/framework-mcp/src/tools/framework/orchestrate.js +0 -5
  22. package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +0 -27
  23. package/framework-mcp/dist/framework-mcp/src/tools/framework/submit_plan.js +0 -13
  24. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_contract_hash.js +0 -5
  25. package/framework-mcp/dist/framework-mcp/src/tools/framework/update_memory.js +0 -8
  26. package/framework-mcp/dist/framework-mcp/src/tools/index.js +0 -62
  27. package/framework-mcp/dist/framework-mcp/src/tools/memory/get_insights.js +0 -34
  28. package/framework-mcp/dist/framework-mcp/src/tools/memory/read_memory.js +0 -28
  29. package/framework-mcp/dist/framework-mcp/src/tools/messaging/log_action.js +0 -22
  30. package/framework-mcp/dist/framework-mcp/src/tools/messaging/send_message.js +0 -94
  31. package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +0 -26
  32. package/framework-mcp/dist/framework-mcp/src/tools/observability/get_health.js +0 -19
  33. package/framework-mcp/dist/framework-mcp/src/tools/quality/check_lint.js +0 -30
  34. package/framework-mcp/dist/framework-mcp/src/tools/search/get_gaps.js +0 -48
  35. package/framework-mcp/dist/framework-mcp/src/tools/search/get_map.js +0 -43
  36. package/framework-mcp/dist/framework-mcp/src/tools/search/grep_search.js +0 -75
  37. package/framework-mcp/dist/framework-mcp/src/tools/search/list_dir.js +0 -28
  38. package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +0 -56
  39. package/framework-mcp/dist/framework-mcp/src/tools/types.js +0 -1
  40. package/framework-mcp/dist/framework-mcp/src/utils/cli.js +0 -59
  41. package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +0 -231
  42. package/framework-mcp/dist/framework-mcp/src/utils/fs.js +0 -44
  43. package/framework-mcp/dist/framework-mcp/src/utils/metrics.js +0 -56
  44. package/framework-mcp/dist/framework-mcp/src/utils/permissions.js +0 -71
  45. package/framework-mcp/dist/framework-mcp/src/utils/security.js +0 -60
  46. package/framework-mcp/dist/src/cli/adapters/core.js +0 -71
  47. package/framework-mcp/dist/src/cli/adapters/index.js +0 -5
  48. package/framework-mcp/dist/src/cli/adapters/paths.js +0 -101
  49. package/framework-mcp/dist/src/cli/adapters/scaffold.js +0 -71
  50. package/framework-mcp/dist/src/cli/adapters/utils.js +0 -75
  51. package/framework-mcp/dist/src/cli/commands/approve.js +0 -63
  52. package/framework-mcp/dist/src/cli/commands/check.js +0 -181
  53. package/framework-mcp/dist/src/cli/commands/compliance.js +0 -50
  54. package/framework-mcp/dist/src/cli/commands/contract.js +0 -50
  55. package/framework-mcp/dist/src/cli/commands/dashboard.js +0 -123
  56. package/framework-mcp/dist/src/cli/commands/explorer.js +0 -42
  57. package/framework-mcp/dist/src/cli/commands/git.js +0 -40
  58. package/framework-mcp/dist/src/cli/commands/init/create-agent.js +0 -58
  59. package/framework-mcp/dist/src/cli/commands/init/scaffold-core.js +0 -112
  60. package/framework-mcp/dist/src/cli/commands/init/scaffold-docs.js +0 -34
  61. package/framework-mcp/dist/src/cli/commands/init/scaffold-ops.js +0 -80
  62. package/framework-mcp/dist/src/cli/commands/init/scaffold-standards.js +0 -67
  63. package/framework-mcp/dist/src/cli/commands/init.js +0 -167
  64. package/framework-mcp/dist/src/cli/commands/knowledge.js +0 -42
  65. package/framework-mcp/dist/src/cli/commands/lint.js +0 -22
  66. package/framework-mcp/dist/src/cli/commands/log.js +0 -10
  67. package/framework-mcp/dist/src/cli/commands/memory.js +0 -4
  68. package/framework-mcp/dist/src/cli/commands/orchestrate.js +0 -159
  69. package/framework-mcp/dist/src/cli/commands/plan.js +0 -117
  70. package/framework-mcp/dist/src/cli/commands/script.js +0 -19
  71. package/framework-mcp/dist/src/cli/commands/security.js +0 -36
  72. package/framework-mcp/dist/src/cli/commands/status.js +0 -97
  73. package/framework-mcp/dist/src/cli/commands/trace.js +0 -109
  74. package/framework-mcp/dist/src/cli/index.js +0 -338
  75. package/framework-mcp/dist/src/cli/shims.js +0 -66
  76. package/framework-mcp/dist/src/cli/utils/claude.js +0 -56
  77. package/framework-mcp/dist/src/cli/utils/compliance.js +0 -173
  78. package/framework-mcp/dist/src/cli/utils/config-schema.js +0 -42
  79. package/framework-mcp/dist/src/cli/utils/fs.js +0 -137
  80. package/framework-mcp/dist/src/cli/utils/i18n.js +0 -30
  81. package/framework-mcp/dist/src/cli/utils/memory.js +0 -276
  82. package/framework-mcp/dist/src/cli/utils/pkg.js +0 -282
  83. package/framework-mcp/dist/src/cli/utils/schemas.js +0 -19
  84. package/framework-mcp/dist/src/cli/utils/string.js +0 -49
  85. package/framework-mcp/dist/src/cli/utils/time.js +0 -27
  86. package/framework-mcp/dist/src/cli/utils/ui.js +0 -58
  87. package/framework-mcp/dist/src/contracts/index.js +0 -1
  88. package/framework-mcp/dist/src/contracts/tasks.js +0 -20
  89. package/framework-mcp/dist/src/dashboard/vite.config.js +0 -15
  90. package/framework-mcp/dist/src/modules/adapters/definitions.js +0 -140
  91. package/framework-mcp/dist/src/modules/adapters/registry.js +0 -18
  92. package/framework-mcp/dist/src/modules/adapters/shared.js +0 -104
  93. package/framework-mcp/dist/src/modules/adapters/types.js +0 -1
  94. package/framework-mcp/dist/src/modules/agents/definitions.js +0 -457
  95. package/framework-mcp/dist/src/modules/agents/registry/analyst.js +0 -39
  96. package/framework-mcp/dist/src/modules/agents/registry/architect.js +0 -42
  97. package/framework-mcp/dist/src/modules/agents/registry/backend.js +0 -49
  98. package/framework-mcp/dist/src/modules/agents/registry/database.js +0 -45
  99. package/framework-mcp/dist/src/modules/agents/registry/devops.js +0 -45
  100. package/framework-mcp/dist/src/modules/agents/registry/explorer.js +0 -36
  101. package/framework-mcp/dist/src/modules/agents/registry/frontend.js +0 -51
  102. package/framework-mcp/dist/src/modules/agents/registry/git.js +0 -36
  103. package/framework-mcp/dist/src/modules/agents/registry/manager.js +0 -53
  104. package/framework-mcp/dist/src/modules/agents/registry/mobile.js +0 -39
  105. package/framework-mcp/dist/src/modules/agents/registry/native.js +0 -39
  106. package/framework-mcp/dist/src/modules/agents/registry/quality.js +0 -41
  107. package/framework-mcp/dist/src/modules/agents/registry/security.js +0 -43
  108. package/framework-mcp/dist/src/modules/agents/types.js +0 -1
  109. package/framework-mcp/dist/src/modules/engines/evaluation-engine.js +0 -102
  110. package/framework-mcp/dist/src/modules/engines/health-engine.js +0 -49
  111. package/framework-mcp/dist/src/modules/engines/planning-engine.js +0 -78
  112. package/framework-mcp/dist/src/modules/engines/risk-engine.js +0 -105
  113. package/framework-mcp/dist/src/modules/engines/routing-engine.js +0 -73
  114. package/framework-mcp/dist/src/modules/engines/types.js +0 -1
  115. package/framework-mcp/dist/src/modules/skills/definitions.js +0 -70
  116. package/framework-mcp/dist/src/shared/constants.js +0 -187
  117. package/framework-mcp/dist/src/shared/errors.js +0 -68
  118. package/framework-mcp/dist/src/shared/fs.js +0 -51
  119. package/framework-mcp/dist/src/shared/logger.js +0 -116
  120. package/framework-mcp/dist/src/shared/storage.js +0 -207
  121. package/framework-mcp/dist/src/shared/types.js +0 -12
  122. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/errors.js +0 -0
  123. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/memory.js +0 -0
  124. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/storage.js +0 -0
  125. /package/framework-mcp/dist/{framework-mcp/src/utils → utils}/types.js +0 -0
@@ -1,101 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { ADAPTER_IDS } from "../../modules/adapters/types.js";
4
- import { LEGACY_AGENT_LAYOUT_BASES, UNIFIED_ADAPTER_SLUG, UNIFIED_HUB_DIR, pathJoin, unifiedAdapterPath, } from "../../shared/constants.js";
5
- import { ADAPTERS } from "./core.js";
6
- export { CORE_FRAMEWORK_DIR, UNIFIED_HUB_DIR, UNIFIED_ADAPTER_SLUG, } from "../../shared/constants.js";
7
- export function unifiedAdapterRoot(aiToolDir, adapterId) {
8
- return pathJoin(aiToolDir, UNIFIED_ADAPTER_SLUG[adapterId]);
9
- }
10
- export function resolveAgentsDir(adapterId, isUnified, aiToolDir = UNIFIED_HUB_DIR) {
11
- const adapter = ADAPTERS[adapterId];
12
- if (!isUnified) {
13
- return {
14
- agentsDir: adapter.agentsDir ?? pathJoin(adapter.frameworkDir, "agents"),
15
- agentsExt: adapter.agentsExt ?? ".md",
16
- nestedAntigravity: adapterId === "antigravity-cli",
17
- };
18
- }
19
- const base = unifiedAdapterRoot(aiToolDir, adapterId);
20
- switch (adapterId) {
21
- case "cursor":
22
- return { agentsDir: pathJoin(base, "rules"), agentsExt: ".mdc", nestedAntigravity: false };
23
- case "codex":
24
- return { agentsDir: pathJoin(base, "instructions"), agentsExt: ".md", nestedAntigravity: false };
25
- case "antigravity-cli":
26
- // Antigravity CLI expects workspace agents at .agents/agents/{agent_name}/agent.json
27
- return { agentsDir: pathJoin(aiToolDir, "agents"), agentsExt: ".json", nestedAntigravity: true };
28
- default:
29
- return { agentsDir: pathJoin(base, "agents"), agentsExt: ".md", nestedAntigravity: false };
30
- }
31
- }
32
- export function getUnifiedAgentLayoutBases(aiToolDir = UNIFIED_HUB_DIR) {
33
- return ADAPTER_IDS.map((id) => resolveAgentsDir(id, true, aiToolDir).agentsDir);
34
- }
35
- const AGENT_INSTRUCTION_CANDIDATES = [
36
- (n) => ADAPTER_IDS.flatMap((id) => {
37
- const { agentsDir, nestedAntigravity, agentsExt } = resolveAgentsDir(id, true);
38
- if (nestedAntigravity) {
39
- return [pathJoin(agentsDir, n, "agent.json"), pathJoin(agentsDir, n, "agent.md")];
40
- }
41
- return [pathJoin(agentsDir, `${n}${agentsExt}`)];
42
- }),
43
- (n) => LEGACY_AGENT_LAYOUT_BASES.flatMap((base) => {
44
- if (base.includes("antigravity")) {
45
- return [pathJoin(base, n, "agent.json"), pathJoin(base, n, "agent.md")];
46
- }
47
- const ext = base.includes("rules") ? ".mdc" : ".md";
48
- return [pathJoin(base, `${n}${ext}`)];
49
- }),
50
- ];
51
- export function findAgentInstruction(projectRoot, agentName) {
52
- for (const buildPaths of AGENT_INSTRUCTION_CANDIDATES) {
53
- for (const rel of buildPaths(agentName)) {
54
- const full = path.join(projectRoot, rel);
55
- if (fs.existsSync(full))
56
- return rel;
57
- }
58
- }
59
- return null;
60
- }
61
- export function detectActiveAgentLayouts(projectRoot) {
62
- const unified = getUnifiedAgentLayoutBases()
63
- .filter((b) => fs.existsSync(path.join(projectRoot, b)));
64
- const legacy = LEGACY_AGENT_LAYOUT_BASES
65
- .filter((b) => fs.existsSync(path.join(projectRoot, b)));
66
- return [...new Set([...unified, ...legacy])];
67
- }
68
- function copyDirectoryRecursive(src, dest) {
69
- fs.mkdirSync(dest, { recursive: true });
70
- for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
71
- const srcPath = path.join(src, entry.name);
72
- const destPath = path.join(dest, entry.name);
73
- if (entry.isDirectory()) {
74
- copyDirectoryRecursive(srcPath, destPath);
75
- }
76
- else {
77
- fs.copyFileSync(srcPath, destPath);
78
- }
79
- }
80
- }
81
- export function mirrorUnifiedAgentsToNative(projectRoot, adapterId) {
82
- const { agentsDir: unifiedDir } = resolveAgentsDir(adapterId, true);
83
- const nativeRel = ADAPTERS[adapterId].agentsDir;
84
- if (!nativeRel)
85
- return;
86
- const src = path.join(projectRoot, unifiedDir);
87
- const dest = path.join(projectRoot, nativeRel);
88
- if (!fs.existsSync(src) || path.resolve(src) === path.resolve(dest))
89
- return;
90
- if (fs.existsSync(dest)) {
91
- fs.rmSync(dest, { recursive: true, force: true });
92
- }
93
- copyDirectoryRecursive(src, dest);
94
- }
95
- /** Cursor global rule destinations (native + unified hub). */
96
- export function getCursorGlobalRulePaths(projectRoot) {
97
- return [
98
- path.join(projectRoot, ADAPTERS.cursor.frameworkDir, "rules", "global.mdc"),
99
- path.join(projectRoot, unifiedAdapterPath(UNIFIED_ADAPTER_SLUG.cursor, "rules", "global.mdc")),
100
- ];
101
- }
@@ -1,71 +0,0 @@
1
- import { writeTextFile } from "../utils/fs.js";
2
- import path from "path";
3
- import fs from "fs";
4
- import { getPackageRoot } from "../utils/pkg.js";
5
- import { ALL_AGENTS, toClaudeCodeMd, toGeminiCliMd, toCodexMd, toAntigravityJson, toCursorMdc } from "../../modules/agents/definitions.js";
6
- import { ADAPTERS } from "./core.js";
7
- export function scaffoldAgents(projectRoot, adapterId, dryRun, agentsToScaffold, explicitDestDir, explicitExt, paths, backendLanguage, _language) {
8
- const adapter = ADAPTERS[adapterId];
9
- if (!adapter)
10
- return;
11
- const allowedAgents = agentsToScaffold ? new Set(agentsToScaffold) : undefined;
12
- const destAgentsDir = explicitDestDir ? path.join(projectRoot, explicitDestDir) : (adapter.agentsDir ? path.join(projectRoot, adapter.agentsDir) : null);
13
- const extension = explicitExt || adapter.agentsExt || ".md";
14
- if (!destAgentsDir)
15
- return;
16
- const baseKnowledgeDir = path.join(getPackageRoot(), "templates/standards");
17
- try {
18
- if (!dryRun)
19
- fs.mkdirSync(destAgentsDir, { recursive: true });
20
- for (const agent of ALL_AGENTS) {
21
- if (allowedAgents && !allowedAgents.has(agent.name))
22
- continue;
23
- let content = "";
24
- let fileName = `${agent.name}${extension}`;
25
- let secondaryContent = null;
26
- let secondaryFileName = null;
27
- switch (adapterId) {
28
- case "gemini":
29
- content = toGeminiCliMd(agent, baseKnowledgeDir, paths, backendLanguage);
30
- break;
31
- case "grok":
32
- // Grok uses same Gemini-compatible YAML format
33
- content = toGeminiCliMd(agent, baseKnowledgeDir, paths, backendLanguage);
34
- break;
35
- case "claude":
36
- content = toClaudeCodeMd(agent, baseKnowledgeDir, paths, backendLanguage);
37
- break;
38
- case "cursor":
39
- content = toCursorMdc(agent, baseKnowledgeDir, paths, backendLanguage);
40
- break;
41
- case "codex":
42
- content = toCodexMd(agent, baseKnowledgeDir, paths, backendLanguage);
43
- break;
44
- case "antigravity-cli": {
45
- // Antigravity uses nested folders: agents/{name}/agent.json and agents/{name}/agent.md
46
- const agentDir = path.join(destAgentsDir, agent.name);
47
- if (!dryRun)
48
- fs.mkdirSync(agentDir, { recursive: true });
49
- content = toAntigravityJson(agent, baseKnowledgeDir, paths, backendLanguage);
50
- fileName = path.join(agent.name, "agent.json");
51
- secondaryContent = `# [ATABEY] Agent Atabey — @${agent.name}\n\n${agent.instructions.identity}\n\n${agent.instructions.mission}`;
52
- secondaryFileName = path.join(agent.name, "agent.md");
53
- break;
54
- }
55
- default:
56
- // Fallback to Gemini format
57
- content = toGeminiCliMd(agent, baseKnowledgeDir, paths, backendLanguage);
58
- break;
59
- }
60
- if (!dryRun) {
61
- writeTextFile(path.join(destAgentsDir, fileName), content, dryRun);
62
- if (secondaryContent && secondaryFileName) {
63
- writeTextFile(path.join(destAgentsDir, secondaryFileName), secondaryContent, dryRun);
64
- }
65
- }
66
- }
67
- }
68
- catch (e) {
69
- console.warn(`[WARN] Failed to scaffold agents for ${adapterId}: ${e}`);
70
- }
71
- }
@@ -1,75 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { logger } from "../../shared/logger.js";
4
- import { UI } from "../utils/ui.js";
5
- import { ADAPTERS, SHIM_FILES } from "./core.js";
6
- export function resolveAdapter(input) {
7
- let normalized = (input || "gemini").toLowerCase();
8
- if (normalized === "antigravity") {
9
- normalized = "antigravity-cli";
10
- }
11
- else if (normalized === "copilot" || normalized === "github") {
12
- normalized = "codex";
13
- }
14
- let config;
15
- if (normalized in ADAPTERS) {
16
- config = { ...ADAPTERS[normalized] };
17
- }
18
- else {
19
- UI.warning(`Unknown adapter "${input}". Falling back to gemini.`);
20
- config = { ...ADAPTERS.gemini };
21
- }
22
- return config;
23
- }
24
- export function isAdapterShimFile(fileName) {
25
- return SHIM_FILES.includes(fileName);
26
- }
27
- export function remapFrameworkContent(content, frameworkDir, adapterId) {
28
- let result = content;
29
- result = result.replace(/\{\{FRAMEWORK_DIR\}\}/g, frameworkDir);
30
- result = result.replace(/\{\{ADAPTER\}\}/g, adapterId);
31
- let agentFolder = "agents";
32
- let knowledgeFolder = "knowledge";
33
- if (frameworkDir !== ".atabey") {
34
- if (adapterId === "antigravity-cli") {
35
- agentFolder = "agents";
36
- knowledgeFolder = "rules";
37
- }
38
- // Note: Grok uses the same directory structure as Gemini (".grok/agents").
39
- // No override needed — default agentFolder = "agents" is correct.
40
- }
41
- const frameworkPattern = ".atabey/";
42
- result = result.replace(new RegExp(frameworkPattern + "agents/", "g"), `${frameworkDir}/${agentFolder}/`);
43
- result = result.replace(new RegExp(frameworkPattern + "knowledge/", "g"), `${frameworkDir}/${knowledgeFolder}/`);
44
- result = result.replace(/\.atabey\//g, `${frameworkDir}/`);
45
- result = result.replace(/`\.atabey`/g, `\`${frameworkDir}\``);
46
- result = result.replace(/\.atabey(?![\w/-])/g, frameworkDir);
47
- let backend = "apps/backend";
48
- let frontend = "apps/web";
49
- let docs = "docs";
50
- let tests = "tests";
51
- try {
52
- const configPath = path.join(process.cwd(), frameworkDir, "config.json");
53
- if (fs.existsSync(configPath)) {
54
- const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
55
- if (config.paths) {
56
- if (config.paths.backend)
57
- backend = config.paths.backend;
58
- if (config.paths.frontend)
59
- frontend = config.paths.frontend;
60
- if (config.paths.docs)
61
- docs = config.paths.docs;
62
- if (config.paths.tests)
63
- tests = config.paths.tests;
64
- }
65
- }
66
- }
67
- catch (err) {
68
- logger.debug("Failed to read config.json in remapFrameworkContent", err);
69
- }
70
- result = result.replace(/\{\{BACKEND_DIR\}\}/g, backend);
71
- result = result.replace(/\{\{FRONTEND_DIR\}\}/g, frontend);
72
- result = result.replace(/\{\{DOCS_DIR\}\}/g, docs);
73
- result = result.replace(/\{\{TESTS_DIR\}\}/g, tests);
74
- return result;
75
- }
@@ -1,63 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { getFrameworkDir } from "../utils/memory.js";
4
- import { UI } from "../utils/ui.js";
5
- import { writeTextFile, appendFile } from "../utils/fs.js";
6
- import { ValidationError } from "../../shared/errors.js";
7
- import { HermesMessageSchema } from "./orchestrate.js";
8
- export async function approveCommand(traceId) {
9
- const frameworkDir = getFrameworkDir();
10
- const messagesDir = path.join(frameworkDir, "messages");
11
- if (!fs.existsSync(messagesDir)) {
12
- throw new ValidationError("No messages directory found.", null, "Ensure the framework is initialized and the Hermes orchestrator has been run at least once.");
13
- }
14
- const files = fs.readdirSync(messagesDir).filter((f) => f.endsWith(".json"));
15
- let found = false;
16
- for (const file of files) {
17
- const filePath = path.join(messagesDir, file);
18
- try {
19
- const content = fs.readFileSync(filePath, "utf8").trim();
20
- if (!content)
21
- continue;
22
- const lines = content.split("\n");
23
- let updated = false;
24
- const newLines = lines.map((line) => {
25
- if (!line.trim())
26
- return line;
27
- try {
28
- const parsed = JSON.parse(line);
29
- const msg = HermesMessageSchema.parse(parsed);
30
- if (msg.traceId === traceId && msg.status === "PENDING" && (msg.category === "ALERT" || msg.category === "ACTION")) {
31
- msg.status = "APPROVED";
32
- updated = true;
33
- found = true;
34
- UI.success(`Approved message from ${msg.from} to ${msg.to} (Action: ${msg.action || "None"})`);
35
- }
36
- return JSON.stringify(msg);
37
- }
38
- catch (e) {
39
- UI.error(`Skipping invalid Hermes message during approval: ${e.message}`);
40
- return line;
41
- }
42
- });
43
- if (updated) {
44
- writeTextFile(filePath, newLines.join("\n") + "\n");
45
- }
46
- }
47
- catch (e) {
48
- UI.error(`Error reading or updating message file ${file}: ${e.message}`);
49
- }
50
- }
51
- if (found) {
52
- // Log user approval to audit log
53
- const auditPath = path.join(frameworkDir, "observability/audit_log.md");
54
- if (fs.existsSync(auditPath)) {
55
- const logEntry = "\n- **[" + new Date().toISOString() + "]** USER -> @manager | APPROVED | Trace: " + traceId;
56
- appendFile(auditPath, logEntry);
57
- }
58
- UI.success("Successfully approved Trace: " + traceId);
59
- }
60
- else {
61
- throw new ValidationError(`No pending approval request found for Trace ID: ${traceId}`, null, "Run 'npx atabey status' to see active traces and ensure the ID is correct and pending approval.");
62
- }
63
- }
@@ -1,181 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { execSync } from "child_process";
4
- import { getFrameworkDir, getMemoryPath, getConfiguredPaths, isFrameworkDevelopmentRepo, readState } from "../utils/memory.js";
5
- import { getPackageVersion, getValidatorPath } from "../utils/pkg.js";
6
- import { UI } from "../utils/ui.js";
7
- import { logger } from "../../shared/logger.js";
8
- import { scanProjectCompliance } from "../utils/compliance.js";
9
- import { ALL_AGENTS } from "../../modules/agents/definitions.js";
10
- import { detectActiveAgentLayouts, findAgentInstruction } from "../adapters/paths.js";
11
- import { verifyApiContractCommand } from "./contract.js";
12
- export async function checkCommand() {
13
- UI.intent("Agent Atabey Health Check", `Checking system health and discipline rules (v${getPackageVersion()})...`);
14
- let issues = 0;
15
- const state = readState();
16
- if (!state) {
17
- UI.error("Memory state not found. Run 'init' first.");
18
- return;
19
- }
20
- const frameworkDir = getFrameworkDir();
21
- const memoryPath = getMemoryPath();
22
- const pathsMap = getConfiguredPaths();
23
- UI.success(`Using framework dir: ${frameworkDir}`);
24
- // --- Contract Gate (Phase 2+ Discipline) ---
25
- if (["PHASE_2", "PHASE_3", "PHASE_4"].includes(state.phase)) {
26
- console.warn("\n📝 Validating API Contracts (Phase 2+ Required)...");
27
- try {
28
- const contractOk = await verifyApiContractCommand({ silent: true });
29
- if (!contractOk) {
30
- UI.error("Contract verification FAILED! You cannot be in Phase 2+ with unverified contracts.");
31
- issues++;
32
- }
33
- else {
34
- UI.success("API Contracts verified and sealed.");
35
- }
36
- }
37
- catch {
38
- UI.error("Error during contract verification.");
39
- issues++;
40
- }
41
- }
42
- let knowledgeDir = "knowledge";
43
- if (frameworkDir === ".github")
44
- knowledgeDir = "instructions";
45
- const constitutionPath = fs.existsSync(path.join(process.cwd(), "ATABEY.md")) ? "ATABEY.md" : path.join(frameworkDir, "ATABEY.md");
46
- const rootPandaPath = path.join(process.cwd(), "panda.config.ts");
47
- const appPandaPath = path.join(pathsMap.frontend, "panda.config.ts");
48
- if (fs.existsSync(rootPandaPath)) {
49
- UI.error(`Panda CSS config must NOT be at the root directory! Move it to '${pathsMap.frontend}/panda.config.ts'.`);
50
- issues++;
51
- }
52
- const isFrameworkDevelopment = isFrameworkDevelopmentRepo();
53
- const checks = [
54
- { name: "Constitution (ATABEY.md)", path: constitutionPath },
55
- { name: "Memory (PROJECT_MEMORY.md)", path: path.relative(process.cwd(), memoryPath) },
56
- { name: "Command Map (cli-commands.json)", path: path.join(frameworkDir, "cli-commands.json") },
57
- { name: "Framework Config (config.json)", path: path.join(frameworkDir, "config.json") },
58
- { name: "Agent Status (STATUS.md)", path: path.join(frameworkDir, "STATUS.md") },
59
- { name: "MCP Config (mcp.json)", path: "mcp.json" },
60
- { name: "ESLint Config (eslint.config.js)", path: "eslint.config.js", optional: !isFrameworkDevelopment },
61
- { name: "ESLint Standards", path: path.join(frameworkDir, `${knowledgeDir}/eslint-standards.md`) },
62
- { name: "CRUD Governance Standards", path: path.join(frameworkDir, `${knowledgeDir}/crud-governance.md`) },
63
- { name: "Architecture Standards", path: path.join(frameworkDir, `${knowledgeDir}/architecture-standards.md`) },
64
- { name: "Frontend Standards", path: path.join(frameworkDir, `${knowledgeDir}/frontend-standards.md`) },
65
- { name: "Vite Standards", path: path.join(frameworkDir, `${knowledgeDir}/vite-standards.md`), optional: true },
66
- { name: "Next.js Standards", path: path.join(frameworkDir, `${knowledgeDir}/nextjs-standards.md`), optional: true },
67
- { name: "Tailwind Standards", path: path.join(frameworkDir, `${knowledgeDir}/tailwind-standards.md`), optional: true },
68
- { name: "Mobile Standards", path: path.join(frameworkDir, `${knowledgeDir}/mobile-standards.md`) },
69
- { name: "Security Standards", path: path.join(frameworkDir, `${knowledgeDir}/security-standards.md`) },
70
- { name: "Quality & Discipline Standards", path: path.join(frameworkDir, `${knowledgeDir}/quality-standards.md`) },
71
- { name: "Logging & Secrets Standards", path: path.join(frameworkDir, `${knowledgeDir}/logging-and-secrets.md`) },
72
- { name: "Testing Standards", path: path.join(frameworkDir, `${knowledgeDir}/testing-standards.md`) },
73
- { name: "i18n Standards", path: path.join(frameworkDir, `${knowledgeDir}/i18n-standards.md`) },
74
- { name: ".env.example", path: ".env.example" },
75
- ...(isFrameworkDevelopment ? [{ name: "MCP Server", path: "framework-mcp/package.json" }] : []),
76
- { name: "Panda CSS Config", path: appPandaPath, optional: true },
77
- ];
78
- for (const check of checks) {
79
- const fullPath = path.isAbsolute(check.path) ? check.path : path.join(process.cwd(), check.path);
80
- if (fs.existsSync(fullPath)) {
81
- UI.success(`${check.name} found.`);
82
- }
83
- else {
84
- if (check.optional) {
85
- UI.warning(`${check.name} MISSING! (${check.path}) [Optional]`);
86
- }
87
- else {
88
- UI.error(`${check.name} MISSING! (${check.path})`);
89
- issues++;
90
- }
91
- }
92
- }
93
- // Agent Army Check
94
- console.warn("\n[SECURITY] Running Agent Army Compliance...");
95
- try {
96
- const validatorScript = getValidatorPath();
97
- execSync(`node "${validatorScript}"`, { stdio: "pipe" });
98
- UI.success("Agent Army AL validation PASSED.");
99
- }
100
- catch (error) {
101
- const err = error;
102
- UI.error(`Agent Army AL validation FAILED: ${err.message}`);
103
- if (err.stderr)
104
- console.error(err.stderr.toString());
105
- issues++;
106
- }
107
- // Agent Documentation Check (Live Integrity)
108
- console.warn("\n📚 Checking Agent Integrity (Instructions)...");
109
- const projectRoot = process.cwd();
110
- const activeLayouts = detectActiveAgentLayouts(projectRoot);
111
- if (activeLayouts.length > 0) {
112
- UI.success(`Active agent layout(s): ${activeLayouts.join(", ")}`);
113
- ALL_AGENTS.forEach((agent) => {
114
- const found = findAgentInstruction(projectRoot, agent.name);
115
- if (found) {
116
- UI.success(`Instructions for @${agent.name} found at ${found}`);
117
- }
118
- else {
119
- UI.error(`Instructions for @${agent.name} MISSING! Run 'atabey init' to scaffold.`);
120
- issues++;
121
- }
122
- });
123
- }
124
- else {
125
- UI.warning("No active agent instruction directory detected. Run 'atabey init [adapter]' first.");
126
- issues++;
127
- }
128
- // Code Quality - Using the new Compliance Scanner
129
- console.warn("\n⚖️ Checking Discipline (Code Quality)...");
130
- const complianceIssues = scanProjectCompliance();
131
- if (complianceIssues.length > 0) {
132
- complianceIssues.forEach(issue => {
133
- UI.error(`${issue.rule} in ${issue.file}:${issue.line}`);
134
- });
135
- issues += complianceIssues.length;
136
- }
137
- else {
138
- UI.success("No compliance issues detected.");
139
- }
140
- const rootTestFiles = checkRootTestFiles();
141
- if (rootTestFiles.length > 0) {
142
- UI.warning(`Test files found in the root directory: ${rootTestFiles.join(", ")}. It is recommended to place all test files under the 'tests/' folder or application-specific directories.`);
143
- }
144
- try {
145
- UI.intent("Type Check", "Running 'npx tsc --noEmit' (this may take a few seconds)...");
146
- execSync("npx tsc --noEmit", { stdio: "pipe" });
147
- UI.success("TypeScript type check PASSED.");
148
- }
149
- catch (err) {
150
- UI.warning("TypeScript type check FAILED or 'tsc' not found. This is a non-blocking warning for lightweight checks.");
151
- logger.debug("npx tsc --noEmit check failed", err);
152
- }
153
- if (issues === 0) {
154
- UI.success("\n[START] All systems green! Agent Atabey is ready.");
155
- }
156
- else {
157
- UI.error(`\n[WARN] Found ${issues} issues. Please fix them.`);
158
- process.exit(1);
159
- }
160
- }
161
- function checkRootTestFiles() {
162
- const rootDir = process.cwd();
163
- if (!fs.existsSync(rootDir))
164
- return [];
165
- const files = fs.readdirSync(rootDir);
166
- const testFiles = [];
167
- for (const file of files) {
168
- const fullPath = path.join(rootDir, file);
169
- try {
170
- if (fs.statSync(fullPath).isFile()) {
171
- if (file.includes(".test.") || file.includes(".spec.")) {
172
- testFiles.push(file);
173
- }
174
- }
175
- }
176
- catch (err) {
177
- logger.debug(`Failed to stat file ${fullPath} in checkRootTestFiles`, err);
178
- }
179
- }
180
- return testFiles;
181
- }
@@ -1,50 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
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
- }