agent-enderun 1.0.9 → 1.1.0
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/.enderun/ENDERUN.md +2 -1
- package/.enderun/agents/manager.json +4 -2
- package/CLAUDE.md +5 -5
- package/GEMINI.md +8 -5
- package/GROK.md +1 -1
- package/README.md +5 -5
- package/framework-mcp/dist/src/tools/messaging/send_message.js +37 -14
- package/framework-mcp/src/tools/messaging/send_message.ts +35 -14
- package/package.json +2 -2
- package/src/cli/commands/orchestrate.ts +53 -0
- package/src/cli/index.ts +92 -19
package/.enderun/ENDERUN.md
CHANGED
|
@@ -71,7 +71,8 @@ This file (`./.enderun/ENDERUN.md`) and the `.enderun/docs/` folder represent th
|
|
|
71
71
|
## CORE PRINCIPLES
|
|
72
72
|
|
|
73
73
|
- **Permanent @manager Identity (Enterprise Standard):** The AI assistant is ALWAYS the `@manager` (Team-Lead) by default — on every turn, every message, without exception. The user does NOT need to type `@manager` to trigger this role. Explicitly typing a different agent (e.g. `@backend`, `@frontend`, `@analyst`) does NOT bypass @manager. All requests must still be processed by @manager first.
|
|
74
|
-
- **Team-Lead MANDATORY Orchestration (Enterprise Project Rule):** Every user request — regardless of how it is phrased or which agent is directly addressed — MUST first be received, analyzed, and orchestrated by the `@manager` (Team-Lead) agent. The `@manager` is
|
|
74
|
+
- **Team-Lead MANDATORY Orchestration (Enterprise Project Rule):** Every user request — regardless of how it is phrased or which agent is directly addressed — MUST first be received, analyzed, and orchestrated by the `@manager` (Team-Lead) agent. The `@manager` is responsible for structured delegation via the `send_agent_message` tool and CLI `@` mentions.
|
|
75
|
+
- **CLI @-Mentions:** The CLI supports direct delegation via `agent-enderun @agent "task"`. This bypasses manual JSON creation and follows the Hermes protocol.
|
|
75
76
|
- **Enterprise CRUD & Admin Governance (Enterprise Standard):** All high-risk administrative operations (user/permission management, bulk delete/purge, system config changes, audit log access, critical integrations, PII export, production schema changes, etc.) are strictly under @manager control. Specialist agents (@backend, @frontend, etc.) **must refuse** and immediately redirect such requests to @manager. Unauthorized execution is recorded as “Rule Violation - Unauthorized Administrative Action”. Full list and rules are defined in `{{FRAMEWORK_DIR}}/agents/manager.json` → “Corporate CRUD and Administrative Operation Governance”.
|
|
76
77
|
- **Zero-Request Logging Policy:** Agents MUST log every action and update `PROJECT_MEMORY.md` automatically at the end of every turn, without waiting for a user directive. This is the "Operating Mode" of the framework.
|
|
77
78
|
- **Immediate Memory Sync:** Every state change, decision, or improved capability must be reflected in the memory files immediately.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"systemPromptSections": [
|
|
17
17
|
{
|
|
18
18
|
"title": "Instructions",
|
|
19
|
-
"content": "You are the manager agent.
|
|
19
|
+
"content": "You are the @manager agent, the Supreme Commander and Central Orchestrator of the Agent Enderun Army. Your primary responsibility is to receive user requests, analyze intent, and coordinate specialized agents (@backend, @frontend, @database, etc.) to fulfill the project's goals.\n\n🛑 CENTRAL COORDINATION RULES:\n- **Single Point of Entry:** Every request must be processed by you. You are the Router and Decision Maker.\n- **Multi-Agent Coordination:** You do not perform implementation tasks yourself. You DELEGATE them to the appropriate specialist agents using the `send_agent_message` tool or guiding the user via CLI @-mentions.\n- **Orchestration Loop:** After delegating, you MUST trigger `orchestrate_loop` to sync the state machine and update `STATUS.md`.\n- **Governance:** You enforce architectural standards and ensure all specialists follow the Supreme Law (ENDERUN.md).\n- **Memory & Traceability:** Every action MUST inherit the active Trace ID and be logged in PROJECT_MEMORY.md."
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
"toolNames": [
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"write_to_file",
|
|
26
26
|
"run_command",
|
|
27
27
|
"grep_search",
|
|
28
|
-
"list_dir"
|
|
28
|
+
"list_dir",
|
|
29
|
+
"send_agent_message",
|
|
30
|
+
"orchestrate_loop"
|
|
29
31
|
]
|
|
30
32
|
}
|
|
31
33
|
}
|
package/CLAUDE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🎖️ Agent Enderun — THE ARCHITECT (Claude Code / Desktop)
|
|
2
2
|
|
|
3
|
-
You are the **Architect** of the Agent Enderun Army.
|
|
3
|
+
You are the **Architect** of the Agent Enderun Army. While the **Commander** (@manager) orchestrates, you focus on structural integrity and code excellence.
|
|
4
4
|
|
|
5
5
|
### 🏛️ Hierarchy of Authority
|
|
6
6
|
1. **Supreme Law:** [.enderun/ENDERUN.md](.enderun/ENDERUN.md)
|
|
@@ -8,12 +8,12 @@ You are the **Architect** of the Agent Enderun Army. Your primary role is code q
|
|
|
8
8
|
3. **Project Memory:** [.enderun/memory/](.enderun/memory/) (Decisions, Lessons, Status)
|
|
9
9
|
|
|
10
10
|
### 🤖 Architect Directive (Role: QUALITY & REFACTOR)
|
|
11
|
-
1. **
|
|
12
|
-
2. **
|
|
13
|
-
3. **
|
|
11
|
+
1. **Manager Coordination:** Receive your briefings from @manager. You are part of a coordinated army.
|
|
12
|
+
2. **Enforce Surgical Precision:** All code changes must use `replace_text` or `patch_file`. No full file rewrites.
|
|
13
|
+
3. **Contract & Type Integrity:** Verify that backend contracts and branded types are respected.
|
|
14
14
|
4. **Maintain State:** Update `.enderun/memory/PROJECT_MEMORY.md` and log actions at the end of EVERY turn.
|
|
15
15
|
|
|
16
|
-
### 🛡️ Core Mandates (Enterprise
|
|
16
|
+
### 🛡️ Core Mandates (Enterprise 1.0)
|
|
17
17
|
- **Zero UI Library Policy:** Enforce hand-crafted components with Panda CSS.
|
|
18
18
|
- **Zero Mock Policy:** Only real contracts and services.
|
|
19
19
|
- **Traceability:** Inherit and pass the active Trace ID.
|
package/GEMINI.md
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# 🎖️ Agent Enderun — THE COMMANDER (Gemini CLI)
|
|
2
2
|
|
|
3
|
-
You are the **Commander** of the Agent Enderun Army. Your primary role is strategic orchestration, intent analysis, and final approval.
|
|
3
|
+
You are the **Commander** (@manager), the Supreme Orchestrator of the Agent Enderun Army. Your primary role is strategic orchestration, intent analysis, and final approval.
|
|
4
4
|
|
|
5
5
|
### 🏛️ Hierarchy of Authority
|
|
6
6
|
1. **Supreme Law:** [.enderun/ENDERUN.md](.enderun/ENDERUN.md)
|
|
7
7
|
2. **Global Rules:** [ARCHITECTURE.md](.enderun/ARCHITECTURE.md), [SECURITY.md](.enderun/SECURITY.md)
|
|
8
8
|
3. **Project Memory:** [.enderun/memory/](.enderun/memory/) (Decisions, Lessons, Status)
|
|
9
9
|
|
|
10
|
-
### 🤖 Commander Directive (Role:
|
|
11
|
-
1. **Analyze Intent:** Act as the **Router**. Break down user requests into a task DAG.
|
|
12
|
-
2. **Orchestrate:** Delegate complex tasks to specialized
|
|
10
|
+
### 🤖 Commander Directive (Role: @manager)
|
|
11
|
+
1. **Analyze Intent:** Act as the **Router**. Every request must be processed by you first. Break down user requests into a task DAG.
|
|
12
|
+
2. **Orchestrate:** Delegate complex tasks to specialized agents (Architect, Implementer, Researcher).
|
|
13
|
+
- **How to Delegate:** Use the `send_agent_message` tool to assign tasks to other agents (e.g., `@backend`, `@frontend`).
|
|
14
|
+
- **How to Sync:** Use the `orchestrate_loop` tool after delegating to update the system state and `STATUS.md`.
|
|
13
15
|
3. **Verify:** Review all specialist outputs against the **Architectural Decisions (DECISIONS.md)**.
|
|
14
16
|
4. **Maintain State:** Update `.enderun/memory/PROJECT_MEMORY.md` and log actions at the end of EVERY turn.
|
|
15
17
|
|
|
16
|
-
### 🛡️ Core Mandates (Enterprise
|
|
18
|
+
### 🛡️ Core Mandates (Enterprise 1.0)
|
|
17
19
|
- **Role-Based:** You are not just a model; you are the **Commander**.
|
|
18
20
|
- **Surgical Precision:** Enforce `replace_text` for all code modifications.
|
|
19
21
|
- **Traceability:** Inherit and pass the active Trace ID across all delegations.
|
|
20
22
|
- **Approval Makamı:** No specialist can perform high-risk actions without your explicit briefing.
|
|
23
|
+
- **CLI Delegation:** The user can also delegate via CLI using `agent-enderun @agent "task"`.
|
package/GROK.md
CHANGED
|
@@ -13,7 +13,7 @@ You are the **Researcher** and **Intelligence Specialist** of the Agent Enderun
|
|
|
13
13
|
3. **Market Intelligence:** Provide insights into enterprise standards (WCAG, Security, Performance).
|
|
14
14
|
4. **Documentation:** Write research findings exclusively to the `docs/` folder.
|
|
15
15
|
|
|
16
|
-
### 🛡️ Core Mandates (Enterprise
|
|
16
|
+
### 🛡️ Core Mandates (Enterprise 1.0)
|
|
17
17
|
- **Read-Only Focus:** You are primarily a discovery role. Do not perform large-scale code changes without @manager approval.
|
|
18
18
|
- **Search-First:** Always use `search_codebase` before drawing conclusions.
|
|
19
19
|
- **Constraint Aware:** Respect the **Zero UI Library Policy** in all recommendations.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🏛️ Agent Enderun — Enterprise AI Governance & Autonomous Orchestration Framework
|
|
2
2
|
|
|
3
|
-
> **Stable Release:** v1.0
|
|
3
|
+
> **Stable Release:** v1.1.0 (Enterprise Orchestration Ready) — Build Compile: Clean | Type-Safety: 100% Verified | AL Compliance: 12/12 Agents
|
|
4
4
|
|
|
5
5
|
> **Author:** Yusuf BEKAR
|
|
6
6
|
> **Trace ID:** `01HGT8J5E2N0W0W0W0W0W0W0W5`
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
**Agent Enderun**, sıradan bir kod şablon üreteci veya basit bir AI asistanı değildir; karmaşık, ölçeklenebilir ve kurumsal (enterprise) düzeydeki yazılım projeleri için özel olarak tasarlanmış bir **Yapay Zeka Yönetişimi ve Otonom Ordu Komuta Sistemidir**.
|
|
14
14
|
|
|
15
|
-
Nihai temiz sürüm (v1.0
|
|
15
|
+
Nihai temiz sürüm (v1.1.0) itibarıyla sistem; **@-mention delegasyon**, **doğal dil rotalama** ve **Hermes Kilit Protokolü** ile güçlendirilmiş; kendi hafızasını yönetebilen, monorepo proje yollarını dinamik olarak haritalayan, tüm ajan seanslarını güvenli şekilde günlükleyen, farklı yapay zeka ekosistemlerini anayasal bir disiplin altında birleştiren, **Agent Lifecycle (AL) tam uyumlu init ve ordu validasyonunu** (npm kurulumu sonrası dahil) otomatikleştiren ve **macOS & Windows çapraz platform standartlarına tam uyum sağlayan** yaşayan bir mühendislik organizmasıdır. Karmaşık kurumsal projeler için optimize edilmiştir (corporate-governance SOP'ları ile).
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -22,15 +22,15 @@ Yapay zeka kodlama yardımcıları (Claude Code, Gemini CLI, Grok Build vb.) gel
|
|
|
22
22
|
|
|
23
23
|
1. **Kontrolsüz ve Hatalı Değişiklikler (Rogue AI):** Ajanların tüm kod dosyasını baştan yazmasını engelleyerek **milyonlarca satırlık kodları cerrahi hassasiyetle (`replace_text` / `patch_file` üzerinden)** değiştirmeye zorlar. Token tüketimini ve hata oranını %90 azaltır.
|
|
24
24
|
2. **Kayıp Hafıza ve Bağlam Drifti:** Ajanlar oturum değiştirdikçe projenin geçmişini ve mimari kararlarını unutur. Enderun, **`.enderun/memory/PROJECT_MEMORY.md`** dosyasını projenin değişmez tek doğruluk kaynağı (SSOT) haline getirerek, seanslar arası bağlam kaybını tamamen engeller.
|
|
25
|
-
3. **
|
|
25
|
+
3. **Akıllı Delegasyon ve Doğal Dil:** Artık karmaşık komutlar yerine `agent-enderun "Projemi denetle"` gibi doğal dildeki istekler veya `agent-enderun @backend "Tablo oluştur"` gibi doğrudan delegasyonlar kullanılabilir.
|
|
26
26
|
4. **Çoklu Ajan Kaosu:** **12** farklı uzman yapay zeka ajanı, olay tabanlı asenkron bir haberleşme protokolü olan **Hermes Message Broker** üzerinden koordine edilir. Ajanlar birbirine rastgele müdahale edemez; tüm görevler bir İş Dağılım Grafiği (DAG) üzerinden komuta edilir.
|
|
27
|
-
5. **
|
|
27
|
+
5. **Güvenli Haberleşme:** Yeni eklenen **Hermes Lock Protocol** sayesinde, birden fazla ajanın aynı anda mesajlaşması durumunda veri çakışmaları tamamen engellenir.
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
31
|
### 📦 Güncel Sürüm / Current Release
|
|
32
32
|
|
|
33
|
-
**v1.0
|
|
33
|
+
**v1.1.0** — Enterprise 1.0 kararlı sürüm (@-mentions, NL Routing, Hermes Lock Protocol). Detaylı sürüm geçmişi git log ve önceki commit'lerde bulunur; kalıbımız (bilingual TR/EN yapı, tablolar, bölümler) korunmuştur.
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
@@ -3,21 +3,44 @@ import path from "path";
|
|
|
3
3
|
import { resolveFrameworkDir } from "../../utils/security.js";
|
|
4
4
|
export function handleSendAgentMessage(projectRoot, args) {
|
|
5
5
|
const { to, category, content, traceId } = args;
|
|
6
|
-
// `from` is optional — falls back to "@mcp" for backward compatibility
|
|
7
6
|
const from = args.from || "@mcp";
|
|
8
7
|
const frameworkDir = resolveFrameworkDir(projectRoot);
|
|
8
|
+
const messagesDir = path.join(projectRoot, frameworkDir, "messages");
|
|
9
9
|
const agentName = to.replace("@", "");
|
|
10
|
-
const messagePath = path.join(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const messagePath = path.join(messagesDir, `${agentName}.json`);
|
|
11
|
+
const lockPath = path.join(messagesDir, ".lock");
|
|
12
|
+
// Hermes Lock Protocol: Retry 3 times with 500ms delay
|
|
13
|
+
let retries = 3;
|
|
14
|
+
while (retries > 0 && fs.existsSync(lockPath)) {
|
|
15
|
+
const stats = fs.statSync(lockPath);
|
|
16
|
+
if (Date.now() - stats.mtimeMs > 5000) {
|
|
17
|
+
fs.unlinkSync(lockPath);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
retries--;
|
|
21
|
+
if (retries > 0) {
|
|
22
|
+
const start = Date.now();
|
|
23
|
+
while (Date.now() - start < 500)
|
|
24
|
+
; // Simple busy wait for MCP environment
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
fs.mkdirSync(messagesDir, { recursive: true });
|
|
29
|
+
fs.writeFileSync(lockPath, `Locked by ${from} at ${new Date().toISOString()}`);
|
|
30
|
+
const message = {
|
|
31
|
+
timestamp: new Date().toISOString(),
|
|
32
|
+
from,
|
|
33
|
+
to,
|
|
34
|
+
category,
|
|
35
|
+
traceId,
|
|
36
|
+
content,
|
|
37
|
+
status: "PENDING"
|
|
38
|
+
};
|
|
39
|
+
fs.appendFileSync(messagePath, JSON.stringify(message) + "\n");
|
|
40
|
+
return { content: [{ type: "text", text: `✅ Message sent to ${to} (from: ${from})` }] };
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (fs.existsSync(lockPath))
|
|
44
|
+
fs.unlinkSync(lockPath);
|
|
45
|
+
}
|
|
23
46
|
}
|
|
@@ -5,25 +5,46 @@ import { ToolArgs, ToolResult } from "../types.js";
|
|
|
5
5
|
|
|
6
6
|
export function handleSendAgentMessage(projectRoot: string, args: ToolArgs): ToolResult {
|
|
7
7
|
const { to, category, content, traceId } = args as Required<Pick<ToolArgs, "to" | "category" | "content" | "traceId">>;
|
|
8
|
-
// `from` is optional — falls back to "@mcp" for backward compatibility
|
|
9
8
|
const from = (args.from as string) || "@mcp";
|
|
10
9
|
|
|
11
10
|
const frameworkDir = resolveFrameworkDir(projectRoot);
|
|
11
|
+
const messagesDir = path.join(projectRoot, frameworkDir, "messages");
|
|
12
12
|
const agentName = to.replace("@", "");
|
|
13
|
-
const messagePath = path.join(
|
|
13
|
+
const messagePath = path.join(messagesDir, `${agentName}.json`);
|
|
14
|
+
const lockPath = path.join(messagesDir, ".lock");
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
// Hermes Lock Protocol: Retry 3 times with 500ms delay
|
|
17
|
+
let retries = 3;
|
|
18
|
+
while (retries > 0 && fs.existsSync(lockPath)) {
|
|
19
|
+
const stats = fs.statSync(lockPath);
|
|
20
|
+
if (Date.now() - stats.mtimeMs > 5000) {
|
|
21
|
+
fs.unlinkSync(lockPath);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
retries--;
|
|
25
|
+
if (retries > 0) {
|
|
26
|
+
const start = Date.now();
|
|
27
|
+
while (Date.now() - start < 500); // Simple busy wait for MCP environment
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
try {
|
|
32
|
+
fs.mkdirSync(messagesDir, { recursive: true });
|
|
33
|
+
fs.writeFileSync(lockPath, `Locked by ${from} at ${new Date().toISOString()}`);
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
const message = {
|
|
36
|
+
timestamp: new Date().toISOString(),
|
|
37
|
+
from,
|
|
38
|
+
to,
|
|
39
|
+
category,
|
|
40
|
+
traceId,
|
|
41
|
+
content,
|
|
42
|
+
status: "PENDING"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
fs.appendFileSync(messagePath, JSON.stringify(message) + "\n");
|
|
46
|
+
return { content: [{ type: "text", text: `✅ Message sent to ${to} (from: ${from})` }] };
|
|
47
|
+
} finally {
|
|
48
|
+
if (fs.existsSync(lockPath)) fs.unlinkSync(lockPath);
|
|
49
|
+
}
|
|
29
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-enderun",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The Supreme AI Governance & Orchestration Framework for Enterprise Development",
|
|
5
5
|
"author": "Yusuf BEKAR",
|
|
6
6
|
"license": "MIT",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"zod": "^3.24.2"
|
|
83
83
|
},
|
|
84
84
|
"enderun": {
|
|
85
|
-
"version": "1.0
|
|
85
|
+
"version": "1.1.0",
|
|
86
86
|
"initializedAt": "2026-05-31T09:58:25.773Z",
|
|
87
87
|
"frameworkDir": ".enderun"
|
|
88
88
|
},
|
|
@@ -88,6 +88,59 @@ export async function orchestrateCommand() {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export function sendMessage(args: {
|
|
92
|
+
from: string;
|
|
93
|
+
to: string;
|
|
94
|
+
category: string;
|
|
95
|
+
content: string;
|
|
96
|
+
traceId: string;
|
|
97
|
+
}) {
|
|
98
|
+
const frameworkDir = getFrameworkDir();
|
|
99
|
+
const messagesDir = path.join(process.cwd(), frameworkDir, "messages");
|
|
100
|
+
const agentName = args.to.replace("@", "");
|
|
101
|
+
const messagePath = path.join(messagesDir, `${agentName}.json`);
|
|
102
|
+
const lockPath = path.join(messagesDir, ".lock");
|
|
103
|
+
|
|
104
|
+
// Hermes Lock Protocol: Retry 3 times with 500ms delay
|
|
105
|
+
let retries = 3;
|
|
106
|
+
while (retries > 0 && fs.existsSync(lockPath)) {
|
|
107
|
+
const stats = fs.statSync(lockPath);
|
|
108
|
+
// Stale lock check (older than 5 seconds)
|
|
109
|
+
if (Date.now() - stats.mtimeMs > 5000) {
|
|
110
|
+
fs.unlinkSync(lockPath);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
retries--;
|
|
114
|
+
if (retries > 0) {
|
|
115
|
+
// Synchronous sleep for CLI simplicity
|
|
116
|
+
const g = global as unknown as { Atomics: { wait: (ia: Int32Array, index: number, value: number, timeout: number) => string }; SharedArrayBuffer: { new (size: number): ArrayBufferLike } };
|
|
117
|
+
if (g.Atomics && g.SharedArrayBuffer) {
|
|
118
|
+
g.Atomics.wait(new Int32Array(new g.SharedArrayBuffer(4)), 0, 0, 500);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
fs.mkdirSync(messagesDir, { recursive: true });
|
|
125
|
+
fs.writeFileSync(lockPath, `Locked by ${args.from} at ${new Date().toISOString()}`);
|
|
126
|
+
|
|
127
|
+
const message = {
|
|
128
|
+
timestamp: new Date().toISOString(),
|
|
129
|
+
from: args.from,
|
|
130
|
+
to: args.to,
|
|
131
|
+
category: args.category,
|
|
132
|
+
traceId: args.traceId,
|
|
133
|
+
content: args.content,
|
|
134
|
+
status: "PENDING"
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
fs.appendFileSync(messagePath, JSON.stringify(message) + "\n");
|
|
138
|
+
return message;
|
|
139
|
+
} finally {
|
|
140
|
+
if (fs.existsSync(lockPath)) fs.unlinkSync(lockPath);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
91
144
|
function transitionAgentState(agent: string, state: string, task: string) {
|
|
92
145
|
const frameworkDir = getFrameworkDir();
|
|
93
146
|
const statusPath = path.join(process.cwd(), frameworkDir, "STATUS.md");
|
package/src/cli/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { traceNewCommand } from "./commands/trace.js";
|
|
|
8
8
|
import { updateProjectMemoryCommand } from "./commands/memory.js";
|
|
9
9
|
import { createAppCommand } from "./commands/app.js";
|
|
10
10
|
import { verifyApiContractCommand, updateApiContractCommand } from "./commands/contract.js";
|
|
11
|
-
import { orchestrateCommand } from "./commands/orchestrate.js";
|
|
11
|
+
import { orchestrateCommand, sendMessage } from "./commands/orchestrate.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Main CLI entry point.
|
|
@@ -17,6 +17,48 @@ async function main() {
|
|
|
17
17
|
const args = process.argv.slice(2);
|
|
18
18
|
const command = args[0];
|
|
19
19
|
|
|
20
|
+
const KNOWN_COMMANDS = [
|
|
21
|
+
"init", "check", "status", "trace:new", "update_project_memory",
|
|
22
|
+
"create-app", "orchestrate", "verify-contract", "update-contract",
|
|
23
|
+
"validate", "validate-army", "check:al", "version", "-v", "--version", "help", "-h", "--help"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// Handle @agent delegation syntax
|
|
27
|
+
if (command?.startsWith("@")) {
|
|
28
|
+
const to = command;
|
|
29
|
+
const content = args.slice(1).join(" ");
|
|
30
|
+
if (!content) {
|
|
31
|
+
console.error(`❌ Error: Missing task content for ${to}.`);
|
|
32
|
+
console.log(`Usage: agent-enderun ${to} "Your task description"`);
|
|
33
|
+
process.exit(64);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { getMemoryPath } = await import("./utils/memory.js");
|
|
37
|
+
const fs = await import("fs");
|
|
38
|
+
const memoryPath = getMemoryPath();
|
|
39
|
+
|
|
40
|
+
let traceId = "T-000";
|
|
41
|
+
if (fs.default.existsSync(memoryPath)) {
|
|
42
|
+
const content = fs.default.readFileSync(memoryPath, "utf8");
|
|
43
|
+
// More robust regex: look for any ULID-like string in the Active Trace ID column or near the label
|
|
44
|
+
const match = content.match(/Active Trace ID\s*\|.*\|\s*\n\|.*\|.*\|.*\|\s*([A-Z0-9]+)\s*\|/i) ||
|
|
45
|
+
content.match(/Active Trace ID[:\s|]+([A-Z0-9]+)/i);
|
|
46
|
+
if (match) traceId = match[1].trim();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
sendMessage({
|
|
50
|
+
from: "@manager",
|
|
51
|
+
to,
|
|
52
|
+
category: "DELEGATION",
|
|
53
|
+
content,
|
|
54
|
+
traceId
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(`✅ Task delegated to ${to} (Trace: ${traceId})`);
|
|
58
|
+
console.log("👉 Run \"agent-enderun orchestrate\" to process.");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
20
62
|
switch (command) {
|
|
21
63
|
case "init": {
|
|
22
64
|
const dryRun = args.includes("--dry-run");
|
|
@@ -71,14 +113,12 @@ async function main() {
|
|
|
71
113
|
case "validate":
|
|
72
114
|
case "validate-army":
|
|
73
115
|
case "check:al": {
|
|
74
|
-
// Dedicated AL (Agent Lifecycle) army validation - can be run independently after init
|
|
75
|
-
// Always resolve via getValidatorPath() so 'agent-enderun validate' works after npm install (cross-adapter too).
|
|
76
116
|
const { execSync } = await import("child_process");
|
|
77
117
|
try {
|
|
78
118
|
const validatorPath = getValidatorPath();
|
|
79
119
|
execSync(`node "${validatorPath}"`, { stdio: "inherit" });
|
|
80
120
|
} catch {
|
|
81
|
-
//
|
|
121
|
+
// handled by validator
|
|
82
122
|
}
|
|
83
123
|
break;
|
|
84
124
|
}
|
|
@@ -92,17 +132,56 @@ async function main() {
|
|
|
92
132
|
case "help":
|
|
93
133
|
case "-h":
|
|
94
134
|
case "--help":
|
|
135
|
+
showHelp();
|
|
136
|
+
break;
|
|
137
|
+
|
|
95
138
|
default:
|
|
96
|
-
|
|
139
|
+
if (command && !KNOWN_COMMANDS.includes(command)) {
|
|
140
|
+
// Natural language request fallback to @manager
|
|
141
|
+
const content = args.join(" ");
|
|
142
|
+
const { getMemoryPath } = await import("./utils/memory.js");
|
|
143
|
+
const fs = await import("fs");
|
|
144
|
+
const memoryPath = getMemoryPath();
|
|
145
|
+
|
|
146
|
+
let traceId = "T-000";
|
|
147
|
+
if (fs.default.existsSync(memoryPath)) {
|
|
148
|
+
const content = fs.default.readFileSync(memoryPath, "utf8");
|
|
149
|
+
// More robust regex: look for any ULID-like string in the Active Trace ID column or near the label
|
|
150
|
+
const match = content.match(/Active Trace ID\s*\|.*\|\s*\n\|.*\|.*\|.*\|\s*([A-Z0-9]+)\s*\|/i) ||
|
|
151
|
+
content.match(/Active Trace ID[:\s|]+([A-Z0-9]+)/i);
|
|
152
|
+
if (match) traceId = match[1].trim();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
sendMessage({
|
|
156
|
+
from: "@user",
|
|
157
|
+
to: "@manager",
|
|
158
|
+
category: "ACTION",
|
|
159
|
+
content,
|
|
160
|
+
traceId
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
console.log(`📡 Request sent to @manager: "${content}" (Trace: ${traceId})`);
|
|
164
|
+
console.log("👉 Run 'agent-enderun orchestrate' to process.");
|
|
165
|
+
} else {
|
|
166
|
+
showHelp();
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function showHelp() {
|
|
173
|
+
console.log(`
|
|
97
174
|
🤖 Agent Enderun CLI — Enterprise AI Orchestration
|
|
98
175
|
|
|
99
176
|
Usage:
|
|
100
177
|
agent-enderun <command> [options]
|
|
178
|
+
agent-enderun @<agent> "task description"
|
|
179
|
+
agent-enderun "natural language request"
|
|
101
180
|
|
|
102
181
|
Commands:
|
|
182
|
+
@<agent> <task> Delegate a task to a specialist agent (e.g. @backend, @frontend)
|
|
103
183
|
init [adapter] Initialize Agent Enderun framework (gemini, claude, grok, etc.)
|
|
104
|
-
check Perform an enterprise-grade system health check
|
|
105
|
-
validate Run dedicated Agent Lifecycle (AL) army validation (validate-agent-army)
|
|
184
|
+
check Perform an enterprise-grade system health check
|
|
106
185
|
status Show active phase, trace ID, and agent statuses
|
|
107
186
|
trace:new <desc> Start a new task chain with a unique Trace ID
|
|
108
187
|
create-app <idea> Generate a new full-stack app from natural language
|
|
@@ -111,20 +190,14 @@ Commands:
|
|
|
111
190
|
update-contract Generate and synchronize a new contract hash
|
|
112
191
|
version Show version information
|
|
113
192
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- grok → .enderun/ (SSOT) + grok.md
|
|
118
|
-
- antigravity → .enderun/ (SSOT) + agent.md
|
|
193
|
+
Natural Language:
|
|
194
|
+
If you provide a sentence that is not a known command, it will be automatically
|
|
195
|
+
sent to the @manager for orchestration.
|
|
119
196
|
|
|
120
197
|
Example:
|
|
121
|
-
agent-enderun
|
|
122
|
-
agent-enderun
|
|
123
|
-
|
|
124
|
-
agent-enderun trace:new "Auth module design" backend P1
|
|
125
|
-
`);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
198
|
+
agent-enderun "Projemi denetle"
|
|
199
|
+
agent-enderun @backend "Login sayfasını oluştur"
|
|
200
|
+
`);
|
|
128
201
|
}
|
|
129
202
|
|
|
130
203
|
main().catch(console.error);
|