@juicesharp/rpiv-pi 2.14.0 → 2.14.2
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/extensions/rpiv-core/artifact-collector.ts +28 -10
- package/extensions/rpiv-core/built-ins/gate-rosters.ts +5 -1
- package/extensions/rpiv-core/built-ins/plan-cite.ts +1 -1
- package/extensions/rpiv-core/built-ins/priors.ts +60 -40
- package/package.json +2 -2
- package/skills/validate/SKILL.md +1 -1
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
* disk-corroborated basename fallback — when both scans miss (agent mangled
|
|
22
22
|
* the directory prefix in prose), a bare `<file>.md` token from the transcript
|
|
23
23
|
* is accepted iff it resolves to exactly one existing file under
|
|
24
|
-
* `.rpiv/artifacts/` — see that section below.
|
|
24
|
+
* `.rpiv/artifacts/` — see that section below. A scanned path that is not on
|
|
25
|
+
* disk yields to the newest announced full path that is (see `withDiskFallback`).
|
|
25
26
|
*
|
|
26
27
|
* One parser: `frontmatterParser` parses YAML frontmatter from the
|
|
27
28
|
* primary fs artifact into `Record<string, unknown>` — what
|
|
@@ -92,8 +93,8 @@ const RPIV_ARTIFACT_PATTERN = new RegExp(String.raw`\.rpiv/artifacts/${TEMPERED_
|
|
|
92
93
|
// fatal stands.
|
|
93
94
|
const BASENAME_PATTERN = new RegExp(String.raw`${TEMPERED_SEGMENT}\.md`, "g");
|
|
94
95
|
|
|
95
|
-
/**
|
|
96
|
-
function
|
|
96
|
+
/** Matches of `pattern` in assistant text, last-mentioned first, deduped. */
|
|
97
|
+
function textMentions(branch: BranchEntry[], pattern: RegExp, offsetStart?: number): string[] {
|
|
97
98
|
const out: string[] = [];
|
|
98
99
|
const seen = new Set<string>();
|
|
99
100
|
const start = Math.max(offsetStart ?? 0, 0);
|
|
@@ -105,7 +106,7 @@ function basenameCandidates(branch: BranchEntry[], offsetStart?: number): string
|
|
|
105
106
|
for (let j = content.length - 1; j >= 0; j--) {
|
|
106
107
|
const part = content[j]!;
|
|
107
108
|
if (part.type !== "text" || typeof part.text !== "string") continue;
|
|
108
|
-
const matches = part.text.match(
|
|
109
|
+
const matches = part.text.match(pattern) ?? [];
|
|
109
110
|
for (let k = matches.length - 1; k >= 0; k--) {
|
|
110
111
|
const m = matches[k]!;
|
|
111
112
|
if (!seen.has(m)) {
|
|
@@ -130,13 +131,29 @@ function resolveUnderArtifacts(cwd: string, basename: string, bucket?: string):
|
|
|
130
131
|
return buckets.filter((b) => existsSync(join(root, b, basename))).map((b) => `.rpiv/artifacts/${b}/${basename}`);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
/**
|
|
134
|
-
|
|
134
|
+
/** A handle path resolved against `cwd` when repo-relative. */
|
|
135
|
+
const absArtifactPath = (cwd: string, path: string): string => (isAbsolute(path) ? path : join(cwd, path));
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Full-path scan first. A scanned path that is not on disk — an agent that
|
|
139
|
+
* announced its own file and then cited a sibling's path it misremembered —
|
|
140
|
+
* yields to the newest announced full path that is on disk; with none, the
|
|
141
|
+
* scanned path stands and the parser fatals on it. On a scan miss, the
|
|
142
|
+
* disk-corroborated basename fallback.
|
|
143
|
+
*/
|
|
144
|
+
function withDiskFallback(primary: ArtifactCollector, pattern: RegExp, bucket?: string): ArtifactCollector {
|
|
135
145
|
return defineCollector({
|
|
136
146
|
collect: async (ctx) => {
|
|
137
147
|
const scanned = await primary.collect(ctx);
|
|
138
|
-
if (scanned.kind === "ok")
|
|
139
|
-
|
|
148
|
+
if (scanned.kind === "ok") {
|
|
149
|
+
const handle = scanned.artifacts[0]?.handle;
|
|
150
|
+
if (handle?.kind !== "fs" || existsSync(absArtifactPath(ctx.cwd, handle.path))) return scanned;
|
|
151
|
+
const onDisk = textMentions(ctx.branch, pattern, ctx.branchOffset).find((p) =>
|
|
152
|
+
existsSync(absArtifactPath(ctx.cwd, p)),
|
|
153
|
+
);
|
|
154
|
+
return onDisk ? { kind: "ok", artifacts: [{ handle: fsHandle(onDisk), role: "primary" }] } : scanned;
|
|
155
|
+
}
|
|
156
|
+
for (const basename of textMentions(ctx.branch, BASENAME_PATTERN, ctx.branchOffset)) {
|
|
140
157
|
const hits = resolveUnderArtifacts(ctx.cwd, basename, bucket);
|
|
141
158
|
if (hits.length === 1) {
|
|
142
159
|
return { kind: "ok", artifacts: [{ handle: fsHandle(hits[0]!), role: "primary" }] };
|
|
@@ -170,6 +187,7 @@ const TOOL_ARG_FALLBACK = { match: isFileWrite, argKeys: ["path"] as const };
|
|
|
170
187
|
/** Bucket-agnostic — accepts any `.rpiv/artifacts/<bucket>/...md`. */
|
|
171
188
|
export const rpivArtifactCollector: ArtifactCollector = withDiskFallback(
|
|
172
189
|
transcriptPathCollector({ pattern: RPIV_ARTIFACT_PATTERN, ...TOOL_ARG_FALLBACK }),
|
|
190
|
+
RPIV_ARTIFACT_PATTERN,
|
|
173
191
|
);
|
|
174
192
|
|
|
175
193
|
/** Bucket-narrowed — accepts only `.rpiv/artifacts/<bucket>/...md`. The filename
|
|
@@ -178,7 +196,7 @@ export const rpivArtifactCollector: ArtifactCollector = withDiskFallback(
|
|
|
178
196
|
export function rpivBucketCollector(bucket: string): ArtifactCollector {
|
|
179
197
|
const escaped = bucket.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
180
198
|
const pattern = new RegExp(String.raw`\.rpiv/artifacts/${escaped}/${TEMPERED_SEGMENT}\.md`, "g");
|
|
181
|
-
return withDiskFallback(transcriptPathCollector({ pattern, ...TOOL_ARG_FALLBACK }), bucket);
|
|
199
|
+
return withDiskFallback(transcriptPathCollector({ pattern, ...TOOL_ARG_FALLBACK }), pattern, bucket);
|
|
182
200
|
}
|
|
183
201
|
|
|
184
202
|
// ---------------------------------------------------------------------------
|
|
@@ -209,7 +227,7 @@ export const frontmatterParser: ArtifactParser<undefined, "artifact-md", Record<
|
|
|
209
227
|
message: `${ctx.skill}: frontmatterParser requires an fs artifact (got ${primary?.handle.kind ?? "none"})`,
|
|
210
228
|
};
|
|
211
229
|
}
|
|
212
|
-
const abs =
|
|
230
|
+
const abs = absArtifactPath(ctx.cwd, primary.handle.path);
|
|
213
231
|
if (!existsSync(abs)) {
|
|
214
232
|
return {
|
|
215
233
|
kind: "fatal",
|
|
@@ -225,6 +225,9 @@ export const planAuthoredRisks = (state: RunView, channel: string): Map<string,
|
|
|
225
225
|
return out;
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
+
/** `scripts/Makefile:18` — the `/` keeps `HTTP:80` out. Evidence-only: the shared regex also feeds the citation floor. */
|
|
229
|
+
const EXTENSIONLESS_FILE_LINE_RE = /(?<!\w)(?:\.?\/|\w[\w.-]*\/)+\w[\w.-]*:\d+/;
|
|
230
|
+
|
|
228
231
|
/**
|
|
229
232
|
* A mechanics-pass ruling's evidence duty: when the plan AUTHORED a
|
|
230
233
|
* `claim_type: "mechanics"` risk for the ruling's id, a `pass` ruling MUST
|
|
@@ -243,7 +246,8 @@ export const evidenceCitesFileLine = (r: RiskRuling, authored?: RiskRecord): boo
|
|
|
243
246
|
// A deferred claim may concern code the plan has not written yet, so its
|
|
244
247
|
// procedure + owner are the duty instead.
|
|
245
248
|
if (authored?.claim_type !== "mechanics" || authored.disposition === "verify-at-implement") return true;
|
|
246
|
-
|
|
249
|
+
if (typeof r.evidence !== "string") return false;
|
|
250
|
+
return r.evidence.match(FILE_LINE_CITATION_RE) !== null || EXTENSIONLESS_FILE_LINE_RE.test(r.evidence);
|
|
247
251
|
};
|
|
248
252
|
|
|
249
253
|
/**
|
|
@@ -49,7 +49,7 @@ const EXTENSIONLESS_FILENAME_RE =
|
|
|
49
49
|
* with a `:12-30` range appended — carries a line range the bare form rejects).
|
|
50
50
|
* Extensionless recognition is allowlist-only (never "any `/`-bearing token"):
|
|
51
51
|
* prose like `and/or` must not read as a declared write. The extension is
|
|
52
|
-
* bounded to 1–5 chars starting with a letter
|
|
52
|
+
* bounded to 1–5 chars starting with a letter, tighter than FILE_LINE_CITATION_RE,
|
|
53
53
|
* so a dotted IDENTIFIER (`deps.finalize` — an observed false coverage
|
|
54
54
|
* finding) never reads as a file. */
|
|
55
55
|
const isPathLike = (s: string): boolean => {
|
|
@@ -225,54 +225,74 @@ const sectionIndexOf = (lines: readonly string[]): string[] => {
|
|
|
225
225
|
return idx;
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
+
/** Group a document's lines by their `sectionIndexOf` key, preserving order within each section. */
|
|
229
|
+
const linesBySection = (lines: readonly string[]): Map<string, string[]> => {
|
|
230
|
+
const keys = sectionIndexOf(lines);
|
|
231
|
+
const out = new Map<string, string[]>();
|
|
232
|
+
for (let i = 0; i < lines.length; i++) {
|
|
233
|
+
const run = out.get(keys[i]);
|
|
234
|
+
if (run) run.push(lines[i]);
|
|
235
|
+
else out.set(keys[i], [lines[i]]);
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
};
|
|
239
|
+
|
|
228
240
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* document. Returns the union of touched section keys and a coarse changed-line
|
|
233
|
-
* count (deletions + insertions). Insertion-tolerant: a 1-line insert does not
|
|
234
|
-
* mark every trailing line changed (the LCS keeps shared context matched).
|
|
241
|
+
* LCS length of two line sequences. The common prefix and suffix are counted
|
|
242
|
+
* directly and trimmed, so the O(n·m) time is spent only on the edited span,
|
|
243
|
+
* and two `Uint32Array` rows stand in for the full table: memory is O(m).
|
|
235
244
|
*/
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
const lcsLength = (a: readonly string[], b: readonly string[]): number => {
|
|
246
|
+
let lo = 0;
|
|
247
|
+
while (lo < a.length && lo < b.length && a[lo] === b[lo]) lo++;
|
|
248
|
+
let ha = a.length;
|
|
249
|
+
let hb = b.length;
|
|
250
|
+
while (ha > lo && hb > lo && a[ha - 1] === b[hb - 1]) {
|
|
251
|
+
ha--;
|
|
252
|
+
hb--;
|
|
253
|
+
}
|
|
254
|
+
const shared = lo + (a.length - ha);
|
|
255
|
+
const n = ha - lo;
|
|
256
|
+
const m = hb - lo;
|
|
257
|
+
if (n === 0 || m === 0) return shared;
|
|
258
|
+
let prev = new Uint32Array(m + 1);
|
|
259
|
+
let cur = new Uint32Array(m + 1);
|
|
260
|
+
for (let i = 1; i <= n; i++) {
|
|
261
|
+
const ai = a[lo + i - 1];
|
|
262
|
+
for (let j = 1; j <= m; j++) {
|
|
263
|
+
cur[j] = ai === b[lo + j - 1] ? prev[j - 1] + 1 : Math.max(prev[j], cur[j - 1]);
|
|
246
264
|
}
|
|
265
|
+
[prev, cur] = [cur, prev];
|
|
247
266
|
}
|
|
267
|
+
return shared + prev[m];
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Line-level diff of `prior` vs `current` plan bodies, mapped to plan sections.
|
|
272
|
+
* Lines are grouped by their `## ` section key (`sectionIndexOf`, in their own
|
|
273
|
+
* document) and each section is diffed only against its counterpart, so memory
|
|
274
|
+
* scales with the largest section, not the whole plan — an out-of-memory kill
|
|
275
|
+
* is not an exception, and `decideSurgicalFix`'s catch could not fail closed on
|
|
276
|
+
* it. A section is touched when its prior and current lines differ; the
|
|
277
|
+
* changed-line count is deletions + insertions summed over sections
|
|
278
|
+
* (`|prior| + |current| − 2·LCS`). Insertion-tolerant: a 1-line insert does not
|
|
279
|
+
* mark every trailing line changed. A line moved between sections counts as a
|
|
280
|
+
* deletion in one and an insertion in the other, the fail-closed direction.
|
|
281
|
+
*/
|
|
282
|
+
const sectionDiff = (prior: string, current: string): { touchedSections: Set<string>; changedLines: number } => {
|
|
283
|
+
const pa = linesBySection(prior.split("\n"));
|
|
284
|
+
const pb = linesBySection(current.split("\n"));
|
|
248
285
|
const touched = new Set<string>();
|
|
249
286
|
let changed = 0;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
touched.add(sa[i]); // a[i] deleted (present in prior, absent in current)
|
|
258
|
-
changed++;
|
|
259
|
-
i++;
|
|
260
|
-
} else {
|
|
261
|
-
touched.add(sb[j]); // b[j] inserted (present in current, absent in prior)
|
|
262
|
-
changed++;
|
|
263
|
-
j++;
|
|
287
|
+
for (const key of new Set([...pa.keys(), ...pb.keys()])) {
|
|
288
|
+
const a = pa.get(key) ?? [];
|
|
289
|
+
const b = pb.get(key) ?? [];
|
|
290
|
+
const delta = a.length + b.length - 2 * lcsLength(a, b);
|
|
291
|
+
if (delta > 0) {
|
|
292
|
+
touched.add(key);
|
|
293
|
+
changed += delta;
|
|
264
294
|
}
|
|
265
295
|
}
|
|
266
|
-
while (i < a.length) {
|
|
267
|
-
touched.add(sa[i]);
|
|
268
|
-
changed++;
|
|
269
|
-
i++;
|
|
270
|
-
}
|
|
271
|
-
while (j < b.length) {
|
|
272
|
-
touched.add(sb[j]);
|
|
273
|
-
changed++;
|
|
274
|
-
j++;
|
|
275
|
-
}
|
|
276
296
|
return { touchedSections: touched, changedLines: changed };
|
|
277
297
|
};
|
|
278
298
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-pi",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.2",
|
|
4
4
|
"description": "A skill-based development workflow for Pi Agent. 30 contract-carrying skills (discover → research → design → plan → implement → validate → code-review → commit, and more), the 15 named subagents they dispatch, and four built-in /wf workflows that chain them end to end in detached parallel runs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@juicesharp/rpiv-config": "^2.14.
|
|
55
|
+
"@juicesharp/rpiv-config": "^2.14.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@earendil-works/pi-ai": "*",
|
package/skills/validate/SKILL.md
CHANGED
|
@@ -161,7 +161,7 @@ For each phase in the plan:
|
|
|
161
161
|
### Step 3: Write the Validation Report
|
|
162
162
|
|
|
163
163
|
1. **Determine metadata** (from the Metadata block at the top of this skill):
|
|
164
|
-
- Filename: `.rpiv/artifacts/validation/<slug>_<plan-
|
|
164
|
+
- Filename: `.rpiv/artifacts/validation/<slug>_<plan-name>.md` — `<slug>` is the second tab-separated field on line 1 of the Metadata block above; `<plan-name>` is the plan file's basename without its leading timestamp and `.md` (plan `2026-10-15_13-56-46_tkt-1234-widget-sync.md` → `tkt-1234-widget-sync`). Never build it from the plan's `topic:` value: its em dashes, parentheses and commas make a path the workflow cannot collect.
|
|
165
165
|
- `repository:` ← `repo:` label; `branch:` / `commit:` ← matching labels.
|
|
166
166
|
- `date:` ← `<iso>` (first tab-separated field on line 1 of the Metadata block above, offset verbatim).
|
|
167
167
|
- `author:` ← matching label (fallback: `unknown`).
|