@theronap/agnoclast-mcp 0.9.316 → 0.9.318
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/bin/cortex-mcp.mjs +2 -2
- package/lib/editors/claude.mjs +18 -5
- package/lib/setup.mjs +3 -1
- package/lib/turn_check.mjs +6 -1
- package/package.json +1 -1
package/bin/cortex-mcp.mjs
CHANGED
|
@@ -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,
|
|
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
|
|
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()
|
package/lib/editors/claude.mjs
CHANGED
|
@@ -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).
|
|
191
|
-
//
|
|
192
|
-
//
|
|
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
|
|
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) ||
|
|
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/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)
|
package/lib/turn_check.mjs
CHANGED
|
@@ -28,8 +28,13 @@ const textOf = (content) =>
|
|
|
28
28
|
typeof content === 'string' ? content : Array.isArray(content) ? content.filter((b) => b?.type === 'text').map((b) => b.text).join('\n') : ''
|
|
29
29
|
|
|
30
30
|
/** PURE. A user entry that starts a turn: something the person (or the app) sent, not a tool result or this hook's own feedback. */
|
|
31
|
+
// A hand-back from a subagent or another session ("peer") and a background-task notification are stored as meta entries,
|
|
32
|
+
// but each brings in new information and starts work of its own. Counting them as turn starts gives every such stretch
|
|
33
|
+
// its own check and its own MAX_BLOCKS, instead of one long autonomous turn spending two send-backs and running unchecked.
|
|
34
|
+
const WAKING_ORIGINS = new Set(['peer', 'task-notification'])
|
|
31
35
|
export function isTurnStart(d) {
|
|
32
|
-
if (d?.type !== 'user' || d.
|
|
36
|
+
if (d?.type !== 'user' || d.isCompactSummary || d.isSidechain) return false
|
|
37
|
+
if (d.isMeta && !WAKING_ORIGINS.has(d.origin?.kind)) return false
|
|
33
38
|
const c = d.message?.content
|
|
34
39
|
if (Array.isArray(c) && c.some((b) => b?.type === 'tool_result')) return false
|
|
35
40
|
const t = textOf(c)
|
package/package.json
CHANGED