diff --git a/README.md b/README.md index 16109a9a70..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 `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 bfbaad09ef..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 ``` -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 `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 6d909cf5d3..a535ac9c24 100644 --- a/scripts/install-nightly.sh +++ b/scripts/install-nightly.sh @@ -42,6 +42,17 @@ 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 "$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' + 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 9b80cf253e..645a7fb22d 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,33 @@ 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'); + 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'); });