@leonardo-marziali/ad-lfl-kit 2.10.1 → 2.10.3
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/README.md +8 -5
- package/changes.js +56 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -277,11 +277,14 @@ How `toolChangedFiles` answers for tools that don't name their files.
|
|
|
277
277
|
time and `HEAD`), for watching a window that stays open.
|
|
278
278
|
- **`filesChangedSince(snapshot, { cwd })`** — absolute paths written since
|
|
279
279
|
the snapshot. In a repo: the dirty and untracked files from `git status`,
|
|
280
|
-
plus the files of commits made during the call (so
|
|
281
|
-
isn't missed), keeping only those whose mtime falls
|
|
282
|
-
Already-dirty files the call didn't touch are older
|
|
283
|
-
`checkout` or `pull` leaves the tree clean and
|
|
284
|
-
|
|
280
|
+
plus the files of commits this checkout made during the call (so
|
|
281
|
+
`edit && git commit` isn't missed), keeping only those whose mtime falls
|
|
282
|
+
after the snapshot. Already-dirty files the call didn't touch are older
|
|
283
|
+
than that. A `checkout` or `pull` leaves the tree clean, and the HEAD
|
|
284
|
+
reflog records its commits as arriving (`pull:`, `merge … Fast-forward`)
|
|
285
|
+
rather than as made here (`commit:`, `cherry-pick:`, `revert:`), so a
|
|
286
|
+
commit someone else pushed while the call ran — a release bot's
|
|
287
|
+
`CHANGELOG.md` — isn't attributed to the session. Outside a repo: a
|
|
285
288
|
bounded walk of the cwd. Gitignored files and dependency directories
|
|
286
289
|
(`node_modules`, `.venv`, `__pycache__`…) are never reported. Unlike
|
|
287
290
|
`scope.js` this fails closed — an error means "nothing changed" — since
|
package/changes.js
CHANGED
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
* PostToolUse hook asks what changed since:
|
|
11
11
|
*
|
|
12
12
|
* - in a git repo, the dirty and untracked files (`git status`), plus the
|
|
13
|
-
* files of any commit made during the call
|
|
14
|
-
* command isn't missed;
|
|
13
|
+
* files of any commit this checkout made during the call (per the HEAD
|
|
14
|
+
* reflog), so `edit && git commit` in one command isn't missed;
|
|
15
15
|
* - outside a repo, a bounded walk of the cwd;
|
|
16
16
|
*
|
|
17
17
|
* and in both cases keeps only files whose mtime falls inside the call's
|
|
18
18
|
* window. Pre-existing dirty files the call didn't touch are older than the
|
|
19
|
-
* snapshot, and a `git checkout` / `git pull` leaves the tree clean and
|
|
20
|
-
*
|
|
19
|
+
* snapshot, and a `git checkout` / `git pull` leaves the tree clean and its
|
|
20
|
+
* commits are logged as arriving, not as made here — even one pushed by
|
|
21
|
+
* someone else while the call ran — so neither drags unrelated files in.
|
|
21
22
|
*
|
|
22
23
|
* Everything here fails CLOSED, unlike scope.js: a snapshot or a git call
|
|
23
24
|
* that fails resolves to "nothing changed". This module decides which files
|
|
@@ -135,22 +136,62 @@ function dirtyFiles(root) {
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
/*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
139
|
+
* HEAD reflog subjects of commits this checkout created: `commit:`,
|
|
140
|
+
* `commit (initial):`, `commit (amend):`, `commit (merge):`, plus
|
|
141
|
+
* `cherry-pick:` and `revert:`. A commit that only arrived — `pull:`,
|
|
142
|
+
* `merge <branch>: Fast-forward`, `checkout:`, `reset:`, `rebase …` — was
|
|
143
|
+
* made somewhere else, even when its committer date falls inside the call.
|
|
144
|
+
*/
|
|
145
|
+
const OWN_COMMIT_SUBJECT = /^(commit( \([^)]*\))?|cherry-pick|revert):/;
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* Commits this checkout made since `startedAt`, newest first, read from the
|
|
149
|
+
* HEAD reflog: `<sha> NUL <unix seconds> NUL <subject>` per entry.
|
|
150
|
+
*/
|
|
151
|
+
function ownCommitsSince(root, startedAt) {
|
|
152
|
+
const out = git(['log', '-g', '--date=unix', '--format=%H%x00%gd%x00%gs', 'HEAD'], root);
|
|
153
|
+
if (out === null) return [];
|
|
154
|
+
|
|
155
|
+
const since = startedAt - MTIME_SLACK_MS;
|
|
156
|
+
const commits = [];
|
|
157
|
+
for (const line of out.split('\n')) {
|
|
158
|
+
const [sha, selector, subject] = line.split('\0');
|
|
159
|
+
const seconds = Number(/@\{(\d+)\}$/.exec(selector || '')?.[1]);
|
|
160
|
+
// Entries are newest first, so the first one before the call ends the walk.
|
|
161
|
+
if (!sha || !Number.isFinite(seconds) || seconds * 1000 < since) break;
|
|
162
|
+
if (OWN_COMMIT_SUBJECT.test(subject || '')) commits.push(sha);
|
|
163
|
+
}
|
|
164
|
+
return commits;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* Files touched by commits the call itself made. Neither the commit range
|
|
169
|
+
* nor committer dates can tell those apart from commits that arrived during
|
|
170
|
+
* the call — a release bot that pushes while the session's `git pull` runs
|
|
171
|
+
* makes a commit just as fresh — so the HEAD reflog decides instead (see
|
|
172
|
+
* OWN_COMMIT_SUBJECT). No reflog (`core.logAllRefUpdates` off) means no
|
|
173
|
+
* files, failing closed like the rest of this module.
|
|
141
174
|
*/
|
|
142
175
|
function committedFiles(root, fromHead, startedAt) {
|
|
143
176
|
const head = headOf(root);
|
|
144
177
|
if (!head || head === fromHead) return [];
|
|
145
178
|
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
179
|
+
const files = [];
|
|
180
|
+
for (const sha of ownCommitsSince(root, startedAt)) {
|
|
181
|
+
// A merge commit lists nothing here, as `git log --name-only` didn't.
|
|
182
|
+
const out = git(
|
|
183
|
+
['diff-tree', '--no-commit-id', '--name-only', '-r', '-z', '--root', sha],
|
|
184
|
+
root,
|
|
185
|
+
);
|
|
186
|
+
if (out === null) continue;
|
|
187
|
+
files.push(
|
|
188
|
+
...out
|
|
189
|
+
.split('\0')
|
|
190
|
+
.filter(Boolean)
|
|
191
|
+
.map((rel) => path.resolve(root, rel)),
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
return files;
|
|
154
195
|
}
|
|
155
196
|
|
|
156
197
|
function walkFiles(dir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leonardo-marziali/ad-lfl-kit",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"description": "Agentic development lint-fix-loop kit: session-scoped file tracking and a capped Stop-hook fix loop for Claude Code plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|