@juicesharp/rpiv-pi 2.8.0 → 2.10.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/extensions/rpiv-core/agent-enablement.ts +164 -0
- package/extensions/rpiv-core/agents.ts +98 -12
- package/extensions/rpiv-core/artifact-collector.ts +30 -7
- package/extensions/rpiv-core/built-in-workflows.ts +370 -96
- package/extensions/rpiv-core/built-ins/citations.ts +9 -0
- package/extensions/rpiv-core/built-ins/design.ts +64 -0
- package/extensions/rpiv-core/built-ins/elaboration.ts +53 -0
- package/extensions/rpiv-core/built-ins/gates.ts +282 -12
- package/extensions/rpiv-core/built-ins/grade-panel.ts +54 -26
- package/extensions/rpiv-core/built-ins/index.ts +20 -1
- package/extensions/rpiv-core/built-ins/markdown-fence.ts +26 -1
- package/extensions/rpiv-core/built-ins/plan-phases.ts +8 -0
- package/extensions/rpiv-core/built-ins/priors.ts +9 -2
- package/extensions/rpiv-core/built-ins/reconcile-directives.d.mts +29 -0
- package/extensions/rpiv-core/built-ins/reconcile-directives.mjs +338 -0
- package/extensions/rpiv-core/built-ins/reconcile.ts +88 -130
- package/extensions/rpiv-core/built-ins/remediation.ts +60 -7
- package/extensions/rpiv-core/built-ins/scope-checks.ts +74 -11
- package/extensions/rpiv-core/built-ins/shared.ts +5 -3
- package/extensions/rpiv-core/built-ins/slice-checks.ts +164 -28
- package/extensions/rpiv-core/built-ins/slices.ts +44 -13
- package/extensions/rpiv-core/built-ins/verdict-collector.ts +207 -0
- package/extensions/rpiv-core/built-ins/verdict-outcome.ts +36 -0
- package/extensions/rpiv-core/frontmatter.ts +22 -0
- package/extensions/rpiv-core/lane-list.ts +10 -1
- package/extensions/rpiv-core/lane-progress.ts +1 -1
- package/extensions/rpiv-core/lane-usage.ts +1 -1
- package/extensions/rpiv-core/models-config.ts +86 -6
- package/extensions/rpiv-core/models-picker.ts +4 -3
- package/extensions/rpiv-core/package-checks.ts +13 -0
- package/extensions/rpiv-core/run-lane-registry.ts +1 -2
- package/extensions/rpiv-core/sdk-workflow-host.ts +20 -4
- package/extensions/rpiv-core/session-hooks.ts +1 -1
- package/extensions/rpiv-core/workflow-execution-host.ts +3 -2
- package/package.json +4 -3
- package/skills/_shared/reconcile-lint.mjs +125 -0
- package/skills/_shared/stitch-elaborations.mjs +282 -21
- package/skills/acceptance/SKILL.md +3 -2
- package/skills/amend/SKILL.md +5 -5
- package/skills/design-slice/SKILL.md +5 -0
- package/skills/elaborate/SKILL.md +13 -6
- package/skills/grade/SKILL.md +15 -12
- package/skills/implement/SKILL.md +17 -2
- package/skills/research/SKILL.md +1 -1
- package/skills/slice/SKILL.md +2 -2
- package/skills/synthesize/SKILL.md +1 -1
- package/skills/validate/SKILL.md +14 -0
|
@@ -194,7 +194,7 @@ export async function registerLaneProgress(): Promise<void> {
|
|
|
194
194
|
units: info.units ? { done: 0, total: info.units.length } : undefined,
|
|
195
195
|
});
|
|
196
196
|
},
|
|
197
|
-
//
|
|
197
|
+
// Materialize a per-unit
|
|
198
198
|
// sub-row (label + running) for fan-out units ONLY. The host publishes the
|
|
199
199
|
// live session separately (setCurrentSession at this index); both upsert the
|
|
200
200
|
// same key in either order. The lifecycle bus is the sole cross-package channel.
|
|
@@ -33,7 +33,7 @@ export interface LaneUsage {
|
|
|
33
33
|
/** Scalar cost, USD (`SessionStats.cost`). Optional — surfaced when present. */
|
|
34
34
|
cost?: number;
|
|
35
35
|
/** Context-window fill %, or `null` if unknown post-compaction
|
|
36
|
-
* (`SessionStats.contextUsage.percent`). Optional —
|
|
36
|
+
* (`SessionStats.contextUsage.percent`). Optional — the lane progress UI renders `CH%`. */
|
|
37
37
|
percent?: number | null;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -58,10 +58,12 @@ const _persistableLevelsMatchPiAi: _PersistableLevelsMatchPiAi = true;
|
|
|
58
58
|
* Background-lane concurrency cap fallback. The fail-soft default applied by
|
|
59
59
|
* `resolveMaxConcurrency` when `~/.config/rpiv-pi/models.json` is absent or
|
|
60
60
|
* carries no valid `maxConcurrency`. Rate limits, not CPU, are the real cap —
|
|
61
|
-
*
|
|
61
|
+
* 6 lanes clears the widest built-in fanout batch (the 5-dimension grade
|
|
62
|
+
* panel, which a cap of 4 split into a 4+1 second batch on every panel) with
|
|
63
|
+
* one lane of headroom; no rate-limit events were observed at 4. Re-exported from
|
|
62
64
|
* packages/rpiv-pi/extensions/rpiv-core/workflow-execution-host.ts to preserve the tested public surface.
|
|
63
65
|
*/
|
|
64
|
-
export const DEFAULT_MAX_CONCURRENCY =
|
|
66
|
+
export const DEFAULT_MAX_CONCURRENCY = 6;
|
|
65
67
|
|
|
66
68
|
// ---------------------------------------------------------------------------
|
|
67
69
|
// TypeBox schemas
|
|
@@ -106,6 +108,18 @@ const ModelEntrySchema = Type.Union(
|
|
|
106
108
|
}),
|
|
107
109
|
),
|
|
108
110
|
thinking: Type.Optional(ThinkingLevelSchema),
|
|
111
|
+
extensions: Type.Optional(
|
|
112
|
+
Type.Array(Type.String(), {
|
|
113
|
+
description:
|
|
114
|
+
"Sibling extension names the agent may load when installed (per-agent axis only — ignored in defaults)",
|
|
115
|
+
}),
|
|
116
|
+
),
|
|
117
|
+
tools: Type.Optional(
|
|
118
|
+
Type.Array(Type.String(), {
|
|
119
|
+
description:
|
|
120
|
+
"Tool selectors appended to the agent's tools frontmatter (per-agent axis only — ignored in defaults)",
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
109
123
|
},
|
|
110
124
|
{ additionalProperties: false },
|
|
111
125
|
),
|
|
@@ -172,6 +186,10 @@ export interface ResolvedModelConfig {
|
|
|
172
186
|
model?: string;
|
|
173
187
|
/** Explicit level incl. "off" (disable). Absent ⇒ inherit session/baseline. */
|
|
174
188
|
thinking?: ModelThinkingLevelValue;
|
|
189
|
+
/** Sibling extensions the agent may load when installed (per-agent axis only). */
|
|
190
|
+
extensions?: string[];
|
|
191
|
+
/** Tool selectors appended to the agent's tools frontmatter (per-agent axis only). */
|
|
192
|
+
tools?: string[];
|
|
175
193
|
}
|
|
176
194
|
|
|
177
195
|
/** The resolved config shape returned by loadModelsConfig. */
|
|
@@ -189,6 +207,24 @@ export interface ModelsConfig {
|
|
|
189
207
|
// Helper — resolve a ModelEntry (string or object) to ResolvedModelConfig.
|
|
190
208
|
// ---------------------------------------------------------------------------
|
|
191
209
|
|
|
210
|
+
/**
|
|
211
|
+
* String-filter salvage for the agent-axis arrays, hardened against
|
|
212
|
+
* frontmatter-line injection: keeps strings, drops non-strings silently (the
|
|
213
|
+
* standing salvage contract), and drops any string carrying `\n`/`\r` with a
|
|
214
|
+
* console.warn naming the field — such an entry would smuggle extra physical
|
|
215
|
+
* lines into a synced agent's frontmatter (see the call-site comment).
|
|
216
|
+
*/
|
|
217
|
+
function filterFrontmatterSafeStrings(values: readonly unknown[], field: "tools" | "extensions"): string[] {
|
|
218
|
+
const strings = values.filter((v): v is string => typeof v === "string");
|
|
219
|
+
const safe = strings.filter((v) => !/[\r\n]/.test(v));
|
|
220
|
+
if (safe.length !== strings.length) {
|
|
221
|
+
console.warn(
|
|
222
|
+
`[rpiv-pi] models.json: dropped ${strings.length - safe.length} \`${field}\` entr${strings.length - safe.length === 1 ? "y" : "ies"} containing newline characters — a multi-line entry would inject frontmatter lines into synced agent definitions`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return safe;
|
|
226
|
+
}
|
|
227
|
+
|
|
192
228
|
/** Resolve a raw ModelEntry value to a ResolvedModelConfig. */
|
|
193
229
|
function resolveModelEntry(entry: unknown): ResolvedModelConfig {
|
|
194
230
|
if (typeof entry === "string") {
|
|
@@ -209,6 +245,21 @@ function resolveModelEntry(entry: unknown): ResolvedModelConfig {
|
|
|
209
245
|
);
|
|
210
246
|
}
|
|
211
247
|
}
|
|
248
|
+
// Agent-axis fields: per-field string-filter salvage — an array value
|
|
249
|
+
// survives with non-string elements dropped (an explicit [] is meaningful:
|
|
250
|
+
// it suppresses the map default downstream); a non-array value drops the
|
|
251
|
+
// field entirely (falls back to map defaults). Entries carrying \n/\r are
|
|
252
|
+
// dropped LOUDLY: these strings land on one logical frontmatter line of
|
|
253
|
+
// ~/.pi/agent/agents/*.md, where an interior newline becomes a physical
|
|
254
|
+
// line the Pi runtime reads as agent capability config — a copy-paste
|
|
255
|
+
// artifact like "x\nisolated: false" would silently un-isolate an agent
|
|
256
|
+
// (review 2026-08-31 S1).
|
|
257
|
+
if (Array.isArray(obj.tools)) {
|
|
258
|
+
result.tools = filterFrontmatterSafeStrings(obj.tools, "tools");
|
|
259
|
+
}
|
|
260
|
+
if (Array.isArray(obj.extensions)) {
|
|
261
|
+
result.extensions = filterFrontmatterSafeStrings(obj.extensions, "extensions");
|
|
262
|
+
}
|
|
212
263
|
return result;
|
|
213
264
|
}
|
|
214
265
|
return {};
|
|
@@ -231,6 +282,29 @@ export function loadModelsConfig(): ModelsConfig {
|
|
|
231
282
|
const validated = validateConfig(ModelsConfigSchema, raw);
|
|
232
283
|
|
|
233
284
|
const defaults = resolvedEntry(validated.defaults);
|
|
285
|
+
// Agent-axis-only fields never cascade: strip them from `defaults` (one
|
|
286
|
+
// warn) so the {...defaults, ...resolved} cascade and the
|
|
287
|
+
// getAgentModelConfig defaults fallback cannot leak enablement to every
|
|
288
|
+
// configured agent.
|
|
289
|
+
if (defaults && (defaults.extensions !== undefined || defaults.tools !== undefined)) {
|
|
290
|
+
console.warn("[rpiv-pi] models.json: `extensions`/`tools` in `defaults` are ignored — they are per-agent fields");
|
|
291
|
+
delete defaults.extensions;
|
|
292
|
+
delete defaults.tools;
|
|
293
|
+
}
|
|
294
|
+
// The SAME strip on every other non-agents axis (review 2026-08-31 I3):
|
|
295
|
+
// the shared ModelEntrySchema admits `tools`/`extensions` everywhere, but
|
|
296
|
+
// only the agents-axis lookup consumes them — a stages/skills/preset entry
|
|
297
|
+
// carrying them passed validation and silently granted nothing. One warn
|
|
298
|
+
// per load, naming the offending axes.
|
|
299
|
+
const strippedAxes = new Set<string>();
|
|
300
|
+
const stripAgentAxisFields = (entry: ResolvedModelConfig, axis: string): ResolvedModelConfig => {
|
|
301
|
+
if (entry.extensions !== undefined || entry.tools !== undefined) {
|
|
302
|
+
strippedAxes.add(axis);
|
|
303
|
+
delete entry.extensions;
|
|
304
|
+
delete entry.tools;
|
|
305
|
+
}
|
|
306
|
+
return entry;
|
|
307
|
+
};
|
|
234
308
|
const agents: Record<string, ResolvedModelConfig> = {};
|
|
235
309
|
const stages: Record<string, ResolvedModelConfig> = {};
|
|
236
310
|
const skills: Record<string, ResolvedModelConfig> = {};
|
|
@@ -244,13 +318,13 @@ export function loadModelsConfig(): ModelsConfig {
|
|
|
244
318
|
|
|
245
319
|
if (validated.stages && typeof validated.stages === "object") {
|
|
246
320
|
for (const [name, entry] of Object.entries(validated.stages)) {
|
|
247
|
-
stages[name] = resolvedEntryWithCascade(entry, defaults);
|
|
321
|
+
stages[name] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "stages");
|
|
248
322
|
}
|
|
249
323
|
}
|
|
250
324
|
|
|
251
325
|
if (validated.skills && typeof validated.skills === "object") {
|
|
252
326
|
for (const [name, entry] of Object.entries(validated.skills)) {
|
|
253
|
-
skills[name] = resolvedEntryWithCascade(entry, defaults);
|
|
327
|
+
skills[name] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "skills");
|
|
254
328
|
}
|
|
255
329
|
}
|
|
256
330
|
|
|
@@ -260,7 +334,7 @@ export function loadModelsConfig(): ModelsConfig {
|
|
|
260
334
|
const presetStages: Record<string, ResolvedModelConfig> = {};
|
|
261
335
|
if (presetBlock.stages && typeof presetBlock.stages === "object") {
|
|
262
336
|
for (const [stageName, entry] of Object.entries(presetBlock.stages)) {
|
|
263
|
-
presetStages[stageName] = resolvedEntryWithCascade(entry, defaults);
|
|
337
|
+
presetStages[stageName] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "presets");
|
|
264
338
|
}
|
|
265
339
|
}
|
|
266
340
|
if (Object.keys(presetStages).length > 0) {
|
|
@@ -269,6 +343,12 @@ export function loadModelsConfig(): ModelsConfig {
|
|
|
269
343
|
}
|
|
270
344
|
}
|
|
271
345
|
|
|
346
|
+
if (strippedAxes.size > 0) {
|
|
347
|
+
console.warn(
|
|
348
|
+
`[rpiv-pi] models.json: \`extensions\`/\`tools\` in ${[...strippedAxes].sort().join("/")} entries are ignored — they are per-agent fields (only \`agents.<name>\` consumes them)`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
272
352
|
const result: ModelsConfig = {
|
|
273
353
|
defaults,
|
|
274
354
|
agents: Object.keys(agents).length > 0 ? agents : undefined,
|
|
@@ -359,7 +439,7 @@ export function resolveStageModel(
|
|
|
359
439
|
|
|
360
440
|
/**
|
|
361
441
|
* Resolve the background-lane concurrency cap from `~/.config/rpiv-pi/models.json`.
|
|
362
|
-
* Returns `DEFAULT_MAX_CONCURRENCY` (
|
|
442
|
+
* Returns `DEFAULT_MAX_CONCURRENCY` (6) when the key is absent OR holds an invalid
|
|
363
443
|
* value (non-integer, < 1).
|
|
364
444
|
*
|
|
365
445
|
* NOTE: `Value.Clean` (typebox@1.3.6) does NOT strip invalid scalars — it only
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* models-picker — filterable select panel for /rpiv-models cascade pickers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* package (e.g. packages/rpiv-tui/) is
|
|
4
|
+
* Local clone of the advisor's showFilterablePicker (advisor-ui.ts) — the
|
|
5
|
+
* zero-cross-imports contract forbids an rpiv-core → rpiv-advisor import.
|
|
6
|
+
* Promotion to a shared TUI package (e.g. packages/rpiv-tui/) is a candidate
|
|
7
|
+
* follow-up.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import { DynamicBorder, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
@@ -17,3 +17,16 @@ export function findMissingSiblings(): SiblingPlugin[] {
|
|
|
17
17
|
const installed = result.packages.filter((e): e is string => typeof e === "string");
|
|
18
18
|
return SIBLINGS.filter((s) => !installed.some((entry) => s.matches.test(entry)));
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Return the SIBLINGS currently installed — the exact complement of
|
|
23
|
+
* findMissingSiblings over the same readPiAgentSettings() read. No settings
|
|
24
|
+
* file (or a packages array that isn't one) ⇒ [] — mirroring
|
|
25
|
+
* findMissingSiblings' all-missing fallback in the opposite direction.
|
|
26
|
+
*/
|
|
27
|
+
export function findInstalledSiblings(): SiblingPlugin[] {
|
|
28
|
+
const result = readPiAgentSettings();
|
|
29
|
+
if (!result) return [];
|
|
30
|
+
const installed = result.packages.filter((e): e is string => typeof e === "string");
|
|
31
|
+
return SIBLINGS.filter((s) => installed.some((entry) => s.matches.test(entry)));
|
|
32
|
+
}
|
|
@@ -88,8 +88,7 @@ export interface PendingInput {
|
|
|
88
88
|
export const SINGLE_UNIT_KEY = -1;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* One fan-out unit's switchable sub-lane. Bundles
|
|
92
|
-
* live as a single scalar on `LaneEntry` — the live child session, the terminal
|
|
91
|
+
* One fan-out unit's switchable sub-lane. Bundles the live child session, the terminal
|
|
93
92
|
* snapshot (branch/cwd/tool-defs), the durable disk-fallback pointer, and the
|
|
94
93
|
* deferred-input queue — so each concurrent unit owns its own slot keyed by its
|
|
95
94
|
* declared fan-out `index`. Under fan-out a sibling's teardown can never clobber
|
|
@@ -159,8 +159,13 @@ export function withoutAmbientExtensions(base: LoadExtensionsResult): LoadExtens
|
|
|
159
159
|
* the dir from cwd+runId and hands rpiv-pi the concrete path.
|
|
160
160
|
*/
|
|
161
161
|
export interface SdkWorkflowHostDeps {
|
|
162
|
-
/**
|
|
163
|
-
|
|
162
|
+
/**
|
|
163
|
+
* The interactive ctx — observer (sessionManager reads) + the hasUI source.
|
|
164
|
+
* Deliberately NOT the toast channel: every `live` member is a pi getter that
|
|
165
|
+
* throws stale once the launcher session is replaced/disposed mid-run, so
|
|
166
|
+
* toasts route through the raw `uiContext` below instead (see `relayUi`).
|
|
167
|
+
*/
|
|
168
|
+
live: Pick<WorkflowHostContext, "sessionManager" | "hasUI">;
|
|
164
169
|
/** Borrowed at session_start (carries auth/OAuth state). */
|
|
165
170
|
modelRegistry: ModelRegistry;
|
|
166
171
|
/** The real launcher UI the deferring relay forwards to (captured at session_start). */
|
|
@@ -459,7 +464,9 @@ export class SdkWorkflowHost implements WorkflowHostContext {
|
|
|
459
464
|
private adapt(session: AgentSession, depth: number, watchdog: BashWatchdog): WorkflowSessionContext {
|
|
460
465
|
return {
|
|
461
466
|
cwd: this.cwd,
|
|
462
|
-
|
|
467
|
+
// Constructor snapshot, not a fresh `live.hasUI` getter read — adapt
|
|
468
|
+
// runs mid-run, when the launcher ctx may already be stale.
|
|
469
|
+
hasUI: this.hasUI,
|
|
463
470
|
ui: this.relayUi(),
|
|
464
471
|
maxConcurrency: this.maxConcurrency,
|
|
465
472
|
// A child may itself fan out — each level increments the depth, bounded
|
|
@@ -513,9 +520,18 @@ export class SdkWorkflowHost implements WorkflowHostContext {
|
|
|
513
520
|
: undefined;
|
|
514
521
|
}
|
|
515
522
|
|
|
523
|
+
/**
|
|
524
|
+
* Toasts go through the session_start-captured RAW uiContext, never a
|
|
525
|
+
* guarded `live.ui` getter read: the stage machinery and audit paths notify
|
|
526
|
+
* mid-run — long after `/wf` returned — and pi invalidates every ctx getter
|
|
527
|
+
* of the old generation on launcher session replacement (/new, resume,
|
|
528
|
+
* /reload, auto-compaction). The raw object survives replacement and still
|
|
529
|
+
* points at the persistent TUI, so a floated run's progress/completion
|
|
530
|
+
* toasts can't throw the stale-ctx error out of the runner.
|
|
531
|
+
*/
|
|
516
532
|
private relayUi() {
|
|
517
533
|
return {
|
|
518
|
-
notify: (message: string, level?: "info" | "warning" | "error") => this.deps.
|
|
534
|
+
notify: (message: string, level?: "info" | "warning" | "error") => this.deps.uiContext.notify(message, level),
|
|
519
535
|
};
|
|
520
536
|
}
|
|
521
537
|
}
|
|
@@ -97,7 +97,7 @@ export function createWorkflowExecution(
|
|
|
97
97
|
cwd: observer.cwd,
|
|
98
98
|
runId,
|
|
99
99
|
childSessionsDir, // resolved by the runner; rpiv-pi does not synthesize the path
|
|
100
|
-
maxConcurrency: resolveMaxConcurrency(loadModelsConfig()), // config-driven background-lane cap (default
|
|
100
|
+
maxConcurrency: resolveMaxConcurrency(loadModelsConfig()), // config-driven background-lane cap (default 6)
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// Record this run as a switchable lane at launch (appears in the ambient
|
|
@@ -177,7 +177,8 @@ export async function registerWorkflowExecutionHostProvider(): Promise<void> {
|
|
|
177
177
|
const { registerWorkflowExecutionHost } = await import("@juicesharp/rpiv-workflow/startup");
|
|
178
178
|
registerWorkflowExecutionHost({
|
|
179
179
|
createHost: createWorkflowExecution,
|
|
180
|
-
resolveModel: ({ stage, skill }) =>
|
|
180
|
+
resolveModel: ({ workflow, stage, skill }) =>
|
|
181
|
+
toModelSelection(resolveStageModel(loadModelsConfig(), { workflow, stage, skill })),
|
|
181
182
|
// Death-scene reader — re-open the just-failed session's persisted JSONL
|
|
182
183
|
// and return its branch, narrowed to the workflow-owned BranchEntry shape
|
|
183
184
|
// (the SDK's SessionEntry union carries private discriminators — the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-pi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
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",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"!docs/*.svg",
|
|
39
39
|
"README.md",
|
|
40
40
|
"LICENSE",
|
|
41
|
-
"!**/*.test.ts"
|
|
41
|
+
"!**/*.test.ts",
|
|
42
|
+
"!extensions/rpiv-core/built-ins/__fixtures__/"
|
|
42
43
|
],
|
|
43
44
|
"pi": {
|
|
44
45
|
"image": "https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-pi/docs/cover.png",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
]
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@juicesharp/rpiv-config": "^2.
|
|
54
|
+
"@juicesharp/rpiv-config": "^2.10.0",
|
|
54
55
|
"typebox": "^1.1.24"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Pre-flight lint for `#### Reconciliation` directives — the deterministic
|
|
4
|
+
* `reconcile` gate's own parser (reconcile-directives.mjs, the same module
|
|
5
|
+
* extensions/rpiv-core/built-ins/reconcile.ts imports) run in check-only mode,
|
|
6
|
+
* so a directive that lints clean here parses and applies cleanly at the gate.
|
|
7
|
+
* The implement skill runs this after recording a directive and before printing
|
|
8
|
+
* its closing block: every finding caught here is one `/skill:amend` repair
|
|
9
|
+
* session plus a gate re-entry that never happens.
|
|
10
|
+
*
|
|
11
|
+
* Usage: node reconcile-lint.mjs <plan.md> [--phase <N>] [--root <dir>]
|
|
12
|
+
*
|
|
13
|
+
* <plan.md> the plan artifact carrying the `#### Reconciliation` section(s)
|
|
14
|
+
* --phase <N> lint only the `## Phase N:` section's directives (an implement
|
|
15
|
+
* phase checks its OWN directives without tripping over a
|
|
16
|
+
* sibling's); the declared write-set is still read from the
|
|
17
|
+
* whole plan
|
|
18
|
+
* --root <dir> repo root the targets resolve against (default: cwd)
|
|
19
|
+
*
|
|
20
|
+
* Checks per directive, mirroring the gate's failure classes: grammar
|
|
21
|
+
* (malformed attempts), containment (target must resolve inside the root),
|
|
22
|
+
* eligibility (target must be in the plan's declared write-set — the union of
|
|
23
|
+
* every phase's `files:`, twin-expanded; best-effort frontmatter scan, the
|
|
24
|
+
* gate holds the authoritative YAML parse), and find-presence against the
|
|
25
|
+
* target's CURRENT bytes — with the gate's already-applied /
|
|
26
|
+
* deletion-satisfied tolerances, so a legitimately-applied directive never
|
|
27
|
+
* false-fails. Language-agnostic: eligibility derives from the plan's own
|
|
28
|
+
* declarations, never from a filename convention. Read-only: never writes.
|
|
29
|
+
*
|
|
30
|
+
* Exit codes: 0 = clean; 1 = findings (each printed on its own line);
|
|
31
|
+
* 2 = usage / unreadable plan.
|
|
32
|
+
*/
|
|
33
|
+
import { readFileSync } from "node:fs";
|
|
34
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
35
|
+
import {
|
|
36
|
+
classifyApplication,
|
|
37
|
+
declaredWriteSet,
|
|
38
|
+
phaseSection,
|
|
39
|
+
reconciliationRecords,
|
|
40
|
+
} from "../../extensions/rpiv-core/built-ins/reconcile-directives.mjs";
|
|
41
|
+
|
|
42
|
+
const usage = () => {
|
|
43
|
+
console.error("usage: node reconcile-lint.mjs <plan.md> [--phase <N>] [--root <dir>]");
|
|
44
|
+
process.exit(2);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const args = process.argv.slice(2);
|
|
48
|
+
let planPath;
|
|
49
|
+
let phase;
|
|
50
|
+
let root = process.cwd();
|
|
51
|
+
for (let i = 0; i < args.length; i++) {
|
|
52
|
+
if (args[i] === "--phase") {
|
|
53
|
+
phase = args[++i];
|
|
54
|
+
if (phase === undefined) usage();
|
|
55
|
+
} else if (args[i] === "--root") {
|
|
56
|
+
root = args[++i];
|
|
57
|
+
if (root === undefined) usage();
|
|
58
|
+
} else if (planPath === undefined) {
|
|
59
|
+
planPath = args[i];
|
|
60
|
+
} else {
|
|
61
|
+
usage();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (planPath === undefined) usage();
|
|
65
|
+
|
|
66
|
+
let planBody;
|
|
67
|
+
try {
|
|
68
|
+
planBody = readFileSync(resolve(root, planPath), "utf-8");
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.error(`reconcile-lint: cannot read ${planPath} — ${err instanceof Error ? err.message : String(err)}`);
|
|
71
|
+
process.exit(2);
|
|
72
|
+
}
|
|
73
|
+
const declared = declaredWriteSet(planBody);
|
|
74
|
+
let scanBody = planBody;
|
|
75
|
+
if (phase !== undefined) {
|
|
76
|
+
const section = phaseSection(planBody, phase);
|
|
77
|
+
if (section === undefined) {
|
|
78
|
+
console.error(`reconcile-lint: no "## Phase ${phase}:" section in ${planPath}`);
|
|
79
|
+
process.exit(2);
|
|
80
|
+
}
|
|
81
|
+
scanBody = section;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { directives, malformed } = reconciliationRecords(scanBody);
|
|
85
|
+
const findings = [];
|
|
86
|
+
for (const m of malformed) {
|
|
87
|
+
findings.push(
|
|
88
|
+
"malformed directive — use one list item: - `<target>`: replace `<find>` → `<replace>` — <rationale> " +
|
|
89
|
+
"(no inner backticks in the spans), or the fenced form (- `<target>`: replace — <rationale>, then a find: " +
|
|
90
|
+
`line + fenced block, then a replace: line + fenced block) for content with backticks — offending item: ${m}`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
for (const d of directives) {
|
|
94
|
+
const abs = resolve(root, d.target);
|
|
95
|
+
const rel = relative(root, abs);
|
|
96
|
+
if (rel.startsWith("..") || isAbsolute(rel)) {
|
|
97
|
+
findings.push(`target ${d.target} resolves outside the working tree — use a repo-root-relative target`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!declared.has(d.target)) {
|
|
101
|
+
findings.push(
|
|
102
|
+
`target ${d.target} is not in the plan's declared write-set (the union of every phase's 'files:', twin-expanded) — the gate rejects undeclared targets; declare the file in the owning phase's 'files:' or route the edit through validate's remediation arm`,
|
|
103
|
+
);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
let content;
|
|
107
|
+
try {
|
|
108
|
+
content = readFileSync(abs, "utf-8");
|
|
109
|
+
} catch {
|
|
110
|
+
findings.push(`target ${d.target} is unreadable — the gate will fail this directive; check the path`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (classifyApplication(d, content) === "missing") {
|
|
114
|
+
findings.push(
|
|
115
|
+
`find substring not present in ${d.target} (and the replacement is absent) — Read the file and copy the find bytes verbatim; if the text carries backticks, use the fenced form`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (findings.length > 0) {
|
|
121
|
+
for (const f of findings) console.log(`reconcile-lint: ${f}`);
|
|
122
|
+
console.log(`reconcile-lint: FAIL — ${findings.length} finding(s) across ${directives.length} directive(s)`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
console.log(`reconcile-lint: OK — ${directives.length} directive(s), 0 findings`);
|