@claudexor/workspace 4.3.0 → 4.4.0
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/anchor-store.d.ts.map +1 -1
- package/dist/anchor-store.js +3 -25
- package/dist/anchor-store.js.map +1 -1
- package/dist/continuation-evidence.d.ts +182 -0
- package/dist/continuation-evidence.d.ts.map +1 -0
- package/dist/continuation-evidence.js +70 -0
- package/dist/continuation-evidence.js.map +1 -0
- package/dist/continuation-sources.d.ts +3 -1
- package/dist/continuation-sources.d.ts.map +1 -1
- package/dist/continuation-sources.js +28 -4
- package/dist/continuation-sources.js.map +1 -1
- package/dist/git-nested-repositories.d.ts +18 -0
- package/dist/git-nested-repositories.d.ts.map +1 -0
- package/dist/git-nested-repositories.js +62 -0
- package/dist/git-nested-repositories.js.map +1 -0
- package/dist/git-run.d.ts +20 -0
- package/dist/git-run.d.ts.map +1 -0
- package/dist/git-run.js +31 -0
- package/dist/git-run.js.map +1 -0
- package/dist/git-transient-capture.d.ts +30 -0
- package/dist/git-transient-capture.d.ts.map +1 -0
- package/dist/git-transient-capture.js +130 -0
- package/dist/git-transient-capture.js.map +1 -0
- package/dist/git.d.ts +2 -33
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +12 -149
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manager.d.ts +3 -0
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +6 -0
- package/dist/manager.js.map +1 -1
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-store.d.ts","sourceRoot":"","sources":["../src/anchor-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anchor-store.d.ts","sourceRoot":"","sources":["../src/anchor-store.ts"],"names":[],"mappings":"AAaA;8EAC8E;AAC9E,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAOD,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5F;AAiBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;4EAC4E;AAC5E,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAC9B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;CAC/C,GAAG,oBAAoB,CAuBvB;AAED;kDACkD;AAClD,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxB"}
|
package/dist/anchor-store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { fsyncDirectory, projectRuntimeDir, sha256, writePatchObject } from "@claudexor/util";
|
|
4
4
|
import { WorkspaceError } from "@claudexor/core";
|
|
5
5
|
import { diffTrees } from "./git.js";
|
|
6
6
|
const ANCHOR_ID = /^sha256:[0-9a-f]{64}$/;
|
|
@@ -31,7 +31,6 @@ function persistRevertAnchor(repo, patch) {
|
|
|
31
31
|
const id = sha256(patch);
|
|
32
32
|
const target = objectPath(repo, id);
|
|
33
33
|
const targetDir = dirname(target);
|
|
34
|
-
ensureDir(targetDir);
|
|
35
34
|
if (existsSync(target)) {
|
|
36
35
|
if (sha256(readFileSync(target, "utf8")) !== id) {
|
|
37
36
|
throw new WorkspaceError(`revert anchor ${id} failed its content digest`);
|
|
@@ -39,28 +38,7 @@ function persistRevertAnchor(repo, patch) {
|
|
|
39
38
|
fsyncDirectory(targetDir);
|
|
40
39
|
return id;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
const fd = openSync(temp, "wx", 0o600);
|
|
44
|
-
try {
|
|
45
|
-
writeSync(fd, patch, undefined, "utf8");
|
|
46
|
-
fsyncSync(fd);
|
|
47
|
-
}
|
|
48
|
-
finally {
|
|
49
|
-
closeSync(fd);
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
renameSync(temp, target);
|
|
53
|
-
fsyncDirectory(targetDir);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
try {
|
|
57
|
-
unlinkSync(temp);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
// The original rename error is authoritative.
|
|
61
|
-
}
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
41
|
+
writePatchObject(projectRuntimeDir(repo), target, patch);
|
|
64
42
|
return id;
|
|
65
43
|
}
|
|
66
44
|
export function readRevertAnchor(repo, id) {
|
package/dist/anchor-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-store.js","sourceRoot":"","sources":["../src/anchor-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":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,CAAC,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IACtE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC5C,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC;QAC7D,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EACJ,oGAAoG;SACvG,CAAC;IACJ,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,IAAI,CAAC;YACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;QAChF,CAAC;QAAC,MAAM,CAAC;YACP,6EAA6E;QAC/E,CAAC;IACH,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,MAAM,EACJ,iGAAiG;KACpG,CAAC;AACJ,CAAC;AAED;kDACkD;AAClD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAAY,EACZ,UAAyB,EACzB,WAA0B;IAE1B,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,MAAM,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { SessionCapsule } from "@claudexor/schema";
|
|
2
|
+
export declare function runFilesExpired(runDir: string): boolean;
|
|
3
|
+
export declare function readSessionCapsule(attemptDir: string): SessionCapsule | null;
|
|
4
|
+
export declare function readContinuationEvidence(runDir: string): {
|
|
5
|
+
resumable: {
|
|
6
|
+
cause: "cancelled" | "context_exhausted" | "host_restart" | "input_required" | "other" | "permission_denied" | "pinned_limit" | "pool_exhausted" | "transport" | "vendor_limit" | "wall_clock";
|
|
7
|
+
resetsAt: string | null;
|
|
8
|
+
limitWindow: string | null;
|
|
9
|
+
limitEvidence: "unspecified" | "window" | null;
|
|
10
|
+
carriers: ("native" | "native_moved" | "packet")[];
|
|
11
|
+
limitCode: string | null;
|
|
12
|
+
session: {
|
|
13
|
+
harness: string;
|
|
14
|
+
nativeSessionId: string;
|
|
15
|
+
holderProfileId: string | null;
|
|
16
|
+
} | null;
|
|
17
|
+
workspace: {
|
|
18
|
+
kind: "in_place" | "none" | "retained_envelope";
|
|
19
|
+
root: string | null;
|
|
20
|
+
};
|
|
21
|
+
} | undefined;
|
|
22
|
+
held: {
|
|
23
|
+
attemptId: string;
|
|
24
|
+
capsule: {
|
|
25
|
+
harness: string;
|
|
26
|
+
nativeSessionId: string;
|
|
27
|
+
holderProfileId: string | null;
|
|
28
|
+
file: string | null;
|
|
29
|
+
mtimeMs: number | null;
|
|
30
|
+
sidecars: string[];
|
|
31
|
+
cwd: string;
|
|
32
|
+
requestedModel: string | null;
|
|
33
|
+
};
|
|
34
|
+
} | null;
|
|
35
|
+
attemptId: string;
|
|
36
|
+
attempt: {
|
|
37
|
+
request_refusal?: {
|
|
38
|
+
scope: "turn_text";
|
|
39
|
+
unit: "unicode_scalars";
|
|
40
|
+
source: string;
|
|
41
|
+
kind: "input_too_large";
|
|
42
|
+
limit: number | null;
|
|
43
|
+
actual: number | null;
|
|
44
|
+
native_code: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "vendor_cli_too_old";
|
|
47
|
+
native_code: "claude_code_version_too_old";
|
|
48
|
+
source: "claude_stdout";
|
|
49
|
+
binary_path: string | null;
|
|
50
|
+
installed_version: string | null;
|
|
51
|
+
} | undefined;
|
|
52
|
+
effort_resolution?: {
|
|
53
|
+
requested: string | null;
|
|
54
|
+
submitted: string | null;
|
|
55
|
+
resolution: "downward" | "exact" | "floor" | "omitted" | "rejected" | "unverifiable";
|
|
56
|
+
source: "account_catalog" | "adapter" | "live_probe" | "versioned_snapshot";
|
|
57
|
+
parameter: string | null;
|
|
58
|
+
observed: string | null;
|
|
59
|
+
observedSource: string | null;
|
|
60
|
+
reason?: string | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
processing?: {
|
|
63
|
+
requested: "economy" | "fast" | "standard" | null;
|
|
64
|
+
submitted: "economy" | "fast" | "standard" | null;
|
|
65
|
+
submittedNative: string | null;
|
|
66
|
+
observed: "economy" | "fast" | "mixed" | "standard" | "unknown";
|
|
67
|
+
observedNative: string[];
|
|
68
|
+
reason: string | null;
|
|
69
|
+
source: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
processing_cost_basis?: {
|
|
72
|
+
nativeMode: string | null;
|
|
73
|
+
kind: "cash" | "included" | "paid_credits" | "unknown" | "valuation";
|
|
74
|
+
source: string;
|
|
75
|
+
debit?: "unobserved" | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
usage_cost?: {
|
|
78
|
+
cashUsd: number;
|
|
79
|
+
valuationUsd: number;
|
|
80
|
+
unknownUsd: number;
|
|
81
|
+
cashKnowledge: "estimated" | "exact" | "unknown";
|
|
82
|
+
valuationKnowledge: "estimated" | "exact" | "unknown";
|
|
83
|
+
} | undefined;
|
|
84
|
+
attempt_id: string;
|
|
85
|
+
harness_id: string;
|
|
86
|
+
observed_model: string | null;
|
|
87
|
+
auth_mode: "api_key" | "local_session" | "unknown" | null;
|
|
88
|
+
auth_source: "api_key_env" | "api_key_flag" | "native_session" | "none" | "oauth_token_env" | "provider_auth_file" | null;
|
|
89
|
+
profile_id: string | null;
|
|
90
|
+
requested_model: string | null;
|
|
91
|
+
request_requirements: {
|
|
92
|
+
capability: "browser" | "delegation" | "path_deny";
|
|
93
|
+
harness_id: string;
|
|
94
|
+
eligible: boolean;
|
|
95
|
+
requested: boolean;
|
|
96
|
+
effective: boolean;
|
|
97
|
+
reason: "access_profile_incompatible" | "effective" | "manifest_unsupported" | "not_requested" | "postdiff_only" | "runtime_unavailable" | "web_policy_off";
|
|
98
|
+
evidence_refs: string[];
|
|
99
|
+
}[];
|
|
100
|
+
web: {
|
|
101
|
+
required: boolean;
|
|
102
|
+
policy: "auto" | "cached" | "live" | "off";
|
|
103
|
+
effective_mode: "auto" | "cached" | "live" | "off";
|
|
104
|
+
attempted: boolean;
|
|
105
|
+
satisfied: boolean;
|
|
106
|
+
status: "attempted" | "failed" | "none" | "satisfied" | "unverified";
|
|
107
|
+
verification: "dispatched" | "none" | "verified";
|
|
108
|
+
tool: string | null;
|
|
109
|
+
target: string | null;
|
|
110
|
+
error_summary: string | null;
|
|
111
|
+
};
|
|
112
|
+
tool_errors: {
|
|
113
|
+
tool: string;
|
|
114
|
+
kind: "command" | "file" | "mcp" | "other" | "search" | "web";
|
|
115
|
+
target: string | null;
|
|
116
|
+
summary: string;
|
|
117
|
+
recovered: boolean;
|
|
118
|
+
tool_use_id: string | null;
|
|
119
|
+
}[];
|
|
120
|
+
tool_errors_total: number;
|
|
121
|
+
unrecovered_tool_errors: number;
|
|
122
|
+
statusless_tool_results: number;
|
|
123
|
+
dropped_events: number;
|
|
124
|
+
transient_failures: {
|
|
125
|
+
kind: "network" | "service_unavailable" | "stream_disconnect" | "timeout" | "unknown";
|
|
126
|
+
category: "auth_failed" | "capability_refused" | "config_error" | "process_crash" | "rate_limited" | "timeout" | "unknown_harness_error";
|
|
127
|
+
retryable: boolean;
|
|
128
|
+
retry_delay_ms: number | null;
|
|
129
|
+
http_status: number | null;
|
|
130
|
+
signal: string | null;
|
|
131
|
+
adapter_code: string | null;
|
|
132
|
+
}[];
|
|
133
|
+
outcome: {
|
|
134
|
+
deliverable_present: boolean;
|
|
135
|
+
gates_passed: boolean | null;
|
|
136
|
+
harness_errored: boolean;
|
|
137
|
+
web_required_unsatisfied: boolean;
|
|
138
|
+
delegation_belt_unavailable: boolean;
|
|
139
|
+
tool_warnings_count: number;
|
|
140
|
+
status: "blocked" | "failed" | "success" | "success_with_warnings";
|
|
141
|
+
work_state?: {
|
|
142
|
+
state: "completed" | "incomplete" | "needs_input" | "unverified";
|
|
143
|
+
source: "absent" | "constrained" | "validated";
|
|
144
|
+
required_inputs?: {
|
|
145
|
+
kind: "context" | "credential" | "decision" | "external_dependency" | "file" | "permission";
|
|
146
|
+
locator: string | null;
|
|
147
|
+
description: string;
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
unverified_reason?: "footer_missing" | "footer_not_json" | "footer_not_object" | "legacy_output_invalid" | "report_contradictory" | "report_malformed" | "report_missing" | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
};
|
|
152
|
+
delegation_belt?: {
|
|
153
|
+
requested: boolean;
|
|
154
|
+
server_name: string | null;
|
|
155
|
+
ready: boolean;
|
|
156
|
+
failed: boolean;
|
|
157
|
+
tool_evidence: boolean;
|
|
158
|
+
} | undefined;
|
|
159
|
+
browser?: {
|
|
160
|
+
requested: boolean;
|
|
161
|
+
server_name: string | null;
|
|
162
|
+
attempted: boolean;
|
|
163
|
+
satisfied: boolean;
|
|
164
|
+
failed: boolean;
|
|
165
|
+
unused: boolean;
|
|
166
|
+
} | undefined;
|
|
167
|
+
usage: {
|
|
168
|
+
input_tokens: number | null;
|
|
169
|
+
output_tokens: number | null;
|
|
170
|
+
cached_input_tokens: number | null;
|
|
171
|
+
input_token_usage?: {
|
|
172
|
+
total_tokens: number | null;
|
|
173
|
+
cache_read_tokens: number | null;
|
|
174
|
+
cache_write_tokens: number | null;
|
|
175
|
+
} | undefined;
|
|
176
|
+
};
|
|
177
|
+
} | undefined;
|
|
178
|
+
patch: string;
|
|
179
|
+
output: string;
|
|
180
|
+
hasEvidence: boolean;
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=continuation-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-evidence.d.ts","sourceRoot":"","sources":["../src/continuation-evidence.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8B,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAI/E,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAQvD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAO5E;AAYD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CtD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Shared evidence facts for admission and the successor's carrier planner. */
|
|
2
|
+
import { existsSync, lstatSync, readdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parse as yamlParse } from "yaml";
|
|
5
|
+
import { RunResumable, RunTelemetry, SessionCapsule } from "@claudexor/schema";
|
|
6
|
+
import { readRunEvents, retainedOutput } from "@claudexor/event-log";
|
|
7
|
+
import { readTextSafe } from "@claudexor/util";
|
|
8
|
+
export function runFilesExpired(runDir) {
|
|
9
|
+
try {
|
|
10
|
+
lstatSync(join(runDir, "tombstone.yaml"));
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error.code === "ENOENT")
|
|
15
|
+
return false;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function readSessionCapsule(attemptDir) {
|
|
20
|
+
try {
|
|
21
|
+
const text = readTextSafe(join(attemptDir, "session-capsule.json"));
|
|
22
|
+
return text === null ? null : SessionCapsule.parse(JSON.parse(text));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function yaml(path) {
|
|
29
|
+
const text = readTextSafe(path);
|
|
30
|
+
if (text === null)
|
|
31
|
+
return null;
|
|
32
|
+
try {
|
|
33
|
+
return yamlParse(text);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function readContinuationEvidence(runDir) {
|
|
40
|
+
const finalDir = join(runDir, "final");
|
|
41
|
+
const resumable = RunResumable.safeParse(yaml(join(finalDir, "resumable.yaml"))).data;
|
|
42
|
+
const telemetry = RunTelemetry.safeParse(yaml(join(finalDir, "telemetry.yaml"))).data;
|
|
43
|
+
const attemptsDir = join(runDir, "attempts");
|
|
44
|
+
const sessions = existsSync(attemptsDir)
|
|
45
|
+
? readdirSync(attemptsDir)
|
|
46
|
+
.sort()
|
|
47
|
+
.flatMap((attemptId) => {
|
|
48
|
+
const capsule = readSessionCapsule(join(attemptsDir, attemptId));
|
|
49
|
+
return capsule ? [{ attemptId, capsule }] : [];
|
|
50
|
+
})
|
|
51
|
+
: [];
|
|
52
|
+
const held = sessions.find((entry) => entry.capsule.nativeSessionId === resumable?.session?.nativeSessionId) ??
|
|
53
|
+
sessions.reduce((newest, entry) => newest && (newest.capsule.mtimeMs ?? 0) > (entry.capsule.mtimeMs ?? 0) ? newest : entry, null);
|
|
54
|
+
const attemptId = held?.attemptId ?? telemetry?.final_attempt_id ?? "a01";
|
|
55
|
+
const attempt = telemetry?.attempts.find((entry) => entry.attempt_id === attemptId);
|
|
56
|
+
const patch = readTextSafe(join(attemptsDir, attemptId, "patch.diff")) ??
|
|
57
|
+
readTextSafe(join(finalDir, "patch.diff")) ??
|
|
58
|
+
"";
|
|
59
|
+
const events = readRunEvents(join(runDir, "events.jsonl"));
|
|
60
|
+
const output = readTextSafe(join(finalDir, "answer.md"))?.trim() ||
|
|
61
|
+
readTextSafe(join(finalDir, "retained-output.md"))?.trim() ||
|
|
62
|
+
retainedOutput(events.events, events.malformed) ||
|
|
63
|
+
"";
|
|
64
|
+
const hasEvidence = !!patch.trim() ||
|
|
65
|
+
!!output ||
|
|
66
|
+
events.events.some((event) => event.type === "harness.event" &&
|
|
67
|
+
["tool_call", "file_change"].includes(String(event.payload["type"])));
|
|
68
|
+
return { resumable, held, attemptId, attempt, patch, output, hasEvidence };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=continuation-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-evidence.js","sourceRoot":"","sources":["../src/continuation-evidence.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACrE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;QACpE,OAAO,IAAI,KAAK,IAAI,CA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C,CAAC,KAAK,CAAC,IAAI,EAAE;QACd,CAAC,CAAC,MAAM;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,eAAe;YAC9B,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CACvE,CAAC;IACJ,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ContinuationSources } from "@claudexor/schema";
|
|
2
2
|
export declare function writeContinuationSources(runDir: string, sources: ContinuationSources): void;
|
|
3
|
-
export declare function readContinuationSources(runDir: string
|
|
3
|
+
export declare function readContinuationSources(runDir: string, options?: {
|
|
4
|
+
strict?: boolean;
|
|
5
|
+
}): ContinuationSources;
|
|
4
6
|
export declare function retainedEnvelopeInChain(sources: ContinuationSources): {
|
|
5
7
|
version: 1;
|
|
6
8
|
state: "live" | "retained";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continuation-sources.d.ts","sourceRoot":"","sources":["../src/continuation-sources.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"continuation-sources.d.ts","sourceRoot":"","sources":["../src/continuation-sources.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKxD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAkB3F;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,mBAAmB,CAYrB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;SAMnE"}
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
/** Durable predecessor addresses; custody remains authoritative in each envelope. */
|
|
2
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { fsyncDirectory } from "@claudexor/util";
|
|
3
5
|
import { dirname, join } from "node:path";
|
|
4
6
|
import { ContinuationSources } from "@claudexor/schema";
|
|
5
7
|
import { retainedEnvelopeOfRun } from "./retained-envelopes.js";
|
|
6
8
|
const SOURCES_FILE = "context/continuation.json";
|
|
7
9
|
export function writeContinuationSources(runDir, sources) {
|
|
8
10
|
const path = join(runDir, SOURCES_FILE);
|
|
11
|
+
const text = JSON.stringify(ContinuationSources.parse(sources)) + "\n";
|
|
9
12
|
mkdirSync(dirname(path), { recursive: true });
|
|
10
|
-
|
|
13
|
+
const temp = `${path}.tmp-${randomUUID()}`;
|
|
14
|
+
try {
|
|
15
|
+
const fd = openSync(temp, "wx", 0o600);
|
|
16
|
+
try {
|
|
17
|
+
writeFileSync(fd, text);
|
|
18
|
+
fsyncSync(fd);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
closeSync(fd);
|
|
22
|
+
}
|
|
23
|
+
renameSync(temp, path);
|
|
24
|
+
fsyncDirectory(dirname(path));
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
rmSync(temp, { force: true });
|
|
28
|
+
}
|
|
11
29
|
}
|
|
12
|
-
export function readContinuationSources(runDir) {
|
|
30
|
+
export function readContinuationSources(runDir, options = {}) {
|
|
13
31
|
try {
|
|
14
32
|
return ContinuationSources.parse(JSON.parse(readFileSync(join(runDir, SOURCES_FILE), "utf8")));
|
|
15
33
|
}
|
|
16
|
-
catch {
|
|
34
|
+
catch (error) {
|
|
35
|
+
// Absence is normal for a non-continuation. Retirement must distinguish
|
|
36
|
+
// that from unreadable evidence instead of proving false non-ownership.
|
|
37
|
+
if (options.strict && error.code !== "ENOENT")
|
|
38
|
+
throw new Error(`continuation references ${join(runDir, SOURCES_FILE)}: ${String(error)}`, {
|
|
39
|
+
cause: error,
|
|
40
|
+
});
|
|
17
41
|
return [];
|
|
18
42
|
}
|
|
19
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continuation-sources.js","sourceRoot":"","sources":["../src/continuation-sources.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,
|
|
1
|
+
{"version":3,"file":"continuation-sources.js","sourceRoot":"","sources":["../src/continuation-sources.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAEjD,MAAM,UAAU,wBAAwB,CAAC,MAAc,EAAE,OAA4B;IACnF,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,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MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAChE,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Untracked nested repositories that no `.gitmodules` entry declares, as
|
|
3
|
+
* worktree-top-relative paths: `git ls-files --others` names each one with a
|
|
4
|
+
* trailing slash because Git never descends into another repository, and
|
|
5
|
+
* `--full-name` keeps the names top-relative when the capture runs in a
|
|
6
|
+
* subdirectory, matching both the patch paths and the `:(top)` exclusions.
|
|
7
|
+
* Read against the caller's scratch index (`env`), so the set is "not in the
|
|
8
|
+
* base tree", never the user's staging state.
|
|
9
|
+
*
|
|
10
|
+
* A patch cannot carry another repository (Git records a commit link, or
|
|
11
|
+
* refuses a repository without a commit outright), so callers leave these out
|
|
12
|
+
* of their `git add` with `nestedRepositoryExcludes` instead of failing.
|
|
13
|
+
*/
|
|
14
|
+
export declare function untrackedNestedRepositories(repo: string, env: Record<string, string>, pathspec: string[], label: string): Promise<string[]>;
|
|
15
|
+
/** Exclusion pathspecs for `untrackedNestedRepositories` paths: top-relative
|
|
16
|
+
* and literal, so a name with glob characters never swallows a sibling. */
|
|
17
|
+
export declare function nestedRepositoryExcludes(paths: string[]): string[];
|
|
18
|
+
//# sourceMappingURL=git-nested-repositories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-nested-repositories.d.ts","sourceRoot":"","sources":["../src/git-nested-repositories.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;;;;GAYG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBnB;AAED;2EAC2E;AAC3E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { WorkspaceError } from "@claudexor/core";
|
|
2
|
+
import { gitEnv } from "./git-run.js";
|
|
3
|
+
/** Submodule paths the working tree's own `.gitmodules` declares, relative to
|
|
4
|
+
* the worktree top (where the file lives, whatever directory the capture runs
|
|
5
|
+
* in): a submodule the candidate added on purpose is captured as its commit
|
|
6
|
+
* link, as before. No file, or no declared path, declares nothing. The file is
|
|
7
|
+
* named relative to the capture directory (`--show-cdup` is only `../`
|
|
8
|
+
* steps), so no worktree path, whatever its spelling, is parsed here. */
|
|
9
|
+
async function declaredSubmodulePaths(repo, env) {
|
|
10
|
+
const cdup = await gitEnv(repo, ["rev-parse", "--show-cdup"], env);
|
|
11
|
+
if (cdup.code !== 0)
|
|
12
|
+
return new Set();
|
|
13
|
+
const listed = await gitEnv(repo, [
|
|
14
|
+
"config",
|
|
15
|
+
"--file",
|
|
16
|
+
`${cdup.stdout.trim()}.gitmodules`,
|
|
17
|
+
"--null",
|
|
18
|
+
"--get-regexp",
|
|
19
|
+
"^submodule\\..*\\.path$",
|
|
20
|
+
], env);
|
|
21
|
+
if (listed.code !== 0)
|
|
22
|
+
return new Set();
|
|
23
|
+
// --null: each entry is "key\nvalue\0", so a path keeps its spaces and newlines.
|
|
24
|
+
return new Set(listed.stdout
|
|
25
|
+
.split("\0")
|
|
26
|
+
.filter((entry) => entry.includes("\n"))
|
|
27
|
+
.map((entry) => entry.slice(entry.indexOf("\n") + 1))
|
|
28
|
+
.filter((path) => path.length > 0));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Untracked nested repositories that no `.gitmodules` entry declares, as
|
|
32
|
+
* worktree-top-relative paths: `git ls-files --others` names each one with a
|
|
33
|
+
* trailing slash because Git never descends into another repository, and
|
|
34
|
+
* `--full-name` keeps the names top-relative when the capture runs in a
|
|
35
|
+
* subdirectory, matching both the patch paths and the `:(top)` exclusions.
|
|
36
|
+
* Read against the caller's scratch index (`env`), so the set is "not in the
|
|
37
|
+
* base tree", never the user's staging state.
|
|
38
|
+
*
|
|
39
|
+
* A patch cannot carry another repository (Git records a commit link, or
|
|
40
|
+
* refuses a repository without a commit outright), so callers leave these out
|
|
41
|
+
* of their `git add` with `nestedRepositoryExcludes` instead of failing.
|
|
42
|
+
*/
|
|
43
|
+
export async function untrackedNestedRepositories(repo, env, pathspec, label) {
|
|
44
|
+
const listed = await gitEnv(repo, ["ls-files", "--others", "--exclude-standard", "--full-name", "-z", "--", ...pathspec], env);
|
|
45
|
+
if (listed.code !== 0) {
|
|
46
|
+
throw new WorkspaceError(`${label} could not list untracked files: ${listed.stderr.trim()}`);
|
|
47
|
+
}
|
|
48
|
+
const nested = listed.stdout
|
|
49
|
+
.split("\0")
|
|
50
|
+
.filter((entry) => entry.endsWith("/"))
|
|
51
|
+
.map((entry) => entry.slice(0, -1));
|
|
52
|
+
if (nested.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
const declared = await declaredSubmodulePaths(repo, env);
|
|
55
|
+
return nested.filter((path) => !declared.has(path));
|
|
56
|
+
}
|
|
57
|
+
/** Exclusion pathspecs for `untrackedNestedRepositories` paths: top-relative
|
|
58
|
+
* and literal, so a name with glob characters never swallows a sibling. */
|
|
59
|
+
export function nestedRepositoryExcludes(paths) {
|
|
60
|
+
return paths.map((path) => `:(exclude,top,literal)${path}`);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=git-nested-repositories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-nested-repositories.js","sourceRoot":"","sources":["../src/git-nested-repositories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;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,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,GAAG,KAAK,oCAAoC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM;SACzB,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC;AAED;2EAC2E;AAC3E,MAAM,UAAU,wBAAwB,CAAC,KAAe;IACtD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** BYTE-FAITHFUL git capture: raw buffers, never readline — CR
|
|
2
|
+
* bytes in CRLF diff content survive, and no trailing newline is fabricated
|
|
3
|
+
* (trim-based consumers like revParse are unaffected: git ends its own
|
|
4
|
+
* output with \n). */
|
|
5
|
+
export declare function git(repo: string, args: string[], input?: string): Promise<{
|
|
6
|
+
code: number | null;
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** `git` with extra environment (e.g. a scratch GIT_INDEX_FILE for snapshots). */
|
|
11
|
+
export declare function gitEnv(repo: string, args: string[], env: Record<string, string>, input?: string): Promise<{
|
|
12
|
+
code: number | null;
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Capture-time honesty: with --binary a payload-less "Binary files differ"
|
|
17
|
+
* stub should be impossible; if one appears anyway, fail AT CAPTURE with a
|
|
18
|
+
* typed error instead of shipping a patch that cannot apply. */
|
|
19
|
+
export declare function assertNoBinaryStubs(diff: string, label: string): void;
|
|
20
|
+
//# sourceMappingURL=git-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-run.d.ts","sourceRoot":"","sources":["../src/git-run.ts"],"names":[],"mappings":"AAOA;;;sBAGsB;AACtB,wBAAsB,GAAG,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAIlE;AAED,kFAAkF;AAClF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQlE;AAED;;gEAEgE;AAChE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQrE"}
|
package/dist/git-run.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assertCaptureComplete, parseUnifiedDiff, runCaptureRaw, WorkspaceError, } from "@claudexor/core";
|
|
2
|
+
/** BYTE-FAITHFUL git capture: raw buffers, never readline — CR
|
|
3
|
+
* bytes in CRLF diff content survive, and no trailing newline is fabricated
|
|
4
|
+
* (trim-based consumers like revParse are unaffected: git ends its own
|
|
5
|
+
* output with \n). */
|
|
6
|
+
export async function git(repo, args, input) {
|
|
7
|
+
const r = await runCaptureRaw("git", ["-C", repo, ...args], { timeoutMs: 60_000, input });
|
|
8
|
+
assertCaptureComplete(r);
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
/** `git` with extra environment (e.g. a scratch GIT_INDEX_FILE for snapshots). */
|
|
12
|
+
export async function gitEnv(repo, args, env, input) {
|
|
13
|
+
const r = await runCaptureRaw("git", ["-C", repo, ...args], {
|
|
14
|
+
timeoutMs: 60_000,
|
|
15
|
+
env,
|
|
16
|
+
input,
|
|
17
|
+
});
|
|
18
|
+
assertCaptureComplete(r);
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
/** Capture-time honesty: with --binary a payload-less "Binary files differ"
|
|
22
|
+
* stub should be impossible; if one appears anyway, fail AT CAPTURE with a
|
|
23
|
+
* typed error instead of shipping a patch that cannot apply. */
|
|
24
|
+
export function assertNoBinaryStubs(diff, label) {
|
|
25
|
+
const stubs = parseUnifiedDiff(diff).files.filter((f) => f.binaryStub);
|
|
26
|
+
if (stubs.length > 0) {
|
|
27
|
+
const names = stubs.map((f) => f.newPath ?? f.oldPath ?? "(unknown)").join(", ");
|
|
28
|
+
throw new WorkspaceError(`${label} produced undeliverable binary stub(s) for: ${names}; the work product cannot be applied`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=git-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-run.js","sourceRoot":"","sources":["../src/git-run.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB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,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CaptureOutputExceeded } from "@claudexor/core";
|
|
2
|
+
/**
|
|
3
|
+
* Capture the current worktree against an exact base without writing its blobs
|
|
4
|
+
* into the user's Git object database. In-place harness output is untrusted
|
|
5
|
+
* until the secret fence has inspected the resulting patch; `snapshotTree`
|
|
6
|
+
* would otherwise leave a dangling raw-secret blob even when artifact
|
|
7
|
+
* persistence later refused the patch.
|
|
8
|
+
*
|
|
9
|
+
* Git still owns filename, mode, symlink, binary, ignored-file, and untracked
|
|
10
|
+
* semantics. A scratch index plus an isolated temporary object directory holds
|
|
11
|
+
* the candidate tree only for the duration of `git diff`; the real object
|
|
12
|
+
* directory is read-only through Git's alternates mechanism.
|
|
13
|
+
*/
|
|
14
|
+
export interface TransientDiffCapture {
|
|
15
|
+
captureIncomplete: boolean;
|
|
16
|
+
captureFailure?: CaptureOutputExceeded;
|
|
17
|
+
patch: string;
|
|
18
|
+
/** Changed binary files whose pre- or postimage holds secret-like bytes (or
|
|
19
|
+
* could not be read for inspection). The exact patch still carries their
|
|
20
|
+
* payload; a persisted COPY withholds it and discloses these paths (INV-062). */
|
|
21
|
+
binarySecretPaths: string[];
|
|
22
|
+
/** Untracked directories holding their own Git repository. A patch cannot
|
|
23
|
+
* carry another repository (Git would record a commit link, or refuse a
|
|
24
|
+
* repository without a commit), so they are left out of the capture and
|
|
25
|
+
* named here instead of failing the whole capture. */
|
|
26
|
+
excludedNestedRepositories?: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare function captureWorkingTreeTransient(repo: string, baseSha: string, pathExcludes?: string[]): Promise<TransientDiffCapture>;
|
|
29
|
+
export declare function diffWorkingTreeTransient(repo: string, baseSha: string, pathExcludes?: string[]): Promise<string>;
|
|
30
|
+
//# sourceMappingURL=git-transient-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-transient-capture.d.ts","sourceRoot":"","sources":["../src/git-transient-capture.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAoC,MAAM,iBAAiB,CAAC;AAQ1F;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;qFAEiF;IACjF,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B;;;0DAGsD;IACtD,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;CACvC;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,YAAY,GAAE,MAAM,EAAO,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA2H/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,YAAY,GAAE,MAAM,EAAO,GAC1B,OAAO,CAAC,MAAM,CAAC,CAIjB"}
|