slicekit 0.0.1 → 0.1.2

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.
Files changed (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +252 -3
  3. package/bin/slicekit.js +4 -0
  4. package/package.json +21 -4
  5. package/src/adapters/githost/errors.js +17 -0
  6. package/src/adapters/githost/fixture.js +136 -0
  7. package/src/adapters/githost/gh-json.js +99 -0
  8. package/src/adapters/githost/github.js +127 -0
  9. package/src/adapters/githost/index.js +12 -0
  10. package/src/adapters/tracker/errors.js +53 -0
  11. package/src/adapters/tracker/fixture.js +71 -0
  12. package/src/adapters/tracker/github-issues.js +65 -0
  13. package/src/adapters/tracker/index.js +14 -0
  14. package/src/baseline.js +109 -0
  15. package/src/build/commit.js +201 -0
  16. package/src/build/decline.js +81 -0
  17. package/src/build/finish.js +155 -0
  18. package/src/build/order.js +158 -0
  19. package/src/build/overlap.js +173 -0
  20. package/src/build/parallel.js +50 -0
  21. package/src/build/pr.js +263 -0
  22. package/src/build/record.js +28 -0
  23. package/src/build/red.js +207 -0
  24. package/src/build/review.js +123 -0
  25. package/src/build/sync.js +47 -0
  26. package/src/build/verdict.js +410 -0
  27. package/src/build/worktree.js +169 -0
  28. package/src/check/ci-event.js +52 -0
  29. package/src/check/context.js +129 -0
  30. package/src/check/index.js +140 -0
  31. package/src/check/rules/.gitkeep +0 -0
  32. package/src/check/rules/ci-body.js +22 -0
  33. package/src/check/rules/ci-title.js +43 -0
  34. package/src/check/rules/citations.js +224 -0
  35. package/src/check/rules/commands.js +146 -0
  36. package/src/check/rules/coverage.js +248 -0
  37. package/src/check/rules/hooks.js +58 -0
  38. package/src/check/rules/journal.js +17 -0
  39. package/src/check/rules/layout.js +56 -0
  40. package/src/check/rules/managed.js +31 -0
  41. package/src/check/rules/queue.js +106 -0
  42. package/src/check/rules/references.js +249 -0
  43. package/src/check/rules/style.js +177 -0
  44. package/src/check/rules/trailer.js +67 -0
  45. package/src/cli/baseline.js +66 -0
  46. package/src/cli/branch.js +86 -0
  47. package/src/cli/build.js +239 -0
  48. package/src/cli/check.js +40 -0
  49. package/src/cli/decide.js +59 -0
  50. package/src/cli/gaps.js +73 -0
  51. package/src/cli/hook.js +28 -0
  52. package/src/cli/index.js +83 -0
  53. package/src/cli/init.js +96 -0
  54. package/src/cli/instructions.js +63 -0
  55. package/src/cli/intake.js +107 -0
  56. package/src/cli/journal.js +82 -0
  57. package/src/cli/plan.js +29 -0
  58. package/src/cli/pr.js +83 -0
  59. package/src/cli/process.js +59 -0
  60. package/src/cli/ready-label.js +119 -0
  61. package/src/cli/review.js +64 -0
  62. package/src/cli/spec.js +31 -0
  63. package/src/cli/stage.js +37 -0
  64. package/src/cli/state.js +106 -0
  65. package/src/cli/status.js +108 -0
  66. package/src/cli/update.js +62 -0
  67. package/src/cli/workflow.js +48 -0
  68. package/src/config.js +203 -0
  69. package/src/decisions.js +289 -0
  70. package/src/evidence.js +27 -0
  71. package/src/fs.js +38 -0
  72. package/src/gaps.js +271 -0
  73. package/src/git.js +209 -0
  74. package/src/githooks.js +37 -0
  75. package/src/hook-cli.js +63 -0
  76. package/src/hooks/io.js +205 -0
  77. package/src/hooks/paths.js +82 -0
  78. package/src/hooks/pre-bash.js +715 -0
  79. package/src/hooks/pre-compact.js +139 -0
  80. package/src/hooks/pre-edit.js +170 -0
  81. package/src/hooks/session-end.js +118 -0
  82. package/src/hooks/session-start.js +209 -0
  83. package/src/hooks/shapes.js +103 -0
  84. package/src/hooks/stop.js +37 -0
  85. package/src/hooks/subagent-marker.js +88 -0
  86. package/src/hooks/subagent-start.js +100 -0
  87. package/src/hooks/subagent-stop.js +106 -0
  88. package/src/ids.js +43 -0
  89. package/src/init.js +281 -0
  90. package/src/instructions.js +235 -0
  91. package/src/intake.js +409 -0
  92. package/src/journal.js +326 -0
  93. package/src/lock.js +35 -0
  94. package/src/markdown.js +155 -0
  95. package/src/paths.js +33 -0
  96. package/src/plan.js +25 -0
  97. package/src/pr.js +73 -0
  98. package/src/prbody.js +266 -0
  99. package/src/ready-label.js +107 -0
  100. package/src/redact.js +33 -0
  101. package/src/render/compare.js +23 -0
  102. package/src/render/entry.js +101 -0
  103. package/src/render/index.js +27 -0
  104. package/src/render/managed.js +128 -0
  105. package/src/render/manifest.js +24 -0
  106. package/src/render/settings.js +76 -0
  107. package/src/render/update.js +151 -0
  108. package/src/slicefile.js +173 -0
  109. package/src/spec-verify.js +58 -0
  110. package/src/stage.js +325 -0
  111. package/src/state/build.js +156 -0
  112. package/src/state/covers.js +58 -0
  113. package/src/state/index.js +191 -0
  114. package/src/state/sync.js +64 -0
  115. package/src/state/transitions.js +282 -0
  116. package/src/verdict.js +203 -0
  117. package/src/which.js +37 -0
  118. package/src/workflow.js +177 -0
  119. package/src/worktrees.js +68 -0
  120. package/templates/claude-code/agents/auditor.md +7 -0
  121. package/templates/claude-code/agents/designer.md +7 -0
  122. package/templates/claude-code/agents/developer.md +7 -0
  123. package/templates/claude-code/agents/fixer.md +7 -0
  124. package/templates/claude-code/agents/ops.md +7 -0
  125. package/templates/claude-code/agents/reviewer.md +7 -0
  126. package/templates/claude-code/commands/slicekit-audit.md +7 -0
  127. package/templates/claude-code/commands/slicekit-build.md +7 -0
  128. package/templates/claude-code/commands/slicekit-gaps.md +6 -0
  129. package/templates/claude-code/commands/slicekit-intake.md +7 -0
  130. package/templates/claude-code/commands/slicekit-ops.md +7 -0
  131. package/templates/claude-code/commands/slicekit-plan.md +6 -0
  132. package/templates/claude-code/commands/slicekit-release.md +7 -0
  133. package/templates/claude-code/commands/slicekit-review.md +7 -0
  134. package/templates/claude-code/commands/slicekit-specify.md +6 -0
  135. package/templates/claude-code/commands/slicekit.md +7 -0
  136. package/templates/claude-code/hooks.json +90 -0
  137. package/templates/claude-code/manifest.json +171 -0
  138. package/templates/claude-code/skills/slicekit-ids/SKILL.md +16 -0
  139. package/templates/claude-code/skills/slicekit-loop/SKILL.md +23 -0
  140. package/templates/claude-code/skills/slicekit-writing/SKILL.md +24 -0
  141. package/templates/docs/BUILD.md +5 -0
  142. package/templates/docs/decisions.md +15 -0
  143. package/templates/docs/intake/.keep +0 -0
  144. package/templates/docs/observability.md +25 -0
  145. package/templates/docs/phases/.keep +0 -0
  146. package/templates/docs/platform.md +25 -0
  147. package/templates/docs/releases/.keep +0 -0
  148. package/templates/docs/runbook.md +21 -0
  149. package/templates/docs/spec/00-overview.md +8 -0
  150. package/templates/docs/spec/contracts/.keep +0 -0
  151. package/templates/docs/spec/gaps.md +6 -0
  152. package/templates/docs/spec/stack.md +3 -0
  153. package/templates/githooks/pre-commit +79 -0
  154. package/templates/githooks/pre-merge-commit +79 -0
  155. package/templates/githooks/prepare-commit-msg +110 -0
  156. package/templates/instructions/agents/auditor.md +33 -0
  157. package/templates/instructions/agents/designer.md +21 -0
  158. package/templates/instructions/agents/developer.md +49 -0
  159. package/templates/instructions/agents/fixer.md +41 -0
  160. package/templates/instructions/agents/ops.md +21 -0
  161. package/templates/instructions/agents/reviewer.md +63 -0
  162. package/templates/instructions/commands/build.md +234 -0
  163. package/templates/instructions/commands/gaps.md +65 -0
  164. package/templates/instructions/commands/intake.md +90 -0
  165. package/templates/instructions/commands/plan.md +60 -0
  166. package/templates/instructions/commands/review.md +117 -0
  167. package/templates/instructions/commands/specify.md +49 -0
  168. package/templates/style.json +11 -0
  169. package/templates/workflow/pins.json +6 -0
  170. package/templates/workflow/slicekit.yml +110 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aditya Pandya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,254 @@
1
- # slicekit
1
+ # Agentic SliceKit
2
2
 
3
- This name is reserved for slicekit, a spec-driven agentic workflow kit for Claude Code.
3
+ Agentic SliceKit is a zero-dependency Node 22 kit for building software with AI coding agents on
4
+ Claude Code, one slice at a time, with a traceable line from every requirement to its tests,
5
+ commits, pull requests and releases. The spec stays true because a machine checks it each time the
6
+ agent finishes a turn and again in CI, not because anyone remembers to update it.
4
7
 
5
- The first real release is 0.1.0. This 0.0.1 package contains no code.
8
+ ## Status: preview
9
+
10
+ Phases 1 and 2 work: intake, specify, the gap scan, plan, the build from red tests to green, the
11
+ review loop, the independent review and `/slicekit build --parallel`. Phase 3 will add the
12
+ traceability graph, its queries and views, and workspaces that span several repositories. Phase 4
13
+ will add release, ops and audit, and the other examples (`fullstack` and `data`). Phases 3 and 4
14
+ are not built yet.
15
+
16
+ The kit is on npm as a preview from 0.1.1. It needs Node 22 or later and git, and it has no
17
+ dependencies of its own. In your project:
18
+
19
+ ```sh
20
+ npm i -D slicekit
21
+ npx slicekit init --shape backend --name <your-project>
22
+ ```
23
+
24
+ Each change to the kit ships as the next 0.x version, and a 0.x version may change how a command
25
+ works. After an upgrade, `npx slicekit update` shows what would change in each of the kit's files,
26
+ and `npx slicekit update --yes` writes the changes.
27
+
28
+ The walkthrough below runs from a clone instead, because it copies files only the repository
29
+ holds (`examples/backend` and `examples/walkthrough`):
30
+
31
+ ```sh
32
+ git clone https://github.com/adityapandya1/agentic-slicekit
33
+ cd agentic-slicekit
34
+ node bin/slicekit.js --version
35
+ ```
36
+
37
+ The last line prints the version the clone carries.
38
+
39
+ `docs/spec/00-overview.md` says what the kit is and why, `docs/decisions.md` holds every choice
40
+ made so far, and `BUILD.md` shows the order the kit is built in. The kit is built with itself.
41
+
42
+ ## Walkthrough
43
+
44
+ This takes about ten minutes. It builds the one slice of `examples/backend`, P1/S-01 "Greet a name",
45
+ from `todo` to `merged`: red tests, green code, a review round, an independent review, green CI and
46
+ the merge.
47
+
48
+ In your own project you type two commands into Claude Code, `/slicekit build` and
49
+ `/slicekit review`, and the kit's agents write the tests, the code and the verdicts. (Each command
50
+ also has a file of its own, so `/slicekit-build` and `/slicekit-review` work too.) Here each step
51
+ is the command line that those two commands run, and the files the agents would write are copied
52
+ in from `examples/walkthrough`. A local bare repository stands in for GitHub's copy of the project,
53
+ and two fixture directories stand in for its pull requests and issues. So the walkthrough needs no
54
+ account, no agent and no network.
55
+
56
+ Run it from the root of your clone, in bash. On Windows, use Git Bash. The kit's own test runs these
57
+ blocks as written, in order, in one shell.
58
+
59
+ git needs a name and an email set (`git config --global user.name` and `user.email`), since the kit
60
+ makes commits. If your git signs commits, it signs these too, and may ask for your key at each of
61
+ them. To skip that for this run, run `export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false`
62
+ first.
63
+
64
+ ### 1. A project to build in
65
+
66
+ `KIT` is your clone. On Windows, `pwd -W` gives a path that Node can read; elsewhere it fails and
67
+ `pwd` is used. `WORK` is a new temporary directory for everything else.
68
+
69
+ ```sh
70
+ KIT="$(pwd -W 2>/dev/null || pwd)"
71
+ WORK="$(mktemp -d)"
72
+ cp -R examples/backend "$WORK/greeting"
73
+ git init -q --bare "$WORK/origin.git"
74
+ mkdir "$WORK/githost" "$WORK/tracker"
75
+ export SLICEKIT_GITHOST_FIXTURE="$WORK/githost"
76
+ export SLICEKIT_TRACKER_FIXTURE="$WORK/tracker"
77
+ ```
78
+
79
+ With `SLICEKIT_GITHOST_FIXTURE` set, the kit keeps pull requests as files in that directory instead
80
+ of calling `gh`. `SLICEKIT_TRACKER_FIXTURE` does the same for issues.
81
+
82
+ ### 2. Add the kit to the project
83
+
84
+ These are the steps in `examples/backend/README.md`. `init` adds the hooks, the Claude Code
85
+ commands and the rest of the docs layout. `--cli` tells the hooks how to run the kit from your
86
+ clone. The path inside it is quoted, so a clone under a folder with a space in its name still works.
87
+
88
+ ```sh
89
+ cd "$WORK/greeting"
90
+ git init -q -b main
91
+ git remote add origin "$WORK/origin.git"
92
+ node "$KIT/bin/slicekit.js" init --shape backend --cli "node \"$KIT/bin/slicekit.js\""
93
+ node "$KIT/bin/slicekit.js" status --write
94
+ ```
95
+
96
+ The kit's git hook refuses a commit on `main` unless `ALLOW_PROTECTED_COMMIT=1` is set. This first
97
+ commit is the one time it is needed. On Windows, git may print warnings that LF will be replaced by
98
+ CRLF; they are harmless.
99
+
100
+ ```sh
101
+ git add -A
102
+ ALLOW_PROTECTED_COMMIT=1 git commit -q -m "chore: slicekit init"
103
+ git push -q -u origin main
104
+ ```
105
+
106
+ ### 3. Pick the slice and start it
107
+
108
+ From here to step 6, the steps are what `/slicekit build` runs. `build next` prints the next slice
109
+ that is ready to build. `build start` makes its worktree and branch, and pushes the branch.
110
+
111
+ ```sh
112
+ node "$KIT/bin/slicekit.js" build next
113
+ node "$KIT/bin/slicekit.js" build start P1/S-01
114
+ WT=.worktrees/P1-S-01
115
+ ```
116
+
117
+ ### 4. Red tests, then green code
118
+
119
+ In `/slicekit build` the developer agent writes the tests first. `build red` runs them, refuses
120
+ them unless they fail, and commits them. From then on the tests are frozen: a later commit that
121
+ changes them is refused.
122
+
123
+ ```sh
124
+ mkdir -p "$WT/test"
125
+ cp "$KIT/examples/walkthrough/test/greet.test.js" "$KIT/examples/walkthrough/test/greet-empty.test.js" "$WT/test/"
126
+ node "$KIT/bin/slicekit.js" build red P1/S-01 --tests test/greet.test.js,test/greet-empty.test.js --worktree "$WT"
127
+ ```
128
+
129
+ Then the developer agent writes the code. `build commit --require-green` commits it only when every
130
+ test passes.
131
+
132
+ ```sh
133
+ mkdir -p "$WT/src"
134
+ cp "$KIT/examples/walkthrough/src/greet.js" "$WT/src/"
135
+ node "$KIT/bin/slicekit.js" build commit P1/S-01 --message "feat(P1/S-01): greet a name" --require-green --worktree "$WT"
136
+ ```
137
+
138
+ ### 5. The draft pull request and a review round
139
+
140
+ `build pr` runs the tests and `slicekit check`, pushes, and opens a draft pull request. It builds
141
+ the body from the slice file and from the notes that the developer agent reported. The last line it
142
+ prints is `verdict <path>`, the file the reviewer writes its verdict to.
143
+
144
+ ```sh
145
+ node "$KIT/bin/slicekit.js" build pr P1/S-01 --notes "$KIT/examples/walkthrough/notes.json" --worktree "$WT" | tee "$WORK/pr.txt"
146
+ VERDICT="$(sed -n 's/^verdict //p' "$WORK/pr.txt")"
147
+ ```
148
+
149
+ In `/slicekit build` the reviewer agent writes the verdict now. The copy here is an `APPROVE` with
150
+ no findings. `build verdict` checks it, commits it to the branch and prints the next step, `ci`.
151
+
152
+ ```sh
153
+ cp "$KIT/examples/walkthrough/P1-S-01-r1.md" "$VERDICT"
154
+ node "$KIT/bin/slicekit.js" build verdict P1/S-01 "$VERDICT" --worktree "$WT"
155
+ ```
156
+
157
+ ### 6. Green CI
158
+
159
+ On GitHub, CI reports on each push by itself. Here `host.js ci` records a green run on the pull
160
+ request's head. `build finish` waits for CI and, on green, records `ci-green` and pushes that
161
+ record. It then prints `ready: waiting for an independent review`: a second session must review the
162
+ slice before the merge. The push made a new head, so CI reports again.
163
+
164
+ ```sh
165
+ node "$KIT/examples/walkthrough/host.js" ci 1 success
166
+ node "$KIT/bin/slicekit.js" build finish P1/S-01 --worktree "$WT"
167
+ node "$KIT/examples/walkthrough/host.js" ci 1 success
168
+ ```
169
+
170
+ ### 7. The independent review
171
+
172
+ This is what `/slicekit review 1` runs, in a new Claude Code session. `review start` checks out the
173
+ pull request's head in a fresh worktree, `.worktrees/review-P1-S-01`, and prints the slice, the
174
+ worktree, the round and the verdict path.
175
+
176
+ ```sh
177
+ node "$KIT/bin/slicekit.js" review start 1 | tee "$WORK/review.txt"
178
+ VERDICT="$(sed -n 's/^verdict //p' "$WORK/review.txt")"
179
+ ```
180
+
181
+ The independent reviewer's verdict is round 2, also an `APPROVE`. `build verdict --independent`
182
+ commits it in the review worktree and pushes it. CI reports on that new head. It still prints
183
+ `rounds: 1 of 2`: round 2 counts all of the slice's verdicts, while `rounds` counts only the two
184
+ review rounds inside `/slicekit build`, and the independent review uses neither of them.
185
+
186
+ ```sh
187
+ cp "$KIT/examples/walkthrough/P1-S-01i-r2.md" "$VERDICT"
188
+ node "$KIT/bin/slicekit.js" build verdict P1/S-01 "$VERDICT" --independent --worktree .worktrees/review-P1-S-01
189
+ node "$KIT/examples/walkthrough/host.js" ci 1 success
190
+ ```
191
+
192
+ `build finish` now prints `ready`: CI is green and the independent verdict is on this head.
193
+
194
+ ```sh
195
+ node "$KIT/bin/slicekit.js" build finish P1/S-01 --worktree .worktrees/review-P1-S-01
196
+ ```
197
+
198
+ ### 8. The merge
199
+
200
+ A human merges. On GitHub you press Merge; here `host.js merge` makes the same merge in the bare
201
+ repository. The merge happened on the remote, and the slice's state is kept in files on `main`, so
202
+ pull `main` first. Then `status --sync` reads the merge from the git host and moves the slice to
203
+ `merged`.
204
+
205
+ ```sh
206
+ node "$KIT/examples/walkthrough/host.js" merge 1
207
+ git pull -q --ff-only
208
+ node "$KIT/bin/slicekit.js" status --sync
209
+ node "$KIT/bin/slicekit.js" status
210
+ ```
211
+
212
+ The last line reads `P1/S-01 merged PR #1 Greet a name`.
213
+
214
+ ### 9. Clean up
215
+
216
+ Unset the two fixture variables. Otherwise a later slicekit command in this shell writes pull
217
+ requests and issues into a deleted folder, instead of calling `gh`. The same line unsets the
218
+ `GIT_CONFIG_*` variables, in case you set them above to turn signing off. Then go back to your
219
+ clone and remove `$WORK`, which holds the project, the bare repository and the fixture directories.
220
+
221
+ ```sh
222
+ unset SLICEKIT_GITHOST_FIXTURE SLICEKIT_TRACKER_FIXTURE GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0
223
+ cd "$KIT"
224
+ rm -rf "$WORK"
225
+ ```
226
+
227
+ ## Scope
228
+
229
+ The kit does not parse source code. Its graph, coming in Phase 3, will be built from its own IDs and
230
+ from git: requirements, decisions, slices, tests, commits, pull requests and releases. It will infer
231
+ no calls or imports. For a code graph,
232
+ [graphify](https://github.com/Graphify-Labs/graphify) or a similar tool sits alongside. This line
233
+ installs graphify and its Claude Code skill:
234
+
235
+ ```sh
236
+ pip install graphifyy && graphify install
237
+ ```
238
+
239
+ Then one Claude Code session runs both: `/graphify .` for the code graph, then `/slicekit build`.
240
+
241
+ ## How the hooks find slicekit
242
+
243
+ `slicekit init` writes the hook command as `node node_modules/slicekit/bin/slicekit.js` when the
244
+ repository has a local install, and `slicekit` otherwise, which needs slicekit on PATH. When neither
245
+ is found, init still writes `slicekit` and warns that the hooks will fail until it is installed; it
246
+ never fetches slicekit from the registry. `cli` in `.slicekit/config.json` (or `init --cli <command>`)
247
+ overrides that choice, and init and update warn when the command does not answer `--version`. The
248
+ usual setup is a local install, `npm i -D slicekit`, before init. To run the kit from a clone
249
+ instead, pass `--cli` to init, as the walkthrough does:
250
+ `--cli "node \"<path-to-kit>/bin/slicekit.js\""`. The
251
+ hooks run from the session's working directory, so a worktree outside the repository tree needs an
252
+ absolute path in `cli` or a global install.
253
+
254
+ License: MIT.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { runProcess } from '../src/cli/process.js';
3
+
4
+ await runProcess(process.argv.slice(2));
package/package.json CHANGED
@@ -1,8 +1,25 @@
1
1
  {
2
2
  "name": "slicekit",
3
- "version": "0.0.1",
4
- "description": "Spec-driven agentic workflow kit for Claude Code. Name reserved; the first release is 0.1.0.",
3
+ "version": "0.1.2",
4
+ "description": "Spec-driven agentic workflow kit",
5
5
  "license": "MIT",
6
- "author": "Aditya Pandya",
7
- "files": ["README.md"]
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/adityapandya1/agentic-slicekit.git"
9
+ },
10
+ "homepage": "https://github.com/adityapandya1/agentic-slicekit#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/adityapandya1/agentic-slicekit/issues"
13
+ },
14
+ "type": "module",
15
+ "bin": {
16
+ "slicekit": "bin/slicekit.js"
17
+ },
18
+ "files": ["bin", "src", "templates"],
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "scripts": {
23
+ "test": "node --test \"test/**/*.test.js\""
24
+ }
8
25
  }
@@ -0,0 +1,17 @@
1
+ // Every failure a git host raises is a GitHostError, so a caller can tell "the host said no"
2
+ // from a bug in the kit. GitHostNotFound is the one a sync may skip past: the host answered,
3
+ // and the thing asked for is not there.
4
+ export class GitHostError extends Error {
5
+ constructor(message, { stderr } = {}) {
6
+ super(message);
7
+ this.name = 'GitHostError';
8
+ if (stderr !== undefined) this.stderr = stderr;
9
+ }
10
+ }
11
+
12
+ export class GitHostNotFound extends GitHostError {
13
+ constructor(message, opts) {
14
+ super(message, opts);
15
+ this.name = 'GitHostNotFound';
16
+ }
17
+ }
@@ -0,0 +1,136 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { GitHostError, GitHostNotFound } from './errors.js';
4
+ import { assertDate, assertSha } from '../../evidence.js';
5
+ import { redact } from '../../redact.js';
6
+ import { assertBranch, assertLabel, assertLabelColor, assertPrNumber, assertTitle, filterMergedSince, mapPullRequest, pickBranchPullRequest, reduceRuns } from './gh-json.js';
7
+
8
+ // The test seam for C-1 (05 REQ-5.2): a directory of gh-shaped JSON files.
9
+ // pr-<n>.json what `gh pr view <n> --json ...` prints
10
+ // merged-since.json what `gh pr list --state merged --json ...` prints (an array)
11
+ // ci-<sha>.json what `gh run list --commit <sha> --json ...` prints (an array)
12
+ // label-error.txt, label-create-error.txt gh refusing `pr edit`, `label create`
13
+ // label-calls.jsonl written: one line per label call, in order
14
+ // pr-create-error.txt gh refusing `pr create`
15
+ // pr-calls.jsonl written: `{op, ...input}` per pull request write (open, update, ready, draft)
16
+ // openPullRequest writes pr-<n>.json (n one above the highest there, else 1); updatePullRequestBody,
17
+ // markReady and markDraft rewrite it, so a later getPullRequest or pullRequestForBranch sees the change.
18
+ // A missing file is what the real host says for "not there"; an unreadable one is a host failure.
19
+ function readJson(file) {
20
+ try {
21
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
22
+ } catch (e) {
23
+ if (e.code === 'ENOENT') return undefined;
24
+ throw new GitHostError(`git host fixture ${file}: ${e.message}`);
25
+ }
26
+ }
27
+
28
+ // Throws what gh would when the fixture holds a refusal for this call.
29
+ function refuse(dir, file, call) {
30
+ let refusal;
31
+ try {
32
+ refusal = fs.readFileSync(path.join(dir, file), 'utf8').trim();
33
+ } catch (e) {
34
+ if (e.code !== 'ENOENT') throw new GitHostError(`git host fixture ${dir}: ${e.message}`);
35
+ }
36
+ if (refusal !== undefined) throw new GitHostError(`${call} failed: ${redact(refusal)}`, { stderr: refusal });
37
+ }
38
+
39
+ const record = (dir, call) => fs.appendFileSync(path.join(dir, 'label-calls.jsonl'), `${JSON.stringify(call)}\n`);
40
+ const recordPr = (dir, call) => fs.appendFileSync(path.join(dir, 'pr-calls.jsonl'), `${JSON.stringify(call)}\n`);
41
+
42
+ // The numbers of the pull requests the fixture holds, ascending.
43
+ function prNumbers(dir) {
44
+ let names;
45
+ try {
46
+ names = fs.readdirSync(dir);
47
+ } catch (e) {
48
+ throw new GitHostError(`git host fixture ${dir}: ${e.message}`);
49
+ }
50
+ return names
51
+ .map((n) => /^pr-(\d+)\.json$/.exec(n)?.[1])
52
+ .filter((n) => n !== undefined)
53
+ .map(Number)
54
+ .sort((a, b) => a - b);
55
+ }
56
+
57
+ const prFile = (dir, n) => path.join(dir, `pr-${n}.json`);
58
+ const writePr = (dir, raw) => fs.writeFileSync(prFile(dir, raw.number), `${JSON.stringify(raw, null, 2)}\n`);
59
+ function readPr(dir, n) {
60
+ const raw = readJson(prFile(dir, n));
61
+ if (raw === undefined) throw new GitHostNotFound(`pull request ${n} not found`);
62
+ return raw;
63
+ }
64
+
65
+ export function fixtureHost(dir) {
66
+ return {
67
+ kind: 'fixture',
68
+ getPullRequest(n) {
69
+ assertPrNumber(n);
70
+ const raw = readJson(path.join(dir, `pr-${n}.json`));
71
+ if (raw === undefined) throw new GitHostNotFound(`pull request ${n} not found`);
72
+ return mapPullRequest(raw);
73
+ },
74
+ listMergedSince(isoDate) {
75
+ const since = assertDate(isoDate);
76
+ return filterMergedSince(readJson(path.join(dir, 'merged-since.json')) ?? [], since);
77
+ },
78
+ ciStatus(sha) {
79
+ assertSha(sha);
80
+ return reduceRuns(readJson(path.join(dir, `ci-${sha}.json`)) ?? []);
81
+ },
82
+ setLabel(n, name, present) {
83
+ assertPrNumber(n);
84
+ assertLabel(name);
85
+ refuse(dir, 'label-error.txt', 'gh pr edit');
86
+ record(dir, { number: n, name, present: Boolean(present) });
87
+ },
88
+ ensureLabel(name, { color, description }) {
89
+ assertLabel(name);
90
+ assertLabelColor(color);
91
+ assertLabel(description);
92
+ refuse(dir, 'label-create-error.txt', 'gh label create');
93
+ record(dir, { create: name, color, description });
94
+ },
95
+ openPullRequest({ branch, base, title, body, draft }) {
96
+ assertBranch(branch);
97
+ assertBranch(base);
98
+ assertTitle(title);
99
+ refuse(dir, 'pr-create-error.txt', 'gh pr create');
100
+ const number = (prNumbers(dir).at(-1) ?? 0) + 1;
101
+ const url = `https://example.test/pull/${number}`;
102
+ const isDraft = Boolean(draft);
103
+ const text = String(body ?? '');
104
+ writePr(dir, { number, url, state: 'OPEN', isDraft, headRefName: branch, baseRefName: base, title, body: text, headRefOid: null, labels: [] });
105
+ recordPr(dir, { op: 'openPullRequest', branch, base, title, body: text, draft: isDraft });
106
+ return { number, url };
107
+ },
108
+ updatePullRequestBody(n, body) {
109
+ assertPrNumber(n);
110
+ const raw = readPr(dir, n);
111
+ const text = String(body ?? '');
112
+ writePr(dir, { ...raw, body: text });
113
+ recordPr(dir, { op: 'updatePullRequestBody', number: n, body: text });
114
+ },
115
+ markReady(n) {
116
+ assertPrNumber(n);
117
+ const raw = readPr(dir, n);
118
+ writePr(dir, { ...raw, isDraft: false });
119
+ recordPr(dir, { op: 'markReady', number: n });
120
+ },
121
+ markDraft(n) {
122
+ assertPrNumber(n);
123
+ const raw = readPr(dir, n);
124
+ writePr(dir, { ...raw, isDraft: true });
125
+ recordPr(dir, { op: 'markDraft', number: n });
126
+ },
127
+ // As the GitHub host: the open pull requests with that head, a fork's (isCrossRepository) dropped.
128
+ pullRequestForBranch(branch, { base } = {}) {
129
+ assertBranch(branch);
130
+ const open = prNumbers(dir)
131
+ .map((n) => readJson(prFile(dir, n)))
132
+ .filter((raw) => raw?.state === 'OPEN');
133
+ return pickBranchPullRequest(open, branch, base);
134
+ },
135
+ };
136
+ }
@@ -0,0 +1,99 @@
1
+ // gh's JSON shapes and the kit's view of them, shared by the GitHub host and the fixture host,
2
+ // so a fixture exercises the same mapping the real host does.
3
+ import { assertRef } from '../../git.js';
4
+
5
+ const OK_CONCLUSIONS = new Set(['success', 'skipped', 'neutral']);
6
+
7
+ export function assertPrNumber(n) {
8
+ if (!Number.isInteger(n) || n < 1) throw new Error(`pull request number must be a positive integer, got ${n}`);
9
+ return n;
10
+ }
11
+
12
+ // A label colour as gh takes it: six hex digits, no '#'.
13
+ export function assertLabelColor(color) {
14
+ if (typeof color !== 'string' || !/^[0-9a-fA-F]{6}$/.test(color)) {
15
+ throw new Error(`label color must be six hex digits, got ${JSON.stringify(color)}`);
16
+ }
17
+ return color;
18
+ }
19
+
20
+ export function assertLabel(name) {
21
+ if (typeof name !== 'string' || name.trim() === '' || /[\r\n]/.test(name)) {
22
+ throw new Error(`label must be a non-empty single-line string, got ${JSON.stringify(name)}`);
23
+ }
24
+ return name;
25
+ }
26
+
27
+ // A branch name as gh's --head takes it: a ref, and never `owner:branch` (git forbids ':' in a branch
28
+ // name, and gh would read it as another repository's branch).
29
+ export function assertBranch(name) {
30
+ assertRef(name);
31
+ if (name.includes(':')) throw new Error(`branch must be a branch of this repository, got ${JSON.stringify(name)}`);
32
+ return name;
33
+ }
34
+
35
+ // A pull request title as gh takes it: one non-empty line.
36
+ export function assertTitle(title) {
37
+ if (typeof title !== 'string' || title.trim() === '' || /[\r\n]/.test(title)) {
38
+ throw new Error(`pull request title must be a non-empty single line, got ${JSON.stringify(title)}`);
39
+ }
40
+ return title;
41
+ }
42
+
43
+ // The number and url gh prints for a pull request it made: the last line holding `/pull/<n>`.
44
+ export function parsePullRequestUrl(out) {
45
+ const line = String(out ?? '')
46
+ .split(/\r?\n/)
47
+ .map((l) => l.trim())
48
+ .reverse()
49
+ .find((l) => /^https?:\/\/\S+\/pull\/\d+$/.test(l));
50
+ if (line === undefined) return null;
51
+ return { number: Number(/\/pull\/(\d+)$/.exec(line)[1]), url: line };
52
+ }
53
+
54
+ // The fields `gh pr list --head` is asked for when finding a branch's pull request.
55
+ export const BRANCH_PR_FIELDS = 'number,url,isCrossRepository,baseRefName,headRefName';
56
+
57
+ // The open pull request of `branch` among `list` (open pull requests), as { number, url, base }, or
58
+ // null. A pull request from a fork has the same head name but is not this repository's branch, so it
59
+ // never matches. Of several, the one into `base` (when given) wins, else the newest.
60
+ export function pickBranchPullRequest(list, branch, base) {
61
+ const same = (Array.isArray(list) ? list : [])
62
+ .filter((p) => p && p.isCrossRepository !== true && p.headRefName === branch && Number.isInteger(p.number))
63
+ .sort((a, b) => b.number - a.number);
64
+ const pr = (base !== undefined && same.find((p) => p.baseRefName === base)) || same[0];
65
+ return pr ? { number: pr.number, url: pr.url, base: pr.baseRefName ?? null } : null;
66
+ }
67
+
68
+ export function mapPullRequest(raw) {
69
+ return {
70
+ number: raw.number,
71
+ url: raw.url,
72
+ state: raw.state,
73
+ mergedAt: raw.mergedAt || null,
74
+ headSha: raw.headRefOid,
75
+ headRef: raw.headRefName ?? null,
76
+ draft: typeof raw.isDraft === 'boolean' ? raw.isDraft : null,
77
+ title: raw.title,
78
+ body: raw.body ?? '',
79
+ labels: (raw.labels ?? []).map((l) => (typeof l === 'string' ? l : l.name)),
80
+ };
81
+ }
82
+
83
+ // `since` is assertDate's result, checked by the host before it spends a call.
84
+ export function filterMergedSince(list, since) {
85
+ return list
86
+ .filter((p) => p.mergedAt && Date.parse(p.mergedAt) >= since)
87
+ .map((p) => ({ number: p.number, mergedAt: p.mergedAt, headSha: p.headRefOid, title: p.title }));
88
+ }
89
+
90
+ // gh lists runs newest first. Any run still going → pending; any completed run that did not
91
+ // succeed (skipped and neutral count as success) → failure; all succeeded → success; none → unknown.
92
+ export function reduceRuns(runs) {
93
+ if (!Array.isArray(runs) || runs.length === 0) return { status: 'unknown', url: null };
94
+ const going = runs.find((r) => r.status !== 'completed');
95
+ if (going) return { status: 'pending', url: going.url ?? null };
96
+ const failed = runs.find((r) => !OK_CONCLUSIONS.has(r.conclusion));
97
+ if (failed) return { status: 'failure', url: failed.url ?? null };
98
+ return { status: 'success', url: runs[0].url ?? null };
99
+ }