A local-first multi-agent app development platform, built on PenguinHarness
refactor(cli,scripts): 边界面变量的写侧改用 Adelie 的名字(非桌面壳那两处)
lmliheng1ded7a94ceee
diff --git a/FORK-PROGRESS.md b/FORK-PROGRESS.mdindex e4bd584b..a0562f8e 100644--- a/FORK-PROGRESS.md+++ b/FORK-PROGRESS.md@@ -81,14 +81,20 @@`ROOT_ENV` / `LEGACY_ROOT_ENV` 同一规则)。读侧接上的地方:`server` 的 `config.ts`(那五个)、`http/routes/version.ts` 的 `CLI_ENTRY`、`machines/layout.ts` 的 `PROFILE`、CLI 三个命令的`WEB_DB`、core 的 `BUNDLED_SHELL`;`packages/server/README.md` 的环境表与各处注释跟上。- **写侧一个都没改**(理由见下),所以这一条还不能勾掉。+ **写侧一个都没改**(理由见下),所以这一条还不能勾掉 —— 到 2026-10-06 第七轮才把**不是桌面壳+ 写的那两处**改掉(见下一条)。+ - **写侧做了一半(2026-10-06,第七轮)**:**不是桌面壳写的那两处已经改用 Adelie 的名字** ——+ 两个启动脚本 `scripts/launchers/penguin{,.cmd}` 现在导出 `ADELIE_WEB_DIST`(显式的旧名+ `PENGUIN_WEB_DIST` 仍照办:新名 > 旧名 > 本安装的 `web/`,与 `ADELIE_HOME` 同一写法)与+ `ADELIE_BUNDLED_SHELL`;`penguin server|web`(`packages/cli/src/commands/serve.ts`)导出的入口+ 改叫 `ADELIE_CLI_ENTRY`。读侧本来就两个都认,新旧搭配都跑得通(实测见「已完成的轮次」)。- **还差什么(做这一条时要一起收的尾)**:- 1. **写侧**:桌面壳(`packages/desktop/src/{server-process,launcher,web-dist}.ts` 现在仍导出 /- 传 `PENGUIN_PROFILE` / `PENGUIN_CLI_ENTRY` / `PENGUIN_WEB_DIST` / `PENGUIN_DESKTOP_TOKEN` /- `PENGUIN_PORT_FILE` / `PENGUIN_BUNDLED_SHELL`)、两个启动脚本 `scripts/launchers/penguin{,.cmd}`- 的 `PENGUIN_BUNDLED_SHELL`、CLI 的 `penguin server|web` 导出的 `PENGUIN_CLI_ENTRY`、- `machines/commands.ts` 写进远端命令的 `PENGUIN_PROFILE`(远端可能是旧安装,这一处要留旧名- 更久)。桌面壳按纪律本机没碰(3.5 才决定取哪个桌面壳)。+ 1. **写侧剩下的全在桌面壳一侧**:`packages/desktop/src/{server-process,launcher,web-dist}.ts`+ 仍导出 / 传 `PENGUIN_PROFILE` / `PENGUIN_CLI_ENTRY` / `PENGUIN_WEB_DIST` / `PENGUIN_DESKTOP_TOKEN` /+ `PENGUIN_PORT_FILE` / `PENGUIN_BUNDLED_SHELL`(读侧两个都认,所以今天也跑得通)。桌面壳按纪律+ 本机没碰(依赖没装、3.5 才决定取哪个桌面壳),这一批等那一步一起改。+ `machines/commands.ts` 写进远端命令的 `PENGUIN_PROFILE` 也是**有意留着**:远端可能是一台还没+ 升级的安装、只认旧名;等那一步的语义定下来(探测远端版本,或两个都写)再说。2. **本机部署**:`adelie-app.service`(3004,已 stop + disable)仍设 `PENGUIN_HOME` /`PENGUIN_WEB_DIST` / `PENGUIN_CLI_ENTRY`;读侧现在两条都认,所以不改也能跑,要在发布版里换新名得连单元一起改(发布动作)。@@ -694,6 +700,7 @@ v0.2.2」——它只加台账里 v0.2.2 那一节与两行表格,**跟本轮| 2026-10-05 | 第五轮 | 升级 **v0.2.2**:tag + GitHub Release(无资产)+ 重打三件安装包放 3003 `/downloads/v0.2.2/`(`BUILD_COMMIT=2d6abe83`),打包脚本改「边做边清」把峰值从 1.5G 压到 ~0.3G | 见「v0.2.2:默认项目名 default、中文文案、手机上的导入 Trace 与草稿」一节 | tag `v0.2.2` = `2d6abe83` || 2026-10-05 | 2.2b | 控制面环境变量改名:25 个名字 / 77 个文件 / 388 处 `PENGUIN_*` → `ADELIE_*`(会话、API、语言、终端、审批与测试脚手架那批;注释、zh/en 文案、插件技能契约、`docker/compose.yaml` 一起改);`core` 的剥离规则注释补写「为什么仍留两个前缀」 | 六包 typecheck 过;`pnpm lint` 0 警告;`pnpm format:check` 干净(两处超宽行交给 prettier);core **1350 / 5 跳过**、ui **1000**、web **2887 / 2 跳过**、cli **505**、server **2563 / 2 跳过**(首跑 1 条红是 `dist/install.ps1` 副本过期,重建 server 后转绿)—— 0 失败;运行时实测:`ADELIE_LANG=zh` 出中文帮助、旧名 `PENGUIN_LANG=zh` 不再生效、`ADELIE_SEED_ADMIN_PASSWORD` 起服务不再打印 claim 链接;浏览器(7431,数据根 `/root/adelie-fork-data`)标题 `Sign in · Adelie`、console 唯一 error 是登录前 `/api/me` 401;推送后 CI run `37302398244` **22 个 job 全绿**(含本机按纪律没跑的 desktop 一族,等于替桌面壳那半边也验了一遍) | 见本行提交 || 2026-10-06 | 2.2c(前半) | 边界面部署变量的**读侧**同时认 Adelie 的名字与旧名:core 新增 `state/boundary-env.ts`(`ADELIE_*` ← 旧 `PENGUIN_*` 的表 + 读取函数,新名优先);接上 server 的 `config.ts`(WEB_DIST / WEB_DB / PORT_FILE / DESKTOP_TOKEN / CLI_ENTRY)、version 路由的 CLI_ENTRY、`machines/layout.ts` 的 PROFILE、CLI 三个命令的 WEB_DB、core 的 BUNDLED_SHELL,server README 的环境表与各处注释跟上。**写侧一个没改**(桌面壳按纪律没碰),所以 2.2c 仍未勾掉,「还差什么」写在条目里 | 六个包 typecheck 过;`pnpm lint` 0 警告、`pnpm format:check` 干净;core 1359 / 5 跳过 · server 2594 / 2 跳过 · cli 505 · ui 1000 · web 2877 / 2 跳过,**0 失败**;真起服务三次(数据根 `/root/adelie-fork-data/alias-*`,端口 7451 只用新名 / 7452 只用旧名 / 7453 两名并存):三次都 302 → 登录页 `<title>Adelie</title>`,日志里的 SQLite 与 Web dist 都对,端口文件按各自的名字落盘;并存那次落的是新名的 `new.db` / `new.port`,旧名的 `old.db` / `old.port` 与 `PENGUIN_HOME` 指的旧根**一个都没建** | `83acbdf0` |+| 2026-10-06 | 2.2c(写侧的非桌面壳部分) | 边界面变量**写侧的两处**(都不是桌面壳写的)改用 Adelie 的名字:两个启动脚本 `scripts/launchers/penguin{,.cmd}` 导出 `ADELIE_WEB_DIST`(操作者显式的旧名 `PENGUIN_WEB_DIST` 仍照办,新名优先)与 `ADELIE_BUNDLED_SHELL`;`penguin server|web` 导出 `ADELIE_CLI_ENTRY`。跟着改的地方:`scripts/test-installer.sh` 对两个启动脚本的守卫、core 剥离用例新增这两个新名、`config.ts` / `update-job.ts` / `session-manager.ts` 的注释与 `server/README.md` 的写法说明。桌面壳一侧与 `machines/commands.ts` 有意未动(见 2.2c 的「还差什么」) | 六包 typecheck 过;`pnpm lint` 0 警告、`pnpm format:check` 干净、`sh scripts/test-installer.sh` 通过;core 1359(+5 跳过)· server 2600(+2 跳过)· cli 505 · web 2877(+2 跳过)· ui 1003,**0 失败**;启动脚本用桩 CLI 实测四种环境(默认 / 只给旧名 / 两名并存取新名 / 显式 `ADELIE_HOME`),旧名覆盖仍生效;真起服务两次(经 CLI 起,7455/7456,数据根 `/root/adelie-fork-data/write-side*`):日志 `Agent CLI: <root>/bin/penguin -> …/packages/cli/dist/penguin.js`、**子进程 environ 里是 `ADELIE_CLI_ENTRY`、没有旧名**、`ADELIE_WEB_DIST` 指哪就服务哪;浏览器打开 7456 是 `登录 · Adelie`,唯一 console error 是登录前 `/api/me` 401 | 见本行提交 |> **2026-10-06 与另一条线的交汇(第六轮)**:本轮开工时 `git status --short` 是干净的;做完检查那一> 步时工作区里多出**另一条线**的改动 —— 47 个 `package.json` 的 `version` 0.3.0 → 0.3.1、diff --git a/packages/cli/src/commands/serve.ts b/packages/cli/src/commands/serve.tsindex 6df956d6..179f3de5 100644--- a/packages/cli/src/commands/serve.ts+++ b/packages/cli/src/commands/serve.ts@@ -11,7 +11,7 @@* in parallel. Port/host priority: command-line option > existing environment variable* (including .env) > default 7364 / 127.0.0.1. `penguin web` additionally polls until the* service is ready, prints the URL, and opens a browser per-platform (`--no-open`- * disables this). Before the import, PENGUIN_CLI_ENTRY is exported (when node can re-run+ * disables this). Before the import, ADELIE_CLI_ENTRY is exported (when node can re-run* this entry) so the server's admin self-update endpoint can invoke `penguin update`.** Supervision: when plain node can re-run this entry, the service runs as a CHILD process@@ -199,7 +199,7 @@ async function startServer(// run) the variable stays unset and the endpoint reports "unsupported".const cliEntry = cliEntryFor(process.argv[1]);if (cliEntry !== null) {- process.env.PENGUIN_CLI_ENTRY = cliEntry;+ process.env.ADELIE_CLI_ENTRY = cliEntry;}// The same re-runnable entry is what makes supervision possible: the child is exactly// this command again, marked as the child so it does not supervise in turn.diff --git a/packages/core/src/environment/tools/command/session-manager.ts b/packages/core/src/environment/tools/command/session-manager.tsindex 46082a99..85c1981c 100644--- a/packages/core/src/environment/tools/command/session-manager.ts+++ b/packages/core/src/environment/tools/command/session-manager.ts@@ -50,8 +50,10 @@ const HARDENED_ENV: NodeJS.ProcessEnv = {* a particular port should be told so in its own invocation (or through the vault), never by* ambient inheritance.*- * `PENGUIN_CLI_ENTRY` is internal plumbing: the CLI uses it to tell the server which script to- * re-run for self-update. It means nothing to any other program and leaks the install path.+ * `ADELIE_CLI_ENTRY` is internal plumbing: the CLI writes it to tell the server which script to+ * re-run for self-update (the by-name entry below still lists the pre-rename `PENGUIN_CLI_ENTRY`,+ * which is what the desktop shell hands the server). It means nothing to any other program and+ * leaks the install path.** `PENGUIN_WEB_DIST` is *not* internal — it is a documented deployment override (see the* configuration reference and the server README) — and is stripped anyway because it names this@@ -106,7 +108,8 @@ const STRIPPED_ENV_KEYS = new Set([* Twenty-five existed when this was written and a by-name list had caught seven.** Two prefixes because the installation carries two spellings of the same settings today:- * `ADELIE_*` is Adelie's own — the installed launcher exports `ADELIE_HOME` — and `PENGUIN_*` is+ * `ADELIE_*` is Adelie's own — the installed launcher exports `ADELIE_HOME`, `ADELIE_WEB_DIST`+ * and `ADELIE_BUNDLED_SHELL` — and `PENGUIN_*` is* the pre-rename spelling that existing deployments, systemd units and scripts still set, with* the data root read from either. It is not only history: the settings whose *other* end is a* program Adelie does not build in this repository (the desktop shell's launch environment, thediff --git a/packages/core/test/exec-session.test.ts b/packages/core/test/exec-session.test.tsindex f589242f..9f3ec741 100644--- a/packages/core/test/exec-session.test.ts+++ b/packages/core/test/exec-session.test.ts@@ -312,6 +312,11 @@ describe("harness environment variables never reach a spawned command", () => {// The post-rename spelling of the same setting, exported by the installed launcher: both// prefixes are the rule, so a root named the new way has to be stripped exactly like the old."ADELIE_HOME",+ // What Adelie itself writes today: `penguin server|web` exports ADELIE_CLI_ENTRY and the+ // installed launcher exports ADELIE_WEB_DIST (the pre-rename spellings above are still+ // stripped too — the desktop shell and existing deployments keep writing those).+ "ADELIE_CLI_ENTRY",+ "ADELIE_WEB_DIST",// A sample of the PENGUIN_* the prefix rule covers that no by-name list ever named: the// resolved shell, the release feed, the UI language and the install location. Whether these// specific ones are set at run time is beside the point — the rule is the prefix, and a new@@ -341,6 +346,8 @@ describe("harness environment variables never reach a spawned command", () => {process.env.PENGUIN_HOME = "/home/someone/.penguin/data";process.env.PENGUIN_WEB_DB = "/home/someone/.penguin/data/web.db";process.env.ADELIE_HOME = "/home/someone/.adelie/data";+ process.env.ADELIE_CLI_ENTRY = "/opt/adelie/lib/dist/index.js";+ process.env.ADELIE_WEB_DIST = "/opt/adelie/web";process.env.ADELIE_SHELL = "/opt/penguin/bin/bash";process.env.PENGUIN_UPDATE_FEED_URL = "https://example.invalid/feed";process.env.ADELIE_LANG = "zh";diff --git a/packages/server/README.md b/packages/server/README.mdindex b6e4d650..92df91a8 100644--- a/packages/server/README.md+++ b/packages/server/README.md@@ -22,7 +22,7 @@ The full route tables and the SSE protocol are documented in the [Server API ref| `ADELIE_WEB_DB` (was `PENGUIN_WEB_DB`) | SQLite file path | `<root>/web.db` || `ADELIE_WEB_DIST` (was `PENGUIN_WEB_DIST`) | Front-end build dir (static hosting + SPA fallback when present) | `../web/dist`, or the bundled `web-dist/` in the npm package || `ADELIE_TRUST_PROXY` | Trust `x-forwarded-proto` (`1` to enable): it opens the hot-update network gate over proxied HTTPS and marks session cookies `Secure` — only behind a reverse proxy that sets/strips the header itself | unset (untrusted) |-| `ADELIE_CLI_ENTRY` (was `PENGUIN_CLI_ENTRY`) | CLI entry script offered to the Agents this server runs: it is written into `<root>/bin/penguin` and put at the front of every command's PATH | `penguin server\|web` and the desktop shell set it; otherwise the entry of the checkout this server was started from, when it has one |+| `ADELIE_CLI_ENTRY` (was `PENGUIN_CLI_ENTRY`) | CLI entry script offered to the Agents this server runs: it is written into `<root>/bin/penguin` and put at the front of every command's PATH | `penguin server\|web` sets it under that name, the desktop shell passes the pre-rename one; otherwise the entry of the checkout this server was started from, when it has one |Every deployment variable above keeps reading the spelling in parentheses: its writer is outsidethis repository (the desktop shell's launch environment, an existing deployment's unit file, andiff --git a/packages/server/src/config.ts b/packages/server/src/config.tsindex 59946c71..d358d1b4 100644--- a/packages/server/src/config.ts+++ b/packages/server/src/config.ts@@ -112,8 +112,9 @@ export interface ServerConfig {/*** The CLI entry script this harness offers to the Agents it runs — the file the* `<root>/bin/penguin` shim execs (see services/cli-shim.ts). `ADELIE_CLI_ENTRY` when- * set (`PENGUIN_CLI_ENTRY` is read too — `penguin server|web` still exports that spelling and- * the desktop shell passes it, see state/boundary-env.ts): `penguin server|web` exports its own+ * set (`PENGUIN_CLI_ENTRY` is read too — the desktop shell passes that spelling, and its+ * launch environment is not built in this repository, see state/boundary-env.ts):+ * `penguin server|web` exports its own* entry there, and the desktop shell passes* the bundled one to the server it forks. Otherwise the entry of the checkout this* server was started from, when it has a built one. Null = no CLI to offer, and no shimdiff --git a/packages/server/src/services/update-job.ts b/packages/server/src/services/update-job.tsindex 966a867b..bde6059e 100644--- a/packages/server/src/services/update-job.ts+++ b/packages/server/src/services/update-job.ts@@ -7,8 +7,9 @@* the next start (which is also how a failed run is retried).** How the self-update works: `penguin server|web` exports its own entry script path as- * PENGUIN_CLI_ENTRY — the pre-rename spelling of ADELIE_CLI_ENTRY, and the config parser- * reads both — before importing this server, and the job re-runs that script as+ * ADELIE_CLI_ENTRY — the pre-rename PENGUIN_CLI_ENTRY is read as well, because the desktop+ * shell still hands the server that spelling — before importing this server, and the job+ * re-runs that script as* `node <entry> update --yes` — the CLI's update command owns all install-kind detection,* download and replacement logic (packages/cli/src/commands/update.ts). A server started* any other way (tests, a custom embedding) has no CLI to run and reports "unsupported".diff --git a/scripts/launchers/penguin b/scripts/launchers/penguinindex 6eb08cd6..2b1b77f6 100755--- a/scripts/launchers/penguin+++ b/scripts/launchers/penguin@@ -16,7 +16,11 @@ while [ -h "$SOURCE" ]; dodoneDIR=$(dirname "$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)")-export PENGUIN_WEB_DIST="${PENGUIN_WEB_DIST:-$DIR/web}"+# The front-end build this install serves. Adelie's own spelling wins, then the pre-rename+# PENGUIN_WEB_DIST a launcher from an older release (or an operator's shell rc) set — the reader+# accepts both and prefers this one (core's state/boundary-env.ts), so honoring the old name here+# is what keeps an explicit override working across the rename.+export ADELIE_WEB_DIST="${ADELIE_WEB_DIST:-${PENGUIN_WEB_DIST:-$DIR/web}}"# The data root this install owns. The installer lays the program out in a program directory and# keeps the data root inside it (`<program>/data`) — that is where an install made before Adelie# spelled its environment Adelie's way has its Agents, Sessions and usage, so exporting the pathdiff --git a/scripts/launchers/penguin.cmd b/scripts/launchers/penguin.cmdindex 6282536d..7e8b54ae 100644--- a/scripts/launchers/penguin.cmd+++ b/scripts/launchers/penguin.cmd@@ -8,13 +8,17 @@ rem PATH, and client Windows defaults to the Restricted execution policy, whichrem then break the plain `penguin` command. Batch files are exempt from that policy.setlocalset "DIR=%~dp0.."-if not defined PENGUIN_WEB_DIST set "PENGUIN_WEB_DIST=%DIR%\web"+rem The front-end build this install serves: Adelie's own spelling wins, then the+rem pre-rename PENGUIN_WEB_DIST an older launcher or an operator's environment set (the+rem reader accepts both and prefers this one).+if not defined ADELIE_WEB_DIST if defined PENGUIN_WEB_DIST set "ADELIE_WEB_DIST=%PENGUIN_WEB_DIST%"+if not defined ADELIE_WEB_DIST set "ADELIE_WEB_DIST=%DIR%\web"rem The data root this install owns: the installer keeps it inside the program directory asrem data\, which is where an install made before the rename keeps its Agents and Sessions.rem An explicit ADELIE_HOME wins, then the pre-2.2 PENGUIN_HOME, then this install's own data\.if not defined ADELIE_HOME if defined PENGUIN_HOME set "ADELIE_HOME=%PENGUIN_HOME%"if not defined ADELIE_HOME set "ADELIE_HOME=%DIR%\data"-if exist "%DIR%\git\usr\bin\sh.exe" set "PENGUIN_BUNDLED_SHELL=%DIR%\git\usr\bin\sh.exe"+if exist "%DIR%\git\usr\bin\sh.exe" set "ADELIE_BUNDLED_SHELL=%DIR%\git\usr\bin\sh.exe"if exist "%DIR%\node\node.exe" ("%DIR%\node\node.exe" "%DIR%\lib\dist\penguin.js" %*) else (diff --git a/scripts/test-installer.sh b/scripts/test-installer.shindex 0904be94..5f9206e8 100755--- a/scripts/test-installer.sh+++ b/scripts/test-installer.sh@@ -23,11 +23,11 @@ fail_test() {LAUNCHER_SH="$ROOT_DIR/scripts/launchers/penguin"LAUNCHER_CMD="$ROOT_DIR/scripts/launchers/penguin.cmd"[ -x "$LAUNCHER_SH" ] || fail_test "scripts/launchers/penguin is missing or not executable"-for marker in 'PENGUIN_WEB_DIST:-$DIR/web' '$DIR/node/bin/node' '$DIR/lib/dist/penguin.js'; do+for marker in 'ADELIE_WEB_DIST:-${PENGUIN_WEB_DIST:-$DIR/web}' '$DIR/node/bin/node' '$DIR/lib/dist/penguin.js'; dogrep -qF "$marker" "$LAUNCHER_SH" || fail_test "the POSIX launcher does not carry $marker"donesh -n "$LAUNCHER_SH" || fail_test "the POSIX launcher is not valid sh"-for marker in '%DIR%\web' '%DIR%\node\node.exe' '%DIR%\lib\dist\penguin.js'; do+for marker in 'set "ADELIE_WEB_DIST=%DIR%\web"' 'set "ADELIE_BUNDLED_SHELL=%DIR%\git\usr\bin\sh.exe"' '%DIR%\node\node.exe' '%DIR%\lib\dist\penguin.js'; dogrep -qF "$marker" "$LAUNCHER_CMD" || fail_test "the Windows launcher does not carry $marker"done# .gitattributes keeps this one CRLF, the only form cmd.exe is fully reliable with.