@eclipse-docks/extension-canvas 0.8.14 → 0.8.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // src/skills/eclipse-docks-canvas/SKILL.md?raw
2
- var SKILL_default = "---\nname: eclipse-docks-canvas\ndescription: >-\n Create or edit interactive Eclipse Docks canvases (.canvas.js and the matching\n .canvas.md spec): CanvasView UIs, dashboards, todo apps, widgets, maps, and\n previewable tools. Use when the user wants an interactive view, canvas, widget,\n or .canvas.js file, or when a .canvas.md spec is open — even if they do not say\n \"canvas\".\n---\n\n# Eclipse Docks canvas\n\nWrite a workspace file ending in `.canvas.js`. Default-export a `CanvasView` subclass from `docks/canvas`. The host registers the tag.\n\n```js\nimport { CanvasView, html, css, nothing } from \"docks/canvas\";\n```\n\n`docks/canvas` exports `CanvasView`, the Lit module (`html`, `css`, `nothing`, `repeat`, and the rest), and the Web Awesome module (`registerIconLibrary`). `CanvasView` registers the Web Awesome elements. A canvas does not import `docks/lit` or `docks/webawesome`, and it does not extend `LitElement` or `HTMLElement`.\n\n## CanvasView\n\n| Call | Role |\n| --- | --- |\n| `this.getState(key, fallback)` | Read persisted state. Returns `fallback` when the key is missing. |\n| `this.setState(key, value)` | Write persisted state. Creates a sidecar `canvas.json` for this canvas. |\n| `this.openFile(path)` | Open a workspace path in the editor. |\n| `this.subscribe(topic, callback)` | Listen on the app event bus. The subscription ends when this canvas disconnects. |\n| `this.unsubscribe(token)` | End one subscription early. |\n| `this.publish(topic, data)` | Publish on the app event bus. |\n| `onConnect()` | The element is connected and the host is attached. Hydrate state here. |\n| `onDisconnect()` | The element is leaving the document. Release timers, streams, and object URLs. |\n\nThe host attaches after construction and before `onConnect`. From `constructor`, `getState` returns the fallback, and `setState` and `openFile` do nothing. Leave `connectedCallback` and `disconnectedCallback` on `CanvasView`. The subclass still owns `render`, `static properties`, and `static styles`.\n\nA canvas app consists of three files with the same stem: `….canvas.js`, `….canvas.json`, and `….canvas.md`. The `….canvas.md` file is the input that drives generation of the `….canvas.js` app. `setState` creates the `….canvas.json`. The canvas does not import either sidecar.\n\nWrite `….canvas.md` in this order. `# Requirements` is the user's request. `# Spec` is the behavior contract the module must satisfy. `# State` and `# Interface` are what generation needs and the behavior contract leaves out.\n\n```md\n# Requirements\n\nWhat the user asked for, in their words.\n\n# Spec\n\n## Purpose\n\nOne or two sentences on what this canvas is for.\n\n## Requirements\n\n### Requirement: Add an item\n\nThe canvas SHALL append a non-empty draft to the list and clear the draft.\n\n#### Scenario: Submit a non-empty draft\n\n- WHEN the user submits a non-empty draft\n- THEN the list gains one item with that text and the draft is empty\n\n#### Scenario: Empty draft\n\n- WHEN the user submits an empty draft\n- THEN the list is unchanged\n\n# State\n\nKeys stored through `setState`, and the shape of each value.\n\n# Interface\n\nControls and layout the behavior depends on.\n```\n\nSpec rules:\n\n- One behavior per `### Requirement:`. State it with SHALL or MUST.\n- Every requirement has at least one `#### Scenario:`. Every scenario has a WHEN line and a THEN line. Add AND lines for further outcomes.\n- A scenario states observable behavior: what the user does, what the canvas shows, and what it stores. Class names, Lit details, and component choices stay out of `# Spec`.\n- `# State` names each `setState` key and the shape of its value. `# Interface` names the controls and layout a scenario depends on. It is not a widget catalog.\n\n## Hard rules\n\n1. Pure JavaScript only — no TypeScript, no decorators. Declare reactive fields with `static properties = { … }`. Initialize plain defaults in `constructor`; hydrate with `getState` in `onConnect`.\n2. Build controls and chrome with Web Awesome (`wa-button`, `wa-input`, `wa-checkbox`, `wa-card`, `wa-callout`, `wa-spinner`). A raw `<button>` or `<input>` is not a substitute. Load `eclipse-docks-webawesome` before a non-trivial UI, and use `--wa-color-*` tokens instead of hardcoded colors.\n3. Emit complete, valid JavaScript — no truncated objects or unfinished strings.\n4. The page uses `Cross-Origin-Embedder-Policy: require-corp`. A cross-origin response loads only when the request is CORS and the server sends `Access-Control-Allow-Origin`, or when the server sends `Cross-Origin-Resource-Policy: cross-origin`. An `<iframe srcdoc>` inherits this policy; `sandbox=\"allow-same-origin\"` does not exempt it.\n5. The `….canvas.md` file is the input that drives the `….canvas.js` app. When the request changes, update the requirement and its scenarios first, and `# State` or `# Interface` when those change, then regenerate the module so each scenario still holds.\n\n## Code\n\nFollow clean code, DRY, SOLID, KISS, YAGNI, AHA, separation of concerns, fail fast, least astonishment, and the usual design patterns. Make the UI accessible and responsive. Format the file for a person to read: 2-space indentation, semicolons, double quotes, and templates and CSS broken across lines.\n\n## Minimal pattern\n\n```js\nimport { CanvasView, html, css } from \"docks/canvas\";\n\nexport default class extends CanvasView {\n static properties = {\n items: { state: true },\n draft: { state: true },\n };\n\n static styles = css`\n :host { display: block; padding: 1rem; box-sizing: border-box; }\n `;\n\n constructor() {\n super();\n this.items = [];\n this.draft = \"\";\n }\n\n onConnect() {\n const saved = this.getState(\"items\", null);\n if (Array.isArray(saved)) this.items = saved;\n }\n\n persist() {\n this.setState(\"items\", this.items);\n }\n\n addItem() {\n const input = this.renderRoot.querySelector(\"wa-input\");\n const text = String(input?.value ?? \"\").trim();\n if (!text) return;\n this.items = [...this.items, { id: crypto.randomUUID(), text, done: false }];\n this.draft = \"\";\n this.persist();\n }\n\n render() {\n return html`\n <wa-input\n placeholder=\"New item\"\n .value=${this.draft}\n @keydown=${(e) => { if (e.key === \"Enter\") this.addItem(); }}\n ></wa-input>\n <wa-button @click=${() => this.addItem()}>Add</wa-button>\n <ul>\n ${this.items.map((item) => html`<li>${item.text}</li>`)}\n </ul>\n `;\n }\n}\n```\n\n## Cross-origin resources\n\n`<img>`, `<link>`, and `<script>` tags without `crossorigin` are no-cors. A no-cors response that omits `Cross-Origin-Resource-Policy` fails with `not-set cross-origin-resource-policy`, even when it sends `Access-Control-Allow-Origin: *`. Moving that URL into an `<iframe srcdoc>` does not change the check. Subresources inside the frame follow the same rule.\n\nWhen the server only sends `Access-Control-Allow-Origin`, request the resource as CORS. `fetch()` already does. For an element, set `crossorigin=\"anonymous\"`. When a library creates the element, set its equivalent option (often `crossOrigin: \"anonymous\"`). A missing `Access-Control-Allow-Origin` header on that request is a CORS error, not the CORP error.\n\n```html\n<img crossorigin=\"anonymous\" src=\"https://cdn.example/asset.png\" />\n<script crossorigin=\"anonymous\" src=\"https://cdn.example/lib.js\"><\/script>\n```\n\nA host that sends neither header cannot be embedded in this page. Pass the string `\"anonymous\"` to a library option (`crossOrigin: \"anonymous\"`). A boolean `true` is not that option.\n\n## Styles inside the shadow root\n\nThe canvas renders in a shadow root. A `<link>` or `<style>` added to `document.head` does not apply to nodes inside that root. A widget that positions its own DOM with classes will load its images and still draw them in the wrong place until its stylesheet is on the shadow root.\n\nFetch the stylesheet as CORS and adopt it before constructing the widget:\n\n```js\nconst cssText = await (await fetch(stylesheetUrl, { mode: \"cors\" })).text();\nconst sheet = new CSSStyleSheet();\nsheet.replaceSync(cssText);\nthis.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, sheet];\n```\n\n`static styles` is for the host. Do not rely on a document-level stylesheet for DOM the library creates inside the shadow root.\n\n## Imports\n\n- `docks/canvas` — `CanvasView`, the Lit exports (`html`, `css`, `nothing`, `repeat`, `when`, `classMap`, and the rest), and the Web Awesome exports (`registerIconLibrary`). The elements are already registered.\n- `docks/core` — workspace files, dialogs, toasts, and commands. `openFile` does not need this import.\n- Relative imports → workspace files (compiler inlines them: JSON → value, text/CSS → string, binaries → data URL)\n\nBefore non-trivial UI or shell integration, load companion skills as needed:\n\n- `skills.load` `eclipse-docks-lit` — reactive properties, templates, directives (pure JS)\n- `skills.load` `eclipse-docks-webawesome` — `wa-*` components and layout utilities\n- `skills.load` `eclipse-docks-core` — workspace, editors, commands, dialogs, events\n\n## Workflow\n\n1. `workspace_write` the `<root>/….canvas.md` input in the structure above (qualify with a root from `workspace_list`).\n2. `workspace_write` the `<root>/….canvas.js` app that this markdown drives, with the same stem in the same folder. Each scenario in `# Spec` holds in the module.\n3. `canvas.open` with that path — returns `ready` or the compile/runtime error.\n4. Before changing a canvas, `workspace_read` its `….canvas.md`. If the request changed, update the requirement and its scenarios in that file, then `canvas.apply_source`. If that canvas is open in an editor, the editor marks itself dirty and recompiles the preview and does not save. If it is not open in an editor, the tool writes the file. Do not `workspace_write` a canvas that is already open.\n5. Optional: `canvas.capture_preview` to attach a screenshot (iframe contents may be blank).\n\nExtension-registered canvases live on `system.canvases` and open by name via `canvas.open`. That opens a read-only viewer. Do not edit it: `canvas.apply_source`, `canvas.get_source`, `canvas.set_state`, and any tools declared by that canvas are not available while it is active.\n";
2
+ var SKILL_default = "---\nname: eclipse-docks-canvas\ndescription: >-\n Implement Eclipse Docks canvases (.canvas.js) from a plan-*.plan.md file:\n CanvasView UIs, dashboards, todo apps, widgets, maps, and previewable tools.\n Use when the user wants an interactive view, canvas, widget, or .canvas.js\n file, or when a plan file is open — even if they do not say \"canvas\".\n Plan mode writes the plan. This skill implements the module.\n---\n\n# Eclipse Docks canvas\n\nWrite a workspace file ending in `.canvas.js`. The file default-exports one `CanvasView` subclass from `docks/canvas`:\n\n```js\nexport default class App extends CanvasView {}\n```\n\nDo not use `export class` without `default`, and do not call `customElements.define`. The host registers the tag. A module without a default export does not load.\n\n```js\nimport { CanvasView, html, css, nothing } from \"docks/canvas\";\n```\n\n`docks/canvas` exports `CanvasView`, the Lit module (`html`, `css`, `nothing`, `repeat`, and the rest), and the Web Awesome module (`registerIconLibrary`). `CanvasView` registers the Web Awesome elements. A canvas does not import `docks/lit` or `docks/webawesome`, and it does not extend `LitElement` or `HTMLElement`.\n\n## CanvasView\n\n| Call | Role |\n| --- | --- |\n| `this.getState(key, fallback)` | Read persisted state. Returns `fallback` when the key is missing. |\n| `this.setState(key, value)` | Write persisted state. Creates a sidecar `canvas.json` for this canvas. |\n| `this.openFile(path)` | Open a workspace path in the editor. |\n| `this.subscribe(topic, callback)` | Listen on the app event bus. The subscription ends when this canvas disconnects. |\n| `this.unsubscribe(token)` | End one subscription early. |\n| `this.publish(topic, data)` | Publish on the app event bus. |\n| `onConnect()` | The element is connected and the host is attached. Hydrate state here. |\n| `onDisconnect()` | The element is leaving the document. Release timers, streams, and object URLs. |\n\nThe host attaches after construction and before `onConnect`. From `constructor`, `getState` returns the fallback, and `setState` and `openFile` do nothing. Leave `connectedCallback` and `disconnectedCallback` on `CanvasView`. The subclass still owns `render`, `static properties`, and `static styles`.\n\nA canvas app consists of `….canvas.js` and `….canvas.json`. The plan is a separate `plan-<short-description>.plan.md`, the same document used for every other task. Plan mode writes it with `create_plan`. It is the ground truth that drives the `….canvas.js` app. `setState` creates the `….canvas.json`. The canvas does not import the plan or the json file.\n\nThe plan uses this order. `# Requirements` is the user's request, paraphrased in correct language. Fix typos and unclear wording, and do not copy the user's text into the plan. `# Spec` is the behavior contract the module must satisfy. `# State` and `# Interface` are what generation needs and the behavior contract leaves out. `# Files` names the module and any other file Build will change.\n\n```md\n# Requirements\n\nA clean paraphrase of what the user asked for. Typos are corrected here.\n\n# Spec\n\n## Purpose\n\nOne or two sentences on what this canvas is for.\n\n## Requirements\n\n### Requirement: Add an item\n\nThe canvas SHALL append a non-empty draft to the list and clear the draft.\n\n#### Scenario: Submit a non-empty draft\n\n- WHEN the user submits a non-empty draft\n- THEN the list gains one item with that text and the draft is empty\n\n#### Scenario: Empty draft\n\n- WHEN the user submits an empty draft\n- THEN the list is unchanged\n\n# State\n\nKeys stored through `setState`, and the shape of each value.\n\n# Interface\n\nControls and layout the behavior depends on.\n\n# Files\n\n- `<stem>.canvas.js` — the module Build writes\n```\n\nSpec rules:\n\n- One behavior per `### Requirement:`. State it with SHALL or MUST.\n- Every requirement has at least one `#### Scenario:`. Every scenario has a WHEN line and a THEN line. Add AND lines for further outcomes.\n- A scenario states observable behavior: what the user does, what the canvas shows, and what it stores. Class names, Lit details, and component choices stay out of `# Spec`.\n- `# State` names each `setState` key and the shape of its value. `# Interface` names the controls and layout a scenario depends on. It is not a widget catalog. `# Files` names the module Build will write.\n\n## Hard rules\n\n1. Pure JavaScript only — no TypeScript, no decorators. The module default-exports the view (`export default class … extends CanvasView`). Do not call `customElements.define`, and do not leave the class as a named `export class` without `default`. Declare reactive fields with `static properties = { … }`. Initialize plain defaults in `constructor`; hydrate with `getState` in `onConnect`.\n2. Build controls and chrome with Web Awesome (`wa-button`, `wa-input`, `wa-checkbox`, `wa-card`, `wa-callout`, `wa-spinner`). A raw `<button>` or `<input>` is not a substitute. Load `eclipse-docks-webawesome` before a non-trivial UI, and use `--wa-color-*` tokens instead of hardcoded colors.\n3. Emit complete, valid JavaScript — no truncated objects or unfinished strings.\n4. The page uses `Cross-Origin-Embedder-Policy: require-corp`. A cross-origin response loads only when the request is CORS and the server sends `Access-Control-Allow-Origin`, or when the server sends `Cross-Origin-Resource-Policy: cross-origin`. An `<iframe srcdoc>` inherits this policy; `sandbox=\"allow-same-origin\"` does not exempt it.\n5. The `plan-….plan.md` file drives the `….canvas.js` app. When the request changes, `workspace_read` that plan and `workspace_write` the same file so `# Spec`, and `# State` or `# Interface` when those change, match the request. Then update the module so each scenario still holds. Do not create a different plan file, and do not leave the plan describing the old behavior. Do not generate the module during plan mode.\n\n## Code\n\nFollow clean code, DRY, SOLID, KISS, YAGNI, AHA, separation of concerns, fail fast, least astonishment, and the usual design patterns. Make the UI accessible and responsive. Format the file for a person to read: 2-space indentation, semicolons, double quotes, and templates and CSS broken across lines.\n\n## Minimal pattern\n\n```js\nimport { CanvasView, html, css } from \"docks/canvas\";\n\nexport default class extends CanvasView {\n static properties = {\n items: { state: true },\n draft: { state: true },\n };\n\n static styles = css`\n :host { display: block; padding: 1rem; box-sizing: border-box; }\n `;\n\n constructor() {\n super();\n this.items = [];\n this.draft = \"\";\n }\n\n onConnect() {\n const saved = this.getState(\"items\", null);\n if (Array.isArray(saved)) this.items = saved;\n }\n\n persist() {\n this.setState(\"items\", this.items);\n }\n\n addItem() {\n const input = this.renderRoot.querySelector(\"wa-input\");\n const text = String(input?.value ?? \"\").trim();\n if (!text) return;\n this.items = [...this.items, { id: crypto.randomUUID(), text, done: false }];\n this.draft = \"\";\n this.persist();\n }\n\n render() {\n return html`\n <wa-input\n placeholder=\"New item\"\n .value=${this.draft}\n @keydown=${(e) => { if (e.key === \"Enter\") this.addItem(); }}\n ></wa-input>\n <wa-button @click=${() => this.addItem()}>Add</wa-button>\n <ul>\n ${this.items.map((item) => html`<li>${item.text}</li>`)}\n </ul>\n `;\n }\n}\n```\n\n## Cross-origin resources\n\n`<img>`, `<link>`, and `<script>` tags without `crossorigin` are no-cors. A no-cors response that omits `Cross-Origin-Resource-Policy` fails with `not-set cross-origin-resource-policy`, even when it sends `Access-Control-Allow-Origin: *`. Moving that URL into an `<iframe srcdoc>` does not change the check. Subresources inside the frame follow the same rule.\n\nWhen the server only sends `Access-Control-Allow-Origin`, request the resource as CORS. `fetch()` already does. For an element, set `crossorigin=\"anonymous\"`. When a library creates the element, set its equivalent option (often `crossOrigin: \"anonymous\"`). A missing `Access-Control-Allow-Origin` header on that request is a CORS error, not the CORP error.\n\n```html\n<img crossorigin=\"anonymous\" src=\"https://cdn.example/asset.png\" />\n<script crossorigin=\"anonymous\" src=\"https://cdn.example/lib.js\"><\/script>\n```\n\nA host that sends neither header cannot be embedded in this page. Pass the string `\"anonymous\"` to a library option (`crossOrigin: \"anonymous\"`). A boolean `true` is not that option.\n\n## Styles inside the shadow root\n\nThe canvas renders in a shadow root. A `<link>` or `<style>` added to `document.head` does not apply to nodes inside that root. A widget that positions its own DOM with classes will load its images and still draw them in the wrong place until its stylesheet is on the shadow root.\n\nFetch the stylesheet as CORS and adopt it before constructing the widget:\n\n```js\nconst cssText = await (await fetch(stylesheetUrl, { mode: \"cors\" })).text();\nconst sheet = new CSSStyleSheet();\nsheet.replaceSync(cssText);\nthis.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, sheet];\n```\n\n`static styles` is for the host. Do not rely on a document-level stylesheet for DOM the library creates inside the shadow root.\n\n## Imports\n\n- `docks/canvas` — `CanvasView`, the Lit exports (`html`, `css`, `nothing`, `repeat`, `when`, `classMap`, and the rest), and the Web Awesome exports (`registerIconLibrary`). The elements are already registered.\n- `docks/core` — workspace files, dialogs, toasts, and commands. `openFile` does not need this import.\n- Relative imports → workspace files (compiler inlines them: JSON → value, text/CSS → string, binaries → data URL)\n\nLoad a companion skill only when the plan depends on a component or API this skill does not already specify. Do not load every companion before writing the module:\n\n- `skills.load` `eclipse-docks-lit` — reactive properties, templates, directives (pure JS)\n- `skills.load` `eclipse-docks-webawesome` — `wa-*` components and layout utilities\n- `skills.load` `eclipse-docks-core` — workspace, editors, commands, dialogs, events\n\n## Workflow\n\nPlan mode owns the spec. This skill owns the module.\n\n1. In plan mode, call `create_plan` once this turn. The first call writes `plan-<short-description>.plan.md` and lists the `<stem>.canvas.js` under `# Files`. A later change passes that file as `path` and rewrites it. Do not create a second plan for the same app, and do not write the module in plan mode.\n2. Build reads that plan once and writes the `<stem>.canvas.js` so every scenario in `# Spec` holds, then `canvas.open` with that path. The module default-exports the `CanvasView` subclass and does not call `customElements.define`. Do not list the workspace again or read the plan again. `canvas.open` returns `ready` or the compile/runtime error.\n3. Before changing a canvas, `workspace_read` its `plan-….plan.md`. If the request changed, `workspace_write` that same plan so the requirement and its scenarios match, then update the module. Then `canvas.apply_source`. If that canvas is open in an editor, the editor marks itself dirty and recompiles the preview and does not save. If it is not open in an editor, the tool writes the file. Do not `workspace_write` a canvas that is already open.\n4. Optional: `canvas.capture_preview` to attach a screenshot (iframe contents may be blank).\n\nExtension-registered canvases live on `system.canvases` and open by name via `canvas.open`. That opens a read-only viewer. Do not edit it: `canvas.apply_source`, `canvas.get_source`, `canvas.set_state`, and any tools declared by that canvas are not available while it is active.\n";
3
3
  export { SKILL_default as default };
4
4
 
5
5
  //# sourceMappingURL=SKILL.js.map
@@ -1,5 +1,5 @@
1
1
  // src/skills/eclipse-docks-core/SKILL.md?raw
2
- var SKILL_default = "---\nname: eclipse-docks-core\ndescription: >-\n Eclipse Docks core runtime from docks/core: workspace files, editors, commands,\n contributions, dialogs, toasts, settings, and events. Use when a canvas or\n extension needs to open files, register UI, run commands, or talk to the shell.\n---\n\n# Eclipse Docks core (`docks/core`)\n\n```js\nimport {\n workspaceService,\n File,\n editorRegistry,\n commandRegistry,\n registerAll,\n contributionRegistry,\n publish,\n subscribe,\n unsubscribe,\n appSettings,\n toastInfo,\n toastError,\n confirmDialog,\n promptDialog,\n filebrowserDialog,\n} from \"docks/core\";\n```\n\nAlias: `@eclipse-docks/core`. `publish`, `subscribe`, and `unsubscribe` come from this module.\n\n## Workspace\n\n```js\nconst workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\nconst resource = await workspace.getResource(\"folder/note.md\");\nif (resource instanceof File) {\n const text = await resource.getContents();\n await resource.saveContents(text);\n}\n```\n\n- Paths are workspace-relative (root-prefixed in the composite workspace).\n- Create with `getResource(path, { create: true })` when the API allows.\n- A canvas opens a path in the editor with `this.openFile(path)` and does not import core for that call. Reading or writing file bytes still uses `workspaceService` and `File`.\n\n## Editors\n\n```js\nawait editorRegistry.loadEditor(file); // default handler\nawait editorRegistry.loadEditor(file, \"system.canvas-editor\");\n```\n\n`EditorInput` objects carry `title`, `key`, `data`, `component`, optional `state`. Prefer opening a `File` when one exists.\n\n## Commands\n\n```js\nregisterAll({\n command: {\n id: \"demo.ping\",\n name: \"Ping\",\n description: \"Demo command\",\n parameters: [],\n },\n handler: {\n execute: async () => \"pong\",\n },\n});\n\nawait commandRegistry.execute(\"demo.ping\", {});\n```\n\nCommands registered this way can surface as AI tools when the cognitive runtime refreshes command tools.\n\n## Contributions\n\n```js\nimport { SIDEBAR_MAIN, TOOLBAR_MAIN_RIGHT } from \"docks/core\";\n\ncontributionRegistry.registerContribution(SIDEBAR_MAIN, {\n name: \"demo.view\",\n label: \"Demo\",\n icon: \"star\",\n component: (id) => /* Lit html template for the view */ null,\n});\n```\n\nCommon slots: sidebars, panel bottom, toolbars, settings. Canvas modules contributed by extensions use `system.canvases` (`SYSTEM_CANVASES` from `@eclipse-docks/extension-canvas/contribution`). Each contribution sets a unique `settingsKey` for the state behind `getState` / `setState`. `load()` returns `{ default: CustomElementConstructor }`, or `source` is the canvas module text and the preview compiles it. A contributed canvas is not editable and opens without a toolbar.\n\n## Dialogs & toasts\n\n```js\nconst ok = await confirmDialog(\"Replace file?\");\nconst name = await promptDialog(\"Name?\");\ntoastInfo(\"Saved\");\ntoastError(\"Failed\");\n```\n\n`filebrowserDialog` for folder/file picks; `formDialog` for multi-field forms. Prefer these over ad-hoc `window.prompt` in shell-integrated code.\n\n## Settings & events\n\n```js\nawait appSettings.set(\"demo.flag\", true);\nconst flag = await appSettings.get(\"demo.flag\");\n\nconst id = subscribe(\"topic.name\", (event) => { /* … */ });\npublish(\"topic.name\", { detail: 1 });\nunsubscribe(id);\n```\n\n## Logging\n\n```js\nimport { createLogger } from \"docks/core\";\nconst log = createLogger(\"demo\");\nlog.info(\"ready\");\n```\n\n## Canvas notes\n\n- A canvas app consists of three files with the same stem: `….canvas.js`, `….canvas.json`, and `….canvas.md`. The `….canvas.md` file is the input that drives generation of the `….canvas.js` app. Persist with `this.getState` / `this.setState` inside `onConnect` and later. `setState` creates the `….canvas.json`. Use `appSettings` only to share app-wide settings. A contributed canvas stores that state under its `settingsKey` and has no `….canvas.md`.\n- `this.openFile(path)` opens a workspace path. Dialogs, toasts, and file contents stay on `docks/core`.\n- A canvas listens and publishes with `this.subscribe`, `this.unsubscribe`, and `this.publish`. It does not import those functions.\n- Cross-origin loads follow the canvas skill: CORS plus `Access-Control-Allow-Origin`, or `Cross-Origin-Resource-Policy: cross-origin`. An iframe `srcdoc` does not opt out.\n\n## Anti-patterns\n\n- Bare filenames at the composite workspace root when a durable root prefix is required\n- Calling `getState`, `setState`, or `openFile` before `onConnect`\n- Re-implementing toast/dialog with `alert` when core helpers are available\n";
2
+ var SKILL_default = "---\nname: eclipse-docks-core\ndescription: >-\n Eclipse Docks core runtime from docks/core: workspace files, editors, commands,\n contributions, dialogs, toasts, settings, and events. Use when a canvas or\n extension needs to open files, register UI, run commands, or talk to the shell.\n---\n\n# Eclipse Docks core (`docks/core`)\n\n```js\nimport {\n workspaceService,\n File,\n editorRegistry,\n commandRegistry,\n registerAll,\n contributionRegistry,\n publish,\n subscribe,\n unsubscribe,\n appSettings,\n toastInfo,\n toastError,\n confirmDialog,\n promptDialog,\n filebrowserDialog,\n} from \"docks/core\";\n```\n\nAlias: `@eclipse-docks/core`. `publish`, `subscribe`, and `unsubscribe` come from this module.\n\n## Workspace\n\n```js\nconst workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\nconst resource = await workspace.getResource(\"folder/note.md\");\nif (resource instanceof File) {\n const text = await resource.getContents();\n await resource.saveContents(text);\n}\n```\n\n- Paths are workspace-relative (root-prefixed in the composite workspace).\n- Create with `getResource(path, { create: true })` when the API allows.\n- A canvas opens a path in the editor with `this.openFile(path)` and does not import core for that call. Reading or writing file bytes still uses `workspaceService` and `File`.\n\n## Editors\n\n```js\nawait editorRegistry.loadEditor(file); // default handler\nawait editorRegistry.loadEditor(file, \"system.canvas-editor\");\n```\n\n`EditorInput` objects carry `title`, `key`, `data`, `component`, optional `state`. Prefer opening a `File` when one exists.\n\n## Commands\n\n```js\nregisterAll({\n command: {\n id: \"demo.ping\",\n name: \"Ping\",\n description: \"Demo command\",\n parameters: [],\n },\n handler: {\n execute: async () => \"pong\",\n },\n});\n\nawait commandRegistry.execute(\"demo.ping\", {});\n```\n\nCommands registered this way can surface as AI tools when the cognitive runtime refreshes command tools.\n\n## Contributions\n\n```js\nimport { SIDEBAR_MAIN, TOOLBAR_MAIN_RIGHT } from \"docks/core\";\n\ncontributionRegistry.registerContribution(SIDEBAR_MAIN, {\n name: \"demo.view\",\n label: \"Demo\",\n icon: \"star\",\n component: (id) => /* Lit html template for the view */ null,\n});\n```\n\nCommon slots: sidebars, panel bottom, toolbars, settings. Canvas modules contributed by extensions use `system.canvases` (`SYSTEM_CANVASES` from `@eclipse-docks/extension-canvas/contribution`). Each contribution sets a unique `settingsKey` for the state behind `getState` / `setState`. `load()` returns `{ default: CustomElementConstructor }`, or `source` is the canvas module text and the preview compiles it. A contributed canvas is not editable and opens without a toolbar.\n\n## Dialogs & toasts\n\n```js\nconst ok = await confirmDialog(\"Replace file?\");\nconst name = await promptDialog(\"Name?\");\ntoastInfo(\"Saved\");\ntoastError(\"Failed\");\n```\n\n`filebrowserDialog` for folder/file picks; `formDialog` for multi-field forms. Prefer these over ad-hoc `window.prompt` in shell-integrated code.\n\n## Settings & events\n\n```js\nawait appSettings.set(\"demo.flag\", true);\nconst flag = await appSettings.get(\"demo.flag\");\n\nconst id = subscribe(\"topic.name\", (event) => { /* … */ });\npublish(\"topic.name\", { detail: 1 });\nunsubscribe(id);\n```\n\n## Logging\n\n```js\nimport { createLogger } from \"docks/core\";\nconst log = createLogger(\"demo\");\nlog.info(\"ready\");\n```\n\n## Canvas notes\n\n- A canvas app consists of `….canvas.js` and `….canvas.json`. Its behavior contract is a `plan-….plan.md` file, the same plan document used for every other task. Plan mode writes the plan; Build generates the `….canvas.js` from it. A later change revises that same plan, then the module. Persist with `this.getState` / `this.setState` inside `onConnect` and later. `setState` creates the `….canvas.json`. Use `appSettings` only to share app-wide settings. A contributed canvas stores that state under its `settingsKey` and has no plan file.\n- `this.openFile(path)` opens a workspace path. Dialogs, toasts, and file contents stay on `docks/core`.\n- A canvas listens and publishes with `this.subscribe`, `this.unsubscribe`, and `this.publish`. It does not import those functions.\n- Cross-origin loads follow the canvas skill: CORS plus `Access-Control-Allow-Origin`, or `Cross-Origin-Resource-Policy: cross-origin`. An iframe `srcdoc` does not opt out.\n\n## Anti-patterns\n\n- Bare filenames at the composite workspace root when a durable root prefix is required\n- Calling `getState`, `setState`, or `openFile` before `onConnect`\n- Re-implementing toast/dialog with `alert` when core helpers are available\n";
3
3
  export { SKILL_default as default };
4
4
 
5
5
  //# sourceMappingURL=SKILL.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/extension-canvas",
3
- "version": "0.8.14",
3
+ "version": "0.8.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",