---
name: ishell-plugin-dev
description: Build, validate, and package native iShell Pro 4.0 plugins (TypeScript/JavaScript + Deno worker runtime) with accurate manifest.json, permissions, SSH/SFTP/Terminal/Sidebar APIs, and CLI check/pack workflow.
---

# iShell Pro 4.0 Plugin Development Skill

Use this skill whenever the user asks to create, debug, review, or package an **iShell Pro 4.0** plugin.

## 1. Architecture & Runtime Rules

- iShell Pro 4.0 desktop plugins run inside an isolated **Deno** worker managed by the Rust host (`iShellProNative` / `ishellpro`).
- Plugins **cannot** enable themselves, access arbitrary host filesystem paths, or bypass explicit permission grants.
- Every side-effecting capability (`ssh.exec`, `sftp.read`, `sftp.write`, `storage.local`, `notifications.publish`, `ui.sidebar`, `terminal.*`, `network.*`) must be declared in `manifest.json` under `permissions` AND approved by the user on the exact code fingerprint.
- Always respect `context.signal` (`AbortSignal`): abrupt cancellation may terminate the worker without running `finally` blocks.
- Keep `ishell.d.ts` (download from `https://www.ishell.cc/sdk/ishell.d.ts`) in your project root for strict TypeScript checking.

## 2. Standard Project Layout

```text
my-plugin/
├── manifest.json       # Plugin metadata, API version, permissions, contributes
├── main.ts             # Entry module exporting default PluginDefinition
├── ishell.d.ts         # Official SDK TypeScript definitions
└── README.md           # Usage, permissions explanation, and screenshots
```

Quick scaffold with the bundled CLI:

```bash
ishellpro plugin init ./my-plugin --id yourname.my-plugin --template commands
```

## 3. `manifest.json` Contract

```json
{
  "id": "yourname.nginx-inspector",
  "name": "Nginx Inspector",
  "version": "1.0.0",
  "apiVersion": "0.1.36",
  "description": "Inspect Nginx config, test syntax, and reload safely over the active SSH host.",
  "entry": "main.ts",
  "permissions": [
    "ssh.exec",
    "notifications.publish"
  ],
  "contributes": {
    "commands": [
      {
        "id": "test-config",
        "title": "Test Nginx Configuration",
        "description": "Run nginx -t on the selected host"
      }
    ]
  }
}
```

Key constraints:
- `id`: `<namespace>.<slug>` (lowercase letters, digits, hyphens; must match your registered publisher namespace before submitting to the Plugin Market).
- Every key in `export default { commands, resourceProviders, terminalRenderers }` **must exactly match** the IDs declared under `contributes` in `manifest.json`.
- Never request unused permissions; narrow permissions speed up user approval and market review.

## 4. Core `PluginContext` APIs (from `ishell.d.ts`)

- `context.input<T>()`: Read JSON arguments passed to the command invocation.
- `context.signal`: `AbortSignal` triggered when the user cancels or timeout expires.
- `context.settings`: Frozen user-configured settings snapshot (`definitionVersion`, `revision`, `binding`, `values`).
- `context.storage`: Atomic compare-and-set key-value store (`read(keys)`, `keys()`, `commit(expectedRevision, changes)` — up to 128 keys, 1..16 per commit; requires `storage.local`).
- `context.notifications?.publish({ severity, title, message, dedupeKey })`: Plain-text host toast/notice (max 8 per invocation, no secrets; requires `notifications.publish`).
- `context.terminal`: Scoped to the host-selected terminal session (`blocks`, `output`, `screen.read()`, `render`).
- `ResourceProvider` (`list(query, context)`, `get(resourceId, context)`): Populate searchable tables and resource detail views inside the native OneUI workspace.

## 5. Minimal `main.ts` Example

```ts
import type { PluginContext, PluginDefinition } from "./ishell.d.ts";

const plugin: PluginDefinition = {
  commands: {
    "test-config": {
      async run(context: PluginContext) {
        if (context.signal.aborted) {
          return { ok: false, message: "Cancelled before start" };
        }
        const args = await context.input<{ configPath?: string }>();
        const target = args?.configPath?.trim() || "/etc/nginx/nginx.conf";

        await context.notifications?.publish({
          severity: "info",
          title: "Nginx Inspector",
          message: `Checking ${target}...`,
        });

        return {
          ok: true,
          summary: `Prepared check for ${target}`,
        };
      },
    },
  },
};

export default plugin;
```

## 6. Local Verification & Packaging Checklist

Before finishing or submitting to `https://www.ishell.cc/zh-CN/developers`:

1. Run static validation (never executes plugin code):
   ```bash
   ishellpro plugin check ./my-plugin
   ```
2. Pack into a distributable archive:
   ```bash
   ishellpro plugin pack ./my-plugin --out ./dist/my-plugin.ishellpkg
   ```
3. Verify inside iShell Pro desktop client:
   - Success path (valid input + active host)
   - Failure path (missing binary / non-zero exit / invalid input)
   - Cancellation path (abort mid-flight, no leaked temp files or misleading notices)
   - No hardcoded secrets, tokens, or silent background exfiltration.

## 7. Official Links

- Developer Center & Publishing: https://www.ishell.cc/zh-CN/developers
- SDK Type Definitions: https://www.ishell.cc/sdk/ishell.d.ts
- Runnable Examples Archive: https://www.ishell.cc/sdk/plugin-examples.zip
- OneUI Open-Source Native C++ Framework: https://github.com/too1soft/OneUi
