@robhowley/pi-remembrancer 0.3.0 → 0.5.0
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 +44 -15
- package/extensions/remembrancer/capture-review.ts +76 -0
- package/extensions/remembrancer/capture.ts +158 -0
- package/extensions/remembrancer/checkpoints.ts +291 -25
- package/extensions/remembrancer/config.ts +14 -3
- package/extensions/remembrancer/index.ts +64 -127
- package/extensions/remembrancer/proposal-ui.ts +275 -0
- package/extensions/remembrancer/proposals.ts +290 -0
- package/extensions/remembrancer/render.ts +38 -25
- package/extensions/remembrancer/review-pages.ts +268 -0
- package/extensions/remembrancer/reviewer.ts +212 -0
- package/extensions/remembrancer/taskwarrior.ts +288 -0
- package/package.json +1 -1
- package/skills/remembrancer/SKILL.md +36 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-remembrancer
|
|
2
2
|
|
|
3
|
-
Remembrancer is an agent-powered personal task manager built on Taskwarrior. It
|
|
3
|
+
Remembrancer is an agent-powered personal task manager built on Taskwarrior. It reviews user and assistant messages from your saved Pi sessions to find what you said you would do and what you have done since. It checks what is already on your list, then suggests new tasks, progress notes, and completions for you to review in one pass.
|
|
4
4
|
|
|
5
5
|
> **Remembrancer** _(noun)_ - an officer of the medieval English Exchequer who kept the _memoranda rolls_, a record of debts owed to the Crown and other unfinished business to bring back before the court.
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ Explicit requests to add or change a task are applied directly after the actual
|
|
|
47
47
|
| “Wrap up this session.” | Suggest new tasks, progress notes, and completions from this conversation. |
|
|
48
48
|
| “What changed since my last review?” | Review new activity across saved sessions and suggest changes together. |
|
|
49
49
|
|
|
50
|
-
The waiting-condition examples require the [optional field below](#
|
|
50
|
+
The waiting-condition examples require the [optional field below](#track-task-blockers).
|
|
51
51
|
|
|
52
52
|
You can also invoke the skill directly:
|
|
53
53
|
|
|
@@ -55,7 +55,47 @@ You can also invoke the skill directly:
|
|
|
55
55
|
/skill:remembrancer review commitments across my saved sessions
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Automatic TODO suggestions
|
|
59
|
+
|
|
60
|
+
Save task suggestions when you leave a session, without asking for a review each time. Capture never changes your Taskwarrior tasks; you approve suggestions later in [Saved proposals](#saved-proposals).
|
|
61
|
+
|
|
62
|
+
Capture is off by default. To enable it, add this to Pi's global settings file, normally `~/.pi/agent/settings.json`:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{ "pi-remembrancer": { "autoCapture": true } }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### What to expect
|
|
69
|
+
|
|
70
|
+
- **When:** your interactive session ends.
|
|
71
|
+
- **Scope:** the session you're leaving, but only messages that haven't yet been reviewed.
|
|
72
|
+
- **Model:** your session's selected model
|
|
73
|
+
- **Result:** proposals and review progress are saved together. Open `/remembrancer proposals` to review them.
|
|
74
|
+
|
|
75
|
+
## Saved proposals
|
|
76
|
+
|
|
77
|
+
Review the suggestions saved by automatic capture in Pi's interactive terminal:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
/remembrancer proposals
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
At startup, a reminder such as `3 task proposals · /remembrancer proposals` shows how many pending items await review.
|
|
84
|
+
|
|
85
|
+
Select an item to see its proposed changes, current task, explanation, and saved quotes.
|
|
86
|
+
|
|
87
|
+
| Key | Action |
|
|
88
|
+
| ------------------- | ---------------------------------------------------------------------- |
|
|
89
|
+
| ↑ / ↓ | Select a proposal from the preview. |
|
|
90
|
+
| Page Up / Page Down | Scroll details. |
|
|
91
|
+
| `Ctrl+A` | Approve and apply the displayed proposal. |
|
|
92
|
+
| `e` | Edit and save a pending proposal's JSON draft, without changing tasks. |
|
|
93
|
+
| `d` | Dismiss a pending proposal. |
|
|
94
|
+
| `s` | View surrounding source context. |
|
|
95
|
+
| `h` | View the saved proposal and revision history. |
|
|
96
|
+
| Esc | Return from Source/History to the preview, then close. |
|
|
97
|
+
|
|
98
|
+
## Track task blockers
|
|
59
99
|
|
|
60
100
|
To record what a task is waiting on, add the `waitingon` field:
|
|
61
101
|
|
|
@@ -65,21 +105,10 @@ task config uda.waitingon.type string
|
|
|
65
105
|
|
|
66
106
|
Skip this setup if you do not need waiting conditions; other task operations work without it.
|
|
67
107
|
|
|
68
|
-
## What gets reviewed
|
|
69
|
-
|
|
70
|
-
- Regular reviews cover sessions opened or resumed with Remembrancer enabled. An older session included for the first time this way can bring in its full history; use seed to set a starting point instead.
|
|
71
|
-
- Seed also searches Pi's configured session archive, including saved worker sessions. It does not reconstruct which sessions had Remembrancer disabled in the past.
|
|
72
|
-
- A shorter seed duration does not narrow existing review coverage. Repeating a seed skips unchanged text that has already been reviewed.
|
|
73
|
-
- Only user and assistant text is sent to the model in your reviewing session, not tool outputs, model thinking, or images.
|
|
74
|
-
- Reviews run only when you ask. Activity added during a review waits for the next one.
|
|
75
|
-
- If a session cannot be read, Remembrancer reports it and leaves it for a later review. Cancelling a review leaves review progress unsaved, but it does not undo task changes already applied.
|
|
76
|
-
|
|
77
108
|
## Settings
|
|
78
109
|
|
|
79
|
-
Remembrancer is enabled by default.
|
|
110
|
+
Remembrancer is enabled by default. Turn off remembrancer at any time by adding this to Pi's global settings file, normally `~/.pi/agent/settings.json`:
|
|
80
111
|
|
|
81
112
|
```json
|
|
82
113
|
{ "pi-remembrancer": { "disabled": true } }
|
|
83
114
|
```
|
|
84
|
-
|
|
85
|
-
A trusted project's `.pi/settings.json` takes precedence over the global value. After changing settings, run `/reload` or start a new session. The skill remains available: direct task requests can still change Taskwarrior tasks.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import type { FinishPlan } from './checkpoints.js';
|
|
3
|
+
import { prepareReview, type Checkpoint, type Source } from './evidence.js';
|
|
4
|
+
import { validateSubmission, type ProposalSubmission } from './proposals.js';
|
|
5
|
+
import {
|
|
6
|
+
boundedEvidencePage,
|
|
7
|
+
frozenContext,
|
|
8
|
+
groupEvidencePage,
|
|
9
|
+
type PageCursor,
|
|
10
|
+
type Selected,
|
|
11
|
+
} from './review-pages.js';
|
|
12
|
+
|
|
13
|
+
// Only host-selected source preparation creates coverage. Model reads cannot supply
|
|
14
|
+
// a plan, move the evidence cursor, or promote supporting context into evidence.
|
|
15
|
+
export class CaptureReview {
|
|
16
|
+
readonly id = randomUUID();
|
|
17
|
+
private readonly review;
|
|
18
|
+
private cursor: PageCursor = { index: 0, offset: 0 };
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
source: Source,
|
|
22
|
+
reviewed: readonly Checkpoint[],
|
|
23
|
+
private readonly assertActive: () => void,
|
|
24
|
+
) {
|
|
25
|
+
this.review = prepareReview([source], [...reviewed]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get hasEvidence(): boolean {
|
|
29
|
+
return this.review.evidence.length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get incomplete(): boolean {
|
|
33
|
+
return this.review.incomplete;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get warnings() {
|
|
37
|
+
return structuredClone(this.review.warnings);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
page(envelope: Record<string, unknown> = {}) {
|
|
41
|
+
this.assertActive();
|
|
42
|
+
const result = boundedEvidencePage(this.review.evidence, this.cursor, (entries, cursor) => ({
|
|
43
|
+
...envelope,
|
|
44
|
+
batch: this.id,
|
|
45
|
+
groups: groupEvidencePage(entries),
|
|
46
|
+
hasMore: cursor.index < this.review.evidence.length,
|
|
47
|
+
}));
|
|
48
|
+
this.cursor = result.cursor;
|
|
49
|
+
return result.data;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
context(args: { batch: string; selected?: Selected; before?: number; offset?: number }): object {
|
|
53
|
+
this.assertActive();
|
|
54
|
+
if (args.batch !== this.id) throw new Error('No matching open capture in this Pi session.');
|
|
55
|
+
return frozenContext(this.review, this.id, args);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
completion(submissions: readonly ProposalSubmission[]) {
|
|
59
|
+
this.assertActive();
|
|
60
|
+
if (this.incomplete) throw new Error('Cannot finish incomplete capture scope');
|
|
61
|
+
if (!this.hasEvidence) throw new Error('Cannot finish capture without eligible evidence');
|
|
62
|
+
if (this.cursor.index !== this.review.evidence.length || this.cursor.offset !== 0)
|
|
63
|
+
throw new Error('Read all evidence pages before finishing');
|
|
64
|
+
if (!Array.isArray(submissions))
|
|
65
|
+
throw new Error('Capture requires proposals array (empty is valid)');
|
|
66
|
+
const sources = submissions.map((submission) =>
|
|
67
|
+
validateSubmission(submission, this.review.evidence),
|
|
68
|
+
);
|
|
69
|
+
const plan: FinishPlan = {
|
|
70
|
+
sources: this.review.successfulSources,
|
|
71
|
+
sourceDefaults: this.review.sourceDefaults,
|
|
72
|
+
checkpoints: this.review.checkpoints,
|
|
73
|
+
};
|
|
74
|
+
return { plan: structuredClone(plan), sources };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Type, type TSchema, type Static } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { ExtensionContext, ToolDefinition } from '@earendil-works/pi-coding-agent';
|
|
3
|
+
import { CheckpointStore } from './checkpoints.js';
|
|
4
|
+
import { loadRemembrancerConfig } from './config.js';
|
|
5
|
+
import { serializedResponse, type Selected } from './review-pages.js';
|
|
6
|
+
import { proposalParameters, stringEnumSchema, type ProposalSubmission } from './proposals.js';
|
|
7
|
+
import { runReviewer } from './reviewer.js';
|
|
8
|
+
import { lookupTasks } from './taskwarrior.js';
|
|
9
|
+
|
|
10
|
+
export const CAPTURE_BUDGET_MS = 300_000;
|
|
11
|
+
|
|
12
|
+
/** Own one outgoing review through SDK cleanup. The extension owns the database lifetime. */
|
|
13
|
+
export async function captureOutgoing(
|
|
14
|
+
ctx: ExtensionContext,
|
|
15
|
+
store: () => CheckpointStore,
|
|
16
|
+
deadline: number,
|
|
17
|
+
): Promise<void> {
|
|
18
|
+
const file = ctx.sessionManager.getSessionFile();
|
|
19
|
+
if (ctx.mode !== 'tui' || !file) return;
|
|
20
|
+
let owned: CheckpointStore | undefined;
|
|
21
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
22
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
23
|
+
try {
|
|
24
|
+
const config = loadRemembrancerConfig(ctx.cwd, ctx.isProjectTrusted());
|
|
25
|
+
if (config.disabled || !config.autoCapture) return;
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
const checkDeadline = () => {
|
|
28
|
+
if (Date.now() >= deadline) controller.abort(new Error('Review timed out'));
|
|
29
|
+
controller.signal.throwIfAborted();
|
|
30
|
+
};
|
|
31
|
+
checkDeadline();
|
|
32
|
+
timer = setTimeout(
|
|
33
|
+
() => controller.abort(new Error('Review timed out')),
|
|
34
|
+
deadline - Date.now(),
|
|
35
|
+
);
|
|
36
|
+
const db = store();
|
|
37
|
+
db.claimReview();
|
|
38
|
+
owned = db;
|
|
39
|
+
const current = db.prepareCapture({ sessionId, file });
|
|
40
|
+
if (current.incomplete) throw new Error('Cannot capture incomplete evidence');
|
|
41
|
+
if (!current.hasEvidence) return;
|
|
42
|
+
let staged: ProposalSubmission[] | undefined;
|
|
43
|
+
let failed = false;
|
|
44
|
+
const tool = <T extends TSchema>(
|
|
45
|
+
name: string,
|
|
46
|
+
description: string,
|
|
47
|
+
parameters: T,
|
|
48
|
+
execute: (args: Static<T>) => object | Promise<object>,
|
|
49
|
+
submission = false,
|
|
50
|
+
): ToolDefinition => ({
|
|
51
|
+
name,
|
|
52
|
+
label: name,
|
|
53
|
+
description,
|
|
54
|
+
parameters: parameters as unknown as ToolDefinition['parameters'],
|
|
55
|
+
executionMode: 'sequential',
|
|
56
|
+
async execute(_id, args) {
|
|
57
|
+
try {
|
|
58
|
+
checkDeadline();
|
|
59
|
+
if (failed) throw new Error('Review failed');
|
|
60
|
+
if (staged !== undefined) {
|
|
61
|
+
if (submission) throw new Error('Duplicate submission');
|
|
62
|
+
return {
|
|
63
|
+
content: [{ type: 'text', text: 'Review closed.' }],
|
|
64
|
+
details: {},
|
|
65
|
+
terminate: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const data = await execute(args as Static<T>);
|
|
69
|
+
checkDeadline();
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: 'text', text: serializedResponse(data) }],
|
|
72
|
+
details: {},
|
|
73
|
+
terminate: staged !== undefined,
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
failed = true;
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const tools = [
|
|
82
|
+
tool(
|
|
83
|
+
'remembrancer_read_evidence',
|
|
84
|
+
'Read the next frozen evidence page. Read every continuation before submission.',
|
|
85
|
+
Type.Object({}),
|
|
86
|
+
() => current.page(),
|
|
87
|
+
),
|
|
88
|
+
tool(
|
|
89
|
+
'remembrancer_context',
|
|
90
|
+
'Read earlier frozen context for an eligible evidence item; not additional extraction scope.',
|
|
91
|
+
Type.Object({
|
|
92
|
+
selected: Type.Object({
|
|
93
|
+
sessionId: Type.String(),
|
|
94
|
+
branchId: Type.String(),
|
|
95
|
+
entryId: Type.String(),
|
|
96
|
+
editId: Type.Union([Type.String(), Type.Null()]),
|
|
97
|
+
}),
|
|
98
|
+
before: Type.Optional(Type.Integer({ minimum: 1, maximum: 40 })),
|
|
99
|
+
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
100
|
+
}),
|
|
101
|
+
(args: { selected: Selected; before?: number; offset?: number }) =>
|
|
102
|
+
current.context({ ...args, batch: current.id }),
|
|
103
|
+
),
|
|
104
|
+
tool(
|
|
105
|
+
'remembrancer_tasks',
|
|
106
|
+
'Read tasks, including completed tasks. No writes or arbitrary filters.',
|
|
107
|
+
Type.Object({
|
|
108
|
+
uuid: Type.Optional(Type.String()),
|
|
109
|
+
status: Type.Optional(stringEnumSchema(['pending', 'completed'] as const)),
|
|
110
|
+
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
111
|
+
}),
|
|
112
|
+
lookupTasks,
|
|
113
|
+
),
|
|
114
|
+
tool(
|
|
115
|
+
'remembrancer_proposals',
|
|
116
|
+
'Read stored proposals, including drafts, decisions and dismissal history.',
|
|
117
|
+
Type.Object({ offset: Type.Optional(Type.Integer({ minimum: 0 })) }),
|
|
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
|
+
},
|
|
123
|
+
),
|
|
124
|
+
tool(
|
|
125
|
+
'remembrancer_submit',
|
|
126
|
+
'Submit final proposals once, alone in its tool batch. Empty is valid. Does not approve or apply tasks.',
|
|
127
|
+
Type.Object({ proposals: Type.Array(proposalParameters) }),
|
|
128
|
+
(args: { proposals: ProposalSubmission[] }) => {
|
|
129
|
+
db.validateCapture(current.id, args.proposals);
|
|
130
|
+
staged = structuredClone(args.proposals);
|
|
131
|
+
return { submitted: true };
|
|
132
|
+
},
|
|
133
|
+
true,
|
|
134
|
+
),
|
|
135
|
+
];
|
|
136
|
+
checkDeadline();
|
|
137
|
+
await runReviewer({
|
|
138
|
+
cwd: ctx.cwd,
|
|
139
|
+
model: ctx.model,
|
|
140
|
+
sessionId,
|
|
141
|
+
tools,
|
|
142
|
+
signal: controller.signal,
|
|
143
|
+
});
|
|
144
|
+
// runReviewer has awaited prompt/abort settlement and disposed the temporary session.
|
|
145
|
+
checkDeadline();
|
|
146
|
+
if (failed || staged === undefined)
|
|
147
|
+
throw new Error('Review did not submit a valid final result');
|
|
148
|
+
db.finishCapture(current.id, staged);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const detail = (error instanceof Error ? error.message : String(error))
|
|
151
|
+
.split('\n')[0]!
|
|
152
|
+
.slice(0, 180);
|
|
153
|
+
ctx.ui.notify(`Remembrancer capture ${sessionId} failed: ${detail}`, 'warning');
|
|
154
|
+
} finally {
|
|
155
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
156
|
+
owned?.releaseReview();
|
|
157
|
+
}
|
|
158
|
+
}
|