@introspection-ai/recipes 0.41.0 → 0.43.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/dist/artifact-review-tui.d.ts +35 -0
- package/dist/artifact-review-tui.d.ts.map +1 -0
- package/dist/artifact-review-tui.js +315 -0
- package/dist/artifact-review-tui.js.map +1 -0
- package/dist/artifact-review.d.ts +55 -0
- package/dist/artifact-review.d.ts.map +1 -0
- package/dist/artifact-review.js +267 -0
- package/dist/artifact-review.js.map +1 -0
- package/dist/artifact-viewer-tui.d.ts +10 -8
- package/dist/artifact-viewer-tui.d.ts.map +1 -1
- package/dist/artifact-viewer-tui.js +24 -15
- package/dist/artifact-viewer-tui.js.map +1 -1
- package/dist/artifact-viewer.d.ts +13 -14
- package/dist/artifact-viewer.d.ts.map +1 -1
- package/dist/artifact-viewer.js +96 -58
- package/dist/artifact-viewer.js.map +1 -1
- package/dist/interaction-tui.d.ts +27 -0
- package/dist/interaction-tui.d.ts.map +1 -1
- package/dist/interaction-tui.js +39 -5
- package/dist/interaction-tui.js.map +1 -1
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +35 -2
- package/dist/pi-extension.js.map +1 -1
- package/dist/recipe/skills.d.ts +1 -0
- package/dist/recipe/skills.d.ts.map +1 -1
- package/dist/recipe/skills.js +1 -1
- package/dist/recipe/skills.js.map +1 -1
- package/dist/recipe-session-entry.d.ts +18 -0
- package/dist/recipe-session-entry.d.ts.map +1 -0
- package/dist/recipe-session-entry.js +27 -0
- package/dist/recipe-session-entry.js.map +1 -0
- package/dist/session.js +2 -2
- package/dist/session.js.map +1 -1
- package/dist/skill-progress.d.ts +68 -0
- package/dist/skill-progress.d.ts.map +1 -0
- package/dist/skill-progress.js +253 -0
- package/dist/skill-progress.js.map +1 -0
- package/docs/pi-extension.md +89 -12
- package/docs/recipe-format.md +122 -17
- package/package.json +5 -5
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `review_artifacts`: the user reviews several markdown files the agent wrote,
|
|
3
|
+
* one decision per file, as in a pull request review: approve or request
|
|
4
|
+
* changes, each with an optional comment.
|
|
5
|
+
*
|
|
6
|
+
* It is a Recipes interaction (docs/interactions.md), so it works on every
|
|
7
|
+
* host. In Pi's terminal it is inline in place of the editor, each file shown
|
|
8
|
+
* in the dialog itself (`./artifact-review-tui.ts`); over RPC each file is a select
|
|
9
|
+
* and an optional comment; a pause/resume host renders its own review widget
|
|
10
|
+
* from `details.interrupt` (`metadata.kind` is `review_artifacts`) and resumes
|
|
11
|
+
* with `{ answer }` in the text format `formatReviews` writes.
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
import { Type } from "typebox";
|
|
15
|
+
import { showReviewTui } from "./artifact-review-tui.js";
|
|
16
|
+
import { resolveArtifactPath, } from "./artifact-viewer.js";
|
|
17
|
+
import { askUser } from "./interactions.js";
|
|
18
|
+
export const REVIEW_ARTIFACTS_TOOL_NAME = "review_artifacts";
|
|
19
|
+
/** At most this many files in one review, so the user can get through it. */
|
|
20
|
+
export const MAX_REVIEW_ITEMS = 20;
|
|
21
|
+
const description = [
|
|
22
|
+
"Ask the user to review several markdown files you wrote (a brief, test cases, a design), one decision per file: approve, with an optional comment, or request changes, saying what to change.",
|
|
23
|
+
"In Pi's terminal the user steps through the files with each one shown in the panel on the right; other hosts render their own review. Prefer it to asking for approval of files in plain text.",
|
|
24
|
+
`Give 1 to ${MAX_REVIEW_ITEMS} files, in reading order, with a short label for each. Paths are relative to the working directory; only markdown files can be reviewed.`,
|
|
25
|
+
"The result lists each file's decision and comment. Record an approval only for a file the result says was approved, and change any file with changes requested, then review it again. When a change request doesn't say what to change, ask the user about that file before editing it.",
|
|
26
|
+
].join("\n");
|
|
27
|
+
const parameters = Type.Object({
|
|
28
|
+
title: Type.String({
|
|
29
|
+
description: 'What is being reviewed, e.g. "The interview agent\'s cases".',
|
|
30
|
+
}),
|
|
31
|
+
items: Type.Array(Type.Object({
|
|
32
|
+
path: Type.String({
|
|
33
|
+
description: "A markdown file, relative to the working directory.",
|
|
34
|
+
}),
|
|
35
|
+
label: Type.Optional(Type.String({
|
|
36
|
+
description: 'A short label, e.g. "C2: the candidate gives a vague answer".',
|
|
37
|
+
})),
|
|
38
|
+
section: Type.Optional(Type.String({
|
|
39
|
+
description: 'The heading of the part to approve, e.g. "Part A" for a brief; shown from that heading to the next at its level.',
|
|
40
|
+
})),
|
|
41
|
+
}, { additionalProperties: false }), { minItems: 1, maxItems: MAX_REVIEW_ITEMS }),
|
|
42
|
+
}, { additionalProperties: false });
|
|
43
|
+
/**
|
|
44
|
+
* What the review shows of a file: its front matter folded into one line (the
|
|
45
|
+
* case's check, inputs and approval, not the fields themselves), and with a
|
|
46
|
+
* `section`, only that heading's part.
|
|
47
|
+
*/
|
|
48
|
+
export function reviewSource(source, section) {
|
|
49
|
+
let text = source;
|
|
50
|
+
let summary;
|
|
51
|
+
const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
52
|
+
if (front) {
|
|
53
|
+
text = text.slice(front[0].length);
|
|
54
|
+
const field = (name) => new RegExp(`^${name}:[ \\t]*(.*)$`, "m").exec(front[1])?.[1]?.trim();
|
|
55
|
+
const inputs = [...front[1].matchAll(/^\s*-\s*name:\s*(.+)$/gm)].map((m) => m[1].trim());
|
|
56
|
+
const by = field("approved_by");
|
|
57
|
+
const parts = [
|
|
58
|
+
field("check") ? `check: ${field("check")}` : undefined,
|
|
59
|
+
inputs.length ? `inputs: ${inputs.join(", ")}` : undefined,
|
|
60
|
+
by
|
|
61
|
+
? `approved by ${by}${field("approved_at") ? ` on ${field("approved_at")}` : ""}`
|
|
62
|
+
: "not yet approved",
|
|
63
|
+
].filter(Boolean);
|
|
64
|
+
summary = `_${parts.join(" · ")}_`;
|
|
65
|
+
}
|
|
66
|
+
if (section?.trim()) {
|
|
67
|
+
const lines = text.split("\n");
|
|
68
|
+
const wanted = section.trim().toLowerCase();
|
|
69
|
+
// A `#` line inside a fenced code block isn't a heading.
|
|
70
|
+
let fenced = false;
|
|
71
|
+
const levels = lines.map((line) => {
|
|
72
|
+
if (/^\s*(```|~~~)/.test(line))
|
|
73
|
+
fenced = !fenced;
|
|
74
|
+
return !fenced && /^#{1,6}\s/.test(line)
|
|
75
|
+
? /^#+/.exec(line)[0].length
|
|
76
|
+
: 0;
|
|
77
|
+
});
|
|
78
|
+
const heading = (line) => line
|
|
79
|
+
.replace(/^#+\s*/, "")
|
|
80
|
+
.replace(/\s+#*\s*$/, "")
|
|
81
|
+
.trim()
|
|
82
|
+
.toLowerCase();
|
|
83
|
+
// An exact heading first, so "Part A" isn't taken from "Part A overview" above it.
|
|
84
|
+
const exact = lines.findIndex((line, i) => levels[i] > 0 && heading(line) === wanted);
|
|
85
|
+
const start = exact >= 0
|
|
86
|
+
? exact
|
|
87
|
+
: lines.findIndex((line, i) => levels[i] > 0 && heading(line).includes(wanted));
|
|
88
|
+
if (start >= 0) {
|
|
89
|
+
let end = lines.length;
|
|
90
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
91
|
+
if (levels[i] > 0 && levels[i] <= levels[start]) {
|
|
92
|
+
end = i;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
text = lines.slice(start, end).join("\n");
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
text = `_No heading "${section.trim()}" in this file, so all of it is shown._\n\n${text}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return summary ? `${summary}\n\n${text}` : text;
|
|
103
|
+
}
|
|
104
|
+
const DECISION_TEXT = {
|
|
105
|
+
approved: "approved",
|
|
106
|
+
changes_requested: "changes requested",
|
|
107
|
+
not_reviewed: "not reviewed",
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The answer text the model receives, one line per file after a tally. A
|
|
111
|
+
* pause/resume host resumes with this same text as `{ answer }`.
|
|
112
|
+
*/
|
|
113
|
+
export function formatReviews(reviews) {
|
|
114
|
+
const count = (decision) => reviews.filter((r) => r.decision === decision).length;
|
|
115
|
+
const lines = [
|
|
116
|
+
`Reviewed ${reviews.length} file${reviews.length === 1 ? "" : "s"}: ${count("approved")} approved, ${count("changes_requested")} with changes requested, ${count("not_reviewed")} not reviewed.`,
|
|
117
|
+
];
|
|
118
|
+
for (const review of reviews) {
|
|
119
|
+
// One line per file: the answer is parsed line by line, so a comment's own newlines are folded.
|
|
120
|
+
const text = review.comment?.replace(/\s+/g, " ").trim();
|
|
121
|
+
const comment = text ? ` — "${text}"` : "";
|
|
122
|
+
const unopened = review.opened ? "" : " (not opened)";
|
|
123
|
+
lines.push(`${review.path}: ${DECISION_TEXT[review.decision]}${unopened}${comment}`);
|
|
124
|
+
}
|
|
125
|
+
return lines.join("\n");
|
|
126
|
+
}
|
|
127
|
+
/** Read the reviews back from `formatReviews` text, as a host's resume carries it. */
|
|
128
|
+
export function parseReviews(text) {
|
|
129
|
+
const reviews = [];
|
|
130
|
+
for (const line of text.split("\n").slice(1)) {
|
|
131
|
+
const match = /^(.+?): (approved|changes requested|not reviewed)( \(not opened\))?(?: — "(.*)")?$/.exec(line);
|
|
132
|
+
if (!match)
|
|
133
|
+
continue;
|
|
134
|
+
const decision = Object.keys(DECISION_TEXT).find((d) => DECISION_TEXT[d] === match[2]);
|
|
135
|
+
reviews.push({
|
|
136
|
+
path: match[1],
|
|
137
|
+
decision,
|
|
138
|
+
opened: !match[3],
|
|
139
|
+
...(match[4] ? { comment: match[4] } : {}),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return reviews;
|
|
143
|
+
}
|
|
144
|
+
/** The RPC review: per file, a select and an optional comment. */
|
|
145
|
+
async function reviewOverDialogs(documents, ui, dialog) {
|
|
146
|
+
const reviews = [];
|
|
147
|
+
for (const item of documents) {
|
|
148
|
+
// An RPC client renders only what the dialog carries, so the file goes in it.
|
|
149
|
+
const choice = await ui.select(`${item.label} (${item.path})\n\n${item.content}`, ["Approve", "Request changes", "Skip"], dialog);
|
|
150
|
+
if (choice === undefined)
|
|
151
|
+
return null;
|
|
152
|
+
if (choice === "Skip") {
|
|
153
|
+
reviews.push({
|
|
154
|
+
path: item.path,
|
|
155
|
+
decision: "not_reviewed",
|
|
156
|
+
opened: true,
|
|
157
|
+
});
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
let comment;
|
|
161
|
+
if (choice === "Approve") {
|
|
162
|
+
comment = (await ui.input("Comment (optional)", "", dialog))?.trim();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// A change request says what to change; dismissing the prompt cancels the review.
|
|
166
|
+
while (!comment) {
|
|
167
|
+
const typed = await ui.input("What should change?", "", dialog);
|
|
168
|
+
if (typed === undefined)
|
|
169
|
+
return null;
|
|
170
|
+
comment = typed.trim();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
reviews.push({
|
|
174
|
+
path: item.path,
|
|
175
|
+
decision: choice === "Approve" ? "approved" : "changes_requested",
|
|
176
|
+
opened: true,
|
|
177
|
+
...(comment ? { comment } : {}),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return reviews;
|
|
181
|
+
}
|
|
182
|
+
/** Each file as the review shows it, read once when the review opens. */
|
|
183
|
+
function reviewDocuments(items) {
|
|
184
|
+
return items.map((item) => {
|
|
185
|
+
let content;
|
|
186
|
+
try {
|
|
187
|
+
content = reviewSource(readFileSync(item.target.absolutePath, "utf8"), item.section);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
content = "_This file doesn't exist._";
|
|
191
|
+
}
|
|
192
|
+
return { path: item.target.relativePath, label: item.label, content };
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function answered(reviews) {
|
|
196
|
+
return reviews
|
|
197
|
+
? { type: "answered", answer: formatReviews(reviews) }
|
|
198
|
+
: { type: "declined" };
|
|
199
|
+
}
|
|
200
|
+
/** Build the tool over a session's viewer. */
|
|
201
|
+
export function createReviewArtifactsTool(env,
|
|
202
|
+
/** Called before the terminal review opens, so an open artifact panel doesn't cover it. */
|
|
203
|
+
beforeReview) {
|
|
204
|
+
const tool = {
|
|
205
|
+
name: REVIEW_ARTIFACTS_TOOL_NAME,
|
|
206
|
+
label: "Review artifacts",
|
|
207
|
+
description,
|
|
208
|
+
promptSnippet: "Ask the user to review files you wrote, one decision per file",
|
|
209
|
+
promptGuidelines: [
|
|
210
|
+
"When the user must approve several markdown files you wrote (cases, a brief), ask with review_artifacts instead of asking in plain text.",
|
|
211
|
+
],
|
|
212
|
+
parameters,
|
|
213
|
+
executionMode: "sequential",
|
|
214
|
+
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
215
|
+
const items = params.items.map((item) => {
|
|
216
|
+
const target = resolveArtifactPath(ctx.cwd, item.path);
|
|
217
|
+
return {
|
|
218
|
+
target,
|
|
219
|
+
label: item.label?.trim() || target.relativePath,
|
|
220
|
+
...(item.section?.trim() ? { section: item.section.trim() } : {}),
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
const result = await askUser({
|
|
224
|
+
reason: "review",
|
|
225
|
+
message: params.title,
|
|
226
|
+
metadata: {
|
|
227
|
+
kind: REVIEW_ARTIFACTS_TOOL_NAME,
|
|
228
|
+
items: items.map((item) => ({
|
|
229
|
+
path: item.target.relativePath,
|
|
230
|
+
label: item.label,
|
|
231
|
+
...(item.section ? { section: item.section } : {}),
|
|
232
|
+
})),
|
|
233
|
+
},
|
|
234
|
+
display: {
|
|
235
|
+
kind: REVIEW_ARTIFACTS_TOOL_NAME,
|
|
236
|
+
title: params.title,
|
|
237
|
+
sections: items.map((item) => ({
|
|
238
|
+
title: item.label,
|
|
239
|
+
body: item.target.relativePath,
|
|
240
|
+
})),
|
|
241
|
+
},
|
|
242
|
+
}, {
|
|
243
|
+
toolCallId,
|
|
244
|
+
ctx,
|
|
245
|
+
signal,
|
|
246
|
+
...(env ? { env } : {}),
|
|
247
|
+
interactive: async (ui, dialog) => answered(ctx.mode === "tui"
|
|
248
|
+
? (beforeReview?.(),
|
|
249
|
+
await showReviewTui(params.title, reviewDocuments(items), ui, signal))
|
|
250
|
+
: await reviewOverDialogs(reviewDocuments(items), ui, dialog)),
|
|
251
|
+
});
|
|
252
|
+
const reviews = result.outcome.type === "answered" && result.outcome.answer
|
|
253
|
+
? parseReviews(result.outcome.answer)
|
|
254
|
+
: [];
|
|
255
|
+
return {
|
|
256
|
+
content: result.content,
|
|
257
|
+
details: { ...result.details, reviews },
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
return tool;
|
|
262
|
+
}
|
|
263
|
+
/** Whether the agent opted into the review. */
|
|
264
|
+
export function wantsArtifactReview(agentTools) {
|
|
265
|
+
return agentTools.includes(REVIEW_ARTIFACTS_TOOL_NAME);
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=artifact-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-review.js","sourceRoot":"","sources":["../src/artifact-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAe,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAuB,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EACL,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAYnC,MAAM,WAAW,GAAG;IAClB,+LAA+L;IAC/L,gMAAgM;IAChM,aAAa,gBAAgB,0IAA0I;IACvK,yRAAyR;CAC1R,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,UAAU,G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,EAAE,MAAM,EAAE,EAAE,CAChC,QAAQ,CACN,GAAG,CAAC,IAAI,KAAK,KAAK;oBAChB,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE;wBACjB,MAAM,aAAa,CACjB,MAAM,CAAC,KAAK,EACZ,eAAe,CAAC,KAAK,CAAC,EACtB,EAAE,EACF,MAAM,CACP,CAAC;oBACJ,CAAC,CAAC,MAAM,iBAAiB,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAChE;aACJ,CACF,CAAC;YACF,MAAM,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM;gBACzD,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;gBACrC,CAAC,CAAC,EAAE,CAAC;YACT,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;aACxC,CAAC;QACJ,CAAC;KACF,CAAC;IACF,OAAO,IAAiC,CAAC;AAC3C,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,mBAAmB,CAAC,UAA6B;IAC/D,OAAO,UAAU,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* file and calls `setDocument()`; the panel only draws and handles keys.
|
|
7
7
|
*/
|
|
8
8
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import { type
|
|
9
|
+
import { type Component, type MarkdownTheme, type OverlayHandle, type OverlayOptions } from "@earendil-works/pi-tui";
|
|
10
10
|
/** Where the panel sits: the top-right corner, 45% wide, full height. */
|
|
11
|
+
/** Below this many columns the panel isn't drawn. */
|
|
12
|
+
export declare const ARTIFACT_PANEL_MIN_TERMINAL_COLUMNS = 100;
|
|
11
13
|
export declare const ARTIFACT_PANEL_OVERLAY_OPTIONS: OverlayOptions;
|
|
12
14
|
/** The document the panel shows. */
|
|
13
15
|
export interface ArtifactDocument {
|
|
@@ -43,18 +45,13 @@ export declare class ArtifactPanel implements Component {
|
|
|
43
45
|
private readonly tui;
|
|
44
46
|
private readonly theme;
|
|
45
47
|
private readonly actions;
|
|
46
|
-
/** The focus shortcut, so pressing it in the panel returns to the editor. */
|
|
47
|
-
private readonly focusKey;
|
|
48
|
-
private readonly focusKeyLabel;
|
|
49
48
|
private document;
|
|
50
49
|
private readonly markdown;
|
|
51
50
|
private scrollTop;
|
|
52
51
|
private lastBodyHeight;
|
|
53
52
|
private lastMaxScroll;
|
|
54
53
|
private handle;
|
|
55
|
-
constructor(tui: PanelTui, theme: Theme, document: ArtifactDocument, actions: ArtifactPanelActions
|
|
56
|
-
/** The focus shortcut, so pressing it in the panel returns to the editor. */
|
|
57
|
-
focusKey: KeyId, focusKeyLabel: string);
|
|
54
|
+
constructor(tui: PanelTui, theme: Theme, document: ArtifactDocument, actions: ArtifactPanelActions);
|
|
58
55
|
/** Called once Pi has shown the overlay. */
|
|
59
56
|
attach(handle: OverlayHandle): void;
|
|
60
57
|
isFocused(): boolean;
|
|
@@ -67,7 +64,12 @@ export declare class ArtifactPanel implements Component {
|
|
|
67
64
|
invalidate(): void;
|
|
68
65
|
requestRender(): void;
|
|
69
66
|
dispose(): void;
|
|
70
|
-
private
|
|
67
|
+
private dialogHint;
|
|
68
|
+
/** While a dialog holds the keyboard, its scroll keys replace the footer's. */
|
|
69
|
+
setDialogHint(hint: string | undefined): void;
|
|
70
|
+
/** Lines a page scroll moves: the body's last height, less one for context. */
|
|
71
|
+
get pageLines(): number;
|
|
72
|
+
scrollBy(lines: number): void;
|
|
71
73
|
handleInput(data: string): void;
|
|
72
74
|
}
|
|
73
75
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-viewer-tui.d.ts","sourceRoot":"","sources":["../src/artifact-viewer-tui.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CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,MAAM,CAA4B;IAE1C,YACmB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EAC7B,QAAQ,EAAE,gBAAgB,EACT,OAAO,EAAE,oBAAoB,EAS/C;IAED,4CAA4C;IAC5C,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAElC;IAED,SAAS,IAAI,OAAO,CAEnB;IAED,qGAAqG;IACrG,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,UAAU,UAAQ,GAAG,IAAI,CAKhE;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,SAAS;IAYjB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAsC9B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,aAAa,IAAI,IAAI,CAEpB;IAED,OAAO,IAAI,IAAI,CAEd;IAED,OAAO,CAAC,UAAU,CAAqB;IAEvC,+EAA+E;IAC/E,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI5C;IAED,+EAA+E;IAC/E,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAQ5B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAmB9B;CACF"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Key, Markdown, matchesKey, truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
|
|
9
9
|
/** Where the panel sits: the top-right corner, 45% wide, full height. */
|
|
10
|
+
/** Below this many columns the panel isn't drawn. */
|
|
11
|
+
export const ARTIFACT_PANEL_MIN_TERMINAL_COLUMNS = 100;
|
|
10
12
|
export const ARTIFACT_PANEL_OVERLAY_OPTIONS = {
|
|
11
13
|
anchor: "top-right",
|
|
12
14
|
width: "45%",
|
|
@@ -15,6 +17,8 @@ export const ARTIFACT_PANEL_OVERLAY_OPTIONS = {
|
|
|
15
17
|
margin: 1,
|
|
16
18
|
// Opening the panel never takes input from the editor.
|
|
17
19
|
nonCapturing: true,
|
|
20
|
+
// It draws over the conversation, so on a narrow terminal it would hide most of it.
|
|
21
|
+
visible: (termWidth) => termWidth >= ARTIFACT_PANEL_MIN_TERMINAL_COLUMNS,
|
|
18
22
|
};
|
|
19
23
|
/** Pi's theme tokens for markdown, taken from the theme the overlay was given. */
|
|
20
24
|
export function artifactMarkdownTheme(theme) {
|
|
@@ -47,22 +51,16 @@ export class ArtifactPanel {
|
|
|
47
51
|
tui;
|
|
48
52
|
theme;
|
|
49
53
|
actions;
|
|
50
|
-
focusKey;
|
|
51
|
-
focusKeyLabel;
|
|
52
54
|
document;
|
|
53
55
|
markdown;
|
|
54
56
|
scrollTop = 0;
|
|
55
57
|
lastBodyHeight = 1;
|
|
56
58
|
lastMaxScroll = 0;
|
|
57
59
|
handle;
|
|
58
|
-
constructor(tui, theme, document, actions
|
|
59
|
-
/** The focus shortcut, so pressing it in the panel returns to the editor. */
|
|
60
|
-
focusKey, focusKeyLabel) {
|
|
60
|
+
constructor(tui, theme, document, actions) {
|
|
61
61
|
this.tui = tui;
|
|
62
62
|
this.theme = theme;
|
|
63
63
|
this.actions = actions;
|
|
64
|
-
this.focusKey = focusKey;
|
|
65
|
-
this.focusKeyLabel = focusKeyLabel;
|
|
66
64
|
this.document = document;
|
|
67
65
|
this.markdown = new Markdown(document.markdown ?? "", 0, 0, artifactMarkdownTheme(theme));
|
|
68
66
|
}
|
|
@@ -91,7 +89,9 @@ export class ArtifactPanel {
|
|
|
91
89
|
}
|
|
92
90
|
bodyLines(contentWidth) {
|
|
93
91
|
if (this.document.markdown === undefined) {
|
|
94
|
-
return [
|
|
92
|
+
return [
|
|
93
|
+
this.theme.fg("warning", "This file was removed or cannot be read."),
|
|
94
|
+
];
|
|
95
95
|
}
|
|
96
96
|
if (this.document.markdown.trim() === "") {
|
|
97
97
|
return [this.theme.fg("muted", "(empty file)")];
|
|
@@ -124,8 +124,8 @@ export class ArtifactPanel {
|
|
|
124
124
|
lines.push(padToWidth(`${border("│")} ${visible[index] ?? ""}`, width));
|
|
125
125
|
}
|
|
126
126
|
const hint = focused
|
|
127
|
-
? `↑↓ PgUp/PgDn scroll · o open · q/Esc close
|
|
128
|
-
:
|
|
127
|
+
? `↑↓ PgUp/PgDn scroll · o open · q/Esc close`
|
|
128
|
+
: (this.dialogHint ?? "Esc close");
|
|
129
129
|
lines.push(padToWidth(this.theme.fg("dim", ` ${hint}`), width));
|
|
130
130
|
return lines;
|
|
131
131
|
}
|
|
@@ -138,6 +138,18 @@ export class ArtifactPanel {
|
|
|
138
138
|
dispose() {
|
|
139
139
|
this.actions.disposed();
|
|
140
140
|
}
|
|
141
|
+
dialogHint;
|
|
142
|
+
/** While a dialog holds the keyboard, its scroll keys replace the footer's. */
|
|
143
|
+
setDialogHint(hint) {
|
|
144
|
+
if (hint === this.dialogHint)
|
|
145
|
+
return;
|
|
146
|
+
this.dialogHint = hint;
|
|
147
|
+
this.tui.requestRender();
|
|
148
|
+
}
|
|
149
|
+
/** Lines a page scroll moves: the body's last height, less one for context. */
|
|
150
|
+
get pageLines() {
|
|
151
|
+
return Math.max(1, this.lastBodyHeight - 1);
|
|
152
|
+
}
|
|
141
153
|
scrollBy(lines) {
|
|
142
154
|
const next = Math.min(this.lastMaxScroll, Math.max(0, this.scrollTop + lines));
|
|
143
155
|
if (next === this.scrollTop)
|
|
@@ -146,11 +158,8 @@ export class ArtifactPanel {
|
|
|
146
158
|
this.tui.requestRender();
|
|
147
159
|
}
|
|
148
160
|
handleInput(data) {
|
|
149
|
-
const page =
|
|
150
|
-
if (matchesKey(data,
|
|
151
|
-
this.actions.unfocus();
|
|
152
|
-
}
|
|
153
|
-
else if (matchesKey(data, Key.up) || data === "k") {
|
|
161
|
+
const page = this.pageLines;
|
|
162
|
+
if (matchesKey(data, Key.up) || data === "k") {
|
|
154
163
|
this.scrollBy(-1);
|
|
155
164
|
}
|
|
156
165
|
else if (matchesKey(data, Key.down) || data === "j") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-viewer-tui.js","sourceRoot":"","sources":["../src/artifact-viewer-tui.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,GAAG,EAEH,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,GAKb,MAAM,wBAAwB,CAAC;AAEhC,yEAAyE;AACzE,MAAM,CAAC,MAAM,8BAA8B,GAAmB;IAC5D,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,CAAC;IACT,uDAAuD;IACvD,YAAY,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"artifact-viewer-tui.js","sourceRoot":"","sources":["../src/artifact-viewer-tui.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,GAAG,EAEH,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,GAKb,MAAM,wBAAwB,CAAC;AAEhC,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAmB;IAC5D,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,CAAC;IACT,uDAAuD;IACvD,YAAY,EAAE,IAAI;IAClB,oFAAoF;IACpF,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC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C,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACtD,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACrD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC9B,CAAC;aAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The first-party artifact viewer: a `show_artifact` tool
|
|
2
|
+
* The first-party artifact viewer: a `show_artifact` tool and `/recipe view`
|
|
3
3
|
* and a focus shortcut that show a markdown file the agent wrote in a panel on
|
|
4
4
|
* the right of Pi's terminal, so the user can read it before approving it.
|
|
5
5
|
*
|
|
@@ -13,11 +13,11 @@ import type { ExtensionContext, ExtensionFactory, ToolDefinition } from "@earend
|
|
|
13
13
|
import type { AutocompleteItem } from "@earendil-works/pi-tui";
|
|
14
14
|
import { Type, type Static } from "typebox";
|
|
15
15
|
import type { RecipeExtensionRegistrationRegistry } from "./extensions.js";
|
|
16
|
+
import { type ArtifactPanelScrollBy } from "./interaction-tui.js";
|
|
16
17
|
export declare const SHOW_ARTIFACT_TOOL_NAME = "show_artifact";
|
|
17
18
|
/** The viewer's commands, as subcommands of Recipes' own `/recipe` so they
|
|
18
19
|
* never clash with another extension's or the user's commands. */
|
|
19
20
|
export declare const VIEW_ARTIFACT_COMMAND = "recipe view";
|
|
20
|
-
export declare const CLOSE_ARTIFACT_COMMAND = "recipe close";
|
|
21
21
|
/** A `/recipe` subcommand an optional built-in adds: `/recipe <name> <args>`. */
|
|
22
22
|
export type RecipeSubcommand = (args: string, ctx: ExtensionContext) => Promise<void>;
|
|
23
23
|
/** The `/recipe` subcommand `name` registered for this Pi instance, if any. */
|
|
@@ -44,13 +44,6 @@ export declare function recipeSubcommandCompletions(pi: object, prefix: string,
|
|
|
44
44
|
* so a large workspace stays quick; hidden folders and build output are skipped.
|
|
45
45
|
*/
|
|
46
46
|
export declare function markdownFilesFor(cwd: string, query: string): AutocompleteItem[];
|
|
47
|
-
/**
|
|
48
|
-
* Moves input between the editor and the panel. Alt+R ("recipe") is unbound
|
|
49
|
-
* in Pi's defaults; plain Ctrl letters are all taken, and Ctrl+Shift letters
|
|
50
|
-
* are indistinguishable from Ctrl letters in terminals without the Kitty
|
|
51
|
-
* keyboard protocol.
|
|
52
|
-
*/
|
|
53
|
-
export declare const ARTIFACT_PANEL_FOCUS_KEY: "alt+r";
|
|
54
47
|
/** File extensions the panel renders. */
|
|
55
48
|
export declare const ARTIFACT_MARKDOWN_EXTENSIONS: readonly string[];
|
|
56
49
|
declare const parameters: Type.TObject<{
|
|
@@ -116,6 +109,7 @@ export declare class ArtifactViewer {
|
|
|
116
109
|
/** The last markdown file shown or written, relative to the working directory. */
|
|
117
110
|
get lastPath(): string | undefined;
|
|
118
111
|
get isOpen(): boolean;
|
|
112
|
+
get isHidden(): boolean;
|
|
119
113
|
/** Remember a markdown file the agent wrote, for `/recipe view` with no argument. */
|
|
120
114
|
remember(cwd: string, path: string): void;
|
|
121
115
|
/**
|
|
@@ -123,26 +117,31 @@ export declare class ArtifactViewer {
|
|
|
123
117
|
* focus unless `focus` is set.
|
|
124
118
|
*/
|
|
125
119
|
show(ctx: ExtensionContext, target: ResolvedArtifactPath, focus?: boolean): void;
|
|
126
|
-
/**
|
|
127
|
-
|
|
120
|
+
/** Scroll the open panel without taking focus. */
|
|
121
|
+
scroll(by: ArtifactPanelScrollBy): void;
|
|
122
|
+
/** Hide or show the open panel, so the user can read the conversation under it. Returns whether it is now hidden. */
|
|
123
|
+
toggleHidden(): boolean;
|
|
124
|
+
/** While a dialog holds the keyboard, its keys replace the panel footer's; when it ends, the panel takes the keyboard back. */
|
|
125
|
+
setDialogHint(hint: string | undefined): void;
|
|
128
126
|
/** Close the panel, if it is open. */
|
|
129
127
|
close(): void;
|
|
130
128
|
private focus;
|
|
131
129
|
private unfocus;
|
|
132
130
|
private openCurrent;
|
|
133
131
|
private watch;
|
|
132
|
+
private readonly panelControl;
|
|
134
133
|
private release;
|
|
135
134
|
}
|
|
136
135
|
/** Build the tool over a session's viewer. */
|
|
137
136
|
export declare function createShowArtifactTool(viewer: ArtifactViewer): ToolDefinition;
|
|
138
137
|
/**
|
|
139
|
-
* An extension factory registering the tool
|
|
138
|
+
* An extension factory registering the tool and `/recipe view`,
|
|
140
139
|
* unless a Recipe or host extension already registered a `show_artifact`
|
|
141
140
|
* tool. Callers add it only when the agent lists `show_artifact` in `tools`,
|
|
142
141
|
* after the Recipe's own extensions.
|
|
143
142
|
*/
|
|
144
|
-
export declare function artifactViewerExtension(registrations?: RecipeExtensionRegistrationRegistry, options?: ArtifactViewerOptions): ExtensionFactory;
|
|
145
|
-
/** Whether the agent opted into the built-in viewer. */
|
|
143
|
+
export declare function artifactViewerExtension(registrations?: RecipeExtensionRegistrationRegistry, options?: ArtifactViewerOptions, agentTools?: readonly string[], env?: NodeJS.ProcessEnv): ExtensionFactory;
|
|
144
|
+
/** Whether the agent opted into the built-in viewer, directly or through review_artifacts. */
|
|
146
145
|
export declare function wantsArtifactViewer(agentTools: readonly string[]): boolean;
|
|
147
146
|
export {};
|
|
148
147
|
//# sourceMappingURL=artifact-viewer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-viewer.d.ts","sourceRoot":"","sources":["../src/artifact-viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"artifact-viewer.d.ts","sourceRoot":"","sources":["../src/artifact-viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoBH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAY5C,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AACvD;kEACkE;AAClE,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG,CAC7B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAE9B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAGA;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,EAAE,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