@wjarka/cezarion 0.17.0-dev.5581 → 0.17.0-dev.5593
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/delegation/routes.d.ts +11 -11
- package/dist/delegation/transport.d.ts +73 -73
- package/dist/git-command.d.ts +7 -0
- package/dist/git-command.js +8 -0
- package/dist/git-command.js.map +1 -0
- package/dist/git-private-index.d.ts +11 -0
- package/dist/git-private-index.js +51 -0
- package/dist/git-private-index.js.map +1 -0
- package/dist/git-worktree.d.ts +3 -12
- package/dist/git-worktree.js +8 -56
- package/dist/git-worktree.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/git-changes.d.ts +2 -0
- package/dist/server/git-changes.js +5 -2
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/open-in-targets.d.ts +7 -0
- package/dist/server/open-in-targets.js +18 -15
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/run-checkout.d.ts +5 -5
- package/dist/server/run-checkout.js +16 -8
- package/dist/server/run-checkout.js.map +1 -1
- package/dist/server/server.d.ts +1589 -1589
- package/dist/server/server.js +32 -29
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/package.json +3 -3
|
@@ -82,17 +82,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
82
82
|
"/discover": {
|
|
83
83
|
$post: {
|
|
84
84
|
output: {
|
|
85
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
86
|
-
models: {
|
|
87
|
-
id: string;
|
|
88
|
-
label: string;
|
|
89
|
-
description: string;
|
|
90
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
91
|
-
}[];
|
|
92
|
-
source: "cache" | "live" | "unavailable";
|
|
93
|
-
stale: boolean;
|
|
94
|
-
reason?: string | undefined;
|
|
95
|
-
} | {
|
|
96
85
|
tasks: {
|
|
97
86
|
id: string;
|
|
98
87
|
title: string;
|
|
@@ -113,6 +102,17 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
113
102
|
authFailureId?: string | undefined;
|
|
114
103
|
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
115
104
|
}[];
|
|
105
|
+
} | {
|
|
106
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
107
|
+
models: {
|
|
108
|
+
id: string;
|
|
109
|
+
label: string;
|
|
110
|
+
description: string;
|
|
111
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
112
|
+
}[];
|
|
113
|
+
source: "cache" | "live" | "unavailable";
|
|
114
|
+
stale: boolean;
|
|
115
|
+
reason?: string | undefined;
|
|
116
116
|
};
|
|
117
117
|
outputFormat: "json";
|
|
118
118
|
status: 200;
|
|
@@ -2,18 +2,6 @@ import type { DelegationRoutes } from './routes.ts';
|
|
|
2
2
|
export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
|
|
3
3
|
"/list": {
|
|
4
4
|
$get: {
|
|
5
|
-
output: {
|
|
6
|
-
error: string;
|
|
7
|
-
code?: "invalid_input" | undefined;
|
|
8
|
-
};
|
|
9
|
-
outputFormat: "json";
|
|
10
|
-
status: 400;
|
|
11
|
-
input: {
|
|
12
|
-
query: {
|
|
13
|
-
offset?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
} | {
|
|
17
5
|
output: {
|
|
18
6
|
workers: {
|
|
19
7
|
workerId: string;
|
|
@@ -51,6 +39,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
51
39
|
offset?: string | undefined;
|
|
52
40
|
};
|
|
53
41
|
};
|
|
42
|
+
} | {
|
|
43
|
+
output: {
|
|
44
|
+
error: string;
|
|
45
|
+
code?: "invalid_input" | undefined;
|
|
46
|
+
};
|
|
47
|
+
outputFormat: "json";
|
|
48
|
+
status: 400;
|
|
49
|
+
input: {
|
|
50
|
+
query: {
|
|
51
|
+
offset?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
} & {
|
|
@@ -65,6 +65,17 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
65
65
|
authFailureId?: string | undefined;
|
|
66
66
|
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
67
67
|
}[];
|
|
68
|
+
} | {
|
|
69
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
70
|
+
models: {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
description: string;
|
|
74
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
75
|
+
}[];
|
|
76
|
+
source: "cache" | "live" | "unavailable";
|
|
77
|
+
stale: boolean;
|
|
78
|
+
reason?: string | undefined;
|
|
68
79
|
} | {
|
|
69
80
|
tasks: {
|
|
70
81
|
id: string;
|
|
@@ -77,17 +88,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
77
88
|
reason?: string | undefined;
|
|
78
89
|
}[];
|
|
79
90
|
nextOffset?: number | undefined;
|
|
80
|
-
} | {
|
|
81
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
82
|
-
models: {
|
|
83
|
-
id: string;
|
|
84
|
-
label: string;
|
|
85
|
-
description: string;
|
|
86
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
87
|
-
}[];
|
|
88
|
-
source: "cache" | "live" | "unavailable";
|
|
89
|
-
stale: boolean;
|
|
90
|
-
reason?: string | undefined;
|
|
91
91
|
};
|
|
92
92
|
outputFormat: "json";
|
|
93
93
|
status: 200;
|
|
@@ -588,18 +588,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
588
588
|
} & {
|
|
589
589
|
"/:workerId": {
|
|
590
590
|
$get: {
|
|
591
|
-
output: {
|
|
592
|
-
error: string;
|
|
593
|
-
code?: "invalid_input" | undefined;
|
|
594
|
-
};
|
|
595
|
-
outputFormat: "json";
|
|
596
|
-
status: 400;
|
|
597
|
-
input: {
|
|
598
|
-
param: {
|
|
599
|
-
workerId: string;
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
} | {
|
|
603
591
|
output: {
|
|
604
592
|
workerId: string;
|
|
605
593
|
parentRunId: string;
|
|
@@ -703,11 +691,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
703
691
|
workerId: string;
|
|
704
692
|
};
|
|
705
693
|
};
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
} & {
|
|
709
|
-
"/:workerId/collect": {
|
|
710
|
-
$post: {
|
|
694
|
+
} | {
|
|
711
695
|
output: {
|
|
712
696
|
error: string;
|
|
713
697
|
code?: "invalid_input" | undefined;
|
|
@@ -718,10 +702,12 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
718
702
|
param: {
|
|
719
703
|
workerId: string;
|
|
720
704
|
};
|
|
721
|
-
} & {
|
|
722
|
-
json: Record<string, never>;
|
|
723
705
|
};
|
|
724
|
-
}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
} & {
|
|
709
|
+
"/:workerId/collect": {
|
|
710
|
+
$post: {
|
|
725
711
|
output: {
|
|
726
712
|
workerId: string;
|
|
727
713
|
parentRunId: string;
|
|
@@ -823,11 +809,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
823
809
|
} & {
|
|
824
810
|
json: Record<string, never>;
|
|
825
811
|
};
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
} & {
|
|
829
|
-
"/:workerId/steer": {
|
|
830
|
-
$post: {
|
|
812
|
+
} | {
|
|
831
813
|
output: {
|
|
832
814
|
error: string;
|
|
833
815
|
code?: "invalid_input" | undefined;
|
|
@@ -839,11 +821,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
839
821
|
workerId: string;
|
|
840
822
|
};
|
|
841
823
|
} & {
|
|
842
|
-
json:
|
|
843
|
-
text: string;
|
|
844
|
-
};
|
|
824
|
+
json: Record<string, never>;
|
|
845
825
|
};
|
|
846
|
-
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
} & {
|
|
829
|
+
"/:workerId/steer": {
|
|
830
|
+
$post: {
|
|
847
831
|
output: {
|
|
848
832
|
workerId: string;
|
|
849
833
|
state: "delivered" | "queued";
|
|
@@ -859,11 +843,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
859
843
|
text: string;
|
|
860
844
|
};
|
|
861
845
|
};
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
} & {
|
|
865
|
-
"/:workerId/stop": {
|
|
866
|
-
$post: {
|
|
846
|
+
} | {
|
|
867
847
|
output: {
|
|
868
848
|
error: string;
|
|
869
849
|
code?: "invalid_input" | undefined;
|
|
@@ -875,9 +855,15 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
875
855
|
workerId: string;
|
|
876
856
|
};
|
|
877
857
|
} & {
|
|
878
|
-
json:
|
|
858
|
+
json: {
|
|
859
|
+
text: string;
|
|
860
|
+
};
|
|
879
861
|
};
|
|
880
|
-
}
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
} & {
|
|
865
|
+
"/:workerId/stop": {
|
|
866
|
+
$post: {
|
|
881
867
|
output: {
|
|
882
868
|
workerId: string;
|
|
883
869
|
state: "stopping" | "terminated";
|
|
@@ -891,11 +877,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
891
877
|
} & {
|
|
892
878
|
json: Record<string, never>;
|
|
893
879
|
};
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
} & {
|
|
897
|
-
"/:workerId/destroy": {
|
|
898
|
-
$post: {
|
|
880
|
+
} | {
|
|
899
881
|
output: {
|
|
900
882
|
error: string;
|
|
901
883
|
code?: "invalid_input" | undefined;
|
|
@@ -909,7 +891,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
909
891
|
} & {
|
|
910
892
|
json: Record<string, never>;
|
|
911
893
|
};
|
|
912
|
-
}
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
} & {
|
|
897
|
+
"/:workerId/destroy": {
|
|
898
|
+
$post: {
|
|
913
899
|
output: {
|
|
914
900
|
workerId: string;
|
|
915
901
|
state: "complete" | "incomplete";
|
|
@@ -932,6 +918,20 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
932
918
|
} & {
|
|
933
919
|
json: Record<string, never>;
|
|
934
920
|
};
|
|
921
|
+
} | {
|
|
922
|
+
output: {
|
|
923
|
+
error: string;
|
|
924
|
+
code?: "invalid_input" | undefined;
|
|
925
|
+
};
|
|
926
|
+
outputFormat: "json";
|
|
927
|
+
status: 400;
|
|
928
|
+
input: {
|
|
929
|
+
param: {
|
|
930
|
+
workerId: string;
|
|
931
|
+
};
|
|
932
|
+
} & {
|
|
933
|
+
json: Record<string, never>;
|
|
934
|
+
};
|
|
935
935
|
} | {
|
|
936
936
|
output: {
|
|
937
937
|
workerId: string;
|
|
@@ -961,11 +961,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
961
961
|
"/:workerId/diff": {
|
|
962
962
|
$get: {
|
|
963
963
|
output: {
|
|
964
|
-
|
|
965
|
-
|
|
964
|
+
workerId: string;
|
|
965
|
+
baselineSha: string;
|
|
966
|
+
diff: string;
|
|
967
|
+
truncated: boolean;
|
|
966
968
|
};
|
|
967
969
|
outputFormat: "json";
|
|
968
|
-
status:
|
|
970
|
+
status: 200;
|
|
969
971
|
input: {
|
|
970
972
|
param: {
|
|
971
973
|
workerId: string;
|
|
@@ -973,13 +975,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
973
975
|
};
|
|
974
976
|
} | {
|
|
975
977
|
output: {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
diff: string;
|
|
979
|
-
truncated: boolean;
|
|
978
|
+
error: string;
|
|
979
|
+
code?: "invalid_input" | undefined;
|
|
980
980
|
};
|
|
981
981
|
outputFormat: "json";
|
|
982
|
-
status:
|
|
982
|
+
status: 400;
|
|
983
983
|
input: {
|
|
984
984
|
param: {
|
|
985
985
|
workerId: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface GitResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
}
|
|
6
|
+
/** Run git, never throw — degradation is the caller's policy. */
|
|
7
|
+
export declare function git(cwd: string, args: string[], timeout?: number, env?: NodeJS.ProcessEnv): Promise<GitResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
/** Run git, never throw — degradation is the caller's policy. */
|
|
3
|
+
export function git(cwd, args, timeout, env) {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
execFile('git', args, { cwd, maxBuffer: 32 * 1024 * 1024, encoding: 'utf8', timeout, ...(env ? { env } : {}) }, (err, stdout, stderr) => resolve({ ok: !err, stdout: stdout ?? '', stderr: stderr ?? '' }));
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=git-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-command.js","sourceRoot":"","sources":["../src/git-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQ9C,iEAAiE;AACjE,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,OAAgB,EAAE,GAAuB;IACxF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CACN,KAAK,EACL,IAAI,EACJ,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EACxF,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAC3F,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type GitResult } from './git-command.ts';
|
|
2
|
+
export type LiveIndexCheck = () => string | undefined;
|
|
3
|
+
export type DiffRefusal = {
|
|
4
|
+
error: string;
|
|
5
|
+
};
|
|
6
|
+
export type IndexGit = (args: string[]) => Promise<GitResult>;
|
|
7
|
+
/**
|
|
8
|
+
* Read through a private index copy. Try OS temp, then the Git directory; if neither is
|
|
9
|
+
* writable, check beforeLiveIndex before the real-index fallback. Always remove scratch state.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withPrivateIndex<T, Refusal = never>(worktreePath: string, read: (git: IndexGit) => Promise<T>, beforeLiveIndex?: () => Refusal | undefined): Promise<T | Refusal>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { git } from './git-command.js';
|
|
5
|
+
import { copyGitIndex } from './git-index-copy.js';
|
|
6
|
+
import { fallbackProjectWriteError } from './project-paths.js';
|
|
7
|
+
/**
|
|
8
|
+
* Read through a private index copy. Try OS temp, then the Git directory; if neither is
|
|
9
|
+
* writable, check beforeLiveIndex before the real-index fallback. Always remove scratch state.
|
|
10
|
+
*/
|
|
11
|
+
export async function withPrivateIndex(worktreePath, read, beforeLiveIndex) {
|
|
12
|
+
const real = await git(worktreePath, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
|
|
13
|
+
const realIndex = real.ok ? real.stdout.trim() : '';
|
|
14
|
+
let scratch;
|
|
15
|
+
for (const parent of [tmpdir(), ...(realIndex ? [dirname(realIndex)] : [])]) {
|
|
16
|
+
try {
|
|
17
|
+
scratch = await mkdtemp(join(parent, 'cez-diff-index-'));
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
catch { /* Not writable: try the next location. */ }
|
|
21
|
+
}
|
|
22
|
+
if (!scratch) {
|
|
23
|
+
const blocked = beforeLiveIndex?.();
|
|
24
|
+
if (blocked !== undefined)
|
|
25
|
+
return blocked;
|
|
26
|
+
const refusal = fallbackProjectWriteError(worktreePath);
|
|
27
|
+
if (refusal)
|
|
28
|
+
throw new Error(refusal);
|
|
29
|
+
return read((args) => git(worktreePath, args));
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const index = join(scratch, 'index');
|
|
33
|
+
const env = { ...process.env, GIT_INDEX_FILE: index };
|
|
34
|
+
const indexed = (args) => git(worktreePath, args, undefined, env);
|
|
35
|
+
let seeded = false;
|
|
36
|
+
if (realIndex) {
|
|
37
|
+
try {
|
|
38
|
+
await copyGitIndex(realIndex, index);
|
|
39
|
+
seeded = true;
|
|
40
|
+
}
|
|
41
|
+
catch { /* No index yet: seed from HEAD. */ }
|
|
42
|
+
}
|
|
43
|
+
if (!seeded)
|
|
44
|
+
await indexed(['read-tree', 'HEAD']);
|
|
45
|
+
return await read(indexed);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
await rm(scratch, { recursive: true, force: true }).catch(() => undefined);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=git-private-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-private-index.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Check, type DiffRefusal } from './git-private-index.ts';
|
|
2
3
|
/** One worktree per task (spec 006). Only createWorktree throws; its caller reports failure. */
|
|
3
4
|
export declare const DIFF_CAP = 400000;
|
|
4
|
-
interface GitResult {
|
|
5
|
-
ok: boolean;
|
|
6
|
-
stdout: string;
|
|
7
|
-
stderr: string;
|
|
8
|
-
}
|
|
9
5
|
export declare function branchFor(runId: string): string;
|
|
10
6
|
/**
|
|
11
7
|
* Resolve a worktree base without throwing. Prefer local only when it contains origin’s base;
|
|
@@ -105,17 +101,13 @@ export interface AutosaveCommitOptions extends AutosaveOptions {
|
|
|
105
101
|
* merge, and a blind `git add -A` would do it again.
|
|
106
102
|
*/
|
|
107
103
|
export declare function autosaveCommit(dir: string, reason: AutosaveReason, options?: AutosaveCommitOptions): Promise<AutosaveResult>;
|
|
108
|
-
type IndexGit = (args: string[]) => Promise<GitResult>;
|
|
109
|
-
/**
|
|
110
|
-
* Read through a private index copy. Try OS temp, then the Git directory; if neither is
|
|
111
|
-
* writable, retain the real-index fallback. Always remove scratch state.
|
|
112
|
-
*/
|
|
113
|
-
export declare function withPrivateIndex<T>(worktreePath: string, read: (git: IndexGit) => Promise<T>): Promise<T>;
|
|
114
104
|
/**
|
|
115
105
|
* Whole-branch committed, uncommitted and untracked diff against the merge-base. Preserve this
|
|
116
106
|
* anchor for the protected text endpoint and conservative settlement checks.
|
|
107
|
+
* Callers without a live-index check, including settlement, keep a string result.
|
|
117
108
|
*/
|
|
118
109
|
export declare function worktreeDiff(worktreePath: string, baseBranch: string, cap?: number): Promise<string>;
|
|
110
|
+
export declare function worktreeDiff(worktreePath: string, baseBranch: string, cap: number | undefined, beforeLiveIndex: LiveIndexCheck): Promise<string | DiffRefusal>;
|
|
119
111
|
/**
|
|
120
112
|
* Whole-branch diff --stat for variant comparisons. Includes committed work; returns an empty
|
|
121
113
|
* string on failure.
|
|
@@ -154,4 +146,3 @@ export declare function worktreeShortstat(worktreePath: string, baseBranch: stri
|
|
|
154
146
|
* branch). Returns the removed run ids for the boot log. Never throws.
|
|
155
147
|
*/
|
|
156
148
|
export declare function pruneOrphans(repoRoot: string, validIds: ReadonlySet<string>): Promise<string[]>;
|
|
157
|
-
export {};
|
package/dist/git-worktree.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
1
2
|
import { projectPaths, isFallbackProjectPath, fallbackProjectWriteError } from './project-paths.js';
|
|
2
3
|
import { inspectGeneration } from './delegation/process-liveness.js';
|
|
3
|
-
import {
|
|
4
|
+
import { git } from './git-command.js';
|
|
4
5
|
import { autosaveGit } from './autosave-git.js';
|
|
5
6
|
import { workerWorkspaceSchema } from './contract/index.js';
|
|
6
7
|
import { existsSync, realpathSync } from 'node:fs';
|
|
7
|
-
import { lstat, mkdir,
|
|
8
|
-
import { tmpdir } from 'node:os';
|
|
8
|
+
import { lstat, mkdir, readdir, readFile, rm, stat } from 'node:fs/promises';
|
|
9
9
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
10
10
|
import { resolveTaskDiffBase } from './git-diff-base.js';
|
|
11
|
-
import {
|
|
11
|
+
import { withPrivateIndex } from './git-private-index.js';
|
|
12
12
|
import { isSafeGitRef } from './git-refs.js';
|
|
13
13
|
import { withWorktreeMutation } from './git-worktree-lock.js';
|
|
14
14
|
/** One worktree per task (spec 006). Only createWorktree throws; its caller reports failure. */
|
|
15
15
|
export const DIFF_CAP = 400_000;
|
|
16
|
-
/** Run git, never throw — degradation is the caller's policy. */
|
|
17
|
-
function git(cwd, args, timeout, env) {
|
|
18
|
-
return new Promise((resolve) => {
|
|
19
|
-
execFile('git', args, { cwd, maxBuffer: 32 * 1024 * 1024, encoding: 'utf8', timeout, ...(env ? { env } : {}) }, (err, stdout, stderr) => resolve({ ok: !err, stdout: stdout ?? '', stderr: stderr ?? '' }));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
16
|
export function branchFor(runId) {
|
|
23
17
|
return `cez/${runId.slice(0, 8)}`;
|
|
24
18
|
}
|
|
@@ -753,57 +747,12 @@ function unquotePath(path) {
|
|
|
753
747
|
}
|
|
754
748
|
return Buffer.from(bytes).toString('utf8');
|
|
755
749
|
}
|
|
756
|
-
/**
|
|
757
|
-
* Read through a private index copy. Try OS temp, then the Git directory; if neither is
|
|
758
|
-
* writable, retain the real-index fallback. Always remove scratch state.
|
|
759
|
-
*/
|
|
760
|
-
export async function withPrivateIndex(worktreePath, read) {
|
|
761
|
-
const real = await git(worktreePath, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
|
|
762
|
-
const realIndex = real.ok ? real.stdout.trim() : '';
|
|
763
|
-
let scratch;
|
|
764
|
-
for (const parent of [tmpdir(), ...(realIndex ? [dirname(realIndex)] : [])]) {
|
|
765
|
-
try {
|
|
766
|
-
scratch = await mkdtemp(join(parent, 'cez-diff-index-'));
|
|
767
|
-
break;
|
|
768
|
-
}
|
|
769
|
-
catch { /* Not writable: try the next location. */ }
|
|
770
|
-
}
|
|
771
|
-
if (!scratch) {
|
|
772
|
-
const refusal = fallbackProjectWriteError(worktreePath);
|
|
773
|
-
if (refusal)
|
|
774
|
-
throw new Error(refusal);
|
|
775
|
-
return read((args) => git(worktreePath, args));
|
|
776
|
-
}
|
|
777
|
-
try {
|
|
778
|
-
const index = join(scratch, 'index');
|
|
779
|
-
const env = { ...process.env, GIT_INDEX_FILE: index };
|
|
780
|
-
const indexed = (args) => git(worktreePath, args, undefined, env);
|
|
781
|
-
let seeded = false;
|
|
782
|
-
if (realIndex) {
|
|
783
|
-
try {
|
|
784
|
-
await copyGitIndex(realIndex, index);
|
|
785
|
-
seeded = true;
|
|
786
|
-
}
|
|
787
|
-
catch { /* No index yet: seed from HEAD. */ }
|
|
788
|
-
}
|
|
789
|
-
if (!seeded)
|
|
790
|
-
await indexed(['read-tree', 'HEAD']);
|
|
791
|
-
return await read(indexed);
|
|
792
|
-
}
|
|
793
|
-
finally {
|
|
794
|
-
await rm(scratch, { recursive: true, force: true }).catch(() => undefined);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
750
|
async function prepareWholeBranchDiff(git, baseBranch) {
|
|
798
751
|
await git(['add', '-N', '.']); // intent-to-add (private index, hearsay-tools/cezarion#1080): untracked files show up
|
|
799
752
|
const mergeBase = await git(['merge-base', baseBranch, 'HEAD']);
|
|
800
753
|
return mergeBase.ok && mergeBase.stdout.trim() ? mergeBase.stdout.trim() : baseBranch;
|
|
801
754
|
}
|
|
802
|
-
|
|
803
|
-
* Whole-branch committed, uncommitted and untracked diff against the merge-base. Preserve this
|
|
804
|
-
* anchor for the protected text endpoint and conservative settlement checks.
|
|
805
|
-
*/
|
|
806
|
-
export async function worktreeDiff(worktreePath, baseBranch, cap = DIFF_CAP) {
|
|
755
|
+
export async function worktreeDiff(worktreePath, baseBranch, cap = DIFF_CAP, beforeLiveIndex) {
|
|
807
756
|
if (!isSafeGitRef(baseBranch))
|
|
808
757
|
return '(diff failed: refusing option-like base ref)';
|
|
809
758
|
return withPrivateIndex(worktreePath, async (git) => {
|
|
@@ -814,6 +763,9 @@ export async function worktreeDiff(worktreePath, baseBranch, cap = DIFF_CAP) {
|
|
|
814
763
|
if (res.stdout.length > cap)
|
|
815
764
|
return `${res.stdout.slice(0, cap)}\n… (diff truncated)`;
|
|
816
765
|
return res.stdout;
|
|
766
|
+
}, () => {
|
|
767
|
+
const error = beforeLiveIndex?.();
|
|
768
|
+
return error === undefined ? undefined : { error };
|
|
817
769
|
});
|
|
818
770
|
}
|
|
819
771
|
/**
|