Commit Graph

63 Commits

Author SHA1 Message Date
typebasedio bbc41646ee feat(release): add Gitea release-publishing pipeline
Release / release (push) Successful in 27s
- Add scripts/build-release.sh: cross-compile linux+windows amd64 with
  ldflags injecting main.version and main.commit, write
  checksums-sha256.txt and release-manifest.json (full commit SHA).
- Add scripts/release-check.sh: local mirror of CI (test, vet, build,
  --version substring check); falls back to Windows artifact when run
  on a Windows host where the Linux binary can't exec.
- Wire main.version / main.commit -> cmd.SetVersionInfo. Default to
  "dev" / "" so local builds without ldflags still produce a
  sensible string. Output format: single line
  'ctask <version> (<short-sha>)' or 'ctask <version>' / 'ctask dev'.
- Add .gitea/workflows/release.yml: triggered on v* tags, runs-on
  ctask-release (golang:1.26-bookworm). Tag parsed from gitea.ref
  (not gitea.ref_name). Pure shell + Gitea API; no actions/checkout,
  no setup-go, no third-party release action. Installs jq at job
  start. RC tags are deletable+recreatable; final tags are immutable.
  Verify step downloads published assets, sha256sum -c's, and runs
  --version.
- notes.md: log Phase 0/2/3 + version-injection completion.
2026-05-20 15:19:59 -04:00
typebasedio beb517478e chore(v0.6): bump version to 0.6.0 2026-05-15 14:31:02 -04:00
typebasedio d575ddd0f5 feat(v0.6): route lease-freshness callsites through IsStale
InspectLease, CleanupStaleLease, runActiveLeaseCheck, and statusAt now
use the PID-aware IsStale predicate. A dead local owner PID makes a lease
stale immediately; SessionStatus / list / info reflect this with no
display-code change.

Corrects three cmd-package session-display test fixtures that built
"active" leases with the local hostname but synthetic PIDs — now that
freshness is PID-aware, an active session must be owned by a live
process, so the fixtures use os.Getpid().
2026-05-15 14:29:50 -04:00
typebasedio 0f96d202c7 feat(v0.6): ctask agents check + doctor integration
ctask agents check [workspace] validates that a workspace's agent
configuration can be launched without launching it: agent type known,
command resolvable on PATH, launch_dir valid, AGENTS.md present,
CLAUDE.md shim present (WARN only, claude type only). agent.env keys
are displayed informationally, with a WARN line when any key shadows a
ctask-exported CTASK_* var. Returns non-zero when any check FAILs.

ctask doctor includes the same sweep when a workspace context is
resolvable — the most-recently-active workspace via
workspace.MostRecentActive. When no active workspace exists, doctor
shows "Agent check: skipped (no workspace context)" without bumping
the failure counter. runAgentsCheckOnWorkspace is shared between the
standalone command and the doctor integration.

TestCompletionSubcommandViaExecute is made order-independent: cobra's
default completion command captures the root output writer on the first
Execute() in the process, and the new agents-check tests now run an
Execute() earlier in the suite.
2026-05-15 11:28:14 -04:00
typebasedio a61f900c86 feat(v0.6): --agent flag on ctask new selects agent type
Resolver gains SetCLIFlagAgent; DefaultAgent now layers CLIFlag above
EnvVar so doctor/info attribution renders the correct precedence chain
(CLIFlag overrides EnvVar overrides ConfigFile overrides Builtin).

ctask new --agent <type> writes agent.type into the new workspace's
task.yaml. Resolution and validation run before workspace.Create, so
--agent custom without a companion command refuses ("type custom
requires command") with no half-created workspace left on disk. The
deferred Phase 1 test TestCLIFlagOverridesEnvVar lands here.

--agent on resume/last/attach is unchanged (one-shot agent.command
override on the AgentSpec — Open Q 1).
2026-05-15 11:11:16 -04:00
typebasedio b75b82e676 feat(v0.6): launch path carries ResolvedAgent (command + args + env)
LaunchOpts.Agent (string) and WorkspaceEntryOptions.Agent (string) are
replaced by *agent.Resolved, carrying Command, Args, and Env. The five
entry commands (new, resume, last, open, attach) each construct an
AgentSpec from the workspace metadata, apply --agent as a one-shot
agent.command override (Open Q 1 — keeps muscle memory for users
passing executable paths), call agent.Resolve, and pass the result
through. resolveEntryAgent centralises the resume/last/open/attach path.

shell.ExecAgent and shell.ExecTmuxAgent gain an args parameter; agent.env
is merged into the env map at the session.Run launch switch, AFTER
ctask's exported CTASK_* vars (per spec §5: agent.env wins on collision).
mergeAgentEnv is the centralised merge.

Lease, manifest, write lock, heartbeat, summary, and provisional
cleanup are unchanged. The Agent string fields on Lease, SessionSummary,
and SessionInfo continue to record the launched command for diagnostics.
2026-05-15 11:08:03 -04:00
typebasedio 8120c399df feat(v0.6): AgentSpec field on TaskMeta with backward-compat unmarshal
Replace TaskMeta.Agent (string) with TaskMeta.Agent (AgentSpec) carrying
type/command/args/env. Custom UnmarshalYAML preserves the legacy scalar
form: a built-in name (claude, opencode) maps to that type; any other
scalar maps to type=custom with the scalar as command. A missing agent
field leaves Type empty so the resolver fills in default_agent at launch.

ValidateAgentSpec enforces: known type (claude|opencode|custom),
type=custom requires command, command must be an executable name or
path with no whitespace or shell metacharacters.

Launch-path wiring (Task 3) and the --agent flag rework (Task 4) are
intentionally not part of this commit; cmd/* call sites are patched to
the minimum needed for the build to compile.
2026-05-15 10:58:06 -04:00
typebasedio 6182d89135 feat(v0.6): platform-override stderr warning on launch paths
Closes the half-feature surfaced during Phase 1 review: doctor now
shows that persistent session_mode is overridden to direct on native
Windows, but the launch-time entry paths were silently downgrading
without telling the user. This commit adds the one-line warning
specified by the user, gated to the four entry commands where the
downgrade actually has an effect.

cmd/persistent.go:

- New package-level const platformOverrideWarning carries the exact
  spec-mandated text so tests don't have to retype the copy.
- New helper emitPlatformOverrideWarningIfNeeded(alwaysPersistent).
  Loads the resolver, reads SessionMode(), and emits the warning to
  stderr when:
    1. the call site is NOT AlwaysPersistent (attach has no
       direct-mode fallback and continues to refuse on native
       Windows via preflightPersistentEntry), AND
    2. the resolver's value resolved through PlatformOverride.
  Doctor and info do not call this helper — they render source
  attribution themselves and an extra stderr line from a diagnostic
  command would be noise. "Once per invocation" is provided
  implicitly by the call site running at most once per ctask
  command; no warn-once subsystem.

cmd/entry.go:

- defaultRunWorkspaceEntry calls the helper at the top, before any
  launch work. This covers all four entry paths (new / resume / last
  / open) since they all funnel through runWorkspaceEntry. attach
  also routes here but sets AlwaysPersistent=true, so the helper
  short-circuits.

cmd/platform_warning_test.go (5 cases):

- TestPlatformOverrideWarningEmittedOnLaunch — simulated native
  Windows + config session_mode: persistent + AlwaysPersistent=false
  → warning text appears on stderr.
- TestPlatformOverrideWarningNotEmittedWhenDirect — config
  session_mode: direct → no warning even on simulated Windows.
- TestPlatformOverrideWarningNotEmittedWithoutConfig — builtin
  default (direct) → no warning.
- TestPlatformOverrideWarningNotEmittedOnNonWindows — persistent
  config but isNativeWindows() returns false → no warning.
- TestPlatformOverrideWarningSkippedForAlwaysPersistent — attach's
  AlwaysPersistent=true gate prevents emission. attach's actual
  refusal contract on native Windows is already covered by
  TestPreflightRefusesNativeWindows in persistent_test.go.

Validation: `go test ./... -count=1`, `go vet ./...`, `go build`,
and `just build-linux` all clean.
2026-05-14 22:12:28 -04:00
typebasedio 937a1c8216 feat(v0.6): info source attribution on Agent and Launch session mode
Adds source-attribution rendering to `ctask info` for the two Phase 1
settings whose effective value depends on user-level defaults: the
agent recorded in task.yaml and the configured launch session mode.

cmd/info.go:

- runInfo loads the resolver once (config.LoadResolver) and reuses
  it across the rendering — matches the user's correction that "new
  doctor/info code should load the resolver once and reuse it".
- Agent line now reads `Agent: <value> (workspace)` when task.yaml
  has a non-empty agent (the common case), or `Agent: <value>
  (default)` / `Agent: <value> (default — <source label>)` when the
  field is empty and the value comes from the resolver fallback
  chain. The fallback path is informational only: every workspace
  created by recent ctask versions writes the resolved default into
  task.yaml at Create time, so the (workspace) branch is what users
  normally see.
- New "Launch session mode:" line lives immediately after Agent and
  before Created — outside the v0.5.4 Session block per the user's
  placement decision ("Keep it outside the Session block because it
  represents the configured launch default, not the current session
  lease mode"). Format: `Launch session mode: <value> (<source>)`.
- Two small helpers added: agentLineWithSource composes the agent
  payload + label; infoSourceLabel renders a single-row source
  string (CTASK_X env var / config file / built-in default /
  platform override). infoSourceLabel intentionally omits the
  override-chain suffix used by doctor — info's row layout has no
  room for the extra parenthetical.

cmd/info_attribution_test.go (5 cases):

- TestInfoAgentSourceWorkspace — task.yaml with agent set → "(workspace)"
- TestInfoAgentSourceDefaultForLegacy — empty agent → "(default)"
- TestInfoLaunchSessionModeFromConfig — config session_mode value +
  "config file" source label
- TestInfoLaunchSessionModeBuiltinDefault — no config, no env →
  "direct (built-in default)"
- TestInfoLaunchSessionModeAfterAgentBeforeCreated — placement check:
  Agent < Launch session mode < Created in the rendered output

Smoke-verified against an existing v0.5.x workspace on the installed
binary; render order and source labels match the spec example.
2026-05-14 21:57:20 -04:00
typebasedio c918e5ceab feat(v0.6): doctor Settings section with source attribution
Adds a new ── Settings ── block at the bottom of `ctask doctor` (after
the existing tmux INFO line, before the summary). The block reports
every user-level default tracked by the resolver — ctask_root,
project_root, seed_dir, default_agent, default_category, session_mode,
editor — together with the source it was drawn from.

Implementation:

- runDoctor calls config.LoadResolver() once and passes the resolver
  into checkSettings; no setting is re-resolved mid-block (the user's
  correction: "new doctor/info code should load the resolver once and
  reuse it").
- checkSettings prints the config-file lifecycle line first
  (`Config file: <path>` / `Config file: not found — using built-in
  defaults` / `[FAIL] unknown key: "..."` per the resolver's
  ConfigErr state), then iterates the resolver's ResolvedSetting
  accessors and feeds each one through printSettingLine.
- printSettingLine renders the key + value pair plus a `source: …`
  child line. When the resolver chains an Override, the source line
  embeds the overridden source + value in parens. For the
  PlatformOverride session_mode case, an additional
  `configured: <value>` line surfaces what the user asked for.
- formatSettingSource centralises the "EnvVar → CTASK_X env var" /
  "PlatformOverride → ... (persistent mode requires tmux; not
  available on native Windows)" / override-chain wording so doctor
  and info can share the same labels in commit 4.
- Only the invalid-config-file branch increments the failed counter.
  Missing file is INFO. The valid-file branch is purely informational.

Tests (cmd/doctor_settings_test.go, 6 cases):

- TestDoctorShowsSettingsSection — header present + all keys appear
- TestDoctorShowsSourceAttribution — every line has source: + at
  least one "built-in default"
- TestDoctorShowsOverrides — env vs config override chain rendered
- TestDoctorConfigNotFound — INFO, no failed bump
- TestDoctorConfigInvalid — FAIL bump + unknown key named
- TestDoctorSessionModePlatformOverrideRendered — direct value +
  "platform override" label + "configured: persistent" row

Smoke-verified end-to-end against the installed binary:
- no config + no env → all "built-in default"
- env CTASK_AGENT=aider + config default_agent=opencode →
  "CTASK_AGENT env var (overrides config file: opencode)"
- config session_mode=persistent on native Windows → "platform
  override (...)" plus "configured: persistent"
- config with typo "default_agnet: foo" → [FAIL] line names the key
  and the "settings not applied" advisory
2026-05-14 21:55:02 -04:00
typebasedio 6f80c8bf5c feat(v0.6): config file parser + resolver + source attribution
Phase 1 foundation. Adds:

- internal/config/configfile.go — strict-key YAML parser for the
  global config file. Unknown top-level keys invalidate the entire
  file (no partial apply); future schema versions are rejected with
  an upgrade message. Platform-appropriate path (XDG_CONFIG_HOME or
  ~/.config on Unix, %APPDATA% on native Windows).

- internal/config/resolver.go — Resolver / ResolvedSetting /
  SettingSource (Builtin, ConfigFileSrc, EnvVar, CLIFlag,
  PlatformOverride). Each setting carries provenance plus an
  Override chain so callers can render "env var (overrides config
  file: X)" lines. session_mode applies the native-Windows
  platform override at the resolver layer with the configured
  value chained as Override. Exports SetConfigPathForTest and
  SetIsNativeWindowsForTest so cross-package tests can isolate
  themselves from host config or simulate the override.

- internal/config/config.go — legacy ResolveRoot / ResolveAgent /
  ResolveSeedDir / ResolveProjectRoot / ResolveSessionMode now
  delegate to LoadResolver so config-file values take effect for
  entry commands. ResolveProjectRoot preserves the "" sentinel for
  built-in source so SearchRoots and doctor checkProjectRoot keep
  their existing fallback semantics. ResolveSessionMode preserves
  the v0.5.3 unknown-value stderr warning, distinguishing env-var
  and config-file sources in the message.

- Tests: 6 LoadConfigFile cases (missing, basic, partial, unknown
  key, future schema, malformed YAML), 3 ConfigFilePath cases
  (XDG / ~/.config / %APPDATA%), 11 resolver cases including
  layering, override chains, path expansion, platform override,
  and SettingSource string rendering.

- Test isolation: vulnerable tests in config_test.go and
  config_roots_test.go that asserted Builtin-source defaults now
  call SetConfigPathForTest to point at a nonexistent path,
  insulating them from developer-host config files. Three cmd
  tests that asserted persistent session_mode behavior now call
  SetIsNativeWindowsForTest to disable the platform override
  (Phase 1 introduces the override; the layering-only behavior
  these tests cover is tested separately in resolver_test.go).

No new dependencies (gopkg.in/yaml.v3 was already in go.mod).
No version bump (lands at the end of Phase 3 per the v0.6 spec).
2026-05-14 21:47:25 -04:00
typebasedio 7704cd93fc release(v0.5.4): bump version to 0.5.4 2026-05-14 20:01:57 -04:00
typebasedio ae9bfafb1f polish(v0.5.4): suppress Cobra duplicate Error on archived resume
ctask resume <archived-workspace> printed both the helpful [ctask]
diagnostic + restore hint AND a redundant trailing "Error: workspace
archived" line from Cobra's default error rendering. Cosmetic but
unprofessional.

Add an errArchivedWorkspace sentinel and have runResume flip
SilenceErrors only when the inner error is that sentinel. All other
resume errors (lookup failure, metadata write failure, etc.) continue
to flow through Cobra's default rendering unchanged — we only silence
the case where we have already printed an equivalent diagnostic
ourselves.

Verified end-to-end through Cobra Execute (not just runResume direct
invocation) so the SilenceErrors-flip-from-RunE timing is exercised.
2026-05-14 20:01:19 -04:00
typebasedio 0fb8de697b polish(v0.5.4): invocation-name audit + targeted regression tests
Audit walked every cmd/ and internal/ file that produces user-facing
output. All command-form hints (text the user is meant to type back)
were already routed through invocationName() in v0.5.3 — the audit is
a verification pass, not a code rewrite.

Additions:

- Extract formatResumeRestoreHint and formatDirectModeTmuxHint as
  testable string-only helpers. Production paths are unchanged
  behaviorally; the helpers exist purely so the audit can pin down
  the format strings without simulating tmux or stderr capture.

- Two new tests pinning the invocation name to a non-canonical value
  ("my-bin"). The pre-existing tests already protect these surfaces
  but pin the name to "ctask", so they cannot detect a regression
  that hard-codes "ctask" inside the format string. The new tests
  flush that out for the resume restore hint and the Layer-1
  active-session attach hint.

- Drop the duplicated withInvocationName helper accidentally added in
  the info-session tests; reuse the canonical helper from
  persistent_test.go.

Product-identity references ("ctask persistent mode requires tmux",
the SSH-remote `ssh -t <host> ctask <subcmd>` hint, doctor's "[ctask]"
diagnostic prefix, root-command Use:/Long:) deliberately remain
literal per spec §2.
2026-05-14 19:56:05 -04:00
typebasedio 0c8076aba9 feat(v0.5.4): list SESSION column
Add a SESSION column to ctask list output, inserted to the right of
STATUS per spec. Values: "direct", "persistent", "stale", or em dash
for no session. Populated by SessionStatus, so each workspace adds at
most one short lease-file read — negligible for typical workspace
counts.

Archived workspaces always render as the em dash regardless of any
lease file present. The spec calls this a display simplification, not
a lifecycle invariant: ctask info still surfaces the raw session
state on archived workspaces because info is the diagnostic command.

ctask list --names is unchanged: one basename per line, no header,
no SESSION column. Verified by a regression test that asserts every
emitted line is bare-basename whitespace-free and contains none of
the SESSION tokens.
2026-05-14 19:52:52 -04:00
typebasedio e0e9cd764e feat(v0.5.4): info Session block
Add a Session block to ctask info output, surfacing the workspace
session lease state derived from SessionStatus. Inserted between Path
and any launch-dir fields so the new content is visually distinct
from both blocks.

Format: state on the header line, then indented Mode / Owner / Attach
/ Note rows aligned at column 14. The Owner line omits the hostname
when it matches the local machine. The Attach hint surfaces only for
active+persistent sessions and uses invocationName() so the suggested
command reflects the user's actual invocation. Malformed leases
render as stale with a single-line diagnostic and no Mode/Owner/Attach
rows so we never display fields parsed from a broken file.

Exposes session.CurrentHostname() so the cmd layer has a single
source of truth for the local-vs-remote hostname check.
2026-05-14 19:51:21 -04:00
typebasedio c204d87b47 polish(v0.5.3): v0.4 lease-prompt hint, invocation-name in user-facing commands, smoke-checklist fixes
Three independent v0.5.3 polish items surfaced during manual WSL smoke testing,
bundled into one commit since they're all string/UX touches with no behavior change.

1. v0.4 lease-prompt tightening (`internal/session/{lease,run,run_preflight}.go`,
   `cmd/entry.go`): when ctask is about to enter direct mode on a workspace that
   already has a live tmux session, the "Continue anyway?" prompt now suggests
   `ctask attach <slug>` as the reattach path. Threaded via
   `PreflightOpts.ActiveLeaseHint` / `LaunchOpts.ActiveLeaseHint`; computed in
   `cmd/entry.go::directModeTmuxHint` (best-effort: silent when no tmux on PATH
   or no session for the workspace). Closes the footgun where a user forgot to
   `export CTASK_SESSION_MODE=persistent` in a second terminal and hit the v0.4
   coexistence prompt without realizing tmux passive-reattach was the intended
   path.

2. Invocation-name in user-facing command hints (`cmd/invocation.go` new,
   `cmd/{persistent,entry,resume,doctor}.go`): the binary name printed in
   bypass / restore / "create one with" suggestions now reflects
   `filepath.Base(os.Args[0])` instead of a hard-coded "ctask". Local-build
   PowerShell users running `.\ctask.exe` see `ctask.exe new <ws> --direct`,
   matching what they need to type. Installed contexts continue to see `ctask`.
   Test seam (`invocationNameOverride`) pins the name to "ctask" in unit tests
   so substring assertions stay stable across Go test binary names. Descriptive
   prose ("ctask persistent mode requires...") and the ssh-remote hint
   (`ssh -t <host> ctask <subcmd>`) intentionally keep the literal "ctask" —
   they refer to the program identity / remote invocation, not the local
   command form. Affected tests: `cmd/{persistent,resume}_test.go` tightened to
   check the full `"<binary> <subcmd> <workspace> --direct"` form.

3. Smoke-checklist fixes (`docs/.../2026-05-08-v0.5.3-smoke-test-checklist.md`):
   six issues caught during the run -- S2 now exports CTASK_SESSION_MODE in
   both terminals (previously only WSL-A had it, which routed WSL-B's
   secondary resume through direct mode instead of passive reattach); O3/A2
   tmux-ls expectations corrected (tmux doesn't emit a literal "(detached)"
   token); P2 expected behavior rewritten (passive reattach detach returns to
   prompt immediately -- AttachExisting calls only shell.AttachSession with
   no PollSessionEnd, the owner is responsible for finalize); A1 no longer
   asks for Ctrl-C in WSL-B; A6 path now uses a glob (was hardcoded to the
   checklist's authoring date, broke on v0.5.1 local-time directory naming);
   M1 PATH-hide rewritten to `$HOME/.local/bin` only (was `:/bin` which is a
   symlink to /usr/bin on usrmerge systems, did not hide tmux) and uses
   `command -v` instead of `which` (which is itself in /usr/bin, unreachable
   under the minimal PATH); M3/M4 reordered so the no-workspace verification
   runs after PATH is restored (was silently failing under minimal PATH);
   T1 wording made "substring match" explicit; T2 wording made N/A
   unambiguous; section 10 split into 10a-10f, each a separate input, to
   work around PSReadLine multi-line paste parsing.
2026-05-14 18:22:27 -04:00
typebasedio dea64fcbb7 chore(v0.5.3): bump version to 0.5.3 2026-05-08 14:05:16 -04:00
typebasedio be508e2ec7 feat(v0.5.3): doctor -- checkTmux three-state helper 2026-05-08 14:04:14 -04:00
typebasedio 8dec5e08a4 feat(v0.5.3): cmd attach -- always-tmux entry via runWorkspaceEntry 2026-05-08 14:02:56 -04:00
typebasedio 5f76feecdf feat(v0.5.3): cmd open -- preserve --all resolution; delegate to runWorkspaceEntry with Shell:true 2026-05-08 14:02:03 -04:00
typebasedio 2d3ebfbc3a feat(v0.5.3): cmd new -- persistent preflight before workspace.Create; delegate to runWorkspaceEntry 2026-05-08 14:01:07 -04:00
typebasedio f5746df314 feat(v0.5.3): shared workspace-entry helper; resume + last delegate; fresh_remote prompt 2026-05-08 13:59:53 -04:00
typebasedio 08b0f1a6a7 feat(v0.5.3): shared persistent preflight (cmd/persistent.go) 2026-05-08 13:51:21 -04:00
typebasedio 5910100d88 chore(v0.5.2): bump version to 0.5.2 2026-05-07 20:45:54 -04:00
typebasedio 56d2e07716 feat(v0.5.2): list --names for machine-readable enumeration
Adds a --names flag to ctask list that emits one workspace
directory basename per line, no header, no decoration. Empty
result is empty stdout with zero exit code (no "No workspaces
found." placeholder).

Used by shell completion scripts and external tooling. Candidates
are directory basenames rather than bare slugs because basenames
are unique under the resolver's exact-match step while slugs can
collide across categories or dates.

Respects existing list filters: --all, --task, --projects,
--category, --limit. So:

  ctask list --names           active workspaces only
  ctask list --names --all     active and archived
  ctask list --names --projects active project workspaces

The new TestListNamesCandidatesResolveUniquely test enforces the
spec invariant: every line emitted by list --names must resolve
to exactly one workspace via the standard resolver.
2026-05-07 19:47:33 -04:00
typebasedio b923ae8892 feat(v0.5.2): direct lookup includes archived; resume hint for archived
Apply the v0.5.2 lookup policy to the existing commands and wire
ValidArgsFunction hooks across the workspace-accepting surface.

info: drop the --all/-a flag entirely. Direct lookup is now
archived-inclusive by default — the user typed a name, so we find
the workspace and surface its status in the output. The Status
line already distinguishes active vs archived clearly.

resume: when targeting an archived workspace, fail with a useful
hint instead of letting the resolver report "not found":

  [ctask] error: workspace "X" is archived

  To restore it:
    ctask restore X

This is implemented by resolving archived-inclusive and rejecting
status==archived before any session-launch logic runs. Genuine
not-found and ambiguous-match behavior are unchanged.

Adds ValidArgsFunction hooks to archive (active), delete (active),
open (active), info (any), resume (active). Restore/notes/path
already have hooks from the previous commit. Shell completion now
covers the full direct-lookup surface.
2026-05-07 19:47:24 -04:00
typebasedio 176e788f67 feat(v0.5.2): add restore, notes, path commands with completion plumbing
Three new direct-lookup commands per v0.5.2-spec.md:

- ctask restore <ws>   un-archive a workspace (metadata-only flip,
                       mirrors archive's lease guard, refuses to
                       restore an already-active workspace)
- ctask notes <ws>     stream a workspace's notes.md to stdout (raw,
                       no framing, [ctask]-prefixed stderr on error)
                       so AI agents can read prior workspace context
                       through standard shell pipelines
- ctask path <ws>      print the absolute filesystem path of a
                       workspace, OS-native separators, one line

All three resolve archived-inclusive: the user typed a name, so we
find the workspace whether or not it's archived. Listing stays
filtered (active-only by default) per the v0.5.2 design rule
"listing is filtered, direct lookup is comprehensive".

Adds shared completion infrastructure (cmd/completion.go) used by
these commands and wired into the existing workspace-accepting
commands in a follow-up commit. Candidates are workspace directory
basenames (e.g. 2026-04-22_promptvolley) rather than bare slugs
because basenames are unique under the resolver's exact-match step
while slugs can collide across categories or dates.
2026-05-07 19:47:14 -04:00
typebasedio 7a7b2490c2 feat(v0.5.1): Linux portability baseline
- justfile: add build-linux, build-windows, build-all (output to dist/)
- .gitignore: cover ctask, ctask-*, dist/
- scripts/install.sh + scripts/uninstall.sh: POSIX equivalents of .ps1
- remove WorkspacePath metadata field (no production readers; legacy
  task.yaml files continue to parse silently)

Linux smoke-test on WSL/container pending.
See audit-report.md and v0.5.1-spec.md.
2026-05-07 18:22:41 -04:00
typebasedio a11d48b8cd chore(v0.5.1): bump version to 0.5.1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:33:55 -04:00
typebasedio a162aec0b2 fix(v0.5.1): use local time for workspace directory prefix and info display
Workspace directory names (YYYY-MM-DD_slug) and the YYYYMMDD-HHMMSS ID
field now use local time so users see their wall-clock date rather
than UTC — the prior behavior caused evening-EST creations to appear
under tomorrow's date for several hours every day. ctask info's
Created/Updated/Archived lines also convert to local for display.

Stored timestamps in task.yaml, session logs, the lease, the manifest,
and the session summary all continue to use UTC. Only user-facing
surfaces change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:33:52 -04:00
typebasedio 8130a689d4 chore(v0.5): bump version to 0.5.0
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 19:53:45 -04:00
typebasedio 70bd1674b3 feat(v0.5): add CTASK_PROJECT_ROOT check to ctask doctor
Three-state check matching the seed-dir pattern: INFO when unset
(points at the default discovery location), INFO with user-scope
advisory when set and present, FAIL when set but the directory
doesn't exist. Advisory wording is recommendatory, not prescriptive
(per spec amendment).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 19:51:52 -04:00
typebasedio cdff7f32eb feat(v0.5): show launch_dir fields in ctask info output
For project workspaces with launch_dir set, info prints three extra
lines after Path: Launch dir, Launch path, and Dir exists (yes/no
from a direct os.Stat of the intended path). Tasks and pre-v0.5
projects still omit these lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 19:50:07 -04:00
typebasedio 103f2cd33e feat(v0.5): launch agent inside project subdirectory via launch_dir
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>
2026-04-22 19:49:29 -04:00
typebasedio 509a6d64ea feat(v0.5): export CTASK_LAUNCH_DIR into child sessions
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>
2026-04-22 19:48:23 -04:00
typebasedio 35d3b24e09 chore(v0.4.1): bump version to 0.4.1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 18:03:43 -04:00
typebasedio 4fdd153bc4 feat(v0.4.1): warn when archiving workspace with active session
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>
2026-04-22 17:57:31 -04:00
typebasedio 57c6c909d3 feat(v0.4.1): add seed directory checks to ctask doctor
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>
2026-04-22 17:56:27 -04:00
typebasedio 0c1f03ba3a fix(v0.4.1): route all workspace commands through SearchRoots
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>
2026-04-22 17:54:58 -04:00
typebasedio 02dcdcc215 fix: remove provisional workspace when launch is canceled with no changes
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>
2026-04-22 12:01:34 -04:00
typebasedio f129d59596 feat(v0.4): bump version to 0.4.0 2026-04-21 17:17:07 -04:00
typebasedio 67138584d4 feat(v0.4): add --force flag on resume, last, and open 2026-04-21 17:07:04 -04:00
typebasedio ab89a167a5 refactor(v0.4): route session-lifecycle and archive task.yaml writes through write lock 2026-04-21 17:04:23 -04:00
typebasedio 3dbf963d38 feat(v0.3): clean up ctask list semantics
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.
2026-04-10 17:02:27 -04:00
typebasedio ce742470b2 refactor(v0.3): consolidate cmd/last and cmd/delete onto MostRecentActive
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)
2026-04-10 17:00:42 -04:00
typebasedio bd1cff5b26 refactor(v0.3): replace ListOpts.Projects bool with tri-state Type filter
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.
2026-04-10 16:49:49 -04:00
typebasedio f22b266c6c chore(v0.3): bump version to 0.3.0 2026-04-10 14:55:23 -04:00
typebasedio 9e23277094 feat(v0.3): add informational seed directory checks to doctor
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".
2026-04-10 14:55:01 -04:00
typebasedio 1be121813e feat(v0.3): add --projects flag to ctask list
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.
2026-04-10 14:50:43 -04:00