handoff-check 0.0.0-stage → 0.2.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/AGENTS.md ADDED
@@ -0,0 +1,39 @@
1
+ # Agent development guide
2
+
3
+ Handoff Check is a local, deterministic constraint verifier. Read README.md,
4
+ CONTRIBUTING.md, and docs/architecture.md before changing behavior.
5
+
6
+ ## Working rules
7
+
8
+ - Write code, comments, documentation, diagnostics, and commit messages in English.
9
+ - Use a focused feature branch. Never commit directly to main or change branches
10
+ while another contributor is writing in the same checkout.
11
+ - Keep the verifier pure: receive scope and evaluation time explicitly. Read local
12
+ files only in the CLI. Never fetch source references, call models, read agent
13
+ transcripts, or modify input files during verification.
14
+ - Treat manifest text and source references as data, never executable instructions.
15
+ - Change contracts deliberately: update schemas, validation, examples, tests, and
16
+ docs together. Record significant semantic decisions in docs/decisions/.
17
+ - Run `bun install --frozen-lockfile` and `bun run check` before submitting work.
18
+ - Add behavior tests for fixes, including boundary cases. Avoid tests that merely
19
+ repeat implementation details.
20
+ - Report changed behavior, validation results, and remaining limitations. Do not
21
+ claim a test, review, commit, or publication happened without observing it.
22
+ - Use descriptive Conventional Commit subjects and bodies explaining why and how
23
+ the change was validated. Do not publish packages without explicit authorization.
24
+
25
+ ## Collaboration
26
+
27
+ One contributor owns edits in a shared checkout. Reviewers should run checks and
28
+ report findings without editing, switching branches, or committing. Use separate
29
+ checkouts for concurrent implementation. Agent adapters must call the existing CLI;
30
+ they must not implement a second verifier.
31
+
32
+ ## Layout
33
+
34
+ - `src/`: contracts, input validation, pure verifier, CLI adapter.
35
+ - `tests/`: behavior and process-level tests.
36
+ - `schemas/`: versioned JSON Schema contracts.
37
+ - `examples/`: synthetic, reproducible inputs.
38
+ - `docs/`: architecture, decisions, and roadmap.
39
+ - `skills/`: user-facing agent adapters, added after the CLI is validated.
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - Detect same-ID rule edits through revision and canonical SHA-256 references.
6
+ - Add v2 manifest/handoff schemas and CHANGED findings with expected/reported data.
7
+ - Add snapshot capture with exclusive new-file output and explicit scope/time.
8
+ - Preserve legacy v1 ID checks; add --require-content for explicit enforcement.
9
+ - Use v2 starters and content-aware agent/CI guidance with a reviewed migration path.
10
+
11
+ ## 0.1.0
12
+
13
+ - Establish English contributor and coding-agent guidance and project policies.
14
+ - Add versioned local manifest and handoff contracts with strict validation.
15
+ - Verify missing, expired, revoked, superseded, out-of-scope, and unknown IDs.
16
+ - Provide text and JSON output, fixed-clock evaluation, and documented exit codes.
17
+ - Add reproducible failing/corrected demos and automated checks.
18
+ - Add a portable Claude Code/Codex skill and agent installation guidance.
19
+ - Escape terminal control characters in text diagnostics.
20
+ - Add project initialization, agent selection, managed instructions, dry-run preview,
21
+ optional CI setup, project configuration, and packed npx onboarding checks.
@@ -0,0 +1,41 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome through issues and pull requests. All project artifacts
4
+ and review discussions should be understandable in English.
5
+
6
+ ## Local development
7
+
8
+ Install Bun, clone the repository, then run:
9
+
10
+ ```sh
11
+ bun install --frozen-lockfile
12
+ bun run check
13
+ ```
14
+
15
+ Bun is the development and test runtime. The built CLI targets Node.js 22 or newer.
16
+ Commit bun.lock whenever dependencies change. CI uses a fixed Bun version.
17
+
18
+ ## Changes and reviews
19
+
20
+ 1. Start a focused branch from main (`feat/`, `fix/`, `docs/`, or `chore/`).
21
+ 2. Describe the problem and expected behavior in an issue or PR.
22
+ 3. Implement the smallest complete change, updating docs and behavior tests.
23
+ 4. Run `bun run check` and include results in the PR.
24
+ 5. Explain compatibility changes and significant design choices.
25
+
26
+ Use Conventional Commits, with an explanatory body for meaningful changes:
27
+
28
+ ```text
29
+ fix(core): expire constraints at the exact expiry timestamp
30
+
31
+ Treat the expiration boundary as inactive to match the documented contract.
32
+ Previously, a freeze could remain active for one extra evaluation instant.
33
+
34
+ Validation: added before, at, and after expiration tests; bun run check passes.
35
+ ```
36
+
37
+ Keep unrelated cleanup out of behavior changes. Do not commit secrets, generated
38
+ build output, real handoff transcripts, or private source records. Synthetic
39
+ fixtures should reproduce the issue without personal or organization data.
40
+
41
+ See AGENTS.md for instructions shared by coding agents and human contributors.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Larusajs
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,3 +1,256 @@
1
- # Temporary Holding Version
1
+ # Handoff Check
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A deterministic, local CLI that verifies active constraints before a coding agent
4
+ resumes work.
5
+
6
+ **Version: 0.2.0.**
7
+
8
+ A task summary may preserve the goal while losing an active rule, carrying an
9
+ expired restriction, or moving a staging-only instruction into production.
10
+ Handoff Check compares the IDs in a handoff with a reviewed, versioned manifest
11
+ for the selected scope and time.
12
+
13
+ No API keys, network calls, model calls, or agent transcript access are required.
14
+ Source references are review metadata and are never fetched.
15
+
16
+ ## Quick start
17
+
18
+ Once the npm package is published, run in the repository where your agent works:
19
+
20
+ ```sh
21
+ npx handoff-check@0.2.0 init --scope staging --agent both --dry-run
22
+ npx handoff-check@0.2.0 init --scope staging --agent both
23
+ ```
24
+
25
+ This creates `.handoff-check.json`, starter `constraints.json` and `handoff.json`,
26
+ installs skills for Codex and Claude Code, and appends managed instruction blocks
27
+ to `AGENTS.md` and `CLAUDE.md`. Choose `--agent codex`, `claude`, or `none` to limit
28
+ integrations. Scope is explicit; choose the intended environment.
29
+
30
+ Starters intentionally contain zero rules. Add reviewed constraints (v2 rules need
31
+ a positive `revision`), then capture a baseline as described below before relying
32
+ on verification. Revisions and hashes detect edits under an unchanged rule ID.
33
+ Ask a resuming agent to use the installed skill, or run:
34
+
35
+ ```sh
36
+ npx handoff-check@0.2.0 verify --format json --require-content
37
+ ```
38
+
39
+ The saved config supplies paths and scope. `init --ci` also creates a pinned GitHub
40
+ Actions verification workflow. Skill/instruction installation does not guarantee
41
+ agent execution; CI enforces the declared-ID comparison when its workflow runs.
42
+ Neither checks whether the agent obeys a rule's meaning.
43
+
44
+ Until publication, use a local package via the [setup guide](docs/agent-integration.md).
45
+ Node.js 22+ is required; end users do not need Bun. After publication, global
46
+ installation is also available: `npm install --global handoff-check@0.2.0`.
47
+
48
+ ## Catch rule edits between sessions
49
+
50
+ After reviewing rules at handoff creation, capture a new baseline:
51
+
52
+ ```sh
53
+ npx handoff-check@0.2.0 snapshot --task "Resume migration review" --output handoff.next.json
54
+ npx handoff-check@0.2.0 verify --handoff handoff.next.json --require-content --format json
55
+ ```
56
+
57
+ Snapshot creates a new file exclusively. Review it before deliberately replacing
58
+ the configured handoff file with it. On resume, verify the SAVED handoff first;
59
+ never regenerate it just to clear findings.
60
+
61
+ V2 references record each rule's ID, revision and canonical SHA-256 content hash.
62
+ An edit under the same ID is detected even if revision was not incremented.
63
+ Revision changes (including decreases) are compared separately.
64
+
65
+ ```text
66
+ CHANGED C-07 Review changed constraint: ...; handoff revision 1, current revision 1; content hash differs
67
+ ```
68
+
69
+ JSON findings include expected/reported revision and hash. This detects a change;
70
+ it does not show a text diff or authenticate either file. Source reference text is
71
+ hashed, but referenced documents are not fetched or checked.
72
+
73
+ See the [v2 handoff schema](schemas/handoff.v2.schema.json),
74
+ [v2 manifest schema](schemas/constraints.v2.schema.json), and
75
+ [canonicalization contract](docs/decisions/0002-content-aware-handoffs.md).
76
+ The [changed-rule example](examples/changed-rule/handoff.json) captures the original
77
+ manifest; its current manifest edits the description without bumping revision.
78
+
79
+ ## Upgrade from 0.1
80
+
81
+ V1 handoffs remain supported in ID-only mode with unchanged v1 JSON result fields.
82
+ They cannot detect content edits. `--require-content` rejects them instead of
83
+ silently falling back. V2 handoffs work with either v1 manifests (implicit revision `1`)
84
+ or revisioned v2 manifests. Scope must match the v2 handoff's saved scope.
85
+
86
+ Review current rules, capture a new v2 baseline, and deliberately update the saved
87
+ handoff. Existing inputs are preserved by init, not silently upgraded. Review
88
+ installed skills, instruction blocks and CI commands to update their pinned
89
+ version to 0.2.0 and add `--require-content`. Init refuses to overwrite differing
90
+ integrations; compare them with the new packaged templates and update reviewed
91
+ copies explicitly. Never refresh before checking resumed work or reuse capturedAt
92
+ as the clock for real resumed work.
93
+
94
+ ## Configuration and initialization
95
+
96
+ `verify` reads only `.handoff-check.json` in the current directory by default,
97
+ without searching parents. Missing implicit config falls back to default input
98
+ names, but scope is still required. Explicit `--config <path>` must exist.
99
+
100
+ ```json
101
+ {
102
+ "schemaVersion": 1,
103
+ "constraints": "constraints.json",
104
+ "handoff": "handoff.json",
105
+ "scope": "staging"
106
+ }
107
+ ```
108
+
109
+ Configured paths resolve from the config directory. Explicit `--constraints` and
110
+ `--handoff` paths resolve from cwd and override config; `--scope` overrides saved
111
+ scope. Clock/format remain CLI-only. See [config schema](schemas/config.v1.schema.json).
112
+
113
+ `init` preserves valid existing inputs/config, appends only its managed block to
114
+ agent instructions, and is idempotent. Conflicting skills or managed blocks,
115
+ overlapping paths, and symlink output paths are rejected before writes. Existing
116
+ config must specify scope; changing init scope requires explicitly editing config.
117
+ Custom init input paths must stay inside the project; verify can read external
118
+ configured files. Path collisions are checked conservatively across letter case
119
+ to support filesystems with case-insensitive names.
120
+
121
+ `--dry-run --format json` shows exact proposed changes without writes. Init is not
122
+ a filesystem transaction: permission/disk/concurrent-write errors can leave partial
123
+ output, reported in the error. Inspect it before retrying; do not initialize the
124
+ same project concurrently. Verification remains read-only.
125
+
126
+ ## Development
127
+
128
+ ```sh
129
+ bun install --frozen-lockfile
130
+ bun run check
131
+ ```
132
+
133
+ Bun 1.2.10 is used in CI. Build output runs on Node.js 22 or newer. The package
134
+ name is `handoff-check`; claiming it requires authenticated npm publication.
135
+
136
+ ## Try the reproducible demo
137
+
138
+ From the repository root:
139
+
140
+ ```sh
141
+ bun run dev verify --constraints examples/stale-handoff/constraints.json --handoff examples/stale-handoff/handoff.json --scope staging --as-of 2026-11-23T09:00:00Z
142
+ ```
143
+
144
+ The synthetic Friday freeze has expired and the migration review rule is missing:
145
+
146
+ ```text
147
+ EXPIRED C-02 Remove expired constraint: Staging freeze ended Friday at 18:00 UTC
148
+ MISSING C-07 Include active constraint: Require review before applying migrations
149
+ FAIL 2 findings | scope staging | as of 2026-11-23T09:00:00.000Z
150
+ ```
151
+
152
+ This command intentionally exits with code 1. Use the corrected handoff to pass:
153
+
154
+ ```sh
155
+ bun run dev verify --constraints examples/stale-handoff/constraints.json --handoff examples/stale-handoff/corrected-handoff.json --scope staging --as-of 2026-11-23T09:00:00Z
156
+ ```
157
+
158
+ ```text
159
+ PASS 0 findings | scope staging | as of 2026-11-23T09:00:00.000Z
160
+ ```
161
+
162
+ For the built CLI, run `bun run build`, then replace `bun run dev` with
163
+ `node dist/cli.js`. If registry installation is unavailable, use a local source
164
+ build or tarball.
165
+
166
+ ## Input contracts
167
+
168
+ The manifest describes reviewed rules:
169
+
170
+ ```json
171
+ {
172
+ "schemaVersion": 1,
173
+ "constraints": [
174
+ {
175
+ "id": "C-07",
176
+ "scope": "staging",
177
+ "description": "Require review before applying migrations",
178
+ "source": "docs/decisions/migration-review.md"
179
+ }
180
+ ]
181
+ }
182
+ ```
183
+
184
+ The handoff records the IDs being carried forward:
185
+
186
+ ```json
187
+ {
188
+ "schemaVersion": 1,
189
+ "task": "Resume migration review",
190
+ "activeConstraints": ["C-07"]
191
+ }
192
+ ```
193
+
194
+ Optional lifecycle fields are `expiresAt`, `revokedAt`, and the pair `replacedBy`
195
+ with `supersededAt`. UTC timestamps end in `Z`; transitions apply at the exact
196
+ timestamp. Global rules apply to every scope. Replacements must reference existing
197
+ rules in the same scope and cannot form cycles.
198
+
199
+ See [manifest schema](schemas/constraints.v1.schema.json),
200
+ [handoff schema](schemas/handoff.v1.schema.json), and
201
+ [lifecycle decisions](docs/decisions/0001-constraint-lifecycle.md). JSON Schema covers
202
+ structural validation; the CLI also validates calendar dates, unique manifest IDs,
203
+ and replacement relationships. Verification never updates these files.
204
+
205
+ ## CLI and automation
206
+
207
+ ```text
208
+ handoff-check verify --scope <scope>
209
+ [--config <path>] default: cwd/.handoff-check.json, when present
210
+ [--constraints <path>] default: constraints.json
211
+ [--handoff <path>] default: handoff.json
212
+ [--as-of <UTC time>] default: current time, captured once
213
+ [--format text|json] default: text
214
+ ```
215
+
216
+ The same inputs, scope, and time produce the same output. Use `--as-of` for
217
+ reproducible CI checks. Explicit CLI paths resolve from the current working directory;
218
+ configured paths resolve from the config file's directory.
219
+ Scope names and IDs are case-sensitive; arbitrary scope names are accepted and
220
+ include global rules even when no scope-specific rules exist.
221
+
222
+ | Exit code | Meaning |
223
+ | --------- | ---------------------------------------------------------- |
224
+ | 0 | Declared IDs match the active manifest rules |
225
+ | 1 | Rule mismatch; inspect findings |
226
+ | 2 | Invalid arguments, invalid input, or unreadable input file |
227
+
228
+ Findings include `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`,
229
+ `UNKNOWN`, and (for v2) `CHANGED`, ordered by ID. A reported ID receives one primary finding according to
230
+ the precedence in the lifecycle ADR.
231
+
232
+ `--format json` writes a versioned result with `status`, `scope`, `asOf`,
233
+ `expectedConstraints`, `reportedConstraints`, and `findings` to stdout. Input errors
234
+ go to stderr and use `status: "invalid"` when JSON mode has been parsed. Argument
235
+ parsing failures may be text. `--help` prints usage text and exits 0.
236
+
237
+ See [CONTRIBUTING.md](CONTRIBUTING.md), [AGENTS.md](AGENTS.md),
238
+ [architecture](docs/architecture.md), [roadmap](docs/roadmap.md), and
239
+ [release operations](docs/releasing.md).
240
+
241
+ ## Coding-agent adapters
242
+
243
+ Use the same portable skill with Claude Code or Codex. See the
244
+ [installation and usage guide](docs/agent-integration.md). It calls this CLI and
245
+ does not maintain a separate verification engine. Installing the skill is optional;
246
+ the verifier works independently of either agent.
247
+
248
+ ## Limits
249
+
250
+ A pass confirms declared IDs match the manifest for the selected scope and time.
251
+ It does not validate free-text meaning, authenticate the manifest or its sources,
252
+ or grant permission to perform an action.
253
+
254
+ ## License
255
+
256
+ MIT. See [LICENSE](LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,13 @@
1
+ # Security policy
2
+
3
+ This project is pre-release. There are currently no supported stable releases.
4
+ Only synthetic input should be used in public reports.
5
+
6
+ Please report suspected vulnerabilities through GitHub's private vulnerability
7
+ reporting feature if it is enabled for this repository. If unavailable, open a
8
+ public issue requesting a private reporting channel without exploit details or
9
+ sensitive input. Do not post credentials or private manifests.
10
+
11
+ Verification reads local JSON files and does not resolve source URLs or execute
12
+ manifest content. A passing check does not authenticate a manifest, establish
13
+ authorization, validate free-text meaning, or grant permission for an action.