@ascenda-one/history-import 0.1.37 → 0.1.39

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.
@@ -1,9 +1,264 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars, require-yield */
2
- export async function* extractGit(snapshotDir, extractionId) {
3
- // Open work. Unlike the other stores git needs no staging copy — history
4
- // is immutable; `git log --format` against the live repo is the extraction.
5
- // The snapshotDir parameter is accepted for interface uniformity and
6
- // ignored.
7
- throw new Error("extractGit is not implemented yet — scaffolded, no extraction path built");
1
+ /**
2
+ * Git extractor: commit cadence and size for the repositories a person's
3
+ * agent sessions ran in.
4
+ *
5
+ * Off by default (`import --git`). The backend's consent store list has to
6
+ * name `git` before these rows are accepted, so nothing here runs unless the
7
+ * person asks for it.
8
+ *
9
+ * Which repositories: only the ones the other stores already named, handed
10
+ * in as `repoRefs` (the cwd or project path on each extracted event). Nothing
11
+ * walks a disk looking for `.git`. A ref that is a subdirectory, a linked
12
+ * worktree or a path that no longer exists resolves to its repository root or
13
+ * is skipped and counted.
14
+ *
15
+ * Which commits: the ones whose author email equals `git config user.email`
16
+ * in that repository. Other people's commits are never emitted. A repository
17
+ * with no configured email emits nothing and is counted.
18
+ *
19
+ * What an event carries: the commit time, the repository key and branch hash
20
+ * the live hooks use (`deriveWorkContext`, `forgeRepoKey`,
21
+ * `deriveBranchHash`), a files-changed count, lines-added and lines-removed
22
+ * buckets, and whether it was a merge commit. No message, no path, no diff,
23
+ * no name or email, and no commit id: the session id on each event is a hash
24
+ * of the id, so a re-import keys the same commit the same way.
25
+ *
26
+ * The event type is `editor_activity`, which already exists, with
27
+ * `activity: "git_commit"` and `gitAction: "commit"`. The backend reads
28
+ * `gitAction` off any event, so no new type is needed.
29
+ *
30
+ * Branch: git doesn't record which branch a commit was made on. Each commit
31
+ * gets a branch it is reachable from, searched feature branches first and the
32
+ * default branch last. A commit on a branch deleted since is reachable from
33
+ * the default branch only, and carries no branch key.
34
+ */
35
+ import { execFile } from "node:child_process";
36
+ import { createHash } from "node:crypto";
37
+ import * as fs from "node:fs/promises";
38
+ import { promisify } from "node:util";
39
+ import { bucketLinesChanged, deriveBranchHash, deriveWorkContext, forgeBranchKey, forgeRepoKey, readForgeFullName, repoKeysEnabled } from "@ascenda-one/tool-kit";
40
+ import { HISTORICAL_PROVENANCE } from "../types.js";
41
+ const execFileAsync = promisify(execFile);
42
+ export const DEFAULT_GIT_SINCE_DAYS = 365;
43
+ async function git(repo, args) {
44
+ const { stdout } = await execFileAsync("git", ["-C", repo, ...args], {
45
+ maxBuffer: 256 * 1024 * 1024,
46
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", LC_ALL: "C" }
47
+ });
48
+ return stdout;
49
+ }
50
+ /** The repository root a ref points inside, or null. */
51
+ async function repoRootOf(ref) {
52
+ try {
53
+ await fs.access(ref);
54
+ const root = (await git(ref, ["rev-parse", "--show-toplevel"])).trim();
55
+ return root || null;
56
+ }
57
+ catch {
58
+ return null;
59
+ }
60
+ }
61
+ /** Local branch names, the default branch last. */
62
+ async function branchOrder(repo) {
63
+ let names = [];
64
+ try {
65
+ names = (await git(repo, ["for-each-ref", "--format=%(refname:short)", "refs/heads"]))
66
+ .split("\n")
67
+ .map((n) => n.trim())
68
+ .filter(Boolean);
69
+ }
70
+ catch {
71
+ return { branches: [], defaultBranch: null };
72
+ }
73
+ let defaultBranch = null;
74
+ try {
75
+ const head = (await git(repo, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"])).trim();
76
+ if (head.startsWith("origin/"))
77
+ defaultBranch = head.slice("origin/".length);
78
+ }
79
+ catch {
80
+ /* no origin/HEAD */
81
+ }
82
+ if (!defaultBranch)
83
+ defaultBranch = names.find((n) => n === "main" || n === "master") ?? null;
84
+ const rest = names.filter((n) => n !== defaultBranch);
85
+ const branches = defaultBranch && names.includes(defaultBranch) ? [...rest, defaultBranch] : rest;
86
+ return { branches, defaultBranch };
87
+ }
88
+ const COMMIT_MARK = "\x1e";
89
+ /**
90
+ * One `git log` over the branches, in the order that decides which branch a
91
+ * commit is attributed to. `--numstat` prints nothing for a merge commit, so
92
+ * a merge has zero files and lines here, by design.
93
+ */
94
+ export function parseGitLog(output) {
95
+ const commits = [];
96
+ for (const block of output.split(COMMIT_MARK)) {
97
+ if (!block.trim())
98
+ continue;
99
+ const [header, ...stat] = block.split("\n");
100
+ const [sha, parentField, epoch, email, source] = header.split("\x1f");
101
+ if (!sha || !epoch)
102
+ continue;
103
+ const seconds = Number(epoch);
104
+ if (!Number.isFinite(seconds))
105
+ continue;
106
+ let files = 0;
107
+ let added = 0;
108
+ let removed = 0;
109
+ for (const line of stat) {
110
+ const m = /^(\d+|-)\t(\d+|-)\t/.exec(line);
111
+ if (!m)
112
+ continue;
113
+ files += 1;
114
+ if (m[1] !== "-")
115
+ added += Number(m[1]);
116
+ if (m[2] !== "-")
117
+ removed += Number(m[2]);
118
+ }
119
+ commits.push({
120
+ sha,
121
+ parents: parentField.trim() === "" ? 0 : parentField.trim().split(" ").length,
122
+ at: new Date(seconds * 1000).toISOString(),
123
+ email: (email ?? "").trim().toLowerCase(),
124
+ branch: source ? source.trim() : null,
125
+ files,
126
+ added,
127
+ removed
128
+ });
129
+ }
130
+ return commits;
131
+ }
132
+ export async function* extractGit(repoRefs, extractionId, options = {}) {
133
+ const now = options.now ?? new Date();
134
+ const sinceDays = options.sinceDays ?? DEFAULT_GIT_SINCE_DAYS;
135
+ const since = new Date(now.getTime() - sinceDays * 86_400_000).toISOString();
136
+ // Resolve every ref to a repository root first, so two refs in one
137
+ // repository (or a worktree and its parent's subdirectory) read it once.
138
+ const roots = new Map();
139
+ let skipped = 0;
140
+ for (const ref of new Set(repoRefs)) {
141
+ const root = await repoRootOf(ref);
142
+ if (!root) {
143
+ skipped += 1;
144
+ continue;
145
+ }
146
+ // A linked worktree shares its parent's history. Read the canonical
147
+ // repository once, through whichever checkout named it first.
148
+ const canonical = deriveWorkContext(root)?.projectPath ?? root;
149
+ if (!roots.has(canonical))
150
+ roots.set(canonical, root);
151
+ }
152
+ let read = 0;
153
+ let withoutIdentity = 0;
154
+ let windowOldest = null;
155
+ let windowNewest = null;
156
+ for (const [canonical, checkout] of roots) {
157
+ let me = "";
158
+ try {
159
+ me = (await git(checkout, ["config", "user.email"])).trim().toLowerCase();
160
+ }
161
+ catch {
162
+ me = "";
163
+ }
164
+ if (!me) {
165
+ withoutIdentity += 1;
166
+ continue;
167
+ }
168
+ const { branches, defaultBranch } = await branchOrder(checkout);
169
+ if (branches.length === 0) {
170
+ skipped += 1;
171
+ continue;
172
+ }
173
+ let output;
174
+ try {
175
+ output = await git(checkout, [
176
+ "log",
177
+ "--source",
178
+ "--numstat",
179
+ "--no-renames",
180
+ `--since=${since}`,
181
+ `--format=${COMMIT_MARK}%H\x1f%P\x1f%ct\x1f%ae\x1f%S`,
182
+ ...branches,
183
+ "--"
184
+ ]);
185
+ }
186
+ catch {
187
+ skipped += 1;
188
+ continue;
189
+ }
190
+ read += 1;
191
+ const fullName = repoKeysEnabled() ? readForgeFullName(canonical) : null;
192
+ const context = deriveWorkContext(canonical);
193
+ const seen = new Set();
194
+ for (const commit of parseGitLog(output)) {
195
+ // `--source` over several branches lists a commit once, but a repository
196
+ // with a replace ref or a graft can repeat one.
197
+ if (seen.has(commit.sha))
198
+ continue;
199
+ seen.add(commit.sha);
200
+ if (commit.email !== me)
201
+ continue;
202
+ const isMerge = commit.parents > 1;
203
+ const metrics = {
204
+ activity: "git_commit",
205
+ gitAction: "commit",
206
+ isMergeCommit: isMerge,
207
+ authoredByMe: true,
208
+ filesChangedCount: commit.files,
209
+ linesAddedBucket: bucketLinesChanged(commit.added),
210
+ linesRemovedBucket: bucketLinesChanged(commit.removed),
211
+ linesChangedBucket: bucketLinesChanged(commit.added + commit.removed)
212
+ };
213
+ const onDefault = commit.branch !== null && commit.branch === defaultBranch;
214
+ if (commit.branch && !onDefault) {
215
+ // `gitBranch` is hashed by the shipper through deriveBranchHash, the
216
+ // function the live hooks call.
217
+ if (deriveBranchHash(commit.branch))
218
+ metrics.gitBranch = commit.branch;
219
+ }
220
+ if (fullName) {
221
+ metrics.repoKey = forgeRepoKey(fullName);
222
+ if (commit.branch && !onDefault)
223
+ metrics.branchKey = forgeBranchKey(fullName, commit.branch);
224
+ }
225
+ if (!windowOldest || commit.at < windowOldest)
226
+ windowOldest = commit.at;
227
+ if (!windowNewest || commit.at > windowNewest)
228
+ windowNewest = commit.at;
229
+ yield {
230
+ occurredAt: commit.at,
231
+ store: "git",
232
+ sourceVersion: null,
233
+ // A digest of the commit id: unique per commit and stable across
234
+ // runs, which is what keeps two commits in one second apart without
235
+ // putting the id itself on the wire.
236
+ sessionRef: "git:" + createHash("sha256").update(commit.sha).digest("hex").slice(0, 16),
237
+ repoRef: context?.projectPath ?? canonical,
238
+ eventKind: "editor_activity",
239
+ metrics,
240
+ provenance: HISTORICAL_PROVENANCE.direct,
241
+ extractionId
242
+ };
243
+ }
244
+ }
245
+ if (read > 0 || skipped > 0 || withoutIdentity > 0) {
246
+ yield {
247
+ occurredAt: windowNewest ?? now.toISOString(),
248
+ store: "git",
249
+ sourceVersion: null,
250
+ sessionRef: null,
251
+ repoRef: null,
252
+ eventKind: "extraction_epoch",
253
+ metrics: {
254
+ ...(windowOldest && windowNewest ? { windowOldest, windowNewest } : {}),
255
+ gitReposRead: read,
256
+ gitReposSkipped: skipped,
257
+ gitReposWithoutIdentity: withoutIdentity
258
+ },
259
+ provenance: HISTORICAL_PROVENANCE.derived,
260
+ extractionId
261
+ };
262
+ }
8
263
  }
9
264
  //# sourceMappingURL=git.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/extractors/git.ts"],"names":[],"mappings":"AAYA,qEAAqE;AACrE,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,UAAU,CAC/B,WAAmB,EACnB,YAAoB;IAEpB,yEAAyE;IACzE,4EAA4E;IAC5E,qEAAqE;IACrE,WAAW;IACX,MAAM,IA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