@twigpine/openclaude 0.0.0 → 0.32.0
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.
- package/LICENSE +29 -0
- package/README.md +553 -1
- package/bin/heap-limit.mjs +220 -0
- package/bin/import-specifier.mjs +13 -0
- package/bin/import-specifier.test.mjs +13 -0
- package/bin/node-compile-cache.mjs +17 -0
- package/bin/openclaude +140 -0
- package/dist/cli.mjs +11331 -0
- package/dist/sdk.mjs +286447 -0
- package/docs/windows-aliases-and-launchers.md +176 -0
- package/package.json +217 -3
- package/scripts/windows/openclaude-aliases.ps1 +206 -0
- package/src/entrypoints/sdk/coreTypes.generated.ts +2385 -0
- package/src/entrypoints/sdk.d.ts +621 -0
- package/vendor/node-domexception-shim/index.js +3 -0
- package/vendor/node-domexception-shim/package.json +8 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Windows aliases and launchers
|
|
2
|
+
|
|
3
|
+
This page documents optional PowerShell helper functions for launching OpenClaude on Windows after a global npm install.
|
|
4
|
+
|
|
5
|
+
These helpers are designed for the installed package workflow:
|
|
6
|
+
|
|
7
|
+
~~~powershell
|
|
8
|
+
npm install -g @twigpine/openclaude
|
|
9
|
+
~~~
|
|
10
|
+
|
|
11
|
+
The helpers use the installed `openclaude` CLI command. They do not require a source checkout and do not call source-only `bun run scripts/*.ts` entrypoints.
|
|
12
|
+
|
|
13
|
+
## One-time setup
|
|
14
|
+
|
|
15
|
+
Run this once in PowerShell:
|
|
16
|
+
|
|
17
|
+
~~~powershell
|
|
18
|
+
$packageRoot = Join-Path (npm root -g) "@twigpine/openclaude"
|
|
19
|
+
$aliases = Join-Path $packageRoot "scripts\windows\openclaude-aliases.ps1"
|
|
20
|
+
|
|
21
|
+
if (-not (Test-Path $aliases)) {
|
|
22
|
+
throw "Alias script not found at $aliases. Update or reinstall @twigpine/openclaude."
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (-not (Test-Path $PROFILE)) {
|
|
26
|
+
New-Item -ItemType File -Path $PROFILE -Force | Out-Null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$profileLine = ". `"$aliases`""
|
|
30
|
+
|
|
31
|
+
if (-not (Select-String -Path $PROFILE -Pattern ([regex]::Escape($profileLine)) -Quiet)) {
|
|
32
|
+
Add-Content -Path $PROFILE -Value "`n$profileLine"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
. $aliases
|
|
36
|
+
oc-help
|
|
37
|
+
~~~
|
|
38
|
+
|
|
39
|
+
Open a new PowerShell window after setup, or dot-source the profile:
|
|
40
|
+
|
|
41
|
+
~~~powershell
|
|
42
|
+
. $PROFILE
|
|
43
|
+
~~~
|
|
44
|
+
|
|
45
|
+
### Upgrading from `@gitlawb/openclaude`
|
|
46
|
+
|
|
47
|
+
The setup above adds a line to `$PROFILE` that loads the helpers from the
|
|
48
|
+
installed package folder. If you ran it while the package was still named
|
|
49
|
+
`@gitlawb/openclaude`, that line points at a folder that no longer exists once
|
|
50
|
+
you switch packages, and every new PowerShell window reports an error.
|
|
51
|
+
|
|
52
|
+
After installing `@twigpine/openclaude`, remove the old line and run the
|
|
53
|
+
one-time setup again:
|
|
54
|
+
|
|
55
|
+
~~~powershell
|
|
56
|
+
(Get-Content $PROFILE) | Where-Object { $_ -notmatch '@gitlawb[\\/]openclaude' } | Set-Content $PROFILE
|
|
57
|
+
~~~
|
|
58
|
+
|
|
59
|
+
## Daily commands
|
|
60
|
+
|
|
61
|
+
### Launch OpenClaude using the installed CLI
|
|
62
|
+
|
|
63
|
+
~~~powershell
|
|
64
|
+
oc
|
|
65
|
+
~~~
|
|
66
|
+
|
|
67
|
+
You can pass normal CLI arguments through `oc`:
|
|
68
|
+
|
|
69
|
+
~~~powershell
|
|
70
|
+
oc --version
|
|
71
|
+
oc --help
|
|
72
|
+
~~~
|
|
73
|
+
|
|
74
|
+
### Launch with local Ollama/OpenAI-compatible environment hints
|
|
75
|
+
|
|
76
|
+
~~~powershell
|
|
77
|
+
oc-local
|
|
78
|
+
~~~
|
|
79
|
+
|
|
80
|
+
By default, this uses local Ollama through the OpenAI-compatible API:
|
|
81
|
+
|
|
82
|
+
~~~text
|
|
83
|
+
CLAUDE_CODE_USE_OPENAI=1
|
|
84
|
+
OPENAI_BASE_URL=http://localhost:11434/v1
|
|
85
|
+
OPENAI_MODEL=llama3.1:8b
|
|
86
|
+
~~~
|
|
87
|
+
|
|
88
|
+
To use a different local model for that invocation:
|
|
89
|
+
|
|
90
|
+
~~~powershell
|
|
91
|
+
oc-local -Model "qwen2.5-coder:7b"
|
|
92
|
+
~~~
|
|
93
|
+
|
|
94
|
+
The environment overrides are scoped to that single `openclaude` invocation. A later plain `oc` call returns to normal installed CLI behavior and saved-provider-profile behavior.
|
|
95
|
+
|
|
96
|
+
### Launch with low-latency local defaults
|
|
97
|
+
|
|
98
|
+
~~~powershell
|
|
99
|
+
oc-fast
|
|
100
|
+
~~~
|
|
101
|
+
|
|
102
|
+
To use a different model:
|
|
103
|
+
|
|
104
|
+
~~~powershell
|
|
105
|
+
oc-fast -Model "qwen2.5-coder:7b"
|
|
106
|
+
~~~
|
|
107
|
+
|
|
108
|
+
Like `oc-local`, the environment overrides are scoped to that single invocation.
|
|
109
|
+
|
|
110
|
+
### Open the provider manager
|
|
111
|
+
|
|
112
|
+
~~~powershell
|
|
113
|
+
oc-provider
|
|
114
|
+
~~~
|
|
115
|
+
|
|
116
|
+
This opens the provider manager through the installed OpenClaude CLI.
|
|
117
|
+
|
|
118
|
+
### Check local Ollama state
|
|
119
|
+
|
|
120
|
+
~~~powershell
|
|
121
|
+
oc-check
|
|
122
|
+
~~~
|
|
123
|
+
|
|
124
|
+
To check a specific model:
|
|
125
|
+
|
|
126
|
+
~~~powershell
|
|
127
|
+
oc-check -Model "qwen2.5-coder:7b"
|
|
128
|
+
~~~
|
|
129
|
+
|
|
130
|
+
### Pull/check a local model, then launch local mode
|
|
131
|
+
|
|
132
|
+
~~~powershell
|
|
133
|
+
oc-init
|
|
134
|
+
~~~
|
|
135
|
+
|
|
136
|
+
To choose a model:
|
|
137
|
+
|
|
138
|
+
~~~powershell
|
|
139
|
+
oc-init -Model "qwen2.5-coder:7b"
|
|
140
|
+
~~~
|
|
141
|
+
|
|
142
|
+
To skip pulling the model and only check/launch:
|
|
143
|
+
|
|
144
|
+
~~~powershell
|
|
145
|
+
oc-init -Model "qwen2.5-coder:7b" -SkipModelPull
|
|
146
|
+
~~~
|
|
147
|
+
|
|
148
|
+
`oc-init` does not save a provider profile. It pulls/checks the local Ollama model and then launches `oc-local`.
|
|
149
|
+
|
|
150
|
+
### Show quick help
|
|
151
|
+
|
|
152
|
+
~~~powershell
|
|
153
|
+
oc-help
|
|
154
|
+
~~~
|
|
155
|
+
|
|
156
|
+
## Command summary
|
|
157
|
+
|
|
158
|
+
| Command | Purpose |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| `oc` | Launch OpenClaude using the installed CLI and saved/default behavior |
|
|
161
|
+
| `oc-local` | Launch once with local Ollama/OpenAI-compatible environment hints |
|
|
162
|
+
| `oc-fast` | Launch once with local Ollama/OpenAI-compatible low-latency hints |
|
|
163
|
+
| `oc-provider` | Open the provider manager |
|
|
164
|
+
| `oc-check` | Show local Ollama install/listening/model state |
|
|
165
|
+
| `oc-init` | Pull/check a local Ollama model, then launch local mode |
|
|
166
|
+
| `oc-help` | Show quick command help |
|
|
167
|
+
|
|
168
|
+
## Notes
|
|
169
|
+
|
|
170
|
+
These helpers are intentionally global-install oriented. They use the installed CLI instead of source-checkout development scripts.
|
|
171
|
+
|
|
172
|
+
For advanced provider setup, use the built-in provider manager:
|
|
173
|
+
|
|
174
|
+
~~~powershell
|
|
175
|
+
oc-provider
|
|
176
|
+
~~~
|
package/package.json
CHANGED
|
@@ -1,7 +1,221 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twigpine/openclaude",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.32.0",
|
|
4
|
+
"description": "OpenClaude opens coding-agent workflows to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"openclaude": "./bin/openclaude"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
"./dist/cli.mjs": "./dist/cli.mjs",
|
|
12
|
+
"./sdk": {
|
|
13
|
+
"types": "./src/entrypoints/sdk.d.ts",
|
|
14
|
+
"import": "./dist/sdk.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/",
|
|
19
|
+
"dist/cli.mjs",
|
|
20
|
+
"dist/sdk.mjs",
|
|
21
|
+
"src/entrypoints/sdk.d.ts",
|
|
22
|
+
"src/entrypoints/sdk/coreTypes.generated.ts",
|
|
23
|
+
"scripts/windows/openclaude-aliases.ps1",
|
|
24
|
+
"vendor/node-domexception-shim/",
|
|
25
|
+
"docs/windows-aliases-and-launchers.md",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bun run scripts/build.ts",
|
|
30
|
+
"benchmark:startup": "node scripts/benchmark-openclaude-startup.mjs",
|
|
31
|
+
"integrations:generate": "bun run scripts/generate-integrations-artifacts.ts",
|
|
32
|
+
"integrations:check": "bun run scripts/generate-integrations-artifacts.ts --check",
|
|
33
|
+
"dev": "bun run build && node bin/openclaude",
|
|
34
|
+
"dev:profile": "bun run scripts/provider-launch.ts",
|
|
35
|
+
"dev:profile:fast": "bun run scripts/provider-launch.ts auto --fast --bare",
|
|
36
|
+
"dev:codex": "bun run scripts/provider-launch.ts codex",
|
|
37
|
+
"dev:openai": "bun run scripts/provider-launch.ts openai",
|
|
38
|
+
"dev:gemini": "bun run scripts/provider-launch.ts gemini",
|
|
39
|
+
"dev:ollama": "bun run scripts/provider-launch.ts ollama",
|
|
40
|
+
"dev:ollama:fast": "bun run scripts/provider-launch.ts ollama --fast --bare",
|
|
41
|
+
"dev:atomic-chat": "bun run scripts/provider-launch.ts atomic-chat",
|
|
42
|
+
"profile:init": "bun run scripts/provider-bootstrap.ts",
|
|
43
|
+
"profile:recommend": "bun run scripts/provider-recommend.ts",
|
|
44
|
+
"profile:auto": "bun run scripts/provider-recommend.ts --apply",
|
|
45
|
+
"profile:codex": "bun run profile:init -- --provider codex --model codexplan",
|
|
46
|
+
"profile:fast": "bun run profile:init -- --provider ollama --model llama3.2:3b",
|
|
47
|
+
"profile:code": "bun run profile:init -- --provider ollama --model qwen2.5-coder:7b",
|
|
48
|
+
"dev:fast": "bun run profile:fast && bun run dev:ollama:fast",
|
|
49
|
+
"dev:code": "bun run profile:code && bun run dev:profile",
|
|
50
|
+
"dev:grpc": "bun run scripts/start-grpc.ts",
|
|
51
|
+
"dev:grpc:cli": "bun run scripts/grpc-cli.ts",
|
|
52
|
+
"start": "node bin/openclaude",
|
|
53
|
+
"web:dev": "bun run --cwd web dev",
|
|
54
|
+
"web:build": "bun run --cwd web build",
|
|
55
|
+
"web:preview": "bun run --cwd web preview",
|
|
56
|
+
"web:typecheck": "bun run --cwd web typecheck",
|
|
57
|
+
"test": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1",
|
|
58
|
+
"test:full": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 && bun run test:conversation-arc",
|
|
59
|
+
"test:conversation-arc": "bun test --feature=CONVERSATION_ARC --feature=MULTI_TURN_CONTEXT --max-concurrency=1 src/query.conversationArc.test.ts",
|
|
60
|
+
"test:coverage": "bun test --feature=UNATTENDED_RETRY --coverage --coverage-reporter=lcov --coverage-dir=coverage --max-concurrency=1 && bun run scripts/render-coverage-heatmap.ts",
|
|
61
|
+
"test:coverage:ui": "bun run scripts/render-coverage-heatmap.ts",
|
|
62
|
+
"security:pr-scan": "bun run scripts/pr-intent-scan.ts",
|
|
63
|
+
"test:provider-recommendation": "bun test src/utils/providerRecommendation.test.ts src/utils/providerProfile.test.ts",
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"typecheck:type-tests": "bun run scripts/typecheck-type-tests.ts",
|
|
66
|
+
"smoke": "bun run build && node dist/cli.mjs --version",
|
|
67
|
+
"deadcode": "knip --include files,dependencies",
|
|
68
|
+
"lint": "eslint .",
|
|
69
|
+
"lint:any-budget": "bun run scripts/any-usage-report.ts --check",
|
|
70
|
+
"check": "bun run lint:any-budget && bun run smoke && bun run deadcode && bun run test:full",
|
|
71
|
+
"check:strict": "bun run typecheck && bun run lint && bun run lint:any-budget && bun run smoke && bun run deadcode && bun run test:full",
|
|
72
|
+
"verify:privacy": "bun run scripts/verify-no-phone-home.ts",
|
|
73
|
+
"install:verify": "bun run scripts/verify-clean-install.ts",
|
|
74
|
+
"install:verify:published": "bun run scripts/verify-clean-install.ts --published",
|
|
75
|
+
"build:verified": "bun run build && bun run verify:privacy",
|
|
76
|
+
"test:provider": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 src/services/api/*.test.ts src/services/api/openaiShim/*.test.ts src/utils/context.test.ts",
|
|
77
|
+
"doctor:runtime": "bun run scripts/system-check.ts",
|
|
78
|
+
"doctor:runtime:json": "bun run scripts/system-check.ts --json",
|
|
79
|
+
"doctor:report": "bun run scripts/system-check.ts --out reports/doctor-runtime.json",
|
|
80
|
+
"hardening:check": "bun run smoke && bun run doctor:runtime",
|
|
81
|
+
"hardening:strict": "bun run typecheck && bun run hardening:check",
|
|
82
|
+
"prepack": "npm run build"
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"@orama/orama": "3.1.18",
|
|
86
|
+
"@orama/plugin-data-persistence": "3.1.18",
|
|
87
|
+
"@vscode/ripgrep": "1.18.0"
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@alcalzone/ansi-tokenize": "0.3.0",
|
|
91
|
+
"@anthropic-ai/bedrock-sdk": "0.29.1",
|
|
92
|
+
"@anthropic-ai/foundry-sdk": "0.2.3",
|
|
93
|
+
"@anthropic-ai/sandbox-runtime": "0.0.55",
|
|
94
|
+
"@anthropic-ai/sdk": "0.94.0",
|
|
95
|
+
"@aws-sdk/client-bedrock": "3.1047.0",
|
|
96
|
+
"@aws-sdk/client-sts": "3.1047.0",
|
|
97
|
+
"@aws-sdk/credential-provider-node": "3.972.41",
|
|
98
|
+
"@azure/identity": "^4.13.1",
|
|
99
|
+
"@commander-js/extra-typings": "12.1.0",
|
|
100
|
+
"@grpc/grpc-js": "^1.14.3",
|
|
101
|
+
"@grpc/proto-loader": "^0.8.0",
|
|
102
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
103
|
+
"@sentry/node": "^10.70.0",
|
|
104
|
+
"@smithy/core": "3.24.3",
|
|
105
|
+
"@smithy/node-http-handler": "4.7.3",
|
|
106
|
+
"@types/bun": "1.3.11",
|
|
107
|
+
"@types/node": "25.5.0",
|
|
108
|
+
"@types/react": "19.2.14",
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
110
|
+
"@typescript-eslint/parser": "^8.69.0",
|
|
111
|
+
"ajv": "8.18.0",
|
|
112
|
+
"auto-bind": "5.0.1",
|
|
113
|
+
"axios": "1.16.0",
|
|
114
|
+
"bidi-js": "1.0.3",
|
|
115
|
+
"chalk": "5.6.2",
|
|
116
|
+
"chokidar": "4.0.3",
|
|
117
|
+
"cli-boxes": "3.0.0",
|
|
118
|
+
"cli-highlight": "2.1.11",
|
|
119
|
+
"commander": "12.1.0",
|
|
120
|
+
"cross-spawn": "7.0.6",
|
|
121
|
+
"diff": "8.0.3",
|
|
122
|
+
"duck-duck-scrape": "^2.2.7",
|
|
123
|
+
"emoji-regex": "10.6.0",
|
|
124
|
+
"env-paths": "3.0.0",
|
|
125
|
+
"eslint": "9.39.5",
|
|
126
|
+
"execa": "9.6.1",
|
|
127
|
+
"fflate": "0.8.2",
|
|
128
|
+
"figures": "6.1.0",
|
|
129
|
+
"fuse.js": "7.1.0",
|
|
130
|
+
"get-east-asian-width": "1.5.0",
|
|
131
|
+
"google-auth-library": "10.6.2",
|
|
132
|
+
"graphology": "0.26.0",
|
|
133
|
+
"graphology-metrics": "2.4.0",
|
|
134
|
+
"https-proxy-agent": "7.0.6",
|
|
135
|
+
"ignore": "7.0.5",
|
|
136
|
+
"indent-string": "5.0.0",
|
|
137
|
+
"js-tiktoken": "1.0.21",
|
|
138
|
+
"jsonc-parser": "3.3.1",
|
|
139
|
+
"knip": "^6.16.1",
|
|
140
|
+
"lodash-es": "4.18.1",
|
|
141
|
+
"lru-cache": "11.2.7",
|
|
142
|
+
"marked": "15.0.12",
|
|
143
|
+
"p-map": "7.0.4",
|
|
144
|
+
"picomatch": "4.0.4",
|
|
145
|
+
"proper-lockfile": "4.1.2",
|
|
146
|
+
"qrcode": "1.5.4",
|
|
147
|
+
"react": "19.2.4",
|
|
148
|
+
"react-compiler-runtime": "1.0.0",
|
|
149
|
+
"react-reconciler": "0.33.0",
|
|
150
|
+
"semver": "7.7.4",
|
|
151
|
+
"sharp": "^0.34.5",
|
|
152
|
+
"shell-quote": "1.8.4",
|
|
153
|
+
"signal-exit": "4.1.0",
|
|
154
|
+
"supports-hyperlinks": "3.2.0",
|
|
155
|
+
"tree-kill": "1.2.2",
|
|
156
|
+
"tree-sitter-wasms": "0.1.13",
|
|
157
|
+
"turndown": "7.2.2",
|
|
158
|
+
"type-fest": "4.41.0",
|
|
159
|
+
"typescript": "5.9.3",
|
|
160
|
+
"undici": "7.28.0",
|
|
161
|
+
"usehooks-ts": "3.1.1",
|
|
162
|
+
"vscode-languageserver-protocol": "3.17.5",
|
|
163
|
+
"web-tree-sitter": "0.25.10",
|
|
164
|
+
"wrap-ansi": "9.0.2",
|
|
165
|
+
"ws": "8.21.0",
|
|
166
|
+
"xss": "1.0.15",
|
|
167
|
+
"yaml": "2.8.3",
|
|
168
|
+
"zod": "3.25.76"
|
|
169
|
+
},
|
|
170
|
+
"peerDependencies": {
|
|
171
|
+
"@anthropic-ai/sdk": "^0.94.0",
|
|
172
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
173
|
+
"react": "^19.0.0",
|
|
174
|
+
"react-reconciler": "^0.33.0"
|
|
175
|
+
},
|
|
176
|
+
"peerDependenciesMeta": {
|
|
177
|
+
"@anthropic-ai/sdk": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"@modelcontextprotocol/sdk": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
183
|
+
"react": {
|
|
184
|
+
"optional": true
|
|
185
|
+
},
|
|
186
|
+
"react-reconciler": {
|
|
187
|
+
"optional": true
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"engines": {
|
|
191
|
+
"node": ">=22.0.0"
|
|
192
|
+
},
|
|
193
|
+
"repository": {
|
|
194
|
+
"type": "git",
|
|
195
|
+
"url": "https://github.com/Twigpine/openclaude.git"
|
|
196
|
+
},
|
|
197
|
+
"keywords": [
|
|
198
|
+
"claude-code",
|
|
199
|
+
"openai",
|
|
200
|
+
"llm",
|
|
201
|
+
"cli",
|
|
202
|
+
"agent",
|
|
203
|
+
"deepseek",
|
|
204
|
+
"ollama",
|
|
205
|
+
"gemini"
|
|
206
|
+
],
|
|
5
207
|
"license": "SEE LICENSE FILE",
|
|
6
|
-
"
|
|
208
|
+
"publishConfig": {
|
|
209
|
+
"access": "public"
|
|
210
|
+
},
|
|
211
|
+
"overrides": {
|
|
212
|
+
"ip-address": "10.2.0",
|
|
213
|
+
"google-auth-library": "10.6.2",
|
|
214
|
+
"lodash-es": "4.18.1",
|
|
215
|
+
"node-domexception": "file:vendor/node-domexception-shim"
|
|
216
|
+
},
|
|
217
|
+
"allowScripts": {
|
|
218
|
+
"protobufjs@7.6.4": true,
|
|
219
|
+
"sharp@0.34.5": true
|
|
220
|
+
}
|
|
7
221
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Set-StrictMode -Version Latest
|
|
2
|
+
|
|
3
|
+
function Test-OpenClaudeCommand {
|
|
4
|
+
[CmdletBinding()]
|
|
5
|
+
param(
|
|
6
|
+
[Parameter(Mandatory = $true)]
|
|
7
|
+
[string]$Name
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
return [bool](Get-Command -Name $Name -ErrorAction SilentlyContinue)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function Assert-OpenClaudeCommand {
|
|
14
|
+
[CmdletBinding()]
|
|
15
|
+
param(
|
|
16
|
+
[Parameter(Mandatory = $true)]
|
|
17
|
+
[string]$Name,
|
|
18
|
+
[Parameter(Mandatory = $true)]
|
|
19
|
+
[string]$InstallHint
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
if (-not (Test-OpenClaudeCommand -Name $Name)) {
|
|
23
|
+
throw "Required command '$Name' was not found. $InstallHint"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Invoke-OpenClaude {
|
|
28
|
+
[CmdletBinding()]
|
|
29
|
+
param(
|
|
30
|
+
[Parameter(ValueFromRemainingArguments = $true)]
|
|
31
|
+
[string[]]$OpenClaudeArgs
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
Assert-OpenClaudeCommand -Name "openclaude" -InstallHint "Install with: npm install -g @twigpine/openclaude"
|
|
35
|
+
|
|
36
|
+
& openclaude @OpenClaudeArgs
|
|
37
|
+
|
|
38
|
+
if ($LASTEXITCODE -ne 0) {
|
|
39
|
+
throw "openclaude failed with exit code $LASTEXITCODE."
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Invoke-OpenClaudeWithEnvironment {
|
|
44
|
+
[CmdletBinding()]
|
|
45
|
+
param(
|
|
46
|
+
[Parameter(Mandatory = $true)]
|
|
47
|
+
[hashtable]$Environment,
|
|
48
|
+
[Parameter(ValueFromRemainingArguments = $true)]
|
|
49
|
+
[string[]]$OpenClaudeArgs
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
$previousValues = @{}
|
|
53
|
+
|
|
54
|
+
foreach ($name in $Environment.Keys) {
|
|
55
|
+
$previousValues[$name] = [Environment]::GetEnvironmentVariable($name, "Process")
|
|
56
|
+
Set-Item -Path "Env:$name" -Value $Environment[$name]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
Invoke-OpenClaude @OpenClaudeArgs
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
foreach ($name in $Environment.Keys) {
|
|
64
|
+
if ($null -eq $previousValues[$name]) {
|
|
65
|
+
Remove-Item -Path "Env:$name" -ErrorAction SilentlyContinue
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
Set-Item -Path "Env:$name" -Value $previousValues[$name]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function Get-OpenClaudeQuickHelp {
|
|
75
|
+
[CmdletBinding()]
|
|
76
|
+
param()
|
|
77
|
+
|
|
78
|
+
@(
|
|
79
|
+
"OpenClaude quick commands:",
|
|
80
|
+
" oc [args...] -> launch OpenClaude using the installed CLI",
|
|
81
|
+
" oc-local [args...] -> launch OpenClaude with local/Ollama OpenAI-compatible environment hints for this invocation only",
|
|
82
|
+
" oc-fast [args...] -> launch OpenClaude with low-latency local defaults for this invocation only",
|
|
83
|
+
" oc-provider -> open the provider manager in OpenClaude",
|
|
84
|
+
" oc-check -> show Ollama install/listening/model state",
|
|
85
|
+
" oc-init -> pull/check the local model, then launch local/Ollama mode",
|
|
86
|
+
" oc-help -> show this help"
|
|
87
|
+
) -join [Environment]::NewLine
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function oc {
|
|
91
|
+
[CmdletBinding()]
|
|
92
|
+
param(
|
|
93
|
+
[Parameter(ValueFromRemainingArguments = $true)]
|
|
94
|
+
[string[]]$OpenClaudeArgs
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
Invoke-OpenClaude @OpenClaudeArgs
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function oc-local {
|
|
101
|
+
[CmdletBinding()]
|
|
102
|
+
param(
|
|
103
|
+
[string]$Model = "llama3.1:8b",
|
|
104
|
+
[Parameter(ValueFromRemainingArguments = $true)]
|
|
105
|
+
[string[]]$OpenClaudeArgs
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
Invoke-OpenClaudeWithEnvironment `
|
|
109
|
+
-Environment @{
|
|
110
|
+
CLAUDE_CODE_USE_OPENAI = "1"
|
|
111
|
+
OPENAI_BASE_URL = "http://localhost:11434/v1"
|
|
112
|
+
OPENAI_MODEL = $Model
|
|
113
|
+
} `
|
|
114
|
+
@OpenClaudeArgs
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function oc-fast {
|
|
118
|
+
[CmdletBinding()]
|
|
119
|
+
param(
|
|
120
|
+
[string]$Model = "llama3.1:8b",
|
|
121
|
+
[Parameter(ValueFromRemainingArguments = $true)]
|
|
122
|
+
[string[]]$OpenClaudeArgs
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
Invoke-OpenClaudeWithEnvironment `
|
|
126
|
+
-Environment @{
|
|
127
|
+
CLAUDE_CODE_USE_OPENAI = "1"
|
|
128
|
+
OPENAI_BASE_URL = "http://localhost:11434/v1"
|
|
129
|
+
OPENAI_MODEL = $Model
|
|
130
|
+
OPENCLAUDE_FAST_MODE = "1"
|
|
131
|
+
} `
|
|
132
|
+
@OpenClaudeArgs
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function oc-provider {
|
|
136
|
+
[CmdletBinding()]
|
|
137
|
+
param()
|
|
138
|
+
|
|
139
|
+
Invoke-OpenClaude "/provider"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function oc-check {
|
|
143
|
+
[CmdletBinding()]
|
|
144
|
+
param(
|
|
145
|
+
[string]$Model = "llama3.1:8b"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
Assert-OpenClaudeCommand -Name "ollama" -InstallHint "Install Ollama from https://ollama.com/download/windows."
|
|
149
|
+
|
|
150
|
+
$version = & ollama --version 2>$null
|
|
151
|
+
$modelNames = (& ollama list 2>$null | Select-Object -Skip 1 | ForEach-Object {
|
|
152
|
+
($_ -split "\s+")[0]
|
|
153
|
+
}) | Where-Object { $_ }
|
|
154
|
+
|
|
155
|
+
$isModelAvailable = $modelNames -contains $Model
|
|
156
|
+
$probeSucceeded = $false
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
$response = Invoke-RestMethod -Uri "http://localhost:11434/api/tags" -Method Get -TimeoutSec 3
|
|
160
|
+
if ($response.models) {
|
|
161
|
+
$probeSucceeded = $true
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
$probeSucceeded = $false
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
[PSCustomObject]@{
|
|
169
|
+
OllamaInstalled = $true
|
|
170
|
+
OllamaVersion = $version
|
|
171
|
+
OllamaListening = $probeSucceeded
|
|
172
|
+
Model = $Model
|
|
173
|
+
ModelAvailable = $isModelAvailable
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function oc-init {
|
|
178
|
+
[CmdletBinding()]
|
|
179
|
+
param(
|
|
180
|
+
[string]$Model = "llama3.1:8b",
|
|
181
|
+
[switch]$SkipModelPull
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
Assert-OpenClaudeCommand -Name "ollama" -InstallHint "Install Ollama from https://ollama.com/download/windows."
|
|
185
|
+
|
|
186
|
+
if (-not $SkipModelPull) {
|
|
187
|
+
& ollama pull $Model
|
|
188
|
+
if ($LASTEXITCODE -ne 0) {
|
|
189
|
+
throw "ollama pull $Model failed with exit code $LASTEXITCODE."
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
$health = oc-check -Model $Model
|
|
194
|
+
if (-not $health.OllamaListening) {
|
|
195
|
+
Write-Warning "Ollama is installed but API probe to localhost:11434 did not succeed. Start Ollama and retry."
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
oc-local -Model $Model
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function oc-help {
|
|
202
|
+
[CmdletBinding()]
|
|
203
|
+
param()
|
|
204
|
+
|
|
205
|
+
Get-OpenClaudeQuickHelp
|
|
206
|
+
}
|