Skip to content

Latest commit

 

History

History
189 lines (152 loc) · 8.69 KB

README.md

File metadata and controls

189 lines (152 loc) · 8.69 KB

Command Code Mods

A composable suite of Command Code mods: self-verifying and self-improving.

Agent configurations rot silently — a prompt change quietly breaks a workflow and nobody notices until output quality drops. These mods carry their own verification so a change either proves itself or fails loudly.

What you get

  • Composable mods with a shared verification contract
  • Self-checking prompts and routing rules
  • Works with Command Code's mod surface

A composable suite of agent mods that turn Command Code into a self-verifying, self-improving engineering system.

At a glance. finish-line rides the normal loop and speaks only when a run is about to claim success with nothing behind the claim. debrief reads the receipts those runs leave behind, drafts a reusable procedure, and promotes it to a project skill after three independent sightings. instrument turns their telemetry into health reports and improvement proposals, at user scope. No mode to enter, no command you have to remember, no flags.

contract check License: MIT

The loop

work ──► gate ──► continue ──► summary ──► suggest
                     │
                     └──► episode ──► (next session) draft ──► 3 sightings ──► skill

finish-line

  1. Work. No intervention.
  2. Gate. When the run would end naturally: did a check run after the last change, and did it exit green? If not, the mod asks once for the project's own check. If that still doesn't happen, it runs the check itself — announced, capped at five minutes. Red sends the failure back once; a second stop ends the run marked UNVERIFIED.
  3. Continue. If the todos built-in mod is enabled and its checklist has open items, the mod continues with the next one. Up to five, one per distinct item, never after a failure, never above 85% context.
  4. Summary. One row: verified or unverified, the command that proved it, the files, continuations, vetoes, and the real cache hit rate.
  5. Suggest. After a verified run, one small completion proposes up to three next steps. It cannot start them.

The invariant: a run may claim success only when a verification command ran after the last change and exited green. Otherwise the summary says UNVERIFIED and names the command that would prove it.

Every verified run with changes also appends one structured episode to .agents/learning/episodes.jsonl — the receipt the learner reads.

debrief

  • Signals, not guesses. Only verified runs with a correction qualify: a check failed then passed, the same input failed twice, the gate caught an unverified "done", or a shared-state veto fired.
  • One batch per session. At session start, a single cmd.model.complete reads up to five unprocessed episodes. No turn, no transcript entry, no tools.
  • Mechanical validation. Every fenced command must appear verbatim in the evidence; names, description length, body size, sections, secrets, bidi characters, and injection phrases are all checked. A draft that invents a flag is discarded.
  • Three sightings. A lesson is fingerprinted from the evidence (failing command + error class + check), so phrasing never matters. Three distinct episodes promote it to .agents/skills/<slug>/SKILL.md, where Command Code discovers it natively. Three matching episodes in one batch promote immediately.
  • Ownership. Promoted skills carry .managed.json. A skill debrief didn't write is never touched, edited, or archived.
  • Usage. activate_skill tool calls and skill_loaded events increment usage.json (uses, first/last used, contradictions). A SKILL.md mtime is the fallback for older skills.
  • Curation, never deletion. Soft cap of 15 managed skills; at the cap promotion pauses and /debrief audit suggests merges and archive candidates. /debrief archive <name> moves a skill to .agents/learning/archive/<stamp>/; /debrief pin <name> exempts it.
  • Journal. .agents/learning/journal.md — chronological, mechanical, append-only, unbounded. No model writes a line in it.
  • Taste stays native. Preference-shaped lessons go to suggestions.md and a status count; never a skill, never an AGENTS.md write.

instrument

  • User-level telemetry. Every mod appends one JSON line per event to ~/.commandcode/mods/.telemetry/events/<date>.jsonl — counts, timings, and categories, never prompts, code, absolute paths, or secrets. Daily files, 30-day retention.
  • Two tiers. A deterministic health.md with rates and sample sizes, and a model pass that reads only the computed digest and returns at most three findings, each with a hypothesis, the exact function to change, and a testable acceptance criterion. Findings citing a metric that isn't in the digest are dropped.
  • Threshold-triggered, at most once a day. /instrument report is deterministic, /instrument analyze forces the model pass, /instrument issue writes a sanitized, copy-ready issue body (project keys only).
  • It never edits a mod. Findings point at mods/*.ts; the fix goes through contracts, tests, and sync in a normal task.

The rule for the package: a new mod must declare TELEMETRY_SCHEMA, declare MOD_VERSION matching package.json, and emit at least one event. CI enforces all three, so the package improves as it grows.

Install

commandcode mods add -g FishRaposo/command-code-mods
commandcode mods list    # three mods, zero load warnings

Project scope: drop -g. Each mod is standalone: finish-line alone gives the full gate and keeps writing episodes; debrief alone tracks usage and curates existing skills; instrument alone reads an empty stream. Install all three and the package closes its own loop.

Requirements: the Command Code CLI. Node 22.6+ is needed only to run this repo's checks and tests.

Configuration

None required.

  • /finish-line — gate status; /finish-line off|on persists.
  • /debrief — learning status; /debrief audit, /debrief archive <name>, /debrief pin <name>.
  • /instrument — package health; /instrument report, /instrument analyze, /instrument issue.

Security

  • finish-line's fallback runs the project's own configured check (package.json scripts, Makefile, Cargo.toml, go.mod, pyproject.toml, dotnet) through the harness runtime. That is arbitrary code from the repository you opened — announced first, bounded to five minutes, only after the agent was asked and didn't.
  • debrief writes project files: drafts under .agents/learning/, and promoted skills under .agents/skills/. Model output is data: it is validated mechanically, secrets are redacted, bidi and injection language are rejected, and a skill is only promoted after three independent episodes. Nothing is ever deleted.
  • instrument keeps telemetry at user scope, never inside a project. Records are counts, timings, and categories; the shareable issue body uses hashed project keys only.

See SECURITY.md for the full trust model.

Efficiency

  • Zero system-prompt bytes from either mod. The contract check fails the build if appendSystemPrompt or transformSystemPrompt appears.
  • One-shot tail injections only — resume brief, post-compaction anchor, context-pressure note.
  • One learning completion per session, not per run; drafts sit outside the skills tree and cost no prompt tokens.
  • No re-runs. A check that is still green for an unchanged file set is not run again.
  • Measured, not claimed. Summaries report cache read/write from the provider's own usage numbers.
  • Telemetry is one line per run, user-level and bounded at 30 days; the analysis pass runs at most once a day and only when a threshold fires.

Repository

mods/finish-line.ts   the gate (~1,300 lines)
mods/debrief.ts       the learner (~1,250 lines)
mods/instrument.ts    package telemetry and health (~1,150 lines)
tests/                node --test coverage, including simulated multi-session loops
scripts/              contract check + user-scope sync
legacy/               archived nine-mod suite (reference only, not shipped)

Contributing

See CONTRIBUTING.md. Short version: a behavior change needs an entry in CHANGELOG.md in the same commit, npm run contracts and npm test must pass, and all three mods must load with zero warnings.

License

MIT

Built by Vinícius Raposo — more work, and contact for fixed-price engagements.