@cardor/agent-harness-kit 1.8.1 → 1.10.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 +80 -58
- package/README.md +126 -44
- package/dist/agent-templates/builder.md +13 -0
- package/dist/{chunk-OEPZRC7J.js → chunk-ADV7OPU2.js} +4 -1
- package/dist/chunk-ADV7OPU2.js.map +1 -0
- package/dist/chunk-DNFFWQWR.js +821 -0
- package/dist/chunk-DNFFWQWR.js.map +1 -0
- package/dist/cli.js +952 -905
- package/dist/cli.js.map +1 -1
- package/dist/dashboard-dist/assets/index-CyU-X1yO.js +9 -0
- package/dist/dashboard-dist/assets/index-CzEB2a6I.css +1 -0
- package/dist/dashboard-dist/index.html +2 -2
- package/dist/db-QQ7BR5K7.js +23 -0
- package/dist/db-QQ7BR5K7.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/skills/ahk-review/SKILL.md +45 -0
- package/dist/{sqlite-KWYK4IJW.js → sqlite-TR4D324R.js} +5 -5
- package/dist/{sqlite-KWYK4IJW.js.map → sqlite-TR4D324R.js.map} +1 -1
- package/package.json +3 -2
- package/dist/chunk-OEPZRC7J.js.map +0 -1
- package/dist/dashboard-dist/assets/index-6UCLKb-M.css +0 -1
- package/dist/dashboard-dist/assets/index-CoqlHfTu.js +0 -9
package/LICENSE
CHANGED
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
not limited to compiled object code, generated documentation,
|
|
33
33
|
and conversions to other media types.
|
|
34
34
|
|
|
35
|
-
"Work" shall mean the work of authorship
|
|
36
|
-
the License, as indicated by a
|
|
37
|
-
|
|
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).
|
|
38
39
|
|
|
39
40
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
41
|
form, that is based on (or derived from) the Work and for which the
|
|
@@ -44,21 +45,23 @@
|
|
|
44
45
|
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
46
|
the Work and Derivative Works thereof.
|
|
46
47
|
|
|
47
|
-
"Contribution" shall mean
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
or
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
62
65
|
|
|
63
66
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
67
|
this License, each Contributor hereby grants to You a perpetual,
|
|
@@ -74,22 +77,22 @@
|
|
|
74
77
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
78
|
where such license applies only to those patent claims licensable
|
|
76
79
|
by such Contributor that are necessarily infringed by their
|
|
77
|
-
Contribution(s) alone or by
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
81
|
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
-
institute patent litigation against any entity (including a
|
|
80
|
-
or counterclaim in a lawsuit) alleging that the Work
|
|
81
|
-
Contribution
|
|
82
|
-
patent infringement, then any patent licenses
|
|
83
|
-
this License for that Work shall terminate
|
|
84
|
-
litigation is filed.
|
|
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.
|
|
85
88
|
|
|
86
89
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
90
|
Work or Derivative Works thereof in any medium, with or without
|
|
88
91
|
modifications, and in Source or Object form, provided that You
|
|
89
92
|
meet the following conditions:
|
|
90
93
|
|
|
91
|
-
(a) You must give any other recipients of the Work or
|
|
92
|
-
Works a copy of this License; and
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
93
96
|
|
|
94
97
|
(b) You must cause any modified files to carry prominent notices
|
|
95
98
|
stating that You changed the files; and
|
|
@@ -101,24 +104,28 @@
|
|
|
101
104
|
the Derivative Works; and
|
|
102
105
|
|
|
103
106
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
-
distribution,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
the
|
|
109
|
-
Derivative Works;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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.
|
|
122
129
|
|
|
123
130
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
124
131
|
any Contribution intentionally submitted for inclusion in the Work
|
|
@@ -137,10 +144,10 @@
|
|
|
137
144
|
agreed to in writing, Licensor provides the Work (and each
|
|
138
145
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
139
146
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
140
|
-
implied, including, without limitation, any
|
|
141
|
-
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
142
|
-
PURPOSE. You are solely responsible for determining the
|
|
143
|
-
appropriateness of using 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
|
|
144
151
|
risks associated with Your exercise of permissions under this License.
|
|
145
152
|
|
|
146
153
|
8. Limitation of Liability. In no event and under no legal theory,
|
|
@@ -148,23 +155,38 @@
|
|
|
148
155
|
unless required by applicable law (such as deliberate and grossly
|
|
149
156
|
negligent acts) or agreed to in writing, shall any Contributor be
|
|
150
157
|
liable to You for damages, including any direct, indirect, special,
|
|
151
|
-
incidental, or
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
152
159
|
result of this License or out of the use or inability to use the
|
|
153
|
-
Work (
|
|
154
|
-
|
|
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.
|
|
155
164
|
|
|
156
165
|
9. Accepting Warranty or Additional Liability. While redistributing
|
|
157
166
|
the Work or Derivative Works thereof, You may choose to offer,
|
|
158
167
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
159
168
|
or other liability obligations and/or rights consistent with this
|
|
160
|
-
License. However, in accepting such obligations, You may
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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.
|
|
164
175
|
|
|
165
176
|
END OF TERMS AND CONDITIONS
|
|
166
177
|
|
|
167
|
-
|
|
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 2026 Franklin Enmanuel Magallanes Pinargote
|
|
168
190
|
|
|
169
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
170
192
|
you may not use this file except in compliance with the License.
|
|
@@ -176,4 +198,4 @@
|
|
|
176
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
177
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
178
200
|
See the License for the specific language governing permissions and
|
|
179
|
-
limitations under the License.
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ npx ahk init
|
|
|
30
30
|
- [Features](#features)
|
|
31
31
|
- [Requirements](#requirements)
|
|
32
32
|
- [Installation](#installation)
|
|
33
|
+
- [MCP command per package manager](#mcp-command-per-package-manager)
|
|
33
34
|
- [Commands](#commands)
|
|
34
35
|
- [`ahk init`](#ahk-init)
|
|
35
36
|
- [`ahk build`](#ahk-build)
|
|
@@ -114,7 +115,7 @@ Everything is stored locally in a SQLite database (`.harness/harness.db`). No cl
|
|
|
114
115
|
- **Health gate** — agents must run `health.sh` and get a green exit before starting or closing any task. You define what "healthy" means.
|
|
115
116
|
- **Markdown fallback** — `current.md` is always regenerated so agents can understand the session state even without the MCP server.
|
|
116
117
|
- **Docs search** — agents can call `docs.search(query)` to find relevant content in your project's docs folder before writing code.
|
|
117
|
-
- **Multi-database support** — SQLite by default (
|
|
118
|
+
- **Multi-database support** — SQLite by default (uses `better-sqlite3` on Node ≥ 22 or `bun:sqlite` on Bun). Switch to PostgreSQL or MySQL with a single config line — same schema, same MCP tools, same workflow.
|
|
118
119
|
- **Incremental scaffold** — `ahk init` preserves files you've already customized (agent definitions you've edited are kept). `ahk build` always regenerates agent files from the latest templates so they stay up to date.
|
|
119
120
|
- **Global installation** — `ahk init` can scaffold the harness into your home directory (`~/.claude` or `~/.config/opencode`) to share it across all projects.
|
|
120
121
|
- **Input validation** — CLI prompts validate all inputs (name length, path format, task title, etc.) and retry with the error message instead of silently accepting bad values.
|
|
@@ -131,35 +132,74 @@ Everything is stored locally in a SQLite database (`.harness/harness.db`). No cl
|
|
|
131
132
|
## Installation
|
|
132
133
|
|
|
133
134
|
```bash
|
|
134
|
-
# Install in your project as a dev dependency
|
|
135
|
+
# Install in your project as a dev dependency (recommended)
|
|
135
136
|
npm install --save-dev @cardor/agent-harness-kit
|
|
136
|
-
|
|
137
|
-
# Or globally
|
|
138
|
-
npm install -g @cardor/agent-harness-kit
|
|
139
137
|
```
|
|
140
138
|
|
|
141
139
|
Then run the interactive setup inside your project:
|
|
142
140
|
|
|
143
141
|
```bash
|
|
144
142
|
npx ahk init
|
|
145
|
-
# or, if installed globally:
|
|
146
|
-
ahk init
|
|
147
143
|
```
|
|
148
144
|
|
|
145
|
+
> **Local install required.** `ahk` needs to resolve your project's `agent-harness-kit.config.ts` and its dependencies relative to your project's own `node_modules`. A **global-only** install (`npm install -g @cardor/agent-harness-kit`) cannot do this reliably, so every command except `--version`/`--help` will detect a global-only install and exit with an error telling you to run `npm install --save-dev @cardor/agent-harness-kit` (or the `pnpm`/`yarn`/`bun` equivalent) in your project root.
|
|
146
|
+
>
|
|
147
|
+
> This check also works with **Yarn Berry (PnP)** projects, which never create a `node_modules` folder — `ahk` detects `.pnp.cjs`/`.pnp.loader.mjs` and falls back to checking that the package is declared in `package.json` instead of requiring a `node_modules` entry.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## MCP command per package manager
|
|
152
|
+
|
|
153
|
+
`ahk init` and `ahk build` detect which package manager your project uses and generate the MCP server launch command (`.mcp.json`, `opencode.json`, or `.codex/config.toml`) accordingly, instead of hardcoding `npx`:
|
|
154
|
+
|
|
155
|
+
| Package manager | Detected via | Generated command |
|
|
156
|
+
| -------------------------- | --------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
157
|
+
| npm | `packageManager` field, `package-lock.json`, or fallback | `npx --no ahk serve --port <port>` |
|
|
158
|
+
| pnpm | `packageManager` field or `pnpm-lock.yaml` | `pnpm exec ahk serve --port <port>` |
|
|
159
|
+
| yarn classic (v1) | `packageManager` field (major 1) or `yarn.lock` without `.yarnrc.yml` | `yarn run ahk serve --port <port>` |
|
|
160
|
+
| yarn berry (v2+, PnP or node-modules) | `packageManager` field (major ≥ 2) or `yarn.lock` + `.yarnrc.yml` | `yarn run ahk serve --port <port>` |
|
|
161
|
+
| bun | `packageManager` field or `bun.lockb`/`bun.lock` | `bunx --no-install ahk serve --port <port>` |
|
|
162
|
+
|
|
163
|
+
Detection order: the `packageManager` field in your `package.json` (e.g. `"packageManager": "pnpm@8.15.0"`) takes priority when present; otherwise `ahk` falls back to lockfile heuristics; if nothing is detected, it defaults to npm.
|
|
164
|
+
|
|
165
|
+
**Existing projects:** if you initialized your project before this change, your `.mcp.json`/`opencode.json`/`.codex/config.toml` may still have a hardcoded `npx` command. No migration step is needed — `ahk build` always regenerates (merges) these files from scratch on every run, so the command self-corrects the next time you run `ahk build` (or `ahk build --sync`), including if you've since switched package managers.
|
|
166
|
+
|
|
149
167
|
---
|
|
150
168
|
|
|
151
169
|
## Commands
|
|
152
170
|
|
|
153
171
|
### `ahk init`
|
|
154
172
|
|
|
155
|
-
Interactive scaffold. Asks for your project name, description, AI provider, docs path, task adapter, and an optional first task. Creates all harness files in the current directory.
|
|
173
|
+
Interactive scaffold. Asks for your project name, description, AI provider, docs path, storage scope, task adapter, and an optional first task. Creates all harness files in the current directory.
|
|
174
|
+
|
|
175
|
+
For Claude Code and Codex CLI (not OpenCode), you'll also be asked whether to personalize the model per agent (lead/explorer/consultant/builder/reviewer):
|
|
176
|
+
|
|
177
|
+
- Claude Code: pick from `inherit` (default), `haiku`, `sonnet`, `opus`, `fable` per agent.
|
|
178
|
+
- Codex CLI: free-text model name per agent — Codex does not validate this value; leaving it blank or under 3 characters means no override is written to that agent's TOML file.
|
|
179
|
+
|
|
180
|
+
**Storage scope** — where the harness DB (and its `current.md` fallback) physically lives:
|
|
181
|
+
|
|
182
|
+
- `local` (default) — `.harness/harness.db`, inside the project.
|
|
183
|
+
- `global` — `~/.harness/dbs/<projectId>/harness.db`, outside the project tree (useful to keep the DB out of version control entirely, or to centralize storage for many projects). `<projectId>` is a UUID generated once at init and persisted in `agent-harness-kit.config.ts` — it's never regenerated on subsequent runs.
|
|
184
|
+
|
|
185
|
+
Regardless of scope, `.harness/storage-state.json` is always written to the project — it records the *actual* current storage state (`scope`, `projectId`, `dbType`, `migratedAt`), separate from the *desired* state declared in the config file.
|
|
186
|
+
|
|
187
|
+
When `--storage-scope global` is chosen, `ahk init` also synchronizes your provider's agent and skill files into your home directory (in addition to the project-local files it always writes), so subsequent `ahk init --storage-scope global` runs in *other* projects on the same machine can reuse them instead of re-scaffolding:
|
|
188
|
+
|
|
189
|
+
| Provider | Global agents dir | Global skills dir |
|
|
190
|
+
| ------------- | ---------------------------- | ----------------------------- |
|
|
191
|
+
| `claude-code` | `~/.claude/agents/` | `~/.claude/skills/` |
|
|
192
|
+
| `codex-cli` | `~/.codex/agents/` | `~/.agents/skills/` (separate namespace from `~/.codex/agents`) |
|
|
193
|
+
| `opencode` | `~/.config/opencode/agents/` | `~/.config/opencode/skills/` |
|
|
194
|
+
|
|
195
|
+
This sync is idempotent and non-destructive: it only creates files that are missing. If everything is already present, `ahk init` prints a message and skips; if only some files are missing, it creates just those and reports what was added. Files it detects as already customized/outdated are left untouched (same "preserve, don't overwrite" rule used for project-local agent files).
|
|
156
196
|
|
|
157
197
|
```bash
|
|
158
198
|
ahk init
|
|
159
199
|
|
|
160
200
|
# Skip prompts with flags
|
|
161
|
-
ahk init --name "my-app" --provider claude-code --docs ./docs --tasks local
|
|
162
|
-
ahk init --name "my-app" --provider codex-cli --docs ./docs --tasks local
|
|
201
|
+
ahk init --name "my-app" --provider claude-code --docs ./docs --tasks local --storage-scope local
|
|
202
|
+
ahk init --name "my-app" --provider codex-cli --docs ./docs --tasks local --storage-scope global
|
|
163
203
|
```
|
|
164
204
|
|
|
165
205
|
Run this once per project. If the project is already initialized, the command prints an 'already initialized' message with suggested next-step commands (`ahk build`, `ahk build --sync`, `ahk reset`, `ahk serve`) and exits without overwriting anything.
|
|
@@ -240,7 +280,7 @@ Reports three categories:
|
|
|
240
280
|
|
|
241
281
|
- **lib version** — compares installed version against the latest on npm. Shows `[✓]` if up to date, `[!]` if an update is available, or `[~]` if the registry could not be reached.
|
|
242
282
|
- **agent files** — reads each agent file on disk and compares against what `ahk build` would generate. Reports `[!]` with the file name if outdated.
|
|
243
|
-
- **harness skills** — checks that `ahk-ask`, `ahk-consultant`, and `ahk-
|
|
283
|
+
- **harness skills** — checks that `ahk-ask`, `ahk-consultant`, `ahk-triage`, and `ahk-review` skills exist and match the bundled source. Reports `[!]` if missing or outdated.
|
|
244
284
|
|
|
245
285
|
Run `ahk build` to fix any reported issues.
|
|
246
286
|
|
|
@@ -331,14 +371,48 @@ After a reset, run `ahk init` to scaffold a fresh harness.
|
|
|
331
371
|
|
|
332
372
|
### `ahk migrate`
|
|
333
373
|
|
|
374
|
+
`ahk migrate` has two subcommands: `provider` (migrate scaffold files to a different AI provider) and `storage` (migrate the harness database between storage backends). `ahk migrate --to <provider>` (no subcommand) is kept as a backward-compatible alias for `ahk migrate provider --to <provider>` — existing scripts/CI using the old form keep working unchanged.
|
|
375
|
+
|
|
376
|
+
#### `ahk migrate provider`
|
|
377
|
+
|
|
334
378
|
Migrates provider-specific files from one AI provider to another. Useful when switching from Claude Code to OpenCode or vice versa.
|
|
335
379
|
|
|
336
380
|
```bash
|
|
381
|
+
ahk migrate provider --to opencode
|
|
382
|
+
ahk migrate provider --to claude-code
|
|
383
|
+
ahk migrate provider --to codex-cli
|
|
384
|
+
|
|
385
|
+
# Backward-compatible alias (identical behavior):
|
|
337
386
|
ahk migrate --to opencode
|
|
338
|
-
ahk migrate --to claude-code
|
|
339
|
-
ahk migrate --to codex-cli
|
|
340
387
|
```
|
|
341
388
|
|
|
389
|
+
#### `ahk migrate storage` — ⚠️ sensitive, reads/writes real harness data
|
|
390
|
+
|
|
391
|
+
Migrates the harness database between storage backends: **local↔global scope** (moving `.harness/harness.db` in/out of `~/.harness/dbs/<projectId>/`) and **sqlite↔postgres/mysql** (dumping and reloading all 6 tables — tasks, task_acceptance, actions, action_sections, action_files, action_tools — inside a single transaction). It is **not interactive** — `agent-harness-kit.config.ts` (`storage.scope`, `database.type`/`path`/`connectionString`) is the only source of truth for the desired target, compared against the real current state recorded in `.harness/storage-state.json`.
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
ahk migrate storage # migrate to whatever agent-harness-kit.config.ts declares
|
|
395
|
+
ahk migrate storage --dry-run # preview what would happen, without touching anything
|
|
396
|
+
ahk migrate storage --force # required whenever the destination already has data
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
What it does, case by case:
|
|
400
|
+
|
|
401
|
+
| Situation | Behavior |
|
|
402
|
+
|---|---|
|
|
403
|
+
| Config and real storage state already match | No-op — reports "nothing to migrate" |
|
|
404
|
+
| Only `storage.scope` differs (same DB engine) | Copies the `.db` file (+ WAL/SHM) and `current.md` directly to the new location, verifies the copy, then removes the original |
|
|
405
|
+
| Only `database.type` differs (sqlite → postgres/mysql) | Full export/import of all 6 tables inside one transaction; on failure, the destination is rolled back exactly as it was found |
|
|
406
|
+
| Destination already has data | **Requires `--force`.** Without it, the command aborts and touches nothing. With it, the destination's current content is backed up to `.harness/backups/pre-migrate-<timestamp>.json` **before** anything is overwritten — if the backup can't be written, the whole command aborts |
|
|
407
|
+
| Both source and destination have diverging data (not just empty vs. full) | Same as above (`--force` + backup required) — the command never attempts to auto-merge two independent histories |
|
|
408
|
+
| `.harness/storage-state.json` is missing | Never assumed to mean "safe, empty destination." Both the local and global sqlite candidate locations are inspected for real data first; if both have data, the command refuses to guess and asks for manual resolution |
|
|
409
|
+
|
|
410
|
+
**Limitations (by design, matches the current scope):**
|
|
411
|
+
- No connection pooling or incremental/partial migrations — always a full dump/load.
|
|
412
|
+
- After inserting rows with their original ids, the destination's internal id sequence is explicitly re-synced (`setval` on Postgres, `sqlite_sequence` update on SQLite; MySQL's `AUTO_INCREMENT` advances on its own) so that the next normal task/action created after migrating never collides with an imported id.
|
|
413
|
+
- Migrating *away from* a previously remote (postgres/mysql) database isn't supported automatically — `storage-state.json` intentionally never stores connection credentials, so there's nothing to reconnect to. Export manually with `ahk export --json` while still connected to the old database first.
|
|
414
|
+
- The original sqlite file is **not** deleted after a sqlite→remote migration — remove it manually once you've verified the migrated data.
|
|
415
|
+
|
|
342
416
|
---
|
|
343
417
|
|
|
344
418
|
### `ahk export`
|
|
@@ -365,8 +439,9 @@ your-project/
|
|
|
365
439
|
├── CLAUDE.md
|
|
366
440
|
├── health.sh
|
|
367
441
|
├── .harness/
|
|
368
|
-
│ ├── harness.db ← gitignored
|
|
369
|
-
│ ├── current.md ← gitignored
|
|
442
|
+
│ ├── harness.db ← gitignored (local scope only — absent when scope: 'global')
|
|
443
|
+
│ ├── current.md ← gitignored (local scope only — absent when scope: 'global')
|
|
444
|
+
│ ├── storage-state.json ← always present, reflects the REAL current storage scope/projectId
|
|
370
445
|
│ └── feature_list.json
|
|
371
446
|
└── .claude/
|
|
372
447
|
├── agents/
|
|
@@ -421,8 +496,9 @@ your-project/
|
|
|
421
496
|
| `AGENTS.md` | Navigation map agents read first. Regenerated by `ahk build` | No — changes will be overwritten |
|
|
422
497
|
| `health.sh` | Shell script agents run before starting work. Must exit 0 | **Yes — implement your checks here** |
|
|
423
498
|
| `.harness/feature_list.json` | Task backlog in JSON. Humans edit this, `ahk sync` loads it into SQLite | Yes — add tasks here |
|
|
424
|
-
| `.harness/harness.db` | SQLite database. Source of truth for tasks, actions, sections
|
|
425
|
-
| `.harness/current.md` | Auto-generated session snapshot for agents without MCP access
|
|
499
|
+
| `.harness/harness.db` | SQLite database (local scope only). Source of truth for tasks, actions, sections | No — managed by the harness |
|
|
500
|
+
| `.harness/current.md` | Auto-generated session snapshot for agents without MCP access (local scope only) | No — regenerated automatically |
|
|
501
|
+
| `.harness/storage-state.json` | Always project-local. Records the REAL current storage state (`scope`, `projectId`, `dbType`, `migratedAt`) — used by migration tooling | No — managed by the harness |
|
|
426
502
|
| `.claude/agents/*.md` | Agent role definitions (Claude Code). Created once, never overwritten | **Yes — customize agent behavior** |
|
|
427
503
|
| `.claude/mcp.json` | MCP server registration for Claude Code. Merged by `ahk build` | Yes, carefully — don't remove the `agent-harness-kit` entry |
|
|
428
504
|
| `.claude/settings.json` | Sets `agent: "lead"` so lead runs as the default session agent. Merged by `ahk build` | Yes, carefully |
|
|
@@ -458,10 +534,11 @@ export default defineHarness({
|
|
|
458
534
|
provider: 'claude-code', // 'claude-code' | 'opencode' | 'codex-cli'
|
|
459
535
|
|
|
460
536
|
agents: {
|
|
461
|
-
lead: { instructionsPath: null },
|
|
462
|
-
explorer: { instructionsPath: null, allowedPaths: ['./docs', './src'] },
|
|
537
|
+
lead: { instructionsPath: null, model: 'sonnet' }, // optional per-agent model override
|
|
538
|
+
explorer: { instructionsPath: null, allowedPaths: ['./docs', './src'], model: 'haiku' },
|
|
463
539
|
builder: { instructionsPath: null, writablePaths: ['./src', './tests'] },
|
|
464
540
|
reviewer: { instructionsPath: null },
|
|
541
|
+
consultant: { instructionsPath: null, model: 'haiku' },
|
|
465
542
|
custom: [], // define extra agents here
|
|
466
543
|
},
|
|
467
544
|
|
|
@@ -486,6 +563,10 @@ export default defineHarness({
|
|
|
486
563
|
nextSteps: false, // optional next steps field
|
|
487
564
|
},
|
|
488
565
|
markdownFallback: { enabled: true, path: '.harness/current.md' },
|
|
566
|
+
// 'local' (default) — DB lives in .harness/ (project-relative).
|
|
567
|
+
// 'global' — DB lives under ~/.harness/dbs/<projectId>/, outside the project.
|
|
568
|
+
scope: 'local', // 'local' | 'global'
|
|
569
|
+
projectId: '5f2c...', // UUID, generated once at init, never regenerated
|
|
489
570
|
},
|
|
490
571
|
|
|
491
572
|
health: {
|
|
@@ -598,24 +679,24 @@ Good acceptance criteria make the difference — the reviewer agent uses them to
|
|
|
598
679
|
|
|
599
680
|
The harness exposes these tools via MCP. Agents use them instead of reading files directly.
|
|
600
681
|
|
|
601
|
-
| Tool | Parameters | Description
|
|
602
|
-
| ------------------------- | ----------------------------------------------- |
|
|
603
|
-
| `tasks.get` | `status?` | List tasks, optionally filtered by `pending \| in_progress \| done \| blocked`
|
|
604
|
-
| `tasks.claim` | `id, agent` | Atomically claim a pending task. Returns `task_already_claimed` if another agent got it first
|
|
605
|
-
| `tasks.update` | `id, status` | Change task status
|
|
606
|
-
| `tasks.add` | `title, slug?, description?, acceptance?` | Create a new task directly from MCP (agents can queue work on the fly)
|
|
607
|
-
| `tasks.acceptance.update` | `criterionId` | Mark an acceptance criterion as met. Criterion IDs come from `tasks.acceptance_get`
|
|
608
|
-
| `actions.start` | `taskId, agent` | Start a new action, returns `actionId`
|
|
609
|
-
| `actions.write` | `actionId, sectionType, content` | Record a text section: `result \| tools_used \| blockers \| next_steps`. Does **not** populate the Files dashboard — use `actions.record_file` for that
|
|
610
|
-
| `actions.complete` | `actionId, summary` | Close an action with a one-line summary
|
|
611
|
-
| `actions.get` | `taskId` | Full action history for a task (all agents, all sections)
|
|
612
|
-
| `actions.record_file` | `actionId, filePath, operation, notes?` | Register a file touch. The **only** way to populate the Files dashboard. `operation`: `read \| created \| modified \| deleted`
|
|
613
|
-
| `actions.record_tool` | `actionId, toolName, argsJson?, resultSummary?` | Register a tool call. The **only** way to populate the Tools dashboard
|
|
614
|
-
| `docs.search` | `query` | Search the `docsPath` folder for content matching the query
|
|
615
|
-
| `tasks.acceptance_get` | `taskId` | Returns all acceptance criteria for a task with their `id`, `task_id`, `criterion` text, and `met` status. Use the returned `id` values with `tasks.acceptance.update`
|
|
616
|
-
| `deps.snapshot` | _(none)_ | Snapshot current `package.json` dependencies to `.harness/deps-lock.json`
|
|
617
|
-
| `deps.check` | _(none)_ | Compare current `package.json` against `.harness/deps-lock.json`. Returns `{ significant, added, removed, majorBumps, advisory }`
|
|
618
|
-
| `ahk.doctor` | _(none)_ | Check lib version, agent files, and harness skills sync status. Returns `{ lib: { current, latest, outdated }, agents: { outdated,
|
|
682
|
+
| Tool | Parameters | Description |
|
|
683
|
+
| ------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
684
|
+
| `tasks.get` | `status?` | List tasks, optionally filtered by `pending \| in_progress \| done \| blocked` |
|
|
685
|
+
| `tasks.claim` | `id, agent` | Atomically claim a pending task. Returns `task_already_claimed` if another agent got it first |
|
|
686
|
+
| `tasks.update` | `id, status` | Change task status |
|
|
687
|
+
| `tasks.add` | `title, slug?, description?, acceptance?` | Create a new task directly from MCP (agents can queue work on the fly) |
|
|
688
|
+
| `tasks.acceptance.update` | `criterionId` | Mark an acceptance criterion as met. Criterion IDs come from `tasks.acceptance_get` |
|
|
689
|
+
| `actions.start` | `taskId, agent` | Start a new action, returns `actionId` |
|
|
690
|
+
| `actions.write` | `actionId, sectionType, content` | Record a text section: `result \| tools_used \| blockers \| next_steps`. Does **not** populate the Files dashboard — use `actions.record_file` for that |
|
|
691
|
+
| `actions.complete` | `actionId, summary` | Close an action with a one-line summary |
|
|
692
|
+
| `actions.get` | `taskId` | Full action history for a task (all agents, all sections) |
|
|
693
|
+
| `actions.record_file` | `actionId, filePath, operation, notes?` | Register a file touch. The **only** way to populate the Files dashboard. `operation`: `read \| created \| modified \| deleted` |
|
|
694
|
+
| `actions.record_tool` | `actionId, toolName, argsJson?, resultSummary?` | Register a tool call. The **only** way to populate the Tools dashboard |
|
|
695
|
+
| `docs.search` | `query` | Search the `docsPath` folder for content matching the query |
|
|
696
|
+
| `tasks.acceptance_get` | `taskId` | Returns all acceptance criteria for a task with their `id`, `task_id`, `criterion` text, and `met` status. Use the returned `id` values with `tasks.acceptance.update` |
|
|
697
|
+
| `deps.snapshot` | _(none)_ | Snapshot current `package.json` dependencies to `.harness/deps-lock.json` |
|
|
698
|
+
| `deps.check` | _(none)_ | Compare current `package.json` against `.harness/deps-lock.json`. Returns `{ significant, added, removed, majorBumps, advisory }` |
|
|
699
|
+
| `ahk.doctor` | _(none)_ | Check lib version, agent files, and harness skills sync status. Returns `{ lib: { current, latest, outdated }, agents: { missing, outdated, ok }, skills: { missing, outdated, ok } }`. The `lib` version lookup (npm registry check) is cached in-memory with a 5-minute TTL — repeated calls within that window do not hit the network again. |
|
|
619
700
|
|
|
620
701
|
---
|
|
621
702
|
|
|
@@ -675,10 +756,11 @@ Each agent role has a scoped set of MCP tools enforced through the agent definit
|
|
|
675
756
|
| `opencode.json` | Yes |
|
|
676
757
|
| `.codex/agents/*.toml` | Yes |
|
|
677
758
|
| `.codex/config.toml` | Yes |
|
|
678
|
-
| `.harness/harness.db` | **No** (gitignored) |
|
|
679
|
-
| `.harness/current.md` | **No** (gitignored) |
|
|
759
|
+
| `.harness/harness.db` | **No** (gitignored, local scope only) |
|
|
760
|
+
| `.harness/current.md` | **No** (gitignored, local scope only) |
|
|
761
|
+
| `.harness/storage-state.json` | Yes (metadata, not gitignored — always present regardless of scope) |
|
|
680
762
|
|
|
681
|
-
The rule: commit inputs (config, task definitions, agent instructions). Ignore outputs (DB, auto-generated snapshots).
|
|
763
|
+
The rule: commit inputs (config, task definitions, agent instructions). Ignore outputs (DB, auto-generated snapshots). `storage-state.json` is metadata about *where* those outputs live, not an output itself — it's committed so the harness can detect storage drift.
|
|
682
764
|
|
|
683
765
|
---
|
|
684
766
|
|
|
@@ -686,11 +768,11 @@ The rule: commit inputs (config, task definitions, agent instructions). Ignore o
|
|
|
686
768
|
|
|
687
769
|
| Runtime | SQLite | PostgreSQL | MySQL |
|
|
688
770
|
| ---------------- | ------------------------------ | ------------------------- | ----------------------- |
|
|
689
|
-
| Node.js ≥ 22 | ✅ uses `
|
|
690
|
-
| Bun (any recent) | ✅ uses `bun:sqlite` built-in
|
|
691
|
-
| Node.js < 22 | ❌ `node
|
|
771
|
+
| Node.js ≥ 22 | ✅ uses `better-sqlite3` package | ✅ via `postgres` package | ✅ via `mysql2` package |
|
|
772
|
+
| Bun (any recent) | ✅ uses `bun:sqlite` built-in | ✅ via `postgres` package | ✅ via `mysql2` package |
|
|
773
|
+
| Node.js < 22 | ❌ blocked by `engines.node` (not by the SQLite driver) | ✅ | ✅ |
|
|
692
774
|
|
|
693
|
-
SQLite
|
|
775
|
+
SQLite is included via the `better-sqlite3` dependency (installed automatically). For PostgreSQL install `postgres`, for MySQL install `mysql2`:
|
|
694
776
|
|
|
695
777
|
```bash
|
|
696
778
|
npm install postgres # for PostgreSQL
|
|
@@ -152,6 +152,19 @@ Then complete your action with a blocked status — do not guess through ambigui
|
|
|
152
152
|
actions.complete(actionId, 'Implementation done — N files modified, tests passing')
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
## Committing changes with git
|
|
156
|
+
|
|
157
|
+
Only commit when explicitly asked to.
|
|
158
|
+
|
|
159
|
+
Before writing a commit message, detect whether the repo already enforces a commit message convention:
|
|
160
|
+
- Look for `commitlint.config.*` or `.commitlintrc*` in the repo root
|
|
161
|
+
- Look for `.husky/commit-msg`
|
|
162
|
+
- Look for `commitlint` or `husky` listed in `package.json` dependencies/devDependencies
|
|
163
|
+
|
|
164
|
+
**If tooling is detected** — follow the repo's existing convention. Do not invent or override a different format.
|
|
165
|
+
|
|
166
|
+
**If no tooling is detected** — use the pattern `<action>(<scope>): <message>`, where `<message>` is at most 50 characters. Example: `fix(auth): handle expired refresh tokens`.
|
|
167
|
+
|
|
155
168
|
## Hard rules
|
|
156
169
|
|
|
157
170
|
- **Read the plan and analysis first.** Never implement cold.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/core/config.ts
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
2
3
|
import { existsSync } from "fs";
|
|
3
4
|
import { join } from "path";
|
|
4
5
|
import { createJiti } from "jiti";
|
|
@@ -61,6 +62,8 @@ function applyDefaults(config) {
|
|
|
61
62
|
nextSteps: false
|
|
62
63
|
},
|
|
63
64
|
markdownFallback: { enabled: true, path: ".harness/current.md" },
|
|
65
|
+
scope: "local",
|
|
66
|
+
projectId: c.storage?.projectId ?? randomUUID(),
|
|
64
67
|
...c.storage
|
|
65
68
|
},
|
|
66
69
|
health: {
|
|
@@ -81,4 +84,4 @@ export {
|
|
|
81
84
|
loadConfig,
|
|
82
85
|
defineHarness
|
|
83
86
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-ADV7OPU2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/config.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { createJiti } from 'jiti'\n\nimport type { HarnessConfig } from '@/types'\n\nconst CONFIG_NAMES = [\n 'agent-harness-kit.config.ts',\n 'agent-harness-kit.config',\n 'agent-harness-kit.config.mjs',\n 'agent-harness-kit.config.cjs',\n]\n\nexport function findConfigFile(cwd: string): string | null {\n for (const name of CONFIG_NAMES) {\n const candidate = join(cwd, name)\n if (existsSync(candidate)) return candidate\n }\n return null\n}\n\nexport async function loadConfig(cwd: string): Promise<HarnessConfig> {\n const configPath = findConfigFile(cwd)\n if (!configPath) {\n throw new Error('No agent-harness-kit.config found. Run: ahk init')\n }\n\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(configPath) as { default?: HarnessConfig } | HarnessConfig\n const config = (mod as { default?: HarnessConfig }).default ?? (mod as HarnessConfig)\n\n if (!config || typeof config !== 'object') {\n throw new Error(`agent-harness-kit.config must export a default HarnessConfig object.`)\n }\n\n return applyDefaults(config as HarnessConfig)\n}\n\nexport function defineHarness(config: HarnessConfig): HarnessConfig {\n return config\n}\n\nfunction applyDefaults(config: HarnessConfig): HarnessConfig {\n const c = config as Partial<HarnessConfig>\n return {\n ...config,\n provider: c.provider ?? 'claude-code',\n project: {\n docsPath: './docs',\n agentsMd: './AGENTS.md',\n ...c.project,\n } as HarnessConfig['project'],\n agents: {\n lead: { instructionsPath: null },\n explorer: { instructionsPath: null },\n builder: { instructionsPath: null },\n reviewer: { instructionsPath: null },\n custom: [],\n ...c.agents,\n } as HarnessConfig['agents'],\n database: c.database ?? { type: 'sqlite' as const, path: '.harness/harness.db' },\n storage: {\n dir: '.harness',\n tasks: { adapter: 'local' as const },\n sections: {\n toolsUsed: true,\n filesModified: true,\n result: true,\n blockers: true,\n nextSteps: false,\n },\n markdownFallback: { enabled: true, path: '.harness/current.md' },\n scope: 'local' as const,\n projectId: c.storage?.projectId ?? randomUUID(),\n ...c.storage,\n } as HarnessConfig['storage'],\n health: {\n scriptPath: './health.sh',\n required: true,\n ...c.health,\n },\n tools: {\n mcp: { enabled: true, port: 3742 },\n scripts: { enabled: true, outputDir: './.harness/scripts' },\n ...c.tools,\n } as HarnessConfig['tools'],\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAI3B,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,eAAe,KAA4B;AACzD,aAAW,QAAQ,cAAc;AAC/B,UAAM,YAAY,KAAK,KAAK,IAAI;AAChC,QAAI,WAAW,SAAS,EAAG,QAAO;AAAA,EACpC;AACA,SAAO;AACT;AAEA,eAAsB,WAAW,KAAqC;AACpE,QAAM,aAAa,eAAe,GAAG;AACrC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAEA,QAAM,OAAO,WAAW,YAAY,GAAG;AACvC,QAAM,MAAM,MAAM,KAAK,OAAO,UAAU;AACxC,QAAM,SAAU,IAAoC,WAAY;AAEhE,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,sEAAsE;AAAA,EACxF;AAEA,SAAO,cAAc,MAAuB;AAC9C;AAEO,SAAS,cAAc,QAAsC;AAClE,SAAO;AACT;AAEA,SAAS,cAAc,QAAsC;AAC3D,QAAM,IAAI;AACV,SAAO;AAAA,IACL,GAAG;AAAA,IACH,UAAU,EAAE,YAAY;AAAA,IACxB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,MACV,GAAG,EAAE;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,EAAE,kBAAkB,KAAK;AAAA,MAC/B,UAAU,EAAE,kBAAkB,KAAK;AAAA,MACnC,SAAS,EAAE,kBAAkB,KAAK;AAAA,MAClC,UAAU,EAAE,kBAAkB,KAAK;AAAA,MACnC,QAAQ,CAAC;AAAA,MACT,GAAG,EAAE;AAAA,IACP;AAAA,IACA,UAAU,EAAE,YAAY,EAAE,MAAM,UAAmB,MAAM,sBAAsB;AAAA,IAC/E,SAAS;AAAA,MACP,KAAK;AAAA,MACL,OAAO,EAAE,SAAS,QAAiB;AAAA,MACnC,UAAU;AAAA,QACR,WAAW;AAAA,QACX,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,WAAW;AAAA,MACb;AAAA,MACA,kBAAkB,EAAE,SAAS,MAAM,MAAM,sBAAsB;AAAA,MAC/D,OAAO;AAAA,MACP,WAAW,EAAE,SAAS,aAAa,WAAW;AAAA,MAC9C,GAAG,EAAE;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,GAAG,EAAE;AAAA,IACP;AAAA,IACA,OAAO;AAAA,MACL,KAAK,EAAE,SAAS,MAAM,MAAM,KAAK;AAAA,MACjC,SAAS,EAAE,SAAS,MAAM,WAAW,qBAAqB;AAAA,MAC1D,GAAG,EAAE;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|