@cleocode/core 2026.6.15 → 2026.6.17
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/dist/docs/export-document.js +41 -0
- package/dist/docs/export-document.js.map +1 -1
- package/dist/gc/janitor.d.ts +149 -0
- package/dist/gc/janitor.d.ts.map +1 -0
- package/dist/gc/janitor.js +760 -0
- package/dist/gc/janitor.js.map +1 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +15 -4
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +78 -21
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/credential-pool.d.ts +62 -0
- package/dist/llm/credential-pool.d.ts.map +1 -1
- package/dist/llm/credential-pool.js +161 -0
- package/dist/llm/credential-pool.js.map +1 -1
- package/dist/llm/cross-provider-selector.d.ts +8 -3
- package/dist/llm/cross-provider-selector.d.ts.map +1 -1
- package/dist/llm/cross-provider-selector.js +71 -8
- package/dist/llm/cross-provider-selector.js.map +1 -1
- package/dist/llm/plugin-facade.js +122 -1
- package/dist/llm/plugin-facade.js.map +1 -1
- package/dist/selfimprove/fix-gen-context.d.ts +172 -0
- package/dist/selfimprove/fix-gen-context.d.ts.map +1 -0
- package/dist/selfimprove/fix-gen-context.js +218 -0
- package/dist/selfimprove/fix-gen-context.js.map +1 -0
- package/dist/selfimprove/fix-gen.d.ts +60 -4
- package/dist/selfimprove/fix-gen.d.ts.map +1 -1
- package/dist/selfimprove/fix-gen.js +91 -11
- package/dist/selfimprove/fix-gen.js.map +1 -1
- package/dist/selfimprove/op-source-map.d.ts +92 -0
- package/dist/selfimprove/op-source-map.d.ts.map +1 -0
- package/dist/selfimprove/op-source-map.js +187 -0
- package/dist/selfimprove/op-source-map.js.map +1 -0
- package/dist/selfimprove/probe-helper.d.ts +61 -0
- package/dist/selfimprove/probe-helper.d.ts.map +1 -0
- package/dist/selfimprove/probe-helper.js +64 -0
- package/dist/selfimprove/probe-helper.js.map +1 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/golden.json +18 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/scenario.json +12 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +1 -0
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/models-roles.d.ts +32 -1
- package/dist/setup/sections/models-roles.d.ts.map +1 -1
- package/dist/setup/sections/models-roles.js +118 -19
- package/dist/setup/sections/models-roles.js.map +1 -1
- package/dist/setup/whoami-summary.d.ts +34 -0
- package/dist/setup/whoami-summary.d.ts.map +1 -0
- package/dist/setup/whoami-summary.js +106 -0
- package/dist/setup/whoami-summary.js.map +1 -0
- package/package.json +12 -12
|
@@ -40,6 +40,14 @@
|
|
|
40
40
|
import { writeFileSync } from 'node:fs';
|
|
41
41
|
import { resolve as resolvePath } from 'node:path';
|
|
42
42
|
import { cwd as processCwd } from 'node:process';
|
|
43
|
+
import { redact } from '@cleocode/utils';
|
|
44
|
+
import { loadFileContext, renderFileContextSection, } from './fix-gen-context.js';
|
|
45
|
+
/**
|
|
46
|
+
* Maximum byte length of a model-reply excerpt stored in DHQ evidence or logs.
|
|
47
|
+
* Replies beyond this threshold are truncated with a marker so logs stay bounded
|
|
48
|
+
* while preserving enough context for diagnosis.
|
|
49
|
+
*/
|
|
50
|
+
const REPLY_EXCERPT_MAX_BYTES = 3072;
|
|
43
51
|
/**
|
|
44
52
|
* The E9 system-of-use label the fix-generator resolves its model under. Maps to
|
|
45
53
|
* the `judgement` role (see `SYSTEM_ROLE_MAP`) — the closest standing role for
|
|
@@ -83,14 +91,27 @@ export function looksLikeUnifiedDiff(text) {
|
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* Build the system + user prompt the real generator sends to the LLM. Pure
|
|
86
|
-
* (no IO) so it is unit-testable in isolation
|
|
87
|
-
*
|
|
88
|
-
*
|
|
94
|
+
* (no IO) so it is unit-testable in isolation when an explicit `fileContext` is
|
|
95
|
+
* passed; the default path calls {@link loadFileContext} to resolve the relevant
|
|
96
|
+
* source files for each regressing op-coordinate (IO-bearing path used in
|
|
97
|
+
* production).
|
|
98
|
+
*
|
|
99
|
+
* The prompt is deliberately strict: "respond with ONLY a unified diff" — anything
|
|
100
|
+
* else fails {@link looksLikeUnifiedDiff} downstream and degrades to "no patch".
|
|
101
|
+
* When file context is available it is embedded between the regression description
|
|
102
|
+
* and the "produce the diff" instruction so the model can locate the responsible
|
|
103
|
+
* code. When context is absent (unmapped op or budget exhausted) the model is
|
|
104
|
+
* explicitly told it may respond `NO_PATCH` — this keeps the prompt honest.
|
|
89
105
|
*
|
|
90
106
|
* @param request - The fix-generation request.
|
|
107
|
+
* @param fileContext - Optional pre-loaded file context (injected for pure unit
|
|
108
|
+
* tests). When absent, {@link loadFileContext} is called with the request's
|
|
109
|
+
* `repoContext.projectRoot` and the op-coordinates from `regressions`.
|
|
91
110
|
* @returns The `{ system, user }` prompt pair.
|
|
111
|
+
*
|
|
112
|
+
* @task T11988
|
|
92
113
|
*/
|
|
93
|
-
export function buildFixGenPrompt(request) {
|
|
114
|
+
export function buildFixGenPrompt(request, fileContext) {
|
|
94
115
|
const system = 'You are an autonomous software-maintenance agent. You are given a detected ' +
|
|
95
116
|
'regression in a TypeScript monorepo (a divergence between a replayed scenario ' +
|
|
96
117
|
'and its golden expected output). Produce a MINIMAL fix as a single unified diff ' +
|
|
@@ -100,14 +121,48 @@ export function buildFixGenPrompt(request) {
|
|
|
100
121
|
'NO_PATCH.';
|
|
101
122
|
const lines = request.regressions.map((r) => `- op ${r.opCoord} (#${r.opIndex}) at path \`${r.path}\`: ` +
|
|
102
123
|
`actual=${JSON.stringify(r.actual)} expected=${JSON.stringify(r.expected)}`);
|
|
124
|
+
// Resolve file context: use the pre-loaded context (pure test path) or load it
|
|
125
|
+
// now from disk (production path). Either way we render the same section string.
|
|
126
|
+
const ctx = fileContext ??
|
|
127
|
+
loadFileContext({
|
|
128
|
+
projectRoot: request.repoContext.projectRoot,
|
|
129
|
+
opCoords: request.regressions.map((r) => r.opCoord),
|
|
130
|
+
...request.repoContext.contextBudget,
|
|
131
|
+
});
|
|
132
|
+
const fileSection = renderFileContextSection(ctx);
|
|
103
133
|
const user = `Regression ${request.dhqId} in scenario \`${request.scenario}\` ` +
|
|
104
134
|
`(${request.regressions.length} diverging path(s)).\n` +
|
|
105
135
|
(request.repoContext.summary ? `Scenario summary: ${request.repoContext.summary}\n` : '') +
|
|
106
136
|
`Project root: ${request.repoContext.projectRoot}\n\n` +
|
|
107
|
-
`Diverging paths:\n${lines.join('\n')}\n
|
|
108
|
-
|
|
137
|
+
`Diverging paths:\n${lines.join('\n')}\n` +
|
|
138
|
+
(fileSection
|
|
139
|
+
? `\n${fileSection}\n`
|
|
140
|
+
: '\n[No source file context available — respond NO_PATCH if you cannot locate the fix.]\n') +
|
|
141
|
+
'\nProduce the unified diff that resolves these divergences.';
|
|
109
142
|
return { system, user };
|
|
110
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Produce a credential-redacted, byte-bounded excerpt of a raw model reply for
|
|
146
|
+
* safe logging and DHQ evidence attachment.
|
|
147
|
+
*
|
|
148
|
+
* The excerpt is at most {@link REPLY_EXCERPT_MAX_BYTES} UTF-8 bytes. When the
|
|
149
|
+
* reply is longer a `…[truncated <N> bytes]` marker replaces the tail so the
|
|
150
|
+
* caller can distinguish a genuinely-short reply from a truncated one. The
|
|
151
|
+
* returned string is already passed through {@link redact} so no downstream
|
|
152
|
+
* scrubbing is needed.
|
|
153
|
+
*
|
|
154
|
+
* @param reply - The raw model reply text.
|
|
155
|
+
* @returns A scrubbed, bounded excerpt string.
|
|
156
|
+
*/
|
|
157
|
+
export function truncateReply(reply) {
|
|
158
|
+
const scrubbed = redact(reply);
|
|
159
|
+
const buf = Buffer.from(scrubbed, 'utf8');
|
|
160
|
+
if (buf.byteLength <= REPLY_EXCERPT_MAX_BYTES)
|
|
161
|
+
return scrubbed;
|
|
162
|
+
const truncated = buf.subarray(0, REPLY_EXCERPT_MAX_BYTES).toString('utf8');
|
|
163
|
+
const overflow = buf.byteLength - REPLY_EXCERPT_MAX_BYTES;
|
|
164
|
+
return `${truncated}…[truncated ${overflow} bytes]`;
|
|
165
|
+
}
|
|
111
166
|
/**
|
|
112
167
|
* Lazily-resolved module logger (import-time side-effect-free).
|
|
113
168
|
*/
|
|
@@ -156,12 +211,28 @@ export async function generateFixPatch(opts) {
|
|
|
156
211
|
return { kind: 'skipped', reason };
|
|
157
212
|
}
|
|
158
213
|
if (output.kind === 'none') {
|
|
159
|
-
|
|
160
|
-
|
|
214
|
+
// For model-declined the generator already pre-sanitized the rawReply field;
|
|
215
|
+
// log it at debug so the reply is visible without noise on green runs.
|
|
216
|
+
const replyExcerpt = output.rawReply;
|
|
217
|
+
if (replyExcerpt !== undefined) {
|
|
218
|
+
logger.debug({ dhqId: request.dhqId, scenario: request.scenario, reason: output.reason, replyExcerpt }, 'fix-gen model declined — raw reply excerpt (redacted, truncated) attached to DHQ evidence');
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
logger.info({ dhqId: request.dhqId, scenario: request.scenario, reason: output.reason }, 'fix-gen produced no patch (graceful skip — no PR)');
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
kind: 'skipped',
|
|
225
|
+
reason: `fixgen-none:${output.reason}`,
|
|
226
|
+
...(replyExcerpt !== undefined ? { replyExcerpt } : {}),
|
|
227
|
+
};
|
|
161
228
|
}
|
|
162
229
|
if (!looksLikeUnifiedDiff(output.diff)) {
|
|
163
|
-
|
|
164
|
-
|
|
230
|
+
// The model returned something but it is not a unified diff. Log the reply
|
|
231
|
+
// excerpt at warn (actionable — the model may need a prompt tweak) and
|
|
232
|
+
// attach it to the DHQ evidence row for the operator.
|
|
233
|
+
const replyExcerpt = truncateReply(output.diff);
|
|
234
|
+
logger.warn({ dhqId: request.dhqId, scenario: request.scenario, replyExcerpt }, 'fix-gen output is not a unified diff (graceful skip — no PR); raw reply attached to DHQ evidence');
|
|
235
|
+
return { kind: 'skipped', reason: 'fixgen-not-a-diff', replyExcerpt };
|
|
165
236
|
}
|
|
166
237
|
// Normalize a trailing newline so `git apply` accepts the hunk.
|
|
167
238
|
const diff = output.diff.endsWith('\n') ? output.diff : `${output.diff}\n`;
|
|
@@ -239,7 +310,16 @@ export function createLlmFixGenerator(opts = {}) {
|
|
|
239
310
|
});
|
|
240
311
|
const text = (response.content ?? '').trim();
|
|
241
312
|
if (text.length === 0 || text === 'NO_PATCH') {
|
|
242
|
-
|
|
313
|
+
// Attach a redacted, bounded excerpt so the caller can log it onto
|
|
314
|
+
// the DHQ evidence row without having to re-run. The empty-reply case
|
|
315
|
+
// carries no useful excerpt; only the non-empty case (e.g. prose like
|
|
316
|
+
// "I cannot fix this") is worth capturing.
|
|
317
|
+
const rawReply = text.length > 0 ? truncateReply(text) : undefined;
|
|
318
|
+
return {
|
|
319
|
+
kind: 'none',
|
|
320
|
+
reason: 'model-declined',
|
|
321
|
+
...(rawReply !== undefined ? { rawReply } : {}),
|
|
322
|
+
};
|
|
243
323
|
}
|
|
244
324
|
return { kind: 'patch', diff: stripCodeFences(text), model: response.model };
|
|
245
325
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-gen.js","sourceRoot":"","sources":["../../src/selfimprove/fix-gen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"fix-gen.js","sourceRoot":"","sources":["../../src/selfimprove/fix-gen.ts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AAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/E,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CACT,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAChF,iDAAiD,CAClD,CAAC;gBACF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;YACrD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,KAAK,GAAG,+BAA+B,CAAC;IAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static op-coordinate → source-file map for the self-improvement fix-gen stage.
|
|
3
|
+
*
|
|
4
|
+
* Given a regression's `opCoord` (the `domain.operation` string produced by
|
|
5
|
+
* {@link "../selfimprove/envelope-diff.js".DiffEntry.opCoord}, e.g. `tasks.show`),
|
|
6
|
+
* this module resolves the **repo-relative** paths of the CLI handler and the
|
|
7
|
+
* core module(s) most likely to contain the regression. The file list is fed into
|
|
8
|
+
* the fix-gen prompt builder ({@link "./fix-gen-context.js"}) so the LLM receives
|
|
9
|
+
* bounded, targeted code context rather than zero context or an unbounded repo
|
|
10
|
+
* dump.
|
|
11
|
+
*
|
|
12
|
+
* ## Design: static map, not a registry query
|
|
13
|
+
*
|
|
14
|
+
* The ops catalog (the `OPERATIONS` array in `@cleocode/contracts`) encodes
|
|
15
|
+
* `{ gateway, domain, operation }` but does NOT track source-file provenance.
|
|
16
|
+
* Runtime nexus queries (`cleo nexus query`) would work but introduce an
|
|
17
|
+
* in-process dependency on the nexus subsystem (an expensive side-effectful
|
|
18
|
+
* import in the fix-gen hot path). A **static map keyed by `domain.operation`**
|
|
19
|
+
* is the cost-free alternative: it is derived once (by reading the repo's known
|
|
20
|
+
* handler layout), is small enough to inline, and carries zero import-time cost.
|
|
21
|
+
*
|
|
22
|
+
* The map covers the common `tasks` domain operations exercised by the canonical
|
|
23
|
+
* scenarios. The entry for an unregistered `opCoord` returns an empty file list
|
|
24
|
+
* (`{ handlerFiles: [], coreFiles: [] }`) — the fix-gen stage degrades gracefully
|
|
25
|
+
* to "no context" (the model still receives the regression diff and may emit
|
|
26
|
+
* `NO_PATCH`, which is the honest outcome when context is absent).
|
|
27
|
+
*
|
|
28
|
+
* ## File path convention
|
|
29
|
+
*
|
|
30
|
+
* Every path is **repo-relative** (no leading `/`). The file content loader
|
|
31
|
+
* ({@link "./fix-gen-context.js"}) resolves them against `repoContext.projectRoot`
|
|
32
|
+
* before reading.
|
|
33
|
+
*
|
|
34
|
+
* Import-time side-effect-free: no IO, no dynamic imports.
|
|
35
|
+
*
|
|
36
|
+
* @module @cleocode/core/selfimprove/op-source-map
|
|
37
|
+
* @epic T11889
|
|
38
|
+
* @task T11988
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Resolved source files for one op-coordinate.
|
|
42
|
+
*
|
|
43
|
+
* - `handlerFiles`: the CLI dispatch handler(s) in `packages/cleo/src/dispatch/domains/`
|
|
44
|
+
* - `coreFiles`: the core-logic module(s) in `packages/core/src/` (the file most
|
|
45
|
+
* likely to contain the regression for this operation)
|
|
46
|
+
*
|
|
47
|
+
* Both lists are repo-relative. Either may be empty when not applicable.
|
|
48
|
+
*/
|
|
49
|
+
export interface OpSourceEntry {
|
|
50
|
+
/** CLI dispatch handler files (repo-relative). */
|
|
51
|
+
readonly handlerFiles: readonly string[];
|
|
52
|
+
/** Core module files that implement the operation logic (repo-relative). */
|
|
53
|
+
readonly coreFiles: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the handler + core source files for a given op-coordinate.
|
|
57
|
+
*
|
|
58
|
+
* Returns the {@link OpSourceEntry} from the static map when the `opCoord` is
|
|
59
|
+
* registered, or {@link EMPTY_ENTRY} when it is not. NEVER throws. The returned
|
|
60
|
+
* lists contain repo-relative paths; callers resolve them against the project root
|
|
61
|
+
* before reading.
|
|
62
|
+
*
|
|
63
|
+
* @param opCoord - The op coordinate to resolve (e.g. `'tasks.show'`).
|
|
64
|
+
* @returns The resolved {@link OpSourceEntry} (may be empty for unknown ops).
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const { handlerFiles, coreFiles } = resolveOpSourceFiles('tasks.show');
|
|
69
|
+
* // handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts']
|
|
70
|
+
* // coreFiles: ['packages/core/src/tasks/show.ts']
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveOpSourceFiles(opCoord: string): OpSourceEntry;
|
|
74
|
+
/**
|
|
75
|
+
* Collect the unique set of source files for a list of op-coordinates.
|
|
76
|
+
*
|
|
77
|
+
* Deduplicates across entries so a scenario with two ops from the same handler
|
|
78
|
+
* does not include the handler twice. Returns the merged `{ handlerFiles, coreFiles }`
|
|
79
|
+
* with order preserved (first-seen wins for dedup).
|
|
80
|
+
*
|
|
81
|
+
* @param opCoords - The op-coordinate strings to collect files for.
|
|
82
|
+
* @returns The merged, deduplicated {@link OpSourceEntry}.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const entry = collectOpSourceFiles(['tasks.find', 'tasks.show']);
|
|
87
|
+
* // entry.handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts']
|
|
88
|
+
* // entry.coreFiles: ['packages/core/src/tasks/find.ts', 'packages/core/src/tasks/show.ts']
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function collectOpSourceFiles(opCoords: readonly string[]): OpSourceEntry;
|
|
92
|
+
//# sourceMappingURL=op-source-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-source-map.d.ts","sourceRoot":"","sources":["../../src/selfimprove/op-source-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AA2FD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAEnE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAuB/E"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static op-coordinate → source-file map for the self-improvement fix-gen stage.
|
|
3
|
+
*
|
|
4
|
+
* Given a regression's `opCoord` (the `domain.operation` string produced by
|
|
5
|
+
* {@link "../selfimprove/envelope-diff.js".DiffEntry.opCoord}, e.g. `tasks.show`),
|
|
6
|
+
* this module resolves the **repo-relative** paths of the CLI handler and the
|
|
7
|
+
* core module(s) most likely to contain the regression. The file list is fed into
|
|
8
|
+
* the fix-gen prompt builder ({@link "./fix-gen-context.js"}) so the LLM receives
|
|
9
|
+
* bounded, targeted code context rather than zero context or an unbounded repo
|
|
10
|
+
* dump.
|
|
11
|
+
*
|
|
12
|
+
* ## Design: static map, not a registry query
|
|
13
|
+
*
|
|
14
|
+
* The ops catalog (the `OPERATIONS` array in `@cleocode/contracts`) encodes
|
|
15
|
+
* `{ gateway, domain, operation }` but does NOT track source-file provenance.
|
|
16
|
+
* Runtime nexus queries (`cleo nexus query`) would work but introduce an
|
|
17
|
+
* in-process dependency on the nexus subsystem (an expensive side-effectful
|
|
18
|
+
* import in the fix-gen hot path). A **static map keyed by `domain.operation`**
|
|
19
|
+
* is the cost-free alternative: it is derived once (by reading the repo's known
|
|
20
|
+
* handler layout), is small enough to inline, and carries zero import-time cost.
|
|
21
|
+
*
|
|
22
|
+
* The map covers the common `tasks` domain operations exercised by the canonical
|
|
23
|
+
* scenarios. The entry for an unregistered `opCoord` returns an empty file list
|
|
24
|
+
* (`{ handlerFiles: [], coreFiles: [] }`) — the fix-gen stage degrades gracefully
|
|
25
|
+
* to "no context" (the model still receives the regression diff and may emit
|
|
26
|
+
* `NO_PATCH`, which is the honest outcome when context is absent).
|
|
27
|
+
*
|
|
28
|
+
* ## File path convention
|
|
29
|
+
*
|
|
30
|
+
* Every path is **repo-relative** (no leading `/`). The file content loader
|
|
31
|
+
* ({@link "./fix-gen-context.js"}) resolves them against `repoContext.projectRoot`
|
|
32
|
+
* before reading.
|
|
33
|
+
*
|
|
34
|
+
* Import-time side-effect-free: no IO, no dynamic imports.
|
|
35
|
+
*
|
|
36
|
+
* @module @cleocode/core/selfimprove/op-source-map
|
|
37
|
+
* @epic T11889
|
|
38
|
+
* @task T11988
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The static `opCoord → source files` map.
|
|
42
|
+
*
|
|
43
|
+
* Keys are `domain.operation` strings (lowercase, e.g. `'tasks.show'`). Values
|
|
44
|
+
* are {@link OpSourceEntry} objects with repo-relative paths.
|
|
45
|
+
*
|
|
46
|
+
* Coverage: the `tasks` domain operations exercised by the built-in scenarios
|
|
47
|
+
* (T11988: `seeded-code-regression`) plus the pre-existing `dhq-replay-find`
|
|
48
|
+
* scenario (`tasks.find`, `tasks.show`).
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
const OP_SOURCE_MAP = {
|
|
53
|
+
'tasks.show': {
|
|
54
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
55
|
+
coreFiles: ['packages/core/src/tasks/show.ts'],
|
|
56
|
+
},
|
|
57
|
+
'tasks.find': {
|
|
58
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
59
|
+
coreFiles: ['packages/core/src/tasks/find.ts'],
|
|
60
|
+
},
|
|
61
|
+
'tasks.list': {
|
|
62
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
63
|
+
coreFiles: ['packages/core/src/tasks/list.ts'],
|
|
64
|
+
},
|
|
65
|
+
'tasks.add': {
|
|
66
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
67
|
+
coreFiles: ['packages/core/src/tasks/add.ts'],
|
|
68
|
+
},
|
|
69
|
+
'tasks.update': {
|
|
70
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
71
|
+
coreFiles: ['packages/core/src/tasks/update.ts'],
|
|
72
|
+
},
|
|
73
|
+
'tasks.complete': {
|
|
74
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
75
|
+
coreFiles: ['packages/core/src/tasks/complete.ts'],
|
|
76
|
+
},
|
|
77
|
+
'tasks.delete': {
|
|
78
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
79
|
+
coreFiles: ['packages/core/src/tasks/delete.ts'],
|
|
80
|
+
},
|
|
81
|
+
'tasks.next': {
|
|
82
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
83
|
+
coreFiles: ['packages/core/src/tasks/next.ts'],
|
|
84
|
+
},
|
|
85
|
+
'tasks.current': {
|
|
86
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
87
|
+
coreFiles: ['packages/core/src/tasks/current.ts'],
|
|
88
|
+
},
|
|
89
|
+
'tasks.tree': {
|
|
90
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
91
|
+
coreFiles: ['packages/core/src/tasks/generic-tree.ts'],
|
|
92
|
+
},
|
|
93
|
+
'tasks.analyze': {
|
|
94
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'],
|
|
95
|
+
coreFiles: ['packages/core/src/tasks/analyze.ts'],
|
|
96
|
+
},
|
|
97
|
+
'memory.find': {
|
|
98
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/memory.ts'],
|
|
99
|
+
coreFiles: [],
|
|
100
|
+
},
|
|
101
|
+
'memory.fetch': {
|
|
102
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/memory.ts'],
|
|
103
|
+
coreFiles: [],
|
|
104
|
+
},
|
|
105
|
+
'selfimprove.run': {
|
|
106
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/selfimprove.ts'],
|
|
107
|
+
coreFiles: ['packages/core/src/selfimprove/run-loop.ts'],
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* `selfimprove.probe` — the seeded-code-regression scenario target (T11988).
|
|
111
|
+
* The probe-helper is intentionally broken (`probeVersion()` returns `2`
|
|
112
|
+
* instead of `1`); the fix is a single-line change in this file.
|
|
113
|
+
*/
|
|
114
|
+
'selfimprove.probe': {
|
|
115
|
+
handlerFiles: ['packages/cleo/src/dispatch/domains/selfimprove.ts'],
|
|
116
|
+
coreFiles: ['packages/core/src/selfimprove/probe-helper.ts'],
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* An empty source entry returned for unknown or unmapped op-coordinates.
|
|
121
|
+
*
|
|
122
|
+
* The fix-gen stage treats an empty file list as "no context available" and
|
|
123
|
+
* degrades the prompt to the regression-only view. The model may still produce
|
|
124
|
+
* a patch (or `NO_PATCH`) without file context.
|
|
125
|
+
*/
|
|
126
|
+
const EMPTY_ENTRY = { handlerFiles: [], coreFiles: [] };
|
|
127
|
+
/**
|
|
128
|
+
* Resolve the handler + core source files for a given op-coordinate.
|
|
129
|
+
*
|
|
130
|
+
* Returns the {@link OpSourceEntry} from the static map when the `opCoord` is
|
|
131
|
+
* registered, or {@link EMPTY_ENTRY} when it is not. NEVER throws. The returned
|
|
132
|
+
* lists contain repo-relative paths; callers resolve them against the project root
|
|
133
|
+
* before reading.
|
|
134
|
+
*
|
|
135
|
+
* @param opCoord - The op coordinate to resolve (e.g. `'tasks.show'`).
|
|
136
|
+
* @returns The resolved {@link OpSourceEntry} (may be empty for unknown ops).
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* const { handlerFiles, coreFiles } = resolveOpSourceFiles('tasks.show');
|
|
141
|
+
* // handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts']
|
|
142
|
+
* // coreFiles: ['packages/core/src/tasks/show.ts']
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function resolveOpSourceFiles(opCoord) {
|
|
146
|
+
return OP_SOURCE_MAP[opCoord] ?? EMPTY_ENTRY;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Collect the unique set of source files for a list of op-coordinates.
|
|
150
|
+
*
|
|
151
|
+
* Deduplicates across entries so a scenario with two ops from the same handler
|
|
152
|
+
* does not include the handler twice. Returns the merged `{ handlerFiles, coreFiles }`
|
|
153
|
+
* with order preserved (first-seen wins for dedup).
|
|
154
|
+
*
|
|
155
|
+
* @param opCoords - The op-coordinate strings to collect files for.
|
|
156
|
+
* @returns The merged, deduplicated {@link OpSourceEntry}.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const entry = collectOpSourceFiles(['tasks.find', 'tasks.show']);
|
|
161
|
+
* // entry.handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts']
|
|
162
|
+
* // entry.coreFiles: ['packages/core/src/tasks/find.ts', 'packages/core/src/tasks/show.ts']
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function collectOpSourceFiles(opCoords) {
|
|
166
|
+
const seenHandler = new Set();
|
|
167
|
+
const seenCore = new Set();
|
|
168
|
+
const handlerFiles = [];
|
|
169
|
+
const coreFiles = [];
|
|
170
|
+
for (const coord of opCoords) {
|
|
171
|
+
const entry = resolveOpSourceFiles(coord);
|
|
172
|
+
for (const f of entry.handlerFiles) {
|
|
173
|
+
if (!seenHandler.has(f)) {
|
|
174
|
+
seenHandler.add(f);
|
|
175
|
+
handlerFiles.push(f);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const f of entry.coreFiles) {
|
|
179
|
+
if (!seenCore.has(f)) {
|
|
180
|
+
seenCore.add(f);
|
|
181
|
+
coreFiles.push(f);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { handlerFiles, coreFiles };
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=op-source-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-source-map.js","sourceRoot":"","sources":["../../src/selfimprove/op-source-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAkBH;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAA4C;IAC7D,YAAY,EAAE;QACZ,YAAY,EAAE,CAAC,6CAA6C,CAAC;QAC7D,SAAS,EAAE,CAAC,iCAAiC,CAAC;KAC/C;IACD,YAAY,EAAE;QACZ,YAAY,EAAE,CAAC,6CAA6C,CAAC;QAC7D,SAAS,EAAE,CAAC,iCAAiC,CAAC;KAC/C;IACD,YAAY,EAAE;QACZ,YAAY,EAAE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
1
|
+
/**
|
|
2
|
+
* Self-improvement probe helper — selfimprove.probe op (T11988).
|
|
3
|
+
*
|
|
4
|
+
* This tiny module exists to give the seeded-code-regression scenario a
|
|
5
|
+
* **real, patchable code bug** for end-to-end fix-gen proof. The function
|
|
6
|
+
* {@link probeVersion} is supposed to return `1` (the canonical probe API
|
|
7
|
+
* version), but ships with an intentional off-by-one (`return 2`) so that a
|
|
8
|
+
* live replay of the `seeded-code-regression` scenario diverges from the
|
|
9
|
+
* golden (`version: 1`) and the LLM can produce a correct one-line unified
|
|
10
|
+
* diff to fix it.
|
|
11
|
+
*
|
|
12
|
+
* ### Why a dedicated file?
|
|
13
|
+
*
|
|
14
|
+
* The seeded bug must be:
|
|
15
|
+
* 1. **In a repo-relative path** the op-source-map can register under
|
|
16
|
+
* `selfimprove.probe` so the fix-gen context loader includes it in the
|
|
17
|
+
* LLM prompt.
|
|
18
|
+
* 2. **Minimal** — the simplest possible off-by-one so the model cannot
|
|
19
|
+
* rationally refuse (`NO_PATCH`).
|
|
20
|
+
* 3. **Self-contained** — no live DB, no side effects; the probe op
|
|
21
|
+
* never mutates.
|
|
22
|
+
*
|
|
23
|
+
* ### Fixing the bug
|
|
24
|
+
*
|
|
25
|
+
* Change `return 2` → `return 1` in {@link probeVersion}. This is the EXACT
|
|
26
|
+
* one-line fix the self-improvement loop's LLM fix-gen stage should propose
|
|
27
|
+
* when replaying the seeded scenario.
|
|
28
|
+
*
|
|
29
|
+
* @module @cleocode/core/selfimprove/probe-helper
|
|
30
|
+
* @task T11988
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Return the canonical probe API version.
|
|
34
|
+
*
|
|
35
|
+
* Expected value: `1`.
|
|
36
|
+
*
|
|
37
|
+
* @returns The probe version number.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* probeVersion(); // => 1 (expected)
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @bug SEEDED — currently returns `2` instead of `1` (T11988 intentional).
|
|
45
|
+
* The seeded-code-regression scenario golden asserts `version: 1`; the
|
|
46
|
+
* mismatch is the regression the fix-gen LLM prompt targets.
|
|
47
|
+
*/
|
|
48
|
+
export declare function probeVersion(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Build the `selfimprove.probe` response payload.
|
|
51
|
+
*
|
|
52
|
+
* Returns `{ probe: 'ok', version: <probeVersion()> }` — the envelope `data`
|
|
53
|
+
* block the `selfimprove.probe` query op emits.
|
|
54
|
+
*
|
|
55
|
+
* @returns The probe response payload.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildProbePayload(): {
|
|
58
|
+
probe: 'ok';
|
|
59
|
+
version: number;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=probe-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe-helper.d.ts","sourceRoot":"","sources":["../../src/selfimprove/probe-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAEpE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-improvement probe helper — selfimprove.probe op (T11988).
|
|
3
|
+
*
|
|
4
|
+
* This tiny module exists to give the seeded-code-regression scenario a
|
|
5
|
+
* **real, patchable code bug** for end-to-end fix-gen proof. The function
|
|
6
|
+
* {@link probeVersion} is supposed to return `1` (the canonical probe API
|
|
7
|
+
* version), but ships with an intentional off-by-one (`return 2`) so that a
|
|
8
|
+
* live replay of the `seeded-code-regression` scenario diverges from the
|
|
9
|
+
* golden (`version: 1`) and the LLM can produce a correct one-line unified
|
|
10
|
+
* diff to fix it.
|
|
11
|
+
*
|
|
12
|
+
* ### Why a dedicated file?
|
|
13
|
+
*
|
|
14
|
+
* The seeded bug must be:
|
|
15
|
+
* 1. **In a repo-relative path** the op-source-map can register under
|
|
16
|
+
* `selfimprove.probe` so the fix-gen context loader includes it in the
|
|
17
|
+
* LLM prompt.
|
|
18
|
+
* 2. **Minimal** — the simplest possible off-by-one so the model cannot
|
|
19
|
+
* rationally refuse (`NO_PATCH`).
|
|
20
|
+
* 3. **Self-contained** — no live DB, no side effects; the probe op
|
|
21
|
+
* never mutates.
|
|
22
|
+
*
|
|
23
|
+
* ### Fixing the bug
|
|
24
|
+
*
|
|
25
|
+
* Change `return 2` → `return 1` in {@link probeVersion}. This is the EXACT
|
|
26
|
+
* one-line fix the self-improvement loop's LLM fix-gen stage should propose
|
|
27
|
+
* when replaying the seeded scenario.
|
|
28
|
+
*
|
|
29
|
+
* @module @cleocode/core/selfimprove/probe-helper
|
|
30
|
+
* @task T11988
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Return the canonical probe API version.
|
|
34
|
+
*
|
|
35
|
+
* Expected value: `1`.
|
|
36
|
+
*
|
|
37
|
+
* @returns The probe version number.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* probeVersion(); // => 1 (expected)
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @bug SEEDED — currently returns `2` instead of `1` (T11988 intentional).
|
|
45
|
+
* The seeded-code-regression scenario golden asserts `version: 1`; the
|
|
46
|
+
* mismatch is the regression the fix-gen LLM prompt targets.
|
|
47
|
+
*/
|
|
48
|
+
export function probeVersion() {
|
|
49
|
+
// SEEDED BUG (T11988): should be `return 1` — intentional off-by-one for
|
|
50
|
+
// the seeded-code-regression end-to-end fix-gen scenario.
|
|
51
|
+
return 2;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the `selfimprove.probe` response payload.
|
|
55
|
+
*
|
|
56
|
+
* Returns `{ probe: 'ok', version: <probeVersion()> }` — the envelope `data`
|
|
57
|
+
* block the `selfimprove.probe` query op emits.
|
|
58
|
+
*
|
|
59
|
+
* @returns The probe response payload.
|
|
60
|
+
*/
|
|
61
|
+
export function buildProbePayload() {
|
|
62
|
+
return { probe: 'ok', version: probeVersion() };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=probe-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe-helper.js","sourceRoot":"","sources":["../../src/selfimprove/probe-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY;IAC1B,yEAAyE;IACzE,0DAA0D;IAC1D,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "seeded-code-regression",
|
|
3
|
+
"envelopes": [
|
|
4
|
+
{
|
|
5
|
+
"success": true,
|
|
6
|
+
"meta": {
|
|
7
|
+
"gateway": "query",
|
|
8
|
+
"domain": "selfimprove",
|
|
9
|
+
"operation": "probe",
|
|
10
|
+
"source": "rpc"
|
|
11
|
+
},
|
|
12
|
+
"data": {
|
|
13
|
+
"probe": "ok",
|
|
14
|
+
"version": 1
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "seeded-code-regression",
|
|
3
|
+
"description": "Seeded code-regression scenario for end-to-end fix-gen proof (T11988). A deliberately broken selfimprove helper returns the wrong value; the regression is detectable from the replay envelope and fixable by a targeted one-line code patch.",
|
|
4
|
+
"ops": [
|
|
5
|
+
{
|
|
6
|
+
"gateway": "query",
|
|
7
|
+
"domain": "selfimprove",
|
|
8
|
+
"operation": "probe",
|
|
9
|
+
"params": { "scenario": "seeded-code-regression" }
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
package/dist/setup/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { createProjectConventionsSection } from './sections/project-conventions.
|
|
|
27
27
|
export { createSentientSection } from './sections/sentient.js';
|
|
28
28
|
export { createTelemetrySection } from './sections/telemetry.js';
|
|
29
29
|
export { createVerificationSection, type VerificationCheck, } from './sections/verification.js';
|
|
30
|
+
export { printWhoamiSummaryAndOfferTui } from './whoami-summary.js';
|
|
30
31
|
export { StubWizardIO, WizardFatalError, WizardInterruptError, type WizardIO, type WizardOptions, WizardRunner, type WizardRunResult, type WizardSection, type WizardSectionResult, type WizardSectionRunner, } from './wizard.js';
|
|
31
32
|
/**
|
|
32
33
|
* Construct every built-in {@link WizardSectionRunner} in canonical order.
|