Documente et illustre deux contrats SDK : - Multi-fichiers ESM : le `main` du manifeste peut importer d'autres fichiers du package via specifiers relatifs, servis par IdeA sur `idea-plugin://` (build `tsc` non bundlé). Le packager embarque tout `dist/**/*.js` et vérifie la présence du `main`. Les bare specifiers (`node_modules`) restent hors contrat : à bundler ou vendorer. - Storage plugin-owned : `ctx.storage` est la place canonique de l'état interne du plugin (compteurs, flags, préférences, caches), hors des fichiers projet. Les APIs workspace/config restent pour le contenu project-owned. L'exemple hello-plugin est éclaté en modules (constants, core/layout, core/workspace, core/storage) pour exercer l'import relatif et le storage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
49 lines
2.2 KiB
Markdown
49 lines
2.2 KiB
Markdown
# Hello Plugin
|
|
|
|
Installable IdeA plugin example rebuilt from the public SDK types.
|
|
|
|
It exercises the current plugin primitives end to end:
|
|
|
|
- top-level menu: `Hello Plugin`;
|
|
- menu entry: `hello-plugin`;
|
|
- command: `hello-plugin`, returning `hello-world`;
|
|
- layout contribution: `hello-plugin.hello-world`, rendered as `hello-world`.
|
|
- plugin-owned storage: activation count, command run count and initialization flag;
|
|
- tooling capability: logs the focused workspace project when `ctx.services` is available.
|
|
|
|
The source is intentionally split across multiple TypeScript modules:
|
|
|
|
- `src/index.ts` is the manifest entrypoint and imports relative ESM modules;
|
|
- `src/constants.ts` owns shared command/layout identifiers;
|
|
- `src/core/layout.ts` and `src/core/workspace.ts` hold feature logic.
|
|
- `src/core/storage.ts` keeps plugin-owned counters and flags in `ctx.storage`.
|
|
|
|
The build uses plain `tsc`; it does not bundle the plugin into one file. The archive includes all
|
|
compiled `dist/**/*.js` files so IdeA can load `dist/index.js` and serve its package-relative imports
|
|
through `idea-plugin://`. Runtime imports from `node_modules` are outside this contract: vendor them
|
|
as relative files or bundle them into the plugin output before packaging.
|
|
|
|
```sh
|
|
npm run typecheck:examples
|
|
npm run package:hello-plugin
|
|
```
|
|
|
|
The installable archive is emitted at `examples/hello-plugin/build/hello-plugin-0.1.0.zip`.
|
|
It contains `idea-plugin.json` at the ZIP root and the compiled multi-file ESM output under `dist/`,
|
|
including `dist/index.js`, matching the manifest `main` field.
|
|
|
|
## Diagnostics
|
|
|
|
During activation the plugin logs:
|
|
|
|
- whether the command and layout runtime registries are available;
|
|
- whether plugin-owned storage is available;
|
|
- activation count and initialization state stored through `ctx.storage`;
|
|
- successful registration of the `hello-plugin` command;
|
|
- successful registration of the `hello-plugin.hello-world` layout;
|
|
- availability of the workspace service from the `tooling` runtime capability;
|
|
- the first layout render, including project/node identifiers.
|
|
|
|
These messages are intentionally small and stable so installation, bundle import, activation and
|
|
layout rendering failures can be separated quickly in IdeA logs/devtools.
|