@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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentWatchEvent } from './events.types.js';
|
|
2
|
+
/** Where a replay stands: counting, sending, waiting for the machine or the backend, or over. */
|
|
3
|
+
export type ReplayProgressState = 'scanning' | 'running' | 'paused' | 'done' | 'stopped';
|
|
4
|
+
/**
|
|
5
|
+
* How far one replay of a developer's earlier sessions has got (contract:
|
|
6
|
+
* core `replayProgressSchema`).
|
|
7
|
+
*
|
|
8
|
+
* Counts and the window only: no path, no text, no session content. One run
|
|
9
|
+
* has one `replay_id`, so a second replay replaces the first one's numbers.
|
|
10
|
+
* `turns_total` is 0 while `scanning`; `turns_sent` is what the edge handed
|
|
11
|
+
* the backend, not what the backend has grouped.
|
|
12
|
+
*/
|
|
13
|
+
export interface ReplayProgressEvent extends AgentWatchEvent<'replay.progress'> {
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly surface: string;
|
|
16
|
+
readonly developer_id: string;
|
|
17
|
+
readonly replay_id: string;
|
|
18
|
+
readonly state: ReplayProgressState;
|
|
19
|
+
readonly window_start: string;
|
|
20
|
+
readonly window_end: string;
|
|
21
|
+
readonly turns_total: number;
|
|
22
|
+
readonly turns_sent: number;
|
|
23
|
+
readonly sessions_total: number;
|
|
24
|
+
readonly sessions_sent: number;
|
|
25
|
+
readonly started_at: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { AgentWatchEvent } from './events.types.js';
|
|
2
|
-
/** One file a commit changed: the path from the repository root
|
|
2
|
+
/** One file a commit changed: the path from the repository root. No status letter: nothing reads it. */
|
|
3
3
|
export interface RepoSnapshotCommitFile {
|
|
4
4
|
readonly path: string;
|
|
5
|
-
readonly status: string;
|
|
6
5
|
}
|
|
7
6
|
/** One commit of a branch's delta, as the backend receives it. */
|
|
8
7
|
export interface RepoSnapshotCommit {
|
|
9
8
|
readonly sha: string;
|
|
10
9
|
readonly subject: string;
|
|
11
|
-
readonly authored_at?: string;
|
|
12
10
|
/** Names only, never contents. Absent when the listing failed or ran out of time. */
|
|
13
11
|
readonly files?: readonly RepoSnapshotCommitFile[];
|
|
14
12
|
}
|
|
@@ -16,7 +14,6 @@ export interface RepoSnapshotCommit {
|
|
|
16
14
|
export interface RepoSnapshotBranch {
|
|
17
15
|
readonly name: string;
|
|
18
16
|
readonly head_sha: string;
|
|
19
|
-
readonly last_commit_at?: string;
|
|
20
17
|
readonly commits: readonly RepoSnapshotCommit[];
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentWatchEvent } from './events.types.js';
|
|
2
|
+
/** One source file of the default branch: path and top-level declaration names. Never contents. */
|
|
3
|
+
export interface RepoTreeFile {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly names: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A repository's default-branch source listing (contract: core `repoTreeSchema`).
|
|
9
|
+
*
|
|
10
|
+
* What a tenant with no GitHub App gets its code feature catalog named from:
|
|
11
|
+
* paths and declaration names stand in for the source nothing may clone. Sent
|
|
12
|
+
* per repository and install identity, and again when the trunk's tree changes
|
|
13
|
+
* (checked hourly); other turns cost one state read.
|
|
14
|
+
*/
|
|
15
|
+
export interface RepoTreeEvent extends AgentWatchEvent<'repo.tree'> {
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
readonly surface: string;
|
|
18
|
+
readonly repository: string;
|
|
19
|
+
readonly developer_id?: string;
|
|
20
|
+
/** When the listing was read. */
|
|
21
|
+
readonly captured_at: string;
|
|
22
|
+
/** Files or names were dropped to fit the contract's caps; core still names the tree. */
|
|
23
|
+
readonly truncated: boolean;
|
|
24
|
+
readonly files: readonly RepoTreeFile[];
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extensions core's naming pass reads (`isNamingSourceFile`,
|
|
3
|
+
* agent-watch-core `packages/llm/src/naming.ts`), mirrored verbatim. Core
|
|
4
|
+
* filters again with the same rule, so a drifted copy costs bytes, never
|
|
5
|
+
* correctness.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TREE_SOURCE_EXTENSIONS: readonly string[];
|
|
8
|
+
/** And the paths it skips: tests, vendored and generated trees, docs, migrations. */
|
|
9
|
+
export declare const TREE_RE_SKIP: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* The declarations the spike measured (`decl-all.cjs`), as one git ERE:
|
|
12
|
+
* exported TS/JS declarations, column-0 Python (and Ruby) `def`/`class`, and
|
|
13
|
+
* exported Go funcs. Run over every source file, so the TS, Python and Go
|
|
14
|
+
* names are exactly what the naming result was measured on.
|
|
15
|
+
*
|
|
16
|
+
* One anchored alternation, deliberately: anchored, git skips a line at its
|
|
17
|
+
* first byte; mixed with an unanchored pattern every position of every line is
|
|
18
|
+
* tried, and agent-watch-core's search goes from ~130 ms to ~800 ms.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TREE_DECLARATION_PATTERN: string;
|
|
21
|
+
/**
|
|
22
|
+
* Route paths, the one string content a catalog may read: Nest decorators and
|
|
23
|
+
* Express routers (the spike's), and Spring mappings. PCRE, because these are
|
|
24
|
+
* unanchored and the platform ERE engine scans them at ~500 ms on
|
|
25
|
+
* agent-watch-core against ~80 ms. A git built without PCRE fails this search
|
|
26
|
+
* alone, and the tree goes without route names.
|
|
27
|
+
*/
|
|
28
|
+
export declare const TREE_ROUTE_PATTERN: string;
|
|
29
|
+
/**
|
|
30
|
+
* Declarations of the languages the spike's patterns do not reach, run only
|
|
31
|
+
* over their own files so they cannot change what TS, Python or Go send:
|
|
32
|
+
* types (Java, Kotlin, C#, PHP, Rust, Dart, Ruby modules; indented, for C#
|
|
33
|
+
* namespaces and nested types), column-0 functions (Kotlin, PHP, Rust) and
|
|
34
|
+
* Elixir modules. Anchored, for the reason above.
|
|
35
|
+
*/
|
|
36
|
+
export declare const TREE_EXTRA_DECLARATION_PATTERN: string;
|
|
37
|
+
/** The files the extra patterns run over. */
|
|
38
|
+
export declare const TREE_EXTRA_PATHSPECS: readonly string[];
|
|
39
|
+
/** The name a declaration match ends with: a quoted route, or the identifier. */
|
|
40
|
+
export declare const TREE_RE_QUOTED_NAME: RegExp;
|
|
41
|
+
export declare const TREE_RE_TRAILING_NAME: RegExp;
|
|
42
|
+
/** The schema's caps (core `REPO_TREE_LIMITS`): over them, files or names are dropped and the tree marked truncated. */
|
|
43
|
+
export declare const TREE_MAX_FILES = 20000;
|
|
44
|
+
export declare const TREE_MAX_NAMES_PER_FILE = 64;
|
|
45
|
+
export declare const TREE_MAX_NAME_LENGTH = 200;
|
|
46
|
+
/** The id's provider slot: fixed, so every agent sending one trunk derives one id. */
|
|
47
|
+
export declare const TREE_EVENT_ID_PROVIDER = "agent-watch-edge";
|
|
48
|
+
/** The contract's target for one serialized event (UTF-8 bytes), half the gateway's 8 MiB body limit. */
|
|
49
|
+
export declare const TREE_MAX_EVENT_BYTES: number;
|
|
50
|
+
/** A blob larger than this is generated or vendored: listed, but its names are not read. */
|
|
51
|
+
export declare const TREE_MAX_NAMED_BLOB_BYTES: number;
|
|
52
|
+
/**
|
|
53
|
+
* stdout ceiling for the listing and the name search. With `-z` an overrun
|
|
54
|
+
* listing cannot be salvaged (no newline to cut at), so a tree past it is
|
|
55
|
+
* simply not sent rather than sent partial.
|
|
56
|
+
*/
|
|
57
|
+
export declare const TREE_MAX_BUFFER_BYTES: number;
|
|
58
|
+
/** Output this close to {@link TREE_MAX_BUFFER_BYTES} was salvaged from an overrun, not complete. */
|
|
59
|
+
export declare const TREE_SALVAGE_MARGIN_BYTES: number;
|
|
60
|
+
/** The tree object of one commit-ish, quietly absent when there is none. */
|
|
61
|
+
export declare function gitTreeShaArgs(ref: string): readonly string[];
|
|
62
|
+
/** Every entry of one tree, with blob sizes, NUL-terminated. */
|
|
63
|
+
export declare function gitListTreeArgs(tree: string): readonly string[];
|
|
64
|
+
/**
|
|
65
|
+
* Only the matched declaration text of every blob in one tree, never a body:
|
|
66
|
+
* `-o` prints the match alone, `-I` skips binaries. Line numbers and columns
|
|
67
|
+
* are switched off explicitly so a user's `grep.lineNumber` cannot reshape it.
|
|
68
|
+
* `:(top)` and `--full-name` keep a hook that runs in a subdirectory searching
|
|
69
|
+
* and naming the whole tree, as `ls-tree --full-tree` lists it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function gitDeclarationGrepArgs(tree: string, syntax: '-E' | '-P', pattern: string, pathspecs: readonly string[]): readonly string[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extensions core's naming pass reads (`isNamingSourceFile`,
|
|
3
|
+
* agent-watch-core `packages/llm/src/naming.ts`), mirrored verbatim. Core
|
|
4
|
+
* filters again with the same rule, so a drifted copy costs bytes, never
|
|
5
|
+
* correctness.
|
|
6
|
+
*/
|
|
7
|
+
// prettier-ignore
|
|
8
|
+
export const TREE_SOURCE_EXTENSIONS = [
|
|
9
|
+
'.ts', '.tsx', '.js', '.mjs', '.jsm', '.vue', '.svelte', '.py', '.go', '.rb', '.rs', '.java',
|
|
10
|
+
'.kt', '.ex', '.exs', '.php', '.dart', '.cs', '.sql', '.prisma',
|
|
11
|
+
'.c', '.cc', '.cpp', '.cxx', '.h', '.hh', '.hpp', '.m', '.mm', '.idl', '.webidl'
|
|
12
|
+
];
|
|
13
|
+
/** And the paths it skips: tests, vendored and generated trees, docs, migrations. */
|
|
14
|
+
export const TREE_RE_SKIP = /(^|\/)(test|tests|__tests__|e2e|spec|fixtures|node_modules|vendor|third_party|dist|build|\.github|docs?)\/|\.(test|spec|stories|d)\.[cm]?[jt]sx?$|\.md$|(^|\/)migrations?\//;
|
|
15
|
+
/**
|
|
16
|
+
* The declarations the spike measured (`decl-all.cjs`), as one git ERE:
|
|
17
|
+
* exported TS/JS declarations, column-0 Python (and Ruby) `def`/`class`, and
|
|
18
|
+
* exported Go funcs. Run over every source file, so the TS, Python and Go
|
|
19
|
+
* names are exactly what the naming result was measured on.
|
|
20
|
+
*
|
|
21
|
+
* One anchored alternation, deliberately: anchored, git skips a line at its
|
|
22
|
+
* first byte; mixed with an unanchored pattern every position of every line is
|
|
23
|
+
* tried, and agent-watch-core's search goes from ~130 ms to ~800 ms.
|
|
24
|
+
*/
|
|
25
|
+
export const TREE_DECLARATION_PATTERN = '^('
|
|
26
|
+
+ 'export[[:space:]]+(default[[:space:]]+)?(declare[[:space:]]+)?(abstract[[:space:]]+)?(async[[:space:]]+)?(function\\*?|class|const|let|var|interface|type|enum)[[:space:]]+[A-Za-z_$][A-Za-z0-9_$]*'
|
|
27
|
+
+ '|(async[[:space:]]+)?(def|class)[[:space:]]+[A-Za-z_][A-Za-z0-9_]*'
|
|
28
|
+
+ '|func[[:space:]]+(\\([^)]*\\)[[:space:]]*)?[A-Z][A-Za-z0-9_]*'
|
|
29
|
+
+ ')';
|
|
30
|
+
/**
|
|
31
|
+
* Route paths, the one string content a catalog may read: Nest decorators and
|
|
32
|
+
* Express routers (the spike's), and Spring mappings. PCRE, because these are
|
|
33
|
+
* unanchored and the platform ERE engine scans them at ~500 ms on
|
|
34
|
+
* agent-watch-core against ~80 ms. A git built without PCRE fails this search
|
|
35
|
+
* alone, and the tree goes without route names.
|
|
36
|
+
*/
|
|
37
|
+
export const TREE_ROUTE_PATTERN = '@(?:Controller|Get|Post|Put|Patch|Delete|Resolver)\\(\\s*[\'"`][^\'"`]+[\'"`]'
|
|
38
|
+
+ '|\\b(?:router|app)\\.(?:get|post|put|patch|delete|use)\\(\\s*[\'"`][^\'"`]+[\'"`]'
|
|
39
|
+
+ '|@(?:Get|Post|Put|Patch|Delete|Request)Mapping\\(\\s*(?:value\\s*=\\s*)?"[^"]+"';
|
|
40
|
+
/**
|
|
41
|
+
* Declarations of the languages the spike's patterns do not reach, run only
|
|
42
|
+
* over their own files so they cannot change what TS, Python or Go send:
|
|
43
|
+
* types (Java, Kotlin, C#, PHP, Rust, Dart, Ruby modules; indented, for C#
|
|
44
|
+
* namespaces and nested types), column-0 functions (Kotlin, PHP, Rust) and
|
|
45
|
+
* Elixir modules. Anchored, for the reason above.
|
|
46
|
+
*/
|
|
47
|
+
export const TREE_EXTRA_DECLARATION_PATTERN = '^('
|
|
48
|
+
+ '[[:space:]]*((public|internal|private|protected|abstract|final|sealed|static|partial|open|data|enum|annotation|inner|readonly|value|pub(\\([a-z]+\\))?)[[:space:]]+)*(class|interface|enum|record|struct|object|trait|module|mixin)[[:space:]]+[A-Za-z_][A-Za-z0-9_]*'
|
|
49
|
+
+ '|((public|internal|private|protected|open|override|suspend|inline|static|final|abstract|async|pub(\\([a-z]+\\))?)[[:space:]]+)*(fun|function|fn)[[:space:]]+[A-Za-z_][A-Za-z0-9_]*'
|
|
50
|
+
+ '|[[:space:]]*defmodule[[:space:]]+[A-Z][A-Za-z0-9_.]*'
|
|
51
|
+
+ ')';
|
|
52
|
+
/** The files the extra patterns run over. */
|
|
53
|
+
export const TREE_EXTRA_PATHSPECS = ['*.java', '*.kt', '*.cs', '*.php', '*.rs', '*.dart', '*.rb', '*.ex', '*.exs'];
|
|
54
|
+
/** The name a declaration match ends with: a quoted route, or the identifier. */
|
|
55
|
+
export const TREE_RE_QUOTED_NAME = /['"`]([^'"`]+)['"`]$/;
|
|
56
|
+
export const TREE_RE_TRAILING_NAME = /([A-Za-z_$][\w$.]*)$/;
|
|
57
|
+
/** The schema's caps (core `REPO_TREE_LIMITS`): over them, files or names are dropped and the tree marked truncated. */
|
|
58
|
+
export const TREE_MAX_FILES = 20_000;
|
|
59
|
+
export const TREE_MAX_NAMES_PER_FILE = 64;
|
|
60
|
+
export const TREE_MAX_NAME_LENGTH = 200;
|
|
61
|
+
/** The id's provider slot: fixed, so every agent sending one trunk derives one id. */
|
|
62
|
+
export const TREE_EVENT_ID_PROVIDER = 'agent-watch-edge';
|
|
63
|
+
/** The contract's target for one serialized event (UTF-8 bytes), half the gateway's 8 MiB body limit. */
|
|
64
|
+
export const TREE_MAX_EVENT_BYTES = 4 * 1024 * 1024;
|
|
65
|
+
/** A blob larger than this is generated or vendored: listed, but its names are not read. */
|
|
66
|
+
export const TREE_MAX_NAMED_BLOB_BYTES = 1024 * 1024;
|
|
67
|
+
/**
|
|
68
|
+
* stdout ceiling for the listing and the name search. With `-z` an overrun
|
|
69
|
+
* listing cannot be salvaged (no newline to cut at), so a tree past it is
|
|
70
|
+
* simply not sent rather than sent partial.
|
|
71
|
+
*/
|
|
72
|
+
export const TREE_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
|
|
73
|
+
/** Output this close to {@link TREE_MAX_BUFFER_BYTES} was salvaged from an overrun, not complete. */
|
|
74
|
+
export const TREE_SALVAGE_MARGIN_BYTES = 64 * 1024;
|
|
75
|
+
/** The tree object of one commit-ish, quietly absent when there is none. */
|
|
76
|
+
export function gitTreeShaArgs(ref) {
|
|
77
|
+
return ['rev-parse', '--verify', '-q', `${ref}^{tree}`];
|
|
78
|
+
}
|
|
79
|
+
/** Every entry of one tree, with blob sizes, NUL-terminated. */
|
|
80
|
+
export function gitListTreeArgs(tree) {
|
|
81
|
+
return ['ls-tree', '-r', '-l', '-z', '--full-tree', tree];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Only the matched declaration text of every blob in one tree, never a body:
|
|
85
|
+
* `-o` prints the match alone, `-I` skips binaries. Line numbers and columns
|
|
86
|
+
* are switched off explicitly so a user's `grep.lineNumber` cannot reshape it.
|
|
87
|
+
* `:(top)` and `--full-name` keep a hook that runs in a subdirectory searching
|
|
88
|
+
* and naming the whole tree, as `ls-tree --full-tree` lists it.
|
|
89
|
+
*/
|
|
90
|
+
export function gitDeclarationGrepArgs(tree, syntax, pattern, pathspecs) {
|
|
91
|
+
return ['grep', '-I', '-o', '-z', syntax, '--full-name', '--no-color', '--no-line-number', '--no-column', '-e', pattern, tree, '--', ...pathspecs.map((pathspec) => `:(top)${pathspec}`)];
|
|
92
|
+
}
|
|
@@ -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))] : [];
|
|
@@ -92,6 +92,7 @@ export declare function repositoryIdentity(root: string, remoteRaw: string | und
|
|
|
92
92
|
* @param timeoutMs - Kill budget.
|
|
93
93
|
* @param home - HOME to read global git config (identity!) from, so tests and
|
|
94
94
|
* sandboxes never pick up the developer's real one.
|
|
95
|
+
* @param maxBufferBytes - stdout ceiling, when the default is too small.
|
|
95
96
|
* @returns Trailing-trimmed stdout, or undefined.
|
|
96
97
|
*/
|
|
97
98
|
export declare const runGit: GitRunner;
|
package/dist/git/git-context.js
CHANGED
|
@@ -247,13 +247,18 @@ function readOctalEscape(inner, start) {
|
|
|
247
247
|
* @param timeoutMs - Kill budget.
|
|
248
248
|
* @param home - HOME to read global git config (identity!) from, so tests and
|
|
249
249
|
* sandboxes never pick up the developer's real one.
|
|
250
|
+
* @param maxBufferBytes - stdout ceiling, when the default is too small.
|
|
250
251
|
* @returns Trailing-trimmed stdout, or undefined.
|
|
251
252
|
*/
|
|
252
|
-
export const runGit = (args, cwd, timeoutMs, home) => new Promise((resolve) => {
|
|
253
|
-
|
|
253
|
+
export const runGit = (args, cwd, timeoutMs, home, maxBufferBytes = GIT_MAX_BUFFER_BYTES) => new Promise((resolve) => {
|
|
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') } : {}) };
|
|
254
259
|
// `--no-optional-locks`, on every call the edge makes: a hook must never
|
|
255
260
|
// take `index.lock` from under the agent's own `git commit` in that checkout.
|
|
256
|
-
execFile('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, maxBuffer:
|
|
261
|
+
execFile('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, maxBuffer: maxBufferBytes, windowsHide: true, env }, (error, stdout) => {
|
|
257
262
|
// Trailing-only trim: `status --porcelain` lines carry a significant
|
|
258
263
|
// leading space (" M file"); a full trim() would eat the first character
|
|
259
264
|
// of the first filename.
|
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';
|