agent-orchestration 0.5.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/.cursor/rules/orchestrator-auto.mdc +107 -0
- package/.cursor/rules/orchestrator-main.mdc +86 -0
- package/.cursor/rules/orchestrator-sub.mdc +114 -0
- package/LICENSE +21 -0
- package/README.md +329 -0
- package/activeContext.md +37 -0
- package/dist/bin/cli.d.ts +11 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +410 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/database.d.ts +91 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +522 -0
- package/dist/database.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +132 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +124 -0
- package/dist/models.js.map +1 -0
- package/dist/tools/agent.d.ts +10 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +185 -0
- package/dist/tools/agent.js.map +1 -0
- package/dist/tools/coordination.d.ts +6 -0
- package/dist/tools/coordination.d.ts.map +1 -0
- package/dist/tools/coordination.js +114 -0
- package/dist/tools/coordination.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +108 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/task.d.ts +6 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +267 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/utility.d.ts +6 -0
- package/dist/tools/utility.d.ts.map +1 -0
- package/dist/tools/utility.js +162 -0
- package/dist/tools/utility.js.map +1 -0
- package/dist/utils/contextSync.d.ts +12 -0
- package/dist/utils/contextSync.d.ts.map +1 -0
- package/dist/utils/contextSync.js +124 -0
- package/dist/utils/contextSync.js.map +1 -0
- package/package.json +54 -0
- package/src/bin/cli.ts +430 -0
- package/src/database.ts +764 -0
- package/src/index.ts +71 -0
- package/src/models.ts +226 -0
- package/src/tools/agent.ts +241 -0
- package/src/tools/coordination.ts +152 -0
- package/src/tools/index.ts +9 -0
- package/src/tools/memory.ts +150 -0
- package/src/tools/task.ts +334 -0
- package/src/tools/utility.ts +202 -0
- package/src/utils/contextSync.ts +144 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to sync orchestration state to activeContext.md
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { getDatabase } from '../database.js';
|
|
7
|
+
import { TaskStatus } from '../models.js';
|
|
8
|
+
/**
|
|
9
|
+
* Check if context sync is enabled via environment variable
|
|
10
|
+
*/
|
|
11
|
+
export function isContextSyncEnabled() {
|
|
12
|
+
const envVar = process.env.MCP_ORCH_SYNC_CONTEXT;
|
|
13
|
+
return envVar === 'true' || envVar === '1';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the path to activeContext.md
|
|
17
|
+
*/
|
|
18
|
+
function getContextPath() {
|
|
19
|
+
return path.join(process.cwd(), 'activeContext.md');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sync the current orchestration state to activeContext.md
|
|
23
|
+
*/
|
|
24
|
+
export function syncToActiveContext() {
|
|
25
|
+
if (!isContextSyncEnabled()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const db = getDatabase();
|
|
30
|
+
// Get current state
|
|
31
|
+
const agents = db.listAgents();
|
|
32
|
+
const activeAgents = agents.filter((a) => ['active', 'busy'].includes(a.status));
|
|
33
|
+
const inProgressTasks = db.listTasks({ status: TaskStatus.IN_PROGRESS });
|
|
34
|
+
const pendingTasks = db.listTasks({ status: TaskStatus.PENDING });
|
|
35
|
+
const decisions = db.listMemory('decisions');
|
|
36
|
+
const context = db.listMemory('context');
|
|
37
|
+
// Get current focus
|
|
38
|
+
const focusEntry = db.getMemory('current_focus', 'context');
|
|
39
|
+
const currentFocus = focusEntry
|
|
40
|
+
? String(focusEntry.value)
|
|
41
|
+
: '_Not set. Use `memory_set` with key "current_focus" in namespace "context"._';
|
|
42
|
+
// Build markdown content
|
|
43
|
+
const lines = [
|
|
44
|
+
'# Active Context',
|
|
45
|
+
'',
|
|
46
|
+
`_Last updated: ${new Date().toISOString()}_`,
|
|
47
|
+
'',
|
|
48
|
+
'## Current Focus',
|
|
49
|
+
'',
|
|
50
|
+
currentFocus,
|
|
51
|
+
'',
|
|
52
|
+
'## Active Agents',
|
|
53
|
+
'',
|
|
54
|
+
];
|
|
55
|
+
if (activeAgents.length === 0) {
|
|
56
|
+
lines.push('_No active agents._');
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
for (const agent of activeAgents) {
|
|
60
|
+
const statusEmoji = agent.status === 'busy' ? '🔵' : '🟢';
|
|
61
|
+
lines.push(`- ${statusEmoji} **${agent.name}** (${agent.role})`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
lines.push('', '## In Progress', '');
|
|
65
|
+
if (inProgressTasks.length === 0) {
|
|
66
|
+
lines.push('_No tasks in progress._');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
for (const task of inProgressTasks) {
|
|
70
|
+
const progress = task.metadata.progress ?? 0;
|
|
71
|
+
const assignee = task.assignedTo
|
|
72
|
+
? agents.find((a) => a.id === task.assignedTo)?.name ?? task.assignedTo.slice(0, 8)
|
|
73
|
+
: 'unassigned';
|
|
74
|
+
lines.push(`- 🔄 **${task.title}** - ${assignee} (${progress}%)`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
lines.push('', '## Pending Tasks', '');
|
|
78
|
+
if (pendingTasks.length === 0) {
|
|
79
|
+
lines.push('_No pending tasks._');
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
for (const task of pendingTasks.slice(0, 10)) {
|
|
83
|
+
const priority = task.priority !== 'normal' ? ` [${task.priority}]` : '';
|
|
84
|
+
lines.push(`- ⏳ ${task.title}${priority}`);
|
|
85
|
+
}
|
|
86
|
+
if (pendingTasks.length > 10) {
|
|
87
|
+
lines.push(`- _...and ${pendingTasks.length - 10} more_`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
lines.push('', '## Recent Decisions', '');
|
|
91
|
+
if (decisions.length === 0) {
|
|
92
|
+
lines.push('_No decisions recorded._');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
for (const decision of decisions.slice(0, 10)) {
|
|
96
|
+
const value = typeof decision.value === 'string'
|
|
97
|
+
? decision.value.slice(0, 100)
|
|
98
|
+
: JSON.stringify(decision.value).slice(0, 100);
|
|
99
|
+
lines.push(`- **${decision.key}**: ${value}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
lines.push('', '## Context Notes', '');
|
|
103
|
+
const otherContext = context.filter((c) => c.key !== 'current_focus');
|
|
104
|
+
if (otherContext.length === 0) {
|
|
105
|
+
lines.push('_No additional context._');
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
for (const entry of otherContext.slice(0, 10)) {
|
|
109
|
+
const value = typeof entry.value === 'string'
|
|
110
|
+
? entry.value.slice(0, 80)
|
|
111
|
+
: JSON.stringify(entry.value).slice(0, 80);
|
|
112
|
+
lines.push(`- **${entry.key}**: ${value}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
lines.push('', '---', '', '_This file is auto-generated by the Agent Orchestration server._', '_Edit shared memory to update this context._');
|
|
116
|
+
// Write to file
|
|
117
|
+
fs.writeFileSync(getContextPath(), lines.join('\n'), 'utf-8');
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
// Silently fail - this is a nice-to-have feature
|
|
121
|
+
console.error('Failed to sync activeContext.md:', error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=contextSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextSync.js","sourceRoot":"","sources":["../../src/utils/contextSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IACjD,OAAO,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,GAAG,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,SAAS,cAAc;IACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;QAEzB,oBAAoB;QACpB,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACjF,MAAM,eAAe,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,E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AK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;oBAC1B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC/C,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,KAAK,CAAC,IAAI,CACR,EAAE,EACF,KAAK,EACL,EAAE,EACF,kEAAkE,EAClE,8CAA8C,CAC/C,CAAC;QAEF,gBAAgB;QAChB,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iDAAiD;QACjD,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-orchestration",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Agent Orchestration - MCP server for multi-agent coordination across IDEs and CLI tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agent-orchestration": "dist/bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"lint": "eslint src --ext .ts",
|
|
15
|
+
"clean": "rm -rf dist"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"agents-md",
|
|
21
|
+
"cursor",
|
|
22
|
+
"ai-agents",
|
|
23
|
+
"orchestration",
|
|
24
|
+
"multi-agent",
|
|
25
|
+
"codex",
|
|
26
|
+
"aider",
|
|
27
|
+
"windsurf",
|
|
28
|
+
"copilot"
|
|
29
|
+
],
|
|
30
|
+
"author": "Aris Setiawan <https://madebyaris.com>",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"homepage": "https://github.com/madebyaris/agent-orchestration#readme",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/madebyaris/agent-orchestration.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/madebyaris/agent-orchestration/issues"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
42
|
+
"better-sqlite3": "^11.8.1",
|
|
43
|
+
"ulid": "^2.3.0",
|
|
44
|
+
"zod": "^3.24.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
48
|
+
"@types/node": "^22.10.5",
|
|
49
|
+
"typescript": "^5.7.3"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/bin/cli.ts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI for Agent Orchestration
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* init - Creates AGENTS.md for cross-IDE/CLI compatibility
|
|
7
|
+
* init-cursor - Copies .cursor/rules/ for Cursor IDE
|
|
8
|
+
* serve - Run the MCP server (used by IDEs via npx)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = path.dirname(__filename);
|
|
17
|
+
|
|
18
|
+
// Path to the package root (dist/bin/cli.js -> ../../)
|
|
19
|
+
const packageRoot = path.resolve(__dirname, '..', '..');
|
|
20
|
+
|
|
21
|
+
function printUsage(): void {
|
|
22
|
+
console.log(`
|
|
23
|
+
Agent Orchestration CLI
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
npx agent-orchestration init Create AGENTS.md (works with any AI agent)
|
|
27
|
+
npx agent-orchestration init-cursor Setup for Cursor IDE (.cursor/rules/)
|
|
28
|
+
npx agent-orchestration serve Run the MCP server
|
|
29
|
+
npx agent-orchestration help Show this help message
|
|
30
|
+
|
|
31
|
+
Commands:
|
|
32
|
+
init Creates AGENTS.md with full orchestration instructions.
|
|
33
|
+
Compatible with: OpenAI Codex, Google Jules, Cursor, Aider,
|
|
34
|
+
Windsurf, VS Code Copilot, and many more.
|
|
35
|
+
|
|
36
|
+
init-cursor Sets up Cursor-specific rules in .cursor/rules/.
|
|
37
|
+
Also creates activeContext.md and updates .gitignore.
|
|
38
|
+
|
|
39
|
+
serve Runs the MCP server. IDEs call this via their MCP config.
|
|
40
|
+
The server uses the current working directory as the project root.
|
|
41
|
+
|
|
42
|
+
Example:
|
|
43
|
+
cd /path/to/my-project
|
|
44
|
+
npx agent-orchestration init
|
|
45
|
+
`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generate the AGENTS.md content with full orchestration instructions
|
|
50
|
+
*/
|
|
51
|
+
function generateAgentsMd(): string {
|
|
52
|
+
return `# AGENTS.md
|
|
53
|
+
|
|
54
|
+
This project uses **Agent Orchestration** for multi-agent coordination.
|
|
55
|
+
|
|
56
|
+
## MCP Server Setup
|
|
57
|
+
|
|
58
|
+
Add this to your IDE's MCP configuration:
|
|
59
|
+
|
|
60
|
+
\`\`\`json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"agent-orchestration": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
66
|
+
"env": {
|
|
67
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
\`\`\`
|
|
73
|
+
|
|
74
|
+
**Note**: Run from your project root. The server uses the current directory.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## First Action: Bootstrap
|
|
79
|
+
|
|
80
|
+
Before doing any work, you MUST run:
|
|
81
|
+
|
|
82
|
+
\`\`\`
|
|
83
|
+
bootstrap
|
|
84
|
+
\`\`\`
|
|
85
|
+
|
|
86
|
+
This registers you with the orchestrator and shows:
|
|
87
|
+
- Current project focus
|
|
88
|
+
- Tasks assigned to you
|
|
89
|
+
- Recent decisions
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## If You Have a Specific Task
|
|
94
|
+
|
|
95
|
+
If you were given a specific task to work on, run:
|
|
96
|
+
|
|
97
|
+
\`\`\`
|
|
98
|
+
claim_todo:
|
|
99
|
+
title: "<the task title>"
|
|
100
|
+
\`\`\`
|
|
101
|
+
|
|
102
|
+
This registers you AND claims the task in one call.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Available Tools
|
|
107
|
+
|
|
108
|
+
### Session Management
|
|
109
|
+
| Tool | Description |
|
|
110
|
+
|------|-------------|
|
|
111
|
+
| \`bootstrap\` | Initialize session: register, get focus, tasks, decisions |
|
|
112
|
+
| \`claim_todo\` | Register + claim a task in one call |
|
|
113
|
+
| \`agent_whoami\` | Get your current agent info |
|
|
114
|
+
|
|
115
|
+
### Agent Coordination
|
|
116
|
+
| Tool | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| \`agent_register\` | Register with the orchestration system |
|
|
119
|
+
| \`agent_heartbeat\` | Send heartbeat to indicate you're active |
|
|
120
|
+
| \`agent_list\` | List all registered agents |
|
|
121
|
+
| \`agent_unregister\` | Unregister (releases all locks) |
|
|
122
|
+
|
|
123
|
+
### Shared Memory
|
|
124
|
+
| Tool | Description |
|
|
125
|
+
|------|-------------|
|
|
126
|
+
| \`memory_set\` | Store a value in shared memory |
|
|
127
|
+
| \`memory_get\` | Retrieve a value from shared memory |
|
|
128
|
+
| \`memory_list\` | List all keys in a namespace |
|
|
129
|
+
| \`memory_delete\` | Delete a value from shared memory |
|
|
130
|
+
|
|
131
|
+
### Task Management
|
|
132
|
+
| Tool | Description |
|
|
133
|
+
|------|-------------|
|
|
134
|
+
| \`task_create\` | Create a new task |
|
|
135
|
+
| \`task_claim\` | Claim a task to work on |
|
|
136
|
+
| \`task_update\` | Update task status or progress |
|
|
137
|
+
| \`task_complete\` | Mark task as completed |
|
|
138
|
+
| \`task_list\` | List tasks with filters |
|
|
139
|
+
| \`is_my_turn\` | Check if work is available |
|
|
140
|
+
|
|
141
|
+
### Resource Locking
|
|
142
|
+
| Tool | Description |
|
|
143
|
+
|------|-------------|
|
|
144
|
+
| \`lock_acquire\` | Acquire a lock on a file/resource |
|
|
145
|
+
| \`lock_release\` | Release a held lock |
|
|
146
|
+
| \`lock_check\` | Check if a resource is locked |
|
|
147
|
+
| \`coordination_status\` | Get overall system status |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Workflow for Main Orchestrator
|
|
152
|
+
|
|
153
|
+
\`\`\`
|
|
154
|
+
1. bootstrap # Start session
|
|
155
|
+
2. memory_set current_focus "..." # Set project focus
|
|
156
|
+
3. task_create "Feature X" # Create tasks
|
|
157
|
+
4. coordination_status # Monitor progress
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
## Workflow for Sub-Agents
|
|
161
|
+
|
|
162
|
+
\`\`\`
|
|
163
|
+
1. claim_todo "Feature X" # Register + claim
|
|
164
|
+
2. lock_acquire "src/feature.ts" # Lock before editing
|
|
165
|
+
3. [do the work]
|
|
166
|
+
4. task_complete <task_id> "Done" # Complete the task
|
|
167
|
+
5. agent_unregister # Clean up
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Memory Namespaces
|
|
173
|
+
|
|
174
|
+
Use these namespaces for organization:
|
|
175
|
+
|
|
176
|
+
| Namespace | Purpose | Example Keys |
|
|
177
|
+
|-----------|---------|--------------|
|
|
178
|
+
| \`context\` | Current state and focus | \`current_focus\`, \`current_branch\` |
|
|
179
|
+
| \`decisions\` | Architectural decisions | \`auth_strategy\`, \`db_choice\` |
|
|
180
|
+
| \`findings\` | Analysis results | \`perf_issues\`, \`security_audit\` |
|
|
181
|
+
| \`blockers\` | Issues blocking progress | \`api_down\`, \`missing_deps\` |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Coordination Patterns
|
|
186
|
+
|
|
187
|
+
### Before Editing Files
|
|
188
|
+
\`\`\`
|
|
189
|
+
lock_check: { resource: "src/file.ts" }
|
|
190
|
+
lock_acquire: { resource: "src/file.ts", reason: "Implementing feature" }
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
### After Editing Files
|
|
194
|
+
\`\`\`
|
|
195
|
+
lock_release: { resource: "src/file.ts" }
|
|
196
|
+
\`\`\`
|
|
197
|
+
|
|
198
|
+
### Check Before Major Work
|
|
199
|
+
\`\`\`
|
|
200
|
+
is_my_turn
|
|
201
|
+
\`\`\`
|
|
202
|
+
|
|
203
|
+
### When Done
|
|
204
|
+
\`\`\`
|
|
205
|
+
task_complete: { task_id: "<id>", output: "Summary of changes" }
|
|
206
|
+
agent_unregister
|
|
207
|
+
\`\`\`
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Reference activeContext.md
|
|
212
|
+
|
|
213
|
+
Check \`activeContext.md\` for current project state - it's auto-updated.
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Run the MCP server
|
|
219
|
+
*/
|
|
220
|
+
async function runServer(): Promise<void> {
|
|
221
|
+
// Import and start the server
|
|
222
|
+
const { startServer } = await import('../index.js');
|
|
223
|
+
await startServer();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Initialize with AGENTS.md (cross-IDE compatible)
|
|
228
|
+
*/
|
|
229
|
+
function initAgentsMd(): void {
|
|
230
|
+
const cwd = process.cwd();
|
|
231
|
+
console.log(`\nInitializing Agent Orchestration (AGENTS.md) in: ${cwd}\n`);
|
|
232
|
+
|
|
233
|
+
// 1. Create AGENTS.md
|
|
234
|
+
const agentsMdPath = path.join(cwd, 'AGENTS.md');
|
|
235
|
+
if (!fs.existsSync(agentsMdPath)) {
|
|
236
|
+
fs.writeFileSync(agentsMdPath, generateAgentsMd());
|
|
237
|
+
console.log('✓ Created AGENTS.md');
|
|
238
|
+
} else {
|
|
239
|
+
console.log('✓ AGENTS.md already exists (not overwritten)');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 2. Update .gitignore
|
|
243
|
+
updateGitignore(cwd);
|
|
244
|
+
|
|
245
|
+
// 3. Create activeContext.md
|
|
246
|
+
createActiveContext(cwd);
|
|
247
|
+
|
|
248
|
+
// 4. Print success message
|
|
249
|
+
console.log(`
|
|
250
|
+
✓ Setup complete!
|
|
251
|
+
|
|
252
|
+
AGENTS.md is now ready. This works with:
|
|
253
|
+
- OpenAI Codex
|
|
254
|
+
- Google Jules
|
|
255
|
+
- Cursor
|
|
256
|
+
- Aider
|
|
257
|
+
- Windsurf
|
|
258
|
+
- VS Code Copilot
|
|
259
|
+
- And many more!
|
|
260
|
+
|
|
261
|
+
MCP Server Config (add to your IDE):
|
|
262
|
+
|
|
263
|
+
{
|
|
264
|
+
"mcpServers": {
|
|
265
|
+
"agent-orchestration": {
|
|
266
|
+
"command": "npx",
|
|
267
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
268
|
+
"env": {
|
|
269
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
Then restart your IDE to activate the MCP server.
|
|
276
|
+
`);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Initialize for Cursor IDE (copies .cursor/rules/)
|
|
281
|
+
*/
|
|
282
|
+
function initCursor(): void {
|
|
283
|
+
const cwd = process.cwd();
|
|
284
|
+
console.log(`\nInitializing Agent Orchestration for Cursor in: ${cwd}\n`);
|
|
285
|
+
|
|
286
|
+
// 1. Copy Cursor rules
|
|
287
|
+
const rulesSourceDir = path.join(packageRoot, '.cursor', 'rules');
|
|
288
|
+
const rulesTargetDir = path.join(cwd, '.cursor', 'rules');
|
|
289
|
+
|
|
290
|
+
if (fs.existsSync(rulesSourceDir)) {
|
|
291
|
+
fs.mkdirSync(rulesTargetDir, { recursive: true });
|
|
292
|
+
|
|
293
|
+
const ruleFiles = fs.readdirSync(rulesSourceDir);
|
|
294
|
+
for (const file of ruleFiles) {
|
|
295
|
+
if (file.endsWith('.mdc')) {
|
|
296
|
+
const source = path.join(rulesSourceDir, file);
|
|
297
|
+
const target = path.join(rulesTargetDir, file);
|
|
298
|
+
fs.copyFileSync(source, target);
|
|
299
|
+
console.log(`✓ Copied rule: .cursor/rules/${file}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
console.log('⚠ Cursor rules not found in package. Skipping rule copy.');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 2. Update .gitignore
|
|
307
|
+
updateGitignore(cwd);
|
|
308
|
+
|
|
309
|
+
// 3. Create activeContext.md
|
|
310
|
+
createActiveContext(cwd);
|
|
311
|
+
|
|
312
|
+
// 4. Print MCP config
|
|
313
|
+
console.log(`
|
|
314
|
+
✓ Cursor setup complete!
|
|
315
|
+
|
|
316
|
+
Add this to your ~/.cursor/mcp.json:
|
|
317
|
+
|
|
318
|
+
{
|
|
319
|
+
"mcpServers": {
|
|
320
|
+
"agent-orchestration": {
|
|
321
|
+
"command": "npx",
|
|
322
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
323
|
+
"env": {
|
|
324
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
Then restart Cursor to activate the MCP server.
|
|
331
|
+
`);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Update .gitignore with orchestration entries
|
|
336
|
+
*/
|
|
337
|
+
function updateGitignore(cwd: string): void {
|
|
338
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
339
|
+
const ignoreEntry = '.agent-orchestration/';
|
|
340
|
+
|
|
341
|
+
let gitignoreContent = '';
|
|
342
|
+
if (fs.existsSync(gitignorePath)) {
|
|
343
|
+
gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (!gitignoreContent.includes(ignoreEntry)) {
|
|
347
|
+
const newContent =
|
|
348
|
+
gitignoreContent.trim() + '\n\n# Agent Orchestration\n' + ignoreEntry + '\n';
|
|
349
|
+
fs.writeFileSync(gitignorePath, newContent);
|
|
350
|
+
console.log('✓ Added .agent-orchestration/ to .gitignore');
|
|
351
|
+
} else {
|
|
352
|
+
console.log('✓ .gitignore already contains .agent-orchestration/');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Create activeContext.md template
|
|
358
|
+
*/
|
|
359
|
+
function createActiveContext(cwd: string): void {
|
|
360
|
+
const activeContextPath = path.join(cwd, 'activeContext.md');
|
|
361
|
+
if (!fs.existsSync(activeContextPath)) {
|
|
362
|
+
const template = `# Active Context
|
|
363
|
+
|
|
364
|
+
_Last updated: Initial setup_
|
|
365
|
+
|
|
366
|
+
## Current Focus
|
|
367
|
+
|
|
368
|
+
_Not set. Use \`memory_set\` with key "current_focus" in namespace "context"._
|
|
369
|
+
|
|
370
|
+
## Active Agents
|
|
371
|
+
|
|
372
|
+
_No active agents. Start the MCP server and register agents to see them here._
|
|
373
|
+
|
|
374
|
+
## In Progress
|
|
375
|
+
|
|
376
|
+
_No tasks in progress._
|
|
377
|
+
|
|
378
|
+
## Pending Tasks
|
|
379
|
+
|
|
380
|
+
_No pending tasks. Create tasks using the \`task_create\` tool._
|
|
381
|
+
|
|
382
|
+
## Recent Decisions
|
|
383
|
+
|
|
384
|
+
_No decisions recorded. Use \`memory_set\` in namespace "decisions" to record decisions._
|
|
385
|
+
|
|
386
|
+
## Context Notes
|
|
387
|
+
|
|
388
|
+
_No additional context._
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
_This file is auto-generated by the Agent Orchestration server._
|
|
393
|
+
_Edit shared memory to update this context._
|
|
394
|
+
`;
|
|
395
|
+
fs.writeFileSync(activeContextPath, template);
|
|
396
|
+
console.log('✓ Created activeContext.md');
|
|
397
|
+
} else {
|
|
398
|
+
console.log('✓ activeContext.md already exists');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Main
|
|
403
|
+
const args = process.argv.slice(2);
|
|
404
|
+
const command = args[0];
|
|
405
|
+
|
|
406
|
+
switch (command) {
|
|
407
|
+
case 'init':
|
|
408
|
+
initAgentsMd();
|
|
409
|
+
break;
|
|
410
|
+
case 'init-cursor':
|
|
411
|
+
initCursor();
|
|
412
|
+
break;
|
|
413
|
+
case 'serve':
|
|
414
|
+
runServer().catch((err) => {
|
|
415
|
+
console.error('Server error:', err);
|
|
416
|
+
process.exit(1);
|
|
417
|
+
});
|
|
418
|
+
break;
|
|
419
|
+
case 'help':
|
|
420
|
+
case '--help':
|
|
421
|
+
case '-h':
|
|
422
|
+
printUsage();
|
|
423
|
+
break;
|
|
424
|
+
default:
|
|
425
|
+
if (command) {
|
|
426
|
+
console.error(`Unknown command: ${command}`);
|
|
427
|
+
}
|
|
428
|
+
printUsage();
|
|
429
|
+
process.exit(command ? 1 : 0);
|
|
430
|
+
}
|