atabey 0.0.13 → 0.0.14
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.
- package/ATABEY.md +1 -1
- package/README.md +252 -52
- package/dist/framework-mcp/src/index.js +914 -62
- package/dist/framework-mcp/src/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/compliance/mask_pii.d.ts +17 -0
- package/dist/framework-mcp/src/tools/compliance/mask_pii.js +56 -0
- package/dist/framework-mcp/src/tools/compliance/mask_pii.js.map +1 -0
- package/dist/framework-mcp/src/tools/definitions.js +10 -9
- package/dist/framework-mcp/src/tools/definitions.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/run_tests.js +25 -0
- package/dist/framework-mcp/src/tools/framework/run_tests.js.map +1 -1
- package/dist/framework-mcp/src/tools/index.js +7 -8
- package/dist/framework-mcp/src/tools/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/messaging/approve_operation.d.ts +22 -0
- package/dist/framework-mcp/src/tools/messaging/approve_operation.js +81 -0
- package/dist/framework-mcp/src/tools/messaging/approve_operation.js.map +1 -0
- package/dist/framework-mcp/src/tools/messaging/ask_human.d.ts +15 -0
- package/dist/framework-mcp/src/tools/messaging/ask_human.js +89 -20
- package/dist/framework-mcp/src/tools/messaging/ask_human.js.map +1 -1
- package/dist/framework-mcp/src/tools/observability/check_ports.js +3 -1
- package/dist/framework-mcp/src/tools/observability/check_ports.js.map +1 -1
- package/dist/framework-mcp/src/tools/quality/analyze_code_quality.js +13 -64
- package/dist/framework-mcp/src/tools/quality/analyze_code_quality.js.map +1 -1
- package/dist/framework-mcp/src/tools/schemas.d.ts +48 -53
- package/dist/framework-mcp/src/tools/schemas.js +18 -22
- package/dist/framework-mcp/src/tools/schemas.js.map +1 -1
- package/dist/framework-mcp/src/tools/shell/run_command.js +10 -0
- package/dist/framework-mcp/src/tools/shell/run_command.js.map +1 -1
- package/dist/framework-mcp/src/tools/types.d.ts +11 -105
- package/dist/framework-mcp/src/tools/types.js +1 -0
- package/dist/framework-mcp/src/tools/types.js.map +1 -1
- package/dist/framework-mcp/src/utils/auth.d.ts +36 -0
- package/dist/framework-mcp/src/utils/auth.js +79 -0
- package/dist/framework-mcp/src/utils/auth.js.map +1 -0
- package/dist/framework-mcp/src/utils/auto-rollback.d.ts +71 -0
- package/dist/framework-mcp/src/utils/auto-rollback.js +266 -0
- package/dist/framework-mcp/src/utils/auto-rollback.js.map +1 -0
- package/dist/framework-mcp/src/utils/compliance.js +12 -4
- package/dist/framework-mcp/src/utils/compliance.js.map +1 -1
- package/dist/framework-mcp/src/utils/context-optimizer.d.ts +69 -0
- package/dist/framework-mcp/src/utils/context-optimizer.js +157 -0
- package/dist/framework-mcp/src/utils/context-optimizer.js.map +1 -0
- package/dist/framework-mcp/src/utils/discipline.d.ts +68 -0
- package/dist/framework-mcp/src/utils/discipline.js +218 -0
- package/dist/framework-mcp/src/utils/discipline.js.map +1 -0
- package/dist/framework-mcp/src/utils/finops.d.ts +143 -0
- package/dist/framework-mcp/src/utils/finops.js +326 -0
- package/dist/framework-mcp/src/utils/finops.js.map +1 -0
- package/dist/framework-mcp/src/utils/human-in-loop.d.ts +95 -0
- package/dist/framework-mcp/src/utils/human-in-loop.js +216 -0
- package/dist/framework-mcp/src/utils/human-in-loop.js.map +1 -0
- package/dist/framework-mcp/src/utils/license-scanner.d.ts +71 -0
- package/dist/framework-mcp/src/utils/license-scanner.js +284 -0
- package/dist/framework-mcp/src/utils/license-scanner.js.map +1 -0
- package/dist/framework-mcp/src/utils/loop-detector.d.ts +105 -0
- package/dist/framework-mcp/src/utils/loop-detector.js +362 -0
- package/dist/framework-mcp/src/utils/loop-detector.js.map +1 -0
- package/dist/framework-mcp/src/utils/quality.d.ts +19 -0
- package/dist/framework-mcp/src/utils/quality.js +124 -0
- package/dist/framework-mcp/src/utils/quality.js.map +1 -0
- package/dist/framework-mcp/src/utils/rules-engine.d.ts +78 -0
- package/dist/framework-mcp/src/utils/rules-engine.js +232 -0
- package/dist/framework-mcp/src/utils/rules-engine.js.map +1 -0
- package/dist/framework-mcp/src/utils/silent-router.d.ts +47 -0
- package/dist/framework-mcp/src/utils/silent-router.js +129 -0
- package/dist/framework-mcp/src/utils/silent-router.js.map +1 -0
- package/dist/framework-mcp/src/utils/storage.d.ts +1 -0
- package/dist/framework-mcp/src/utils/storage.js +2 -2
- package/dist/framework-mcp/src/utils/storage.js.map +1 -1
- package/dist/framework-mcp/src/utils/telemetry-streamer.d.ts +133 -0
- package/dist/framework-mcp/src/utils/telemetry-streamer.js +397 -0
- package/dist/framework-mcp/src/utils/telemetry-streamer.js.map +1 -0
- package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js +2 -2
- package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js.map +1 -1
- package/dist/framework-mcp/tests/tools/framework/run_tests.test.d.ts +1 -0
- package/dist/framework-mcp/tests/tools/framework/run_tests.test.js +49 -0
- package/dist/framework-mcp/tests/tools/framework/run_tests.test.js.map +1 -0
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js +14 -5
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js.map +1 -1
- package/dist/framework-mcp/tests/tools/observability/check_ports.test.d.ts +1 -0
- package/dist/framework-mcp/tests/tools/observability/check_ports.test.js +30 -0
- package/dist/framework-mcp/tests/tools/observability/check_ports.test.js.map +1 -0
- package/dist/framework-mcp/tests/tools/shell/run_command.test.js +7 -0
- package/dist/framework-mcp/tests/tools/shell/run_command.test.js.map +1 -1
- package/dist/framework-mcp/tests/utils/auto-rollback.test.d.ts +7 -0
- package/dist/framework-mcp/tests/utils/auto-rollback.test.js +178 -0
- package/dist/framework-mcp/tests/utils/auto-rollback.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/context-optimizer.test.d.ts +1 -0
- package/dist/framework-mcp/tests/utils/context-optimizer.test.js +62 -0
- package/dist/framework-mcp/tests/utils/context-optimizer.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/finops.test.d.ts +7 -0
- package/dist/framework-mcp/tests/utils/finops.test.js +157 -0
- package/dist/framework-mcp/tests/utils/finops.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/human-in-loop.test.d.ts +1 -0
- package/dist/framework-mcp/tests/utils/human-in-loop.test.js +59 -0
- package/dist/framework-mcp/tests/utils/human-in-loop.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/license-scanner.test.d.ts +7 -0
- package/dist/framework-mcp/tests/utils/license-scanner.test.js +131 -0
- package/dist/framework-mcp/tests/utils/license-scanner.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/loop-detector.test.d.ts +7 -0
- package/dist/framework-mcp/tests/utils/loop-detector.test.js +204 -0
- package/dist/framework-mcp/tests/utils/loop-detector.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/rules-engine.test.d.ts +1 -0
- package/dist/framework-mcp/tests/utils/rules-engine.test.js +106 -0
- package/dist/framework-mcp/tests/utils/rules-engine.test.js.map +1 -0
- package/dist/framework-mcp/tests/utils/telemetry-streamer.test.d.ts +7 -0
- package/dist/framework-mcp/tests/utils/telemetry-streamer.test.js +201 -0
- package/dist/framework-mcp/tests/utils/telemetry-streamer.test.js.map +1 -0
- package/dist/src/cli/commands/check.js +16 -1
- package/dist/src/cli/commands/check.js.map +1 -1
- package/dist/src/cli/commands/dashboard.js +188 -164
- package/dist/src/cli/commands/dashboard.js.map +1 -1
- package/dist/src/cli/commands/gateway.js +2 -2
- package/dist/src/cli/commands/gateway.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-core.d.ts +2 -0
- package/dist/src/cli/commands/init/scaffold-core.js +16 -1
- package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-ops.js +2 -2
- package/dist/src/cli/commands/init/scaffold-ops.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-standards.js +13 -1
- package/dist/src/cli/commands/init/scaffold-standards.js.map +1 -1
- package/dist/src/cli/commands/init.d.ts +4 -0
- package/dist/src/cli/commands/init.js +80 -24
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/quickstart.d.ts +1 -1
- package/dist/src/cli/commands/quickstart.js +12 -24
- package/dist/src/cli/commands/quickstart.js.map +1 -1
- package/dist/src/cli/index.js +24 -23
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/shims.js +7 -7
- package/dist/src/cli/utils/pkg.js +2 -3
- package/dist/src/cli/utils/pkg.js.map +1 -1
- package/dist/src/cli/utils/quality.d.ts +10 -0
- package/dist/src/cli/utils/quality.js +10 -0
- package/dist/src/cli/utils/quality.js.map +1 -0
- package/dist/src/modules/agents/definitions.js +45 -40
- package/dist/src/modules/agents/definitions.js.map +1 -1
- package/dist/src/modules/agents/registry/manager.js +6 -1
- package/dist/src/modules/agents/registry/manager.js.map +1 -1
- package/dist/src/modules/engines/agent-executor.d.ts +6 -10
- package/dist/src/modules/engines/agent-executor.js +53 -21
- package/dist/src/modules/engines/agent-executor.js.map +1 -1
- package/dist/src/modules/engines/agent-loop.d.ts +34 -0
- package/dist/src/modules/engines/agent-loop.js +102 -0
- package/dist/src/modules/engines/agent-loop.js.map +1 -0
- package/dist/src/modules/engines/evaluation-engine.js +2 -2
- package/dist/src/modules/engines/evaluation-engine.js.map +1 -1
- package/dist/src/modules/engines/quality-gate.d.ts +13 -5
- package/dist/src/modules/engines/quality-gate.js +39 -31
- package/dist/src/modules/engines/quality-gate.js.map +1 -1
- package/dist/src/modules/engines/routing-engine.d.ts +5 -3
- package/dist/src/modules/engines/routing-engine.js +16 -9
- package/dist/src/modules/engines/routing-engine.js.map +1 -1
- package/dist/src/modules/gateway/cost-tracker.d.ts +5 -0
- package/dist/src/modules/gateway/cost-tracker.js +71 -0
- package/dist/src/modules/gateway/cost-tracker.js.map +1 -1
- package/dist/src/modules/gateway/gateway.d.ts +4 -0
- package/dist/src/modules/gateway/gateway.js +8 -0
- package/dist/src/modules/gateway/gateway.js.map +1 -1
- package/dist/src/shared/audit.js +3 -2
- package/dist/src/shared/audit.js.map +1 -1
- package/dist/src/shared/pii.d.ts +41 -9
- package/dist/src/shared/pii.js +122 -31
- package/dist/src/shared/pii.js.map +1 -1
- package/dist/src/shared/storage.d.ts +19 -0
- package/dist/src/shared/storage.js +46 -6
- package/dist/src/shared/storage.js.map +1 -1
- package/dist/tests/embedding.test.d.ts +1 -0
- package/dist/tests/embedding.test.js +82 -0
- package/dist/tests/embedding.test.js.map +1 -0
- package/dist/tests/engines/evaluation-engine.test.d.ts +1 -0
- package/dist/tests/engines/evaluation-engine.test.js +71 -0
- package/dist/tests/engines/evaluation-engine.test.js.map +1 -0
- package/dist/tests/engines/planning-engine.test.d.ts +1 -0
- package/dist/tests/engines/planning-engine.test.js +100 -0
- package/dist/tests/engines/planning-engine.test.js.map +1 -0
- package/dist/tests/engines/quality-gate.test.d.ts +1 -0
- package/dist/tests/engines/quality-gate.test.js +59 -0
- package/dist/tests/engines/quality-gate.test.js.map +1 -0
- package/dist/tests/engines/risk-engine.test.d.ts +1 -0
- package/dist/tests/engines/risk-engine.test.js +80 -0
- package/dist/tests/engines/risk-engine.test.js.map +1 -0
- package/dist/tests/engines/routing-engine.test.d.ts +1 -0
- package/dist/tests/engines/routing-engine.test.js +78 -0
- package/dist/tests/engines/routing-engine.test.js.map +1 -0
- package/dist/tests/integration/hermes_locking.test.js +1 -0
- package/dist/tests/integration/hermes_locking.test.js.map +1 -1
- package/dist/tests/modules/gateway/cost-tracker.test.js +20 -1
- package/dist/tests/modules/gateway/cost-tracker.test.js.map +1 -1
- package/dist/tests/shared/lock.test.d.ts +1 -0
- package/dist/tests/shared/lock.test.js +95 -0
- package/dist/tests/shared/lock.test.js.map +1 -0
- package/dist/tests/shared/pii.test.d.ts +1 -0
- package/dist/tests/shared/pii.test.js +183 -0
- package/dist/tests/shared/pii.test.js.map +1 -0
- package/framework-mcp/README.md +307 -35
- package/framework-mcp/dist/dashboard/assets/index-B2mYld0c.js +1221 -0
- package/framework-mcp/dist/dashboard/index.html +1 -1
- package/framework-mcp/dist/framework-mcp/src/index.js +914 -62
- package/framework-mcp/dist/framework-mcp/src/tools/compliance/mask_pii.js +55 -0
- package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +10 -9
- package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +25 -0
- package/framework-mcp/dist/framework-mcp/src/tools/index.js +7 -8
- package/framework-mcp/dist/framework-mcp/src/tools/messaging/approve_operation.js +80 -0
- package/framework-mcp/dist/framework-mcp/src/tools/messaging/ask_human.js +89 -20
- package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +3 -1
- package/framework-mcp/dist/framework-mcp/src/tools/quality/analyze_code_quality.js +13 -64
- package/framework-mcp/dist/framework-mcp/src/tools/schemas.js +18 -22
- package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +10 -0
- package/framework-mcp/dist/framework-mcp/src/tools/types.js +1 -0
- package/framework-mcp/dist/framework-mcp/src/utils/auth.js +78 -0
- package/framework-mcp/dist/framework-mcp/src/utils/auto-rollback.js +265 -0
- package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +12 -4
- package/framework-mcp/dist/framework-mcp/src/utils/context-optimizer.js +156 -0
- package/framework-mcp/dist/framework-mcp/src/utils/discipline.js +217 -0
- package/framework-mcp/dist/framework-mcp/src/utils/finops.js +325 -0
- package/framework-mcp/dist/framework-mcp/src/utils/human-in-loop.js +215 -0
- package/framework-mcp/dist/framework-mcp/src/utils/license-scanner.js +283 -0
- package/framework-mcp/dist/framework-mcp/src/utils/loop-detector.js +361 -0
- package/framework-mcp/dist/framework-mcp/src/utils/quality.js +123 -0
- package/framework-mcp/dist/framework-mcp/src/utils/rules-engine.js +231 -0
- package/framework-mcp/dist/framework-mcp/src/utils/silent-router.js +128 -0
- package/framework-mcp/dist/framework-mcp/src/utils/storage.js +2 -2
- package/framework-mcp/dist/framework-mcp/src/utils/telemetry-streamer.js +396 -0
- package/framework-mcp/dist/src/cli/platforms/core.js +72 -0
- package/framework-mcp/dist/src/cli/platforms/index.js +5 -0
- package/framework-mcp/dist/src/cli/platforms/paths.js +101 -0
- package/framework-mcp/dist/src/cli/platforms/scaffold.js +72 -0
- package/framework-mcp/dist/src/cli/platforms/utils.js +75 -0
- package/framework-mcp/dist/src/cli/utils/claude.js +57 -0
- package/framework-mcp/dist/src/cli/utils/compliance.js +12 -0
- package/framework-mcp/dist/src/cli/utils/fs.js +138 -0
- package/framework-mcp/dist/src/cli/utils/pkg.js +282 -0
- package/framework-mcp/dist/src/cli/utils/quality.js +9 -0
- package/framework-mcp/dist/src/modules/agents/definitions.js +563 -0
- package/framework-mcp/dist/src/modules/agents/registry/analyst.js +39 -0
- package/framework-mcp/dist/src/modules/agents/registry/architect.js +42 -0
- package/framework-mcp/dist/src/modules/agents/registry/backend.js +50 -0
- package/framework-mcp/dist/src/modules/agents/registry/database.js +45 -0
- package/framework-mcp/dist/src/modules/agents/registry/devops.js +45 -0
- package/framework-mcp/dist/src/modules/agents/registry/explorer.js +37 -0
- package/framework-mcp/dist/src/modules/agents/registry/frontend.js +52 -0
- package/framework-mcp/dist/src/modules/agents/registry/git.js +36 -0
- package/framework-mcp/dist/src/modules/agents/registry/manager.js +64 -0
- package/framework-mcp/dist/src/modules/agents/registry/mobile.js +41 -0
- package/framework-mcp/dist/src/modules/agents/registry/native.js +41 -0
- package/framework-mcp/dist/src/modules/agents/registry/quality.js +43 -0
- package/framework-mcp/dist/src/modules/agents/registry/security.js +42 -0
- package/framework-mcp/dist/src/modules/agents/types.js +1 -0
- package/framework-mcp/dist/src/modules/engines/quality-gate.js +92 -0
- package/framework-mcp/dist/src/modules/engines/risk-engine.js +105 -0
- package/framework-mcp/dist/src/modules/engines/routing-engine.js +408 -0
- package/framework-mcp/dist/src/modules/engines/types.js +1 -0
- package/framework-mcp/dist/src/modules/providers/definitions.js +140 -0
- package/framework-mcp/dist/src/modules/providers/registry.js +18 -0
- package/framework-mcp/dist/src/modules/providers/shared.js +104 -0
- package/framework-mcp/dist/src/modules/providers/types.js +1 -0
- package/framework-mcp/dist/src/modules/skills/adapter-skills.js +449 -0
- package/framework-mcp/dist/src/modules/skills/definitions.js +70 -0
- package/framework-mcp/dist/src/shared/audit.js +220 -0
- package/framework-mcp/dist/src/shared/errors.js +68 -0
- package/framework-mcp/dist/src/shared/lock.js +159 -0
- package/framework-mcp/dist/src/shared/pii.js +122 -31
- package/framework-mcp/dist/src/shared/retention.js +170 -0
- package/framework-mcp/dist/src/shared/storage.js +46 -6
- package/framework-mcp/dist/src/shared/string.js +29 -0
- package/framework-mcp/package.json +8 -2
- package/mcp.json +11 -6
- package/package.json +13 -6
- package/templates/full/ATABEY_FULL.md +1 -1
- package/framework-mcp/dist/dashboard/assets/index-BAPGLiWE.js +0 -267
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { writeTextFile } from "./fs.js";
|
|
4
|
+
import { UI } from "./ui.js";
|
|
5
|
+
/**
|
|
6
|
+
* Finds the Claude config file path (if it exists).
|
|
7
|
+
*/
|
|
8
|
+
export function findClaudeConfigPath() {
|
|
9
|
+
const home = process.env.HOME || process.env.USERPROFILE;
|
|
10
|
+
if (!home)
|
|
11
|
+
return null;
|
|
12
|
+
const possiblePaths = [
|
|
13
|
+
// Claude Desktop
|
|
14
|
+
path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"), // macOS Claude Desktop
|
|
15
|
+
path.join(home, "AppData", "Roaming", "Claude", "claude_desktop_config.json"), // Windows Claude Desktop
|
|
16
|
+
// Claude Code CLI
|
|
17
|
+
path.join(home, ".claude.json"), // Global Claude Code CLI MCP config
|
|
18
|
+
// Legacy or system-specific paths
|
|
19
|
+
path.join(home, ".config", "claude", "config.json"),
|
|
20
|
+
path.join(home, ".claude", "config.json"),
|
|
21
|
+
path.join(home, "Library", "Application Support", "Claude Code", "config.json"),
|
|
22
|
+
path.join(home, ".config", "Claude", "config.json"),
|
|
23
|
+
];
|
|
24
|
+
for (const p of possiblePaths) {
|
|
25
|
+
if (fs.existsSync(p)) {
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Adds or updates an MCP server entry in Claude's config file.
|
|
33
|
+
*/
|
|
34
|
+
export function addMcpServerToClaude(configPath, serverName, serverConfig) {
|
|
35
|
+
try {
|
|
36
|
+
let config = { mcpServers: {} };
|
|
37
|
+
if (fs.existsSync(configPath)) {
|
|
38
|
+
const content = fs.readFileSync(configPath, "utf8");
|
|
39
|
+
config = JSON.parse(content);
|
|
40
|
+
}
|
|
41
|
+
if (!config.mcpServers) {
|
|
42
|
+
config.mcpServers = {};
|
|
43
|
+
}
|
|
44
|
+
config.mcpServers[serverName] = serverConfig;
|
|
45
|
+
// Ensure parent directory exists
|
|
46
|
+
const dir = path.dirname(configPath);
|
|
47
|
+
if (!fs.existsSync(dir)) {
|
|
48
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
writeTextFile(configPath, JSON.stringify(config, null, 2));
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
UI.warning(` Failed to add MCP server to Claude config at ${configPath}: ${e}`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compliance utilities for Agent Atabey.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: The primary compliance scanner lives in framework-mcp:
|
|
5
|
+
* framework-mcp/src/utils/compliance.ts
|
|
6
|
+
*
|
|
7
|
+
* This file re-exports the framework-mcp version for CLI compatibility.
|
|
8
|
+
* If you need to modify compliance logic, edit framework-mcp/src/utils/compliance.ts
|
|
9
|
+
* instead of this file.
|
|
10
|
+
*/
|
|
11
|
+
// Re-export everything from framework-mcp's compliance module
|
|
12
|
+
export { isHighRiskOperation, scanProjectCompliance, verifyCorporateCompliance, verifyRiskAndAwaitApproval } from "../../../framework-mcp/src/utils/compliance.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { appendFile, ensureDir, writeJsonFile, writeTextFile } from "../../shared/fs.js";
|
|
5
|
+
import { remapFrameworkContent } from "../platforms/index.js";
|
|
6
|
+
import { UI } from "./ui.js";
|
|
7
|
+
export { appendFile, ensureDir, writeJsonFile, writeTextFile };
|
|
8
|
+
export function updateGitIgnore(targetPath, frameworkDir = ".atabey", dryRun = false) {
|
|
9
|
+
const IGNORE_LINES = [
|
|
10
|
+
"# Agent Atabey",
|
|
11
|
+
`${frameworkDir}/logs/*.json`,
|
|
12
|
+
`${frameworkDir}/*.lock`,
|
|
13
|
+
`${frameworkDir}/memory/`,
|
|
14
|
+
".env",
|
|
15
|
+
".DS_Store",
|
|
16
|
+
];
|
|
17
|
+
let content = "";
|
|
18
|
+
if (fs.existsSync(targetPath)) {
|
|
19
|
+
content = fs.readFileSync(targetPath, "utf8");
|
|
20
|
+
}
|
|
21
|
+
const lines = content.split("\n").map((l) => l.trim());
|
|
22
|
+
let added = false;
|
|
23
|
+
for (const line of IGNORE_LINES) {
|
|
24
|
+
if (!lines.includes(line)) {
|
|
25
|
+
content += (content.endsWith("\n") || content === "" ? "" : "\n") + line + "\n";
|
|
26
|
+
added = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (added) {
|
|
30
|
+
if (dryRun) {
|
|
31
|
+
UI.info(`[DRY RUN] Would update .gitignore at ${targetPath}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
writeTextFile(targetPath, content);
|
|
35
|
+
UI.success(" .gitignore updated.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function copyDir(src, dest, skipSet = new Set(), nonDestructive = false, frameworkDir = ".gemini", targetScope = "", sanitizeJson, adapterId = "gemini", dryRun = false) {
|
|
40
|
+
const DEFAULT_SKIP = new Set(["node_modules", ".git", ".DS_Store", "package-lock.json"]);
|
|
41
|
+
const actualSkip = new Set([...DEFAULT_SKIP, ...skipSet]);
|
|
42
|
+
if (!fs.existsSync(dest) && !dryRun) {
|
|
43
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
fs.readdirSync(src, { withFileTypes: true }).forEach((entry) => {
|
|
46
|
+
if (actualSkip.has(entry.name))
|
|
47
|
+
return;
|
|
48
|
+
const srcPath = path.join(src, entry.name);
|
|
49
|
+
// Physical folder remapping during copy.
|
|
50
|
+
// In unified mode (frameworkDir === ".atabey") folder names are always standard —
|
|
51
|
+
// agents/ stays agents/, knowledge/ stays knowledge/.
|
|
52
|
+
// Only remap when using a legacy non-unified adapter directory.
|
|
53
|
+
let effectiveEntryName = entry.name;
|
|
54
|
+
if (entry.isDirectory() && frameworkDir !== ".atabey") {
|
|
55
|
+
if (entry.name === "agents") {
|
|
56
|
+
if (adapterId === "antigravity-cli")
|
|
57
|
+
effectiveEntryName = "skills";
|
|
58
|
+
else if (adapterId === "grok")
|
|
59
|
+
effectiveEntryName = "plugins";
|
|
60
|
+
}
|
|
61
|
+
else if (entry.name === "knowledge") {
|
|
62
|
+
if (adapterId === "antigravity-cli")
|
|
63
|
+
effectiveEntryName = "rules";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const destPath = path.join(dest, effectiveEntryName);
|
|
67
|
+
if (entry.isDirectory()) {
|
|
68
|
+
copyDir(srcPath, destPath, skipSet, nonDestructive, frameworkDir, targetScope, sanitizeJson, adapterId, dryRun);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (nonDestructive && fs.existsSync(destPath)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const ext = path.extname(entry.name);
|
|
75
|
+
const textExtensions = [".md", ".json", ".js", ".ts", ".txt", ""];
|
|
76
|
+
if (textExtensions.includes(ext)) {
|
|
77
|
+
let content = fs.readFileSync(srcPath, "utf8");
|
|
78
|
+
content = remapFrameworkContent(content, frameworkDir, adapterId); // Use the new remap function
|
|
79
|
+
if (ext === ".json") {
|
|
80
|
+
try {
|
|
81
|
+
const json = JSON.parse(content);
|
|
82
|
+
writeJsonFile(destPath, sanitizeJson(json, targetScope), dryRun);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
const fallback = content.replace(/workspace:[^"'\s]*/g, "*");
|
|
86
|
+
writeTextFile(destPath, fallback, dryRun);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
content = content.replace(/workspace:[^"'\s]*/g, "*");
|
|
91
|
+
content = remapFrameworkContent(content, frameworkDir, adapterId); // Apply remap once to the final content
|
|
92
|
+
writeTextFile(destPath, content, dryRun);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (dryRun) {
|
|
97
|
+
UI.info(`[DRY RUN] Would copy binary file: ${destPath}`);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
fs.copyFileSync(srcPath, destPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function collectFiles(dir, extensions) {
|
|
107
|
+
let results = [];
|
|
108
|
+
if (!fs.existsSync(dir))
|
|
109
|
+
return results;
|
|
110
|
+
const list = fs.readdirSync(dir);
|
|
111
|
+
list.forEach((file) => {
|
|
112
|
+
file = path.join(dir, file);
|
|
113
|
+
const stat = fs.statSync(file);
|
|
114
|
+
if (stat && stat.isDirectory()) {
|
|
115
|
+
if (!file.includes("node_modules") && !file.includes(".git")) {
|
|
116
|
+
results = results.concat(collectFiles(file, extensions));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (extensions.includes(path.extname(file))) {
|
|
120
|
+
results.push(file);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return results;
|
|
124
|
+
}
|
|
125
|
+
export function computeTypesHash(projectRoot, sharedDir) {
|
|
126
|
+
const walk = (d) => fs.readdirSync(d, { withFileTypes: true }).flatMap((e) => {
|
|
127
|
+
const fullPath = path.join(d, e.name);
|
|
128
|
+
return e.isDirectory() ? walk(fullPath) : (e.name.endsWith(".ts") ? [fullPath] : []);
|
|
129
|
+
});
|
|
130
|
+
const hash = crypto.createHash("sha256");
|
|
131
|
+
for (const filePath of walk(sharedDir).sort()) {
|
|
132
|
+
hash.update(path.relative(projectRoot, filePath));
|
|
133
|
+
hash.update("\0");
|
|
134
|
+
hash.update(fs.readFileSync(filePath));
|
|
135
|
+
hash.update("\0");
|
|
136
|
+
}
|
|
137
|
+
return hash.digest("hex");
|
|
138
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { writeJsonFile, writeTextFile } from "./fs.js";
|
|
4
|
+
import { UI } from "./ui.js";
|
|
5
|
+
export function getPackageVersion() {
|
|
6
|
+
const root = getPackageRoot();
|
|
7
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
8
|
+
return pkg.version;
|
|
9
|
+
}
|
|
10
|
+
export function getPackageManager() {
|
|
11
|
+
const override = process.env.ATABEY_PACKAGE_MANAGER;
|
|
12
|
+
if (override)
|
|
13
|
+
return override.toLowerCase();
|
|
14
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
15
|
+
const npmExecPath = process.env.npm_execpath || "";
|
|
16
|
+
if (userAgent.includes("pnpm") || npmExecPath.includes("pnpm"))
|
|
17
|
+
return "pnpm";
|
|
18
|
+
if (userAgent.includes("yarn") || npmExecPath.includes("yarn"))
|
|
19
|
+
return "yarn";
|
|
20
|
+
// Check for lockfiles in target directory
|
|
21
|
+
if (fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml")) || fs.existsSync(path.join(process.cwd(), "pnpm-workspace.yaml")))
|
|
22
|
+
return "pnpm";
|
|
23
|
+
if (fs.existsSync(path.join(process.cwd(), "yarn.lock")))
|
|
24
|
+
return "yarn";
|
|
25
|
+
return "npm";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Robustly locates the atabey package root from the currently executing module (src via tsx or bin).
|
|
29
|
+
* Walks up from import.meta.url until it finds package.json with name === "atabey".
|
|
30
|
+
* This ensures getValidatorPath() and getPackageVersion() work correctly both in source tree
|
|
31
|
+
* AND when the package is consumed from node_modules after `npm install atabey` (global or local).
|
|
32
|
+
* Critical for AL validation (validate-al-registry) and cross-adapter inits to work from npm.
|
|
33
|
+
*/
|
|
34
|
+
function findAgentAtabeyPackageRoot() {
|
|
35
|
+
let current = path.dirname(new URL(import.meta.url).pathname);
|
|
36
|
+
const root = path.parse(current).root;
|
|
37
|
+
while (current !== root) {
|
|
38
|
+
if (path.basename(current) === "dist") {
|
|
39
|
+
current = path.dirname(current);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const pkgPath = path.join(current, "package.json");
|
|
43
|
+
if (fs.existsSync(pkgPath)) {
|
|
44
|
+
try {
|
|
45
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
46
|
+
if (pkg.name === "atabey") {
|
|
47
|
+
return current;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// ignore parse errors on intermediate package.jsons (e.g. user's project), continue
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
current = path.dirname(current);
|
|
55
|
+
}
|
|
56
|
+
// Fallback maintains prior behavior for unusual layouts
|
|
57
|
+
const __filenameLocal = new URL(import.meta.url).pathname;
|
|
58
|
+
const __dirnameLocal = path.dirname(__filenameLocal);
|
|
59
|
+
return path.join(__dirnameLocal, "../../..");
|
|
60
|
+
}
|
|
61
|
+
export function getPackageRoot() {
|
|
62
|
+
return findAgentAtabeyPackageRoot();
|
|
63
|
+
}
|
|
64
|
+
export function getValidatorPath() {
|
|
65
|
+
return path.join(getPackageRoot(), "bin", "validate-al-registry.js");
|
|
66
|
+
}
|
|
67
|
+
export function getDependencyVersions() {
|
|
68
|
+
const root = getPackageRoot();
|
|
69
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
70
|
+
const devDependencies = pkg.devDependencies || {};
|
|
71
|
+
const dependencies = pkg.dependencies || {};
|
|
72
|
+
return {
|
|
73
|
+
// ── Backend Core ──────────────────────────────────────────
|
|
74
|
+
"fastify": dependencies["fastify"] || "^5.0.0",
|
|
75
|
+
"@fastify/cors": dependencies["@fastify/cors"] || "^11.0.0",
|
|
76
|
+
"@fastify/swagger": dependencies["@fastify/swagger"] || "^9.0.0",
|
|
77
|
+
"@fastify/swagger-ui": dependencies["@fastify/swagger-ui"] || "^5.0.0",
|
|
78
|
+
"@fastify/rate-limit": dependencies["@fastify/rate-limit"] || "^10.0.0",
|
|
79
|
+
"@fastify/static": dependencies["@fastify/static"] || "^8.0.0",
|
|
80
|
+
"zod": dependencies["zod"] || "^3.24.2",
|
|
81
|
+
// ── Database / ORM ────────────────────────────────────────
|
|
82
|
+
"kysely": dependencies["kysely"] || "^0.27.0",
|
|
83
|
+
"typeorm": dependencies["typeorm"] || "^0.3.0",
|
|
84
|
+
"reflect-metadata": dependencies["reflect-metadata"] || "^0.2.0",
|
|
85
|
+
"pg": dependencies["pg"] || "^8.13.0",
|
|
86
|
+
"better-sqlite3": dependencies["better-sqlite3"] || "^11.0.0",
|
|
87
|
+
// ── Authentication ────────────────────────────────────────
|
|
88
|
+
"bcrypt": dependencies["bcrypt"] || "^5.1.0",
|
|
89
|
+
"@types/bcrypt": devDependencies["@types/bcrypt"] || "^5.0.0",
|
|
90
|
+
"jsonwebtoken": dependencies["jsonwebtoken"] || "^9.0.0",
|
|
91
|
+
"@types/jsonwebtoken": devDependencies["@types/jsonwebtoken"] || "^9.0.0",
|
|
92
|
+
// ── Logging ───────────────────────────────────────────────
|
|
93
|
+
"pino": dependencies["pino"] || "^9.0.0",
|
|
94
|
+
"pino-pretty": devDependencies["pino-pretty"] || "^12.0.0",
|
|
95
|
+
// ── Validation ────────────────────────────────────────────
|
|
96
|
+
"@fastify/type-provider-typebox": dependencies["@fastify/type-provider-typebox"] || "^5.0.0",
|
|
97
|
+
// Backend devDependencies
|
|
98
|
+
"@types/node": devDependencies["@types/node"] || "^22.13.4",
|
|
99
|
+
"tsx": devDependencies["tsx"] || "^4.19.4",
|
|
100
|
+
"typescript": devDependencies["typescript"] || "^5.9.3",
|
|
101
|
+
"vitest-backend": devDependencies["vitest"] || "^3.0.5",
|
|
102
|
+
// ── Frontend Core ─────────────────────────────────────────
|
|
103
|
+
"@vitejs/plugin-react": dependencies["@vitejs/plugin-react"] || "^5.0.0",
|
|
104
|
+
"vite": dependencies["vite"] || "^7.0.0",
|
|
105
|
+
"react": dependencies["react"] || "^19.0.0",
|
|
106
|
+
"react-dom": dependencies["react-dom"] || "^19.0.0",
|
|
107
|
+
"lucide-react": dependencies["lucide-react"] || "^0.468.0",
|
|
108
|
+
"react-router-dom": dependencies["react-router-dom"] || "^7.0.0",
|
|
109
|
+
"@tanstack/react-query": dependencies["@tanstack/react-query"] || "^5.0.0",
|
|
110
|
+
// Frontend devDependencies
|
|
111
|
+
"@types/react": devDependencies["@types/react"] || "^19.0.0",
|
|
112
|
+
"@types/react-dom": devDependencies["@types/react-dom"] || "^19.0.0",
|
|
113
|
+
"vitest-frontend": devDependencies["vitest"] || "^3.0.5",
|
|
114
|
+
// ── Testing ───────────────────────────────────────────────
|
|
115
|
+
"@playwright/test": devDependencies["@playwright/test"] || "^1.50.0",
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function mergePackageJson(targetPath, sourcePath) {
|
|
119
|
+
let targetPkg = {};
|
|
120
|
+
if (fs.existsSync(targetPath)) {
|
|
121
|
+
try {
|
|
122
|
+
targetPkg = JSON.parse(fs.readFileSync(targetPath, "utf8"));
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
UI.warning(" Could not parse existing package.json, creating a new one.");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const sourcePkg = JSON.parse(fs.readFileSync(sourcePath, "utf8"));
|
|
129
|
+
const sanitizeDeps = (deps) => {
|
|
130
|
+
if (!deps)
|
|
131
|
+
return deps;
|
|
132
|
+
const cleaned = {};
|
|
133
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
134
|
+
cleaned[name] = (typeof version === "string" && version.startsWith("workspace:")) ? "*" : String(version || "");
|
|
135
|
+
}
|
|
136
|
+
return cleaned;
|
|
137
|
+
};
|
|
138
|
+
const actualTargetScope = targetPkg.name && targetPkg.name.startsWith("@")
|
|
139
|
+
? targetPkg.name.split("/")[0]
|
|
140
|
+
: (targetPkg.name ? `@${targetPkg.name}` : "");
|
|
141
|
+
// Cleanup potential leftovers from previous bugged runs where atabey was renamed to target name
|
|
142
|
+
if (actualTargetScope) {
|
|
143
|
+
const scopeName = actualTargetScope.startsWith("@") ? actualTargetScope.slice(1) : actualTargetScope;
|
|
144
|
+
const cleanup = (obj) => {
|
|
145
|
+
if (!obj)
|
|
146
|
+
return;
|
|
147
|
+
delete obj[scopeName];
|
|
148
|
+
delete obj[actualTargetScope];
|
|
149
|
+
delete obj["atabey"]; // Will be re-added correctly
|
|
150
|
+
};
|
|
151
|
+
cleanup(targetPkg.devDependencies);
|
|
152
|
+
cleanup(targetPkg.dependencies);
|
|
153
|
+
}
|
|
154
|
+
targetPkg.dependencies = sanitizeDeps({
|
|
155
|
+
...targetPkg.dependencies,
|
|
156
|
+
...sourcePkg.dependencies
|
|
157
|
+
});
|
|
158
|
+
// Merge scripts
|
|
159
|
+
const pkgMgr = getPackageManager();
|
|
160
|
+
const runCmd = pkgMgr === "yarn" ? "yarn" : (pkgMgr === "pnpm" ? "pnpm" : "npm run");
|
|
161
|
+
targetPkg.scripts = {
|
|
162
|
+
...targetPkg.scripts,
|
|
163
|
+
"atabey:status": "atabey status",
|
|
164
|
+
"atabey:trace": "atabey trace:new",
|
|
165
|
+
"atabey:verify": "atabey verify-contract",
|
|
166
|
+
"atabey:check": "atabey check",
|
|
167
|
+
"atabey:test": "vitest run",
|
|
168
|
+
"atabey:test:watch": "vitest",
|
|
169
|
+
"atabey:build": `${runCmd} build --prefix framework-mcp`,
|
|
170
|
+
};
|
|
171
|
+
const sourceDevDeps = sourcePkg.devDependencies || {};
|
|
172
|
+
targetPkg.devDependencies = sanitizeDeps({
|
|
173
|
+
...targetPkg.devDependencies,
|
|
174
|
+
"atabey": `^${sourcePkg.version}`,
|
|
175
|
+
...(sourceDevDeps["@modelcontextprotocol/sdk"] ? { "@modelcontextprotocol/sdk": sourceDevDeps["@modelcontextprotocol/sdk"] } : {}),
|
|
176
|
+
...(sourceDevDeps["zod"] ? { "zod": sourceDevDeps["zod"] } : {}),
|
|
177
|
+
...(sourceDevDeps["ts-morph"] ? { "ts-morph": sourceDevDeps["ts-morph"] } : {}),
|
|
178
|
+
...(sourceDevDeps["typescript"] ? { "typescript": sourceDevDeps["typescript"] } : {}),
|
|
179
|
+
...(sourceDevDeps["@types/node"] ? { "@types/node": sourceDevDeps["@types/node"] } : {}),
|
|
180
|
+
...(sourceDevDeps["tsx"] ? { "tsx": sourceDevDeps["tsx"] } : {}),
|
|
181
|
+
...(sourceDevDeps["vitest"] ? { "vitest": sourceDevDeps["vitest"] } : {})
|
|
182
|
+
});
|
|
183
|
+
if (targetPkg.peerDependencies) {
|
|
184
|
+
targetPkg.peerDependencies = sanitizeDeps(targetPkg.peerDependencies);
|
|
185
|
+
}
|
|
186
|
+
if (targetPkg.optionalDependencies) {
|
|
187
|
+
targetPkg.optionalDependencies = sanitizeDeps(targetPkg.optionalDependencies);
|
|
188
|
+
}
|
|
189
|
+
// Ensure basic fields
|
|
190
|
+
if (!targetPkg.name)
|
|
191
|
+
targetPkg.name = path.basename(process.cwd());
|
|
192
|
+
if (!targetPkg.version)
|
|
193
|
+
targetPkg.version = "0.0.12";
|
|
194
|
+
if (!targetPkg.type)
|
|
195
|
+
targetPkg.type = "module";
|
|
196
|
+
// DO NOT add framework-mcp to workspaces in consumer projects
|
|
197
|
+
// if (!targetPkg.workspaces) targetPkg.workspaces = ["framework-mcp"];
|
|
198
|
+
// Add metadata
|
|
199
|
+
targetPkg.atabey = {
|
|
200
|
+
version: sourcePkg.version || "0.0.0",
|
|
201
|
+
initializedAt: new Date().toISOString(),
|
|
202
|
+
};
|
|
203
|
+
writeJsonFile(targetPath, targetPkg);
|
|
204
|
+
UI.success(" package.json updated with Atabey scripts and dependencies.");
|
|
205
|
+
}
|
|
206
|
+
export function sanitizeJson(obj, targetScope = "") {
|
|
207
|
+
if (typeof obj !== "object" || obj === null)
|
|
208
|
+
return obj;
|
|
209
|
+
if (Array.isArray(obj))
|
|
210
|
+
return obj.map(item => sanitizeJson(item, targetScope));
|
|
211
|
+
const cleaned = {};
|
|
212
|
+
const record = obj;
|
|
213
|
+
for (const [key, value] of Object.entries(record)) {
|
|
214
|
+
let finalKey = key;
|
|
215
|
+
let finalValue = value;
|
|
216
|
+
// Remove UnoCSS related keys or values
|
|
217
|
+
if (typeof key === "string" && key.includes("unocss"))
|
|
218
|
+
continue;
|
|
219
|
+
if (typeof value === "string" && value.includes("unocss")) {
|
|
220
|
+
continue; // Skip this script/field
|
|
221
|
+
}
|
|
222
|
+
// Replace scope if needed
|
|
223
|
+
if (targetScope) {
|
|
224
|
+
const scopeName = targetScope.startsWith("@") ? targetScope.slice(1) : targetScope;
|
|
225
|
+
// Handle scoped: @atabey/foo -> @target/foo
|
|
226
|
+
if (typeof key === "string" && key.startsWith("@atabey/")) {
|
|
227
|
+
finalKey = key.replace("@atabey/", `${targetScope}/`);
|
|
228
|
+
}
|
|
229
|
+
if (typeof value === "string" && value.startsWith("@atabey/")) {
|
|
230
|
+
finalValue = value.replace("@atabey/", `${targetScope}/`);
|
|
231
|
+
}
|
|
232
|
+
// Handle unscoped: atabey-foo -> target-foo
|
|
233
|
+
if (typeof key === "string" && key.startsWith("atabey-")) {
|
|
234
|
+
finalKey = key.replace("atabey-", `${scopeName}-`);
|
|
235
|
+
}
|
|
236
|
+
if (typeof value === "string" && value.startsWith("atabey-")) {
|
|
237
|
+
finalValue = value.replace("atabey-", `${scopeName}-`);
|
|
238
|
+
}
|
|
239
|
+
// Handle atabey -> target (ONLY for the package name)
|
|
240
|
+
if (key === "name" && value === "atabey") {
|
|
241
|
+
finalValue = scopeName;
|
|
242
|
+
}
|
|
243
|
+
// Preserve atabey in dependencies and bin
|
|
244
|
+
// (No action needed as finalKey/finalValue default to original)
|
|
245
|
+
if (typeof value === "string" && value.startsWith("workspace:")) {
|
|
246
|
+
finalValue = "*";
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else if (typeof value === "string" && value.startsWith("workspace:")) {
|
|
250
|
+
finalValue = "*";
|
|
251
|
+
}
|
|
252
|
+
cleaned[finalKey] = (typeof finalValue === "object" && finalValue !== null) ? sanitizeJson(finalValue, targetScope) : finalValue;
|
|
253
|
+
}
|
|
254
|
+
return cleaned;
|
|
255
|
+
}
|
|
256
|
+
export function deepCleanProtocols(dir, targetScope = "") {
|
|
257
|
+
if (!fs.existsSync(dir))
|
|
258
|
+
return;
|
|
259
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
260
|
+
for (const entry of entries) {
|
|
261
|
+
const fullPath = path.join(dir, entry.name);
|
|
262
|
+
if (entry.isDirectory()) {
|
|
263
|
+
if (entry.name === "node_modules" || entry.name === ".git")
|
|
264
|
+
continue;
|
|
265
|
+
deepCleanProtocols(fullPath, targetScope);
|
|
266
|
+
}
|
|
267
|
+
else if (entry.name === "package.json") {
|
|
268
|
+
try {
|
|
269
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
270
|
+
const json = JSON.parse(content);
|
|
271
|
+
const cleaned = JSON.stringify(sanitizeJson(json, targetScope), null, 2);
|
|
272
|
+
writeTextFile(fullPath, cleaned);
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// ignore malformed json
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else if (entry.name === "package-lock.json") {
|
|
279
|
+
fs.unlinkSync(fullPath);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Quality utilities for Agent Atabey.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: The primary quality scanner lives in framework-mcp:
|
|
5
|
+
* framework-mcp/src/utils/quality.ts
|
|
6
|
+
*
|
|
7
|
+
* This file re-exports the framework-mcp version for CLI compatibility.
|
|
8
|
+
*/
|
|
9
|
+
export { analyzePathQuality } from "../../../framework-mcp/src/utils/quality.js";
|