@invictus-group-ai/hooks 0.5.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/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/bin.d.ts +11 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +37 -0
- package/dist/bin.js.map +1 -0
- package/dist/engine.d.ts +53 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +182 -0
- package/dist/engine.js.map +1 -0
- package/dist/git/post-commit.d.ts +43 -0
- package/dist/git/post-commit.d.ts.map +1 -0
- package/dist/git/post-commit.js +166 -0
- package/dist/git/post-commit.js.map +1 -0
- package/dist/git/pre-push.d.ts +43 -0
- package/dist/git/pre-push.d.ts.map +1 -0
- package/dist/git/pre-push.js +102 -0
- package/dist/git/pre-push.js.map +1 -0
- package/dist/git/prepare-commit-msg.d.ts +97 -0
- package/dist/git/prepare-commit-msg.d.ts.map +1 -0
- package/dist/git/prepare-commit-msg.js +623 -0
- package/dist/git/prepare-commit-msg.js.map +1 -0
- package/dist/git-activate.d.ts +25 -0
- package/dist/git-activate.d.ts.map +1 -0
- package/dist/git-activate.js +75 -0
- package/dist/git-activate.js.map +1 -0
- package/dist/hooks/db-guard.d.ts +31 -0
- package/dist/hooks/db-guard.d.ts.map +1 -0
- package/dist/hooks/db-guard.js +290 -0
- package/dist/hooks/db-guard.js.map +1 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/journal-nudge.d.ts +14 -0
- package/dist/hooks/journal-nudge.d.ts.map +1 -0
- package/dist/hooks/journal-nudge.js +60 -0
- package/dist/hooks/journal-nudge.js.map +1 -0
- package/dist/hooks/loc-recorder.d.ts +79 -0
- package/dist/hooks/loc-recorder.d.ts.map +1 -0
- package/dist/hooks/loc-recorder.js +183 -0
- package/dist/hooks/loc-recorder.js.map +1 -0
- package/dist/hooks/metrics-capture.d.ts +34 -0
- package/dist/hooks/metrics-capture.d.ts.map +1 -0
- package/dist/hooks/metrics-capture.js +275 -0
- package/dist/hooks/metrics-capture.js.map +1 -0
- package/dist/hooks/secret-guard.d.ts +19 -0
- package/dist/hooks/secret-guard.d.ts.map +1 -0
- package/dist/hooks/secret-guard.js +163 -0
- package/dist/hooks/secret-guard.js.map +1 -0
- package/dist/hooks/session-boot.d.ts +17 -0
- package/dist/hooks/session-boot.d.ts.map +1 -0
- package/dist/hooks/session-boot.js +123 -0
- package/dist/hooks/session-boot.js.map +1 -0
- package/dist/hooks/stop-gate.d.ts +17 -0
- package/dist/hooks/stop-gate.d.ts.map +1 -0
- package/dist/hooks/stop-gate.js +97 -0
- package/dist/hooks/stop-gate.js.map +1 -0
- package/dist/hooks/typecheck-on-edit.d.ts +18 -0
- package/dist/hooks/typecheck-on-edit.d.ts.map +1 -0
- package/dist/hooks/typecheck-on-edit.js +110 -0
- package/dist/hooks/typecheck-on-edit.js.map +1 -0
- package/dist/i18n/en.d.ts +45 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +53 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +35 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +56 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +12 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +50 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/kit-cli.d.ts +36 -0
- package/dist/kit-cli.d.ts.map +1 -0
- package/dist/kit-cli.js +68 -0
- package/dist/kit-cli.js.map +1 -0
- package/dist/metrics-schema.d.ts +215 -0
- package/dist/metrics-schema.d.ts.map +1 -0
- package/dist/metrics-schema.js +83 -0
- package/dist/metrics-schema.js.map +1 -0
- package/dist/shared.d.ts +81 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +276 -0
- package/dist/shared.js.map +1 -0
- package/githooks/prepare-commit-msg +30 -0
- package/githooks/prepare-commit-msg.cmd +16 -0
- package/package.json +71 -0
- package/settings-template.json +97 -0
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commit-metrics-encoder — the git-side hook (`prepare-commit-msg`).
|
|
3
|
+
* Works on every CLI, not only Claude Code.
|
|
4
|
+
*
|
|
5
|
+
* Reads the metrics accumulated in the event log since the last trailer
|
|
6
|
+
* (session.end entries), appends ONE `task.commit` summary entry, builds a
|
|
7
|
+
* TrailerPayload from it (the trailer is DERIVED from the log entry —
|
|
8
|
+
* ARCHITECTURE §5), encodes via the core codec, and appends
|
|
9
|
+
*
|
|
10
|
+
* Assisted-by: <model> via Invictus Kit
|
|
11
|
+
* Invictus: v1.<base64url(deflate(cbor))>.<hmac16>
|
|
12
|
+
*
|
|
13
|
+
* to the commit message — unless the trailers are already present or this
|
|
14
|
+
* is a merge/squash/fixup/amend commit.
|
|
15
|
+
*
|
|
16
|
+
* HMAC key: `.invictus/local/dev.key` (git-ignored, per-dev, derived from
|
|
17
|
+
* the client master key at provisioning). ABSENT KEY → SKIP SILENTLY: an
|
|
18
|
+
* absent trailer is a signal (the "untracked commit" metric), never an
|
|
19
|
+
* error, and this hook must never break `git commit`.
|
|
20
|
+
*/
|
|
21
|
+
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { HASH_PREFIX_RE, canonicalJson, decodeTrailer, defaultLogDir, extractTrailers, formatTrailerLine, readLog, sha256Prefix, } from '@invictus-group-ai/core';
|
|
25
|
+
import { appendEvent } from '@invictus-group-ai/core';
|
|
26
|
+
import { agentLocPath } from '../hooks/loc-recorder.js';
|
|
27
|
+
import { sessionEndDataSchema } from '../metrics-schema.js';
|
|
28
|
+
import { ensureDir, gitOutput, isEntryModule, resolveDevId, shortHash8 } from '../shared.js';
|
|
29
|
+
const CLIENT_ID_RE = /^[a-z0-9_-]{1,32}$/;
|
|
30
|
+
const SKIP_SOURCES = new Set(['merge', 'squash', 'commit']); // 'commit' = amend/-c/-C
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Local state
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function readHmacKey(projectDir) {
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = readFileSync(join(projectDir, '.invictus', 'local', 'dev.key'), 'utf8').trim();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (raw === '')
|
|
43
|
+
return null;
|
|
44
|
+
if (/^[0-9a-fA-F]+$/.test(raw) && raw.length % 2 === 0 && raw.length >= 32) {
|
|
45
|
+
return Buffer.from(raw, 'hex');
|
|
46
|
+
}
|
|
47
|
+
return Buffer.from(raw, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
function resolveClientId(projectDir, env) {
|
|
50
|
+
const fromEnv = env.INVICTUS_CLIENT_ID;
|
|
51
|
+
if (typeof fromEnv === 'string' && CLIENT_ID_RE.test(fromEnv))
|
|
52
|
+
return fromEnv;
|
|
53
|
+
try {
|
|
54
|
+
const raw = readFileSync(join(projectDir, '.invictus', 'local', 'client.json'), 'utf8');
|
|
55
|
+
const parsed = JSON.parse(raw);
|
|
56
|
+
if (typeof parsed.clientId === 'string' && CLIENT_ID_RE.test(parsed.clientId)) {
|
|
57
|
+
return parsed.clientId;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
/* fall through */
|
|
62
|
+
}
|
|
63
|
+
return 'c_unknown';
|
|
64
|
+
}
|
|
65
|
+
function lastTrailerStatePath(projectDir) {
|
|
66
|
+
return join(projectDir, '.invictus', 'metrics', 'last-trailer.json');
|
|
67
|
+
}
|
|
68
|
+
function readLastTrailer(projectDir) {
|
|
69
|
+
const hashOrNull = (v) => typeof v === 'string' && HASH_PREFIX_RE.test(v) ? v : null;
|
|
70
|
+
try {
|
|
71
|
+
const raw = readFileSync(lastTrailerStatePath(projectDir), 'utf8');
|
|
72
|
+
const parsed = JSON.parse(raw);
|
|
73
|
+
const hash = hashOrNull(parsed.hash);
|
|
74
|
+
if (hash !== null)
|
|
75
|
+
return { hash, j: hashOrNull(parsed.j), prev: hashOrNull(parsed.prev) };
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* first trailer */
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function writeLastTrailer(projectDir, state) {
|
|
83
|
+
const path = lastTrailerStatePath(projectDir);
|
|
84
|
+
if (!ensureDir(dirname(path)))
|
|
85
|
+
return;
|
|
86
|
+
try {
|
|
87
|
+
writeFileSync(path, JSON.stringify({ ...state, ts: Math.floor(Date.now() / 1000) }) + '\n', 'utf8');
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* non-fatal: next trailer will carry prev=null and the chain restarts */
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function kitVersion() {
|
|
94
|
+
try {
|
|
95
|
+
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');
|
|
96
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
97
|
+
if (typeof pkg.version === 'string')
|
|
98
|
+
return pkg.version;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
/* fall through */
|
|
102
|
+
}
|
|
103
|
+
return '0.0.0';
|
|
104
|
+
}
|
|
105
|
+
function snapshotOf(d) {
|
|
106
|
+
return {
|
|
107
|
+
t: { i: d.t.i, o: d.t.o, cr: d.t.cr, cw: d.t.cw },
|
|
108
|
+
usdCents: d.usdCents,
|
|
109
|
+
prompts: d.prompts,
|
|
110
|
+
toolCalls: d.toolCalls,
|
|
111
|
+
accepts: d.acc ?? 0,
|
|
112
|
+
rejects: d.rej ?? 0,
|
|
113
|
+
// Entries written by hooks ≤0.2.0 have no actSec: fall back to durSec
|
|
114
|
+
// per session (the documented old act = dur behavior).
|
|
115
|
+
actSec: d.actSec ?? d.durSec,
|
|
116
|
+
durSec: d.durSec,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const ZERO_SNAPSHOT = {
|
|
120
|
+
t: { i: 0, o: 0, cr: 0, cw: 0 },
|
|
121
|
+
usdCents: 0,
|
|
122
|
+
prompts: 0,
|
|
123
|
+
toolCalls: 0,
|
|
124
|
+
accepts: 0,
|
|
125
|
+
rejects: 0,
|
|
126
|
+
actSec: 0,
|
|
127
|
+
durSec: 0,
|
|
128
|
+
};
|
|
129
|
+
/** Non-negative difference: a session's counters never legitimately shrink. */
|
|
130
|
+
function delta(now, before) {
|
|
131
|
+
const sub = (a, b) => Math.max(0, a - b);
|
|
132
|
+
const z = before ?? ZERO_SNAPSHOT;
|
|
133
|
+
return {
|
|
134
|
+
t: { i: sub(now.t.i, z.t.i), o: sub(now.t.o, z.t.o), cr: sub(now.t.cr, z.t.cr), cw: sub(now.t.cw, z.t.cw) },
|
|
135
|
+
usdCents: sub(now.usdCents, z.usdCents),
|
|
136
|
+
prompts: sub(now.prompts, z.prompts),
|
|
137
|
+
toolCalls: sub(now.toolCalls, z.toolCalls),
|
|
138
|
+
accepts: sub(now.accepts, z.accepts),
|
|
139
|
+
rejects: sub(now.rejects, z.rejects),
|
|
140
|
+
actSec: sub(now.actSec, z.actSec),
|
|
141
|
+
durSec: sub(now.durSec, z.durSec),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Commits that never landed (amend, reset, aborted commit)
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
/**
|
|
148
|
+
* A `task.commit` is written while the commit message is being prepared —
|
|
149
|
+
* before the commit exists. When that commit is then amended with a new
|
|
150
|
+
* message, reset away, or rejected by a later hook, the entry had already
|
|
151
|
+
* claimed the window and the commit that replaced it shipped with no trailer
|
|
152
|
+
* (seen in a client repo: the commit that carried the trailer was amended
|
|
153
|
+
* away, and the one that survived had none).
|
|
154
|
+
*
|
|
155
|
+
* The fix: an entry only counts as credited if some ref still carries a
|
|
156
|
+
* trailer derived from it. Otherwise its window is handed to the next commit.
|
|
157
|
+
*/
|
|
158
|
+
/** A `task.commit` older than this is never re-credited, carried or not. */
|
|
159
|
+
export const ORPHAN_MAX_AGE_SEC = 24 * 3600;
|
|
160
|
+
/** Committer dates can trail the log entry a little (clock skew, slow hooks). */
|
|
161
|
+
const ANCHOR_SLACK_SEC = 3600;
|
|
162
|
+
/**
|
|
163
|
+
* True when a commit reachable from any ref (branches, tags, remotes — not the
|
|
164
|
+
* reflog) carries a trailer whose `j` is this entry. When git cannot answer,
|
|
165
|
+
* the answer is yes: re-crediting work that did land would double-count it,
|
|
166
|
+
* which is worse than leaving one commit without a trailer.
|
|
167
|
+
*/
|
|
168
|
+
export function carriedByAnyRef(projectDir, entry) {
|
|
169
|
+
const since = Math.max(0, entry.ts - ANCHOR_SLACK_SEC);
|
|
170
|
+
const log = gitOutput(['log', '--all', `--since=@${since}`, '-n', '2000', '--format=%B%x1e'], projectDir, 8000);
|
|
171
|
+
if (log === null)
|
|
172
|
+
return true;
|
|
173
|
+
for (const message of log.split('\x1e')) {
|
|
174
|
+
for (const trailer of extractTrailers(message)) {
|
|
175
|
+
try {
|
|
176
|
+
if (decodeTrailer(trailer).j === entry.h)
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
/* malformed trailer — not ours to judge here */
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Which `task.commit` entries never landed. Only the newest entry is checked:
|
|
188
|
+
* any older one was already judged when the entry after it was written, and
|
|
189
|
+
* if it was taken over, that entry names it in `re` — so the chain is followed
|
|
190
|
+
* instead of asking git again.
|
|
191
|
+
*/
|
|
192
|
+
export function supersededCommits(entries, isCarried, nowSec) {
|
|
193
|
+
const commits = entries.filter((e) => e.type === 'task.commit');
|
|
194
|
+
const last = commits[commits.length - 1];
|
|
195
|
+
if (!last || nowSec - last.ts > ORPHAN_MAX_AGE_SEC || isCarried(last)) {
|
|
196
|
+
return { hashes: new Set(), head: null };
|
|
197
|
+
}
|
|
198
|
+
const byHash = new Map(commits.map((c) => [c.h, c]));
|
|
199
|
+
const hashes = new Set([last.h]);
|
|
200
|
+
let re = last.data['re'];
|
|
201
|
+
while (typeof re === 'string' && !hashes.has(re)) {
|
|
202
|
+
hashes.add(re);
|
|
203
|
+
re = byHash.get(re)?.data['re'];
|
|
204
|
+
}
|
|
205
|
+
return { hashes, head: last };
|
|
206
|
+
}
|
|
207
|
+
/** Last session.end snapshot per sid within a slice of the log. */
|
|
208
|
+
function snapshotsBySid(slice) {
|
|
209
|
+
const bySid = new Map();
|
|
210
|
+
for (const entry of slice) {
|
|
211
|
+
if (entry.type !== 'session.end')
|
|
212
|
+
continue;
|
|
213
|
+
const parsed = sessionEndDataSchema.safeParse(entry.data);
|
|
214
|
+
if (!parsed.success)
|
|
215
|
+
continue;
|
|
216
|
+
bySid.set(entry.sid, { snap: snapshotOf(parsed.data), data: parsed.data });
|
|
217
|
+
}
|
|
218
|
+
return bySid;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* What this commit is credited with = (latest snapshot per session in this
|
|
222
|
+
* window) − (the snapshot already credited to an earlier commit).
|
|
223
|
+
*
|
|
224
|
+
* Counting only `SessionEnd` — the previous rule — silently produced EMPTY
|
|
225
|
+
* trailers for any session that never ended gracefully: a real install was
|
|
226
|
+
* found with 456 SubagentStop entries, zero SessionEnd, and therefore not a
|
|
227
|
+
* single metric on any commit. SubagentStop snapshots are cumulative over the
|
|
228
|
+
* same parent transcript, so they carry the very number that was missing.
|
|
229
|
+
*
|
|
230
|
+
* Working in deltas is what makes using them safe. A session spanning three
|
|
231
|
+
* commits would otherwise have its running total re-counted by each one.
|
|
232
|
+
*/
|
|
233
|
+
function accumulate(entries, superseded = new Set()) {
|
|
234
|
+
let lastCommitIdx = -1;
|
|
235
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
236
|
+
const entry = entries[i];
|
|
237
|
+
if (entry.type === 'task.commit' && !superseded.has(entry.h)) {
|
|
238
|
+
lastCommitIdx = i;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const alreadyCredited = snapshotsBySid(entries.slice(0, lastCommitIdx + 1));
|
|
243
|
+
const inWindow = snapshotsBySid(entries.slice(lastCommitIdx + 1));
|
|
244
|
+
if (inWindow.size === 0)
|
|
245
|
+
return null;
|
|
246
|
+
const acc = {
|
|
247
|
+
sessions: [],
|
|
248
|
+
t: { i: 0, o: 0, cr: 0, cw: 0 },
|
|
249
|
+
usdCents: 0,
|
|
250
|
+
prompts: 0,
|
|
251
|
+
toolCalls: 0,
|
|
252
|
+
accepts: 0,
|
|
253
|
+
rejects: 0,
|
|
254
|
+
actSec: 0,
|
|
255
|
+
durSec: 0,
|
|
256
|
+
m: {},
|
|
257
|
+
model: null,
|
|
258
|
+
tool: null,
|
|
259
|
+
};
|
|
260
|
+
const tagWeights = new Map();
|
|
261
|
+
for (const [sid, { snap, data }] of inWindow) {
|
|
262
|
+
const d = delta(snap, alreadyCredited.get(sid)?.snap);
|
|
263
|
+
acc.sessions.push({ sid, data });
|
|
264
|
+
acc.t.i += d.t.i;
|
|
265
|
+
acc.t.o += d.t.o;
|
|
266
|
+
acc.t.cr += d.t.cr;
|
|
267
|
+
acc.t.cw += d.t.cw;
|
|
268
|
+
acc.usdCents += d.usdCents;
|
|
269
|
+
acc.prompts += d.prompts;
|
|
270
|
+
acc.toolCalls += d.toolCalls;
|
|
271
|
+
acc.accepts += d.accepts;
|
|
272
|
+
acc.rejects += d.rejects;
|
|
273
|
+
acc.actSec += d.actSec;
|
|
274
|
+
acc.durSec += d.durSec;
|
|
275
|
+
if (data.model)
|
|
276
|
+
acc.model = data.model;
|
|
277
|
+
if (data.tool)
|
|
278
|
+
acc.tool = data.tool;
|
|
279
|
+
// Weight each session's model mix by the work it actually contributed
|
|
280
|
+
// here, so a session that barely moved cannot skew the commit's mix.
|
|
281
|
+
const weight = d.t.i + d.t.o + 1;
|
|
282
|
+
for (const [tag, pct] of Object.entries(data.m)) {
|
|
283
|
+
tagWeights.set(tag, (tagWeights.get(tag) ?? 0) + pct * weight);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (acc.sessions.length === 0)
|
|
287
|
+
return null;
|
|
288
|
+
const total = [...tagWeights.values()].reduce((a, b) => a + b, 0);
|
|
289
|
+
if (total > 0) {
|
|
290
|
+
for (const [tag, weight] of tagWeights) {
|
|
291
|
+
acc.m[tag] = Math.min(100, Math.max(0, Math.round((weight / total) * 100)));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return acc;
|
|
295
|
+
}
|
|
296
|
+
// ---------------------------------------------------------------------------
|
|
297
|
+
// LoC attribution (loc.aa/ad vs loc.ha/hd)
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
/** Agent-touched entries older than this are ignored and pruned (stale edits). */
|
|
300
|
+
const AGENT_LOC_MAX_AGE_SEC = 14 * 24 * 3600;
|
|
301
|
+
/**
|
|
302
|
+
* Read the loc-recorder scratch (`.invictus/metrics/agent-loc.jsonl`).
|
|
303
|
+
* Entries consumed by a commit that landed are left out (and dropped on the
|
|
304
|
+
* next rewrite); entries consumed by a superseded commit are handed back.
|
|
305
|
+
*/
|
|
306
|
+
function readAgentLoc(projectDir, superseded = new Set()) {
|
|
307
|
+
let raw;
|
|
308
|
+
try {
|
|
309
|
+
raw = readFileSync(agentLocPath(projectDir), 'utf8');
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
const now = Math.floor(Date.now() / 1000);
|
|
315
|
+
const entries = [];
|
|
316
|
+
for (const line of raw.split('\n')) {
|
|
317
|
+
if (line.trim() === '')
|
|
318
|
+
continue;
|
|
319
|
+
try {
|
|
320
|
+
const parsed = JSON.parse(line);
|
|
321
|
+
if (typeof parsed.f !== 'string' || parsed.f === '')
|
|
322
|
+
continue;
|
|
323
|
+
const ts = typeof parsed.ts === 'number' && Number.isFinite(parsed.ts) ? parsed.ts : 0;
|
|
324
|
+
if (now - ts > AGENT_LOC_MAX_AGE_SEC)
|
|
325
|
+
continue; // stale — prune on rewrite
|
|
326
|
+
const entry = {
|
|
327
|
+
ts,
|
|
328
|
+
f: parsed.f,
|
|
329
|
+
la: typeof parsed.la === 'number' ? parsed.la : 0,
|
|
330
|
+
ld: typeof parsed.ld === 'number' ? parsed.ld : 0,
|
|
331
|
+
};
|
|
332
|
+
// Preserve the session id so consumeAgentLoc's rewrite keeps it for
|
|
333
|
+
// entries carried over to a later commit.
|
|
334
|
+
if (typeof parsed.sid === 'string' && parsed.sid !== '')
|
|
335
|
+
entry.sid = parsed.sid;
|
|
336
|
+
if (typeof parsed.c === 'string' && parsed.c !== '') {
|
|
337
|
+
if (!superseded.has(parsed.c))
|
|
338
|
+
continue; // consumed by a commit that landed
|
|
339
|
+
entry.c = parsed.c;
|
|
340
|
+
}
|
|
341
|
+
entries.push(entry);
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
/* corrupt line — drop */
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return entries;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Consume the scratch entries attributed to this commit. Entries for staged
|
|
351
|
+
* files are marked with the commit's `task.commit` hash rather than deleted:
|
|
352
|
+
* if that commit is amended away or reset, the replacing commit gets the
|
|
353
|
+
* attribution back instead of counting the agent's lines as human. The next
|
|
354
|
+
* commit drops them once this one is proven to have landed. Entries for files
|
|
355
|
+
* NOT staged await a later commit. Fail-soft.
|
|
356
|
+
*/
|
|
357
|
+
function consumeAgentLoc(projectDir, entries, stagedFiles, commitHash) {
|
|
358
|
+
const next = entries.map(({ c: _consumedBy, ...entry }) => stagedFiles.has(entry.f) ? { ...entry, c: commitHash } : entry);
|
|
359
|
+
const path = agentLocPath(projectDir);
|
|
360
|
+
try {
|
|
361
|
+
if (next.length === 0) {
|
|
362
|
+
rmSync(path, { force: true });
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
writeFileSync(path, next.map((e) => JSON.stringify(e)).join('\n') + '\n', 'utf8');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
/* non-fatal: entries get re-attributed (and staged ones re-consumed) next commit */
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Sum the scratch entries per file — multiple edits AND multiple sessions
|
|
374
|
+
* since the last commit accumulate into one added/removed total per file.
|
|
375
|
+
*/
|
|
376
|
+
export function aggregateAgentLoc(entries) {
|
|
377
|
+
const totals = new Map();
|
|
378
|
+
for (const e of entries) {
|
|
379
|
+
const t = totals.get(e.f) ?? { la: 0, ld: 0 };
|
|
380
|
+
t.la += e.la;
|
|
381
|
+
t.ld += e.ld;
|
|
382
|
+
totals.set(e.f, t);
|
|
383
|
+
}
|
|
384
|
+
return totals;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Numstat rename detection: `a/{old => new}/b.ts` or `old.ts => new.ts` →
|
|
388
|
+
* post-rename path + pre-rename path (`pre` null when not a rename).
|
|
389
|
+
*/
|
|
390
|
+
function parseNumstatPath(path) {
|
|
391
|
+
const braced = path.match(/^(.*)\{(.*) => (.*)\}(.*)$/);
|
|
392
|
+
if (braced) {
|
|
393
|
+
return {
|
|
394
|
+
post: (braced[1] + braced[3] + braced[4]).replace(/\/\//g, '/'),
|
|
395
|
+
pre: (braced[1] + braced[2] + braced[4]).replace(/\/\//g, '/'),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
const plain = path.match(/^(.*) => (.*)$/);
|
|
399
|
+
if (plain)
|
|
400
|
+
return { post: plain[2], pre: plain[1] };
|
|
401
|
+
return { post: path, pre: null };
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Staged additions/deletions, split by attribution. Per staged file:
|
|
405
|
+
* `min(recorded agent lines, staged numstat lines)` counts as assisted
|
|
406
|
+
* (`aa`/`ad`) and the remainder as human (`ha`/`hd`) — a per-file
|
|
407
|
+
* line-count BOUND (loc-recorder header has the full semantics):
|
|
408
|
+
*
|
|
409
|
+
* - agent added 10 lines, human added 5 more → aa=10, ha=5;
|
|
410
|
+
* - agent edits reverted by the human before staging → capped by staged
|
|
411
|
+
* reality (recorded counts in excess of the numstat never count);
|
|
412
|
+
* - renamed files (numstat `old => new`) carry attribution recorded under
|
|
413
|
+
* the pre-rename path.
|
|
414
|
+
*
|
|
415
|
+
* Binary files (numstat `-`) carry no line counts and are skipped.
|
|
416
|
+
* `stagedFiles` contains every staged path (pre- AND post-rename) so the
|
|
417
|
+
* caller can consume the matching scratch entries.
|
|
418
|
+
*/
|
|
419
|
+
export function splitStagedLoc(numstat, agentTotals) {
|
|
420
|
+
const loc = { aa: 0, ad: 0, ha: 0, hd: 0 };
|
|
421
|
+
const stagedFiles = new Set();
|
|
422
|
+
if (!numstat)
|
|
423
|
+
return { loc, stagedFiles };
|
|
424
|
+
for (const line of numstat.split('\n')) {
|
|
425
|
+
const first = line.indexOf('\t');
|
|
426
|
+
const second = line.indexOf('\t', first + 1);
|
|
427
|
+
if (first === -1 || second === -1)
|
|
428
|
+
continue;
|
|
429
|
+
const a = Number.parseInt(line.slice(0, first), 10);
|
|
430
|
+
const d = Number.parseInt(line.slice(first + 1, second), 10);
|
|
431
|
+
const { post, pre } = parseNumstatPath(line.slice(second + 1));
|
|
432
|
+
if (post === '')
|
|
433
|
+
continue;
|
|
434
|
+
stagedFiles.add(post);
|
|
435
|
+
if (pre !== null && pre !== '')
|
|
436
|
+
stagedFiles.add(pre);
|
|
437
|
+
// Recorded counts for this file: post-rename path + (rename carry) the
|
|
438
|
+
// pre-rename path — the agent may have edited under both.
|
|
439
|
+
const rec = { la: 0, ld: 0 };
|
|
440
|
+
for (const key of pre !== null && pre !== post ? [post, pre] : [post]) {
|
|
441
|
+
const t = agentTotals.get(key);
|
|
442
|
+
if (t) {
|
|
443
|
+
rec.la += t.la;
|
|
444
|
+
rec.ld += t.ld;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (Number.isFinite(a)) {
|
|
448
|
+
const aa = Math.min(rec.la, a);
|
|
449
|
+
loc.aa += aa;
|
|
450
|
+
loc.ha += a - aa;
|
|
451
|
+
}
|
|
452
|
+
if (Number.isFinite(d)) {
|
|
453
|
+
const ad = Math.min(rec.ld, d);
|
|
454
|
+
loc.ad += ad;
|
|
455
|
+
loc.hd += d - ad;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return { loc, stagedFiles };
|
|
459
|
+
}
|
|
460
|
+
// ---------------------------------------------------------------------------
|
|
461
|
+
// Commit-message editing
|
|
462
|
+
// ---------------------------------------------------------------------------
|
|
463
|
+
const SCISSORS_RE = /^# -+ >8 -+/;
|
|
464
|
+
const KNOWN_TRAILER_RE = /^(?:Signed-off-by|Co-authored-by|Reviewed-by|Acked-by|Tested-by|Reported-by|Suggested-by|Helped-by|Assisted-by|Change-Id|Fixes|Closes|Refs):/i;
|
|
465
|
+
/** Insert trailer lines after the last content line (before git's comment block). */
|
|
466
|
+
export function insertTrailers(message, trailerLines) {
|
|
467
|
+
const lines = message.split('\n');
|
|
468
|
+
let cut = lines.findIndex((l) => SCISSORS_RE.test(l));
|
|
469
|
+
if (cut === -1)
|
|
470
|
+
cut = lines.length;
|
|
471
|
+
let end = -1;
|
|
472
|
+
for (let i = cut - 1; i >= 0; i--) {
|
|
473
|
+
const line = lines[i];
|
|
474
|
+
if (line.trim() !== '' && !line.startsWith('#')) {
|
|
475
|
+
end = i;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (end === -1)
|
|
480
|
+
return null; // empty message — git will abort the commit anyway
|
|
481
|
+
// Join an existing trailer block (Signed-off-by: …) instead of opening a
|
|
482
|
+
// new paragraph, so git keeps parsing one trailer block. A conventional
|
|
483
|
+
// subject line ("fix: …") must NOT count as a trailer block.
|
|
484
|
+
const joinsTrailerBlock = end > 0 && KNOWN_TRAILER_RE.test(lines[end]);
|
|
485
|
+
const insertion = joinsTrailerBlock ? trailerLines : ['', ...trailerLines];
|
|
486
|
+
return [...lines.slice(0, end + 1), ...insertion, ...lines.slice(end + 1)].join('\n');
|
|
487
|
+
}
|
|
488
|
+
// ---------------------------------------------------------------------------
|
|
489
|
+
// Entry point
|
|
490
|
+
// ---------------------------------------------------------------------------
|
|
491
|
+
/**
|
|
492
|
+
* `prepare-commit-msg` implementation. argv: [msgFile, source?, sha?].
|
|
493
|
+
* Always returns 0 — metrics encoding must never break a commit.
|
|
494
|
+
*/
|
|
495
|
+
export async function runPrepareCommitMsg(argv, opts = {}) {
|
|
496
|
+
try {
|
|
497
|
+
const env = opts.env ?? process.env;
|
|
498
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
499
|
+
const msgFileArg = argv[0];
|
|
500
|
+
if (!msgFileArg)
|
|
501
|
+
return 0;
|
|
502
|
+
const source = argv[1];
|
|
503
|
+
if (source !== undefined && SKIP_SOURCES.has(source))
|
|
504
|
+
return 0;
|
|
505
|
+
const projectDir = gitOutput(['rev-parse', '--show-toplevel'], cwd) ?? cwd;
|
|
506
|
+
const msgFile = isAbsolute(msgFileArg) ? msgFileArg : resolve(cwd, msgFileArg);
|
|
507
|
+
let message;
|
|
508
|
+
try {
|
|
509
|
+
message = readFileSync(msgFile, 'utf8');
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
return 0;
|
|
513
|
+
}
|
|
514
|
+
if (/^(?:fixup|squash|amend)!/.test(message))
|
|
515
|
+
return 0;
|
|
516
|
+
if (/^Assisted-by:/im.test(message))
|
|
517
|
+
return 0;
|
|
518
|
+
if (extractTrailers(message).length > 0)
|
|
519
|
+
return 0;
|
|
520
|
+
const hmacKey = readHmacKey(projectDir);
|
|
521
|
+
if (hmacKey === null)
|
|
522
|
+
return 0; // not provisioned — skip silently
|
|
523
|
+
// Trailers enter immutable git history: only a PROVISIONED (salted)
|
|
524
|
+
// dev id may be used here — never the unsalted local fallback.
|
|
525
|
+
const devId = resolveDevId(projectDir, env, { allowUnsalted: false });
|
|
526
|
+
if (devId === null)
|
|
527
|
+
return 0;
|
|
528
|
+
const logDir = defaultLogDir(projectDir);
|
|
529
|
+
let entries;
|
|
530
|
+
try {
|
|
531
|
+
entries = readLog(logDir, devId);
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
return 0; // corrupt log is `invi doctor`'s problem, not the commit's
|
|
535
|
+
}
|
|
536
|
+
// A previous task.commit whose commit never landed hands its window over.
|
|
537
|
+
const superseded = supersededCommits(entries, (entry) => carriedByAnyRef(projectDir, entry), Math.floor(Date.now() / 1000));
|
|
538
|
+
const acc = accumulate(entries, superseded.hashes);
|
|
539
|
+
if (acc === null)
|
|
540
|
+
return 0; // nothing accumulated since last trailer — absent trailer is the signal
|
|
541
|
+
// Split staged lines into assisted vs human: per staged file,
|
|
542
|
+
// min(recorded agent lines, staged numstat lines) is assisted and the
|
|
543
|
+
// remainder human — a line-count bound (see splitStagedLoc).
|
|
544
|
+
const agentEntries = readAgentLoc(projectDir, superseded.hashes);
|
|
545
|
+
const numstat = gitOutput(['diff', '--cached', '--numstat'], projectDir);
|
|
546
|
+
const { loc, stagedFiles } = splitStagedLoc(numstat, aggregateAgentLoc(agentEntries));
|
|
547
|
+
// Active vs wall seconds from the session.end entries; act never exceeds dur.
|
|
548
|
+
const actSec = Math.min(acc.actSec, acc.durSec);
|
|
549
|
+
// One summary entry in the log; the trailer is derived from it (§5).
|
|
550
|
+
const summary = appendEvent(logDir, devId, {
|
|
551
|
+
sid: acc.sessions[acc.sessions.length - 1].sid,
|
|
552
|
+
type: 'task.commit',
|
|
553
|
+
data: {
|
|
554
|
+
t: acc.t,
|
|
555
|
+
usdCents: acc.usdCents,
|
|
556
|
+
m: acc.m,
|
|
557
|
+
prompts: acc.prompts,
|
|
558
|
+
toolCalls: acc.toolCalls,
|
|
559
|
+
acc: acc.accepts,
|
|
560
|
+
rej: acc.rejects,
|
|
561
|
+
actSec,
|
|
562
|
+
durSec: acc.durSec,
|
|
563
|
+
sessions: acc.sessions.map((s) => shortHash8(s.sid)),
|
|
564
|
+
loc,
|
|
565
|
+
// Names the entry whose commit never landed and whose window this
|
|
566
|
+
// one took over — so a later check can follow the chain.
|
|
567
|
+
...(superseded.head !== null ? { re: superseded.head.h } : {}),
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
const lastTrailer = readLastTrailer(projectDir);
|
|
571
|
+
const req = [...new Set(message.match(/REQ-\d+/g) ?? [])].slice(0, 32);
|
|
572
|
+
const payload = {
|
|
573
|
+
v: 1,
|
|
574
|
+
kit: `invictus@${kitVersion()}`,
|
|
575
|
+
tool: acc.tool ?? 'claude-code@0.0.0',
|
|
576
|
+
dev: devId,
|
|
577
|
+
cli_ent: resolveClientId(projectDir, env),
|
|
578
|
+
ts: Math.floor(Date.now() / 1000),
|
|
579
|
+
s: [...new Set(acc.sessions.map((s) => shortHash8(s.sid)))].slice(0, 32),
|
|
580
|
+
t: acc.t,
|
|
581
|
+
usd: acc.usdCents,
|
|
582
|
+
m: acc.m,
|
|
583
|
+
loc,
|
|
584
|
+
px: acc.prompts,
|
|
585
|
+
tl: acc.toolCalls,
|
|
586
|
+
// Edit-tool accepts/rejects, derived from the transcripts at
|
|
587
|
+
// SessionEnd (metrics-capture) — see that hook for the evidence base.
|
|
588
|
+
acc: acc.accepts,
|
|
589
|
+
rej: acc.rejects,
|
|
590
|
+
act: actSec,
|
|
591
|
+
dur: acc.durSec,
|
|
592
|
+
req,
|
|
593
|
+
j: summary.h,
|
|
594
|
+
// A replacement takes the place of the commit it replaced in the chain,
|
|
595
|
+
// rather than pointing at a trailer that no ref carries any more.
|
|
596
|
+
prev: superseded.head !== null && lastTrailer?.j === superseded.head.h
|
|
597
|
+
? lastTrailer.prev
|
|
598
|
+
: (lastTrailer?.hash ?? null),
|
|
599
|
+
};
|
|
600
|
+
const trailerLine = formatTrailerLine(payload, hmacKey);
|
|
601
|
+
const assistedBy = `Assisted-by: ${acc.model ?? 'claude'} via Invictus Kit`;
|
|
602
|
+
const updated = insertTrailers(message, [assistedBy, trailerLine]);
|
|
603
|
+
if (updated === null)
|
|
604
|
+
return 0;
|
|
605
|
+
writeFileSync(msgFile, updated, 'utf8');
|
|
606
|
+
writeLastTrailer(projectDir, {
|
|
607
|
+
hash: sha256Prefix(canonicalJson(payload)),
|
|
608
|
+
j: summary.h,
|
|
609
|
+
prev: payload.prev ?? null,
|
|
610
|
+
});
|
|
611
|
+
consumeAgentLoc(projectDir, agentEntries, stagedFiles, summary.h);
|
|
612
|
+
return 0;
|
|
613
|
+
}
|
|
614
|
+
catch {
|
|
615
|
+
return 0; // never break `git commit`
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
// Direct execution: `node dist/git/prepare-commit-msg.js <msgfile> [source] [sha]`
|
|
619
|
+
// — also through a symlinked package (npm workspaces, pnpm, `file:` installs).
|
|
620
|
+
if (isEntryModule(import.meta.url)) {
|
|
621
|
+
process.exitCode = await runPrepareCommitMsg(process.argv.slice(2));
|
|
622
|
+
}
|
|
623
|
+
//# sourceMappingURL=prepare-commit-msg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-commit-msg.js","sourceRoot":"","sources":["../../src/git/prepare-commit-msg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,C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