@juicesharp/rpiv-workflow 1.19.1 → 2.0.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/README.md +81 -8
- package/api.ts +18 -703
- package/audit-ctx.ts +103 -0
- package/audit-rows.ts +154 -0
- package/audit.ts +158 -190
- package/built-ins.ts +40 -45
- package/chain-state.ts +220 -0
- package/command-run.ts +64 -31
- package/command.ts +123 -21
- package/docs/workflow-authoring.md +356 -63
- package/{lifecycle.ts → events.ts} +161 -37
- package/execution-host.ts +75 -0
- package/host.ts +149 -64
- package/index.ts +25 -81
- package/internal-utils.ts +171 -71
- package/internal.ts +22 -1
- package/judge.ts +241 -0
- package/layers.ts +10 -15
- package/load/alias.ts +6 -12
- package/load/cache.ts +9 -6
- package/load/index.ts +27 -106
- package/load/issues.ts +31 -0
- package/load/legacy.ts +102 -0
- package/load/merge.ts +2 -2
- package/load/resolve-default.ts +3 -4
- package/load/shape-guards.ts +3 -6
- package/load/skill-contract-phase.ts +94 -0
- package/loop-constructors.ts +24 -0
- package/loop-def.ts +285 -0
- package/loop-kinds.ts +750 -0
- package/loop-parallel.ts +250 -0
- package/loop-waves.ts +99 -0
- package/loop.ts +330 -0
- package/loops/constructors.ts +334 -0
- package/loops/derivations.ts +65 -0
- package/loops/introspection.ts +184 -0
- package/loops/panel.ts +196 -0
- package/loops/verify.ts +99 -0
- package/messages.ts +249 -156
- package/outcomes/collectors/directory-path.ts +7 -3
- package/outcomes/collectors/index.ts +1 -0
- package/outcomes/collectors/require-opt.ts +11 -0
- package/outcomes/collectors/text-scan.ts +47 -0
- package/outcomes/collectors/tool-call.ts +8 -3
- package/outcomes/collectors/transcript-path.ts +4 -18
- package/outcomes/collectors/union.ts +30 -10
- package/outcomes/collectors/url.ts +9 -14
- package/outcomes/collectors/workspace-diff.ts +21 -14
- package/outcomes/exec.ts +17 -0
- package/outcomes/git-commit.ts +190 -100
- package/outcomes/index.ts +1 -0
- package/outcomes/parsers/json-body.ts +2 -2
- package/outcomes/side-effect.ts +3 -3
- package/output-spec.ts +36 -10
- package/output.ts +98 -20
- package/package.json +27 -11
- package/predicates.ts +11 -8
- package/preview.ts +81 -21
- package/registration.ts +117 -36
- package/routing-dsl.ts +322 -0
- package/routing.ts +48 -2
- package/runner/by-name.ts +2 -1
- package/runner/by-run-id.ts +2 -1
- package/runner/chain-advance.ts +84 -56
- package/runner/errors.ts +10 -0
- package/runner/failure.ts +163 -0
- package/runner/index.ts +7 -13
- package/runner/input-validation.ts +16 -23
- package/runner/preflight.ts +169 -0
- package/runner/resolve-stage.ts +68 -0
- package/runner/resume-entry.ts +121 -0
- package/runner/resume-loop.ts +131 -0
- package/runner/resume.ts +368 -262
- package/runner/run-context.ts +165 -0
- package/runner/run-stage.ts +490 -0
- package/runner/runner.ts +202 -449
- package/runner/script-stage.ts +104 -112
- package/schema-compat.ts +12 -1
- package/semaphore.ts +55 -0
- package/sessions/extraction.ts +146 -81
- package/sessions/halt-routing.ts +195 -0
- package/sessions/index.ts +3 -1
- package/sessions/locate.ts +141 -0
- package/sessions/reattach.ts +71 -0
- package/sessions/sessions.ts +114 -199
- package/sessions/spawn.ts +132 -119
- package/sessions/success-persist.ts +89 -0
- package/skill-contract.ts +22 -25
- package/skill-contracts/composition.ts +86 -37
- package/skill-contracts/{registries.ts → extension-points.ts} +45 -12
- package/skill-contracts/harvest.ts +4 -4
- package/skill-contracts/index.ts +15 -8
- package/skill-contracts/registry.ts +33 -50
- package/stage-def.ts +595 -0
- package/stage-errors.ts +84 -0
- package/stage-identity.ts +56 -0
- package/startup.ts +4 -1
- package/state/index.ts +8 -1
- package/state/names.ts +91 -65
- package/state/paths.ts +20 -0
- package/state/raw.ts +77 -0
- package/state/reads.ts +103 -85
- package/state/resolve.ts +73 -0
- package/state/state.ts +135 -15
- package/state/writes.ts +29 -12
- package/transcript.ts +24 -0
- package/triggers.ts +11 -3
- package/types.ts +290 -78
- package/validate/contract-compat.ts +198 -0
- package/validate/graph.ts +134 -0
- package/validate/issue.ts +328 -0
- package/validate/stage-rules.ts +499 -0
- package/validate-output.ts +82 -7
- package/validate-workflow.ts +57 -759
- package/validation-bounds.ts +35 -0
- package/control-flow.ts +0 -135
- package/fanout.ts +0 -102
- package/iterate.ts +0 -155
- package/load/cache.test.ts +0 -82
- package/load/shape-guards.test.ts +0 -74
- package/outcomes/collectors/directory-path.test.ts +0 -64
- package/outcomes/collectors/tool-call.test.ts +0 -110
- package/outcomes/collectors/transcript-path.test.ts +0 -70
- package/outcomes/collectors/union.test.ts +0 -59
- package/outcomes/collectors/url.test.ts +0 -67
- package/outcomes/collectors/workspace-diff.test.ts +0 -107
- package/outcomes/git-commit.test.ts +0 -194
- package/outcomes/parsers/json-body.test.ts +0 -80
- package/runner/by-name.test.ts +0 -95
- package/runner/by-run-id.test.ts +0 -115
- package/runner/resume-fanout.test.ts +0 -331
- package/runner/resume-fanout.ts +0 -136
- package/runner/resume-iterate.test.ts +0 -444
- package/runner/resume-iterate.ts +0 -111
- package/runner/resume.test.ts +0 -1130
- package/runner/stage-lifecycle.ts +0 -500
package/judge.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Judge — the first-class model-judge concept. A `Judge` names a dispatchable
|
|
3
|
+
* grading session: a **skill** (`/skill:<judge.skill> <producerHandle>`, the
|
|
4
|
+
* latest producer artifact auto-injected as the input handle) or a raw
|
|
5
|
+
* **prompt** (the author embeds the handle/output themselves). Exactly one of
|
|
6
|
+
* `skill` / `prompt` is the dispatch discriminator — enforced at CONSTRUCTION
|
|
7
|
+
* by `judge()` (the `defineRoute` pattern: invalid shapes are unrepresentable
|
|
8
|
+
* past the factory).
|
|
9
|
+
*
|
|
10
|
+
* A judge session runs as a `produces`-kind session so its verdict is
|
|
11
|
+
* VALIDATED by `outcome` and published into its own dedicated
|
|
12
|
+
* `state.named[outcome.name]` channel. What the verdict DECIDES lives on the
|
|
13
|
+
* consuming site, not here: the `assess()` constructor adds `done(verdict)`;
|
|
14
|
+
* the per-stage `verify` field reuses `done(verdict)` as its pass gate; `panel()` will compose
|
|
15
|
+
* N judges with a vote fold. Keeping the termination predicate off `Judge`
|
|
16
|
+
* is what makes the concept reusable across all three.
|
|
17
|
+
*
|
|
18
|
+
* Leaf module — value imports are limited to `internal-utils.ts` (the
|
|
19
|
+
* `readSymbol`/`markSymbol` leaf, which is itself runner-free); otherwise
|
|
20
|
+
* type-only. Safe on the runner-free `registration`
|
|
21
|
+
* surface (siblings register built-ins without dragging the runner in).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { Artifact } from "./handle.js";
|
|
25
|
+
import { markSymbol, readSymbol } from "./internal-utils.js";
|
|
26
|
+
import type { Output, RunView } from "./output.js";
|
|
27
|
+
import type { Outcome } from "./output-spec.js";
|
|
28
|
+
|
|
29
|
+
export interface JudgeContext {
|
|
30
|
+
cwd: string;
|
|
31
|
+
/** Latest producer output (also the session's input handle). */
|
|
32
|
+
output: Output;
|
|
33
|
+
/** Frozen stage-entry primary, referenceable; the author embeds it if wanted. */
|
|
34
|
+
entryArtifact: Artifact | undefined;
|
|
35
|
+
state: RunView;
|
|
36
|
+
round: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A judge's dynamic prompt — receives the producer output + round context. */
|
|
40
|
+
export type JudgePromptFn = (ctx: JudgeContext) => string | Promise<string>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* An `Outcome` whose `name` is REQUIRED — a judge's verdict must publish
|
|
44
|
+
* to its own dedicated `state.named` channel, so the optional-`name` outcome
|
|
45
|
+
* shape isn't enough here.
|
|
46
|
+
*/
|
|
47
|
+
export interface NamedOutcome extends Outcome {
|
|
48
|
+
name: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fields shared by both judge dispatch arms.
|
|
53
|
+
*
|
|
54
|
+
* `outcome` validates the verdict and names its dedicated `state.named`
|
|
55
|
+
* channel (its `.name` must differ from the producer outcome's; that
|
|
56
|
+
* collision needs the producer's identity, so it stays a workflow-level
|
|
57
|
+
* check in `validateWorkflow`).
|
|
58
|
+
*
|
|
59
|
+
* ≥1-ARTIFACT CONSTRAINT: the collector MUST materialize at least one
|
|
60
|
+
* artifact (e.g. a JSON verdict file whose parser yields `{ done, feedback }`).
|
|
61
|
+
* A judge session whose collector returns zero artifacts is a **fatal halt**
|
|
62
|
+
* via `enforceCompletionContract` — no retry, no soft-stop.
|
|
63
|
+
*/
|
|
64
|
+
interface JudgeBase {
|
|
65
|
+
outcome: NamedOutcome;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Skill dispatch: `/skill:<skill> <producerHandle>` (handle auto-injected). */
|
|
69
|
+
export interface SkillJudge extends JudgeBase {
|
|
70
|
+
skill: string;
|
|
71
|
+
prompt?: never;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Raw-prompt dispatch: the session receives only the prompt text, so the
|
|
76
|
+
* author embeds the producer handle/output themselves (via `JudgeContext`
|
|
77
|
+
* for the dynamic form).
|
|
78
|
+
*/
|
|
79
|
+
export interface PromptJudge extends JudgeBase {
|
|
80
|
+
prompt: string | JudgePromptFn;
|
|
81
|
+
skill?: never;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The reusable judge shape — a union over the two dispatch arms, so
|
|
86
|
+
* skill-XOR-prompt and the named verdict outcome are violations the type
|
|
87
|
+
* system rejects on typed call sites, not just runtime checks. Authored via
|
|
88
|
+
* the `judge()` factory; a hand-rolled object literal (jiti-loaded configs
|
|
89
|
+
* erase TS types) is re-checked defensively at load time by
|
|
90
|
+
* `validateWorkflow` through the same `judgeShapeIssues` rule source —
|
|
91
|
+
* which is why the runtime checks stay.
|
|
92
|
+
*/
|
|
93
|
+
export type Judge = SkillJudge | PromptJudge;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A fold reduces the N member verdicts of a `PanelJudge` to the panel's
|
|
97
|
+
* decision DATA — `unknown` here because the *shape* is path-dependent
|
|
98
|
+
* (canonical `PANEL_VERDICT` vs. a custom author schema), validated downstream
|
|
99
|
+
* by the panel's `outcome`. The fold is pure (the replay contract leans on
|
|
100
|
+
* this: live + resume both recompute it from the durable member rows).
|
|
101
|
+
*/
|
|
102
|
+
export type FoldFn = (verdicts: readonly Output[]) => unknown;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* N independent judges plus a vote `fold` — the adversarial-verification
|
|
106
|
+
* generalization of a single `Judge` (Cohere PoLL: a jury beats a self-agreeing
|
|
107
|
+
* judge). `kind: "panel"` is the discriminator; a single `Judge` carries no
|
|
108
|
+
* `kind`, so `isPanel` distinguishes them structurally.
|
|
109
|
+
*
|
|
110
|
+
* `members` is `Judge[]` — each a full `SkillJudge | PromptJudge`, so the whole
|
|
111
|
+
* judge surface (skill XOR prompt, named verdict outcome, dispatch) is reused
|
|
112
|
+
* per member with zero new vocabulary. Nesting is rejected at construction
|
|
113
|
+
* (`members` is NOT `AnyJudge[]`).
|
|
114
|
+
*
|
|
115
|
+
* `outcome` is the canonical-vs-custom switch: ABSENT ⇒ the built-in
|
|
116
|
+
* `PANEL_VERDICT` shape on the `<stage>-panel` channel (sugar fold); PRESENT ⇒
|
|
117
|
+
* the author's schema + channel (raw fold). The two are kept disjoint by a hard
|
|
118
|
+
* XOR enforced by the `panel()` factory — never both.
|
|
119
|
+
*/
|
|
120
|
+
export interface PanelJudge {
|
|
121
|
+
kind: "panel";
|
|
122
|
+
members: readonly Judge[];
|
|
123
|
+
fold: FoldFn;
|
|
124
|
+
outcome?: NamedOutcome;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The slot type every judge SITE (`assess`, `verify`, any future judge phase)
|
|
129
|
+
* accepts — a plain `Judge` OR a `PanelJudge`. A single judge is the panel of
|
|
130
|
+
* one: sites reference the judge opaquely and let `panelMembers` expand it, so
|
|
131
|
+
* widening this slot is the ONLY signature change panel support imposes.
|
|
132
|
+
*/
|
|
133
|
+
export type AnyJudge = Judge | PanelJudge;
|
|
134
|
+
|
|
135
|
+
/** Discriminate a `PanelJudge` from a single `Judge` (singles carry no `kind`). */
|
|
136
|
+
export const isPanel = (j: AnyJudge): j is PanelJudge => (j as PanelJudge).kind === "panel";
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* THE expander — the single place a judge value becomes its member list. A
|
|
140
|
+
* panel yields its `members`; a single judge yields `[judge]` (the panel of
|
|
141
|
+
* one). Every member-walking site (preflight skill registration, introspection,
|
|
142
|
+
* the judge-phase dispatch) routes through this, so single-judge behavior is
|
|
143
|
+
* the degenerate case of the general path by construction.
|
|
144
|
+
*/
|
|
145
|
+
export const panelMembers = (j: AnyJudge): readonly Judge[] => (isPanel(j) ? j.members : [j]);
|
|
146
|
+
|
|
147
|
+
/** The sugar-fold constructors — the canonical folds (`majority`/`all`/`any`). */
|
|
148
|
+
export type CanonicalFoldName = "majority" | "all" | "any";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Brand carrying the SUGAR-fold name (`majority`/`all`/`any`) so consumers can
|
|
152
|
+
* (a) tell a canonical fold from a raw author closure — the structural signal
|
|
153
|
+
* behind the §4 XOR (sugar ⊕ `outcome`) — and (b) report WHICH fold it is in
|
|
154
|
+
* the introspection summary (`panelSpecOf`). `Symbol.for` so it survives
|
|
155
|
+
* `import` boundaries cleanly, matching the `READS_DATA` / `ROUTE_NOTE`
|
|
156
|
+
* precedent.
|
|
157
|
+
*
|
|
158
|
+
* Framework plumbing, not authoring surface — the sugar constructors brand;
|
|
159
|
+
* `panelShapeIssues` / `validateWorkflow` / `panelSpecOf` read. NOT re-exported
|
|
160
|
+
* from `registration.ts`, like `ROUTE_NOTE`.
|
|
161
|
+
*/
|
|
162
|
+
export const CANONICAL_FOLD: unique symbol = Symbol.for("rpiv.workflow.canonicalFold");
|
|
163
|
+
|
|
164
|
+
/** True iff `fold` was produced by a sugar constructor (carries the `CANONICAL_FOLD` brand). */
|
|
165
|
+
export function marksCanonicalFold(fold: FoldFn): boolean {
|
|
166
|
+
return canonicalFoldName(fold) !== undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The sugar constructor that produced `fold` (`majority`/`all`/`any`), or `undefined` for a raw author closure. */
|
|
170
|
+
export function canonicalFoldName(fold: FoldFn): CanonicalFoldName | undefined {
|
|
171
|
+
return readSymbol<CanonicalFoldName>(fold, CANONICAL_FOLD);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Attach the `CANONICAL_FOLD` brand (the sugar name) and return the fold — the ONE write site (sugar constructors). */
|
|
175
|
+
export function brandCanonicalFold(name: CanonicalFoldName, fold: FoldFn): FoldFn {
|
|
176
|
+
markSymbol(fold, CANONICAL_FOLD, name);
|
|
177
|
+
return fold;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Single rule source for the judge shape. Returns human-readable violations
|
|
182
|
+
* (empty array = valid). `judge()` throws on the first; `validateWorkflow`
|
|
183
|
+
* maps each to a load issue for hand-rolled literals that bypassed the
|
|
184
|
+
* factory. Takes `unknown` ON PURPOSE: the type system already rejects these
|
|
185
|
+
* shapes on typed call sites (the `Judge` union), so everything reaching this
|
|
186
|
+
* checker is an untyped jiti-loaded literal.
|
|
187
|
+
*/
|
|
188
|
+
export function judgeShapeIssues(candidate: unknown): string[] {
|
|
189
|
+
if (!candidate || typeof candidate !== "object") return ["a judge object is required"];
|
|
190
|
+
const j = candidate as { skill?: unknown; prompt?: unknown; outcome?: { name?: unknown } };
|
|
191
|
+
const issues: string[] = [];
|
|
192
|
+
if (!j.outcome?.name) {
|
|
193
|
+
issues.push("judge.outcome must carry a `name` so the verdict publishes to its own named channel");
|
|
194
|
+
}
|
|
195
|
+
const hasSkill = j.skill !== undefined;
|
|
196
|
+
const hasPrompt = j.prompt !== undefined;
|
|
197
|
+
if (hasSkill && hasPrompt) {
|
|
198
|
+
issues.push("judge sets both `skill` and `prompt` — choose one dispatch (skill XOR prompt)");
|
|
199
|
+
}
|
|
200
|
+
if (!hasSkill && !hasPrompt) {
|
|
201
|
+
issues.push("judge sets neither `skill` nor `prompt` — one is required to dispatch the judge");
|
|
202
|
+
}
|
|
203
|
+
return issues;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* THE collect-then-throw-first idiom — one named operation for the
|
|
208
|
+
* `*ShapeIssues(candidate)` → throw-on-first policy the judge/assess/verify/
|
|
209
|
+
* panel factories share. Throws `new Error(`${ctor}(): ${issues[0]}`)` iff the
|
|
210
|
+
* rule source found any violation; the remaining issues are deliberately
|
|
211
|
+
* discarded (one actionable error at the authoring site). The load gate
|
|
212
|
+
* (`validate/stage-rules.ts`) consumes the SAME rule sources via collect-and-
|
|
213
|
+
* report (it does NOT route through here — assertShape owns only the
|
|
214
|
+
* throw-first shape).
|
|
215
|
+
*/
|
|
216
|
+
export function assertShape(ctor: string, issues: string[]): void {
|
|
217
|
+
if (issues.length > 0) throw new Error(`${ctor}(): ${issues[0]}`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Promote a judge literal to a validated `Judge` — identity passthrough that
|
|
222
|
+
* throws on an invalid shape, so a `judge(...)`-authored value is correct by
|
|
223
|
+
* construction (cf. `defineRoute`). Composes into `assess({ judge: judge({...}) })`
|
|
224
|
+
* and `panel(judge({...}), judge({...}))` today.
|
|
225
|
+
*/
|
|
226
|
+
export function judge(spec: Judge): Judge {
|
|
227
|
+
assertShape("judge", judgeShapeIssues(spec));
|
|
228
|
+
return spec;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Resolve a static or dynamic `Judge.prompt`. A dynamic prompt may be async.
|
|
233
|
+
* (Moved from loop.ts — the ONE resolver for every Judge dispatch site.)
|
|
234
|
+
*/
|
|
235
|
+
export async function resolveJudgePrompt(
|
|
236
|
+
prompt: string | ((ctx: JudgeContext) => string | Promise<string>),
|
|
237
|
+
ctx: JudgeContext,
|
|
238
|
+
): Promise<string> {
|
|
239
|
+
if (typeof prompt === "string") return prompt;
|
|
240
|
+
return prompt(ctx);
|
|
241
|
+
}
|
package/layers.ts
CHANGED
|
@@ -8,26 +8,21 @@
|
|
|
8
8
|
* eliminates the silent-drift risk of two parallel string-literal unions.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { assertNever } from "./internal-utils.js";
|
|
12
|
-
|
|
13
11
|
export type ConfigLayer = "built-in" | "user" | "project";
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* Single source for layer → display string. Wrap every interpolation site
|
|
17
15
|
* (`${layer}` in template strings, banner builders, issue prefixes) in this
|
|
18
|
-
* helper
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* helper; the `satisfies Record<ConfigLayer, string>` makes adding a new
|
|
17
|
+
* `ConfigLayer` value a compile error here. The current display form is the
|
|
18
|
+
* layer name verbatim — keep that invariant if you change it.
|
|
21
19
|
*/
|
|
20
|
+
const CONFIG_LAYER_LABELS = {
|
|
21
|
+
"built-in": "built-in",
|
|
22
|
+
user: "user",
|
|
23
|
+
project: "project",
|
|
24
|
+
} satisfies Record<ConfigLayer, string>;
|
|
25
|
+
|
|
22
26
|
export function renderConfigLayer(layer: ConfigLayer): string {
|
|
23
|
-
|
|
24
|
-
case "built-in":
|
|
25
|
-
return "built-in";
|
|
26
|
-
case "user":
|
|
27
|
-
return "user";
|
|
28
|
-
case "project":
|
|
29
|
-
return "project";
|
|
30
|
-
default:
|
|
31
|
-
return assertNever(layer);
|
|
32
|
-
}
|
|
27
|
+
return CONFIG_LAYER_LABELS[layer];
|
|
33
28
|
}
|
package/load/alias.ts
CHANGED
|
@@ -20,20 +20,14 @@
|
|
|
20
20
|
* slot) is never mutated in place; a changed workflow is a new frozen copy.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import type {
|
|
24
|
-
import { resolveSkill } from "../
|
|
23
|
+
import type { Workflow } from "../api.js";
|
|
24
|
+
import { isDispatchingStage, resolveSkill } from "../stage-identity.js";
|
|
25
25
|
import type { LayerOutcome, LoadAccumulator } from "./merge.js";
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* alias remap below (which stages to rewrite) and the no-op-alias warning in
|
|
32
|
-
* `applySkillAliases` (which skills count as "dispatched") — the two must agree.
|
|
33
|
-
*/
|
|
34
|
-
export function isDispatchingStage(stage: StageDef): boolean {
|
|
35
|
-
return stage.run == null && stage.prompt == null;
|
|
36
|
-
}
|
|
27
|
+
// `isDispatchingStage` lives beside `resolveSkill` in chain-state.ts (the
|
|
28
|
+
// validator and harvest consume it without reaching into load/); re-exported
|
|
29
|
+
// here for existing consumers.
|
|
30
|
+
export { isDispatchingStage } from "../stage-identity.js";
|
|
37
31
|
|
|
38
32
|
export function aliasSkills(w: Workflow, aliases: Record<string, string>): Workflow {
|
|
39
33
|
if (!aliases || Object.keys(aliases).length === 0) return w;
|
package/load/cache.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* mtime-keyed jiti import cache. jiti's
|
|
3
|
-
* picks up edits without restart;
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* mtime-keyed jiti import cache. jiti's MODULE cache is disabled so `/reload`
|
|
3
|
+
* picks up edits without restart; its fs TRANSFORM cache stays on (the
|
|
4
|
+
* default) — entries are content-hash validated, so an edited overlay can
|
|
5
|
+
* never be served stale, and fresh sessions skip the ~70ms/file Babel
|
|
6
|
+
* re-transform. This wrapper layers a stat-driven cache on top so unchanged
|
|
7
|
+
* overlays don't re-evaluate top-level code on every `/wf` invocation.
|
|
6
8
|
*
|
|
7
9
|
* The `jiti` instance lives here so the cache and the underlying importer
|
|
8
10
|
* co-locate. Other loader modules import `cachedImport` — none touches
|
|
@@ -18,9 +20,10 @@ import { statSync } from "node:fs";
|
|
|
18
20
|
import { createJiti } from "jiti";
|
|
19
21
|
|
|
20
22
|
const jiti = createJiti(import.meta.url, {
|
|
21
|
-
//
|
|
23
|
+
// Module cache OFF so /reload picks up edits without restart. The fs
|
|
24
|
+
// transform cache (default ON) is deliberately kept: it is content-hash
|
|
25
|
+
// validated (edit-safe) and saves ~70ms/file of Babel work per session.
|
|
22
26
|
moduleCache: false,
|
|
23
|
-
fsCache: false,
|
|
24
27
|
});
|
|
25
28
|
|
|
26
29
|
const overlayCache = new Map<string, { mtimeMs: number; parsed: unknown }>();
|
package/load/index.ts
CHANGED
|
@@ -42,33 +42,30 @@
|
|
|
42
42
|
* (the config file + pack files) before running `/wf`.
|
|
43
43
|
*
|
|
44
44
|
* Module map:
|
|
45
|
+
* ./issues.ts — LoadIssue + Issue (the layer/path-attributed wrapper)
|
|
46
|
+
* ./skill-contract-phase.ts — provider flush/drain + effective registry + derivers
|
|
45
47
|
* ./paths.ts — OverlayPaths + per-layer path helpers
|
|
46
|
-
* ./shape-guards.ts — isWorkflow, isEnvelope, describe
|
|
48
|
+
* ./shape-guards.ts — isWorkflow, isEnvelope, describe
|
|
47
49
|
* ./normalize.ts — normalizeDefaultExport + NormalizeResult
|
|
48
50
|
* ./merge.ts — LoadAccumulator, LayerOutcome, loadLayer, mergeOverlay, loadError
|
|
51
|
+
* ./legacy.ts — legacy-layout advisories (notices + probes)
|
|
49
52
|
* ./resolve-default.ts — resolveDefault (first-workflow fallback)
|
|
50
53
|
* ./cache.ts — mtime-keyed jiti import cache + __resetLoadCache
|
|
51
54
|
*/
|
|
52
55
|
|
|
53
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
54
|
-
import { dirname, join } from "node:path";
|
|
55
56
|
import type { Workflow } from "../api.js";
|
|
56
|
-
import { flushBuiltInProviders, getBuiltIns } from "../built-ins.js";
|
|
57
|
+
import { drainBuiltInProviderErrors, flushBuiltInProviders, getBuiltIns } from "../built-ins.js";
|
|
58
|
+
import { formatError } from "../internal-utils.js";
|
|
57
59
|
import type { ConfigLayer } from "../layers.js";
|
|
58
|
-
import { LEGACY_OVERLAY_NOTICE, LEGACY_RUNS_NOTICE, LEGACY_USER_CONFIG_NOTICE } from "../messages.js";
|
|
59
60
|
import type { SkillContractMap } from "../skill-contract.js";
|
|
60
|
-
import {
|
|
61
|
-
buildEffectiveContracts,
|
|
62
|
-
drainSkillContractCollisions,
|
|
63
|
-
drainSkillContractProviderErrors,
|
|
64
|
-
flushSkillContractProviders,
|
|
65
|
-
getOutcomeDerivers,
|
|
66
|
-
} from "../skill-contracts/index.js";
|
|
67
|
-
import { validateWorkflow, type WorkflowValidationIssue } from "../validate-workflow.js";
|
|
61
|
+
import { validateWorkflow } from "../validate-workflow.js";
|
|
68
62
|
import { applySkillAliases } from "./alias.js";
|
|
63
|
+
import type { Issue } from "./issues.js";
|
|
64
|
+
import { pushLegacyNotices } from "./legacy.js";
|
|
69
65
|
import { type LoadAccumulator, loadLayer } from "./merge.js";
|
|
70
|
-
import {
|
|
66
|
+
import { projectOverlayPaths, userOverlayPaths } from "./paths.js";
|
|
71
67
|
import { resolveDefault } from "./resolve-default.js";
|
|
68
|
+
import { applySkillContractPhase } from "./skill-contract-phase.js";
|
|
72
69
|
|
|
73
70
|
// ===========================================================================
|
|
74
71
|
// Public types
|
|
@@ -77,19 +74,10 @@ import { resolveDefault } from "./resolve-default.js";
|
|
|
77
74
|
export type { ConfigLayer } from "../layers.js";
|
|
78
75
|
export { aliasSkills } from "./alias.js";
|
|
79
76
|
export { __resetLoadCache } from "./cache.js";
|
|
77
|
+
export type { Issue, LoadIssue, LoadIssueOrigin } from "./issues.js";
|
|
80
78
|
export type { OverlayPaths } from "./paths.js";
|
|
81
79
|
export { projectOverlayPaths, userOverlayPaths } from "./paths.js";
|
|
82
80
|
|
|
83
|
-
export interface LoadIssue {
|
|
84
|
-
kind: "load";
|
|
85
|
-
layer: ConfigLayer;
|
|
86
|
-
path?: string;
|
|
87
|
-
severity: "error" | "warning";
|
|
88
|
-
message: string;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type Issue = LoadIssue | (WorkflowValidationIssue & { kind: "validation"; layer: ConfigLayer; path?: string });
|
|
92
|
-
|
|
93
81
|
export interface LoadedWorkflows {
|
|
94
82
|
workflows: readonly Workflow[];
|
|
95
83
|
/**
|
|
@@ -112,7 +100,7 @@ export interface LoadedWorkflows {
|
|
|
112
100
|
*/
|
|
113
101
|
skillAliases: Readonly<Record<string, string>>;
|
|
114
102
|
/**
|
|
115
|
-
* Effective skill-contract registry:
|
|
103
|
+
* Effective skill-contract registry: registered (`declared`-source) contracts merged
|
|
116
104
|
* OVER `harvested` ones (derived from stage usage). Required field, empty
|
|
117
105
|
* `Map` when no contract was declared or harvestable.
|
|
118
106
|
*/
|
|
@@ -146,34 +134,26 @@ export async function loadWorkflows(cwd: string): Promise<LoadedWorkflows> {
|
|
|
146
134
|
// defer constructing definitions to first `/wf` (the earliest reader).
|
|
147
135
|
await flushBuiltInProviders();
|
|
148
136
|
|
|
149
|
-
// Flush skill-contract providers beside the built-in flush. Same provider+flush
|
|
150
|
-
// idiom; contract providers read the filesystem / parse frontmatter (failure-prone),
|
|
151
|
-
// so each throw is recorded (drained below) rather than propagated.
|
|
152
|
-
await flushSkillContractProviders();
|
|
153
|
-
|
|
154
137
|
const acc: LoadAccumulator = {
|
|
155
138
|
issues: [],
|
|
156
139
|
workflowMap: new Map(),
|
|
157
140
|
sources: new Map(),
|
|
158
141
|
sourcePaths: new Map(),
|
|
159
142
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
143
|
+
// Built-in provider failures — each provider throw was RECORDED (not
|
|
144
|
+
// propagated) during `flushBuiltInProviders()`; drain and surface as issues
|
|
145
|
+
// so the loader keeps its never-throws contract without swallowing the
|
|
146
|
+
// failure. Runs before `getBuiltIns()` is read, so a provider that throws
|
|
147
|
+
// before registering contributes its error but (correctly) no workflows.
|
|
148
|
+
for (const err of drainBuiltInProviderErrors()) {
|
|
165
149
|
acc.issues.push({
|
|
166
150
|
kind: "load",
|
|
167
|
-
layer: "
|
|
168
|
-
message: `
|
|
151
|
+
layer: "framework",
|
|
152
|
+
message: `built-in provider failed: ${formatError(err)}`,
|
|
169
153
|
severity: "warning",
|
|
170
154
|
});
|
|
171
155
|
}
|
|
172
|
-
|
|
173
|
-
// divergence is no longer silent.
|
|
174
|
-
for (const message of drainSkillContractCollisions()) {
|
|
175
|
-
acc.issues.push({ kind: "load", layer: "built-in", message, severity: "warning" });
|
|
176
|
-
}
|
|
156
|
+
const layers: ConfigLayer[] = getBuiltIns().length > 0 ? ["built-in"] : [];
|
|
177
157
|
|
|
178
158
|
for (const w of getBuiltIns()) {
|
|
179
159
|
acc.workflowMap.set(w.name, w);
|
|
@@ -203,29 +183,11 @@ export async function loadWorkflows(cwd: string): Promise<LoadedWorkflows> {
|
|
|
203
183
|
// declared the key — see `applySkillAliases` in `./alias.ts`.
|
|
204
184
|
const skillAliases = applySkillAliases(acc, userOutcome, projectOutcome);
|
|
205
185
|
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// Invoke registered outcome derivers (e.g. rpiv-pi's BUCKET_BY_KIND resolver)
|
|
212
|
-
// so `produces` stages that don't declare an explicit `outcome` get one wired
|
|
213
|
-
// from the contract registry before validation checks
|
|
214
|
-
// `produces-without-outcome`.
|
|
215
|
-
for (const deriver of getOutcomeDerivers()) {
|
|
216
|
-
try {
|
|
217
|
-
deriver(acc.workflowMap.values(), skillContracts, (message, severity) => {
|
|
218
|
-
acc.issues.push({ kind: "load", layer: "built-in", severity, message });
|
|
219
|
-
});
|
|
220
|
-
} catch (err) {
|
|
221
|
-
acc.issues.push({
|
|
222
|
-
kind: "load",
|
|
223
|
-
layer: "built-in",
|
|
224
|
-
severity: "error",
|
|
225
|
-
message: `outcome deriver failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
186
|
+
// Skill-contract phase: flush providers, surface their failures +
|
|
187
|
+
// collisions (attributed to "framework", not a config layer), build the
|
|
188
|
+
// effective registry, run outcome derivers on per-load stage copies. Must
|
|
189
|
+
// precede validation — see `./skill-contract-phase.ts`.
|
|
190
|
+
const skillContracts = await applySkillContractPhase(acc);
|
|
229
191
|
|
|
230
192
|
// Validate every merged workflow once. Validation runs even on built-in so
|
|
231
193
|
// that a future built-in regression surfaces in the same channel as user
|
|
@@ -251,44 +213,3 @@ export async function loadWorkflows(cwd: string): Promise<LoadedWorkflows> {
|
|
|
251
213
|
skillContracts,
|
|
252
214
|
};
|
|
253
215
|
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Push the three independent legacy-migration advisories. Each is a `"warning"`
|
|
257
|
-
* (never blocks the run) and each probes a distinct stale layout the unified
|
|
258
|
-
* `.rpiv/workflows/` move left behind:
|
|
259
|
-
* - project dashed dir `<cwd>/.rpiv-workflow/` → config.ts + packs/
|
|
260
|
-
* - orphaned run JSONLs `<cwd>/.rpiv/workflows/*.jsonl` → runs/
|
|
261
|
-
* - user-layer rename `~/.config/rpiv-workflow/workflows.config.ts` → config.ts
|
|
262
|
-
*/
|
|
263
|
-
function pushLegacyNotices(cwd: string, userPaths: OverlayPaths, acc: LoadAccumulator): void {
|
|
264
|
-
if (existsSync(join(cwd, ".rpiv-workflow"))) {
|
|
265
|
-
acc.issues.push({ kind: "load", layer: "project", severity: "warning", message: LEGACY_OVERLAY_NOTICE(cwd) });
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (hasOrphanedRunFiles(cwd)) {
|
|
269
|
-
acc.issues.push({ kind: "load", layer: "project", severity: "warning", message: LEGACY_RUNS_NOTICE(cwd) });
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const userDir = dirname(userPaths.configFile);
|
|
273
|
-
if (existsSync(join(userDir, "workflows.config.ts"))) {
|
|
274
|
-
acc.issues.push({
|
|
275
|
-
kind: "load",
|
|
276
|
-
layer: "user",
|
|
277
|
-
severity: "warning",
|
|
278
|
-
message: LEGACY_USER_CONFIG_NOTICE(userDir),
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* True when `<cwd>/.rpiv/workflows/` holds top-level `*.jsonl` run files written
|
|
285
|
-
* before the `runs/` relocation. `readdirSync` lists only immediate entries, so
|
|
286
|
-
* files already inside `runs/` never match. A missing / unreadable dir → false.
|
|
287
|
-
*/
|
|
288
|
-
function hasOrphanedRunFiles(cwd: string): boolean {
|
|
289
|
-
try {
|
|
290
|
-
return readdirSync(join(cwd, ".rpiv", "workflows")).some((f) => f.endsWith(".jsonl"));
|
|
291
|
-
} catch {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
}
|
package/load/issues.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The loader's issue vocabulary — a LEAF module so `merge.ts` (and any other
|
|
3
|
+
* pipeline stage) can name the `Issue` shape without importing the
|
|
4
|
+
* orchestrator back.
|
|
5
|
+
*
|
|
6
|
+
* `layer`/`path` attribution lives ONLY here: `validateWorkflow` knows
|
|
7
|
+
* nothing about config layers; the loader is the seam that has both
|
|
8
|
+
* `workflowSources` and the issue list in scope, so it wraps each validation
|
|
9
|
+
* issue with the layer/path of the file the surviving workflow came from.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ConfigLayer } from "../layers.js";
|
|
13
|
+
import type { WorkflowValidationIssue } from "../validate/issue.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Where a load issue originated: one of the config layers, or `"framework"`
|
|
17
|
+
* — the loader's own machinery (skill-contract providers, outcome derivers,
|
|
18
|
+
* collision tracking). The framework origin is honest attribution for
|
|
19
|
+
* errors no config file caused.
|
|
20
|
+
*/
|
|
21
|
+
export type LoadIssueOrigin = ConfigLayer | "framework";
|
|
22
|
+
|
|
23
|
+
export interface LoadIssue {
|
|
24
|
+
kind: "load";
|
|
25
|
+
layer: LoadIssueOrigin;
|
|
26
|
+
path?: string;
|
|
27
|
+
severity: "error" | "warning";
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type Issue = LoadIssue | (WorkflowValidationIssue & { kind: "validation"; layer: ConfigLayer; path?: string });
|
package/load/legacy.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy-layout migration advisories — the notice strings AND the probes
|
|
3
|
+
* that fire them (the migration shell snippets are a loader concern, not
|
|
4
|
+
* UI constants).
|
|
5
|
+
*
|
|
6
|
+
* Each advisory is a `"warning"` (never blocks the run) probing a distinct
|
|
7
|
+
* stale layout the unified `.rpiv/workflows/` move left behind. Sunset
|
|
8
|
+
* target ~3 release cycles post-1.0 — remove each `existsSync` gate, its
|
|
9
|
+
* message constant, and the co-located test case together.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import type { LoadAccumulator } from "./merge.js";
|
|
15
|
+
import type { OverlayPaths } from "./paths.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Legacy `.rpiv-workflow/` overlay directory detected at load time. The
|
|
19
|
+
* package moved project config under the unified `.rpiv/workflows/` tree
|
|
20
|
+
* (config.ts + packs/) alongside run state. The old directory is NO LONGER
|
|
21
|
+
* read — this notice points the user at the new location and the one-line
|
|
22
|
+
* `mv` migration. Emitted as a load WARNING (advisory, non-blocking).
|
|
23
|
+
*
|
|
24
|
+
* The embedded shell is `;`-sequenced (not `&&`-chained) and each move is
|
|
25
|
+
* guarded (`[ -f … ]` for the config, `find … 2>/dev/null` for the packs) so
|
|
26
|
+
* the terminal `rm -rf` ALWAYS runs — a config-only legacy dir (no `workflows/`
|
|
27
|
+
* subdir) no longer halts the chain and re-fires this warning forever.
|
|
28
|
+
*/
|
|
29
|
+
export const LEGACY_OVERLAY_NOTICE = (cwd: string): string =>
|
|
30
|
+
`rpiv-workflow: detected legacy \`${join(cwd, ".rpiv-workflow")}\` — project config now lives at ` +
|
|
31
|
+
"`.rpiv/workflows/config.ts` + `.rpiv/workflows/packs/` and is the only location read. " +
|
|
32
|
+
"Move it: `mkdir -p .rpiv/workflows/packs; " +
|
|
33
|
+
"[ -f .rpiv-workflow/workflows.config.ts ] && mv .rpiv-workflow/workflows.config.ts .rpiv/workflows/config.ts; " +
|
|
34
|
+
"find .rpiv-workflow/workflows -name '*.ts' -exec mv {} .rpiv/workflows/packs/ \\; 2>/dev/null; " +
|
|
35
|
+
"rm -rf .rpiv-workflow` " +
|
|
36
|
+
"(the old directory is ignored). " +
|
|
37
|
+
"Note: `.rpiv/workflows/` is commonly gitignored (it holds run state), so the moved " +
|
|
38
|
+
"`config.ts` + `packs/` may be silently uncommittable — add `!.rpiv/workflows/config.ts` and " +
|
|
39
|
+
"`!.rpiv/workflows/packs/` to your `.gitignore` to version-control team workflow config.";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Orphaned run JSONLs detected directly under `.rpiv/workflows/` at load time.
|
|
43
|
+
* Run state moved one level down into `.rpiv/workflows/runs/`; files written by
|
|
44
|
+
* an older version still sit at the parent and are no longer enumerated by
|
|
45
|
+
* `listRuns` (so `/wf` past-run inspection silently can't see them). Emitted as
|
|
46
|
+
* a load WARNING (advisory, non-blocking) — the files are orphaned, not deleted.
|
|
47
|
+
*/
|
|
48
|
+
export const LEGACY_RUNS_NOTICE = (cwd: string): string =>
|
|
49
|
+
`rpiv-workflow: detected legacy run files directly under \`${join(cwd, ".rpiv", "workflows")}\` — ` +
|
|
50
|
+
"run state now lives in `.rpiv/workflows/runs/` and these top-level `*.jsonl` files are no longer " +
|
|
51
|
+
"read by `/wf`. Move them: `mkdir -p .rpiv/workflows/runs && mv .rpiv/workflows/*.jsonl .rpiv/workflows/runs/`.";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Legacy user-layer config filename (`workflows.config.ts`) detected at load
|
|
55
|
+
* time. The user overlay's inner name was aligned with the project layer
|
|
56
|
+
* (`config.ts`) and is the ONLY name read — a stale `workflows.config.ts` would
|
|
57
|
+
* otherwise silently stop contributing its aliases / default / overlay
|
|
58
|
+
* workflows. Mirrors `LEGACY_OVERLAY_NOTICE` at the user layer. Load WARNING.
|
|
59
|
+
*/
|
|
60
|
+
export const LEGACY_USER_CONFIG_NOTICE = (dir: string): string =>
|
|
61
|
+
`rpiv-workflow: detected legacy \`${join(dir, "workflows.config.ts")}\` — the user-layer config now lives at ` +
|
|
62
|
+
`\`${join(dir, "config.ts")}\` and is the only name read. ` +
|
|
63
|
+
`Move it: \`mv ${join(dir, "workflows.config.ts")} ${join(dir, "config.ts")}\` (the old name is ignored).`;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Push the three independent legacy-migration advisories:
|
|
67
|
+
* - project dashed dir `<cwd>/.rpiv-workflow/` → config.ts + packs/
|
|
68
|
+
* - orphaned run JSONLs `<cwd>/.rpiv/workflows/*.jsonl` → runs/
|
|
69
|
+
* - user-layer rename `~/.config/rpiv-workflow/workflows.config.ts` → config.ts
|
|
70
|
+
*/
|
|
71
|
+
export function pushLegacyNotices(cwd: string, userPaths: OverlayPaths, acc: LoadAccumulator): void {
|
|
72
|
+
if (existsSync(join(cwd, ".rpiv-workflow"))) {
|
|
73
|
+
acc.issues.push({ kind: "load", layer: "project", severity: "warning", message: LEGACY_OVERLAY_NOTICE(cwd) });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (hasOrphanedRunFiles(cwd)) {
|
|
77
|
+
acc.issues.push({ kind: "load", layer: "project", severity: "warning", message: LEGACY_RUNS_NOTICE(cwd) });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const userDir = dirname(userPaths.configFile);
|
|
81
|
+
if (existsSync(join(userDir, "workflows.config.ts"))) {
|
|
82
|
+
acc.issues.push({
|
|
83
|
+
kind: "load",
|
|
84
|
+
layer: "user",
|
|
85
|
+
severity: "warning",
|
|
86
|
+
message: LEGACY_USER_CONFIG_NOTICE(userDir),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* True when `<cwd>/.rpiv/workflows/` holds top-level `*.jsonl` run files written
|
|
93
|
+
* before the `runs/` relocation. `readdirSync` lists only immediate entries, so
|
|
94
|
+
* files already inside `runs/` never match. A missing / unreadable dir → false.
|
|
95
|
+
*/
|
|
96
|
+
function hasOrphanedRunFiles(cwd: string): boolean {
|
|
97
|
+
try {
|
|
98
|
+
return readdirSync(join(cwd, ".rpiv", "workflows")).some((f) => f.endsWith(".jsonl"));
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|