@askdkc/dsh-cli 0.11.4 → 0.11.5
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 +16 -5
- package/lib/types/components/ModelPicker.d.ts +6 -0
- package/lib/types/components/ModelPicker.d.ts.map +1 -1
- package/lib/types/components/ModelPicker.js +9 -6
- package/lib/types/dsh-adapter/cli-registration.d.ts +17 -0
- package/lib/types/dsh-adapter/cli-registration.d.ts.map +1 -0
- package/lib/types/dsh-adapter/cli-registration.js +157 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +16 -0
- package/lib/types/i18n.d.ts +20 -4
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +5 -1
- package/lib/types/modelGroups.d.ts +2 -0
- package/lib/types/modelGroups.d.ts.map +1 -1
- package/lib/types/modelGroups.js +11 -0
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +147 -39
- package/lib/types/screens/chatOverlay.d.ts +6 -0
- package/lib/types/screens/chatOverlay.d.ts.map +1 -1
- package/lib/types/screens/chatOverlay.js +4 -0
- package/lib/types/screens/modelSearchInput.d.ts +4 -0
- package/lib/types/screens/modelSearchInput.d.ts.map +1 -0
- package/lib/types/screens/modelSearchInput.js +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,10 +109,18 @@ pnpm dsh --profile dsh-cli
|
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
Replace `~/DIR/TO/deepseek-harness` with your checkout path. The tarball name
|
|
112
|
-
comes from the package's current name, `@askdkc/dsh-cli`, and version.
|
|
113
|
-
|
|
114
|
-
`
|
|
115
|
-
|
|
112
|
+
comes from the package's current name, `@askdkc/dsh-cli`, and version. The
|
|
113
|
+
first interactive `dsh --profile dsh-cli` launch registers `dsh-cli` in
|
|
114
|
+
`~/.local/bin` (Windows: `%LOCALAPPDATA%\dsh-cli\bin`) and adds that directory
|
|
115
|
+
to the user's PATH when needed. Open a new shell before using the command.
|
|
116
|
+
Registration supports zsh, bash, fish and Windows; an existing unrelated
|
|
117
|
+
`dsh-cli` command is left alone. Set `DSH_TUI_AUTO_REGISTER_CLI=0` to disable
|
|
118
|
+
it. The managed PATH block goes in `${ZDOTDIR:-$HOME}/.zshrc` for zsh;
|
|
119
|
+
`.bashrc` and the active login file for bash; or
|
|
120
|
+
`${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/dsh-cli.fish` for fish. To undo
|
|
121
|
+
it, remove the managed command and that block; delete the fish file only if
|
|
122
|
+
it contains nothing else (Windows: remove the command and user PATH entry). The
|
|
123
|
+
existing `dsh-tui` and `dst` commands remain compatibility aliases.
|
|
116
124
|
A locally packed fork should be updated by rebuilding and reinstalling the
|
|
117
125
|
archive, rather than by using the registry-backed `/update` command.
|
|
118
126
|
|
|
@@ -191,7 +199,10 @@ Runtime path, module boundaries, performance notes and persistence locations: [A
|
|
|
191
199
|
## Known Limitations
|
|
192
200
|
|
|
193
201
|
- Injected plugin context has no standalone display; it counts into the context segments.
|
|
194
|
-
- `/model`
|
|
202
|
+
- `/model` filters by space-separated, case-insensitive keywords in any order.
|
|
203
|
+
At the provider level it searches every model; inside a provider or Recents
|
|
204
|
+
it searches that list. Names and IDs of models and providers are matched.
|
|
205
|
+
Switching forks the session; the old session stays in `/resume`.
|
|
195
206
|
- `Ctrl+V` needs platform clipboard tools; unsupported bitmap formats are rejected.
|
|
196
207
|
- A background session lives inside this process and stops when the TUI exits.
|
|
197
208
|
- `/thinking` is not persisted; `/compact` is unavailable under the `minimal` preset; `/update` needs a `dsh --profile` launch and is refused while a turn is running.
|
|
@@ -24,6 +24,9 @@ export declare function ModelPicker(props: {
|
|
|
24
24
|
/** Current route key — its group row carries the ✓ marker. */
|
|
25
25
|
currentProvider: string;
|
|
26
26
|
onPick?: (index: number) => void;
|
|
27
|
+
query?: string;
|
|
28
|
+
cursor?: number;
|
|
29
|
+
emptyReason?: 'loading' | 'empty' | 'no-match' | 'error';
|
|
27
30
|
} | {
|
|
28
31
|
/** Second level (or single-group fast path): one provider's models —
|
|
29
32
|
* or the mixed-provider recents list (`showProviderPrefix`). */
|
|
@@ -38,5 +41,8 @@ export declare function ModelPicker(props: {
|
|
|
38
41
|
/** `provider/model` of the current model — its row carries the ✓ marker. */
|
|
39
42
|
currentModel: string;
|
|
40
43
|
onPick?: (index: number) => void;
|
|
44
|
+
query?: string;
|
|
45
|
+
cursor?: number;
|
|
46
|
+
emptyReason?: 'loading' | 'empty' | 'no-match' | 'error';
|
|
41
47
|
}): React.ReactNode;
|
|
42
48
|
//# sourceMappingURL=ModelPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ModelPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"ModelPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ModelPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAUtD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAC7B;IACA,+DAA+D;IAC/D,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,8DAA8D;IAC9D,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAA;CACzD,GACC;IACA;qEACiE;IACjE,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;IAC/B,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kFAAkF;IAClF,QAAQ,EAAE,OAAO,CAAA;IACjB,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAA;CACzD,GAAG,KAAK,CAAC,SAAS,CA4EpB"}
|
|
@@ -7,6 +7,8 @@ import { ListItem } from './design-system/ListItem.js';
|
|
|
7
7
|
import { HintLine } from './design-system/HintLine.js';
|
|
8
8
|
import { listWindow } from './listWindow.js';
|
|
9
9
|
import { useOverlayListRows } from './OverlayAbove.js';
|
|
10
|
+
import { SearchBox } from './SearchBox.js';
|
|
11
|
+
import { useTerminalFocus } from '../ink/hooks/use-terminal-focus.js';
|
|
10
12
|
/**
|
|
11
13
|
* Model picker: a permission-colored Pane with
|
|
12
14
|
* the rows as Select entries (❯ focus pointer, ✓ on the active row,
|
|
@@ -25,27 +27,28 @@ import { useOverlayListRows } from './OverlayAbove.js';
|
|
|
25
27
|
*/
|
|
26
28
|
export function ModelPicker(props) {
|
|
27
29
|
const inGroups = 'groups' in props;
|
|
30
|
+
const terminalFocused = useTerminalFocus();
|
|
28
31
|
// Captured before the map: union narrowing does not survive into closures.
|
|
29
32
|
const onPick = props.onPick;
|
|
30
33
|
// 焦点窗口化按行预算:ListItem 带 description 时占 2 行(正文+描述,均
|
|
31
34
|
// truncate 成单行),只数项数会把焦点裁出浮层(二次审查实证)。
|
|
32
35
|
// 预算来自最近一层 OverlayAbove 的有效高度(已钳到输入簇上方的真实空间——
|
|
33
36
|
// 按 terminalRows 预算在短会话 + 高终端下窗口高过浮层、顶部整行被裁、
|
|
34
|
-
// 焦点行不可见,#493/#698),减去本面板框架行:Pane 2 + 标题 2 +
|
|
35
|
-
// + 挂载包裹 marginTop 1 =
|
|
37
|
+
// 焦点行不可见,#493/#698),减去本面板框架行:Pane 2 + 标题 2 +
|
|
38
|
+
// 搜索栏 1 + 结果数 1 + 页脚 1 + 挂载包裹 marginTop 1 = 8。
|
|
36
39
|
const rowHeights = inGroups
|
|
37
40
|
? props.groups.map(() => 2)
|
|
38
41
|
: props.models.map(m => (m.description ? 2 : 1));
|
|
39
42
|
const rows = inGroups ? props.groups : props.models;
|
|
40
|
-
const listRows = useOverlayListRows(
|
|
43
|
+
const listRows = useOverlayListRows(8);
|
|
41
44
|
const { start, end } = listWindow(rowHeights, props.focusIndex, listRows);
|
|
42
45
|
const hint = inGroups
|
|
43
46
|
? t('hint-model-groups')
|
|
44
47
|
: props.showBack ? t('hint-model-back') : t('hint-confirm-exit');
|
|
45
|
-
return (_jsxs(Pane, { color: "permission", children: [_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "remember", bold: true, children: inGroups || props.groupLabel === undefined ? t('picker-title-model') : props.groupLabel }) }), rows.slice(start, end).map((row, index) => {
|
|
48
|
+
return (_jsxs(Pane, { color: "permission", children: [_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "remember", bold: true, children: inGroups || props.groupLabel === undefined ? t('picker-title-model') : props.groupLabel }) }), _jsx(SearchBox, { query: props.query ?? '', cursorOffset: props.cursor ?? 0, isFocused: true, isTerminalFocused: terminalFocused, borderless: true, placeholder: t('picker-model-search') }), _jsx(Text, { dimColor: true, children: t('picker-model-results', { count: rows.length }) }), rows.length === 0 && _jsx(Text, { dimColor: true, children: t(props.emptyReason === 'loading' ? 'model-loading' : props.emptyReason === 'error' ? 'picker-model-error' : props.emptyReason === 'no-match' ? 'picker-model-no-match' : 'picker-model-empty') }), rows.slice(start, end).map((row, index) => {
|
|
46
49
|
const absoluteIndex = start + index;
|
|
47
|
-
return inGroups ? (_jsx(ListItem, { isFocused: absoluteIndex === props.focusIndex, isSelected: row.provider === props.currentProvider, description: t('picker-group-count', { count: row.count }), showScrollUp: absoluteIndex === start && start > 0, showScrollDown: absoluteIndex === end - 1 && end < rows.length, onClick: onPick ? () => onPick(absoluteIndex) : undefined, children: row.label === RECENTS_LABEL_PLACEHOLDER && row.provider === RECENTS_GROUP_PROVIDER
|
|
50
|
+
return inGroups ? (_jsx(ListItem, { isFocused: absoluteIndex === props.focusIndex, declareCursor: false, isSelected: row.provider === props.currentProvider, description: t('picker-group-count', { count: row.count }), showScrollUp: absoluteIndex === start && start > 0, showScrollDown: absoluteIndex === end - 1 && end < rows.length, onClick: onPick ? () => onPick(absoluteIndex) : undefined, children: row.label === RECENTS_LABEL_PLACEHOLDER && row.provider === RECENTS_GROUP_PROVIDER
|
|
48
51
|
? t('picker-group-recent')
|
|
49
|
-
: row.label }, row.provider)) : (_jsx(ListItem, { isFocused: absoluteIndex === props.focusIndex, isSelected: `${row.provider}/${row.id}` === props.currentModel, description: row.description, showScrollUp: absoluteIndex === start && start > 0, showScrollDown: absoluteIndex === end - 1 && end < rows.length, onClick: onPick ? () => onPick(absoluteIndex) : undefined, children: props.showProviderPrefix === true ? `${row.provider} / ${row.name}` : row.name }, `${row.provider}/${row.id}`));
|
|
52
|
+
: row.label }, row.provider)) : (_jsx(ListItem, { isFocused: absoluteIndex === props.focusIndex, declareCursor: false, isSelected: `${row.provider}/${row.id}` === props.currentModel, description: row.description, showScrollUp: absoluteIndex === start && start > 0, showScrollDown: absoluteIndex === end - 1 && end < rows.length, onClick: onPick ? () => onPick(absoluteIndex) : undefined, children: props.showProviderPrefix === true ? `${row.provider} / ${row.name}` : row.name }, `${row.provider}/${row.id}`));
|
|
50
53
|
})] }), _jsx(Text, { dimColor: true, italic: true, children: _jsx(HintLine, { text: hint }) })] }));
|
|
51
54
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CliRegistrationOptions {
|
|
2
|
+
home?: string;
|
|
3
|
+
dshHome?: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
shell?: string;
|
|
6
|
+
platform?: NodeJS.Platform;
|
|
7
|
+
zdotdir?: string;
|
|
8
|
+
xdgConfigHome?: string;
|
|
9
|
+
localAppData?: string;
|
|
10
|
+
windowsUserPath?: {
|
|
11
|
+
read(): string;
|
|
12
|
+
write(value: string): void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Register a user-owned launcher for the existing dsh-cli profile. No DSH state is changed. */
|
|
16
|
+
export declare function ensureCliRegistered(options?: CliRegistrationOptions): string;
|
|
17
|
+
//# sourceMappingURL=cli-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-registration.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/cli-registration.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE;QAAE,IAAI,IAAI,MAAM,CAAC;QAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CACjE;AA4DD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,CA0EhF"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { basename, dirname, join } from 'node:path';
|
|
5
|
+
const begin = '# BEGIN dsh-cli managed PATH';
|
|
6
|
+
const end = '# END dsh-cli managed PATH';
|
|
7
|
+
const marker = '# dsh-cli managed launcher';
|
|
8
|
+
function pathExists(path) {
|
|
9
|
+
try {
|
|
10
|
+
lstatSync(path);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function quoted(value) {
|
|
18
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
19
|
+
}
|
|
20
|
+
function atomicWrite(path, content, mode) {
|
|
21
|
+
const temporary = `${path}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
22
|
+
try {
|
|
23
|
+
writeFileSync(temporary, content, { flag: 'wx', mode });
|
|
24
|
+
renameSync(temporary, path);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
if (existsSync(temporary))
|
|
28
|
+
rmSync(temporary);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function updateOwnedFile(path, content, mode) {
|
|
32
|
+
const target = pathExists(path) && lstatSync(path).isSymbolicLink() ? realpathSync(path) : path;
|
|
33
|
+
if (pathExists(target)) {
|
|
34
|
+
const current = readFileSync(target, 'utf8');
|
|
35
|
+
if (current === content)
|
|
36
|
+
return false;
|
|
37
|
+
if (!current.startsWith(`#!/bin/sh\n${marker}`) && !current.startsWith('@echo off\r\nrem dsh-cli managed launcher\r\n')) {
|
|
38
|
+
throw new Error(`${path} already belongs to another command`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
42
|
+
atomicWrite(target, content, mode);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
function updateShellFile(path, line) {
|
|
46
|
+
const target = pathExists(path) && lstatSync(path).isSymbolicLink() ? realpathSync(path) : path;
|
|
47
|
+
const current = pathExists(target) ? readFileSync(target, 'utf8') : '';
|
|
48
|
+
const first = current.indexOf(begin);
|
|
49
|
+
const last = current.indexOf(end);
|
|
50
|
+
if ((first < 0) !== (last < 0) || (first >= 0 && (last < first || current.indexOf(begin, first + begin.length) >= 0 || current.indexOf(end, last + end.length) >= 0))) {
|
|
51
|
+
throw new Error(`malformed dsh-cli PATH block in ${path}`);
|
|
52
|
+
}
|
|
53
|
+
const block = `${begin}\n${line}\n${end}`;
|
|
54
|
+
const next = first < 0
|
|
55
|
+
? `${current}${current !== '' && !current.endsWith('\n') ? '\n' : ''}${block}\n`
|
|
56
|
+
: current.slice(0, first) + block + current.slice(last + end.length);
|
|
57
|
+
if (next === current)
|
|
58
|
+
return false;
|
|
59
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
60
|
+
atomicWrite(target, next, pathExists(target) ? statSync(target).mode : 0o600);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
function posixShellFiles(home, shell, zdotdir, xdg) {
|
|
64
|
+
switch (basename(shell)) {
|
|
65
|
+
case 'zsh': return [join(zdotdir || home, '.zshrc')];
|
|
66
|
+
case 'fish': return [join(xdg || join(home, '.config'), 'fish', 'conf.d', 'dsh-cli.fish')];
|
|
67
|
+
case 'bash': {
|
|
68
|
+
const login = ['.bash_profile', '.bash_login', '.profile'].map(name => join(home, name));
|
|
69
|
+
return [join(home, '.bashrc'), login.find(existsSync) ?? login[0]];
|
|
70
|
+
}
|
|
71
|
+
default: throw new Error(`unsupported shell ${shell}; add ~/.local/bin to PATH manually`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Register a user-owned launcher for the existing dsh-cli profile. No DSH state is changed. */
|
|
75
|
+
export function ensureCliRegistered(options = {}) {
|
|
76
|
+
const home = options.home ?? homedir();
|
|
77
|
+
const dshHome = options.dshHome ?? process.env.DSH_HOME ?? join(home, '.dsh');
|
|
78
|
+
const platform = options.platform ?? process.platform;
|
|
79
|
+
const shell = options.shell ?? process.env.SHELL ?? '';
|
|
80
|
+
const pathValue = options.path ?? process.env.PATH ?? '';
|
|
81
|
+
const binDir = platform === 'win32'
|
|
82
|
+
? join(options.localAppData ?? process.env.LOCALAPPDATA ?? join(home, 'AppData', 'Local'), 'dsh-cli', 'bin')
|
|
83
|
+
: join(home, '.local', 'bin');
|
|
84
|
+
const command = join(binDir, platform === 'win32' ? 'dsh-cli.cmd' : 'dsh-cli');
|
|
85
|
+
const profilePackage = join(dshHome, 'profiles', 'dsh-cli', 'node_modules', '@askdkc', 'dsh-cli');
|
|
86
|
+
try {
|
|
87
|
+
if (JSON.parse(readFileSync(join(profilePackage, 'package.json'), 'utf8')).name !== '@askdkc/dsh-cli') {
|
|
88
|
+
throw new Error('unexpected package identity');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
throw new Error(`dsh-cli profile package is missing or unreadable at ${profilePackage}`);
|
|
93
|
+
}
|
|
94
|
+
const currentCommand = pathValue.split(platform === 'win32' ? ';' : ':')
|
|
95
|
+
.map(dir => join(dir, platform === 'win32' ? 'dsh-cli.cmd' : 'dsh-cli'))
|
|
96
|
+
.find(candidate => candidate !== command && pathExists(candidate) && !candidate.includes(`${join('node_modules', '.bin')}`));
|
|
97
|
+
if (currentCommand !== undefined)
|
|
98
|
+
return `Existing dsh-cli command at ${currentCommand} was kept; automatic registration skipped.`;
|
|
99
|
+
mkdirSync(binDir, { recursive: true });
|
|
100
|
+
const lock = join(binDir, '.dsh-cli-registration.lock');
|
|
101
|
+
let handle;
|
|
102
|
+
try {
|
|
103
|
+
handle = openSync(lock, 'wx');
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
if (pathExists(lock) && Date.now() - statSync(lock).mtimeMs > 120000) {
|
|
107
|
+
rmSync(lock, { force: true });
|
|
108
|
+
handle = openSync(lock, 'wx');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw new Error(`registration is already running (${lock}); retry on next TUI start`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const target = join('profiles', 'dsh-cli', 'node_modules', '@askdkc', 'dsh-cli', 'bin', 'dsh-tui.js');
|
|
116
|
+
const content = platform === 'win32'
|
|
117
|
+
? `@echo off\r\nrem dsh-cli managed launcher\r\nsetlocal DisableDelayedExpansion\r\nif not defined DSH_HOME set "DSH_HOME=${dshHome.replace(/%/g, '%%')}"\r\nnode "%DSH_HOME%\\${target.replace(/\//g, '\\')}" %*\r\nexit /b %ERRORLEVEL%\r\n`
|
|
118
|
+
: `#!/bin/sh\n${marker}\nDEFAULT_DSH_HOME=${quoted(dshHome)}\n: "\${DSH_HOME:=$DEFAULT_DSH_HOME}"\nexport DSH_HOME\nexec node "$DSH_HOME/${target}" "$@"\n`;
|
|
119
|
+
let keepExistingDefault = false;
|
|
120
|
+
if (pathExists(command)) {
|
|
121
|
+
const existing = readFileSync(command, 'utf8');
|
|
122
|
+
keepExistingDefault = existing.startsWith(platform === 'win32' ? '@echo off\r\nrem dsh-cli managed launcher\r\n' : `#!/bin/sh\n${marker}\n`)
|
|
123
|
+
&& existing !== content;
|
|
124
|
+
}
|
|
125
|
+
const changed = keepExistingDefault ? false : updateOwnedFile(command, content, 0o755);
|
|
126
|
+
if (platform === 'win32') {
|
|
127
|
+
const userPath = options.windowsUserPath ?? {
|
|
128
|
+
read: () => execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', '[Environment]::GetEnvironmentVariable("Path", "User")'], { encoding: 'utf8', timeout: 5000 }).trim(),
|
|
129
|
+
write: (value) => {
|
|
130
|
+
execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', '[Environment]::SetEnvironmentVariable("Path", $env:DSH_CLI_USER_PATH, "User")'], {
|
|
131
|
+
env: { ...process.env, DSH_CLI_USER_PATH: value }, timeout: 5000,
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const current = userPath.read();
|
|
136
|
+
if (!current.split(';').some(part => part.toLowerCase() === binDir.toLowerCase())) {
|
|
137
|
+
const next = current ? `${current};${binDir}` : binDir;
|
|
138
|
+
userPath.write(next);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const files = posixShellFiles(home, shell, options.zdotdir ?? process.env.ZDOTDIR, options.xdgConfigHome ?? process.env.XDG_CONFIG_HOME);
|
|
143
|
+
const line = basename(shell) === 'fish'
|
|
144
|
+
? `contains -- ${quoted(binDir)} $PATH; or set -gx PATH ${quoted(binDir)} $PATH`
|
|
145
|
+
: `case ":$PATH:" in *:${quoted(binDir)}:*) ;; *) export PATH=${quoted(binDir)}:"$PATH" ;; esac`;
|
|
146
|
+
for (const file of files)
|
|
147
|
+
updateShellFile(file, line);
|
|
148
|
+
}
|
|
149
|
+
return keepExistingDefault
|
|
150
|
+
? `Kept ${command} with its original DSH_HOME default. Open a new shell to use dsh-cli; set DSH_HOME explicitly to use another installation.`
|
|
151
|
+
: changed ? `Registered ${command}. Open a new shell to use dsh-cli.` : `dsh-cli registration is current at ${command}.`;
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
closeSync(handle);
|
|
155
|
+
rmSync(lock, { force: true });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAe,MAAM,wBAAwB,CAAA;AA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ED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,KAAK,GAAG,SAAS,CAAA;IAC5B,YAAY,EAAE,KAAK,CAAA;CACpB,GAAG,OAAO,CAQV;AAgBD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,GAAG,SAAS,EACxD,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,IAAI,GACf,OAAO,CAAC,IAAI,CAAC,CAmFf;AA4HD,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAIrE"}
|
|
@@ -46,6 +46,7 @@ import { reserveMount } from '../sessionMounts.js';
|
|
|
46
46
|
import { getHostDialogStore } from './dialogs.js';
|
|
47
47
|
import { getHostStatusStore } from './status.js';
|
|
48
48
|
import { createActivityStore } from './activity-store.js';
|
|
49
|
+
import { ensureCliRegistered } from './cli-registration.js';
|
|
49
50
|
import { getHostToastStore } from './toast.js';
|
|
50
51
|
import { getHostShortcuts } from './shortcuts.js';
|
|
51
52
|
import { getHostThemes } from './themes.js';
|
|
@@ -210,6 +211,21 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx) {
|
|
|
210
211
|
// render so every module resolves strings in the same language.
|
|
211
212
|
const envLang = process.env.DSH_TUI_LANG;
|
|
212
213
|
setLang(isLang(envLang) ? envLang : isLang(config.lang) ? config.lang : resolveStartupLang());
|
|
214
|
+
if (resolveDshProfileName() === 'dsh-cli'
|
|
215
|
+
&& !isStandaloneRuntime()
|
|
216
|
+
&& !process.env.CI
|
|
217
|
+
&& process.env.DSH_TUI_AUTO_REGISTER_CLI !== '0') {
|
|
218
|
+
try {
|
|
219
|
+
const result = ensureCliRegistered();
|
|
220
|
+
if (result.startsWith('Registered ') || result.startsWith('Kept '))
|
|
221
|
+
ctx.logger.info(`dsh-tui: ${result}`);
|
|
222
|
+
else if (result.startsWith('Existing '))
|
|
223
|
+
ctx.logger.warn(`dsh-tui: ${result} Remove the conflicting command or adjust PATH, then restart the TUI.`);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
ctx.logger.warn(`dsh-tui: dsh-cli command registration failed: ${error instanceof Error ? error.message : String(error)}. Resolve the reported path or permission issue, then restart the TUI; set DSH_TUI_AUTO_REGISTER_CLI=0 to disable registration.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
213
229
|
// /update restart verification: the pre-update process stamps the version
|
|
214
230
|
// it was leaving behind; if the freshly loaded one is not newer, the
|
|
215
231
|
// package manager "succeeded" without actually moving the version (mirror
|
package/lib/types/i18n.d.ts
CHANGED
|
@@ -2884,6 +2884,26 @@ declare const dict: {
|
|
|
2884
2884
|
readonly zh: "{{count}} 个模型";
|
|
2885
2885
|
readonly en: "{{count}} models";
|
|
2886
2886
|
};
|
|
2887
|
+
readonly 'picker-model-search': {
|
|
2888
|
+
readonly zh: "输入关键词筛选模型";
|
|
2889
|
+
readonly en: "Type keywords to filter models";
|
|
2890
|
+
};
|
|
2891
|
+
readonly 'picker-model-results': {
|
|
2892
|
+
readonly zh: "{{count}} 个结果";
|
|
2893
|
+
readonly en: "{{count}} results";
|
|
2894
|
+
};
|
|
2895
|
+
readonly 'picker-model-empty': {
|
|
2896
|
+
readonly zh: "没有可用模型";
|
|
2897
|
+
readonly en: "No models available";
|
|
2898
|
+
};
|
|
2899
|
+
readonly 'picker-model-no-match': {
|
|
2900
|
+
readonly zh: "没有匹配的模型";
|
|
2901
|
+
readonly en: "No matching models";
|
|
2902
|
+
};
|
|
2903
|
+
readonly 'picker-model-error': {
|
|
2904
|
+
readonly zh: "模型列表获取失败,请重新打开 /model";
|
|
2905
|
+
readonly en: "Could not load models; reopen /model to retry";
|
|
2906
|
+
};
|
|
2887
2907
|
readonly 'hint-model-groups': {
|
|
2888
2908
|
readonly zh: "**Enter** 查看模型 · Esc 退出";
|
|
2889
2909
|
readonly en: "**Enter** to view models · Esc to exit";
|
|
@@ -2964,10 +2984,6 @@ declare const dict: {
|
|
|
2964
2984
|
readonly zh: "正在加载模型";
|
|
2965
2985
|
readonly en: "Loading models";
|
|
2966
2986
|
};
|
|
2967
|
-
readonly 'model-loading-subtitle': {
|
|
2968
|
-
readonly zh: "正在查询 provider…";
|
|
2969
|
-
readonly en: "Querying the provider…";
|
|
2970
|
-
};
|
|
2971
2987
|
readonly 'model-switching': {
|
|
2972
2988
|
readonly zh: "正在切换模型到 {{name}}…";
|
|
2973
2989
|
readonly en: "Switching model to {{name}}…";
|
package/lib/types/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAMH,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAI9B,+DAA+D;AAC/D,eAAO,MAAM,KAAK,uBAAwB,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9D,QAAA,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAMH,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAI9B,+DAA+D;AAC/D,eAAO,MAAM,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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAQ,CAAA;AAI1G;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAS5D;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAkB,GAAG,IAAI,GAAG,SAAS,CAMtE;AAED,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,MAAkB,GAAG,OAAO,CAU1E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAWvC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC"}
|
package/lib/types/i18n.js
CHANGED
|
@@ -900,6 +900,11 @@ const dict = {
|
|
|
900
900
|
'picker-title-model': { zh: '模型', en: 'Model' },
|
|
901
901
|
'picker-group-recent': { zh: '最近使用', en: 'Recently used' },
|
|
902
902
|
'picker-group-count': { zh: '{{count}} 个模型', en: '{{count}} models' },
|
|
903
|
+
'picker-model-search': { zh: '输入关键词筛选模型', en: 'Type keywords to filter models' },
|
|
904
|
+
'picker-model-results': { zh: '{{count}} 个结果', en: '{{count}} results' },
|
|
905
|
+
'picker-model-empty': { zh: '没有可用模型', en: 'No models available' },
|
|
906
|
+
'picker-model-no-match': { zh: '没有匹配的模型', en: 'No matching models' },
|
|
907
|
+
'picker-model-error': { zh: '模型列表获取失败,请重新打开 /model', en: 'Could not load models; reopen /model to retry' },
|
|
903
908
|
'hint-model-groups': { zh: '**Enter** 查看模型 · Esc 退出', en: '**Enter** to view models · Esc to exit' },
|
|
904
909
|
'hint-model-back': { zh: '**Enter** 切换模型 · Esc/⌫ 返回上级', en: '**Enter** to switch · Esc/⌫ to go back' },
|
|
905
910
|
'picker-title-skills': { zh: '技能', en: 'Skills' },
|
|
@@ -920,7 +925,6 @@ const dict = {
|
|
|
920
925
|
'picker-title-color': { zh: '会话强调色', en: 'Session accent color' },
|
|
921
926
|
'picker-title-effort': { zh: '推理强度', en: 'Reasoning effort' },
|
|
922
927
|
'model-loading': { zh: '正在加载模型', en: 'Loading models' },
|
|
923
|
-
'model-loading-subtitle': { zh: '正在查询 provider…', en: 'Querying the provider…' },
|
|
924
928
|
'model-switching': { zh: '正在切换模型到 {{name}}…', en: 'Switching model to {{name}}…' },
|
|
925
929
|
'model-switched': { zh: '模型已切换为 {{name}}', en: 'Model switched to {{name}}' },
|
|
926
930
|
// ── components/RewindPicker.tsx ─────────────────────────────────────
|
|
@@ -31,6 +31,8 @@ export interface ModelGroupRow {
|
|
|
31
31
|
/** How many of the listed models belong to this provider. */
|
|
32
32
|
readonly count: number;
|
|
33
33
|
}
|
|
34
|
+
/** Literal, case-insensitive AND matching across a model's identifying fields. */
|
|
35
|
+
export declare function filterModels(models: readonly LlmModelInfo[], query: string, providers: readonly LlmProviderInfo[]): readonly LlmModelInfo[];
|
|
34
36
|
/**
|
|
35
37
|
* The recent refs that the current catalog still lists, most-recent-first —
|
|
36
38
|
* the second level of the recents group. Refs whose model vanished from the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelGroups.d.ts","sourceRoot":"","sources":["../../src/modelGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEpF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,gBAAgB,CAAA;AAEnD,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,eAAe,CAAA;AAErD,8EAA8E;AAC9E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAA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AE,GAC5B,kBAAkB,CAiBpB"}
|
package/lib/types/modelGroups.js
CHANGED
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
export const RECENTS_GROUP_PROVIDER = '__recents__';
|
|
17
17
|
/** The recents row's raw label; renderers replace it with the localized one. */
|
|
18
18
|
export const RECENTS_LABEL_PLACEHOLDER = '__recent__';
|
|
19
|
+
/** Literal, case-insensitive AND matching across a model's identifying fields. */
|
|
20
|
+
export function filterModels(models, query, providers) {
|
|
21
|
+
const terms = query.trim().toLowerCase().split(/\s+/u).filter(Boolean);
|
|
22
|
+
if (terms.length === 0)
|
|
23
|
+
return models;
|
|
24
|
+
return models.filter(model => {
|
|
25
|
+
const providerName = providers.find(provider => provider.id === model.provider)?.name ?? '';
|
|
26
|
+
const fields = [model.name, model.id, model.provider, providerName].map(value => value.toLowerCase());
|
|
27
|
+
return terms.every(term => fields.some(field => field.includes(term)));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
19
30
|
/**
|
|
20
31
|
* The recent refs that the current catalog still lists, most-recent-first —
|
|
21
32
|
* the second level of the recents group. Refs whose model vanished from the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/screens/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/screens/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AA6BzB,OAAO,KAAK,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,iCAAiC,CAAA;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAwB,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAe,MAAM,kCAAkC,CAAA;A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O,CAAA;IACpB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IAC9D;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC/D,4BAilJA"}
|
|
@@ -17,7 +17,8 @@ import { formatTokens } from '../terminal-utils/format.js';
|
|
|
17
17
|
import { homeDir } from '../utils/paths.js';
|
|
18
18
|
import { execFileNoThrow } from '../utils/execFileNoThrow.js';
|
|
19
19
|
import { cleanRenderText, cleanScalarText } from '../dsh-adapter/sanitize.js';
|
|
20
|
-
import {
|
|
20
|
+
import { nextModelQueryBoundary, previousModelQueryBoundary } from './modelSearchInput.js';
|
|
21
|
+
import { deriveModelGroups, filterModels, modelPickerLanding, recentCatalogModels, RECENTS_GROUP_PROVIDER, } from '../modelGroups.js';
|
|
21
22
|
import { readModelRecents, recordModelUse } from '../modelRecents.js';
|
|
22
23
|
import { TuiDialogStore } from '../dsh-adapter/dialogs.js';
|
|
23
24
|
import { TuiStatusStore } from '../dsh-adapter/status.js';
|
|
@@ -99,8 +100,6 @@ import { markHomeSeen } from '../homePrefs.js';
|
|
|
99
100
|
import { extendTrajectory, projectWave } from '../dsh-adapter/trajectory/index.js';
|
|
100
101
|
import { miniWakeWidth } from '../components/trajectory/MiniWake.js';
|
|
101
102
|
import { readTrajectorySeen, writeTrajectorySeen } from '../trajectoryPrefs.js';
|
|
102
|
-
import { LoadingState } from '../components/design-system/LoadingState.js';
|
|
103
|
-
import { Pane } from '../components/design-system/Pane.js';
|
|
104
103
|
import { loadHistory } from '../history.js';
|
|
105
104
|
import { formatLoadedContextReport } from '../utils/loaded-context.js';
|
|
106
105
|
import { NO_OVERLAY, chatOverlayReducer, dialogOverlayVisible, wrapIndex, } from './chatOverlay.js';
|
|
@@ -343,18 +342,10 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
343
342
|
}
|
|
344
343
|
}, [overlay]);
|
|
345
344
|
const [models, setModels] = React.useState([]);
|
|
345
|
+
const [modelCatalogStatus, setModelCatalogStatus] = React.useState('loading');
|
|
346
|
+
const modelRequestRef = React.useRef(0);
|
|
346
347
|
/** Provider display identities for the /model group level; refreshed alongside `models`. */
|
|
347
348
|
const [providerInfos, setProviderInfos] = React.useState([]);
|
|
348
|
-
React.useEffect(() => {
|
|
349
|
-
const subscribe = channel.providerSetup?.()?.oauth?.onCredentialChange;
|
|
350
|
-
if (subscribe === undefined)
|
|
351
|
-
return;
|
|
352
|
-
return subscribe(() => {
|
|
353
|
-
channel.invalidateModelCompletion();
|
|
354
|
-
void channel.listModels().then(setModels).catch(() => setModels([]));
|
|
355
|
-
void channel.listProviders().then(setProviderInfos).catch(() => setProviderInfos([]));
|
|
356
|
-
});
|
|
357
|
-
}, [channel]);
|
|
358
349
|
/** /model 最近使用分组:成功切换即记录(去重置顶,上限 10),重启保留。 */
|
|
359
350
|
const [modelRecents, setModelRecents] = React.useState(() => readModelRecents());
|
|
360
351
|
/** Two-level /model: the drilled-in provider route; undefined = group level.
|
|
@@ -379,6 +370,69 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
379
370
|
return recentCatalogModels(modelRecents, models);
|
|
380
371
|
return models.filter(model => model.provider === activeModelGroup);
|
|
381
372
|
}, [models, modelRecents, activeModelGroup]);
|
|
373
|
+
const modelQuery = overlay.kind === 'model' ? (overlay.query ?? '') : '';
|
|
374
|
+
const modelSearchActive = modelQuery.trim() !== '';
|
|
375
|
+
const visibleModelRows = React.useMemo(() => filterModels(activeModelGroup === undefined ? models : groupModels, modelQuery, providerInfos), [activeModelGroup, groupModels, models, modelQuery, providerInfos]);
|
|
376
|
+
const visibleModelGroups = activeModelGroup === undefined && !modelSearchActive ? modelGroups : [];
|
|
377
|
+
const modelRowsAreGroups = activeModelGroup === undefined && !modelSearchActive;
|
|
378
|
+
const modelRowCount = modelRowsAreGroups ? visibleModelGroups.length : visibleModelRows.length;
|
|
379
|
+
const modelFocus = overlay.kind === 'model'
|
|
380
|
+
? Math.max(0, Math.min(overlay.index, modelRowCount - 1))
|
|
381
|
+
: 0;
|
|
382
|
+
const modelFocusedRef = React.useRef(null);
|
|
383
|
+
React.useEffect(() => {
|
|
384
|
+
modelFocusedRef.current = overlay.kind === 'model' ? {
|
|
385
|
+
query: modelQuery,
|
|
386
|
+
group: activeModelGroup,
|
|
387
|
+
provider: modelRowsAreGroups ? undefined : visibleModelRows[modelFocus]?.provider,
|
|
388
|
+
id: modelRowsAreGroups ? undefined : visibleModelRows[modelFocus]?.id,
|
|
389
|
+
groupKey: modelRowsAreGroups ? visibleModelGroups[modelFocus]?.provider : undefined,
|
|
390
|
+
} : null;
|
|
391
|
+
}, [overlay, modelQuery, activeModelGroup, modelRowsAreGroups, visibleModelRows, visibleModelGroups, modelFocus]);
|
|
392
|
+
React.useEffect(() => {
|
|
393
|
+
const subscribe = channel.providerSetup?.()?.oauth?.onCredentialChange;
|
|
394
|
+
if (subscribe === undefined)
|
|
395
|
+
return;
|
|
396
|
+
return subscribe(() => {
|
|
397
|
+
channel.invalidateModelCompletion();
|
|
398
|
+
const request = ++modelRequestRef.current;
|
|
399
|
+
void channel.listModels().then(list => {
|
|
400
|
+
if (request !== modelRequestRef.current)
|
|
401
|
+
return;
|
|
402
|
+
const focused = modelFocusedRef.current;
|
|
403
|
+
if (focused !== null) {
|
|
404
|
+
const freshGroups = deriveModelGroups(list, providerInfos, modelRecents);
|
|
405
|
+
if (focused.group !== undefined && !freshGroups.some(group => group.provider === focused.group)) {
|
|
406
|
+
setModelGroup(undefined);
|
|
407
|
+
setModelPickerDirect(false);
|
|
408
|
+
dispatchOverlay({ type: 'model-edit', query: '', cursor: 0 });
|
|
409
|
+
dispatchOverlay({ type: 'set-index', kind: 'model', index: 0 });
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
const scope = focused.group === undefined ? list
|
|
413
|
+
: focused.group === RECENTS_GROUP_PROVIDER ? recentCatalogModels(modelRecents, list)
|
|
414
|
+
: list.filter(model => model.provider === focused.group);
|
|
415
|
+
const rows = filterModels(scope, focused.query, providerInfos);
|
|
416
|
+
const index = focused.group === undefined && focused.query.trim() === ''
|
|
417
|
+
? freshGroups.findIndex(group => group.provider === focused.groupKey)
|
|
418
|
+
: rows.findIndex(model => model.provider === focused.provider && model.id === focused.id);
|
|
419
|
+
dispatchOverlay({ type: 'set-index', kind: 'model', index: Math.max(0, index) });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
setModels(list);
|
|
423
|
+
setModelCatalogStatus('ready');
|
|
424
|
+
}).catch(() => {
|
|
425
|
+
if (request === modelRequestRef.current) {
|
|
426
|
+
setModelCatalogStatus('error');
|
|
427
|
+
channel.notify(t('picker-model-error'), { color: 'warning' });
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
void channel.listProviders().then(list => {
|
|
431
|
+
if (request === modelRequestRef.current)
|
|
432
|
+
setProviderInfos(list);
|
|
433
|
+
}).catch(() => undefined);
|
|
434
|
+
});
|
|
435
|
+
}, [channel, providerInfos, modelRecents]);
|
|
382
436
|
/** Switch + record: every successful switch feeds the /model recents group
|
|
383
437
|
* (picker Enter/click, `/model provider/id`, the wizard's live switch,
|
|
384
438
|
* and /reload's applied model all ride this one path). */
|
|
@@ -1809,16 +1863,51 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
1809
1863
|
const landing = modelPickerLanding(models, channel.provider, channel.model, recentsNow);
|
|
1810
1864
|
setModelGroup(landing.group);
|
|
1811
1865
|
setModelPickerDirect(landing.group !== undefined);
|
|
1812
|
-
dispatchOverlay({ type: 'open', overlay: { kind: 'model', index: landing.index } });
|
|
1866
|
+
dispatchOverlay({ type: 'open', overlay: { kind: 'model', index: landing.index, query: '', cursor: 0 } });
|
|
1813
1867
|
}
|
|
1868
|
+
const modelRequest = ++modelRequestRef.current;
|
|
1869
|
+
setModelCatalogStatus('loading');
|
|
1814
1870
|
void channel.listModels().then((list) => {
|
|
1871
|
+
if (modelRequest !== modelRequestRef.current)
|
|
1872
|
+
return;
|
|
1873
|
+
const focused = modelFocusedRef.current;
|
|
1874
|
+
if (models.length === 0 && (focused === null || (focused.group === undefined && focused.query === ''))) {
|
|
1875
|
+
const landing = modelPickerLanding(list, channel.provider, channel.model, recentsNow);
|
|
1876
|
+
setModelGroup(landing.group);
|
|
1877
|
+
setModelPickerDirect(landing.group !== undefined);
|
|
1878
|
+
dispatchOverlay({ type: 'set-index', kind: 'model', index: landing.index });
|
|
1879
|
+
}
|
|
1880
|
+
else if (focused !== null) {
|
|
1881
|
+
const freshGroups = deriveModelGroups(list, providerInfos, recentsNow);
|
|
1882
|
+
if (focused.group !== undefined && !freshGroups.some(group => group.provider === focused.group)) {
|
|
1883
|
+
setModelGroup(undefined);
|
|
1884
|
+
setModelPickerDirect(false);
|
|
1885
|
+
dispatchOverlay({ type: 'model-edit', query: '', cursor: 0 });
|
|
1886
|
+
dispatchOverlay({ type: 'set-index', kind: 'model', index: 0 });
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
const scope = focused.group === undefined ? list
|
|
1890
|
+
: focused.group === RECENTS_GROUP_PROVIDER ? recentCatalogModels(recentsNow, list)
|
|
1891
|
+
: list.filter(model => model.provider === focused.group);
|
|
1892
|
+
const rows = filterModels(scope, focused.query, providerInfos);
|
|
1893
|
+
const index = focused.group === undefined && focused.query.trim() === ''
|
|
1894
|
+
? freshGroups.findIndex(group => group.provider === focused.groupKey)
|
|
1895
|
+
: rows.findIndex(model => model.provider === focused.provider && model.id === focused.id);
|
|
1896
|
+
dispatchOverlay({ type: 'set-index', kind: 'model', index: Math.max(0, index) });
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1815
1899
|
setModels(list);
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1900
|
+
setModelCatalogStatus('ready');
|
|
1901
|
+
}).catch(() => {
|
|
1902
|
+
if (modelRequest === modelRequestRef.current) {
|
|
1903
|
+
setModelCatalogStatus('error');
|
|
1904
|
+
channel.notify(t('picker-model-error'), { color: 'warning' });
|
|
1905
|
+
}
|
|
1820
1906
|
});
|
|
1821
|
-
void channel.listProviders().then(
|
|
1907
|
+
void channel.listProviders().then(list => {
|
|
1908
|
+
if (modelRequest === modelRequestRef.current)
|
|
1909
|
+
setProviderInfos(list);
|
|
1910
|
+
}).catch(() => undefined);
|
|
1822
1911
|
return true;
|
|
1823
1912
|
}
|
|
1824
1913
|
case 'skills': {
|
|
@@ -3176,22 +3265,24 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
3176
3265
|
return;
|
|
3177
3266
|
}
|
|
3178
3267
|
if (overlay.kind === 'model') {
|
|
3268
|
+
event.stopImmediatePropagation();
|
|
3179
3269
|
// Two-level picker: group rows at the top (Enter drills in), one
|
|
3180
3270
|
// provider's models below (Enter switches, the same live-fork path as
|
|
3181
3271
|
// the flat picker always had). Esc/⌫ climbs one level and only closes
|
|
3182
3272
|
// at the top; a single-group catalog never shows the group level, so
|
|
3183
3273
|
// Esc there closes directly.
|
|
3184
|
-
const rowCount =
|
|
3274
|
+
const rowCount = modelRowCount;
|
|
3275
|
+
const query = overlay.query ?? '';
|
|
3276
|
+
const cursor = overlay.cursor ?? query.length;
|
|
3277
|
+
const editModelQuery = (value, nextCursor) => dispatchOverlay({ type: 'model-edit', query: value, cursor: nextCursor });
|
|
3185
3278
|
if (key.upArrow || key.downArrow) {
|
|
3186
3279
|
dispatchOverlay({ type: 'move', delta: key.upArrow ? -1 : 1, count: rowCount });
|
|
3187
3280
|
}
|
|
3188
3281
|
else if (plainReturn) {
|
|
3189
|
-
if (
|
|
3190
|
-
const group =
|
|
3191
|
-
if (!group)
|
|
3192
|
-
dispatchOverlay({ type: 'close' });
|
|
3282
|
+
if (modelRowsAreGroups) {
|
|
3283
|
+
const group = visibleModelGroups[modelFocus];
|
|
3284
|
+
if (!group)
|
|
3193
3285
|
return;
|
|
3194
|
-
}
|
|
3195
3286
|
setModelGroup(group.provider);
|
|
3196
3287
|
// The recents group opens on its most-recent entry; a provider
|
|
3197
3288
|
// group on its current model when it owns one, else its first row.
|
|
@@ -3203,7 +3294,7 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
3203
3294
|
dispatchOverlay({ type: 'set-index', kind: 'model', index: landing.index });
|
|
3204
3295
|
return;
|
|
3205
3296
|
}
|
|
3206
|
-
const model =
|
|
3297
|
+
const model = visibleModelRows[modelFocus];
|
|
3207
3298
|
// oxlint-disable-next-line typescript/no-unnecessary-condition -- runtime guard: out-of-range index on an empty list
|
|
3208
3299
|
if (model) {
|
|
3209
3300
|
// Enter switches the live model right away: the conversation is
|
|
@@ -3212,20 +3303,41 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
3212
3303
|
dispatchOverlay({ type: 'close' });
|
|
3213
3304
|
void switchModelRecorded(model.provider, model.id, model.name);
|
|
3214
3305
|
}
|
|
3215
|
-
else {
|
|
3216
|
-
dispatchOverlay({ type: 'close' });
|
|
3217
|
-
}
|
|
3218
3306
|
}
|
|
3219
|
-
else if (key.
|
|
3307
|
+
else if (key.backspace && cursor > 0) {
|
|
3308
|
+
const start = previousModelQueryBoundary(query, cursor);
|
|
3309
|
+
editModelQuery(query.slice(0, start) + query.slice(cursor), start);
|
|
3310
|
+
}
|
|
3311
|
+
else if (key.delete && cursor < query.length) {
|
|
3312
|
+
editModelQuery(query.slice(0, cursor) + query.slice(nextModelQueryBoundary(query, cursor)), cursor);
|
|
3313
|
+
}
|
|
3314
|
+
else if (key.leftArrow && cursor > 0) {
|
|
3315
|
+
editModelQuery(query, previousModelQueryBoundary(query, cursor));
|
|
3316
|
+
}
|
|
3317
|
+
else if (key.rightArrow && cursor < query.length) {
|
|
3318
|
+
editModelQuery(query, nextModelQueryBoundary(query, cursor));
|
|
3319
|
+
}
|
|
3320
|
+
else if (key.home) {
|
|
3321
|
+
editModelQuery(query, 0);
|
|
3322
|
+
}
|
|
3323
|
+
else if (key.end) {
|
|
3324
|
+
editModelQuery(query, query.length);
|
|
3325
|
+
}
|
|
3326
|
+
else if (key.escape || (key.backspace && query === '')) {
|
|
3220
3327
|
if (activeModelGroup !== undefined && modelGroups.length > 1 && !modelPickerDirect) {
|
|
3221
3328
|
setModelGroup(undefined);
|
|
3222
3329
|
const groupIndex = Math.max(0, modelGroups.findIndex(group => group.provider === activeModelGroup));
|
|
3330
|
+
dispatchOverlay({ type: 'model-edit', query: '', cursor: 0 });
|
|
3223
3331
|
dispatchOverlay({ type: 'set-index', kind: 'model', index: groupIndex });
|
|
3224
3332
|
}
|
|
3225
3333
|
else {
|
|
3226
3334
|
dispatchOverlay({ type: 'close' });
|
|
3227
3335
|
}
|
|
3228
3336
|
}
|
|
3337
|
+
else if (input.length > 0 && !key.ctrl && !key.meta && !key.super) {
|
|
3338
|
+
const inserted = input.replace(/[\r\n\t]+/gu, ' ');
|
|
3339
|
+
editModelQuery(query.slice(0, cursor) + inserted + query.slice(cursor), cursor + inserted.length);
|
|
3340
|
+
}
|
|
3229
3341
|
return;
|
|
3230
3342
|
}
|
|
3231
3343
|
if (overlay.kind === 'skills') {
|
|
@@ -4142,9 +4254,9 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
4142
4254
|
return;
|
|
4143
4255
|
dispatchOverlay({ type: 'set-index', kind: 'workspace-flow', index });
|
|
4144
4256
|
runWorkspaceFlowAction(signal => choice.choose(signal));
|
|
4145
|
-
} }) })), overlay.kind === 'model' && (_jsx(Box, { flexDirection: "column", marginTop: 1, children: models.length === 0 ?
|
|
4257
|
+
} }) })), overlay.kind === 'model' && (_jsx(Box, { flexDirection: "column", marginTop: 1, children: modelRowsAreGroups ? (_jsx(ModelPicker, { groups: visibleModelGroups, query: modelQuery, cursor: overlay.cursor ?? modelQuery.length, emptyReason: modelCatalogStatus === 'loading' && models.length === 0 ? 'loading' : modelCatalogStatus === 'error' ? 'error' : 'empty', focusIndex: modelFocus, currentProvider: channel.provider, onPick: (index) => {
|
|
4146
4258
|
// 点击分组行 = 进入该组(与 Enter 同一条路径)
|
|
4147
|
-
const group =
|
|
4259
|
+
const group = visibleModelGroups[index];
|
|
4148
4260
|
if (!group)
|
|
4149
4261
|
return;
|
|
4150
4262
|
setModelGroup(group.provider);
|
|
@@ -4154,11 +4266,11 @@ export function Chat({ channel, questionStore, approvalStore, extensionDialogs,
|
|
|
4154
4266
|
}
|
|
4155
4267
|
const landing = modelPickerLanding(models.filter(model => model.provider === group.provider), channel.provider, channel.model);
|
|
4156
4268
|
dispatchOverlay({ type: 'set-index', kind: 'model', index: landing.index });
|
|
4157
|
-
} })) : (_jsx(ModelPicker, { models:
|
|
4269
|
+
} })) : (_jsx(ModelPicker, { models: visibleModelRows, query: modelQuery, cursor: overlay.cursor ?? modelQuery.length, emptyReason: modelCatalogStatus === 'loading' && models.length === 0 ? 'loading' : modelCatalogStatus === 'error' ? 'error' : models.length === 0 ? 'empty' : 'no-match', groupLabel: activeModelGroup === RECENTS_GROUP_PROVIDER
|
|
4158
4270
|
? t('picker-group-recent')
|
|
4159
|
-
: modelGroups.find(group => group.provider === activeModelGroup)?.label, showBack: modelGroups.length > 1 && !modelPickerDirect, showProviderPrefix: activeModelGroup === RECENTS_GROUP_PROVIDER, focusIndex:
|
|
4271
|
+
: modelGroups.find(group => group.provider === activeModelGroup)?.label, showBack: modelGroups.length > 1 && !modelPickerDirect, showProviderPrefix: activeModelGroup === RECENTS_GROUP_PROVIDER || activeModelGroup === undefined, focusIndex: modelFocus, currentModel: `${channel.provider}/${channel.model}`, onPick: (index) => {
|
|
4160
4272
|
// 点击行 = 应用该行模型(与 Enter 同一条路径)
|
|
4161
|
-
const model =
|
|
4273
|
+
const model = visibleModelRows[index];
|
|
4162
4274
|
if (!model)
|
|
4163
4275
|
return;
|
|
4164
4276
|
dispatchOverlay({ type: 'close' });
|
|
@@ -4285,10 +4397,6 @@ function NewMessagesPill({ count, onClick, }) {
|
|
|
4285
4397
|
? t(count === 1 ? 'new-message' : 'new-messages', { n: count })
|
|
4286
4398
|
: t('back-to-bottom'), ' '] }) }) }));
|
|
4287
4399
|
}
|
|
4288
|
-
/** /model while the provider catalog is still loading. */
|
|
4289
|
-
function ModelPickerLoading() {
|
|
4290
|
-
return (_jsx(Pane, { color: "permission", children: _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Text, { bold: true, color: "permission", children: t('picker-title-model') }), _jsx(LoadingState, { message: t('model-loading'), bold: true, subtitle: t('model-loading-subtitle') })] }) }));
|
|
4291
|
-
}
|
|
4292
4400
|
/**
|
|
4293
4401
|
* The `/` incsearch bar: a
|
|
4294
4402
|
* single row above the prompt input with the query, a block cursor, and the
|
|
@@ -63,6 +63,8 @@ export type ChatOverlay = {
|
|
|
63
63
|
} | {
|
|
64
64
|
kind: 'model';
|
|
65
65
|
index: number;
|
|
66
|
+
query?: string;
|
|
67
|
+
cursor?: number;
|
|
66
68
|
} | {
|
|
67
69
|
kind: 'skills';
|
|
68
70
|
index: number;
|
|
@@ -204,6 +206,10 @@ export type ChatOverlayAction =
|
|
|
204
206
|
query?: string;
|
|
205
207
|
cursor?: number;
|
|
206
208
|
focus?: number;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'model-edit';
|
|
211
|
+
query: string;
|
|
212
|
+
cursor: number;
|
|
207
213
|
}
|
|
208
214
|
/** Workspace flow: an action is running (keys except Esc are swallowed). */
|
|
209
215
|
| {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatOverlay.d.ts","sourceRoot":"","sources":["../../../src/screens/chatOverlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,OAAO,E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AAoB,EAAE,MAAM,CAAA;IAC5B,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,GACA,OAAO,CAmBT"}
|
|
@@ -69,6 +69,10 @@ export function chatOverlayReducer(state, action) {
|
|
|
69
69
|
}
|
|
70
70
|
case 'set-index':
|
|
71
71
|
return state.kind === action.kind ? { ...state, index: action.index } : state;
|
|
72
|
+
case 'model-edit':
|
|
73
|
+
return state.kind === 'model'
|
|
74
|
+
? { ...state, query: action.query, cursor: action.cursor, index: action.query === (state.query ?? '') ? state.index : 0 }
|
|
75
|
+
: state;
|
|
72
76
|
case 'history-edit':
|
|
73
77
|
return state.kind === 'history'
|
|
74
78
|
? {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** UTF-16 offsets used by SearchBox, stepped at complete Unicode characters. */
|
|
2
|
+
export declare function previousModelQueryBoundary(query: string, cursor: number): number;
|
|
3
|
+
export declare function nextModelQueryBoundary(query: string, cursor: number): number;
|
|
4
|
+
//# sourceMappingURL=modelSearchInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelSearchInput.d.ts","sourceRoot":"","sources":["../../../src/screens/modelSearchInput.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOhF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM5E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getGraphemeSegmenter } from '../utils/intl.js';
|
|
2
|
+
/** UTF-16 offsets used by SearchBox, stepped at complete Unicode characters. */
|
|
3
|
+
export function previousModelQueryBoundary(query, cursor) {
|
|
4
|
+
let previous = 0;
|
|
5
|
+
for (const { index } of getGraphemeSegmenter().segment(query)) {
|
|
6
|
+
if (index >= cursor)
|
|
7
|
+
break;
|
|
8
|
+
previous = index;
|
|
9
|
+
}
|
|
10
|
+
return previous;
|
|
11
|
+
}
|
|
12
|
+
export function nextModelQueryBoundary(query, cursor) {
|
|
13
|
+
for (const { index, segment } of getGraphemeSegmenter().segment(query)) {
|
|
14
|
+
const end = index + segment.length;
|
|
15
|
+
if (end > cursor)
|
|
16
|
+
return end;
|
|
17
|
+
}
|
|
18
|
+
return query.length;
|
|
19
|
+
}
|