@robhowley/pi-remembrancer 0.5.0 → 0.5.1
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/README.md +1 -1
- package/extensions/remembrancer/capture.ts +6 -11
- package/extensions/remembrancer/index.ts +27 -8
- package/extensions/remembrancer/proposal-read.ts +13 -0
- package/extensions/remembrancer/review-pages.ts +1 -1
- package/extensions/remembrancer/reviewer.ts +12 -5
- package/extensions/remembrancer/taskwarrior.ts +16 -5
- package/package.json +1 -1
- package/skills/remembrancer/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ Explicit requests to add or change a task are applied directly after the actual
|
|
|
45
45
|
| “I’ll send the route after the school confirms pickup. Add that to life.bikebus.” | Add “Send the route” with a waiting condition. |
|
|
46
46
|
| “The school confirmed pickup. Update my route todo.” | Clear the waiting condition; sending the route stays pending. |
|
|
47
47
|
| “Wrap up this session.” | Suggest new tasks, progress notes, and completions from this conversation. |
|
|
48
|
-
| “What changed since my last review?” | Review new activity
|
|
48
|
+
| “What changed since my last review?” | Review new activity and saved suggestions together. |
|
|
49
49
|
|
|
50
50
|
The waiting-condition examples require the [optional field below](#track-task-blockers).
|
|
51
51
|
|
|
@@ -4,6 +4,7 @@ import { CheckpointStore } from './checkpoints.js';
|
|
|
4
4
|
import { loadRemembrancerConfig } from './config.js';
|
|
5
5
|
import { serializedResponse, type Selected } from './review-pages.js';
|
|
6
6
|
import { proposalParameters, stringEnumSchema, type ProposalSubmission } from './proposals.js';
|
|
7
|
+
import { proposalReadDescription, proposalReadParameters, readProposals } from './proposal-read.js';
|
|
7
8
|
import { runReviewer } from './reviewer.js';
|
|
8
9
|
import { lookupTasks } from './taskwarrior.js';
|
|
9
10
|
|
|
@@ -113,13 +114,9 @@ export async function captureOutgoing(
|
|
|
113
114
|
),
|
|
114
115
|
tool(
|
|
115
116
|
'remembrancer_proposals',
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
(args: { offset?: number }) =>
|
|
119
|
-
const offset = args.offset ?? 0;
|
|
120
|
-
const proposals = db.proposals(undefined, offset, 1);
|
|
121
|
-
return { proposals, nextOffset: proposals.length ? offset + 1 : null };
|
|
122
|
-
},
|
|
117
|
+
proposalReadDescription,
|
|
118
|
+
proposalReadParameters,
|
|
119
|
+
(args: { offset?: number }) => readProposals(db, args),
|
|
123
120
|
),
|
|
124
121
|
tool(
|
|
125
122
|
'remembrancer_submit',
|
|
@@ -147,10 +144,8 @@ export async function captureOutgoing(
|
|
|
147
144
|
throw new Error('Review did not submit a valid final result');
|
|
148
145
|
db.finishCapture(current.id, staged);
|
|
149
146
|
} catch (error) {
|
|
150
|
-
const detail =
|
|
151
|
-
|
|
152
|
-
.slice(0, 180);
|
|
153
|
-
ctx.ui.notify(`Remembrancer capture ${sessionId} failed: ${detail}`, 'warning');
|
|
147
|
+
const detail = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
148
|
+
ctx.ui.notify(`Remembrancer capture ${sessionId} failed:\n${detail}`, 'warning');
|
|
154
149
|
} finally {
|
|
155
150
|
if (timer !== undefined) clearTimeout(timer);
|
|
156
151
|
owned?.releaseReview();
|
|
@@ -6,6 +6,7 @@ import { CheckpointStore } from './checkpoints.js';
|
|
|
6
6
|
import { loadRemembrancerConfig } from './config.js';
|
|
7
7
|
import { captureOutgoing, CAPTURE_BUDGET_MS } from './capture.js';
|
|
8
8
|
import { openProposals } from './proposal-ui.js';
|
|
9
|
+
import { proposalReadDescription, proposalReadParameters, readProposals } from './proposal-read.js';
|
|
9
10
|
import { discoverSources } from './discovery.js';
|
|
10
11
|
import {
|
|
11
12
|
renderReviewCall,
|
|
@@ -360,21 +361,39 @@ export default function remembrancer(pi: ExtensionAPI) {
|
|
|
360
361
|
pi.on('session_start', (_event, ctx) => {
|
|
361
362
|
if (loadRemembrancerConfig(ctx.cwd, ctx.isProjectTrusted()).disabled) return;
|
|
362
363
|
registerReviewTool();
|
|
364
|
+
pi.registerTool({
|
|
365
|
+
name: 'remembrancer_proposals',
|
|
366
|
+
label: 'Remembrancer proposals',
|
|
367
|
+
description: proposalReadDescription,
|
|
368
|
+
parameters: proposalReadParameters,
|
|
369
|
+
async execute(_id, args) {
|
|
370
|
+
const data = readProposals(store(), args);
|
|
371
|
+
return {
|
|
372
|
+
content: [{ type: 'text', text: serializedResponse(data) }],
|
|
373
|
+
details: {},
|
|
374
|
+
};
|
|
375
|
+
},
|
|
376
|
+
});
|
|
363
377
|
enroll(ctx);
|
|
364
378
|
if (ctx.mode === 'tui') {
|
|
365
379
|
const count = store().proposalCount();
|
|
366
380
|
if (count) ctx.ui.notify(`${count} task proposals · /remembrancer proposals`, 'info');
|
|
367
381
|
}
|
|
368
382
|
});
|
|
369
|
-
pi.on('session_shutdown', async (
|
|
370
|
-
const deadline = Date.now() + CAPTURE_BUDGET_MS;
|
|
383
|
+
pi.on('session_shutdown', async (event, ctx) => {
|
|
371
384
|
try {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
385
|
+
const deadline = Date.now() + CAPTURE_BUDGET_MS;
|
|
386
|
+
try {
|
|
387
|
+
// Abandon manual coverage before capture claims the same process lock.
|
|
388
|
+
release();
|
|
389
|
+
await captureOutgoing(ctx, store, deadline);
|
|
390
|
+
} finally {
|
|
391
|
+
db?.close();
|
|
392
|
+
db = undefined;
|
|
393
|
+
}
|
|
394
|
+
} catch (error) {
|
|
395
|
+
const detail = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
396
|
+
ctx.ui.notify(`Remembrancer shutdown (${event.reason}) failed:\n${detail}`, 'warning');
|
|
378
397
|
}
|
|
379
398
|
});
|
|
380
399
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Type } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { CheckpointStore } from './checkpoints.js';
|
|
3
|
+
|
|
4
|
+
export const proposalReadDescription =
|
|
5
|
+
'Read stored proposals, including drafts, decisions and dismissal history. Each complete JSON response is capped at 50 KiB UTF-8.';
|
|
6
|
+
export const proposalReadParameters = Type.Object({
|
|
7
|
+
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function readProposals(db: CheckpointStore, { offset = 0 }: { offset?: number }) {
|
|
11
|
+
const proposals = db.proposals(undefined, offset, 1);
|
|
12
|
+
return { proposals, nextOffset: proposals.length ? offset + 1 : null };
|
|
13
|
+
}
|
|
@@ -36,7 +36,7 @@ export function serializedResponse(data: object): string {
|
|
|
36
36
|
return text;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
function fitsResponse(data: object): boolean {
|
|
39
|
+
export function fitsResponse(data: object): boolean {
|
|
40
40
|
const text = JSON.stringify(data);
|
|
41
41
|
if (text === undefined) throw new Error('Remembrancer response is not JSON serializable.');
|
|
42
42
|
return Buffer.byteLength(text, 'utf8') <= REVIEW_RESPONSE_MAX_BYTES;
|
|
@@ -90,9 +90,14 @@ export async function runReviewer({
|
|
|
90
90
|
tools: toolNames,
|
|
91
91
|
customTools: tools.map((tool) => ({
|
|
92
92
|
...tool,
|
|
93
|
-
execute(...args) {
|
|
93
|
+
async execute(...args) {
|
|
94
94
|
if (runError) throw runError;
|
|
95
|
-
|
|
95
|
+
try {
|
|
96
|
+
return await tool.execute(...args);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
runError ??= error instanceof Error ? error : new Error(String(error));
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
96
101
|
},
|
|
97
102
|
})),
|
|
98
103
|
});
|
|
@@ -105,13 +110,15 @@ export async function runReviewer({
|
|
|
105
110
|
message.stopReason === 'aborted' ||
|
|
106
111
|
message.stopReason === 'length'
|
|
107
112
|
)
|
|
108
|
-
runError
|
|
113
|
+
runError ??= new Error(message.errorMessage || `Reviewer ${message.stopReason}`);
|
|
109
114
|
const calls = message.content.filter((item) => item.type === 'toolCall');
|
|
110
115
|
if (calls.length > 1 && calls.some((call) => call.name === 'remembrancer_submit'))
|
|
111
|
-
runError
|
|
116
|
+
runError ??= new Error('Submission must be alone in its tool batch');
|
|
112
117
|
}
|
|
113
118
|
if (event.type === 'tool_execution_end' && event.isError)
|
|
114
|
-
runError ??= new Error(
|
|
119
|
+
runError ??= new Error(
|
|
120
|
+
`Reviewer tool failed (${event.toolName}): ${JSON.stringify(event.result)}`,
|
|
121
|
+
);
|
|
115
122
|
// Do not let the SDK retry extraction after a failed tool or mixed submission.
|
|
116
123
|
// Request cancellation here, but await it outside the event dispatch.
|
|
117
124
|
if (runError) abortSession();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { isDeepStrictEqual } from 'node:util';
|
|
3
3
|
import type { CheckpointStore } from './checkpoints.js';
|
|
4
|
+
import { fitsResponse, REVIEW_RESPONSE_MAX_BYTES } from './review-pages.js';
|
|
4
5
|
import {
|
|
5
6
|
validateDraft,
|
|
6
7
|
validateSnapshot,
|
|
@@ -97,11 +98,21 @@ export async function lookupTasks(
|
|
|
97
98
|
throw new Error('Invalid Taskwarrior record');
|
|
98
99
|
fullUuid(record.uuid);
|
|
99
100
|
}
|
|
100
|
-
const tasks =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
const tasks: TaskRecord[] = [];
|
|
102
|
+
let nextOffset: number | null = null;
|
|
103
|
+
for (const record of records.slice(offset, offset + 50) as TaskRecord[]) {
|
|
104
|
+
tasks.push(record);
|
|
105
|
+
nextOffset = offset + tasks.length < records.length ? offset + tasks.length : null;
|
|
106
|
+
if (fitsResponse({ tasks, nextOffset })) continue;
|
|
107
|
+
if (tasks.length === 1)
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Task ${record['uuid']} cannot fit within the ${REVIEW_RESPONSE_MAX_BYTES}-byte response limit`,
|
|
110
|
+
);
|
|
111
|
+
tasks.pop();
|
|
112
|
+
nextOffset = offset + tasks.length;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return { tasks, nextOffset };
|
|
105
116
|
}
|
|
106
117
|
async function readTask(uuid: string, execute: TaskExecutor): Promise<TaskRecord | null> {
|
|
107
118
|
const { tasks } = await lookupTasks({ uuid }, execute);
|
package/package.json
CHANGED
|
@@ -87,6 +87,8 @@ Use this procedure for evidence from both the current conversation and a frozen
|
|
|
87
87
|
|
|
88
88
|
## Full cross-session review
|
|
89
89
|
|
|
90
|
+
Read all `remembrancer_proposals` pages (`nextOffset` as `offset`, until `null`), even if there is no new evidence. Include saved proposals in reconciliation, using `draft` when present, saved quotes, and decision history.
|
|
91
|
+
|
|
90
92
|
1. Begin the review with the requested `remembrancer_review` action. For `seed 14d`, add `seed: "14d"`. Read every returned page with `action: "next"` and the same batch token until no pages remain. Later changes are not part of the batch. Read evidence and context entries in `groups[].entries` order, retaining their group's source and branch metadata. Join continued text using `offset` and `continues`.
|
|
91
93
|
2. If a selected item needs interpretation, call `action: "context"` with the same batch token and request only the needed context. For context `selected`, take `sessionId` and `branchId` from the group, and `entryId` and `editId` from the entry. Context supports interpretation, not new proposal evidence, and does not advance pages.
|
|
92
94
|
3. Follow **Reconcile evidence** above. Report unavailable sources from warnings; they remain unreviewed but do not prevent finishing the available batch as a partial result. Unknown-time warnings are informational and do not by themselves make the review partial.
|