Repository navigation
fix(templates): give explore the project's context and rules #1408
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@fission-ai/openspec": patch | ||
| --- | ||
|
|
||
| Explore now reads the project's context and rules from `openspec/config.yaml` (or `config.yml`) at the start of a session, so it reasons with the same tech stack and conventions the artifact-creating workflows already receive. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { | ||
| getExploreSkillTemplate, | ||
| getOpsxExploreCommandTemplate, | ||
| } from '../../../src/core/templates/skill-templates.js'; | ||
|
|
||
| const skill = getExploreSkillTemplate(); | ||
| const command = getOpsxExploreCommandTemplate(); | ||
|
|
||
| // Both delivery surfaces must carry the same contract; every behavioral | ||
| // assertion below runs against each body. | ||
| const bodies: Array<[string, string]> = [ | ||
| ['skill', skill.instructions], | ||
| ['command', command.content], | ||
| ]; | ||
|
|
||
| describe('explore templates', () => { | ||
| // Regression for #696: explore never loaded the project's declared | ||
| // context, so it reasoned without the tech stack, conventions, and | ||
| // rules every artifact-creating workflow already receives. | ||
| it('loads project context from the OpenSpec config at startup (#696)', () => { | ||
| for (const [label, body] of bodies) { | ||
| expect(body, label).toContain('openspec/config.yaml'); | ||
| expect(body, label).toContain('`context`: project background'); | ||
| expect(body, label).toContain('`rules`: keyed by artifact id'); | ||
| } | ||
| }); | ||
|
|
||
| it('resolves the config through the reported root rather than assuming a repo-local path (#696)', () => { | ||
| for (const [label, body] of bodies) { | ||
| expect(body, label).toContain('openspec list --json'); | ||
| expect(body, label).toContain('<root.path>/openspec/config.yaml'); | ||
| expect(body, label).toContain('root.path'); | ||
| } | ||
| }); | ||
|
|
||
| // resolveConfigFilePath() probes config.yaml then config.yml, and | ||
| // `openspec init` leaves a .yml project on .yml forever - naming only | ||
| // .yaml would silently skip context for those projects. | ||
| it('accepts config.yml as well as config.yaml (#696)', () => { | ||
| for (const [label, body] of bodies) { | ||
| expect(body, label).toContain('config.yml'); | ||
| expect(body, label).toContain('skip this if neither file exists'); | ||
| } | ||
| }); | ||
|
|
||
| // `rules` is Record<artifactId, string[]>; explore holds no artifact at | ||
| // startup, so the guidance must not invite blanket application. | ||
| it('scopes rules to the artifact they are keyed to (#696)', () => { | ||
| for (const [label, body] of bodies) { | ||
| expect(body, label).toContain( | ||
| 'the entries for an artifact apply only when you write that artifact' | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| // House style across instructions.ts and the sibling workflow templates | ||
| // forbids leaking context/rules into the artifact, not just the chat. | ||
| it('treats project context as constraints that must not leak into output (#696)', () => { | ||
| for (const [label, body] of bodies) { | ||
| expect(body, label).toContain('constraints for you to follow'); | ||
| expect(body, label).toContain( | ||
| 'do NOT copy them into the conversation or into any artifact you create' | ||
| ); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert that config loading follows
openspec list --json.These assertions only verify independent substrings; they would pass if the config instructions appeared before root resolution or were unrelated to the
openspec list --jsonstep. Assert the relative ordering usingindexOf(...)so the startup contract is protected.Run with
pnpm exec vitest run test/core/templates/explore.test.ts.📝 Committable suggestion
🤖 Prompt for AI Agents