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.
This commit is contained in:
2026-05-07 19:47:14 -04:00
parent a5e508bcb6
commit 176e788f67
8 changed files with 902 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/warrenronsiek/ctask/internal/config"
)
var pathCmd = &cobra.Command{
Use: "path <query>",
Short: "Print the absolute filesystem path of a workspace",
Args: cobra.ExactArgs(1),
SilenceUsage: true,
RunE: runPath,
}
func init() {
pathCmd.ValidArgsFunction = completeWorkspaces(completionAny)
rootCmd.AddCommand(pathCmd)
}
// runPath prints QueryResult.Path to stdout with a single trailing newline.
// Uses native path separators — backslashes on Windows, forward slashes on
// Linux. Output is meant to be consumed by shell pipelines and agent tooling.
func runPath(cmd *cobra.Command, args []string) error {
roots := config.SearchRoots()
ws := resolveOne(roots, args[0], true)
fmt.Println(ws.Path)
return nil
}