2026-01-30 00:22:47 +00:00
|
|
|
// ai_updates.go implements task update and completion commands.
|
|
|
|
|
|
|
|
|
|
package ai
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/host-uk/core/pkg/agentic"
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
2026-01-30 00:47:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-01-30 00:22:47 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// task:update command flags
|
|
|
|
|
var (
|
|
|
|
|
taskUpdateStatus string
|
|
|
|
|
taskUpdateProgress int
|
|
|
|
|
taskUpdateNotes string
|
|
|
|
|
)
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// task:complete command flags
|
|
|
|
|
var (
|
|
|
|
|
taskCompleteOutput string
|
|
|
|
|
taskCompleteFailed bool
|
|
|
|
|
taskCompleteErrorMsg string
|
|
|
|
|
)
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
var taskUpdateCmd = &cobra.Command{
|
|
|
|
|
Use: "task:update [task-id]",
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
Short: i18n.T("cmd.ai.task_update.short"),
|
|
|
|
|
Long: i18n.T("cmd.ai.task_update.long"),
|
|
|
|
|
Args: cobra.ExactArgs(1),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
taskID := args[0]
|
|
|
|
|
|
|
|
|
|
if taskUpdateStatus == "" && taskUpdateProgress == 0 && taskUpdateNotes == "" {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
return fmt.Errorf(i18n.T("cmd.ai.task_update.flag_required"))
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cfg, err := agentic.LoadConfig("")
|
|
|
|
|
if err != nil {
|
2026-01-30 11:35:38 +00:00
|
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := agentic.NewClientFromConfig(cfg)
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
update := agentic.TaskUpdate{
|
2026-01-30 00:47:54 +00:00
|
|
|
Progress: taskUpdateProgress,
|
|
|
|
|
Notes: taskUpdateNotes,
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
2026-01-30 00:47:54 +00:00
|
|
|
if taskUpdateStatus != "" {
|
|
|
|
|
update.Status = agentic.TaskStatus(taskUpdateStatus)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := client.UpdateTask(ctx, taskID, update); err != nil {
|
2026-01-30 11:44:45 +00:00
|
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "update task"}), err)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 11:44:45 +00:00
|
|
|
fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task updated"}))
|
2026-01-30 00:22:47 +00:00
|
|
|
return nil
|
2026-01-30 00:47:54 +00:00
|
|
|
},
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
var taskCompleteCmd = &cobra.Command{
|
|
|
|
|
Use: "task:complete [task-id]",
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
Short: i18n.T("cmd.ai.task_complete.short"),
|
|
|
|
|
Long: i18n.T("cmd.ai.task_complete.long"),
|
|
|
|
|
Args: cobra.ExactArgs(1),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
taskID := args[0]
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
cfg, err := agentic.LoadConfig("")
|
|
|
|
|
if err != nil {
|
2026-01-30 11:35:38 +00:00
|
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := agentic.NewClientFromConfig(cfg)
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
result := agentic.TaskResult{
|
2026-01-30 00:47:54 +00:00
|
|
|
Success: !taskCompleteFailed,
|
|
|
|
|
Output: taskCompleteOutput,
|
|
|
|
|
ErrorMessage: taskCompleteErrorMsg,
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := client.CompleteTask(ctx, taskID, result); err != nil {
|
2026-01-30 11:44:45 +00:00
|
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "complete task"}), err)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
if taskCompleteFailed {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf("%s %s\n", errorStyle.Render(">>"), i18n.T("cmd.ai.task_complete.failed", map[string]interface{}{"ID": taskID}))
|
2026-01-30 00:22:47 +00:00
|
|
|
} else {
|
2026-01-30 11:44:45 +00:00
|
|
|
fmt.Printf("%s %s\n", successStyle.Render(">>"), i18n.T("common.success.completed", map[string]any{"Action": "Task completed"}))
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
2026-01-30 00:47:54 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
// task:update command flags
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
taskUpdateCmd.Flags().StringVar(&taskUpdateStatus, "status", "", i18n.T("cmd.ai.task_update.flag.status"))
|
|
|
|
|
taskUpdateCmd.Flags().IntVar(&taskUpdateProgress, "progress", 0, i18n.T("cmd.ai.task_update.flag.progress"))
|
|
|
|
|
taskUpdateCmd.Flags().StringVar(&taskUpdateNotes, "notes", "", i18n.T("cmd.ai.task_update.flag.notes"))
|
2026-01-30 00:47:54 +00:00
|
|
|
|
|
|
|
|
// task:complete command flags
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
taskCompleteCmd.Flags().StringVar(&taskCompleteOutput, "output", "", i18n.T("cmd.ai.task_complete.flag.output"))
|
|
|
|
|
taskCompleteCmd.Flags().BoolVar(&taskCompleteFailed, "failed", false, i18n.T("cmd.ai.task_complete.flag.failed"))
|
|
|
|
|
taskCompleteCmd.Flags().StringVar(&taskCompleteErrorMsg, "error", "", i18n.T("cmd.ai.task_complete.flag.error"))
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addTaskUpdateCommand(parent *cobra.Command) {
|
|
|
|
|
parent.AddCommand(taskUpdateCmd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addTaskCompleteCommand(parent *cobra.Command) {
|
|
|
|
|
parent.AddCommand(taskCompleteCmd)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|