Skip to content

[codex] Propose workspace open agent context#1054

Merged
alfred-openspec merged 6 commits intomainfrom
codex/workspace-open-agent-context
May 6, 2026
Merged

[codex] Propose workspace open agent context#1054
alfred-openspec merged 6 commits intomainfrom
codex/workspace-open-agent-context

Conversation

@TabishB
Copy link
Copy Markdown
Contributor

@TabishB TabishB commented May 5, 2026

Summary

  • Adds the workspace-open-agent-context OpenSpec proposal artifacts.
  • Captures the workspace-open capability for opening a workspace through a preferred agent or VS Code editor.
  • Extends workspace state and maintained open-surface requirements through the existing workspace capability area.

Validation

  • node bin/openspec.js validate workspace-open-agent-context --strict

Summary by CodeRabbit

  • New Features

    • Added workspace open to launch a workspace in a preferred agent or VS Code; supports agent/editor overrides, interactive picker, and auto-select when only one workspace is known.
    • --opener option for workspace setup and interactive opener selection to persist a preferred opener.
    • Workspace guidance and workspace descriptor files are now maintained for smoother editor integration.
  • Documentation

    • CLI and concepts docs expanded with examples and behavior notes for open/setup flows.
  • Tests

    • New tests covering open flows, opener selection, and surface synchronization.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Caution

Review failed

Pull request was closed or merged during review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 614f535e-29ba-4ef7-9085-a263a52ea44b

📥 Commits

Reviewing files that changed from the base of the PR and between 66b2ac1 and 105aafd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • openspec/specs/workspace-foundation/spec.md
  • package.json
  • src/commands/workspace/open.ts
  • test/commands/workspace-open.test.ts
  • test/commands/workspace.interactive.test.ts
  • test/commands/workspace.test.ts
  • test/core/workspace/foundation.test.ts

📝 Walkthrough

Walkthrough

Adds a new workspace-open capability: CLI surface and command, per-workspace preferred-opener state, opener discovery/validation, open-surface sync (AGENTS.md, .code-workspace, .gitignore), launcher construction/spawn, and tests covering interactive and non‑interactive flows.

Changes

Workspace Open Feature

Layer / File(s) Summary
Data Shape / Types
src/core/workspace/foundation.ts, src/commands/workspace/types.ts
Adds WorkspacePreferredOpener type and preferred_opener?: WorkspacePreferredOpener to WorkspaceLocalState; constants for supported opener values; new WorkspaceOpenOptions interface and opener?: string setup option.
Core Utilities: Openers
src/core/workspace/openers.ts
Introduces opener choice definitions, executable discovery (isWorkspaceExecutableAvailable), mapping to executables/labels, listWorkspaceOpenerChoices, and default-choice logic with cross-platform PATH/PATHEXT handling.
Core Utilities: Open Surface
src/core/workspace/open-surface.ts
Adds guidance-block markers/body, functions to build/apply guidance block, generate .code-workspace JSON, resolve linked paths (valid vs skipped), and syncWorkspaceOpenSurface to update AGENTS.md, code-workspace file, and .gitignore.
State & Operations
src/commands/workspace/operations.ts, src/core/workspace/foundation.ts
createManagedWorkspace now accepts optional preferredOpener; local state read/write updated to round-trip preferred_opener; state mutation flows call syncWorkspaceOpenSurface; adds code-workspace path helpers.
Open Workflow Implementation
src/commands/workspace/open.ts
New end-to-end open flow: readWorkspaceOpenState, build launch command (buildWorkspaceOpenLaunchCommand), resolve links and write workspace file, assertWorkspaceOpenerAvailable, and launchWorkspaceOpenCommand which spawns the opener with robust error mapping.
CLI Commands & Wiring
src/commands/workspace.ts, src/core/completions/command-registry.ts
Adds --opener <id> to workspace setup; new workspace open [name] subcommand with --workspace, --agent, --editor, --no-interactive; interactive setup gains a preferred-opener step; resolves opener precedence and selection.
Selection UX
src/commands/workspace/selection.ts
selectWorkspaceForCommand gains selectionOptions.preferPositionalName to vary ambiguous-workspace messaging/fix suggestion (positional vs --workspace).
Public API Aggregation
src/core/workspace/index.ts
Re-exports new modules openers.js and open-surface.js to expose new workspace APIs.
Tests
test/commands/workspace-open.test.ts, test/commands/workspace.test.ts, test/commands/workspace.interactive.test.ts, test/core/workspace/foundation.test.ts
Adds/updates unit and integration tests: launcher command building, spawn behavior, opener availability errors, interactive opener prompts and storage, non-interactive --opener behavior, .code-workspace generation, AGENTS.md guidance handling, and open-surface sync verification.
Docs & Specs
docs/cli.md, docs/concepts.md, openspec/specs/..., openspec/changes/...
CLI reference, conceptual docs, design/proposal/spec/task docs added/updated to describe workspace open, opener semantics, open-surface invariants, and test/implementation notes.
Dependency
package.json
Adds dependency cross-spawn (v7.0.6) used for process spawning.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant CLI as CLI Handler
    participant Select as Workspace Selection
    participant State as State Reader
    participant Sync as Open Surface
    participant Opener as Opener Resolver
    participant Launcher as Process Launcher
    participant Process as Editor/Agent

    User->>CLI: runs `openspec workspace open [name] --agent/--editor`
    CLI->>Select: selectWorkspaceForCommand(...)
    Select-->>CLI: SelectedWorkspace
    CLI->>State: readWorkspaceOpenState(selected)
    State->>Sync: resolveWorkspaceOpenLinks(sharedState, localState)
    Sync-->>State: { links, skipped }
    State-->>CLI: WorkspaceOpenState (incl. codeWorkspacePath)
    CLI->>Opener: resolveWorkspaceOpenOpener(localState, options)
    Opener-->>CLI: PreferredOpener (stored / explicit / prompt result)
    CLI->>CLI: buildWorkspaceOpenCommandForState(opener, state)
    CLI->>Opener: assertWorkspaceOpenerAvailable(opener, codeWorkspacePath)
    CLI->>Launcher: launchWorkspaceOpenCommand(command)
    Launcher->>Process: spawn(executable, args, {cwd, shell})
    Process-->>Launcher: exit / error
    Launcher-->>CLI: success / WorkspaceCliError
    CLI-->>User: status or error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Fission-AI/OpenSpec#1029: Foundational workspace types/state that this change extends with opener preferences and open-surface sync.
  • Fission-AI/OpenSpec#1046: Prior workspace setup/link operations that this PR builds upon for opener selection and surface refresh workflows.

Suggested reviewers

  • alfred-openspec

Poem

🐇 I hop and nudge the workspace door,

Agents, editors — I set the score.
AGENTS.md gleams, the folders line,
A code-workspace waits to shine.
Open we go—adventures more!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: proposing the workspace-open-agent-context feature with additions to OpenSpec capability definitions, CLI commands, and implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/workspace-open-agent-context

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 and usage tips.

@TabishB TabishB force-pushed the codex/workspace-open-agent-context branch from e7e7458 to 159b38f Compare May 5, 2026 18:58
@TabishB TabishB marked this pull request as ready for review May 5, 2026 20:29
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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
`@openspec/changes/workspace-open-agent-context/specs/workspace-foundation/spec.md`:
- Around line 11-19: Update the two scenarios so they explicitly mark the
commands as non-interactive by adding the --no-interactive flag; change the
example commands 'openspec workspace setup --opener codex' to 'openspec
workspace setup --opener codex --no-interactive' and 'openspec workspace setup'
to 'openspec workspace setup --no-interactive', and ensure the scenario text
still refers to “non-interactive” flow to avoid ambiguity between interactive
defaults and explicit non-interactive behavior.

In `@openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md`:
- Around line 76-109: The spec lacks an explicit rule for the conflicting flags
`--agent` and `--editor` on the command `openspec workspace open`; add a short
requirement and scenario under "Opener Resolution" that declares this
combination invalid and mandates a fail-fast behavior with a clear conflict
error (e.g. "Cannot specify both --agent and --editor; choose one"), update any
resolution precedence bullets to reference this conflict, and include a test
scenario describing the GIVEN (both flags present), WHEN (user runs the
command), and THEN (command fails immediately with the specified error message).

In `@openspec/changes/workspace-open-agent-context/tasks.md`:
- Line 83: Update the checklist command to the documented runnable form so
contributors can run it without a global install: replace the checklist entry
string "openspec validate workspace-open-agent-context --strict" with "node
bin/openspec.js validate workspace-open-agent-context --strict" (or include both
variants) in the tasks.md checklist so the validation step matches the PR
objective and is reproducible.
🪄 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: d4a9eb17-a905-4145-9c7a-e7fbf492266d

📥 Commits

Reviewing files that changed from the base of the PR and between f510581 and 159b38f.

📒 Files selected for processing (5)
  • openspec/changes/workspace-open-agent-context/design.md
  • openspec/changes/workspace-open-agent-context/proposal.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-foundation/spec.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md
  • openspec/changes/workspace-open-agent-context/tasks.md

Comment thread openspec/changes/workspace-open-agent-context/specs/workspace-foundation/spec.md Outdated
Comment thread openspec/changes/workspace-open-agent-context/tasks.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (1)
openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md (1)

76-109: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Still missing a scenario for conflicting --agent and --editor overrides.

The Opener Resolution requirement enumerates each override individually but does not specify behavior when both --agent <tool> and --editor are passed in the same invocation. Without an explicit rule, the implementation contract is ambiguous (which override wins, is it a fail-fast, etc.). Add a scenario codifying fail-fast behavior so tests/implementation can rely on it.

📝 Suggested addition
 #### Scenario: Failing when no opener is stored in non-interactive mode
 - **GIVEN** the workspace has no stored preferred opener
 - **AND** the terminal is non-interactive
 - **WHEN** the user runs `openspec workspace open` using default opener resolution
 - **THEN** OpenSpec SHALL fail with a clear message
 - **AND** it SHALL ask the user to pass `--agent <tool>` or `--editor`
+
+#### Scenario: Conflicting opener overrides
+- **WHEN** the user runs `openspec workspace open --agent <tool> --editor`
+- **THEN** OpenSpec SHALL fail with a clear conflict error naming both flags
+- **AND** it SHALL not launch any opener
🤖 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 `@openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md`
around lines 76 - 109, Add a new Scenario under "Requirement: Opener Resolution"
that covers conflicting overrides for `openspec workspace open` when both
`--agent <tool>` and `--editor` are provided; specify that OpenSpec SHALL fail
fast with a clear error message explaining the conflict and instructing the user
to pass only one of `--agent <tool>` or `--editor`, and that no stored
preference is changed. Reference the command and flags (`openspec workspace
open`, `--agent`, `--editor`) so tests and implementations know to treat
simultaneous `--agent` and `--editor` as an error case.
🧹 Nitpick comments (1)
src/core/completions/command-registry.ts (1)

177-181: ⚡ Quick win

Provide values: arrays for enum-like flags to improve shell completions.

--opener (setup) and --agent (open) accept a fixed set of identifiers that the description spells out, but the registry entries omit values:. Other enum-like flags in this file (--type, --scope) declare values: so completion scripts can suggest them. Add the same here for parity and a better UX in zsh/bash/fish completions.

♻️ Suggested change
           {
             name: 'opener',
             description: 'Preferred opener: codex, claude, github-copilot, or editor',
             takesValue: true,
+            values: ['codex', 'claude', 'github-copilot', 'editor'],
           },
           {
             name: 'agent',
             description: 'Use an agent for this session: codex, claude, or github-copilot',
             takesValue: true,
+            values: ['codex', 'claude', 'github-copilot'],
           },

Also applies to: 277-281

🤖 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/core/completions/command-registry.ts` around lines 177 - 181, Add
explicit values arrays for the enum-like flags so shell completions can suggest
options: update the command registry entries for the flags named 'opener' (in
the setup command) and 'agent' (in the open command) to include a values: array
with the allowed identifiers (e.g., "codex", "claude", "github-copilot",
"editor"); keep the existing name, description, and takesValue: true properties
and only add the values field to both flag objects to match how '--type' and
'--scope' are declared.
🤖 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 `@src/commands/workspace.ts`:
- Around line 434-436: The interactive branch currently calls
promptPreferredOpener without filtering out unavailable launchers, which can
lead to a dead-end prompt; update the branch that checks
resolveNoInteractive/options and isInteractive(options) to first call
listWorkspaceOpenerChoices() and filter for available choices (the same
availability criteria used by assertWorkspaceOpenerAvailable()), then if the
filtered list is empty throw a targeted error (e.g., a clear "no available
openers" error) instead of prompting, otherwise call promptPreferredOpener with
only the available choices so the prompt never offers unlaunchable options.

In `@src/commands/workspace/open.ts`:
- Around line 115-124: The returned launch command uses the stale
state.codeWorkspacePath even after resolveWorkspaceOpenLinks recomputes
openLinks.links/skipped, so regenerate the maintained .code-workspace from
openLinks.links before returning; specifically, after calling
resolveWorkspaceOpenLinks and before buildWorkspaceOpenLaunchCommand, write an
updated workspace file (based on openLinks.links.map(link => link.path)) to
state.codeWorkspacePath (or the maintained workspace writer function) so the
editor/GitHub Copilot open uses the refreshed folders and skipped entries are
reflected.

In `@src/commands/workspace/operations.ts`:
- Around line 636-639: The code writes shared/local state files before calling
syncWorkspaceOpenSurface(), which creates a new failure point that can leave
workspace files stale; change the order so
syncWorkspaceOpenSurface(selected.root, updatedSharedState, updatedLocalState)
is invoked and completes successfully before calling
writeWorkspaceSharedState(selected.root, updatedSharedState),
writeWorkspaceLocalState(selected.root, updatedLocalState), and then
recordSelectedWorkspaceAfterMutation(selected); apply the same reorder to the
other occurrence around the functions at lines 674-676 so the open-surface
refresh succeeds before persisting the link state.

In `@test/commands/workspace-open.test.ts`:
- Around line 74-111: The spawn call inside launchWorkspaceOpenCommand does not
pass a shell option, which breaks execution of Windows .cmd wrappers; update the
call that invokes spawnCommand (the spot that creates the child process in
launchWorkspaceOpenCommand) to include shell: true in the options object along
with cwd and stdio (i.e., pass { cwd: command.cwd, stdio: 'inherit', shell: true
}) so Windows PATH-wrapped executables like code/codex run correctly.

---

Duplicate comments:
In `@openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md`:
- Around line 76-109: Add a new Scenario under "Requirement: Opener Resolution"
that covers conflicting overrides for `openspec workspace open` when both
`--agent <tool>` and `--editor` are provided; specify that OpenSpec SHALL fail
fast with a clear error message explaining the conflict and instructing the user
to pass only one of `--agent <tool>` or `--editor`, and that no stored
preference is changed. Reference the command and flags (`openspec workspace
open`, `--agent`, `--editor`) so tests and implementations know to treat
simultaneous `--agent` and `--editor` as an error case.

---

Nitpick comments:
In `@src/core/completions/command-registry.ts`:
- Around line 177-181: Add explicit values arrays for the enum-like flags so
shell completions can suggest options: update the command registry entries for
the flags named 'opener' (in the setup command) and 'agent' (in the open
command) to include a values: array with the allowed identifiers (e.g., "codex",
"claude", "github-copilot", "editor"); keep the existing name, description, and
takesValue: true properties and only add the values field to both flag objects
to match how '--type' and '--scope' are declared.
🪄 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: a99a0674-fb14-4d58-8ea0-4c3b24ef43c9

📥 Commits

Reviewing files that changed from the base of the PR and between 159b38f and a85eb02.

📒 Files selected for processing (21)
  • docs/cli.md
  • docs/concepts.md
  • openspec/changes/workspace-open-agent-context/design.md
  • openspec/changes/workspace-open-agent-context/proposal.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-foundation/spec.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md
  • openspec/changes/workspace-open-agent-context/tasks.md
  • src/commands/workspace.ts
  • src/commands/workspace/open.ts
  • src/commands/workspace/operations.ts
  • src/commands/workspace/selection.ts
  • src/commands/workspace/types.ts
  • src/core/completions/command-registry.ts
  • src/core/workspace/foundation.ts
  • src/core/workspace/index.ts
  • src/core/workspace/open-surface.ts
  • src/core/workspace/openers.ts
  • test/commands/workspace-open.test.ts
  • test/commands/workspace.interactive.test.ts
  • test/commands/workspace.test.ts
  • test/core/workspace/foundation.test.ts

Comment thread src/commands/workspace.ts
Comment thread src/commands/workspace/open.ts
Comment on lines 636 to 639
await writeWorkspaceSharedState(selected.root, updatedSharedState);
await writeWorkspaceLocalState(selected.root, updatedLocalState);
await syncWorkspaceOpenSurface(selected.root, updatedSharedState, updatedLocalState);
await recordSelectedWorkspaceAfterMutation(selected);
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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Avoid committing link state before the open-surface refresh succeeds.

syncWorkspaceOpenSurface() now adds another failure point after the shared/local state files are already written. If that refresh throws, the command returns an error even though the link change has already been persisted, which leaves AGENTS.md / <workspace>.code-workspace stale and the workspace partially updated.

Also applies to: 674-676

🤖 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/workspace/operations.ts` around lines 636 - 639, The code writes
shared/local state files before calling syncWorkspaceOpenSurface(), which
creates a new failure point that can leave workspace files stale; change the
order so syncWorkspaceOpenSurface(selected.root, updatedSharedState,
updatedLocalState) is invoked and completes successfully before calling
writeWorkspaceSharedState(selected.root, updatedSharedState),
writeWorkspaceLocalState(selected.root, updatedLocalState), and then
recordSelectedWorkspaceAfterMutation(selected); apply the same reorder to the
other occurrence around the functions at lines 674-676 so the open-surface
refresh succeeds before persisting the link state.

Comment thread test/commands/workspace-open.test.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@src/commands/workspace/open.ts`:
- Around line 138-175: The current spawn logic uses shell: platform === 'win32'
which concatenates args on Windows and causes argument-splitting (affecting
command.args and command.executable); change to use cross-spawn (import spawn
from 'cross-spawn') and invoke spawn(command.executable, command.args, { cwd:
command.cwd, stdio: 'inherit', shell: false }) so cross-spawn resolves Windows
shims and preserves args, and only set shell: true conditionally when the
resolved executable name endsWith('.cmd') || endsWith('.bat') (so .cmd/.bat keep
shell while normal .exe/.ps1 calls do not); keep existing error handling
(child.on('error', ...) and child.on('close', ...)) and still throw
WorkspaceCliError with asErrorMessage on failure.

In `@src/core/workspace/open-surface.ts`:
- Around line 95-99: The workspace root entry in the folders array is emitting a
synthetic name; update the root folder object in open-surface.ts (the folders
constant) to omit the name property and only emit { path: '.' } for the
coordination root so the workspace JSON conforms to the new spec and VS Code
shows the correct label.
🪄 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: e1d87a21-2b4f-40eb-8ea0-a2f6bd18522e

📥 Commits

Reviewing files that changed from the base of the PR and between a85eb02 and 514ab21.

📒 Files selected for processing (12)
  • docs/cli.md
  • docs/concepts.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-foundation/spec.md
  • openspec/changes/workspace-open-agent-context/specs/workspace-open/spec.md
  • openspec/changes/workspace-open-agent-context/tasks.md
  • src/commands/workspace.ts
  • src/commands/workspace/open.ts
  • src/core/completions/command-registry.ts
  • src/core/workspace/open-surface.ts
  • test/commands/workspace-open.test.ts
  • test/commands/workspace.interactive.test.ts
  • test/commands/workspace.test.ts

Comment thread src/commands/workspace/open.ts
Comment thread src/core/workspace/open-surface.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/core/workspace/foundation.test.ts`:
- Around line 462-473: The test calls buildWorkspaceCodeWorkspaceContent with
only links but the exported signature in open-surface.ts is
buildWorkspaceCodeWorkspaceContent(workspaceName, workspaceRoot, links); update
the test to pass the missing workspaceName and workspaceRoot parameters (e.g., a
stable name and root string) before the links array when invoking
buildWorkspaceCodeWorkspaceContent in foundation.test.ts so the call matches the
implementation's parameters.
- Around line 496-497: Replace the blanket '*.code-workspace' ignore in the test
setup/assertions with a scoped entry for the maintained workspace file (e.g.
`${workspaceName}.code-workspace`) by updating the fs.writeFileSync call and any
assertions that expect the synced .gitignore; specifically change places that
write or assert '*.code-workspace' (see uses of fs.writeFileSync and
workspaceRoot in this test and the similar block at 533-535) to instead assert
the scoped `<workspaceName>.code-workspace` entry, and add an assertion that if
the repo originally contained the wildcard entry OpenSpec either removes or
rewrites it to the scoped entry during sync (use sharedState or the test helper
that performs the sync to verify the rewrite/removal).
🪄 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: e9235e98-c27a-4ae4-9f09-f8056e155be7

📥 Commits

Reviewing files that changed from the base of the PR and between 514ab21 and 66b2ac1.

📒 Files selected for processing (9)
  • openspec/changes/archive/2026-05-06-workspace-open-agent-context/design.md
  • openspec/changes/archive/2026-05-06-workspace-open-agent-context/proposal.md
  • openspec/changes/archive/2026-05-06-workspace-open-agent-context/specs/workspace-foundation/spec.md
  • openspec/changes/archive/2026-05-06-workspace-open-agent-context/specs/workspace-open/spec.md
  • openspec/changes/archive/2026-05-06-workspace-open-agent-context/tasks.md
  • openspec/specs/workspace-foundation/spec.md
  • openspec/specs/workspace-open/spec.md
  • src/core/workspace/open-surface.ts
  • test/core/workspace/foundation.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/workspace/open-surface.ts

Comment on lines +462 to +473
it('builds VS Code workspace content with stable root and linked paths', () => {
const content = buildWorkspaceCodeWorkspaceContent([
{
name: 'api',
path: '/repos/api',
},
{
name: 'windows',
path: 'D:\\repos\\web',
},
]);
const payload = JSON.parse(content);
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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Match the new buildWorkspaceCodeWorkspaceContent signature.

Line 463 calls this helper with only the links array, but src/core/workspace/open-surface.ts:92-107 exports it as buildWorkspaceCodeWorkspaceContent(workspaceName, workspaceRoot, links). As written, this test will not type-check against the implementation.

🤖 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 `@test/core/workspace/foundation.test.ts` around lines 462 - 473, The test
calls buildWorkspaceCodeWorkspaceContent with only links but the exported
signature in open-surface.ts is
buildWorkspaceCodeWorkspaceContent(workspaceName, workspaceRoot, links); update
the test to pass the missing workspaceName and workspaceRoot parameters (e.g., a
stable name and root string) before the links array when invoking
buildWorkspaceCodeWorkspaceContent in foundation.test.ts so the call matches the
implementation's parameters.

Comment on lines +496 to +497
fs.writeFileSync(path.join(workspaceRoot, '.gitignore'), '*.code-workspace\n');
const sharedState = {
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t lock in the old blanket *.code-workspace ignore.

This expectation preserves *.code-workspace in the synced .gitignore, which contradicts the new requirement that only the maintained <workspace-name>.code-workspace entry is ignored so user-authored workspace files stay trackable. Please assert the scoped entry instead, and if OpenSpec owns the wildcard line, verify sync removes or rewrites it.

Also applies to: 533-535

🤖 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 `@test/core/workspace/foundation.test.ts` around lines 496 - 497, Replace the
blanket '*.code-workspace' ignore in the test setup/assertions with a scoped
entry for the maintained workspace file (e.g. `${workspaceName}.code-workspace`)
by updating the fs.writeFileSync call and any assertions that expect the synced
.gitignore; specifically change places that write or assert '*.code-workspace'
(see uses of fs.writeFileSync and workspaceRoot in this test and the similar
block at 533-535) to instead assert the scoped `<workspaceName>.code-workspace`
entry, and add an assertion that if the repo originally contained the wildcard
entry OpenSpec either removes or rewrites it to the scoped entry during sync
(use sharedState or the test helper that performs the sync to verify the
rewrite/removal).

Copy link
Copy Markdown
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

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

Reviewed the diff and validated locally. CI is green.

@alfred-openspec alfred-openspec added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 1cdf041 May 6, 2026
11 of 12 checks passed
@alfred-openspec alfred-openspec deleted the codex/workspace-open-agent-context branch May 6, 2026 03:57
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