mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
feat: add session resume support and improve output format
- Support session_id in parallel task config for resuming failed tasks - Change output format from JSON to human-readable text - Add helper functions (hello, greet, farewell) with tests - Clean up code formatting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,6 @@ const (
|
||||
stdinSpecialChars = "\n\\\"'`$"
|
||||
)
|
||||
|
||||
|
||||
// Test hooks for dependency injection
|
||||
var (
|
||||
stdinReader io.Reader = os.Stdin
|
||||
@@ -58,8 +57,8 @@ type TaskSpec struct {
|
||||
Task string `json:"task"`
|
||||
WorkDir string `json:"workdir,omitempty"`
|
||||
Dependencies []string `json:"dependencies,omitempty"`
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
Mode string `json:"-"`
|
||||
SessionID string `json:"-"`
|
||||
UseStdin bool `json:"-"`
|
||||
}
|
||||
|
||||
@@ -72,7 +71,6 @@ type TaskResult struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
|
||||
func parseParallelConfig(data []byte) (*ParallelConfig, error) {
|
||||
trimmed := bytes.TrimSpace(data)
|
||||
if len(trimmed) == 0 {
|
||||
@@ -115,6 +113,9 @@ func parseParallelConfig(data []byte) (*ParallelConfig, error) {
|
||||
task.ID = value
|
||||
case "workdir":
|
||||
task.WorkDir = value
|
||||
case "session_id":
|
||||
task.SessionID = value
|
||||
task.Mode = "resume"
|
||||
case "dependencies":
|
||||
for _, dep := range strings.Split(value, ",") {
|
||||
dep = strings.TrimSpace(dep)
|
||||
@@ -396,7 +397,6 @@ func run() int {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logInfo("Script started")
|
||||
|
||||
cfg, err := parseArgs()
|
||||
@@ -856,8 +856,16 @@ func min(a, b int) int {
|
||||
return b
|
||||
}
|
||||
|
||||
func test() string {
|
||||
return "hello $world"
|
||||
func hello() string {
|
||||
return "hello world"
|
||||
}
|
||||
|
||||
func greet(name string) string {
|
||||
return "hello " + name
|
||||
}
|
||||
|
||||
func farewell(name string) string {
|
||||
return "goodbye " + name
|
||||
}
|
||||
|
||||
func logInfo(msg string) {
|
||||
|
||||
Reference in New Issue
Block a user