Fix portable prompt record export command routing
Hop-State: A_06FN6WBVEZC485TNKJEW7T0 Hop-Proposal: R_06FN6WAJ8346WS9XJEJY32R Hop-Task: T_06FN6VQSN9Z7GEWHBVEFAJG Hop-Attempt: AT_06FN6VQSN9TK8EEXTFR77ZG
This commit is contained in:
+8
-9
@@ -206,6 +206,14 @@ func RunCLIWithInput(args []string, stdin io.Reader, stdout, stderr io.Writer) i
|
||||
fmt.Fprintln(stderr, "usage: hop checkpoint STATE")
|
||||
return 2
|
||||
}
|
||||
state, err := service.Checkpoint(ctx, commandArgs[0])
|
||||
if err != nil {
|
||||
return printCLIError(err, jsonOutput, stdout, stderr)
|
||||
}
|
||||
value = state
|
||||
if !jsonOutput {
|
||||
fmt.Fprintf(stdout, "Created checkpoint %s · tree %s\n", state.ID, shortHash(state.SourceTree))
|
||||
}
|
||||
|
||||
case "export":
|
||||
fs := flag.NewFlagSet("export", flag.ContinueOnError)
|
||||
@@ -229,15 +237,6 @@ func RunCLIWithInput(args []string, stdin io.Reader, stdout, stderr io.Writer) i
|
||||
}
|
||||
fmt.Fprintf(stdout, "Exported %d prompt records to %s\n", len(ledger.Prompts), filepath.Join(root, ".hop", "records", "prompts"))
|
||||
}
|
||||
state, err := service.Checkpoint(ctx, commandArgs[0])
|
||||
if err != nil {
|
||||
return printCLIError(err, jsonOutput, stdout, stderr)
|
||||
}
|
||||
value = state
|
||||
if !jsonOutput {
|
||||
fmt.Fprintf(stdout, "Created checkpoint %s · tree %s\n", state.ID, shortHash(state.SourceTree))
|
||||
}
|
||||
|
||||
case "check":
|
||||
stateID, argv, ok := splitCommand(commandArgs)
|
||||
if !ok {
|
||||
|
||||
@@ -345,6 +345,28 @@ func TestCLIJSONWorkflow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLIExportWritesPortablePromptRecords(t *testing.T) {
|
||||
t.Setenv("HOP_ROOT", "")
|
||||
root := t.TempDir()
|
||||
writeTestFile(t, filepath.Join(root, "base.txt"), "base\n")
|
||||
previousDirectory, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Chdir(root); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = os.Chdir(previousDirectory) })
|
||||
|
||||
runCLIJSONTest(t, []string{"init", "--json"})
|
||||
runCLIJSONTest(t, []string{"begin", "--agent", "codex", "--json", "Publish prompt records"})
|
||||
runCLIJSONTest(t, []string{"export", "--output", ".", "--json"})
|
||||
entries, err := filepath.Glob(filepath.Join(root, ".hop", "records", "prompts", "P_*.json"))
|
||||
if err != nil || len(entries) != 1 {
|
||||
t.Fatalf("portable prompt records = %v, err=%v", entries, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLIBeginAutoInitializesAndContinuesCodexSession(t *testing.T) {
|
||||
t.Setenv("HOP_ROOT", "")
|
||||
root := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user