@agent-watch-ai/edge 0.6.0 → 0.7.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/CHANGELOG.md +219 -9
- package/README.md +303 -4
- package/dist/billing/billing-mode.d.ts +37 -5
- package/dist/billing/billing-mode.js +28 -19
- package/dist/billing/constants/billing.constants.d.ts +0 -2
- package/dist/billing/constants/billing.constants.js +0 -2
- package/dist/billing/index.d.ts +2 -1
- package/dist/billing/index.js +1 -1
- package/dist/billing/session-billing.d.ts +3 -2
- package/dist/billing/session-billing.js +8 -8
- package/dist/billing/types/billing.types.d.ts +7 -0
- package/dist/capture/capture-env.d.ts +147 -0
- package/dist/capture/capture-env.js +301 -0
- package/dist/capture/captured-step.d.ts +88 -0
- package/dist/capture/captured-step.js +479 -0
- package/dist/capture/constants/capture.constants.d.ts +70 -0
- package/dist/capture/constants/capture.constants.js +72 -0
- package/dist/capture/launched-runs.d.ts +16 -0
- package/dist/capture/launched-runs.js +151 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +823 -0
- package/dist/capture/schemas/capture.schema.d.ts +35 -0
- package/dist/capture/schemas/capture.schema.js +31 -0
- package/dist/capture/types/capture.types.d.ts +20 -0
- package/dist/cli/constants/cli.constants.d.ts +2 -6
- package/dist/cli/constants/cli.constants.js +3 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +13 -0
- package/dist/cli/doctor-run-capture.js +19 -0
- package/dist/cli/doctor.js +16 -67
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +40 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/misc.js +10 -2
- package/dist/cli/replay.d.ts +33 -0
- package/dist/cli/replay.js +193 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +154 -26
- package/dist/cli/status.js +45 -5
- package/dist/cli/toggle.js +10 -0
- package/dist/cli/types/cli.types.d.ts +15 -1
- package/dist/cli/uninstall.js +8 -22
- package/dist/cli.js +104 -17
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.js +2 -0
- package/dist/config/events-transport.d.ts +15 -0
- package/dist/config/events-transport.js +29 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/root-config.d.ts +12 -0
- package/dist/config/root-config.js +24 -0
- package/dist/config/schemas/config.schema.d.ts +13 -0
- package/dist/config/schemas/config.schema.js +42 -6
- package/dist/config/types/config.types.d.ts +7 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/version.d.ts +9 -0
- package/dist/core/version.js +14 -0
- package/dist/core/which.d.ts +11 -0
- package/dist/core/which.js +18 -0
- package/dist/credentials/cloud-claim.d.ts +32 -0
- package/dist/credentials/cloud-claim.js +42 -0
- package/dist/credentials/constants/credentials.constants.d.ts +8 -1
- package/dist/credentials/constants/credentials.constants.js +9 -2
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/sign-in.d.ts +27 -0
- package/dist/credentials/sign-in.js +31 -1
- package/dist/credentials/token-refresher.d.ts +5 -1
- package/dist/credentials/token-refresher.js +10 -2
- package/dist/events/constants/events.constants.d.ts +5 -2
- package/dist/events/constants/events.constants.js +4 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/product-event.d.ts +6 -3
- package/dist/events/types/events.types.d.ts +6 -0
- package/dist/events/types/replay-progress.types.d.ts +26 -0
- package/dist/events/types/replay-progress.types.js +1 -0
- package/dist/events/types/repo-tree.types.d.ts +2 -1
- package/dist/feature/ticket-candidates.d.ts +1 -1
- package/dist/git/checkout-root.d.ts +15 -0
- package/dist/git/checkout-root.js +18 -0
- package/dist/git/code-state.d.ts +2 -16
- package/dist/git/code-state.js +11 -12
- package/dist/git/constants/git.constants.d.ts +31 -11
- package/dist/git/constants/git.constants.js +36 -12
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.js +5 -1
- package/dist/git/index.d.ts +1 -2
- package/dist/git/index.js +1 -1
- package/dist/git/repo-snapshot.d.ts +13 -4
- package/dist/git/repo-snapshot.js +47 -9
- package/dist/git/types/snapshot.types.d.ts +2 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
- package/dist/pipeline/constants/pipeline.constants.js +3 -0
- package/dist/pipeline/hook-pipeline.js +81 -57
- package/dist/privacy/product-capture.js +2 -0
- package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.capture.js +5 -0
- package/dist/providers/antigravity/antigravity.detect.js +8 -22
- package/dist/providers/antigravity/antigravity.provider.js +10 -3
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
- package/dist/providers/claude/claude.adapter.js +9 -6
- package/dist/providers/claude/claude.detect.js +2 -17
- package/dist/providers/claude/claude.otel.d.ts +21 -3
- package/dist/providers/claude/claude.otel.js +216 -61
- package/dist/providers/claude/claude.provider.js +17 -1
- package/dist/providers/claude/claude.version.d.ts +9 -0
- package/dist/providers/claude/claude.version.js +28 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.constants.js +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
- package/dist/providers/claude/types/claude.types.d.ts +13 -0
- package/dist/providers/codex/codex.capture.d.ts +76 -0
- package/dist/providers/codex/codex.capture.js +454 -0
- package/dist/providers/codex/codex.detect.js +2 -4
- package/dist/providers/codex/codex.otel.d.ts +38 -2
- package/dist/providers/codex/codex.otel.js +50 -6
- package/dist/providers/codex/codex.provider.js +8 -0
- package/dist/providers/codex/codex.surface.d.ts +9 -0
- package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
- package/dist/providers/codex/codex.titles.d.ts +14 -0
- package/dist/providers/codex/codex.titles.js +35 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
- package/dist/providers/codex/constants/codex.constants.js +4 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
- package/dist/providers/cursor/constants/cursor.constants.js +25 -5
- package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
- package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
- package/dist/providers/cursor/cursor.adapter.js +20 -82
- package/dist/providers/cursor/cursor.capture.d.ts +1 -0
- package/dist/providers/cursor/cursor.capture.js +4 -0
- package/dist/providers/cursor/cursor.detect.d.ts +5 -1
- package/dist/providers/cursor/cursor.detect.js +11 -26
- package/dist/providers/cursor/cursor.hooks.js +2 -2
- package/dist/providers/cursor/cursor.provider.js +16 -7
- package/dist/providers/cursor/cursor.titles.d.ts +14 -0
- package/dist/providers/cursor/cursor.titles.js +20 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
- package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
- package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
- package/dist/providers/gemini/constants/gemini.constants.js +17 -0
- package/dist/providers/gemini/gemini.capture.d.ts +81 -0
- package/dist/providers/gemini/gemini.capture.js +210 -0
- package/dist/providers/gemini/gemini.detect.js +57 -24
- package/dist/providers/gemini/gemini.otel.d.ts +38 -2
- package/dist/providers/gemini/gemini.otel.js +56 -125
- package/dist/providers/gemini/gemini.provider.js +5 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/provider.d.ts +8 -0
- package/dist/providers/provider.js +9 -0
- package/dist/providers/registry.d.ts +14 -0
- package/dist/providers/registry.js +14 -0
- package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
- package/dist/providers/shared/constants/hook-config.constants.js +2 -0
- package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
- package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
- package/dist/providers/shared/editor-paths.d.ts +8 -0
- package/dist/providers/shared/editor-paths.js +18 -0
- package/dist/providers/shared/hook-config.d.ts +5 -0
- package/dist/providers/shared/hook-config.js +39 -1
- package/dist/providers/shared/hooks-marker.d.ts +14 -0
- package/dist/providers/shared/hooks-marker.js +23 -0
- package/dist/providers/shared/install-record.d.ts +29 -0
- package/dist/providers/shared/install-record.js +52 -0
- package/dist/providers/shared/session-title-store.d.ts +23 -0
- package/dist/providers/shared/session-title-store.js +50 -0
- package/dist/providers/shared/terminal-capture.d.ts +41 -0
- package/dist/providers/shared/terminal-capture.js +109 -0
- package/dist/providers/shared/tooling.d.ts +21 -0
- package/dist/providers/shared/tooling.js +36 -1
- package/dist/providers/types/provider.types.d.ts +57 -4
- package/dist/replay/checkout-resolver.d.ts +29 -0
- package/dist/replay/checkout-resolver.js +69 -0
- package/dist/replay/codex-turns.d.ts +24 -0
- package/dist/replay/codex-turns.js +221 -0
- package/dist/replay/constants/replay.constants.d.ts +99 -0
- package/dist/replay/constants/replay.constants.js +102 -0
- package/dist/replay/describe.d.ts +10 -0
- package/dist/replay/describe.js +31 -0
- package/dist/replay/gemini-turns.d.ts +36 -0
- package/dist/replay/gemini-turns.js +192 -0
- package/dist/replay/machine.d.ts +34 -0
- package/dist/replay/machine.js +68 -0
- package/dist/replay/progress-event.d.ts +21 -0
- package/dist/replay/progress-event.js +45 -0
- package/dist/replay/replay-runner.d.ts +58 -0
- package/dist/replay/replay-runner.js +529 -0
- package/dist/replay/replay-scan.d.ts +83 -0
- package/dist/replay/replay-scan.js +170 -0
- package/dist/replay/replay-state.d.ts +108 -0
- package/dist/replay/replay-state.js +199 -0
- package/dist/replay/resume.d.ts +18 -0
- package/dist/replay/resume.js +34 -0
- package/dist/replay/start.d.ts +23 -0
- package/dist/replay/start.js +39 -0
- package/dist/replay/throttle.d.ts +35 -0
- package/dist/replay/throttle.js +41 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +215 -0
- package/dist/replay/turn-event.d.ts +38 -0
- package/dist/replay/turn-event.js +116 -0
- package/dist/replay/types/replay.types.d.ts +162 -0
- package/dist/replay/types/replay.types.js +1 -0
- package/dist/replay/window.d.ts +28 -0
- package/dist/replay/window.js +41 -0
- package/dist/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +71 -41
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
- package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
- package/dist/snapshot/constants/snapshot.constants.js +34 -7
- package/dist/snapshot/index.d.ts +2 -2
- package/dist/snapshot/index.js +1 -1
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +6 -2
- package/dist/snapshot/tree-pipeline.d.ts +1 -1
- package/dist/snapshot/tree-pipeline.js +34 -15
- package/dist/snapshot/types/snapshot.types.d.ts +20 -3
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/delivery-stats.d.ts +13 -1
- package/dist/transport/delivery-stats.js +18 -2
- package/dist/transport/delivery.d.ts +4 -3
- package/dist/transport/delivery.js +21 -7
- package/dist/transport/identity-delivery.d.ts +20 -0
- package/dist/transport/identity-delivery.js +41 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/types/delivery-flow.types.d.ts +7 -0
- package/dist/turns/claude-transcript.js +4 -12
- package/dist/turns/codex-transcript.d.ts +9 -0
- package/dist/turns/codex-transcript.js +27 -19
- package/dist/turns/constants/turns.constants.d.ts +13 -12
- package/dist/turns/constants/turns.constants.js +15 -19
- package/dist/turns/gemini-transcript.d.ts +19 -1
- package/dist/turns/gemini-transcript.js +29 -18
- package/dist/turns/index.d.ts +3 -4
- package/dist/turns/index.js +2 -3
- package/dist/turns/run-state.d.ts +71 -0
- package/dist/turns/run-state.js +114 -0
- package/dist/turns/tool-events.d.ts +11 -1
- package/dist/turns/tool-events.js +32 -9
- package/dist/turns/transcript.d.ts +15 -14
- package/dist/turns/transcript.js +23 -4
- package/dist/turns/turn-state.d.ts +49 -7
- package/dist/turns/turn-state.js +78 -10
- package/dist/turns/turn-summary.js +7 -2
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +162 -86
- package/dist/turns/types/transcript.types.d.ts +11 -1
- package/dist/turns/types/turn-provider.types.d.ts +33 -0
- package/dist/turns/types/turn-provider.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +9 -0
- package/dist/turns/types/turn-summary.types.d.ts +17 -1
- package/dist/turns/types/turn-tracker.types.d.ts +3 -1
- package/dist/turns/work-checkout.js +1 -2
- package/docs/AUDIT_PROMPT.md +10 -0
- package/docs/DATA_HANDLING.md +193 -7
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +10 -0
- package/package.json +3 -2
- package/dist/events/canonical-event.d.ts +0 -10
- package/dist/events/canonical-event.js +0 -9
- package/dist/git/repository-root.d.ts +0 -39
- package/dist/git/repository-root.js +0 -131
- package/dist/git/types/repository-root.types.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -6
- package/dist/turns/codex-originator.d.ts +0 -11
- package/dist/turns/cursor-transcript.d.ts +0 -21
- package/dist/turns/cursor-transcript.js +0 -66
- package/dist/turns/native-session-titles.d.ts +0 -26
- package/dist/turns/native-session-titles.js +0 -102
- /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
- /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
|
@@ -9,7 +9,8 @@ export interface RepoTreeFile {
|
|
|
9
9
|
*
|
|
10
10
|
* What a tenant with no GitHub App gets its code feature catalog named from:
|
|
11
11
|
* paths and declaration names stand in for the source nothing may clone. Sent
|
|
12
|
-
*
|
|
12
|
+
* per repository and install identity, and again when the trunk's tree changes
|
|
13
|
+
* (checked hourly); other turns cost one state read.
|
|
13
14
|
*/
|
|
14
15
|
export interface RepoTreeEvent extends AgentWatchEvent<'repo.tree'> {
|
|
15
16
|
readonly provider: string;
|
|
@@ -25,3 +25,18 @@ export declare function checkoutOf(target: string): Promise<{
|
|
|
25
25
|
root: string;
|
|
26
26
|
relative: string;
|
|
27
27
|
} | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a path is a directory or lies inside it.
|
|
30
|
+
*
|
|
31
|
+
* The two answers that disqualify it are a relative path that climbs out and
|
|
32
|
+
* one that stays absolute (a different drive or root). A sibling named
|
|
33
|
+
* `..foo` climbs nowhere, which is why the separator is part of the test.
|
|
34
|
+
*
|
|
35
|
+
* Asked of a repository path read back out of local turn state, which must not
|
|
36
|
+
* be trusted to stay inside the folder the session started in.
|
|
37
|
+
*
|
|
38
|
+
* @param boundary - Folder that bounds the target.
|
|
39
|
+
* @param target - Path to test against it.
|
|
40
|
+
* @returns True when the target is the boundary or beneath it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isBeneath(boundary: string, target: string): boolean;
|
|
@@ -73,3 +73,21 @@ async function existingDirectory(target) {
|
|
|
73
73
|
}
|
|
74
74
|
return undefined;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Whether a path is a directory or lies inside it.
|
|
78
|
+
*
|
|
79
|
+
* The two answers that disqualify it are a relative path that climbs out and
|
|
80
|
+
* one that stays absolute (a different drive or root). A sibling named
|
|
81
|
+
* `..foo` climbs nowhere, which is why the separator is part of the test.
|
|
82
|
+
*
|
|
83
|
+
* Asked of a repository path read back out of local turn state, which must not
|
|
84
|
+
* be trusted to stay inside the folder the session started in.
|
|
85
|
+
*
|
|
86
|
+
* @param boundary - Folder that bounds the target.
|
|
87
|
+
* @param target - Path to test against it.
|
|
88
|
+
* @returns True when the target is the boundary or beneath it.
|
|
89
|
+
*/
|
|
90
|
+
export function isBeneath(boundary, target) {
|
|
91
|
+
const relative = path.relative(boundary, target);
|
|
92
|
+
return !path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`);
|
|
93
|
+
}
|
package/dist/git/code-state.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { CodeState
|
|
1
|
+
import type { CodeState } from './types/git.types.js';
|
|
2
2
|
export type { CodeState } from './types/git.types.js';
|
|
3
|
-
/** Hashes what one git command writes to stdout; undefined unless it exits 0. */
|
|
4
|
-
export type GitDigester = (args: readonly string[], cwd: string, timeoutMs: number) => Promise<string | undefined>;
|
|
5
3
|
/**
|
|
6
4
|
* HEAD and a digest of the uncommitted diff, taken in the completion hook of
|
|
7
5
|
* a check so a later run of it can be told to cover an earlier one only on
|
|
@@ -16,18 +14,6 @@ export type GitDigester = (args: readonly string[], cwd: string, timeoutMs: numb
|
|
|
16
14
|
* checkout digests the empty diff. Untracked files are not covered.
|
|
17
15
|
*
|
|
18
16
|
* @param cwd - Where the call ran.
|
|
19
|
-
* @param run - Git runner; injectable for tests.
|
|
20
|
-
* @param digest - Streaming hasher; injectable for tests.
|
|
21
|
-
* @param timeoutMs - Budget per git process.
|
|
22
17
|
* @returns The state, or undefined outside a repository or before its first commit.
|
|
23
18
|
*/
|
|
24
|
-
export declare function codeStateAt(cwd: string
|
|
25
|
-
/**
|
|
26
|
-
* sha256 of a git command's stdout, streamed: never buffered, never cut.
|
|
27
|
-
*
|
|
28
|
-
* @param args - Argument vector.
|
|
29
|
-
* @param cwd - Working directory.
|
|
30
|
-
* @param timeoutMs - Kill budget.
|
|
31
|
-
* @returns The hex digest when git exits 0, else undefined. Never rejects.
|
|
32
|
-
*/
|
|
33
|
-
export declare const digestGitOutput: GitDigester;
|
|
19
|
+
export declare function codeStateAt(cwd: string): Promise<CodeState | undefined>;
|
package/dist/git/code-state.js
CHANGED
|
@@ -16,13 +16,10 @@ import { runGit } from './git-context.js';
|
|
|
16
16
|
* checkout digests the empty diff. Untracked files are not covered.
|
|
17
17
|
*
|
|
18
18
|
* @param cwd - Where the call ran.
|
|
19
|
-
* @param run - Git runner; injectable for tests.
|
|
20
|
-
* @param digest - Streaming hasher; injectable for tests.
|
|
21
|
-
* @param timeoutMs - Budget per git process.
|
|
22
19
|
* @returns The state, or undefined outside a repository or before its first commit.
|
|
23
20
|
*/
|
|
24
|
-
export async function codeStateAt(cwd
|
|
25
|
-
const [commit, diffFp] = await Promise.all([
|
|
21
|
+
export async function codeStateAt(cwd) {
|
|
22
|
+
const [commit, diffFp] = await Promise.all([runGit(['rev-parse', 'HEAD'], cwd, GIT_TIMEOUT_MS), digestGitOutput(UNCOMMITTED_DIFF_ARGS, cwd, GIT_TIMEOUT_MS)]);
|
|
26
23
|
if (commit === undefined || !RE_OBJECT_ID.test(commit))
|
|
27
24
|
return undefined;
|
|
28
25
|
return { commit, diffFp };
|
|
@@ -35,10 +32,12 @@ export async function codeStateAt(cwd, run = runGit, digest = digestGitOutput, t
|
|
|
35
32
|
* @param timeoutMs - Kill budget.
|
|
36
33
|
* @returns The hex digest when git exits 0, else undefined. Never rejects.
|
|
37
34
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
function digestGitOutput(args, cwd, timeoutMs) {
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
const hash = crypto.createHash('sha256');
|
|
38
|
+
const child = spawn('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
39
|
+
child.stdout.on('data', (chunk) => hash.update(chunk));
|
|
40
|
+
child.on('error', () => resolve(undefined));
|
|
41
|
+
child.on('close', (code) => resolve(code === 0 ? hash.digest('hex') : undefined));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -47,7 +47,8 @@ export declare const GIT_FIELD_SEPARATOR = "\u001F";
|
|
|
47
47
|
* compared against.
|
|
48
48
|
*
|
|
49
49
|
* One process for the whole listing, and it carries the heads — which is what
|
|
50
|
-
* lets the cache diff run before any `git log
|
|
50
|
+
* lets the cache diff run before any `git log` — and whether each upstream is
|
|
51
|
+
* gone, which costs nothing here and a process per branch anywhere else. On an ordinary closing turn,
|
|
51
52
|
* where nothing moved, that is the difference between two git processes and
|
|
52
53
|
* twelve.
|
|
53
54
|
*
|
|
@@ -55,6 +56,12 @@ export declare const GIT_FIELD_SEPARATOR = "\u001F";
|
|
|
55
56
|
* @returns The argument vector.
|
|
56
57
|
*/
|
|
57
58
|
export declare function gitRecentBranchesArgs(count: number): readonly string[];
|
|
59
|
+
/**
|
|
60
|
+
* What `%(upstream:track)` prints for a branch whose upstream was deleted on
|
|
61
|
+
* the remote and pruned here: the usual end of a merged or closed pull request.
|
|
62
|
+
* Plumbing prints it untranslated (only `git branch -vv` localizes it).
|
|
63
|
+
*/
|
|
64
|
+
export declare const GIT_UPSTREAM_GONE = "[gone]";
|
|
58
65
|
/**
|
|
59
66
|
* The commits on a branch that its default branch does not have.
|
|
60
67
|
*
|
|
@@ -68,6 +75,29 @@ export declare function gitRecentBranchesArgs(count: number): readonly string[];
|
|
|
68
75
|
* @returns The argument vector.
|
|
69
76
|
*/
|
|
70
77
|
export declare function gitBranchDeltaArgs(defaultBranch: string, branch: string, count: number): readonly string[];
|
|
78
|
+
/**
|
|
79
|
+
* The tree a merge of `branch` into `base` would produce, without touching the
|
|
80
|
+
* checkout or the index (git >= 2.38; older gits reject the form and the caller
|
|
81
|
+
* reads that as "not merged").
|
|
82
|
+
*
|
|
83
|
+
* Equal to the base's own tree means the branch adds nothing the trunk lacks,
|
|
84
|
+
* however it got there: a squash or rebase merge leaves the branch's commits
|
|
85
|
+
* outside `base..branch` but its changes inside the trunk, and this sees the
|
|
86
|
+
* changes. It writes the merged objects to the object store, unreferenced, for
|
|
87
|
+
* `gc` to prune; it exits non-zero on a conflict.
|
|
88
|
+
*
|
|
89
|
+
* @param base - The trunk the delta was taken against.
|
|
90
|
+
* @param branch - The branch to test.
|
|
91
|
+
* @returns The argument vector.
|
|
92
|
+
*/
|
|
93
|
+
export declare function gitMergeTreeArgs(base: string, branch: string): readonly string[];
|
|
94
|
+
/**
|
|
95
|
+
* The tree of a ref, to compare a {@link gitMergeTreeArgs} result against.
|
|
96
|
+
*
|
|
97
|
+
* @param ref - The ref.
|
|
98
|
+
* @returns The argument vector.
|
|
99
|
+
*/
|
|
100
|
+
export declare function gitTreeArgs(ref: string): readonly string[];
|
|
71
101
|
/** One name-status letter: added, copied, deleted, modified, renamed, type-changed, unmerged, unknown. */
|
|
72
102
|
export declare const RE_NAME_STATUS: RegExp;
|
|
73
103
|
/** The newline git puts between a commit's header and its first name-status entry. */
|
|
@@ -172,16 +202,6 @@ export declare const GATE_REMOTE_MEMO_TTL_MS = 3600000;
|
|
|
172
202
|
* remoteless checkout pays one subprocess a minute rather than one per prompt.
|
|
173
203
|
*/
|
|
174
204
|
export declare const GATE_REMOTE_ABSENT_TTL_MS = 60000;
|
|
175
|
-
/**
|
|
176
|
-
* The entry that marks a repository root. A *file* of that name counts too:
|
|
177
|
-
* that is what a linked worktree and a submodule check out as.
|
|
178
|
-
*/
|
|
179
|
-
export declare const GIT_ENTRY_NAME = ".git";
|
|
180
|
-
/**
|
|
181
|
-
* The errors that mean "no `.git` here". Anything else — a permission or I/O
|
|
182
|
-
* error — means the answer is unknown, not no.
|
|
183
|
-
*/
|
|
184
|
-
export declare const GIT_ENTRY_ABSENT_CODES: ReadonlySet<string>;
|
|
185
205
|
/**
|
|
186
206
|
* One fingerprint of a checkout: HEAD, branch and every dirty entry in one
|
|
187
207
|
* process. NUL-separated so a path is never quoted, split or trimmed; every
|
|
@@ -47,7 +47,8 @@ export const GIT_FIELD_SEPARATOR = '';
|
|
|
47
47
|
* compared against.
|
|
48
48
|
*
|
|
49
49
|
* One process for the whole listing, and it carries the heads — which is what
|
|
50
|
-
* lets the cache diff run before any `git log
|
|
50
|
+
* lets the cache diff run before any `git log` — and whether each upstream is
|
|
51
|
+
* gone, which costs nothing here and a process per branch anywhere else. On an ordinary closing turn,
|
|
51
52
|
* where nothing moved, that is the difference between two git processes and
|
|
52
53
|
* twelve.
|
|
53
54
|
*
|
|
@@ -60,9 +61,15 @@ export function gitRecentBranchesArgs(count) {
|
|
|
60
61
|
'refs/heads',
|
|
61
62
|
'--sort=-committerdate',
|
|
62
63
|
`--count=${String(count)}`,
|
|
63
|
-
`--format=%(refname:short)${GIT_FIELD_SEPARATOR}%(objectname)${GIT_FIELD_SEPARATOR}%(committerdate:iso-strict)`
|
|
64
|
+
`--format=%(refname:short)${GIT_FIELD_SEPARATOR}%(objectname)${GIT_FIELD_SEPARATOR}%(committerdate:iso-strict)${GIT_FIELD_SEPARATOR}%(upstream:track)`
|
|
64
65
|
];
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* What `%(upstream:track)` prints for a branch whose upstream was deleted on
|
|
69
|
+
* the remote and pruned here: the usual end of a merged or closed pull request.
|
|
70
|
+
* Plumbing prints it untranslated (only `git branch -vv` localizes it).
|
|
71
|
+
*/
|
|
72
|
+
export const GIT_UPSTREAM_GONE = '[gone]';
|
|
66
73
|
/**
|
|
67
74
|
* The commits on a branch that its default branch does not have.
|
|
68
75
|
*
|
|
@@ -85,6 +92,33 @@ export function gitBranchDeltaArgs(defaultBranch, branch, count) {
|
|
|
85
92
|
'--'
|
|
86
93
|
];
|
|
87
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The tree a merge of `branch` into `base` would produce, without touching the
|
|
97
|
+
* checkout or the index (git >= 2.38; older gits reject the form and the caller
|
|
98
|
+
* reads that as "not merged").
|
|
99
|
+
*
|
|
100
|
+
* Equal to the base's own tree means the branch adds nothing the trunk lacks,
|
|
101
|
+
* however it got there: a squash or rebase merge leaves the branch's commits
|
|
102
|
+
* outside `base..branch` but its changes inside the trunk, and this sees the
|
|
103
|
+
* changes. It writes the merged objects to the object store, unreferenced, for
|
|
104
|
+
* `gc` to prune; it exits non-zero on a conflict.
|
|
105
|
+
*
|
|
106
|
+
* @param base - The trunk the delta was taken against.
|
|
107
|
+
* @param branch - The branch to test.
|
|
108
|
+
* @returns The argument vector.
|
|
109
|
+
*/
|
|
110
|
+
export function gitMergeTreeArgs(base, branch) {
|
|
111
|
+
return ['merge-tree', '--write-tree', base, branch];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The tree of a ref, to compare a {@link gitMergeTreeArgs} result against.
|
|
115
|
+
*
|
|
116
|
+
* @param ref - The ref.
|
|
117
|
+
* @returns The argument vector.
|
|
118
|
+
*/
|
|
119
|
+
export function gitTreeArgs(ref) {
|
|
120
|
+
return ['rev-parse', '--verify', '-q', `${ref}^{tree}`];
|
|
121
|
+
}
|
|
88
122
|
/** One name-status letter: added, copied, deleted, modified, renamed, type-changed, unmerged, unknown. */
|
|
89
123
|
export const RE_NAME_STATUS = /^[ACDMRTUX]$/;
|
|
90
124
|
/** The newline git puts between a commit's header and its first name-status entry. */
|
|
@@ -218,16 +252,6 @@ export const GATE_REMOTE_MEMO_TTL_MS = 3_600_000;
|
|
|
218
252
|
* remoteless checkout pays one subprocess a minute rather than one per prompt.
|
|
219
253
|
*/
|
|
220
254
|
export const GATE_REMOTE_ABSENT_TTL_MS = 60_000;
|
|
221
|
-
/**
|
|
222
|
-
* The entry that marks a repository root. A *file* of that name counts too:
|
|
223
|
-
* that is what a linked worktree and a submodule check out as.
|
|
224
|
-
*/
|
|
225
|
-
export const GIT_ENTRY_NAME = '.git';
|
|
226
|
-
/**
|
|
227
|
-
* The errors that mean "no `.git` here". Anything else — a permission or I/O
|
|
228
|
-
* error — means the answer is unknown, not no.
|
|
229
|
-
*/
|
|
230
|
-
export const GIT_ENTRY_ABSENT_CODES = new Set(['ENOENT', 'ENOTDIR']);
|
|
231
255
|
/**
|
|
232
256
|
* One fingerprint of a checkout: HEAD, branch and every dirty entry in one
|
|
233
257
|
* process. NUL-separated so a path is never quoted, split or trimmed; every
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fingerprint
|
|
1
|
+
import type { Fingerprint } from './types/git.types.js';
|
|
2
2
|
export type { DirtyEntry, Fingerprint } from './types/git.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* What a checkout looks like right now: HEAD, branch, and every dirty entry
|
|
@@ -14,11 +14,9 @@ export type { DirtyEntry, Fingerprint } from './types/git.types.js';
|
|
|
14
14
|
* else.
|
|
15
15
|
*
|
|
16
16
|
* @param root - Checkout root.
|
|
17
|
-
* @param run - Git runner; injectable for tests.
|
|
18
|
-
* @param timeoutMs - Kill budget for the git process.
|
|
19
17
|
* @returns The fingerprint, or undefined when git could not give one.
|
|
20
18
|
*/
|
|
21
|
-
export declare function fingerprint(root: string
|
|
19
|
+
export declare function fingerprint(root: string): Promise<Fingerprint | undefined>;
|
|
22
20
|
/**
|
|
23
21
|
* `git status --porcelain=v2 --branch -z`, read.
|
|
24
22
|
*
|
|
@@ -58,10 +56,9 @@ export declare function dirtyDelta(baseline: Fingerprint, closing: Fingerprint):
|
|
|
58
56
|
* @param from - Where the turn started; undefined when the branch was unborn.
|
|
59
57
|
* @param to - Where it ended: an oid, or a branch ref.
|
|
60
58
|
* @param gitDir - Ask this git dir rather than the one `cwd` would find.
|
|
61
|
-
* @param run - Git runner; injectable for tests.
|
|
62
59
|
* @returns Repository-relative paths; empty when git could not say.
|
|
63
60
|
*/
|
|
64
|
-
export declare function commitFiles(cwd: string, from: string | undefined, to: string, gitDir?: string
|
|
61
|
+
export declare function commitFiles(cwd: string, from: string | undefined, to: string, gitDir?: string): Promise<string[]>;
|
|
65
62
|
/**
|
|
66
63
|
* A fingerprint out of turn state, type-checked field by field.
|
|
67
64
|
*
|
package/dist/git/fingerprint.js
CHANGED
|
@@ -18,12 +18,10 @@ import { runGit } from './git-context.js';
|
|
|
18
18
|
* else.
|
|
19
19
|
*
|
|
20
20
|
* @param root - Checkout root.
|
|
21
|
-
* @param run - Git runner; injectable for tests.
|
|
22
|
-
* @param timeoutMs - Kill budget for the git process.
|
|
23
21
|
* @returns The fingerprint, or undefined when git could not give one.
|
|
24
22
|
*/
|
|
25
|
-
export async function fingerprint(root
|
|
26
|
-
const [status, commonDir] = await Promise.all([
|
|
23
|
+
export async function fingerprint(root) {
|
|
24
|
+
const [status, commonDir] = await Promise.all([runGit(GIT_FINGERPRINT_ARGS, root, GIT_TIMEOUT_MS), readCommonDir(root)]);
|
|
27
25
|
if (status === undefined)
|
|
28
26
|
return undefined;
|
|
29
27
|
const parsed = parsePorcelainV2(status);
|
|
@@ -105,14 +103,13 @@ export function dirtyDelta(baseline, closing) {
|
|
|
105
103
|
* @param from - Where the turn started; undefined when the branch was unborn.
|
|
106
104
|
* @param to - Where it ended: an oid, or a branch ref.
|
|
107
105
|
* @param gitDir - Ask this git dir rather than the one `cwd` would find.
|
|
108
|
-
* @param run - Git runner; injectable for tests.
|
|
109
106
|
* @returns Repository-relative paths; empty when git could not say.
|
|
110
107
|
*/
|
|
111
|
-
export async function commitFiles(cwd, from, to, gitDir
|
|
108
|
+
export async function commitFiles(cwd, from, to, gitDir) {
|
|
112
109
|
const asked = (args) => (gitDir ? ['--git-dir', gitDir, ...args] : args);
|
|
113
110
|
const [diverged, output] = await Promise.all([
|
|
114
|
-
from === undefined ? '' :
|
|
115
|
-
|
|
111
|
+
from === undefined ? '' : runGit(asked(gitNotAncestorArgs(from, to)), cwd, GIT_TIMEOUT_MS),
|
|
112
|
+
runGit(asked(gitOwnCommitFilesArgs(from, to)), cwd, GIT_TIMEOUT_MS)
|
|
116
113
|
]);
|
|
117
114
|
// `diverged` is undefined when git failed, which is no proof either way.
|
|
118
115
|
return diverged === '' && output ? [...new Set(output.split('\0').filter(Boolean))] : [];
|
package/dist/git/git-context.js
CHANGED
|
@@ -251,7 +251,11 @@ function readOctalEscape(inner, start) {
|
|
|
251
251
|
* @returns Trailing-trimmed stdout, or undefined.
|
|
252
252
|
*/
|
|
253
253
|
export const runGit = (args, cwd, timeoutMs, home, maxBufferBytes = GIT_MAX_BUFFER_BYTES) => new Promise((resolve) => {
|
|
254
|
-
|
|
254
|
+
// `GIT_NO_LAZY_FETCH`: in a partial clone a missing blob would otherwise be
|
|
255
|
+
// fetched from the remote inside the hook (merge-tree reads blobs). Git
|
|
256
|
+
// before 2.44 ignores it, and a call that needed the blob fails as any
|
|
257
|
+
// other git failure does.
|
|
258
|
+
const env = { ...process.env, GIT_NO_LAZY_FETCH: '1', ...(home ? { HOME: home, XDG_CONFIG_HOME: path.join(home, '.config') } : {}) };
|
|
255
259
|
// `--no-optional-locks`, on every call the edge makes: a hook must never
|
|
256
260
|
// take `index.lock` from under the agent's own `git commit` in that checkout.
|
|
257
261
|
execFile('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, maxBuffer: maxBufferBytes, windowsHide: true, env }, (error, stdout) => {
|
package/dist/git/index.d.ts
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type { CodeState, GitContext, GitContextOptions, GitRunner, GitUserEmailOptions, RemoteParts } from './types/git.types.js';
|
|
6
6
|
export type { BranchCommit, BranchRef, CommitFile, SnapshotBranch } from './types/snapshot.types.js';
|
|
7
|
-
export type { RepositoryRootFinder } from './types/repository-root.types.js';
|
|
8
7
|
export { codeStateAt } from './code-state.js';
|
|
9
8
|
export { collectGitContext, developerIdentity, gitUserEmail, runGit } from './git-context.js';
|
|
10
9
|
export { collectBranchCommits, collectBranchRefs, parseCommitFiles, resolveDefaultBranch } from './repo-snapshot.js';
|
|
11
10
|
export { normalizeRemote, remoteHash, stripRemoteCredentials } from './remote-sanitize.js';
|
|
12
|
-
export { isBeneath
|
|
11
|
+
export { isBeneath } from './checkout-root.js';
|
package/dist/git/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { codeStateAt } from './code-state.js';
|
|
|
2
2
|
export { collectGitContext, developerIdentity, gitUserEmail, runGit } from './git-context.js';
|
|
3
3
|
export { collectBranchCommits, collectBranchRefs, parseCommitFiles, resolveDefaultBranch } from './repo-snapshot.js';
|
|
4
4
|
export { normalizeRemote, remoteHash, stripRemoteCredentials } from './remote-sanitize.js';
|
|
5
|
-
export { isBeneath
|
|
5
|
+
export { isBeneath } from './checkout-root.js';
|
|
@@ -37,14 +37,23 @@ export declare function resolveDefaultBranch(cwd: string, run: GitRunner): Promi
|
|
|
37
37
|
* and taken together that would cost the branch the subjects of every commit
|
|
38
38
|
* older than it. Apart, the worst a huge commit does is lose some paths.
|
|
39
39
|
*
|
|
40
|
+
* A branch whose work is already on the trunk is undefined, not empty: one
|
|
41
|
+
* with no delta at all (merged, or created and never committed on), and one
|
|
42
|
+
* whose delta merges into the trunk without changing it (squash- or
|
|
43
|
+
* rebase-merged, where the trunk holds the changes under other shas). Named
|
|
44
|
+
* alone, either becomes a feature for work that is finished. A just-created
|
|
45
|
+
* branch that is checked out still reaches the platform, through the turn that
|
|
46
|
+
* names it (core AWT-419).
|
|
47
|
+
*
|
|
40
48
|
* @param branch - Branch to describe.
|
|
41
49
|
* @param options - Where to look, the base branch and the commit cap.
|
|
42
50
|
* @param run - Git runner.
|
|
43
|
-
* @returns The delta commits, newest first
|
|
44
|
-
*
|
|
45
|
-
*
|
|
51
|
+
* @returns The delta commits, newest first, or undefined when the branch's
|
|
52
|
+
* work is already on the trunk. Empty when there is no base to subtract or
|
|
53
|
+
* git failed, which is the honest answer: the alternative is reporting the
|
|
54
|
+
* trunk's commits as this branch's work, and "unknown" is not "merged".
|
|
46
55
|
*/
|
|
47
|
-
export declare function collectBranchCommits(branch: string, options: CollectCommitsOptions, run: GitRunner): Promise<BranchCommit[]>;
|
|
56
|
+
export declare function collectBranchCommits(branch: string, options: CollectCommitsOptions, run: GitRunner): Promise<BranchCommit[] | undefined>;
|
|
48
57
|
/**
|
|
49
58
|
* The files of each commit in one `log -z --name-status --format=%H` listing.
|
|
50
59
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASSUMED_DEFAULT_BRANCHES, GIT_FIELD_SEPARATOR, GIT_ORIGIN_HEAD_ARGS, GIT_TIMEOUT_MS, RE_LEADING_NEWLINE, RE_NAME_STATUS, RE_OBJECT_ID, gitBranchDeltaArgs, gitBranchFilesArgs, gitRecentBranchesArgs, gitVerifyRefArgs } from './constants/git.constants.js';
|
|
1
|
+
import { ASSUMED_DEFAULT_BRANCHES, GIT_FIELD_SEPARATOR, GIT_ORIGIN_HEAD_ARGS, GIT_TIMEOUT_MS, GIT_UPSTREAM_GONE, RE_LEADING_NEWLINE, RE_NAME_STATUS, RE_OBJECT_ID, gitBranchDeltaArgs, gitBranchFilesArgs, gitMergeTreeArgs, gitRecentBranchesArgs, gitTreeArgs, gitVerifyRefArgs } from './constants/git.constants.js';
|
|
2
2
|
/** `origin/HEAD` is reported as `origin/main`; the branch is what comes after. */
|
|
3
3
|
const REMOTE_PREFIX = 'origin/';
|
|
4
4
|
/**
|
|
@@ -54,22 +54,37 @@ export async function resolveDefaultBranch(cwd, run) {
|
|
|
54
54
|
* and taken together that would cost the branch the subjects of every commit
|
|
55
55
|
* older than it. Apart, the worst a huge commit does is lose some paths.
|
|
56
56
|
*
|
|
57
|
+
* A branch whose work is already on the trunk is undefined, not empty: one
|
|
58
|
+
* with no delta at all (merged, or created and never committed on), and one
|
|
59
|
+
* whose delta merges into the trunk without changing it (squash- or
|
|
60
|
+
* rebase-merged, where the trunk holds the changes under other shas). Named
|
|
61
|
+
* alone, either becomes a feature for work that is finished. A just-created
|
|
62
|
+
* branch that is checked out still reaches the platform, through the turn that
|
|
63
|
+
* names it (core AWT-419).
|
|
64
|
+
*
|
|
57
65
|
* @param branch - Branch to describe.
|
|
58
66
|
* @param options - Where to look, the base branch and the commit cap.
|
|
59
67
|
* @param run - Git runner.
|
|
60
|
-
* @returns The delta commits, newest first
|
|
61
|
-
*
|
|
62
|
-
*
|
|
68
|
+
* @returns The delta commits, newest first, or undefined when the branch's
|
|
69
|
+
* work is already on the trunk. Empty when there is no base to subtract or
|
|
70
|
+
* git failed, which is the honest answer: the alternative is reporting the
|
|
71
|
+
* trunk's commits as this branch's work, and "unknown" is not "merged".
|
|
63
72
|
*/
|
|
64
73
|
export async function collectBranchCommits(branch, options, run) {
|
|
65
74
|
const delta = await branchDelta(branch, options, run);
|
|
66
|
-
if (!delta
|
|
75
|
+
if (!delta)
|
|
67
76
|
return [];
|
|
77
|
+
if (delta.output === '')
|
|
78
|
+
return undefined;
|
|
68
79
|
const commits = delta.output
|
|
69
80
|
.split('\n')
|
|
70
81
|
.map((line) => parseCommit(line))
|
|
71
82
|
.filter((commit) => commit !== undefined);
|
|
72
|
-
if (commits.length === 0
|
|
83
|
+
if (commits.length === 0)
|
|
84
|
+
return commits;
|
|
85
|
+
if (await alreadyOnTrunk(delta.base, branch, options.cwd, run))
|
|
86
|
+
return undefined;
|
|
87
|
+
if (options.withFiles === false)
|
|
73
88
|
return commits;
|
|
74
89
|
const listing = await run(gitBranchFilesArgs(delta.base, branch, options.commitCount), options.cwd, GIT_TIMEOUT_MS);
|
|
75
90
|
// A listing that failed or ran out of budget leaves every commit without
|
|
@@ -82,6 +97,29 @@ export async function collectBranchCommits(branch, options, run) {
|
|
|
82
97
|
return changed ? { ...commit, files: changed } : commit;
|
|
83
98
|
});
|
|
84
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Whether merging the branch into its base would leave the base unchanged.
|
|
102
|
+
*
|
|
103
|
+
* Two processes, on branches that have a delta only. Any failure is "no": an
|
|
104
|
+
* old git, a conflict (a squash the trunk has since edited on top of) or a
|
|
105
|
+
* spent budget keeps the branch, which is what every edge before this did.
|
|
106
|
+
*
|
|
107
|
+
* ponytail: the base tree is read once per branch; one read per snapshot would
|
|
108
|
+
* save ~5 ms a branch but needs the delta's base carried out of branchDelta.
|
|
109
|
+
*
|
|
110
|
+
* @param base - The ref the delta was taken against.
|
|
111
|
+
* @param branch - Branch to test.
|
|
112
|
+
* @param cwd - Repository directory.
|
|
113
|
+
* @param run - Git runner.
|
|
114
|
+
* @returns True only when git said so.
|
|
115
|
+
*/
|
|
116
|
+
async function alreadyOnTrunk(base, branch, cwd, run) {
|
|
117
|
+
const merged = await run(gitMergeTreeArgs(base, branch), cwd, GIT_TIMEOUT_MS);
|
|
118
|
+
if (!merged)
|
|
119
|
+
return false;
|
|
120
|
+
const tree = await run(gitTreeArgs(base), cwd, GIT_TIMEOUT_MS);
|
|
121
|
+
return tree !== undefined && merged.split('\n', 1)[0] === tree;
|
|
122
|
+
}
|
|
85
123
|
/**
|
|
86
124
|
* The delta's log output and the base it was taken against.
|
|
87
125
|
*
|
|
@@ -171,14 +209,14 @@ export function parseCommitFiles(output) {
|
|
|
171
209
|
/**
|
|
172
210
|
* One `for-each-ref` record.
|
|
173
211
|
*
|
|
174
|
-
* @param line - `name<sep>sha<sep>date`.
|
|
212
|
+
* @param line - `name<sep>sha<sep>date<sep>track`.
|
|
175
213
|
* @returns The branch, or undefined for a line missing a name or a head.
|
|
176
214
|
*/
|
|
177
215
|
function parseBranchRef(line) {
|
|
178
|
-
const [name, headSha, lastCommitAt] = line.split(GIT_FIELD_SEPARATOR);
|
|
216
|
+
const [name, headSha, lastCommitAt, track] = line.split(GIT_FIELD_SEPARATOR);
|
|
179
217
|
if (!name || !headSha)
|
|
180
218
|
return undefined;
|
|
181
|
-
return { name, headSha, lastCommitAt: lastCommitAt || undefined };
|
|
219
|
+
return { name, headSha, lastCommitAt: lastCommitAt || undefined, ...(track === GIT_UPSTREAM_GONE ? { upstreamGone: true } : {}) };
|
|
182
220
|
}
|
|
183
221
|
/**
|
|
184
222
|
* One `log` record.
|
|
@@ -3,6 +3,8 @@ export interface BranchRef {
|
|
|
3
3
|
readonly name: string;
|
|
4
4
|
readonly headSha: string;
|
|
5
5
|
readonly lastCommitAt?: string;
|
|
6
|
+
/** Its upstream was deleted on the remote and pruned here; absent when it has none or it exists. */
|
|
7
|
+
readonly upstreamGone?: boolean;
|
|
6
8
|
}
|
|
7
9
|
/** One file a commit changed: git's name-status letter and the repository-relative path. */
|
|
8
10
|
export interface CommitFile {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CanonicalEventType } from '../../events/types/events.types.js';
|
|
2
2
|
/** Stage names, used in the flow definition and in its debug trace. */
|
|
3
|
+
export declare const STAGE_IGNORED_ROOT = "ignored-root";
|
|
3
4
|
export declare const STAGE_RESOLVE_CONTEXT = "resolve-context";
|
|
4
5
|
export declare const STAGE_PARSE_EVENTS = "parse-events";
|
|
5
6
|
export declare const STAGE_AWAIT_SIGN_IN = "await-sign-in";
|
|
@@ -8,6 +9,7 @@ export declare const MAX_WORKSPACE_ROOTS = 4;
|
|
|
8
9
|
export declare const STAGE_NOMINATE = "nominate";
|
|
9
10
|
export declare const STAGE_UNTRACED = "untraced";
|
|
10
11
|
export declare const STAGE_UPDATE = "update";
|
|
12
|
+
export declare const STAGE_REPLAY_RESUME = "replay-resume";
|
|
11
13
|
/** SessionStart sources that are not a developer starting work: no update notice on them. */
|
|
12
14
|
export declare const QUIET_SESSION_SOURCES: ReadonlySet<string>;
|
|
13
15
|
export declare const STAGE_ENFORCE = "enforce";
|
|
@@ -17,6 +19,7 @@ export declare const STAGE_DELIVER = "deliver";
|
|
|
17
19
|
export declare const STAGE_REWRITE_BEARERS = "rewrite-bearers";
|
|
18
20
|
export declare const STAGE_SNAPSHOT = "repo-snapshot";
|
|
19
21
|
/** Reasons a stage ends the flow early. */
|
|
22
|
+
export declare const STOP_IGNORED_ROOT = "working directory is in ignoredRoots: nothing is captured, sent or queued";
|
|
20
23
|
export declare const STOP_NO_EVENTS = "provider produced no canonical events";
|
|
21
24
|
export declare const STOP_DRY_RUN = "dry run: nothing delivered";
|
|
22
25
|
export declare const STOP_NO_SNAPSHOT = "no closed turn, or git capture is off";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Stage names, used in the flow definition and in its debug trace. */
|
|
2
|
+
export const STAGE_IGNORED_ROOT = 'ignored-root';
|
|
2
3
|
export const STAGE_RESOLVE_CONTEXT = 'resolve-context';
|
|
3
4
|
export const STAGE_PARSE_EVENTS = 'parse-events';
|
|
4
5
|
export const STAGE_AWAIT_SIGN_IN = 'await-sign-in';
|
|
@@ -7,6 +8,7 @@ export const MAX_WORKSPACE_ROOTS = 4;
|
|
|
7
8
|
export const STAGE_NOMINATE = 'nominate';
|
|
8
9
|
export const STAGE_UNTRACED = 'untraced';
|
|
9
10
|
export const STAGE_UPDATE = 'update';
|
|
11
|
+
export const STAGE_REPLAY_RESUME = 'replay-resume';
|
|
10
12
|
/** SessionStart sources that are not a developer starting work: no update notice on them. */
|
|
11
13
|
export const QUIET_SESSION_SOURCES = new Set(['clear', 'compact']);
|
|
12
14
|
export const STAGE_ENFORCE = 'enforce';
|
|
@@ -16,6 +18,7 @@ export const STAGE_DELIVER = 'deliver';
|
|
|
16
18
|
export const STAGE_REWRITE_BEARERS = 'rewrite-bearers';
|
|
17
19
|
export const STAGE_SNAPSHOT = 'repo-snapshot';
|
|
18
20
|
/** Reasons a stage ends the flow early. */
|
|
21
|
+
export const STOP_IGNORED_ROOT = 'working directory is in ignoredRoots: nothing is captured, sent or queued';
|
|
19
22
|
export const STOP_NO_EVENTS = 'provider produced no canonical events';
|
|
20
23
|
export const STOP_DRY_RUN = 'dry run: nothing delivered';
|
|
21
24
|
export const STOP_NO_SNAPSHOT = 'no closed turn, or git capture is off';
|