feat(core): add action dispatcher and source editing tools#96
Closed
svallory wants to merge 3 commits intodocmd-io:mainfrom
Closed
feat(core): add action dispatcher and source editing tools#96svallory wants to merge 3 commits intodocmd-io:mainfrom
svallory wants to merge 3 commits intodocmd-io:mainfrom
Conversation
Plugins can now export `actions` (for WebSocket RPC handlers) and `events` (for fire-and-forget handlers) alongside existing build-time hooks. Also defines PluginModule, ActionContext, and SourceTools types for the plugin API contract.
Action dispatcher routes WebSocket RPC calls and events to plugin handlers with a sandboxed ActionContext. Source-tools translate rendered-output references (block positions, text offsets) back to raw markdown source positions for safe file editing. - Port action-dispatcher.js to TypeScript/ESM with async fs.promises - Port source-tools.js to TypeScript/ESM with async fs.promises - Import createMarkdownProcessor from @docmd/parser (upstream export) - safePath rejects any path traversal outside projectRoot - Export both modules from @docmd/core barrel
This was referenced Apr 5, 2026
Fixes prefer-const lint error on the removal cleanup loop index.
Closed
Member
|
Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
action-dispatcher.ts— routes WebSocket RPC calls to plugin action handlers with a sandboxedActionContextsource-tools.ts— translates rendered-output references (block positions, text offsets) to raw markdown source positions for safe file editingfs.promises) and path-sandboxed (safePathrejects traversal)Context
Part of the plugin API infrastructure discussed in #73. Depends on #95 (plugin actions/events hooks).
The action dispatcher creates a fresh
ActionContextper call with:readFile,writeFile,readFileLines— sandboxed to project rootsource— block-level editing tools (getBlockAt, findText, wrapText, insertAfter, replaceBlock, removeBlock)broadcast— push events to connected browser clientsChanges
packages/core/src/utils/action-dispatcher.tspackages/core/src/utils/source-tools.tspackages/core/src/index.tsTest plan
safePath: rejects../../../etc/passwd, acceptsdocs/index.md{ result, reload }getBlockAt,findText,wrapTextpnpm test