ac-framework 1.9.4 → 1.9.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.
- package/README.md +8 -0
- package/bin/postinstall.js +2 -0
- package/framework/mobile_development/.agent/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.agent/workflows/ac.md +226 -410
- package/framework/mobile_development/.amazonq/prompts/ac-lite.md +70 -179
- package/framework/mobile_development/.amazonq/prompts/ac.md +226 -410
- package/framework/mobile_development/.antigravity/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.antigravity/workflows/ac.md +226 -410
- package/framework/mobile_development/.augment/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.augment/commands/ac.md +226 -410
- package/framework/mobile_development/.claude/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.claude/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.cline/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.cline/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.clinerules/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.clinerules/workflows/ac.md +226 -410
- package/framework/mobile_development/.codebuddy/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.codebuddy/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.continue/prompts/ac-lite.md +70 -179
- package/framework/mobile_development/.continue/prompts/ac.md +226 -410
- package/framework/mobile_development/.cospec/openspec/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.cospec/openspec/commands/ac.md +226 -410
- package/framework/mobile_development/.crush/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.crush/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.cursor/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.cursor/commands/ac.md +226 -410
- package/framework/mobile_development/.factory/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.factory/commands/ac.md +226 -410
- package/framework/mobile_development/.gemini/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.gemini/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.github/prompts/ac-lite.md +70 -179
- package/framework/mobile_development/.github/prompts/ac.md +226 -410
- package/framework/mobile_development/.github/prompts/ac.prompt.md +282 -177
- package/framework/mobile_development/.iflow/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.iflow/commands/ac.md +226 -410
- package/framework/mobile_development/.kilocode/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.kilocode/workflows/ac.md +226 -410
- package/framework/mobile_development/.kimi/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.kimi/workflows/ac.md +226 -410
- package/framework/mobile_development/.opencode/command/ac-lite.md +70 -179
- package/framework/mobile_development/.opencode/command/ac.md +226 -410
- package/framework/mobile_development/.qoder/commands/opsx/ac-lite.md +70 -179
- package/framework/mobile_development/.qoder/commands/opsx/ac.md +226 -410
- package/framework/mobile_development/.qwen/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.qwen/commands/ac.md +226 -410
- package/framework/mobile_development/.roo/commands/ac-lite.md +70 -179
- package/framework/mobile_development/.roo/commands/ac.md +226 -410
- package/framework/mobile_development/.windsurf/workflows/ac-lite.md +70 -179
- package/framework/mobile_development/.windsurf/workflows/ac.md +226 -410
- package/framework/mobile_development/AGENTS.md +205 -416
- package/framework/mobile_development/CLAUDE.md +205 -416
- package/framework/mobile_development/GEMINI.md +205 -416
- package/framework/mobile_development/copilot-instructions.md +205 -416
- package/framework/new_project/.opencode/command/ac.md +27 -0
- package/framework/new_project/AGENTS.md +27 -0
- package/framework/web_development/.opencode/command/ac.md +27 -0
- package/framework/web_development/AGENTS.md +27 -0
- package/package.json +1 -1
- package/src/commands/agents.js +71 -2
- package/src/commands/init.js +33 -0
- package/src/mcp/collab-server.js +198 -0
- package/src/services/mcp-installer.js +82 -54
|
@@ -98,6 +98,33 @@ acfm memory stats
|
|
|
98
98
|
|
|
99
99
|
**User communication:** "Memory saved: [brief description]" when auto-saving occurs.
|
|
100
100
|
|
|
101
|
+
### SynapseGrid Collaborative MCP Protocol (Optional)
|
|
102
|
+
|
|
103
|
+
If SynapseGrid is enabled in `acfm init`, AC Framework installs the collaborative MCP server automatically for detected assistants.
|
|
104
|
+
|
|
105
|
+
**Session-start requirement when collaboration is enabled:**
|
|
106
|
+
1. Prefer the available SynapseGrid MCP tools for collaborative session control before falling back to direct CLI.
|
|
107
|
+
2. Use shared session state and transcript as the source of truth for role-by-role collaboration.
|
|
108
|
+
3. If collaborative MCP is unavailable, use CLI fallback commands and keep behavior equivalent.
|
|
109
|
+
|
|
110
|
+
**How to use SynapseGrid collaboration:**
|
|
111
|
+
```text
|
|
112
|
+
Preferred: use SynapseGrid MCP tools (ac-framework-collab) for session start/status/step/stop.
|
|
113
|
+
Fallback: use AC Framework agents CLI commands directly.
|
|
114
|
+
```
|
|
115
|
+
```bash
|
|
116
|
+
# Optional install/reinstall of collaborative MCP servers
|
|
117
|
+
acfm agents install-mcps
|
|
118
|
+
|
|
119
|
+
# Start collaborative runtime manually
|
|
120
|
+
acfm agents start --task "design and implement feature X"
|
|
121
|
+
|
|
122
|
+
# Resume/list/export operations
|
|
123
|
+
acfm agents resume
|
|
124
|
+
acfm agents list
|
|
125
|
+
acfm agents export --format md --out synapse-session.md
|
|
126
|
+
```
|
|
127
|
+
|
|
101
128
|
|
|
102
129
|
### OpenSpec Skills (The heart of the framework)
|
|
103
130
|
|
|
@@ -98,6 +98,33 @@ acfm memory stats
|
|
|
98
98
|
|
|
99
99
|
**User communication:** "Memory saved: [brief description]" when auto-saving occurs.
|
|
100
100
|
|
|
101
|
+
### SynapseGrid Collaborative MCP Protocol (Optional)
|
|
102
|
+
|
|
103
|
+
If SynapseGrid is enabled in `acfm init`, AC Framework installs the collaborative MCP server automatically for detected assistants.
|
|
104
|
+
|
|
105
|
+
**Session-start requirement when collaboration is enabled:**
|
|
106
|
+
1. Prefer the available SynapseGrid MCP tools for collaborative session control before falling back to direct CLI.
|
|
107
|
+
2. Use shared session state and transcript as the source of truth for role-by-role collaboration.
|
|
108
|
+
3. If collaborative MCP is unavailable, use CLI fallback commands and keep behavior equivalent.
|
|
109
|
+
|
|
110
|
+
**How to use SynapseGrid collaboration:**
|
|
111
|
+
```text
|
|
112
|
+
Preferred: use SynapseGrid MCP tools (ac-framework-collab) for session start/status/step/stop.
|
|
113
|
+
Fallback: use AC Framework agents CLI commands directly.
|
|
114
|
+
```
|
|
115
|
+
```bash
|
|
116
|
+
# Optional install/reinstall of collaborative MCP servers
|
|
117
|
+
acfm agents install-mcps
|
|
118
|
+
|
|
119
|
+
# Start collaborative runtime manually
|
|
120
|
+
acfm agents start --task "design and implement feature X"
|
|
121
|
+
|
|
122
|
+
# Resume/list/export operations
|
|
123
|
+
acfm agents resume
|
|
124
|
+
acfm agents list
|
|
125
|
+
acfm agents export --format md --out synapse-session.md
|
|
126
|
+
```
|
|
127
|
+
|
|
101
128
|
|
|
102
129
|
### OpenSpec Skills (The heart of the framework)
|
|
103
130
|
|
|
@@ -98,6 +98,33 @@ acfm memory stats
|
|
|
98
98
|
|
|
99
99
|
**User communication:** "Memory saved: [brief description]" when auto-saving occurs.
|
|
100
100
|
|
|
101
|
+
### SynapseGrid Collaborative MCP Protocol (Optional)
|
|
102
|
+
|
|
103
|
+
If SynapseGrid is enabled in `acfm init`, AC Framework installs the collaborative MCP server automatically for detected assistants.
|
|
104
|
+
|
|
105
|
+
**Session-start requirement when collaboration is enabled:**
|
|
106
|
+
1. Prefer the available SynapseGrid MCP tools for collaborative session control before falling back to direct CLI.
|
|
107
|
+
2. Use shared session state and transcript as the source of truth for role-by-role collaboration.
|
|
108
|
+
3. If collaborative MCP is unavailable, use CLI fallback commands and keep behavior equivalent.
|
|
109
|
+
|
|
110
|
+
**How to use SynapseGrid collaboration:**
|
|
111
|
+
```text
|
|
112
|
+
Preferred: use SynapseGrid MCP tools (ac-framework-collab) for session start/status/step/stop.
|
|
113
|
+
Fallback: use AC Framework agents CLI commands directly.
|
|
114
|
+
```
|
|
115
|
+
```bash
|
|
116
|
+
# Optional install/reinstall of collaborative MCP servers
|
|
117
|
+
acfm agents install-mcps
|
|
118
|
+
|
|
119
|
+
# Start collaborative runtime manually
|
|
120
|
+
acfm agents start --task "design and implement feature X"
|
|
121
|
+
|
|
122
|
+
# Resume/list/export operations
|
|
123
|
+
acfm agents resume
|
|
124
|
+
acfm agents list
|
|
125
|
+
acfm agents export --format md --out synapse-session.md
|
|
126
|
+
```
|
|
127
|
+
|
|
101
128
|
|
|
102
129
|
### OpenSpec Skills (The heart of the framework)
|
|
103
130
|
|
|
@@ -98,6 +98,33 @@ acfm memory stats
|
|
|
98
98
|
|
|
99
99
|
**User communication:** "Memory saved: [brief description]" when auto-saving occurs.
|
|
100
100
|
|
|
101
|
+
### SynapseGrid Collaborative MCP Protocol (Optional)
|
|
102
|
+
|
|
103
|
+
If SynapseGrid is enabled in `acfm init`, AC Framework installs the collaborative MCP server automatically for detected assistants.
|
|
104
|
+
|
|
105
|
+
**Session-start requirement when collaboration is enabled:**
|
|
106
|
+
1. Prefer the available SynapseGrid MCP tools for collaborative session control before falling back to direct CLI.
|
|
107
|
+
2. Use shared session state and transcript as the source of truth for role-by-role collaboration.
|
|
108
|
+
3. If collaborative MCP is unavailable, use CLI fallback commands and keep behavior equivalent.
|
|
109
|
+
|
|
110
|
+
**How to use SynapseGrid collaboration:**
|
|
111
|
+
```text
|
|
112
|
+
Preferred: use SynapseGrid MCP tools (ac-framework-collab) for session start/status/step/stop.
|
|
113
|
+
Fallback: use AC Framework agents CLI commands directly.
|
|
114
|
+
```
|
|
115
|
+
```bash
|
|
116
|
+
# Optional install/reinstall of collaborative MCP servers
|
|
117
|
+
acfm agents install-mcps
|
|
118
|
+
|
|
119
|
+
# Start collaborative runtime manually
|
|
120
|
+
acfm agents start --task "design and implement feature X"
|
|
121
|
+
|
|
122
|
+
# Resume/list/export operations
|
|
123
|
+
acfm agents resume
|
|
124
|
+
acfm agents list
|
|
125
|
+
acfm agents export --format md --out synapse-session.md
|
|
126
|
+
```
|
|
127
|
+
|
|
101
128
|
|
|
102
129
|
### OpenSpec Skills (The heart of the framework)
|
|
103
130
|
|
package/package.json
CHANGED
package/src/commands/agents.js
CHANGED
|
@@ -163,18 +163,87 @@ export function agentsCommand() {
|
|
|
163
163
|
.command('setup')
|
|
164
164
|
.description('Install optional collaboration dependencies (OpenCode + tmux)')
|
|
165
165
|
.option('--json', 'Output as JSON')
|
|
166
|
-
.action((opts) => {
|
|
166
|
+
.action(async (opts) => {
|
|
167
167
|
const result = ensureCollabDependencies();
|
|
168
|
-
|
|
168
|
+
let collabMcp = null;
|
|
169
|
+
|
|
170
|
+
if (result.success) {
|
|
171
|
+
const { detectAndInstallMCPs } = await import('../services/mcp-installer.js');
|
|
172
|
+
collabMcp = detectAndInstallMCPs({ target: 'collab' });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const payload = { ...result, collabMcp };
|
|
176
|
+
output(payload, opts.json);
|
|
169
177
|
if (!opts.json) {
|
|
170
178
|
const oLabel = result.opencode.success ? chalk.green('ok') : chalk.red('failed');
|
|
171
179
|
const tLabel = result.tmux.success ? chalk.green('ok') : chalk.red('failed');
|
|
172
180
|
console.log(`OpenCode: ${oLabel} - ${result.opencode.message}`);
|
|
173
181
|
console.log(`tmux: ${tLabel} - ${result.tmux.message}`);
|
|
182
|
+
if (collabMcp) {
|
|
183
|
+
console.log(`Collab MCP: ${chalk.green('ok')} - installed ${collabMcp.success}/${collabMcp.installed} on detected assistants`);
|
|
184
|
+
}
|
|
174
185
|
}
|
|
175
186
|
if (!result.success) process.exit(1);
|
|
176
187
|
});
|
|
177
188
|
|
|
189
|
+
agents
|
|
190
|
+
.command('install-mcps')
|
|
191
|
+
.description('Install SynapseGrid MCP server into detected AI assistants')
|
|
192
|
+
.option('--all', 'Install for all supported assistants, without detection', false)
|
|
193
|
+
.option('--json', 'Output as JSON')
|
|
194
|
+
.action(async (opts) => {
|
|
195
|
+
try {
|
|
196
|
+
const { detectAndInstallMCPs, installAllMCPs, ASSISTANTS, isAssistantInstalled } = await import('../services/mcp-installer.js');
|
|
197
|
+
const result = opts.all
|
|
198
|
+
? installAllMCPs({ target: 'collab' })
|
|
199
|
+
: detectAndInstallMCPs({ target: 'collab' });
|
|
200
|
+
|
|
201
|
+
output({ total: result.total ?? result.installed, success: result.success, target: 'collab' }, opts.json);
|
|
202
|
+
|
|
203
|
+
if (!opts.json) {
|
|
204
|
+
if (!opts.all) {
|
|
205
|
+
if (result.installed === 0) {
|
|
206
|
+
console.log(chalk.yellow('No AI assistants detected.'));
|
|
207
|
+
console.log(chalk.dim('Use --all to install for all supported assistants.'));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
for (const assistant of ASSISTANTS) {
|
|
211
|
+
if (isAssistantInstalled(assistant)) {
|
|
212
|
+
console.log(
|
|
213
|
+
chalk.hex('#00B894')('◆ ') + chalk.bold(assistant.name) +
|
|
214
|
+
chalk.dim(` → ${assistant.configPath}`)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
console.log(chalk.green(`\n✓ SynapseGrid MCP installed (${result.success}/${result.total ?? result.installed})`));
|
|
220
|
+
}
|
|
221
|
+
} catch (error) {
|
|
222
|
+
output({ error: error.message }, opts.json);
|
|
223
|
+
if (!opts.json) console.error(chalk.red(`Error: ${error.message}`));
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
agents
|
|
229
|
+
.command('uninstall-mcps')
|
|
230
|
+
.description('Uninstall SynapseGrid MCP server from detected AI assistants')
|
|
231
|
+
.option('--json', 'Output as JSON')
|
|
232
|
+
.action(async (opts) => {
|
|
233
|
+
try {
|
|
234
|
+
const { uninstallAllMCPs } = await import('../services/mcp-installer.js');
|
|
235
|
+
const result = uninstallAllMCPs({ target: 'collab' });
|
|
236
|
+
output({ success: result.success, target: 'collab' }, opts.json);
|
|
237
|
+
if (!opts.json) {
|
|
238
|
+
console.log(chalk.green(`✓ SynapseGrid MCP uninstalled (${result.success})`));
|
|
239
|
+
}
|
|
240
|
+
} catch (error) {
|
|
241
|
+
output({ error: error.message }, opts.json);
|
|
242
|
+
if (!opts.json) console.error(chalk.red(`Error: ${error.message}`));
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
178
247
|
agents
|
|
179
248
|
.command('list')
|
|
180
249
|
.description('List SynapseGrid sessions from local storage')
|
package/src/commands/init.js
CHANGED
|
@@ -190,9 +190,41 @@ async function setupCollaborativeSystem() {
|
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
async function installCollabMcpConnections() {
|
|
194
|
+
console.log();
|
|
195
|
+
console.log(chalk.hex('#B2BEC3')(` Connecting ${COLLAB_SYSTEM_NAME} MCP tools to detected assistants...`));
|
|
196
|
+
console.log();
|
|
197
|
+
|
|
198
|
+
const { detectAndInstallMCPs, ASSISTANTS, isAssistantInstalled } = await import('../services/mcp-installer.js');
|
|
199
|
+
const { installed, success } = detectAndInstallMCPs({ target: 'collab' });
|
|
200
|
+
|
|
201
|
+
if (installed === 0) {
|
|
202
|
+
console.log(chalk.hex('#636E72')(' No AI assistants detected yet.'));
|
|
203
|
+
console.log(chalk.hex('#636E72')(' Run ') + chalk.hex('#DFE6E9')('acfm agents install-mcps') + chalk.hex('#636E72')(' after installing an assistant.'));
|
|
204
|
+
console.log();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
for (const assistant of ASSISTANTS) {
|
|
209
|
+
if (isAssistantInstalled(assistant)) {
|
|
210
|
+
console.log(
|
|
211
|
+
chalk.hex('#00B894')(' ◆ ') +
|
|
212
|
+
chalk.hex('#DFE6E9').bold(assistant.name) +
|
|
213
|
+
chalk.hex('#636E72')(` · MCP config → ${assistant.configPath}`)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
console.log();
|
|
219
|
+
const successBadge = chalk.hex('#2D3436').bgHex('#00B894').bold(` ${success}/${installed} `);
|
|
220
|
+
console.log(` ${successBadge} ${chalk.hex('#B2BEC3')(`${COLLAB_SYSTEM_NAME} MCP connections installed`)}`);
|
|
221
|
+
console.log();
|
|
222
|
+
}
|
|
223
|
+
|
|
193
224
|
if (alreadyReady) {
|
|
194
225
|
console.log();
|
|
195
226
|
console.log(chalk.hex('#00B894')(' ◆ OpenCode and tmux are already available.'));
|
|
227
|
+
await installCollabMcpConnections();
|
|
196
228
|
console.log(chalk.hex('#636E72')(' Run `acfm agents start --task "..."` to launch collaboration.'));
|
|
197
229
|
console.log();
|
|
198
230
|
return;
|
|
@@ -211,6 +243,7 @@ async function setupCollaborativeSystem() {
|
|
|
211
243
|
console.log();
|
|
212
244
|
|
|
213
245
|
if (result.success) {
|
|
246
|
+
await installCollabMcpConnections();
|
|
214
247
|
console.log(chalk.hex('#00B894').bold(` ${COLLAB_SYSTEM_NAME} is active.`));
|
|
215
248
|
console.log(chalk.hex('#636E72')(' Run acfm agents start --task "..." to open the war-room.'));
|
|
216
249
|
} else {
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MCP Server for AC Framework SynapseGrid Collaboration System
|
|
5
|
+
* Exposes collaborative multi-agent session controls via MCP.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { COLLAB_ROLES } from '../agents/constants.js';
|
|
12
|
+
import { runWorkerIteration } from '../agents/orchestrator.js';
|
|
13
|
+
import {
|
|
14
|
+
addUserMessage,
|
|
15
|
+
createSession,
|
|
16
|
+
loadCurrentSessionId,
|
|
17
|
+
loadSessionState,
|
|
18
|
+
loadTranscript,
|
|
19
|
+
saveSessionState,
|
|
20
|
+
setCurrentSession,
|
|
21
|
+
stopSession,
|
|
22
|
+
} from '../agents/state-store.js';
|
|
23
|
+
|
|
24
|
+
class MCPCollabServer {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.server = new McpServer({
|
|
27
|
+
name: 'ac-framework-collab',
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
this.setupTools();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setupTools() {
|
|
35
|
+
this.server.tool(
|
|
36
|
+
'collab_start_session',
|
|
37
|
+
'Start a SynapseGrid collaborative session',
|
|
38
|
+
{
|
|
39
|
+
task: z.string().describe('Initial collaborative task'),
|
|
40
|
+
maxRounds: z.number().int().positive().default(3).describe('Maximum collaboration rounds'),
|
|
41
|
+
model: z.string().optional().describe('Model id (provider/model) for opencode run'),
|
|
42
|
+
},
|
|
43
|
+
async ({ task, maxRounds, model }) => {
|
|
44
|
+
try {
|
|
45
|
+
const state = await createSession(task, {
|
|
46
|
+
roles: COLLAB_ROLES,
|
|
47
|
+
maxRounds,
|
|
48
|
+
model: model || null,
|
|
49
|
+
workingDirectory: process.cwd(),
|
|
50
|
+
});
|
|
51
|
+
await setCurrentSession(state.sessionId);
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: JSON.stringify({ success: true, sessionId: state.sessionId, status: state.status }, null, 2),
|
|
56
|
+
}],
|
|
57
|
+
};
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }], isError: true };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
this.server.tool(
|
|
65
|
+
'collab_send_message',
|
|
66
|
+
'Send a user message to the active collaborative session',
|
|
67
|
+
{
|
|
68
|
+
message: z.string().describe('User message to add to shared context'),
|
|
69
|
+
sessionId: z.string().optional().describe('Session ID (defaults to current session)'),
|
|
70
|
+
},
|
|
71
|
+
async ({ message, sessionId }) => {
|
|
72
|
+
try {
|
|
73
|
+
const id = sessionId || await loadCurrentSessionId();
|
|
74
|
+
if (!id) {
|
|
75
|
+
throw new Error('No active session found');
|
|
76
|
+
}
|
|
77
|
+
let state = await loadSessionState(id);
|
|
78
|
+
state = await addUserMessage(state, message);
|
|
79
|
+
state = await saveSessionState(state);
|
|
80
|
+
return {
|
|
81
|
+
content: [{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: JSON.stringify({ success: true, sessionId: id, messages: state.messages.length }, null, 2),
|
|
84
|
+
}],
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }], isError: true };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
this.server.tool(
|
|
93
|
+
'collab_step',
|
|
94
|
+
'Execute one collaborative worker turn by role',
|
|
95
|
+
{
|
|
96
|
+
role: z.enum(COLLAB_ROLES).describe('Role to execute for one step'),
|
|
97
|
+
sessionId: z.string().optional().describe('Session ID (defaults to current session)'),
|
|
98
|
+
},
|
|
99
|
+
async ({ role, sessionId }) => {
|
|
100
|
+
try {
|
|
101
|
+
const id = sessionId || await loadCurrentSessionId();
|
|
102
|
+
if (!id) {
|
|
103
|
+
throw new Error('No active session found');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const state = await runWorkerIteration(id, role, {
|
|
107
|
+
cwd: process.cwd(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
content: [{
|
|
112
|
+
type: 'text',
|
|
113
|
+
text: JSON.stringify({
|
|
114
|
+
success: true,
|
|
115
|
+
sessionId: id,
|
|
116
|
+
status: state.status,
|
|
117
|
+
round: state.round,
|
|
118
|
+
activeAgent: state.activeAgent,
|
|
119
|
+
messageCount: state.messages.length,
|
|
120
|
+
}, null, 2),
|
|
121
|
+
}],
|
|
122
|
+
};
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }], isError: true };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
this.server.tool(
|
|
130
|
+
'collab_status',
|
|
131
|
+
'Get current collaborative session state',
|
|
132
|
+
{
|
|
133
|
+
sessionId: z.string().optional().describe('Session ID (defaults to current session)'),
|
|
134
|
+
includeTranscript: z.boolean().default(false).describe('Include transcript JSONL messages'),
|
|
135
|
+
},
|
|
136
|
+
async ({ sessionId, includeTranscript }) => {
|
|
137
|
+
try {
|
|
138
|
+
const id = sessionId || await loadCurrentSessionId();
|
|
139
|
+
if (!id) {
|
|
140
|
+
throw new Error('No active session found');
|
|
141
|
+
}
|
|
142
|
+
const state = await loadSessionState(id);
|
|
143
|
+
const transcript = includeTranscript ? await loadTranscript(id) : undefined;
|
|
144
|
+
return {
|
|
145
|
+
content: [{
|
|
146
|
+
type: 'text',
|
|
147
|
+
text: JSON.stringify({ state, transcript }, null, 2),
|
|
148
|
+
}],
|
|
149
|
+
};
|
|
150
|
+
} catch (error) {
|
|
151
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }], isError: true };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
this.server.tool(
|
|
157
|
+
'collab_stop_session',
|
|
158
|
+
'Stop current collaborative session',
|
|
159
|
+
{
|
|
160
|
+
sessionId: z.string().optional().describe('Session ID (defaults to current session)'),
|
|
161
|
+
},
|
|
162
|
+
async ({ sessionId }) => {
|
|
163
|
+
try {
|
|
164
|
+
const id = sessionId || await loadCurrentSessionId();
|
|
165
|
+
if (!id) {
|
|
166
|
+
throw new Error('No active session found');
|
|
167
|
+
}
|
|
168
|
+
const state = await loadSessionState(id);
|
|
169
|
+
const updated = await stopSession(state, 'stopped');
|
|
170
|
+
return {
|
|
171
|
+
content: [{
|
|
172
|
+
type: 'text',
|
|
173
|
+
text: JSON.stringify({ success: true, sessionId: id, status: updated.status }, null, 2),
|
|
174
|
+
}],
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }], isError: true };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async run() {
|
|
184
|
+
const transport = new StdioServerTransport();
|
|
185
|
+
await this.server.connect(transport);
|
|
186
|
+
console.error('AC Framework SynapseGrid MCP Server running on stdio');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
191
|
+
const server = new MCPCollabServer();
|
|
192
|
+
server.run().catch((error) => {
|
|
193
|
+
console.error('Failed to start SynapseGrid MCP server:', error);
|
|
194
|
+
process.exit(1);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default MCPCollabServer;
|