feat: session lifecycle wrapper with manifest capture and session logging
Refactor new/resume/open to use session.Run() which wraps child process launch with pre/post manifest capture and append-only session logging to logs/sessions.log. Bump version to 0.2.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+13
-14
@@ -5,14 +5,15 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warrenronsiek/ctask/internal/config"
|
||||
"github.com/warrenronsiek/ctask/internal/session"
|
||||
"github.com/warrenronsiek/ctask/internal/shell"
|
||||
"github.com/warrenronsiek/ctask/internal/workspace"
|
||||
)
|
||||
|
||||
var newCmd = &cobra.Command{
|
||||
Use: "new [title]",
|
||||
Short: "Create a new task workspace and launch the agent",
|
||||
Long: "Create a new task workspace and launch the agent. If title is omitted, generates task-HHMMSS.",
|
||||
Use: "new [title]",
|
||||
Short: "Create a new task workspace and launch the agent",
|
||||
Long: "Create a new task workspace and launch the agent. If title is omitted, generates task-HHMMSS.",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
SilenceUsage: true,
|
||||
RunE: runNew,
|
||||
@@ -28,7 +29,7 @@ var (
|
||||
|
||||
func init() {
|
||||
newCmd.Flags().StringVarP(&newCategory, "category", "c", "general", "Workspace category subdirectory")
|
||||
newCmd.Flags().BoolVar(&newContainer, "container", false, "Launch in container sandbox (v0.2)")
|
||||
newCmd.Flags().BoolVar(&newContainer, "container", false, "Launch in container sandbox (deferred)")
|
||||
newCmd.Flags().BoolVar(&newShell, "shell", false, "Open interactive shell instead of agent")
|
||||
newCmd.Flags().StringVarP(&newAgent, "agent", "a", "", "Command to exec as the agent")
|
||||
newCmd.Flags().BoolVar(&newNoLaunch, "no-launch", false, "Create workspace only, do not launch")
|
||||
@@ -72,14 +73,12 @@ func runNew(cmd *cobra.Command, args []string) error {
|
||||
|
||||
envVars := config.EnvVars(ws.Meta.Slug, ws.Meta.Mode, root, ws.Path, ws.Meta.Category)
|
||||
|
||||
if newShell {
|
||||
return shell.ExecShell(ws.Path, envVars, ws.Meta.Slug, ws.Meta.Mode)
|
||||
}
|
||||
|
||||
// Agent mode: print banner and exec
|
||||
for _, line := range shell.BannerLines(ws.Meta.Mode, ws.Meta.Slug, ws.Path) {
|
||||
fmt.Println(line)
|
||||
}
|
||||
|
||||
return shell.ExecAgent(agent, ws.Path, envVars)
|
||||
return session.Run(session.LaunchOpts{
|
||||
WsDir: ws.Path,
|
||||
EnvVars: envVars,
|
||||
Agent: agent,
|
||||
Mode: ws.Meta.Mode,
|
||||
Slug: ws.Meta.Slug,
|
||||
Shell: newShell,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user