@theronap/cortex-mcp 0.9.115 → 0.9.117

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 (2) hide show
  1. package/lib/server.mjs +84 -0
  2. package/package.json +1 -1
package/lib/server.mjs CHANGED
@@ -1698,6 +1698,90 @@ export async function runServer(version) {
1698
1698
  },
1699
1699
  )
1700
1700
 
1701
+ server.registerTool(
1702
+ 'split_page',
1703
+ {
1704
+ title: 'Move sections onto a new child page',
1705
+ description: 'SPLIT a page: move whole sections onto a NEW page, leaving the original in place. Use it when a page has grown past what can be read in one turn — that is a correctness problem, not just a cost one, because an agent that cannot read the whole authority answers from part of it (a head page and its governing page disagreed about a gate status for a week that way). Measured across 480 pages: the median page is ~3,500 chars, but 5.2% of pages hold a third of all authored text, so this is a targeted tool for the tail, not routine hygiene. It does NOT make pages go wrong less often — corrections scale roughly linearly with size — it changes what each correction COSTS to make: fixing one claim on a 165k-char page means reading ~42,000 tokens; on a 20k child, ~5,000. WHAT IT NEVER DOES, each for a measured reason: it never retires the original (a split is 1→2 and `superseded_by` holds one successor, so naming one would be false; the original also keeps receiving traffic that has no narrower match); it never moves governance (attaching a record to the child does not change its tier — reassigning governance is a privacy act and stays separate); it never rewrites inbound [[links]] (the splitter cannot know which half a link meant, the reader following it does — so the child says where it came from and lets them decide); and it never adds a link on the SOURCE, because where that link goes is prose — the response tells you to add one. GUARDS: the child is created BEFORE the source is trimmed, so a mid-way failure duplicates sections rather than losing them; `headings` must match the STORED heading exactly, INCLUDING any `· as of <date>` suffix (the rendered page can show a second `as of` stamp that is not part of it); moving every section is refused as a rename; and a child STRICTER than its parent is refused outright, because access is the union of attachments capped by the governing page — records attached to a stricter child keep their audience through the original, so it would look private while its evidence stayed readable. The child inherits the parent tier and its access grants, and gets an `In short` section rather than a summary. Fully reversible: `page_history` + `rollback_page` restore the source, and the child can be retired.',
1706
+ inputSchema: {
1707
+ name: z.string().describe('the exact page name to split, as read_page shows it'),
1708
+ headings: z.array(z.string()).min(1).describe('the headings of the sections to MOVE, matched EXACTLY against the stored heading — include any `· as of <date>` suffix. Everything not listed stays on the original.'),
1709
+ new_title: z.string().describe('the title of the new child page. It must not already exist in this brain.'),
1710
+ base_version: z.string().describe('the `version` read_page prints for the SOURCE page (64-hex). REQUIRED — it is the concurrency check AND how the right brain is resolved.'),
1711
+ reason: z.string().describe('WHY you are splitting, in one short phrase — recorded in page_history. Say what outgrew the page.'),
1712
+ owner: z.string().optional().describe('user id to own the child. Defaults to you, and the response says so when it does — worth setting deliberately, because ownership transfer has no reachable path once an owner is deactivated.'),
1713
+ tier: z.enum(['accessible', 'scoped', 'confidential']).optional().describe('omit to COPY the source page tier, which is almost always right. A LOOSER tier is a deliberate widening; a STRICTER one is refused, since a split cannot tighten access.'),
1714
+ },
1715
+ },
1716
+ async ({ name, headings, new_title, base_version, reason, owner, tier }) => {
1717
+ let res
1718
+ try {
1719
+ res = await fetchCortex(`${BASE}/api/brain/split-page`, {
1720
+ method: 'POST',
1721
+ headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
1722
+ body: JSON.stringify({
1723
+ name, headings, new_title, base_version, reason,
1724
+ ...(owner ? { owner } : {}), ...(tier ? { tier } : {}),
1725
+ }),
1726
+ })
1727
+ } catch (e) {
1728
+ return toolError(`Could not split the page: ${e.message}`)
1729
+ }
1730
+ const out = await res.json().catch(() => null)
1731
+ if (!res.ok) {
1732
+ // `child_created` + `remaining` is the one failure worth reading carefully: it means the split
1733
+ // is HALF DONE and nothing was lost. Surface it first so the caller finishes rather than retries
1734
+ // from the top, which would 409 on the now-taken title and look like a different problem.
1735
+ const extra = [
1736
+ out?.child_created ? `the child "${out.child_created}" EXISTS and holds every moved section — nothing was lost` : '',
1737
+ Array.isArray(out?.remaining) ? `still on BOTH pages, re-run for these: ${out.remaining.join(' · ')}` : '',
1738
+ Array.isArray(out?.detail) ? `detail: ${out.detail.join(' · ')}` : '',
1739
+ out?.message ?? '',
1740
+ ].filter(Boolean).join('\n')
1741
+ const hint = out?.hint ? `\n${out.hint}` : ''
1742
+ return toolError(`Could not split "${name}": ${out?.error ?? res.status}${extra ? `\n${extra}` : ''}${hint}`)
1743
+ }
1744
+ const ownerNote = out.owner_defaulted
1745
+ ? '\n⚠ The child is owned by you because no `owner` was given. Set one deliberately if it should belong to someone else — transfer is unreachable once an owner is deactivated.'
1746
+ : ''
1747
+ const grants = out.grants_copied ? ` ${out.grants_copied} access grant(s) copied.` : ''
1748
+ return { content: [{ type: 'text', text: `Split "${name}" (${out.brain} · ${out.tier} tier) → new page "${out.child}". Moved: ${out.moved.join(' · ')}.${grants} Child version: ${out.version}\n${out.note}\nNEXT: ${out.next}${ownerNote}\nReversible: \`page_history "${name}"\` then \`rollback_page\` restores the source; the child can be retired with set_page_validity.` }] }
1749
+ },
1750
+ )
1751
+
1752
+ server.registerTool(
1753
+ 'snooze_routing_claim',
1754
+ {
1755
+ title: 'Stop surfacing one unclaimed source',
1756
+ description: "Silence one identifier in the `Sources nothing has claimed` block at session start. Use it when a recurring source genuinely belongs nowhere — a scratch repo, a bot channel, someone else's project that happens to cc you. NOT for something you simply have not got to yet: that is what leaving it alone does. A snooze silences the NOTICE and routes nothing; the events keep landing exactly where they land today. The block already has a volume floor that keeps one-off identifiers out, so anything you see there is recurring by construction — which is precisely why no threshold can tell 'not yet decided' from 'decided: nowhere', and why this exists. Bounded to at most a year and defaulting to 90 days, because a repo that was noise in August may be the centre of the work by November. Identity namespaces (`email:`, `thread:`) are refused: they are never surfaced as claimable in the first place, so there is nothing to snooze.",
1757
+ inputSchema: {
1758
+ identifier: z.string().describe('the identifier exactly as the context block prints it, e.g. `repo:owner/name`'),
1759
+ brain: z.string().optional().describe('which brain to stop surfacing it in. Required when you belong to more than one — the call refuses rather than picking.'),
1760
+ days: z.number().optional().describe('how long to stay quiet (1-365, default 90).'),
1761
+ reason: z.string().optional().describe('why it belongs nowhere, in one phrase — the next person to see it resurface will want this.'),
1762
+ },
1763
+ },
1764
+ async ({ identifier, brain, days, reason }) => {
1765
+ let res
1766
+ try {
1767
+ res = await fetchCortex(`${BASE}/api/brain/snooze-routing-claim`, {
1768
+ method: 'POST',
1769
+ headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
1770
+ body: JSON.stringify({ identifier, ...(brain ? { brain } : {}), ...(days ? { days } : {}), ...(reason ? { reason } : {}) }),
1771
+ })
1772
+ } catch (e) {
1773
+ return toolError(`Could not snooze ${identifier}: ${e.message}`)
1774
+ }
1775
+ const out = await res.json().catch(() => null)
1776
+ if (!res.ok) {
1777
+ const extra = Array.isArray(out?.brains) ? `\nyour brains: ${out.brains.join(' · ')}` : ''
1778
+ const hint = out?.hint ? `\n${out.hint}` : ''
1779
+ return toolError(`Could not snooze ${identifier}: ${out?.error ?? res.status}${extra}${hint}`)
1780
+ }
1781
+ return { content: [{ type: 'text', text: `${out.note}\nIf it should route somewhere after all, \`set_routing_identifier\` on the owning page overrides this — a claim always beats a snooze.` }] }
1782
+ },
1783
+ )
1784
+
1701
1785
  server.registerTool(
1702
1786
  'set_summary',
1703
1787
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.115",
3
+ "version": "0.9.117",
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": {