@erclx/aitk 0.47.0 → 0.48.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aitk",
3
3
  "description": "Automated governance, versioning, and discovery tools for Claude Code.",
4
- "version": "0.47.0",
4
+ "version": "0.48.0",
5
5
  "author": {
6
6
  "name": "Eric Le",
7
7
  "url": "https://github.com/erclx"
@@ -9,14 +9,21 @@ description: What the review return leg is for, the gaps it closes, and why the
9
9
 
10
10
  Without this skill, review findings are worked in whatever order the author read them and the thread never records which landed. A reply posted before the push describes code the remote does not have, so a reviewer checks the branch and finds the old version. A failing check gets treated as separate from the review, which produces a follow-up that answers every comment and leaves continuous integration red. One finding nobody can resolve stalls the rest.
11
11
 
12
+ A branch also goes stale from `main` moving rather than from anything the branch did. Nothing in the return leg rebases it, so the worker closes every finding, reports the pull request answered, and the branch still cannot merge. Half the resolution is mechanical and wrong to do by hand, since a generated file merged manually produces a diff the next regen discards.
13
+
12
14
  ## Must
13
15
 
14
16
  - Treat a failing check as a finding alongside the review comments, so the follow-up closes both
15
17
  - Handle each finding independently, so one unresolved item does not block the others
16
18
  - Verify before pushing, since a red follow-up costs the reviewer a second pass
19
+ - Rebase onto `origin/main` when the branch no longer merges, after the findings are addressed and before the push, so one force-push carries both
20
+ - Test staleness on every invocation, including one carrying no findings, since a branch goes stale from `main` moving rather than from anything the review said
21
+ - Re-test once the fixes are commits, since the first test reads committed history and cannot see a fix that touches lines `main` moved
22
+ - Rebuild a generated file through the project check rather than resolving its conflict by hand
17
23
  - Push before replying, so the comment never runs ahead of the code it describes
18
24
  - Map every finding to what changed, or to a one-line reason when it is a question or a conscious accept
19
25
  - Post the terminal comment only when the findings are addressed and every check passes
26
+ - Say what the run actually did on a rebase-only pass, since a reply mapping findings and a terminal comment claiming they were addressed are both false on a pull request carrying none
20
27
  - Scan the reply for banned characters and internal phase labels before posting, since the comment leaves for the remote unchecked
21
28
 
22
29
  ## Must not
@@ -26,11 +33,15 @@ Without this skill, review findings are worked in whatever order the author read
26
33
  - Post the closing comment while a check is failing
27
34
  - Reimplement the follow-up push or the doc refresh. Both have owners, and a second copy here drifts from them.
28
35
  - Edit silently. A finding answered without a reply leaves the reviewer re-deriving the change from the diff.
36
+ - Take one side of a conflict wholesale. Both sides are valid content, so `--ours` or `--theirs` drops one silently and passes every check.
37
+ - Merge `main` into the branch. The repository squash-merges, so a merge commit reads as noise on the pull request.
38
+ - Guess at a hunk the tree does not settle. That case reaches the operator as an ordinary finding on the next pass only if the worker stops.
29
39
 
30
40
  ## Guards
31
41
 
32
42
  - No open pull request for the current branch: stop
33
- - The pull request carries no review comments or threads: stop with a pass
43
+ - The pull request carries no review comments or threads and the branch still merges: stop with a pass. A closed review says nothing about whether the branch still merges, so the staleness test decides this one rather than the finding count.
44
+ - A conflict needing a decision the tree does not carry: stop with the branch left on its old base
34
45
 
35
46
  ## Out of scope
36
47
 
@@ -38,3 +49,4 @@ Without this skill, review findings are worked in whatever order the author read
38
49
  - Staging, committing, and pushing the follow-up, which `git-followup` owns under this skill's direction
39
50
  - Refreshing the `.claude/` docs the fixes made stale, which `claude-docs` owns
40
51
  - Re-reviewing its own fixes, which hands back to the orchestrator
52
+ - Re-reading a rewritten branch, which `claude-pr-review` absorbs by testing whether the prior reviewed commit still reaches the head and paying for a full pass when it does not
@@ -11,7 +11,7 @@ the PR from an independent session. This skill consumes them: fix, reply, push.
11
11
  ## Guards
12
12
 
13
13
  - If no open PR resolves for the current branch via `gh pr view`, stop: `❌ No open PR. Nothing to address.`
14
- - If the PR has no review comments or threads, stop: `✅ No review findings to address.`
14
+ - If the PR has no review comments or threads, run step 5's staleness test before deciding. A branch that still merges stops here: `✅ No review findings to address.` One that does not skips steps 1 through 4 and runs step 5 onward, since a branch goes stale from `main` moving and a closed review says nothing about whether it still merges.
15
15
  - Fix findings. Do not merge.
16
16
 
17
17
  ## Step 1: pull the review findings and CI status
@@ -48,7 +48,57 @@ Do not push a red follow-up.
48
48
 
49
49
  The fixes may have changed or added behavior that `.claude/` context entries, docs, or wireframes describe. Refresh them with the `claude-docs` skill, which maps the changed files to the entries that reference them and rewrites the stale sections. Do not reimplement that mapping here. When a fix adds a new capability with no existing entry, `claude-docs` flags it rather than creating one.
50
50
 
51
- ## Step 5: push, then reply
51
+ ## Step 5: rebase a stale branch
52
+
53
+ A branch goes stale from `main` moving rather than from anything the branch did,
54
+ so the test runs on every invocation, including the one the second guard sends
55
+ straight here with no findings to fix. Fetch first. A stale local `origin/main`
56
+ reports no conflict on a branch that has one.
57
+
58
+ ```bash
59
+ git fetch origin main
60
+ git merge-tree --write-tree origin/main HEAD
61
+ ```
62
+
63
+ A zero exit means the branch still merges. Skip to step 6. A non-zero exit means
64
+ it does not. Stash the fixes first when `git status --porcelain` reports
65
+ anything, since a rebase refuses to run over a dirty tree, then rebase onto
66
+ `origin/main` and restore them:
67
+
68
+ ```bash
69
+ git stash push -u
70
+ git rebase origin/main
71
+ git stash pop
72
+ ```
73
+
74
+ Pop only when the stash ran. On a clean tree, which is what a run whose findings
75
+ were all conscious-accepts leaves behind, `git stash push` saves nothing and
76
+ exits zero, so the pop restores an unrelated entry from an earlier session.
77
+
78
+ Never merge `main` into the branch. The repository squash-merges, so a merge
79
+ commit here reads as noise on the pull request.
80
+
81
+ Resolve every conflict under these rules, which apply to a hunk from the rebase
82
+ and a hunk from the stash pop alike:
83
+
84
+ - Never take one side wholesale with `--ours` or `--theirs`. Both sides are valid content, so the drop is silent and passes every check.
85
+ - Never resolve a generated file by hand. A file the project check rebuilds, such as an `index.md` carrying no `auto: false`, takes either side to clear the conflict and gets its real content from the regen below.
86
+ - Where two branches wrote prose into one file, keep both sides and rewrite what the merge broke. A section that opens by counting what follows needs the count updated rather than the two versions concatenated.
87
+ - When a hunk needs a decision the tree does not carry, stop rather than guessing, and name where the branch was left. The two sources recover differently. A hunk raised by the rebase takes `git rebase --abort`, which restores the old base: `❌ Conflict needs a decision at <file>. Branch left on its old base.` A hunk raised by the stash pop arrives after the rebase already landed, so no abort applies and the conflict stays in the tree: `❌ Conflict needs a decision at <file>. Branch rebased, fixes left conflicted in the tree.` A guess that compiles is the failure this stage would otherwise introduce, and either case reaches the operator as an ordinary finding on the next review pass.
88
+
89
+ Both sides of every hunk sit in the conflict and `git log origin/main` names what
90
+ landed, so the tree carries the context. Do not wait on the orchestrator for it.
91
+
92
+ Re-run the project check after the rebase. It rebuilds the generated files and
93
+ covers what the replayed commits broke, and step 6 commits the result alongside
94
+ the fixes.
95
+
96
+ `git merge-tree` reads committed history, so this test says nothing about the
97
+ fixes still sitting in the working tree. A branch that merges clean as committed,
98
+ whose fixes touch lines `main` moved, passes here and reaches the remote
99
+ unmergeable. Step 6 re-runs the test once those fixes are commits.
100
+
101
+ ## Step 6: push, then reply
52
102
 
53
103
  Push the fixes before posting the reply so the comment never runs ahead of the
54
104
  code it describes. Ship the fixes as a follow-up commit on the same branch with
@@ -56,7 +106,21 @@ the `git-followup` skill, invoked with `reply-owned` so it stages, commits,
56
106
  pushes, and refreshes the open PR body without posting its own comment. This
57
107
  skill owns the reply. Do not reimplement that flow here. For in-place fixes to
58
108
  files the PR body already covers, `git-followup` leaves the body untouched and
59
- the reply comment carries the fix log.
109
+ the reply comment carries the fix log. A rebase in step 5 rewrote the branch, so
110
+ that push is a force-push and `git-followup` resolves it from the tracking
111
+ branch. Worker branches are single-owner here, which is what makes overwriting
112
+ the remote safe.
113
+
114
+ `git-followup` stops on an unchanged tree. A run that answered every finding as a
115
+ conscious-accept and whose rebase left the generated files alone has nothing for
116
+ it to commit, so the rebase would never reach the remote. Push that case directly
117
+ with `git push --force-with-lease`, then post the reply below.
118
+
119
+ Once the fixes are commits, re-run step 5's staleness test against the new head.
120
+ A conflict that appears only now is one the fixes introduced against lines `main`
121
+ moved, which the earlier test could not see. Rebase again under step 5's rules
122
+ and force-push, then continue. The second push costs one extra force-push in a
123
+ case that needs the fix and the sibling to touch the same lines.
60
124
 
61
125
  Then write a summary reply to `.claude/.tmp/address-review/reply-<number>.md`
62
126
  mapping each finding to what changed, or to a one-line reason when it is a
@@ -72,6 +136,18 @@ review itself carries. Follow it with a one-line summary sentence, then one
72
136
  bullet per finding, each opening with the bolded finding identifier.
73
137
  Close the body with `🤖 Addressed by Claude Code` on its own line so the reply
74
138
  reads as an independent machine pass, not a human sign-off.
139
+ When step 5 rebased the branch, say so in the summary sentence and name which
140
+ files were resolved by hand and which the regen rebuilt. The next review is a
141
+ full pass rather than a delta, and the reader is owed the reason.
142
+
143
+ A run the second guard sent straight to step 5 has no findings to map, so it
144
+ takes a different body rather than an empty list. Open it with `## Rebase`, not
145
+ `## Review response`, since nothing on the pull request is being responded to and
146
+ that heading claims a review this run never read. State that the branch stopped
147
+ merging, name what landed on `main`, name the files resolved by hand and those
148
+ the regen rebuilt, and close the same way. The heading stays outside the
149
+ `## Review` family so the close-out's equality test on the first line never
150
+ matches it.
75
151
 
76
152
  Before posting, run the scan in `.claude/standards/publish.md`
77
153
  against the reply, or `${CLAUDE_SKILL_DIR}/../../standards/publish.md` when
@@ -82,7 +158,7 @@ only gate on the published reply. Post it to the PR:
82
158
  gh pr comment <number> --body-file .claude/.tmp/address-review/reply-<number>.md
83
159
  ```
84
160
 
85
- ## Step 6: confirm resolution
161
+ ## Step 7: confirm resolution
86
162
 
87
163
  After the follow-up push, watch CI on the PR. Poll `gh pr checks <number>`
88
164
  until no check is pending, then read the final status. When every finding is
@@ -93,15 +169,33 @@ clear terminal state:
93
169
  gh pr comment <number> --body "✅ All review findings addressed, CI green."
94
170
  ```
95
171
 
172
+ A rebase-only run addressed no finding, so it takes its own terminal comment
173
+ rather than that one. Claiming findings were addressed on a pull request that
174
+ carries none is false on a surface nothing else checks:
175
+
176
+ ```bash
177
+ gh pr comment <number> --body "✅ Rebased onto origin/main, CI green. No review findings were open."
178
+ ```
179
+
96
180
  If any check fails, do not post the closing comment. Report the failing check
97
181
  so it can be fixed first. This is a resolution signal, not a formal approval,
98
182
  since the PR author cannot approve their own PR.
99
183
 
100
- ## Step 7: output
184
+ ## Step 8: output
101
185
 
102
186
  ```plaintext
103
187
  Addressed <N> findings on PR #<number>. Follow-up pushed.
188
+ <Rebased onto origin/main. <N> files resolved by hand, <N> rebuilt by the check.>
189
+ ```
190
+
191
+ Omit the second line when the branch still merged. Name any finding left as a
192
+ reply rather than a code change, with its one-line reason.
193
+
194
+ A rebase-only run drops the first line rather than reporting zero findings
195
+ addressed, and leads with the rebase instead:
196
+
197
+ ```plaintext
198
+ Rebased PR #<number> onto origin/main. <N> files resolved by hand, <N> rebuilt by the check.
104
199
  ```
105
200
 
106
- Name any finding left as a reply rather than a code change, with its one-line
107
- reason. Do not merge. Hand back to the orchestrator for re-review.
201
+ Do not merge. Hand back to the orchestrator for re-review.
@@ -7,7 +7,7 @@ description: What the follow-up push is for, the gaps it closes, and how it spli
7
7
 
8
8
  ## Gap
9
9
 
10
- Without this skill, an edit made after a pull request is already open ships as a bare push. The body still describes the scope from before the edit, so a reviewer returning to the page reads a description the diff no longer matches. A reviewer who left comments gets no reply, and when a caller has already posted its own reply, a second one lands underneath it.
10
+ Without this skill, an edit made after a pull request is already open ships as a bare push. The body still describes the scope from before the edit, so a reviewer returning to the page reads a description the diff no longer matches. A reviewer who left comments gets no reply, and when a caller has already posted its own reply, a second one lands underneath it. A caller that rebased the branch before handing over hits a rejected push, since the tracking branch no longer reaches the head.
11
11
 
12
12
  ## Must
13
13
 
@@ -16,6 +16,7 @@ Without this skill, an edit made after a pull request is already open ships as a
16
16
  - Sync the body when the new commit moves the scope, and the title when the shift makes it inaccurate
17
17
  - Reply on the pull request when it carries review comments, and scan that reply for the banned characters and internal phase labels before posting. The hook watches files and never sees a comment body on its way to the remote.
18
18
  - Suppress the reply when the caller owns it, and still run the push and the body sync
19
+ - Force the push under a lease when the tracking branch no longer reaches the head, so a caller's rebase lands and a commit this session never read is not overwritten
19
20
 
20
21
  ## Must not
21
22
 
@@ -22,7 +22,7 @@ its own reply, so skip the comment in step 6. The push and body sync still run.
22
22
  1. Run `git status` to confirm the changes are intentional
23
23
  2. Run `git add -A` to stage every change
24
24
  3. Invoke `aitk:git-commit` to generate one conventional commit from the staged diff
25
- 4. Run `git push` to the tracking branch
25
+ 4. Run `git push` to the tracking branch. When `git merge-base --is-ancestor @{u} HEAD` exits non-zero, a caller rewrote the branch and a plain push is rejected, so push with `--force-with-lease` instead. The lease is what stops the force from overwriting a commit this session never read.
26
26
  5. Check for existing review comments: `gh api 'repos/{owner}/{repo}/pulls/<number>/comments' --jq 'length'`, resolving `<number>` from `gh pr view --json number`.
27
27
  6. When invoked with `reply-owned`, skip this step's comment: the caller posts the reply. Otherwise, if the count is above zero, the followup addresses review feedback: post a one-line summary of the fix with `gh pr comment --body`, first running the scan in `.claude/standards/publish.md` against it, or `${CLAUDE_SKILL_DIR}/../../standards/publish.md` when the project does not have it, since the hook does not see an inline comment body. If it is zero, run `gh pr view --json url,title,body` and update the body with `gh pr edit --body` when the new commit changes scope, and the title with `gh pr edit --title` when the scope shifted enough to make it inaccurate.
28
28
 
@@ -139,7 +139,7 @@ Before the first feature session on a UI-heavy project, pick a design tier. The
139
139
  | `aitk:claude-design-extract` | Draft `.claude/DESIGN.md`, sourcing tokens from existing UI code or proposing them from requirements on day one |
140
140
  | `aitk:claude-review` | In a fresh session, review all changes since main |
141
141
  | `aitk:claude-pr-review` | Review an open PR from an independent session, then re-review the commits added since until nothing is open |
142
- | `aitk:claude-address-review` | Address PR findings and CI status, refresh stale docs, then push a follow-up |
142
+ | `aitk:claude-address-review` | Address PR findings and CI status, refresh stale docs, rebase a branch that stopped merging, then push a follow-up |
143
143
  | `aitk:claude-tasks` | Add a task to `.claude/tasks/` or archive a shipped one out of the folder |
144
144
  | `aitk:claude-docs` | When decisions diverged from plan, update `.claude/` docs |
145
145
  | `aitk:claude-ui-test` | After UI changes, generate and run e2e tests + visual checklist |
@@ -33,9 +33,9 @@ One feature travels this path end to end.
33
33
  2. Orchestrator plans the next feature with `claude-feature`, writing a plan to `.claude/plans/`. Planning stays in the warm session because good planning is cross-feature. It needs the contract other features consume and the shared wiring seam. A cold session would re-derive or guess.
34
34
  3. The human opens a worker worktree with `claude-worktree` and runs `claude-autoship` against the plan. The worker builds, self-checks, opens a PR, and stops at the PR boundary.
35
35
  4. Orchestrator reviews the PR with `claude-pr-review` and posts findings to it.
36
- 5. Worker addresses the findings with `claude-address-review`, then pushes a follow-up.
36
+ 5. Worker addresses the findings with `claude-address-review`, rebases onto `origin/main` when a sibling landed first and left the branch unable to merge, then pushes a follow-up.
37
37
  6. Orchestrator closes the review out with `claude-pr-review` again. The second pass reads only the commits the follow-up added, and posts under `## Review closed` when it finds nothing open or under `## Review` when it does, so a reader learns the state from the heading. Repeat from step 5 until the review closes.
38
- 7. The human reads the result and merges. The orchestrator tells any trailing worker to rebase when its branch shares a seam with the merged one.
38
+ 7. The human reads the result and merges. The orchestrator tells any trailing worker whose branch shares a seam with the merged one to run `claude-address-review`, which rebases whether or not the review left anything open.
39
39
 
40
40
  There is no loop construct here. Each worker is a single build that halts at the
41
41
  PR. The merge stays a manual human gate. Reliability comes from the plan being
@@ -61,6 +61,14 @@ the PR. `claude-address-review` reads them back, fixes each, replies or resolves
61
61
  the threads, and pushes a follow-up. `claude-pr-review` then runs again, reading
62
62
  only what the follow-up added.
63
63
 
64
+ A branch that stopped merging while the review was open is the worker's problem
65
+ to close. `claude-address-review` rebases onto `origin/main` between the fixes
66
+ and the push, so one force-push carries both and the reviewer reads one delta.
67
+ The staleness test sits ahead of the no-findings guard, so a branch whose review
68
+ closed clean and then went stale still rebases when the skill is invoked. The
69
+ re-read costs a full pass rather than a delta, since the prior reviewed commit no
70
+ longer reaches the head, and `claude-pr-review` detects that itself.
71
+
64
72
  The heading carries the state rather than the pass number. A pass with a finding
65
73
  takes `## Review` and a pass with none takes `## Review closed`, so a thread can
66
74
  be scanned for what is still open without opening a comment. The feedback
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@erclx/aitk",
3
3
  "type": "module",
4
- "version": "0.47.0",
4
+ "version": "0.48.0",
5
5
  "description": "Infrastructure and quality tooling for developer workflows",
6
6
  "license": "MIT",
7
7
  "bin": {