agent-working-memory 0.7.17 → 0.8.6
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 +156 -15
- package/dist/adapters/common.d.ts.map +1 -1
- package/dist/adapters/common.js +289 -202
- package/dist/adapters/common.js.map +1 -1
- package/dist/adapters/http.js +22 -22
- package/dist/api/routes.d.ts +1 -1
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +258 -79
- package/dist/api/routes.js.map +1 -1
- package/dist/cli/migrate.d.ts +42 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +268 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli.js +147 -103
- package/dist/cli.js.map +1 -1
- package/dist/coordination/circuit-breaker.d.ts +24 -0
- package/dist/coordination/circuit-breaker.d.ts.map +1 -0
- package/dist/coordination/circuit-breaker.js +70 -0
- package/dist/coordination/circuit-breaker.js.map +1 -0
- package/dist/coordination/failure-modes.d.ts +21 -0
- package/dist/coordination/failure-modes.d.ts.map +1 -0
- package/dist/coordination/failure-modes.js +49 -0
- package/dist/coordination/failure-modes.js.map +1 -0
- package/dist/coordination/peer-decisions.js +7 -7
- package/dist/coordination/routes.d.ts.map +1 -1
- package/dist/coordination/routes.js +44 -1
- package/dist/coordination/routes.js.map +1 -1
- package/dist/coordination/schema.d.ts.map +1 -1
- package/dist/coordination/schema.js +18 -0
- package/dist/coordination/schema.js.map +1 -1
- package/dist/coordination/schemas.d.ts +9 -9
- package/dist/coordination/stale.d.ts +9 -1
- package/dist/coordination/stale.d.ts.map +1 -1
- package/dist/coordination/stale.js +53 -9
- package/dist/coordination/stale.js.map +1 -1
- package/dist/core/embeddings.d.ts +16 -10
- package/dist/core/embeddings.d.ts.map +1 -1
- package/dist/core/embeddings.js +54 -38
- package/dist/core/embeddings.js.map +1 -1
- package/dist/core/ml-worker-entry.d.ts +17 -0
- package/dist/core/ml-worker-entry.d.ts.map +1 -0
- package/dist/core/ml-worker-entry.js +193 -0
- package/dist/core/ml-worker-entry.js.map +1 -0
- package/dist/core/ml-worker.d.ts +59 -0
- package/dist/core/ml-worker.d.ts.map +1 -0
- package/dist/core/ml-worker.js +253 -0
- package/dist/core/ml-worker.js.map +1 -0
- package/dist/core/query-expander.d.ts +13 -15
- package/dist/core/query-expander.d.ts.map +1 -1
- package/dist/core/query-expander.js +48 -54
- package/dist/core/query-expander.js.map +1 -1
- package/dist/core/reranker.d.ts +9 -19
- package/dist/core/reranker.d.ts.map +1 -1
- package/dist/core/reranker.js +33 -35
- package/dist/core/reranker.js.map +1 -1
- package/dist/core/salience.d.ts +32 -5
- package/dist/core/salience.d.ts.map +1 -1
- package/dist/core/salience.js +201 -28
- package/dist/core/salience.js.map +1 -1
- package/dist/core/write-pipeline.d.ts +10 -2
- package/dist/core/write-pipeline.d.ts.map +1 -1
- package/dist/core/write-pipeline.js +218 -49
- package/dist/core/write-pipeline.js.map +1 -1
- package/dist/engine/activation.d.ts +2 -2
- package/dist/engine/activation.d.ts.map +1 -1
- package/dist/engine/activation.js +238 -115
- package/dist/engine/activation.js.map +1 -1
- package/dist/engine/confidence.d.ts +62 -0
- package/dist/engine/confidence.d.ts.map +1 -0
- package/dist/engine/confidence.js +100 -0
- package/dist/engine/confidence.js.map +1 -0
- package/dist/engine/connections.d.ts +47 -8
- package/dist/engine/connections.d.ts.map +1 -1
- package/dist/engine/connections.js +83 -22
- package/dist/engine/connections.js.map +1 -1
- package/dist/engine/consolidation-scheduler.d.ts +46 -10
- package/dist/engine/consolidation-scheduler.d.ts.map +1 -1
- package/dist/engine/consolidation-scheduler.js +170 -50
- package/dist/engine/consolidation-scheduler.js.map +1 -1
- package/dist/engine/consolidation.d.ts +16 -2
- package/dist/engine/consolidation.d.ts.map +1 -1
- package/dist/engine/consolidation.js +143 -44
- package/dist/engine/consolidation.js.map +1 -1
- package/dist/engine/eval.d.ts +2 -2
- package/dist/engine/eval.d.ts.map +1 -1
- package/dist/engine/eval.js +9 -9
- package/dist/engine/eval.js.map +1 -1
- package/dist/engine/eviction.d.ts +4 -4
- package/dist/engine/eviction.d.ts.map +1 -1
- package/dist/engine/eviction.js +15 -15
- package/dist/engine/eviction.js.map +1 -1
- package/dist/engine/retraction.d.ts +93 -5
- package/dist/engine/retraction.d.ts.map +1 -1
- package/dist/engine/retraction.js +238 -19
- package/dist/engine/retraction.js.map +1 -1
- package/dist/engine/staging.d.ts +1 -1
- package/dist/engine/staging.d.ts.map +1 -1
- package/dist/engine/staging.js +3 -3
- package/dist/engine/staging.js.map +1 -1
- package/dist/hooks/sidecar.d.ts +1 -1
- package/dist/hooks/sidecar.d.ts.map +1 -1
- package/dist/hooks/sidecar.js +4 -4
- package/dist/hooks/sidecar.js.map +1 -1
- package/dist/index.js +48 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +167 -141
- package/dist/mcp.js.map +1 -1
- package/dist/storage/factory.d.ts +55 -0
- package/dist/storage/factory.d.ts.map +1 -0
- package/dist/storage/factory.js +135 -0
- package/dist/storage/factory.js.map +1 -0
- package/dist/storage/pglite-schema.d.ts +20 -0
- package/dist/storage/pglite-schema.d.ts.map +1 -0
- package/dist/storage/pglite-schema.js +165 -0
- package/dist/storage/pglite-schema.js.map +1 -0
- package/dist/storage/pglite.d.ts +187 -0
- package/dist/storage/pglite.d.ts.map +1 -0
- package/dist/storage/pglite.js +1114 -0
- package/dist/storage/pglite.js.map +1 -0
- package/dist/storage/sqlite.d.ts +117 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +357 -8
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/storage/store.d.ts +63 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +27 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/types/engram.d.ts +92 -2
- package/dist/types/engram.d.ts.map +1 -1
- package/dist/types/engram.js.map +1 -1
- package/package.json +3 -1
- package/src/adapters/claude-code.ts +218 -218
- package/src/adapters/codex.ts +252 -252
- package/src/adapters/common.ts +498 -411
- package/src/adapters/cursor.ts +135 -135
- package/src/adapters/http.ts +93 -93
- package/src/adapters/index.ts +31 -31
- package/src/adapters/types.ts +75 -75
- package/src/api/index.ts +3 -3
- package/src/api/routes.ts +970 -714
- package/src/cli/migrate.ts +307 -0
- package/src/cli.ts +755 -719
- package/src/coordination/circuit-breaker.ts +83 -0
- package/src/coordination/events.ts +90 -90
- package/src/coordination/failure-modes.ts +50 -0
- package/src/coordination/peer-decisions.ts +105 -105
- package/src/coordination/plugin-loader.ts +60 -60
- package/src/coordination/plugin.ts +44 -44
- package/src/coordination/routes.ts +56 -1
- package/src/coordination/schema.ts +13 -0
- package/src/coordination/stale.ts +80 -11
- package/src/coordination/types.ts +311 -311
- package/src/coordination/write-mutex.ts +69 -69
- package/src/core/auto-tagger.ts +168 -168
- package/src/core/decay.ts +63 -63
- package/src/core/embeddings.ts +110 -93
- package/src/core/index.ts +5 -5
- package/src/core/logger.ts +36 -36
- package/src/core/ml-worker-entry.ts +194 -0
- package/src/core/ml-worker.ts +281 -0
- package/src/core/query-expander.ts +122 -128
- package/src/core/reranker.ts +119 -125
- package/src/core/salience.ts +200 -33
- package/src/core/write-pipeline.ts +521 -343
- package/src/engine/activation.ts +235 -109
- package/src/engine/confidence.ts +120 -0
- package/src/engine/connections.ts +162 -103
- package/src/engine/consolidation-scheduler.ts +242 -125
- package/src/engine/consolidation.ts +138 -45
- package/src/engine/eval.ts +102 -102
- package/src/engine/eviction.ts +101 -101
- package/src/engine/index.ts +8 -8
- package/src/engine/retraction.ts +366 -116
- package/src/engine/staging.ts +74 -74
- package/src/hooks/sidecar.ts +5 -5
- package/src/index.ts +226 -212
- package/src/mcp.ts +1145 -1121
- package/src/storage/factory.ts +147 -0
- package/src/storage/index.ts +3 -3
- package/src/storage/pglite-schema.ts +166 -0
- package/src/storage/pglite.ts +1363 -0
- package/src/storage/sqlite.ts +402 -7
- package/src/storage/store.ts +80 -0
- package/src/types/agent.ts +67 -67
- package/src/types/checkpoint.ts +46 -46
- package/src/types/engram.ts +101 -3
- package/src/types/eval.ts +100 -100
- package/src/types/index.ts +6 -6
package/src/adapters/cursor.ts
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Cursor adapter — writes .cursor/mcp.json and .cursorrules.
|
|
6
|
-
*
|
|
7
|
-
* Cursor uses the same MCP config format as Claude Code (JSON with mcpServers).
|
|
8
|
-
* Instructions go in .cursorrules (project) or ~/.cursor/rules (global).
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
12
|
-
import { join, dirname, basename } from 'node:path';
|
|
13
|
-
import type { CLIAdapter, SetupContext, DiagnosticResult } from './types.js';
|
|
14
|
-
import { resolveMcpCommand, homedir, AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
|
|
15
|
-
|
|
16
|
-
const adapter: CLIAdapter = {
|
|
17
|
-
id: 'cursor',
|
|
18
|
-
name: 'Cursor',
|
|
19
|
-
supportsProjectScope: true,
|
|
20
|
-
supportsGlobalScope: true,
|
|
21
|
-
|
|
22
|
-
writeMcpConfig(ctx: SetupContext): string {
|
|
23
|
-
const mcpCmd = resolveMcpCommand(ctx);
|
|
24
|
-
const mcpConfig = { ...mcpCmd, env: ctx.envVars };
|
|
25
|
-
|
|
26
|
-
const mcpJsonPath = ctx.isGlobal
|
|
27
|
-
? join(homedir(), '.cursor', 'mcp.json')
|
|
28
|
-
: join(ctx.cwd, '.cursor', 'mcp.json');
|
|
29
|
-
|
|
30
|
-
const mcpDir = dirname(mcpJsonPath);
|
|
31
|
-
if (!existsSync(mcpDir)) {
|
|
32
|
-
mkdirSync(mcpDir, { recursive: true });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let existing: any = { mcpServers: {} };
|
|
36
|
-
if (existsSync(mcpJsonPath)) {
|
|
37
|
-
try {
|
|
38
|
-
existing = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));
|
|
39
|
-
if (!existing.mcpServers) existing.mcpServers = {};
|
|
40
|
-
} catch {
|
|
41
|
-
existing = { mcpServers: {} };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
existing.mcpServers['agent-working-memory'] = mcpConfig;
|
|
46
|
-
writeFileSync(mcpJsonPath, JSON.stringify(existing, null, 2) + '\n');
|
|
47
|
-
return `MCP config: ${mcpJsonPath}`;
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
writeInstructions(ctx: SetupContext, skip: boolean): string {
|
|
51
|
-
const rulesPath = ctx.isGlobal
|
|
52
|
-
? join(homedir(), '.cursor', 'rules')
|
|
53
|
-
: join(ctx.cwd, '.cursorrules');
|
|
54
|
-
|
|
55
|
-
if (skip) return '.cursorrules: skipped (--no-instructions)';
|
|
56
|
-
|
|
57
|
-
return upsertAwmSection(rulesPath, AWM_INSTRUCTION_CONTENT, { titleIfNew: '# Agent Working Memory' });
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
writeHooks(_ctx: SetupContext, _skip: boolean): string {
|
|
61
|
-
return 'Hooks: not supported by Cursor (auto-checkpoint unavailable)';
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
diagnose(ctx: SetupContext): DiagnosticResult[] {
|
|
65
|
-
const results: DiagnosticResult[] = [];
|
|
66
|
-
|
|
67
|
-
// Check MCP config
|
|
68
|
-
const mcpJsonPath = ctx.isGlobal
|
|
69
|
-
? join(homedir(), '.cursor', 'mcp.json')
|
|
70
|
-
: join(ctx.cwd, '.cursor', 'mcp.json');
|
|
71
|
-
|
|
72
|
-
if (!existsSync(mcpJsonPath)) {
|
|
73
|
-
results.push({
|
|
74
|
-
check: 'MCP config',
|
|
75
|
-
status: 'fail',
|
|
76
|
-
message: `${mcpJsonPath} not found`,
|
|
77
|
-
fix: `Run: awm setup cursor${ctx.isGlobal ? ' --global' : ''}`,
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
try {
|
|
81
|
-
const config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));
|
|
82
|
-
if (config.mcpServers?.['agent-working-memory']) {
|
|
83
|
-
results.push({ check: 'MCP config', status: 'ok', message: `AWM registered in ${mcpJsonPath}` });
|
|
84
|
-
} else {
|
|
85
|
-
results.push({
|
|
86
|
-
check: 'MCP config',
|
|
87
|
-
status: 'fail',
|
|
88
|
-
message: `${mcpJsonPath} exists but missing agent-working-memory entry`,
|
|
89
|
-
fix: `Run: awm setup cursor${ctx.isGlobal ? ' --global' : ''}`,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
results.push({ check: 'MCP config', status: 'fail', message: `${mcpJsonPath} is not valid JSON` });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Check entrypoint
|
|
98
|
-
if (ctx.hasDist) {
|
|
99
|
-
results.push({ check: 'MCP entrypoint', status: 'ok', message: 'dist/mcp.js exists' });
|
|
100
|
-
} else {
|
|
101
|
-
results.push({
|
|
102
|
-
check: 'MCP entrypoint',
|
|
103
|
-
status: 'warn',
|
|
104
|
-
message: 'dist/mcp.js not found — using dev mode',
|
|
105
|
-
fix: 'Run: npm run build',
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Check database
|
|
110
|
-
if (existsSync(ctx.dbPath)) {
|
|
111
|
-
results.push({ check: 'Database', status: 'ok', message: ctx.dbPath });
|
|
112
|
-
} else {
|
|
113
|
-
results.push({ check: 'Database', status: 'warn', message: `${ctx.dbPath} not found` });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Check instructions
|
|
117
|
-
const rulesPath = ctx.isGlobal
|
|
118
|
-
? join(homedir(), '.cursor', 'rules')
|
|
119
|
-
: join(ctx.cwd, '.cursorrules');
|
|
120
|
-
if (existsSync(rulesPath)) {
|
|
121
|
-
const content = readFileSync(rulesPath, 'utf-8');
|
|
122
|
-
if (content.includes('## Memory (AWM)')) {
|
|
123
|
-
results.push({ check: 'Instructions', status: 'ok', message: '.cursorrules has AWM section' });
|
|
124
|
-
} else {
|
|
125
|
-
results.push({ check: 'Instructions', status: 'warn', message: '.cursorrules exists but missing AWM section' });
|
|
126
|
-
}
|
|
127
|
-
} else {
|
|
128
|
-
results.push({ check: 'Instructions', status: 'warn', message: '.cursorrules not found' });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return results;
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default adapter;
|
|
1
|
+
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cursor adapter — writes .cursor/mcp.json and .cursorrules.
|
|
6
|
+
*
|
|
7
|
+
* Cursor uses the same MCP config format as Claude Code (JSON with mcpServers).
|
|
8
|
+
* Instructions go in .cursorrules (project) or ~/.cursor/rules (global).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
12
|
+
import { join, dirname, basename } from 'node:path';
|
|
13
|
+
import type { CLIAdapter, SetupContext, DiagnosticResult } from './types.js';
|
|
14
|
+
import { resolveMcpCommand, homedir, AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
|
|
15
|
+
|
|
16
|
+
const adapter: CLIAdapter = {
|
|
17
|
+
id: 'cursor',
|
|
18
|
+
name: 'Cursor',
|
|
19
|
+
supportsProjectScope: true,
|
|
20
|
+
supportsGlobalScope: true,
|
|
21
|
+
|
|
22
|
+
writeMcpConfig(ctx: SetupContext): string {
|
|
23
|
+
const mcpCmd = resolveMcpCommand(ctx);
|
|
24
|
+
const mcpConfig = { ...mcpCmd, env: ctx.envVars };
|
|
25
|
+
|
|
26
|
+
const mcpJsonPath = ctx.isGlobal
|
|
27
|
+
? join(homedir(), '.cursor', 'mcp.json')
|
|
28
|
+
: join(ctx.cwd, '.cursor', 'mcp.json');
|
|
29
|
+
|
|
30
|
+
const mcpDir = dirname(mcpJsonPath);
|
|
31
|
+
if (!existsSync(mcpDir)) {
|
|
32
|
+
mkdirSync(mcpDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let existing: any = { mcpServers: {} };
|
|
36
|
+
if (existsSync(mcpJsonPath)) {
|
|
37
|
+
try {
|
|
38
|
+
existing = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));
|
|
39
|
+
if (!existing.mcpServers) existing.mcpServers = {};
|
|
40
|
+
} catch {
|
|
41
|
+
existing = { mcpServers: {} };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
existing.mcpServers['agent-working-memory'] = mcpConfig;
|
|
46
|
+
writeFileSync(mcpJsonPath, JSON.stringify(existing, null, 2) + '\n');
|
|
47
|
+
return `MCP config: ${mcpJsonPath}`;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
writeInstructions(ctx: SetupContext, skip: boolean): string {
|
|
51
|
+
const rulesPath = ctx.isGlobal
|
|
52
|
+
? join(homedir(), '.cursor', 'rules')
|
|
53
|
+
: join(ctx.cwd, '.cursorrules');
|
|
54
|
+
|
|
55
|
+
if (skip) return '.cursorrules: skipped (--no-instructions)';
|
|
56
|
+
|
|
57
|
+
return upsertAwmSection(rulesPath, AWM_INSTRUCTION_CONTENT, { titleIfNew: '# Agent Working Memory' });
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
writeHooks(_ctx: SetupContext, _skip: boolean): string {
|
|
61
|
+
return 'Hooks: not supported by Cursor (auto-checkpoint unavailable)';
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
diagnose(ctx: SetupContext): DiagnosticResult[] {
|
|
65
|
+
const results: DiagnosticResult[] = [];
|
|
66
|
+
|
|
67
|
+
// Check MCP config
|
|
68
|
+
const mcpJsonPath = ctx.isGlobal
|
|
69
|
+
? join(homedir(), '.cursor', 'mcp.json')
|
|
70
|
+
: join(ctx.cwd, '.cursor', 'mcp.json');
|
|
71
|
+
|
|
72
|
+
if (!existsSync(mcpJsonPath)) {
|
|
73
|
+
results.push({
|
|
74
|
+
check: 'MCP config',
|
|
75
|
+
status: 'fail',
|
|
76
|
+
message: `${mcpJsonPath} not found`,
|
|
77
|
+
fix: `Run: awm setup cursor${ctx.isGlobal ? ' --global' : ''}`,
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
try {
|
|
81
|
+
const config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));
|
|
82
|
+
if (config.mcpServers?.['agent-working-memory']) {
|
|
83
|
+
results.push({ check: 'MCP config', status: 'ok', message: `AWM registered in ${mcpJsonPath}` });
|
|
84
|
+
} else {
|
|
85
|
+
results.push({
|
|
86
|
+
check: 'MCP config',
|
|
87
|
+
status: 'fail',
|
|
88
|
+
message: `${mcpJsonPath} exists but missing agent-working-memory entry`,
|
|
89
|
+
fix: `Run: awm setup cursor${ctx.isGlobal ? ' --global' : ''}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} catch {
|
|
93
|
+
results.push({ check: 'MCP config', status: 'fail', message: `${mcpJsonPath} is not valid JSON` });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check entrypoint
|
|
98
|
+
if (ctx.hasDist) {
|
|
99
|
+
results.push({ check: 'MCP entrypoint', status: 'ok', message: 'dist/mcp.js exists' });
|
|
100
|
+
} else {
|
|
101
|
+
results.push({
|
|
102
|
+
check: 'MCP entrypoint',
|
|
103
|
+
status: 'warn',
|
|
104
|
+
message: 'dist/mcp.js not found — using dev mode',
|
|
105
|
+
fix: 'Run: npm run build',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Check database
|
|
110
|
+
if (existsSync(ctx.dbPath)) {
|
|
111
|
+
results.push({ check: 'Database', status: 'ok', message: ctx.dbPath });
|
|
112
|
+
} else {
|
|
113
|
+
results.push({ check: 'Database', status: 'warn', message: `${ctx.dbPath} not found` });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Check instructions
|
|
117
|
+
const rulesPath = ctx.isGlobal
|
|
118
|
+
? join(homedir(), '.cursor', 'rules')
|
|
119
|
+
: join(ctx.cwd, '.cursorrules');
|
|
120
|
+
if (existsSync(rulesPath)) {
|
|
121
|
+
const content = readFileSync(rulesPath, 'utf-8');
|
|
122
|
+
if (content.includes('## Memory (AWM)')) {
|
|
123
|
+
results.push({ check: 'Instructions', status: 'ok', message: '.cursorrules has AWM section' });
|
|
124
|
+
} else {
|
|
125
|
+
results.push({ check: 'Instructions', status: 'warn', message: '.cursorrules exists but missing AWM section' });
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
results.push({ check: 'Instructions', status: 'warn', message: '.cursorrules not found' });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return results;
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default adapter;
|
package/src/adapters/http.ts
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* HTTP adapter — generic fallback for any tool that can make REST calls.
|
|
6
|
-
*
|
|
7
|
-
* Doesn't write MCP config. Prints connection instructions for the HTTP API.
|
|
8
|
-
* Optionally writes an instruction file.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import type { CLIAdapter, SetupContext, DiagnosticResult } from './types.js';
|
|
14
|
-
import { AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
|
|
15
|
-
|
|
16
|
-
const HTTP_ADDENDUM = `
|
|
17
|
-
### HTTP API (for tools without MCP support)
|
|
18
|
-
|
|
19
|
-
If your tool doesn't support MCP, use the HTTP API directly:
|
|
20
|
-
|
|
21
|
-
**Base URL:** \`http://127.0.0.1:8400\`
|
|
22
|
-
|
|
23
|
-
| Method | Endpoint | Purpose |
|
|
24
|
-
|--------|----------|---------|
|
|
25
|
-
| GET | /memory/restore/:agentId | Restore context from prior sessions |
|
|
26
|
-
| POST | /memory/activate | Cognitive recall (use \`context\` field) |
|
|
27
|
-
| POST | /memory/write | Write a memory |
|
|
28
|
-
| POST | /memory/feedback | Report if memory was useful |
|
|
29
|
-
| POST | /memory/retract | Invalidate a wrong memory |
|
|
30
|
-
| POST | /memory/checkpoint | Save execution state |
|
|
31
|
-
| POST | /task/create | Create a task |
|
|
32
|
-
| POST | /task/update | Update task status |
|
|
33
|
-
| GET | /task/list/:agentId | List tasks |
|
|
34
|
-
| GET | /task/next/:agentId | Get next actionable task |
|
|
35
|
-
| GET | /health | Health check |
|
|
36
|
-
|
|
37
|
-
Start the server with: \`awm serve\`
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
const adapter: CLIAdapter = {
|
|
41
|
-
id: 'http',
|
|
42
|
-
name: 'HTTP (generic)',
|
|
43
|
-
supportsProjectScope: true,
|
|
44
|
-
supportsGlobalScope: false,
|
|
45
|
-
|
|
46
|
-
writeMcpConfig(ctx: SetupContext): string {
|
|
47
|
-
const port = process.env.AWM_PORT ?? '8400';
|
|
48
|
-
return `MCP config: N/A (HTTP mode)\n Start server: awm serve --port ${port}\n Base URL: http://127.0.0.1:${port}`;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
writeInstructions(ctx: SetupContext, skip: boolean): string {
|
|
52
|
-
const instrPath = join(ctx.cwd, 'AWM-INSTRUCTIONS.md');
|
|
53
|
-
|
|
54
|
-
if (skip) return 'AWM-INSTRUCTIONS.md: skipped (--no-instructions)';
|
|
55
|
-
|
|
56
|
-
return upsertAwmSection(instrPath, AWM_INSTRUCTION_CONTENT, {
|
|
57
|
-
titleIfNew: '# Agent Working Memory',
|
|
58
|
-
suffix: HTTP_ADDENDUM,
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
writeHooks(_ctx: SetupContext, _skip: boolean): string {
|
|
63
|
-
return 'Hooks: N/A (HTTP mode)';
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
diagnose(ctx: SetupContext): DiagnosticResult[] {
|
|
67
|
-
const results: DiagnosticResult[] = [];
|
|
68
|
-
|
|
69
|
-
// Check database
|
|
70
|
-
if (existsSync(ctx.dbPath)) {
|
|
71
|
-
results.push({ check: 'Database', status: 'ok', message: ctx.dbPath });
|
|
72
|
-
} else {
|
|
73
|
-
results.push({ check: 'Database', status: 'warn', message: `${ctx.dbPath} not found` });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check if HTTP server is reachable
|
|
77
|
-
// (can't do async in diagnose, so just check if the entrypoint exists)
|
|
78
|
-
if (ctx.hasDist) {
|
|
79
|
-
results.push({ check: 'Server entrypoint', status: 'ok', message: 'dist/index.js exists' });
|
|
80
|
-
} else {
|
|
81
|
-
results.push({
|
|
82
|
-
check: 'Server entrypoint',
|
|
83
|
-
status: 'warn',
|
|
84
|
-
message: 'dist/index.js not found — use: npx tsx src/index.ts',
|
|
85
|
-
fix: 'Run: npm run build',
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return results;
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default adapter;
|
|
1
|
+
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTTP adapter — generic fallback for any tool that can make REST calls.
|
|
6
|
+
*
|
|
7
|
+
* Doesn't write MCP config. Prints connection instructions for the HTTP API.
|
|
8
|
+
* Optionally writes an instruction file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import type { CLIAdapter, SetupContext, DiagnosticResult } from './types.js';
|
|
14
|
+
import { AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
|
|
15
|
+
|
|
16
|
+
const HTTP_ADDENDUM = `
|
|
17
|
+
### HTTP API (for tools without MCP support)
|
|
18
|
+
|
|
19
|
+
If your tool doesn't support MCP, use the HTTP API directly:
|
|
20
|
+
|
|
21
|
+
**Base URL:** \`http://127.0.0.1:8400\`
|
|
22
|
+
|
|
23
|
+
| Method | Endpoint | Purpose |
|
|
24
|
+
|--------|----------|---------|
|
|
25
|
+
| GET | /memory/restore/:agentId | Restore context from prior sessions |
|
|
26
|
+
| POST | /memory/activate | Cognitive recall (use \`context\` field) |
|
|
27
|
+
| POST | /memory/write | Write a memory |
|
|
28
|
+
| POST | /memory/feedback | Report if memory was useful |
|
|
29
|
+
| POST | /memory/retract | Invalidate a wrong memory |
|
|
30
|
+
| POST | /memory/checkpoint | Save execution state |
|
|
31
|
+
| POST | /task/create | Create a task |
|
|
32
|
+
| POST | /task/update | Update task status |
|
|
33
|
+
| GET | /task/list/:agentId | List tasks |
|
|
34
|
+
| GET | /task/next/:agentId | Get next actionable task |
|
|
35
|
+
| GET | /health | Health check |
|
|
36
|
+
|
|
37
|
+
Start the server with: \`awm serve\`
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const adapter: CLIAdapter = {
|
|
41
|
+
id: 'http',
|
|
42
|
+
name: 'HTTP (generic)',
|
|
43
|
+
supportsProjectScope: true,
|
|
44
|
+
supportsGlobalScope: false,
|
|
45
|
+
|
|
46
|
+
writeMcpConfig(ctx: SetupContext): string {
|
|
47
|
+
const port = process.env.AWM_PORT ?? '8400';
|
|
48
|
+
return `MCP config: N/A (HTTP mode)\n Start server: awm serve --port ${port}\n Base URL: http://127.0.0.1:${port}`;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
writeInstructions(ctx: SetupContext, skip: boolean): string {
|
|
52
|
+
const instrPath = join(ctx.cwd, 'AWM-INSTRUCTIONS.md');
|
|
53
|
+
|
|
54
|
+
if (skip) return 'AWM-INSTRUCTIONS.md: skipped (--no-instructions)';
|
|
55
|
+
|
|
56
|
+
return upsertAwmSection(instrPath, AWM_INSTRUCTION_CONTENT, {
|
|
57
|
+
titleIfNew: '# Agent Working Memory',
|
|
58
|
+
suffix: HTTP_ADDENDUM,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
writeHooks(_ctx: SetupContext, _skip: boolean): string {
|
|
63
|
+
return 'Hooks: N/A (HTTP mode)';
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
diagnose(ctx: SetupContext): DiagnosticResult[] {
|
|
67
|
+
const results: DiagnosticResult[] = [];
|
|
68
|
+
|
|
69
|
+
// Check database
|
|
70
|
+
if (existsSync(ctx.dbPath)) {
|
|
71
|
+
results.push({ check: 'Database', status: 'ok', message: ctx.dbPath });
|
|
72
|
+
} else {
|
|
73
|
+
results.push({ check: 'Database', status: 'warn', message: `${ctx.dbPath} not found` });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check if HTTP server is reachable
|
|
77
|
+
// (can't do async in diagnose, so just check if the entrypoint exists)
|
|
78
|
+
if (ctx.hasDist) {
|
|
79
|
+
results.push({ check: 'Server entrypoint', status: 'ok', message: 'dist/index.js exists' });
|
|
80
|
+
} else {
|
|
81
|
+
results.push({
|
|
82
|
+
check: 'Server entrypoint',
|
|
83
|
+
status: 'warn',
|
|
84
|
+
message: 'dist/index.js not found — use: npx tsx src/index.ts',
|
|
85
|
+
fix: 'Run: npm run build',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return results;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default adapter;
|
package/src/adapters/index.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Adapter registry — lazy-loads adapters by ID.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { CLIAdapter } from './types.js';
|
|
9
|
-
|
|
10
|
-
const adapters = new Map<string, () => Promise<CLIAdapter>>();
|
|
11
|
-
|
|
12
|
-
adapters.set('claude-code', () => import('./claude-code.js').then(m => m.default));
|
|
13
|
-
adapters.set('codex', () => import('./codex.js').then(m => m.default));
|
|
14
|
-
adapters.set('cursor', () => import('./cursor.js').then(m => m.default));
|
|
15
|
-
adapters.set('http', () => import('./http.js').then(m => m.default));
|
|
16
|
-
|
|
17
|
-
// Aliases
|
|
18
|
-
adapters.set('claude', () => import('./claude-code.js').then(m => m.default));
|
|
19
|
-
|
|
20
|
-
export function listAdapters(): string[] {
|
|
21
|
-
return ['claude-code', 'codex', 'cursor', 'http'];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function getAdapter(id: string): Promise<CLIAdapter> {
|
|
25
|
-
const factory = adapters.get(id);
|
|
26
|
-
if (!factory) {
|
|
27
|
-
const valid = listAdapters().join(', ');
|
|
28
|
-
throw new Error(`Unknown target: "${id}". Valid targets: ${valid}`);
|
|
29
|
-
}
|
|
30
|
-
return factory();
|
|
31
|
-
}
|
|
1
|
+
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adapter registry — lazy-loads adapters by ID.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { CLIAdapter } from './types.js';
|
|
9
|
+
|
|
10
|
+
const adapters = new Map<string, () => Promise<CLIAdapter>>();
|
|
11
|
+
|
|
12
|
+
adapters.set('claude-code', () => import('./claude-code.js').then(m => m.default));
|
|
13
|
+
adapters.set('codex', () => import('./codex.js').then(m => m.default));
|
|
14
|
+
adapters.set('cursor', () => import('./cursor.js').then(m => m.default));
|
|
15
|
+
adapters.set('http', () => import('./http.js').then(m => m.default));
|
|
16
|
+
|
|
17
|
+
// Aliases
|
|
18
|
+
adapters.set('claude', () => import('./claude-code.js').then(m => m.default));
|
|
19
|
+
|
|
20
|
+
export function listAdapters(): string[] {
|
|
21
|
+
return ['claude-code', 'codex', 'cursor', 'http'];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function getAdapter(id: string): Promise<CLIAdapter> {
|
|
25
|
+
const factory = adapters.get(id);
|
|
26
|
+
if (!factory) {
|
|
27
|
+
const valid = listAdapters().join(', ');
|
|
28
|
+
throw new Error(`Unknown target: "${id}". Valid targets: ${valid}`);
|
|
29
|
+
}
|
|
30
|
+
return factory();
|
|
31
|
+
}
|