Skip to content

dojo CLI overnight fest — genius-protocol-by-default + correctness/security hardening - #2

Merged
DojoGenesis merged 23 commits into
mainfrom
dojo-cli-fest-20260716
Jul 16, 2026
Merged

dojo CLI overnight fest — genius-protocol-by-default + correctness/security hardening#2
DojoGenesis merged 23 commits into
mainfrom
dojo-cli-fest-20260716

Conversation

@DojoGenesis

Copy link
Copy Markdown
Owner

The dojo-cli-fest-20260716 overnight fest — 23 commits, every wave gated green (build · vet · uncapped-lint · test). Nothing here was published or deployed.

What's in it

  • Genius protocol by default — an embedded L0 protocol doc injected each session; DOJO.md overlay override + DOJO_PROTOCOL_DISABLED; a JIT tell-triggered nudge (config-vs-code gate on wiring errors, debugging gate on repeated build/test failures); /protocol show|edit.
  • Correctness + security — P0 error-swallowing, a Gemini key leak, a path-traversal, a panic, and a /disposition brick, all fixed.
  • Root-cause fix — a non-hermetic test was overwriting ~/.dojo/settings.json on every go test; fixed with package TestMain HOME isolation (3a7cd64).
  • Activation + UX — SessionStart lifecycle, /doctor, session resume (--resume / --session), full shell tab-completion, token readout, /code undo, markdown rendering, opt-in verify-loop.

Verification

Every wave was gated green: go build ./..., go vet ./..., uncapped golangci-lint, go test ./.... Built + installed from this branch and dogfooded live against the gateway on :7340.

Refs DGS-74. This PR closes only the "review + merge the branch" follow-up; the others on DGS-74 (re-set the ~/.dojo gateway token, optional Gateway system_prompt wire field) remain open.

🤖 Generated with Claude Code

TresPies-source and others added 23 commits July 16, 2026 03:39
Fix all golangci-lint findings (errcheck/staticcheck/unused) across the module so the milestone-gate lint layer passes and the CLI can be release-tagged. Behavior-preserving. Uncapped total exceeded the capped default view; final sweep closed client/repl/spirit/skills stragglers the per-package pass could not see.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
P0: gateway error events were swallowed (blank output, exit 0); EventError now renders visibly and one-shot exits non-zero in both text and --json. REPL prints the real stream error, not a canned string. Ctrl+C mid-response cancels only that turn (per-turn context) and returns to the prompt instead of ending the session; idle Ctrl+C quits. --plain/--json drop the thinking placeholder and welcome banner; --json warns without --one-shot. Added a per-chunk stream stall watchdog and FriendlyError for connection/auth failures. Bare 'dojo version'/'help' now work.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hygiene

/help rebuilt into 13 grouped sections covering all 34 commands (previously omitted /craft, /guide, /tools and many subcommands). /health and /home label 401/403 as auth-failed and 5xx as gateway-error instead of always 'unreachable'. Removed stale --trace guidance, the dead bloom 'garden' alias, and the phantom /garden harvest verb; /projects documents its no-arg behavior; /session <id> no longer overclaims.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
/craft adr and claude-md --fix capture the streamed content and write files (with confirmation); memory prune actually deletes; seed elevate stores to memory; scaffold confirms before writing; harvest is honest about being a list. craftStream now surfaces gateway event:error instead of silently producing nothing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…panic

Move the Gemini API key from the URL query string to the x-goog-api-key header so it cannot leak into Go's url.Error text on network failures. Contain /project artifact filenames within the artifacts root (a traversal also created intermediate dirs via AtomicWriteFile's MkdirAll). Guard ref[:12] against short refs that panicked /skill package-all. Dedup the /run DAG poll loop with a clean cancel message.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…shell

/disposition set validates against the same merged preset source /disposition ls shows; config.Load degrades an invalid disposition to the default (with a warning) instead of refusing to start (a typo or file-preset name previously bricked every launch). Gateway wiring errors still hard-fail. DOJO_TELEMETRY_DISABLED disables the telemetry sink, which now discloses its endpoint once. Hook exec uses cmd /C on Windows; invalid matcher globs are logged, not silently dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… at init

New internal/protocol package embeds an L0 operating-discipline doc (the workspace's 8 gates as tells) and injects it once per session into chat and one-shot requests: inline-prepend for immediate effect plus a new ChatRequest.system_prompt field for when the gateway supports it. On by default; override with project ./DOJO.md or DOJO_PROTOCOL_DISABLED=1 / DOJO_PROTOCOL_PATH. /init installs kata-harness (ratified) + bring-loop/community-skills/dojo-craft and writes an overridable ~/.dojo/DOJO.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A hooks.json using the Claude-Code wrapper shape ({hooks:{...}}) — e.g. kata-harness — previously threw a swallowed unmarshal error and loaded zero rules. Now both wrapper and flat schemas parse; CC event names map to dojo's five (PreToolUse->PreCommand, PostToolUse->PostCommand, SubagentStop->PostAgent, SessionEnd->SessionEnd); events with no dojo equivalent are skipped with a logged note, not guessed to the wrong lifecycle point.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Read-only diagnostic printing OK/WARN for gateway reachability, per-provider status (surfacing the 'gateway healthy but a provider is 429/404' blind spot), config basics, and plugin/hook counts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s fire

dojo had no session-start hook event, so an installed harness's SessionStart hook (e.g. kata-harness) parsed but could never fire. Add EventSessionStart, fire it at REPL start with SessionEnd deferred across all exit paths, and map Claude-Code SessionStart to it in the plugin scanner. One-shot stays unfired to protect the --json contract. Also gate the --plain 'Last session:' hint. Verified live: a real kata-shaped plugin's hooks execute on a run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ition discipline

Env overrides (DOJO_PROTOCOL_DISABLED, DOJO_GATEWAY_URL, etc.) were applied to the same fields Save() serializes, so a later Save() (/model set, /disposition set) baked the transient value in — this silently disabled the protocol on disk during testing. Load() now records env overrides in an unexported (unmarshaled) slice; Save() restores the pre-env file/default value for any field still holding its env value, keeping fields the user explicitly changed. Adds a 5th DispositionPreset field (Discipline). Regression-tested against a reverted naive Save().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add PROTOCOL (enabled + source; WARN when silenced) and HARNESSES (kata-harness installed?) sections so a disabled protocol or missing harness is visible rather than silent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s.json

A package TestMain now points HOME at a temp dir. Several commands call cfg.Save() (e.g. /disposition set); unisolated tests were overwriting the developer's real settings.json on every 'go test ./...' — writing gateway.url=http://test:7340 and protocol.enabled=false, the source of the spurious 'lookup test: no such host' failures seen while dogfooding. Fixed at the package level so any future Save-triggering test is safe.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RenderMarkdown(full, plain) styles assistant markdown (code fences, lists, headings) width-aware when interactive, raw passthrough under --plain/--json. Live streaming and Render/RenderJSON/ClassifyChunk are unchanged; end-of-turn wiring follows separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ssion

state keeps a bounded (20) de-duplicated session history recorded transparently on Save(). /session ls lists recent sessions (active marked); /session resume <id> switches to a specific id (warn-but-allow); new --session <id> launch flag resumes via the existing resume path with no repl.New signature change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Completer now covers /craft, all guide IDs (from guide.All so it can't drift), /doctor, /protocol, /session ls, /code undo, /model direct, /settings effective|profile, /skill search|package-all, /home plain; removed stale /garden harvest and /projects ls. Adds a dim interactive-only per-turn token/latency footer that reads usage in three shapes — a graceful no-op until the gateway attaches usage data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
git restore of unstaged changes to tracked files within the project root, after showing the diff and confirming. Staged content, history, and untracked files are structurally untouched; clean errors when git is missing or not a repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
/protocol status shows protocol + kata-harness state; /protocol harnesses lists the KE catalog (portable: KE_CATALOG_PATH -> home-relative -> embedded snapshot); /protocol install <name> copies a ratified, locally-available harness plugin into ~/.dojo/plugins with confirmation. Never runs operator-gated ke promote/publish.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l get and /doc

Moves RenderMarkdown out of package repl into a new internal/mdrender package (gated on gcolor.Enable, no plain param) so package commands can use it without an import cycle. /skill get and /doc now glamour-render fetched markdown when color is enabled, raw under --plain/--no-color.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l completions

/help gains a Protocol section + the new commands; README documents them plus genius-protocol-by-default behavior; zsh/bash/fish completions include /doctor and /protocol.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nudge

Verify.AfterAgent (opt-in, env-transient) runs go build + go test after a successful /agent dispatch or /run and prints [verify] PASS/FAIL. On a gateway error whose text matches a wiring/boundary signature (connection refused, 401/403, 404, dial tcp, model-not-found), the REPL surfaces the single relevant config-vs-code gate as a dim [protocol] nudge — once per gate per session, suppressed under --plain and when the protocol is disabled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…build/test failures

TellFor now also maps build/test/panic/compile signatures to the debugging gate (state the causal chain + cheapest on/off experiment), with stable per-gate keys so wiring and debugging de-dupe independently; wiring wins on ties. The REPL tracks a normalized error signature and, after the same failure recurs 3x, surfaces the debugging gate once. Suppression under --plain and when protocol is disabled still holds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
/protocol show prints the currently-effective protocol doc (project ./DOJO.md > ~/.dojo/DOJO.md > embedded default) glamour-rendered, with a WARN when the protocol is disabled. /protocol edit opens the writable overlay in $EDITOR/$VISUAL (creating it from the default if absent, never clobbering; safe argv handling; guidance fallback when no editor is set).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DojoGenesis
DojoGenesis merged commit e4db7d9 into main Jul 16, 2026
2 checks passed
@DojoGenesis
DojoGenesis deleted the dojo-cli-fest-20260716 branch July 16, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants