@theronap/agnoclast-mcp 0.9.323 → 0.9.325
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/file_sealed_capture.mjs +35 -0
- package/lib/locked_tools.mjs +2 -0
- package/lib/record_render.mjs +4 -1
- package/lib/release_gate.mjs +1 -1
- package/lib/server.mjs +101 -4
- package/lib/split_render.mjs +49 -2
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// capture_record files its own save (ADR-0101 §2.2). Every account seals every capture into private intake, and a
|
|
2
|
+
// save the person asked for "already carries the judgment … sealed, then filed in the same call by every surface
|
|
3
|
+
// that creates it". The hosted connector did that (fileSealedUnit, web/lib/mcp/tools.ts); this package did not, so
|
|
4
|
+
// an agent on it (Muse's runner, Hermes) left each save sealed as a unit nobody would file — found in the agent
|
|
5
|
+
// harness spike, 2026-11-06, when Grok's save became a record and Muse's and Hermes's did not.
|
|
6
|
+
//
|
|
7
|
+
// Claim first, as every filer must: a materialize resolves whatever claim is on a unit, so filing an unclaimed one
|
|
8
|
+
// could close a session's lease. fetchCortex already sends this process's x-cortex-session-key.
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* File one sealed capture as a record in `orgId`. `fetchJson(path, body)` POSTs and resolves to
|
|
12
|
+
* `{ ok: boolean, status: number, body: object|null }`; it must not throw (callers wrap the network).
|
|
13
|
+
* @returns {Promise<{ ok: true, recordId: string|null } | { ok: false, why: string }>}
|
|
14
|
+
*/
|
|
15
|
+
export async function fileSealedCapture(fetchJson, { intakeItemId, orgId, title }) {
|
|
16
|
+
if (!intakeItemId || !orgId) return { ok: false, why: 'the save came back without its unit or brain' }
|
|
17
|
+
const c = await fetchJson('/api/intake/claim', { claimKind: 'relevance', intakeItemIds: [intakeItemId] })
|
|
18
|
+
if (!c.ok) return { ok: false, why: `could not hold it to file (${c.body?.error ?? `HTTP ${c.status}`})` }
|
|
19
|
+
const outcome = (c.body?.outcomes ?? []).find((o) => (o.intakeItemId ?? o.id) === intakeItemId)?.outcome
|
|
20
|
+
if (outcome && outcome !== 'claimed' && outcome !== 'held_by_you') return { ok: false, why: `it cannot be filed now (${outcome})` }
|
|
21
|
+
const m = await fetchJson('/api/intake/materialize', {
|
|
22
|
+
intakeItemId,
|
|
23
|
+
orgId,
|
|
24
|
+
documentIds: [],
|
|
25
|
+
// NESTED under `record`: the route ignores a top-level title (see log_session's materialize in server.mjs).
|
|
26
|
+
record: title ? { title } : {},
|
|
27
|
+
attachmentMeta: [],
|
|
28
|
+
origin: 'session',
|
|
29
|
+
})
|
|
30
|
+
if (!m.ok) {
|
|
31
|
+
const b = m.body ?? {}
|
|
32
|
+
return { ok: false, why: `not filed: ${b.error ?? `HTTP ${m.status}`}${b.hint ? ` — ${b.hint}` : b.detail ? ` — ${b.detail}` : ''}` }
|
|
33
|
+
}
|
|
34
|
+
return { ok: true, recordId: m.body?.recordId ?? null }
|
|
35
|
+
}
|
package/lib/locked_tools.mjs
CHANGED
|
@@ -23,6 +23,8 @@ export const REGULAR_ONLY_TOOLS = [
|
|
|
23
23
|
'relabel_record_people', 'supersede_record', 'move_record', 'contain_record', 'pending_records', 'claim_record',
|
|
24
24
|
'route_record', 'unroute_record', 'request_file', 'get_file', 'create_custom_source', 'search_spam_email',
|
|
25
25
|
'gmail_modify', 'draft_email_reply', 'request_send_email', 'send_imessage',
|
|
26
|
+
// Agents are Regular (obligation ea1ee929).
|
|
27
|
+
'hand_task', 'my_tasks', 'tasks_waiting', 'hold_task', 'finish_task', 'handed_tasks', 'set_working_hours',
|
|
26
28
|
]
|
|
27
29
|
|
|
28
30
|
/** What a locked tool answers when the check itself could not be made. Nothing was run. */
|
package/lib/record_render.mjs
CHANGED
|
@@ -20,6 +20,8 @@ const SOURCE_LABEL = {
|
|
|
20
20
|
github: 'GitHub', email: 'Email', 'email-in': 'Email', gmail: 'Email', 'claude-code': 'Claude Code session',
|
|
21
21
|
imessage: 'Text messages', 'google-calendar': 'Calendar', 'agnoclast-calendar': 'Calendar',
|
|
22
22
|
handoff: 'Transcript or document', meeting: 'Meeting',
|
|
23
|
+
// Every remote connector's saves, not only claude.ai's: which AI made one is rec.capturedBy (header line below).
|
|
24
|
+
'claude-connector': 'Saved through a connector',
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const label = (source) => SOURCE_LABEL[source] ?? source
|
|
@@ -38,7 +40,8 @@ export function renderRecord(rec, maxChars = READ_RECORD_DEFAULT_CHARS, part = '
|
|
|
38
40
|
const cap = Number.isFinite(maxChars) && maxChars > 0 ? Math.trunc(maxChars) : READ_RECORD_DEFAULT_CHARS
|
|
39
41
|
const out = []
|
|
40
42
|
out.push(`# ${rec.title || '(untitled record)'}`)
|
|
41
|
-
|
|
43
|
+
const by = typeof rec.capturedBy === 'string' && rec.capturedBy ? ` (${rec.capturedBy})` : ''
|
|
44
|
+
out.push(`${label(rec.source)}${by} · ${rec.occurredAt} · brain ${rec.brain?.name ?? rec.brain ?? '?'}${rec.superseded ? ' · ⚠ superseded by a newer version' : ''}`)
|
|
42
45
|
out.push(`id: ${rec.id}`)
|
|
43
46
|
out.push('')
|
|
44
47
|
const content = typeof rec.content === 'string' ? rec.content : ''
|
package/lib/release_gate.mjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// That is safe because hiding a tool is a courtesy, and every gated route checks its own flag on the server.
|
|
12
12
|
|
|
13
13
|
/** Tools any release flag gates — hidden when the server cannot be asked. Mirror of allGatedTools(). */
|
|
14
|
-
export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_split', 'upload_document_version']
|
|
14
|
+
export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'relink_links', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version']
|
|
15
15
|
|
|
16
16
|
export const RELEASE_FETCH_TIMEOUT_MS = 2500
|
|
17
17
|
/** A remembered answer older than this is not trusted: a week covers a quiet weekend without hiding tools for long. */
|
package/lib/server.mjs
CHANGED
|
@@ -36,7 +36,7 @@ import { formatSeriesRefusal, formatSeriesUpdated } from './series_render.mjs'
|
|
|
36
36
|
import { formatSends } from './sends_render.mjs'
|
|
37
37
|
import { applyLock, fetchLockState, lockedAnswerFor, lockStateWithin } from './locked_tools.mjs'
|
|
38
38
|
import { applyRelease, fetchReleaseState, releaseStateWithin, rememberReleaseState, rememberedReleaseState } from './release_gate.mjs'
|
|
39
|
-
import { renderMerge, renderMergeUndo, renderPlacement, renderSplitRefusal, renderUndo, renderWorklist } from './split_render.mjs'
|
|
39
|
+
import { renderMerge, renderMergeUndo, renderPlacement, renderRelink, renderRelinkUndo, renderSplitRefusal, renderUndo, renderWorklist } from './split_render.mjs'
|
|
40
40
|
import { filterUnshownSettling, renderSettlingV2 } from './settling_shown.mjs'
|
|
41
41
|
import { renderContactBriefing, renderContactCandidates, renderContactList } from './contacts_render.mjs'
|
|
42
42
|
import { renderConversation, renderMessageInbox } from './messages_render.mjs'
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
UPDATE_EVENT_DESCRIPTION, UPDATE_SERIES_DESCRIPTION, renderEventCancelled, renderSeriesRevised, seriesPatchBody,
|
|
47
47
|
} from './calendar_events.mjs'
|
|
48
48
|
import { formatFoundDocuments } from './found_documents.mjs'
|
|
49
|
+
import { fileSealedCapture } from './file_sealed_capture.mjs'
|
|
49
50
|
|
|
50
51
|
// PAGE tiers (ADR-0071). Six for a PAGE; a RECORD keeps three (`privacy` on log_session and
|
|
51
52
|
// set_record_privacy below) — an owner-relative tier is applied to a page's records when they are read
|
|
@@ -3061,7 +3062,7 @@ function renderNudge(payload) {
|
|
|
3061
3062
|
'merge_pages',
|
|
3062
3063
|
{
|
|
3063
3064
|
title: 'Merge one topic page into another',
|
|
3064
|
-
description: 'Fold one topic page (the SOURCE) into another (the TARGET), in ONE transaction. Preview first (mode:\'preview\', writes nothing), then apply the plan it returns (mode:\'apply\', plan). What a merge does: the source\'s sections are appended to the target WORD FOR WORD, each under "Merged from <source> — <heading>", keeping their dates (condense the overlap afterwards with merge_sections or edit_page); EVERY record on the source is attached to the target too and the target becomes the governing page of the records the source governed — nothing needs reading, a merge has one destination; the source\'s routing claims move to the target; the source is retired (superseded by the target, never deleted),
|
|
3065
|
+
description: 'Fold one topic page (the SOURCE) into another (the TARGET), in ONE transaction. Preview first (mode:\'preview\', writes nothing), then apply the plan it returns (mode:\'apply\', plan). What a merge does: the source\'s sections are appended to the target WORD FOR WORD, each under "Merged from <source> — <heading>", keeping their dates (condense the overlap afterwards with merge_sections or edit_page); EVERY record on the source is attached to the target too and the target becomes the governing page of the records the source governed — nothing needs reading, a merge has one destination; the source\'s routing claims move to the target; the source is retired (superseded by the target, never deleted), and every [[link]] to its title on a page you can edit is repointed to the target with its wording kept ([[Source]] → [[Target|Source]]); pages you cannot edit are listed and left. Refused at preview: a person page (use request_person_page_merge), pages in different brains, a page you do not own, and pages with a different tier or different grants — a merge must not change who can read anything, so align them first. undo_merge reverses all of it while neither page has changed.',
|
|
3065
3066
|
inputSchema: {
|
|
3066
3067
|
source_version: z.string().describe('the `version` read_page prints for the page being folded in (it is retired)'),
|
|
3067
3068
|
target_version: z.string().describe('the `version` read_page prints for the page that survives'),
|
|
@@ -3091,7 +3092,7 @@ function renderNudge(payload) {
|
|
|
3091
3092
|
'undo_merge',
|
|
3092
3093
|
{
|
|
3093
3094
|
title: 'Undo a page merge',
|
|
3094
|
-
description: 'Undo a page merge you applied, in ONE transaction: the appended sections come off the target, the source page is current again, governance and routing claims go back to it,
|
|
3095
|
+
description: 'Undo a page merge you applied, in ONE transaction: the appended sections come off the target, the source page is current again, governance and routing claims go back to it, the record attachments the merge added are removed, and repointed links go back to the source\'s name (a link section edited since is left and listed). Refused when either page changed after the merge. Only the member who applied it, and only once.',
|
|
3095
3096
|
inputSchema: {
|
|
3096
3097
|
plan: z.string().describe('the `plan` token of the applied merge'),
|
|
3097
3098
|
reason: z.string().optional().describe('why, in one phrase — recorded in page_history'),
|
|
@@ -3114,6 +3115,67 @@ function renderNudge(payload) {
|
|
|
3114
3115
|
},
|
|
3115
3116
|
)
|
|
3116
3117
|
|
|
3118
|
+
server.registerTool(
|
|
3119
|
+
'relink_links',
|
|
3120
|
+
{
|
|
3121
|
+
title: 'Send links to a page where they should go now',
|
|
3122
|
+
description: 'Trace every [[link]] to a name (a page title — current or retired — or an old alias) on pages in the same brain, and send each where it belongs now, in ONE transaction. merge_pages and rename_page already do this on their own; use this (1) after split_page: each link to the original is decided — move (to the new page), both (keep it and add the new page), or keep — by reading its paragraph; unless a link clearly rules one out, choose both; and (2) to clean up links left by a page retired or renamed before relinking existed. Preview first (mode:\'preview\', writes nothing) — it lists every link with an id and its paragraph; then apply with the plan and a decision per link id (or default_action). Only the link changes, never the prose: move gives [[New|Old]] (or [[New]] with style:\'rename\'). Pages you cannot edit are listed and left. undo_relink puts the links back.',
|
|
3123
|
+
inputSchema: {
|
|
3124
|
+
from: z.string().describe('the name the links use now — the original page after a split, or a retired page / old name'),
|
|
3125
|
+
to_version: z.string().describe('the `version` read_page prints for the page the links should reach'),
|
|
3126
|
+
mode: z.enum(['preview', 'apply']).describe("'preview' first; then 'apply' with the plan it returned"),
|
|
3127
|
+
plan: z.string().optional().describe('the plan token a preview returned (apply only)'),
|
|
3128
|
+
decisions: z.record(z.enum(['move', 'both', 'keep'])).optional().describe('apply: link id (from the preview) → move | both | keep'),
|
|
3129
|
+
default_action: z.enum(['move', 'both', 'keep']).optional().describe('apply: the action for every link not in decisions'),
|
|
3130
|
+
style: z.enum(['repoint', 'rename']).optional().describe("'repoint' (default) keeps the old words as display text; 'rename' writes the new name"),
|
|
3131
|
+
reason: z.string().describe('why, in one phrase — recorded in page_history on every page changed'),
|
|
3132
|
+
},
|
|
3133
|
+
},
|
|
3134
|
+
async ({ from, to_version, mode, plan, decisions, default_action, style, reason }) => {
|
|
3135
|
+
let res
|
|
3136
|
+
try {
|
|
3137
|
+
res = await fetchCortex(`${BASE}/api/brain/relink-links`, {
|
|
3138
|
+
method: 'POST',
|
|
3139
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
3140
|
+
body: JSON.stringify({ from, to_version, mode, reason, ...(plan ? { plan } : {}), ...(decisions ? { decisions } : {}),
|
|
3141
|
+
...(default_action ? { default_action } : {}), ...(style ? { style } : {}) }),
|
|
3142
|
+
})
|
|
3143
|
+
} catch (e) {
|
|
3144
|
+
return toolError(`Could not relink: ${e.message}`)
|
|
3145
|
+
}
|
|
3146
|
+
const out = await res.json().catch(() => null)
|
|
3147
|
+
if (!res.ok || !out?.ok) return toolError(renderSplitRefusal('relink', out, res.status))
|
|
3148
|
+
return { content: [{ type: 'text', text: renderRelink(out) }] }
|
|
3149
|
+
},
|
|
3150
|
+
)
|
|
3151
|
+
|
|
3152
|
+
server.registerTool(
|
|
3153
|
+
'undo_relink',
|
|
3154
|
+
{
|
|
3155
|
+
title: 'Undo a relink',
|
|
3156
|
+
description: 'Put back the links a relink_links apply — or a rename\'s relink — changed, in ONE transaction. A section edited since is left as it is and listed. Only the member who applied it, and only once.',
|
|
3157
|
+
inputSchema: {
|
|
3158
|
+
plan: z.string().describe('the `plan` token of the applied relink (rename_page reports it as its undo_relink plan)'),
|
|
3159
|
+
reason: z.string().optional().describe('why, in one phrase — recorded in page_history'),
|
|
3160
|
+
},
|
|
3161
|
+
},
|
|
3162
|
+
async ({ plan, reason }) => {
|
|
3163
|
+
let res
|
|
3164
|
+
try {
|
|
3165
|
+
res = await fetchCortex(`${BASE}/api/brain/relink-undo`, {
|
|
3166
|
+
method: 'POST',
|
|
3167
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
3168
|
+
body: JSON.stringify({ plan, ...(reason ? { reason } : {}) }),
|
|
3169
|
+
})
|
|
3170
|
+
} catch (e) {
|
|
3171
|
+
return toolError(`Could not undo the relink: ${e.message}`)
|
|
3172
|
+
}
|
|
3173
|
+
const out = await res.json().catch(() => null)
|
|
3174
|
+
if (!res.ok || !out?.ok) return toolError(renderSplitRefusal('undo the relink', out, res.status))
|
|
3175
|
+
return { content: [{ type: 'text', text: renderRelinkUndo(out) }] }
|
|
3176
|
+
},
|
|
3177
|
+
)
|
|
3178
|
+
|
|
3117
3179
|
server.registerTool(
|
|
3118
3180
|
'snooze_routing_claim',
|
|
3119
3181
|
{
|
|
@@ -4370,8 +4432,36 @@ function renderNudge(payload) {
|
|
|
4370
4432
|
// On a private-intake account the content is stored encrypted and becomes a record only when
|
|
4371
4433
|
// materialised — so it cannot be found, routed or contained until then. Reporting it as a
|
|
4372
4434
|
// plain success is how someone believes a transcript is filed when it is sitting sealed.
|
|
4435
|
+
// ADR-0101 §2.2: a save the person asked for is sealed, then FILED IN THE SAME CALL — the brain is named and the
|
|
4436
|
+
// judgment is made. Only when filing fails does the unit stay sealed, and the reply below says so.
|
|
4437
|
+
let fileFailed = null
|
|
4438
|
+
if (body.sealed && body.intakeItemId && body.orgId && !body.duplicate) {
|
|
4439
|
+
const filed = await fileSealedCapture(async (path, payload) => {
|
|
4440
|
+
try {
|
|
4441
|
+
const r = await fetchCortex(`${BASE}${path}`, {
|
|
4442
|
+
method: 'POST',
|
|
4443
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
4444
|
+
body: JSON.stringify(payload),
|
|
4445
|
+
})
|
|
4446
|
+
return { ok: r.ok, status: r.status, body: await r.json().catch(() => null) }
|
|
4447
|
+
} catch (e) {
|
|
4448
|
+
return { ok: false, status: 0, body: { error: e.message } }
|
|
4449
|
+
}
|
|
4450
|
+
}, { intakeItemId: body.intakeItemId, orgId: body.orgId, title })
|
|
4451
|
+
if (filed.ok) {
|
|
4452
|
+
const lines = [`Captured "${title}" as record ${filed.recordId ?? '(id not returned)'}.`]
|
|
4453
|
+
if (body.identifiers?.length || body.routed_by?.length) lines.push(`Routes via: ${(body.routed_by ?? body.identifiers).join(', ')} — it reaches whatever page claims those.`)
|
|
4454
|
+
else lines.push('⚠ NO IDENTIFIERS — this record reaches no page. Nobody will find it unless you give it one (identifiers) or attach it by hand.')
|
|
4455
|
+
if (body.containerDeferred) lines.push(`Placed inside container ${body.containerRecordId} as it was filed.`)
|
|
4456
|
+
const check = obligationCheckLine(spawnObligationWorker(filed.recordId ? { target: { recordId: filed.recordId }, text, title } : { target: { intakeItemId: body.intakeItemId }, text, title }), false)
|
|
4457
|
+
if (check) lines.push(check)
|
|
4458
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] }
|
|
4459
|
+
}
|
|
4460
|
+
fileFailed = filed.why
|
|
4461
|
+
}
|
|
4373
4462
|
if (body.sealed) {
|
|
4374
4463
|
const l = [`Stored "${title}" as a SEALED private-intake unit (${body.intakeItemId}).`]
|
|
4464
|
+
if (fileFailed) l.push(`Filing it in the same call failed (${fileFailed}). File it with intake_materialize, naming the page it is about.`)
|
|
4375
4465
|
l.push('It is NOT a record yet — it becomes one when you materialise it, and only then can it be routed or placed in a container.')
|
|
4376
4466
|
if (body.duplicate) l.push('This matched an existing unit rather than creating a new one.')
|
|
4377
4467
|
if (body.routed_by?.length) l.push(`Carries: ${body.routed_by.join(', ')} — it will route on those once materialised.`)
|
|
@@ -6742,7 +6832,7 @@ function renderNudge(payload) {
|
|
|
6742
6832
|
'rename_page',
|
|
6743
6833
|
{
|
|
6744
6834
|
title: 'Give a page a correct name',
|
|
6745
|
-
description: "Change the TITLE of an existing page, keeping the page itself — every record, attachment, routing claim, grant and revision on it survives untouched, because they all point at the node id and nothing anywhere points at a name. Use it on the stub names automatic minting produces from an email localpart or a display-name header: `Bna2005` -> `Brandon Andersen`, `Theriv` -> `The Riviera`, `Kentgee` -> `Kent Gee`. NOT COSMETIC — a stub carrying a bad name will not dedupe against the real person when they are authored properly, so renaming it is how you PREVENT the duplicate that would otherwise have to be merged later. The old name is kept as an alias automatically, so existing [[links]] and readers who know the old name still resolve. Renaming ONTO a name another page already holds is refused, naming the holder: combining two pages is a merge decision, not a rename. `user` pages cannot be renamed (that is an account identity).",
|
|
6835
|
+
description: "Change the TITLE of an existing page, keeping the page itself — every record, attachment, routing claim, grant and revision on it survives untouched, because they all point at the node id and nothing anywhere points at a name. Use it on the stub names automatic minting produces from an email localpart or a display-name header: `Bna2005` -> `Brandon Andersen`, `Theriv` -> `The Riviera`, `Kentgee` -> `Kent Gee`. NOT COSMETIC — a stub carrying a bad name will not dedupe against the real person when they are authored properly, so renaming it is how you PREVENT the duplicate that would otherwise have to be merged later. The old name is kept as an alias automatically, so existing [[links]] and readers who know the old name still resolve — and, where relinking is on, every [[Old]] link on a page you can edit is rewritten to the new name (undo_relink reverses that alone). Renaming ONTO a name another page already holds is refused, naming the holder: combining two pages is a merge decision, not a rename. `user` pages cannot be renamed (that is an account identity).",
|
|
6746
6836
|
inputSchema: {
|
|
6747
6837
|
kind: z.enum(['project', 'person', 'org']).describe('the page kind'),
|
|
6748
6838
|
name: z.string().optional().describe('current page title (or pass ref)'),
|
|
@@ -6785,6 +6875,13 @@ function renderNudge(payload) {
|
|
|
6785
6875
|
const lines = [`Renamed "${out.from}" -> "${out.to}" in ${out.brain} (${out.kind}, ref ${out.ref}).`]
|
|
6786
6876
|
lines.push(`${out.recordsCarried} record(s) came along; ${out.documentsRetitled} tier-doc(s) retitled.`)
|
|
6787
6877
|
lines.push(`"${out.aliasWritten}" still resolves to this page, so existing [[links]] are not broken.`)
|
|
6878
|
+
// Relinking (page_splitting brains): the server rewrote inbound [[Old]] links to the new name.
|
|
6879
|
+
if (out.linksRewritten != null) {
|
|
6880
|
+
lines.push(out.linksRewritten
|
|
6881
|
+
? `${out.linksRewritten} inbound link(s) now read [[${out.to}]]${out.linkPages?.length ? ` on ${out.linkPages.map((p) => `"${p}"`).join(', ')}` : ''}${out.relinkPlan ? ` (undo_relink plan ${out.relinkPlan} puts them back)` : ''}.`
|
|
6882
|
+
: 'No other page you can edit linked to the old name.')
|
|
6883
|
+
if (out.linksSkipped?.length) lines.push(`Not yours to edit, left on the old name (it still resolves): ${out.linksSkipped.map((p) => `"${p.page}"`).join(', ')}.`)
|
|
6884
|
+
}
|
|
6788
6885
|
return { content: [{ type: 'text', text: lines.join(' ') }] }
|
|
6789
6886
|
},
|
|
6790
6887
|
)
|
package/lib/split_render.mjs
CHANGED
|
@@ -65,7 +65,7 @@ export function renderPlacement(out) {
|
|
|
65
65
|
if (yes.length) lines.push(`The new page now claims too: ${yes.join(', ')} — future records with ${yes.length > 1 ? 'these' : 'it'} land on both pages.`)
|
|
66
66
|
if (no.length) lines.push(`Claims kept by the source alone: ${no.join(', ')}.`)
|
|
67
67
|
}
|
|
68
|
-
lines.push('Next: inbound [[links]]
|
|
68
|
+
lines.push('Next: send inbound [[links]] where they belong now — relink_links from the original page to the new one (preview lists every link with its paragraph; decide move / both / keep each). undo_split reverses the whole split.')
|
|
69
69
|
return lines.join('\n')
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -89,6 +89,20 @@ export function renderSplitRefusal(what, out, status) {
|
|
|
89
89
|
|
|
90
90
|
// ── Page merge (ADR-0036 phase 3) ──────────────────────────────────────────────────────────────────
|
|
91
91
|
|
|
92
|
+
// Inbound links (relink.ts): what a merge repoints, and the pages it may not touch. Absent on an older server.
|
|
93
|
+
function linkLines(out, preview) {
|
|
94
|
+
if (out.linksRepointed == null) return []
|
|
95
|
+
const pages = out.linkPages?.length ? ` on ${out.linkPages.map((p) => `"${p}"`).join(', ')}` : ''
|
|
96
|
+
const lines = [preview
|
|
97
|
+
? `Inbound links: ${out.linksRepointed} link(s) to "${out.source}"${pages} will point to "${out.target}", their wording kept.`
|
|
98
|
+
: `Inbound links repointed to "${out.target}": ${out.linksRepointed}${pages}.`]
|
|
99
|
+
if (out.linksSkipped?.length) {
|
|
100
|
+
lines.push(`Not yours to edit, left as they are (the old name still leads to "${out.target}" there): ${out.linksSkipped.map((p) => `"${p.page}" (${p.links})`).join(', ')}.`)
|
|
101
|
+
}
|
|
102
|
+
if (out.linksChangedSince?.length) lines.push(`Changed since the preview, left alone: ${out.linksChangedSince.join('; ')}.`)
|
|
103
|
+
return lines
|
|
104
|
+
}
|
|
105
|
+
|
|
92
106
|
export function renderMerge(out) {
|
|
93
107
|
const lines = []
|
|
94
108
|
const verb = out.preview ? 'PREVIEW — nothing written' : out.replayed ? 'already applied (this is its first result)' : 'APPLIED'
|
|
@@ -97,7 +111,8 @@ export function renderMerge(out) {
|
|
|
97
111
|
if (out.preview) {
|
|
98
112
|
lines.push(`Records: all ${out.records} on "${out.source}" will also attach to "${out.target}"${out.governed ? `; "${out.target}" becomes the governing page of ${out.governed}` : ''}. No reading needed — a merge has one destination.`)
|
|
99
113
|
lines.push(`Routing claims moving to "${out.target}": ${out.claims.length ? out.claims.join(', ') : 'none'}.`)
|
|
100
|
-
lines.push(`"${out.source}" will be retired (superseded by "${out.target}", never deleted)
|
|
114
|
+
lines.push(`"${out.source}" will be retired (superseded by "${out.target}", never deleted).`)
|
|
115
|
+
lines.push(...linkLines(out, true))
|
|
101
116
|
lines.push(`Audience unchanged: same tier, same ${out.grants} grant(s).`)
|
|
102
117
|
lines.push(`plan: ${out.plan}`)
|
|
103
118
|
lines.push(`Next: merge_pages with mode:'apply' and plan:'${out.plan}'. Afterwards, condense overlapping sections with merge_sections.`)
|
|
@@ -105,6 +120,7 @@ export function renderMerge(out) {
|
|
|
105
120
|
lines.push(`Records newly attached to "${out.target}": ${out.records}${out.recordsAlreadyOnTarget ? ` (${out.recordsAlreadyOnTarget} were already there)` : ''}; governance moved: ${out.governed}.`)
|
|
106
121
|
lines.push(`Routing claims moved: ${out.claims.length ? out.claims.join(', ') : 'none'}.`)
|
|
107
122
|
lines.push(`"${out.source}" is retired, superseded by "${out.target}".`)
|
|
123
|
+
lines.push(...linkLines(out, false))
|
|
108
124
|
lines.push(`"${out.target}" is now version ${out.targetVersion}.`)
|
|
109
125
|
lines.push(`plan: ${out.plan} — undo_merge with this plan reverses all of it while neither page has changed.`)
|
|
110
126
|
lines.push(`Next: read "${out.target}" and condense the "Merged from" sections into the page with merge_sections or edit_page.`)
|
|
@@ -117,6 +133,37 @@ export function renderMergeUndo(out) {
|
|
|
117
133
|
`Merge undone (${out.brain}): "${out.source}" is current again; "${out.target}" lost the ${out.sectionsRemoved} appended section(s).`,
|
|
118
134
|
`Record attachments the merge added, removed: ${out.recordsDetached}. Governance returned: ${out.governanceRestored}. Routing claims returned: ${out.claimsRestored}.`,
|
|
119
135
|
...(out.laterTargetRecords ? [`${out.laterTargetRecords} record(s) reached "${out.target}" after the merge and stay there.`] : []),
|
|
136
|
+
...(out.linksRestored != null ? [`Links put back to "${out.source}": ${out.linksRestored}.`] : []),
|
|
137
|
+
...(out.linksChangedSince?.length ? [`Left as they are (edited after the merge): ${out.linksChangedSince.join('; ')}.`] : []),
|
|
120
138
|
`Versions now: "${out.source}" ${out.sourceVersion} · "${out.target}" ${out.targetVersion}.`,
|
|
121
139
|
].join('\n')
|
|
122
140
|
}
|
|
141
|
+
|
|
142
|
+
export function renderRelink(out) {
|
|
143
|
+
const lines = []
|
|
144
|
+
const verb = out.preview ? 'PREVIEW — nothing written' : out.replayed ? 'already applied (this is its first result)' : 'APPLIED'
|
|
145
|
+
lines.push(`Relink "${out.from}" → "${out.to}" (${out.brain}) — ${verb}.`)
|
|
146
|
+
lines.push(`Names traced: ${out.names.map((n) => `"${n}"`).join(', ')}.`)
|
|
147
|
+
if (out.preview) {
|
|
148
|
+
if (!out.links.length) lines.push('No page you can edit links to it.')
|
|
149
|
+
for (const l of out.links) {
|
|
150
|
+
lines.push('', `[${l.id}] "${l.page}" — ${l.heading}`, ` link: ${l.text}`, ` context: ${l.context.replace(/\n+/g, ' ')}`)
|
|
151
|
+
}
|
|
152
|
+
if (out.skipped?.length) lines.push('', `Not yours to edit, left alone: ${out.skipped.map((p) => `"${p.page}" (${p.links})`).join(', ')}.`)
|
|
153
|
+
lines.push('', `plan: ${out.plan}`)
|
|
154
|
+
lines.push(`Next: decide EVERY link — move (point it at "${out.to}"), both (keep it and add "${out.to}"), or keep. Read each link's paragraph: does it mean what moved, what stayed, or both? Unless it clearly rules one out, choose both. Then relink_links with mode:'apply', plan:'${out.plan}', decisions:{ "<id>": "move"|"both"|"keep" } (or default_action for all).`)
|
|
155
|
+
} else {
|
|
156
|
+
lines.push(`Moved: ${out.moved ?? 0} · both: ${out.both ?? 0} · kept: ${out.kept ?? 0}. Pages changed: ${out.pagesChanged?.length ? out.pagesChanged.map((p) => `"${p}"`).join(', ') : 'none'}.`)
|
|
157
|
+
if (out.changedSince?.length) lines.push(`Changed since the preview, left alone: ${out.changedSince.join('; ')}.`)
|
|
158
|
+
if (out.skipped?.length) lines.push(`Not yours to edit, left alone: ${out.skipped.map((p) => `"${p.page}" (${p.links})`).join(', ')}.`)
|
|
159
|
+
lines.push(`plan: ${out.plan} — undo_relink with this plan puts the links back.`)
|
|
160
|
+
}
|
|
161
|
+
return lines.join('\n')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function renderRelinkUndo(out) {
|
|
165
|
+
return [
|
|
166
|
+
`Relink undone (${out.brain}): ${out.restored} section(s) put back${out.pages?.length ? ` on ${out.pages.map((p) => `"${p}"`).join(', ')}` : ''}.`,
|
|
167
|
+
...(out.changedSince?.length ? [`Left as they are (edited after the relink): ${out.changedSince.join('; ')}.`] : []),
|
|
168
|
+
].join('\n')
|
|
169
|
+
}
|
package/package.json
CHANGED