@percepta/kaizen 0.6.0 → 0.7.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/README.md +54 -126
- package/agent/claude-command.md +23 -0
- package/agent/evals.md +41 -0
- package/agent/overview.md +53 -0
- package/agent/variant-builder.md +22 -0
- package/agent/views.md +51 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/BUILD_ID +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/build-manifest.json +22 -22
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/prerender-manifest.json +3 -3
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/routes-manifest.json +30 -10
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/chunks/27.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/chunks/516.js +8 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/chunks/913.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/middleware-build-manifest.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/404.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/500.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/benchmarks.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/benchmarks.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/data/[[...path]].html +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/data/[[...path]].js.nft.json +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/eval.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/eval.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/experiments/[[...path]].html +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/experiments/[[...path]].js.nft.json +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/ideas.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/ideas.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-action.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-action.js.nft.json +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset-item.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset-item.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset-mutation.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset-mutation.js.nft.json +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-dataset.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-datasets.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-datasets.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-trace.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-trace.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-traces.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/langfuse-traces.js.nft.json +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/linear-ideas.js +2 -2
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/linear-ideas.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-events.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-events.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-failures.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-failures.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-traces.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/run-traces.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/runs.js +2 -2
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/runs.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/systems.js +2 -2
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/systems.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/trace-renderer.js +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/api/trace-renderer.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/index.html +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/index.js.nft.json +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages-manifest.json +8 -5
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/SCF0o7YxElB9rzWaOohsA/_buildManifest.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/253-85c76c34f33c9604.js +8 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/{benchmarks-559dc9df52db3af4.js → benchmarks-30a17b7659010b8c.js} +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/data/[[...path]]-e5f4083fe9ffe429.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/{eval-3c911ea8744631fd.js → eval-160237a604b47416.js} +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/experiments/[[...path]]-91e47a4893093600.js +1 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/{ideas-6829a271003150a9.js → ideas-96e58e4624952e26.js} +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/{index-1d8b6719f49e4ae0.js → index-d3306bb6f5d7d235.js} +1 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/css/cd3873236eb77caa.css +1 -0
- package/dashboard/.next/standalone/packages/kaizen/package.json +5 -3
- package/dashboard/.next/standalone/packages/kaizen/shared/workspace-paths.js +84 -0
- package/dist/commands/create-view.js +58 -0
- package/dist/commands/create-view.js.map +1 -0
- package/dist/commands/guide.js +66 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/ideas.js +4 -8
- package/dist/commands/ideas.js.map +1 -1
- package/dist/commands/init-system.js +22 -20
- package/dist/commands/init-system.js.map +1 -1
- package/dist/commands/init.js +28 -64
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/log.js +5 -11
- package/dist/commands/log.js.map +1 -1
- package/dist/commands/rebuild.js +7 -9
- package/dist/commands/rebuild.js.map +1 -1
- package/dist/commands/run.js +5 -9
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/studio.js +3 -3
- package/dist/commands/studio.js.map +1 -1
- package/dist/index.js +17 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/cli.js +20 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/events.js.map +1 -1
- package/dist/lib/fs-utils.js +3 -27
- package/dist/lib/fs-utils.js.map +1 -1
- package/dist/lib/leaderboard.js +1 -1
- package/dist/lib/leaderboard.js.map +1 -1
- package/dist/lib/paths.js +3 -3
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/promotion.js.map +1 -1
- package/dist/lib/run-dir.js +1 -1
- package/dist/lib/run-dir.js.map +1 -1
- package/dist/lib/runner.js +6 -5
- package/dist/lib/runner.js.map +1 -1
- package/dist/lib/system.js +4 -2
- package/dist/lib/system.js.map +1 -1
- package/dist/package.js +5 -3
- package/dist/shared/view-types.d.ts +67 -0
- package/dist/shared/view-types.d.ts.map +1 -0
- package/dist/shared/workspace-paths.js +84 -0
- package/dist/shared/workspace-paths.js.map +1 -0
- package/dist/types.d.ts +3 -30
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -3
- package/shared/view-types.d.ts +69 -0
- package/shared/view-types.js +1 -0
- package/shared/workspace-paths.d.ts +19 -0
- package/shared/workspace-paths.js +84 -0
- package/templates/system/eval.py +13 -6
- package/templates/system/eval.ts +11 -5
- package/templates/system/rubric.md +1 -1
- package/templates/system/system.md +6 -5
- package/templates/view/dataset-item.tsx +63 -0
- package/templates/view/trace.tsx +10 -0
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/chunks/715.js +0 -6
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/data.html +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/data.js.nft.json +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/experiments.html +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/server/pages/[system]/experiments.js.nft.json +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/YpQ-I4VL-aEdQrM5uN7_3/_buildManifest.js +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/673-ed4be46027ae7a37.js +0 -6
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/data-644e4280b4c86fe0.js +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/chunks/pages/[system]/experiments-42f31600c2bb47ad.js +0 -1
- package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/css/b18a6732b96168e1.css +0 -1
- package/dist/lib/env.js +0 -2
- package/dist/shared/env.js +0 -4
- package/templates/workspace/.claude/agents/variant-builder.md +0 -51
- package/templates/workspace/.claude/commands/kaizen.md +0 -65
- /package/dashboard/.next/standalone/packages/kaizen/dashboard/.next/static/{YpQ-I4VL-aEdQrM5uN7_3 → SCF0o7YxElB9rzWaOohsA}/_ssgManifest.js +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: variant-builder
|
|
3
|
-
description: Implement and evaluate a single variant for a system
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
You implement and evaluate a single variant. You are a single-shot agent: implement, record one run via `kaizen run`, exit.
|
|
7
|
-
|
|
8
|
-
## Working directory
|
|
9
|
-
|
|
10
|
-
You receive a worktree path created by the orchestrator. All work happens in that worktree. Do not modify the main repo checkout.
|
|
11
|
-
You also receive the canonical Kaizen state directory for the main checkout. Export it before running Kaizen so Studio sees the run even though evaluation happens from the worktree.
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
cd <worktree_path>
|
|
15
|
-
export KAIZEN_STATE_DIR=<main_repo_path>/.kaizen
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Setup
|
|
19
|
-
|
|
20
|
-
1. Read the system definition at the absolute path in your prompt. The frontmatter has `run_eval`, `primary_metric`, `target`, `execution_mode`.
|
|
21
|
-
2. Read the parent run's `manifest.json` (if you have a parent) for context — its hypothesis, score, and `failures.jsonl` tells you what to fix.
|
|
22
|
-
3. For `server` execution_mode, start the system's servers on the assigned ports given in your prompt. For `in_process`, install deps as the system's setup section says.
|
|
23
|
-
|
|
24
|
-
## Implement
|
|
25
|
-
|
|
26
|
-
Modify code in your worktree to implement the variant described in your prompt. If you have a parent, the parent's code is already present (your worktree branched from theirs); build on it.
|
|
27
|
-
|
|
28
|
-
## Run
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
kaizen run \
|
|
32
|
-
--system <system_id> \
|
|
33
|
-
--variant <variant_id> \
|
|
34
|
-
--parent <parent_or_omit> \
|
|
35
|
-
--hypothesis "<one-line hypothesis>" \
|
|
36
|
-
--state-dir "$KAIZEN_STATE_DIR"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The `kaizen run` runner is plain code, not an agent. It handles everything: writes manifest, tails NDJSON events into `events.jsonl`, atomically updates `state.json`, dumps worst items to `failures.jsonl`, decides promotion via paired-bootstrap statistical test, prints the score.
|
|
40
|
-
|
|
41
|
-
The eval script may also write Langfuse dataset-run links and trace scores. Treat those writes as diagnostic persistence only. The authoritative run result for this loop is still the `complete.score` that `kaizen run` records from the NDJSON stream.
|
|
42
|
-
|
|
43
|
-
You do **not** write `.kaizen/` files. You do **not** call any status CLI. The single `kaizen run` invocation is the whole interaction.
|
|
44
|
-
|
|
45
|
-
## After the run
|
|
46
|
-
|
|
47
|
-
- `kaizen run` prints `score=<n> run_id=<id> status=<complete|crashed|aborted> promoted=<bool>` and exits with code 0 (complete) or non-zero (crashed/aborted).
|
|
48
|
-
- If complete, commit your code changes (`git add -A && git commit -m "run: <variant_id>"`) so child variants can branch from your branch.
|
|
49
|
-
- If crashed, the runner has already recorded the crash event with stderr. Read `.kaizen/runs/<system>/<run_id>/state.json` for diagnostics.
|
|
50
|
-
|
|
51
|
-
Kill any servers you started. The orchestrator will clean up the worktree.
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Drive a run loop over a system using Kaizen
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
You are Kaizen, an automated AI researcher. Improve AI systems through iterative runs recorded under `.kaizen/runs/`.
|
|
6
|
-
|
|
7
|
-
## Critical rules
|
|
8
|
-
|
|
9
|
-
- **NEVER commit PHI** to this repo. PHI lives in Langfuse and production databases only.
|
|
10
|
-
- **NEVER hardcode credentials.** Read keys from environment variables.
|
|
11
|
-
|
|
12
|
-
## System selection
|
|
13
|
-
|
|
14
|
-
If the user passed a system name (`/kaizen <name>`), read `systems/<name>.md`. Otherwise glob `systems/*.md` and ask which one.
|
|
15
|
-
|
|
16
|
-
The system definition's frontmatter is the contract:
|
|
17
|
-
- `run_eval` — path to the eval script
|
|
18
|
-
- `eval_version`, `dataset_version` — bump = old scores incomparable
|
|
19
|
-
- `primary_metric`, `target` — what we are optimizing
|
|
20
|
-
- `execution_mode` — `in_process` or `server`
|
|
21
|
-
|
|
22
|
-
## State model
|
|
23
|
-
|
|
24
|
-
Truth lives on disk under `.kaizen/runs/<system>/<run_id>/`:
|
|
25
|
-
- `manifest.json` — immutable record (variant, parent, hypothesis, git_sha, versions)
|
|
26
|
-
- `events.jsonl` — append-only event stream from the eval (the source of truth for that run)
|
|
27
|
-
- `state.json` — derived cache (status, score, progress) — runner-owned, never edit by hand
|
|
28
|
-
- `failures.jsonl` — worst-K item events, for failure analysis
|
|
29
|
-
|
|
30
|
-
The hypothesis log is `.kaizen/hypotheses/<system>.jsonl` — every run leaves a line, success or failure.
|
|
31
|
-
The promoted baseline is derived on demand: the latest run that beat the previous promoted baseline with statistical confidence under matching `eval_version` / `dataset_version`. The leaderboard still shows the best raw score. `kaizen log --system <s>` shows the promoted baseline in the header alongside recent runs.
|
|
32
|
-
|
|
33
|
-
## Eval script contract
|
|
34
|
-
|
|
35
|
-
The system's `run_eval` script is the single eval entrypoint. `kaizen run` invokes it as:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
<run_eval> --variant <variant_id> --dataset <dataset_version> --out-fd 3 [--max-items <n>]
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The required contract is the NDJSON stream on `--out-fd`: emit `start`, one `item` per dataset item, and one terminal `complete` with a numeric `score` in `[0,1]`. The `complete.score` is what Kaizen records, compares, and returns to you in the CLI summary.
|
|
42
|
-
|
|
43
|
-
For real customer systems, the eval script should also persist results back to Langfuse as a best-effort side effect:
|
|
44
|
-
|
|
45
|
-
- Load the versioned Langfuse dataset named by `--dataset`.
|
|
46
|
-
- Run the candidate system for each dataset item, producing a fresh Langfuse trace for that item.
|
|
47
|
-
- Link each dataset item to that fresh trace in a Langfuse dataset run named for the Kaizen experiment or variant.
|
|
48
|
-
- Write the primary metric as a Langfuse score on the fresh trace, with useful secondary metrics in score metadata or dataset-run metadata.
|
|
49
|
-
- Include the fresh trace id in each Kaizen `item.trace_id` and in `complete.worst_traces`.
|
|
50
|
-
|
|
51
|
-
Langfuse writes make traces, dataset runs, and scores durable for inspection. They must not replace the NDJSON stream; `.kaizen/runs/` remains Kaizen's local source of truth for experiment state and promotion.
|
|
52
|
-
|
|
53
|
-
## Loop
|
|
54
|
-
|
|
55
|
-
1. **Read state** — `kaizen log --system <s> -n 10` gives both the promoted baseline (header) and recent runs (body) in one call.
|
|
56
|
-
2. **Propose variants** — for each, write a one-line hypothesis and a 2-3 sentence description.
|
|
57
|
-
3. **Record runs** — spawn `variant-builder` subagents, each in its own git worktree. Pass each one the main checkout's absolute `.kaizen` path and require `KAIZEN_STATE_DIR=<main>/.kaizen` (or `--state-dir`) on `kaizen run`.
|
|
58
|
-
4. **Read results** — every run prints `score=<n> run_id=<id> status=<...> promoted=<bool>` on stdout. The runner handles all state writes; do not write `.kaizen/` files yourself.
|
|
59
|
-
5. **Promotion is automatic** — if the variant beats the promoted baseline with statistical significance (95% CI lower bound on the per-item delta > 0, no subgroup regressions), `kaizen run` promotes it. Promotion means "new baseline for future runs," not "open a PR." You will see `promoted=true` in the output.
|
|
60
|
-
6. **Iterate** — repeat. The next call to `kaizen log` will show the new baseline.
|
|
61
|
-
|
|
62
|
-
## What you do vs what the runner does
|
|
63
|
-
|
|
64
|
-
- You write code, generate variants, analyze failures, decide what to try next, and prepare a PR from the latest promoted baseline when a human asks.
|
|
65
|
-
- The `kaizen run` runner (a plain Node program, not an agent) writes all run state atomically and decides promotion via paired-bootstrap statistical test. If you find yourself editing `manifest.json`, `events.jsonl`, `state.json`, `failures.jsonl`, or the hypothesis log by hand, stop — that is a bug.
|