@aaryanbindage/omnicontext 0.0.0-stage → 0.1.2
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/LICENSE +21 -0
- package/README.md +159 -2
- package/dist/omnicontext.mjs +149 -0
- package/package.json +58 -4
- package/src/cli.js +200 -0
- package/src/context.js +85 -0
- package/src/index.js +5 -0
- package/src/install.js +67 -0
- package/src/mcp.js +323 -0
- package/src/resolve.js +55 -0
- package/src/store.js +303 -0
- package/src/sync.js +127 -0
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aaryanbindage/omnicontext",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Persistent, cross-device memory for Claude: your profile, your projects, and resumable handoffs — shared by every Claude session (Claude Code plugin + MCP server + desktop app).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"omnicontext": "dist/omnicontext.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "src/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/omnicontext.mjs",
|
|
15
|
+
"src",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "node scripts/build.mjs",
|
|
21
|
+
"test": "node --test",
|
|
22
|
+
"mcpb": "node scripts/pack-mcpb.mjs"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"mcpName": "io.github.aaryanbindage/omnicontext",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"claude",
|
|
30
|
+
"claude-code",
|
|
31
|
+
"claude-code-plugin",
|
|
32
|
+
"claude-desktop",
|
|
33
|
+
"mcp",
|
|
34
|
+
"mcp-server",
|
|
35
|
+
"model-context-protocol",
|
|
36
|
+
"memory",
|
|
37
|
+
"persistent-memory",
|
|
38
|
+
"context",
|
|
39
|
+
"ai-memory",
|
|
40
|
+
"cross-device",
|
|
41
|
+
"sync",
|
|
42
|
+
"handoff",
|
|
43
|
+
"llm"
|
|
44
|
+
],
|
|
45
|
+
"author": "aaryanbindage (https://github.com/aaryanbindage)",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"homepage": "https://aaryanbindage.github.io/omnicontext/",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/aaryanbindage/omnicontext.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/aaryanbindage/omnicontext/issues"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
57
|
+
"zod": "^4.6.7",
|
|
58
|
+
"esbuild": "^0.28.2"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// omnicontext CLI: MCP server, Claude Code hooks, and management commands.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { Store, VERSION } from './store.js';
|
|
6
|
+
import { buildContext, projectLine, handoffLine } from './context.js';
|
|
7
|
+
import { resolveProjects } from './resolve.js';
|
|
8
|
+
import { sync, pull, initSync, createGithubRemote, syncStatus } from './sync.js';
|
|
9
|
+
import { installClaudeDesktop, installClaudeCode } from './install.js';
|
|
10
|
+
|
|
11
|
+
const HELP = `omnicontext ${VERSION} — persistent, cross-device memory for Claude
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
omnicontext mcp Run the MCP server (stdio)
|
|
15
|
+
omnicontext context [--cwd DIR] Print the briefing Claude sees
|
|
16
|
+
omnicontext status Data folder, device, sync state
|
|
17
|
+
|
|
18
|
+
omnicontext remember "<fact>" Add a fact to your profile
|
|
19
|
+
omnicontext profile [--edit FILE] Print profile, or replace it from FILE
|
|
20
|
+
omnicontext projects List projects
|
|
21
|
+
omnicontext project add <name> [--alias A]... [--tag T]... [--desc D] [--path DIR] [--repo URL]
|
|
22
|
+
omnicontext project note <project> "<note>"
|
|
23
|
+
omnicontext resolve "<reference>" e.g. omnicontext resolve "my game project"
|
|
24
|
+
omnicontext handoffs [--all] List handoffs
|
|
25
|
+
|
|
26
|
+
omnicontext sync Sync now
|
|
27
|
+
omnicontext sync --github [NAME] Create a private GitHub repo (via gh) and sync to it
|
|
28
|
+
omnicontext sync --remote <git-url> Sync to any git remote you own
|
|
29
|
+
omnicontext device <name> Name this device
|
|
30
|
+
|
|
31
|
+
omnicontext install claude-desktop Add the MCP server to Claude Desktop
|
|
32
|
+
omnicontext install claude-code Install the Claude Code plugin
|
|
33
|
+
|
|
34
|
+
omnicontext hook session-start|session-end (used by the Claude Code plugin)
|
|
35
|
+
|
|
36
|
+
Data lives in ~/.omnicontext (override with OMNICONTEXT_HOME).`;
|
|
37
|
+
|
|
38
|
+
function parseFlags(argv) {
|
|
39
|
+
const pos = [];
|
|
40
|
+
const flags = {};
|
|
41
|
+
for (let i = 0; i < argv.length; i++) {
|
|
42
|
+
const a = argv[i];
|
|
43
|
+
if (a.startsWith('--')) {
|
|
44
|
+
const key = a.slice(2);
|
|
45
|
+
const val = argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[++i] : true;
|
|
46
|
+
if (flags[key] === undefined) flags[key] = val;
|
|
47
|
+
else flags[key] = [].concat(flags[key], val);
|
|
48
|
+
} else pos.push(a);
|
|
49
|
+
}
|
|
50
|
+
return { pos, flags };
|
|
51
|
+
}
|
|
52
|
+
const list = (v) => (v === undefined || v === true ? undefined : [].concat(v));
|
|
53
|
+
|
|
54
|
+
async function readStdinJson() {
|
|
55
|
+
if (process.stdin.isTTY) return {};
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
let data = '';
|
|
58
|
+
const done = () => {
|
|
59
|
+
try {
|
|
60
|
+
resolve(data.trim() ? JSON.parse(data) : {});
|
|
61
|
+
} catch {
|
|
62
|
+
resolve({});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
process.stdin.setEncoding('utf8');
|
|
66
|
+
process.stdin.on('data', (c) => (data += c));
|
|
67
|
+
process.stdin.on('end', done);
|
|
68
|
+
setTimeout(done, 1500);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
73
|
+
const [cmd, ...rest] = argv;
|
|
74
|
+
const { pos, flags } = parseFlags(rest);
|
|
75
|
+
|
|
76
|
+
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') return console.log(HELP);
|
|
77
|
+
if (cmd === '--version' || cmd === '-v') return console.log(VERSION);
|
|
78
|
+
|
|
79
|
+
if (cmd === 'mcp') {
|
|
80
|
+
const { startMcpServer } = await import('./mcp.js');
|
|
81
|
+
return startMcpServer();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const store = new Store();
|
|
85
|
+
|
|
86
|
+
switch (cmd) {
|
|
87
|
+
case 'hook': {
|
|
88
|
+
const input = await readStdinJson();
|
|
89
|
+
const cwd = input.cwd || process.cwd();
|
|
90
|
+
if (pos[0] === 'session-start') {
|
|
91
|
+
if (store.getLocal().autoSync !== false) {
|
|
92
|
+
try {
|
|
93
|
+
pull(store.home, { timeout: 6000 });
|
|
94
|
+
} catch {}
|
|
95
|
+
}
|
|
96
|
+
process.stdout.write(
|
|
97
|
+
JSON.stringify({
|
|
98
|
+
hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: buildContext(store, { cwd }) },
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
const p = store.projectForCwd(cwd);
|
|
102
|
+
if (p) store.touchProject(p.slug);
|
|
103
|
+
} else if (pos[0] === 'session-end') {
|
|
104
|
+
// Hand off to a detached process so Claude can exit without waiting on the network.
|
|
105
|
+
if (store.getLocal().autoSync !== false && syncStatus(store.home).configured) {
|
|
106
|
+
spawn(process.execPath, [process.argv[1], 'sync'], { detached: true, stdio: 'ignore', windowsHide: true }).unref();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case 'context':
|
|
113
|
+
return console.log(buildContext(store, { cwd: flags.cwd || process.cwd() }));
|
|
114
|
+
|
|
115
|
+
case 'status': {
|
|
116
|
+
const st = syncStatus(store.home);
|
|
117
|
+
console.log(`Data: ${store.home}\nDevice: ${store.device}`);
|
|
118
|
+
console.log(`Projects: ${store.listProjects().length} Open handoffs: ${store.listHandoffs({ status: 'open' }).length}`);
|
|
119
|
+
console.log(`Sync: ${st.configured ? `${st.remote}${st.dirty ? ' (unsynced changes)' : ''}` : 'not configured (omnicontext sync --github)'}`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case 'remember':
|
|
124
|
+
if (!pos.length) throw new Error('Usage: omnicontext remember "<fact>"');
|
|
125
|
+
console.log('Saved:', store.remember(pos.join(' ')));
|
|
126
|
+
return;
|
|
127
|
+
|
|
128
|
+
case 'profile':
|
|
129
|
+
if (typeof flags.edit === 'string') store.setProfile(fs.readFileSync(flags.edit, 'utf8'));
|
|
130
|
+
return console.log(store.getProfile());
|
|
131
|
+
|
|
132
|
+
case 'projects':
|
|
133
|
+
for (const p of store.listProjects()) console.log(projectLine(p, store.device));
|
|
134
|
+
return;
|
|
135
|
+
|
|
136
|
+
case 'project': {
|
|
137
|
+
const [sub, name, ...more] = pos;
|
|
138
|
+
if (sub === 'add') {
|
|
139
|
+
const p = store.upsertProject({
|
|
140
|
+
name,
|
|
141
|
+
aliases: list(flags.alias),
|
|
142
|
+
tags: list(flags.tag),
|
|
143
|
+
description: typeof flags.desc === 'string' ? flags.desc : undefined,
|
|
144
|
+
repo: typeof flags.repo === 'string' ? flags.repo : undefined,
|
|
145
|
+
path: flags.path === true ? process.cwd() : flags.path,
|
|
146
|
+
});
|
|
147
|
+
return console.log(`Saved ${p.name} (${p.slug})`);
|
|
148
|
+
}
|
|
149
|
+
if (sub === 'note') {
|
|
150
|
+
store.addProjectNote(name, more.join(' '));
|
|
151
|
+
return console.log('Note added.');
|
|
152
|
+
}
|
|
153
|
+
if (sub === 'rm') {
|
|
154
|
+
store.deleteProject(name);
|
|
155
|
+
return console.log('Removed.');
|
|
156
|
+
}
|
|
157
|
+
throw new Error('Usage: omnicontext project add|note|rm ...');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
case 'resolve': {
|
|
161
|
+
const hits = resolveProjects(store.listProjects(), pos.join(' '));
|
|
162
|
+
if (!hits.length) return console.log('No match.');
|
|
163
|
+
for (const h of hits) console.log(`${String(h.score).padStart(4)} ${projectLine(h.project, store.device)}`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
case 'handoffs':
|
|
168
|
+
for (const h of store.listHandoffs({ status: flags.all ? 'all' : 'open' })) console.log(handoffLine(h), `[${h.status}]`);
|
|
169
|
+
return;
|
|
170
|
+
|
|
171
|
+
case 'device':
|
|
172
|
+
if (!pos[0]) return console.log(store.device);
|
|
173
|
+
store.setLocal({ deviceName: pos.join(' ') });
|
|
174
|
+
return console.log(`This device is now "${store.device}".`);
|
|
175
|
+
|
|
176
|
+
case 'sync': {
|
|
177
|
+
let res;
|
|
178
|
+
if (flags.github) res = createGithubRemote(store.home, typeof flags.github === 'string' ? flags.github : undefined, store.device);
|
|
179
|
+
else if (typeof flags.remote === 'string') res = initSync(store.home, flags.remote, store.device);
|
|
180
|
+
else res = sync(store.home, store.device);
|
|
181
|
+
console.log(res.ok ? `Synced (${[res.committed && 'committed', res.pulled && 'pulled', res.pushed && 'pushed'].filter(Boolean).join(', ') || 'up to date'})` : `Not synced: ${res.reason}`);
|
|
182
|
+
if (!res.ok) process.exitCode = 1;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
case 'install': {
|
|
187
|
+
if (pos[0] === 'claude-desktop') {
|
|
188
|
+
const file = installClaudeDesktop();
|
|
189
|
+
return console.log(`Added "omnicontext" to ${file}. Restart Claude Desktop.`);
|
|
190
|
+
}
|
|
191
|
+
if (pos[0] === 'claude-code') return console.log(installClaudeCode());
|
|
192
|
+
throw new Error('Usage: omnicontext install claude-desktop|claude-code');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
default:
|
|
196
|
+
console.error(`Unknown command "${cmd}".\n`);
|
|
197
|
+
console.log(HELP);
|
|
198
|
+
process.exitCode = 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
package/src/context.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Builds the markdown briefing injected at the start of every Claude session.
|
|
2
|
+
|
|
3
|
+
const clip = (s, n) => (s.length > n ? s.slice(0, n) + `\n…(truncated; ${s.length - n} more chars — call get_profile)` : s);
|
|
4
|
+
const ago = (iso) => {
|
|
5
|
+
if (!iso) return '';
|
|
6
|
+
const d = (Date.now() - new Date(iso).getTime()) / 86400000;
|
|
7
|
+
return d < 1 ? 'today' : d < 2 ? 'yesterday' : `${Math.floor(d)}d ago`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function projectLine(p, device, current) {
|
|
11
|
+
const bits = [`**${p.name}** (\`${p.slug}\`)`];
|
|
12
|
+
if (p.aliases?.length) bits.push(`aka ${p.aliases.map((a) => `"${a}"`).join(', ')}`);
|
|
13
|
+
if (p.tags?.length) bits.push(`[${p.tags.join(', ')}]`);
|
|
14
|
+
if (p.status && p.status !== 'active') bits.push(`(${p.status})`);
|
|
15
|
+
let line = `- ${bits.join(' ')}`;
|
|
16
|
+
if (p.description) line += ` — ${p.description.split('\n')[0].slice(0, 160)}`;
|
|
17
|
+
const here = p.paths?.[device];
|
|
18
|
+
const elsewhere = Object.keys(p.paths || {}).filter((d) => d !== device);
|
|
19
|
+
if (here) line += ` · here: \`${here}\``;
|
|
20
|
+
else if (elsewhere.length) line += ` · on: ${elsewhere.join(', ')}`;
|
|
21
|
+
const last = p.notes?.[p.notes.length - 1];
|
|
22
|
+
if (last) line += ` · latest note: ${last.text.slice(0, 140)}`;
|
|
23
|
+
if (current) line += ' ← **current directory**';
|
|
24
|
+
return line;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function handoffLine(h) {
|
|
28
|
+
const next = h.nextSteps?.length ? ` Next: ${h.nextSteps.slice(0, 2).join('; ')}` : '';
|
|
29
|
+
return `- \`${h.id}\` **${h.title}**${h.project ? ` (${h.project})` : ''} — from ${h.device}, ${ago(h.createdAt)}.${next}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function buildContext(store, { cwd } = {}) {
|
|
33
|
+
const device = store.device;
|
|
34
|
+
const projects = store.listProjects();
|
|
35
|
+
const current = store.projectForCwd(cwd);
|
|
36
|
+
const open = store.listHandoffs({ status: 'open', limit: 5 });
|
|
37
|
+
const profile = store.getProfile().replace(/<!--[\s\S]*?-->/g, '').replace(/\n{3,}/g, '\n\n').trim();
|
|
38
|
+
|
|
39
|
+
const out = [];
|
|
40
|
+
out.push(`# OmniContext — what you know about this user (synced across their devices)`);
|
|
41
|
+
out.push(`Device: ${device}. This is the user's own long-term memory, available in every Claude session.`);
|
|
42
|
+
|
|
43
|
+
out.push(`\n## About the user\n${clip(profile, 4000) || '_(empty — learn about the user and call `remember`)_'}`);
|
|
44
|
+
|
|
45
|
+
out.push(`\n## Their projects (${projects.length})`);
|
|
46
|
+
if (projects.length) {
|
|
47
|
+
out.push(
|
|
48
|
+
'When the user mentions a project loosely ("my game project", "the website"), match it to this list. ' +
|
|
49
|
+
'Use `resolve_project` / `get_project` for full details and notes.',
|
|
50
|
+
);
|
|
51
|
+
for (const p of projects.slice(0, 40)) out.push(projectLine(p, device, current && p.slug === current.slug));
|
|
52
|
+
if (projects.length > 40) out.push(`- …and ${projects.length - 40} more (call \`list_projects\`)`);
|
|
53
|
+
} else {
|
|
54
|
+
out.push('_None yet. When the user works on something ongoing, offer to register it with `upsert_project`._');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (current) {
|
|
58
|
+
out.push(`\n## Current project: ${current.name}`);
|
|
59
|
+
if (current.description) out.push(current.description);
|
|
60
|
+
if (current.repo) out.push(`Repo: ${current.repo}`);
|
|
61
|
+
const notes = (current.notes || []).slice(-8);
|
|
62
|
+
if (notes.length) {
|
|
63
|
+
out.push('Recent notes:');
|
|
64
|
+
for (const n of notes) out.push(`- ${n.text} _(${n.device}, ${ago(n.at)})_`);
|
|
65
|
+
}
|
|
66
|
+
} else if (cwd && projects.length) {
|
|
67
|
+
out.push(`\nThe current directory (\`${cwd}\`) isn't linked to a project. If it belongs to one above, ` +
|
|
68
|
+
'call `upsert_project` with `path` to link it on this device.');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (open.length) {
|
|
72
|
+
out.push(`\n## Open handoffs (work that can be resumed)`);
|
|
73
|
+
for (const h of open) out.push(handoffLine(h));
|
|
74
|
+
out.push('If the user says "resume", "continue", or "pick up where I left off", call `resume_handoff`.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
out.push(
|
|
78
|
+
`\n## Keeping this memory useful\n` +
|
|
79
|
+
'- Durable fact about the user (preference, role, tool, goal) → `remember`.\n' +
|
|
80
|
+
'- Decision or status on a project → `add_project_note`.\n' +
|
|
81
|
+
'- Before stopping mid-task, or when asked to hand off → `save_handoff` with a summary and next steps, so any device can resume.\n' +
|
|
82
|
+
"- Don't store secrets, passwords, or API keys.",
|
|
83
|
+
);
|
|
84
|
+
return out.join('\n');
|
|
85
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Store, defaultHome, slugify, VERSION } from './store.js';
|
|
2
|
+
export { resolveProjects, scoreProject } from './resolve.js';
|
|
3
|
+
export { buildContext } from './context.js';
|
|
4
|
+
export { sync, pull, initSync, createGithubRemote, syncStatus } from './sync.js';
|
|
5
|
+
export { installClaudeDesktop, installClaudeCode, claudeDesktopConfigPath } from './install.js';
|
package/src/install.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Wire OmniContext into Claude Desktop and Claude Code.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
export const MARKETPLACE = 'aaryanbindage/omnicontext';
|
|
9
|
+
|
|
10
|
+
export function claudeDesktopConfigPath() {
|
|
11
|
+
const home = os.homedir();
|
|
12
|
+
if (process.platform === 'win32')
|
|
13
|
+
return path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
|
|
14
|
+
if (process.platform === 'darwin')
|
|
15
|
+
return path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
16
|
+
return path.join(process.env.XDG_CONFIG_HOME || path.join(home, '.config'), 'Claude', 'claude_desktop_config.json');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Add (or replace) the "omnicontext" MCP server entry in Claude Desktop's config. */
|
|
20
|
+
export function installClaudeDesktop(server = { command: 'npx', args: ['-y', '@aaryanbindage/omnicontext', 'mcp'] }) {
|
|
21
|
+
const file = claudeDesktopConfigPath();
|
|
22
|
+
let cfg = {};
|
|
23
|
+
if (fs.existsSync(file)) {
|
|
24
|
+
const raw = fs.readFileSync(file, 'utf8');
|
|
25
|
+
try {
|
|
26
|
+
cfg = raw.trim() ? JSON.parse(raw) : {};
|
|
27
|
+
} catch {
|
|
28
|
+
throw new Error(`${file} is not valid JSON; fix it before installing.`);
|
|
29
|
+
}
|
|
30
|
+
fs.copyFileSync(file, file + '.bak');
|
|
31
|
+
}
|
|
32
|
+
cfg.mcpServers = { ...(cfg.mcpServers || {}), omnicontext: server };
|
|
33
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
34
|
+
fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + '\n');
|
|
35
|
+
return file;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function run(cmd, args) {
|
|
39
|
+
return execFileSync(cmd, args, {
|
|
40
|
+
encoding: 'utf8',
|
|
41
|
+
windowsHide: true,
|
|
42
|
+
shell: process.platform === 'win32',
|
|
43
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Install the Claude Code plugin through the `claude` CLI. */
|
|
48
|
+
export function installClaudeCode() {
|
|
49
|
+
try {
|
|
50
|
+
run('claude', ['--version']);
|
|
51
|
+
} catch {
|
|
52
|
+
throw new Error('Claude Code CLI (`claude`) not found on PATH. Install it, then run: ' +
|
|
53
|
+
`claude plugin marketplace add ${MARKETPLACE} && claude plugin install omnicontext@omnicontext`);
|
|
54
|
+
}
|
|
55
|
+
const log = [];
|
|
56
|
+
try {
|
|
57
|
+
log.push(run('claude', ['plugin', 'marketplace', 'add', MARKETPLACE]));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// Already added is fine; anything else is surfaced by the install step.
|
|
60
|
+
log.push(String(e.stderr || e.message));
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
run('claude', ['plugin', 'marketplace', 'update', 'omnicontext']);
|
|
64
|
+
} catch {}
|
|
65
|
+
log.push(run('claude', ['plugin', 'install', 'omnicontext@omnicontext']));
|
|
66
|
+
return log.join('\n').trim();
|
|
67
|
+
}
|