Skip to content

Conversation

@tommy-ca
Copy link
Contributor

@tommy-ca tommy-ca commented Oct 7, 2025

🎯 Feature Overview

Adds non-interactive CLI options to openspec init for 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

  • CLI Options: Added to src/cli/index.ts with validation
  • Command Logic: Modified InitCommand in src/core/init.ts
  • Spec Updates: Enhanced openspec/specs/cli-init/spec.md
  • Testing: 187 tests passing including new integration tests

✅ Quality Assurance

  • Test Coverage: 100% for new functionality
  • Backward Compatibility: Zero breaking changes
  • Error Handling: Comprehensive validation with user-friendly messages
  • Spec Compliance: All requirements implemented and tested

📋 Change Proposal

Implements: openspec/changes/add-non-interactive-init-options/

🧪 Testing

# Run all tests
pnpm test

# Test specific functionality
pnpm test -- test/cli-e2e/basic.test.ts -t "init command non-interactive"

# Validate change proposal
openspec validate add-non-interactive-init-options

📊 Files Changed

  • openspec/specs/cli-init/spec.md - Updated spec with non-interactive requirements
  • src/cli/index.ts - Added CLI options and validation
  • src/core/init.ts - Modified InitCommand for non-interactive mode
  • test/cli-e2e/basic.test.ts - Added integration tests
  • test/core/init.test.ts - Added unit tests
  • openspec/changes/add-non-interactive-init-options/ - Change proposal

Closes change proposal: add-non-interactive-init-options

@tommy-ca tommy-ca requested a review from TabishB as a code owner October 7, 2025 00:36
@TabishB
Copy link
Contributor

TabishB commented Oct 7, 2025

@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.

@tommy-ca
Copy link
Contributor Author

tommy-ca commented Oct 7, 2025

@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,

Copy link
Contributor

@TabishB TabishB left a 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!

Comment on lines 7 to 21
#### 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
Copy link
Contributor

@TabishB TabishB Oct 7, 2025

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


#### Scenario: Displaying interactive menu
- **WHEN** run in fresh or extend mode
- **WHEN** run in fresh or extend mode without non-interactive options
Copy link
Contributor

@TabishB TabishB Oct 7, 2025

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)')
Copy link
Contributor

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
@tommy-ca tommy-ca force-pushed the feature/add-non-interactive-init-options branch from 6a1abce to 0318e60 Compare October 10, 2025 01:02
@tommy-ca
Copy link
Contributor Author

Rebased on origin/main (2025-10-10) and updated the change to the single --tools flag design. CLI help text now shows the current AI tool ids. Tests: pnpm build and pnpm vitest run test/core/init.test.ts test/cli-e2e/basic.test.ts.

@tommy-ca
Copy link
Contributor Author

@codex review

@tommy-ca
Copy link
Contributor Author

Added a CLI e2e test that asserts openspec init --help lists the dynamic --tools values from AI_TOOLS. Rebuilt and force-pushed (pnpm build).

TabishB and others added 3 commits October 13, 2025 19:45
The canonical spec shouldn't be edited directly when a change delta
already captures the update. Archiving that delta will sync the spec.
@TabishB TabishB merged commit cc9d540 into Fission-AI:main Oct 14, 2025
6 checks passed
@TabishB
Copy link
Contributor

TabishB commented Oct 14, 2025

@tommy-ca Sorry about the delay, just got this merged in. Thanks for the contribution @tommy-ca 🎉

Kh05ifr4nD pushed a commit to Kh05ifr4nD/sorapec that referenced this pull request Jan 6, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants