@theronap/cortex-mcp 0.9.4 → 0.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.
@@ -17,7 +17,7 @@
17
17
  * Get your token from the Cortex console → Connect your AI.
18
18
  */
19
19
 
20
- const VERSION = '0.9.4'
20
+ const VERSION = '0.9.5'
21
21
  const cmd = process.argv[2]
22
22
  const rest = process.argv.slice(3)
23
23
 
@@ -35,6 +35,7 @@ if (cmd === '--help' || cmd === '-h' || cmd === 'help') {
35
35
  `sessions flow into the org automatically. Restart Claude Code after.\n\n` +
36
36
  `Subcommands:\n` +
37
37
  ` setup <token> wire MCP server + capture hook into ~/.claude config\n` +
38
+ ` repair re-run setup at the latest version using your existing token (no token needed)\n` +
38
39
  ` doctor live health check — confirm your token works (no restart needed)\n` +
39
40
  ` status one-line connected/not-connected check (used by the SessionStart hook)\n` +
40
41
  ` skills install/repair the managed Cortex skills (also wired by setup)\n` +
@@ -58,6 +59,13 @@ if (cmd === 'setup') {
58
59
  await runSetup(rest, VERSION)
59
60
  const { closeFetch } = await import('../lib/diagnose.mjs')
60
61
  await closeFetch()
62
+ } else if (cmd === 'repair' || cmd === 'update') {
63
+ // Re-run setup at THIS version using the already-wired token (no token arg needed). Fixes a
64
+ // machine set up with an older version: re-pins MCP + hooks, reinstalls skills to the flat path.
65
+ const { runRepair } = await import('../lib/setup.mjs')
66
+ await runRepair(VERSION)
67
+ const { closeFetch } = await import('../lib/diagnose.mjs')
68
+ await closeFetch()
61
69
  } else if (cmd === 'doctor') {
62
70
  const { runDoctor } = await import('../lib/doctor.mjs')
63
71
  process.exitCode = await runDoctor()
package/lib/setup.mjs CHANGED
@@ -215,3 +215,35 @@ export async function runSetup(argv, version) {
215
215
  log(` Console: ${base}`)
216
216
  log('')
217
217
  }
218
+
219
+ // Find the token already wired on this machine, so `repair` can re-run setup without re-pasting it.
220
+ // Checks Claude's config first, then Codex's config.toml.
221
+ export function readWiredToken() {
222
+ try {
223
+ const cfg = readJson(join(homedir(), '.claude.json'))
224
+ const t = cfg?.mcpServers?.cortex?.env?.CORTEX_TOKEN
225
+ if (t) return t
226
+ } catch { /* fall through */ }
227
+ try {
228
+ const toml = readFileSync(join(homedir(), '.codex', 'config.toml'), 'utf8')
229
+ const m = toml.match(/\[mcp_servers\.cortex\.env\][\s\S]*?CORTEX_TOKEN\s*=\s*"([^"]+)"/)
230
+ if (m) return m[1]
231
+ } catch { /* fall through */ }
232
+ return null
233
+ }
234
+
235
+ // `repair`: re-run the FULL setup at THIS version using the already-wired token. The one-command fix
236
+ // for a machine set up with an older version (e.g. when skills were installed to the old nested path,
237
+ // or the hooks are pinned to a stale version). No token argument needed.
238
+ export async function runRepair(version) {
239
+ const token = readWiredToken()
240
+ if (!token) {
241
+ process.stderr.write(
242
+ 'No existing Cortex token found in ~/.claude.json or ~/.codex/config.toml.\n' +
243
+ 'Run setup once with your token: npx -y @theronap/cortex-mcp setup <YOUR_TOKEN>\n',
244
+ )
245
+ process.exit(1)
246
+ }
247
+ process.stdout.write('Cortex repair — re-running setup with your existing token at this version…\n')
248
+ await runSetup([token], version)
249
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {