@cardor/agent-harness-kit 1.9.0 → 1.10.1
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/README.md +100 -24
- 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 +779 -850
- 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 +8 -0
- package/dist/index.js +1 -1
- 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/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,40 +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.
|
|
156
174
|
|
|
157
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):
|
|
158
176
|
|
|
159
177
|
- Claude Code: pick from `inherit` (default), `haiku`, `sonnet`, `opus`, `fable` per agent.
|
|
160
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.
|
|
161
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).
|
|
196
|
+
|
|
162
197
|
```bash
|
|
163
198
|
ahk init
|
|
164
199
|
|
|
165
200
|
# Skip prompts with flags
|
|
166
|
-
ahk init --name "my-app" --provider claude-code --docs ./docs --tasks local
|
|
167
|
-
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
|
|
168
203
|
```
|
|
169
204
|
|
|
170
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.
|
|
@@ -336,14 +371,48 @@ After a reset, run `ahk init` to scaffold a fresh harness.
|
|
|
336
371
|
|
|
337
372
|
### `ahk migrate`
|
|
338
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
|
+
|
|
339
378
|
Migrates provider-specific files from one AI provider to another. Useful when switching from Claude Code to OpenCode or vice versa.
|
|
340
379
|
|
|
341
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):
|
|
342
386
|
ahk migrate --to opencode
|
|
343
|
-
ahk migrate --to claude-code
|
|
344
|
-
ahk migrate --to codex-cli
|
|
345
387
|
```
|
|
346
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
|
+
|
|
347
416
|
---
|
|
348
417
|
|
|
349
418
|
### `ahk export`
|
|
@@ -370,8 +439,9 @@ your-project/
|
|
|
370
439
|
├── CLAUDE.md
|
|
371
440
|
├── health.sh
|
|
372
441
|
├── .harness/
|
|
373
|
-
│ ├── harness.db ← gitignored
|
|
374
|
-
│ ├── 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
|
|
375
445
|
│ └── feature_list.json
|
|
376
446
|
└── .claude/
|
|
377
447
|
├── agents/
|
|
@@ -426,8 +496,9 @@ your-project/
|
|
|
426
496
|
| `AGENTS.md` | Navigation map agents read first. Regenerated by `ahk build` | No — changes will be overwritten |
|
|
427
497
|
| `health.sh` | Shell script agents run before starting work. Must exit 0 | **Yes — implement your checks here** |
|
|
428
498
|
| `.harness/feature_list.json` | Task backlog in JSON. Humans edit this, `ahk sync` loads it into SQLite | Yes — add tasks here |
|
|
429
|
-
| `.harness/harness.db` | SQLite database. Source of truth for tasks, actions, sections
|
|
430
|
-
| `.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 |
|
|
431
502
|
| `.claude/agents/*.md` | Agent role definitions (Claude Code). Created once, never overwritten | **Yes — customize agent behavior** |
|
|
432
503
|
| `.claude/mcp.json` | MCP server registration for Claude Code. Merged by `ahk build` | Yes, carefully — don't remove the `agent-harness-kit` entry |
|
|
433
504
|
| `.claude/settings.json` | Sets `agent: "lead"` so lead runs as the default session agent. Merged by `ahk build` | Yes, carefully |
|
|
@@ -492,6 +563,10 @@ export default defineHarness({
|
|
|
492
563
|
nextSteps: false, // optional next steps field
|
|
493
564
|
},
|
|
494
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
|
|
495
570
|
},
|
|
496
571
|
|
|
497
572
|
health: {
|
|
@@ -621,7 +696,7 @@ The harness exposes these tools via MCP. Agents use them instead of reading file
|
|
|
621
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` |
|
|
622
697
|
| `deps.snapshot` | _(none)_ | Snapshot current `package.json` dependencies to `.harness/deps-lock.json` |
|
|
623
698
|
| `deps.check` | _(none)_ | Compare current `package.json` against `.harness/deps-lock.json`. Returns `{ significant, added, removed, majorBumps, advisory }` |
|
|
624
|
-
| `ahk.doctor` | _(none)_ | Check lib version, agent files, and harness skills sync status. Returns `{ lib: { current, latest, outdated }, agents: { outdated,
|
|
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. |
|
|
625
700
|
|
|
626
701
|
---
|
|
627
702
|
|
|
@@ -681,10 +756,11 @@ Each agent role has a scoped set of MCP tools enforced through the agent definit
|
|
|
681
756
|
| `opencode.json` | Yes |
|
|
682
757
|
| `.codex/agents/*.toml` | Yes |
|
|
683
758
|
| `.codex/config.toml` | Yes |
|
|
684
|
-
| `.harness/harness.db` | **No** (gitignored) |
|
|
685
|
-
| `.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) |
|
|
686
762
|
|
|
687
|
-
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.
|
|
688
764
|
|
|
689
765
|
---
|
|
690
766
|
|
|
@@ -692,11 +768,11 @@ The rule: commit inputs (config, task definitions, agent instructions). Ignore o
|
|
|
692
768
|
|
|
693
769
|
| Runtime | SQLite | PostgreSQL | MySQL |
|
|
694
770
|
| ---------------- | ------------------------------ | ------------------------- | ----------------------- |
|
|
695
|
-
| Node.js ≥ 22 | ✅ uses `
|
|
696
|
-
| Bun (any recent) | ✅ uses `bun:sqlite` built-in
|
|
697
|
-
| 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) | ✅ | ✅ |
|
|
698
774
|
|
|
699
|
-
SQLite
|
|
775
|
+
SQLite is included via the `better-sqlite3` dependency (installed automatically). For PostgreSQL install `postgres`, for MySQL install `mysql2`:
|
|
700
776
|
|
|
701
777
|
```bash
|
|
702
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":[]}
|