@on-par/factory-cli 0.9.8-next.52 → 0.9.8-next.54
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/cli/doctor-harness.d.ts +2 -0
- package/dist/cli/doctor-harness.d.ts.map +1 -1
- package/dist/cli/doctor-harness.js +7 -0
- package/dist/cli/doctor-harness.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +7 -4
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/index.d.ts +4 -6
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +24 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/worktree-reap.d.ts +28 -0
- package/dist/cli/worktree-reap.d.ts.map +1 -0
- package/dist/cli/worktree-reap.js +44 -0
- package/dist/cli/worktree-reap.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FactoryConfig, getFactoryPaths } from '@on-par/factory-core';
|
|
2
|
+
import { type WorktreeSandbox, type reapCleanShipWorktree, type reapLaneWorktree } from '@on-par/factory-core/internal';
|
|
3
|
+
import type { CliDeps } from './index.js';
|
|
4
|
+
type Paths = ReturnType<typeof getFactoryPaths>;
|
|
5
|
+
/** What the reaps read from index.ts's per-invocation state, passed in so they stay cycle-free. */
|
|
6
|
+
export interface ReapRuntime {
|
|
7
|
+
configLoaders: Required<Pick<CliDeps, 'loadFactoryConfigForRepo' | 'loadRepoConfig'>>;
|
|
8
|
+
worktreePathFor: (repoRoot: string, ghRepo: string, issue: number, prefix?: string) => string;
|
|
9
|
+
}
|
|
10
|
+
/** The repo's current docker-sandbox descriptor for worktree-gc sweeps, or undefined for
|
|
11
|
+
* every other runtime/config state (including a fixture config with no `sandbox` key). */
|
|
12
|
+
export declare function gcWorktreeSandbox(sandboxCfg: FactoryConfig['sandbox'] | undefined, repoRoot: string): WorktreeSandbox | undefined;
|
|
13
|
+
/** Shared body of both reaps: resolves the lane's conventional worktree under the git+file
|
|
14
|
+
* lock pairing every worktree mutation site uses. Failures are logged as a warn and never surface. */
|
|
15
|
+
declare function reapUnderLock<R>(rt: ReapRuntime, [issue, repoRoot, ghRepo, paths, prefixOverride]: [number, string, string, Paths, string | undefined], failure: string, reap: (worktreePath: string, opts: Parameters<typeof reapLaneWorktree>[2]) => Promise<R>): Promise<{
|
|
16
|
+
worktreePath: string;
|
|
17
|
+
result: R;
|
|
18
|
+
} | undefined>;
|
|
19
|
+
/** Eagerly reaps a parked lane's own worktree inside `factory run` (#1007). All the safety
|
|
20
|
+
* gates live in reapLaneWorktree. A reap failure is logged as a warn and never surfaces —
|
|
21
|
+
* parking must always succeed. */
|
|
22
|
+
export declare function reapParkedLane(rt: ReapRuntime, reap: typeof reapLaneWorktree, args: Parameters<typeof reapUnderLock>[1]): Promise<void>;
|
|
23
|
+
/** Removes a one-shot `factory ship`'s worktree and branch when it ended without a PR and left
|
|
24
|
+
* them clean with no commits (#3008). All safety gates live in reapCleanShipWorktree; a
|
|
25
|
+
* failure is logged as a warn and never changes the ship's exit. */
|
|
26
|
+
export declare function reapPrlessShip(rt: ReapRuntime, reap: typeof reapCleanShipWorktree, args: Parameters<typeof reapUnderLock>[1]): Promise<void>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=worktree-reap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-reap.d.ts","sourceRoot":"","sources":["../../src/cli/worktree-reap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAItB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC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I,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// packages/cli/src/cli/worktree-reap.ts — eager lane-worktree reaps (#1007, #3008), moved out of index.ts
|
|
2
|
+
import { resolveSandboxPolicy } from '@on-par/factory-core';
|
|
3
|
+
import { logEvent, resolveEffectiveConfig, withFileLock, withGitLock, worktreeSandboxFor, } from '@on-par/factory-core/internal';
|
|
4
|
+
/** The repo's current docker-sandbox descriptor for worktree-gc sweeps, or undefined for
|
|
5
|
+
* every other runtime/config state (including a fixture config with no `sandbox` key). */
|
|
6
|
+
export function gcWorktreeSandbox(sandboxCfg, repoRoot) {
|
|
7
|
+
if (!sandboxCfg)
|
|
8
|
+
return undefined;
|
|
9
|
+
const policy = resolveSandboxPolicy(sandboxCfg, { worktree: repoRoot, repoRoot });
|
|
10
|
+
return worktreeSandboxFor(policy?.runtime);
|
|
11
|
+
}
|
|
12
|
+
/** Shared body of both reaps: resolves the lane's conventional worktree under the git+file
|
|
13
|
+
* lock pairing every worktree mutation site uses. Failures are logged as a warn and never surface. */
|
|
14
|
+
async function reapUnderLock(rt, [issue, repoRoot, ghRepo, paths, prefixOverride], failure, reap) {
|
|
15
|
+
try {
|
|
16
|
+
const factoryConfig = rt.configLoaders.loadFactoryConfigForRepo(paths.config);
|
|
17
|
+
const branchPrefix = prefixOverride ?? resolveEffectiveConfig(rt.configLoaders.loadRepoConfig(repoRoot)).branchPrefix;
|
|
18
|
+
const worktreePath = rt.worktreePathFor(repoRoot, ghRepo, issue, branchPrefix);
|
|
19
|
+
const log = (type, msg) => logEvent(paths.events, type, issue, msg);
|
|
20
|
+
const sandbox = gcWorktreeSandbox(factoryConfig.sandbox, repoRoot);
|
|
21
|
+
const result = await withGitLock(repoRoot, () => withFileLock(paths.gitLock, () => reap(worktreePath, { issue, branchPrefix, log, sandbox })));
|
|
22
|
+
return { worktreePath, result };
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
logEvent(paths.events, 'warn', issue, `${failure}: ${err?.message ?? String(err)}`);
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Eagerly reaps a parked lane's own worktree inside `factory run` (#1007). All the safety
|
|
30
|
+
* gates live in reapLaneWorktree. A reap failure is logged as a warn and never surfaces —
|
|
31
|
+
* parking must always succeed. */
|
|
32
|
+
export async function reapParkedLane(rt, reap, args) {
|
|
33
|
+
await reapUnderLock(rt, args, 'parked-lane worktree reap failed', (worktreePath, opts) => reap(args[1], worktreePath, opts));
|
|
34
|
+
}
|
|
35
|
+
/** Removes a one-shot `factory ship`'s worktree and branch when it ended without a PR and left
|
|
36
|
+
* them clean with no commits (#3008). All safety gates live in reapCleanShipWorktree; a
|
|
37
|
+
* failure is logged as a warn and never changes the ship's exit. */
|
|
38
|
+
export async function reapPrlessShip(rt, reap, args) {
|
|
39
|
+
const done = await reapUnderLock(rt, args, 'PR-less ship worktree cleanup failed', (worktreePath, opts) => reap(args[1], worktreePath, opts));
|
|
40
|
+
if (done?.result.outcome === 'removed') {
|
|
41
|
+
console.log(`🧹 Removed worktree ${done.worktreePath}${done.result.branchDeleted ? ` and branch ${done.result.branch}` : ''} — no PR was opened and nothing was committed`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=worktree-reap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-reap.js","sourceRoot":"","sources":["../../src/cli/worktree-reap.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAG1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAEL,QAAQ,EACR,sBAAsB,EAGtB,YAAY,EACZ,WAAW,EACX,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAYvC;2FAC2F;AAC3F,MAAM,UAAU,iBAAiB,CAC/B,UAAg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+
"version": "0.9.8-next.54",
|
|
4
4
|
"description": "On PAR Dev's Software Factory CLI: takes a GitHub issue through plan, build and check with AI agents, then opens a ready-for-review PR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@octokit/plugin-retry": "^8.1.1",
|
|
48
48
|
"@octokit/plugin-throttling": "^11.0.5",
|
|
49
49
|
"@octokit/rest": "^22.0.0",
|
|
50
|
-
"@on-par/factory-core": "0.9.8-next.
|
|
51
|
-
"@on-par/factory-tui": "0.9.8-next.
|
|
50
|
+
"@on-par/factory-core": "0.9.8-next.54",
|
|
51
|
+
"@on-par/factory-tui": "0.9.8-next.54",
|
|
52
52
|
"commander": "^15.0.0"
|
|
53
53
|
},
|
|
54
54
|
"license": "MIT",
|