Imported from byronwall/vsc-markdown-helpers (
AGENTS.md). Install upstream withnpx skills add byronwall/vsc-markdown-helpers. Copyright stays with the author.
Copilot Instructions for vsc-md-helpers
Big picture architecture
- This is a VS Code extension with a split runtime:
- Extension host in
src/for discovery, commands, document links, code block helpers, and preview panel hosting. - Webview client in
media/for rendered markdown preview, navigation, and preview-side code block actions.
- Extension host in
- Main flow:
src/extension.tswires services, commands, providers, and configuration.src/discovery.tsindexes markdown files and emits snapshot updates.src/browserView.tsrenders markdown to HTML, hosts the preview panel, and bridges webview actions back to VS Code.src/editorTools.tshandles file-path links in code view and fenced code block extraction.
Critical workflows
- Install deps:
pnpm install - Validate extension code:
pnpm run compile - Dev loop:
pnpm run watchandpnpm run dev:host - Package/install locally:
pnpm run build:install - Use the pinned pnpm 11 version; keep pnpm project settings in
pnpm-workspace.yaml, notpackage.json.
Project-specific patterns
- Treat markdown path references aggressively: if a path token resolves cleanly against the current file or workspace root, turn it into a link.
- Keep the wrap-width behavior non-destructive: use editor defaults and preview CSS rather than mutating document text.
- Keep preview HTML generation in the extension host so the webview stays lightweight and deterministic.
- Use
MarkdownLoggerfor structured host logging instead of ad-hocconsole.logcalls.
Webview editing conventions
media/src/viewer.cssis only an import hub.- Put tokens in
media/src/viewer.tokens.css, layout inmedia/src/viewer.layout.css, and UI pieces inmedia/src/viewer.components.css. - Do not hand-edit generated webview bundles like
media/dist/viewer.bundle.cssormedia/dist/viewer.bundle.js; update source files and regenerate them with the project build command. - Preserve the webview template placeholders
{{CSP}},{{STYLE_URI}}, and{{SCRIPT_URI}}.
Integration points to keep stable
- Commands and IDs are defined in
package.jsonand implemented insrc/extension.ts; keep them aligned. - Webview message
typevalues are the contract betweensrc/browserView.tsandmedia/src/viewer.js. - Fenced code block parsing is shared behavior for code lenses, editor commands, and preview actions; keep it consistent.