@theronap/agnoclast-mcp 0.9.306 → 0.9.307
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/closeout_wiki.mjs +50 -7
- package/package.json +1 -1
package/lib/closeout_wiki.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const PAGES_PER_CALL = 5
|
|
|
11
11
|
const SEARCH_HITS = 12
|
|
12
12
|
const HITS_PER_QUERY = 2
|
|
13
13
|
const MAX_EDITS = 10
|
|
14
|
-
const MAX_EXPLORED_EDITS =
|
|
14
|
+
const MAX_EXPLORED_EDITS = 40
|
|
15
15
|
const EVIDENCE_WINDOW = 1_500
|
|
16
16
|
const MAX_EVIDENCE = 60_000
|
|
17
17
|
const MAX_PAGE_CHARS = 24_000
|
|
@@ -168,11 +168,11 @@ export function gateEdit(edit, { page, allowedBrains, evidence }) {
|
|
|
168
168
|
export function explorePrompt({ segments, read, facts, asOf }) {
|
|
169
169
|
const seen = [...new Set([...segments.flatMap((s) => s.pages), ...read.pages, ...Object.keys(read.pagesRead ?? {})])]
|
|
170
170
|
return `A work session has just closed. Its record and fact notes are below. Bring the team wiki up to date with what it established, the way a careful colleague closing the session would.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Finish with JSON only:
|
|
171
|
+
First list what the session established that a wiki reader needs: for each workstream, every status that changed, every result, and every rule, preference or decision a person stated ("never list connectors in public copy" is one). Then find the page each item belongs on.
|
|
172
|
+
Use grep to find every existing page this session's work made wrong, out of date or incomplete: the feature, system, decision, project, status, bug-list and person pages it touched. Search for names, identifiers, PR numbers and phrases from the work, follow [[links]] on the pages you read, and read each page before proposing an edit to it. Run at least one search for every workstream, even when you already know a page for it: the pages a session made stale are mostly ones it never opened. Pages it opened: ${seen.join(', ') || 'none'}.
|
|
173
|
+
Bring each page fully current: every item that belongs on it, not only the first. Several edits to one page are normal. A stated rule or decision goes on the page it governs, with who stated it and the date.
|
|
174
|
+
${RULES(segments, asOf)}
|
|
175
|
+
Finish with JSON only: {"items": [{"item": one short phrase, "page": the page it went on, or null}], "edits": [at most ${MAX_EXPLORED_EDITS} objects ${EDIT_SHAPE}]}.
|
|
176
176
|
|
|
177
177
|
SESSION RECORD:
|
|
178
178
|
${segments.map((s) => `[${s.brain}]\n${s.summary}`).join('\n\n')}
|
|
@@ -181,6 +181,43 @@ FACT NOTES:
|
|
|
181
181
|
${facts.slice(-40_000)}`
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* PURE. The second exploring run: only the items the first left without a page. In the 2026-11-03 test the first run
|
|
186
|
+
* proposed nothing at all for 2 of 8 sessions whose manual close-out fixed a page each.
|
|
187
|
+
*/
|
|
188
|
+
export function gapPrompt({ segments, facts, asOf, open, done }) {
|
|
189
|
+
return `A work session has just closed, and the team wiki has been partly updated for it. These items it established have no page yet:
|
|
190
|
+
${open.map((i) => `- ${i.item}`).join('\n')}
|
|
191
|
+
For each one, search the wiki (grep with names, identifiers and phrases, then follow [[links]]) for an existing page it belongs on, and read the page. An item may truly belong nowhere; then leave it. Pages already being edited, which you need not repeat: ${[...new Set(done.map((e) => e.page))].join(', ') || 'none'}.
|
|
192
|
+
${RULES(segments, asOf)}
|
|
193
|
+
Finish with JSON only: an array of at most ${MAX_EXPLORED_EDITS} objects ${EDIT_SHAPE}.
|
|
194
|
+
|
|
195
|
+
SESSION RECORD:
|
|
196
|
+
${segments.map((s) => `[${s.brain}]\n${s.summary}`).join('\n\n')}
|
|
197
|
+
|
|
198
|
+
FACT NOTES:
|
|
199
|
+
${facts.slice(-40_000)}`
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const EDIT_SHAPE = '{"page": exact page name, "heading": the section heading, "old_string": text copied exactly from what read_page printed, appearing once on the page, "new_string": the replacement, "reason": one short phrase}'
|
|
203
|
+
const RULES = (segments, asOf) => `Only pages in these brains: ${segments.map((s) => s.brain).join(', ')}. Never a confidential page.
|
|
204
|
+
State a status only as it stood when the session ended: the fact notes run in order and later ones win, so a thing first described as not done and later done is done. Promised or still owed is not done. Propose an edit only for something this session established first-hand.
|
|
205
|
+
Prefer correcting the sentence that went stale over adding a new paragraph, and never drop a warning or reason that still holds. Copy the page's style. Date what you state, in the form ${asOf ?? 'YYYY-MM-DD'}. Keep every [[link]] in the passage you replace. No process remarks, no mention of this session or record. A page in a shared brain must not gain family, friends, classes, health, private messages or phone numbers.`
|
|
206
|
+
|
|
207
|
+
/** PURE. The exploring run's reply: its checklist and edits, or a bare array of edits. */
|
|
208
|
+
export function parseExplore(text) {
|
|
209
|
+
const fenced = [...text.matchAll(/```(?:json)?\s*\n([\s\S]*?)```/g)].map((m) => m[1].trim())
|
|
210
|
+
const start = text.indexOf('{"items"') >= 0 ? text.indexOf('{"items"') : text.search(/\{\s*"items"/)
|
|
211
|
+
for (const t of [...fenced.reverse(), start >= 0 ? text.slice(start, text.lastIndexOf('}') + 1) : '']) {
|
|
212
|
+
try {
|
|
213
|
+
const o = JSON.parse(t)
|
|
214
|
+
if (o && Array.isArray(o.edits)) return { items: Array.isArray(o.items) ? o.items : [], edits: o.edits }
|
|
215
|
+
if (Array.isArray(o)) return { items: [], edits: o }
|
|
216
|
+
} catch {}
|
|
217
|
+
}
|
|
218
|
+
return { items: [], edits: parseJsonArray(text) }
|
|
219
|
+
}
|
|
220
|
+
|
|
184
221
|
/** The fixed proposer: search, read a set of pages, and propose over them a few at a time. */
|
|
185
222
|
async function proposeFromPages({ segments, read, facts, call, readPage, search, asOf, allowedBrains }) {
|
|
186
223
|
const pages = []
|
|
@@ -209,7 +246,13 @@ async function proposeFromPages({ segments, read, facts, call, readPage, search,
|
|
|
209
246
|
*/
|
|
210
247
|
export async function proposeWikiEdits({ segments, read, facts, raw, log = '', call, readPage, search = async () => [], asOf, explore }) {
|
|
211
248
|
const allowedBrains = segments.map((s) => s.brain)
|
|
212
|
-
let proposed =
|
|
249
|
+
let proposed = []
|
|
250
|
+
if (explore) {
|
|
251
|
+
const first = parseExplore((await explore(explorePrompt({ segments, read, facts, asOf }))) ?? '')
|
|
252
|
+
proposed = first.edits.slice(0, MAX_EXPLORED_EDITS)
|
|
253
|
+
const open = first.items.filter((i) => i && typeof i.item === 'string' && !i.page)
|
|
254
|
+
if (open.length) proposed.push(...parseExplore((await explore(gapPrompt({ segments, facts, asOf, open, done: proposed }))) ?? '').edits.slice(0, MAX_EXPLORED_EDITS))
|
|
255
|
+
}
|
|
213
256
|
let pages = []
|
|
214
257
|
if (proposed.length) {
|
|
215
258
|
for (const name of new Set(proposed.map((e) => e.page))) {
|
package/package.json
CHANGED