Skip to content

fix: avoid npx when applying profile changes#1351

Merged
clay-good merged 7 commits into
Fission-AI:mainfrom
showms:codex/fix-config-profile-npx
Jul 18, 2026
Merged

fix: avoid npx when applying profile changes#1351
clay-good merged 7 commits into
Fission-AI:mainfrom
showms:codex/fix-config-profile-npx

Conversation

@showms

@showms showms commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the interactive openspec config profile apply step by invoking openspec update directly instead of routing through npx.

Closes #1304 #1306 .

Problem

After saving profile or workflow changes, the config wizard prompts:

Apply changes to this project now?

When confirmed, it currently runs:

npx openspec update

This unnecessarily depends on npm/npx and may fail when:

  • OpenSpec is installed with Bun or as a standalone binary
  • The current project uses pnpm or another package manager
  • npm fails while inspecting the project's dependency tree

The openspec executable is already available on PATH, so invoking it through npx is unnecessary.

Changes

  • Replace npx openspec update with openspec update
  • Update the config profile test expectation

Verification

  • test/commands/config-profile.test.ts: 19 tests passed
  • node build.js: passed
  • git diff --check: passed

Summary by CodeRabbit

  • Bug Fixes
    • Improved the project profile “apply now” workflow by performing the update directly via the built-in update command rather than shell execution.
    • Enhanced failure reporting to include a clearer error reason and an instruction to run the update manually if it fails.
  • Tests
    • Updated the config profile flow tests to reflect the new update behavior, including environment/path adjustments.
    • Added coverage for error handling when the update fails (ensures detailed messaging and a non-zero exit code).

@showms
showms requested a review from TabishB as a code owner July 12, 2026 08:52
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c7f44908-5079-4ea3-a4a6-f7f24281fb13

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5eb37 and 01348bc.

📒 Files selected for processing (2)
  • src/commands/config.ts
  • test/commands/config-profile.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/commands/config.ts

📝 Walkthrough

Walkthrough

The config profile apply flow now calls UpdateCommand directly instead of invoking npx openspec update. Tests cover successful execution without PATH resolution and update failures with detailed error output.

Changes

Config apply command

Layer / File(s) Summary
Direct update invocation
src/commands/config.ts
The apply-now flow executes UpdateCommand with the project directory and reports the specific failure reason alongside manual update instructions.
Apply flow validation
test/commands/config-profile.test.ts
Tests remove execSync mocking and verify successful output, environment cleanup, error reporting, and process exit state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • #1304: The change removes the hardcoded npx openspec update path described in the issue.
  • #1306: The issue directly covers the same config profile apply-now flow and update command invocation.

Possibly related PRs

Suggested reviewers: tabishb, alfred-openspec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: replacing npx during profile application.
Linked Issues check ✅ Passed The PR directly addresses #1304 by removing npx and calling the update command from PATH.
Out of Scope Changes check ✅ Passed The test and error-handling changes support the same apply-now fix and don't introduce unrelated behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

TabishB
TabishB previously approved these changes Jul 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/commands/config.ts (1)

627-630: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Log the actual error message for better debuggability.

Currently, if the update fails, the underlying error is swallowed and a generic failure message is logged. Capturing and logging the actual error will help users diagnose the root cause (e.g., file permission issues, invalid configurations).

💡 Proposed fix
-            } catch {
-              console.error('`openspec update` failed. Please run it manually to apply the profile changes.');
+            } catch (error) {
+              const errorMessage = error instanceof Error ? error.message : String(error);
+              console.error(`\`openspec update\` failed: ${errorMessage}`);
+              console.error('Please run it manually to apply the profile changes.');
               process.exitCode = 1;
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/config.ts` around lines 627 - 630, Update the catch block around
the openspec update operation to capture the thrown error and include its
message or details in the console.error output alongside the existing failure
context, while preserving process.exitCode = 1.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/commands/config-profile.test.ts`:
- Around line 376-378: Update the test setup around the empty-bin PATH scenario
to use Vitest’s vi.stubEnv() instead of assigning process.env.PATH directly.
Ensure the stub is restored through the test lifecycle so subsequent tests
retain the original PATH and can resolve system binaries.

---

Outside diff comments:
In `@src/commands/config.ts`:
- Around line 627-630: Update the catch block around the openspec update
operation to capture the thrown error and include its message or details in the
console.error output alongside the existing failure context, while preserving
process.exitCode = 1.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9d9fb890-ed45-4603-a338-e3b4e6fb93a4

📥 Commits

Reviewing files that changed from the base of the PR and between 2625ca7 and 6c5eb37.

📒 Files selected for processing (2)
  • src/commands/config.ts
  • test/commands/config-profile.test.ts

Comment thread test/commands/config-profile.test.ts Outdated
@clay-good
clay-good added this pull request to the merge queue Jul 18, 2026
Merged via the queue into Fission-AI:main with commit a0eb70e Jul 18, 2026
11 checks passed
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.

Config wizard 'apply now' fails on bun/standalone installs — hardcoded npx openspec update

3 participants