@juicesharp/rpiv-pi 2.5.2 → 2.6.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.
@@ -107,12 +107,13 @@ your current session model stays sovereign for anything you invoke by hand.
107
107
 
108
108
  ### Reasoning levels
109
109
 
110
- Six values are accepted in `thinking`: `off`, `minimal`, `low`, `medium`, `high`,
111
- `xhigh`. Omitting the field and setting it to `off` are different: omitting inherits the
112
- session baseline, `off` explicitly disables reasoning. Anything else is warned about:
110
+ `thinking` accepts the explicit `off` plus every graded level Pi reports (`minimal` → `max`).
111
+ Omitting the field and setting it to `off` are different: omitting inherits the
112
+ session baseline, `off` explicitly disables reasoning. Anything else is warned about
113
+ (the warning enumerates the accepted set):
113
114
 
114
115
  ```
115
- [rpiv-pi] models.json: unknown thinking level "<v>" — valid values: off, minimal, low, medium, high, xhigh
116
+ [rpiv-pi] models.json: unknown thinking level "<v>" — valid values: off, minimal, …, max
116
117
  ```
117
118
 
118
119
  ### Model key form
@@ -1061,8 +1061,10 @@ type BasenameIndex = { index: Map<string, string[]>; truncated: boolean };
1061
1061
  * (`validate/stage-rules.ts:70` for `packages/rpiv-workflow/validate/stage-rules.ts`)
1062
1062
  * — mechanical path-prefix omissions, not fabricated references. The basename
1063
1063
  * keys the candidates; `verifyCitations` narrows them by whole-segment suffix.
1064
- * A UNIQUE match backs the citation; an AMBIGUOUS one stays unresolved so the
1065
- * producer must disambiguate with the repo-root-relative path. Skips
1064
+ * A UNIQUE match backs the citation; an AMBIGUOUS one stays unresolved — unless
1065
+ * the caller's declared-`files:` tiebreak in `verifyCitations` names exactly one
1066
+ * candidate — so the producer must disambiguate with the repo-root-relative
1067
+ * path. Skips
1066
1068
  * vendored/generated trees so a citation never resolves to a build copy or a
1067
1069
  * prior artifact. Bounded by the file cap.
1068
1070
  */
@@ -1172,7 +1174,11 @@ const resolveCitationPath = (
1172
1174
  * for zero risk averted (three of f329's floor failures were this class). */
1173
1175
  const PLACEHOLDER_CITATION_PREFIXES: readonly string[] = ["path/to/", "packages/x/"];
1174
1176
 
1175
- const verifyCitations = (body: string, cwd: string): { detail: string; where: string }[] => {
1177
+ const verifyCitations = (
1178
+ body: string,
1179
+ cwd: string,
1180
+ declared?: ReadonlySet<string>,
1181
+ ): { detail: string; where: string }[] => {
1176
1182
  const findings: { detail: string; where: string }[] = [];
1177
1183
  const seen = new Set<string>();
1178
1184
  // Fenced text is example/fixture territory, not prose asserting a real
@@ -1192,7 +1198,26 @@ const verifyCitations = (body: string, cwd: string): { detail: string; where: st
1192
1198
  const key = `${path}:${startStr}${endStr ? `-${endStr}` : ""}`;
1193
1199
  if (seen.has(key)) continue;
1194
1200
  seen.add(key);
1195
- const resolved = resolveCitationPath(path, cwd, indexHolder);
1201
+ let resolved = resolveCitationPath(path, cwd, indexHolder);
1202
+ if (resolved && "ambiguous" in resolved && declared !== undefined) {
1203
+ // Declared-write-set tiebreak: when the caller supplies the artifact's own
1204
+ // declared `files:` union and exactly ONE ambiguous candidate is in it, the
1205
+ // artifact has already named the file it means — resolve there instead of
1206
+ // halting the run over a path-prefix omission. A tie INSIDE the declared
1207
+ // set (two declared `command.ts` files) stays ambiguous: the citation is
1208
+ // then genuinely unreadable even against the artifact's own write-set.
1209
+ const declaredMatches = resolved.ambiguous.filter(
1210
+ (abs) =>
1211
+ abs.startsWith(cwd + sep) &&
1212
+ declared.has(
1213
+ abs
1214
+ .slice(cwd.length + 1)
1215
+ .split(sep)
1216
+ .join("/"),
1217
+ ),
1218
+ );
1219
+ if (declaredMatches.length === 1) resolved = { abs: declaredMatches[0] };
1220
+ }
1196
1221
  if (resolved && "ambiguous" in resolved) {
1197
1222
  // More than one tree file matches — name the candidates so the fix arm can disambiguate.
1198
1223
  const shown = resolved.ambiguous
@@ -1756,6 +1781,29 @@ const verifyPhaseFilesCoverage = (content: string, who: string, path: string): {
1756
1781
  return findings;
1757
1782
  };
1758
1783
 
1784
+ /**
1785
+ * The union of every phase's declared `files:` across the plan's frontmatter —
1786
+ * the disambiguation pool `planCitationCheck` hands `verifyCitations`. A plan's
1787
+ * write-set is the one place the plan itself names its files repo-root-relative
1788
+ * (the coverage floor enforces exactly that), so it is a deterministic
1789
+ * tiebreaker for the ambiguous-suffix findings that would otherwise STOP a
1790
+ * loop-less preset (ship) over a bare `messages.ts:18` whose owning file the
1791
+ * plan already declares. Degrades to the empty set on malformed frontmatter —
1792
+ * never throws out of the deterministic floor.
1793
+ */
1794
+ const declaredPlanFiles = (content: string): ReadonlySet<string> => {
1795
+ let fm: Record<string, unknown>;
1796
+ try {
1797
+ fm = parseFrontmatter(content).frontmatter as Record<string, unknown>;
1798
+ } catch {
1799
+ return new Set();
1800
+ }
1801
+ const phases = Array.isArray(fm.phases) ? fm.phases : [];
1802
+ const declared = new Set<string>();
1803
+ for (const entry of phases) for (const f of phaseFiles(entry)) declared.add(f);
1804
+ return declared;
1805
+ };
1806
+
1759
1807
  /**
1760
1808
  * Deterministic citation floor for a synthesized/spliced plan — the plan-scope
1761
1809
  * twin of `sliceStructureCheck`'s citation backing, extending the citation
@@ -1765,7 +1813,9 @@ const verifyPhaseFilesCoverage = (content: string, who: string, path: string): {
1765
1813
  * "structure" }` verdict on `who`'s channel that the gate route folds via
1766
1814
  * `allDimensionsPass`; the matching `<fix>` stage reads `fanin(who)` so the
1767
1815
  * findings DRIVE the amend rather than blind-halt. Reuses `verifyCitations` — no
1768
- * fuzzy wrong-symbol heuristic. Basename-keyed ⇒ idempotent across fix rounds.
1816
+ * fuzzy wrong-symbol heuristic — threading the plan's declared `files:` union so
1817
+ * an ambiguous suffix citation resolves when exactly one candidate is in the
1818
+ * plan's own write-set. Basename-keyed ⇒ idempotent across fix rounds.
1769
1819
  */
1770
1820
  const planCitationCheck =
1771
1821
  (who: string) =>
@@ -1779,7 +1829,7 @@ const planCitationCheck =
1779
1829
  );
1780
1830
  }
1781
1831
  const body = readArtifactFile(latest.handle.path, cwd);
1782
- const findings = verifyCitations(body, cwd);
1832
+ const findings = verifyCitations(body, cwd, declaredPlanFiles(body));
1783
1833
  // Plan-time coverage floor: a body edit not declared in its phase's `files:`
1784
1834
  // fails structurally, same channel/verdict/route as an unbacked citation.
1785
1835
  findings.push(...verifyPhaseFilesCoverage(body, who, latest.handle.path));
@@ -12,6 +12,7 @@
12
12
  * take effect on the next session start or /rpiv-update-agents.
13
13
  */
14
14
 
15
+ import type { ModelThinkingLevel, ThinkingLevel } from "@earendil-works/pi-ai";
15
16
  import { configPath, loadJsonConfigWithLegacyFallback, validateConfig } from "@juicesharp/rpiv-config";
16
17
  import { type Static, Type } from "typebox";
17
18
 
@@ -21,20 +22,38 @@ import { type Static, Type } from "typebox";
21
22
  // The host's setThinkingLevel (pi-agent-core ThinkingLevel) AND agent
22
23
  // frontmatter both accept "off" — "off" is a first-class level meaning "no
23
24
  // reasoning" (it's even the session default). models.json therefore persists
24
- // all SIX values. Note the distinction from ABSENCE: a missing `thinking`
25
+ // every value. Note the distinction from ABSENCE: a missing `thinking`
25
26
  // field means "inherit the session/baseline level"; an explicit "off" means
26
- // "disable reasoning". THINKING_LEVEL_VALUES (the 5 reasoning levels) is kept
27
- // for surfaces that list only the graded levels (e.g. the picker).
27
+ // "disable reasoning". THINKING_LEVEL_VALUES (the graded reasoning levels) is
28
+ // kept for surfaces that list only the graded levels (e.g. the picker).
28
29
  // ---------------------------------------------------------------------------
29
30
 
30
- /** The 5 graded reasoning levels (excludes "off"). */
31
- export const THINKING_LEVEL_VALUES = ["minimal", "low", "medium", "high", "xhigh"] as const;
31
+ /** The graded reasoning levels (excludes "off"). */
32
+ export const THINKING_LEVEL_VALUES = ["minimal", "low", "medium", "high", "xhigh", "max"] as const;
32
33
  export type ThinkingLevelValue = (typeof THINKING_LEVEL_VALUES)[number];
33
34
 
34
- /** All 6 persistable thinking values, including the explicit "off" (disable reasoning). */
35
+ /** All persistable thinking values, including the explicit "off" (disable reasoning). */
35
36
  export const MODEL_THINKING_LEVEL_VALUES = ["off", ...THINKING_LEVEL_VALUES] as const;
36
37
  export type ModelThinkingLevelValue = (typeof MODEL_THINKING_LEVEL_VALUES)[number];
37
38
 
39
+ // Guards: the local vocabulary must stay in lockstep with pi-ai's thinking-level
40
+ // universe (type-only imports — erased at runtime, no runtime dep). If pi-ai
41
+ // adds or removes a level, the bidirectional extends checks fail and this file
42
+ // won't compile until the arrays follow. They also make casts of
43
+ // pi.getThinkingLevel() to the local types provably safe.
44
+ type _GradedLevelsMatchPiAi = ThinkingLevelValue extends ThinkingLevel
45
+ ? ThinkingLevel extends ThinkingLevelValue
46
+ ? true
47
+ : never
48
+ : never;
49
+ const _gradedLevelsMatchPiAi: _GradedLevelsMatchPiAi = true;
50
+ type _PersistableLevelsMatchPiAi = ModelThinkingLevelValue extends ModelThinkingLevel
51
+ ? ModelThinkingLevel extends ModelThinkingLevelValue
52
+ ? true
53
+ : never
54
+ : never;
55
+ const _persistableLevelsMatchPiAi: _PersistableLevelsMatchPiAi = true;
56
+
38
57
  /**
39
58
  * Background-lane concurrency cap fallback. The fail-soft default applied by
40
59
  * `resolveMaxConcurrency` when `~/.config/rpiv-pi/models.json` is absent or
@@ -56,8 +75,9 @@ const ThinkingLevelSchema = Type.Union(
56
75
  Type.Literal("medium"),
57
76
  Type.Literal("high"),
58
77
  Type.Literal("xhigh"),
78
+ Type.Literal("max"),
59
79
  ] as const,
60
- { description: "Effort/thinking level: off | minimal | low | medium | high | xhigh" },
80
+ { description: "Effort/thinking level: off | minimal | low | medium | high | xhigh | max" },
61
81
  );
62
82
 
63
83
  // Guard: schema literals must stay in lockstep with MODEL_THINKING_LEVEL_VALUES.
@@ -28,12 +28,6 @@ import {
28
28
  buildModelItems,
29
29
  INHERIT_VALUE,
30
30
  loadRawConfig,
31
- MSG_REQUIRES_INTERACTIVE,
32
- MSG_RESET_ALL,
33
- MSG_RESET_ALL_BODY,
34
- MSG_RESET_ALL_CANCELLED,
35
- MSG_RESET_ALL_TITLE,
36
- MSG_SAVE_FAILED,
37
31
  RESET_LABEL,
38
32
  RESET_VALUE,
39
33
  scopeItems,
@@ -42,6 +36,12 @@ import {
42
36
  applyOverride,
43
37
  floatChecked,
44
38
  type KeyStep,
39
+ MSG_REQUIRES_INTERACTIVE,
40
+ MSG_RESET_ALL,
41
+ MSG_RESET_ALL_BODY,
42
+ MSG_RESET_ALL_CANCELLED,
43
+ MSG_RESET_ALL_TITLE,
44
+ MSG_SAVE_FAILED,
45
45
  removeOverride,
46
46
  SCOPE_DEFAULTS,
47
47
  SCOPE_RESET_ALL,
@@ -2,8 +2,8 @@
2
2
  * rpiv-models — Directory barrel for the /rpiv-models cascade picker.
3
3
  *
4
4
  * Module map:
5
- * overrides — ScopeDescriptor table, CRUD convenience functions, UI helpers
6
- * items — SelectItem builders, string constants, loadRawConfig
5
+ * overrides — ScopeDescriptor table, CRUD convenience functions, UI helpers, string constants
6
+ * items — SelectItem builders, picker sentinels, loadRawConfig
7
7
  * command — /rpiv-models command registration
8
8
  */
9
9
 
@@ -13,12 +13,6 @@ export {
13
13
  buildModelItems,
14
14
  INHERIT_VALUE,
15
15
  loadRawConfig,
16
- MSG_REQUIRES_INTERACTIVE,
17
- MSG_RESET_ALL,
18
- MSG_RESET_ALL_BODY,
19
- MSG_RESET_ALL_CANCELLED,
20
- MSG_RESET_ALL_TITLE,
21
- MSG_SAVE_FAILED,
22
16
  RESET_LABEL,
23
17
  RESET_VALUE,
24
18
  scopeItems,
@@ -28,6 +22,12 @@ export {
28
22
  CHECK,
29
23
  floatChecked,
30
24
  keyItems,
25
+ MSG_REQUIRES_INTERACTIVE,
26
+ MSG_RESET_ALL,
27
+ MSG_RESET_ALL_BODY,
28
+ MSG_RESET_ALL_CANCELLED,
29
+ MSG_RESET_ALL_TITLE,
30
+ MSG_SAVE_FAILED,
31
31
  type OverrideEntry,
32
32
  removeOverride,
33
33
  SCOPE_AGENTS,
@@ -2,8 +2,8 @@
2
2
  * rpiv-models/items — UI item builders and picker utilities for /rpiv-models.
3
3
  *
4
4
  * Pure functions that construct SelectItem arrays for the cascade pickers
5
- * (scope, key, model, effort). String constants and sentinel values live here
6
- * so the command handler stays a flat story.
5
+ * (scope, key, model, effort), plus the picker sentinel values. User-facing
6
+ * string constants live in overrides.ts with the rest of the command prose.
7
7
  */
8
8
 
9
9
  import type { Api, Model } from "@earendil-works/pi-ai";
@@ -33,23 +33,6 @@ const RESET_LABEL = "Reset to default";
33
33
  // distinct from the real "off" value, which persists thinking:"off" (disable).
34
34
  const INHERIT_VALUE = "__inherit__";
35
35
 
36
- // ---------------------------------------------------------------------------
37
- // String constants
38
- // ---------------------------------------------------------------------------
39
-
40
- export const MSG_REQUIRES_INTERACTIVE = "/rpiv-models requires an interactive UI session.";
41
- export const MSG_SAVE_FAILED = "Failed to save models.json (disk error or permissions).";
42
- export const MSG_RESET_ALL = "All model overrides cleared.";
43
- export const MSG_RESET_ALL_TITLE = "Reset ALL model overrides?";
44
- export const MSG_RESET_ALL_BODY = [
45
- "This clears every override in `~/.config/rpiv-pi/models.json` (defaults,",
46
- "agents, stages, skills, presets). This cannot be undone.",
47
- "",
48
- "Per-agent overrides already written into agent frontmatter revert on the",
49
- "next agent sync / session start, not immediately.",
50
- ].join("\n");
51
- export const MSG_RESET_ALL_CANCELLED = "Reset cancelled.";
52
-
53
36
  // ---------------------------------------------------------------------------
54
37
  // Re-exported sentinel values for command.ts
55
38
  // ---------------------------------------------------------------------------
@@ -71,6 +54,9 @@ export function scopeItems(raw: ModelsConfigSchema): SelectItem[] {
71
54
  ];
72
55
  }
73
56
 
57
+ // Mirror: packages/rpiv-advisor/advisor/command.ts buildModelItems — structural
58
+ // twin kept in a separate package by the zero-cross-imports contract; evolve
59
+ // model-picker semantics together.
74
60
  export function buildModelItems(models: Model<Api>[], currentKey?: string): SelectItem[] {
75
61
  const items = models.map((m) => {
76
62
  const key = modelKey(m);
@@ -86,6 +72,9 @@ export function buildModelItems(models: Model<Api>[], currentKey?: string): Sele
86
72
  return items;
87
73
  }
88
74
 
75
+ // Mirror: packages/rpiv-advisor/advisor/command.ts buildEffortItems — same
76
+ // filter-in/map-out shape, different sentinels and persist target; evolve
77
+ // level-picker semantics together.
89
78
  export function buildEffortItems(picked: Model<Api>): SelectItem[] {
90
79
  const supported = getSupportedThinkingLevels(picked);
91
80
  const levels = supported.filter((l): l is ThinkingLevelValue => THINKING_LEVEL_VALUES.includes(l as never));
@@ -31,6 +31,23 @@ export const SCOPE_SKILLS = "skills";
31
31
  export const SCOPE_PRESETS = "presets";
32
32
  export const SCOPE_RESET_ALL = "__reset_all__";
33
33
 
34
+ // ---------------------------------------------------------------------------
35
+ // User-facing string constants (command prose; item builders stay pure)
36
+ // ---------------------------------------------------------------------------
37
+
38
+ export const MSG_REQUIRES_INTERACTIVE = "/rpiv-models requires an interactive UI session.";
39
+ export const MSG_SAVE_FAILED = "Failed to save models.json (disk error or permissions).";
40
+ export const MSG_RESET_ALL = "All model overrides cleared.";
41
+ export const MSG_RESET_ALL_TITLE = "Reset ALL model overrides?";
42
+ export const MSG_RESET_ALL_BODY = [
43
+ "This clears every override in `~/.config/rpiv-pi/models.json` (defaults,",
44
+ "agents, stages, skills, presets). This cannot be undone.",
45
+ "",
46
+ "Per-agent overrides already written into agent frontmatter revert on the",
47
+ "next agent sync / session start, not immediately.",
48
+ ].join("\n");
49
+ export const MSG_RESET_ALL_CANCELLED = "Reset cancelled.";
50
+
34
51
  // ---------------------------------------------------------------------------
35
52
  // Small UI helpers (shared with items.ts and command.ts)
36
53
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-pi",
3
- "version": "2.5.2",
3
+ "version": "2.6.0",
4
4
  "description": "A skill-based development workflow for Pi Agent. 29 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",
@@ -49,7 +49,7 @@
49
49
  ]
50
50
  },
51
51
  "dependencies": {
52
- "@juicesharp/rpiv-config": "^2.5.2",
52
+ "@juicesharp/rpiv-config": "^2.6.0",
53
53
  "typebox": "^1.1.24"
54
54
  },
55
55
  "peerDependencies": {