Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,71 @@ Plugin Playground supports AI-assisted extension prototyping in both JupyterLite

### Commands for AI Agents and Automation

Plugin Playground now exposes command APIs that mirror sidebar data and support optional `query` filtering:
Plugin Playground now exposes command APIs that mirror sidebar data.
Discovery commands support optional `query` filtering:

- `plugin-playground:list-tokens`
- `plugin-playground:list-commands`
- `plugin-playground:list-extension-examples`
- `plugin-playground:discover-plugin-docs` (supports optional `{ query?: string, package?: string, detailLevel?: 1 | 2 | 3 }`)
- `plugin-playground:export-as-extension` (supports optional `{ path: string }`)
- `plugin-playground:fetch-plugin-doc` (requires `{ path: string }`, supports optional `{ maxChars: number }`)

Example:

```typescript
await app.commands.execute('plugin-playground:list-tokens', {
query: 'notebook'
});
const docs = await app.commands.execute(
'plugin-playground:discover-plugin-docs',
{ query: 'skill', detailLevel: 1 }
);

const docContent = await app.commands.execute(
'plugin-playground:fetch-plugin-doc',
{
path: docs.items[0].path,
maxChars: 8000
}
);

await app.commands.execute('plugin-playground:export-as-extension', {
path: 'my-extension/src/index.ts'
});
```

Each command returns a JSON object with:
Discovery commands (`list-*`, `discover-*`) return:

- `query`: the filter text that was applied
- `total`: total number of available records
- `count`: number of records returned after filtering
- `items`: matching records

`discover-plugin-docs` also returns:

- `package`: the package filter text that was applied
- `detailLevel`: resolved detail level used for discovery
- `remaining`: how many matches were omitted at current detail level
- `hasMore`: whether additional matches are available
- `hint`: guidance for fetching more context (for low detail responses)

For `discover-plugin-docs`, `package` matches inferred package context for each doc (for example `plugin-playground`, extension example name, or skill name).

`plugin-playground:fetch-plugin-doc` returns:

- `ok`: whether the fetch succeeded
- `path`: fetched documentation file path
- `title`: human-readable document title
- `source`: where the document came from
- `content`: fetched text content (possibly truncated)
- `contentLength`: original full text length
- `truncated`: whether `content` was truncated by `maxChars`

By default, `fetch-plugin-doc` uses the `docFetchMaxChars` setting (default `20000`) and also caps any larger `maxChars` argument to that value.

## Advanced Settings

The Advanced Settings for the Plugin Playground enable you to configure plugins to load every time JupyterLab starts up. Automatically loaded plugins can be configured in two ways:
The Advanced Settings for the Plugin Playground enable you to configure plugins to load every time JupyterLab starts up. Automatically loaded plugins can be configured in several ways:

- `docFetchMaxChars` sets the default and maximum character budget for `plugin-playground:fetch-plugin-doc`.
- `urls` is a list of URLs that will be fetched and loaded as plugins automatically when JupyterLab starts up. For example, you can point to a GitHub gist or a file you host on a local server that serves text files like the above examples.
- `plugins` is a list of strings of plugin text, like the examples above, that are loaded automatically when JupyterLab starts up. Since JSON strings cannot have multiple lines, you will need to encode any newlines in your plugin text directly as `\n\` (the second backslash is to allow the string to continue on the next line). For example, here is a user setting to encode a small plugin to run at startup:
```json5
Expand Down
6 changes: 5 additions & 1 deletion _agents/skills/plugin-authoring/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ Produce working plugin code that can be loaded with `plugin-playground:load-as-e
- `app.commands.execute('plugin-playground:list-tokens', { query: 'status' })`
- `app.commands.execute('plugin-playground:list-commands', { query: 'notebook' })`

3. Discover reference examples
3. Discover reference examples and docs

- Run `plugin-playground:list-extension-examples`.
- Filter by topic with `query` (for example `toolbar`, `commands`, `widget`, `notebook`).
- Open selected example source/README from the sidebar for implementation details.
- Run `plugin-playground:discover-plugin-docs` to find relevant docs (`README`, skill docs, example READMEs).
- Use `query`, `package`, and `detailLevel` (`1`/`2`/`3`) to control precision and context size.
- Run `plugin-playground:fetch-plugin-doc` with a discovered `path` to retrieve doc text for grounded implementation details.
- Use the `docFetchMaxChars` setting to control the default/maximum doc context size.

4. Implement plugin code

Expand Down
8 changes: 8 additions & 0 deletions schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
"default": false,
"type": "boolean"
},
"docFetchMaxChars": {
"title": "Max characters for doc fetch",
"description": "Maximum number of characters returned by plugin-playground:fetch-plugin-doc. Also used as the default when maxChars is omitted.",
"default": 20000,
"type": "integer",
"minimum": 1,
"maximum": 200000
},
"plugins": {
"title": "Plugins",
"description": "List of strings of plugin text to load automatically. Line breaks are encoded as '\\n'",
Expand Down
Loading
Loading