@wjarka/cezarion 0.17.0-dev.5579 → 0.17.0-dev.5585
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/run-checkout.d.ts +5 -3
- package/dist/server/run-checkout.js +14 -4
- package/dist/server/run-checkout.js.map +1 -1
- package/dist/server/self-update-routes.d.ts +19 -19
- package/dist/server/server.d.ts +1566 -1566
- package/dist/server/server.js +15 -13
- 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,6 +2,18 @@ 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
|
+
} | {
|
|
5
17
|
output: {
|
|
6
18
|
workers: {
|
|
7
19
|
workerId: string;
|
|
@@ -39,18 +51,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
39
51
|
offset?: string | undefined;
|
|
40
52
|
};
|
|
41
53
|
};
|
|
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,6 +588,18 @@ 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
|
+
} | {
|
|
591
603
|
output: {
|
|
592
604
|
workerId: string;
|
|
593
605
|
parentRunId: string;
|
|
@@ -691,7 +703,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
691
703
|
workerId: string;
|
|
692
704
|
};
|
|
693
705
|
};
|
|
694
|
-
}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
} & {
|
|
709
|
+
"/:workerId/collect": {
|
|
710
|
+
$post: {
|
|
695
711
|
output: {
|
|
696
712
|
error: string;
|
|
697
713
|
code?: "invalid_input" | undefined;
|
|
@@ -702,12 +718,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
702
718
|
param: {
|
|
703
719
|
workerId: string;
|
|
704
720
|
};
|
|
721
|
+
} & {
|
|
722
|
+
json: Record<string, never>;
|
|
705
723
|
};
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
} & {
|
|
709
|
-
"/:workerId/collect": {
|
|
710
|
-
$post: {
|
|
724
|
+
} | {
|
|
711
725
|
output: {
|
|
712
726
|
workerId: string;
|
|
713
727
|
parentRunId: string;
|
|
@@ -809,7 +823,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
809
823
|
} & {
|
|
810
824
|
json: Record<string, never>;
|
|
811
825
|
};
|
|
812
|
-
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
} & {
|
|
829
|
+
"/:workerId/steer": {
|
|
830
|
+
$post: {
|
|
813
831
|
output: {
|
|
814
832
|
error: string;
|
|
815
833
|
code?: "invalid_input" | undefined;
|
|
@@ -821,13 +839,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
821
839
|
workerId: string;
|
|
822
840
|
};
|
|
823
841
|
} & {
|
|
824
|
-
json:
|
|
842
|
+
json: {
|
|
843
|
+
text: string;
|
|
844
|
+
};
|
|
825
845
|
};
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
} & {
|
|
829
|
-
"/:workerId/steer": {
|
|
830
|
-
$post: {
|
|
846
|
+
} | {
|
|
831
847
|
output: {
|
|
832
848
|
workerId: string;
|
|
833
849
|
state: "delivered" | "queued";
|
|
@@ -843,7 +859,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
843
859
|
text: string;
|
|
844
860
|
};
|
|
845
861
|
};
|
|
846
|
-
}
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
} & {
|
|
865
|
+
"/:workerId/stop": {
|
|
866
|
+
$post: {
|
|
847
867
|
output: {
|
|
848
868
|
error: string;
|
|
849
869
|
code?: "invalid_input" | undefined;
|
|
@@ -855,15 +875,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
855
875
|
workerId: string;
|
|
856
876
|
};
|
|
857
877
|
} & {
|
|
858
|
-
json:
|
|
859
|
-
text: string;
|
|
860
|
-
};
|
|
878
|
+
json: Record<string, never>;
|
|
861
879
|
};
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
} & {
|
|
865
|
-
"/:workerId/stop": {
|
|
866
|
-
$post: {
|
|
880
|
+
} | {
|
|
867
881
|
output: {
|
|
868
882
|
workerId: string;
|
|
869
883
|
state: "stopping" | "terminated";
|
|
@@ -877,7 +891,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
877
891
|
} & {
|
|
878
892
|
json: Record<string, never>;
|
|
879
893
|
};
|
|
880
|
-
}
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
} & {
|
|
897
|
+
"/:workerId/destroy": {
|
|
898
|
+
$post: {
|
|
881
899
|
output: {
|
|
882
900
|
error: string;
|
|
883
901
|
code?: "invalid_input" | undefined;
|
|
@@ -891,11 +909,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
891
909
|
} & {
|
|
892
910
|
json: Record<string, never>;
|
|
893
911
|
};
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
} & {
|
|
897
|
-
"/:workerId/destroy": {
|
|
898
|
-
$post: {
|
|
912
|
+
} | {
|
|
899
913
|
output: {
|
|
900
914
|
workerId: string;
|
|
901
915
|
state: "complete" | "incomplete";
|
|
@@ -918,20 +932,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
918
932
|
} & {
|
|
919
933
|
json: Record<string, never>;
|
|
920
934
|
};
|
|
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,13 +961,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
961
961
|
"/:workerId/diff": {
|
|
962
962
|
$get: {
|
|
963
963
|
output: {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
diff: string;
|
|
967
|
-
truncated: boolean;
|
|
964
|
+
error: string;
|
|
965
|
+
code?: "invalid_input" | undefined;
|
|
968
966
|
};
|
|
969
967
|
outputFormat: "json";
|
|
970
|
-
status:
|
|
968
|
+
status: 400;
|
|
971
969
|
input: {
|
|
972
970
|
param: {
|
|
973
971
|
workerId: string;
|
|
@@ -975,11 +973,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
975
973
|
};
|
|
976
974
|
} | {
|
|
977
975
|
output: {
|
|
978
|
-
|
|
979
|
-
|
|
976
|
+
workerId: string;
|
|
977
|
+
baselineSha: string;
|
|
978
|
+
diff: string;
|
|
979
|
+
truncated: boolean;
|
|
980
980
|
};
|
|
981
981
|
outputFormat: "json";
|
|
982
|
-
status:
|
|
982
|
+
status: 200;
|
|
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.js","sourceRoot":"","sources":["../src/git-private-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAkB,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAO/D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,YAAoB,EACpB,IAAmC,EACnC,eAA2C;IAE3C,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,wBAAwB,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;IACrG,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,IAAI,OAA2B,CAAC;IAChC,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC5E,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;YACzD,MAAM;QACR,CAAC;QAAC,MAAM,CAAC,CAAC,0CAA0C,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,eAAe,EAAE,EAAE,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC;QAC1C,MAAM,OAAO,GAAG,yBAAyB,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;QACtD,MAAM,OAAO,GAAa,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAC5E,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC;gBAAC,MAAM,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBAAC,MAAM,GAAG,IAAI,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,mCAAmC,CAAC,CAAC;QAC5G,CAAC;QACD,IAAI,CAAC,MAAM;YAAE,MAAM,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
package/dist/git-worktree.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { type AutosaveOptions } from './autosave-git.ts';
|
|
2
|
+
import { type LiveIndexCheck, 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
|
/**
|