From b1387a0b10fb4cbec2ff63470063824534623b78 Mon Sep 17 00:00:00 2001 From: zjywill Date: Wed, 25 Nov 2026 18:58:03 +0800 Subject: [PATCH 1/2] Provide dimn in the curl nightly installer Refs #2131 Amp-Thread-ID: https://ampcode.com/threads/T-01a21131-e6b2-7500-992a-243f2e876f70 --- README.md | 2 +- docs/release/README.md | 2 +- scripts/install-nightly.sh | 9 +++++++++ scripts/nightly.test.mjs | 17 +++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16109a9a70..9827f6626d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ npm install -g dimcode-alpha@alpha dima ``` -For the independent nightly build on macOS or GNU/Linux, use the [curl installer](docs/release/README.md#nightly-curl-channel) and run `dim-nightly`. Rerun the installer to upgrade without changing your npm alpha installation. +For the independent nightly build on macOS or GNU/Linux, use the [curl installer](docs/release/README.md#nightly-curl-channel) and run `dimn` or `dim-nightly`. Rerun the installer to upgrade without changing your npm alpha installation. Add a provider with `/connect` (or `/provider`), sign in to DimAgent with `/login`, or select a configured model with `/models`. Type `ls` in the chat and press Enter. In this session Dim asks to run `ls -la` in `runtime/plugins`. Choosing **Allow once** lets it list the three plugin directories. diff --git a/docs/release/README.md b/docs/release/README.md index bfbaad09ef..b380c8186d 100644 --- a/docs/release/README.md +++ b/docs/release/README.md @@ -44,7 +44,7 @@ Install or upgrade the standalone `dim-nightly` on macOS or GNU/Linux (arm64 or curl -fsSL https://raw.githubusercontent.com/arcships/dim/main/scripts/install-nightly.sh | sh ``` -The entry point is `~/.local/bin/dim-nightly`. The installer leaves npm installations alone and keeps each payload under `${XDG_DATA_HOME:-~/.local/share}/dim-nightly`. The CLI defaults to `~/.dimcode-nightly`. The release environment needs the same build-time account settings as the alpha native builds. Restrict nightly tag creation and manual publication to trusted maintainers. If deployment filters are enabled, allow both `main` and the nightly tag pattern in `release-build`. Rolling assets require a mutable GitHub prerelease. +Run `dimn` or `dim-nightly` from `~/.local/bin`. Installation and upgrades add `dimn` as a shortcut to `dim-nightly` without replacing anything already at `~/.local/bin/dimn`. The installer leaves npm installations alone and keeps each payload under `${XDG_DATA_HOME:-~/.local/share}/dim-nightly`. The CLI defaults to `~/.dimcode-nightly`. The release environment needs the same build-time account settings as the alpha native builds. Restrict nightly tag creation and manual publication to trusted maintainers. If deployment filters are enabled, allow both `main` and the nightly tag pattern in `release-build`. Rolling assets require a mutable GitHub prerelease. Nightly (`X.Y.Z-nightly.N`) and npm alpha (`X.Y.Z-alpha.N`) number releases independently. Start a nightly without a version PR in either of two ways: diff --git a/scripts/install-nightly.sh b/scripts/install-nightly.sh index 6d909cf5d3..318e1980c1 100644 --- a/scripts/install-nightly.sh +++ b/scripts/install-nightly.sh @@ -42,6 +42,15 @@ install_nightly() ( ln -s "$dest/bin/dimcode" "$linkdir/dim-nightly" mv -f "$linkdir/dim-nightly" "$entry" printf 'Installed dim-nightly %s at %s\n' "$version" "$entry" + short=$bin/dimn + if [ ! -e "$short" ] && [ ! -L "$short" ]; then + ln -s dim-nightly "$short" + fi + if [ -L "$short" ] && [ "$(readlink "$short")" = dim-nightly ]; then + printf 'Run dimn or dim-nightly to start Nightly.\n' + else + printf 'Keeping existing %s; use dim-nightly to start Nightly.\n' "$short" >&2 + fi case :$PATH: in *:"$bin":*) :;; *) printf 'Add %s to PATH to run dim-nightly.\n' "$bin";; esac ) diff --git a/scripts/nightly.test.mjs b/scripts/nightly.test.mjs index 9b80cf253e..55d1181f5e 100644 --- a/scripts/nightly.test.mjs +++ b/scripts/nightly.test.mjs @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { execFileSync, spawnSync } from 'node:child_process'; -import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; +import { mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; import test from 'node:test'; @@ -41,11 +41,16 @@ esac\n`, { mode: 0o755 }); assert.equal(run.status === 0, ok, run.stderr); } const install = () => spawnSync('sh', [path.join(import.meta.dirname, 'install-nightly.sh')], { env, encoding: 'utf8' }); - const installed = () => execFileSync(file('.local/bin/dim-nightly'), ['--version'], { env, encoding: 'utf8' }).trim(); + const installed = (command = 'dim-nightly') => execFileSync(file('.local/bin', command), ['--version'], { env, encoding: 'utf8' }).trim(); + const shortcut = file('.local/bin/dimn'); const release = () => JSON.parse(readFileSync(file('release'))).name; publish(8); assert.equal(install().status, 0); assert.equal(installed(), 'dimcode 1.2.3-nightly.8'); + assert.equal(installed('dimn'), 'dimcode 1.2.3-nightly.8'); + rmSync(shortcut); + assert.equal(install().status, 0); + assert.equal(installed('dimn'), 'dimcode 1.2.3-nightly.8'); writeFileSync(file('.local/bin/dima'), 'npm installation'); writeFileSync(file('assets/unrelated.txt'), 'keep'); writeFileSync(file('interrupt'), ''); @@ -68,6 +73,14 @@ esac\n`, { mode: 0o755 }); const run = install(); assert.equal(run.status, 0, run.stderr); assert.equal(installed(), 'dimcode 1.2.3-nightly.11'); + assert.equal(installed('dimn'), 'dimcode 1.2.3-nightly.11'); } + rmSync(shortcut); + symlinkSync('unrelated-command', shortcut); + const conflict = install(); + assert.equal(conflict.status, 0, conflict.stderr); + assert.match(conflict.stderr, /Keeping existing .*dimn/); + assert.equal(readlinkSync(shortcut), 'unrelated-command'); + assert.equal(installed(), 'dimcode 1.2.3-nightly.11'); assert.equal(readFileSync(file('.local/bin/dima'), 'utf8'), 'npm installation'); }); From 0506c22b6832bf62c7cce6cb3e060798e3d14dde Mon Sep 17 00:00:00 2001 From: zjywill Date: Thu, 26 Nov 2026 11:01:23 +0800 Subject: [PATCH 2/2] Keep nightly installation successful when the dimn shortcut is occupied Amp-Thread-ID: https://ampcode.com/threads/T-01a2125b-f93a-7216-9485-dafd82fea69f --- README.md | 2 +- docs/release/README.md | 2 +- scripts/install-nightly.sh | 6 ++++-- scripts/nightly.test.mjs | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9827f6626d..a1ab356535 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ npm install -g dimcode-alpha@alpha dima ``` -For the independent nightly build on macOS or GNU/Linux, use the [curl installer](docs/release/README.md#nightly-curl-channel) and run `dimn` or `dim-nightly`. Rerun the installer to upgrade without changing your npm alpha installation. +For the independent nightly build on macOS or GNU/Linux, use the [curl installer](docs/release/README.md#nightly-curl-channel) and run `dim-nightly` (or `dimn` if the shortcut is available). Rerun the installer to upgrade without changing your npm alpha installation. Add a provider with `/connect` (or `/provider`), sign in to DimAgent with `/login`, or select a configured model with `/models`. Type `ls` in the chat and press Enter. In this session Dim asks to run `ls -la` in `runtime/plugins`. Choosing **Allow once** lets it list the three plugin directories. diff --git a/docs/release/README.md b/docs/release/README.md index b380c8186d..a0d1cd468f 100644 --- a/docs/release/README.md +++ b/docs/release/README.md @@ -44,7 +44,7 @@ Install or upgrade the standalone `dim-nightly` on macOS or GNU/Linux (arm64 or curl -fsSL https://raw.githubusercontent.com/arcships/dim/main/scripts/install-nightly.sh | sh ``` -Run `dimn` or `dim-nightly` from `~/.local/bin`. Installation and upgrades add `dimn` as a shortcut to `dim-nightly` without replacing anything already at `~/.local/bin/dimn`. The installer leaves npm installations alone and keeps each payload under `${XDG_DATA_HOME:-~/.local/share}/dim-nightly`. The CLI defaults to `~/.dimcode-nightly`. The release environment needs the same build-time account settings as the alpha native builds. Restrict nightly tag creation and manual publication to trusted maintainers. If deployment filters are enabled, allow both `main` and the nightly tag pattern in `release-build`. Rolling assets require a mutable GitHub prerelease. +Run `dim-nightly` from `~/.local/bin`. Installation and upgrades also offer `dimn` as a shortcut. If the shortcut is unavailable or its name is already taken, the installer leaves it alone and `dim-nightly` remains ready to use. The installer leaves npm installations alone and keeps each payload under `${XDG_DATA_HOME:-~/.local/share}/dim-nightly`. The CLI defaults to `~/.dimcode-nightly`. The release environment needs the same build-time account settings as the alpha native builds. Restrict nightly tag creation and manual publication to trusted maintainers. If deployment filters are enabled, allow both `main` and the nightly tag pattern in `release-build`. Rolling assets require a mutable GitHub prerelease. Nightly (`X.Y.Z-nightly.N`) and npm alpha (`X.Y.Z-alpha.N`) number releases independently. Start a nightly without a version PR in either of two ways: diff --git a/scripts/install-nightly.sh b/scripts/install-nightly.sh index 318e1980c1..a535ac9c24 100644 --- a/scripts/install-nightly.sh +++ b/scripts/install-nightly.sh @@ -44,12 +44,14 @@ install_nightly() ( printf 'Installed dim-nightly %s at %s\n' "$version" "$entry" short=$bin/dimn if [ ! -e "$short" ] && [ ! -L "$short" ]; then - ln -s dim-nightly "$short" + { ln -s dim-nightly "$linkdir/dimn" && ln -P "$linkdir/dimn" "$bin/"; } || : fi if [ -L "$short" ] && [ "$(readlink "$short")" = dim-nightly ]; then printf 'Run dimn or dim-nightly to start Nightly.\n' - else + elif [ -e "$short" ] || [ -L "$short" ]; then printf 'Keeping existing %s; use dim-nightly to start Nightly.\n' "$short" >&2 + else + printf 'Shortcut unavailable; use dim-nightly to start Nightly.\n' >&2 fi case :$PATH: in *:"$bin":*) :;; *) printf 'Add %s to PATH to run dim-nightly.\n' "$bin";; esac ) diff --git a/scripts/nightly.test.mjs b/scripts/nightly.test.mjs index 55d1181f5e..645a7fb22d 100644 --- a/scripts/nightly.test.mjs +++ b/scripts/nightly.test.mjs @@ -82,5 +82,24 @@ esac\n`, { mode: 0o755 }); assert.match(conflict.stderr, /Keeping existing .*dimn/); assert.equal(readlinkSync(shortcut), 'unrelated-command'); assert.equal(installed(), 'dimcode 1.2.3-nightly.11'); + rmSync(shortcut); + writeFileSync(file('ln'), `#!/bin/sh +set -eu +case "$*" in *dimn*) + if [ ! -e "$HOME/.local/bin/dimn" ]; then + if [ -f "$HOME/race-directory" ]; then mkdir "$HOME/.local/bin/dimn"; else echo foreign >"$HOME/.local/bin/dimn"; fi + fi;; +esac +exec /bin/ln "$@"\n`, { mode: 0o755 }); + for (const directory of [false, true]) { + if (directory) writeFileSync(file('race-directory'), ''); + const collision = install(); + assert.equal(collision.status, 0, collision.stderr); + assert.match(collision.stderr, /Keeping existing .*dimn/); + if (directory) assert.deepEqual(readdirSync(shortcut), []); + else assert.equal(readFileSync(shortcut, 'utf8'), 'foreign\n'); + rmSync(shortcut, { recursive: true }); + } + assert.equal(installed(), 'dimcode 1.2.3-nightly.11'); assert.equal(readFileSync(file('.local/bin/dima'), 'utf8'), 'npm installation'); });