atabey 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/cli/adapters/core.js +12 -19
- package/dist/src/cli/adapters/core.js.map +1 -1
- package/dist/src/shared/constants.d.ts +1 -0
- package/dist/src/shared/constants.js +1 -0
- package/dist/src/shared/constants.js.map +1 -1
- package/dist/tests/adapter.test.js +3 -2
- package/dist/tests/adapter.test.js.map +1 -1
- package/framework-mcp/dist/constants.js +64 -0
- package/framework-mcp/dist/framework-mcp/src/constants.js +64 -0
- package/framework-mcp/dist/framework-mcp/src/index.js +144 -0
- package/framework-mcp/dist/framework-mcp/src/resources/index.js +58 -0
- package/framework-mcp/dist/framework-mcp/src/tools/control_plane/locking.js +82 -0
- package/framework-mcp/dist/framework-mcp/src/tools/control_plane/registry.js +35 -0
- package/framework-mcp/dist/framework-mcp/src/tools/definitions.js +322 -0
- package/framework-mcp/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +64 -0
- package/framework-mcp/dist/framework-mcp/src/tools/file_system/patch_file.js +34 -0
- package/framework-mcp/dist/framework-mcp/src/tools/file_system/read_file.js +51 -0
- package/framework-mcp/dist/framework-mcp/src/tools/file_system/replace_text.js +50 -0
- package/framework-mcp/dist/framework-mcp/src/tools/file_system/write_file.js +43 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/audit_deps.js +41 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/get_status.js +5 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/orchestrate.js +5 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/run_tests.js +27 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/submit_plan.js +13 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/update_contract_hash.js +5 -0
- package/framework-mcp/dist/framework-mcp/src/tools/framework/update_memory.js +8 -0
- package/framework-mcp/dist/framework-mcp/src/tools/index.js +62 -0
- package/framework-mcp/dist/framework-mcp/src/tools/memory/get_insights.js +34 -0
- package/framework-mcp/dist/framework-mcp/src/tools/memory/read_memory.js +28 -0
- package/framework-mcp/dist/framework-mcp/src/tools/messaging/log_action.js +22 -0
- package/framework-mcp/dist/framework-mcp/src/tools/messaging/send_message.js +94 -0
- package/framework-mcp/dist/framework-mcp/src/tools/observability/check_ports.js +26 -0
- package/framework-mcp/dist/framework-mcp/src/tools/observability/get_health.js +19 -0
- package/framework-mcp/dist/framework-mcp/src/tools/quality/check_lint.js +30 -0
- package/framework-mcp/dist/framework-mcp/src/tools/search/get_gaps.js +48 -0
- package/framework-mcp/dist/framework-mcp/src/tools/search/get_map.js +43 -0
- package/framework-mcp/dist/framework-mcp/src/tools/search/grep_search.js +75 -0
- package/framework-mcp/dist/framework-mcp/src/tools/search/list_dir.js +28 -0
- package/framework-mcp/dist/framework-mcp/src/tools/shell/run_command.js +56 -0
- package/framework-mcp/dist/framework-mcp/src/tools/types.js +1 -0
- package/framework-mcp/dist/framework-mcp/src/utils/cli.js +59 -0
- package/framework-mcp/dist/framework-mcp/src/utils/compliance.js +231 -0
- package/framework-mcp/dist/framework-mcp/src/utils/fs.js +44 -0
- package/framework-mcp/dist/framework-mcp/src/utils/metrics.js +56 -0
- package/framework-mcp/dist/framework-mcp/src/utils/permissions.js +71 -0
- package/framework-mcp/dist/framework-mcp/src/utils/security.js +60 -0
- package/framework-mcp/dist/index.js +144 -0
- package/framework-mcp/dist/resources/index.js +58 -0
- package/framework-mcp/dist/src/cli/adapters/core.js +71 -0
- package/framework-mcp/dist/src/cli/adapters/index.js +5 -0
- package/framework-mcp/dist/src/cli/adapters/paths.js +101 -0
- package/framework-mcp/dist/src/cli/adapters/scaffold.js +71 -0
- package/framework-mcp/dist/src/cli/adapters/utils.js +75 -0
- package/framework-mcp/dist/src/cli/commands/approve.js +63 -0
- package/framework-mcp/dist/src/cli/commands/check.js +181 -0
- package/framework-mcp/dist/src/cli/commands/compliance.js +50 -0
- package/framework-mcp/dist/src/cli/commands/contract.js +50 -0
- package/framework-mcp/dist/src/cli/commands/dashboard.js +123 -0
- package/framework-mcp/dist/src/cli/commands/explorer.js +42 -0
- package/framework-mcp/dist/src/cli/commands/git.js +40 -0
- package/framework-mcp/dist/src/cli/commands/init/create-agent.js +58 -0
- package/framework-mcp/dist/src/cli/commands/init/scaffold-core.js +112 -0
- package/framework-mcp/dist/src/cli/commands/init/scaffold-docs.js +34 -0
- package/framework-mcp/dist/src/cli/commands/init/scaffold-ops.js +80 -0
- package/framework-mcp/dist/src/cli/commands/init/scaffold-standards.js +67 -0
- package/framework-mcp/dist/src/cli/commands/init.js +167 -0
- package/framework-mcp/dist/src/cli/commands/knowledge.js +42 -0
- package/framework-mcp/dist/src/cli/commands/lint.js +22 -0
- package/framework-mcp/dist/src/cli/commands/log.js +10 -0
- package/framework-mcp/dist/src/cli/commands/memory.js +4 -0
- package/framework-mcp/dist/src/cli/commands/orchestrate.js +159 -0
- package/framework-mcp/dist/src/cli/commands/plan.js +117 -0
- package/framework-mcp/dist/src/cli/commands/script.js +19 -0
- package/framework-mcp/dist/src/cli/commands/security.js +36 -0
- package/framework-mcp/dist/src/cli/commands/status.js +97 -0
- package/framework-mcp/dist/src/cli/commands/trace.js +109 -0
- package/framework-mcp/dist/src/cli/index.js +338 -0
- package/framework-mcp/dist/src/cli/shims.js +66 -0
- package/framework-mcp/dist/src/cli/utils/claude.js +56 -0
- package/framework-mcp/dist/src/cli/utils/compliance.js +173 -0
- package/framework-mcp/dist/src/cli/utils/config-schema.js +42 -0
- package/framework-mcp/dist/src/cli/utils/fs.js +137 -0
- package/framework-mcp/dist/src/cli/utils/i18n.js +30 -0
- package/framework-mcp/dist/src/cli/utils/memory.js +276 -0
- package/framework-mcp/dist/src/cli/utils/pkg.js +282 -0
- package/framework-mcp/dist/src/cli/utils/schemas.js +19 -0
- package/framework-mcp/dist/src/cli/utils/string.js +49 -0
- package/framework-mcp/dist/src/cli/utils/time.js +27 -0
- package/framework-mcp/dist/src/cli/utils/ui.js +58 -0
- package/framework-mcp/dist/src/contracts/index.js +1 -0
- package/framework-mcp/dist/src/contracts/tasks.js +20 -0
- package/framework-mcp/dist/src/dashboard/vite.config.js +15 -0
- package/framework-mcp/dist/src/modules/adapters/definitions.js +140 -0
- package/framework-mcp/dist/src/modules/adapters/registry.js +18 -0
- package/framework-mcp/dist/src/modules/adapters/shared.js +104 -0
- package/framework-mcp/dist/src/modules/adapters/types.js +1 -0
- package/framework-mcp/dist/src/modules/agents/definitions.js +457 -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 +49 -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 +36 -0
- package/framework-mcp/dist/src/modules/agents/registry/frontend.js +51 -0
- package/framework-mcp/dist/src/modules/agents/registry/git.js +36 -0
- package/framework-mcp/dist/src/modules/agents/registry/manager.js +53 -0
- package/framework-mcp/dist/src/modules/agents/registry/mobile.js +39 -0
- package/framework-mcp/dist/src/modules/agents/registry/native.js +39 -0
- package/framework-mcp/dist/src/modules/agents/registry/quality.js +41 -0
- package/framework-mcp/dist/src/modules/agents/registry/security.js +43 -0
- package/framework-mcp/dist/src/modules/agents/types.js +1 -0
- package/framework-mcp/dist/src/modules/engines/evaluation-engine.js +102 -0
- package/framework-mcp/dist/src/modules/engines/health-engine.js +49 -0
- package/framework-mcp/dist/src/modules/engines/planning-engine.js +78 -0
- package/framework-mcp/dist/src/modules/engines/risk-engine.js +105 -0
- package/framework-mcp/dist/src/modules/engines/routing-engine.js +73 -0
- package/framework-mcp/dist/src/modules/engines/types.js +1 -0
- package/framework-mcp/dist/src/modules/skills/definitions.js +70 -0
- package/framework-mcp/dist/src/shared/constants.js +187 -0
- package/framework-mcp/dist/src/shared/errors.js +68 -0
- package/framework-mcp/dist/src/shared/fs.js +51 -0
- package/framework-mcp/dist/src/shared/logger.js +116 -0
- package/framework-mcp/dist/src/shared/storage.js +207 -0
- package/framework-mcp/dist/src/shared/types.js +12 -0
- package/framework-mcp/dist/tools/control_plane/locking.js +82 -0
- package/framework-mcp/dist/tools/control_plane/registry.js +35 -0
- package/framework-mcp/dist/tools/definitions.js +322 -0
- package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +64 -0
- package/framework-mcp/dist/tools/file_system/patch_file.js +34 -0
- package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
- package/framework-mcp/dist/tools/file_system/replace_text.js +50 -0
- package/framework-mcp/dist/tools/file_system/write_file.js +43 -0
- package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
- package/framework-mcp/dist/tools/framework/get_status.js +5 -0
- package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
- package/framework-mcp/dist/tools/framework/run_tests.js +27 -0
- package/framework-mcp/dist/tools/framework/submit_plan.js +13 -0
- package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
- package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
- package/framework-mcp/dist/tools/index.js +62 -0
- package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
- package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
- package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
- package/framework-mcp/dist/tools/messaging/send_message.js +94 -0
- package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
- package/framework-mcp/dist/tools/observability/get_health.js +19 -0
- package/framework-mcp/dist/tools/quality/check_lint.js +30 -0
- package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
- package/framework-mcp/dist/tools/search/get_map.js +43 -0
- package/framework-mcp/dist/tools/search/grep_search.js +75 -0
- package/framework-mcp/dist/tools/search/list_dir.js +28 -0
- package/framework-mcp/dist/tools/shell/run_command.js +56 -0
- package/framework-mcp/dist/tools/types.js +1 -0
- package/framework-mcp/dist/utils/cli.js +59 -0
- package/framework-mcp/dist/utils/compliance.js +231 -0
- package/framework-mcp/dist/utils/fs.js +44 -0
- package/framework-mcp/dist/utils/metrics.js +56 -0
- package/framework-mcp/dist/utils/permissions.js +71 -0
- package/framework-mcp/dist/utils/security.js +60 -0
- package/framework-mcp/package.json +35 -0
- package/mcp.json +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { ensureDir, writeTextFile } from "../../utils/fs.js";
|
|
4
|
+
import { getPackageRoot } from "../../utils/pkg.js";
|
|
5
|
+
import { CORE_SKILLS } from "../../../modules/skills/definitions.js";
|
|
6
|
+
const FRAMEWORK_NAME = "Agent Atabey";
|
|
7
|
+
export function scaffoldSkills(skillsBaseDir, dryRun) {
|
|
8
|
+
if (dryRun)
|
|
9
|
+
return;
|
|
10
|
+
ensureDir(skillsBaseDir, dryRun);
|
|
11
|
+
for (const [key, skill] of Object.entries(CORE_SKILLS)) {
|
|
12
|
+
const mdContent = `# 🛠️ ${FRAMEWORK_NAME} Skill — ${skill.name}\n\n${skill.description}\n\n## 🔌 Associated Tools\n${skill.tools.map(t => `- \`${t}\``).join("\n")}\n\n## [SECURITY] Core Mandates\n${skill.mandates.join("\n")}\n`;
|
|
13
|
+
writeTextFile(path.join(skillsBaseDir, `${key.toLowerCase()}.md`), mdContent);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function scaffoldStandards(frameworkDir, dryRun) {
|
|
17
|
+
if (dryRun)
|
|
18
|
+
return;
|
|
19
|
+
const knowledgePath = path.join(frameworkDir, "knowledge");
|
|
20
|
+
if (!fs.existsSync(knowledgePath))
|
|
21
|
+
fs.mkdirSync(knowledgePath, { recursive: true });
|
|
22
|
+
const eslintStandardsContent = `# [ATABEY] Agent Atabey — ESLint Standards
|
|
23
|
+
|
|
24
|
+
This document outlines the strict ESLint coding standards for Agent Atabey projects.
|
|
25
|
+
|
|
26
|
+
## 📏 Core Rules
|
|
27
|
+
- **Indentation:** 4 spaces (strict).
|
|
28
|
+
- **Quotes:** Double quotes (\`"\`) for strings.
|
|
29
|
+
- **Semicolons:** Always terminate statements with a semicolon (\`;\`).
|
|
30
|
+
- **No Explicit Any:** Avoid using \`any\`. Use strongly typed interfaces, generics, or \`unknown\` with type assertions.
|
|
31
|
+
- **Unused Variables:** Warning on unused variables unless prefixed with an underscore (\`_\`).
|
|
32
|
+
`;
|
|
33
|
+
writeTextFile(path.join(knowledgePath, "eslint-standards.md"), eslintStandardsContent);
|
|
34
|
+
const standards = [
|
|
35
|
+
// ── Supreme Governance (required by @manager, @security, @architect) ──────
|
|
36
|
+
{ file: "governance-standards.md", template: "templates/standards/governance-standards.md", default: "# [ATABEY] Agent Atabey — Governance & Nizam Standards" },
|
|
37
|
+
// ── Core Engineering Standards ────────────────────────────────────────────
|
|
38
|
+
{ file: "crud-governance.md", template: "templates/standards/crud-governance.md", default: "# [GOV] Corporate CRUD and Governance Standards" },
|
|
39
|
+
{ file: "architecture-standards.md", template: "templates/standards/architecture-standards.md", default: "# 📐 Corporate Architecture Standards" },
|
|
40
|
+
{ file: "frontend-standards.md", template: "templates/standards/frontend-standards.md", default: "# 🎨 Corporate Frontend Standards" },
|
|
41
|
+
{ file: "vite-standards.md", template: "templates/standards/vite-standards.md", default: "# ⚡ Corporate Vite Standards" },
|
|
42
|
+
{ file: "nextjs-standards.md", template: "templates/standards/nextjs-standards.md", default: "# ⚛️ Corporate Next.js Standards" },
|
|
43
|
+
{ file: "tailwind-standards.md", template: "templates/standards/tailwind-standards.md", default: "# 🌊 Corporate Tailwind Standards" },
|
|
44
|
+
{ file: "mobile-standards.md", template: "templates/standards/mobile-standards.md", default: "# 📱 Corporate Mobile Standards" },
|
|
45
|
+
{ file: "security-standards.md", template: "templates/standards/security-standards.md", default: "# [SECURITY] Corporate Security Standards" },
|
|
46
|
+
{ file: "quality-standards.md", template: "templates/standards/quality-standards.md", default: "# ⚖️ Corporate Code Quality Standards" },
|
|
47
|
+
{ file: "logging-and-secrets.md", template: "templates/standards/logging-and-secrets.md", default: "# 🪵 Corporate Logging Standards" },
|
|
48
|
+
{ file: "testing-standards.md", template: "templates/standards/testing-standards.md", default: "# [SKILL] Corporate Testing Standards" },
|
|
49
|
+
{ file: "i18n-standards.md", template: "templates/standards/i18n-standards.md", default: "# 🌐 Corporate i18n Standards" },
|
|
50
|
+
{ file: "llm-governance.md", template: "templates/standards/llm-governance.md", default: "# [AI] LLM Governance Standards" },
|
|
51
|
+
{ file: "observability-standards.md", template: "templates/standards/observability-standards.md", default: "# 📈 Corporate Observability Standards" },
|
|
52
|
+
{ file: "deployment-standards.md", template: "templates/standards/deployment-standards.md", default: "# [START] Corporate Deployment Standards" },
|
|
53
|
+
{ file: "performance-standards.md", template: "templates/standards/performance-standards.md", default: "# ⚡ Corporate Performance Standards" },
|
|
54
|
+
{ file: "security-audit-standards.md", template: "templates/standards/security-audit-standards.md", default: "# 🔍 Corporate Security Audit Standards" }
|
|
55
|
+
];
|
|
56
|
+
for (const std of standards) {
|
|
57
|
+
let content = std.default;
|
|
58
|
+
try {
|
|
59
|
+
const fullTemplatePath = path.join(getPackageRoot(), std.template);
|
|
60
|
+
if (fs.existsSync(fullTemplatePath)) {
|
|
61
|
+
content = fs.readFileSync(fullTemplatePath, "utf8");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch { /* fallback to default */ }
|
|
65
|
+
writeTextFile(path.join(knowledgePath, std.file), content);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import readline from "readline";
|
|
3
|
+
import { resolveAdapter, runAdapterPostInit, scaffoldAgents, resolveAgentsDir, mirrorUnifiedAgentsToNative, ADAPTER_IDS, } from "../adapters/index.js";
|
|
4
|
+
import { ensureDir } from "../utils/fs.js";
|
|
5
|
+
import { initializeMemory, getConfiguredPaths } from "../utils/memory.js";
|
|
6
|
+
import { getPackageVersion, getPackageRoot, mergePackageJson } from "../utils/pkg.js";
|
|
7
|
+
import { UI } from "../utils/ui.js";
|
|
8
|
+
import { ALL_AGENTS } from "../../modules/agents/definitions.js";
|
|
9
|
+
import { scaffoldConstitution, scaffoldFrameworkConfigs, scaffoldShims } from "./init/scaffold-core.js";
|
|
10
|
+
import { scaffoldSkills, scaffoldStandards } from "./init/scaffold-standards.js";
|
|
11
|
+
import { scaffoldOps } from "./init/scaffold-ops.js";
|
|
12
|
+
import { scaffoldProjectDocs } from "./init/scaffold-docs.js";
|
|
13
|
+
import { TRANSLATIONS } from "../utils/i18n.js";
|
|
14
|
+
const FRAMEWORK_NAME = "Agent Atabey";
|
|
15
|
+
const FRAMEWORK_SUBDIRS = [
|
|
16
|
+
"agents",
|
|
17
|
+
"skills",
|
|
18
|
+
"knowledge",
|
|
19
|
+
"prompts",
|
|
20
|
+
"memory",
|
|
21
|
+
"router",
|
|
22
|
+
"registry",
|
|
23
|
+
"observability",
|
|
24
|
+
"rules",
|
|
25
|
+
];
|
|
26
|
+
async function runInteractiveInit() {
|
|
27
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
28
|
+
const question = (query) => new Promise((resolve) => rl.question(query, resolve));
|
|
29
|
+
try {
|
|
30
|
+
console.warn("\n🌐 Select Framework Language / Dil Seçimi:");
|
|
31
|
+
console.warn("1. Türkçe");
|
|
32
|
+
console.warn("2. English");
|
|
33
|
+
const langInput = await question("\nSelect (1-2) or Enter for 'tr': ");
|
|
34
|
+
const language = langInput.trim() === "2" ? "en" : "tr";
|
|
35
|
+
const t = TRANSLATIONS[language];
|
|
36
|
+
console.warn(`\n[START] ${t.welcome}`);
|
|
37
|
+
console.warn(`\n${t.select_backend}:`);
|
|
38
|
+
const languages = ["Node.js (TypeScript)", "Go", "Java (Spring Boot)", "Python (FastAPI)", ".NET"];
|
|
39
|
+
languages.forEach((l, i) => console.warn(`${i + 1}. ${l}`));
|
|
40
|
+
const bLangInput = await question("\nSelect (1-5) or Enter for \"Node.js\": ");
|
|
41
|
+
const backendLanguage = languages[parseInt(bLangInput.trim()) - 1] || "Node.js (TypeScript)";
|
|
42
|
+
console.warn(`\n${t.select_frontend}:`);
|
|
43
|
+
const frontendFrameworks = ["Vite (React)", "Next.js (App Router)", "Vanilla HTML/JS"];
|
|
44
|
+
frontendFrameworks.forEach((f, i) => console.warn(`${i + 1}. ${f}`));
|
|
45
|
+
const fFrameInput = await question("\nSelect (1-3) or Enter for \"Vite (React)\": ");
|
|
46
|
+
const frontendFramework = frontendFrameworks[parseInt(fFrameInput.trim()) - 1] || "Vite (React)";
|
|
47
|
+
console.warn("\nAvailable Framework Directories:");
|
|
48
|
+
FRAMEWORK_SUBDIRS.forEach((d, i) => console.warn(`${i + 1}. ${d}`));
|
|
49
|
+
const dirInput = await question(`\n${t.select_dirs} `);
|
|
50
|
+
const selectedDirs = dirInput ? dirInput.split(",").map(n => FRAMEWORK_SUBDIRS[parseInt(n.trim()) - 1]).filter(Boolean) : [...FRAMEWORK_SUBDIRS];
|
|
51
|
+
console.warn("\nAvailable Core Agents:");
|
|
52
|
+
ALL_AGENTS.forEach((a, i) => console.warn(`${i + 1}. ${a.name}`));
|
|
53
|
+
const agentInput = await question(`\n${t.select_agents} `);
|
|
54
|
+
const selectedAgents = agentInput ? agentInput.split(",").map(n => ALL_AGENTS[parseInt(n.trim()) - 1].name).filter(Boolean) : ALL_AGENTS.map(a => a.name);
|
|
55
|
+
console.warn("\nAvailable Color Palettes:");
|
|
56
|
+
const palettes = ["Modern Blue", "Enterprise Slate", "Deep Purple"];
|
|
57
|
+
palettes.forEach((p, i) => console.warn(`${i + 1}. ${p}`));
|
|
58
|
+
const palInput = await question(`\n${t.select_palette} `);
|
|
59
|
+
const selectedPalette = palettes[parseInt(palInput.trim()) - 1] || "Modern Blue";
|
|
60
|
+
return { selectedDirs, selectedAgents, selectedPalette, backendLanguage, frontendFramework, language };
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
rl.close();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function initCommand(adapterName, options) {
|
|
67
|
+
const adapterId = (adapterName || "gemini");
|
|
68
|
+
const adapter = resolveAdapter(adapterId);
|
|
69
|
+
if (!adapter) {
|
|
70
|
+
UI.error(`Unknown adapter: ${adapterId}`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
const projectRoot = process.cwd();
|
|
74
|
+
const isUnified = options.unified || false;
|
|
75
|
+
// STRICT ISOLATION STRATEGY
|
|
76
|
+
const coreDir = ".atabey"; // Pure Memory & Knowledge
|
|
77
|
+
const aiToolDir = isUnified ? ".agents" : adapter.frameworkDir; // Pure Agents & Skills
|
|
78
|
+
const dryRun = options.dryRun || false;
|
|
79
|
+
const forceYes = options.yes || false;
|
|
80
|
+
UI.intent("Atabey Initialization", `Bootstrapping ${FRAMEWORK_NAME} (v${getPackageVersion()}) with ${adapterId} adapter...`);
|
|
81
|
+
let selectedDirs;
|
|
82
|
+
let selectedAgents;
|
|
83
|
+
let selectedPalette;
|
|
84
|
+
let backendLanguage;
|
|
85
|
+
let frontendFramework;
|
|
86
|
+
let language;
|
|
87
|
+
if (forceYes) {
|
|
88
|
+
selectedDirs = ["knowledge", "prompts", "memory", "router", "registry", "observability", "rules"];
|
|
89
|
+
selectedAgents = ALL_AGENTS.map(a => a.name);
|
|
90
|
+
selectedPalette = "Modern Blue";
|
|
91
|
+
backendLanguage = "Node.js (TypeScript)";
|
|
92
|
+
frontendFramework = "Vite (React)";
|
|
93
|
+
language = "tr";
|
|
94
|
+
UI.success("Non-interactive mode: Using default configurations (Language: tr, Backend: Node.js, Frontend: Vite).");
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const result = await runInteractiveInit();
|
|
98
|
+
selectedDirs = result.selectedDirs.filter(d => d !== "agents" && d !== "skills");
|
|
99
|
+
selectedAgents = result.selectedAgents;
|
|
100
|
+
selectedPalette = result.selectedPalette;
|
|
101
|
+
backendLanguage = result.backendLanguage;
|
|
102
|
+
frontendFramework = result.frontendFramework;
|
|
103
|
+
language = result.language;
|
|
104
|
+
}
|
|
105
|
+
const t = TRANSLATIONS[language];
|
|
106
|
+
ensureDir(path.join(projectRoot, coreDir), dryRun);
|
|
107
|
+
selectedDirs.forEach(dir => {
|
|
108
|
+
ensureDir(path.join(projectRoot, coreDir, dir), dryRun);
|
|
109
|
+
});
|
|
110
|
+
ensureDir(path.join(projectRoot, aiToolDir), dryRun);
|
|
111
|
+
if (adapter.nestedDirs) {
|
|
112
|
+
adapter.nestedDirs.forEach(dir => ensureDir(path.join(projectRoot, aiToolDir, dir), dryRun));
|
|
113
|
+
}
|
|
114
|
+
scaffoldConstitution(projectRoot, coreDir, adapterId, dryRun, language);
|
|
115
|
+
scaffoldFrameworkConfigs(projectRoot, coreDir, adapter, dryRun, selectedPalette, {
|
|
116
|
+
unified: isUnified,
|
|
117
|
+
adapters: isUnified ? [...ADAPTER_IDS] : [adapterId],
|
|
118
|
+
backendLanguage,
|
|
119
|
+
frontendFramework,
|
|
120
|
+
language
|
|
121
|
+
});
|
|
122
|
+
scaffoldStandards(path.join(projectRoot, coreDir), dryRun);
|
|
123
|
+
const pathsMap = getConfiguredPaths();
|
|
124
|
+
if (isUnified) {
|
|
125
|
+
// Scaffold ALL agents for ALL adapters under unified hub
|
|
126
|
+
for (const id of ADAPTER_IDS) {
|
|
127
|
+
const adapterId = id;
|
|
128
|
+
const dest = resolveAgentsDir(adapterId, true, aiToolDir);
|
|
129
|
+
scaffoldAgents(projectRoot, adapterId, dryRun, selectedAgents, dest.agentsDir, dest.agentsExt, pathsMap, backendLanguage, language);
|
|
130
|
+
if (!dryRun)
|
|
131
|
+
mirrorUnifiedAgentsToNative(projectRoot, adapterId);
|
|
132
|
+
}
|
|
133
|
+
UI.success(`[OK] Scaffolding complete for all adapters under ${aiToolDir}/ with native mirrors.`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// Standard single-adapter scaffold
|
|
137
|
+
const dest = resolveAgentsDir(adapterId, false);
|
|
138
|
+
scaffoldAgents(projectRoot, adapterId, dryRun, selectedAgents, dest.agentsDir, dest.agentsExt, pathsMap, backendLanguage, language);
|
|
139
|
+
UI.success(`[OK] Generated agent definitions under ${dest.agentsDir}/`);
|
|
140
|
+
}
|
|
141
|
+
const skillsBaseDir = path.join(projectRoot, aiToolDir, "skills");
|
|
142
|
+
scaffoldSkills(skillsBaseDir, dryRun);
|
|
143
|
+
scaffoldOps(path.join(projectRoot, coreDir), dryRun);
|
|
144
|
+
scaffoldProjectDocs(projectRoot, { backendLanguage, frontendFramework }, dryRun);
|
|
145
|
+
scaffoldShims(projectRoot, coreDir, adapterId, adapter, dryRun, isUnified);
|
|
146
|
+
// Initialize runtime directories
|
|
147
|
+
if (!dryRun) {
|
|
148
|
+
ensureDir(path.join(projectRoot, coreDir, "messages"));
|
|
149
|
+
ensureDir(path.join(projectRoot, coreDir, "logs"));
|
|
150
|
+
ensureDir(path.join(projectRoot, coreDir, "memory-graph"));
|
|
151
|
+
}
|
|
152
|
+
initializeMemory(path.join(projectRoot, coreDir), dryRun);
|
|
153
|
+
// Scaffolding package.json
|
|
154
|
+
if (!dryRun) {
|
|
155
|
+
const pkgJsonPath = path.join(projectRoot, "package.json");
|
|
156
|
+
const sourcePkgPath = path.join(getPackageRoot(), "package.json");
|
|
157
|
+
mergePackageJson(pkgJsonPath, sourcePkgPath);
|
|
158
|
+
}
|
|
159
|
+
runAdapterPostInit(adapter, projectRoot);
|
|
160
|
+
UI.success(`\n[START] ${FRAMEWORK_NAME} (v${getPackageVersion()}) ${t.init_success}`);
|
|
161
|
+
console.warn(`\n- Brain & Memory Hub (Protected): ${coreDir}/`);
|
|
162
|
+
console.warn(`- AI Agent Commands (Active): ${aiToolDir}/`);
|
|
163
|
+
console.warn(`\n${t.next_steps}`);
|
|
164
|
+
console.warn(" 1. Run 'npm install' (or pnpm/yarn) to install dependencies.");
|
|
165
|
+
console.warn(" 2. Run 'atabey status' to verify the environment.");
|
|
166
|
+
console.warn(` 3. Open ${adapterId === "claude" ? "Claude Desktop" : "your AI Assistant"} and start commanding the Army.`);
|
|
167
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { getFrameworkDir } from "../utils/memory.js";
|
|
4
|
+
import { writeTextFile } from "../utils/fs.js";
|
|
5
|
+
export async function updateKnowledgeBaseCommand(topic, content) {
|
|
6
|
+
if (!topic || !content) {
|
|
7
|
+
console.error("[ERROR] Usage: atabey update_knowledge_base <topic> <content>");
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const frameworkDir = getFrameworkDir();
|
|
11
|
+
const kbDir = path.join(frameworkDir, "knowledge");
|
|
12
|
+
if (!fs.existsSync(kbDir))
|
|
13
|
+
fs.mkdirSync(kbDir, { recursive: true });
|
|
14
|
+
const fileName = topic.replace(/[^a-z0-9]/gi, "_").toLowerCase() + ".md";
|
|
15
|
+
writeTextFile(path.join(kbDir, fileName), content);
|
|
16
|
+
console.warn(`[OK] Knowledge base updated: ${topic}`);
|
|
17
|
+
}
|
|
18
|
+
export async function searchKnowledgeBaseCommand(query) {
|
|
19
|
+
if (!query) {
|
|
20
|
+
console.error("[ERROR] Usage: atabey search_knowledge_base <query>");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const frameworkDir = getFrameworkDir();
|
|
24
|
+
const kbDir = path.join(frameworkDir, "knowledge");
|
|
25
|
+
if (!fs.existsSync(kbDir)) {
|
|
26
|
+
console.warn("ℹ️ Knowledge base is empty.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const files = fs.readdirSync(kbDir).filter(f => f.endsWith(".md"));
|
|
30
|
+
let found = false;
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const content = fs.readFileSync(path.join(kbDir, file), "utf-8");
|
|
33
|
+
if (content.toLowerCase().includes(query.toLowerCase()) || file.toLowerCase().includes(query.toLowerCase())) {
|
|
34
|
+
console.warn(`
|
|
35
|
+
### ${file.replace(".md", "")}
|
|
36
|
+
${content.slice(0, 300)}...`);
|
|
37
|
+
found = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!found)
|
|
41
|
+
console.warn("ℹ️ No matching entries found.");
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { getPackageVersion } from "../utils/pkg.js";
|
|
3
|
+
/**
|
|
4
|
+
* Run ESLint for the project (same as npm run lint).
|
|
5
|
+
*/
|
|
6
|
+
export async function lintCommand() {
|
|
7
|
+
console.warn(`🔍 Running ESLint (v${getPackageVersion()})...`);
|
|
8
|
+
const projectRoot = process.cwd();
|
|
9
|
+
try {
|
|
10
|
+
execSync("npm run lint", {
|
|
11
|
+
cwd: projectRoot,
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
env: process.env,
|
|
14
|
+
});
|
|
15
|
+
console.warn("\n[OK] ESLint passed with no errors.");
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
console.warn("\n[ERROR] ESLint reported errors. Fix violations before committing.");
|
|
19
|
+
console.warn(" Tip: npm run lint -- --fix");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { normalizeAgentName } from "../utils/string.js";
|
|
2
|
+
import { Storage } from "../../shared/storage.js";
|
|
3
|
+
export async function logAgentActionCommand(data) {
|
|
4
|
+
const agent = normalizeAgentName(data.agent);
|
|
5
|
+
const db = Storage.getDB();
|
|
6
|
+
db.prepare(`
|
|
7
|
+
INSERT INTO logs (agent, action, trace_id, status, summary, findings)
|
|
8
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
9
|
+
`).run(agent, data.action, data.traceId || null, data.status || "SUCCESS", data.summary || "", data.details ? JSON.stringify(data.details) : null);
|
|
10
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { UI } from "../utils/ui.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { logger } from "../../shared/logger.js";
|
|
4
|
+
import { sleep } from "../utils/time.js";
|
|
5
|
+
import { Storage } from "../../shared/storage.js";
|
|
6
|
+
import { asTraceID } from "../../shared/types.js";
|
|
7
|
+
export const HermesMessageSchema = z.object({
|
|
8
|
+
timestamp: z.string(),
|
|
9
|
+
from: z.string(),
|
|
10
|
+
to: z.string(),
|
|
11
|
+
category: z.enum(["ACTION", "DELEGATION", "SUBTASK", "REPLY", "ALERT"]),
|
|
12
|
+
content: z.string(), // This is the payload to be validated
|
|
13
|
+
traceId: z.string(),
|
|
14
|
+
parentId: z.string().optional(),
|
|
15
|
+
status: z.enum(["PENDING", "PROCESSED", "WAITING", "APPROVED"]),
|
|
16
|
+
priority: z.enum(["HIGH", "NORMAL", "LOW"]).optional(),
|
|
17
|
+
action: z.string().optional(),
|
|
18
|
+
requiresApproval: z.boolean().optional(),
|
|
19
|
+
dependencies: z.array(z.string()).optional(),
|
|
20
|
+
});
|
|
21
|
+
let isLooping = false;
|
|
22
|
+
export async function orchestrateCommand(options) {
|
|
23
|
+
UI.intent("Hermes Message Broker", "Starting the live agent orchestration loop...");
|
|
24
|
+
const maxIterations = options?.maxIterations;
|
|
25
|
+
let iterationCount = 0;
|
|
26
|
+
isLooping = true;
|
|
27
|
+
while (isLooping) {
|
|
28
|
+
try {
|
|
29
|
+
// 1. Check for agent timeouts using SQLite
|
|
30
|
+
const agents = Storage.getAllAgents();
|
|
31
|
+
for (const agent of agents) {
|
|
32
|
+
if (agent.state === "EXECUTING" && agent.last_updated) {
|
|
33
|
+
const lastUpdatedTime = Date.parse(agent.last_updated);
|
|
34
|
+
if (!isNaN(lastUpdatedTime) && Date.now() - lastUpdatedTime > 30 * 60 * 1000) {
|
|
35
|
+
const displayAgent = `@${agent.name}`;
|
|
36
|
+
UI.error(`[WARN] Agent ${displayAgent} has TIMED OUT. Triggering Self-Healing...`);
|
|
37
|
+
Storage.updateAgentStatus(agent.name, "READY", "Idle (Recovered from Timeout)");
|
|
38
|
+
UI.success(`[OK] Hermes Self-Healing: ${displayAgent} reset to READY state.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// 2. Fetch actionable messages from SQLite
|
|
43
|
+
const pendingMessages = Storage.getPendingMessages() || [];
|
|
44
|
+
if (pendingMessages.length > 0) {
|
|
45
|
+
UI.intent("Multi-Agent Orchestration", `${pendingMessages.length} pending tasks found in database.`);
|
|
46
|
+
for (const msg of pendingMessages) {
|
|
47
|
+
// Dependency Check
|
|
48
|
+
if (msg.parentId) {
|
|
49
|
+
const tasks = Storage.getTasks(asTraceID(msg.traceId));
|
|
50
|
+
const task = tasks.find(t => t.id === msg.parentId);
|
|
51
|
+
if (task && task.dependencies.length > 0) {
|
|
52
|
+
const incompleteDeps = tasks.filter(t => task.dependencies.includes(t.id) && t.status !== "COMPLETED");
|
|
53
|
+
if (incompleteDeps.length > 0) {
|
|
54
|
+
logger.debug(`Skipping task ${msg.parentId} for ${msg.to} - waiting for dependencies: ${incompleteDeps.map(d => d.id).join(", ")}`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Risk and Approval Logic
|
|
60
|
+
let riskFlag = false;
|
|
61
|
+
try {
|
|
62
|
+
const { RiskEngine } = await import("../../modules/engines/risk-engine.js");
|
|
63
|
+
const assessment = RiskEngine.assessTaskRisk(msg.content);
|
|
64
|
+
if (assessment.requiresApproval) {
|
|
65
|
+
riskFlag = true;
|
|
66
|
+
UI.warning(`[SECURITY] Risk Engine auto-flagged Trace ${msg.traceId} as HIGH RISK`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch { /* engine not ready */ }
|
|
70
|
+
if ((msg.category === "ACTION" || msg.category === "ALERT" || riskFlag) && (msg.requiresApproval || riskFlag) && msg.status !== "APPROVED") {
|
|
71
|
+
UI.warning(`\n[WARN] [APPROVAL REQUEST] Trace ${msg.traceId} requires approval:`);
|
|
72
|
+
UI.warning(` Description: ${msg.content}`);
|
|
73
|
+
const approved = await askUserApproval(msg.traceId, msg.content);
|
|
74
|
+
if (approved && msg.id !== undefined) {
|
|
75
|
+
Storage.updateMessageStatus(msg.id, "APPROVED");
|
|
76
|
+
UI.success(`Approved trace: ${msg.traceId}`);
|
|
77
|
+
}
|
|
78
|
+
else if (msg.id !== undefined) {
|
|
79
|
+
Storage.updateMessageStatus(msg.id, "PROCESSED"); // Mark as ignored/rejected
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Process message
|
|
84
|
+
UI.agentBox(msg.to, msg.content, `Trace: ${msg.traceId} | From: ${msg.from} | Category: ${msg.category}`);
|
|
85
|
+
let targetState = "EXECUTING";
|
|
86
|
+
if (msg.category === "DELEGATION" || msg.category === "SUBTASK")
|
|
87
|
+
targetState = "BRIEFED";
|
|
88
|
+
let taskDescription = msg.content;
|
|
89
|
+
try {
|
|
90
|
+
const payload = JSON.parse(msg.content);
|
|
91
|
+
taskDescription = payload.task || msg.content;
|
|
92
|
+
}
|
|
93
|
+
catch { /* ... */ }
|
|
94
|
+
Storage.updateAgentStatus(msg.to, targetState, taskDescription);
|
|
95
|
+
if (targetState === "BRIEFED") {
|
|
96
|
+
Storage.updateAgentStatus(msg.to, "EXECUTING", taskDescription);
|
|
97
|
+
}
|
|
98
|
+
if (msg.id !== undefined) {
|
|
99
|
+
Storage.updateMessageStatus(msg.id, "PROCESSED");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Sync to Markdown for human readability
|
|
103
|
+
const { syncMarkdownMemory } = await import("../utils/memory.js");
|
|
104
|
+
syncMarkdownMemory();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (globalLoopErr) {
|
|
108
|
+
UI.error(`[WARN] Critical error in Hermes orchestration loop: ${globalLoopErr.message}`);
|
|
109
|
+
}
|
|
110
|
+
iterationCount++;
|
|
111
|
+
if (maxIterations !== undefined && iterationCount >= maxIterations) {
|
|
112
|
+
isLooping = false;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
await sleep(2000);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Standard tool for agents to delegate tasks to other agents.
|
|
120
|
+
*/
|
|
121
|
+
export async function sendMessage(args) {
|
|
122
|
+
try {
|
|
123
|
+
const message = {
|
|
124
|
+
timestamp: new Date().toISOString(),
|
|
125
|
+
from: args.from,
|
|
126
|
+
to: args.to,
|
|
127
|
+
category: args.category,
|
|
128
|
+
content: args.content,
|
|
129
|
+
traceId: asTraceID(args.traceId),
|
|
130
|
+
parentId: args.parentId,
|
|
131
|
+
status: "PENDING",
|
|
132
|
+
priority: args.priority || "NORMAL",
|
|
133
|
+
requiresApproval: args.requiresApproval || false
|
|
134
|
+
};
|
|
135
|
+
Storage.saveMessage(message);
|
|
136
|
+
return message;
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
UI.error(`Message could not be delivered: ${args.from} -> ${args.to}`);
|
|
140
|
+
logger.debug("Hermes sendMessage failed", err);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function askUserApproval(_traceId, _content) {
|
|
144
|
+
if (process.env.ATABEY_TEST_DIR || !process.stdin.isTTY) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const readline = await import("readline");
|
|
148
|
+
const rl = readline.createInterface({
|
|
149
|
+
input: process.stdin,
|
|
150
|
+
output: process.stdout
|
|
151
|
+
});
|
|
152
|
+
return new Promise((resolve) => {
|
|
153
|
+
rl.question("[INFO] Approve this operation? (y/N): ", (answer) => {
|
|
154
|
+
rl.close();
|
|
155
|
+
const cleanAnswer = answer.trim().toLowerCase();
|
|
156
|
+
resolve(cleanAnswer === "y" || cleanAnswer === "yes");
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { generateULID } from "../utils/time.js";
|
|
4
|
+
import { UI } from "../utils/ui.js";
|
|
5
|
+
import { RoutingEngine } from "../../modules/engines/routing-engine.js";
|
|
6
|
+
import { PlanningEngine } from "../../modules/engines/planning-engine.js";
|
|
7
|
+
import { sendMessage } from "./orchestrate.js";
|
|
8
|
+
import { Storage } from "../../shared/storage.js";
|
|
9
|
+
import { asTraceID } from "../../shared/types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Submits a structured plan (DAG) to the framework.
|
|
12
|
+
*/
|
|
13
|
+
export async function submitPlanCommand(tasks) {
|
|
14
|
+
const traceId = asTraceID(generateULID());
|
|
15
|
+
const plan = PlanningEngine.createPlan(tasks);
|
|
16
|
+
const validation = PlanningEngine.validatePlan(plan);
|
|
17
|
+
if (!validation.valid) {
|
|
18
|
+
UI.error("Invalid Plan Submission:");
|
|
19
|
+
validation.errors.forEach((e) => UI.error(` - ${e}`));
|
|
20
|
+
process.exit(64);
|
|
21
|
+
}
|
|
22
|
+
UI.intent("Dynamic Task Planner", `Processing plan with ${plan.tasks.length} tasks (Plan Trace: ${traceId})`);
|
|
23
|
+
// Save plan metadata to SQLite
|
|
24
|
+
Storage.setMetadata(`plan_${traceId}`, JSON.stringify(plan));
|
|
25
|
+
for (const task of plan.tasks) {
|
|
26
|
+
const taskData = {
|
|
27
|
+
id: task.id,
|
|
28
|
+
traceId,
|
|
29
|
+
description: task.task,
|
|
30
|
+
agent: task.agent,
|
|
31
|
+
priority: "NORMAL",
|
|
32
|
+
status: "PENDING",
|
|
33
|
+
dependencies: task.dependencies || []
|
|
34
|
+
};
|
|
35
|
+
Storage.saveTask(taskData);
|
|
36
|
+
// Queue as a delegated message in SQLite
|
|
37
|
+
await sendMessage({
|
|
38
|
+
from: "@manager",
|
|
39
|
+
to: task.agent,
|
|
40
|
+
category: "DELEGATION",
|
|
41
|
+
content: JSON.stringify({ task: task.task, traceId }),
|
|
42
|
+
traceId,
|
|
43
|
+
parentId: task.id,
|
|
44
|
+
priority: "NORMAL",
|
|
45
|
+
dependencies: task.dependencies || []
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
UI.success(`[OK] Dynamic plan submitted and queued: ${plan.tasks.length} tasks.`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reads ALL markdown files from the docs/ directory and creates
|
|
52
|
+
* planning tasks from them. Agents will use this to understand
|
|
53
|
+
* project requirements and generate code accordingly.
|
|
54
|
+
*/
|
|
55
|
+
export async function planCommand() {
|
|
56
|
+
const projectRoot = process.cwd();
|
|
57
|
+
const docsDir = path.join(projectRoot, "docs");
|
|
58
|
+
if (!fs.existsSync(docsDir)) {
|
|
59
|
+
UI.error("Docs directory not found at docs/");
|
|
60
|
+
console.warn("[TIP] Create a docs/ folder with your project requirements in .md files.");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const entries = fs.readdirSync(docsDir, { withFileTypes: true });
|
|
64
|
+
const mdFiles = entries.filter(e => e.isFile() && e.name.endsWith(".md"));
|
|
65
|
+
if (mdFiles.length === 0) {
|
|
66
|
+
UI.warning("No markdown files found in docs/ directory.");
|
|
67
|
+
console.warn("[TIP] Add .md files to docs/ with your project requirements.");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
UI.intent("Planning Engine", `Reading ${mdFiles.length} document(s) from docs/...`);
|
|
71
|
+
let totalTasks = 0;
|
|
72
|
+
for (const file of mdFiles) {
|
|
73
|
+
const filePath = path.join(docsDir, file.name);
|
|
74
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
75
|
+
const traceId = asTraceID(generateULID());
|
|
76
|
+
UI.success(`📄 docs/${file.name} (Trace: ${traceId})`);
|
|
77
|
+
// Extract checklist items and create sequential task chain
|
|
78
|
+
const taskRegex = /- \[ \]\s+(.+)/g;
|
|
79
|
+
let taskMatch;
|
|
80
|
+
let taskCount = 0;
|
|
81
|
+
let lastTaskId = null;
|
|
82
|
+
while ((taskMatch = taskRegex.exec(content)) !== null) {
|
|
83
|
+
const taskText = taskMatch[1].trim();
|
|
84
|
+
if (taskText.length >= 3) {
|
|
85
|
+
taskCount++;
|
|
86
|
+
totalTasks++;
|
|
87
|
+
// Capability routing via RoutingEngine
|
|
88
|
+
const targetAgent = RoutingEngine.resolveAgent(taskText);
|
|
89
|
+
const subTaskId = generateULID();
|
|
90
|
+
const taskData = {
|
|
91
|
+
id: subTaskId,
|
|
92
|
+
traceId,
|
|
93
|
+
description: taskText,
|
|
94
|
+
agent: targetAgent,
|
|
95
|
+
priority: "NORMAL",
|
|
96
|
+
status: "PENDING",
|
|
97
|
+
dependencies: lastTaskId ? [lastTaskId] : []
|
|
98
|
+
};
|
|
99
|
+
Storage.saveTask(taskData);
|
|
100
|
+
// Queue as a delegated message
|
|
101
|
+
await sendMessage({
|
|
102
|
+
from: "@manager",
|
|
103
|
+
to: targetAgent,
|
|
104
|
+
category: "DELEGATION",
|
|
105
|
+
content: JSON.stringify({ task: taskText, traceId }),
|
|
106
|
+
traceId,
|
|
107
|
+
parentId: subTaskId,
|
|
108
|
+
priority: "NORMAL",
|
|
109
|
+
dependencies: lastTaskId ? [lastTaskId] : []
|
|
110
|
+
});
|
|
111
|
+
lastTaskId = subTaskId;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
console.warn(` 📋 Actionable tasks detected: ${taskCount}`);
|
|
115
|
+
}
|
|
116
|
+
UI.success(`\n[OK] Planning complete: ${totalTasks} tasks identified.`);
|
|
117
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import cp from "child_process";
|
|
4
|
+
const targetDir = process.cwd(); // Assuming targetDir is process.cwd() in the CLI context
|
|
5
|
+
export async function runScriptCommand(script, projectPath) {
|
|
6
|
+
const fullPath = path.join(targetDir, projectPath);
|
|
7
|
+
if (!fs.existsSync(fullPath)) {
|
|
8
|
+
console.warn(`[ERROR] Project path not found: ${projectPath}`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
console.warn(`[START] Running 'npm run ${script}' in ${projectPath}...`);
|
|
12
|
+
try {
|
|
13
|
+
cp.spawnSync("npm", ["run", script], { cwd: fullPath, stdio: "inherit", shell: true });
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
const message = e instanceof Error ? e.message : "Unknown error";
|
|
17
|
+
console.warn(`[ERROR] Failed to run script: ${message}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { collectFiles } from "../utils/fs.js";
|
|
4
|
+
const targetDir = process.cwd();
|
|
5
|
+
export async function securityAuditCommand(targetPath) {
|
|
6
|
+
console.warn(`🔍 Running Advanced Security Audit on: ${targetPath}...`);
|
|
7
|
+
const scanRules = [
|
|
8
|
+
{ pattern: /sql`/, message: "Potential Raw SQL usage detected", severity: "HIGH" },
|
|
9
|
+
{
|
|
10
|
+
pattern: /(password|secret|api_?key)\s*[:=]\s*['"][^'"]+['"]/i,
|
|
11
|
+
message: "Potential hardcoded secret detected",
|
|
12
|
+
severity: "CRITICAL",
|
|
13
|
+
},
|
|
14
|
+
{ pattern: /:\s*any(?!\w)/, message: "Usage of 'any' type detected", severity: "MEDIUM" },
|
|
15
|
+
{ pattern: /\.innerHTML\s*=/, message: "Unsafe innerHTML assignment detected", severity: "MEDIUM" },
|
|
16
|
+
];
|
|
17
|
+
const issues = [];
|
|
18
|
+
const files = collectFiles(path.join(targetDir, targetPath), [".ts", ".tsx", ".js", ".jsx"]);
|
|
19
|
+
files.forEach((f) => {
|
|
20
|
+
const content = fs.readFileSync(f, "utf8");
|
|
21
|
+
const lines = content.split("\n");
|
|
22
|
+
lines.forEach((line, i) => {
|
|
23
|
+
scanRules.forEach((rule) => {
|
|
24
|
+
if (rule.pattern.test(line)) {
|
|
25
|
+
issues.push(`[${rule.severity}] ${rule.message} in ${path.relative(targetDir, f)}:${i + 1}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
if (issues.length === 0) {
|
|
31
|
+
console.warn("[OK] No security issues detected.");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
issues.forEach((issue) => console.warn(`[WARN] ${issue}`));
|
|
35
|
+
}
|
|
36
|
+
}
|