Flip cwd default to the task file's dir; replace Dir: with Opts: inherit-cwd (v0.2.0) - #7
Merged
Merged
Conversation
…rit-cwd
BREAKING (v0.2.0). Flip the working-directory default to match just: a task now
runs in the directory of the file that defines it (for a layered/fallback task,
the ancestor file's dir), not the invocation directory. A task script is written
against its project's layout, so it runs from that project's root, and just runs
recipes from the justfile's dir the same way (fallback recipes included, verified
empirically).
`Dir:` is removed. Its only durable value was picking one of two anchors (the
file's dir vs where you invoked); a specific subdir or absolute path is a one-line
`cd` in the script, and `Dir: {{ arg }}` was a raw path-injection footgun that
`cd "$arg"` fixes with shell quoting. In its place, `Opts:` carries per-task
flags (space-separated), with one flag today: `inherit-cwd` runs the task in the
invocation directory (just's `[no-cd]`). One key absorbs future flags without new
keys. A leftover `Dir:` line is reported as a warning pointing at the migration;
an unknown `Opts:` flag warns and is ignored.
Robustness: an empty task_file_dir (a bare filename's parent, e.g. `-f tasks.md`)
falls back to cwd rather than trying to run in an empty path.
Migration: relative paths now resolve from the task file's directory; add
`Opts: inherit-cwd` for the old "run where invoked" behavior. Tests, fixture, and
README updated; both crates bumped to 0.2.0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wrSiZfmH1jnLESCR41Xzw
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.
Breaking (v0.2.0). Fixes the cwd model, informed by dogfooding + empirically checking how
justbehaves.The finding
justruns every recipe in the directory of the justfile that defines it — includingset fallbackrecipes from a parent (verified: a parent recipe invoked from a child runs in the parent's dir;[no-cd]opts into the invocation dir). mdtask had the inverse default (invocation dir), so every project task file paidDir: .per task. A task script is written against its project's layout, so it should run from that project's root.The change
inherit-cwdis the opt-in for "run where invoked."Dir:is removed. Its only durable value was the two-anchor choice; a specific subdir/absolute path is a one-linecd, andDir: {{ arg }}was a raw path-injection footgun (cd "$arg"gets shell quoting for free). A leftoverDir:warns with a migration pointer.Opts:carries per-task flags, space-separated. One flag today:inherit-cwd. One key absorbs future flags ([private],[confirm], ...) without new keys — the API-minimizing choice. Unknown flags warn and are ignored.task_file_dir(a bare filename, e.g.-f tasks.md) falls back to cwd instead of running in an empty path.Verified
where(default) from a subdir runs in the task-file dir;here(inherit-cwd) runs in the invocation dir; a leftoverDir: .warns and still runs.just check-equivalent green: fmt, clippy-D warnings(default +--features mcp), all tests both ways. Tests, fixture, and README migrated. Both crates at 0.2.0.Follow-ups after release: strip the now-redundant
Dir: .from the gha-runner/briefs dogfood files, and bump gloaming'smdtask-coredep to0.2(no code change — gloaming never usedDir:andinvocation's signature is unchanged).🤖 Generated with Claude Code