Commit 6c8c778
authored
fix(config): handle null rules field in project config (Fission-AI#529)
* feat(config): add project-level configuration via openspec/config.yaml
Adds openspec/config.yaml support for project-level customization without
forking schemas. Teams can now:
- Set a default schema (used when --schema flag not provided)
- Inject project context into all artifact instructions
- Add per-artifact rules (e.g., proposal rules, specs rules)
Key changes:
- New `src/core/project-config.ts` with Zod schema and resilient parsing
- New `src/core/config-prompts.ts` for interactive config creation
- Updated schema resolution order: CLI → change metadata → config → default
- Updated instruction generation to inject <context> and <rules> XML sections
- Integrated config creation prompts into `artifact-experimental-setup`
Schema resolution precedence:
1. --schema CLI flag (explicit override)
2. .openspec.yaml in change directory (change-specific)
3. openspec/config.yaml schema field (project default)
4. "spec-driven" (hardcoded fallback)
* test(config): add e2e tests and performance benchmarks for project config
- Add project config integration tests in artifact-workflow.test.ts:
- Test new change uses schema from config
- Test CLI schema overrides config schema
- Test context and rules injection in instructions
- Test backwards compatibility without config file
- Test immediate reflection of config changes
- Add performance benchmark tests in project-config.test.ts:
- Typical config (1KB): <20ms target
- Large config (50KB): <50ms target
- Repeated reads consistency check
- Missing config fast-path test
- Add project configuration documentation in experimental-workflow.md:
- Config fields reference (schema, context, rules)
- Schema precedence explanation
- Artifact IDs by schema
- Troubleshooting guide
- Mark all tasks complete in tasks.md
* refactor(config): remove benchmark tests, document decision in source
Remove performance benchmark tests from project-config.test.ts and
document the results directly in the source code instead. Benchmarks
showed config reads are fast enough (~0.5ms typical) that caching
is unnecessary.
* fix(config): resolve three issues in project config feature
- Remove nested <template> tags: generateInstructions() no longer wraps
template content since printInstructionsText() already handles XML
structure
- Fix schema message accuracy: newChangeCommand() now uses the resolved
schema returned from createChange() instead of hardcoded fallback
- Add TTY check: artifact-experimental-setup skips interactive prompts
in non-TTY environments (CI, automation) to prevent hangs
* fix(config): handle null rules field in project config
Add null check when parsing rules field since YAML `rules:` with no
value parses to null, and `typeof null === 'object'` in JavaScript.
Without this check, Object.entries(null) would throw an error.1 parent 43b01ad commit 6c8c778
2 files changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
145 | 169 | | |
146 | 170 | | |
147 | 171 | | |
| |||
0 commit comments