mirror of
https://github.com/JuliusBrussee/cavekit.git
synced 2026-09-14 16:32:40 +08:00
499205d2e0
Introduces the machinery that turns /ck:make into a hands-off autonomous
loop without changing the Hunt methodology. Nothing in existing commands,
skills, or agents breaks; the new layer is additive and opt-in.
New runtime (scripts/):
- cavekit-tools.cjs — state machine, lock with heartbeat, token ledger,
task registry, routing, capability discovery, backprop directive,
status-block dashboard. Zero runtime deps.
- cavekit-router.cjs — five-axis task scoring mapped to haiku/sonnet/opus
tiers with role baselines and budget-pressure demotion.
New hook system (hooks/):
- stop-hook.sh — Stop-event driver; reads .cavekit/state, routes the next
prompt, returns {decision:"block",reason:...} to keep the session going
until <promise>CAVEKIT_COMPLETE</promise> is emitted or a budget trips.
- token-monitor.sh — per-task budget (80% warn, 100% halt).
- tool-cache.js / tool-cache-store.js — 120s TTL cache for read-only tools.
- test-output-filter.js — condense test output around failure lines.
- auto-backprop.js — write flag file on test failure; stop-hook prepends
a backpropagation directive on the next iteration.
- progress-tracker.js — zero-stdout snapshot for /ck:watch.
- hooks.json — registers all of the above (Stop + PreToolUse + PostToolUse).
New skills (skills/):
- karpathy-guardrails — four behavioral rules (think-before-code, simplicity,
surgical, goal-driven) enforced by reviewer and task-builder.
- caveman-internal — three intensity modes (lite/full/ultra) for
machine-to-machine artifacts, with budget-pressure auto-selection and a
verbose-regeneration fallback. Separate from the user-facing /caveman skill.
- backpropagation — six-step bug-to-kit trace; auto-triggered by the
auto-backprop hook or manually via /ck:backprop.
- complexity-detection — five-axis scoring rubric; depth mapping
(0-6 quick / 7-13 standard / 14+ thorough).
- autonomous-loop — end-to-end loop reference (state files, sentinels,
lock protocol, debugging).
- capability-discovery — MCP + plugin + CLI detection, writes
.cavekit/capabilities.json.
- graphify-integration — optional knowledge-graph queries; degrades to grep
when graphify-out/graph.json is absent.
New commands (commands/):
- /ck:watch — live dashboard.
- /ck:resume — recover from crash, lock conflict, or interrupt.
- /ck:backprop — manual entry to the backpropagation skill.
- /ck:review-branch — two-pass (kit + code) branch review, optional Codex.
- /ck:setup-tools — run capability discovery and summarize.
New agents (agents/):
- complexity — haiku-only classifier, returns JSON score.
- verifier — goal-backward verification with stub detection.
- researcher — multi-source research brief with citations.
Templates (templates/):
- state.md, config.json, task-status.json, spec-kit.md — seed files that
commands copy into .cavekit/ or context/ on init.
Config (scripts/bp-config.sh):
- Adds session_budget, max_iterations, task_budget_{quick,standard,thorough},
auto_backprop, tool_cache(+_ttl_ms), test_filter, progress_tracker,
parallelism_max_{agents,per_repo}, model_routing, graphify_enabled.
- Extends caveman_phases validator to accept review and verify.
Plugin manifest (.claude-plugin/):
- plugin.json + marketplace.json for the marketplace discovery path.
Existing root plugin.json bumped to 2.1.0; install.sh version strings
bumped to match.
Tests (tests/):
- 34 zero-dep Node.js tests covering frontmatter round-trip, state
merging, lock acquire/heartbeat/steal/release, per-task + session
budget, task registry with dependency ordering, routing sentinels,
router tier bands, preset matrix, and deep-merged config loading.
- Runner: `node tests/run-tests.cjs`.
No changes to existing /ck:sketch, /ck:map, /ck:make, /ck:check, or any
existing skill/agent — this commit strictly adds the runtime layer beneath
them.
https://claude.ai/code/session_018edLvsv8JE9947oFiBXyHS
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
"use strict";
|
|
const assert = require("assert");
|
|
const { parseFrontmatter, serializeFrontmatter } = require("../scripts/cavekit-tools.cjs");
|
|
|
|
function parses_basic_frontmatter() {
|
|
const { meta, body } = parseFrontmatter(
|
|
"---\nphase: building\niteration: 3\n---\nhello\nworld\n"
|
|
);
|
|
assert.strictEqual(meta.phase, "building");
|
|
assert.strictEqual(meta.iteration, 3);
|
|
assert.strictEqual(body.trim(), "hello\nworld");
|
|
}
|
|
|
|
function handles_quoted_strings_and_booleans() {
|
|
const { meta } = parseFrontmatter(
|
|
`---\ntitle: "Hello: world"\nflag: true\nother: null\n---\n`
|
|
);
|
|
assert.strictEqual(meta.title, "Hello: world");
|
|
assert.strictEqual(meta.flag, true);
|
|
assert.strictEqual(meta.other, null);
|
|
}
|
|
|
|
function serialize_roundtrip() {
|
|
const meta = { phase: "building", iteration: 7, tags: ["a", "b"] };
|
|
const out = serializeFrontmatter(meta, "body\n");
|
|
const { meta: round } = parseFrontmatter(out);
|
|
assert.strictEqual(round.phase, "building");
|
|
assert.strictEqual(round.iteration, 7);
|
|
assert.deepStrictEqual(round.tags, ["a", "b"]);
|
|
}
|
|
|
|
function serializer_quotes_ambiguous_strings() {
|
|
const meta = { bool_looking: "true", num_looking: "42" };
|
|
const out = serializeFrontmatter(meta);
|
|
assert.ok(out.includes('bool_looking: "true"'));
|
|
assert.ok(out.includes('num_looking: "42"'));
|
|
}
|
|
|
|
module.exports = {
|
|
parses_basic_frontmatter,
|
|
handles_quoted_strings_and_booleans,
|
|
serialize_roundtrip,
|
|
serializer_quotes_ambiguous_strings,
|
|
};
|