@grigdesk/dsh 0.2.0 → 0.2.2
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/README.md +13 -10
- package/bin/launcher.mjs +2 -2
- package/package.json +4 -4
- package/scripts/lib/install.mjs +33 -8
- package/scripts/postinstall.mjs +2 -2
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @grigdesk/dsh
|
|
2
2
|
|
|
3
3
|
Terminal commands for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) as shipped by
|
|
4
|
-
[GrigDesk](https://app.grigdesk.com): one pinned runtime,
|
|
4
|
+
[GrigDesk](https://app.grigdesk.com): one pinned runtime for DeepSeek, GLM and Qwen.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
7
|
npm i -g @grigdesk/dsh
|
|
8
8
|
|
|
9
|
-
deepseek
|
|
10
|
-
glm
|
|
11
|
-
qwen
|
|
9
|
+
deepseek # DeepSeek chat in the current directory
|
|
10
|
+
glm # GLM (Z.ai) chat
|
|
11
|
+
dsh chat -p qwen # Qwen chat
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
The package itself is tiny. `postinstall` downloads the standalone binary for your platform from the
|
|
@@ -18,11 +18,12 @@ SHA-256 against `manifest.json`, and keeps every version side by side:
|
|
|
18
18
|
```
|
|
19
19
|
~/.local/share/grigdesk-dsh/versions/v1.2.3/deepseek # binary
|
|
20
20
|
~/.local/share/grigdesk-dsh/current -> versions/v1.2.3
|
|
21
|
-
~/.local/bin/deepseek, glm, qwen
|
|
21
|
+
~/.local/bin/dsh, deepseek, glm, qwen # command links (qwen when available)
|
|
22
22
|
~/.deepseek/ # terminal chat sessions and settings
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Supported platforms: Linux x64, Linux ARM64, macOS on Apple Silicon.
|
|
26
|
+
With an existing `qwen` command such as Qwen Code, use `dsh chat -p qwen` to choose DSH explicitly.
|
|
26
27
|
|
|
27
28
|
The chat checks for stable releases in the background and links to available updates in the header.
|
|
28
29
|
Use `npm i -g @grigdesk/dsh@latest` to upgrade, or `deepseek chat --no-update-check` to skip the check.
|
|
@@ -30,20 +31,22 @@ Use `npm i -g @grigdesk/dsh@latest` to upgrade, or `deepseek chat --no-update-ch
|
|
|
30
31
|
## API keys
|
|
31
32
|
|
|
32
33
|
```bash
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
dsh login # pick a provider, paste the key (hidden input) → ~/.deepseek/credentials.json (0600)
|
|
35
|
+
dsh login --status
|
|
36
|
+
dsh logout qwen
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
Keys are resolved in this order: the terminal environment (`DEEPSEEK_API_KEY`, `ZAI_API_KEY` or
|
|
39
40
|
`ZAI_CODING_API_KEY` for GLM API / Coding Plan, `QWEN_API_KEY`) → `~/.deepseek/credentials.json` →
|
|
40
|
-
the `.env` file of an installed GrigDesk
|
|
41
|
+
the `.env` file of an installed GrigDesk. DSH reuses the saved service and region when using GrigDesk's
|
|
42
|
+
Qwen API key (`DASHSCOPE_API_KEY`). A Qwen Code sign-in belongs to Qwen Code. For a separate API key,
|
|
43
|
+
use `dsh login qwen` and choose the corresponding service when opening the chat.
|
|
41
44
|
|
|
42
45
|
## Without network at install time
|
|
43
46
|
|
|
44
47
|
```bash
|
|
45
48
|
npm i -g --ignore-scripts @grigdesk/dsh
|
|
46
|
-
|
|
49
|
+
dsh install # downloads later; repeat any time
|
|
47
50
|
```
|
|
48
51
|
|
|
49
52
|
## Options
|
package/bin/launcher.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export async function launch(provider) {
|
|
|
33
33
|
|
|
34
34
|
if (!elf) {
|
|
35
35
|
process.stderr.write('DeepSeek Harness не установлен. Выполните:\n'
|
|
36
|
-
+
|
|
36
|
+
+ ' dsh install\n');
|
|
37
37
|
|
|
38
38
|
return 1;
|
|
39
39
|
}
|
|
@@ -78,7 +78,7 @@ export async function install({ log = () => {}, env = process.env, fetchImpl = f
|
|
|
78
78
|
log(`Добавьте ${directory} в PATH или откройте новый терминал`);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
log(`
|
|
81
|
+
log(`DSH ${version}: ${binary}`);
|
|
82
82
|
|
|
83
83
|
return 0;
|
|
84
84
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grigdesk/dsh",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "DeepSeek Harness CLI for
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "DeepSeek Harness CLI for DeepSeek, GLM and Qwen in the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=18.18"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
+
"dsh": "./bin/deepseek.mjs",
|
|
11
12
|
"deepseek": "./bin/deepseek.mjs",
|
|
12
|
-
"glm": "./bin/glm.mjs"
|
|
13
|
-
"qwen": "./bin/qwen.mjs"
|
|
13
|
+
"glm": "./bin/glm.mjs"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"bin/",
|
package/scripts/lib/install.mjs
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Уже установленная версия с совпавшей суммой не скачивается повторно.
|
|
5
5
|
*/
|
|
6
6
|
import { createHash, randomBytes } from 'node:crypto';
|
|
7
|
-
import { createWriteStream } from 'node:fs';
|
|
8
|
-
import {
|
|
7
|
+
import { constants, createWriteStream } from 'node:fs';
|
|
8
|
+
import {
|
|
9
|
+
access, chmod, lstat, mkdir, open, readFile, readlink, realpath, rename, rm, stat, symlink, unlink,
|
|
10
|
+
} from 'node:fs/promises';
|
|
9
11
|
import path from 'node:path';
|
|
10
12
|
import { pipeline } from 'node:stream/promises';
|
|
11
13
|
|
|
@@ -16,7 +18,7 @@ import {
|
|
|
16
18
|
const MANIFEST_FORMAT = 1;
|
|
17
19
|
const MANIFEST_TIMEOUT_MS = 30000;
|
|
18
20
|
const DOWNLOAD_TIMEOUT_MS = 20 * 60 * 1000;
|
|
19
|
-
export const COMMANDS = Object.freeze(['deepseek', 'glm', 'qwen']);
|
|
21
|
+
export const COMMANDS = Object.freeze(['dsh', 'deepseek', 'glm', 'qwen']);
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Читает manifest.json релиза и выбирает asset платформы. Только полный SHA-256 и
|
|
@@ -149,8 +151,8 @@ export async function switchCurrent(home, tag) {
|
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
|
-
* Команды в ~/.local/bin ссылаются на launcher'ы пакета.
|
|
153
|
-
*
|
|
154
|
+
* Команды в ~/.local/bin ссылаются на launcher'ы пакета. Короткий qwen создаётся,
|
|
155
|
+
* только если он свободен в PATH. При совпадении доступна команда dsh chat -p qwen.
|
|
154
156
|
* @param {{ packageDirectory: string, env?: NodeJS.ProcessEnv, log?: (line: string) => void }} options
|
|
155
157
|
*/
|
|
156
158
|
export async function linkCommands({ packageDirectory, env = process.env, log = () => {} }) {
|
|
@@ -160,13 +162,13 @@ export async function linkCommands({ packageDirectory, env = process.env, log =
|
|
|
160
162
|
|
|
161
163
|
for (const command of COMMANDS) {
|
|
162
164
|
const file = path.join(directory, command);
|
|
163
|
-
const target = path.join(packageDirectory, 'bin', `${command}.mjs`);
|
|
165
|
+
const target = path.join(packageDirectory, 'bin', `${command === 'dsh' ? 'deepseek' : command}.mjs`);
|
|
164
166
|
const info = await lstat(file).catch(() => null);
|
|
165
167
|
|
|
166
168
|
if (info?.isSymbolicLink()) {
|
|
167
|
-
const current = await
|
|
169
|
+
const current = await readlink(file).catch(() => null);
|
|
168
170
|
|
|
169
|
-
if (current === target) {
|
|
171
|
+
if (current && path.resolve(directory, current) === target) {
|
|
170
172
|
continue;
|
|
171
173
|
}
|
|
172
174
|
|
|
@@ -183,6 +185,11 @@ export async function linkCommands({ packageDirectory, env = process.env, log =
|
|
|
183
185
|
continue;
|
|
184
186
|
}
|
|
185
187
|
|
|
188
|
+
if (command === 'qwen' && await hasOtherCommand(command, target, env.PATH)) {
|
|
189
|
+
log('Команда qwen уже есть в PATH. Для Qwen в DSH используйте `dsh chat -p qwen`.');
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
186
193
|
await symlink(target, file);
|
|
187
194
|
log(`Команда ${command} → ${file}`);
|
|
188
195
|
}
|
|
@@ -190,6 +197,24 @@ export async function linkCommands({ packageDirectory, env = process.env, log =
|
|
|
190
197
|
return directory;
|
|
191
198
|
}
|
|
192
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Смотрим исполняемые файлы во всём PATH перед созданием необязательного алиаса.
|
|
202
|
+
* Символическая ссылка на тот же launcher не считается сторонней командой.
|
|
203
|
+
*/
|
|
204
|
+
async function hasOtherCommand(command, target, searchPath = '') {
|
|
205
|
+
for (const directory of searchPath.split(path.delimiter)) {
|
|
206
|
+
const candidate = path.resolve(directory, command);
|
|
207
|
+
const info = await stat(candidate).catch(() => null);
|
|
208
|
+
|
|
209
|
+
if (info?.isFile() && await access(candidate, constants.X_OK).then(() => true, () => false)
|
|
210
|
+
&& await realpathOrNull(candidate) !== target) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
|
|
193
218
|
async function executable(file) {
|
|
194
219
|
const info = await lstat(file).catch(() => null);
|
|
195
220
|
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* postinstall npm-пакета: ставит ELF версии пакета и связывает команды в ~/.local/bin.
|
|
4
4
|
* Отказ сети или контрольной суммы завершает установку кодом 1: пакет без ELF бесполезен,
|
|
5
|
-
* а `
|
|
5
|
+
* а `dsh install` повторяет попытку позже без переустановки пакета.
|
|
6
6
|
*/
|
|
7
7
|
import { install } from '../bin/launcher.mjs';
|
|
8
8
|
|
|
@@ -10,6 +10,6 @@ install({ log: (line) => process.stderr.write(`${line}\n`) }).then((code) => {
|
|
|
10
10
|
process.exitCode = code;
|
|
11
11
|
}, (error) => {
|
|
12
12
|
process.stderr.write(`Установка DeepSeek Harness не завершена: ${error.message}\n`
|
|
13
|
-
+ 'Повторите позже командой `
|
|
13
|
+
+ 'Повторите позже командой `dsh install` (нужна сеть до GitHub Releases).\n');
|
|
14
14
|
process.exitCode = 1;
|
|
15
15
|
});
|