fix(init): validate --lang and --title and quote the title per file #278
No reviewers
Labels
No labels
bug
enhancement
needs-triage
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle!278
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/271"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #271
What changed
Validation before any write.
initcmd.Runchecks--langwithpagepath.ValidLangTagand checks--titlefor control characters before it scans or plans anything. A refusal is a*initcmd.UsageError, andharness initmaps it to exit 2 (harness init: --lang: "Bad Code" is not a valid language code: …). Nothing is written: an absent target stays absent and an empty one stays empty. A non-empty target still exits 1.Each file gets the value in its own format. The scaffold templates no longer put quotes around the markers:
harness.yamluses@@TITLE_YAML@@,@@LANG_YAML@@and@@LANG_LABEL_YAML@@, written as single-quoted YAML scalars.hugo.tomluses@@TITLE_TOML@@and@@LANG_TOML@@, written as TOML strings.AGENTS.mdkeeps the raw@@TITLE@@.Substitution runs in one
strings.Replacerpass. Output for the default title and language is byte-identical to before, and a test pins it.One owner for each rule.
checkCode,checkLabel,tomlQuoteandyamlQuotemoved frominternal/langcmdto a newinternal/configvaluepackage asCheckLangCode,CheckOneLine,TOMLandYAML. Bothlangcmdandinitcmdcall them.lang addmessages are unchanged.Docs. The
initbullet indocs/harness.mdnow covers the validation, the exit-2 refusals and the per-file quoting.docs/agents/docs-map.mdlists the new package. The skills (setup-site,migrate-site,redo-theme) mentioninitonly as a step that has already run, so they need no change.README.mdandscaffold/site/AGENTS.md(apart from its template marker) are untouched.Verification
internal/initcmd:--langvalues and for titles containing\n,\tand\x07, each checking that the target is untouched.',",\,''and non-ASCII titles throughsiteconfig.Load, Hugo's TOML decoder and theAGENTS.mdheading.internal/configvalue: table tests for both renderers and both checks.cmd/harness: exit 2 and the stderr message for each refused flag value.go vet ./...is clean andgo test ./...passes. The subagent also ran the suite with Hugo 0.167.0 extended on PATH, so the hugo-build tests ran instead of skipping.--langvalues and the multi-line title exit 2 and leave no directory.--title "Bob's Site"exits 0.harness checkreportsok: no problems found,harness.yamlhastitle: 'Bob''s Site'andhugo.tomlhastitle = "Bob's Site".harness serveon the new site.Note
The title refusal reads
harness init: --title: title "…" contains a line break or control character. The shared message format is<what> %q contains …, and theUsageErroradds the flag prefix in front of it.🤖 Generated with Claude Code
[autoland] verdict: pass
Verdict: CONCERNS (non-blocking). Approved, not merged.
Signal relied on:
labctl pr checks 278reportedsuccess.ci / build-and-testinstalls Hugo 0.167.0 extended and runsgo vet ./...,go test ./...andgo build, so the hugo-build tests ran as well. Nothing was re-run locally.Conventions:
Closes #271: present.*UsageErrormaps to exit 2, the rules moved tointernal/configvalueandlangcmdcalls them, the templates no longer carry quotes, and the default output is pinned byte for byte.Concern:
docs/features.md:32is now stale. It still says "@@TITLE@@,@@LANG@@,@@LANG_LABEL@@and@@HUGO_VERSION@@are substituted in exactly five files". This PR removes@@LANG@@and@@LANG_LABEL@@, and the templates now use@@TITLE_YAML@@,@@TITLE_TOML@@,@@LANG_YAML@@,@@LANG_TOML@@and@@LANG_LABEL_YAML@@(internal/initcmd/init.go:51-59,scaffold/site/harness.yaml,scaffold/site/hugo.toml). The line should list the current markers, or say that each_YAML/_TOMLmarker receives a complete rendered scalar. Per CLAUDE.md "Every fact has one document", keeping that prose true is part of the change. No drift test catches it.Note (not a concern): the issue's grep criterion still finds
func yamlQuoteininternal/content/apply_yaml.go:315. That function predates this PR and is a different rule: it renders double-quoted front-matter scalars, not single-quoted config scalars.Addressed the concern in
1c7164b: the init paragraph indocs/features.mdnow lists the current markers (@@TITLE_YAML@@,@@LANG_YAML@@,@@LANG_LABEL_YAML@@forharness.yaml;@@TITLE_TOML@@,@@LANG_TOML@@forhugo.toml; bare@@TITLE@@forAGENTS.md;@@HUGO_VERSION@@) and says each_YAML/_TOMLmarker receives a complete rendered scalar.go test ./docs/ ./internal/initcmd/is green.