From c52244bee10c31a130ee6c2c4e670eddf4f5143f Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Thu, 5 Nov 2026 11:38:59 -0800 Subject: [PATCH] Keep metrics and bot out of plan2code update unless run from a git checkout, and end shims cleanly AI Assisted --- .agents-docs/AGENTS-architecture.md | 2 +- .agents-docs/AGENTS-development-commands.md | 2 +- QUICK-REFERENCE.md | 2 +- install.js | 17 +++++++++++++---- src/statusline-claude/README.md | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.agents-docs/AGENTS-architecture.md b/.agents-docs/AGENTS-architecture.md index b66ba93..29d1691 100644 --- a/.agents-docs/AGENTS-architecture.md +++ b/.agents-docs/AGENTS-architecture.md @@ -663,4 +663,4 @@ On a terminal it first prints a Planny banner (`renderBanner()`). With more than The macOS and Linux shortcuts carry the `plan2code-launcher` marker as a comment line. A `.lnk` has nowhere to hide one (its Description is the hover tooltip), so it's recognized by what it runs: the UTF-16 strings `plan2code.ps1` and `--pick-folder` stored in the file (`plan2code.cmd` also matches, so shortcuts from before the PowerShell switch get refreshed). `uninstallLauncher()` removes only a recognized shortcut, plus the icons (`plan2code.ico`, `plan2code.png`), `bin/models.json` and `launcher.json` (never the user's `~/.plan2code/models.json`). A shortcut failure prints a warning and never fails the command install. -**Installer integration** lives in `install.js` under the `PLAN2CODE COMMAND` section (`installLauncher`, `uninstallLauncher`, plus the shortcut helpers). `install()` awaits it after a successful skills install (so `I` and Advanced → `E` get it), `U` removes it, and Advanced → `D` installs it alone. Every global install writes `~/.plan2code/install.json`, the install record listing the pieces installed (skills, launcher, statusline, loop, metrics, bot); `install.js --update` (what `plan2code update` runs) reinstalls exactly those, with no menu and never uninstalling, or with no record the skills and the `plan2code` command. After an install, `printGettingStarted()` prints the three steps (cd into the project, start Plan2Code, pick a card) and, when no agent CLI is on `PATH`, how to get one. +**Installer integration** lives in `install.js` under the `PLAN2CODE COMMAND` section (`installLauncher`, `uninstallLauncher`, plus the shortcut helpers). `install()` awaits it after a successful skills install (so `I` and Advanced → `E` get it), `U` removes it, and Advanced → `D` installs it alone. Every global install writes `~/.plan2code/install.json`, the install record listing the pieces installed (skills, launcher, statusline, loop, metrics, bot); `install.js --update` (what `plan2code update` runs) reinstalls those (metrics and bot only when run from a git checkout), with no menu and never uninstalling, or with no record the skills and the `plan2code` command. After an install, `printGettingStarted()` prints the three steps (cd into the project, start Plan2Code, pick a card) and, when no agent CLI is on `PATH`, how to get one. diff --git a/.agents-docs/AGENTS-development-commands.md b/.agents-docs/AGENTS-development-commands.md index ca9ccee..4e58523 100644 --- a/.agents-docs/AGENTS-development-commands.md +++ b/.agents-docs/AGENTS-development-commands.md @@ -126,7 +126,7 @@ The root `npm test` does not run the metrics or bot vitest suites; run them in t |------|--------| | `--build-skills` | Regenerate `skills/` from `src/`, pruning stale skills and reference files | | `--verify-skills` | Diff local `skills/` against `src/`; exits 1 on drift. Diagnostic only, the installer rebuilds anyway | -| `--update` | No menu: reinstall what `~/.plan2code/install.json` lists (skills, launcher, statusline, metrics, bot), never uninstalling; with no record, the skills and the `plan2code` command. `plan2code update` runs it through npx | +| `--update` | No menu: reinstall what `~/.plan2code/install.json` lists (skills, launcher, app, statusline; metrics and bot only when run from a git checkout, since they run from the install folder, which npx's cache is not), never uninstalling; with no record, the skills and the `plan2code` command. `plan2code update` runs it through npx | ## How the Installer Works diff --git a/QUICK-REFERENCE.md b/QUICK-REFERENCE.md index c64de1b..249412b 100644 --- a/QUICK-REFERENCE.md +++ b/QUICK-REFERENCE.md @@ -16,7 +16,7 @@ The web console is the main way in: a local page where questions, documents, bui | From your project (shell) | `plan2code` | Opens Claude Code, Devin or Codex on the dashboard (`--cli claude` / `devin` / `codex` to choose) | | Inside any agent | `/plan2code` (`$plan2code` in Codex) | Opens the dashboard: a card for every skill, launched on the same page | | Install | `npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git` | Installs the skills and the `plan2code` command (re-run it to update without the `plan2code` command) | -| Update | `plan2code update` | Updates everything that was installed, with no menu; never uninstalls anything | +| Update | `plan2code update` | Updates the skills, command, app and status line, with no menu (metrics and the bot only from a git checkout: `node install.js`); never uninstalls anything | | Straight into a skill | `/plan2code-1-plan --web` (any step) | Skips the "web console or terminal?" question and opens the page | The install command always opens a menu. Back at your prompt with no output at all? npm could not reach the repository and hid the reason: run `git ls-remote https://github.com/jparkerweb/plan2code.git` to see it (usually the network, a proxy or the VPN). diff --git a/install.js b/install.js index 69aed11..4a97b81 100644 --- a/install.js +++ b/install.js @@ -2305,10 +2305,12 @@ function getLauncherShims(binDir, nodePath = process.execPath) { '@echo off', `rem ${LAUNCHER_MARKER}`, `if not exist "${cmdNode}" goto p2c_path_node`, - `"${cmdNode}" "${cmdDest}" %*`, - 'exit /b %ERRORLEVEL%', + // Each command ends its own line with `& exit /b`: cmd.exe reads a running .cmd by byte + // offset, and `plan2code update` rewrites this file while it runs, so nothing may be read + // after the command returns. A bare `exit /b` keeps the command's exit code. + `"${cmdNode}" "${cmdDest}" %* & exit /b`, ':p2c_path_node', - `node "${cmdDest}" %*`, + `node "${cmdDest}" %* & exit /b`, '', ].join('\r\n'), }, @@ -2597,7 +2599,7 @@ function uninstallLauncher() { const shortcut = getShortcutFile(); if (isOurShortcut(shortcut)) remove(shortcut); forgetInstalled('launcher'); - for (const file of [LAUNCHER_DEST, MODELS_DEST, UPDATE_CHECK_DEST, LAUNCHER_VERSION_DEST, SHORTCUT_ICON_DEST, SHORTCUT_PNG_DEST, LAUNCHER_STATE, INSTALL_RECORD]) { + for (const file of [LAUNCHER_DEST, MODELS_DEST, UPDATE_CHECK_DEST, LAUNCHER_VERSION_DEST, SHORTCUT_ICON_DEST, SHORTCUT_PNG_DEST, LAUNCHER_STATE, INSTALL_RECORD, AGENTS_DEST, AGENT_LOOKUP_DEST]) { if (fs.existsSync(file)) remove(file); } try { @@ -2855,6 +2857,13 @@ async function update({ steps = UPDATE_STEPS, cleanShims = removeLegacyLoopShims const results = {}; for (const piece of INSTALL_PIECES) { if (!pieces.includes(piece) || piece in results) continue; + // The metrics and bot commands run from this folder: from npx's cache (which the launcher + // note above calls free to delete) they would break once it is cleared, so only a checkout updates them. + if ((piece === 'metrics' || piece === 'bot') && !fs.existsSync(path.join(__dirname, '.git'))) { + results[piece] = 'kept (update it from a git checkout: node install.js)'; + console.log(''); + continue; + } const outcome = {}; try { const code = await steps[piece]({ quiet: true, unattended: true, outcome }); diff --git a/src/statusline-claude/README.md b/src/statusline-claude/README.md index 8010338..c65258e 100644 --- a/src/statusline-claude/README.md +++ b/src/statusline-claude/README.md @@ -40,7 +40,7 @@ The absolute token count before the context bar (`84k ⋅`) only appears on Pro/ ```bash node install.js -# Select A (Install All + dev tools) or C (Custom) → S (Status Line) +# Select A (Advanced) → S (Status Line), or A → E (Everything) ``` This automatically: