Commit Graph

68 Commits

Author SHA1 Message Date
typebasedio f129d59596 feat(v0.4): bump version to 0.4.0 2026-04-21 17:17:07 -04:00
typebasedio 46c7ef2c5c docs(v0.4): document --force, session lease, stale-workspace detection, and coexisting-session limitation 2026-04-21 17:16:54 -04:00
typebasedio 0e7d4a5717 test(v0.4): cover session finalize end-to-end 2026-04-21 17:10:58 -04:00
typebasedio c8e06a5324 feat(v0.4): sequence session.Run through Layers 1-4 2026-04-21 17:10:37 -04:00
typebasedio a050b116fa feat(v0.4): add Preflight checks for Layer 1 and Layer 3 2026-04-21 17:09:41 -04:00
typebasedio 77513aa5f8 feat(v0.4): add DetectExternalChanges and stale-workspace warning 2026-04-21 17:08:46 -04:00
typebasedio aabb7c6464 test(v0.4): cover SummarizeFromDiff and FormatLaunchContext 2026-04-21 17:08:09 -04:00
typebasedio 68a4f7e4cc feat(v0.4): add SessionSummary type with round-trip and launch-context formatter 2026-04-21 17:07:47 -04:00
typebasedio 67138584d4 feat(v0.4): add --force flag on resume, last, and open 2026-04-21 17:07:04 -04:00
typebasedio 25b2b46171 feat(v0.4): add Force to LaunchOpts (no-op until Phase 9) 2026-04-21 17:06:32 -04:00
typebasedio 8d7d4cbff9 feat(v0.4): add FormatActiveWarning and FormatStaleCleanupNotice 2026-04-21 17:06:14 -04:00
typebasedio cc7a8535a3 feat(v0.4): add ConfirmYN prompt helper 2026-04-21 17:05:36 -04:00
typebasedio 42fce73824 feat(v0.4): add heartbeat goroutine that updates lease timestamp 2026-04-21 17:05:15 -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 d1bcd1a1ba feat(v0.4): add WriteMetaLocked wrapper backed by workspace write lock 2026-04-21 17:04:01 -04:00
typebasedio bc5410f722 feat(v0.4): add lease freshness check and stale cleanup 2026-04-21 17:03:21 -04:00
typebasedio c29985b663 feat(v0.4): add NewLease and NewSessionID constructors 2026-04-21 17:02:48 -04:00
typebasedio 305a9d7c23 feat(v0.4): add session Lease type with JSON round-trip 2026-04-21 17:02:23 -04:00
typebasedio 1c62410a06 feat(v0.4): add WithLock helper that warns-and-skips on timeout 2026-04-21 17:01:36 -04:00
typebasedio dc16713f11 test(v0.4): cover lockfile release, contention, and stale removal 2026-04-21 17:01:16 -04:00
typebasedio c64f9ac88c feat(v0.4): add internal/lockfile primitive with atomic exclusive acquire 2026-04-21 17:00:57 -04:00
typebasedio 6532cba94f docs(v0.3): document new ctask list semantics and --task flag
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
2026-04-10 17:02:58 -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 3a4a8d28f2 test(v0.3): add MostRecentActive helper with focused unit coverage
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.
2026-04-10 17:00:05 -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 4b6c8fad4b docs(v0.3): add v0.3 spec and implementation plan
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.
2026-04-10 15:01:52 -04:00
typebasedio dacd8018cf docs(v0.3): document --project, --projects, seed dirs, CTASK_TYPE
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.
2026-04-10 14:57:00 -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 2d1d779f4b feat(v0.3): show |project marker in status line when CTASK_TYPE=project
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)
2026-04-10 14:54:06 -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
typebasedio bfe89d830c feat(v0.3): add Projects filter to ListWorkspaces; fix last/delete
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).
2026-04-10 14:43:28 -04:00
typebasedio 84ca6a8d1c feat(v0.3): run git init and ensure .gitignore for project workspaces
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.
2026-04-10 14:42:01 -04:00
typebasedio 6519582de6 feat(v0.3): add EnsureGitignore + RunGitInit helpers
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
2026-04-10 14:41:14 -04:00
typebasedio 8cda541f2c feat(v0.3): add --project flag, CTASK_TYPE env, project root semantics
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.
2026-04-10 14:40:06 -04:00
typebasedio 3adfe62410 feat(v0.3): add SkipCategoryDir for CTASK_PROJECT_ROOT semantics
When SkipCategoryDir is true, Create places the workspace directly
under Root and does not append a Category subdirectory. This is the
mechanism that prevents doubled paths like
~/projects/projects/<slug> when the user sets CTASK_PROJECT_ROOT
without an explicit -c flag. The Category value is still recorded
on TaskMeta so list/info/filter still work.
2026-04-10 14:38:01 -04:00
typebasedio e09eac62d1 feat(v0.3): support project mode and layered seed overlay in Create
CreateOpts gains IsProject, SeedDir, and ProjectSeedDir. The new
seeding flow is:

  1. write built-in defaults (task or project CLAUDE.md + notes.md)
  2. apply general seed if SeedDir != "" (overlay)
  3. apply project seed if IsProject && ProjectSeedDir != "" (overlay)
  4. write task.yaml (last, so seeds can never inject metadata)

The obsolete TestCreateDoesNotOverwriteSeedFiles test is removed:
its v0.2 invariant ("don't overwrite existing files") no longer
holds because v0.3 always lays defaults onto a fresh dir and seeds
are expected to overwrite.
2026-04-10 14:37:09 -04:00
typebasedio 72be64cc1a feat(v0.3): add Type field to TaskMeta with backward-compat helper
TaskMeta now records type: task or type: project. EffectiveType
returns 'task' for missing/empty/unknown values and for nil meta,
so v0.2 workspaces continue to read as tasks without any
migration. The field is placed between Category and Mode in the
YAML output. Tests cover the round-trip and the legacy
no-type-field case.
2026-04-10 14:34:53 -04:00
typebasedio 6fe28464d5 feat(v0.3): add CopySeedDir with task.yaml/.ctask skip
CopySeedDir is the v0.3 user seed overlay primitive: recursive copy
from a seed directory to a workspace, overwriting destination
files. task.yaml and the .ctask metadata directory at the seed root
are intentionally skipped so a stale or hostile seed cannot
overwrite ctask-owned state. Missing src is a no-op (the seed
directory is optional).
2026-04-10 14:33:42 -04:00
typebasedio d3e20821d7 feat(v0.3): add seed dir and project root resolvers in config
ResolveSeedDir, ResolveProjectSeedDir, and ResolveProjectRoot read
the v0.3 environment variables (CTASK_SEED_DIR,
CTASK_SEED_PROJECT_DIR, CTASK_PROJECT_ROOT) and fall back to
platform defaults under %APPDATA%\ctask or ~/.config/ctask. The
expandPath helper handles tilde expansion + abs-path resolution
once for all resolvers.
2026-04-10 14:32:46 -04:00
typebasedio ced0d276b4 feat(v0.3): add built-in project CLAUDE.md template
ClaudeMDProject returns the project-oriented default used when
--project is passed (and no project seed overrides it). Adds tests
asserting required v0.3 spec sections and ASCII-only content.
2026-04-10 14:31:39 -04:00
typebasedio 0439702833 feat(v0.3): replace built-in task CLAUDE.md with v0.3 default content
Replaces the v0.2 task-scoped template with the v0.3 workspace
guidelines (file placement conventions + session handoff).
ClaudeMD signature is preserved for API compatibility; the
parameters are no longer interpolated.
2026-04-10 14:30:54 -04:00
typebasedio 401092f55a docs: add README, install, commands, and troubleshooting documentation
README.md: project overview, quick start, command table, install/uninstall summary.
docs/install.md: prerequisites, install/uninstall procedures, install location, PATH behavior, status-line setup.
docs/commands.md: all 9 commands with syntax, flags, examples, query resolution, env vars, exit codes.
docs/troubleshooting.md: practical fixes for PATH, status line, doctor failures, delete protection, file locations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:44:25 -04:00
typebasedio 44e3c38248 fix: doctor gives copy-pasteable statusLine fix with actual discovered path
When the status-line helper is found but Claude settings are misconfigured,
the fix suggestion now shows the real path (e.g. /c/Users/Warren/...) instead
of a <you> placeholder. Always suggests the .sh variant even if only .ps1
was found, since Claude Code runs statusLine through bash.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:35:45 -04:00
typebasedio 3562d063e5 feat: justfile task runner and updated install/setup documentation
justfile with build/install/uninstall/test targets. CLAUDE.md updated with
new install path and commands. status-line-setup.md updated for
%LOCALAPPDATA%\ctask\bin location.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:19:53 -04:00
typebasedio bbd10d6e62 fix: doctor searches %LOCALAPPDATA%\ctask\bin first for status-line helper
Adds the canonical install location as the primary search path on Windows,
before falling back to GOPATH/bin. Updates the Claude config guidance message
to reference the new path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:18:21 -04:00
typebasedio 2bdeffc8ae feat: PowerShell uninstall script for Windows
Removes only ctask-owned files from %LOCALAPPDATA%\ctask\bin. Removes PATH
entry only if .ctask-path-added marker exists (ownership tracking). Cleans
empty install directory. Never touches workspace data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:16:47 -04:00
typebasedio dce3317eec feat: PowerShell install script for Windows
Builds from local repo, installs to %LOCALAPPDATA%\ctask\bin, adds to user
PATH with ownership marker (.ctask-path-added) for safe uninstall. Finds Go
in standard install location if not on PowerShell PATH.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:15:47 -04:00
typebasedio 2a606053dd docs: anti-guessing guardrails in project CLAUDE.md and seeded workspace template
Add "Repository and Package Identity" rule to both the project-level CLAUDE.md
and the seeded CLAUDE.md template (internal/seed/templates.go). Every new ctask
workspace now inherits guidance against fabricating repo URLs, module paths,
GitHub identities, or remote install commands.

Also adds local-only build/install instructions and data safety invariant
documentation to the project-level CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:09:29 -04:00