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>
This commit is contained in:
2026-04-22 17:54:58 -04:00
parent 075000497f
commit 0c1f03ba3a
9 changed files with 26 additions and 24 deletions
+6 -4
View File
@@ -7,9 +7,11 @@ import (
"github.com/warrenronsiek/ctask/internal/workspace"
)
// resolveOne resolves a query to exactly one workspace. Prints errors and exits on 0 or >1 matches.
func resolveOne(root, query string, includeArchived bool) *workspace.QueryResult {
results, err := workspace.ResolveQuery(root, query, includeArchived)
// resolveOne resolves a query to exactly one workspace across the given roots.
// Prints errors and exits on 0 or >1 matches. Callers typically pass
// config.SearchRoots() so both CTASK_ROOT and CTASK_PROJECT_ROOT are searched.
func resolveOne(roots []string, query string, includeArchived bool) *workspace.QueryResult {
results, err := workspace.ResolveQuery(roots, query, includeArchived)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
@@ -23,7 +25,7 @@ func resolveOne(root, query string, includeArchived bool) *workspace.QueryResult
if len(results) > 1 {
fmt.Fprintf(os.Stderr, "Multiple workspaces match %q:\n", query)
for _, r := range results {
fmt.Fprintf(os.Stderr, " %s\n", workspace.RelativePath(root, r.Path))
fmt.Fprintf(os.Stderr, " %s\n", workspace.RelativePath(r.Root, r.Path))
}
fmt.Fprintln(os.Stderr, "Specify a more precise query.")
os.Exit(1)