@ekravo/cli 0.0.0-stage → 0.1.107
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 +203 -0
- package/README.md +649 -2
- package/UpdateCLI.md +147 -0
- package/bin/ekravo.js +19 -0
- package/package.json +150 -4
- package/scripts/copy-resources.js +109 -0
- package/scripts/patch-pi-ai-oauth.js +101 -0
- package/scripts/postinstall.js +237 -0
- package/scripts/set-version.js +31 -0
package/UpdateCLI.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Updating and releasing the Ekravo CLI
|
|
2
|
+
|
|
3
|
+
Read this file before updating or publishing the CLI. Verify current source, tags,
|
|
4
|
+
and release state rather than assuming the versions or paths from an old chat.
|
|
5
|
+
Native release archives also include this guide at `share/ekravo/UpdateCLI.md`.
|
|
6
|
+
|
|
7
|
+
## Find the correct repository
|
|
8
|
+
|
|
9
|
+
The CLI repository is `https://github.com/EOSKILLZ/ACHECLI`, with default branch
|
|
10
|
+
`master`. Confirm with `git remote -v` and `gh repo view`. The website and the
|
|
11
|
+
desktop app are separate repositories. A CLI directory inside a workspace can be
|
|
12
|
+
a snapshot; do not publish it as the CLI repository.
|
|
13
|
+
|
|
14
|
+
Read `AGENTS.md` and applicable release/testing guidance. Use Corepack with the
|
|
15
|
+
`packageManager` version in `package.json`; this repository uses pnpm, not npm.
|
|
16
|
+
Never include unrelated working-tree changes or publish credentials.
|
|
17
|
+
|
|
18
|
+
## Prepare a release
|
|
19
|
+
|
|
20
|
+
1. Fetch `origin` and tags. Inspect `gh release list --repo EOSKILLZ/ACHECLI` and
|
|
21
|
+
the current package version. Pick a new, unused stable version.
|
|
22
|
+
2. Add regression tests for behavior changes. Update the package version with
|
|
23
|
+
`node scripts/set-version.js v<VERSION>`. Review the complete diff.
|
|
24
|
+
3. Run `pnpm run verify`: lint, typecheck, native binary build, unit tests, and
|
|
25
|
+
smoke tests. Run the shared-fixture terminal tests for visible CLI changes.
|
|
26
|
+
Resolve failures; do not disable checks. On Windows, use LF source files so
|
|
27
|
+
checkout CRLF conversion does not produce Biome formatting failures.
|
|
28
|
+
4. Push the feature branch, open a PR, and merge the reviewed change into
|
|
29
|
+
`master`. Do not tag an unrelated commit or overwrite a published tag.
|
|
30
|
+
5. Tag the exact merged commit `v<VERSION>` and push the tag. The workflow
|
|
31
|
+
`.github/workflows/release.yml` validates, builds five platforms, packages,
|
|
32
|
+
smoke-tests, and publishes a stable GitHub release. Wait for completion;
|
|
33
|
+
a pushed tag alone is not a completed release.
|
|
34
|
+
|
|
35
|
+
## When GitHub Actions is unavailable
|
|
36
|
+
|
|
37
|
+
GitHub Actions previously failed with `startup_failure` when account minutes
|
|
38
|
+
were exhausted. Inspect the run before assuming code is broken. Do not keep
|
|
39
|
+
retrying an unchanged billing failure.
|
|
40
|
+
|
|
41
|
+
Use the repository build/package scripts on available build hosts. Each build
|
|
42
|
+
replaces `dist`, so package or stage it before building the next target:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
node scripts/build-binary.js --target <TARGET>
|
|
46
|
+
node scripts/package-release-asset.js --os <OS> --arch <ARCH> --outDir <STAGING>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
| TARGET | OS | ARCH | Required archive |
|
|
50
|
+
| --- | --- | --- | --- |
|
|
51
|
+
| windows-x64 | windows | amd64 | ekravo_windows_amd64.zip |
|
|
52
|
+
| linux-x64 | linux | amd64 | ekravo_linux_amd64.tar.gz |
|
|
53
|
+
| linux-arm64 | linux | arm64 | ekravo_linux_arm64.tar.gz |
|
|
54
|
+
| darwin-x64 | darwin | amd64 | ekravo_darwin_amd64.tar.gz |
|
|
55
|
+
| darwin-arm64 | darwin | arm64 | ekravo_darwin_arm64.tar.gz |
|
|
56
|
+
|
|
57
|
+
Use native platform build/validation where possible, especially macOS signing
|
|
58
|
+
and native clipboard dependencies. Cross-compiling is not proof of runtime
|
|
59
|
+
compatibility. Never relabel an old binary as a new version.
|
|
60
|
+
|
|
61
|
+
Cross-built Bun macOS executables can contain an invalid code-page digest after
|
|
62
|
+
the embedded payload is written. Repair their ad-hoc signatures before packaging
|
|
63
|
+
using native `codesign` or a verified portable signer, and verify the signed code
|
|
64
|
+
pages. Native macOS runtime testing remains separate from digest verification.
|
|
65
|
+
|
|
66
|
+
Create a **draft** release, upload all archives, `scripts/install.ps1`,
|
|
67
|
+
`scripts/install.sh`, and `checksums.txt`. The checksum file uses SHA-256 in
|
|
68
|
+
standard `HASH FILENAME` format for all five archives. Verify archive layout
|
|
69
|
+
(`bin/` and `share/ekravo/`), versions, bundled proxy-helper architecture, checksums,
|
|
70
|
+
and installer/update behavior before publishing the draft as the latest stable
|
|
71
|
+
release. Document any platform validation limitations in the release notes.
|
|
72
|
+
Do not expose a partial release to auto-updaters.
|
|
73
|
+
|
|
74
|
+
## Verify users can download the release
|
|
75
|
+
|
|
76
|
+
The private GitHub repository is exposed to users through the website mirror:
|
|
77
|
+
|
|
78
|
+
- Metadata: `https://ekravo.com/cli-releases/api/repos/EOSKILLZ/ACHECLI/releases/latest`
|
|
79
|
+
- Assets: `https://ekravo.com/cli-releases/dl/EOSKILLZ/ACHECLI/releases/download/<TAG>/<ASSET>`
|
|
80
|
+
- Windows installer: `https://ekravo.com/cli/install.ps1`
|
|
81
|
+
|
|
82
|
+
After publication, verify the mirror returns the new tag and can download an
|
|
83
|
+
archive whose SHA-256 matches the release checksum. Allow for mirror caching.
|
|
84
|
+
Test installation/update in an isolated temporary installation and home, never
|
|
85
|
+
overwrite the developer's installed CLI just to validate a release. An ordinary
|
|
86
|
+
CLI release needs no website deployment if the mirror and installer work.
|
|
87
|
+
|
|
88
|
+
## How existing users update
|
|
89
|
+
|
|
90
|
+
Run `ekravo update` (or `ekravo update --force` for an explicitly requested
|
|
91
|
+
noninteractive update), then `ekravo --version`. Inside Ekravo, `/update` exposes
|
|
92
|
+
the update action and auto-update toggle.
|
|
93
|
+
|
|
94
|
+
Auto-update is **opt-in**, disabled by default. Enabled native installations
|
|
95
|
+
check at interactive startup. On Windows, the running executable is rotated
|
|
96
|
+
and the new version takes effect on the next launch; quit and reopen Ekravo.
|
|
97
|
+
Linux/macOS hand off to the new executable. Update checks can be cached for
|
|
98
|
+
24 hours; explicit `ekravo update` skips the cache. Source runs, Homebrew installs,
|
|
99
|
+
protocol/print modes, `--no-auto-update`, and `EKRAVO_NO_UPDATE_CHECK` skip the
|
|
100
|
+
automatic update path. Never silently change a user's update preference.
|
|
101
|
+
|
|
102
|
+
Windows update validation must also account for install and temporary directories
|
|
103
|
+
on different drives. Older updaters can fail with `EXDEV` when moving an executable
|
|
104
|
+
from `%TEMP%` on C: into a custom installation on D:. Test the default installation
|
|
105
|
+
drive separately. If an existing client hits this error, reinstall with the
|
|
106
|
+
PowerShell installer below using the same `EKRAVO_INSTALL_DIR`; do not treat a
|
|
107
|
+
successful release upload as proof that this older updater can cross volumes.
|
|
108
|
+
|
|
109
|
+
Windows users can also reinstall the latest native build with:
|
|
110
|
+
|
|
111
|
+
```powershell
|
|
112
|
+
irm https://ekravo.com/cli/install.ps1 | iex
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Reasoning regression to preserve
|
|
116
|
+
|
|
117
|
+
Managed Ekravo providers must send `include_reasoning: true` through
|
|
118
|
+
`src/extensions/ekravo-reasoning.ts`, registered in both the main CLI and bot
|
|
119
|
+
worker extension factories. The website API only exposes separate reasoning
|
|
120
|
+
when requested. The pinned SDK maps `reasoning` / `reasoning_content` deltas
|
|
121
|
+
to native thinking blocks. Keep the answer in text blocks; do not turn reasoning
|
|
122
|
+
into normal assistant text or force a model's reasoning effort/budget.
|
|
123
|
+
|
|
124
|
+
Relevant tests: `ekravo-reasoning.test.ts`, agent-runner tests, thinking-steps
|
|
125
|
+
renderer tests, and hide-thinking tests. Report push, merge, tag, assets,
|
|
126
|
+
publication, mirror verification, and remaining limitations accurately.
|
|
127
|
+
|
|
128
|
+
## Image support regression to preserve
|
|
129
|
+
|
|
130
|
+
The website must advertise the stored model vision capability as `input_modalities`
|
|
131
|
+
in `/v1/models`, and the CLI must preserve it in its model registry. Do not infer
|
|
132
|
+
vision support from model names or mark every model as image-capable.
|
|
133
|
+
|
|
134
|
+
The clipboard extension uses the SDK image resizer. Ship `bin/photon_rs_bg.wasm`
|
|
135
|
+
with every platform archive and preserve it through native installers, package
|
|
136
|
+
postinstall, local installation, and self-update. Test image paste without the
|
|
137
|
+
build machine's original Photon WASM file so missing runtime resources are caught.
|
|
138
|
+
The shared-fixture terminal test is `clipboard-image-paste.test.ts`.
|
|
139
|
+
|
|
140
|
+
Also bundle Photon in shared resources: older updaters only copy that directory.
|
|
141
|
+
`src/auxiliary-files/image-runtime.ts` restores the omitted file beside the Ekravo
|
|
142
|
+
executable at startup. Verify a real upgrade from the previous stable release,
|
|
143
|
+
not just a fresh installation with the latest installer.
|
|
144
|
+
|
|
145
|
+
Windows image paste uses **Alt+V**; macOS/Linux use **Ctrl+V**. `/paste-image` is
|
|
146
|
+
the fallback when the terminal intercepts paste shortcuts. Image instructions are
|
|
147
|
+
in `docs/images.md` and bundled at `share/ekravo/images.md`.
|
package/bin/ekravo.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process"
|
|
3
|
+
import { existsSync } from "node:fs"
|
|
4
|
+
import { join, dirname } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
const isWin = process.platform === "win32"
|
|
9
|
+
const binName = isWin ? "ekravo.exe" : "ekravo"
|
|
10
|
+
const binPath = join(__dirname, "..", "dist", "bin", binName)
|
|
11
|
+
|
|
12
|
+
if (!existsSync(binPath)) {
|
|
13
|
+
console.error(`[ekravo] binary not found at ${binPath}`)
|
|
14
|
+
console.error(`[ekravo] run \`node scripts/postinstall.js\` or reinstall @ekravo/cli`)
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" })
|
|
19
|
+
process.exit(result.status ?? (result.error ? 1 : 0))
|
package/package.json
CHANGED
|
@@ -1,6 +1,152 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekravo/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.107",
|
|
4
|
+
"description": "ekravo — a coding agent CLI powered by Cast AI, built on Ekravo",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ekravo": "./bin/ekravo.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"bin/",
|
|
13
|
+
"scripts/postinstall.js",
|
|
14
|
+
"scripts/patch-pi-ai-oauth.js",
|
|
15
|
+
"scripts/copy-resources.js",
|
|
16
|
+
"scripts/set-version.js",
|
|
17
|
+
"README.md",
|
|
18
|
+
"UpdateCLI.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"build": "tsc --noEmit && node scripts/copy-resources.js --dev",
|
|
24
|
+
"build:proxy-helper": "node scripts/build-proxy-helper.js",
|
|
25
|
+
"build:binary": "node scripts/build-binary.js",
|
|
26
|
+
"install:local": "node scripts/install-local.js",
|
|
27
|
+
"build:binary-linux-arm64": "node scripts/build-binary.js --target linux-arm64",
|
|
28
|
+
"build:binary-linux-x64": "node scripts/build-binary.js --target linux-x64",
|
|
29
|
+
"build:binary-windows-x64": "node scripts/build-binary.js --target windows-x64",
|
|
30
|
+
"dev": "make -C tools/proxy-helper/ copy-for-dev && bun run --preload ./src/set-package-dir.ts src/entry.ts",
|
|
31
|
+
"dev:overlay": "scripts/dev-overlay.sh",
|
|
32
|
+
"dev:setup": "bun run --preload ./src/set-package-dir.ts src/entry.ts setup",
|
|
33
|
+
"lint": "biome check src/ scripts/ tests/",
|
|
34
|
+
"lint:fix": "biome check --write src/ scripts/ tests/",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"check": "pnpm run lint && pnpm run typecheck",
|
|
37
|
+
"test": "vitest run --dir src",
|
|
38
|
+
"test:smoke": "vitest run --config tests/smoke/vitest.config.ts",
|
|
39
|
+
"test:e2e:tui": "pnpm run build:binary && node scripts/run-tui-e2e.js",
|
|
40
|
+
"test:e2e:tui:debug": "pnpm run build:binary && node scripts/run-tui-e2e.js --debug",
|
|
41
|
+
"test:e2e:tui:trace": "pnpm run build:binary && node scripts/run-tui-e2e.js --trace",
|
|
42
|
+
"test:e2e:tui:trace:replay": "node scripts/run-tui-e2e.js replay",
|
|
43
|
+
"test:e2e:acp": "pnpm run build:binary && vitest run --config tests/e2e/acp/vitest.config.ts",
|
|
44
|
+
"postinstall": "node scripts/postinstall.js",
|
|
45
|
+
"prepare": "husky",
|
|
46
|
+
"verify": "pnpm run check && pnpm run build:binary && pnpm run test && pnpm run test:smoke"
|
|
47
|
+
},
|
|
48
|
+
"piConfig": {
|
|
49
|
+
"name": "ekravo",
|
|
50
|
+
"configDir": ".config/ekravo/harness"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@agentclientprotocol/sdk": "0.19.2",
|
|
54
|
+
"@bulkhead-ai/core": "^0.7.0",
|
|
55
|
+
"@clack/prompts": "^1.3.0",
|
|
56
|
+
"@earendil-works/pi-coding-agent": "0.84.1",
|
|
57
|
+
"@earendil-works/pi-tui": "0.84.1",
|
|
58
|
+
"@modelcontextprotocol/ext-apps": "^1.7.1",
|
|
59
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
60
|
+
"@shikijs/cli": "^4.0.2",
|
|
61
|
+
"@types/diff": "^8.0.0",
|
|
62
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
63
|
+
"@types/ssh2": "^1.15.5",
|
|
64
|
+
"@xterm/headless": "^6.0.0",
|
|
65
|
+
"diff": "^9.0.0",
|
|
66
|
+
"micromatch": "^4.0.8",
|
|
67
|
+
"open": "^10.2.0",
|
|
68
|
+
"proper-lockfile": "^4.1.2",
|
|
69
|
+
"shell-quote": "1.8.4",
|
|
70
|
+
"shiki": "^4.0.2",
|
|
71
|
+
"ssh2": "^1.17.0",
|
|
72
|
+
"tar": "^7.5.22",
|
|
73
|
+
"undici": "^8.10.0",
|
|
74
|
+
"uuid": "^14.0.0",
|
|
75
|
+
"wcwidth": "^1.0.1",
|
|
76
|
+
"yaml": "^2.8.4",
|
|
77
|
+
"zod": "^4.4.3"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"typebox": "*"
|
|
81
|
+
},
|
|
82
|
+
"optionalDependencies": {
|
|
83
|
+
"@mariozechner/clipboard-darwin-arm64": "0.3.6",
|
|
84
|
+
"@mariozechner/clipboard-darwin-universal": "0.3.6",
|
|
85
|
+
"@mariozechner/clipboard-darwin-x64": "0.3.6",
|
|
86
|
+
"@mariozechner/clipboard-linux-arm64-gnu": "0.3.6",
|
|
87
|
+
"@mariozechner/clipboard-linux-arm64-musl": "0.3.6",
|
|
88
|
+
"@mariozechner/clipboard-linux-x64-gnu": "0.3.6",
|
|
89
|
+
"@mariozechner/clipboard-linux-x64-musl": "0.3.6",
|
|
90
|
+
"@mariozechner/clipboard-win32-arm64-msvc": "0.3.6",
|
|
91
|
+
"@mariozechner/clipboard-win32-x64-msvc": "0.3.6"
|
|
92
|
+
},
|
|
93
|
+
"devDependencies": {
|
|
94
|
+
"@biomejs/biome": "^2.5.3",
|
|
95
|
+
"@earendil-works/pi-ai": "0.84.1",
|
|
96
|
+
"@microsoft/tui-test": "0.0.4",
|
|
97
|
+
"@mixmark-io/domino": "^2.2.0",
|
|
98
|
+
"@types/micromatch": "^4.0.10",
|
|
99
|
+
"@types/node": "^22.19.18",
|
|
100
|
+
"@types/shell-quote": "^1.7.5",
|
|
101
|
+
"@types/tar": "^7.0.87",
|
|
102
|
+
"@types/turndown": "^5.0.6",
|
|
103
|
+
"@types/ws": "^8.18.1",
|
|
104
|
+
"husky": "^9.1.7",
|
|
105
|
+
"node-pty": "^1.1.0",
|
|
106
|
+
"playwright": "1.59.1",
|
|
107
|
+
"supports-color": "^10.2.2",
|
|
108
|
+
"tsx": "^4.21.0",
|
|
109
|
+
"turndown": "^7.2.4",
|
|
110
|
+
"typescript": "^5.9.3",
|
|
111
|
+
"vitest": "^3.2.4",
|
|
112
|
+
"ws": "^8.21.3"
|
|
113
|
+
},
|
|
114
|
+
"engines": {
|
|
115
|
+
"node": ">=22.19.0"
|
|
116
|
+
},
|
|
117
|
+
"packageManager": "pnpm@10.8.1",
|
|
118
|
+
"pnpm": {
|
|
119
|
+
"onlyBuiltDependencies": [
|
|
120
|
+
"@biomejs/biome",
|
|
121
|
+
"esbuild",
|
|
122
|
+
"koffi",
|
|
123
|
+
"node-pty",
|
|
124
|
+
"protobufjs"
|
|
125
|
+
],
|
|
126
|
+
"ignoredOptionalDependencies": [
|
|
127
|
+
"cpu-features",
|
|
128
|
+
"nan"
|
|
129
|
+
],
|
|
130
|
+
"patchedDependencies": {
|
|
131
|
+
"playwright-core@1.59.1": "patches/playwright-core@1.59.1.patch",
|
|
132
|
+
"@earendil-works/pi-ai@0.84.1": "patches/@earendil-works__pi-ai@0.84.1.patch",
|
|
133
|
+
"@earendil-works/pi-tui@0.84.1": "patches/@earendil-works__pi-tui@0.84.1.patch",
|
|
134
|
+
"@earendil-works/pi-coding-agent@0.84.1": "patches/@earendil-works__pi-coding-agent@0.84.1.patch"
|
|
135
|
+
},
|
|
136
|
+
"supportedArchitectures": {
|
|
137
|
+
"os": [
|
|
138
|
+
"current",
|
|
139
|
+
"linux"
|
|
140
|
+
],
|
|
141
|
+
"cpu": [
|
|
142
|
+
"current",
|
|
143
|
+
"x64"
|
|
144
|
+
],
|
|
145
|
+
"libc": [
|
|
146
|
+
"current",
|
|
147
|
+
"glibc",
|
|
148
|
+
"musl"
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copy non-TypeScript resources that tsc doesn't handle.
|
|
2
|
+
//
|
|
3
|
+
// --dev (used by `build`): theme files from node_modules → src/modes/interactive/theme/
|
|
4
|
+
// export-html templates → src/core/export-html/
|
|
5
|
+
// so `bun run src/cli.ts` resolves assets via pi-mono's getters
|
|
6
|
+
// (getThemesDir, getExportTemplateDir) relative to ekravo's project root
|
|
7
|
+
//
|
|
8
|
+
// default (used by `build-binary`): theme files from node_modules → dist/share/ekravo/theme/
|
|
9
|
+
// export-html templates → dist/share/ekravo/export-html/
|
|
10
|
+
// plus package.json → dist/share/ekravo/
|
|
11
|
+
// so the compiled binary resolves assets from the shared data directory
|
|
12
|
+
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs"
|
|
14
|
+
import { createRequire } from "node:module"
|
|
15
|
+
import { platform } from "node:os"
|
|
16
|
+
import { dirname, join } from "node:path"
|
|
17
|
+
import { fileURLToPath } from "node:url"
|
|
18
|
+
|
|
19
|
+
const projectRoot = join(dirname(fileURLToPath(import.meta.url)), "..")
|
|
20
|
+
const piAgentDist = join(projectRoot, "node_modules", "@earendil-works", "pi-coding-agent", "dist")
|
|
21
|
+
|
|
22
|
+
const themeFiles = ["dark.json", "light.json", "theme-schema.json"]
|
|
23
|
+
const themeSrc = join(piAgentDist, "modes", "interactive", "theme")
|
|
24
|
+
|
|
25
|
+
// Skip TypeScript declarations and source maps when staging export-html — only template.{html,css,js}
|
|
26
|
+
// and vendor/*.min.js are read at runtime, so .d.ts/.map files are pure payload bloat.
|
|
27
|
+
const exportHtmlSkipSuffixes = [".d.ts", ".d.ts.map", ".js.map"]
|
|
28
|
+
const exportHtmlSrc = join(piAgentDist, "core", "export-html")
|
|
29
|
+
|
|
30
|
+
const isDev = process.argv.includes("--dev")
|
|
31
|
+
const themeDest = isDev
|
|
32
|
+
? join(projectRoot, "src", "modes", "interactive", "theme")
|
|
33
|
+
: join(projectRoot, "dist", "share", "ekravo", "theme")
|
|
34
|
+
const exportHtmlDest = isDev
|
|
35
|
+
? join(projectRoot, "src", "core", "export-html")
|
|
36
|
+
: join(projectRoot, "dist", "share", "ekravo", "export-html")
|
|
37
|
+
|
|
38
|
+
mkdirSync(themeDest, { recursive: true })
|
|
39
|
+
for (const file of themeFiles) {
|
|
40
|
+
cpSync(join(themeSrc, file), join(themeDest, file))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
cpSync(exportHtmlSrc, exportHtmlDest, {
|
|
44
|
+
recursive: true,
|
|
45
|
+
filter: (src) => !exportHtmlSkipSuffixes.some((suffix) => src.endsWith(suffix)),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Post-process export HTML template to inject the ekravo version number.
|
|
49
|
+
const pkg = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"))
|
|
50
|
+
// Match src/utils.ts getVersion() mapping (0.0.0 → "dev").
|
|
51
|
+
const appVersion = pkg.version && pkg.version !== "0.0.0" ? pkg.version : "dev"
|
|
52
|
+
// Inject a single inline script just before </body> that sets the version
|
|
53
|
+
// and dynamically patches the DOM after renderHeader() has already run.
|
|
54
|
+
// renderHeader() stays upstream code, so this survives template.js refactors.
|
|
55
|
+
const templateHtmlPath = join(exportHtmlDest, "template.html")
|
|
56
|
+
let templateHtml = readFileSync(templateHtmlPath, "utf-8")
|
|
57
|
+
templateHtml = templateHtml.replace(
|
|
58
|
+
"</body>",
|
|
59
|
+
`<script>
|
|
60
|
+
(function() {
|
|
61
|
+
window.__EKRAVO_VERSION = ${JSON.stringify(appVersion)};
|
|
62
|
+
const container = document.querySelector('.header-info');
|
|
63
|
+
if (!container) return;
|
|
64
|
+
const el = document.createElement('div');
|
|
65
|
+
el.className = 'info-item';
|
|
66
|
+
el.innerHTML = '<span class="info-label">Version:</span><span class="info-value">' + window.__EKRAVO_VERSION + '</span>';
|
|
67
|
+
container.appendChild(el);
|
|
68
|
+
})();
|
|
69
|
+
</script>
|
|
70
|
+
</body>`,
|
|
71
|
+
)
|
|
72
|
+
writeFileSync(templateHtmlPath, templateHtml, "utf-8")
|
|
73
|
+
|
|
74
|
+
// ekravo's own themes live outside node_modules — copy them alongside the upstream themes
|
|
75
|
+
const ekravoThemesSrc = join(projectRoot, "themes")
|
|
76
|
+
const ekravoThemeFiles = readdirSync(ekravoThemesSrc).filter((f) => f.endsWith(".json"))
|
|
77
|
+
for (const file of ekravoThemeFiles) {
|
|
78
|
+
cpSync(join(ekravoThemesSrc, file), join(themeDest, file))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!isDev) {
|
|
82
|
+
const resourceRequire = createRequire(import.meta.url)
|
|
83
|
+
const photonEntry = resourceRequire.resolve("@silvia-odwyer/photon-node", { paths: [realpathSync(piAgentDist)] })
|
|
84
|
+
cpSync(join(dirname(photonEntry), "photon_rs_bg.wasm"), join(projectRoot, "dist", "bin", "photon_rs_bg.wasm"))
|
|
85
|
+
cpSync(
|
|
86
|
+
join(dirname(photonEntry), "photon_rs_bg.wasm"),
|
|
87
|
+
join(projectRoot, "dist", "share", "ekravo", "photon_rs_bg.wasm"),
|
|
88
|
+
)
|
|
89
|
+
cpSync(join(projectRoot, "package.json"), join(projectRoot, "dist", "share", "ekravo", "package.json"))
|
|
90
|
+
cpSync(join(projectRoot, "UpdateCLI.md"), join(projectRoot, "dist", "share", "ekravo", "UpdateCLI.md"))
|
|
91
|
+
cpSync(join(projectRoot, "docs", "images.md"), join(projectRoot, "dist", "share", "ekravo", "images.md"))
|
|
92
|
+
|
|
93
|
+
// Copy custom OAuth page templates
|
|
94
|
+
const oauthSrc = join(projectRoot, "resources", "oauth")
|
|
95
|
+
const oauthDest = join(projectRoot, "dist", "share", "ekravo", "oauth")
|
|
96
|
+
mkdirSync(oauthDest, { recursive: true })
|
|
97
|
+
cpSync(oauthSrc, oauthDest, { recursive: true })
|
|
98
|
+
|
|
99
|
+
// Copy proxy-helper binary built by scripts/build-proxy-helper.js.
|
|
100
|
+
const buildTargetOS = process.env.EKRAVO_BUILD_TARGET_OS || platform()
|
|
101
|
+
const proxyHelperName = buildTargetOS === "win32" || buildTargetOS === "windows" ? "proxy-helper.exe" : "proxy-helper"
|
|
102
|
+
const proxyHelperSrc = join(projectRoot, "tools", "proxy-helper", "bin", proxyHelperName)
|
|
103
|
+
const proxyHelperBinDest = join(projectRoot, "dist", "share", "ekravo", "bin")
|
|
104
|
+
if (!existsSync(proxyHelperSrc)) {
|
|
105
|
+
throw new Error(`proxy-helper binary not found: ${proxyHelperSrc}`)
|
|
106
|
+
}
|
|
107
|
+
mkdirSync(proxyHelperBinDest, { recursive: true })
|
|
108
|
+
cpSync(proxyHelperSrc, join(proxyHelperBinDest, proxyHelperName))
|
|
109
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-install patch for @earendil-works/pi-ai OAuth pages.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the hardcoded Pi-branded HTML in pi-ai's oauth-page.js with a
|
|
6
|
+
* renderer that reads Ekravo templates from EKRAVO_OAUTH_TEMPLATE_DIR.
|
|
7
|
+
* The templates themselves live in resources/oauth/ — designers iterate
|
|
8
|
+
* on them without touching node_modules or refreshing this patch.
|
|
9
|
+
*
|
|
10
|
+
* If the env var is missing or the template can't be read, the renderer
|
|
11
|
+
* falls through to a minimal unbranded HTML fallback. We deliberately avoid
|
|
12
|
+
* upstream's Pi-branded fallback (ekravo shipping competitor branding is the
|
|
13
|
+
* exact failure mode this patch exists to eliminate), and we avoid throwing
|
|
14
|
+
* (the token is already saved by the time the renderer is called — blank-
|
|
15
|
+
* paging the user mid-flow is worse UX than a degraded-looking page).
|
|
16
|
+
*
|
|
17
|
+
* Remove when upstream supports configurable OAuth page templates.
|
|
18
|
+
* Tracking: TODO - open upstream issue against pi-mono for OAuth page customization.
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync, writeFileSync } from "node:fs"
|
|
21
|
+
import { join } from "node:path"
|
|
22
|
+
|
|
23
|
+
const target = join(process.cwd(), "node_modules", "@earendil-works", "pi-ai", "dist", "auth", "oauth", "oauth-page.js")
|
|
24
|
+
|
|
25
|
+
const patched = `import { readFileSync } from "node:fs";
|
|
26
|
+
function escapeHtml(value) {
|
|
27
|
+
return value
|
|
28
|
+
.replaceAll("&", "&")
|
|
29
|
+
.replaceAll("<", "<")
|
|
30
|
+
.replaceAll(">", ">")
|
|
31
|
+
.replaceAll('"', """)
|
|
32
|
+
.replaceAll("'", "'");
|
|
33
|
+
}
|
|
34
|
+
function renderPage(options) {
|
|
35
|
+
const templateDir = process.env.EKRAVO_OAUTH_TEMPLATE_DIR;
|
|
36
|
+
if (templateDir) {
|
|
37
|
+
try {
|
|
38
|
+
const filePath = templateDir + "/" + (options.template || "default") + ".html";
|
|
39
|
+
let html = readFileSync(filePath, "utf-8");
|
|
40
|
+
html = html.replaceAll("{{TITLE}}", escapeHtml(options.title || ""));
|
|
41
|
+
html = html.replaceAll("{{HEADING}}", escapeHtml(options.heading || ""));
|
|
42
|
+
html = html.replaceAll("{{MESSAGE}}", escapeHtml(options.message || ""));
|
|
43
|
+
html = html.replaceAll("{{DETAILS}}", options.details ? \`<div class="details">\${escapeHtml(options.details)}</div>\` : "");
|
|
44
|
+
return html;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// fall through to minimal unbranded fallback
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const title = escapeHtml(options.title || "");
|
|
51
|
+
const heading = escapeHtml(options.heading || "");
|
|
52
|
+
const message = escapeHtml(options.message || "");
|
|
53
|
+
const details = options.details ? escapeHtml(options.details) : undefined;
|
|
54
|
+
return \`<!doctype html>
|
|
55
|
+
<html lang="en">
|
|
56
|
+
<head>
|
|
57
|
+
<meta charset="utf-8" />
|
|
58
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
59
|
+
<title>\${title}</title>
|
|
60
|
+
<style>
|
|
61
|
+
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 480px; margin: 48px auto; padding: 24px; line-height: 1.5; color: #111; }
|
|
62
|
+
h1 { font-size: 20px; margin: 0 0 12px; }
|
|
63
|
+
p { margin: 0 0 12px; color: #555; }
|
|
64
|
+
.details { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #f5f5f5; padding: 12px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; }
|
|
65
|
+
</style>
|
|
66
|
+
</head>
|
|
67
|
+
<body>
|
|
68
|
+
<h1>\${heading}</h1>
|
|
69
|
+
<p>\${message}</p>
|
|
70
|
+
\${details ? \`<div class="details">\${details}</div>\` : ""}
|
|
71
|
+
</body>
|
|
72
|
+
</html>\`;
|
|
73
|
+
}
|
|
74
|
+
export function oauthSuccessHtml(message) {
|
|
75
|
+
return renderPage({
|
|
76
|
+
title: "Authentication successful",
|
|
77
|
+
heading: "Authentication successful",
|
|
78
|
+
message,
|
|
79
|
+
template: "success",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function oauthErrorHtml(message, details) {
|
|
83
|
+
return renderPage({
|
|
84
|
+
title: "Authentication failed",
|
|
85
|
+
heading: "Authentication failed",
|
|
86
|
+
message,
|
|
87
|
+
details,
|
|
88
|
+
template: "error",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=oauth-page.js.map
|
|
92
|
+
`
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
if (!existsSync(target)) throw new Error(`Expected upstream file not found: ${target}`)
|
|
96
|
+
writeFileSync(target, patched)
|
|
97
|
+
console.log("[patch-pi-ai-oauth] Patched pi-ai OAuth page templates.")
|
|
98
|
+
} catch (err) {
|
|
99
|
+
console.error("[patch-pi-ai-oauth] Could not patch file:", err instanceof Error ? err.message : String(err))
|
|
100
|
+
process.exit(1)
|
|
101
|
+
}
|