mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-09-14 20:16:53 +08:00
d73705736f
* feat: make apply instructions schema-aware
The `generateApplyInstructions` function was hardcoded to check for
`spec-driven` artifacts. This change makes it read artifact definitions
from the schema's new `apply` block, enabling support for different
workflows like TDD.
Changes:
- Add `ApplyPhaseSchema` Zod schema with `requires`, `tracks`, and
`instruction` fields to types.ts
- Update `SchemaYamlSchema` to include optional `apply` field
- Add `apply` block to spec-driven and tdd schemas
- Refactor `generateApplyInstructions` to:
- Load schema via `resolveSchema()`
- Read `apply.requires` for required artifacts
- Check artifact existence dynamically (supports glob patterns)
- Use `apply.tracks` for progress tracking (or skip if null)
- Use `apply.instruction` for custom guidance
- Build `contextFiles` from all existing artifacts in schema
- Handle fallback when schema has no `apply` block (require all artifacts)
- Add 8 new tests for schema-aware apply behavior
* fix: improve apply instructions robustness and consistency
- Fix artifactOutputExists to properly handle glob patterns cross-platform
by using path.sep and verifying actual file matches
- Remove redundant if/else in contextFiles loop
- Distinguish between missing tracks file vs empty tracks file
- Use consistent { error: } key in ApplyPhaseSchema validation
- Rename fallback test to accurately describe what it tests
* test: add fallback behavior tests for schemas without apply block
Add two tests that verify the fallback logic when a schema lacks an
apply block:
- Blocks when not all artifacts exist (requires ALL artifacts)
- Ready state with default instruction when all artifacts exist
Uses XDG_DATA_HOME to create temporary user schemas for testing.
1.3 KiB
1.3 KiB
Prerequisites
- 0.1 Implement
add-per-change-schema-metadatafirst (to auto-detect schema)
1. Schema Format
- 1.1 Add
ApplyPhaseSchemaZod schema tosrc/core/artifact-graph/types.ts - 1.2 Update
SchemaYamlSchemato include optionalapplyfield - 1.3 Export
ApplyPhasetype
2. Update Existing Schemas
- 2.1 Add
applyblock toschemas/spec-driven/schema.yaml - 2.2 Add
applyblock toschemas/tdd/schema.yaml
3. Refactor generateApplyInstructions
- 3.1 Load schema via
resolveSchema(schemaName) - 3.2 Read
apply.requiresto determine required artifacts - 3.3 Check artifact existence dynamically (not hardcoded paths)
- 3.4 Use
apply.tracksfor progress tracking (or skip if null) - 3.5 Use
apply.instructionfor the instruction text - 3.6 Build
contextFilesfrom all existing artifacts in schema
4. Handle Fallback
- 4.1 If schema has no
applyblock, require all artifacts to exist - 4.2 Default instruction: "All artifacts complete. Proceed with implementation."
5. Tests
- 5.1 Test apply instructions with spec-driven schema
- 5.2 Test apply instructions with tdd schema
- 5.3 Test fallback when schema has no apply block
- 5.4 Test blocked state when required artifacts missing