@cohesivity/init 0.8.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +20 -6
  2. package/bin/cli.js +76 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -40,17 +40,31 @@ adapter.
40
40
 
41
41
  Known adapters without a Cohesivity plugin package receive the canonical
42
42
  standalone skill plus the remote MCP endpoint
43
- `https://cohesivity.ai/mcp/manage`, configured through the adapter's documented
43
+ `https://cohesivity.ai/mcp`, configured through the adapter's documented
44
44
  native command. The installer currently supports this fallback for GitHub
45
45
  Copilot CLI, VS Code, Cline CLI, and Grok. It does not modify JSON, TOML, or YAML
46
46
  configuration with regular expressions.
47
47
 
48
48
  The installer never starts OAuth or opens a browser. It prints the relevant
49
- restart and authentication steps after delivery. Three MCP surfaces have
50
- different boundaries: the public documentation server at
51
- `https://cohesivity.ai/mcp` needs no login, the installed local project-bootstrap
52
- server needs no login, and `https://cohesivity.ai/mcp/manage` requires OAuth for
53
- account-scoped management. OpenCode users start that last flow explicitly with
49
+ restart and authentication steps after delivery. Two MCP surfaces have
50
+ different boundaries, and neither needs a login: the installed local
51
+ project-bootstrap server, and the hosted server at `https://cohesivity.ai/mcp`,
52
+ which serves documentation and management publicly and accepts optional account
53
+ OAuth. The former `https://cohesivity.ai/mcp/manage` endpoint is retired and
54
+ returns HTTP 410. Rerunning this installer moves configured clients to the new
55
+ URL: plugin packages and the Hermes import are reinstalled, OpenCode and Cline
56
+ overwrite their `cohesivity` entry on `mcp add`. GitHub Copilot CLI refuses a
57
+ duplicate, so after `mcp add` reports that the entry already exists, the
58
+ installer reads it with `copilot mcp list --json`. An enabled entry already on
59
+ the new URL is left alone; a disabled one stays disabled, and setup reports
60
+ `copilot mcp enable cohesivity` instead of calling it installed. A plain remote entry on another URL is removed and added
61
+ again, and if that add fails the previous entry is added back. An entry with
62
+ headers, env, a tool filter, a timeout, or a disabled state is left unchanged,
63
+ and setup reports `copilot mcp remove cohesivity` as the manual step. Grok gets
64
+ the same manual step instead of a removal, because its CLI's entry format was
65
+ not verified. VS Code's `--add-mcp` behavior on an existing entry was not
66
+ verified. `--dry-run` prints the conditional Copilot replacement. Clients that signed in before the move sign in again. OpenCode users
67
+ start optional account sign-in explicitly with
54
68
  `opencode mcp auth cohesivity`. Hermes uses the exact native server name
55
69
  `cohesivity`; `hermes mcp login cohesivity` starts its management OAuth flow.
56
70
  The Cohesivity endpoint advertises Dynamic Client Registration, so Hermes does
package/bin/cli.js CHANGED
@@ -44,7 +44,7 @@ import { gunzipSync } from 'node:zlib';
44
44
  const argv = process.argv.slice(2);
45
45
  const has = (f) => argv.includes(f);
46
46
  const flag = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
47
- const PKG_VERSION = '0.8.5';
47
+ const PKG_VERSION = '0.9.0';
48
48
 
49
49
  function validateArgs() {
50
50
  const switches = new Set(['--dry-run', '--no-plugin', '--no-branding', '--tenant-only', '--help', '-h']);
@@ -63,7 +63,7 @@ if (has('--help') || has('-h')) { help(); process.exit(0); }
63
63
 
64
64
  // ── config ──────────────────────────────────────────────────────────────────
65
65
  const BASE = (flag('--base') || process.env.COHESIVITY_BASE || 'https://cohesivity.ai').replace(/\/+$/, '');
66
- const MCP_URL = 'https://cohesivity.ai/mcp/manage';
66
+ const MCP_URL = 'https://cohesivity.ai/mcp';
67
67
 
68
68
  // Machine id: one per machine, stored outside any project. A project's
69
69
  // .cohesivity is per project, so a machine that runs setup in several projects
@@ -78,16 +78,16 @@ const MACHINE_ID_FILE = join(MACHINE_ID_DIR, 'machine-id');
78
78
 
79
79
  // The skill is pinned to an immutable commit in the public, auditable repo.
80
80
  // Bumping the pin is a deliberate release step. See COH-172.
81
- const SKILL_PIN = 'ce021d9d5cf6dadd4dce30d71c2d880b9c0f4c48';
81
+ const SKILL_PIN = 'dd8df44d38749ea08903844368f73609cd00f69b';
82
82
  const SKILL_URL = `https://raw.githubusercontent.com/cohesivity-org/cohesivity-skill/${SKILL_PIN}/cohesivity.skill.md`;
83
83
 
84
84
  // Plugin release pins live in this one block. Bump all three values together
85
85
  // after publishing a new two-commit artifact manifest from cohesivity-plugin.
86
86
  // Tests inject a complete pin with COHESIVITY_PLUGIN_MANIFEST_PIN.
87
87
  const PLUGIN_RELEASE = Object.freeze({
88
- manifestUrl: 'https://raw.githubusercontent.com/cohesivity-org/cohesivity-plugin/00ecd49b924ca3bd4e06fc768d0d0cbc151178e2/artifacts/v4.1.3/install-manifest.v1.json',
88
+ manifestUrl: 'https://raw.githubusercontent.com/cohesivity-org/cohesivity-plugin/50cb3fa2b80dcb35d13046ce927acd4ebb816f23/artifacts/v5.0.0/install-manifest.v1.json',
89
89
  manifestBytes: 9400,
90
- manifestSha256: '32ec98692955b8a6f12be17031c758bf51726bb7952fcf7d1f1737e7ac5a474e',
90
+ manifestSha256: '97afafe1fdd02f1a301bc09e68ce2284b7c1cc3b0d5b1c4062e1234194d537e6',
91
91
  });
92
92
 
93
93
  const ARTIFACT_KEYS = Object.freeze({
@@ -238,15 +238,37 @@ function detectClients() {
238
238
  ].filter((client) => client.detected);
239
239
  }
240
240
 
241
+ // GitHub Copilot CLI refuses `mcp add` over an existing `cohesivity` entry, so a
242
+ // rerun could not move an entry from the retired /mcp/manage URL to MCP_URL.
243
+ // `replace` reads the saved entry first and removes it only when it is a plain
244
+ // remote entry that `restoreArgs` can add back exactly, so a failed re-add never
245
+ // leaves the client without its previous entry. Adapters without `replace`
246
+ // never remove anything; they report the manual step instead.
247
+ const MCP_REMOVE = ['mcp', 'remove', 'cohesivity'];
248
+ const COPILOT_PLAIN_ENTRY_KEYS = new Set(['type', 'url', 'tools', 'source', 'enabled']);
249
+ const COPILOT_REPLACE = {
250
+ listArgs: ['mcp', 'list', '--json'],
251
+ enableArgs: ['mcp', 'enable', 'cohesivity'],
252
+ entry: (listed) => listed?.mcpServers?.cohesivity || null,
253
+ restoreArgs(entry) {
254
+ const plain = Object.keys(entry).every((key) => COPILOT_PLAIN_ENTRY_KEYS.has(key))
255
+ && (entry.type === 'http' || entry.type === 'sse')
256
+ && typeof entry.url === 'string' && /^https?:\/\//.test(entry.url)
257
+ && (entry.tools === undefined || (Array.isArray(entry.tools) && entry.tools.length === 1 && entry.tools[0] === '*'))
258
+ && (entry.source === undefined || entry.source === 'user')
259
+ && (entry.enabled === undefined || entry.enabled === true);
260
+ return plain ? ['mcp', 'add', '--transport', entry.type, 'cohesivity', entry.url] : null;
261
+ },
262
+ };
241
263
  const FALLBACK_ADAPTERS = [
242
- { id: 'copilot', name: 'GitHub Copilot CLI', bins: ['copilot'], args: [
264
+ { id: 'copilot', name: 'GitHub Copilot CLI', bins: ['copilot'], replace: COPILOT_REPLACE, args: [
243
265
  'mcp', 'add', '--transport', 'http', 'cohesivity', MCP_URL,
244
266
  ] },
245
267
  { id: 'vscode', name: 'VS Code', bins: ['code'], args: [
246
268
  '--add-mcp', JSON.stringify({ name: 'cohesivity', type: 'http', url: MCP_URL }),
247
269
  ] },
248
270
  { id: 'cline', name: 'Cline CLI', bins: ['cline'], args: [
249
- 'mcp', 'add', 'cohesivity', MCP_URL, '--type', 'http',
271
+ 'mcp', 'add', 'cohesivity', MCP_URL, '--transport', 'http', '--yes',
250
272
  ] },
251
273
  { id: 'grok', name: 'Grok', bins: ['grok'], args: [
252
274
  'mcp', 'add', '--transport', 'http', 'cohesivity', MCP_URL,
@@ -327,14 +349,19 @@ async function installClientIntegrations() {
327
349
  if (skillError) failures.push({ client: 'standalone skill', message: skillError.message });
328
350
  for (const adapter of adapters) {
329
351
  if (DRY) {
330
- act(`run ${formatCommand(adapter.bin || adapter.bins[0], adapter.args)}`);
352
+ const bin = adapter.bin || adapter.bins[0];
353
+ act(`run ${formatCommand(bin, adapter.args)}`);
354
+ if (adapter.replace) {
355
+ act(`replace an existing cohesivity entry that points elsewhere: ${formatCommand(bin, adapter.replace.listArgs)}, ` +
356
+ `${formatCommand(bin, MCP_REMOVE)}, then the same add; the previous entry is added back if that add fails`);
357
+ }
331
358
  continue;
332
359
  }
333
360
  if (!adapter.bin) {
334
361
  failures.push({ client: adapter.name, message: 'client state exists but its native CLI is not on PATH' });
335
362
  continue;
336
363
  }
337
- try { runNative(adapter.bin, adapter.args); }
364
+ try { runFallbackAdapter(adapter); }
338
365
  catch (error) { failures.push({ client: adapter.name, message: error.message }); }
339
366
  }
340
367
  }
@@ -343,6 +370,46 @@ async function installClientIntegrations() {
343
370
  return failures;
344
371
  }
345
372
 
373
+ function runFallbackAdapter(adapter) {
374
+ try {
375
+ runNative(adapter.bin, adapter.args);
376
+ return;
377
+ } catch (error) {
378
+ if (!/already exists/i.test(error.message)) throw error;
379
+ if (!adapter.replace) throw manualReplacement(adapter, error.message);
380
+ }
381
+ const entry = adapter.replace.entry(runNativeJson(adapter.bin, adapter.replace.listArgs));
382
+ if (entry?.url === MCP_URL) {
383
+ if (entry.enabled === false) {
384
+ throw new Error(`the existing cohesivity entry already points to ${MCP_URL} but is disabled in ${adapter.name}; ` +
385
+ `setup left it disabled, and \`${formatCommand(adapter.bin, adapter.replace.enableArgs)}\` turns it on`);
386
+ }
387
+ log(`${adapter.name} already points to ${MCP_URL}`);
388
+ return;
389
+ }
390
+ if (!entry) throw manualReplacement(adapter, `${formatCommand(adapter.bin, adapter.replace.listArgs)} did not list the existing cohesivity entry`);
391
+ const restore = adapter.replace.restoreArgs(entry);
392
+ if (!restore) {
393
+ throw manualReplacement(adapter, 'the existing cohesivity entry has settings setup could not add back ' +
394
+ '(headers, env, a tool filter, a timeout, or a disabled state)');
395
+ }
396
+ runNative(adapter.bin, MCP_REMOVE);
397
+ try {
398
+ runNative(adapter.bin, adapter.args);
399
+ } catch (error) {
400
+ try { runNative(adapter.bin, restore); }
401
+ catch (restoreError) {
402
+ throw new Error(`${error.message}; adding back the previous entry (${entry.url}) also failed: ${restoreError.message}`);
403
+ }
404
+ throw new Error(`${error.message}; the previous entry (${entry.url}) was restored`);
405
+ }
406
+ }
407
+
408
+ function manualReplacement(adapter, reason) {
409
+ return new Error(`${reason}. Setup left that entry unchanged; running ` +
410
+ `\`${formatCommand(adapter.bin, MCP_REMOVE)}\` and then setup again moves it to ${MCP_URL}`);
411
+ }
412
+
346
413
  function manifestPin() {
347
414
  if (!process.env.COHESIVITY_PLUGIN_MANIFEST_PIN) return { ...PLUGIN_RELEASE, injected: false };
348
415
  let pin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cohesivity/init",
3
- "version": "0.8.5",
3
+ "version": "0.9.0",
4
4
  "description": "Set up Cohesivity in a project: install the agent skill, create a managed backend tenant, write the project config. Run with `npx @cohesivity/init`.",
5
5
  "type": "module",
6
6
  "bin": {