@entelligentsia/forgecli 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -0
- package/dist/CHANGELOG-forge-plugin.md +114 -0
- package/dist/extensions/forgecli/forge-subagent.js +58 -0
- package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
- package/dist/extensions/forgecli/orchestrators/init/init-phase-dispatch.d.ts +49 -40
- package/dist/extensions/forgecli/orchestrators/init/init-phase-dispatch.js +59 -188
- package/dist/extensions/forgecli/orchestrators/init/init-phase-dispatch.js.map +1 -1
- package/dist/extensions/forgecli/orchestrators/init/init-phases.d.ts +0 -43
- package/dist/extensions/forgecli/orchestrators/init/init-phases.js +11 -59
- package/dist/extensions/forgecli/orchestrators/init/init-phases.js.map +1 -1
- package/dist/extensions/forgecli/orchestrators/init/init-steps.d.ts +115 -0
- package/dist/extensions/forgecli/orchestrators/init/init-steps.js +125 -0
- package/dist/extensions/forgecli/orchestrators/init/init-steps.js.map +1 -0
- package/dist/extensions/forgecli/orchestrators/init/run-init-pipeline.js +400 -211
- package/dist/extensions/forgecli/orchestrators/init/run-init-pipeline.js.map +1 -1
- package/dist/extensions/forgecli/orchestrators/init/run-init-types.d.ts +8 -2
- package/dist/extensions/forgecli/orchestrators/init/run-init-types.js +15 -5
- package/dist/extensions/forgecli/orchestrators/init/run-init-types.js.map +1 -1
- package/dist/forge-payload/.base-pack/workflows-js/wfl-init.js +99 -38
- package/dist/forge-payload/.claude-plugin/plugin.json +1 -1
- package/dist/forge-payload/.init/generation/generate-kb-doc.md +24 -0
- package/dist/forge-payload/.schemas/migrations.json +77 -0
- package/dist/forge-payload/init/generation/generate-kb-doc.md +24 -0
- package/dist/forge-payload/init/phases/phase-2/context.md +23 -0
- package/dist/forge-payload/init/phases/phase-2/database.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/deployment.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/domain-concepts.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/domain-model.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/entity-model.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/index.md +25 -0
- package/dist/forge-payload/init/phases/phase-2/processes.md +26 -0
- package/dist/forge-payload/init/phases/phase-2/routing.md +25 -0
- package/dist/forge-payload/init/phases/phase-2/stack-checklist.md +25 -0
- package/dist/forge-payload/init/phases/phase-2/stack.md +27 -0
- package/dist/forge-payload/init/phases/phase-2/testing.md +26 -0
- package/dist/forge-payload/init/phases/phase-2-discover.md +15 -9
- package/dist/forge-payload/payload-manifest.json +2 -2
- package/dist/forge-payload/tools/seed-store.cjs +14 -0
- package/dist/forge-payload/tools/verify-phase.cjs +61 -4
- package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// init-steps.ts — the /forge:init step machine (FORGE-S35-T02, Slice 1).
|
|
2
|
+
//
|
|
3
|
+
// Replaces the coarse four-phase `INIT_PHASES` walk with a flat table of
|
|
4
|
+
// `Step` descriptors. Each Step declares:
|
|
5
|
+
// - `dependsOn` — ordering edges (the only serialization constraint);
|
|
6
|
+
// - `precondition` — a deterministic input-readiness/ordering gate checked
|
|
7
|
+
// BEFORE any run/dispatch (halts pre-dispatch on failure);
|
|
8
|
+
// - `run` — a discriminated union: a deterministic thunk (local
|
|
9
|
+
// tool/fs work, spawns NO subagent) OR a scoped subagent
|
|
10
|
+
// descriptor dispatched through the existing
|
|
11
|
+
// runForgeSubagent path (IL10 unchanged);
|
|
12
|
+
// - `requiredOutput`— a deterministic postcondition; on failure the step is
|
|
13
|
+
// rerun up to `retryPolicy.maxReruns`, then the pipeline
|
|
14
|
+
// halts;
|
|
15
|
+
// - `retryPolicy` — `{ maxReruns }` (0 = hard-halt on first failure).
|
|
16
|
+
//
|
|
17
|
+
// `topoSortWaves` groups steps with no unresolved dependency into the same wave
|
|
18
|
+
// (Kahn layering); `runWave` dispatches a wave's steps concurrently via
|
|
19
|
+
// `Promise.all` (no new npm dependency — built-ins only). Steps sharing a wave
|
|
20
|
+
// are independent and overlap; cross-reference edges are the sole ordering
|
|
21
|
+
// constraint.
|
|
22
|
+
//
|
|
23
|
+
// This module holds ONLY the reusable machine + the `Step` contract. The
|
|
24
|
+
// concrete `INIT_STEPS` table (which closes over pipeline runtime state and the
|
|
25
|
+
// forge-init deterministic helpers) is assembled by the orchestrator in
|
|
26
|
+
// run-init-pipeline.ts. Keeping the primitives free of forge-init imports keeps
|
|
27
|
+
// them independently unit-testable (init-steps.test.ts).
|
|
28
|
+
//
|
|
29
|
+
// Layering: type-only imports from sibling subagent modules; no runtime deps.
|
|
30
|
+
// ── runStep ───────────────────────────────────────────────────────────────────
|
|
31
|
+
/**
|
|
32
|
+
* Drive one step: check precondition (halt pre-dispatch on failure) → run
|
|
33
|
+
* (deterministic thunk OR subagent) → check requiredOutput → on failure rerun
|
|
34
|
+
* up to `retryPolicy.maxReruns`, else halt.
|
|
35
|
+
*
|
|
36
|
+
* A precondition failure returns `{ ok:false, dispatched:false }` with ZERO
|
|
37
|
+
* dispatches — the gate is always checked before any subagent is spawned.
|
|
38
|
+
*/
|
|
39
|
+
export async function runStep(step, deps) {
|
|
40
|
+
const { ctx, dispatchSubagent } = deps;
|
|
41
|
+
const startMs = Date.now();
|
|
42
|
+
if (step.precondition) {
|
|
43
|
+
const pc = await step.precondition(ctx);
|
|
44
|
+
if (!pc.ok) {
|
|
45
|
+
return {
|
|
46
|
+
ok: false,
|
|
47
|
+
reason: pc.reason ?? `precondition failed for step "${step.id}"`,
|
|
48
|
+
dispatched: false,
|
|
49
|
+
attempts: 0,
|
|
50
|
+
startMs,
|
|
51
|
+
endMs: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const isSubagent = step.run.kind === "subagent";
|
|
56
|
+
const maxAttempts = 1 + Math.max(0, step.retryPolicy?.maxReruns ?? 0);
|
|
57
|
+
let attempts = 0;
|
|
58
|
+
let lastResult;
|
|
59
|
+
let lastReason;
|
|
60
|
+
while (attempts < maxAttempts) {
|
|
61
|
+
attempts++;
|
|
62
|
+
if (step.run.kind === "deterministic") {
|
|
63
|
+
await step.run.thunk(ctx);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
lastResult = await dispatchSubagent(step.run, ctx);
|
|
67
|
+
}
|
|
68
|
+
if (!step.requiredOutput) {
|
|
69
|
+
return { ok: true, dispatched: isSubagent, attempts, result: lastResult, startMs, endMs: Date.now() };
|
|
70
|
+
}
|
|
71
|
+
const ro = await step.requiredOutput(ctx, lastResult);
|
|
72
|
+
if (ro.ok) {
|
|
73
|
+
return { ok: true, dispatched: isSubagent, attempts, result: lastResult, startMs, endMs: Date.now() };
|
|
74
|
+
}
|
|
75
|
+
lastReason = ro.reason;
|
|
76
|
+
// otherwise loop and rerun while attempts remain
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
reason: lastReason ?? `requiredOutput failed for step "${step.id}"`,
|
|
81
|
+
dispatched: isSubagent,
|
|
82
|
+
attempts,
|
|
83
|
+
result: lastResult,
|
|
84
|
+
startMs,
|
|
85
|
+
endMs: Date.now(),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// ── runWave ─────────────────────────────────────────────────────────────────
|
|
89
|
+
/**
|
|
90
|
+
* Dispatch every step in a wave concurrently via `Promise.all`. Steps sharing a
|
|
91
|
+
* wave are independent (no unresolved dependency), so they overlap. Returns the
|
|
92
|
+
* outcomes in the wave's step order. Concurrency is bounded by wave width
|
|
93
|
+
* (≤ 10 for the kb-doc wave), so no explicit limiter is needed this slice.
|
|
94
|
+
*/
|
|
95
|
+
export async function runWave(steps, run) {
|
|
96
|
+
return Promise.all(steps.map((step) => run(step)));
|
|
97
|
+
}
|
|
98
|
+
// ── topoSortWaves ─────────────────────────────────────────────────────────────
|
|
99
|
+
/**
|
|
100
|
+
* Group steps into topo-sorted waves (Kahn layering): every step whose
|
|
101
|
+
* dependencies are all satisfied by earlier waves lands in the next wave.
|
|
102
|
+
* Declaration order is preserved within a wave. Throws on a dependency cycle.
|
|
103
|
+
* Edges to unknown step ids are ignored (treated as already-satisfied).
|
|
104
|
+
*/
|
|
105
|
+
export function topoSortWaves(steps) {
|
|
106
|
+
const known = new Set(steps.map((s) => s.id));
|
|
107
|
+
const deps = new Map();
|
|
108
|
+
for (const s of steps) {
|
|
109
|
+
deps.set(s.id, (s.dependsOn ?? []).filter((d) => known.has(d)));
|
|
110
|
+
}
|
|
111
|
+
const waves = [];
|
|
112
|
+
const placed = new Set();
|
|
113
|
+
while (placed.size < steps.length) {
|
|
114
|
+
const layer = steps.filter((s) => !placed.has(s.id) && (deps.get(s.id) ?? []).every((d) => placed.has(d)));
|
|
115
|
+
if (layer.length === 0) {
|
|
116
|
+
const stuck = steps.filter((s) => !placed.has(s.id)).map((s) => s.id);
|
|
117
|
+
throw new Error(`init-steps: cyclic or unsatisfiable dependency among [${stuck.join(", ")}]`);
|
|
118
|
+
}
|
|
119
|
+
waves.push(layer);
|
|
120
|
+
for (const s of layer)
|
|
121
|
+
placed.add(s.id);
|
|
122
|
+
}
|
|
123
|
+
return waves;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=init-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-steps.js","sourceRoot":"","sources":["../../../../../src/extensions/forgecli/orchestrators/init/init-steps.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,yEAAyE;AACzE,0CAA0C;AAC1C,4EAA4E;AAC5E,8EAA8E;AAC9E,iFAAiF;AACjF,4EAA4E;AAC5E,+EAA+E;AAC/E,mEAAmE;AACnE,gEAAgE;AAChE,8EAA8E;AAC9E,+EAA+E;AAC/E,+BAA+B;AAC/B,0EAA0E;AAC1E,EAAE;AACF,gFAAgF;AAChF,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