@theronap/cortex-mcp 0.9.47 → 0.9.48
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/lib/editors/claude.mjs +33 -1
- package/lib/server.mjs +2 -2
- package/lib/uninstall.mjs +12 -0
- package/package.json +1 -1
package/lib/editors/claude.mjs
CHANGED
|
@@ -15,11 +15,34 @@ export function mergeClaudeMcp(existing, spec, token) {
|
|
|
15
15
|
return cfg
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** The Cortex tools every seat may run WITHOUT a permission prompt: the read surface, the live
|
|
19
|
+
* authoring core, and trivially-reversible maintenance. The contract this enforces: authoring is
|
|
20
|
+
* EXPECTED agent behavior — a page update must never stall on a yes/no dialog the user won't read
|
|
21
|
+
* (the ask-permission failure mode is how pages go stale). Safe because every page edit is
|
|
22
|
+
* CAS-protected + snapshotted (page_revisions → page_history/rollback_page).
|
|
23
|
+
* Deliberately EXCLUDED — these keep prompting: send_imessage (external side effect),
|
|
24
|
+
* set_page_privacy / set_record_privacy / grant_page_access (visibility widening — the
|
|
25
|
+
* unowned-project accessible-default sharp edge, 2026-07-02), rollback_page, decide_page_merge /
|
|
26
|
+
* decide_file_request / request_file / get_file, create_brain / set_active_brain, alias_page,
|
|
27
|
+
* set_writing_style. */
|
|
28
|
+
export const CORTEX_ALLOWED_TOOLS = [
|
|
29
|
+
// read surface
|
|
30
|
+
'grep', 'read_page', 'my_context', 'project_status', 'session_context', 'search_org',
|
|
31
|
+
'list_records', 'page_history', 'timeline_pull', 'my_brains', 'my_sessions', 'writing_style',
|
|
32
|
+
'code_graph_query', 'my_retier_notices', 'list_page_grants', 'file_requests', 'page_merge_requests',
|
|
33
|
+
// live authoring core
|
|
34
|
+
'authoring_context', 'author', 'log_session',
|
|
35
|
+
// routine, reversible maintenance
|
|
36
|
+
'set_page_validity', 'snooze_red_link', 'attribute_thread',
|
|
37
|
+
].map((t) => `mcp__cortex__${t}`)
|
|
38
|
+
|
|
18
39
|
/** Merge Cortex's Claude Code hooks into a ~/.claude/settings.json object. Pure + idempotent: drops
|
|
19
40
|
* any prior cortex entry (old token/path/version) from each hook array before appending the current
|
|
20
41
|
* one — capture (Stop), status + skills-repair + snapshot-context (SessionStart), precompact
|
|
21
42
|
* (PreCompact). Commands carry NO inline token (each subcommand self-resolves it). Mirrors setup.mjs
|
|
22
|
-
* step 2 exactly; foreign hooks are never touched.
|
|
43
|
+
* step 2 exactly; foreign hooks are never touched. Also merges the CORTEX_ALLOWED_TOOLS permission
|
|
44
|
+
* allowlist — additive-only: a user's own allow entries (even extra mcp__cortex__* ones) are never
|
|
45
|
+
* removed, and `deny` is never touched (a user deny always beats our allow). */
|
|
23
46
|
export function mergeClaudeSettings(existing, spec) {
|
|
24
47
|
const s = existing && typeof existing === 'object' ? existing : {}
|
|
25
48
|
s.hooks = s.hooks ?? {}
|
|
@@ -69,6 +92,15 @@ export function mergeClaudeSettings(existing, spec) {
|
|
|
69
92
|
pgrp.hooks = pgrp.hooks ?? []
|
|
70
93
|
pgrp.hooks.push({ type: 'command', command: precompactCmd })
|
|
71
94
|
|
|
95
|
+
// Permissions — pre-authorize the read + authoring core so a page update never stalls on a
|
|
96
|
+
// permission prompt. Append-missing only (no filter-and-rebuild like the hooks above): removals
|
|
97
|
+
// ship via uninstall, and rebuilding would delete allows the user added by hand.
|
|
98
|
+
s.permissions = s.permissions && typeof s.permissions === 'object' ? s.permissions : {}
|
|
99
|
+
s.permissions.allow = Array.isArray(s.permissions.allow) ? s.permissions.allow : []
|
|
100
|
+
for (const rule of CORTEX_ALLOWED_TOOLS) {
|
|
101
|
+
if (!s.permissions.allow.includes(rule)) s.permissions.allow.push(rule)
|
|
102
|
+
}
|
|
103
|
+
|
|
72
104
|
return s
|
|
73
105
|
}
|
|
74
106
|
|
package/lib/server.mjs
CHANGED
|
@@ -500,7 +500,7 @@ export async function runServer(version) {
|
|
|
500
500
|
const head = `[${t.tier}${day(t.updated_at) ? ` · authored ${day(t.updated_at)}` : ''}${t.validity && t.validity !== 'current' ? ` · ${t.validity}` : ''}${versionLine}]`
|
|
501
501
|
return [head, t.summary, secs].filter(Boolean).join('\n')
|
|
502
502
|
})
|
|
503
|
-
let footer = `— Follow any [[links]] above with read_page to go deeper.\n— If you hold fresher FIRST-HAND truth than this page — something you established THIS session (ran the command, made the change, hold the artifact) that a section here gets concretely wrong — re-author just those sections now with \`author\` (any node you are permitted to edit; concise; a material contradiction, not merely extra detail). Pass this page's \`version\` as base_version when you re-author — if the save comes back stale, the page changed under you: re-read, then re-author. Reading a stale page you can fix IS the trigger to fix it.`
|
|
503
|
+
let footer = `— Follow any [[links]] above with read_page to go deeper.\n— If you hold fresher FIRST-HAND truth than this page — something you established THIS session (ran the command, made the change, hold the artifact) that a section here gets concretely wrong — re-author just those sections now with \`author\` (any node you are permitted to edit; concise; a material contradiction, not merely extra detail). Pass this page's \`version\` as base_version when you re-author — if the save comes back stale, the page changed under you: re-read, then re-author. Reading a stale page you can fix IS the trigger to fix it. Re-authoring is pre-authorized — do NOT ask the user before updating (edits are versioned + reversible via page_history/rollback_page); update, then briefly report it.`
|
|
504
504
|
// slice 4: when the page carries identifier stamps, the history projection is one flag away.
|
|
505
505
|
const allBody = m.tiers.flatMap((t) => (t.sections ?? []).map((s) => s.body)).join('\n')
|
|
506
506
|
const stamps = [...new Set((allBody.match(/\[\[repo:[a-z0-9][a-z0-9-]*\/[a-z0-9_.-]+\]\]/gi) ?? []).map((s) => s.toLowerCase()))]
|
|
@@ -1236,7 +1236,7 @@ export async function runServer(version) {
|
|
|
1236
1236
|
{
|
|
1237
1237
|
title: 'Author a wiki node (live, while it is hot)',
|
|
1238
1238
|
description:
|
|
1239
|
-
'Write your CURRENT understanding of a project/person/org/you into the org wiki as a maintained page. Call `authoring_context` FIRST. Author from your own synthesis of the session — the compiled mental model, not a transcript dump: what it IS, where it stands, dated decisions, open threads, key people. Weave inline [[links]] to other nodes (canonical names from the namespace; red-links for wanted-but-absent nodes). The server re-authorizes the tier and resolves links. CREATES the node if it does not exist yet (project/person/org) — the conversation IS the evidence, so a brand-new entity that surfaced only in this session is authorable on the spot; you do NOT need prior records. Because such a node has nothing external to corroborate it, author it DELIBERATELY: only when you genuinely understand it is a real, distinct entity, and use its exact canonical name so it does not duplicate one already in the namespace (`user` nodes are never created). Use this continuously whenever your understanding of a node meaningfully advanced, and at session end (/log).',
|
|
1239
|
+
'Write your CURRENT understanding of a project/person/org/you into the org wiki as a maintained page. Call `authoring_context` FIRST. Author from your own synthesis of the session — the compiled mental model, not a transcript dump: what it IS, where it stands, dated decisions, open threads, key people. Weave inline [[links]] to other nodes (canonical names from the namespace; red-links for wanted-but-absent nodes). The server re-authorizes the tier and resolves links. CREATES the node if it does not exist yet (project/person/org) — the conversation IS the evidence, so a brand-new entity that surfaced only in this session is authorable on the spot; you do NOT need prior records. Because such a node has nothing external to corroborate it, author it DELIBERATELY: only when you genuinely understand it is a real, distinct entity, and use its exact canonical name so it does not duplicate one already in the namespace (`user` nodes are never created). Use this continuously whenever your understanding of a node meaningfully advanced, and at session end (/log). Authoring is PRE-AUTHORIZED — never ask the user "should I update the page?" before calling this (every edit is versioned + reversible via page_history/rollback_page); update, then briefly report what you updated.',
|
|
1240
1240
|
inputSchema: {
|
|
1241
1241
|
kind: z.enum(['project', 'person', 'org', 'user']).describe('the node type'),
|
|
1242
1242
|
name: z.string().describe('the canonical node name — an EXACT existing name from the namespace to update it, or a new name to create the node (project/person/org). e.g. "Cortex" or "Theron Peterson"'),
|
package/lib/uninstall.mjs
CHANGED
|
@@ -58,6 +58,18 @@ export function runUninstall(argv = []) {
|
|
|
58
58
|
if (s.hooks[evt].length === 0) delete s.hooks[evt]
|
|
59
59
|
}
|
|
60
60
|
if (changed) act(` - Stop/SessionStart/PreCompact cortex hooks ← ${SETTINGS}`)
|
|
61
|
+
// cortex permission allowlist (setup wires CORTEX_ALLOWED_TOOLS so authoring never stalls on a
|
|
62
|
+
// prompt) — strip every mcp__cortex__* allow rule; the user's deny list is never touched.
|
|
63
|
+
if (Array.isArray(s.permissions?.allow)) {
|
|
64
|
+
const before = s.permissions.allow.length
|
|
65
|
+
s.permissions.allow = s.permissions.allow.filter((r) => !/^mcp__cortex__/.test(String(r)))
|
|
66
|
+
if (s.permissions.allow.length !== before) {
|
|
67
|
+
changed = true
|
|
68
|
+
act(` - mcp__cortex__* permission allow rules ← ${SETTINGS}`)
|
|
69
|
+
if (s.permissions.allow.length === 0) delete s.permissions.allow
|
|
70
|
+
if (Object.keys(s.permissions).length === 0) delete s.permissions
|
|
71
|
+
}
|
|
72
|
+
}
|
|
61
73
|
return changed
|
|
62
74
|
}, write)
|
|
63
75
|
|