repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

refactor(modernize): keep file lists out of audit output

a71c49d533c8eec5d39f039e36e39a406caef0ec

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (5)

.pi/skills/modernize/SKILL.md

Modified
2 2 name: modernize
3 3 description: "Audit this repository against the latest published Pi changelog and APIs. Use when checking for obsolete Pi extension, SDK, config, prompt, skill, model, session, tool, TUI, or provider code."
4 +disable-model-invocation: true
6 7 # Modernize
21 22 Do not scan, claim clean, or print celebratory art.
23 24 3. Treat the JSON as collected evidence, not conclusions.
24 - Check both changelog sources and every candidate in `candidates`.
25 + Use tools to read both locations in `changelogs`, then check every candidate in `candidates`.
26 27 4. Normalize each candidate against latest Pi truth:
27 28 - read the candidate's linked current documentation when present;
29 30 - identify exact obsolete and replacement code shapes;
30 31 - discard provider catalog, prose, and bug-fix entries that require no repository migration.
32 -5. Scan every path in `files` for each normalized obsolete shape.
33 - Use `grep`, then `read` every match and relevant callers.
34 - Skip binary content, but never silently narrow the returned file set.
33 +5. Obtain the complete scan scope from `git ls-files -z --cached --others --exclude-standard`.
34 + Pipe or chunk its NUL-delimited paths directly into searches; never print the full list into context.
35 + If enumeration fails, stop and report `MODERNIZE FAILED` with the exact reason.
36 + Search that complete scope for each normalized obsolete shape with `grep`, then `read` every match and relevant caller.
37 + Skip binary content, but never silently narrow the enumerated file set.
35 38 Optional user focus prioritizes inspection only; whole-repository coverage remains mandatory.
37 40 6. Confirm a finding only when both are present:

.pi/skills/modernize/scripts/audit.mjs

Modified
1 1 #!/usr/bin/env node
3 3 import { spawnSync } from "node:child_process";
4 -import { createHash } from "node:crypto";
5 4 import {
6 5 accessSync,
7 6 constants,
140 -export function parseGitFiles(raw) {
141 - return raw.split("\0").filter(Boolean);
144 139 function run(command, args, options = {}) {
145 140 const result = spawnSync(command, args, {
146 141 encoding: "utf8",
208 203 return response.text();
211 -function source(kind, location, text) {
212 - return {
213 - kind,
214 - location,
215 - bytes: Buffer.byteLength(text),
216 - sha256: createHash("sha256").update(text).digest("hex"),
217 - };
220 206 function oldestVersion(packages, fallback) {
221 207 return packages.reduce(
222 208 (oldest, item) =>
229 +export function createReport({
230 + piVersion,
231 + candidatesAfterVersion,
232 + localChangelogPath,
233 + remoteChangelogUrl,
234 + candidates,
235 +}) {
236 + return {
237 + schemaVersion: 2,
238 + status: "ok",
239 + piVersion,
240 + candidatesAfterVersion,
241 + changelogs: {
242 + installed: localChangelogPath,
243 + remote: remoteChangelogUrl,
244 + },
245 + candidates,
246 + };
243 249 async function main() {
244 250 const repo = process.cwd();
245 251 const executable = executableOnPath("pi");
273 279 candidates: extractCandidates(remoteChangelog, interval),
276 - const files = parseGitFiles(
277 - run(
278 - "git",
279 - ["ls-files", "-z", "--cached", "--others", "--exclude-standard"],
280 - {
281 - cwd: repo,
282 - },
283 - ),
284 - );
286 282 process.stdout.write(
287 283 `${JSON.stringify(
288 - {
289 - schemaVersion: 1,
290 - status: "ok",
291 - repo,
292 - local: { version: localVersion, executable },
293 - latest: { version: latestVersion, registry: REGISTRY_URL },
294 - interval,
295 - packages,
296 - sources: [
297 - source("installed", localChangelogPath, localChangelog),
298 - source("remote", remoteChangelogUrl, remoteChangelog),
299 - ],
284 + createReport({
285 + piVersion: latestVersion,
286 + candidatesAfterVersion: afterVersion,
287 + localChangelogPath,
288 + remoteChangelogUrl,
300 289 candidates,
301 - files,
302 - },
303 - null,
304 - 2,
290 + }),
305 291 )}\n`,
313 299 main().catch((error) => {
314 300 process.stderr.write(
315 301 `${JSON.stringify({
316 - schemaVersion: 1,
302 + schemaVersion: 2,
317 303 status: "failed",
318 304 reason: error instanceof Error ? error.message : String(error),
319 305 })}\n`,

.pi/skills/modernize/scripts/audit.test.mjs

Modified
4 4 import assert from "node:assert/strict";
5 5 import test from "node:test";
6 6 import {
7 7 assertLatest,
8 8 collectPackageVersions,
9 9 compareVersions,
10 + createReport,
10 11 extractCandidates,
11 12 parseChangelog,
12 - parseGitFiles,
13 13 } from "./audit.mjs";
15 15 const changelog = `# Changelog
102 -test("parses Git NUL file lists", () => {
103 - assert.deepEqual(parseGitFiles("a.ts\0dir/b.md\0\0"), ["a.ts", "dir/b.md"]);
102 +test("reports only evidence needed before tool-driven inspection", () => {
103 + assert.deepEqual(
104 + createReport({
105 + piVersion: "2.0.0",
106 + candidatesAfterVersion: "1.5.0",
107 + localChangelogPath: "/pi/CHANGELOG.md",
108 + remoteChangelogUrl: "https://example.test/CHANGELOG.md",
109 + candidates: [{ version: "2.0.0", text: "Replace alpha." }],
110 + }),
112 + schemaVersion: 2,
113 + status: "ok",
114 + piVersion: "2.0.0",
115 + candidatesAfterVersion: "1.5.0",
116 + changelogs: {
117 + installed: "/pi/CHANGELOG.md",
118 + remote: "https://example.test/CHANGELOG.md",
119 + },
120 + candidates: [{ version: "2.0.0", text: "Replace alpha." }],
121 + },
122 + );

docs/super/plans/2026-07-13-modernize-prompt.md

Modified
4 4 # Modernize Prompt Implementation Plan
6 6 > **For agentic workers:** REQUIRED SUB-SKILL: Use /skill:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
8 8 **Goal:** Add a project-local `/modernize` audit that fails on stale installed Pi, derives migrations from current local and remote changelogs, scans the repository, and celebrates a clean result with ASCII art.
10 -**Architecture:** A Node standard-library script performs deterministic version, changelog, package-lock, candidate, and Git file-set collection. A project skill validates candidates semantically against latest Pi docs/source and scans code. A thin prompt invokes the skill and defines output behavior.
10 +**Architecture:** A Node standard-library script performs deterministic version, changelog, package-lock, and candidate collection. A project skill validates candidates semantically against latest Pi docs/source, enumerates the Git file set with tools, and scans code. A thin prompt invokes the skill and defines output behavior.
12 12 **Tech Stack:** Pi prompt templates, Agent Skills, Node 26, `node:test`, Git, npm registry, GitHub raw changelog
26 26 - [x] **Step 1: Write failing Node tests**
28 -Cover release-section parsing, migration-section extraction, keyword extraction, ordinary-note exclusion, stale installed-version rejection, semantic version ordering, malformed changelog rejection, package-lock Pi version collection, and Git file-list parsing.
28 +Cover release-section parsing, migration-section extraction, keyword extraction, ordinary-note exclusion, stale installed-version rejection, semantic version ordering, malformed changelog rejection, package-lock Pi version collection, and minimal report shaping.
30 30 - [x] **Step 2: Run tests to verify RED**
48 48 - rejects local/latest mismatch;
49 49 - reads `package-lock.json` Pi package versions;
50 50 - extracts candidates newer than the oldest repo-resolved Pi package;
51 -- lists tracked and non-ignored untracked files through Git;
52 -- emits JSON only;
51 +- emits only versions, changelog locations, and candidates as compact JSON;
53 52 - writes no files.
55 54 - [x] **Step 4: Run tests to verify GREEN**
74 73 - [x] **Step 1: Create the skill**
76 -Define a read-only workflow that runs `node .pi/skills/modernize/scripts/audit.mjs`, stops on preflight failure, verifies every candidate against latest Pi docs/source, scans every returned repository file, inspects callers, and reports evidence-backed findings only.
75 +Define a read-only workflow that runs `node .pi/skills/modernize/scripts/audit.mjs`, stops on preflight failure, verifies every candidate against latest Pi docs/source, enumerates every repository file with Git, inspects callers, and reports evidence-backed findings only.
78 77 - [x] **Step 2: Create the prompt**
111 110 node .pi/skills/modernize/scripts/audit.mjs > /tmp/pi-modernize-audit.json
114 -Assert local/latest equality, both changelog sources, candidate count, resolved package versions, and repository file count with `jq`.
113 +Assert the Pi version, both changelog locations, candidate range, and candidate count with `jq`.
116 115 - [x] **Step 2: Run real Pi prompt**

docs/super/specs/2026-07-13-modernize-prompt-design.md

Modified
55 55 - reads repo-resolved `@earendil-works/pi-*` package versions from `package-lock.json`;
56 56 - parses version sections;
57 57 - extracts migration candidates from Breaking Changes, Changed, Removed, and Deprecated sections plus migration-keyword bullets;
58 -- lists Git-tracked and non-ignored untracked files for the semantic scan;
59 -- emits one JSON object to stdout and diagnostics to stderr;
58 +- emits only versions, changelog locations, and migration candidates as compact JSON;
59 +- leaves repository enumeration and content retrieval to later agent tool calls;
60 +- writes diagnostics to stderr;
60 61 - writes no files.
62 63 The installed CLI is the authoritative “local Pi” for the required latest-version gate.
83 84 ## Repository scan
85 -The script obtains the file set with Git rather than recursive filesystem traversal.
86 +The skill obtains the file set with Git rather than receiving every path in the collector output.
86 87 This includes tracked files and non-ignored untracked files while excluding `.git`, ignored caches, dependencies, and generated outputs.
88 89 The skill searches all candidate shapes across that file set, then reads each match and its callers before deciding whether migration is required.
127 128 - installed Pi is not latest;
128 129 - the canonical latest changelog cannot be fetched;
129 130 - changelog parsing yields no release sections;
130 -- Git cannot enumerate the repository.
131 +- later Git enumeration cannot enumerate the repository.
132 133 A failed preflight produces no clean verdict and no celebratory art.