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).
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).
When CTASK_PROJECT_ROOT is unset, SearchRoots now appends
\$CTASK_ROOT/projects/ so that projects created under the default
category are discoverable from any shell without per-session env var
setup. Dedupe in scanAllRoots prevents double-counting workspaces that
are reachable both via the depth-2 scan under CTASK_ROOT and via the
new explicit search root. Adds a named regression test asserting no
duplicates appear in either ResolveQuery or ListWorkspaces results.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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>
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.
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.
Go module, cobra root command, config resolution (CTASK_ROOT, CTASK_AGENT, EnvVars) with tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>