5.8 KiB
G-030 make.tcl dogfoods punk::args: tabled usage, declared subcommands, prompt-free flags
Status: proposed
Scope: src/make.tcl (dispatch, help, prompts), src/bootsupport/AGENTS.md + src/modules/AGENTS.md (bootstrap-tracked staleness contract), src/modules/punk/args-999999.0a1.0.tm (only as consumed)
Goal: make.tcl - the first surface a developer sees - parses its subcommands and options via punk::args and showcases the tabled usage output for help and argument errors, every interactive y/n prompt gains a declared flag equivalent so agents can drive make.tcl with arguments instead of piped input, punk::args joins the bootstrap-tracked staleness set, and the boot phase plus the environment-repair commands keep working with degraded plain help when the bootsupport punk::args (or the table-rendering stack) is stale or unavailable.
Acceptance: tclsh src/make.tcl and -help render punk::args tabled usage listing every subcommand with a summary, and make.tcl help <subcommand> (or <subcommand> -help) shows that subcommand's definition; invalid arguments produce a punk::args usage error rather than ad-hoc messages; every y/n prompt has a documented flag equivalent (proven at least for vfscommonupdate and the project-build confirmations: a run with the flag completes non-interactively with stdin closed) and a non-interactive stdin without the flag fails fast with usage rather than hanging or half-aborting; punk::args is added to the bootstrap-tracked buildversion set with the doc contract updated (src/bootsupport/AGENTS.md, src/modules/AGENTS.md); with bootsupport punk::args unavailable or unloadable, make.tcl still boots and check, bootsupport and modules remain usable with plain-text fallback help (the guarded-require degrade rule); layout make.tcl copies follow via the established sync/G-027 channels (noted, not hand-synced).
Context
make.tcl is the first surface a developer meets in a punkshell-derived project,
but its command handling predates the ecosystem's own tooling: a hand-built
help text, a bare known_commands list, ad-hoc argument handling per
subcommand, and interactive y/n prompts (vfscommonupdate's REPLACE
confirmation, the project-build confirmations, bootsupport staleness prompts).
Eating our own dogfood - punk::args definitions per subcommand with the tabled
usage rendering - both showcases the ecosystem where it is most visible and
makes the parsing declarative.
The prompts are the practical payoff: agent-driven builds currently pipe y
into stdin (fragile, undiscoverable - observed 2026-07-07 while rebuilding
tomlish.exe). With punk::args parsing, prompt-free operation is just another
declared option per subcommand, and non-interactive stdin without the flag can
fail fast with usage instead of hanging on a read or half-aborting.
Precedents already in-tree: src/tests/runtests.tcl parses via punk::args ((script)::runtests definition), and the tomlish cmdline app presents tabled usage as its first surface.
Approach
- One PUNKARGS definition per subcommand (@cmd -summary/-help + opts), plus a
top-level definition enumerating subcommands - replacing punkboot_gethelp
and the hand-maintained help strings.
make.tcl,make.tcl -help, and per-subcommand help all render through punk::args::usage. - Prompt policy: interactive stdin -> prompt as today (default); flag supplied (e.g. -confirm 0 / -y, naming decision recorded here) -> proceed without prompting; non-interactive stdin without the flag -> usage error, fast. The bootsupport staleness prompt keeps its abort/prompt/proceed classification but gains the same flag route.
- Degradation is a hard requirement (the 2026-07-06/07 incidents are the
cautionary tale: a stale bundled fileutil disabled the very make.tcl step
needed to fix it). The boot phase stays self-contained; punk::args is
guarded-lazily required post-boot (the punkboot::utils pattern documented in
src/bootsupport/AGENTS.md); when unavailable, dispatch and the repair
commands (check, bootsupport, modules) keep working with plain-text fallback
help. Note the tabled rendering also pulls punk::ansi/textblock/punk::char -
exactly the modules whose same-version staleness broke shellfilter this week
- so rendering must degrade independently of parsing (punk::args plain output when the ANSI stack is unhealthy).
- Staleness tracking: punk::args joins the bootstrap-tracked buildversion set (currently punkcheck, punk::repo, punk::mix, punk::tdl) with the same bump-at-least-minor-on-call-site-API-change discipline; whether the rendering stack is also tracked or left to degrade is an implementation decision to record here (initial lean: track punk::args only - it is the parsing contract; rendering degrades).
- Layout copies of make.tcl follow through the existing punkcheck-tracked sync (custom/_project) and the G-012/G-027 channels for the rest - noted in completion reports, never hand-synced.
Alternatives considered
- Ad-hoc -y flags bolted onto the current hand parsing - rejected: solves the agent problem but leaves the first-surface help un-showcased and the parsing divergent from the ecosystem's own conventions.
- Requiring punk::args at boot (no fallback) - rejected: make.tcl must be able to repair the very bootsupport snapshot it loads punk::args from.
Notes
- Related: G-015 (agents driving punk tooling non-interactively), G-024 (mapvfs toml errors deserve the same declared-argument quality), G-025 (the version-report subcommand should be born punk::args-defined), G-027 (pull updates deliver the improved make.tcl to derived projects).
- Observation parked here from the same session: runtests/make.tcl-adjacent tooling that returns result dicts should document their key shape (see the runx -tcl exitcode note in G-015's detail).
- Archived-goal references in this file: G-015 achieved 2026-07-07 (goals/archive/G-015-script-subcommand-piped-stdin.md).