@entelligentsia/forgecli 0.11.2 → 0.15.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/CHANGELOG.md +324 -0
- package/README.md +2 -1
- package/dist/CHANGELOG-forge-plugin.md +210 -0
- package/dist/bin/forge.js +20 -1
- package/dist/bin/forge.js.map +1 -1
- package/dist/extensions/forgecli/ask-user-tool.js +32 -20
- package/dist/extensions/forgecli/ask-user-tool.js.map +1 -1
- package/dist/extensions/forgecli/config-layer.d.ts +15 -0
- package/dist/extensions/forgecli/config-layer.js +4 -1
- package/dist/extensions/forgecli/config-layer.js.map +1 -1
- package/dist/extensions/forgecli/config-writer.js +4 -1
- package/dist/extensions/forgecli/config-writer.js.map +1 -1
- package/dist/extensions/forgecli/enhance.js +1 -1
- package/dist/extensions/forgecli/enhance.js.map +1 -1
- package/dist/extensions/forgecli/fix-bug.js +31 -1
- package/dist/extensions/forgecli/fix-bug.js.map +1 -1
- package/dist/extensions/forgecli/forge-cli-schema.json +19 -0
- package/dist/extensions/forgecli/forge-tools.js +80 -0
- package/dist/extensions/forgecli/forge-tools.js.map +1 -1
- package/dist/extensions/forgecli/forge-update-command.js +24 -18
- package/dist/extensions/forgecli/forge-update-command.js.map +1 -1
- package/dist/extensions/forgecli/friction-emit.d.ts +97 -0
- package/dist/extensions/forgecli/friction-emit.js +246 -0
- package/dist/extensions/forgecli/friction-emit.js.map +1 -0
- package/dist/extensions/forgecli/health-check.d.ts +10 -0
- package/dist/extensions/forgecli/health-check.js +160 -8
- package/dist/extensions/forgecli/health-check.js.map +1 -1
- package/dist/extensions/forgecli/hook-dispatcher.js +24 -2
- package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
- package/dist/extensions/forgecli/hooks/write-guard.js +5 -1
- package/dist/extensions/forgecli/hooks/write-guard.js.map +1 -1
- package/dist/extensions/forgecli/index.js +29 -5
- package/dist/extensions/forgecli/index.js.map +1 -1
- package/dist/extensions/forgecli/lib/store-error-remediation.d.ts +65 -0
- package/dist/extensions/forgecli/lib/store-error-remediation.js +298 -0
- package/dist/extensions/forgecli/lib/store-error-remediation.js.map +1 -0
- package/dist/extensions/forgecli/regenerate.d.ts +22 -0
- package/dist/extensions/forgecli/regenerate.js +133 -3
- package/dist/extensions/forgecli/regenerate.js.map +1 -1
- package/dist/extensions/forgecli/run-sprint.js +16 -1
- package/dist/extensions/forgecli/run-sprint.js.map +1 -1
- package/dist/extensions/forgecli/run-task.js +30 -8
- package/dist/extensions/forgecli/run-task.js.map +1 -1
- package/dist/extensions/forgecli/skill-curation-flag.d.ts +21 -0
- package/dist/extensions/forgecli/skill-curation-flag.js +71 -0
- package/dist/extensions/forgecli/skill-curation-flag.js.map +1 -0
- package/dist/extensions/forgecli/skill-curator-subagent.d.ts +101 -0
- package/dist/extensions/forgecli/skill-curator-subagent.js +342 -0
- package/dist/extensions/forgecli/skill-curator-subagent.js.map +1 -0
- package/dist/extensions/forgecli/skill-retriever.d.ts +84 -0
- package/dist/extensions/forgecli/skill-retriever.js +246 -0
- package/dist/extensions/forgecli/skill-retriever.js.map +1 -0
- package/dist/extensions/forgecli/skill-usage-tracker.d.ts +91 -0
- package/dist/extensions/forgecli/skill-usage-tracker.js +224 -0
- package/dist/extensions/forgecli/skill-usage-tracker.js.map +1 -0
- package/dist/extensions/forgecli/store-resolver.d.ts +18 -0
- package/dist/extensions/forgecli/store-resolver.js +44 -4
- package/dist/extensions/forgecli/store-resolver.js.map +1 -1
- package/dist/extensions/forgecli/store-validator.d.ts +3 -0
- package/dist/extensions/forgecli/store-validator.js +4 -2
- package/dist/extensions/forgecli/store-validator.js.map +1 -1
- package/dist/forge-payload/.base-pack/personas/supervisor.md +9 -0
- package/dist/forge-payload/.base-pack/workflows/enhance.md +344 -18
- package/dist/forge-payload/.claude-plugin/plugin.json +1 -1
- package/dist/forge-payload/.schemas/event.schema.json +20 -2
- package/dist/forge-payload/.schemas/migrations.json +112 -0
- package/dist/forge-payload/.schemas/proposal.schema.json +40 -0
- package/dist/forge-payload/agents/store-query-validator.md +103 -0
- package/dist/forge-payload/agents/tomoshibi.md +185 -0
- package/dist/forge-payload/commands/regenerate.md +109 -20
- package/dist/forge-payload/hooks/check-update.js +378 -0
- package/dist/forge-payload/hooks/forge-permissions.js +158 -0
- package/dist/forge-payload/hooks/triage-error.js +71 -0
- package/dist/forge-payload/hooks/validate-write.js +236 -0
- package/dist/forge-payload/integrity.json +32 -0
- package/dist/forge-payload/meta/workflows/meta-enhance.md +344 -18
- package/dist/forge-payload/schemas/structure-manifest.json +511 -0
- package/dist/forge-payload/tools/build-persona-pack.cjs +120 -11
- package/dist/forge-payload/tools/compression-gate.cjs +192 -0
- package/dist/forge-payload/tools/delete-candidate-detector.cjs +114 -0
- package/dist/forge-payload/tools/judge-proposal.cjs +177 -0
- package/dist/forge-payload/tools/manage-versions.cjs +132 -4
- package/dist/forge-payload/tools/queue-drain.cjs +152 -0
- package/dist/forge-payload/tools/replay-scoring.cjs +117 -0
- package/node_modules/@mariozechner/clipboard/package.json +2 -1
- package/node_modules/@mariozechner/clipboard-linux-x64-musl/README.md +3 -0
- package/node_modules/@mariozechner/clipboard-linux-x64-musl/clipboard.linux-x64-musl.node +0 -0
- package/node_modules/@mariozechner/clipboard-linux-x64-musl/package.json +25 -0
- package/package.json +4 -2
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// Per-task curator subagent — FORGE-S24-T10.
|
|
2
|
+
//
|
|
3
|
+
// At task close, the orchestrator hands a trajectory summary, the retrieved
|
|
4
|
+
// skills' bodies (from T08), and the task outcome to a curator subagent. The
|
|
5
|
+
// curator returns zero or more enhancement proposals (insert / update / delete
|
|
6
|
+
// of skill artifacts). This module:
|
|
7
|
+
//
|
|
8
|
+
// 1. Composes a task body that explicitly asks for proposals in a fenced
|
|
9
|
+
// ```json [...] block, with the canonical proposal schema embedded.
|
|
10
|
+
// 2. Dispatches via `runForgeSubagent` (Iron Law 10 — fresh in-process pi
|
|
11
|
+
// session, isolated context, persona-only context loader).
|
|
12
|
+
// 3. Parses zero or more proposals from the final assistant output, dropping
|
|
13
|
+
// any item that fails TypeBox schema validation.
|
|
14
|
+
// 4. Dedupes by `{op, target_path, sha256(diff_body)}` (mirrors T07's drain
|
|
15
|
+
// key — collisions never reach the sprint-close batch).
|
|
16
|
+
// 5. Writes the deduped batch to `.forge/enhancement-proposals/queue/<sprintId>/<taskId>-<ts>.json`
|
|
17
|
+
// (T07 layout) only when there is at least one proposal — zero noise on
|
|
18
|
+
// empty curator runs. If the canonical path already exists, the curator
|
|
19
|
+
// retries with a fresh `-N` suffix on the ts (append-only invariant —
|
|
20
|
+
// queue files are never overwritten).
|
|
21
|
+
//
|
|
22
|
+
// What this module DOES NOT do:
|
|
23
|
+
// - Emit phase events. The orchestrator (caller — `run-task.ts`,
|
|
24
|
+
// `fix-bug.ts`, gated behind FORGE-S24-T12 feature flag) is responsible
|
|
25
|
+
// for the Slice 2 contract: composing & emitting the canonical phase
|
|
26
|
+
// event from runtime telemetry. The curator subagent NEVER calls
|
|
27
|
+
// `store-cli emit` (IL10 / telemetry-actor-split).
|
|
28
|
+
// - Write to `forge/forge/meta/skills/` or `.forge/skills/`. The queue
|
|
29
|
+
// file is the sole sink. (TASK_PROMPT Acceptance Criterion 5.)
|
|
30
|
+
// - Decide WHEN task-close is. The caller invokes this at task close.
|
|
31
|
+
//
|
|
32
|
+
// Iron Laws (forge-cli-engineer):
|
|
33
|
+
// IL1 — code only under forge-cli/src/extensions/forgecli/
|
|
34
|
+
// IL2 — TypeScript + TypeBox; runtime input validated by Value.Parse.
|
|
35
|
+
// IL6 — no shell-string interpolation (no subprocess here; runForgeSubagent
|
|
36
|
+
// owns its spawn discipline).
|
|
37
|
+
// IL7 — failures return a typed result; subagent error surfaces in the
|
|
38
|
+
// returned record.
|
|
39
|
+
// IL10 — orchestrator dispatch via runForgeSubagent; this module emits
|
|
40
|
+
// ZERO phase events; the orchestrator owns runtime attribution and
|
|
41
|
+
// event emission after this function returns.
|
|
42
|
+
import * as fs from "node:fs";
|
|
43
|
+
import * as path from "node:path";
|
|
44
|
+
import * as crypto from "node:crypto";
|
|
45
|
+
import { Type } from "typebox";
|
|
46
|
+
import { Value } from "typebox/value";
|
|
47
|
+
import { getFinalOutput, runForgeSubagent, } from "./forge-subagent.js";
|
|
48
|
+
import { isSkillCurationEnabled } from "./skill-curation-flag.js";
|
|
49
|
+
// ── Public schemas ────────────────────────────────────────────────────────
|
|
50
|
+
/**
|
|
51
|
+
* One retrieved skill (T08 output) supplied to the curator as context.
|
|
52
|
+
* `body` is the actual SKILL.md text the agent was shown during the task —
|
|
53
|
+
* the curator reads it to decide whether the skill needs updating.
|
|
54
|
+
*/
|
|
55
|
+
export const RetrievedSkillBodySchema = Type.Object({
|
|
56
|
+
skillId: Type.String({ minLength: 1 }),
|
|
57
|
+
name: Type.String({ minLength: 1 }),
|
|
58
|
+
body: Type.String(),
|
|
59
|
+
});
|
|
60
|
+
export const TaskOutcomeSchema = Type.Object({
|
|
61
|
+
verdict: Type.Union([
|
|
62
|
+
Type.Literal("approved"),
|
|
63
|
+
Type.Literal("revision"),
|
|
64
|
+
Type.Literal("failed"),
|
|
65
|
+
Type.Literal("aborted"),
|
|
66
|
+
]),
|
|
67
|
+
notes: Type.Optional(Type.String()),
|
|
68
|
+
});
|
|
69
|
+
export const CuratorInputSchema = Type.Object({
|
|
70
|
+
sprintId: Type.String({ minLength: 1 }),
|
|
71
|
+
taskId: Type.String({ minLength: 1 }),
|
|
72
|
+
cwd: Type.String({ minLength: 1 }),
|
|
73
|
+
ts: Type.String({ minLength: 1 }),
|
|
74
|
+
trajectorySummary: Type.String(),
|
|
75
|
+
retrievedSkills: Type.Array(RetrievedSkillBodySchema),
|
|
76
|
+
outcome: TaskOutcomeSchema,
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* The enhancement proposal schema accepted by this module — mirrors
|
|
80
|
+
* `forge/forge/schemas/proposal.schema.json` (the queue-drain contract).
|
|
81
|
+
* `op` is restricted to the canonical three-op enum; other fields are
|
|
82
|
+
* passed through verbatim if present.
|
|
83
|
+
*
|
|
84
|
+
* Strict on required keys (so malformed items are dropped), permissive on
|
|
85
|
+
* optional keys (so the curator can supply rationale, sourceFrictionIds,
|
|
86
|
+
* generated_at, etc., without us re-enumerating the entire schema here).
|
|
87
|
+
*/
|
|
88
|
+
const ProposalSchema = Type.Object({
|
|
89
|
+
op: Type.Union([
|
|
90
|
+
Type.Literal("insert_skill"),
|
|
91
|
+
Type.Literal("update_skill"),
|
|
92
|
+
Type.Literal("delete_skill"),
|
|
93
|
+
]),
|
|
94
|
+
target_path: Type.String({ minLength: 1 }),
|
|
95
|
+
diff_body: Type.String(),
|
|
96
|
+
// Optional pass-through fields (kept minimal — extra unknown keys are
|
|
97
|
+
// also allowed; we use additionalProperties: true to let the curator
|
|
98
|
+
// supply rationale / sourceFrictionIds / generated_at / sprintId).
|
|
99
|
+
rationale: Type.Optional(Type.String()),
|
|
100
|
+
sourceFrictionIds: Type.Optional(Type.Array(Type.String())),
|
|
101
|
+
generated_at: Type.Optional(Type.String()),
|
|
102
|
+
sprintId: Type.Optional(Type.String()),
|
|
103
|
+
proposalId: Type.Optional(Type.String()),
|
|
104
|
+
}, { additionalProperties: true });
|
|
105
|
+
// ── Task-body composition ─────────────────────────────────────────────────
|
|
106
|
+
/**
|
|
107
|
+
* Compose the first user message for the curator subagent. The body embeds
|
|
108
|
+
* the trajectory summary, retrieved-skill bodies, and task outcome, and
|
|
109
|
+
* instructs the curator to return zero or more proposals in a fenced JSON
|
|
110
|
+
* block. The schema is described inline so the curator does not need to
|
|
111
|
+
* read an external file.
|
|
112
|
+
*/
|
|
113
|
+
export function composeCuratorTask(input) {
|
|
114
|
+
const lines = [];
|
|
115
|
+
lines.push(`# Skill-curator task — ${input.taskId}`);
|
|
116
|
+
lines.push("");
|
|
117
|
+
lines.push("You are reviewing one closed Forge task to decide whether any retrieved", "skill should be inserted, updated, or deleted based on what the agent", "actually did. Output zero or more enhancement proposals — empty is fine", "when nothing useful was learned.", "");
|
|
118
|
+
lines.push("## Sprint / Task");
|
|
119
|
+
lines.push(`- sprintId: ${input.sprintId}`);
|
|
120
|
+
lines.push(`- taskId: ${input.taskId}`);
|
|
121
|
+
lines.push(`- verdict: ${input.outcome.verdict}`);
|
|
122
|
+
if (input.outcome.notes) {
|
|
123
|
+
lines.push(`- notes: ${input.outcome.notes}`);
|
|
124
|
+
}
|
|
125
|
+
lines.push("");
|
|
126
|
+
lines.push("## Trajectory summary");
|
|
127
|
+
lines.push(input.trajectorySummary || "(none)");
|
|
128
|
+
lines.push("");
|
|
129
|
+
lines.push("## Retrieved skills (the agent was shown these)");
|
|
130
|
+
if (input.retrievedSkills.length === 0) {
|
|
131
|
+
lines.push("(none)");
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
for (const s of input.retrievedSkills) {
|
|
135
|
+
lines.push(`### ${s.name} (skillId: ${s.skillId})`);
|
|
136
|
+
lines.push("```");
|
|
137
|
+
lines.push(s.body);
|
|
138
|
+
lines.push("```");
|
|
139
|
+
lines.push("");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
lines.push("## Output format");
|
|
143
|
+
lines.push("Return a single fenced ```json``` block containing a JSON array.", "Each array element is one proposal with these required keys:", " - op: one of \"insert_skill\" | \"update_skill\" | \"delete_skill\"", " - target_path: repository-relative path (e.g. forge/skills/engineer-skills.md)", " - diff_body: unified-diff body, or full file body for inserts;", " may be empty string for delete_skill", "Optional keys: rationale, sourceFrictionIds, generated_at, sprintId.", "", "If there is nothing to propose, emit an empty array `[]`.", "Do NOT write any file yourself. Do NOT call store-cli or emit events.", "Your output is consumed by the orchestrator, which writes the queue file.");
|
|
144
|
+
return lines.join("\n");
|
|
145
|
+
}
|
|
146
|
+
// ── Output parsing ────────────────────────────────────────────────────────
|
|
147
|
+
/**
|
|
148
|
+
* Pull zero or more proposals from the curator's final assistant text.
|
|
149
|
+
* Strategy: try fenced ```json blocks first (the requested format), then
|
|
150
|
+
* fall back to a bare JSON array scan. Items that fail TypeBox validation
|
|
151
|
+
* are dropped — the failure mode for ill-formed proposals is silent
|
|
152
|
+
* exclusion, not exception, because the curator's output is best-effort.
|
|
153
|
+
*/
|
|
154
|
+
export function parseProposalsFromOutput(text) {
|
|
155
|
+
if (typeof text !== "string" || text.length === 0)
|
|
156
|
+
return [];
|
|
157
|
+
const candidates = [];
|
|
158
|
+
// 1. Fenced ```json blocks (preferred).
|
|
159
|
+
const fenceRe = /```(?:json|JSON)\s*([\s\S]*?)```/g;
|
|
160
|
+
let m;
|
|
161
|
+
while ((m = fenceRe.exec(text)) !== null) {
|
|
162
|
+
const inner = m[1].trim();
|
|
163
|
+
const parsed = tryParseJsonArray(inner);
|
|
164
|
+
if (parsed)
|
|
165
|
+
candidates.push(...parsed);
|
|
166
|
+
}
|
|
167
|
+
// 2. Fallback: scan for a bare JSON array if no fenced block produced
|
|
168
|
+
// items. Cheap heuristic — find the first `[` and try to parse from
|
|
169
|
+
// there to the matching `]`.
|
|
170
|
+
if (candidates.length === 0) {
|
|
171
|
+
const start = text.indexOf("[");
|
|
172
|
+
if (start >= 0) {
|
|
173
|
+
// Greedy: try the substring from `[` to the last `]`.
|
|
174
|
+
const end = text.lastIndexOf("]");
|
|
175
|
+
if (end > start) {
|
|
176
|
+
const inner = text.slice(start, end + 1);
|
|
177
|
+
const parsed = tryParseJsonArray(inner);
|
|
178
|
+
if (parsed)
|
|
179
|
+
candidates.push(...parsed);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const out = [];
|
|
184
|
+
for (const c of candidates) {
|
|
185
|
+
if (Value.Check(ProposalSchema, c)) {
|
|
186
|
+
out.push(c);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
function tryParseJsonArray(s) {
|
|
192
|
+
try {
|
|
193
|
+
const v = JSON.parse(s);
|
|
194
|
+
return Array.isArray(v) ? v : null;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ── Dedupe ────────────────────────────────────────────────────────────────
|
|
201
|
+
/**
|
|
202
|
+
* Mirror T07's `dedupeKey`: composite of op, target_path, sha256(diff_body).
|
|
203
|
+
* First-seen-wins.
|
|
204
|
+
*/
|
|
205
|
+
function dedupeKey(p) {
|
|
206
|
+
const h = crypto
|
|
207
|
+
.createHash("sha256")
|
|
208
|
+
.update(p.diff_body ?? "", "utf8")
|
|
209
|
+
.digest("hex");
|
|
210
|
+
return `${p.op}|${p.target_path}|${h}`;
|
|
211
|
+
}
|
|
212
|
+
function dedupeProposals(items) {
|
|
213
|
+
const seen = new Set();
|
|
214
|
+
const out = [];
|
|
215
|
+
for (const p of items) {
|
|
216
|
+
const k = dedupeKey(p);
|
|
217
|
+
if (seen.has(k))
|
|
218
|
+
continue;
|
|
219
|
+
seen.add(k);
|
|
220
|
+
out.push(p);
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
// ── Queue write ───────────────────────────────────────────────────────────
|
|
225
|
+
/**
|
|
226
|
+
* Compute the canonical queue file path. T07 layout:
|
|
227
|
+
* <cwd>/.forge/enhancement-proposals/queue/<sprintId>/<taskId>-<ts>.json
|
|
228
|
+
*
|
|
229
|
+
* If the canonical path already exists, suffix `-1`, `-2`, … until a free
|
|
230
|
+
* slot is found. Caller never overwrites an existing file (append-only).
|
|
231
|
+
*/
|
|
232
|
+
function chooseQueuePath(input) {
|
|
233
|
+
const dir = path.join(input.cwd, ".forge", "enhancement-proposals", "queue", input.sprintId);
|
|
234
|
+
const base = `${input.taskId}-${input.ts}`;
|
|
235
|
+
let candidate = path.join(dir, `${base}.json`);
|
|
236
|
+
let n = 1;
|
|
237
|
+
while (fs.existsSync(candidate)) {
|
|
238
|
+
candidate = path.join(dir, `${base}-${n}.json`);
|
|
239
|
+
n++;
|
|
240
|
+
}
|
|
241
|
+
return candidate;
|
|
242
|
+
}
|
|
243
|
+
function writeQueueFile(filePath, proposals) {
|
|
244
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
245
|
+
fs.writeFileSync(filePath, JSON.stringify(proposals, null, 2), "utf8");
|
|
246
|
+
}
|
|
247
|
+
// ── Curator persona ───────────────────────────────────────────────────────
|
|
248
|
+
/**
|
|
249
|
+
* Inline curator persona. We do NOT add a file under
|
|
250
|
+
* `forge/forge/meta/personas/` (Iron Law 1 — forge-cli only). The persona
|
|
251
|
+
* system prompt is small and self-contained; it tells the LLM to act as a
|
|
252
|
+
* skill curator and reiterates the output format and the no-write rule.
|
|
253
|
+
*
|
|
254
|
+
* The persona is exported so tests can introspect it; in production the
|
|
255
|
+
* defaultCuratorPersona() factory is consumed by runSkillCurator.
|
|
256
|
+
*/
|
|
257
|
+
export function defaultCuratorPersona() {
|
|
258
|
+
const systemPrompt = [
|
|
259
|
+
"You are the Forge **skill curator**.",
|
|
260
|
+
"",
|
|
261
|
+
"Your sole job is to look at one closed task — the trajectory summary,",
|
|
262
|
+
"the skills the agent was shown, and the outcome — and propose zero or",
|
|
263
|
+
"more enhancement proposals (insert / update / delete of skill artifacts).",
|
|
264
|
+
"",
|
|
265
|
+
"Hard rules:",
|
|
266
|
+
" - You NEVER write files yourself. Output proposals only.",
|
|
267
|
+
" - You NEVER call store-cli, emit events, or invoke tools that mutate",
|
|
268
|
+
" `.forge/store/`, `forge/skills/`, or `forge/meta/`.",
|
|
269
|
+
" - You return your proposals as a single fenced ```json``` block",
|
|
270
|
+
" containing a JSON array. Empty array `[]` is a valid answer.",
|
|
271
|
+
" - Each proposal MUST have: op, target_path, diff_body.",
|
|
272
|
+
" op ∈ { insert_skill, update_skill, delete_skill }.",
|
|
273
|
+
" - Be conservative: empty array beats a noisy or speculative proposal.",
|
|
274
|
+
].join("\n");
|
|
275
|
+
return {
|
|
276
|
+
name: "skill-curator",
|
|
277
|
+
description: "Forge per-task skill curator",
|
|
278
|
+
// Persona-only context (no extensions/skills/prompts) — read & write are
|
|
279
|
+
// not needed; we don't pass `tools` so pi's defaults apply, but the
|
|
280
|
+
// system prompt forbids writes. Caller may override.
|
|
281
|
+
systemPrompt,
|
|
282
|
+
filePath: "<inline:skill-curator>",
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
// ── Main entry ────────────────────────────────────────────────────────────
|
|
286
|
+
/**
|
|
287
|
+
* Run the per-task curator subagent and write its proposals to the
|
|
288
|
+
* enhancement-proposals queue. Always returns a typed result; never throws
|
|
289
|
+
* on subagent failure (IL7).
|
|
290
|
+
*
|
|
291
|
+
* Caller (orchestrator) is responsible for:
|
|
292
|
+
* - assembling `retrievedSkills` from the T08 retriever's output;
|
|
293
|
+
* - assembling `trajectorySummary` from the task transcript;
|
|
294
|
+
* - emitting the canonical phase event AFTER this call returns,
|
|
295
|
+
* using its own captured runtime telemetry (Slice 2 contract).
|
|
296
|
+
*/
|
|
297
|
+
export async function runSkillCurator(input) {
|
|
298
|
+
// FORGE-S24-T12 — gated rollout. Default off ⇒ no subagent dispatch,
|
|
299
|
+
// no queue file write. Returns success with `written: 0` so the
|
|
300
|
+
// orchestrator's caller sees the same "no proposals" outcome as a
|
|
301
|
+
// flag-on run that produced an empty proposal list.
|
|
302
|
+
if (!isSkillCurationEnabled(input.cwd)) {
|
|
303
|
+
return { exitCode: 0, written: 0 };
|
|
304
|
+
}
|
|
305
|
+
Value.Parse(CuratorInputSchema, input);
|
|
306
|
+
const persona = defaultCuratorPersona();
|
|
307
|
+
const task = composeCuratorTask(input);
|
|
308
|
+
let subResult;
|
|
309
|
+
try {
|
|
310
|
+
subResult = await runForgeSubagent({
|
|
311
|
+
persona,
|
|
312
|
+
task,
|
|
313
|
+
cwd: input.cwd,
|
|
314
|
+
exportTag: `${input.taskId}__skill-curator`,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
const e = err;
|
|
319
|
+
return {
|
|
320
|
+
exitCode: 1,
|
|
321
|
+
written: 0,
|
|
322
|
+
errorMessage: e.message ?? "runForgeSubagent threw",
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (subResult.exitCode !== 0) {
|
|
326
|
+
return {
|
|
327
|
+
exitCode: 1,
|
|
328
|
+
written: 0,
|
|
329
|
+
errorMessage: subResult.errorMessage ?? subResult.stopReason ?? "subagent failed",
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const finalText = getFinalOutput(subResult.messages);
|
|
333
|
+
const proposals = parseProposalsFromOutput(finalText);
|
|
334
|
+
const deduped = dedupeProposals(proposals);
|
|
335
|
+
if (deduped.length === 0) {
|
|
336
|
+
return { exitCode: 0, written: 0 };
|
|
337
|
+
}
|
|
338
|
+
const queueFile = chooseQueuePath(input);
|
|
339
|
+
writeQueueFile(queueFile, deduped);
|
|
340
|
+
return { exitCode: 0, written: deduped.length, queueFile };
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=skill-curator-subagent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-curator-subagent.js","sourceRoot":"","sources":["../../../src/extensions/forgecli/skill-curator-subagent.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;AAC/E,oCAAoC;AACpC,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,gEAAgE;AAChE,+EAA+E;AAC/E,sDAAsD;AACtD,8EAA8E;AAC9E,6DAA6D;AAC7D,sGAAsG;AACtG,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,2CAA2C;AAC3C,EAAE;AACF,gCAAgC;AAChC,mEAAmE;AACnE,4EAA4E;AAC5E,yEAAyE;AACzE,qEAAqE;AACrE,uDAAuD;AACvD,yEAAyE;AACzE,mEAAmE;AACnE,wEAAwE;AACxE,EAAE;AACF,kCAAkC;AAClC,8DAA8D;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C,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import lunr from "lunr";
|
|
2
|
+
import { type Static, Type } from "typebox";
|
|
3
|
+
/**
|
|
4
|
+
* One skill in the retrieval corpus. `frontmatter` is the parsed YAML head
|
|
5
|
+
* of the SKILL.md file (matches `loaders/persona-skill-loader.ts` Skill shape
|
|
6
|
+
* for `frontmatter` field). Only `description` plus selected frontmatter
|
|
7
|
+
* fields are indexed — the body is intentionally excluded to keep the index
|
|
8
|
+
* small and keyword-focused.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RetrievableSkillSchema: Type.TObject<{
|
|
11
|
+
skillId: Type.TString;
|
|
12
|
+
name: Type.TString;
|
|
13
|
+
description: Type.TString;
|
|
14
|
+
frontmatter: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
15
|
+
}>;
|
|
16
|
+
export type RetrievableSkill = Static<typeof RetrievableSkillSchema>;
|
|
17
|
+
export declare const RetrievalHitSchema: Type.TObject<{
|
|
18
|
+
skillId: Type.TString;
|
|
19
|
+
score: Type.TNumber;
|
|
20
|
+
}>;
|
|
21
|
+
export type RetrievalHit = Static<typeof RetrievalHitSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Runtime attribution supplied by the caller (orchestrator).
|
|
24
|
+
* These are NEVER fabricated inside the retriever (IL10).
|
|
25
|
+
*/
|
|
26
|
+
export declare const EmitRuntimeSchema: Type.TObject<{
|
|
27
|
+
storeCli: Type.TString;
|
|
28
|
+
cwd: Type.TString;
|
|
29
|
+
sprintId: Type.TString;
|
|
30
|
+
taskId: Type.TString;
|
|
31
|
+
role: Type.TString;
|
|
32
|
+
action: Type.TString;
|
|
33
|
+
phase: Type.TOptional<Type.TString>;
|
|
34
|
+
iteration: Type.TOptional<Type.TInteger>;
|
|
35
|
+
startTimestamp: Type.TString;
|
|
36
|
+
endTimestamp: Type.TString;
|
|
37
|
+
durationMinutes: Type.TNumber;
|
|
38
|
+
model: Type.TString;
|
|
39
|
+
provider: Type.TString;
|
|
40
|
+
}>;
|
|
41
|
+
export type EmitRuntime = Static<typeof EmitRuntimeSchema>;
|
|
42
|
+
export interface EmitResult {
|
|
43
|
+
emitted: number;
|
|
44
|
+
failed: number;
|
|
45
|
+
stderrs: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Opaque handle returned by `buildSkillIndex`. Internally pairs the lunr
|
|
49
|
+
* index with the corpus so `retrieveTopK` can return the original skillIds.
|
|
50
|
+
*/
|
|
51
|
+
export interface SkillIndex {
|
|
52
|
+
readonly _index: lunr.Index;
|
|
53
|
+
readonly _byRef: Map<string, RetrievableSkill>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build a BM25 index over the supplied corpus. Indexed fields:
|
|
57
|
+
* - `name` (boost 4) — the skill identifier itself
|
|
58
|
+
* - `description` (boost 2) — primary intent text
|
|
59
|
+
* - `frontmatter` (boost 1) — tags / aliases
|
|
60
|
+
*
|
|
61
|
+
* lunr's default scoring is Okapi BM25.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildSkillIndex(corpus: readonly RetrievableSkill[]): SkillIndex;
|
|
64
|
+
/**
|
|
65
|
+
* Return the top-k skills by BM25 score for the given query. Deterministic
|
|
66
|
+
* for fixed (corpus, query) pairs. Returns `[]` when no token in the query
|
|
67
|
+
* is present in any indexed field.
|
|
68
|
+
*/
|
|
69
|
+
export declare function retrieveTopK(index: SkillIndex, query: string, k: number): RetrievalHit[];
|
|
70
|
+
/**
|
|
71
|
+
* Clamp a raw BM25 score into the [0,1] window required by the event
|
|
72
|
+
* schema (`retrieval_score`). BM25 scores are unbounded above; we apply
|
|
73
|
+
* `s / (1 + s)` so the relative ordering is preserved while the absolute
|
|
74
|
+
* value is monotonically squashed into (0,1). Negative scores (lunr never
|
|
75
|
+
* produces these in practice) clamp to 0.
|
|
76
|
+
*/
|
|
77
|
+
export declare function clampRetrievalScore(rawScore: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* Emit one `skill_usage` event per supplied hit via
|
|
80
|
+
* `node <storeCli> emit <sprintId> <json>`. Returns the (emitted, failed)
|
|
81
|
+
* counts. Never throws on subprocess failure — the failure is surfaced via
|
|
82
|
+
* the returned counter and stderr text (IL7 — explicit, not silent).
|
|
83
|
+
*/
|
|
84
|
+
export declare function emitSkillUsageEvents(hits: readonly RetrievalHit[], runtime: EmitRuntime): EmitResult;
|