- This project uses ViewerKit toolkit as the core framework for building file-based extensions in VS Code and compatible editors.
- ViewerKit provides APIs and React hooks for local file I/O, Auto-Save, Hot Reload, and Conflict Resolution.
- The current template is a working example extension located at
extensions/simple-react-extension/, which demonstrates these features for a [DEFAULT_VIEWER] viewer. - Your goal is to create a new extension in
[EXTENSION_FOLDER]by replacing the template's default markdown viewer-specific code with your own [EXTENSION_NAME] logic, following the ViewerKit architecture.
Deliver an MVP [EXTENSION_NAME] Extension that lets a user open a local [TARGET_FILE_TYPE] file, view it as an editable [CONTENT_TYPE] in the WebView, and keep it in two-way sync with the Toolkit back-end.
This will also establish the common UI skeleton for future extensions.
- [FUNCTIONALITY_1] – [Describe functionality 1 here.]
- [FUNCTIONALITY_2] – [Describe functionality 2 here.]
- [FUNCTIONALITY_3] – [Describe functionality 3 here.]
- [FUNCTIONALITY_4] – [Describe functionality 4 here.]
- [FUNCTIONALITY_5] – [Describe functionality 5 here.]
- [FUNCTIONALITY_6] – [Describe functionality 6 here.]
- [FUNCTIONALITY_7] – [Describe functionality 7 here.]
The interface is divided vertically into two sections:
Navbar – a slim bar (about 30 px tall) across the top, showing the current file name on the left and a save-status indicator on the right, with other custom features.
Render Area – fills all remaining space below the navbar and hosts the main [CONTENT_TYPE] component that presents and edits the content.
All future extensions should follow this same “navbar above, content below” structure.
-
Add dependency if needed pnpm add [REQUIRED_DEPENDENCY]
pnpm add -D [REQUIRED_DEPENDENCY_TYPES] -
Suggested folder structure [EXTENSION_FOLDER]/
├─ src/
│ ├─ components/
│ │ ├─ [MAIN_COMPONENT].tsx
│ │ └─ Navbar.tsx
│ ├─ hooks/
│ ├─ index.tsx
│ └─ styles.css
└─ package.json -
Data flow
•[MAIN_COMPONENT]accepts[data, setData].
•useAutoSave(data)debounces disk writes.
•useHotReload()updatessetDataon external changes. -
Replace default viewer
• RemoveMarkdownViewer.tsxand related imports.
• Mount[MAIN_COMPONENT]inindex.tsx. -
⚠️ CRITICAL: VS Code API Injection
• The webview HTML MUST include VS Code API injection script:<script nonce="${nonce}"> const vscode = acquireVsCodeApi(); window.vscode = vscode; </script>
• Without this,
window.vscodewill be undefined and file loading will fail.
• This script must be placed before the main bundle script in the HTML.
- Maintainability – Clear layers, full TypeScript coverage.
- Testing – At least unit-test that edits mutate state correctly.
- Documentation – Update
READMEwith install / enable steps.
- M0 – Environment setup, remove default viewer code
- M1 – Navbar + [MAIN_COMPONENT] components complete
- M2 – Integrate Toolkit hooks, end-to-end save/reload
- M3 – Status indicator & basic tests
- M4 – Code review & docs polish
- Read
extensions/simple-react-extension/**to understand existing hooks (useAutoSave,useHotReload, etc.). - In
[EXTENSION_FOLDER](if any core dependency is needed):
• Delete default viewer-related components and dependencies.
• Add [REQUIRED_DEPENDENCY] and wrap it in[MAIN_COMPONENT].tsx.
Instructions(Remove this section before providing to AI):
- Replace all placeholders in [ALL_CAPS] with your own extension-specific details.
- Expand or edit functional requirements as needed for your use case.
- This template is designed to help you prompt an AI coding assistant to generate a customized extension efficiently.