What the agent does
The agent reads the plugin and the rules its repository sets before it writes an extension. In a plugin laid out like obsidianmd/obsidian-sample-plugin, src/main.ts is a Plugin subclass whose onload adds a ribbon icon, a status bar item, three commands, a settings tab and a global click listener, and src/settings.ts holds a one-field MyPluginSettings interface with SampleSettingTab. esbuild.config.mjs bundles src/main.ts to main.js as CommonJS targeting es2021, and its external list already names @codemirror/view, @codemirror/state and @codemirror/language, because Obsidian ships those modules and a plugin must not bundle its own copies. tsconfig.json is strict with noUncheckedIndexedAccess, eslint.config.mts applies eslint-plugin-obsidianmd's recommended rules, .github/workflows/lint.yml runs npm run build and npm run lint on Node 20, 22 and 24 for every push, and AGENTS.md asks for a small main.ts, feature code in its own modules, every listener registered through a register* helper, and sentence case in UI text.
The extension is a view plugin in src/editor/keyword-highlighter.ts. @codemirror/view and @codemirror/state are added as devDependencies, types only, since the runtime copies come from Obsidian and the esbuild externals keep them out of main.js. A KeywordHighlighter class implements PluginValue: its constructor builds a DecorationSet, update rebuilds it when docChanged or viewportChanged is set on the ViewUpdate, and buildDecorations walks view.visibleRanges with a RangeSetBuilder<Decoration>, matches the configured words with a regular expression over each visible range, and adds a Decoration.mark({ class: 'keyword-highlight' }) for each hit. ViewPlugin.fromClass takes the class and a PluginSpec whose decorations field returns the instance's set, so the editor reads the marks. Marks change styling only, which is what a view plugin may do; the module comment says a state field is the tool if a future change needs to insert content.
Settings drive it without a reload. MyPluginSettings gains highlightKeywords: boolean and keywords: string, defaulting to on and to TODO, FIXME, NOTE, and SampleSettingTab gets a toggle and a text field in place of the placeholder setting. The extension is created by a factory that takes a function returning the current settings, so buildDecorations always reads the live list, and the settings tab calls this.app.workspace.updateOptions() after saving so open editors rebuild their decorations. onload registers it with this.registerEditorExtension(createKeywordHighlighter(() => this.settings)), which Obsidian removes when the plugin unloads, and styles.css, which is empty but for a comment, gets one rule for .keyword-highlight using the --text-accent and --background-modifier-hover theme variables so it follows light and dark themes.
The agent proves it in its sandbox. It runs npm ci, npm run build, which type-checks with tsc -noEmit -skipLibCheck before bundling, and npm run lint, and fixes what strict, noUncheckedIndexedAccess and the Obsidian rules raise, such as a regular expression built from unescaped user input. It installs Obsidian in the sandbox, copies main.js, manifest.json and styles.css into a test vault's .obsidian/plugins/sample-plugin/, enables the plugin, opens a note with the three default words, takes a screenshot of the highlighted editor, toggles the setting off and confirms the marks disappear without a reload, and then opens the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a CodeMirror 6 editor extension to this Obsidian plugin and open a pull request. Read AGENTS.md, src/main.ts, src/settings.ts, esbuild.config.mjs, tsconfig.json, eslint.config.mts, manifest.json, styles.css and .github/workflows/lint.yml first. Add @codemirror/view and @codemirror/state as devDependencies only; they stay in the esbuild externals. Write src/editor/keyword-highlighter.ts with a PluginValue class that builds a DecorationSet over the visible ranges with RangeSetBuilder, rebuilds on docChanged or viewportChanged, and marks configured keywords with a CSS class; export a factory that takes a settings getter and returns ViewPlugin.fromClass with a PluginSpec whose decorations field returns the set. Add highlightKeywords and keywords settings with defaults, a toggle and a text field in the settings tab, and call workspace.updateOptions after saving. Register the extension in onload with registerEditorExtension and keep main.ts small. Add a theme-variable rule to styles.css. Escape user input before building the regular expression. Run npm ci, npm run build and npm run lint until clean, install the built plugin in a test vault in the sandbox, verify the highlight appears and that the toggle removes it without a reload, and open a pull request with a screenshot and the build and lint output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
The pull request adds src/editor/keyword-highlighter.ts, changes src/main.ts, src/settings.ts, styles.css, package.json and package-lock.json, and leaves manifest.json and versions.json alone because no API newer than minAppVersion is used. Its description shows the screenshot from the sandbox vault, quotes the npm run build and npm run lint output, and lists the three settings fields with their defaults.
It explains what the extension deliberately does not do: it marks text and never replaces or inserts it, so it cannot change line layout, and it reads only the visible ranges on each update, so a long note costs no more than a short one. It also names the updateOptions call as the reason a settings change takes effect in open editors.
Before merging, a reviewer checks the regular expression escaping, decides whether matching should be case-sensitive or whole-word, and confirms the CSS rule reads well on the default light and dark themes, since styles.css ships in the release alongside main.js.
Run it on every pull request
An automation on the Project with a github trigger on pull_request.synchronize and the prompt "if this pull request touches src/editor/, build the plugin, install it in the test vault, open a note with the configured keywords and attach a screenshot as a comment" starts one run per push to an open pull request. The trigger adds the pull request after the prompt and fills in nothing else, so a push that only edits the README gets a run that reads the diff and stops.
A developer who maintains several plugins sends this body once per repository from their own server, each POST /o/{org}/sessions with that repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own plugin: one that bundles with Rollup gets the CodeMirror packages added to that config's externals instead, and one whose settings already hold a word list gets the extension wired to it.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A CodeMirror extension in Obsidian has to respect three contracts at once: the editor's, where a view plugin may decorate but not reshape the document and must rebuild cheaply; Obsidian's, where the CodeMirror modules come from the app and the extension is registered so it unloads cleanly; and the repository's, with strict TypeScript, the plugin lint rules and a small main.ts. The agent reads all three from the files and proves the result by installing the built plugin in a real vault in its sandbox, which is the only place a decoration can be seen.
The screenshot, the build and the lint output stay with the run, so a reviewer sees the highlight in an editor rather than imagining it from a diff. A developer with several plugins sends the same request to each and reads one pull request per plugin.
Frequently asked questions
Why are the CodeMirror packages devDependencies?
Obsidian provides @codemirror/view and @codemirror/state at runtime and esbuild.config.mjs lists them as external, so they are never bundled into main.js. The plugin installs them only for their types; a bundled second copy would create a separate CodeMirror instance and the extension would not load.
Why a view plugin rather than a state field?
The highlight changes how text looks and nothing else, which is what a view plugin is for: it runs after layout, reads the visible ranges and returns marks. A state field is needed when an extension inserts widgets that take space or must survive outside the viewport, which this feature does not.
Does a settings change need a reload?
No. The extension reads the settings through a getter on every rebuild, and the settings tab calls this.app.workspace.updateOptions() after saveSettings, which tells every open editor to reconfigure its extensions and rebuild decorations.
Does this work on mobile?
Yes. The extension uses only CodeMirror and Obsidian APIs, no Node or Electron modules, so isDesktopOnly stays false in manifest.json. The status bar item the sample already adds is the one feature that does not show on mobile, and it is unchanged.
More Obsidian plugin jobs
More jobs like this: Hand off a long task
- Add Retries to Resend Email Sending (Resend)
- Add Email Verification to an AdonisJS App (AdonisJS)
- Add Email Verification to a Django REST Framework Project (Django REST Framework)