|
| 1 | +# projspec PyCharm Plugin |
| 2 | + |
| 3 | +PyCharm integration for the [projspec](https://github.com/fsspec/projspec) CLI tool. |
| 4 | + |
| 5 | +<!-- Plugin description --> |
| 6 | +PyCharm integration for the **projspec** CLI tool. |
| 7 | + |
| 8 | +- Browse your **Project Library** in a dedicated sidebar tool window |
| 9 | +- **Add**, **Rescan** and **Remove** directories from the library |
| 10 | +- **Create** new spec types inside an existing project with autocomplete |
| 11 | +- **Make** individual artifacts in an interactive terminal tab |
| 12 | +- Open projects with VSCode, PyCharm, Jupyter Lab, or the system file browser |
| 13 | +- Edit the projspec configuration file with one click |
| 14 | + |
| 15 | +Requires the `projspec` CLI. Configure the binary path under |
| 16 | +**Settings → Tools → Projspec**. |
| 17 | +<!-- Plugin description end --> |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +1. Install the plugin from JetBrains Marketplace (search for `projspec`), or |
| 22 | + build from source with `./gradlew buildPlugin`. |
| 23 | +2. Open **Settings → Tools → Projspec** and set the path to your `projspec` binary |
| 24 | + (or leave as `projspec` if it is on your `PATH`). |
| 25 | +3. The **Project Library** tool window appears in the left sidebar. |
| 26 | + |
| 27 | +## UI overview |
| 28 | + |
| 29 | +The tool window has two panes, mirroring the VSCode extension described in |
| 30 | +[`vsextension/ACTIONS.md`](../vsextension/ACTIONS.md): |
| 31 | + |
| 32 | +- **Library (left)** – a toolbar (*Add*, *Reload*, *Configure*), a filter |
| 33 | + field, and one widget per registered project. Each widget shows the |
| 34 | + project's basename, URL, storage options, and colour-coded chips for its |
| 35 | + *Contents*, *Artifacts* and spec types. A kebab menu offers *Open with |
| 36 | + VSCode / system filebrowser / PyCharm / jupyter*, *Rescan*, *Create spec* |
| 37 | + and *Remove from library*. |
| 38 | +- **Details (right)** – title, doc/link for the selected spec, and one |
| 39 | + card per content/artifact of the selected project. Artifact cards |
| 40 | + include a **Make** button (runs `projspec make …` in a terminal tab) and |
| 41 | + every card has an **ℹ️** info popup. Bodies render as a YAML-style |
| 42 | + collapsible tree, with enum values shown by their member name. |
| 43 | + |
| 44 | +## Development |
| 45 | + |
| 46 | +### Prerequisites |
| 47 | + |
| 48 | +- JDK 21 |
| 49 | +- Gradle 9.x (the Gradle Wrapper is included) |
| 50 | + |
| 51 | +### Run configurations |
| 52 | + |
| 53 | +After opening the project in IntelliJ IDEA, three pre-configured run configurations |
| 54 | +are available from the `.run/` directory: |
| 55 | + |
| 56 | +| Configuration | Gradle task | Description | |
| 57 | +|---|---|---| |
| 58 | +| **Run Plugin** | `runIde` | Launch a sandboxed PyCharm instance with the plugin loaded. Use the Debug icon for breakpoint debugging. | |
| 59 | +| **Run Tests** | `check` | Run all unit tests and generate a Kover coverage report. | |
| 60 | +| **Run Verifications** | `verifyPlugin` | Run the IntelliJ Plugin Verifier to check compatibility against the target IDE range. | |
| 61 | + |
| 62 | +### Build |
| 63 | + |
| 64 | +```bash |
| 65 | +./gradlew buildPlugin # produces build/distributions/projspec-pycharm-*.zip |
| 66 | +./gradlew runIde # launch sandboxed PyCharm |
| 67 | +./gradlew check # run tests + coverage |
| 68 | +./gradlew verifyPlugin # plugin compatibility check |
| 69 | +./gradlew publishPlugin # publish to JetBrains Marketplace (requires secrets) |
| 70 | +``` |
| 71 | + |
| 72 | +### Environment variables (for signing & publishing) |
| 73 | + |
| 74 | +| Variable | Purpose | |
| 75 | +|---|---| |
| 76 | +| `PRIVATE_KEY` | RSA private key for plugin signing | |
| 77 | +| `PRIVATE_KEY_PASSWORD` | Password for the private key | |
| 78 | +| `CERTIFICATE_CHAIN` | Certificate chain for plugin signing | |
| 79 | +| `PUBLISH_TOKEN` | JetBrains Marketplace publish token | |
| 80 | + |
| 81 | +## Architecture |
| 82 | + |
| 83 | +This plugin is a Kotlin port of the VSCode `projspec` extension |
| 84 | +(`vsextension/`). The HTML/CSS/JavaScript that draws the two-pane UI is |
| 85 | +**reused verbatim** from the VSCode webview – the only changes needed for |
| 86 | +JCEF are: |
| 87 | + |
| 88 | +1. `acquireVsCodeApi().postMessage(msg)` → `window.__javaBridge.query(JSON.stringify(msg))` |
| 89 | + (the bridge is a `JBCefJSQuery` registered from Kotlin). |
| 90 | +2. `panel.webview.postMessage(msg)` → `window.__projspecDeliver(msg)` |
| 91 | + (Kotlin calls this via `executeJavaScript` because JCEF does not deliver |
| 92 | + host→frame `message` events the way VSCode does). |
| 93 | +3. A `:root { --vscode-*: … }` block is prepended to the stylesheet so the |
| 94 | + VSCode theme variables map to Darcula-ish colours. |
| 95 | + |
| 96 | +Key type mapping between the two implementations: |
| 97 | + |
| 98 | +| VSCode concept | PyCharm equivalent | |
| 99 | +|-------------------------------|--------------------------------------------------------| |
| 100 | +| `createWebviewPanel` | `JBCefBrowser` (JCEF/Chromium) | |
| 101 | +| `acquireVsCodeApi()` | `JBCefJSQuery` (`window.__javaBridge`) | |
| 102 | +| `panel.webview.postMessage` | `executeJavaScript("window.__projspecDeliver(…)")` | |
| 103 | +| `commands.registerCommand` | Tool-window message dispatch | |
| 104 | +| `showOpenDialog` | `FileChooser.chooseFile` with a folder descriptor | |
| 105 | +| `workspace.openTextDocument` | `FileEditorManager.openFile` + `LocalFileSystem` | |
| 106 | +| `createTerminal` / `sendText` | `TerminalToolWindowManager` (via reflection) | |
| 107 | +| `child_process.spawn` | `GeneralCommandLine` + `CapturingProcessHandler` | |
| 108 | +| `showErrorMessage` | Balloon notification via the `Projspec` group | |
| 109 | + |
| 110 | +### Source layout |
| 111 | + |
| 112 | +``` |
| 113 | +src/main/kotlin/com/projspec/ |
| 114 | + toolwindow/ |
| 115 | + HtmlContent.kt — the full HTML/CSS/JS page (reused verbatim |
| 116 | + from vsextension/src/panel.ts) |
| 117 | + ProjspecToolWindowFactory.kt — registers the tool window |
| 118 | + ProjspecToolWindowPanel.kt — Kotlin side of the JS↔Java bridge, |
| 119 | + mirrors panel.ts's message handlers |
| 120 | + util/ |
| 121 | + ProjspecRunner.kt — all `projspec …` subprocess invocations |
| 122 | + TerminalRunner.kt — `projspec make …` in a terminal tab |
| 123 | + OpenWithHelper.kt — "Open with …" kebab-menu actions |
| 124 | + Notifier.kt — balloon notification helpers |
| 125 | + CliResult.kt — Success/Failure result type |
| 126 | + settings/ |
| 127 | + ProjspecSettings.kt — persistent cliPath setting |
| 128 | + ProjspecSettingsConfigurable.kt — Settings → Tools → Projspec UI |
| 129 | +``` |
| 130 | + |
| 131 | +## License |
| 132 | + |
| 133 | +Apache 2.0 — see [LICENSE](https://github.com/fsspec/projspec/blob/main/LICENSE). |
0 commit comments