agent-enderun 1.11.3 → 1.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +84 -277
  2. package/bin/validate-agent-army.js +0 -1
  3. package/dist/framework-mcp/src/index.js +11 -1
  4. package/dist/framework-mcp/src/index.js.map +1 -1
  5. package/dist/framework-mcp/src/tools/control_plane/locking.js +17 -3
  6. package/dist/framework-mcp/src/tools/control_plane/locking.js.map +1 -1
  7. package/dist/framework-mcp/src/tools/definitions.js +0 -10
  8. package/dist/framework-mcp/src/tools/definitions.js.map +1 -1
  9. package/dist/framework-mcp/src/tools/index.js +0 -2
  10. package/dist/framework-mcp/src/tools/index.js.map +1 -1
  11. package/dist/framework-mcp/src/tools/memory/get_insights.js +4 -4
  12. package/dist/framework-mcp/src/tools/memory/get_insights.js.map +1 -1
  13. package/dist/framework-mcp/src/tools/messaging/send_message.js +10 -5
  14. package/dist/framework-mcp/src/tools/messaging/send_message.js.map +1 -1
  15. package/dist/framework-mcp/src/tools/search/grep_search.js +2 -3
  16. package/dist/framework-mcp/src/tools/search/grep_search.js.map +1 -1
  17. package/dist/framework-mcp/src/utils/compliance.d.ts +1 -1
  18. package/dist/framework-mcp/src/utils/compliance.js +68 -19
  19. package/dist/framework-mcp/src/utils/compliance.js.map +1 -1
  20. package/dist/framework-mcp/tests/tools/messaging/send_message.test.js +7 -7
  21. package/dist/framework-mcp/tests/tools/messaging/send_message.test.js.map +1 -1
  22. package/dist/src/cli/adapters/scaffold.d.ts +1 -1
  23. package/dist/src/cli/adapters/scaffold.js +8 -8
  24. package/dist/src/cli/adapters/scaffold.js.map +1 -1
  25. package/dist/src/cli/commands/check.js +25 -40
  26. package/dist/src/cli/commands/check.js.map +1 -1
  27. package/dist/src/cli/commands/contract.d.ts +3 -1
  28. package/dist/src/cli/commands/contract.js +8 -2
  29. package/dist/src/cli/commands/contract.js.map +1 -1
  30. package/dist/src/cli/commands/init/scaffold-core.d.ts +1 -0
  31. package/dist/src/cli/commands/init/scaffold-core.js +14 -1
  32. package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
  33. package/dist/src/cli/commands/init/scaffold-ops.js +0 -2
  34. package/dist/src/cli/commands/init/scaffold-ops.js.map +1 -1
  35. package/dist/src/cli/commands/init.d.ts +1 -0
  36. package/dist/src/cli/commands/init.js +16 -7
  37. package/dist/src/cli/commands/init.js.map +1 -1
  38. package/dist/src/cli/commands/orchestrate.js +31 -3
  39. package/dist/src/cli/commands/orchestrate.js.map +1 -1
  40. package/dist/src/cli/commands/plan.js +1 -2
  41. package/dist/src/cli/commands/plan.js.map +1 -1
  42. package/dist/src/cli/commands/status.js.map +1 -1
  43. package/dist/src/cli/index.js +18 -21
  44. package/dist/src/cli/index.js.map +1 -1
  45. package/dist/src/cli/shims.js +39 -26
  46. package/dist/src/cli/shims.js.map +1 -1
  47. package/dist/src/cli/utils/compliance.d.ts +5 -1
  48. package/dist/src/cli/utils/compliance.js +90 -42
  49. package/dist/src/cli/utils/compliance.js.map +1 -1
  50. package/dist/src/cli/utils/ui.js +11 -11
  51. package/dist/src/cli/utils/ui.js.map +1 -1
  52. package/dist/src/modules/adapters/definitions.js +130 -113
  53. package/dist/src/modules/adapters/definitions.js.map +1 -1
  54. package/dist/src/modules/adapters/registry.d.ts +12 -0
  55. package/dist/src/modules/adapters/registry.js +19 -0
  56. package/dist/src/modules/adapters/registry.js.map +1 -0
  57. package/dist/src/modules/adapters/shared.js +5 -4
  58. package/dist/src/modules/adapters/shared.js.map +1 -1
  59. package/dist/src/modules/adapters/types.d.ts +1 -1
  60. package/dist/src/modules/adapters/types.js +1 -1
  61. package/dist/src/modules/adapters/types.js.map +1 -1
  62. package/dist/src/modules/agents/definitions.d.ts +6 -6
  63. package/dist/src/modules/agents/definitions.js +35 -18
  64. package/dist/src/modules/agents/definitions.js.map +1 -1
  65. package/dist/src/modules/agents/registry/analyst.js +1 -1
  66. package/dist/src/modules/agents/registry/analyst.js.map +1 -1
  67. package/dist/src/modules/agents/registry/architect.js +1 -1
  68. package/dist/src/modules/agents/registry/architect.js.map +1 -1
  69. package/dist/src/modules/agents/registry/backend.js +1 -1
  70. package/dist/src/modules/agents/registry/backend.js.map +1 -1
  71. package/dist/src/modules/agents/registry/database.js +1 -1
  72. package/dist/src/modules/agents/registry/database.js.map +1 -1
  73. package/dist/src/modules/agents/registry/devops.js +1 -1
  74. package/dist/src/modules/agents/registry/devops.js.map +1 -1
  75. package/dist/src/modules/agents/registry/explorer.js +1 -1
  76. package/dist/src/modules/agents/registry/explorer.js.map +1 -1
  77. package/dist/src/modules/agents/registry/frontend.js +1 -1
  78. package/dist/src/modules/agents/registry/frontend.js.map +1 -1
  79. package/dist/src/modules/agents/registry/git.js +1 -1
  80. package/dist/src/modules/agents/registry/git.js.map +1 -1
  81. package/dist/src/modules/agents/registry/manager.js +1 -2
  82. package/dist/src/modules/agents/registry/manager.js.map +1 -1
  83. package/dist/src/modules/agents/registry/mobile.js +1 -1
  84. package/dist/src/modules/agents/registry/mobile.js.map +1 -1
  85. package/dist/src/modules/agents/registry/quality.js +1 -1
  86. package/dist/src/modules/agents/registry/quality.js.map +1 -1
  87. package/dist/src/modules/agents/registry/security.js +1 -1
  88. package/dist/src/modules/agents/registry/security.js.map +1 -1
  89. package/dist/src/shared/constants.d.ts +5 -2
  90. package/dist/src/shared/constants.js +5 -0
  91. package/dist/src/shared/constants.js.map +1 -1
  92. package/dist/src/shared/fs.js +4 -3
  93. package/dist/src/shared/fs.js.map +1 -1
  94. package/dist/tests/agents-definitions.test.js +2 -1
  95. package/dist/tests/agents-definitions.test.js.map +1 -1
  96. package/dist/tests/approve.test.js +3 -1
  97. package/dist/tests/approve.test.js.map +1 -1
  98. package/dist/tests/integration/agent_flow.test.js +2 -0
  99. package/dist/tests/integration/agent_flow.test.js.map +1 -1
  100. package/dist/tests/integration/hermes_locking.test.d.ts +1 -0
  101. package/dist/tests/integration/hermes_locking.test.js +64 -0
  102. package/dist/tests/integration/hermes_locking.test.js.map +1 -0
  103. package/dist/tests/memory-utils.test.js +2 -0
  104. package/dist/tests/memory-utils.test.js.map +1 -1
  105. package/dist/tests/orchestrate.test.js +11 -6
  106. package/dist/tests/orchestrate.test.js.map +1 -1
  107. package/dist/tests/status.test.js +2 -0
  108. package/dist/tests/status.test.js.map +1 -1
  109. package/framework-mcp/dist/index.js +11 -1
  110. package/framework-mcp/dist/tools/control_plane/locking.js +17 -3
  111. package/framework-mcp/dist/tools/definitions.js +0 -10
  112. package/framework-mcp/dist/tools/index.js +0 -2
  113. package/framework-mcp/dist/tools/memory/get_insights.js +4 -4
  114. package/framework-mcp/dist/tools/messaging/send_message.js +10 -5
  115. package/framework-mcp/dist/tools/search/grep_search.js +2 -3
  116. package/framework-mcp/dist/utils/compliance.js +68 -19
  117. package/framework-mcp/node_modules/.package-lock.json +1179 -0
  118. package/framework-mcp/package-lock.json +1191 -0
  119. package/framework-mcp/package.json +2 -2
  120. package/framework-mcp/src/index.ts +13 -1
  121. package/framework-mcp/src/tools/control_plane/locking.ts +18 -4
  122. package/framework-mcp/src/tools/definitions.ts +0 -10
  123. package/framework-mcp/src/tools/index.ts +0 -2
  124. package/framework-mcp/src/tools/memory/get_insights.ts +4 -4
  125. package/framework-mcp/src/tools/messaging/send_message.ts +11 -5
  126. package/framework-mcp/src/tools/search/grep_search.ts +2 -3
  127. package/framework-mcp/src/utils/compliance.ts +83 -25
  128. package/framework-mcp/tests/tools/messaging/send_message.test.ts +7 -7
  129. package/package.json +5 -5
  130. package/src/cli/adapters/scaffold.ts +9 -8
  131. package/src/cli/commands/check.ts +26 -48
  132. package/src/cli/commands/contract.ts +5 -2
  133. package/src/cli/commands/init/scaffold-core.ts +18 -2
  134. package/src/cli/commands/init/scaffold-ops.ts +0 -3
  135. package/src/cli/commands/init.ts +19 -8
  136. package/src/cli/commands/orchestrate.ts +36 -3
  137. package/src/cli/commands/plan.ts +1 -2
  138. package/src/cli/commands/status.ts +0 -1
  139. package/src/cli/index.ts +18 -22
  140. package/src/cli/shims.ts +39 -26
  141. package/src/cli/utils/compliance.ts +101 -47
  142. package/src/cli/utils/ui.ts +11 -11
  143. package/src/modules/adapters/definitions.ts +102 -57
  144. package/src/modules/adapters/registry.ts +27 -0
  145. package/src/modules/adapters/shared.ts +5 -4
  146. package/src/modules/adapters/types.ts +1 -1
  147. package/src/modules/agents/definitions.ts +35 -17
  148. package/src/modules/agents/registry/analyst.ts +1 -1
  149. package/src/modules/agents/registry/architect.ts +1 -1
  150. package/src/modules/agents/registry/backend.ts +1 -1
  151. package/src/modules/agents/registry/database.ts +1 -1
  152. package/src/modules/agents/registry/devops.ts +1 -1
  153. package/src/modules/agents/registry/explorer.ts +1 -1
  154. package/src/modules/agents/registry/frontend.ts +1 -1
  155. package/src/modules/agents/registry/git.ts +1 -1
  156. package/src/modules/agents/registry/manager.ts +1 -2
  157. package/src/modules/agents/registry/mobile.ts +1 -1
  158. package/src/modules/agents/registry/quality.ts +1 -1
  159. package/src/modules/agents/registry/security.ts +1 -1
  160. package/src/shared/constants.ts +5 -0
  161. package/src/shared/fs.ts +4 -3
  162. package/templates/standards/frontend-standards.md +7 -2
  163. package/templates/standards/governance-standards.md +27 -1
  164. package/templates/standards/quality-standards.md +2 -1
  165. package/bin/enderun-dashboard.js +0 -25
  166. package/framework-mcp/src/tools/dashboard/start_dashboard.ts +0 -33
  167. package/src/cli/commands/dashboard/data-service.ts +0 -167
  168. package/src/cli/commands/dashboard/html-template.ts +0 -696
  169. package/src/cli/commands/dashboard/server.ts +0 -43
  170. package/src/cli/commands/dashboard.ts +0 -11
@@ -32,6 +32,7 @@ export const ADAPTER_DIRS = {
32
32
  CURSOR: ".cursor",
33
33
  CODEX: ".agents",
34
34
  ANTIGRAVITY: ".antigravity",
35
+ LOCAL: ".enderun",
35
36
  LEGACY_AGENT: ".agent",
36
37
  } as const;
37
38
 
@@ -44,6 +45,7 @@ export const FRAMEWORK_DIR_CANDIDATES = [
44
45
  ADAPTER_DIRS.GROK,
45
46
  ADAPTER_DIRS.CURSOR,
46
47
  ADAPTER_DIRS.ANTIGRAVITY,
48
+ ADAPTER_DIRS.LOCAL,
47
49
  ] as const;
48
50
 
49
51
  /** Slug under `.agents/{slug}/` for each adapter in unified mode. */
@@ -53,6 +55,7 @@ export const UNIFIED_ADAPTER_SLUG = {
53
55
  grok: "grok",
54
56
  cursor: "cursor",
55
57
  codex: "codex",
58
+ local: "local",
56
59
  "antigravity-cli": "antigravity",
57
60
  } as const;
58
61
 
@@ -66,6 +69,7 @@ export const NATIVE_AGENT_PATHS = {
66
69
  grok: pathJoin(ADAPTER_DIRS.GROK, "agents"),
67
70
  cursor: pathJoin(ADAPTER_DIRS.CURSOR, "rules"),
68
71
  codex: pathJoin(ADAPTER_DIRS.CODEX, "instructions"),
72
+ local: pathJoin(ADAPTER_DIRS.LOCAL, "agents"),
69
73
  "antigravity-cli": pathJoin(ADAPTER_DIRS.ANTIGRAVITY, "agents"),
70
74
  } as const;
71
75
 
@@ -76,6 +80,7 @@ export const LEGACY_AGENT_LAYOUT_BASES = [
76
80
  NATIVE_AGENT_PATHS.cursor,
77
81
  NATIVE_AGENT_PATHS.grok,
78
82
  NATIVE_AGENT_PATHS.codex,
83
+ NATIVE_AGENT_PATHS.local,
79
84
  NATIVE_AGENT_PATHS["antigravity-cli"],
80
85
  ] as const;
81
86
 
package/src/shared/fs.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { logger } from "./logger.js";
3
4
 
4
5
  export function ensureDir(dirPath: string, dryRun = false): void {
5
6
  if (!fs.existsSync(dirPath)) {
6
7
  if (dryRun) {
7
- console.warn(`[DRY RUN] Would create directory: ${dirPath}`);
8
+ logger.info(`[DRY RUN] Would create directory: ${dirPath}`);
8
9
  } else {
9
10
  fs.mkdirSync(dirPath, { recursive: true });
10
11
  }
@@ -17,7 +18,7 @@ export function ensureDir(dirPath: string, dryRun = false): void {
17
18
  */
18
19
  export function writeTextFile(filePath: string, content: string, dryRun = false): void {
19
20
  if (dryRun) {
20
- console.warn(`[DRY RUN] Would write file: ${filePath}`);
21
+ logger.info(`[DRY RUN] Would write file: ${filePath}`);
21
22
  return;
22
23
  }
23
24
  const dir = path.dirname(filePath);
@@ -37,7 +38,7 @@ export function writeTextFile(filePath: string, content: string, dryRun = false)
37
38
 
38
39
  export function appendFile(filePath: string, content: string, dryRun = false): void {
39
40
  if (dryRun) {
40
- console.warn(`[DRY RUN] Would append to file: ${filePath}`);
41
+ logger.info(`[DRY RUN] Would append to file: ${filePath}`);
41
42
  return;
42
43
  }
43
44
  ensureDir(path.dirname(filePath));
@@ -2,8 +2,13 @@
2
2
 
3
3
  This document defines the UI/UX standards for projects managed by Agent Enderun. All interfaces must comply with "Mobile-First", "Fluid Responsive", and "Cross-Device Adaptive" principles.
4
4
 
5
- ## 1. Design System: Panda CSS & Tailwind Integration
6
- - **Zero UI Library:** Heavy external UI libraries like Ant Design or MUI are not used. All styles are written with type-safe **Panda CSS** or structured **Tailwind CSS**.
5
+ ## 1. Zero UI Library Policy (Supreme Mandate)
6
+ - **NO Third-Party UI Frameworks:** Usage of `@chakra-ui`, `mui`, `@shadcn`, `antd`, or similar pre-built component libraries is **STRICTLY FORBIDDEN**.
7
+ - **Atomic Manual Construction:** Every UI component (Button, Modal, Input, etc.) must be built manually from scratch using atomic CSS principles.
8
+ - **Styling Engine:** All styles must be written with type-safe **Panda CSS** or structured **Tailwind CSS**.
9
+ - **Reasoning:** Pre-built libraries introduce massive bloat, difficult-to-override styles, and dependency lock-in. Agent Enderun enforces pure, lightweight, and 100% customizable UI code.
10
+
11
+ ## 2. Design System: Panda CSS & Tailwind Integration
7
12
  - **Token Usage:** Colors, spacing, and font sizes must be managed via the `token()` function or standard CSS variables.
8
13
  - **Responsive Syntax:** Object-based responsive syntax is mandatory:
9
14
  ```typescript
@@ -28,7 +28,33 @@ A single TODO, lint error, or unverified contract blocks the phase transition.
28
28
 
29
29
  ---
30
30
 
31
- ## 3. Trace ID Discipline
31
+ ## 3. Hermes Self-Healing Protocol
32
+ - If an agent remains in `EXECUTING` state for >30 minutes, the orchestrator triggers **Self-Healing**.
33
+ - The agent is reset to `READY`, and the task is logged for human review or retry.
34
+ - Blocked agents should not be left abandoned; they must be recovered to keep the loop fluid.
35
+
36
+ ---
37
+
38
+ ## 4. Proportional Governance Model (Autonomy Levels)
39
+ Governance controls are mapped to agent autonomy to ensure safety and EU AI Act compliance.
40
+
41
+ | Level | Mode | Authority | Governance Focus |
42
+ |---|---|---|---|
43
+ | **L1** | Observe | Read-only access | Scoped data access, usage logging |
44
+ | **L2** | Advise | Recommendations only | Accuracy checks, bias mitigation |
45
+ | **L3** | Guided | Action with human "OK" | Meaningful human review (No rubber-stamping) |
46
+ | **L4** | Autonomous| Independent execution | **Circuit breakers**, real-time monitoring |
47
+
48
+ ---
49
+
50
+ ## 5. Circuit Breaker & Kill Switch Protocol
51
+ - **L4 Emergency Stop:** Every autonomous agent **must** support an immediate "Kill Switch" signal.
52
+ - **Recursive Failure Guard:** If an agent chain (Agent A calling Agent B) fails twice at the same node, the entire Trace ID is **Frozen** until human intervention.
53
+ - **Audit Traceability:** Every autonomous action must be attributable to a unique **Agent ID** and **Trace ID** in an immutable log.
54
+
55
+ ---
56
+
57
+ ## 6. Trace ID Discipline
32
58
 
33
59
  - Every task chain begins with a unique Trace ID (e.g. `TRC-042`).
34
60
  - All agent messages, logs, and commits **must** carry the active Trace ID.
@@ -7,7 +7,8 @@ This document defines the technical discipline rules that all code produced by t
7
7
  - **No Explicit Any:** The use of `any` is strictly forbidden. `unknown` should be used for uncertain types and verified with type guards.
8
8
  - **Exhaustive Checks:** All cases must be checked (exhaustive) in `switch-case` structures, or safety must be provided with the `never` type.
9
9
 
10
- ## 2. ESLint and Static Analysis
10
+ ## 2. ESLint and Static Analysis (AST Enforced)
11
+ - **Real-Time AST Audits:** Every file mutation by an agent is scanned via **Abstract Syntax Tree (AST)** analysis. Prohibited patterns (`any`, `console.log`) are blocked at the protocol level.
11
12
  - **Zero Warnings:** No ESLint warnings or errors can exist in the codebase.
12
13
  - **Naming Conventions:**
13
14
  - Variables and functions: `camelCase`
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
3
- import { fileURLToPath } from "node:url";
4
- import { dirname, join } from "node:path";
5
- import fs from "node:fs";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = dirname(__filename);
9
-
10
- const cliPath = join(__dirname, "../dist/src/cli/index.js");
11
-
12
- if (!fs.existsSync(cliPath)) {
13
- process.stderr.write("\n❌ Error: Compiled CLI not found at 'dist/src/cli/index.js'\n");
14
- process.stderr.write("💡 Solution Tip: Run 'npm run build' to compile the project first.\n\n");
15
- process.exit(1);
16
- }
17
-
18
- const child = spawn("node", [cliPath, "dashboard", ...process.argv.slice(2)], {
19
- stdio: "inherit",
20
- shell: false
21
- });
22
-
23
- child.on("exit", (code) => {
24
- process.exit(code ?? 0);
25
- });
@@ -1,33 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { exec } from "child_process";
4
- import { StartDashboardArgs, ToolResult } from "../types.js";
5
-
6
- /**
7
- * Starts the Enderun Web Dashboard server.
8
- */
9
- export function handleStartDashboard(projectRoot: string, args: StartDashboardArgs): ToolResult {
10
- const port = args.port || 5858;
11
- const dashboardScript = path.join(projectRoot, "bin/enderun-dashboard.js");
12
-
13
- if (!fs.existsSync(dashboardScript)) {
14
- throw new Error("Dashboard server script not found in bin/enderun-dashboard.js");
15
- }
16
-
17
- try {
18
- // Start the dashboard as a background process
19
- exec(`node "${dashboardScript}"`, {
20
- cwd: projectRoot,
21
- env: { ...process.env, PORT: String(port) }
22
- });
23
-
24
- return {
25
- content: [{
26
- type: "text",
27
- text: `🖥️ **Enderun Web Dashboard started!**\n\nAccess it at: http://localhost:${port}\n\nThis interface will show real-time agent status, system health, and orchestration logs.`
28
- }]
29
- };
30
- } catch (e) {
31
- return { isError: true, content: [{ type: "text", text: `Failed to start dashboard: ${String(e)}` }] };
32
- }
33
- }
@@ -1,167 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { getFrameworkDir } from "../../utils/memory.js";
4
-
5
- export function parseProjectMemory() {
6
- const frameworkDir = getFrameworkDir();
7
- if (!frameworkDir) return { error: "No framework directory found. Run init." };
8
-
9
- const memPath = path.join(frameworkDir, "memory/PROJECT_MEMORY.md");
10
- if (!fs.existsSync(memPath)) return { error: "PROJECT_MEMORY.md not found" };
11
-
12
- try {
13
- const content = fs.readFileSync(memPath, "utf8");
14
-
15
- // Parse Phase & Trace ID
16
- const phaseMatch = content.match(/Phase:\s*([^\n\r]+)/i);
17
- const traceMatch = content.match(/Trace ID:\s*([^\n\r]+)/i);
18
- const managerMatch = content.match(/@manager state:\s*([^\n\r]+)/i);
19
-
20
- // Parse Active Tasks Table
21
- const tasks = [];
22
- const lines = content.split("\n");
23
- let inTaskTable = false;
24
-
25
- for (const line of lines) {
26
- if (line.includes("| Trace ID | Task |")) {
27
- inTaskTable = true;
28
- continue;
29
- }
30
- if (inTaskTable && line.trim() === "") {
31
- inTaskTable = false;
32
- continue;
33
- }
34
- if (inTaskTable && line.startsWith("|") && !line.includes(":---")) {
35
- const cols = line.split("|").map(c => c.trim()).filter(Boolean);
36
- if (cols.length >= 5) {
37
- tasks.push({
38
- traceId: cols[0],
39
- task: cols[1],
40
- agent: cols[2],
41
- priority: cols[3],
42
- status: cols[4]
43
- });
44
- }
45
- }
46
- }
47
-
48
- // Parse History Section
49
- const history = [];
50
- const historyParts = content.split(/##\s+HISTORY/i);
51
- if (historyParts[1]) {
52
- const histLines = historyParts[1].split("\n");
53
- let currentItem: { title: string, body: string[] } | null = null;
54
- for (const line of histLines) {
55
- if (line.startsWith("###")) {
56
- if (currentItem) history.push(currentItem);
57
- currentItem = { title: line.replace("###", "").trim(), body: [] };
58
- } else if (currentItem && line.trim() !== "") {
59
- currentItem.body.push(line.trim());
60
- }
61
- }
62
- if (currentItem) history.push(currentItem);
63
- }
64
-
65
- return {
66
- phase: phaseMatch ? phaseMatch[1].trim() : "PHASE_0",
67
- traceId: traceMatch ? traceMatch[1].trim() : "N/A",
68
- managerState: managerMatch ? managerMatch[1].trim() : "ACTIVE",
69
- tasks,
70
- history: history.slice(0, 15) // Return last 15 entries
71
- };
72
- } catch (e: unknown) {
73
- return { error: e instanceof Error ? e.message : String(e) };
74
- }
75
- }
76
-
77
- interface ProjectStructureEntry {
78
- name: string;
79
- path: string;
80
- type: "directory" | "file";
81
- children?: ProjectStructureEntry[];
82
- }
83
-
84
- export function getProjectStructure(): ProjectStructureEntry[] {
85
- const projectRoot = process.cwd();
86
-
87
- function walk(dir: string, depth = 0): ProjectStructureEntry[] {
88
- if (depth > 3) return []; // Limit depth for performance
89
-
90
- const entries: ProjectStructureEntry[] = [];
91
- let files: fs.Dirent[];
92
-
93
- try {
94
- files = fs.readdirSync(dir, { withFileTypes: true });
95
- } catch (_e) {
96
- // Silently ignore directories that cannot be read
97
- return [];
98
- }
99
-
100
- for (const file of files) {
101
- if (file.name.startsWith(".") || file.name === "node_modules" || file.name === "dist") continue;
102
-
103
- const fullPath = path.join(dir, file.name);
104
- const entry: ProjectStructureEntry = {
105
- name: file.name,
106
- path: path.relative(projectRoot, fullPath),
107
- type: file.isDirectory() ? "directory" : "file"
108
- };
109
-
110
- if (file.isDirectory()) {
111
- entry.children = walk(fullPath, depth + 1);
112
- }
113
- entries.push(entry);
114
- }
115
- return entries;
116
- }
117
-
118
- try {
119
- return walk(projectRoot);
120
- } catch {
121
- return [];
122
- }
123
- }
124
-
125
- export function readManagerLogs() {
126
- const frameworkDir = getFrameworkDir();
127
- if (!frameworkDir) return [];
128
-
129
- const logsPath = path.join(frameworkDir, "logs/manager.json");
130
- if (!fs.existsSync(logsPath)) return [];
131
-
132
- try {
133
- const raw = fs.readFileSync(logsPath, "utf8");
134
- // Handle both json array format and jsonl format
135
- if (raw.trim().startsWith("[")) {
136
- return JSON.parse(raw);
137
- } else {
138
- return raw.split("\n").filter(Boolean).map(line => JSON.parse(line));
139
- }
140
- } catch {
141
- return [];
142
- }
143
- }
144
-
145
- export function listAgents() {
146
- const frameworkDir = getFrameworkDir();
147
- if (!frameworkDir) return [];
148
- const agentsPath = path.join(frameworkDir, "agents");
149
- if (!fs.existsSync(agentsPath)) return [];
150
-
151
- try {
152
- const files = fs.readdirSync(agentsPath).filter(f => f.endsWith(".json") && f !== "agent_army_schema.json");
153
- return files.map(file => {
154
- const content = JSON.parse(fs.readFileSync(path.join(agentsPath, file), "utf8"));
155
- return {
156
- name: content.name,
157
- displayName: content.displayName || content.name,
158
- description: content.description,
159
- role: content.role,
160
- capability: content.capability,
161
- tags: content.tags || []
162
- };
163
- });
164
- } catch {
165
- return [];
166
- }
167
- }