-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(config): handle null rules field in project config #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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)
…nfig - 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
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.
- 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
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.
📝 WalkthroughWalkthroughAdds a null guard to the rules field parsing in project-config.ts to prevent false positives when the rules field is null, since Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Greptile SummaryAdded null check when parsing the
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant readProjectConfig
participant YAML Parser
participant Validation Logic
User->>readProjectConfig: Read config file
readProjectConfig->>YAML Parser: Parse YAML content
YAML Parser-->>readProjectConfig: Return parsed object (rules: null)
readProjectConfig->>Validation Logic: Check raw.rules !== undefined
Validation Logic-->>readProjectConfig: true
readProjectConfig->>Validation Logic: Check typeof raw.rules === 'object'
Validation Logic-->>readProjectConfig: true (typeof null === 'object')
readProjectConfig->>Validation Logic: Check raw.rules !== null (NEW)
Validation Logic-->>readProjectConfig: false (is null)
readProjectConfig->>readProjectConfig: Skip Object.entries(null)
readProjectConfig->>readProjectConfig: Log warning about invalid rules
readProjectConfig-->>User: Return config with schema and context only
|
* 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.
Summary
rulesfield in project configrules:with no value parses tonull, andtypeof null === 'object'in JavaScriptObject.entries(null)would throw an errorTest plan
rules: nullscenario🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.