codex-harness-kit 0.1.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 +201 -0
- package/README.md +279 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +84 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/check-state.d.ts +4 -0
- package/dist/src/commands/check-state.js +15 -0
- package/dist/src/commands/check-state.js.map +1 -0
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +138 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/validate-harness.d.ts +4 -0
- package/dist/src/commands/validate-harness.js +9 -0
- package/dist/src/commands/validate-harness.js.map +1 -0
- package/dist/src/harness.d.ts +13 -0
- package/dist/src/harness.js +572 -0
- package/dist/src/harness.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/templates.d.ts +16 -0
- package/dist/src/templates.js +208 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/types.d.ts +54 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# codex-harness-kit
|
|
2
|
+
|
|
3
|
+
`codex-harness-kit` is a lightweight CLI plus scaffold for making any repository easier to run with a harness-style Codex workflow.
|
|
4
|
+
|
|
5
|
+
It does not try to become a new agent platform. v1 is intentionally small and only helps with five things:
|
|
6
|
+
|
|
7
|
+
1. state recovery
|
|
8
|
+
2. project memory
|
|
9
|
+
3. decision logging
|
|
10
|
+
4. task contracts
|
|
11
|
+
5. a minimal validation entrypoint
|
|
12
|
+
|
|
13
|
+
## What Problem It Solves
|
|
14
|
+
|
|
15
|
+
Long Codex tasks break down when context lives only in chat history. New threads lose the current goal, scope drifts mid-task, repeated failures trigger more guessing, and important decisions disappear.
|
|
16
|
+
|
|
17
|
+
This toolkit moves the durable parts of the workflow into repository files so a new thread can recover context from the repo itself before writing code.
|
|
18
|
+
|
|
19
|
+
## Why It Fits Long Tasks and Multi-Thread Collaboration
|
|
20
|
+
|
|
21
|
+
The harness files make the repo readable by both humans and Codex:
|
|
22
|
+
|
|
23
|
+
- `docs/harness-state.json` stores the current goal, status, blockers, contract, and last verification result.
|
|
24
|
+
- `docs/project-memory.md` stores durable preferences and recurring pitfalls.
|
|
25
|
+
- `docs/decisions.md` stores explicit trade-offs and decisions.
|
|
26
|
+
- `docs/contracts/` stores task contracts with acceptance and validation notes.
|
|
27
|
+
- `AGENTS.md` is the active instruction source. In repos that already have a custom `AGENTS.md`, the tool adds a small activation bridge there and writes the detailed harness rules to `AGENTS.harness.md`.
|
|
28
|
+
|
|
29
|
+
That means a new thread can start with repository context instead of trying to reconstruct intent from old messages.
|
|
30
|
+
|
|
31
|
+
## Non-Goals
|
|
32
|
+
|
|
33
|
+
v1 deliberately does not include:
|
|
34
|
+
|
|
35
|
+
- multi-agent orchestration
|
|
36
|
+
- a background daemon
|
|
37
|
+
- a web UI
|
|
38
|
+
- a database
|
|
39
|
+
- cloud services
|
|
40
|
+
- automatic file watching
|
|
41
|
+
- plugin or MCP ecosystems
|
|
42
|
+
- a new chat interface
|
|
43
|
+
|
|
44
|
+
## Install and Run
|
|
45
|
+
|
|
46
|
+
This repository is npm-ready. If you are using the source repo directly, use the local development path below. After the package is published, the npm install path becomes available.
|
|
47
|
+
|
|
48
|
+
Published package, after release:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx codex-harness-kit init
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Local development from this repository:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install
|
|
58
|
+
npm run build
|
|
59
|
+
node dist/src/cli.js --help
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or link the local checkout:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm link
|
|
66
|
+
codex-harness-kit --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## CLI Commands
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
codex-harness-kit init [path] [--force]
|
|
73
|
+
codex-harness-kit check-state [path]
|
|
74
|
+
codex-harness-kit validate-harness [path]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `init`
|
|
78
|
+
|
|
79
|
+
Generates the minimal harness files in the current directory or a target path.
|
|
80
|
+
|
|
81
|
+
Files created by default:
|
|
82
|
+
|
|
83
|
+
- `AGENTS.md`
|
|
84
|
+
- `docs/harness-config.json`
|
|
85
|
+
- `docs/harness-state.json`
|
|
86
|
+
- `docs/project-memory.md`
|
|
87
|
+
- `docs/decisions.md`
|
|
88
|
+
- `docs/contracts/README.md`
|
|
89
|
+
- `docs/contracts/example-contract.md`
|
|
90
|
+
|
|
91
|
+
When the target repo already has its own `AGENTS.md`, `init` also writes:
|
|
92
|
+
|
|
93
|
+
- `AGENTS.harness.md`
|
|
94
|
+
|
|
95
|
+
Safety behavior:
|
|
96
|
+
|
|
97
|
+
- Existing files are not overwritten by default.
|
|
98
|
+
- Re-running `init` is safe and mostly results in `unchanged` or `skipped` outcomes.
|
|
99
|
+
- If the target repo already has an `AGENTS.md`, this tool preserves the existing content and appends a marker-based activation bridge to that file.
|
|
100
|
+
- In that same case, the detailed harness rules are written to `AGENTS.harness.md`.
|
|
101
|
+
- Re-running `init` does not duplicate the bridge block.
|
|
102
|
+
- Use `--force` only when you explicitly want harness-managed files overwritten.
|
|
103
|
+
|
|
104
|
+
### `check-state`
|
|
105
|
+
|
|
106
|
+
Reads the harness config and state, then prints a concise summary:
|
|
107
|
+
|
|
108
|
+
- current goal
|
|
109
|
+
- current status
|
|
110
|
+
- current contract
|
|
111
|
+
- blockers
|
|
112
|
+
- most recent verification result
|
|
113
|
+
- next step suggestion
|
|
114
|
+
|
|
115
|
+
If files are missing or invalid, it prints a clear error plus a recovery hint.
|
|
116
|
+
|
|
117
|
+
### `validate-harness`
|
|
118
|
+
|
|
119
|
+
Checks that the key harness files exist, required JSON is valid, required fields are present, and the harness is actually activated in `AGENTS.md`.
|
|
120
|
+
|
|
121
|
+
It does not stop at marker detection. The validator also checks that the codex-harness-kit bridge block and harness block still contain non-empty, recognizable activation/workflow content.
|
|
122
|
+
|
|
123
|
+
That means `validate-harness` now fails when:
|
|
124
|
+
|
|
125
|
+
- there is a plain `AGENTS.md` with no codex-harness-kit block
|
|
126
|
+
- `AGENTS.harness.md` exists but `AGENTS.md` does not bridge or merge it
|
|
127
|
+
- the bridge exists but the harness supplement file is missing or malformed
|
|
128
|
+
- the bridge or harness markers still exist, but their actual instructions were hand-edited away and left as empty shells
|
|
129
|
+
|
|
130
|
+
## Initialize an Empty Repo
|
|
131
|
+
|
|
132
|
+
Fastest first-use path after installation:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
codex-harness-kit init
|
|
136
|
+
codex-harness-kit check-state
|
|
137
|
+
codex-harness-kit validate-harness
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Inside the target repository:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
codex-harness-kit init
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or from elsewhere:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
codex-harness-kit init /path/to/repo
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Initialize an Existing Repo
|
|
153
|
+
|
|
154
|
+
Run the same `init` command in the existing repo.
|
|
155
|
+
|
|
156
|
+
If the repo already has its own `AGENTS.md`, the tool:
|
|
157
|
+
|
|
158
|
+
1. preserves the existing content
|
|
159
|
+
2. appends a clearly marked codex-harness-kit activation bridge to `AGENTS.md`
|
|
160
|
+
3. writes the detailed harness workflow to `AGENTS.harness.md`
|
|
161
|
+
|
|
162
|
+
This keeps the repo safe and readable while still making the harness an active instruction source instead of an ignored sidecar.
|
|
163
|
+
|
|
164
|
+
## What Counts as "Harness Activated"
|
|
165
|
+
|
|
166
|
+
The harness is considered activated only when `AGENTS.md` explicitly includes codex-harness-kit instructions.
|
|
167
|
+
|
|
168
|
+
There are two valid states:
|
|
169
|
+
|
|
170
|
+
1. `AGENTS.md` contains the full codex-harness-kit harness block.
|
|
171
|
+
2. `AGENTS.md` contains the codex-harness-kit bridge block and that bridge points to a valid `AGENTS.harness.md`.
|
|
172
|
+
|
|
173
|
+
Having an unrelated `AGENTS.md` file is not enough. Having only `AGENTS.harness.md` is not enough either.
|
|
174
|
+
|
|
175
|
+
## What to Tell Codex After Initialization
|
|
176
|
+
|
|
177
|
+
These prompts are intentionally simple. The harness files carry the durable details.
|
|
178
|
+
|
|
179
|
+
Minimal examples:
|
|
180
|
+
|
|
181
|
+
- `恢复状态并继续`
|
|
182
|
+
- `先更新 contract,再实现`
|
|
183
|
+
- `先别改代码,告诉我当前阻塞`
|
|
184
|
+
- `把这个决定记进项目记忆`
|
|
185
|
+
|
|
186
|
+
Equivalent English examples:
|
|
187
|
+
|
|
188
|
+
- `Restore state and continue.`
|
|
189
|
+
- `Update the contract first, then implement.`
|
|
190
|
+
- `Do not change code yet; tell me the current blockers.`
|
|
191
|
+
- `Write this decision into project memory.`
|
|
192
|
+
|
|
193
|
+
## Recommended Codex Workflow
|
|
194
|
+
|
|
195
|
+
1. Start by restoring state from the harness files.
|
|
196
|
+
2. Update the contract if scope or acceptance changed.
|
|
197
|
+
3. Implement only the scoped task.
|
|
198
|
+
4. Run the smallest meaningful validation command.
|
|
199
|
+
5. Update state, memory, or decisions before ending the thread.
|
|
200
|
+
|
|
201
|
+
## Customizing Validation Commands
|
|
202
|
+
|
|
203
|
+
Edit `docs/harness-config.json` after initialization:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"commands": {
|
|
208
|
+
"verifyQuick": "npm test",
|
|
209
|
+
"verifyFull": "npm run verify",
|
|
210
|
+
"docsGenerate": ""
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`check-state` and the `AGENTS` rules assume these commands describe the repo's minimal and fuller validation steps.
|
|
216
|
+
|
|
217
|
+
## Path Configuration and Recovery
|
|
218
|
+
|
|
219
|
+
The fixed entrypoint is `docs/harness-config.json`.
|
|
220
|
+
|
|
221
|
+
The `AGENTS` instructions intentionally tell Codex to read that config first, then follow:
|
|
222
|
+
|
|
223
|
+
- `paths.stateFile`
|
|
224
|
+
- `paths.memoryFile`
|
|
225
|
+
- `paths.decisionsFile`
|
|
226
|
+
- `paths.contractsDir`
|
|
227
|
+
|
|
228
|
+
So if you later move the state or memory files, update `docs/harness-config.json` and the harness instructions still hold. The active contract path in the state file should also be updated if contract files move.
|
|
229
|
+
|
|
230
|
+
## If Initialization Did Not Activate the Harness
|
|
231
|
+
|
|
232
|
+
Run:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
codex-harness-kit validate-harness
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
If validation fails on activation:
|
|
239
|
+
|
|
240
|
+
1. rerun `codex-harness-kit init`
|
|
241
|
+
2. check that `AGENTS.md` contains the codex-harness-kit block or bridge markers
|
|
242
|
+
3. if the repo uses a bridge, check that `AGENTS.harness.md` exists and still contains the harness-managed block
|
|
243
|
+
|
|
244
|
+
## Using It in Other Projects
|
|
245
|
+
|
|
246
|
+
Until this package is published, the simplest options are:
|
|
247
|
+
|
|
248
|
+
1. clone this repo
|
|
249
|
+
2. run `npm install && npm run build`
|
|
250
|
+
3. use `node /path/to/codex-harness-kit/dist/src/cli.js init /path/to/target-repo`
|
|
251
|
+
|
|
252
|
+
Or link it globally with `npm link`.
|
|
253
|
+
|
|
254
|
+
## Assumptions in v1
|
|
255
|
+
|
|
256
|
+
- The default layout uses `docs/` because it stays readable in ordinary repos.
|
|
257
|
+
- JSON stays intentionally small and explicit instead of introducing a DSL.
|
|
258
|
+
- Validation commands are configured by the repository owner; the toolkit does not guess them.
|
|
259
|
+
|
|
260
|
+
## Development
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
npm run build
|
|
264
|
+
npm run typecheck
|
|
265
|
+
npm test
|
|
266
|
+
npm run verify
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`npm run verify` currently runs:
|
|
270
|
+
|
|
271
|
+
1. TypeScript typecheck
|
|
272
|
+
2. build
|
|
273
|
+
3. Node built-in tests
|
|
274
|
+
|
|
275
|
+
## Current Limitations
|
|
276
|
+
|
|
277
|
+
- `check-state` summarizes the active contract path and title, but it does not parse acceptance criteria yet.
|
|
278
|
+
- `validate-harness` only validates the minimal v1 file set.
|
|
279
|
+
- The CLI does not edit state or contracts for you; it scaffolds and validates the workflow.
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { initializeHarness, renderInitResult } from "./commands/init.js";
|
|
5
|
+
import { runCheckState } from "./commands/check-state.js";
|
|
6
|
+
import { runValidateHarness } from "./commands/validate-harness.js";
|
|
7
|
+
export async function runCli(argv = process.argv.slice(2)) {
|
|
8
|
+
const [command, ...rest] = argv;
|
|
9
|
+
if (!command || command === "--help" || command === "-h") {
|
|
10
|
+
process.stdout.write(`${renderHelp()}\n`);
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
const parsed = parseArgs(rest);
|
|
14
|
+
const targetPath = parsed.positionals[0];
|
|
15
|
+
switch (command) {
|
|
16
|
+
case "init": {
|
|
17
|
+
const result = await initializeHarness({
|
|
18
|
+
targetPath,
|
|
19
|
+
force: parsed.flags.has("force")
|
|
20
|
+
});
|
|
21
|
+
process.stdout.write(`${renderInitResult(result)}\n`);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
case "check-state": {
|
|
25
|
+
const result = await runCheckState(targetPath ?? process.cwd());
|
|
26
|
+
const stream = result.ok ? process.stdout : process.stderr;
|
|
27
|
+
stream.write(`${result.output}\n`);
|
|
28
|
+
return result.ok ? 0 : 1;
|
|
29
|
+
}
|
|
30
|
+
case "validate-harness": {
|
|
31
|
+
const result = await runValidateHarness(targetPath ?? process.cwd());
|
|
32
|
+
const stream = result.ok ? process.stdout : process.stderr;
|
|
33
|
+
stream.write(`${result.output}\n`);
|
|
34
|
+
return result.ok ? 0 : 1;
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
process.stderr.write(`Unknown command: ${command}\n\n${renderHelp()}\n`);
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function parseArgs(argv) {
|
|
42
|
+
const positionals = [];
|
|
43
|
+
const flags = new Set();
|
|
44
|
+
for (const arg of argv) {
|
|
45
|
+
if (arg.startsWith("--")) {
|
|
46
|
+
flags.add(arg.slice(2));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
positionals.push(arg);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { positionals, flags };
|
|
53
|
+
}
|
|
54
|
+
function renderHelp() {
|
|
55
|
+
return `codex-harness-kit
|
|
56
|
+
|
|
57
|
+
Usage:
|
|
58
|
+
codex-harness-kit init [path] [--force]
|
|
59
|
+
codex-harness-kit check-state [path]
|
|
60
|
+
codex-harness-kit validate-harness [path]
|
|
61
|
+
|
|
62
|
+
Commands:
|
|
63
|
+
init Generate the minimal harness files for a repository.
|
|
64
|
+
check-state Read the harness files and print a concise status summary.
|
|
65
|
+
validate-harness Validate required harness files and JSON structure.`;
|
|
66
|
+
}
|
|
67
|
+
const isDirectExecution = isExecutedDirectly();
|
|
68
|
+
if (isDirectExecution) {
|
|
69
|
+
runCli().then((code) => {
|
|
70
|
+
process.exitCode = code;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function isExecutedDirectly() {
|
|
74
|
+
if (process.argv[1] === undefined) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return fileURLToPath(import.meta.url) === process.argv[1];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAOpE,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAEhC,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC;IACX,CAAC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;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildStateSummary, renderValidationReport, validateHarness } from "../harness.js";
|
|
2
|
+
export async function runCheckState(repoRoot) {
|
|
3
|
+
const report = await validateHarness(repoRoot);
|
|
4
|
+
if (!report.ok) {
|
|
5
|
+
return {
|
|
6
|
+
ok: false,
|
|
7
|
+
output: `${renderValidationReport(report)}\n\nFix the errors above, then rerun \`codex-harness-kit check-state\`.`
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
ok: true,
|
|
12
|
+
output: await buildStateSummary(repoRoot)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=check-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-state.js","sourceRoot":"","sources":["../../../src/commands/check-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3F,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,GAAG,sBAAsB,CAAC,MAAM,CAAC,yEAAyE;SACnH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,MAAM,iBAAiB,CAAC,QAAQ,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InitResult } from "../types.js";
|
|
2
|
+
export interface InitOptions {
|
|
3
|
+
targetPath?: string;
|
|
4
|
+
force?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function initializeHarness(options?: InitOptions): Promise<InitResult>;
|
|
7
|
+
export declare function renderInitResult(result: InitResult): string;
|