Why: Generated files kept Word's default theme, US Letter pages, hand-typed bullets and empty sections. Recipes only showed library calls, the prompt had no craft standard, and seeded skills could not be upgraded once written. Evidence: go test ./... passed. The house-style suite covers three themes across docx, pptx and xlsx, and rejects a document that repeats the diagnosed layout failures. lint on the sample minutes exits 1. Impact: Every run gets a resident quality standard. Office files use house-style (switchable themes, templates, imitation) and must pass lint. Skill seeding upgrades untouched builtins and keeps user edits. Uploads land in inputs/, and the default style is a setting. Refs: feature/agent-professional-deliverables Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package runmgr
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestStageWorkspaceInputs(t *testing.T) {
|
|
root := t.TempDir()
|
|
paths, err := StageWorkspaceInputs(root, "alice", "conv1", []WorkspaceFile{
|
|
{Name: "纪要.docx", Content: []byte("docx")},
|
|
{Name: "../secret.txt", Content: []byte("no")},
|
|
{Name: "纪要.docx", Content: []byte("second")},
|
|
{Name: "", Content: []byte("skip")},
|
|
}, "品牌模板.pptx", []byte("tpl"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []string{"inputs/纪要.docx", "inputs/secret.txt", "inputs/纪要-2.docx", "inputs/_default-template.pptx"}
|
|
if len(paths) != len(want) {
|
|
t.Fatalf("paths = %v, want %v", paths, want)
|
|
}
|
|
for i, rel := range want {
|
|
if paths[i] != rel {
|
|
t.Fatalf("paths[%d] = %q, want %q", i, paths[i], rel)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(root, "alice", "conv1", rel)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if _, err := os.Stat(filepath.Join(root, "alice", "secret.txt")); err == nil {
|
|
t.Fatal("path traversal must not escape inputs/")
|
|
}
|
|
empty, err := StageWorkspaceInputs("", "alice", "conv1", []WorkspaceFile{{Name: "a.txt", Content: []byte("x")}}, "", nil)
|
|
if err != nil || empty != nil {
|
|
t.Fatalf("unconfigured root must no-op, got %v %v", empty, err)
|
|
}
|
|
}
|