@introspection-ai/recipes 0.45.0 → 0.46.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/review.js ADDED
@@ -0,0 +1,253 @@
1
+ /**
2
+ * The review of the files an agent wrote, as every renderer shares it: the
3
+ * decisions, the answer text a run resumes with, the interrupt a pause/resume
4
+ * host renders, each tab's name and the diff since the last review, plus the
5
+ * interaction wording. Pi's terminal (`./artifact-review-tui.ts`) and a
6
+ * browser host both import it, so it imports nothing from Node, Pi or a
7
+ * renderer; `test/review-core.test.ts` fails if it does.
8
+ */
9
+ export { DISMISSED_TEXT, formatInteractionOutcome, formatInteractionResume, } from "./interaction-text.js";
10
+ export const REVIEW_ARTIFACTS_TOOL_NAME = "review_artifacts";
11
+ /** At most this many files in one review, so the user can get through it. */
12
+ export const MAX_REVIEW_ITEMS = 20;
13
+ /**
14
+ * At most this many bytes of shown content across one review's interrupt, which
15
+ * a pause/resume host stores with the task. Past it, an item's content is cut
16
+ * and marked `truncated`, and the host must not let it be approved.
17
+ */
18
+ const MAX_REVIEW_INTERRUPT_BYTES = 256 * 1024;
19
+ /**
20
+ * What the review shows of a file: its front matter folded into one line (the
21
+ * case's check, inputs and approval, not the fields themselves), and with a
22
+ * `section`, only that heading's part.
23
+ */
24
+ export function reviewSource(source, section) {
25
+ let text = source;
26
+ let summary;
27
+ const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
28
+ if (front) {
29
+ text = text.slice(front[0].length);
30
+ const field = (name) => new RegExp(`^${name}:[ \\t]*(.*)$`, "m").exec(front[1])?.[1]?.trim();
31
+ const inputs = [...front[1].matchAll(/^\s*-\s*name:\s*(.+)$/gm)].map((m) => m[1].trim());
32
+ const by = field("approved_by");
33
+ const parts = [
34
+ field("check") ? `check: ${field("check")}` : undefined,
35
+ inputs.length ? `inputs: ${inputs.join(", ")}` : undefined,
36
+ by
37
+ ? `approved by ${by}${field("approved_at") ? ` on ${field("approved_at")}` : ""}`
38
+ : "not yet approved",
39
+ ].filter(Boolean);
40
+ summary = `_${parts.join(" · ")}_`;
41
+ }
42
+ if (section?.trim()) {
43
+ const lines = text.split("\n");
44
+ const wanted = section.trim().toLowerCase();
45
+ // A `#` line inside a fenced code block isn't a heading.
46
+ let fenced = false;
47
+ const levels = lines.map((line) => {
48
+ if (/^\s*(```|~~~)/.test(line))
49
+ fenced = !fenced;
50
+ return !fenced && /^#{1,6}\s/.test(line)
51
+ ? /^#+/.exec(line)[0].length
52
+ : 0;
53
+ });
54
+ const heading = (line) => line
55
+ .replace(/^#+\s*/, "")
56
+ .replace(/\s+#*\s*$/, "")
57
+ .trim()
58
+ .toLowerCase();
59
+ // An exact heading first, so "Part A" isn't taken from "Part A overview" above it.
60
+ const exact = lines.findIndex((line, i) => levels[i] > 0 && heading(line) === wanted);
61
+ const start = exact >= 0
62
+ ? exact
63
+ : lines.findIndex((line, i) => levels[i] > 0 && heading(line).includes(wanted));
64
+ if (start >= 0) {
65
+ let end = lines.length;
66
+ for (let i = start + 1; i < lines.length; i += 1) {
67
+ if (levels[i] > 0 && levels[i] <= levels[start]) {
68
+ end = i;
69
+ break;
70
+ }
71
+ }
72
+ text = lines.slice(start, end).join("\n");
73
+ }
74
+ else {
75
+ text = `_No heading "${section.trim()}" in this file, so all of it is shown._\n\n${text}`;
76
+ }
77
+ }
78
+ return summary ? `${summary}\n\n${text}` : text;
79
+ }
80
+ const DECISION_TEXT = {
81
+ approved: "approved",
82
+ changes_requested: "changes requested",
83
+ not_reviewed: "not reviewed",
84
+ };
85
+ /**
86
+ * The answer text the model receives, one line per file after a tally. A
87
+ * pause/resume host resumes with this same text as `{ answer }`.
88
+ */
89
+ export function formatReviews(reviews) {
90
+ const count = (decision) => reviews.filter((r) => r.decision === decision).length;
91
+ const lines = [
92
+ `Reviewed ${reviews.length} file${reviews.length === 1 ? "" : "s"}: ${count("approved")} approved, ${count("changes_requested")} with changes requested, ${count("not_reviewed")} not reviewed.`,
93
+ ];
94
+ for (const review of reviews) {
95
+ // One line per file: the answer is parsed line by line, so a comment's own newlines are folded.
96
+ const text = review.comment?.replace(/\s+/g, " ").trim();
97
+ const comment = text ? ` — "${text}"` : "";
98
+ const unopened = review.opened ? "" : " (not opened)";
99
+ lines.push(`${review.path}: ${DECISION_TEXT[review.decision]}${unopened}${comment}`);
100
+ }
101
+ return lines.join("\n");
102
+ }
103
+ /** Read the reviews back from `formatReviews` text, as a host's resume carries it. */
104
+ export function parseReviews(text) {
105
+ const reviews = [];
106
+ for (const line of text.split("\n").slice(1)) {
107
+ const match = /^(.+?): (approved|changes requested|not reviewed)( \(not opened\))?(?: — "(.*)")?$/.exec(line);
108
+ if (!match)
109
+ continue;
110
+ const decision = Object.keys(DECISION_TEXT).find((d) => DECISION_TEXT[d] === match[2]);
111
+ reviews.push({
112
+ path: match[1],
113
+ decision,
114
+ opened: !match[3],
115
+ ...(match[4] ? { comment: match[4] } : {}),
116
+ });
117
+ }
118
+ return reviews;
119
+ }
120
+ /** The history key for one review scope: a path, and the section of it shown. */
121
+ export function reviewScope(path, section) {
122
+ return `${path}\u0000${section ?? ""}`;
123
+ }
124
+ const encoder = new TextEncoder();
125
+ const decoder = new TextDecoder();
126
+ /**
127
+ * The interrupt's items, holding at most `MAX_REVIEW_INTERRUPT_BYTES` of
128
+ * content: every file's current content first, in reading order, then the
129
+ * previous versions that fit whole in what's left. `previous` is keyed by
130
+ * `reviewScope`, so a different section of the same file is never its previous
131
+ * version.
132
+ */
133
+ export function reviewInterruptItems(documents, sections, previous, budget = MAX_REVIEW_INTERRUPT_BYTES) {
134
+ let left = budget;
135
+ const take = (text) => {
136
+ const bytes = encoder.encode(text);
137
+ if (bytes.length <= left) {
138
+ left -= bytes.length;
139
+ return { text, cut: false };
140
+ }
141
+ const kept = bytes.subarray(0, Math.max(left, 0));
142
+ left = 0;
143
+ // A cut can split a multi-byte character; drop the partial one.
144
+ return { text: decoder.decode(kept).replace(/�$/, ""), cut: true };
145
+ };
146
+ const shown = documents.map((doc) => take(doc.content));
147
+ return documents.map((doc, index) => {
148
+ const section = sections[index];
149
+ const before = previous.get(reviewScope(doc.path, section));
150
+ // A previous version is only worth sending whole, and only in the space the current files left.
151
+ const prior = before !== undefined &&
152
+ before !== doc.content &&
153
+ !shown[index].cut &&
154
+ encoder.encode(before).length <= left
155
+ ? take(before)
156
+ : undefined;
157
+ return {
158
+ path: doc.path,
159
+ label: doc.label,
160
+ ...(section ? { section } : {}),
161
+ content: shown[index].text,
162
+ sha256: doc.sha256,
163
+ ...(prior && !prior.cut ? { previous_content: prior.text } : {}),
164
+ ...(shown[index].cut ? { truncated: true } : {}),
165
+ };
166
+ });
167
+ }
168
+ /** A case-like id at the start of a name: `C1`, `C1-1`, `C4/C5`. */
169
+ const TAB_ID = /^([A-Za-z]{1,3}\d+(?:[-/][A-Za-z]{0,3}\d+)*)(?![A-Za-z0-9])/;
170
+ /**
171
+ * A tab's name: an id at the start of the label ("C1" from "C1: four
172
+ * questions"), else at the start of the file's name ("C1-1" from
173
+ * `outputs/C1-1-transcript.md`), else the file's name when short (`DESIGN`),
174
+ * else the tab's number.
175
+ */
176
+ export function tabName(label, path, index) {
177
+ const name = path.replace(/\/+$/, "").split("/").pop() ?? "";
178
+ const stem = name.replace(/\.[^.]*$/, "");
179
+ const id = TAB_ID.exec(label.trim())?.[1] ?? TAB_ID.exec(stem)?.[1];
180
+ if (id)
181
+ return id;
182
+ return stem.length > 0 && stem.length <= 12 ? stem : String(index + 1);
183
+ }
184
+ /** The most cells the changed middle's table may hold before the diff falls back. */
185
+ export const LINE_DIFF_MAX_CELLS = 1_000_000;
186
+ /**
187
+ * A line diff of a file's previous review (`previous_content`) against now:
188
+ * the common prefix and suffix are kept as they are, and the changed middle
189
+ * is diffed by longest common subsequence. A middle whose table would exceed
190
+ * `LINE_DIFF_MAX_CELLS` reads as removed and then added, so memory stays
191
+ * bounded whatever the input.
192
+ */
193
+ export function lineDiff(before, after) {
194
+ const a = before.split("\n");
195
+ const b = after.split("\n");
196
+ let start = 0;
197
+ while (start < a.length && start < b.length && a[start] === b[start])
198
+ start += 1;
199
+ let endA = a.length;
200
+ let endB = b.length;
201
+ while (endA > start && endB > start && a[endA - 1] === b[endB - 1]) {
202
+ endA -= 1;
203
+ endB -= 1;
204
+ }
205
+ const lines = a
206
+ .slice(0, start)
207
+ .map((text) => ({ kind: "same", text }));
208
+ const midA = a.slice(start, endA);
209
+ const midB = b.slice(start, endB);
210
+ const width = midB.length + 1;
211
+ if ((midA.length + 1) * width > LINE_DIFF_MAX_CELLS) {
212
+ for (const text of midA)
213
+ lines.push({ kind: "removed", text });
214
+ for (const text of midB)
215
+ lines.push({ kind: "added", text });
216
+ }
217
+ else {
218
+ const lengths = new Uint32Array((midA.length + 1) * width);
219
+ for (let i = midA.length - 1; i >= 0; i -= 1) {
220
+ for (let j = midB.length - 1; j >= 0; j -= 1) {
221
+ lengths[i * width + j] =
222
+ midA[i] === midB[j]
223
+ ? lengths[(i + 1) * width + j + 1] + 1
224
+ : Math.max(lengths[(i + 1) * width + j], lengths[i * width + j + 1]);
225
+ }
226
+ }
227
+ let i = 0;
228
+ let j = 0;
229
+ while (i < midA.length && j < midB.length) {
230
+ if (midA[i] === midB[j]) {
231
+ lines.push({ kind: "same", text: midA[i] });
232
+ i += 1;
233
+ j += 1;
234
+ }
235
+ else if (lengths[(i + 1) * width + j] >= lengths[i * width + j + 1]) {
236
+ lines.push({ kind: "removed", text: midA[i] });
237
+ i += 1;
238
+ }
239
+ else {
240
+ lines.push({ kind: "added", text: midB[j] });
241
+ j += 1;
242
+ }
243
+ }
244
+ for (; i < midA.length; i += 1)
245
+ lines.push({ kind: "removed", text: midA[i] });
246
+ for (; j < midB.length; j += 1)
247
+ lines.push({ kind: "added", text: midB[j] });
248
+ }
249
+ for (const text of a.slice(endA))
250
+ lines.push({ kind: "same", text });
251
+ return lines;
252
+ }
253
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -171,7 +171,13 @@ something else.
171
171
  Resume payloads are `{ answer }` for single-answer questions,
172
172
  `{ answers: string[] }` for multi-select questions, and
173
173
  `{ approved, feedback? }` for confirmations. A decline is a resume with
174
- status `cancelled` and **no payload**. Any host-specific pause/resume state
174
+ status `cancelled` and **no payload**. A resume with status `cancelled` and
175
+ `{ dismissed: true }` means the user dismissed the question to reply in the
176
+ chat: the model is told to stop and wait for their message rather than
177
+ proceed. `formatInteractionResume` and `formatInteractionOutcome` are
178
+ importable without Node or Pi from `@introspection-ai/recipes/review`, with
179
+ the `review_artifacts` answer format (`formatReviews`, `parseReviews`), so a
180
+ browser host renders the same bytes as Pi's terminal. Any host-specific pause/resume state
175
181
  should be generated by the host from this request, not authored inside a
176
182
  Recipe.
177
183
 
@@ -202,6 +202,9 @@ then a comment (required for changes); on a pause/resume host it pauses with
202
202
  the host to render its own review, and resumes with `{ answer }` in the format
203
203
  below; headless runs and child agents decline, so nothing is approved without a
204
204
  person.
205
+ `@introspection-ai/recipes/review` exports what a host needs to render it the
206
+ way the terminal does (`formatReviews`, `parseReviews`, `tabName`, `lineDiff`
207
+ for the changes since `previous_content`), with no Node or Pi imports.
205
208
 
206
209
  Each item carries what the reviewer is shown, so the host needs no access to
207
210
  the files:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@introspection-ai/recipes",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "The open format for vertical agents, built on Pi.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -35,6 +35,10 @@
35
35
  "types": "./dist/interactions.d.ts",
36
36
  "import": "./dist/interactions.js"
37
37
  },
38
+ "./review": {
39
+ "types": "./dist/review.d.ts",
40
+ "import": "./dist/review.js"
41
+ },
38
42
  "./extensions": {
39
43
  "types": "./dist/api/extensions.d.ts",
40
44
  "import": "./dist/api/extensions.js"
@@ -106,10 +110,10 @@
106
110
  "@introspection-ai/recipe-channel-slack": ">=0.6.0",
107
111
  "@introspection-ai/recipe-documents-docx": ">=0.3.0",
108
112
  "@introspection-ai/recipe-documents-pdf": ">=0.2.0",
109
- "@introspection-ai/mcp-client-linux-x64": "0.45.0",
110
- "@introspection-ai/mcp-client-linux-arm64": "0.45.0",
111
- "@introspection-ai/mcp-client-darwin-arm64": "0.45.0",
112
- "@introspection-ai/mcp-client-darwin-x64": "0.45.0"
113
+ "@introspection-ai/mcp-client-linux-x64": "0.46.0",
114
+ "@introspection-ai/mcp-client-linux-arm64": "0.46.0",
115
+ "@introspection-ai/mcp-client-darwin-arm64": "0.46.0",
116
+ "@introspection-ai/mcp-client-darwin-x64": "0.46.0"
113
117
  },
114
118
  "peerDependencies": {
115
119
  "@earendil-works/pi-agent-core": ">=1.1.0 <2.0.0",