@agent-watch-ai/edge 0.4.0 → 0.6.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 +50 -0
- package/README.md +8 -7
- package/SECURITY.md +1 -1
- package/dist/config/config-store.js +1 -1
- package/dist/config/repo-config.js +1 -1
- package/dist/config/schemas/config.schema.d.ts +93 -857
- package/dist/config/schemas/config.schema.js +5 -5
- package/dist/credentials/credentials.js +2 -2
- package/dist/credentials/schemas/device-api.schema.d.ts +4 -51
- package/dist/credentials/schemas/device-state.schema.d.ts +3 -38
- package/dist/events/constants/events.constants.d.ts +5 -2
- package/dist/events/constants/events.constants.js +4 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/product-event.d.ts +7 -4
- package/dist/events/types/repo-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +24 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- package/dist/git/code-state.d.ts +33 -0
- package/dist/git/code-state.js +44 -0
- package/dist/git/constants/git.constants.d.ts +6 -0
- package/dist/git/constants/git.constants.js +6 -0
- package/dist/git/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +3 -2
- package/dist/git/index.d.ts +2 -1
- package/dist/git/index.js +1 -0
- 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 +11 -2
- package/dist/git/types/snapshot.types.d.ts +12 -0
- package/dist/pipeline/hook-pipeline.js +40 -24
- package/dist/privacy/command-fingerprint.d.ts +42 -0
- package/dist/privacy/command-fingerprint.js +249 -0
- package/dist/privacy/constants/command-fingerprint.constants.d.ts +34 -0
- package/dist/privacy/constants/command-fingerprint.constants.js +38 -0
- package/dist/privacy/index.d.ts +3 -1
- package/dist/privacy/index.js +2 -0
- package/dist/privacy/product-capture.js +53 -6
- package/dist/privacy/types/privacy.types.d.ts +7 -0
- package/dist/providers/antigravity/antigravity.adapter.js +3 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +18 -492
- package/dist/providers/claude/claude.adapter.js +12 -1
- package/dist/providers/claude/constants/claude.constants.d.ts +6 -0
- package/dist/providers/claude/constants/claude.constants.js +6 -0
- package/dist/providers/claude/schemas/claude.schema.d.ts +1 -43
- package/dist/providers/codex/codex.adapter.js +14 -0
- package/dist/providers/codex/schemas/codex.schema.d.ts +1 -41
- package/dist/providers/cursor/cursor.adapter.js +5 -2
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +5 -85
- package/dist/providers/gemini/constants/gemini.constants.d.ts +2 -0
- package/dist/providers/gemini/constants/gemini.constants.js +2 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +10 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +11 -2
- package/dist/providers/gemini/gemini.detect.d.ts +11 -0
- package/dist/providers/gemini/gemini.detect.js +14 -1
- package/dist/providers/gemini/gemini.hooks.d.ts +3 -3
- package/dist/providers/gemini/gemini.hooks.js +5 -5
- package/dist/providers/gemini/gemini.otel.d.ts +6 -6
- package/dist/providers/gemini/gemini.otel.js +392 -121
- package/dist/providers/gemini/schemas/gemini.schema.d.ts +1 -49
- package/dist/providers/shared/event-builder.d.ts +17 -2
- package/dist/providers/shared/event-builder.js +43 -3
- package/dist/providers/shared/install-record.d.ts +2 -0
- package/dist/providers/shared/install-record.js +3 -2
- package/dist/providers/shared/tooling.d.ts +7 -0
- package/dist/providers/shared/tooling.js +10 -1
- package/dist/providers/shared/types/adapter.types.d.ts +18 -0
- package/dist/snapshot/branch-selection.js +3 -1
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +8 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +8 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +6 -0
- package/dist/snapshot/constants/snapshot.constants.js +6 -0
- package/dist/snapshot/index.d.ts +5 -0
- package/dist/snapshot/index.js +2 -0
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-state.js +19 -1
- 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 +153 -0
- package/dist/snapshot/types/snapshot.types.d.ts +44 -1
- package/dist/storage/schemas/storage.schema.d.ts +11 -175
- package/dist/storage/schemas/storage.schema.js +7 -1
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -0
- package/dist/transport/queue.js +40 -6
- package/dist/transport/schemas/queue.schema.d.ts +1 -16
- package/dist/transport/schemas/queue.schema.js +1 -1
- package/dist/turns/constants/turns.constants.d.ts +17 -0
- package/dist/turns/constants/turns.constants.js +17 -0
- package/dist/turns/index.d.ts +3 -2
- package/dist/turns/index.js +1 -0
- package/dist/turns/tool-events.d.ts +15 -0
- package/dist/turns/tool-events.js +59 -0
- package/dist/turns/turn-state.js +2 -2
- package/dist/turns/turn-summary.d.ts +1 -1
- package/dist/turns/turn-summary.js +4 -4
- package/dist/turns/turn-tracker.js +138 -7
- package/dist/turns/types/turn-state.types.d.ts +28 -1
- package/dist/turns/types/turn-summary.types.d.ts +33 -5
- package/dist/turns/types/turn-tracker.types.d.ts +10 -0
- package/docs/AUDIT_PROMPT.md +11 -0
- package/docs/DATA_HANDLING.md +132 -33
- package/docs/ENTERPRISE_DEPLOYMENT.md +2 -1
- package/docs/PERFORMANCE.md +17 -0
- package/package.json +9 -8
|
@@ -466,11 +466,11 @@ export const configSchema = z
|
|
|
466
466
|
untracedNotices: z.boolean().default(true),
|
|
467
467
|
/** At session start, say when npm has a newer release; checked at most once a day, in the background. */
|
|
468
468
|
updateNotices: z.boolean().default(true),
|
|
469
|
-
capture: captureSchema.
|
|
470
|
-
emit: emitSchema.
|
|
471
|
-
otel: otelSchema.
|
|
472
|
-
delivery: deliverySchema.
|
|
473
|
-
enforcement: enforcementSchema.
|
|
469
|
+
capture: captureSchema.prefault({}),
|
|
470
|
+
emit: emitSchema.prefault({}),
|
|
471
|
+
otel: otelSchema.prefault({}),
|
|
472
|
+
delivery: deliverySchema.prefault({}),
|
|
473
|
+
enforcement: enforcementSchema.prefault({})
|
|
474
474
|
})
|
|
475
475
|
.passthrough()
|
|
476
476
|
.transform((config) => ({
|
|
@@ -162,8 +162,8 @@ export async function forgetDeviceCredentials(ctx) {
|
|
|
162
162
|
const releases = await holdEnrollLocks(ctx, keys.map(credentialId).sort());
|
|
163
163
|
let held = new Map();
|
|
164
164
|
let invalid = false;
|
|
165
|
-
let marked
|
|
166
|
-
let written
|
|
165
|
+
let marked;
|
|
166
|
+
let written;
|
|
167
167
|
try {
|
|
168
168
|
marked = await markUninstalled(ctx.paths, before.state === 'ok' ? configScopes(before.config.roots) : undefined, ctx.env.now()).then(() => true, (error) => {
|
|
169
169
|
debugLog('uninstall: writing the marker failed:', error);
|
|
@@ -6,44 +6,15 @@ export declare const issuedDeviceCredentialSchema: z.ZodObject<{
|
|
|
6
6
|
deviceSecretExpiresAt: z.ZodString;
|
|
7
7
|
accessToken: z.ZodString;
|
|
8
8
|
accessTokenExpiresAt: z.ZodString;
|
|
9
|
-
/**
|
|
10
|
-
* A browser sign-in's approver, the device's developer (AWT-555); older
|
|
11
|
-
* gateways send none. Any shape parses: a bad value must not refuse a device
|
|
12
|
-
* the gateway already issued, so the sign-in checks it instead.
|
|
13
|
-
*/
|
|
14
9
|
developerEmail: z.ZodOptional<z.ZodUnknown>;
|
|
15
|
-
},
|
|
16
|
-
deviceId: string;
|
|
17
|
-
deviceSecret: string;
|
|
18
|
-
deviceSecretExpiresAt: string;
|
|
19
|
-
accessToken: string;
|
|
20
|
-
accessTokenExpiresAt: string;
|
|
21
|
-
developerEmail?: unknown;
|
|
22
|
-
}, {
|
|
23
|
-
deviceId: string;
|
|
24
|
-
deviceSecret: string;
|
|
25
|
-
deviceSecretExpiresAt: string;
|
|
26
|
-
accessToken: string;
|
|
27
|
-
accessTokenExpiresAt: string;
|
|
28
|
-
developerEmail?: unknown;
|
|
29
|
-
}>;
|
|
10
|
+
}, z.core.$strip>;
|
|
30
11
|
/** `POST /v1/devices/token` answer. The device secret is not rotated, so it is not in it. */
|
|
31
12
|
export declare const refreshedAccessTokenSchema: z.ZodObject<{
|
|
32
13
|
deviceId: z.ZodString;
|
|
33
14
|
accessToken: z.ZodString;
|
|
34
15
|
accessTokenExpiresAt: z.ZodString;
|
|
35
16
|
deviceSecretExpiresAt: z.ZodString;
|
|
36
|
-
},
|
|
37
|
-
deviceId: string;
|
|
38
|
-
deviceSecretExpiresAt: string;
|
|
39
|
-
accessToken: string;
|
|
40
|
-
accessTokenExpiresAt: string;
|
|
41
|
-
}, {
|
|
42
|
-
deviceId: string;
|
|
43
|
-
deviceSecretExpiresAt: string;
|
|
44
|
-
accessToken: string;
|
|
45
|
-
accessTokenExpiresAt: string;
|
|
46
|
-
}>;
|
|
17
|
+
}, z.core.$strip>;
|
|
47
18
|
/** `POST /v1/devices/enrollment-sessions` answer: the codes of one browser sign-in. */
|
|
48
19
|
export declare const startedEnrollmentSessionSchema: z.ZodObject<{
|
|
49
20
|
deviceCode: z.ZodString;
|
|
@@ -52,26 +23,8 @@ export declare const startedEnrollmentSessionSchema: z.ZodObject<{
|
|
|
52
23
|
verificationUriComplete: z.ZodString;
|
|
53
24
|
expiresIn: z.ZodNumber;
|
|
54
25
|
interval: z.ZodNumber;
|
|
55
|
-
},
|
|
56
|
-
deviceCode: string;
|
|
57
|
-
userCode: string;
|
|
58
|
-
verificationUri: string;
|
|
59
|
-
verificationUriComplete: string;
|
|
60
|
-
expiresIn: number;
|
|
61
|
-
interval: number;
|
|
62
|
-
}, {
|
|
63
|
-
deviceCode: string;
|
|
64
|
-
userCode: string;
|
|
65
|
-
verificationUri: string;
|
|
66
|
-
verificationUriComplete: string;
|
|
67
|
-
expiresIn: number;
|
|
68
|
-
interval: number;
|
|
69
|
-
}>;
|
|
26
|
+
}, z.core.$strip>;
|
|
70
27
|
/** A poll refused the RFC 6749 §5.2 way: `400 { "error": "…" }`. */
|
|
71
28
|
export declare const pollErrorSchema: z.ZodObject<{
|
|
72
29
|
error: z.ZodString;
|
|
73
|
-
},
|
|
74
|
-
error: string;
|
|
75
|
-
}, {
|
|
76
|
-
error: string;
|
|
77
|
-
}>;
|
|
30
|
+
}, z.core.$strip>;
|
|
@@ -4,48 +4,13 @@ export declare const accessTokenCacheSchema: z.ZodObject<{
|
|
|
4
4
|
accessToken: z.ZodString;
|
|
5
5
|
obtainedAt: z.ZodString;
|
|
6
6
|
expiresAt: z.ZodString;
|
|
7
|
-
},
|
|
8
|
-
accessToken: string;
|
|
9
|
-
obtainedAt: string;
|
|
10
|
-
expiresAt: string;
|
|
11
|
-
}, {
|
|
12
|
-
accessToken: string;
|
|
13
|
-
obtainedAt: string;
|
|
14
|
-
expiresAt: string;
|
|
15
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
16
8
|
/** What one identity remembers about its device credential, beside the token. */
|
|
17
9
|
export declare const deviceStateSchema: z.ZodObject<{
|
|
18
|
-
/**
|
|
19
|
-
* The gateway refused the device secret; nothing but a new enrollment fixes
|
|
20
|
-
* it. An expired secret is enrolled again by any run; a revoked or unknown
|
|
21
|
-
* device only by setup, so a hook never undoes an admin's revocation.
|
|
22
|
-
*/
|
|
23
10
|
refusal: z.ZodOptional<z.ZodObject<{
|
|
24
11
|
reason: z.ZodString;
|
|
25
12
|
since: z.ZodString;
|
|
26
|
-
},
|
|
27
|
-
reason: string;
|
|
28
|
-
since: string;
|
|
29
|
-
}, {
|
|
30
|
-
reason: string;
|
|
31
|
-
since: string;
|
|
32
|
-
}>>;
|
|
33
|
-
/** When the install key was last offered for exchange, so a failure backs off. */
|
|
13
|
+
}, z.core.$strip>>;
|
|
34
14
|
enrollAttemptAt: z.ZodOptional<z.ZodString>;
|
|
35
|
-
/** When a Windows hook last started a background refresh, so it starts one, not one per hook. */
|
|
36
15
|
backgroundRefreshAt: z.ZodOptional<z.ZodString>;
|
|
37
|
-
},
|
|
38
|
-
refusal?: {
|
|
39
|
-
reason: string;
|
|
40
|
-
since: string;
|
|
41
|
-
} | undefined;
|
|
42
|
-
enrollAttemptAt?: string | undefined;
|
|
43
|
-
backgroundRefreshAt?: string | undefined;
|
|
44
|
-
}, {
|
|
45
|
-
refusal?: {
|
|
46
|
-
reason: string;
|
|
47
|
-
since: string;
|
|
48
|
-
} | undefined;
|
|
49
|
-
enrollAttemptAt?: string | undefined;
|
|
50
|
-
backgroundRefreshAt?: string | undefined;
|
|
51
|
-
}>;
|
|
16
|
+
}, z.core.$strip>;
|
|
@@ -20,9 +20,12 @@ export declare const INTERNAL_HOOK_EVENT_TYPES: readonly ["session.started", "se
|
|
|
20
20
|
* `session.billing` states how the session's developer pays, once, when the
|
|
21
21
|
* session opens: a turn that never reaches its Stop hook has no summary to
|
|
22
22
|
* carry that fact, and its calls would be priced as metered spend (AWT-476).
|
|
23
|
+
*
|
|
24
|
+
* `repo.tree` is the default branch's source paths and declaration names, once
|
|
25
|
+
* per repository and identity: what a tenant with no GitHub App gets its feature catalog named from.
|
|
23
26
|
*/
|
|
24
|
-
export declare const PRODUCT_EVENT_TYPES: readonly ["llm.call", "turn.summary", "repo.snapshot", "session.billing"];
|
|
25
|
-
export declare const CANONICAL_EVENT_TYPES: readonly ["session.started", "session.ended", "prompt.submitted", "tool.started", "tool.completed", "tool.failed", "permission.requested", "file.read", "file.edited", "shell.started", "shell.completed", "mcp.started", "mcp.completed", "subagent.started", "subagent.completed", "generation.completed", "compaction.started", "compaction.completed", "agent.error", "agent.other", "llm.call", "turn.summary", "repo.snapshot", "session.billing"];
|
|
27
|
+
export declare const PRODUCT_EVENT_TYPES: readonly ["llm.call", "turn.summary", "repo.snapshot", "session.billing", "repo.tree"];
|
|
28
|
+
export declare const CANONICAL_EVENT_TYPES: readonly ["session.started", "session.ended", "prompt.submitted", "tool.started", "tool.completed", "tool.failed", "permission.requested", "file.read", "file.edited", "shell.started", "shell.completed", "mcp.started", "mcp.completed", "subagent.started", "subagent.completed", "generation.completed", "compaction.started", "compaction.completed", "agent.error", "agent.other", "llm.call", "turn.summary", "repo.snapshot", "session.billing", "repo.tree"];
|
|
26
29
|
/** O(1) membership for the hot path: queue drain checks this per entry. */
|
|
27
30
|
export declare const PRODUCT_EVENT_TYPE_SET: ReadonlySet<string>;
|
|
28
31
|
/** Canonical event types that close a turn. */
|
|
@@ -42,8 +42,11 @@ export const INTERNAL_HOOK_EVENT_TYPES = [
|
|
|
42
42
|
* `session.billing` states how the session's developer pays, once, when the
|
|
43
43
|
* session opens: a turn that never reaches its Stop hook has no summary to
|
|
44
44
|
* carry that fact, and its calls would be priced as metered spend (AWT-476).
|
|
45
|
+
*
|
|
46
|
+
* `repo.tree` is the default branch's source paths and declaration names, once
|
|
47
|
+
* per repository and identity: what a tenant with no GitHub App gets its feature catalog named from.
|
|
45
48
|
*/
|
|
46
|
-
export const PRODUCT_EVENT_TYPES = ['llm.call', 'turn.summary', 'repo.snapshot', 'session.billing'];
|
|
49
|
+
export const PRODUCT_EVENT_TYPES = ['llm.call', 'turn.summary', 'repo.snapshot', 'session.billing', 'repo.tree'];
|
|
47
50
|
export const CANONICAL_EVENT_TYPES = [...INTERNAL_HOOK_EVENT_TYPES, ...PRODUCT_EVENT_TYPES];
|
|
48
51
|
/** O(1) membership for the hot path: queue drain checks this per entry. */
|
|
49
52
|
export const PRODUCT_EVENT_TYPE_SET = new Set(PRODUCT_EVENT_TYPES);
|
package/dist/events/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export type { AgentWatchEvent, CanonicalEventType, ContentEvidence, EventAi, EventGit, EventIdInput, EventPatch, EventSession, EventTool, EventUsage, FeatureCandidate, InternalHookEventType, ProductEventType, UsageBillingMode, UsageSource } from './types/events.types.js';
|
|
6
6
|
export type { BuildLlmCallInput, LlmCallCorrelation, LlmCallEvent, LlmCallStatus, LlmCallUsage } from './types/llm-call.types.js';
|
|
7
7
|
export type { RepoSnapshotBranch, RepoSnapshotCommit, RepoSnapshotCommitFile, RepoSnapshotEvent } from './types/repo-snapshot.types.js';
|
|
8
|
+
export type { RepoTreeEvent, RepoTreeFile } from './types/repo-tree.types.js';
|
|
8
9
|
export type { EnrichOptions, PathRewriter, PathRule } from './types/enrich.types.js';
|
|
9
10
|
export type { ProductEvent } from './product-event.js';
|
|
10
11
|
export { CANONICAL_EVENT_TYPES, EVENT_SCHEMA_VERSION, INTERNAL_HOOK_EVENT_TYPES, PRODUCT_EVENT_TYPES, PRODUCT_EVENT_TYPE_SET, TURN_CLOSING_EVENT_TYPE } from './constants/events.constants.js';
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import type { TurnSummaryEvent } from '../turns/types/turn-summary.types.js';
|
|
2
2
|
import type { LlmCallEvent } from './types/llm-call.types.js';
|
|
3
3
|
import type { RepoSnapshotEvent } from './types/repo-snapshot.types.js';
|
|
4
|
+
import type { RepoTreeEvent } from './types/repo-tree.types.js';
|
|
4
5
|
import type { SessionBillingEvent } from './types/session-billing.types.js';
|
|
5
6
|
export { PRODUCT_EVENT_TYPES } from './constants/events.constants.js';
|
|
6
7
|
export type { ProductEventType } from './types/events.types.js';
|
|
7
8
|
export type { LlmCallEvent, LlmCallCorrelation, LlmCallStatus } from './types/llm-call.types.js';
|
|
8
9
|
export type { RepoSnapshotBranch, RepoSnapshotCommit, RepoSnapshotCommitFile, RepoSnapshotEvent } from './types/repo-snapshot.types.js';
|
|
10
|
+
export type { RepoTreeEvent, RepoTreeFile } from './types/repo-tree.types.js';
|
|
9
11
|
export type { SessionBillingEvent } from './types/session-billing.types.js';
|
|
10
12
|
export type { AgentUsageSummary, TurnSummaryEvent, TurnUsageStatus } from '../turns/types/turn-summary.types.js';
|
|
11
13
|
/**
|
|
12
14
|
* The complete public AgentWatch domain contract.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
16
|
+
* Five record types, deliberately: `llm.call` is the lossless per-request
|
|
15
17
|
* usage ledger, `turn.summary` is the human unit of work, `repo.snapshot`
|
|
16
|
-
* is what the working copy says the work *is* when no tracker can be asked,
|
|
17
|
-
* `session.billing` is how the session's developer pays.
|
|
18
|
+
* is what the working copy says the work *is* when no tracker can be asked,
|
|
19
|
+
* `session.billing` is how the session's developer pays, and `repo.tree` is
|
|
20
|
+
* what the trunk's code is called when nothing can clone it. No
|
|
18
21
|
* lifecycle or tool event is public — those exist only to assemble a summary
|
|
19
22
|
* locally.
|
|
20
23
|
*/
|
|
21
|
-
export type ProductEvent = LlmCallEvent | TurnSummaryEvent | RepoSnapshotEvent | SessionBillingEvent;
|
|
24
|
+
export type ProductEvent = LlmCallEvent | TurnSummaryEvent | RepoSnapshotEvent | SessionBillingEvent | RepoTreeEvent;
|
|
22
25
|
/** The least a value must look like for {@link isProductEvent} to judge it. */
|
|
23
26
|
export interface EventTypeCarrier {
|
|
24
27
|
readonly event?: {
|
|
@@ -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,24 @@
|
|
|
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
|
+
* once per repository per install identity; later turns cost one state read.
|
|
13
|
+
*/
|
|
14
|
+
export interface RepoTreeEvent extends AgentWatchEvent<'repo.tree'> {
|
|
15
|
+
readonly provider: string;
|
|
16
|
+
readonly surface: string;
|
|
17
|
+
readonly repository: string;
|
|
18
|
+
readonly developer_id?: string;
|
|
19
|
+
/** When the listing was read. */
|
|
20
|
+
readonly captured_at: string;
|
|
21
|
+
/** Files or names were dropped to fit the contract's caps; core still names the tree. */
|
|
22
|
+
readonly truncated: boolean;
|
|
23
|
+
readonly files: readonly RepoTreeFile[];
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CodeState, GitRunner } from './types/git.types.js';
|
|
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
|
+
/**
|
|
6
|
+
* HEAD and a digest of the uncommitted diff, taken in the completion hook of
|
|
7
|
+
* a check so a later run of it can be told to cover an earlier one only on
|
|
8
|
+
* the same code (workflow SPEC §11.2). Only for an allowlisted call that ran
|
|
9
|
+
* for a minute: the processes are on the agent's path.
|
|
10
|
+
*
|
|
11
|
+
* Read-only on purpose. `git stash create`, which the plan named, refreshes
|
|
12
|
+
* and writes the index under a lock `--no-optional-locks` does not cover, so
|
|
13
|
+
* it could fail the agent's own `git commit`. `git diff HEAD --binary` writes
|
|
14
|
+
* nothing, and is streamed into the hash, so no diff is cut at a buffer and
|
|
15
|
+
* a failed or timed-out run sends no digest rather than a wrong one. A clean
|
|
16
|
+
* checkout digests the empty diff. Untracked files are not covered.
|
|
17
|
+
*
|
|
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
|
+
* @returns The state, or undefined outside a repository or before its first commit.
|
|
23
|
+
*/
|
|
24
|
+
export declare function codeStateAt(cwd: string, run?: GitRunner, digest?: GitDigester, timeoutMs?: number): Promise<CodeState | undefined>;
|
|
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;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
import { GIT_NO_OPTIONAL_LOCKS, GIT_TIMEOUT_MS, RE_OBJECT_ID, UNCOMMITTED_DIFF_ARGS } from './constants/git.constants.js';
|
|
4
|
+
import { runGit } from './git-context.js';
|
|
5
|
+
/**
|
|
6
|
+
* HEAD and a digest of the uncommitted diff, taken in the completion hook of
|
|
7
|
+
* a check so a later run of it can be told to cover an earlier one only on
|
|
8
|
+
* the same code (workflow SPEC §11.2). Only for an allowlisted call that ran
|
|
9
|
+
* for a minute: the processes are on the agent's path.
|
|
10
|
+
*
|
|
11
|
+
* Read-only on purpose. `git stash create`, which the plan named, refreshes
|
|
12
|
+
* and writes the index under a lock `--no-optional-locks` does not cover, so
|
|
13
|
+
* it could fail the agent's own `git commit`. `git diff HEAD --binary` writes
|
|
14
|
+
* nothing, and is streamed into the hash, so no diff is cut at a buffer and
|
|
15
|
+
* a failed or timed-out run sends no digest rather than a wrong one. A clean
|
|
16
|
+
* checkout digests the empty diff. Untracked files are not covered.
|
|
17
|
+
*
|
|
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
|
+
* @returns The state, or undefined outside a repository or before its first commit.
|
|
23
|
+
*/
|
|
24
|
+
export async function codeStateAt(cwd, run = runGit, digest = digestGitOutput, timeoutMs = GIT_TIMEOUT_MS) {
|
|
25
|
+
const [commit, diffFp] = await Promise.all([run(['rev-parse', 'HEAD'], cwd, timeoutMs), digest(UNCOMMITTED_DIFF_ARGS, cwd, timeoutMs)]);
|
|
26
|
+
if (commit === undefined || !RE_OBJECT_ID.test(commit))
|
|
27
|
+
return undefined;
|
|
28
|
+
return { commit, diffFp };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* sha256 of a git command's stdout, streamed: never buffered, never cut.
|
|
32
|
+
*
|
|
33
|
+
* @param args - Argument vector.
|
|
34
|
+
* @param cwd - Working directory.
|
|
35
|
+
* @param timeoutMs - Kill budget.
|
|
36
|
+
* @returns The hex digest when git exits 0, else undefined. Never rejects.
|
|
37
|
+
*/
|
|
38
|
+
export const digestGitOutput = (args, cwd, timeoutMs) => new Promise((resolve) => {
|
|
39
|
+
const hash = crypto.createHash('sha256');
|
|
40
|
+
const child = spawn('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
41
|
+
child.stdout.on('data', (chunk) => hash.update(chunk));
|
|
42
|
+
child.on('error', () => resolve(undefined));
|
|
43
|
+
child.on('close', (code) => resolve(code === 0 ? hash.digest('hex') : undefined));
|
|
44
|
+
});
|
|
@@ -4,6 +4,12 @@ export declare const GIT_TIMEOUT_MS = 1000;
|
|
|
4
4
|
export declare const MAX_CHANGED_FILES = 50;
|
|
5
5
|
/** Prepended to every git call: status and diff then never write `index.lock`. */
|
|
6
6
|
export declare const GIT_NO_OPTIONAL_LOCKS = "--no-optional-locks";
|
|
7
|
+
/**
|
|
8
|
+
* The uncommitted diff a check's `diff_fp` digests: byte-stable across runs on
|
|
9
|
+
* one machine, so none of the user's diff config (external drivers, textconv,
|
|
10
|
+
* colour, prefixes, rename detection) can change it between two runs.
|
|
11
|
+
*/
|
|
12
|
+
export declare const UNCOMMITTED_DIFF_ARGS: readonly string[];
|
|
7
13
|
/** stdout ceiling per git process. */
|
|
8
14
|
export declare const GIT_MAX_BUFFER_BYTES: number;
|
|
9
15
|
/**
|
|
@@ -4,6 +4,12 @@ export const GIT_TIMEOUT_MS = 1000;
|
|
|
4
4
|
export const MAX_CHANGED_FILES = 50;
|
|
5
5
|
/** Prepended to every git call: status and diff then never write `index.lock`. */
|
|
6
6
|
export const GIT_NO_OPTIONAL_LOCKS = '--no-optional-locks';
|
|
7
|
+
/**
|
|
8
|
+
* The uncommitted diff a check's `diff_fp` digests: byte-stable across runs on
|
|
9
|
+
* one machine, so none of the user's diff config (external drivers, textconv,
|
|
10
|
+
* colour, prefixes, rename detection) can change it between two runs.
|
|
11
|
+
*/
|
|
12
|
+
export const UNCOMMITTED_DIFF_ARGS = ['diff', 'HEAD', '--binary', '--no-ext-diff', '--no-textconv', '--no-color', '--no-renames', '--src-prefix=a/', '--dst-prefix=b/'];
|
|
7
13
|
/** stdout ceiling per git process. */
|
|
8
14
|
export const GIT_MAX_BUFFER_BYTES = 1024 * 1024;
|
|
9
15
|
/**
|
|
@@ -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
|
+
}
|
|
@@ -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,14 @@ 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
|
+
export const runGit = (args, cwd, timeoutMs, home, maxBufferBytes = GIT_MAX_BUFFER_BYTES) => new Promise((resolve) => {
|
|
253
254
|
const env = home ? { ...process.env, HOME: home, XDG_CONFIG_HOME: path.join(home, '.config') } : undefined;
|
|
254
255
|
// `--no-optional-locks`, on every call the edge makes: a hook must never
|
|
255
256
|
// 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:
|
|
257
|
+
execFile('git', [GIT_NO_OPTIONAL_LOCKS, ...args], { cwd, timeout: timeoutMs, maxBuffer: maxBufferBytes, windowsHide: true, env }, (error, stdout) => {
|
|
257
258
|
// Trailing-only trim: `status --porcelain` lines carry a significant
|
|
258
259
|
// leading space (" M file"); a full trim() would eat the first character
|
|
259
260
|
// of the first filename.
|
package/dist/git/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Where the work happened: repository, branch, commit and dirty files, with
|
|
3
3
|
* remote credentials stripped before anything is stored or sent.
|
|
4
4
|
*/
|
|
5
|
-
export type { GitContext, GitContextOptions, GitRunner, GitUserEmailOptions, RemoteParts } from './types/git.types.js';
|
|
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
7
|
export type { RepositoryRootFinder } from './types/repository-root.types.js';
|
|
8
|
+
export { codeStateAt } from './code-state.js';
|
|
8
9
|
export { collectGitContext, developerIdentity, gitUserEmail, runGit } from './git-context.js';
|
|
9
10
|
export { collectBranchCommits, collectBranchRefs, parseCommitFiles, resolveDefaultBranch } from './repo-snapshot.js';
|
|
10
11
|
export { normalizeRemote, remoteHash, stripRemoteCredentials } from './remote-sanitize.js';
|
package/dist/git/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { codeStateAt } from './code-state.js';
|
|
1
2
|
export { collectGitContext, developerIdentity, gitUserEmail, runGit } from './git-context.js';
|
|
2
3
|
export { collectBranchCommits, collectBranchRefs, parseCommitFiles, resolveDefaultBranch } from './repo-snapshot.js';
|
|
3
4
|
export { normalizeRemote, remoteHash, stripRemoteCredentials } from './remote-sanitize.js';
|