@theronap/agnoclast-mcp 0.9.317 → 0.9.319

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.
@@ -215,7 +215,7 @@ if (cmd === 'login') {
215
215
  const { healPageNudge } = await import('../lib/editors/claude.mjs')
216
216
  healPageNudge()
217
217
  } catch { /* never fail session start over this */ }
218
- // And the turn-end check, only where `turn-check-install` wired it.
218
+ // And the turn-end check: on by default, unless the person ran `turn-check-install --remove`.
219
219
  try {
220
220
  const { healTurnCheck } = await import('../lib/editors/claude.mjs')
221
221
  healTurnCheck()
@@ -229,7 +229,7 @@ if (cmd === 'login') {
229
229
  } else if (cmd === 'turn-check-install') {
230
230
  const { installTurnCheck } = await import('../lib/editors/claude.mjs')
231
231
  const did = installTurnCheck({ remove: process.argv.slice(3).includes('--remove') })
232
- console.log(`Turn-end knowledge check ${did}. It applies to Claude Code sessions started from now on.`)
232
+ console.log(`Turn-end knowledge check ${did}. It takes effect at the next turn end of every Claude Code session.${did === 'removed' ? ' It stays off until you run turn-check-install.' : ''}`)
233
233
  } else if (cmd === 'capture') {
234
234
  const { runCapture } = await import('../lib/capture.mjs')
235
235
  await runCapture()
@@ -187,12 +187,15 @@ export function healPageNudge({ home = homedir() } = {}) {
187
187
  return true
188
188
  }
189
189
 
190
- // The turn-end knowledge check (lib/turn_check.mjs; Theron, 2026-11-06). OPT-IN, on purpose: it holds the end of every
191
- // turn until the session says whether it learned anything new, so setup never wires it — `turn-check-install` does,
192
- // on one machine, while it is measured. mergeClaudeSettings leaves it alone (it strips only managed `capture`).
190
+ // The turn-end knowledge check (lib/turn_check.mjs; Theron, 2026-11-06). ON BY DEFAULT since 0.9.318 ("Everyone now",
191
+ // Theron, 2026-11-06 12:54 PM MST, after a blind audit of 30 turns found no major fact missed). Setup and the SessionStart
192
+ // self-heal wire it on every Claude Code seat; `turn-check-install --remove` takes it out AND leaves a marker
193
+ // (~/.cortex/turn-check-off) so no heal puts it back; `turn-check-install` clears the marker. mergeClaudeSettings leaves
194
+ // it alone (it strips only managed `capture`).
193
195
  export const TURN_CHECK_COMMAND =
194
196
  `[ -f "$HOME/.cortex/hooks/turn-check.mjs" ] && node "$HOME/.cortex/hooks/turn-check.mjs" --agnoclast-managed || true`
195
197
 
198
+ const turnCheckOff = (home) => join(home, '.cortex', 'turn-check-off')
196
199
  const hasTurnCheckIn = (s) => (s?.hooks?.Stop ?? []).some((g) => (g.hooks ?? []).some((h) => h.command === TURN_CHECK_COMMAND))
197
200
 
198
201
  /** Copy lib/turn_check.mjs to where its hook runs it. Rewrites only on change. */
@@ -217,10 +220,13 @@ export function installTurnCheck({ home = homedir(), remove = false } = {}) {
217
220
  for (const g of s.hooks.Stop) if (Array.isArray(g.hooks)) g.hooks = g.hooks.filter((h) => h.command !== TURN_CHECK_COMMAND)
218
221
  s.hooks.Stop = s.hooks.Stop.filter((g) => (g.hooks ?? []).length)
219
222
  rmSync(join(home, '.cortex', 'hooks', 'turn-check.mjs'), { force: true })
223
+ mkdirSync(join(home, '.cortex'), { recursive: true, mode: 0o700 })
224
+ writeFileSync(turnCheckOff(home), `turned off ${new Date().toISOString()}; \`turn-check-install\` turns it back on\n`)
220
225
  mkdirSync(dirname(file), { recursive: true })
221
226
  writeFileSync(file, JSON.stringify(s, null, 2))
222
227
  return 'removed'
223
228
  }
229
+ rmSync(turnCheckOff(home), { force: true })
224
230
  copyTurnCheck(home)
225
231
  if (hasTurnCheckIn(s)) return 'already installed'
226
232
  s.hooks.Stop.push({ matcher: '', hooks: [{ type: 'command', command: TURN_CHECK_COMMAND, timeout: 10 }] })
@@ -229,11 +235,18 @@ export function installTurnCheck({ home = homedir(), remove = false } = {}) {
229
235
  return 'installed'
230
236
  }
231
237
 
232
- /** SessionStart self-heal: refresh the copy where the check is wired. Never wires it. */
238
+ /** Setup + SessionStart self-heal: refresh the copy and wire the hook where it is missing, unless the person turned it
239
+ * off (the marker). Only on a machine with Claude Code settings. Returns true when it wired the hook. */
233
240
  export function healTurnCheck({ home = homedir() } = {}) {
234
241
  const file = join(home, '.claude', 'settings.json')
235
- if (!existsSync(file) || !hasTurnCheckIn(JSON.parse(readFileSync(file, 'utf8')))) return false
242
+ if (!existsSync(file) || existsSync(turnCheckOff(home))) return false
236
243
  copyTurnCheck(home)
244
+ const s = JSON.parse(readFileSync(file, 'utf8'))
245
+ if (hasTurnCheckIn(s)) return false
246
+ s.hooks = s.hooks ?? {}
247
+ s.hooks.Stop = Array.isArray(s.hooks.Stop) ? s.hooks.Stop : []
248
+ s.hooks.Stop.push({ matcher: '', hooks: [{ type: 'command', command: TURN_CHECK_COMMAND, timeout: 10 }] })
249
+ writeFileSync(file, JSON.stringify(s, null, 2))
237
250
  return true
238
251
  }
239
252
 
package/lib/server.mjs CHANGED
@@ -2904,7 +2904,7 @@ function renderNudge(payload) {
2904
2904
  'split_page',
2905
2905
  {
2906
2906
  title: 'Move sections onto a new child page',
2907
- description: 'SPLIT a page: move whole sections onto a NEW child page; the original stays. For a page that has outgrown one read — an agent that cannot read the whole authority answers from part of it. TWO STEPS: mode "preview" writes nothing and returns a `plan`; mode "apply" with that plan commits the whole split in ONE transaction (a retry returns the first result). The source then links to the child where the sections were. It NEVER retires the original, moves governance, or rewrites inbound [[links]]. Every refusal comes before any write: you need EDIT access (edit_forbidden); pages with several tier versions are paused (multi_version_page); `headings` must match the STORED heading exactly, INCLUDING any `· as of <date>` suffix, and a heading two sections share is refused (ambiguous_heading); moving every section is a rename; `new_title` must not name any existing page or an archived project (title_taken); a STRICTER child is refused and a LOOSER one needs the source page\'s owner (widening_requires_owner); too_large, identity_claim. The child keeps the source page\'s OWNER, tier and grants. AFTER APPLY, SORT THE RECORDS: split_records lists every candidate; read EACH ONE IN FULL (read_record part "all"; a recording over ~20k chars by its OWN sub-agent reading every word — never keyword search, never skim); unclear → both; then place_split_records, whose description has the whole procedure (rules shadow, inbound links, governance). If a split stops after the child exists (source_trim_failed), finish with merge_sections (`from` only) for each heading in `remaining` — never re-run split_page. undo_split reverses the whole split.',
2907
+ description: 'SPLIT a page: move whole sections onto a NEW child page; the original stays. For a page that has outgrown one read — an agent that cannot read the whole authority answers from part of it. TWO STEPS: mode "preview" writes nothing and returns a `plan`; mode "apply" with that plan commits the whole split in ONE transaction (a retry returns the first result). The source then links to the child where the sections were. It NEVER retires the original, moves governance, or rewrites inbound [[links]]. Every refusal comes before any write: you need EDIT access (edit_forbidden); pages with several tier versions are paused (multi_version_page); `headings` must match the STORED heading exactly, INCLUDING any `· as of <date>` suffix, and a heading two sections share is refused (ambiguous_heading); moving every section is a rename; `new_title` must not name any existing page or an archived project (title_taken); a STRICTER child is refused and a LOOSER one needs the source page\'s owner (widening_requires_owner); too_large, identity_claim. The child keeps the source page\'s OWNER, tier and grants. AFTER APPLY, SORT THE RECORDS: split_records lists every candidate; read EACH ONE IN FULL (read_record part "all"; a recording over ~20k chars by its OWN sub-agent reading every word — never keyword search, never skim); unclear → both; then place_split_records, whose description has the whole procedure (inbound links, governance). If a split stops after the child exists (source_trim_failed), finish with merge_sections (`from` only) for each heading in `remaining` — never re-run split_page. undo_split reverses the whole split.',
2908
2908
  inputSchema: {
2909
2909
  name: z.string().describe('the exact page name to split, as read_page shows it'),
2910
2910
  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. A heading two sections share is refused: rename one with rename_section first. Everything not listed stays on the original.'),
@@ -2972,7 +2972,7 @@ function renderNudge(payload) {
2972
2972
  'split_records',
2973
2973
  {
2974
2974
  title: 'List every record a split must sort',
2975
- description: 'List EVERY record a split you applied left on its source — the full worklist for place_split_records, not the 20 that split_page names. Page through with `offset` until you have covered `total`. Each line: id, title, source/type, date, approximate length, RECORDING when it is a meeting, transcript or handoff (each long one gets its own reader), and how it is attached (moved_claim = through a routing claim the moved text names; direct). Records you cannot read are counted, never named; records held by a routing claim the source keeps stay with it and are not candidates. Also says whether the records were already placed or the split was undone, and the rules pipeline\'s graduation streak. Read-only.',
2975
+ description: 'List EVERY record a split you applied left on its source — the full worklist for place_split_records, not the 20 that split_page names. Page through with `offset` until you have covered `total`. Each line: id, title, source/type, date, approximate length, RECORDING when it is a meeting, transcript or handoff (each long one gets its own reader), and how it is attached (moved_claim = through a routing claim the moved text names; direct). Records you cannot read are counted, never named; records held by a routing claim the source keeps stay with it and are not candidates. Also says whether the records were already placed or the split was undone. Read-only.',
2976
2976
  inputSchema: {
2977
2977
  plan: z.string().describe('the `plan` token split_page returned when you applied the split'),
2978
2978
  offset: z.number().int().min(0).optional().describe('where to start (default 0); the reply names the next offset'),
@@ -2997,7 +2997,7 @@ function renderNudge(payload) {
2997
2997
  'place_split_records',
2998
2998
  {
2999
2999
  title: 'Place a split\'s records, sorted by a full read',
3000
- description: 'Place the records of a split you APPLIED, in ONE transaction: child = attach to the child and detach from the source; both = attach to the child too; parent = leave. PROCEDURE, every split: (a) FULL READ — list the whole worklist with split_records. Read EVERY candidate in full with read_record part "all" and max_chars at least its length. Each recording over ~20k chars gets its OWN sub-agent that reads every word: no keyword search, no skimming (a trial agent once keyword-searched two 150k transcripts). BOTH IS THE DEFAULT: a record goes on one page only when its own content clearly rules it out of the other (mostly-about is not enough); one with nothing readable (a header-only email, or a fragment — a stub, bare commit message, pending-summary fragment or one-line chat/status naming no subject of either page) can never rule itself out → both. (b) SHADOW — also run the FROZEN rules that split_records prints on its first page, without looking at the full read (Haiku segments each recording; Opus decides with rules 1–5, incl. the 0.7 confidence floor), and send them as `shadow` for the same records. Only the full read is applied. (c) INBOUND LINKS — grep "[[<source title>]]" in substring mode; judge each link from its snippet; edit_page the ones you may edit to point at the child when they meant the moved text; list the rest for their owners. (d) GOVERNANCE NEVER MOVES — a record governed by the source stays on it even when you say child (it goes on both). Every readable candidate needs a decision (parent leaves it). Idempotent: a second call returns the first result. Replies with the shadow diff (harmful = the rules put a record on fewer pages or the opposite one; clutter = the rules said both) and the rules\' streak (they graduate after 10 clean splits in a row).',
3000
+ description: 'Place the records of a split you APPLIED, in ONE transaction: child = attach to the child and detach from the source; both = attach to the child too; parent = leave. PROCEDURE, every split: (a) FULL READ — list the whole worklist with split_records. Read EVERY candidate in full with read_record part "all" and max_chars at least its length. Each recording over ~20k chars gets its OWN sub-agent that reads every word: no keyword search, no skimming (a trial agent once keyword-searched two 150k transcripts). BOTH IS THE DEFAULT: a record goes on one page only when its own content clearly rules it out of the other (mostly-about is not enough); one with nothing readable (a header-only email, or a fragment — a stub, bare commit message, pending-summary fragment or one-line chat/status naming no subject of either page) can never rule itself out → both. (b) INBOUND LINKS — grep "[[<source title>]]" in substring mode; judge each link from its snippet; edit_page the ones you may edit to point at the child when they meant the moved text; list the rest for their owners. (c) GOVERNANCE NEVER MOVES — a record governed by the source stays on it even when you say child (it goes on both). Every readable candidate needs a decision (parent leaves it). Idempotent: a second call returns the first result.',
3001
3001
  inputSchema: {
3002
3002
  plan: z.string().describe('the `plan` token of the applied split'),
3003
3003
  decisions: z.array(z.object({
@@ -3006,20 +3006,15 @@ function renderNudge(payload) {
3006
3006
  confidence: z.number().min(0).max(1).optional(),
3007
3007
  reason: z.string().optional().describe('one line: what in the record decided it'),
3008
3008
  })).describe('the FULL READ: one decision for EVERY candidate split_records lists'),
3009
- shadow: z.array(z.object({
3010
- record_id: z.string(),
3011
- placement: z.enum(['child', 'parent', 'both']),
3012
- confidence: z.number().min(0).max(1).optional(),
3013
- })).optional().describe('the frozen rules pipeline\'s decisions for the same records — stored and compared, never applied'),
3014
3009
  },
3015
3010
  },
3016
- async ({ plan, decisions, shadow }) => {
3011
+ async ({ plan, decisions }) => {
3017
3012
  let res
3018
3013
  try {
3019
3014
  res = await fetchCortex(`${BASE}/api/brain/split-records`, {
3020
3015
  method: 'POST',
3021
3016
  headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
3022
- body: JSON.stringify({ plan, decisions, ...(shadow ? { shadow } : {}) }),
3017
+ body: JSON.stringify({ plan, decisions }),
3023
3018
  })
3024
3019
  } catch (e) {
3025
3020
  return toolError(`Could not place the split's records: ${e.message}`)
package/lib/setup.mjs CHANGED
@@ -6,7 +6,7 @@ import { resolveChannel } from './channel.mjs'
6
6
  import { installSkills } from './skills.mjs'
7
7
  // Pure config-merge functions live in the editor adapters; setup imports (and re-exports) THE SAME
8
8
  // functions the `cortex install` path uses, so both write byte-identical config.
9
- import { mergeClaudeMcp, mergeClaudeSettings, installConfidentialGuard, installFileCapture, installPageNudge } from './editors/claude.mjs'
9
+ import { mergeClaudeMcp, mergeClaudeSettings, installConfidentialGuard, installFileCapture, installPageNudge, healTurnCheck } from './editors/claude.mjs'
10
10
  import { mergeCodexToml, mergeCodexHooks } from './editors/codex.mjs'
11
11
 
12
12
  // One-command employee onboarding. Wires both:
@@ -161,6 +161,8 @@ export async function runSetup(argv, version) {
161
161
  ensureDir(settingsJson)
162
162
  writeFileSync(settingsJson, JSON.stringify(s, null, 2))
163
163
  log(` ✓ Capture + hydrate hooks + status line → ${settingsJson}${bak ? ' (backup saved)' : ''}`)
164
+ // The turn-end knowledge check, on by default (0.9.318) unless the person turned it off.
165
+ try { if (healTurnCheck()) log(' ✓ Turn-end knowledge check (turn it off: turn-check-install --remove)') } catch { /* optional */ }
164
166
  } catch (e) {
165
167
  process.stderr.write(` ✗ failed to update ${settingsJson}: ${e.message}\n`)
166
168
  process.exit(1)
@@ -14,13 +14,6 @@ export function worklistLine(r) {
14
14
  `${r.is_recording ? ' · RECORDING' : ''} · ${r.via}`
15
15
  }
16
16
 
17
- export function graduationLine(g) {
18
- if (!g) return ''
19
- return `Rules shadow: ${g.streak} of ${g.needed} clean splits in a row` +
20
- (g.graduated ? ' — GRADUATED (Theron decides whether the rules replace the full read).' : '.') +
21
- ` ${g.splits} split(s) with a shadow so far.`
22
- }
23
-
24
17
  /** split_records' reply: one page of the worklist. */
25
18
  export function renderWorklist(out) {
26
19
  const lines = []
@@ -35,14 +28,11 @@ export function renderWorklist(out) {
35
28
  if (shownTo < out.total) lines.push(`More: split_records with plan "${out.plan}" and offset ${shownTo}.`)
36
29
  if (out.undone_at) lines.push(`⚠ This split was UNDONE at ${out.undone_at}.`)
37
30
  else if (out.placement) lines.push(`Already placed at ${out.placement.applied_at} — place_split_records returns that result.`)
38
- else if (out.total) lines.push('Read every one IN FULL (recordings over ~20k chars by their own sub-agent), run the rules shadow, then place_split_records.')
39
- const g = graduationLine(out.graduation)
40
- if (g) lines.push(g)
41
- if (out.procedure && !out.placement && !out.undone_at) lines.push('', out.procedure)
31
+ else if (out.total) lines.push('Read every one IN FULL (recordings over ~20k chars by their own sub-agent), then place_split_records.')
42
32
  return lines.join('\n')
43
33
  }
44
34
 
45
- /** place_split_records' reply: what moved, the shadow diff, and the streak. */
35
+ /** place_split_records' reply: what moved. */
46
36
  export function renderPlacement(out) {
47
37
  const p = out.placement ?? {}
48
38
  const decisions = Array.isArray(p.decisions) ? p.decisions : []
@@ -56,16 +46,6 @@ export function renderPlacement(out) {
56
46
  const kept = actions.filter((a) => a.kept_governing).length
57
47
  lines.push(`Attached to the child: ${attached}. Detached from the source: ${detached}.` +
58
48
  (kept ? ` ${kept} record(s) GOVERNED by the source stay on it as well — governance never moves in a split.` : ''))
59
- const shadow = Array.isArray(p.shadow) ? p.shadow : []
60
- if (!shadow.length) {
61
- lines.push('No rules shadow was sent, so this split does not count toward the rules\' graduation.')
62
- } else {
63
- const d = p.diff ?? { agree: 0, harmful: [], clutter: [] }
64
- lines.push(`Rules shadow: ${d.agree} agree, ${d.clutter.length} clutter (rules said both), ${d.harmful.length} HARMFUL.`)
65
- if (d.harmful.length) lines.push(`Harmful (rules would have left evidence off a page): ${d.harmful.join(', ')}`)
66
- }
67
- const g = graduationLine(out.graduation)
68
- if (g) lines.push(g)
69
49
  lines.push('Next: inbound [[links]] to the source that meant the moved text (see split_page). undo_split reverses the whole split.')
70
50
  return lines.join('\n')
71
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.317",
3
+ "version": "0.9.319",
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": {