feat(v0.5): export CTASK_LAUNCH_DIR into child sessions

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>
This commit is contained in:
2026-04-22 19:48:23 -04:00
parent 7cfafdc285
commit 509a6d64ea
5 changed files with 39 additions and 19 deletions
+10 -7
View File
@@ -90,17 +90,20 @@ func samePath(a, b string) bool {
// EnvVars returns the environment variables to export into child sessions.
// taskType must be "task" or "project"; an empty value defaults to "task".
func EnvVars(slug, mode, root, workspace, category, taskType string) map[string]string {
// launchDir is the workspace-relative project subdirectory for projects,
// or empty for tasks and pre-v0.5 projects.
func EnvVars(slug, mode, root, workspace, category, taskType, launchDir string) map[string]string {
if taskType == "" {
taskType = "task"
}
return map[string]string{
"CTASK_TASK": slug,
"CTASK_MODE": mode,
"CTASK_ROOT": root,
"CTASK_WORKSPACE": workspace,
"CTASK_CATEGORY": category,
"CTASK_TYPE": taskType,
"CTASK_TASK": slug,
"CTASK_MODE": mode,
"CTASK_ROOT": root,
"CTASK_WORKSPACE": workspace,
"CTASK_CATEGORY": category,
"CTASK_TYPE": taskType,
"CTASK_LAUNCH_DIR": launchDir,
}
}