Skip to content

Flip cwd default to the task file's dir; replace Dir: with Opts: inherit-cwd (v0.2.0) - #7

Merged
jhheider merged 1 commit into
mainfrom
feat/cwd-flip-opts
Jul 21, 2026
Merged

Flip cwd default to the task file's dir; replace Dir: with Opts: inherit-cwd (v0.2.0)#7
jhheider merged 1 commit into
mainfrom
feat/cwd-flip-opts

Conversation

@jhheider

Copy link
Copy Markdown
Owner

Breaking (v0.2.0). Fixes the cwd model, informed by dogfooding + empirically checking how just behaves.

The finding

just runs every recipe in the directory of the justfile that defines it — including set fallback recipes 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 paid Dir: . per task. A task script is written against its project's layout, so it should run from that project's root.

The change

  • Default cwd is now the task file's directory (for a layered/fallback task, the ancestor file's dir), matching just. inherit-cwd is 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-line cd, and Dir: {{ arg }} was a raw path-injection footgun (cd "$arg" gets shell quoting for free). A leftover Dir: 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.
  • Robustness: an empty task_file_dir (a bare filename, e.g. -f tasks.md) falls back to cwd instead of running in an empty path.

Verified

  • Empirically: where (default) from a subdir runs in the task-file dir; here (inherit-cwd) runs in the invocation dir; a leftover Dir: . 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's mdtask-core dep to 0.2 (no code change — gloaming never used Dir: and invocation's signature is unchanged).

🤖 Generated with Claude Code

…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
@jhheider
jhheider merged commit 9c5bd3e into main Jul 21, 2026
6 checks passed
@jhheider
jhheider deleted the feat/cwd-flip-opts branch July 21, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant