feat(autodev): autodev.toml schema reader + parameterised hook prompt#17
Merged
Conversation
Phase 2-4 of the autodev hook redesign. The hook now reads
`<project>/.clawtool/autodev.toml` and emits a project-parameterised
continuation prompt instead of the historical hardcoded clawtool-flavored
template.
Pipeline order in `runAutodevHook` (see in-source comment for the full
docblock):
1. cwd guard — exit 0 silently when no marker resolves upward from $PWD
2. config load — parse the marker; fail-soft to defaults on read or parse
error so a broken TOML does not silently disarm the hook
3. enabled guard — exit 0 silently when `enabled = false` (operator-pause)
4. arm-flag guard — exit 0 silently when `autodev.enabled` flag absent
5. cap guard — emit cap-reached message and exit when counter exceeds
per-session cap (project override or 200 default)
6. fire — increment counter, emit parameterised prompt
Schema (forward-compatible — fields documented in `docs/autodev.md` arrives
in a follow-up):
name string surfaces as `Project: <name>` line
enabled *bool nil → true; &false → operator-pause
cap_per_session int overrides global 200 cap; non-positive → 200
[loop] steps []str numbered list in the prompt; empty → historical
5-step clawtool fallback
[loop] stop_command str surfaced in cap-reached + step fallback;
empty → /clawtool-autodev-stop default
Backwards-compat:
- A minimal marker file (just `name = "..."`) parses cleanly and yields the
historical prompt content via the steps-fallback. No operator action
required for existing armed projects whose markers omit `[loop] steps`.
- The `.clawtool/autodev.toml` shipped in this repo last commit is fully
schema-compliant; verified by `TestRunAutodevHook_RealClawtoolMarker_
ParsesCleanly`.
Tests (10 new, all 15 in the suite race-clean):
- TestLoadAutodevConfig_FullSchema
- TestLoadAutodevConfig_DefaultsWhenFieldsMissing
- TestLoadAutodevConfig_DisabledExplicit
- TestLoadAutodevConfig_NonPositiveCapClamped
- TestLoadAutodevConfig_FailsSoftOnMalformedTOML
- TestLoadAutodevConfig_FailsSoftOnMissingFile
- TestRunAutodevHook_DisabledExplicit_ExitsZero
- TestAutodevHookPrompt_CustomLoopStepsRendered
- TestAutodevHookPrompt_DefaultStepsFallback
- TestRunAutodevHook_RealClawtoolMarker_ParsesCleanly
Verified clean: gofmt, go vet, go test -race ./internal/cli/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2-4 of the autodev hook redesign. Builds on PR #16 (cwd guard) by adding the schema reader for
<project>/.clawtool/autodev.toml, parameterising the continuation prompt, and adding theenabled = falseoperator-pause path.Pipeline order in
runAutodevHookSchema
Backwards-compat
name = "..."alone) parses cleanly. Empty[loop] steps→ historical 5-step clawtool fallback. No operator action required for existing armed projects..clawtool/autodev.tomlshipped in PR feat(autodev): cwd guard —.clawtool/autodev.tomlas project opt-in marker #16 is fully schema-compliant; verified byTestRunAutodevHook_RealClawtoolMarker_ParsesCleanly(regression guard against schema breakage).Files
internal/cli/autodev_config.go(+105 lines) —autodevConfigstruct,loadAutodevConfig, the threeeffective*helpersinternal/cli/autodev.go(+94/-17 lines) — pipeline ordering inrunAutodevHook,autodevHookPrompt(triggerN, cfg)parameterisation,renderAutodevLoopStepshelper with historical fallbackinternal/cli/autodev_config_test.go(+330 lines) — 10 new tests covering schema parse paths, fail-soft cases, prompt rendering, the live clawtool markerVerification
What this unlocks
.clawtool/autodev.toml, save, next turn-end picks up the new template.enabled = falselets an operator pause the loop in a specific project without removing the marker (which would also drop forward-compat schema fields).--include-featuresideator flag) now has a place to plug into:[loop] stepscan referenceclawtool ideate --include-featuresonce that source-tier ships.Wiki context
ADR-037 (
wiki/decisions/037-autodev-hook-redesign.md, gitignored). This PR ships axes 2-4 of the four-axis design; the firing pipeline in §3 is now in place. ADR-037 §3 axes still pending: quiet-state gate (§3a), substrate probe code/wiki/stalled mode selection (§3b),autodev.lockJSON staleness rules (§3c). Those land in follow-up PRs.Hygiene
Commit ran via
mcp__clawtool__Commit(Conventional Commits + pre_commit rules.toml gate). gofmt-clean and race-clean rules trigger on this changeset (Go files touched) — both verified clean above. No internal-doc-id leakage in user-facing surfaces (CLI help, command help, prompt template). The[[037 Autodev hook redesign]]reference in the in-source comment is intentional — it's a Go source comment, not a user-facing surface, and the ADR is the canonical design record for this code.