Split the Windows script into modules; drop the Arkylx Index pieces
claude-mode.ps1 was 2,407 lines. It is now 153: the help block, parameters, paths, the managed-key list, a loader, and the dispatch. The rest moved, verbatim, into eleven files under lib/ - providers, output, files, core, vault, switch, guards, health, catalogue, commands, menu - dot-sourced into the script's scope in their original order, with the same check as the bash split that every original line landed in exactly one file. Inside a module $PSScriptRoot is lib\, so the one path beside the main script (providers.json) now goes through $script:Here. install.ps1 ships lib\, clearing old modules first. The Windows suite parses every module and install.ps1 (36 checks, all green on Windows PowerShell 5.1); install.ps1 is parsed but never run, since it edits the real profile and User PATH. linux/bootstrap.sh and scripts/build-package.ps1 existed only to build and serve packages for the Arkylx Index. Both installers fetch the repository's own archive, so a push to master is the release; the two scripts, the dist/ ignore and their mentions in the docs are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+35
-13
@@ -46,7 +46,7 @@ Under `~/.claude-mode/`:
|
||||
|
||||
| file | written by | read by |
|
||||
|---|---|---|
|
||||
| `bin/claude-mode`, `bin/lib/*.sh`, `bin/cm-json.py`, `bin/cm-vault.sh`, `bin/claude-key-helper.sh` | the installer | — (Windows: `claude-mode.ps1` at the top, `bin/claude-key-helper.ps1` + `.cmd`) |
|
||||
| `bin/claude-mode`, `bin/lib/*.sh`, `bin/cm-json.py`, `bin/cm-vault.sh`, `bin/claude-key-helper.sh` | the installer | — (Windows: `claude-mode.ps1` and `lib\*.ps1` at the top, `bin\claude-key-helper.ps1` + `.cmd`) |
|
||||
| `providers.json` | the installer, every time | the CLI, the key helper's engine, the widget (via `health.json`) |
|
||||
| `presets/*.json` | the installer seeds them; `preset`, `setup`, the panel edit them | everything |
|
||||
| `state.json` | a switch; `preset rename` of the active preset | the CLI, the key helper, the widget |
|
||||
@@ -66,14 +66,15 @@ anything else), `~/.claude/projects/*/*.jsonl` (Claude Code's transcripts, which
|
||||
## The repository
|
||||
|
||||
```
|
||||
claude-mode.ps1, install.ps1 the Windows build and its installer
|
||||
claude-mode.ps1, lib/*.ps1 the Windows build: settings + dispatch, and its modules
|
||||
install.ps1, profile-snippet.ps1 its installer, and the block it adds to the PowerShell profile
|
||||
bin/ the Windows key helper
|
||||
linux/ the POSIX port: claude-mode (settings + dispatch),
|
||||
lib/*.sh (the rest, one file per concern), cm-json.py,
|
||||
cm-vault.sh, claude-key-helper.sh, install.sh, bootstrap.sh
|
||||
lib/*.sh (its modules), cm-json.py, cm-vault.sh,
|
||||
claude-key-helper.sh, install.sh
|
||||
omarchy/ the bar widget and its installer
|
||||
providers.json, presets/ shared by both builds, byte for byte
|
||||
scripts/ test.sh, bump-version.sh, build-package.ps1
|
||||
scripts/ test.sh, bump-version.sh
|
||||
tests/ static, python, cli and windows suites
|
||||
docs/ this
|
||||
```
|
||||
@@ -100,6 +101,27 @@ code rather than the installed version's.
|
||||
| `setup.sh` | `claude-mode setup` |
|
||||
| `repair.sh` | `claude-mode repair-session` and dismissals |
|
||||
|
||||
### The Windows script's modules
|
||||
|
||||
`claude-mode.ps1` holds the help block, the parameters, the paths and flags and
|
||||
the managed-key list, then dot-sources these from `lib\` beside it, in order, and
|
||||
dispatches. Inside a dot-sourced file `$PSScriptRoot` is `lib\`, so paths beside
|
||||
the main script go through `$script:Here`.
|
||||
|
||||
| `lib/` | what is in it |
|
||||
|---|---|
|
||||
| `providers.ps1` | reading `providers.json`; `Get-Provider`, `Resolve-ProviderId`, `Test-ProviderDoctor` |
|
||||
| `output.ps1` | `Write-Ok`/`Write-Warn2`/`Write-Err2`, mode colours, the banner, `Show-Usage` |
|
||||
| `files.ps1` | JSON read/write (5.1 has no `-AsHashtable`), `Protect-FileAcl` |
|
||||
| `core.ps1` | `state.json`, presets, `Resolve-PresetForProvider` |
|
||||
| `vault.ps1` | the DPAPI vault, `Get-PresetAuth` |
|
||||
| `switch.ps1` | `Set-ClaudeMode`, settings backups, the `apiKeyHelper` command line |
|
||||
| `guards.ps1` | the cost guard, the OpenRouter guardrail check, stale cached model ids, `repair` |
|
||||
| `health.ps1` | `health.json`; persistent environment variables that would override a switch |
|
||||
| `catalogue.ps1` | `Get-ProviderCatalogue`, LM Studio's model list and template check, the doctor model and context checks |
|
||||
| `commands.ps1` | `status`, `presets`, `preset`, `models`, `doctor` |
|
||||
| `menu.ps1` | the interactive menu, its pickers, interactive preset editing, `New-PresetScaffold` |
|
||||
|
||||
## Contracts between the pieces
|
||||
|
||||
These are the interfaces one piece relies on another to keep. Each is pinned by a
|
||||
@@ -142,14 +164,14 @@ test.
|
||||
|---|---|---|
|
||||
| a provider's endpoint, auth template, setup, checks or look | `providers.json` | the same file |
|
||||
| a shipped preset | `presets/*.json` | the same files |
|
||||
| what a switch writes to `settings.json` | `cm-json.py` `cmd_apply`, `BASE_MANAGED` | `Set-ClaudeMode`, `$script:BaseManagedEnvKeys` |
|
||||
| what a switch writes to `settings.json` | `cm-json.py` `cmd_apply`, `BASE_MANAGED` | `lib/switch.ps1` `Set-ClaudeMode`; `$script:BaseManagedEnvKeys` in `claude-mode.ps1` |
|
||||
| a command's arguments | the dispatch at the end of `linux/claude-mode` | the dispatch at the end of `claude-mode.ps1` |
|
||||
| what refuses a switch | `lib/preflight.sh` `cm_preflight` | `Set-ClaudeMode` guards |
|
||||
| how a model list is fetched | `lib/catalogue.sh` `provider_catalogue` + a parser in `cm-json.py` | `Get-ProviderCatalogue` |
|
||||
| a doctor check | `lib/doctor.sh` | `Invoke-Doctor`, `Test-PresetCatalogue`, `Test-OllamaContext` |
|
||||
| setup | `lib/setup.sh` | — |
|
||||
| session detection | `lib/sessions.sh` | — |
|
||||
| session repair | `lib/repair.sh`; `cm-json.py` `cmd_scan_sessions`, `cmd_repair_session` | — |
|
||||
| key storage | `cm-vault.sh` | the DPAPI functions in `claude-mode.ps1` |
|
||||
| what refuses a switch | `linux/lib/preflight.sh` `cm_preflight` | the guards in `Set-ClaudeMode` |
|
||||
| how a model list is fetched | `linux/lib/catalogue.sh` `provider_catalogue` + a parser in `cm-json.py` | `lib/catalogue.ps1` `Get-ProviderCatalogue` |
|
||||
| a doctor check | `linux/lib/doctor.sh` | `lib/commands.ps1` `Invoke-Doctor`, `lib/catalogue.ps1` |
|
||||
| setup | `linux/lib/setup.sh` | — |
|
||||
| session detection | `linux/lib/sessions.sh` | — |
|
||||
| session repair | `linux/lib/repair.sh`; `cm-json.py` `cmd_scan_sessions`, `cmd_repair_session` | — |
|
||||
| key storage | `linux/cm-vault.sh` | `lib/vault.ps1` |
|
||||
| the bar icon and state | `omarchy/smoido.claude-mode/BarWidget.qml` | — |
|
||||
| the panel | `omarchy/smoido.claude-mode/Panel.qml` | — |
|
||||
|
||||
Reference in New Issue
Block a user