shipcraft 0.0.0-stage → 2.16.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 +202 -0
- package/README.md +203 -2
- package/bin/shipcraft.js +25 -0
- package/package.json +14 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,204 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shipcraft
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A seatbelt for test-driven development with coding agents.**
|
|
4
|
+
|
|
5
|
+
Code is cheap now. Judgment isn't. Shipcraft makes sure the judgment you put into a test can't be quietly undone by the code that is supposed to satisfy it, and it stays out of the way the rest of the time.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
$ git commit -m "fix rounding"
|
|
9
|
+
shipcraft refused: locked test tests/test_invoice.py changed after RED (index)
|
|
10
|
+
Why: RED is the contract: GREEN changes the code, not the test that judges it
|
|
11
|
+
Next: undo the change in tests/test_invoice.py; if the test looks wrong, stop and tell the RED author
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why
|
|
17
|
+
|
|
18
|
+
A coding agent asked to make a failing test pass has two ways to do it: fix the code, or "fix" the test. Most of the time it fixes the code. Sometimes, under pressure from a hard bug, a confusing assertion or a long session, it edits the assertion, skips the case, deletes the file, or changes the runner config so the suite goes green. Every one of those looks like progress in the diff summary.
|
|
19
|
+
|
|
20
|
+
Prose rules in `AGENTS.md` ("never edit the tests") help, but nothing enforces them. Shipcraft turns that rule into a mechanical check that runs where agents can't argue with it: in the git hook and again in CI.
|
|
21
|
+
|
|
22
|
+
## How it works
|
|
23
|
+
|
|
24
|
+
Work is split into two roles, and they should be different agents (or an agent and you):
|
|
25
|
+
|
|
26
|
+
- **RED** writes the tests that describe the change and runs `shipcraft red`. Shipcraft runs the suite, requires it to **fail on assertions**, and writes a **lock** with a hash of every test file, the config and the failing cases. The lock is committed with the tests.
|
|
27
|
+
- **GREEN** writes the code. While the lock is open, any commit that changes, deletes or skips a locked test, or touches the config, is refused. The first commit where every locked case passes **closes the lock by itself**.
|
|
28
|
+
|
|
29
|
+
```mermaid
|
|
30
|
+
flowchart LR
|
|
31
|
+
A[RED writes tests] --> B["shipcraft red<br/>suite must fail"]
|
|
32
|
+
B --> C[lock committed: open]
|
|
33
|
+
C --> D[GREEN writes code]
|
|
34
|
+
D --> E{git commit}
|
|
35
|
+
E -- locked test changed --> F[refused, 3 lines]
|
|
36
|
+
F --> D
|
|
37
|
+
E -- locked cases still red --> D
|
|
38
|
+
E -- all locked cases pass --> G[lock closes in a commit right after]
|
|
39
|
+
G --> H["shipcraft pr<br/>CI + review"]
|
|
40
|
+
H --> I["shipcraft merge"]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The hook only runs the locked cases, so commits stay fast. `shipcraft ci` then repeats every check on every commit of the branch, from a clean checkout, and runs the full suite. A commit made with `--no-verify` or with an edited hook is caught there.
|
|
44
|
+
|
|
45
|
+
Every refusal is three lines: **what happened, why it matters, and the next step**. Most "Next" lines contain the exact command to run, so an agent that has never heard of Shipcraft can recover on its own.
|
|
46
|
+
|
|
47
|
+
## What it guarantees, and what it doesn't
|
|
48
|
+
|
|
49
|
+
**It guarantees** that a branch cannot reach your main through `shipcraft merge` (or through required status checks on GitHub) if any commit changed, removed or skipped a test that was locked at RED, or changed the config that decides how tests run, while the lock was open.
|
|
50
|
+
|
|
51
|
+
**The threat model is the honest agent that makes mistakes or takes shortcuts.** It is not an adversary rewriting Shipcraft itself. Shipcraft does not sandbox anything, and a determined human with admin rights can always merge around it. When that happens, `shipcraft ci` on main reports the merges that skipped the gate.
|
|
52
|
+
|
|
53
|
+
**It does not judge whether your tests are good.** That's the RED's job, and the review layer's. Shipcraft protects the judgment once it has been made.
|
|
54
|
+
|
|
55
|
+
## Quick start
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# A Node/TypeScript project (macOS): pin Shipcraft in the project, like any dev dependency
|
|
59
|
+
pnpm add -D shipcraft # or: npm i -D shipcraft
|
|
60
|
+
pnpm exec shipcraft init # the hooks call this project's install
|
|
61
|
+
|
|
62
|
+
# macOS (Apple silicon or Intel), any language: the latest release, checksum-verified, into ~/.local/bin
|
|
63
|
+
gh repo clone victorassisalves/shipcraft && bash shipcraft/install.sh
|
|
64
|
+
|
|
65
|
+
# or build from source (macOS or Linux, Rust toolchain)
|
|
66
|
+
git clone https://github.com/victorassisalves/shipcraft && cd shipcraft
|
|
67
|
+
cargo install --path nucleo
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`install.sh --version <v>` pins a version and `install.sh --uninstall` removes the binary. It needs `gh` logged in.
|
|
71
|
+
|
|
72
|
+
Then, in your project:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
shipcraft init # detects the language, writes .shipcraft.toml, wires the hook
|
|
76
|
+
git add .shipcraft.toml && git commit -m "add shipcraft"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A cycle:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# RED: write the failing tests, then lock them
|
|
83
|
+
shipcraft red
|
|
84
|
+
git add -A && git commit -m "red: invoice rounding"
|
|
85
|
+
|
|
86
|
+
# GREEN: write the code; commit as often as you like
|
|
87
|
+
git commit -am "fix rounding" # the lock closes on the first fully green commit
|
|
88
|
+
|
|
89
|
+
# open the PR: CI and review run, and their statuses are published
|
|
90
|
+
shipcraft pr --title "Invoice rounding"
|
|
91
|
+
|
|
92
|
+
# merge only when both are green
|
|
93
|
+
shipcraft merge 42
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`shipcraft status` shows the open locks and how protected the repository really is.
|
|
97
|
+
|
|
98
|
+
## Commands
|
|
99
|
+
|
|
100
|
+
| Command | What it does |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `shipcraft init [--lang python\|node\|go] [--github]` | Detects the language and test runner, writes `.shipcraft.toml`, and wires the hook into your hook manager. |
|
|
103
|
+
| `shipcraft --version` | Prints the version and build commit. |
|
|
104
|
+
| `shipcraft red` | Runs the suite, requires assertion failures, and writes the lock in `.shipcraft/locks/<id>.json`. |
|
|
105
|
+
| `shipcraft check [--commit-msg <file>]` | Called by the hook. Judges the commit being made against open locks and closes a lock when its cases pass. |
|
|
106
|
+
| `shipcraft close` | Closes a lock in its own commit; the post-commit hook runs it, and you can run it by hand. |
|
|
107
|
+
| `shipcraft ci --base <ref> [--pr]` | Re-checks every commit in `<ref>..HEAD` and runs the full suite on HEAD. Runs locally or in GitHub Actions. |
|
|
108
|
+
| `shipcraft pr [--title <t>] [--body <file>]` | Pushes the branch, opens or updates the PR, runs CI and review, and publishes the `shipcraft/ci` and `shipcraft/review` statuses. |
|
|
109
|
+
| `shipcraft review [--pr <n>]` | Runs the review on the local HEAD (to catch blockers before opening the PR) or on any PR. |
|
|
110
|
+
| `shipcraft merge <pr> [--no-review "<reason>"]` | Merges only when CI and review are green on the PR's head. `--no-review "<reason>"` is the recorded way out, and the reason shows up in the PR and in the numbers. |
|
|
111
|
+
| `shipcraft status` | The open locks, and how protected the repository really is (branch protection or only `shipcraft merge`). |
|
|
112
|
+
|
|
113
|
+
## Languages, runners and hook managers
|
|
114
|
+
|
|
115
|
+
| | Supported |
|
|
116
|
+
|---|---|
|
|
117
|
+
| Languages | Python, TypeScript/JavaScript, Go, and any runner that writes JUnit XML through a generic suite |
|
|
118
|
+
| Runners | pytest, vitest, jest, `go test` / gotestsum, anything else via `[[suite]]` |
|
|
119
|
+
| Hook managers | plain git hooks, lefthook, husky, pre-commit |
|
|
120
|
+
| Repositories | single package or monorepo (several `[[suite]]` entries), TypeScript project references (`[build]`) |
|
|
121
|
+
| CI | local (on your machine, no runner needed) or GitHub Actions |
|
|
122
|
+
| Review | a separate agent session: Codex, Claude or Gemini CLI |
|
|
123
|
+
|
|
124
|
+
When `init` finds a hook manager, it integrates with it instead of overwriting it. Shipcraft never edits your test files, your runner config or your existing hooks.
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
`shipcraft init` writes `.shipcraft.toml`. In `command`, `{junit}` is replaced by the path where the runner writes its JUnit report. A typical file:
|
|
129
|
+
|
|
130
|
+
```toml
|
|
131
|
+
shipcraft_min = "2.0"
|
|
132
|
+
|
|
133
|
+
[[suite]]
|
|
134
|
+
name = "api"
|
|
135
|
+
root = "packages/api"
|
|
136
|
+
command = "npx --no -- vitest run --reporter=junit --outputFile={junit}"
|
|
137
|
+
globs = ["**/*.test.ts", "vitest.config.*"]
|
|
138
|
+
|
|
139
|
+
[execution]
|
|
140
|
+
ci = "local" # local | github | off
|
|
141
|
+
review = "local" # local | off
|
|
142
|
+
|
|
143
|
+
[roles]
|
|
144
|
+
review = "codex" # codex | claude | gemini
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Two rules keep the config honest:
|
|
148
|
+
|
|
149
|
+
- **The config is part of the lock.** It can't change while a lock is open.
|
|
150
|
+
- **A PR is judged by the config on the base branch,** not by its own. A PR can't switch off its own review.
|
|
151
|
+
|
|
152
|
+
**Adding a package with a new suite.** Once the base branch has a `.shipcraft.toml`, a `[[suite]]` added in the same PR as its first tests doesn't run in CI, and `shipcraft ci` refuses its locked cases as missing. Bring the suite first, in a PR of its own: the package, its `[[suite]]` entry and one passing test. Once that's merged, rebase and write the RED. `shipcraft red` warns when changed test files match no suite's globs, or when the lock has cases in a suite the base doesn't have.
|
|
153
|
+
|
|
154
|
+
A layer that is switched off is labeled "off in .shipcraft.toml" on every PR, so nobody mistakes it for a check that ran.
|
|
155
|
+
|
|
156
|
+
## The layers
|
|
157
|
+
|
|
158
|
+
| Layer | When it runs | What it catches |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| Hook | every commit | edits to locked tests or config, skipped or missing cases; closes the lock when green |
|
|
161
|
+
| CI | every PR | everything the hook checks, on every commit, from a clean checkout, plus the full suite |
|
|
162
|
+
| Review | every PR, after CI is green | a different agent reads the diff against the spec and the PR body, and runs its own checks. A blocker counts only if the reviewer reproduced it and it breaks a quoted spec rule or crashes. Errors, timeouts and quota failures are never an approval. |
|
|
163
|
+
| Merge gate | `shipcraft merge` | refuses unless CI and review are green on the PR head |
|
|
164
|
+
|
|
165
|
+
A PR that changes only docs (a `*.md` at the root, or anything under `docs/`) still gets every commit checked, but skips the build and the suites, so specs and docs reach main in seconds. Any doubt, such as a Markdown file a suite reads as a test, runs everything.
|
|
166
|
+
|
|
167
|
+
On a public repository (or a paid GitHub plan), `shipcraft init --github` also marks both statuses as required, so the platform enforces the gate too.
|
|
168
|
+
|
|
169
|
+
## Measured, not asserted
|
|
170
|
+
|
|
171
|
+
Shipcraft records every hook, CI and review run in `.git/shipcraft/runs.jsonl`: layer, result, refusal code and time. Nothing is sent anywhere. `shipcraft pr` puts the branch's numbers in the PR summary. `shipcraft report` reads the same log and gives, per lock, the times from RED to close and to merge, with daily runs, refusals and hook times (`--json` for scripts).
|
|
172
|
+
|
|
173
|
+
Every rule in Shipcraft has to pay for itself. It ships with the metric that justifies it and the condition that removes it. Rules that don't catch anything in practice get deleted.
|
|
174
|
+
|
|
175
|
+
## Working with coding agents
|
|
176
|
+
|
|
177
|
+
Agents don't need a plugin, an MCP server or a skill. They find Shipcraft the same way they find every other project constraint:
|
|
178
|
+
|
|
179
|
+
- `git commit` runs the hook, and refusals say exactly what to do next;
|
|
180
|
+
- `shipcraft init` writes a short block in `AGENTS.md` that tells agents to run `shipcraft red` after writing tests. In our trials (four runs per arm, a small sample) this took agents from 0/4 to 4/4 running `shipcraft red` before the first commit.
|
|
181
|
+
|
|
182
|
+
Give the RED and the GREEN to different sessions. They can be the same model; separate context is what matters.
|
|
183
|
+
|
|
184
|
+
## Status and limits
|
|
185
|
+
|
|
186
|
+
Shipcraft 2 is a rewrite of an earlier internal version, built and measured in public from here on.
|
|
187
|
+
|
|
188
|
+
- **Binaries:** prebuilt for macOS (Apple silicon and Intel) through `install.sh`; on Linux, build from source with `cargo install --path nucleo`.
|
|
189
|
+
- **Windows:** not supported.
|
|
190
|
+
- **Fork PRs** are refused by the local review. The good-faith model doesn't hold for code from outside.
|
|
191
|
+
- **Not yet:** a hosted review layer (`review = "github"`), and other CI providers.
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
cargo build --release --manifest-path nucleo/Cargo.toml -j 4
|
|
197
|
+
bash acceptance/run.sh nucleo/target/release/shipcraft all # the full acceptance battery
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Shipcraft is developed with Shipcraft: specs in `docs/`, RED and GREEN by separate agents, and every change gated by the battery and a review.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
[Apache License 2.0](LICENSE)
|
package/bin/shipcraft.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The `shipcraft` command of the npm package: runs the native binary from the
|
|
3
|
+
// platform package npm or pnpm installed next to it (optionalDependencies).
|
|
4
|
+
'use strict';
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const pkg = `shipcraft-${process.platform}-${process.arch}`;
|
|
8
|
+
let bin;
|
|
9
|
+
try {
|
|
10
|
+
bin = require.resolve(`${pkg}/bin/shipcraft`);
|
|
11
|
+
} catch {
|
|
12
|
+
console.error(
|
|
13
|
+
`shipcraft: no binary for ${process.platform}-${process.arch} (package ${pkg} is not installed).\n` +
|
|
14
|
+
'Packages exist for macOS (darwin-arm64, darwin-x64); elsewhere build from source: ' +
|
|
15
|
+
'https://github.com/victorassisalves/shipcraft#quick-start'
|
|
16
|
+
);
|
|
17
|
+
process.exit(2);
|
|
18
|
+
}
|
|
19
|
+
const run = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
20
|
+
if (run.error) {
|
|
21
|
+
console.error(`shipcraft: could not run ${bin}: ${run.error.message}`);
|
|
22
|
+
process.exit(2);
|
|
23
|
+
}
|
|
24
|
+
if (run.signal) process.kill(process.pid, run.signal);
|
|
25
|
+
process.exit(run.status === null ? 1 : run.status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shipcraft",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "2.16.0",
|
|
4
|
+
"description": "A seatbelt for test-driven development with coding agents: locks the tests at RED so GREEN cannot quietly undo them.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": { "type": "git", "url": "git+https://github.com/victorassisalves/shipcraft.git" },
|
|
7
|
+
"homepage": "https://github.com/victorassisalves/shipcraft",
|
|
8
|
+
"keywords": ["tdd", "testing", "git-hooks", "coding-agents", "ci"],
|
|
9
|
+
"bin": { "shipcraft": "bin/shipcraft.js" },
|
|
10
|
+
"files": ["bin/shipcraft.js", "LICENSE", "README.md"],
|
|
11
|
+
"engines": { "node": ">=18" },
|
|
12
|
+
"optionalDependencies": {
|
|
13
|
+
"shipcraft-darwin-arm64": "2.16.0",
|
|
14
|
+
"shipcraft-darwin-x64": "2.16.0"
|
|
15
|
+
}
|
|
16
|
+
}
|