Expand description
Harness packaging for ctx harness (Claude Code integration).
This module scaffolds hook scripts, settings, skills, and plugin
manifests from templates embedded in the binary (templates), stamps
every generated file with a version header and checksum (checksum),
guards generated hooks against version skew (compat), and diagnoses
the whole integration (doctor).
§Ownership model
init records a checksum for every file it writes – in the file itself
(comment header) where the format allows comments, and always in the
.ctx/harness.lock manifest. On re-run, each planned file is classified:
- Missing: written.
- Owned, unmodified (checksum matches): regenerated in place.
- Owned, modified (checksum mismatch): warned about and skipped;
--forceoverwrites. - Foreign (exists but no ctx checksum anywhere): warned about and
skipped;
--forceoverwrites.
Exception: .ctx/rules.toml encodes user policy and is never
overwritten once it exists, not even with --force.
Modules§
- checksum
- Generated-file headers and content checksums for
ctx harness. - compat
- Version compatibility check for
ctx harness compat. - doctor
ctx harness doctor– integration diagnostics.- templates
- Embedded templates for
ctx harness init.
Structs§
- Generated
File - One file
initplans to write: final content (header + checksum already applied) plus write metadata. - Lock
Entry - One manifest entry: the checksum and generator version of a file.
- Lock
File - The
.ctx/harness.lockmanifest: rel_path -> entry.
Enums§
- File
Action - What
write_plandid with one planned file. - Mode
- Scaffolding mode.
- Settings
Wire Action - Outcome of merging the ctx snippet into
.claude/settings.json. - Target
- Harness targets (mirrors the CLI enum; only Claude Code for now).
Constants§
- HOOK_
NAMES - The three hook script basenames (shared by local and plugin modes).
- LOCAL_
HOOKS_ DIR - Directory holding the local-mode hook scripts.
- LOCK_
PATH - Relative path of the harness manifest.
- RULES_
PATH - Relative path of the starter rules file.
Functions§
- plan_
codex_ local - plan_
codex_ plugin - plan_
local - Plan the files for
--mode local: hook scripts under.claude/hooks/ctx/plus a starter.ctx/rules.toml. - plan_
plugin - Plan the files for
--mode plugin: a full Claude Code plugin scaffold. - read_
lock - Read and parse the manifest;
Nonewhen missing or unparseable (a broken manifest falls back to in-file checksum verification). - render_
agents_ md_ block - render_
claude_ md_ block - Render the CLAUDE.md guidance block printed to stdout in local mode.
- render_
settings_ snippet - Render the settings snippet printed to stdout in local mode.
- wire_
local_ settings - Merge the ctx hooks + permissions snippet into
.claude/settings.json. - write_
plan - Write a plan to disk, honoring the ownership model, and update
.ctx/harness.lock.