@agent-watch-ai/edge 0.5.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 +238 -7
- package/README.md +308 -8
- 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 +8 -2
- package/dist/events/constants/events.constants.js +7 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/product-event.d.ts +10 -4
- 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-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +25 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- 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/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +8 -3
- 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/repo-tree.d.ts +69 -0
- package/dist/git/repo-tree.js +130 -0
- package/dist/git/types/git.types.d.ts +5 -2
- package/dist/git/types/snapshot.types.d.ts +14 -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 +112 -72
- package/dist/privacy/product-capture.js +36 -5
- 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 +74 -42
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +10 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +10 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +37 -4
- package/dist/snapshot/constants/snapshot.constants.js +37 -4
- package/dist/snapshot/index.d.ts +6 -1
- package/dist/snapshot/index.js +3 -1
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +24 -2
- package/dist/snapshot/tree-event.d.ts +14 -0
- package/dist/snapshot/tree-event.js +91 -0
- package/dist/snapshot/tree-pipeline.d.ts +12 -0
- package/dist/snapshot/tree-pipeline.js +172 -0
- package/dist/snapshot/types/snapshot.types.d.ts +62 -2
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -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/queue.js +40 -6
- 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 +10 -6
- 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 +20 -6
- 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 +269 -32
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +27 -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
|
@@ -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.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { GitRunner } from './types/git.types.js';
|
|
2
|
+
import type { RepoTree } from './types/snapshot.types.js';
|
|
3
|
+
export type { RepoTree, TreeFile } from './types/snapshot.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The tree of the default branch as the remote knows it, else as the clone has it.
|
|
6
|
+
*
|
|
7
|
+
* The same rule as a branch delta: the local trunk only when `origin/<trunk>`
|
|
8
|
+
* is absent, never because reading it failed — a stale local `main` would
|
|
9
|
+
* describe a product nobody ships.
|
|
10
|
+
*
|
|
11
|
+
* @param cwd - Repository directory.
|
|
12
|
+
* @param defaultBranch - The trunk's name.
|
|
13
|
+
* @param run - Git runner.
|
|
14
|
+
* @returns The tree oid, or undefined when there is none or git failed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveTreeSha(cwd: string, defaultBranch: string, run: GitRunner): Promise<string | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Every source file of one tree with its top-level declaration names.
|
|
19
|
+
*
|
|
20
|
+
* Read from git's object store only — `ls-tree` and `git grep <tree>` — so no
|
|
21
|
+
* checkout state, uncommitted file or working-copy secret can reach it, and no
|
|
22
|
+
* body ever leaves git: `grep -o` prints the declaration text alone.
|
|
23
|
+
*
|
|
24
|
+
* Three searches run side by side: the spike's declarations and the route
|
|
25
|
+
* paths over every source file, and the extra languages' declarations over
|
|
26
|
+
* their own files only, so the TS, Python and Go names stay exactly what the
|
|
27
|
+
* naming result was measured on.
|
|
28
|
+
*
|
|
29
|
+
* @param cwd - Repository directory.
|
|
30
|
+
* @param treeSha - The tree to read.
|
|
31
|
+
* @param run - Git runner; the caller's budgeted one bounds every search.
|
|
32
|
+
* @returns The tree, or undefined when it could not be listed. A search that
|
|
33
|
+
* failed or found nothing leaves its files with no names; the caller tells a
|
|
34
|
+
* search cut short by the budget from one that matched nothing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collectRepoTree(cwd: string, treeSha: string, run: GitRunner): Promise<RepoTree | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a path is source core's naming pass reads: `isNamingSourceFile`, mirrored.
|
|
39
|
+
*
|
|
40
|
+
* @param filePath - Repository-relative path.
|
|
41
|
+
* @returns True for a source file outside tests, vendored trees, docs and migrations.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isTreeSourceFile(filePath: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The source blobs of one `ls-tree -r -l -z` listing, in its order.
|
|
46
|
+
*
|
|
47
|
+
* Submodules (`commit`) and symlinks are not blobs worth naming and fall out of
|
|
48
|
+
* the record pattern; a symlink is a blob but carries a target, not code, and
|
|
49
|
+
* reads as one with no declarations.
|
|
50
|
+
*
|
|
51
|
+
* @param listing - The NUL-terminated listing.
|
|
52
|
+
* @returns Path and size per source file.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseTreeListing(listing: string): {
|
|
55
|
+
path: string;
|
|
56
|
+
size: number;
|
|
57
|
+
}[];
|
|
58
|
+
/**
|
|
59
|
+
* Declaration names per path out of `git grep -o -z <tree>` output.
|
|
60
|
+
*
|
|
61
|
+
* A record is `<tree>:<path>\0<match>\n`. Each match ends with what it declares:
|
|
62
|
+
* a quoted route path, or the identifier. De-duplicated per file in first-seen
|
|
63
|
+
* order, the spike's searches before the extra languages'.
|
|
64
|
+
*
|
|
65
|
+
* @param output - One or more searches' output, newline-joined.
|
|
66
|
+
* @param prefix - `<tree>:`, which git puts before every path.
|
|
67
|
+
* @returns Names by path.
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseDeclarations(output: string, prefix: string): Map<string, string[]>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { GIT_TIMEOUT_MS, gitVerifyRefArgs } from './constants/git.constants.js';
|
|
2
|
+
import { TREE_DECLARATION_PATTERN, TREE_EXTRA_DECLARATION_PATTERN, TREE_EXTRA_PATHSPECS, TREE_MAX_BUFFER_BYTES, TREE_MAX_NAMED_BLOB_BYTES, TREE_RE_QUOTED_NAME, TREE_RE_SKIP, TREE_RE_TRAILING_NAME, TREE_ROUTE_PATTERN, TREE_SALVAGE_MARGIN_BYTES, TREE_SOURCE_EXTENSIONS, gitDeclarationGrepArgs, gitListTreeArgs, gitTreeShaArgs } from './constants/tree.constants.js';
|
|
3
|
+
/** `ls-tree -l` record: `<mode> <type> <sha> <size>\t<path>`. The sha is not kept: nothing reads it. */
|
|
4
|
+
const RE_TREE_ENTRY = /^\d+ blob ([0-9a-f]{40}|[0-9a-f]{64}) +(\d+)\t/;
|
|
5
|
+
/** Every source pathspec at once: `git grep` must not read what the catalog will not send. */
|
|
6
|
+
const SOURCE_PATHSPECS = TREE_SOURCE_EXTENSIONS.map((extension) => `*${extension}`);
|
|
7
|
+
/**
|
|
8
|
+
* The tree of the default branch as the remote knows it, else as the clone has it.
|
|
9
|
+
*
|
|
10
|
+
* The same rule as a branch delta: the local trunk only when `origin/<trunk>`
|
|
11
|
+
* is absent, never because reading it failed — a stale local `main` would
|
|
12
|
+
* describe a product nobody ships.
|
|
13
|
+
*
|
|
14
|
+
* @param cwd - Repository directory.
|
|
15
|
+
* @param defaultBranch - The trunk's name.
|
|
16
|
+
* @param run - Git runner.
|
|
17
|
+
* @returns The tree oid, or undefined when there is none or git failed.
|
|
18
|
+
*/
|
|
19
|
+
export async function resolveTreeSha(cwd, defaultBranch, run) {
|
|
20
|
+
const remoteBase = `origin/${defaultBranch}`;
|
|
21
|
+
const remote = await run(gitTreeShaArgs(remoteBase), cwd, GIT_TIMEOUT_MS);
|
|
22
|
+
if (remote)
|
|
23
|
+
return remote;
|
|
24
|
+
if (await run(gitVerifyRefArgs(remoteBase), cwd, GIT_TIMEOUT_MS))
|
|
25
|
+
return undefined;
|
|
26
|
+
return run(gitTreeShaArgs(defaultBranch), cwd, GIT_TIMEOUT_MS);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Every source file of one tree with its top-level declaration names.
|
|
30
|
+
*
|
|
31
|
+
* Read from git's object store only — `ls-tree` and `git grep <tree>` — so no
|
|
32
|
+
* checkout state, uncommitted file or working-copy secret can reach it, and no
|
|
33
|
+
* body ever leaves git: `grep -o` prints the declaration text alone.
|
|
34
|
+
*
|
|
35
|
+
* Three searches run side by side: the spike's declarations and the route
|
|
36
|
+
* paths over every source file, and the extra languages' declarations over
|
|
37
|
+
* their own files only, so the TS, Python and Go names stay exactly what the
|
|
38
|
+
* naming result was measured on.
|
|
39
|
+
*
|
|
40
|
+
* @param cwd - Repository directory.
|
|
41
|
+
* @param treeSha - The tree to read.
|
|
42
|
+
* @param run - Git runner; the caller's budgeted one bounds every search.
|
|
43
|
+
* @returns The tree, or undefined when it could not be listed. A search that
|
|
44
|
+
* failed or found nothing leaves its files with no names; the caller tells a
|
|
45
|
+
* search cut short by the budget from one that matched nothing.
|
|
46
|
+
*/
|
|
47
|
+
export async function collectRepoTree(cwd, treeSha, run) {
|
|
48
|
+
const listing = await run(gitListTreeArgs(treeSha), cwd, GIT_TIMEOUT_MS, undefined, TREE_MAX_BUFFER_BYTES);
|
|
49
|
+
if (listing === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
const entries = parseTreeListing(listing);
|
|
52
|
+
if (entries.length === 0)
|
|
53
|
+
return { treeSha, files: [], partial: false };
|
|
54
|
+
const searches = await Promise.all([
|
|
55
|
+
run(gitDeclarationGrepArgs(treeSha, '-E', TREE_DECLARATION_PATTERN, SOURCE_PATHSPECS), cwd, GIT_TIMEOUT_MS, undefined, TREE_MAX_BUFFER_BYTES),
|
|
56
|
+
run(gitDeclarationGrepArgs(treeSha, '-P', TREE_ROUTE_PATTERN, SOURCE_PATHSPECS), cwd, GIT_TIMEOUT_MS, undefined, TREE_MAX_BUFFER_BYTES),
|
|
57
|
+
run(gitDeclarationGrepArgs(treeSha, '-E', TREE_EXTRA_DECLARATION_PATTERN, TREE_EXTRA_PATHSPECS), cwd, GIT_TIMEOUT_MS, undefined, TREE_MAX_BUFFER_BYTES)
|
|
58
|
+
]);
|
|
59
|
+
const names = parseDeclarations(searches.join('\n'), `${treeSha}:`);
|
|
60
|
+
const files = [];
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const named = entry.size <= TREE_MAX_NAMED_BLOB_BYTES ? names.get(entry.path) : undefined;
|
|
63
|
+
files.push({ path: entry.path, names: named ?? [] });
|
|
64
|
+
}
|
|
65
|
+
// The runner salvages an overrun up to its last newline, so a cut listing
|
|
66
|
+
// looks complete: anything within a line of the ceiling is taken as cut.
|
|
67
|
+
const partial = [listing, ...searches].some((output) => Buffer.byteLength(output ?? '') > TREE_MAX_BUFFER_BYTES - TREE_SALVAGE_MARGIN_BYTES);
|
|
68
|
+
return { treeSha, files, partial };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Whether a path is source core's naming pass reads: `isNamingSourceFile`, mirrored.
|
|
72
|
+
*
|
|
73
|
+
* @param filePath - Repository-relative path.
|
|
74
|
+
* @returns True for a source file outside tests, vendored trees, docs and migrations.
|
|
75
|
+
*/
|
|
76
|
+
export function isTreeSourceFile(filePath) {
|
|
77
|
+
return TREE_SOURCE_EXTENSIONS.some((extension) => filePath.endsWith(extension)) && !TREE_RE_SKIP.test(filePath);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The source blobs of one `ls-tree -r -l -z` listing, in its order.
|
|
81
|
+
*
|
|
82
|
+
* Submodules (`commit`) and symlinks are not blobs worth naming and fall out of
|
|
83
|
+
* the record pattern; a symlink is a blob but carries a target, not code, and
|
|
84
|
+
* reads as one with no declarations.
|
|
85
|
+
*
|
|
86
|
+
* @param listing - The NUL-terminated listing.
|
|
87
|
+
* @returns Path and size per source file.
|
|
88
|
+
*/
|
|
89
|
+
export function parseTreeListing(listing) {
|
|
90
|
+
const entries = [];
|
|
91
|
+
for (const record of listing.split('\0')) {
|
|
92
|
+
const match = RE_TREE_ENTRY.exec(record);
|
|
93
|
+
if (!match)
|
|
94
|
+
continue;
|
|
95
|
+
const filePath = record.slice(match[0].length);
|
|
96
|
+
if (!isTreeSourceFile(filePath))
|
|
97
|
+
continue;
|
|
98
|
+
entries.push({ path: filePath, size: Number(match[2]) });
|
|
99
|
+
}
|
|
100
|
+
return entries;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Declaration names per path out of `git grep -o -z <tree>` output.
|
|
104
|
+
*
|
|
105
|
+
* A record is `<tree>:<path>\0<match>\n`. Each match ends with what it declares:
|
|
106
|
+
* a quoted route path, or the identifier. De-duplicated per file in first-seen
|
|
107
|
+
* order, the spike's searches before the extra languages'.
|
|
108
|
+
*
|
|
109
|
+
* @param output - One or more searches' output, newline-joined.
|
|
110
|
+
* @param prefix - `<tree>:`, which git puts before every path.
|
|
111
|
+
* @returns Names by path.
|
|
112
|
+
*/
|
|
113
|
+
export function parseDeclarations(output, prefix) {
|
|
114
|
+
const byPath = new Map();
|
|
115
|
+
for (const line of output.split('\n')) {
|
|
116
|
+
const split = line.indexOf('\0');
|
|
117
|
+
if (split === -1 || !line.startsWith(prefix))
|
|
118
|
+
continue;
|
|
119
|
+
const filePath = line.slice(prefix.length, split);
|
|
120
|
+
const text = line.slice(split + 1);
|
|
121
|
+
const name = TREE_RE_QUOTED_NAME.exec(text)?.[1] ?? TREE_RE_TRAILING_NAME.exec(text)?.[1];
|
|
122
|
+
if (!name)
|
|
123
|
+
continue;
|
|
124
|
+
const names = byPath.get(filePath) ?? [];
|
|
125
|
+
if (!names.includes(name))
|
|
126
|
+
names.push(name);
|
|
127
|
+
byPath.set(filePath, names);
|
|
128
|
+
}
|
|
129
|
+
return byPath;
|
|
130
|
+
}
|
|
@@ -22,8 +22,11 @@ export interface GitContextOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
readonly rootOnly?: boolean;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Runs one git command and returns its trimmed stdout, or undefined.
|
|
27
|
+
* `maxBufferBytes` raises the stdout ceiling for the one listing that needs it (a whole tree).
|
|
28
|
+
*/
|
|
29
|
+
export type GitRunner = (args: readonly string[], cwd: string, timeoutMs: number, home?: string, maxBufferBytes?: number) => Promise<string | undefined>;
|
|
27
30
|
export interface GitUserEmailOptions {
|
|
28
31
|
readonly timeoutMs?: number;
|
|
29
32
|
readonly home?: string;
|
|
@@ -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 {
|
|
@@ -32,3 +34,15 @@ export interface CollectCommitsOptions {
|
|
|
32
34
|
readonly defaultBranch?: string;
|
|
33
35
|
readonly commitCount: number;
|
|
34
36
|
}
|
|
37
|
+
/** One source file of a default-branch tree: its path and its top-level declaration names. */
|
|
38
|
+
export interface TreeFile {
|
|
39
|
+
readonly path: string;
|
|
40
|
+
readonly names: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
/** One default-branch tree's source files, in `ls-tree` order, before any cap. */
|
|
43
|
+
export interface RepoTree {
|
|
44
|
+
readonly treeSha: string;
|
|
45
|
+
readonly files: readonly TreeFile[];
|
|
46
|
+
/** A listing or search reached the output ceiling and was salvaged: some files or names are missing. */
|
|
47
|
+
readonly partial: boolean;
|
|
48
|
+
}
|
|
@@ -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';
|