atabey 0.0.13 → 0.0.15
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/PRIVACY.md +8 -14
- package/README.md +405 -56
- package/bin/cli.js +72 -5
- package/dist/framework-mcp/src/index.js +988 -63
- 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.d.ts +1 -0
- package/dist/framework-mcp/src/tools/observability/check_ports.js +24 -8
- 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 +146 -90
- 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 +125 -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 +49 -0
- package/dist/framework-mcp/src/utils/silent-router.js +155 -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 +44 -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 +44 -14
- 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 +94 -31
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/mcp.js +3 -1
- package/dist/src/cli/commands/mcp.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/commands/script.js +8 -1
- package/dist/src/cli/commands/script.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 +63 -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.d.ts +12 -2
- package/dist/src/modules/engines/evaluation-engine.js +78 -11
- 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 +62 -0
- package/dist/src/shared/storage.js +47 -7
- 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/engines/agent-executor.test.js +1 -1
- package/dist/tests/modules/engines/agent-executor.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-B_rK57vi.js +1221 -0
- package/framework-mcp/dist/dashboard/index.html +1 -1
- package/framework-mcp/dist/framework-mcp/src/index.js +988 -63
- 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 +24 -8
- 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 +146 -90
- 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 +124 -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 +154 -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/evaluation-engine.js +169 -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 +47 -7
- package/framework-mcp/dist/src/shared/string.js +29 -0
- package/framework-mcp/package.json +8 -2
- package/mcp.json +12 -6
- package/package.json +11 -5
- package/templates/full/ATABEY_FULL.md +1 -1
- package/framework-mcp/dist/dashboard/assets/index-BAPGLiWE.js +0 -267
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Shared Code Quality Heuristic Scanner
|
|
5
|
+
* Evaluates functions lengths, nesting depth, and usage of the forbidden 'any' type.
|
|
6
|
+
*/
|
|
7
|
+
export function analyzePathQuality(projectRoot, targetPath) {
|
|
8
|
+
const absolutePath = path.resolve(projectRoot, targetPath);
|
|
9
|
+
const files = [];
|
|
10
|
+
function collectFilesSync(dir, exts) {
|
|
11
|
+
if (!fs.existsSync(dir))
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
const stat = fs.statSync(dir);
|
|
15
|
+
if (stat.isFile()) {
|
|
16
|
+
if (exts.some(ext => dir.endsWith(ext))) {
|
|
17
|
+
files.push(dir);
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const fullPath = path.join(dir, entry.name);
|
|
24
|
+
if (entry.isDirectory() && !entry.name.startsWith("node_modules") && !entry.name.startsWith(".")) {
|
|
25
|
+
collectFilesSync(fullPath, exts);
|
|
26
|
+
}
|
|
27
|
+
else if (entry.isFile() && exts.some(ext => entry.name.endsWith(ext))) {
|
|
28
|
+
files.push(fullPath);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Ignore errors reading files/dirs
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
collectFilesSync(absolutePath, [".ts", ".tsx"]);
|
|
37
|
+
const issues = [];
|
|
38
|
+
let longFunctions = 0;
|
|
39
|
+
let deepNesting = 0;
|
|
40
|
+
let anyTypes = 0;
|
|
41
|
+
files.forEach((f) => {
|
|
42
|
+
try {
|
|
43
|
+
const content = fs.readFileSync(f, "utf8");
|
|
44
|
+
const lines = content.split("\n");
|
|
45
|
+
const relativePath = path.relative(projectRoot, f);
|
|
46
|
+
// Check for `any` type
|
|
47
|
+
lines.forEach((line, idx) => {
|
|
48
|
+
if (line.trim().startsWith("//") || line.trim().startsWith("/*"))
|
|
49
|
+
return;
|
|
50
|
+
if (line.match(/\bany\b/) && !line.includes("// eslint-disable") && !line.includes("as any")) {
|
|
51
|
+
anyTypes++;
|
|
52
|
+
issues.push({
|
|
53
|
+
file: relativePath,
|
|
54
|
+
line: idx + 1,
|
|
55
|
+
type: "any-type",
|
|
56
|
+
message: `Line ${idx + 1}: Usage of 'any' type`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
// Check for long functions
|
|
61
|
+
let inFunction = false;
|
|
62
|
+
let funcLines = 0;
|
|
63
|
+
let startLine = 0;
|
|
64
|
+
let funcName = "anonymous";
|
|
65
|
+
for (let i = 0; i < lines.length; i++) {
|
|
66
|
+
const line = lines[i];
|
|
67
|
+
// Detect function/method starts using regex
|
|
68
|
+
const funcMatch = line.match(/(?:public|private|protected|static\s+)?(?:async\s+)?(?:function\s+)?(\w+)\s*\([^)]*\)\s*{/);
|
|
69
|
+
const methodMatch = !funcMatch ? line.match(/^\s*(?:public|private|protected|static\s+)?(\w+)\s*\([^)]*\)\s*{/) : null;
|
|
70
|
+
const arrowMatch = !funcMatch && !methodMatch ? line.match(/(?:const|let|var)?\s*(\w+)?\s*=\s*(?:async\s*)?\([^)]*\)\s*=>\s*{/) : null;
|
|
71
|
+
if (funcMatch || methodMatch || arrowMatch) {
|
|
72
|
+
inFunction = true;
|
|
73
|
+
funcLines = 1;
|
|
74
|
+
startLine = i + 1;
|
|
75
|
+
funcName = (funcMatch?.[1] || methodMatch?.[1] || arrowMatch?.[1] || "anonymous").trim();
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (inFunction) {
|
|
79
|
+
funcLines++;
|
|
80
|
+
if (line.includes("}")) {
|
|
81
|
+
if (funcLines > 50) {
|
|
82
|
+
longFunctions++;
|
|
83
|
+
issues.push({
|
|
84
|
+
file: relativePath,
|
|
85
|
+
line: startLine,
|
|
86
|
+
type: "complexity",
|
|
87
|
+
message: `Function '${funcName}' is ${funcLines} lines long (max: 50)`
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
inFunction = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Check nesting depth
|
|
95
|
+
lines.forEach((line, idx) => {
|
|
96
|
+
const leadingSpaces = line.match(/^(\s*)/)?.[0].length || 0;
|
|
97
|
+
if (leadingSpaces >= 10 && !line.trim().startsWith("//") && !line.trim().startsWith("*")) {
|
|
98
|
+
const indentSize = (leadingSpaces % 4 === 0) ? 4 : 2;
|
|
99
|
+
const depth = Math.floor(leadingSpaces / indentSize);
|
|
100
|
+
if (depth > 4) {
|
|
101
|
+
deepNesting++;
|
|
102
|
+
issues.push({
|
|
103
|
+
file: relativePath,
|
|
104
|
+
line: idx + 1,
|
|
105
|
+
type: "complexity",
|
|
106
|
+
message: `Line ${idx + 1}: Nesting depth ${depth}`
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Ignore files that can't be read
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
totalFiles: files.length,
|
|
118
|
+
totalIssues: issues.length,
|
|
119
|
+
longFunctions,
|
|
120
|
+
deepNesting,
|
|
121
|
+
anyTypes,
|
|
122
|
+
issues
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─── RULES ENGINE (Prompt Conflict Resolution) ────────────────────
|
|
3
|
+
*
|
|
4
|
+
* Resolves conflicts between AI CLI built-in prompts and Atabey governance rules.
|
|
5
|
+
* Ensures Atabey's critical rules ALWAYS override CLI-level instructions.
|
|
6
|
+
*
|
|
7
|
+
* Priority System:
|
|
8
|
+
* - CRITICAL (P0): Non-bypassable rules (zero any, no console.log, PII masking)
|
|
9
|
+
* - HIGH (P1): Important rules that should not be violated
|
|
10
|
+
* - MEDIUM (P2): Standard best practices
|
|
11
|
+
* - LOW (P3): Recommendations only
|
|
12
|
+
*
|
|
13
|
+
* Enforcement Mechanisms:
|
|
14
|
+
* 1. Pre-execution: Rule validation BEFORE tool runs
|
|
15
|
+
* 2. Post-execution: Scan changed files for violations → auto-rollback
|
|
16
|
+
* 3. CLI System Prompt Override: Inject critical rules at MCP initialization
|
|
17
|
+
*/
|
|
18
|
+
import path from "path";
|
|
19
|
+
// ─── Built-in Governance Rules ────────────────────────────────────
|
|
20
|
+
const GOVERNANCE_RULES = [
|
|
21
|
+
// ── CRITICAL (P0) Rules ────────────────────────────────────
|
|
22
|
+
{
|
|
23
|
+
id: "no-any-types",
|
|
24
|
+
name: "Zero Any Type Policy",
|
|
25
|
+
description: "TypeScript 'any' type is strictly forbidden",
|
|
26
|
+
priority: "CRITICAL",
|
|
27
|
+
detectPattern: /:\s*any\b/g,
|
|
28
|
+
appliesToExtensions: [".ts", ".tsx"],
|
|
29
|
+
errorMessage: "CRITICAL: 'any' type is forbidden. Use 'unknown' with proper type guards instead.",
|
|
30
|
+
bypassable: false,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "no-console-log",
|
|
34
|
+
name: "No Console Log",
|
|
35
|
+
description: "console.log/error/warn is forbidden (use logger instead)",
|
|
36
|
+
priority: "CRITICAL",
|
|
37
|
+
detectPattern: /console\.(log|error|warn|debug|info)\s*\(/g,
|
|
38
|
+
appliesToExtensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
39
|
+
errorMessage: "CRITICAL: console.log/error/warn is forbidden. Use the project's logger instead.",
|
|
40
|
+
bypassable: false,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "pii-masking",
|
|
44
|
+
name: "PII Masking Required",
|
|
45
|
+
description: "Sensitive data must be masked before logging or storing",
|
|
46
|
+
priority: "CRITICAL",
|
|
47
|
+
errorMessage: "CRITICAL: Detected potential PII in unmasked form. Use maskText() / maskObject() from pii.ts.",
|
|
48
|
+
bypassable: false,
|
|
49
|
+
},
|
|
50
|
+
// ── HIGH (P1) Rules ────────────────────────────────────────
|
|
51
|
+
{
|
|
52
|
+
id: "no-hardcoded-secrets",
|
|
53
|
+
name: "No Hardcoded Secrets",
|
|
54
|
+
description: "API keys, tokens, passwords must use environment variables",
|
|
55
|
+
priority: "HIGH",
|
|
56
|
+
detectPattern: /(['"])sk-[a-zA-Z0-9]{20,}['"]|(['"])ghp_[a-zA-Z0-9]{36,}['"]|(['"])AIza[0-9A-Za-z_-]{35}['"]/g,
|
|
57
|
+
appliesToExtensions: [".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".java", ".yaml", ".yml", ".env.example"],
|
|
58
|
+
errorMessage: "HIGH: Hardcoded API keys/tokens detected. Use environment variables (process.env.*).",
|
|
59
|
+
bypassable: false,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "no-commented-code",
|
|
63
|
+
name: "No Commented-Out Code",
|
|
64
|
+
description: "Dead code should be removed, not commented out",
|
|
65
|
+
priority: "HIGH",
|
|
66
|
+
detectPattern: /\/\/\s*.{10,}/g,
|
|
67
|
+
appliesToExtensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
68
|
+
errorMessage: "HIGH: Commented-out code detected. Remove dead code instead of commenting.",
|
|
69
|
+
bypassable: true,
|
|
70
|
+
},
|
|
71
|
+
// ── MEDIUM (P2) Rules ──────────────────────────────────────
|
|
72
|
+
{
|
|
73
|
+
id: "no-console-in-jsx",
|
|
74
|
+
name: "No Console in JSX",
|
|
75
|
+
description: "Avoid console statements inside JSX/TSX components",
|
|
76
|
+
priority: "MEDIUM",
|
|
77
|
+
detectPattern: /{.*console\.(log|error|warn)\(.*}/g,
|
|
78
|
+
appliesToExtensions: [".tsx", ".jsx"],
|
|
79
|
+
errorMessage: "MEDIUM: Console statement inside JSX detected. Move to event handler or useEffect.",
|
|
80
|
+
bypassable: true,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "i18n-usage",
|
|
84
|
+
name: "Internationalization Required",
|
|
85
|
+
description: "Use i18n for user-facing strings",
|
|
86
|
+
priority: "MEDIUM",
|
|
87
|
+
detectPattern: /(['"])([A-Z][a-z]+ [a-z]+ [a-z]+)['"]/g,
|
|
88
|
+
appliesToExtensions: [".tsx", ".jsx"],
|
|
89
|
+
errorMessage: "MEDIUM: User-facing string detected. Use i18n translation function instead.",
|
|
90
|
+
bypassable: true,
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
// ─── Rule Engine ──────────────────────────────────────────────────
|
|
94
|
+
let rulesMap = null;
|
|
95
|
+
function getRulesMap() {
|
|
96
|
+
if (!rulesMap) {
|
|
97
|
+
rulesMap = new Map();
|
|
98
|
+
for (const rule of GOVERNANCE_RULES) {
|
|
99
|
+
rulesMap.set(rule.id, rule);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return rulesMap;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get all governance rules.
|
|
106
|
+
*/
|
|
107
|
+
export function getAllRules() {
|
|
108
|
+
return [...GOVERNANCE_RULES];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get rules by priority level.
|
|
112
|
+
*/
|
|
113
|
+
export function getRulesByPriority(priority) {
|
|
114
|
+
return GOVERNANCE_RULES.filter(r => r.priority === priority);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get non-bypassable rules (CRITICAL + HIGH non-bypassable).
|
|
118
|
+
*/
|
|
119
|
+
export function getNonBypassableRules() {
|
|
120
|
+
return GOVERNANCE_RULES.filter(r => !r.bypassable);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Scan file content for rule violations.
|
|
124
|
+
* Returns array of violations found.
|
|
125
|
+
*/
|
|
126
|
+
export function scanFileForViolations(filePath, content) {
|
|
127
|
+
const ext = path.extname(filePath);
|
|
128
|
+
const violations = [];
|
|
129
|
+
const lines = content.split("\n");
|
|
130
|
+
for (const rule of GOVERNANCE_RULES) {
|
|
131
|
+
// Check if rule applies to this file extension
|
|
132
|
+
if (rule.appliesToExtensions && !rule.appliesToExtensions.includes(ext)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Check if rule has a detect pattern
|
|
136
|
+
if (!rule.detectPattern)
|
|
137
|
+
continue;
|
|
138
|
+
// Scan each line
|
|
139
|
+
for (let i = 0; i < lines.length; i++) {
|
|
140
|
+
const match = lines[i].match(rule.detectPattern);
|
|
141
|
+
if (match) {
|
|
142
|
+
violations.push({
|
|
143
|
+
rule,
|
|
144
|
+
match: match[0],
|
|
145
|
+
line: i + 1,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return violations;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Validate tool arguments against governance rules.
|
|
154
|
+
* Returns violation messages if any critical rule is violated.
|
|
155
|
+
*/
|
|
156
|
+
export function validateArgsAgainstRules(toolName, args) {
|
|
157
|
+
const nonBypassable = getNonBypassableRules();
|
|
158
|
+
for (const rule of nonBypassable) {
|
|
159
|
+
// Check if rule applies to this tool
|
|
160
|
+
if (rule.appliesToTools && !rule.appliesToTools.includes(toolName)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// For write_file and replace_text, check content for violations
|
|
164
|
+
if ((toolName === "write_file" || toolName === "replace_text") && args.content) {
|
|
165
|
+
const content = args.content;
|
|
166
|
+
const filePath = args.path || "unknown.ts";
|
|
167
|
+
const violations = scanFileForViolations(filePath, content);
|
|
168
|
+
if (violations.length > 0) {
|
|
169
|
+
const details = violations.map(v => ` Line ${v.line}: ${v.match} (${v.rule.name} - ${v.rule.priority})`).join("\n");
|
|
170
|
+
return [
|
|
171
|
+
`[GOVERNANCE] ${rule.priority} rule violation: ${rule.name}`,
|
|
172
|
+
`${rule.errorMessage}`,
|
|
173
|
+
"\nViolations:",
|
|
174
|
+
details,
|
|
175
|
+
].join("\n");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Validate tool response for governance violations.
|
|
183
|
+
* Returns violation messages if found.
|
|
184
|
+
*/
|
|
185
|
+
export function validateResponseAgainstRules(toolName, responseText) {
|
|
186
|
+
// For file reads, check if the content contains PII or secrets
|
|
187
|
+
if (toolName === "read_file" && responseText.length > 0) {
|
|
188
|
+
const criticalRules = getNonBypassableRules();
|
|
189
|
+
for (const rule of criticalRules) {
|
|
190
|
+
if (rule.detectPattern && rule.detectPattern.test(responseText)) {
|
|
191
|
+
return `[GOVERNANCE] ${rule.priority} violation detected in response: ${rule.name}. ${rule.errorMessage}`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Build system prompt override block for CLI initialization.
|
|
199
|
+
* This is injected into the AI's system prompt at MCP connect time.
|
|
200
|
+
*/
|
|
201
|
+
export function buildSystemPromptOverride() {
|
|
202
|
+
const criticalRules = getRulesByPriority("CRITICAL");
|
|
203
|
+
const highRules = getRulesByPriority("HIGH");
|
|
204
|
+
return [
|
|
205
|
+
"## [ATABEY GOVERNANCE] Critical Rules — DO NOT OVERRIDE",
|
|
206
|
+
"",
|
|
207
|
+
"The following rules are ENFORCED by the Atabey Governance Layer.",
|
|
208
|
+
"They CANNOT be bypassed or disabled.",
|
|
209
|
+
"",
|
|
210
|
+
"### Critical Rules (Non-Bypassable)",
|
|
211
|
+
...criticalRules.map(r => `- 🔴 ${r.name}: ${r.description}`),
|
|
212
|
+
"",
|
|
213
|
+
"### High Priority Rules",
|
|
214
|
+
...highRules.map(r => `- 🟠 ${r.name}: ${r.description}`),
|
|
215
|
+
"",
|
|
216
|
+
"> These rules are injected at the MCP middleware layer and enforced",
|
|
217
|
+
"> at both pre-execution and post-execution stages.",
|
|
218
|
+
"",
|
|
219
|
+
].join("\n");
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Add a custom governance rule at runtime.
|
|
223
|
+
*/
|
|
224
|
+
export function addRule(rule) {
|
|
225
|
+
const map = getRulesMap();
|
|
226
|
+
if (!map.has(rule.id)) {
|
|
227
|
+
GOVERNANCE_RULES.push(rule);
|
|
228
|
+
map.set(rule.id, rule);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export { GOVERNANCE_RULES as DefaultGovernanceRules };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─── SILENT ROUTER ─────────────────────────────────────────────────
|
|
3
|
+
*
|
|
4
|
+
* Automatically routes tool calls to the most appropriate agent
|
|
5
|
+
* WITHOUT requiring the developer to type `@agent` commands.
|
|
6
|
+
*
|
|
7
|
+
* The magic: developer types "Make this API secure" and Atabey
|
|
8
|
+
* silently activates @security agent rules behind the scenes.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Auto-agent detection from tool call context
|
|
12
|
+
* - Silent system prompt injection with specialty memory
|
|
13
|
+
* - Multi-agent chain support
|
|
14
|
+
* - Stealth notifications (stderr/dashboard only, never chat)
|
|
15
|
+
*/
|
|
16
|
+
import { EvaluationEngine } from "../../../src/modules/engines/evaluation-engine.js";
|
|
17
|
+
import { RoutingEngine } from "../../../src/modules/engines/routing-engine.js";
|
|
18
|
+
// ─── Configuration ────────────────────────────────────────────────
|
|
19
|
+
const CONFIG = {
|
|
20
|
+
/** Enable silent routing (default: true) */
|
|
21
|
+
ENABLED: process.env.MCP_SILENT_ROUTING !== "false",
|
|
22
|
+
/** Enable stealth notifications to stderr */
|
|
23
|
+
STEALTH_NOTIFY: process.env.MCP_SILENT_STEALTH !== "false",
|
|
24
|
+
/** Agent override via env (for testing/debugging) */
|
|
25
|
+
FORCE_AGENT: process.env.MCP_FORCE_AGENT || null,
|
|
26
|
+
/** Enable specialty memory injection into context */
|
|
27
|
+
INJECT_SPECIALTY_MEMORY: process.env.MCP_INJECT_SPECIALTY_MEMORY !== "false",
|
|
28
|
+
};
|
|
29
|
+
let agentRuleCache = null;
|
|
30
|
+
async function loadAgentRules() {
|
|
31
|
+
if (agentRuleCache)
|
|
32
|
+
return agentRuleCache;
|
|
33
|
+
try {
|
|
34
|
+
const { ALL_AGENTS } = await import("../../../src/modules/agents/definitions.js");
|
|
35
|
+
agentRuleCache = new Map();
|
|
36
|
+
for (const agent of ALL_AGENTS) {
|
|
37
|
+
agentRuleCache.set(agent.name, {
|
|
38
|
+
name: agent.name,
|
|
39
|
+
identity: agent.instructions.identity,
|
|
40
|
+
mission: agent.instructions.mission,
|
|
41
|
+
rules: agent.instructions.rules,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
agentRuleCache = new Map();
|
|
47
|
+
}
|
|
48
|
+
return agentRuleCache;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Detect the most appropriate agent for a given tool call and arguments.
|
|
52
|
+
* Uses RoutingEngine's TF-IDF matching on the args context.
|
|
53
|
+
*/
|
|
54
|
+
export function detectAgent(toolName, args) {
|
|
55
|
+
if (CONFIG.FORCE_AGENT)
|
|
56
|
+
return CONFIG.FORCE_AGENT;
|
|
57
|
+
const contextParts = [toolName];
|
|
58
|
+
for (const [, value] of Object.entries(args)) {
|
|
59
|
+
if (typeof value === "string") {
|
|
60
|
+
contextParts.push(value);
|
|
61
|
+
}
|
|
62
|
+
else if (Array.isArray(value)) {
|
|
63
|
+
contextParts.push(value.filter(v => typeof v === "string").join(" "));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const context = contextParts.join(" ").substring(0, 500);
|
|
67
|
+
return RoutingEngine.resolveAgent(context);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the system prompt rules for a given agent.
|
|
71
|
+
* Used to inject discipline silently into tool context.
|
|
72
|
+
*/
|
|
73
|
+
export async function getAgentPrompt(agentName) {
|
|
74
|
+
const rules = await loadAgentRules();
|
|
75
|
+
const agent = rules.get(agentName.replace("@", ""));
|
|
76
|
+
if (!agent)
|
|
77
|
+
return null;
|
|
78
|
+
return [
|
|
79
|
+
`## [ATABEY SILENT] ${agent.name} (${agent.identity})`,
|
|
80
|
+
"",
|
|
81
|
+
"### Mission",
|
|
82
|
+
`${agent.mission}`,
|
|
83
|
+
"",
|
|
84
|
+
"### Active Disciplines",
|
|
85
|
+
...agent.rules.map(r => `- ${r}`),
|
|
86
|
+
"",
|
|
87
|
+
"> These rules are injected by Atabey governance layer.",
|
|
88
|
+
"> They supplement (not replace) your existing instructions.",
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Load specialty memory for an agent and format it for injection.
|
|
93
|
+
*/
|
|
94
|
+
function getSpecialtyMemoryContext(agentName) {
|
|
95
|
+
if (!CONFIG.INJECT_SPECIALTY_MEMORY)
|
|
96
|
+
return null;
|
|
97
|
+
try {
|
|
98
|
+
const conventions = EvaluationEngine.readLearnedConventions(agentName);
|
|
99
|
+
if (!conventions)
|
|
100
|
+
return null;
|
|
101
|
+
return [
|
|
102
|
+
"",
|
|
103
|
+
"### Previously Learned Conventions",
|
|
104
|
+
`The following lessons were learned from past tasks for @${agentName}:`,
|
|
105
|
+
"",
|
|
106
|
+
conventions,
|
|
107
|
+
"",
|
|
108
|
+
].join("\n");
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Build a silent context injection payload.
|
|
116
|
+
* Injects agent rules + specialty memory into tool responses.
|
|
117
|
+
*/
|
|
118
|
+
export async function buildSilentContext(detectedAgent, toolName, responseText) {
|
|
119
|
+
if (!CONFIG.ENABLED)
|
|
120
|
+
return responseText;
|
|
121
|
+
const agentPrompt = await getAgentPrompt(detectedAgent);
|
|
122
|
+
if (!agentPrompt)
|
|
123
|
+
return responseText;
|
|
124
|
+
if (responseText.length < 50)
|
|
125
|
+
return responseText;
|
|
126
|
+
// Inject specialty memory if available
|
|
127
|
+
const specialtyContext = getSpecialtyMemoryContext(detectedAgent);
|
|
128
|
+
const fullPrompt = specialtyContext
|
|
129
|
+
? `${agentPrompt}\n${specialtyContext}`
|
|
130
|
+
: agentPrompt;
|
|
131
|
+
const injection = [
|
|
132
|
+
"",
|
|
133
|
+
`<!-- ATABEY_GOVERNANCE agent="${detectedAgent}" tool="${toolName}" -->`,
|
|
134
|
+
`${fullPrompt}`,
|
|
135
|
+
"<!-- /ATABEY_GOVERNANCE -->",
|
|
136
|
+
"",
|
|
137
|
+
].join("\n");
|
|
138
|
+
return injection + responseText;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Send a stealth notification to stderr (never to the chat).
|
|
142
|
+
*/
|
|
143
|
+
export function stealthNotify(agent, toolName, message) {
|
|
144
|
+
if (!CONFIG.STEALTH_NOTIFY)
|
|
145
|
+
return;
|
|
146
|
+
process.stderr.write(`[ATABEY:${agent}] ${message} (tool: ${toolName})\n`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get silent router config.
|
|
150
|
+
*/
|
|
151
|
+
export function getSilentRouterConfig() {
|
|
152
|
+
return { ...CONFIG };
|
|
153
|
+
}
|
|
154
|
+
export { CONFIG as SilentRouterConfig };
|
|
@@ -149,7 +149,6 @@ export class Storage {
|
|
|
149
149
|
let deps = [];
|
|
150
150
|
try {
|
|
151
151
|
const parsed = JSON.parse(r.dependencies || "[]");
|
|
152
|
-
// Handle cases where dependencies might be double-stringified or are raw JSON strings
|
|
153
152
|
deps = Array.isArray(parsed) ? parsed : JSON.parse(parsed);
|
|
154
153
|
}
|
|
155
154
|
catch {
|
|
@@ -162,7 +161,8 @@ export class Storage {
|
|
|
162
161
|
agent: r.agent,
|
|
163
162
|
status: r.status,
|
|
164
163
|
priority: r.priority,
|
|
165
|
-
dependencies: deps
|
|
164
|
+
dependencies: deps,
|
|
165
|
+
createdAt: r.created_at
|
|
166
166
|
};
|
|
167
167
|
});
|
|
168
168
|
}
|