LaunchOpts gains LaunchDir. session.Run resolves it via
workspace.ResolveLaunch, prints any fallback warning, and passes the
absolute path as the child process's working directory. Security
violations (absolute paths, .. escape) abort the session. The banner
gains a 'project dir: <name>/' line when launch_dir is set.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
config.EnvVars gains a 7th launchDir argument. cmd/new, cmd/resume, and
cmd/open pass ws.Meta.LaunchDir. Child sessions can read CTASK_LAUNCH_DIR
to know which subdirectory ctask launched them into.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ctask new --project now creates an empty subdirectory named after the
final suffixed slug inside the workspace root, and sets meta.LaunchDir
to that slug. Task workspaces are unchanged. Seeds do not target the
subdirectory — the user populates it with their project code and their
own CLAUDE.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolves a relative launch_dir into the absolute directory the child
process should cd into. Returns an error for absolute paths and paths
that escape the workspace via .. traversal. Returns (wsDir, warning, nil)
on os.IsNotExist or target-is-a-file so the caller prints a warning and
falls back. Non-IsNotExist stat errors (permission, invalid name, I/O)
propagate as real errors rather than being masked as warnings.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a child-exit-code guard to handleProvisional so a `ctask new`
workspace is reclaimed only when the agent was actually canceled
before real work (trust prompt rejected, Esc during startup, Ctrl+C
mid-launch — all confirmed empirically as exit code 1). A zero exit
means the user entered the agent and exited cleanly, which is a
legitimate workflow that must preserve the workspace even with an
empty manifest diff — for example when the user wants the workspace
directory established so they can populate context/ before resuming.
The exit code reaches handleProvisional via a new childExitCode
helper that unwraps *exec.ExitError from cmd.Run's return. Non-exit
errors (agent not found, OS-level failure) map to -1 so the
workspace is still cleaned up — the child never actually ran.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Archive now inspects .ctask/session.json before mutating task.yaml. A
fresh lease (heartbeat within 60s) triggers a warning. Interactive
stdin gets a y/N prompt (default N). Non-interactive stdin refuses
with a non-zero exit, which is safer than silently hiding an actively
writing workspace. Stale or missing leases pass through unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the always-informational seed-dir block with three-state checks:
INFO when the env var is unset (defaults will be used), PASS when set and
the path exists, FAIL when set but the directory is missing. Only the
configured-but-missing state counts as a failed check and raises the
doctor exit code.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Project CLAUDE.md template now includes a Git section stating that the
workspace uses a single git repo at the root and subdirectory git init
is not permitted. docs/commands.md picks up the same guidance under the
--project flag section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Every resolver, lister, and most-recent caller now passes
config.SearchRoots() so CTASK_PROJECT_ROOT is searched alongside
CTASK_ROOT. Commands use ws.Root when rendering relative paths or
session env vars so displays and CTASK_ROOT exports are correct for
workspaces living under CTASK_PROJECT_ROOT.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rewrites scanWorkspaces to handle both category layout
(root/<category>/<workspace>/task.yaml) and flat layout
(root/<workspace>/task.yaml used under CTASK_PROJECT_ROOT).
Adds scanAllRoots to walk multiple roots with absolute-path dedupe.
ResolveQuery, ListWorkspaces, and MostRecentActive now accept []string.
QueryResult gains a Root field so callers can render display paths and
session env vars relative to the originating root.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When `ctask new` launched the agent or shell and the child exited without
touching any files (e.g. the user canceled at Claude Code's trust prompt),
the workspace was left behind as empty clutter. Now, if the invocation
just created the workspace and the manifest diff is empty (zero added,
modified, deleted), the workspace directory is removed and finalize is
skipped. resume/open/last are unaffected (NewlyCreated defaults to false),
and --no-launch is unaffected (session.Run is never called).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reflects the v0.3 polish-pass changes:
- default 'ctask list' shows active tasks AND projects
- --task flag added; --task and --projects are exclusive
- output now includes a "type" column
- 'ctask last' explicitly notes it considers both types
Default behavior is now the broadest useful active view: 'ctask
list' shows all active workspaces, both tasks and projects.
Flag matrix:
ctask list active tasks + projects
ctask list --all all (incl. archived)
ctask list --task active tasks only
ctask list --task --all all tasks (incl. archived)
ctask list --projects active projects only
ctask list --projects --all all projects (incl. archived)
--task and --projects are mutually exclusive; passing both
returns a usage error rather than silently picking one.
Output gains a small "type" column so the mixed default view
is unambiguous: status, type, mode, category, date, slug.
Empty-result message is type-aware ("No tasks found." /
"No projects found." / "No workspaces found.").
Tests cover all six valid flag combinations, the conflict case,
and the three empty-result message variants.
Both commands now call workspace.MostRecentActive(root) directly
instead of inlining a ListWorkspaces scan + max-by-UpdatedAt loop.
The cross-type behavior is identical to before this commit (it
was already correct after the v0.3 union fix), but it is now
locked down by the focused unit tests added in the previous
commit and there is no duplicated selection logic.
The (nil, nil) "no active workspaces" return is mapped to:
- cmd/last: prints "No active workspaces found." and exits 1
- cmd/delete: silently skips the "most recent" note (the user
is deleting some specific workspace by name; the
note was always best-effort)
Extracts the cross-type "most recently updated active workspace"
selector that previously lived inline in cmd/last and cmd/delete.
The helper takes only a root path and returns (nil, nil) when
nothing matches, which keeps the call sites trivial.
Eight focused tests cover:
- tasks-only fixture
- projects-only fixture
- project most-recent vs older task
- task most-recent vs older project
- legacy v0.2 workspace (no Type field) winning, treated as task
- newest workspace archived, older active project wins
- empty root returns (nil, nil)
- all archived returns (nil, nil)
A new createTestWorkspaceFull helper takes an explicit UpdatedAt
timestamp so the "which is newest" assertions don't depend on
wall-clock ordering.
cmd/last and cmd/delete are migrated onto the helper in the next
commit.
ListOpts now exposes a Type string field (TypeAny / TypeTask /
TypeProject). TypeAny is the new way to express "both tasks and
projects" in a single ListWorkspaces call -- which the next two
commits will use to consolidate cmd/last and cmd/delete onto a
single helper, and to make 'ctask list' default to showing both
types.
Invalid Type values now return an explicit error from
ListWorkspaces (defensive against typos in callers).
cmd/list, cmd/last, and cmd/delete are migrated to the new field.
External behavior is unchanged in this commit; the cleanup of
ctask list semantics happens in a follow-up commit so the diff
stays reviewable.
Adds the v0.3 feature spec (source of truth for this release) and
the inline-execution implementation plan that was followed to land
the v0.3 work in the preceding commits.
Scope of v0.3:
- User seed directories (general + project)
- Improved built-in CLAUDE.md defaults (task + project)
- --project mode (type metadata, project root, git init)
- --projects filter for ctask list
- CTASK_TYPE env export
- Status-line and doctor updates
The 2026-04-06-install-workflow plan (also untracked) is left
alone -- it predates this session and is not part of v0.3.
Updates docs/commands.md to cover the v0.3 surface:
- ctask new --project flag, project mode, project root
semantics, seed order, git init behavior
- ctask list --projects flag and --all/--projects matrix
- Seed directory locations (general + project) and skip rules
- CTASK_TYPE child env var, CTASK_PROJECT_ROOT,
CTASK_SEED_DIR, CTASK_SEED_PROJECT_DIR config vars
- Doctor [INFO] seed directory reporting
No remote install or publish commands are added; the project
remains local-only.
Adds two [INFO] lines after the existing pass/fail checks
reporting whether the resolved general and project seed
directories exist. These are read-only and do not contribute to
the pass/fail counters, so users with no seed directories still
see "5 checks passed, 0 failed".
The task case is byte-for-byte identical to v0.2:
(ctask:slug|mode) /workspace/path
Project sessions append a single |project marker:
(ctask:slug|mode|project) /workspace/path
Both helpers (.sh and .ps1) are updated symmetrically. The empty
case (no CTASK_TASK) still outputs nothing.
Smoke verified:
- task default: (ctask:demo|local) /tmp/demo
- explicit CTASK_TYPE=task: (ctask:demo|local) /tmp/demo
- CTASK_TYPE=project: (ctask:demo|local|project) /tmp/demo
- no CTASK_TASK: (silent)
ctask list shows tasks by default and projects with --projects.
--all controls archived visibility (independent of --projects),
so the four combinations work as the spec defines:
- ctask list active tasks
- ctask list --all active + archived tasks
- ctask list --projects active projects
- ctask list --projects --all active + archived projects
Empty-result message reflects the active filter.
ListOpts gains a Projects bool that filters by EffectiveType.
Default behavior (Projects: false) now returns tasks only --
this is a deliberate semantic change that supports the new
'ctask list' (tasks) vs 'ctask list --projects' (projects)
spec.
The change silently regresses two cmd-level callers that scan
for "the most recently updated workspace": cmd/last.go (used by
'ctask last') and cmd/delete.go (used to print the "this was
your most recent workspace" note). Both are fixed by unioning a
tasks-scan with a projects-scan, so 'last' and 'delete' continue
to consider both types.
Test helper createTestWorkspaceTyped allows setting an explicit
type (or "" to simulate a v0.2 workspace with no type field).
After Create() returns, project mode now:
1. Runs git init (or prints "git not found; skipped..." if git
is unavailable)
2. Calls EnsureGitignore, which is a no-op when a seed already
supplied .gitignore (preserving the seed-wins rule end-to-end)
Both git unavailability and git init failure are non-fatal: ctask
warns and continues, so a missing/broken git toolchain never blocks
project creation.
EnsureGitignore writes a minimal .gitignore (.ctask/ +
logs/sessions.log) iff one does not already exist. This is the
file-system half of the v0.3 seed-wins rule for .gitignore: if
either the general or project seed copied a .gitignore into the
workspace, EnsureGitignore must be a no-op.
GitAvailable + RunGitInit wrap exec.LookPath("git") and `git init`
respectively, so the caller in cmd/new.go can decide whether to
print the informational note when git is missing.
Tests cover:
- missing -> created with the minimal body
- present -> preserved verbatim
- integration: general seed .gitignore preserved end-to-end
- integration: project seed .gitignore preserved end-to-end
- integration: no seed -> minimal body created
ctask new gains --project, which:
- records type=project on the workspace
- defaults the category to "projects"
- applies general + project seed overlays
- uses CTASK_PROJECT_ROOT when set, with no doubled "projects/"
path unless the user explicitly passes -c
- exports CTASK_TYPE=project into the child session
EnvVars now takes a taskType arg and exports CTASK_TYPE. Empty
type defaults to "task" for safety. resume/open also pass
EffectiveType so the env var is correct on resume of a v0.2
workspace.
Git init for project mode is wired in the next commit.