mirror of
https://github.com/larksuite/cli.git
synced 2026-07-06 08:12:36 +08:00
feat: report anygen prompt assets in svglide next
This commit is contained in:
@@ -20,10 +20,12 @@ type StatusReport struct {
|
||||
}
|
||||
|
||||
type NextTaskReport struct {
|
||||
Stage string `json:"stage"`
|
||||
PromptPath string `json:"prompt_path"`
|
||||
Inputs []string `json:"inputs"`
|
||||
Outputs []string `json:"outputs"`
|
||||
Stage string `json:"stage"`
|
||||
PromptPath string `json:"prompt_path,omitempty"`
|
||||
PromptPaths []string `json:"prompt_paths"`
|
||||
PromptManifest string `json:"prompt_manifest"`
|
||||
Inputs []string `json:"inputs"`
|
||||
Outputs []string `json:"outputs"`
|
||||
}
|
||||
|
||||
func ReadRun(root string) (Run, error) {
|
||||
@@ -75,10 +77,6 @@ func NextTask(root string) (NextTaskReport, error) {
|
||||
if len(missingInputs) > 0 {
|
||||
return NextTaskReport{}, fmt.Errorf("current stage %q missing inputs: %s", stage.Name, strings.Join(missingInputs, ", "))
|
||||
}
|
||||
promptPath, err := promptPathForStage(stage.Name)
|
||||
if err != nil {
|
||||
return NextTaskReport{}, err
|
||||
}
|
||||
inputs, err := validateRunPaths(safeRoot, stage.Inputs)
|
||||
if err != nil {
|
||||
return NextTaskReport{}, err
|
||||
@@ -88,10 +86,11 @@ func NextTask(root string) (NextTaskReport, error) {
|
||||
return NextTaskReport{}, err
|
||||
}
|
||||
return NextTaskReport{
|
||||
Stage: stage.Name,
|
||||
PromptPath: promptPath,
|
||||
Inputs: inputs,
|
||||
Outputs: outputs,
|
||||
Stage: stage.Name,
|
||||
PromptPaths: PromptPathsForStage(stage.Name),
|
||||
PromptManifest: "prompt_manifest.json",
|
||||
Inputs: inputs,
|
||||
Outputs: outputs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -366,26 +365,3 @@ func isShellBareword(value string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func promptPathForStage(stage string) (string, error) {
|
||||
switch stage {
|
||||
case StageRequest:
|
||||
return "prompts/01_request.task.md", nil
|
||||
case StageResearch:
|
||||
return "prompts/02_research.task.md", nil
|
||||
case StageDesignBrief:
|
||||
return "prompts/03_design_brief.task.md", nil
|
||||
case StageOutline:
|
||||
return "prompts/04_outline.task.md", nil
|
||||
case StageSlideContent:
|
||||
return "prompts/05_slide_content.task.md", nil
|
||||
case StageAssets:
|
||||
return "prompts/06_assets.task.md", nil
|
||||
case StageSVGAuthor:
|
||||
return "prompts/07_svg_author.task.md", nil
|
||||
case StageValidatePreviewRepair:
|
||||
return "prompts/08_repair.task.md", nil
|
||||
default:
|
||||
return "", fmt.Errorf("stage %q has no prompt mapping", stage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,14 +82,20 @@ func TestNextReturnsCurrentTaskPrompt(t *testing.T) {
|
||||
if next.Stage != StageRequest {
|
||||
t.Fatalf("Stage = %q, want %q", next.Stage, StageRequest)
|
||||
}
|
||||
if next.PromptPath != "prompts/01_request.task.md" {
|
||||
t.Fatalf("PromptPath = %q, want prompts/01_request.task.md", next.PromptPath)
|
||||
if next.PromptManifest != "prompt_manifest.json" {
|
||||
t.Fatalf("PromptManifest = %q, want prompt_manifest.json", next.PromptManifest)
|
||||
}
|
||||
if filepath.IsAbs(next.PromptPath) {
|
||||
t.Fatalf("PromptPath = %q, want relative path", next.PromptPath)
|
||||
if next.PromptPath != "" {
|
||||
t.Fatalf("PromptPath = %q, want empty deprecated field", next.PromptPath)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join("demo", next.PromptPath)); err != nil {
|
||||
t.Fatalf("missing prompt %s: %v", next.PromptPath, err)
|
||||
got := strings.Join(next.PromptPaths, "\n")
|
||||
for _, want := range []string{
|
||||
"skills/lark-slides/references/anygen-svg/mode_system_prompt_svg.md",
|
||||
"skills/lark-slides/references/anygen-svg/svg_reference.md",
|
||||
} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Fatalf("PromptPaths missing %q:\n%s", want, got)
|
||||
}
|
||||
}
|
||||
if len(next.Inputs) != 0 {
|
||||
t.Fatalf("Inputs = %v, want empty", next.Inputs)
|
||||
|
||||
Reference in New Issue
Block a user