agent-enderun 0.8.8 → 0.9.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.
Files changed (103) hide show
  1. package/.enderun/BRAIN_DASHBOARD.md +4 -4
  2. package/{ENDERUN.md → .enderun/ENDERUN.md} +4 -2
  3. package/.enderun/PROJECT_MEMORY.md +12 -45
  4. package/.enderun/STATUS.md +9 -8
  5. package/.enderun/agents/agent_army_schema.json +29 -7
  6. package/.enderun/agents/analyst.md +3 -5
  7. package/.enderun/agents/backend.md +11 -31
  8. package/.enderun/agents/devops.md +2 -3
  9. package/.enderun/agents/explorer.md +4 -4
  10. package/.enderun/agents/frontend.md +76 -69
  11. package/.enderun/agents/git.md +3 -3
  12. package/.enderun/agents/manager.md +30 -42
  13. package/.enderun/agents/mobile.md +3 -3
  14. package/.enderun/agents/native.md +106 -0
  15. package/.enderun/agents/orchestrator.md +2 -2
  16. package/.enderun/agents/qa.md +7 -10
  17. package/.enderun/agents/schema/agent-lifecycle-schema.json +29 -8
  18. package/.enderun/agents/security.md +2 -2
  19. package/.enderun/cli-commands.json +4 -0
  20. package/.enderun/config.json +2 -2
  21. package/.enderun/knowledge/SHIM_TEMPLATE.md +25 -0
  22. package/.enderun/knowledge/eslint-standards.md +63 -0
  23. package/.enderun/knowledge/hermes_protocol.md +1 -1
  24. package/.enderun/knowledge/manager_authority_audit_enforcement.md +2 -2
  25. package/.enderun/mcp_config.json +9 -0
  26. package/.enderun/memory-graph/agent-contexts/analyst.json +1 -1
  27. package/.enderun/memory-graph/agent-contexts/backend.json +1 -1
  28. package/.enderun/memory-graph/agent-contexts/devops.json +1 -1
  29. package/.enderun/memory-graph/agent-contexts/explorer.json +1 -1
  30. package/.enderun/memory-graph/agent-contexts/frontend.json +1 -1
  31. package/.enderun/memory-graph/agent-contexts/git.json +1 -1
  32. package/.enderun/memory-graph/agent-contexts/manager.json +1 -1
  33. package/.enderun/memory-graph/agent-contexts/mobile.json +1 -1
  34. package/.enderun/memory-graph/agent-contexts/native.json +1 -0
  35. package/.enderun/memory-graph/agent-contexts/orchestrator.json +1 -1
  36. package/.enderun/memory-graph/agent-contexts/qa.json +1 -1
  37. package/.enderun/memory-graph/agent-contexts/security.json +1 -1
  38. package/.enderun/memory-graph/graph.json +123 -15
  39. package/.enderun/memory-graph/shared-facts.json +26 -31
  40. package/README.md +89 -413
  41. package/agent.md +25 -0
  42. package/bin/cli.js +9 -9
  43. package/bin/update-contract.js +34 -37
  44. package/bin/validate-agent-army.js +38 -13
  45. package/claude.md +14 -8
  46. package/docs/README.md +35 -16
  47. package/docs/tech-stack.md +30 -0
  48. package/eslint.config.js +68 -0
  49. package/framework-mcp/dist/index.js +184 -24
  50. package/framework-mcp/package.json +6 -33
  51. package/framework-mcp/tsconfig.json +3 -6
  52. package/gemini.md +12 -6
  53. package/grok.md +25 -0
  54. package/package.json +12 -6
  55. package/panda.config.ts +86 -86
  56. package/tsconfig.json +9 -0
  57. package/.enderun/logs/analyst.json +0 -1
  58. package/.enderun/logs/backend.json +0 -1
  59. package/.enderun/logs/devops.json +0 -1
  60. package/.enderun/logs/explorer.json +0 -1
  61. package/.enderun/logs/frontend.json +0 -1
  62. package/.enderun/logs/git.json +0 -1
  63. package/.enderun/logs/manager.json +0 -1
  64. package/.enderun/logs/mobile.json +0 -1
  65. package/.enderun/logs/native.json +0 -1
  66. package/.enderun/logs/orchestrator.json +0 -1
  67. package/.enderun/logs/qa.json +0 -1
  68. package/.enderun/logs/security.json +0 -1
  69. package/.env.example +0 -10
  70. package/cursor.md +0 -19
  71. package/framework-mcp/README.md +0 -55
  72. package/framework-mcp/dist/schemas.js +0 -84
  73. package/framework-mcp/dist/tools/codebase.js +0 -294
  74. package/framework-mcp/dist/tools/contract.js +0 -197
  75. package/framework-mcp/dist/tools/framework.js +0 -225
  76. package/framework-mcp/dist/tools/git.js +0 -51
  77. package/framework-mcp/dist/tools/governance.js +0 -696
  78. package/framework-mcp/dist/tools/index.js +0 -47
  79. package/framework-mcp/dist/tools/knowledge.js +0 -133
  80. package/framework-mcp/dist/tools/memory.js +0 -217
  81. package/framework-mcp/dist/tools/messages.js +0 -193
  82. package/framework-mcp/dist/tools/monitoring.js +0 -294
  83. package/framework-mcp/dist/tools/orchestration.js +0 -369
  84. package/framework-mcp/dist/tools/pipeline.js +0 -267
  85. package/framework-mcp/dist/tools/security.js +0 -137
  86. package/framework-mcp/dist/utils.js +0 -121
  87. package/framework-mcp/src/index.ts +0 -49
  88. package/framework-mcp/src/schemas.ts +0 -106
  89. package/framework-mcp/src/tools/codebase.ts +0 -284
  90. package/framework-mcp/src/tools/contract.ts +0 -221
  91. package/framework-mcp/src/tools/framework.ts +0 -223
  92. package/framework-mcp/src/tools/git.ts +0 -42
  93. package/framework-mcp/src/tools/governance.ts +0 -891
  94. package/framework-mcp/src/tools/index.ts +0 -50
  95. package/framework-mcp/src/tools/knowledge.ts +0 -141
  96. package/framework-mcp/src/tools/memory.ts +0 -207
  97. package/framework-mcp/src/tools/messages.ts +0 -213
  98. package/framework-mcp/src/tools/monitoring.ts +0 -351
  99. package/framework-mcp/src/tools/orchestration.ts +0 -440
  100. package/framework-mcp/src/tools/pipeline.ts +0 -353
  101. package/framework-mcp/src/tools/security.ts +0 -143
  102. package/framework-mcp/src/utils.ts +0 -130
  103. package/src/cli/index.ts +0 -2188
@@ -1,440 +0,0 @@
1
- import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
- import { promises as fs } from "fs";
3
- import path from "path";
4
- import { getFrameworkDir } from "../utils.js";
5
-
6
- // ─── Tool Definitions ─────────────────────────────────────────────────────────
7
-
8
- export const orchestrationTools: Tool[] = [
9
- {
10
- name: "create_task_dag",
11
- description:
12
- "Creates a Directed Acyclic Graph (DAG) of tasks with dependencies. Used by @orchestrator to plan parallel execution. Returns both a JSON structure and a Mermaid diagram for visualization.",
13
- inputSchema: {
14
- type: "object",
15
- properties: {
16
- traceId: {
17
- type: "string",
18
- description: "Trace ID inherited from @manager briefing. Required.",
19
- },
20
- tasks: {
21
- type: "array",
22
- description: "Array of task definitions to build the DAG from.",
23
- items: {
24
- type: "object",
25
- required: ["id", "agent", "briefing"],
26
- properties: {
27
- id: { type: "string", description: "Unique task ID (e.g. T001)" },
28
- agent: { type: "string", description: "Assigned agent (e.g. @backend)" },
29
- briefing: { type: "string", description: "Task description" },
30
- dependsOn: {
31
- type: "array",
32
- items: { type: "string" },
33
- description: "Task IDs that must complete before this task starts",
34
- },
35
- priority: {
36
- type: "string",
37
- enum: ["CRITICAL", "HIGH", "MEDIUM", "LOW"],
38
- default: "MEDIUM",
39
- },
40
- },
41
- },
42
- },
43
- },
44
- required: ["traceId", "tasks"],
45
- },
46
- },
47
- {
48
- name: "assign_agent_to_task",
49
- description:
50
- "Assigns the most capable available agent to a task based on domain and capability score. Checks STATUS.md for agent availability before assigning.",
51
- inputSchema: {
52
- type: "object",
53
- properties: {
54
- traceId: { type: "string", description: "Active Trace ID" },
55
- taskId: { type: "string", description: "Task ID to assign" },
56
- domain: {
57
- type: "string",
58
- enum: ["backend", "frontend", "security", "qa", "devops", "mobile", "native", "analysis", "git", "exploration"],
59
- description: "Domain of the task — used to filter eligible agents",
60
- },
61
- preferredAgent: {
62
- type: "string",
63
- description: "Optional preferred agent. If not available, falls back to capability-based selection.",
64
- },
65
- },
66
- required: ["traceId", "taskId", "domain"],
67
- },
68
- },
69
- {
70
- name: "get_agent_workload",
71
- description:
72
- "Returns the current workload for all agents: active task count, state, current task description, and health score. Used by @orchestrator to make load-aware assignment decisions.",
73
- inputSchema: {
74
- type: "object",
75
- properties: {
76
- projectRoot: { type: "string", description: "Root directory of the project." },
77
- },
78
- required: [],
79
- },
80
- },
81
- {
82
- name: "resolve_agent_blockage",
83
- description:
84
- "Handles a BLOCKED agent by documenting the blockage, escalating to @manager, and optionally reassigning the task to another eligible agent.",
85
- inputSchema: {
86
- type: "object",
87
- properties: {
88
- blockedAgent: { type: "string", description: "The agent identifier that is BLOCKED, e.g. @frontend" },
89
- traceId: { type: "string", description: "Active Trace ID" },
90
- blockReason: { type: "string", description: "Mandatory description of why the agent is blocked" },
91
- reassign: {
92
- type: "boolean",
93
- description: "If true, attempt to find and assign an alternative agent",
94
- default: false,
95
- },
96
- },
97
- required: ["blockedAgent", "traceId", "blockReason"],
98
- },
99
- },
100
- {
101
- name: "broadcast_army_directive",
102
- description:
103
- "Broadcasts a directive message to all agents simultaneously via the Hermes messaging system. Used for war-room mode, policy changes, or global state transitions.",
104
- inputSchema: {
105
- type: "object",
106
- properties: {
107
- traceId: { type: "string", description: "Active Trace ID" },
108
- directiveType: {
109
- type: "string",
110
- enum: [
111
- "WAR_ROOM_ACTIVATE",
112
- "WAR_ROOM_DEACTIVATE",
113
- "CONTRACT_CHANGED",
114
- "PHASE_ROLLBACK",
115
- "POLICY_UPDATE",
116
- "ARMY_PAUSE",
117
- "ARMY_RESUME",
118
- ],
119
- description: "Type of directive being broadcast",
120
- },
121
- message: { type: "string", description: "Human-readable directive message" },
122
- urgency: {
123
- type: "string",
124
- enum: ["IMMEDIATE", "HIGH", "NORMAL"],
125
- default: "NORMAL",
126
- },
127
- },
128
- required: ["traceId", "directiveType", "message"],
129
- },
130
- },
131
- ];
132
-
133
- // ─── Handlers ─────────────────────────────────────────────────────────────────
134
-
135
- export const orchestrationHandlers: Record<
136
- string,
137
- (args: unknown, projectRoot: string) => Promise<{ content: Array<{ type: string; text: string }> }>
138
- > = {
139
- async create_task_dag(args, projectRoot) {
140
- const { traceId, tasks } = args as {
141
- traceId: string;
142
- tasks: Array<{
143
- id: string;
144
- agent: string;
145
- briefing: string;
146
- dependsOn?: string[];
147
- priority?: string;
148
- }>;
149
- };
150
-
151
- // Build adjacency structure
152
- const dagNodes = tasks.map((t) => ({
153
- id: t.id,
154
- agent: t.agent,
155
- briefing: t.briefing,
156
- status: "PENDING",
157
- priority: t.priority ?? "MEDIUM",
158
- dependsOn: t.dependsOn ?? [],
159
- }));
160
-
161
- // Topological sort to find execution order
162
- const executionWaves: string[][] = [];
163
- const resolved = new Set<string>();
164
- const remaining = [...dagNodes];
165
-
166
- while (remaining.length > 0) {
167
- const wave = remaining.filter(
168
- (n) => n.dependsOn.every((dep) => resolved.has(dep))
169
- );
170
- if (wave.length === 0) {
171
- return {
172
- content: [
173
- {
174
- type: "text",
175
- text: JSON.stringify({
176
- error: "CIRCULAR_DEPENDENCY",
177
- message: "Circular dependency detected in task DAG. Check dependsOn fields.",
178
- }),
179
- },
180
- ],
181
- };
182
- }
183
- executionWaves.push(wave.map((n) => n.id));
184
- wave.forEach((n) => {
185
- resolved.add(n.id);
186
- remaining.splice(remaining.indexOf(n), 1);
187
- });
188
- }
189
-
190
- // Generate Mermaid diagram
191
- const mermaidLines = ["graph TD"];
192
- for (const node of dagNodes) {
193
- const label = `${node.id}["${node.agent}: ${node.briefing.slice(0, 40)}..."]`;
194
- mermaidLines.push(` ${node.id}${label}`);
195
- }
196
- for (const node of dagNodes) {
197
- for (const dep of node.dependsOn) {
198
- mermaidLines.push(` ${dep} --> ${node.id}`);
199
- }
200
- }
201
-
202
- const dag = {
203
- traceId,
204
- createdAt: new Date().toISOString(),
205
- nodes: dagNodes,
206
- executionWaves,
207
- mermaid: mermaidLines.join("\n"),
208
- parallelOpportunities: executionWaves.filter((w) => w.length > 1).length,
209
- };
210
-
211
- // Persist to queue
212
- const queueDir = path.join(projectRoot, getFrameworkDir(projectRoot), "queue", "pending");
213
- await fs.mkdir(queueDir, { recursive: true });
214
- await fs.writeFile(
215
- path.join(queueDir, `${traceId}-dag.json`),
216
- JSON.stringify(dag, null, 2),
217
- "utf-8"
218
- );
219
-
220
- return { content: [{ type: "text", text: JSON.stringify(dag, null, 2) }] };
221
- },
222
-
223
- async assign_agent_to_task(args, projectRoot) {
224
- const { traceId, taskId, domain, preferredAgent } = args as {
225
- traceId: string;
226
- taskId: string;
227
- domain: string;
228
- preferredAgent?: string;
229
- };
230
-
231
- // Try to load capability roster from shared-facts.json (dynamic — fixes KRITIK-3)
232
- let agentCapabilityRoster: Array<{ agent: string; primaryDomain: string; capability: number }> = [];
233
- try {
234
- const sharedFactsPath = path.join(projectRoot, getFrameworkDir(projectRoot), "memory-graph", "shared-facts.json");
235
- const content = await fs.readFile(sharedFactsPath, "utf-8");
236
- const facts = JSON.parse(content) as { agentCapabilityRoster?: typeof agentCapabilityRoster };
237
- agentCapabilityRoster = facts.agentCapabilityRoster ?? [];
238
- } catch {
239
- // Fallback to hardcoded map if shared-facts not available
240
- }
241
-
242
- // Build domain → agents map from shared-facts roster
243
- // Exclude @manager — @manager does NOT execute specialist tasks
244
- const domainMap: Record<string, { agent: string; capability: number }[]> = {};
245
- for (const entry of agentCapabilityRoster) {
246
- if (entry.agent === "@manager" || entry.agent === "@orchestrator") continue;
247
- const d = entry.primaryDomain;
248
- if (!domainMap[d]) domainMap[d] = [];
249
- domainMap[d].push({ agent: entry.agent, capability: entry.capability });
250
- }
251
-
252
- // Hardcoded fallback (used only if shared-facts unavailable)
253
- const fallbackDomainMap: Record<string, { agent: string; capability: number }[]> = {
254
- backend: [{ agent: "@backend", capability: 9.2 }],
255
- frontend: [{ agent: "@frontend", capability: 9.0 }],
256
- security: [{ agent: "@security", capability: 9.3 }],
257
- qa: [{ agent: "@qa", capability: 9.1 }],
258
- devops: [{ agent: "@devops", capability: 9.0 }],
259
- mobile: [{ agent: "@mobile", capability: 8.8 }],
260
- native: [{ agent: "@native", capability: 8.9 }],
261
- analysis: [{ agent: "@analyst", capability: 9.6 }],
262
- git: [{ agent: "@git", capability: 9.1 }],
263
- exploration: [{ agent: "@explorer", capability: 9.4 }],
264
- };
265
-
266
- const effectiveMap = Object.keys(domainMap).length > 0 ? domainMap : fallbackDomainMap;
267
- const candidates = effectiveMap[domain] ?? [];
268
- let assigned = [...candidates].sort((a, b) => b.capability - a.capability)[0];
269
-
270
- if (preferredAgent && preferredAgent !== "@manager" && preferredAgent !== "@orchestrator") {
271
- const preferred = candidates.find((c) => c.agent === preferredAgent);
272
- if (preferred) assigned = preferred;
273
- }
274
-
275
- if (!assigned) {
276
- return {
277
- content: [
278
- {
279
- type: "text",
280
- text: JSON.stringify({ error: "NO_ELIGIBLE_AGENT", domain, taskId,
281
- note: "@manager and @orchestrator are excluded from task assignment" }),
282
- },
283
- ],
284
- };
285
- }
286
-
287
- const assignment = {
288
- traceId,
289
- taskId,
290
- assignedAgent: assigned.agent,
291
- capabilityScore: assigned.capability,
292
- assignedAt: new Date().toISOString(),
293
- domain,
294
- sourceMap: Object.keys(domainMap).length > 0 ? "shared-facts" : "fallback",
295
- };
296
-
297
- // Write assignment log
298
- const logPath = path.join(projectRoot, getFrameworkDir(projectRoot), "logs", "orchestrator.json");
299
- let log: { assignments: unknown[] } = { assignments: [] };
300
- try {
301
- const existing = await fs.readFile(logPath, "utf-8");
302
- log = JSON.parse(existing) as { assignments: unknown[] };
303
- } catch {
304
- // File doesn't exist yet — start fresh
305
- }
306
- log.assignments.push(assignment);
307
- await fs.mkdir(path.dirname(logPath), { recursive: true });
308
- await fs.writeFile(logPath, JSON.stringify(log, null, 2), "utf-8");
309
-
310
- return { content: [{ type: "text", text: JSON.stringify(assignment, null, 2) }] };
311
- },
312
-
313
- async get_agent_workload(_args, projectRoot) {
314
- const statusPath = path.join(projectRoot, getFrameworkDir(projectRoot), "STATUS.md");
315
- let statusContent: string;
316
- try {
317
- statusContent = await fs.readFile(statusPath, "utf-8");
318
- } catch {
319
- statusContent = "";
320
- }
321
-
322
- // Parse the markdown table
323
- const lines = statusContent.length > 0
324
- ? statusContent.split("\n").filter((l) => l.includes("|") && !l.includes("---"))
325
- : [];
326
- const agents = lines.length > 1
327
- ? lines
328
- .slice(1) // skip header
329
- .map((line) => {
330
- const cells = line.split("|").map((c) => c.trim()).filter(Boolean);
331
- return cells.length >= 4
332
- ? { agent: cells[0], state: cells[1], currentTask: cells[2], healthScore: cells[4] }
333
- : null;
334
- })
335
- .filter(Boolean)
336
- : [];
337
-
338
- return { content: [{ type: "text", text: JSON.stringify({ agents, generatedAt: new Date().toISOString() }, null, 2) }] };
339
- },
340
-
341
- async resolve_agent_blockage(args, projectRoot) {
342
- const { blockedAgent, traceId, blockReason, reassign } = args as {
343
- blockedAgent: string;
344
- traceId: string;
345
- blockReason: string;
346
- reassign?: boolean;
347
- };
348
-
349
- const resolution = {
350
- traceId,
351
- blockedAgent,
352
- blockReason,
353
- detectedAt: new Date().toISOString(),
354
- escalatedToManager: true,
355
- reassignAttempted: reassign ?? false,
356
- status: "ESCALATED_TO_MANAGER",
357
- };
358
-
359
- // Log blockage
360
- const logPath = path.join(projectRoot, getFrameworkDir(projectRoot), "logs", "orchestrator.json");
361
- let log: { assignments: unknown[]; blockages: unknown[] } = { assignments: [], blockages: [] };
362
- try {
363
- const existing = await fs.readFile(logPath, "utf-8");
364
- log = JSON.parse(existing) as { assignments: unknown[]; blockages: unknown[] };
365
- if (!log.blockages) log.blockages = [];
366
- } catch {
367
- // Start fresh
368
- }
369
- log.blockages.push(resolution);
370
- await fs.mkdir(path.dirname(logPath), { recursive: true });
371
- await fs.writeFile(logPath, JSON.stringify(log, null, 2), "utf-8");
372
-
373
- // Write a message to @manager's inbox via messages folder
374
- const messagesDir = path.join(projectRoot, getFrameworkDir(projectRoot), "messages");
375
- await fs.mkdir(messagesDir, { recursive: true });
376
- const messageFile = path.join(messagesDir, `BLOCKAGE-${traceId}-${Date.now()}.json`);
377
- await fs.writeFile(
378
- messageFile,
379
- JSON.stringify({
380
- from: "@orchestrator",
381
- to: "@manager",
382
- type: "AGENT_BLOCKED",
383
- traceId,
384
- payload: { blockedAgent, blockReason, resolution },
385
- timestamp: new Date().toISOString(),
386
- }),
387
- "utf-8"
388
- );
389
-
390
- return { content: [{ type: "text", text: JSON.stringify(resolution, null, 2) }] };
391
- },
392
-
393
- async broadcast_army_directive(args, projectRoot) {
394
- const { traceId, directiveType, message, urgency } = args as {
395
- traceId: string;
396
- directiveType: string;
397
- message: string;
398
- urgency?: string;
399
- };
400
-
401
- const broadcast = {
402
- id: `BROADCAST-${traceId}-${Date.now()}`,
403
- from: "@orchestrator",
404
- to: "*",
405
- traceId,
406
- directiveType,
407
- message,
408
- urgency: urgency ?? "NORMAL",
409
- timestamp: new Date().toISOString(),
410
- };
411
-
412
- // Write to messages folder for all agents
413
- const messagesDir = path.join(projectRoot, getFrameworkDir(projectRoot), "messages");
414
- await fs.mkdir(messagesDir, { recursive: true });
415
- await fs.writeFile(
416
- path.join(messagesDir, `${broadcast.id}.json`),
417
- JSON.stringify(broadcast, null, 2),
418
- "utf-8"
419
- );
420
-
421
- // Log broadcast
422
- const logPath = path.join(projectRoot, getFrameworkDir(projectRoot), "logs", "orchestrator.json");
423
- let log: { assignments: unknown[]; blockages: unknown[]; broadcasts: unknown[] } = {
424
- assignments: [],
425
- blockages: [],
426
- broadcasts: [],
427
- };
428
- try {
429
- const existing = await fs.readFile(logPath, "utf-8");
430
- log = JSON.parse(existing) as typeof log;
431
- if (!log.broadcasts) log.broadcasts = [];
432
- } catch {
433
- // Start fresh
434
- }
435
- log.broadcasts.push(broadcast);
436
- await fs.writeFile(logPath, JSON.stringify(log, null, 2), "utf-8");
437
-
438
- return { content: [{ type: "text", text: JSON.stringify(broadcast, null, 2) }] };
439
- },
440
- };