nowdev-extension-structure
/nowdev-extension-structure
Opisuje strukturę kodu TypeScript rozszerzenia NowDev AI Toolbox do VS Code i pomaga przy poprawkach błędów, nowych poleceniach oraz widokach paska bocznego i paneli.
- Autor
- danielmadsendk ↗
- Repozytorium
- nowdev-ai-toolbox ↗
- Licencja
- GPL-3.0
- Ostatnia zmiana repozytorium
- 20.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 20.10.2026, bez odwołań do wycofanych modeli i API.
GPL-3.0, otwarta.
Co robi i kiedy
Opisuje strukturę kodu TypeScript rozszerzenia NowDev AI Toolbox do VS Code i pomaga przy poprawkach błędów, nowych poleceniach oraz widokach paska bocznego i paneli.
Oryginalny opis (EN)
Structural guide for the NowDev AI Toolbox VS Code extension TypeScript source code. Use when working on bug fixes, new commands, the sidebar or editor-panel webviews, or any edits to the src/ directory.
Jak działa
- Extension Overview
- Source File Responsibilities
- Build Commands
- Webview Architecture
- Settings and Prerequisites
- Project State Persistence
- Common Patterns
- TypeScript Config
Podgląd SKILL.md
---
name: nowdev-extension-structure
description: Structural guide for the NowDev AI Toolbox VS Code extension TypeScript source code. Use when working on bug fixes, new commands, the sidebar or editor-panel webviews, or any edits to the src/ directory.
---
## Extension Overview
NowDev AI Toolbox is a VS Code extension (`publisher: DanielMadsenDK`, `name: nowdev-ai-toolbox`, version in `package.json`) that adds a sidebar, editor panels and commands for ServiceNow Fluent development, and syncs Copilot agents and skills into the workspace.
- Runtime entry point: `src/extension.ts` → bundled by esbuild to `dist/extension.js`
- Webviews: Preact (TSX) under `src/webview/` → bundled by esbuild to `dist/webview/<entry>.js` and `<entry>.css`, plus the codicon font
- TypeScript validation output: `out/` (used by tests and agent validation; `src/webview/` is excluded and checked separately)
- Minimum VS Code: `^1.142.0`
- Depends on: `github.copilot-chat`
- Loads bundled agent templates from `agents/github-copilot/` and syncs them into `.github/agents/`; bundled skills sync into `.github/skills/` (there is no `chatSkills` contribution)
## Source File Responsibilities
### Extension host
| File | Purpose |
|------|---------|
| `src/extension.ts` | Activation: registers output channels, context keys, panel serializers, the sidebar, the status bar item and all commands. It does not change VS Code settings |
| `src/WelcomeViewProvider.ts` | Sidebar host. Owns sidebar state, builds it into typed slices, posts only changed slices, handles stateful sidebar messages, syncs agents, and fires `onDidChangeAgents` / `onDidChangeInstance` |
| `src/welcome/sidebarCommands.ts` | Sidebar messages that only forward to a VS Code command (no state) |
| `src/welcome/` (other files) | Prerequisite checks (`prerequisites.ts`), config-file persistence (`configFile.ts`), docs download (`docsSync.ts`), model presets, shared types and helpers |
| `src/commands/sdkCommands.ts` | All `now-sdk` commands (Build, Install, Deploy, Sync, Transform, …, auth, CI/CD, Run Script) |
| `src/commands/sdkCommandOptions.ts` | Flag pickers and auth-alias pickers shared by the commands |
| `src/commands/initFluentProject.ts` + `multiStep.ts` | The Initialize Fluent Project wizard and the reusable step/Back input helpers |
| `src/panels/PanelHost.ts` | Creates or revives every editor panel: CSP shell, ready handshake with message queueing, keyed reuse (`PanelRegistry`), serializers, lifetime-bound listeners |
| `src/panels/webviewHtml.ts` | The HTML shell (nonce CSP, bundle script and stylesheet, initial JSON data) shared by the sidebar and panels |
| `src/panels/DocsPanel.ts`, `src/panels/docs/*` | Explain / command-help panel and the pure parsers that turn CLI output into document blocks |
| `src/SdkQueryPanel.ts`, `src/InstanceBrowserPanel.ts`, `src/AgentTopologyPanel.ts` | Controllers for the Query, Instance Browser and Topology panels |
| `src/panels/sdkQuery.ts`, `src/panels/sdkQueryModel.ts` | The shared `now-sdk query` runner and its pure argv/output parser (used by the Query panel and the Instance Browser) |
| `src/activeInstance.ts` | The workspace's active instance (an auth alias stored in workspaceState, defaulting to the SDK default) and `resolveAuth` for SDK commands |
| `src/panels/topologyModel.ts` | Pure builder for the topology tree and its counts |
| `src/AgentTopology.ts` | Static `AGENT_TREE` (hierarchy and roles); must stay in sync with `agents/github-copilot/` |
| `src/statusBar.ts` | Instance status bar item and the `instanceMenu` quick pick |
| `src/contextKeys.ts` | `nowdev.isFluentProject`, `nowdev.hasAuthAlias`, `nowdev.sdkAvailable` (re-checked on refresh and window focus via `refreshSdkAvailable`) |
| `src/outputChannels.ts` | One reusable output channel per area (`sdk`, `init`, `instanceBrowser`), `showErrorWithOutput` (Retry / Re-authenticate) and `showSdkNotFound` |
| `src/AgentRegistry.ts` | Parses bundled `.agent.md` files into `AgentManifest` objects |
| `src/WorkspaceAgentManager.ts`, `src/agentSync/` | Writes generated agents, instructions and skills |
| `src/ToolScanner.ts`, `src/MCPScanner.ts`, `src/AuthAliasScanner.ts` | Environment, MCP server and async `now-sdk auth --list` scanning (shared cache and in-flight scan; `onAuthAliasesScanned` notifies listeners after each real scan) |
### Webviews (`src/webview/`)
| Path | Purpose |
|------|---------|
| `shared/protocol/*.ts` | Typed messages for each surface, plus small pure helpers. Imported by both the extension and the webviews, so no `vscode`, Node or DOM imports |
| `shared/vscode.ts` | `post`, `useHostMessages` (buffers messages that arrive before mount), `usePersistentState`, `useNow`, initial/restore data helpers |
| `shared/bootstrap.tsx` | `mountPanel(App)`: the start-up every editor panel shares |
| `shared/components/` | Button, IconButton, Switch, Field/inputs, Section, Tabs, OverflowMenu, StatusBadge, Banner, EmptyState/ErrorState, ProgressBar, DataTable, CodeBlock, PageHeader |
| `shared/theme.css` | Design tokens and base styles: colours only from `--vscode-*`, sizes relative to `--vscode-font-size`, no style attributes, high-contrast borders |
| `shared/codicons.css` | Codicon font entry, built once to `dist/webview/codicons.css` and linked by the HTML shell |
| `sidebar/` | The sidebar app: `App.tsx` (header, tabs), `tabs/` (Home, Project, Agents, Settings), `parts/`, and pure logic in `onboarding.ts` and `agentGroups.ts` |
| `panels/<name>/index.tsx` | One bundle per editor panel (`docs`, `query`, `topology`, `instanceBrowser`); esbuild picks up every folder automatically |
## Build Commands
```bash
npm ci # Install dependencies from package-lock.json (deterministic)
npm run compile # tsc for the extension host — validates types, outputs to out/
npm run typecheck:webview # tsc for src/webview (tsconfig.webview.json, no emit)
npm run lint # eslint src + typecheck:webview
npm run bundle # Production bundles: dist/extension.js and dist/webview/*
npm run watch # esbuild watch mode for the extension and all webviews (used by F5)
npm run watch:tsc # TypeScript watch mode
npm test # Compile and run tests from out/test/
npm run validate:agents # Compile and validate agents, topology, and bundled skills
```
`npm run build` aliases `npm run compile`. `vscode:prepublish` runs agent validation, the plugin check and the production bundle.
**After TypeScript changes run `npm run compile` and `npm run lint`.** `dist/` must be writable: if F5 shows a stale or unstyled UI, check that `dist/webview/` exists and is up to date.
## Webview Architecture
All webviews follow the same contract:
1. The extension serves `buildWebviewHtml()` with a nonce CSP (`style-src`/`font-src` limited to the webview source, no inline styles) and resources from `dist/webview/` only.
2. The bundle renders, then posts `{ type: 'ready' }`. Editor panels go through `PanelHost`, which queues outgoing messages until `ready` and runs `onReady` handlers (also after a reload).
3. Messages are typed unions with a `type` field, defined in `src/webview/shared/protocol/`.
### Sidebar
- Tabs: **Home**, **Instance**, **Agents**, **Settings**. Only the active tab's content is mounted; UI state (active tab, open sections, expanded agents, drafts) lives in `usePersistentState`.
- `WelcomeViewProvider._buildState()` produces a `SidebarState` (`checks`, `workspace`, `sdk`, `env`, `mcp`, `docs`, `devops`, `profile`, `agents`, …). `_publish()` is debounced; `diffSlices()` sends only the slices whose JSON changed. On `ready`, the cache is cleared so every slice is resent.
- A slice may be missing or `null` until its data exists (for example `sdk.aliases` is `null` until the first alias scan). Components and `deriveOnboardingSteps()` must treat that as unknown, not empty.
- Auth aliases are scanned once after the first `ready` (the scan spawns `now-sdk`); any other scan updates the sidebar through `onAuthAliasesScanned`.
- `focusTab(tab, section)` reveals the view and a section; it is queued until the webview is ready.
### Editor panels
| Panel | View type | Bundle | Reuse |
|-------|-----------|--------|-------|
| Explain / command help | `nowdev.sdkDocs` | `docs` | One per topic/command |
| SDK Query | `nowdev.sdkQuery` | `query` | One per table |
| Instance Browser | `nowdev.instanceBrowser` | `instanceBrowser` | Single |
| Agent Topology | `nowdev.agentTopology` | `topology` | Single, live via `onDidChangeAgents` |
Each panel stores its identity with `rememberRestoreData()`, and a `WebviewPanelSerializer` revives it after Reload Window (`onWebviewPanel:*` activation events in `package.json`).
## Settings and Prerequisites
The extension never changes VS Code settings on its own. `src/welcome/prerequisites.ts` defines the checks shown under **Settings › Copilot settings**; settings change only when the user clicks **Enable**. Optional checks (for example `git.worktreeIncludeFiles`) can be enabled one at a time but are skipped by "Enable recommended". Array settings declare `includes` and are merged, never overwritten. Memory is preview functionality and may be controlled by organization policy; the extension reports availability instead of force-enabling it.
## Project State Persistence
`WelcomeViewProvider` writes `.vscode/nowdev-ai-config.json` as the workspace state file consumed by agents. It currently persists:
- `instanceUrl`
- `customInstructions`
- `fluentApp`
- `environment`
- `mcpIntegrations`
- `mcpUserDismissed`
- `mcpIntegrationConfigs`
- `allDocSources`
- `guidelines`
- `agentOverrides`
- `activeProfile`
- `profileInstructionsOverrides`
- `customProfiles`
- `memoryLocation`
- `devopsConfig`
- `instanceConnection`
The custom-instructions flow (**Settings › Instructions & guidelines**) uses the `nowdev-ai-toolbox.customInstructionsFile` setting. Do not document or add a separate workspace Copilot instructions file flow unless the product behavior changes first. Onboarding steps the user hides are stored in `workspaceState` (`nowdev.dismissedOnboardingSteps`).
## Common Patterns
**Adding a new command:**
1. Register simple global commands in `extension.ts`, or add feature-specific commands under `src/commands/`
2. Add the contribution to `package.json` under `contributes.commands`, with the `NowDev AI` category, a `SDK:` / `Instance:` / `Agents:` / `Copilot:` title prefix, and `…` when it asks follow-up questions
3. Gate project commands in `menus.commandPalette` with `nowdev.isFluentProject`; hide internal commands with `"when": "false"`
4. SDK commands can be run from the palette (no argument), the sidebar (an options object) or a menu (a `Uri`): use `commandFolder()` and `optionsFrom()` in `sdkCommands.ts`
5. Write output to `getOutputChannel(area)`; report failures with `showErrorWithOutput()`
**Adding a sidebar feature:**
1. Add or extend a slice type in `src/webview/shared/protocol/sidebar.ts` and fill it in `WelcomeViewProvider._buildState()`
2. Add a `FromSidebar` message for the action; handle it in `_handleMessage()`, or in `sidebarCommands.ts` if it only forwards to a command
3. Render it in the relevant tab with the shared components; call `_publish()` after state changes
4. Put non-trivial UI logic in a pure `.ts` module (like `onboarding.ts`) and test it from `src/test/`
**Adding an editor panel:**
1. Create `src/webview/panels/<name>/index.tsx` (+ CSS): render, call `rememberRestoreData()`, then `post({ type: 'ready' })`
2. Define its protocol in `src/webview/shared/protocol/<name>.ts`
3. Create the controller with `PanelHost.create()` and register a serializer with `registerPanelSerializer()` from `extension.ts`
4. Add `onWebviewPanel:<viewType>` to `activationEvents`
**Adding a new tool to detect:**
1. Add an entry to `TOOL_DEFINITIONS` in `src/ToolScanner.ts` with `command`, `versionCommand`, `label`, `description`, and `impact`
**Adding a new VS Code agent:**
1. Create the `.agent.md` file in `agents/github-copilot/`
2. Ensure `AgentRegistry.ts` can parse its frontmatter shape (`name`, `description`, `tools`, `user-invocable`)
3. Let `WorkspaceAgentManager.ts` sync it into `.github/agents/`
4. Add a corresponding `AgentNode` to `src/AgentTopology.ts` so it appears in the topology panel
**Adding a new bundled skill:**
1. Create or update `agents/skills/<skill-name>/SKILL.md`
2. Add any sibling reference docs only if the skill genuinely needs them
3. Run `npm run validate:agents` (workspace sync copies it into `.github/skills/`)
## TypeScript Config
- `tsconfig.json` (extension host): target `ES2022`, `module`/`moduleResolution` `node16` (emits CommonJS), strict, output `out/`, excludes `src/webview/`
- `tsconfig.webview.json` (webviews): `jsx: react-jsx` with `jsxImportSource: preact`, `moduleResolution: bundler`, DOM libs, no emit; `src/webview/css.d.ts` declares `*.css` imports
Wersje
W bazie nie ma innych skilli o nazwie nowdev-extension-structure.
Migawka bazy z 13.11.2026 · wersja paczki 4867d8fbfac3 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100nowdev-ai-toolbox-servicenow-sdk
Opakowuje CLI ServiceNow SDK (now-sdk) zasadami NowDev: bez npx, z bramkami zatwierdzeń przy instalacji, cicd, uwierzytelnianiu i przenoszeniu oraz ochroną poświadczeń. - 100nowdev-ai-toolbox-fluent-development
Wskazuje drogę i zasady pracy z ServiceNow Fluent SDK: metadane .now.ts, układ projektu, migracje now.config.json i aktualizacje SDK oraz przekierowanie do specjalistów. - 100general-create-extension-type
Tworzy nowy typ rozszerzenia w rejestrze rozszerzeń backoffice Umbraco, rejestrowany przez manifesty, np. nowy typ dashboardu, aplikacji paska bocznego lub paska narzędzi. - 100scaffold-extension
Tworzy nowy pakiet rozszerzenia w katalogu extensions/ istniejącego frameworka przy pisaniu rozszerzenia dla AIWG. - 95extension-creator
Tworzy rozszerzenia AiderDesk: pliki, metadane, metody interfejsu Extension, polecenia, narzędzia i obsługę zdarzeń. - 100panels
Dodaje do repozytorium panel operatora, czyli małą aplikację webową z katalogu operator/, którą otwierasz z paska bocznego, aby uruchamiać i podglądać repo.