-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add non-interactive options to openspec init #122
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
feat: add non-interactive options to openspec init #122
Conversation
|
@tommy-ca Thanks for this, ill take a proper look later this afternoon. Can i maybe just ask, whats your use case for this? Are you initializing openspec in ci/cd environments? No risk in having this option just trying to wrap my head around the use case haha. |
Hi @TabishB, My use case is to initialize openspec workflow without any interactive input, for example open claude code and prompt to initialize openspec by referring to the github readme link. I intended to initialize the project with "initialize and extract specs from current repo, referring to https://github.com/Fission-AI/OpenSpec and run commands with npx", if openspec init requires interactive input, then claude code will initialize openspec workflow manually. Br, |
TabishB
left a comment
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.
Hey thanks for this! Just a comment on the flag options below, let me know what you think!
| #### Scenario: All tools selection | ||
| - **WHEN** run with `--all-tools` option | ||
| - **THEN** automatically select all available AI tools without prompting | ||
| - **AND** proceed with initialization using the selected tools | ||
|
|
||
| #### Scenario: Specific tools selection | ||
| - **WHEN** run with `--tools <comma-separated-list>` option | ||
| - **THEN** parse the comma-separated tool IDs and validate against available tools | ||
| - **AND** proceed with initialization using only the specified valid tools | ||
| - **AND** display a warning for any invalid tool IDs | ||
|
|
||
| #### Scenario: No tools selection | ||
| - **WHEN** run with `--skip-tools` option | ||
| - **THEN** skip AI tool configuration entirely | ||
| - **AND** only create the OpenSpec directory structure and template files |
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.
What happens if someone tries to use --all-tools and --skip--tools at the same time? For CLI flags its better to try to keep each flag to one concern i.e one flag for tools. The below might be better/easier to implement: --tools all|none|a,b,c
openspec/specs/cli-init/spec.md
Outdated
|
|
||
| #### Scenario: Displaying interactive menu | ||
| - **WHEN** run in fresh or extend mode | ||
| - **WHEN** run in fresh or extend mode without non-interactive options |
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.
If you have the spec deltas file above, you don't need to edit this file directly!
When we archive the above change delta file it'll automatically update this file with the new requirements :)
You can remove the changes here!
src/cli/index.ts
Outdated
| .command('init [path]') | ||
| .description('Initialize OpenSpec in your project') | ||
| .action(async (targetPath = '.') => { | ||
| .option('--tools <tools>', 'Comma-separated list of AI tools to configure (claude,cursor,opencode,kilocode,windsurf)') |
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.
Is it possible to use AI_TOOLS in the description or so? Just trying to think about how AI tools will figure out what tools are currently supported. A static list here is probably not great.
- Add --tools, --all-tools, and --skip-tools CLI options - Enable automated initialization for CI/CD pipelines - Maintain backward compatibility with interactive mode - Add comprehensive validation and error handling - Update cli-init spec with non-interactive requirements - Add unit and integration tests for new functionality Closes change proposal: add-non-interactive-init-options
6a1abce to
0318e60
Compare
|
Rebased on origin/main (2025-10-10) and updated the change to the single |
|
@codex review |
|
Added a CLI e2e test that asserts |
The canonical spec shouldn't be edited directly when a change delta already captures the update. Archiving that delta will sync the spec.
* feat: add non-interactive options to openspec init - Add --tools, --all-tools, and --skip-tools CLI options - Enable automated initialization for CI/CD pipelines - Maintain backward compatibility with interactive mode - Add comprehensive validation and error handling - Update cli-init spec with non-interactive requirements - Add unit and integration tests for new functionality Closes change proposal: add-non-interactive-init-options * feat(init): add single --tools flag for non-interactive init * test(init): verify --tools help lists available ids * Revert manual spec.md edits The canonical spec shouldn't be edited directly when a change delta already captures the update. Archiving that delta will sync the spec. --------- Co-authored-by: Tabish Bidiwale <[email protected]> Co-authored-by: Tabish Bidiwale <[email protected]>
🎯 Feature Overview
Adds non-interactive CLI options to
openspec initfor CI/CD automation while maintaining backward compatibility.✨ New Capabilities
--all-tools: Configure all available AI tools automatically--tools claude,cursor: Configure specific tools by comma-separated list--skip-tools: Skip AI tool configuration (structure only)🔧 Implementation Details
src/cli/index.tswith validationInitCommandinsrc/core/init.tsopenspec/specs/cli-init/spec.md✅ Quality Assurance
📋 Change Proposal
Implements:
openspec/changes/add-non-interactive-init-options/🧪 Testing
📊 Files Changed
openspec/specs/cli-init/spec.md- Updated spec with non-interactive requirementssrc/cli/index.ts- Added CLI options and validationsrc/core/init.ts- Modified InitCommand for non-interactive modetest/cli-e2e/basic.test.ts- Added integration teststest/core/init.test.ts- Added unit testsopenspec/changes/add-non-interactive-init-options/- Change proposalCloses change proposal: add-non-interactive-init-options