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>
This commit is contained in:
2026-04-22 19:51:52 -04:00
parent 47430a1b1e
commit 70bd1674b3
2 changed files with 88 additions and 0 deletions
+25
View File
@@ -200,6 +200,9 @@ func runDoctor(cmd *cobra.Command, args []string) error {
&failed,
)
// Check 8: CTASK_PROJECT_ROOT (v0.5).
checkProjectRoot(&passed, &failed)
// Summary
fmt.Println()
fmt.Printf("%d checks passed, %d failed\n", passed, failed)
@@ -210,6 +213,28 @@ func runDoctor(cmd *cobra.Command, args []string) error {
return nil
}
// checkProjectRoot prints the three-state CTASK_PROJECT_ROOT doctor line:
// - unset -> INFO pointing at the default location under CTASK_ROOT
// - set and exists -> INFO with custom-root advisory
// - set and missing -> FAIL (increments failed counter)
func checkProjectRoot(passed, failed *int) {
_ = passed // reserved for future symmetry with checkSeedDir
envValue := os.Getenv("CTASK_PROJECT_ROOT")
if envValue == "" {
defaultProj := filepath.Join(config.ResolveRoot(), "projects")
fmt.Printf(" [INFO] CTASK_PROJECT_ROOT: not set (projects discovered under %s)\n", defaultProj)
return
}
resolved := config.ResolveProjectRoot()
if info, err := os.Stat(resolved); err == nil && info.IsDir() {
fmt.Printf(" [INFO] CTASK_PROJECT_ROOT: %s (custom -- recommended: set at user scope so all terminals can discover these workspaces)\n", resolved)
return
}
fmt.Printf(" [FAIL] CTASK_PROJECT_ROOT configured but not found: %s\n", resolved)
fmt.Printf(" Fix: create the directory or unset CTASK_PROJECT_ROOT.\n")
*failed++
}
// checkSeedDir prints one of the three seed-directory doctor states.
// envValue is the raw value of the CTASK_SEED_* variable (empty means unset).
// resolved is the absolute path returned by the config resolver (used only