Repository navigation
Description
Summary
uf init's post-scaffold sub-tool initialization (initSubTools in internal/scaffold/scaffold.go) executes dewey, replicator, specify, openspec, and gaze through opts.ExecCmd — the exec.Command(name, args...).CombinedOutput() default with no cmd.Dir — so every sub-tool writes its output into the process cwd instead of the scaffold TargetDir. The npm-based review-plugin activation path has the same inherited-cwd behavior.
When the cmd/unbound-force package tests run (TestRunInit_FreshDir and TestRunInit_ForceFlag call runInit with targetDir: t.TempDir() and real default exec hooks), the test binary's cwd is cmd/unbound-force/, and with the toolchain present on PATH every sub-tool initialization lands inside the repo:
dewey init→.uf/dewey/graph.db,.github/workflows/dewey-distill.yml.examplereplicator init→.uf/replicator/cells.jsonspecify init --here --integration opencode --offline --force→.specify/(the--hereflag explicitly targets cwd)openspec init --tools opencode→openspec/gaze init→.opencode/integration files- review-plugin activation (npm install) →
.opencode/node_modules
Reproduction
rm -rf cmd/unbound-force/{.github,.opencode,.specify,.uf,.devcontainer,openspec}
go test -race -count=1 ./cmd/unbound-force/
ls -A cmd/unbound-force/ | grep -v '\.go$'
# → .devcontainer .github .opencode .specify .uf openspec (all six regenerated)
Bisection (2026-11-24): the full six-directory litter regenerates from this package's suite alone (~175s run, exit 0). It also regenerates on every make test / make coverage-gate / make check run.
Evidence anchors
internal/scaffold/scaffold.go:109-110—defaultExecCmd=exec.Command(name, args...).CombinedOutput()(nocmd.Dir)internal/scaffold/scaffold.go:115-116—defaultExecCmdInDir(dir, name, ...)exists but is unused by the tool-init pathsinternal/scaffold/scaffold.go:2712, 2729, 2751—initDeweyexecsdewey init/dewey index --no-embeddingsviaExecCmd(inherited cwd)internal/scaffold/scaffold.go:2797—initSimpleToolexecs<tool> init [args...]viaExecCmd(inherited cwd)internal/scaffold/scaffold.go:2559-2571—simpleToolstable (replicator, specify with--here, openspec, gaze)internal/scaffold/scaffold.go:2578-2700—initSubToolsdispatch, gated only byopts.LookPath(tool)internal/setup/setup.go:140— same unanchoredexec.Command(...).CombinedOutput()patterncmd/unbound-force/main_test.go:15-91—TestRunInit_FreshDir(real exec hooks, temp target, test cwd = package dir)
Historical masking
.gitignore lines 58/65-70 (commit 641a5af, 2026-04-13, "Prevent stray tool directories in subdirectories") mask five of the six directories (cmd/**/.opencode/, cmd/**/.uf/, cmd/**/.specify/, cmd/**/openspec/, .devcontainer/); only .github/ surfaces in git status, so the condition has been invisible in normal workflows since April.
Recommended fix
Anchor every post-scaffold sub-tool exec to the resolved absolute TargetDir:
- Route the tool-init execs through the existing
ExecCmdInDirhook withopts.TargetDir:initDewey(scaffold.go:2712/2729/2751) andinitSimpleTool(scaffold.go:2797) —opts.ExecCmdInDir(opts.TargetDir, tool.name, args...). - Same anchoring for the npm review-plugin activation path wherever it shells out.
internal/setup/setup.go:140— setcmd.Dirto the resolved target for tool installs.- Guardrail: resolve
TargetDirto an absolute path atRun()entry and validate it against path traversal before any exec or write. - Longer term (separate consideration): an exec-name allowlist for
ExecCmdconsumers, and migrating process-wideos.Chdirtest helpers tot.Chdir.
Per the AGENTS.md commit-scope rule (tooling-scaffold changes ride their own branch, never a feature branch), this fix should ship on a dedicated branch/change. Filed from the opsx/intent-satisfaction-check pipeline after the writer was bisected during its phase-2 gate.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity