Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/dispatch/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ func emitBuildSchema(stdout io.Writer) int {
"const": schemaVersion,
},
"entity_path": map[string]any{
"type": "string",
"type": "string",
"description": "Absolute path or path relative to the caller's current working directory; never relative to workflow_dir. Identifies the project-root/state-checkout entity, not a code-worktree copy (for example, docs/dev/.spacedock-state/example/index.md).",
},
"workflow_dir": map[string]any{
"type": "string",
Expand Down
25 changes: 25 additions & 0 deletions internal/dispatch/build_json_ergonomics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,31 @@ func TestBuildSchemaAndValidateOnly(t *testing.T) {
})
}

func TestBuildSchemaDocumentsEntityPathBase(t *testing.T) {
native := runNativePreservingHostEnv("", "build", "--print-schema")
if native.exit != 0 {
t.Fatalf("print-schema exit=%d stderr=%s", native.exit, native.stderr)
}

var schema map[string]any
if err := json.Unmarshal([]byte(native.stdout), &schema); err != nil {
t.Fatalf("schema is not valid JSON: %v\n%s", err, native.stdout)
}
props, ok := schema["properties"].(map[string]any)
if !ok {
t.Fatalf("schema missing properties object:\n%s", native.stdout)
}
entityPath, ok := props["entity_path"].(map[string]any)
if !ok {
t.Fatalf("schema missing entity_path property:\n%s", native.stdout)
}

const want = "Absolute path or path relative to the caller's current working directory; never relative to workflow_dir. Identifies the project-root/state-checkout entity, not a code-worktree copy (for example, docs/dev/.spacedock-state/example/index.md)."
if got := entityPath["description"]; got != want {
t.Fatalf("entity_path description = %q, want %q", got, want)
}
}

func buildHostFixture(t *testing.T) (string, string) {
t.Helper()
root := t.TempDir()
Expand Down
7 changes: 4 additions & 3 deletions internal/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,14 @@ Flags:

Stdin JSON fields:
schema_version Dispatch schema version. The current supported value is 2.
entity_path Path to the entity file for this dispatch.
entity_path May be absolute or relative to the caller's current working directory; never relative to workflow_dir.
Identifies the project-root/state-checkout entity, not a code-worktree copy.
workflow_dir Workflow directory for the dispatch request.
stage Stage name to dispatch.
checklist Array of checklist strings for the dispatched worker.

Example:
{"schema_version":2,"entity_path":"thing.md","workflow_dir":".","stage":"implementation","checklist":["DONE: run tests"]}
Split-root example (called from the project root):
{"schema_version":2,"entity_path":"docs/dev/.spacedock-state/example/index.md","workflow_dir":"docs/dev","stage":"implementation","checklist":["DONE: run tests"]}
`)
}

Expand Down
18 changes: 18 additions & 0 deletions internal/dispatch/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ func TestDispatchBuildHelpBeforeRequiredFlags(t *testing.T) {
}
}

func TestDispatchBuildHelpDocumentsEntityPathBase(t *testing.T) {
res := runNative("", "build", "--help")
if res.exit != 0 {
t.Fatalf("dispatch build --help exit=%d, want 0\nstderr=%q", res.exit, res.stderr)
}
if res.stderr != "" {
t.Fatalf("dispatch build --help stderr=%q, want empty", res.stderr)
}

assertContainsAll(t, res.stdout,
"absolute or relative to the caller's current working directory",
"never relative to workflow_dir",
"project-root/state-checkout entity, not a code-worktree copy",
`"entity_path":"docs/dev/.spacedock-state/example/index.md"`,
`"workflow_dir":"docs/dev"`,
)
}

func TestDispatchShowStageDefHelpBeforeRequiredFlags(t *testing.T) {
for _, helpFlag := range []string{"--help", "-h"} {
t.Run(helpFlag, func(t *testing.T) {
Expand Down
Loading