@cleocode/core 2026.7.1 → 2026.7.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/dist/selfimprove/draft-pr.d.ts +93 -9
- package/dist/selfimprove/draft-pr.d.ts.map +1 -1
- package/dist/selfimprove/draft-pr.js +164 -23
- package/dist/selfimprove/draft-pr.js.map +1 -1
- package/dist/selfimprove/run-loop.d.ts +9 -1
- package/dist/selfimprove/run-loop.d.ts.map +1 -1
- package/dist/selfimprove/run-loop.js +7 -1
- package/dist/selfimprove/run-loop.js.map +1 -1
- package/package.json +12 -12
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* PR against the cleocode repo (ADR-065 — PRs target `main` via the Merge Queue;
|
|
6
6
|
* NEVER a direct push to `main`, NEVER an auto-merge, NEVER a publish). This module
|
|
7
7
|
* is the egress primitive, modeled on `propose-patch.ts` (the closest "agent
|
|
8
|
-
* proposes a fix PR" exemplar) with
|
|
8
|
+
* proposes a fix PR" exemplar) with four self-dogfooding hardenings:
|
|
9
9
|
*
|
|
10
10
|
* 1. **`--draft` is ALWAYS appended** to `gh pr create` — the PR is never
|
|
11
11
|
* ready-for-merge; a human reviews and undrafts it.
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* side-effect-free at egress by default.
|
|
15
15
|
* 3. **Branch `feat/T11889-selfimprove-<scenario>-<ts>`** — a feature branch
|
|
16
16
|
* (ADR-065); no main mutation path exists in this module.
|
|
17
|
+
* 4. **Workspace isolation (T12007).** The patch is applied inside an
|
|
18
|
+
* *ephemeral transient worktree* cut fresh off `origin/main` — NEVER the
|
|
19
|
+
* invoking checkout — and ONLY the paths the patch names are staged
|
|
20
|
+
* (`git add -- <paths>`, never `git add -A`). This closes a P1 data-safety
|
|
21
|
+
* defect where the egress swept the orchestrator's entire dirty working
|
|
22
|
+
* tree (untracked owner scratch notes, uncommitted edits) into the public
|
|
23
|
+
* branch and deleted them locally. The invoking repo is never mutated.
|
|
17
24
|
*
|
|
18
25
|
* The live path wraps the git/gh shell-out in
|
|
19
26
|
* {@link "../sentient/skill-provenance.js".withProvenance}`('pr-generator', …)`
|
|
@@ -26,21 +33,56 @@
|
|
|
26
33
|
* @module @cleocode/core/selfimprove/draft-pr
|
|
27
34
|
* @epic T11889
|
|
28
35
|
* @task T11913
|
|
36
|
+
* @task T12007
|
|
29
37
|
*/
|
|
30
38
|
/**
|
|
31
39
|
* Pluggable command runner. Returns stdout as UTF-8 text or throws on non-zero
|
|
32
40
|
* exit. Production default wraps `child_process.execFileSync` with piped stdio.
|
|
41
|
+
*
|
|
42
|
+
* The optional `cwd` is REQUIRED for workspace isolation (T12007): every git
|
|
43
|
+
* mutation runs inside the ephemeral worktree, never `process.cwd()` (which
|
|
44
|
+
* would be the invoking checkout). The default runner threads it into
|
|
45
|
+
* `execFileSync`; test doubles capture it to assert the isolation boundary.
|
|
46
|
+
*/
|
|
47
|
+
export type CommandRunner = (file: string, args: readonly string[], cwd?: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Provision arguments for the isolated worktree hook (T12007).
|
|
50
|
+
*
|
|
51
|
+
* @see {@link WorktreeProvisioner}
|
|
52
|
+
*/
|
|
53
|
+
export interface ProvisionWorktreeArgs {
|
|
54
|
+
/** Absolute invoking project root the worktree is registered against. */
|
|
55
|
+
readonly projectRoot: string;
|
|
56
|
+
/** Absolute path where the ephemeral worktree directory is created (tmpdir). */
|
|
57
|
+
readonly worktreePath: string;
|
|
58
|
+
/** The feature branch created inside the worktree. */
|
|
59
|
+
readonly branch: string;
|
|
60
|
+
/** The base ref the worktree (and its branch) is cut from — `origin/main`. */
|
|
61
|
+
readonly baseRef: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Inject hook that provisions the ephemeral isolation worktree. Production
|
|
65
|
+
* leaves it undefined and the module routes through `@cleocode/worktree`'s
|
|
66
|
+
* `addTransientWorktree` (the sanctioned escape hatch for tmpdir worktrees —
|
|
67
|
+
* keeps the raw `git worktree` shell-out out of `packages/core/` per the
|
|
68
|
+
* T9984 lint gate). Tests inject a double to avoid a real git remote.
|
|
33
69
|
*/
|
|
34
|
-
export type
|
|
70
|
+
export type WorktreeProvisioner = (args: ProvisionWorktreeArgs) => Promise<void> | void;
|
|
71
|
+
/**
|
|
72
|
+
* Inject hook that removes the ephemeral isolation worktree. Production leaves
|
|
73
|
+
* it undefined and the module routes through `@cleocode/worktree`'s
|
|
74
|
+
* `removeTransientWorktree`.
|
|
75
|
+
*/
|
|
76
|
+
export type WorktreeRemover = (projectRoot: string, worktreePath: string) => Promise<void> | void;
|
|
35
77
|
/** Failure codes from {@link openDraftPr}. */
|
|
36
78
|
export type DraftPrErrorCode =
|
|
37
79
|
/** Patch file does not exist on disk. */
|
|
38
80
|
'E_NOT_FOUND'
|
|
39
|
-
/** Patch file exists but is empty. */
|
|
81
|
+
/** Patch file exists but is empty (or names no files). */
|
|
40
82
|
| 'E_PATCH_EMPTY'
|
|
41
83
|
/** `gh` CLI missing / not authenticated. */
|
|
42
84
|
| 'E_GH_UNAVAILABLE'
|
|
43
|
-
/** Shell-out failure during the live PR cut. */
|
|
85
|
+
/** Shell-out failure during the live PR cut (incl. worktree provisioning). */
|
|
44
86
|
| 'E_DRAFT_PR_FAILED';
|
|
45
87
|
/** Args for {@link openDraftPr}. */
|
|
46
88
|
export interface OpenDraftPrArgs {
|
|
@@ -60,12 +102,25 @@ export interface OpenDraftPrArgs {
|
|
|
60
102
|
* @defaultValue false
|
|
61
103
|
*/
|
|
62
104
|
readonly execute?: boolean;
|
|
63
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* The INVOKING checkout / project root. Used to (a) resolve {@link diffPath}
|
|
107
|
+
* and (b) register the ephemeral worktree against — it is NEVER mutated
|
|
108
|
+
* (T12007). Defaults to {@link process.cwd}.
|
|
109
|
+
*/
|
|
64
110
|
readonly cwd?: string;
|
|
65
111
|
/** Injectable command runner (tests capture the shell-out). Defaults to {@link execFileSync}. */
|
|
66
112
|
readonly run?: CommandRunner;
|
|
67
113
|
/** Injectable timestamp source for the branch suffix (tests pin it). Defaults to now. */
|
|
68
114
|
readonly timestamp?: () => string;
|
|
115
|
+
/**
|
|
116
|
+
* Explicit path for the ephemeral isolation worktree (T12007). Defaults to a
|
|
117
|
+
* unique `os.tmpdir()` directory. Overridable for deterministic tests.
|
|
118
|
+
*/
|
|
119
|
+
readonly worktreeDir?: string;
|
|
120
|
+
/** Injectable worktree provisioner (tests avoid a real remote). Defaults to `addTransientWorktree`. */
|
|
121
|
+
readonly provisionWorktree?: WorktreeProvisioner;
|
|
122
|
+
/** Injectable worktree remover. Defaults to `removeTransientWorktree`. */
|
|
123
|
+
readonly removeWorktree?: WorktreeRemover;
|
|
69
124
|
}
|
|
70
125
|
/** Dry-run result — the planned steps, no side effects. */
|
|
71
126
|
export interface DraftPrDryRun {
|
|
@@ -74,6 +129,8 @@ export interface DraftPrDryRun {
|
|
|
74
129
|
readonly branchName: string;
|
|
75
130
|
/** The planned shell steps; the `gh pr create` step includes `--draft`. */
|
|
76
131
|
readonly steps: readonly string[];
|
|
132
|
+
/** The repo-relative paths the patch touches — the ONLY paths that will be staged. */
|
|
133
|
+
readonly patchPaths: readonly string[];
|
|
77
134
|
}
|
|
78
135
|
/** Live result — the opened draft PR. */
|
|
79
136
|
export interface DraftPrOk {
|
|
@@ -82,6 +139,8 @@ export interface DraftPrOk {
|
|
|
82
139
|
readonly branchName: string;
|
|
83
140
|
/** The draft PR URL emitted by `gh pr create --draft`. */
|
|
84
141
|
readonly prUrl: string;
|
|
142
|
+
/** The repo-relative paths the patch touched (the PR's complete file set). */
|
|
143
|
+
readonly patchPaths: readonly string[];
|
|
85
144
|
}
|
|
86
145
|
/** Failure result. */
|
|
87
146
|
export interface DraftPrFailure {
|
|
@@ -101,15 +160,40 @@ export type DraftPrResult = DraftPrDryRun | DraftPrOk | DraftPrFailure;
|
|
|
101
160
|
* @returns The branch name.
|
|
102
161
|
*/
|
|
103
162
|
export declare function draftPrBranchName(scenario: string, ts: string): string;
|
|
163
|
+
/**
|
|
164
|
+
* Extract the set of repo-relative paths a unified diff touches — the SSoT for
|
|
165
|
+
* "which paths may be staged" (T12007).
|
|
166
|
+
*
|
|
167
|
+
* Parses the `diff --git a/<old> b/<new>` header (the authoritative per-file
|
|
168
|
+
* boundary in a git-format diff), collecting BOTH the pre-image (`a/`) and
|
|
169
|
+
* post-image (`b/`) paths so renames stage their old path too and deletions
|
|
170
|
+
* stage the removed path. `/dev/null` sentinels (pure add / pure delete) are
|
|
171
|
+
* skipped. Also parses bare `--- ` / `+++ ` headers as a fallback for
|
|
172
|
+
* non-`diff --git` unified diffs. The result is de-duplicated and stable
|
|
173
|
+
* ordered by first appearance.
|
|
174
|
+
*
|
|
175
|
+
* The egress stages ONLY these paths (`git add -- <paths>`), so the isolated
|
|
176
|
+
* worktree can never sweep anything the patch did not name.
|
|
177
|
+
*
|
|
178
|
+
* @param diffText - The unified-diff text.
|
|
179
|
+
* @returns The de-duplicated repo-relative paths the diff touches.
|
|
180
|
+
*/
|
|
181
|
+
export declare function parseUnifiedDiffPaths(diffText: string): string[];
|
|
104
182
|
/**
|
|
105
183
|
* Open ONE DRAFT PR carrying a proposed self-improvement fix.
|
|
106
184
|
*
|
|
107
185
|
* DRY-RUN by default ({@link OpenDraftPrArgs.execute} falsey): returns the planned
|
|
108
186
|
* `steps[]` (the `gh pr create` step ALWAYS carries `--draft`) WITHOUT touching
|
|
109
187
|
* git/gh — so the loop is egress-side-effect-free unless `--execute` is threaded
|
|
110
|
-
* through.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
188
|
+
* through.
|
|
189
|
+
*
|
|
190
|
+
* The live path (`execute: true`) never mutates the invoking checkout (T12007).
|
|
191
|
+
* It cuts an EPHEMERAL transient worktree fresh off `origin/main`, applies the
|
|
192
|
+
* diff there, stages ONLY the paths the patch names (`git add -- <paths>` — NEVER
|
|
193
|
+
* `git add -A`), commits, pushes the FEATURE branch (NEVER `main`), runs
|
|
194
|
+
* `gh pr create --base main --head <branch> --draft`, and tears the worktree
|
|
195
|
+
* down in a `finally`. The orchestrator's untracked/uncommitted files are never
|
|
196
|
+
* staged, pushed, or deleted.
|
|
113
197
|
*
|
|
114
198
|
* NEVER pushes `main`, NEVER auto-merges, NEVER publishes — the only egress is a
|
|
115
199
|
* draft PR against a feature branch.
|
|
@@ -121,7 +205,7 @@ export declare function draftPrBranchName(scenario: string, ts: string): string;
|
|
|
121
205
|
* ```ts
|
|
122
206
|
* // dry-run (default): no side effects, steps include `--draft`
|
|
123
207
|
* const plan = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body });
|
|
124
|
-
* // live: cuts
|
|
208
|
+
* // live: cuts an isolated worktree + opens draft PR (invoking repo untouched)
|
|
125
209
|
* const res = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body, execute: true });
|
|
126
210
|
* ```
|
|
127
211
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft-pr.d.ts","sourceRoot":"","sources":["../../src/selfimprove/draft-pr.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"draft-pr.d.ts","sourceRoot":"","sources":["../../src/selfimprove/draft-pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAkBH;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAM5F;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,QAAQ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|
|
|
5
5
|
* PR against the cleocode repo (ADR-065 — PRs target `main` via the Merge Queue;
|
|
6
6
|
* NEVER a direct push to `main`, NEVER an auto-merge, NEVER a publish). This module
|
|
7
7
|
* is the egress primitive, modeled on `propose-patch.ts` (the closest "agent
|
|
8
|
-
* proposes a fix PR" exemplar) with
|
|
8
|
+
* proposes a fix PR" exemplar) with four self-dogfooding hardenings:
|
|
9
9
|
*
|
|
10
10
|
* 1. **`--draft` is ALWAYS appended** to `gh pr create` — the PR is never
|
|
11
11
|
* ready-for-merge; a human reviews and undrafts it.
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* side-effect-free at egress by default.
|
|
15
15
|
* 3. **Branch `feat/T11889-selfimprove-<scenario>-<ts>`** — a feature branch
|
|
16
16
|
* (ADR-065); no main mutation path exists in this module.
|
|
17
|
+
* 4. **Workspace isolation (T12007).** The patch is applied inside an
|
|
18
|
+
* *ephemeral transient worktree* cut fresh off `origin/main` — NEVER the
|
|
19
|
+
* invoking checkout — and ONLY the paths the patch names are staged
|
|
20
|
+
* (`git add -- <paths>`, never `git add -A`). This closes a P1 data-safety
|
|
21
|
+
* defect where the egress swept the orchestrator's entire dirty working
|
|
22
|
+
* tree (untracked owner scratch notes, uncommitted edits) into the public
|
|
23
|
+
* branch and deleted them locally. The invoking repo is never mutated.
|
|
17
24
|
*
|
|
18
25
|
* The live path wraps the git/gh shell-out in
|
|
19
26
|
* {@link "../sentient/skill-provenance.js".withProvenance}`('pr-generator', …)`
|
|
@@ -26,11 +33,15 @@
|
|
|
26
33
|
* @module @cleocode/core/selfimprove/draft-pr
|
|
27
34
|
* @epic T11889
|
|
28
35
|
* @task T11913
|
|
36
|
+
* @task T12007
|
|
29
37
|
*/
|
|
30
38
|
import { execFileSync } from 'node:child_process';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
39
|
+
import { randomBytes } from 'node:crypto';
|
|
40
|
+
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
41
|
+
import { tmpdir } from 'node:os';
|
|
42
|
+
import { join, resolve as resolvePath } from 'node:path';
|
|
33
43
|
import { cwd as processCwd } from 'node:process';
|
|
44
|
+
import { addTransientWorktree, removeTransientWorktree } from '@cleocode/worktree';
|
|
34
45
|
import { withProvenance } from '../sentient/skill-provenance.js';
|
|
35
46
|
/**
|
|
36
47
|
* The required Claude Code trailer every self-improvement PR body ends with.
|
|
@@ -38,7 +49,15 @@ import { withProvenance } from '../sentient/skill-provenance.js';
|
|
|
38
49
|
*/
|
|
39
50
|
const PR_BODY_TRAILER = '\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)';
|
|
40
51
|
/** Default command runner — wraps `execFileSync` with stdout-piped semantics. */
|
|
41
|
-
const defaultRun = (file, args) => execFileSync(file, [...args], { stdio: 'pipe' }).toString('utf8');
|
|
52
|
+
const defaultRun = (file, args, cwd) => execFileSync(file, [...args], { cwd, stdio: 'pipe' }).toString('utf8');
|
|
53
|
+
/**
|
|
54
|
+
* Sanitize a scenario name into a filesystem/ref-safe stem.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
function safeStem(scenario) {
|
|
59
|
+
return scenario.replace(/[^a-z0-9-]/gi, '-');
|
|
60
|
+
}
|
|
42
61
|
/**
|
|
43
62
|
* Compute the feature branch name for a scenario's draft PR (ADR-065 feature
|
|
44
63
|
* branch — `feat/T11889-selfimprove-<scenario>-<ts>`). The timestamp is
|
|
@@ -49,19 +68,89 @@ const defaultRun = (file, args) => execFileSync(file, [...args], { stdio: 'pipe'
|
|
|
49
68
|
* @returns The branch name.
|
|
50
69
|
*/
|
|
51
70
|
export function draftPrBranchName(scenario, ts) {
|
|
52
|
-
const safeScenario = scenario
|
|
71
|
+
const safeScenario = safeStem(scenario);
|
|
53
72
|
const safeTs = ts.replace(/[:.]/g, '-');
|
|
54
73
|
return `feat/T11889-selfimprove-${safeScenario}-${safeTs}`;
|
|
55
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Extract the set of repo-relative paths a unified diff touches — the SSoT for
|
|
77
|
+
* "which paths may be staged" (T12007).
|
|
78
|
+
*
|
|
79
|
+
* Parses the `diff --git a/<old> b/<new>` header (the authoritative per-file
|
|
80
|
+
* boundary in a git-format diff), collecting BOTH the pre-image (`a/`) and
|
|
81
|
+
* post-image (`b/`) paths so renames stage their old path too and deletions
|
|
82
|
+
* stage the removed path. `/dev/null` sentinels (pure add / pure delete) are
|
|
83
|
+
* skipped. Also parses bare `--- ` / `+++ ` headers as a fallback for
|
|
84
|
+
* non-`diff --git` unified diffs. The result is de-duplicated and stable
|
|
85
|
+
* ordered by first appearance.
|
|
86
|
+
*
|
|
87
|
+
* The egress stages ONLY these paths (`git add -- <paths>`), so the isolated
|
|
88
|
+
* worktree can never sweep anything the patch did not name.
|
|
89
|
+
*
|
|
90
|
+
* @param diffText - The unified-diff text.
|
|
91
|
+
* @returns The de-duplicated repo-relative paths the diff touches.
|
|
92
|
+
*/
|
|
93
|
+
export function parseUnifiedDiffPaths(diffText) {
|
|
94
|
+
const paths = [];
|
|
95
|
+
const seen = new Set();
|
|
96
|
+
const push = (raw) => {
|
|
97
|
+
// Strip surrounding double-quotes git adds for paths with special chars,
|
|
98
|
+
// then drop a leading `a/` or `b/` prefix and any trailing tab-timestamp.
|
|
99
|
+
let p = raw.trim();
|
|
100
|
+
if (p.startsWith('"') && p.endsWith('"') && p.length >= 2)
|
|
101
|
+
p = p.slice(1, -1);
|
|
102
|
+
p = p.replace(/\t.*$/, '');
|
|
103
|
+
if (p === '/dev/null' || p.length === 0)
|
|
104
|
+
return;
|
|
105
|
+
const rel = p.replace(/^[ab]\//, '');
|
|
106
|
+
if (rel.length === 0 || rel === '/dev/null' || seen.has(rel))
|
|
107
|
+
return;
|
|
108
|
+
seen.add(rel);
|
|
109
|
+
paths.push(rel);
|
|
110
|
+
};
|
|
111
|
+
for (const line of diffText.split('\n')) {
|
|
112
|
+
const trimmed = line.replace(/\r$/, '');
|
|
113
|
+
const gitHeader = /^diff --git (\S+) (\S+)\s*$/.exec(trimmed);
|
|
114
|
+
if (gitHeader) {
|
|
115
|
+
push(gitHeader[1]);
|
|
116
|
+
push(gitHeader[2]);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const minus = /^--- (.+)$/.exec(trimmed);
|
|
120
|
+
if (minus) {
|
|
121
|
+
push(minus[1]);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const plus = /^\+\+\+ (.+)$/.exec(trimmed);
|
|
125
|
+
if (plus)
|
|
126
|
+
push(plus[1]);
|
|
127
|
+
}
|
|
128
|
+
return paths;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Build a unique ephemeral worktree path under `os.tmpdir()` for a scenario.
|
|
132
|
+
* The random suffix keeps concurrent self-improve runs from colliding.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
function tempWorktreeDir(scenario) {
|
|
137
|
+
return join(tmpdir(), `cleo-selfimprove-${safeStem(scenario)}-${randomBytes(4).toString('hex')}`);
|
|
138
|
+
}
|
|
56
139
|
/**
|
|
57
140
|
* Open ONE DRAFT PR carrying a proposed self-improvement fix.
|
|
58
141
|
*
|
|
59
142
|
* DRY-RUN by default ({@link OpenDraftPrArgs.execute} falsey): returns the planned
|
|
60
143
|
* `steps[]` (the `gh pr create` step ALWAYS carries `--draft`) WITHOUT touching
|
|
61
144
|
* git/gh — so the loop is egress-side-effect-free unless `--execute` is threaded
|
|
62
|
-
* through.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
145
|
+
* through.
|
|
146
|
+
*
|
|
147
|
+
* The live path (`execute: true`) never mutates the invoking checkout (T12007).
|
|
148
|
+
* It cuts an EPHEMERAL transient worktree fresh off `origin/main`, applies the
|
|
149
|
+
* diff there, stages ONLY the paths the patch names (`git add -- <paths>` — NEVER
|
|
150
|
+
* `git add -A`), commits, pushes the FEATURE branch (NEVER `main`), runs
|
|
151
|
+
* `gh pr create --base main --head <branch> --draft`, and tears the worktree
|
|
152
|
+
* down in a `finally`. The orchestrator's untracked/uncommitted files are never
|
|
153
|
+
* staged, pushed, or deleted.
|
|
65
154
|
*
|
|
66
155
|
* NEVER pushes `main`, NEVER auto-merges, NEVER publishes — the only egress is a
|
|
67
156
|
* draft PR against a feature branch.
|
|
@@ -73,7 +162,7 @@ export function draftPrBranchName(scenario, ts) {
|
|
|
73
162
|
* ```ts
|
|
74
163
|
* // dry-run (default): no side effects, steps include `--draft`
|
|
75
164
|
* const plan = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body });
|
|
76
|
-
* // live: cuts
|
|
165
|
+
* // live: cuts an isolated worktree + opens draft PR (invoking repo untouched)
|
|
77
166
|
* const res = await openDraftPr({ scenario: 'x', diffPath: 'fix.patch', title, body, execute: true });
|
|
78
167
|
* ```
|
|
79
168
|
*/
|
|
@@ -100,6 +189,16 @@ export async function openDraftPr(args) {
|
|
|
100
189
|
message: `Patch file '${resolvedDiff}' is empty`,
|
|
101
190
|
};
|
|
102
191
|
}
|
|
192
|
+
// The authoritative "what may be staged" set. A patch that names no files is
|
|
193
|
+
// treated as empty — staging nothing would produce an empty PR.
|
|
194
|
+
const patchPaths = parseUnifiedDiffPaths(diffBytes);
|
|
195
|
+
if (patchPaths.length === 0) {
|
|
196
|
+
return {
|
|
197
|
+
kind: 'error',
|
|
198
|
+
code: 'E_PATCH_EMPTY',
|
|
199
|
+
message: `Patch file '${resolvedDiff}' names no files (no unified-diff headers)`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
103
202
|
if (execute) {
|
|
104
203
|
try {
|
|
105
204
|
run('gh', ['--version']);
|
|
@@ -113,24 +212,50 @@ export async function openDraftPr(args) {
|
|
|
113
212
|
}
|
|
114
213
|
}
|
|
115
214
|
const branchName = draftPrBranchName(args.scenario, isoNow);
|
|
215
|
+
const worktreePath = args.worktreeDir ?? tempWorktreeDir(args.scenario);
|
|
216
|
+
// Planned steps reflect the ISOLATED flow: every git mutation runs inside the
|
|
217
|
+
// ephemeral worktree (`<worktree>`), and staging is scoped to the patch paths.
|
|
116
218
|
const steps = [
|
|
117
|
-
`git
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
`git
|
|
121
|
-
`git
|
|
219
|
+
`git fetch origin ${base}`,
|
|
220
|
+
`# provision ephemeral worktree at ${worktreePath} off origin/${base} (via @cleocode/worktree)`,
|
|
221
|
+
`git -C <worktree> apply ${resolvedDiff}`,
|
|
222
|
+
`git -C <worktree> add -- ${patchPaths.join(' ')}`,
|
|
223
|
+
`git -C <worktree> commit -m "fix(selfimprove): ${args.scenario} regression"`,
|
|
224
|
+
`git -C <worktree> push -u origin ${branchName}`,
|
|
122
225
|
`gh pr create --base ${base} --head ${branchName} --draft --title "${args.title}" --body <stdin>`,
|
|
226
|
+
'# remove ephemeral worktree (finally)',
|
|
123
227
|
];
|
|
124
228
|
if (!execute) {
|
|
125
|
-
return { kind: 'dry-run', scenario: args.scenario, branchName, steps };
|
|
229
|
+
return { kind: 'dry-run', scenario: args.scenario, branchName, steps, patchPaths };
|
|
126
230
|
}
|
|
231
|
+
const provision = args.provisionWorktree ??
|
|
232
|
+
((o) => addTransientWorktree({
|
|
233
|
+
projectRoot: o.projectRoot,
|
|
234
|
+
worktreePath: o.worktreePath,
|
|
235
|
+
branch: o.branch,
|
|
236
|
+
baseRef: o.baseRef,
|
|
237
|
+
resetBranch: true,
|
|
238
|
+
}));
|
|
239
|
+
const teardown = args.removeWorktree ?? ((projectRoot, p) => removeTransientWorktree(projectRoot, p));
|
|
127
240
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
241
|
+
// Freshen origin/<base> so the isolated worktree branches off the true tip.
|
|
242
|
+
run('git', ['fetch', 'origin', base], cwd);
|
|
243
|
+
// Provision the ephemeral worktree OFF origin/<base> — NEVER the invoking
|
|
244
|
+
// tree. All subsequent git mutations target `worktreePath`.
|
|
245
|
+
await provision({
|
|
246
|
+
projectRoot: cwd,
|
|
247
|
+
worktreePath,
|
|
248
|
+
branch: branchName,
|
|
249
|
+
baseRef: `origin/${base}`,
|
|
250
|
+
});
|
|
251
|
+
const prUrl = await withProvenance('pr-generator', async () => {
|
|
252
|
+
// Apply the patch INSIDE the isolated worktree (its working tree only).
|
|
253
|
+
run('git', ['apply', resolvedDiff], worktreePath);
|
|
254
|
+
// Stage ONLY the paths the patch names — never `git add -A`, never the
|
|
255
|
+
// invoking checkout. This is the crux of the T12007 fix.
|
|
256
|
+
run('git', ['add', '--', ...patchPaths], worktreePath);
|
|
257
|
+
run('git', ['commit', '-m', `fix(selfimprove): ${args.scenario} regression`], worktreePath);
|
|
258
|
+
run('git', ['push', '-u', 'origin', branchName], worktreePath);
|
|
134
259
|
return run('gh', [
|
|
135
260
|
'pr',
|
|
136
261
|
'create',
|
|
@@ -143,9 +268,9 @@ export async function openDraftPr(args) {
|
|
|
143
268
|
args.title,
|
|
144
269
|
'--body',
|
|
145
270
|
body,
|
|
146
|
-
]).trim();
|
|
271
|
+
], worktreePath).trim();
|
|
147
272
|
});
|
|
148
|
-
return { kind: 'ok', scenario: args.scenario, branchName, prUrl };
|
|
273
|
+
return { kind: 'ok', scenario: args.scenario, branchName, prUrl, patchPaths };
|
|
149
274
|
}
|
|
150
275
|
catch (err) {
|
|
151
276
|
return {
|
|
@@ -154,5 +279,21 @@ export async function openDraftPr(args) {
|
|
|
154
279
|
message: `draft-pr failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
155
280
|
};
|
|
156
281
|
}
|
|
282
|
+
finally {
|
|
283
|
+
// Best-effort teardown — the invoking checkout is never touched, only the
|
|
284
|
+
// ephemeral worktree registration + its tmpdir directory.
|
|
285
|
+
try {
|
|
286
|
+
await teardown(cwd, worktreePath);
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
/* best-effort */
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
rmSync(worktreePath, { recursive: true, force: true });
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
/* best-effort */
|
|
296
|
+
}
|
|
297
|
+
}
|
|
157
298
|
}
|
|
158
299
|
//# sourceMappingURL=draft-pr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft-pr.js","sourceRoot":"","sources":["../../src/selfimprove/draft-pr.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"draft-pr.js","sourceRoot":"","sources":["../../src/selfimprove/draft-pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE;;;GAGG;AACH,MAAM,eAAe,GACnB,qEAA8E,CAAC;AAajF,iFAAiF;AACjF,MAAM,UAAU,GAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CACpD,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAoHzE;;;;GAIG;AACH,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,QAAQ,CAAC,OAAO,CAAC,cAAc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AO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,oBAAoB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SAChF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,0EAA0E;QAC1E,0DAA0D;QAC1D,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -56,7 +56,7 @@ import { type ExecutionEnvBackend } from '../llm/pi/resolve-execution-env.js';
|
|
|
56
56
|
import { type ToolGuard } from '../tools/guard.js';
|
|
57
57
|
import { type CircuitBreakerState, DEFAULT_BUDGET, type SelfImproveBudget } from './budget.js';
|
|
58
58
|
import { type DhqAdapter } from './dhq-adapter.js';
|
|
59
|
-
import { type CommandRunner, type DraftPrResult } from './draft-pr.js';
|
|
59
|
+
import { type CommandRunner, type DraftPrResult, type WorktreeProvisioner, type WorktreeRemover } from './draft-pr.js';
|
|
60
60
|
import { type DiffEntry } from './envelope-diff.js';
|
|
61
61
|
import { type FixGenerator, type FixGenResult } from './fix-gen.js';
|
|
62
62
|
import { type ReplayDispatch } from './replay.js';
|
|
@@ -120,6 +120,14 @@ export interface RunSelfImproveOptions {
|
|
|
120
120
|
* tests so the capstone proves the egress WITHOUT a real `gh`/`git` invocation.
|
|
121
121
|
*/
|
|
122
122
|
readonly draftPrRun?: CommandRunner;
|
|
123
|
+
/**
|
|
124
|
+
* Test seam: inject the draft-PR isolation-worktree provisioner (T12007).
|
|
125
|
+
* Defaults to `@cleocode/worktree`'s `addTransientWorktree`. Supplied by tests
|
|
126
|
+
* so the capstone proves the egress WITHOUT a real git repo / remote.
|
|
127
|
+
*/
|
|
128
|
+
readonly draftPrProvisionWorktree?: WorktreeProvisioner;
|
|
129
|
+
/** Test seam: inject the draft-PR isolation-worktree remover (T12007). */
|
|
130
|
+
readonly draftPrRemoveWorktree?: WorktreeRemover;
|
|
123
131
|
/** Test seam: inject the guard backing the in-process fallback env. */
|
|
124
132
|
readonly guard?: ToolGuard;
|
|
125
133
|
/** Test seam: inject the run id (defaults to a timestamped id). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-loop.d.ts","sourceRoot":"","sources":["../../src/selfimprove/run-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAAE,KAAK,mBAAmB,EAAuB,MAAM,oCAAoC,CAAC;AAGnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAGL,KAAK,mBAAmB,EACxB,cAAc,EAEd,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"run-loop.d.ts","sourceRoot":"","sources":["../../src/selfimprove/run-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAAE,KAAK,mBAAmB,EAAuB,MAAM,oCAAoC,CAAC;AAGnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAGL,KAAK,mBAAmB,EACxB,cAAc,EAEd,KAAK,iBAAiB,EACvB,MAA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,CAAC,CAqO5F;AA4CD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -58,7 +58,7 @@ import { LeaseUnavailableError } from '../store/writer-lease.js';
|
|
|
58
58
|
import { createToolGuard } from '../tools/guard.js';
|
|
59
59
|
import { CircuitBreaker, DEFAULT_BUDGET, resolveBudget, } from './budget.js';
|
|
60
60
|
import { createDhqAdapter } from './dhq-adapter.js';
|
|
61
|
-
import { openDraftPr } from './draft-pr.js';
|
|
61
|
+
import { openDraftPr, } from './draft-pr.js';
|
|
62
62
|
import { computeQuestionHash, diffEnvelopes } from './envelope-diff.js';
|
|
63
63
|
import { createLlmFixGenerator, fixPatchPath, generateFixPatch, } from './fix-gen.js';
|
|
64
64
|
import { replayScenario } from './replay.js';
|
|
@@ -248,6 +248,12 @@ export async function runSelfImprove(opts) {
|
|
|
248
248
|
execute,
|
|
249
249
|
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
250
250
|
...(opts.draftPrRun !== undefined ? { run: opts.draftPrRun } : {}),
|
|
251
|
+
...(opts.draftPrProvisionWorktree !== undefined
|
|
252
|
+
? { provisionWorktree: opts.draftPrProvisionWorktree }
|
|
253
|
+
: {}),
|
|
254
|
+
...(opts.draftPrRemoveWorktree !== undefined
|
|
255
|
+
? { removeWorktree: opts.draftPrRemoveWorktree }
|
|
256
|
+
: {}),
|
|
251
257
|
});
|
|
252
258
|
if (draftPr.kind === 'ok') {
|
|
253
259
|
await adapter.recordPrUrl(questionHash, draftPr.prUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-loop.js","sourceRoot":"","sources":["../../src/selfimprove/run-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAA4B,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,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AAY,EACZ,MAAc,EACd,QAAgB,EAChB,KAAa,EACb,QAAiB,EACjB,cAAoC,EAAE,EACtC,eAA8B,IAAI;IAElC,IAAI,MAAM,GAAyB,SAAS,CAAC;IAC7C,IAAI,GAAG,YAAY,qBAAqB,EAAE,CAAC;QACzC,MAAM,GAAG,kBAAkB,CAAC;IAC9B,CAAC;SAAM,IACL,GAAG,KAAK,IAAI;QACZ,OAAO,GAAG,KAAK,QAAQ;QACtB,GAAyB,CAAC,IAAI,KAAK,+BAA+B,EACnE,CAAC;QACD,MAAM,GAAG,eAAe,CAAC;IAC3B,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,sCAAsC,CAAC,CAAC;IACzF,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,QAAQ;QACR,KAAK;QACL,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,OAAO,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleocode/core",
|
|
3
|
-
"version": "2026.7.
|
|
3
|
+
"version": "2026.7.2",
|
|
4
4
|
"description": "CLEO core business logic kernel — tasks, sessions, memory, orchestration, lifecycle, with bundled SQLite store",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -446,16 +446,16 @@
|
|
|
446
446
|
"write-file-atomic": "^7.0.1",
|
|
447
447
|
"yaml": "^2.8.3",
|
|
448
448
|
"zod": "^4.3.6",
|
|
449
|
-
"@cleocode/
|
|
450
|
-
"@cleocode/
|
|
451
|
-
"@cleocode/contracts": "2026.7.
|
|
452
|
-
"@cleocode/
|
|
453
|
-
"@cleocode/git-shim": "2026.7.
|
|
454
|
-
"@cleocode/
|
|
455
|
-
"@cleocode/
|
|
456
|
-
"@cleocode/paths": "2026.7.
|
|
457
|
-
"@cleocode/skills": "2026.7.
|
|
458
|
-
"@cleocode/worktree": "2026.7.
|
|
449
|
+
"@cleocode/adapters": "2026.7.2",
|
|
450
|
+
"@cleocode/agents": "2026.7.2",
|
|
451
|
+
"@cleocode/contracts": "2026.7.2",
|
|
452
|
+
"@cleocode/lafs": "2026.7.2",
|
|
453
|
+
"@cleocode/git-shim": "2026.7.2",
|
|
454
|
+
"@cleocode/caamp": "2026.7.2",
|
|
455
|
+
"@cleocode/nexus": "2026.7.2",
|
|
456
|
+
"@cleocode/paths": "2026.7.2",
|
|
457
|
+
"@cleocode/skills": "2026.7.2",
|
|
458
|
+
"@cleocode/worktree": "2026.7.2"
|
|
459
459
|
},
|
|
460
460
|
"engines": {
|
|
461
461
|
"node": ">=24.16.0"
|
|
@@ -490,7 +490,7 @@
|
|
|
490
490
|
},
|
|
491
491
|
"optionalDependencies": {
|
|
492
492
|
"llmtxt": "^2026.5.15",
|
|
493
|
-
"@cleocode/studio": "^2026.7.
|
|
493
|
+
"@cleocode/studio": "^2026.7.2"
|
|
494
494
|
},
|
|
495
495
|
"scripts": {
|
|
496
496
|
"build": "tsc && node scripts/copy-selfimprove-fixtures.mjs",
|