Skip to content

Add a Workspace Context plugin for editing agent instructions and skills - #51874

Open
jtalborough wants to merge 1 commit into
stablyai:mainfrom
jtalborough:jtalborough/workspace-context-plugin
Open

jtalborough wants to merge 1 commit into
stablyai:mainfrom
jtalborough:jtalborough/workspace-context-plugin

Conversation

@jtalborough

Copy link
Copy Markdown

ELI5

Open Context, choose an agent, and click its instructions or a skill. Orca opens the original Markdown file for editing. The sidebar shows whether a file belongs to this workspace or to the user.

What Changed

Added an opt-in example under examples/plugins/workspace-context. It follows the selected local workspace and looks for Markdown files in the workspace and the current user's standard agent directories.

Context → Instructions or Skills → select a file
  Source in an Orca workspace → open or focus its Markdown tab
  Shared source outside Orca workspaces → edit inline and save to the source

The plugin resolves symlinks before opening a file. A linked file can open in another registered workspace. The two Codex choices share a lookup. The other choices are Claude Code, Gemini CLI, Grok Build, and Hermes.

Why

The Files browser already edits project Markdown well. A person checking an agent's instructions also has to know which other directories to look in. Context brings those files into one list and reuses Orca's editor, including unsaved tabs and the user's preferred Markdown mode.

Linked Issue

This implements the local editing workflow in #14925. Parent-directory discovery remains open. PR #14875 proposes a broader built-in agent inventory. This contribution can be tried independently as an example plugin.

Visual Proof

Before · Files shows the project tree.

Files browser in the example project

After · Context shows both Codex instruction files. Clicking the project copy opens its Markdown tab alongside the README.

Context with personal and project instructions beside the open Markdown editor

Testing

  • Exercised the published Orca 1.4.274 macOS app in an isolated profile with a fresh home and project. Opened a project instruction, applied bold, reopened the dirty tab, saved, and verified the Markdown on disk. Also opened a skill and checked the inline editor for a personal instruction outside the workspace.
  • Both plugin tests passed. They cover empty profiles, project instruction fallbacks, opening a linked source, preserving the link on save, and refusing a stale draft.
  • The fallback regression test fails if the Claude or Hermes lookup change is removed. The save test checks the original file on disk.
  • Plugin validation, plugin check, TypeScript, and all 15 checks selected by pnpm check:changed passed against upstream main.

To try it, enable plugins and run orca plugin dev load . from the example directory. Approve the access Orca displays, then run orca plugin open local.workspace-context --panel context.

Performance

Opening the panel, switching workspaces, and refreshing scan the supported locations. Opening or saving a row rescans to confirm its source. Resolving a shared file can also check the other registered local workspace roots. Large skill collections may take longer. Typing in an open tab uses the regular editor.

Risk

Medium for people who enable the plugin. The trusted Node worker runs with the user's filesystem access. Saving a personal instruction can affect several projects. Inline saving rejects a changed digest and preserves symlinks. Disabling the plugin removes the panel. Edits already saved are ordinary file edits.

AI Disclosure

OpenAI Codex (GPT-6) helped implement and test the plugin and prepared this PR.

Review

Reviewed local path resolution, source validation before edits, workspace switching, and reuse of the native editor. The panel lists Markdown files present on disk. Agent versions, profiles, trust settings, and imports can affect what enters a particular session. Each user must enable and approve the example.

Agent skill upstream boundary

  • This change copies no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Desktop macOS was exercised. Windows and Linux use Node's platform-aware filesystem and path APIs and still need desktop verification. SSH, WSL, containers, mobile, custom profile homes, and full runtime context inspection are outside this example's coverage.

Checklist

  • Focused on one example plugin and registration of its test runner.
  • Described the workflow, implementation, and reason for the change.
  • Documented editing risk and how to disable the plugin.
  • Attached before and after captures from the same disposable project.
  • Reviewed correctness, security, and performance.
  • Considered platform, remote workspace, path, and shortcut behavior.
  • Ran local changed-code checks. Full product builds and suites are left to CI.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The pull request adds a Workspace Context Orca plugin. It discovers user- and project-level instruction files, rules, and skills for five tools. The panel lists and opens those sources, and supports inline edits with digest checks and symbolic-link handling. The changes also add plugin setup documentation, configuration, tests, and a CI runner entry for example-plugin tests.

Merge Risk: Low · up to 654ef

The example plugin works for its main flows, but a save can overwrite an edit made in another editor within a very short window. Some linked, nested, or Gemini-configured instruction files will not appear in the panel. These are bounded issues for an opt-in example, but they should be fixed or accepted explicitly.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding a Workspace Context plugin example for editing agent instructions and skills. The changeset adds the workspace-context plugin (panel, discovery, worker, protoco…
Description check Passed The description follows the repository template and covers each required section: ELI5, What Changed, Why, Linked Issue (#14925, with related PR #14875 noted), Visual Proof (before and after images), …
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.
Full details: Title check

Explanation

The title names the main change: adding a Workspace Context plugin example for editing agent instructions and skills. The changeset adds the workspace-context plugin (panel, discovery, worker, protocol, tests) and registers its test runner, so the title matches the primary change and is specific enough for a scanning teammate.

Full details: Description check

Explanation

The description follows the repository template and covers each required section: ELI5, What Changed, Why, Linked Issue (#14925, with related PR #14875 noted), Visual Proof (before and after images), Testing, Performance, Risk (Medium, with rollback via disabling the plugin), AI Disclosure, Review, upstream boundary, Notes, and Checklist. Its content matches the file-level summaries. Minor gaps: the 'Fixes #' line is replaced by 'implements ... #14925' rather than the template's closing keyword, and the Testing section reports the author's own runs without an independent check. The description is mostly complete, so it passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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: 4

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87cd4206-f83a-42e6-9313-bd43bb61e686
Commits

Reviewing files that changed from the base of the PR and between aa7691f and 654ef7a.

Files selected for processing: 13

  • config/scripts/ci/unit-selection/check-test-file-runners.mjs
  • examples/plugins/workspace-context/.gitattributes
  • examples/plugins/workspace-context/.gitignore
  • examples/plugins/workspace-context/README.md
  • examples/plugins/workspace-context/orca-plugin.json
  • examples/plugins/workspace-context/panel.html
  • examples/plugins/workspace-context/src/discovery.test.ts
  • examples/plugins/workspace-context/src/discovery.ts
  • examples/plugins/workspace-context/src/panel.ts
  • examples/plugins/workspace-context/src/protocol.ts
  • examples/plugins/workspace-context/src/source-save.test.ts
  • examples/plugins/workspace-context/src/worker.ts
  • examples/plugins/workspace-context/tsconfig.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +70 to +71
if (scope === 'Project' && !inside(root, target) && !trusted.has(target)) {
return false

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.

Minor · Functional Correctness · Quick win

Allow links into other registered local workspaces.

If /projects/app/AGENTS.md links to /projects/shared/policy.md, this check removes the source unless a user-level entry already trusts that target. Registering /projects/shared does not help because discover receives no registered workspace roots. The documented cross-workspace opening path is therefore unreachable for this link. (raw.githubusercontent.com)

Include registered local workspace roots in the allowed-target check. Keep rejecting targets outside those roots unless an existing user-source rule permits them.

Comment on lines +109 to +110
if (child.name.endsWith('.md')) {
await add(dir, child.name, owners, scope, 'Rules directory (conditions may apply)')

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.

Minor · Functional Correctness · Quick win

Discover rules in subdirectories.

A rule such as .claude/rules/backend/security.md never reaches add: backend fails the .md check, and this function does not visit it. Claude supports recursive rule directories, so the panel omits a standard instruction source. (code.claude.com)

Traverse rule subdirectories while retaining target containment checks. Track resolved directories to prevent symlink cycles. Keep direct .md files discoverable.

}
await add(claudeHome, 'CLAUDE.md', claude, 'User', 'User instruction file')
await rules(join(claudeHome, 'rules'), claude, 'User')
await add(geminiHome, 'GEMINI.md', gemini, 'User', 'User instruction file')

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.

Minor · Functional Correctness · Quick win

Apply Gemini's configured filenames to user instructions.

If ~/.gemini/settings.json sets context.fileName to "CONTEXT.md", the later loop uses that name only for project files. This line still lists ~/.gemini/GEMINI.md and omits ~/.gemini/CONTEXT.md. Gemini applies the configured filename to its global context file too. (geminicli.com)

Resolve the effective filenames before adding user instructions, then use them for both locations. Preserve GEMINI.md as the default when no override exists.

Comment on lines +133 to +137
(await readDocument(target)).digest !== input.digest
) {
throw new Error('Source changed during save. Reload before saving.')
}
await rename(temp, target)

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.

Major · Data Integrity & Integration · Heavy lift

Close the gap between the digest check and the replacement in save.

The digest comparison at lines 133-135 and the rename at line 137 are separate operations. An external editor can write to target after the comparison and before the rename. The rename then replaces that external edit, and the save still reports success. The worker-local saving marker does not block external writers.

The window is short. The overwrite requires an external write during that interval. The result is silent loss of user content with no recovery path in the save flow, so the gap needs a fix.

Require that a save never replace a target whose content changed after the digest check. A save that detects such a change must reject and leave the target unchanged. Any change must keep the existing stale-draft rejection and the hard-link check. POSIX rename does not compare the target content, so a complete fix needs a design choice. The source does not establish which mechanism to use, so this comment does not prescribe one.

This branch has not been deployed

No deployments
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.

1 participant