@itookit/dsht 0.3.8 → 0.5.1
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.i18n.yaml +2 -2
- package/README.md +30 -11
- package/README.zh.md +30 -11
- package/dist/cli/dsht.js +203 -18
- package/dist/cli/startup.d.ts +40 -0
- package/dist/cli/startup.js +295 -0
- package/dist/cli/trace-summary.d.ts +78 -0
- package/dist/cli/trace-summary.js +241 -0
- package/dist/cli/verifier.d.ts +60 -0
- package/dist/cli/verifier.js +242 -0
- package/dist/contracts.d.ts +344 -0
- package/dist/contracts.js +1 -0
- package/dist/controller/commands.d.ts +47 -0
- package/dist/controller/commands.js +322 -0
- package/dist/controller/connection.d.ts +11 -29
- package/dist/controller/connection.js +26 -60
- package/dist/controller/controller.d.ts +616 -166
- package/dist/controller/controller.js +1395 -146
- package/dist/controller/index.d.ts +8 -1
- package/dist/controller/index.js +5 -0
- package/dist/controller/loop-contract.d.ts +136 -0
- package/dist/controller/loop-contract.js +308 -0
- package/dist/controller/loop-prompts-schema.d.ts +56 -0
- package/dist/controller/loop-prompts-schema.js +144 -0
- package/dist/controller/loop-prompts.d.ts +55 -0
- package/dist/controller/loop-prompts.generated.d.ts +104 -0
- package/dist/controller/loop-prompts.generated.js +185 -0
- package/dist/controller/loop-prompts.js +104 -0
- package/dist/controller/loop-protocols.d.ts +39 -0
- package/dist/controller/loop-protocols.js +115 -0
- package/dist/controller/loop.d.ts +275 -0
- package/dist/controller/loop.js +378 -0
- package/dist/controller/prompts.d.ts +54 -0
- package/dist/controller/prompts.js +162 -0
- package/dist/controller/trace-log.d.ts +45 -0
- package/dist/controller/trace-log.js +144 -0
- package/dist/controller/verifier.d.ts +126 -0
- package/dist/controller/verifier.js +75 -0
- package/dist/cost/index.d.ts +1 -1
- package/dist/cost/index.js +1 -1
- package/dist/cost/ledger.d.ts +0 -1
- package/dist/cost/ledger.js +0 -1
- package/dist/json.d.ts +18 -0
- package/dist/json.js +19 -0
- package/dist/references.d.ts +25 -0
- package/dist/references.js +26 -0
- package/dist/session/connection-view.d.ts +2 -11
- package/dist/session/controller.d.ts +73 -72
- package/dist/session/controller.js +185 -209
- package/dist/session/history.d.ts +6 -18
- package/dist/session/history.js +1 -24
- package/dist/session/index.d.ts +9 -4
- package/dist/session/index.js +7 -3
- package/dist/session/info.d.ts +25 -52
- package/dist/session/info.js +39 -25
- package/dist/session/markdown.js +1 -1
- package/dist/session/math.js +1 -1
- package/dist/session/mutation-gate.d.ts +51 -0
- package/dist/session/mutation-gate.js +73 -0
- package/dist/session/navigation.d.ts +2 -89
- package/dist/session/navigation.js +2 -129
- package/dist/session/peek.d.ts +38 -0
- package/dist/session/peek.js +103 -0
- package/dist/session/references.d.ts +2 -20
- package/dist/session/references.js +1 -26
- package/dist/session/runtime.d.ts +26 -0
- package/dist/session/runtime.js +28 -0
- package/dist/session/telemetry.d.ts +12 -13
- package/dist/session/telemetry.js +27 -58
- package/dist/session/transcript.d.ts +0 -6
- package/dist/session/transcript.js +2 -15
- package/dist/session/types.d.ts +25 -0
- package/dist/session/types.js +0 -1
- package/dist/session-title.d.ts +9 -0
- package/dist/session-title.js +21 -0
- package/dist/shell/controller.d.ts +31 -1
- package/dist/shell/controller.js +34 -2
- package/dist/shell/index.d.ts +3 -3
- package/dist/shell/index.js +2 -2
- package/dist/shell/runner.d.ts +10 -0
- package/dist/shell/runner.js +48 -9
- package/dist/slash/index.d.ts +10 -0
- package/dist/slash/index.js +7 -0
- package/dist/slash/parse.d.ts +166 -0
- package/dist/slash/parse.js +259 -0
- package/dist/slash/pipeline.d.ts +140 -0
- package/dist/slash/pipeline.js +115 -0
- package/dist/slash/registry.d.ts +88 -0
- package/dist/slash/registry.js +177 -0
- package/dist/state.d.ts +14 -4
- package/dist/state.js +3 -2
- package/dist/text.d.ts +28 -0
- package/dist/text.js +55 -0
- package/dist/transport/events.d.ts +104 -0
- package/dist/transport/events.js +149 -0
- package/dist/transport/wire.d.ts +9 -17
- package/dist/transport/wire.js +2 -27
- package/dist/ui/app.js +856 -441
- package/dist/ui/chat/header.js +1 -1
- package/dist/ui/chat/history-view.d.ts +1 -1
- package/dist/ui/chat/loop-status.d.ts +11 -0
- package/dist/ui/chat/loop-status.js +28 -0
- package/dist/ui/chat/navigation-model.d.ts +86 -0
- package/dist/ui/chat/navigation-model.js +107 -0
- package/dist/ui/chat/shell-view.d.ts +15 -2
- package/dist/ui/chat/shell-view.js +37 -3
- package/dist/ui/chat/status.d.ts +47 -3
- package/dist/ui/chat/status.js +65 -50
- package/dist/ui/chat/viewport.d.ts +1 -1
- package/dist/ui/dialogs/cost.d.ts +21 -4
- package/dist/ui/dialogs/cost.js +7 -12
- package/dist/ui/dialogs/index.d.ts +22 -5
- package/dist/ui/dialogs/index.js +19 -3
- package/dist/ui/dialogs/loop.d.ts +43 -0
- package/dist/ui/dialogs/loop.js +224 -0
- package/dist/ui/dialogs/peek.d.ts +25 -0
- package/dist/ui/dialogs/peek.js +35 -0
- package/dist/ui/dialogs/picker.d.ts +2 -0
- package/dist/ui/dialogs/picker.js +4 -2
- package/dist/ui/input/mouse.d.ts +12 -2
- package/dist/ui/input/mouse.js +20 -7
- package/dist/ui/input/references.d.ts +1 -1
- package/dist/ui/status/model.d.ts +7 -0
- package/dist/ui/status/model.js +5 -0
- package/dist/ui/theme/index.d.ts +1 -1
- package/package.json +6 -4
- package/dist/ui/commands/parse.d.ts +0 -104
- package/dist/ui/commands/parse.js +0 -135
- package/dist/ui/commands/registry.d.ts +0 -33
- package/dist/ui/commands/registry.js +0 -73
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itookit/dsht",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Remote-first TUI for DeepSeek Harness with SSH-friendly mobile access and request-level cost tracking",
|
|
6
6
|
"engines": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "tsx src/cli/index.ts",
|
|
29
29
|
"start:profile": "node -e \"require('node:fs').mkdirSync('.diagnostics',{recursive:true})\" && NODE_OPTIONS=\"--expose-gc --heapsnapshot-signal=SIGUSR2 --diagnostic-dir=.diagnostics\" tsx src/cli/index.ts",
|
|
30
|
-
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
|
|
30
|
+
"build": "npm run build:prompts && node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
|
|
31
31
|
"typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json",
|
|
32
32
|
"test": "tsx --test tests/*/*.test.ts tests/*/*.test.tsx",
|
|
33
33
|
"test:terminal": "node scripts/test/terminal.mjs",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"prepack": "npm run build",
|
|
36
36
|
"prepublishOnly": "npm run typecheck && npm run test:terminal",
|
|
37
37
|
"bench:input": "tsx scripts/benchmarks/input.tsx",
|
|
38
|
-
"bench:history": "node --import tsx scripts/benchmarks/history.tsx"
|
|
38
|
+
"bench:history": "node --import tsx scripts/benchmarks/history.tsx",
|
|
39
|
+
"build:prompts": "tsx scripts/build/loop-prompts.mts"
|
|
39
40
|
},
|
|
40
41
|
"keywords": [
|
|
41
42
|
"deepseek",
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
"@types/ws": "^8.18.1",
|
|
85
86
|
"ink-testing-library": "^4.0.0",
|
|
86
87
|
"tsx": "^4.22.0",
|
|
87
|
-
"typescript": "^5.9.3"
|
|
88
|
+
"typescript": "^5.9.3",
|
|
89
|
+
"yaml": "^2.9.1"
|
|
88
90
|
}
|
|
89
91
|
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { State } from '../../state.ts';
|
|
2
|
-
/** One classified submission; every side effect stays with the caller. */
|
|
3
|
-
export type Submission = {
|
|
4
|
-
kind: 'ignore';
|
|
5
|
-
} | {
|
|
6
|
-
kind: 'reference';
|
|
7
|
-
} | {
|
|
8
|
-
kind: 'copy';
|
|
9
|
-
} | {
|
|
10
|
-
kind: 'quit';
|
|
11
|
-
} | {
|
|
12
|
-
kind: 'panel';
|
|
13
|
-
panel: 'cost' | 'status' | 'help';
|
|
14
|
-
} | {
|
|
15
|
-
kind: 'remove';
|
|
16
|
-
target: 'workspace' | 'session';
|
|
17
|
-
query: string;
|
|
18
|
-
} | {
|
|
19
|
-
kind: 'navigate';
|
|
20
|
-
target: 'workspace' | 'session';
|
|
21
|
-
query?: string;
|
|
22
|
-
} | {
|
|
23
|
-
kind: 'path';
|
|
24
|
-
value: string;
|
|
25
|
-
} | {
|
|
26
|
-
kind: 'latest';
|
|
27
|
-
} | {
|
|
28
|
-
kind: 'models';
|
|
29
|
-
args: string[];
|
|
30
|
-
} | {
|
|
31
|
-
kind: 'queue';
|
|
32
|
-
} | {
|
|
33
|
-
kind: 'newSession';
|
|
34
|
-
} | {
|
|
35
|
-
kind: 'history';
|
|
36
|
-
query: string;
|
|
37
|
-
} | {
|
|
38
|
-
kind: 'sessionSearch';
|
|
39
|
-
command: '/ssearch' | '/wsearch';
|
|
40
|
-
query: string;
|
|
41
|
-
} | {
|
|
42
|
-
kind: 'historySearch';
|
|
43
|
-
query: string;
|
|
44
|
-
} | {
|
|
45
|
-
kind: 'think';
|
|
46
|
-
target: string;
|
|
47
|
-
} | {
|
|
48
|
-
kind: 'older';
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'compact';
|
|
51
|
-
} | {
|
|
52
|
-
kind: 'cancel';
|
|
53
|
-
} | {
|
|
54
|
-
kind: 'approval';
|
|
55
|
-
allowed: boolean;
|
|
56
|
-
} | {
|
|
57
|
-
kind: 'hostCommand';
|
|
58
|
-
line: string;
|
|
59
|
-
}
|
|
60
|
-
/** A local `!` command, run on this machine rather than the host. */
|
|
61
|
-
| {
|
|
62
|
-
kind: 'shell';
|
|
63
|
-
command: string;
|
|
64
|
-
} | {
|
|
65
|
-
kind: 'export';
|
|
66
|
-
destination?: string;
|
|
67
|
-
} | {
|
|
68
|
-
kind: 'exportHtml';
|
|
69
|
-
destination?: string;
|
|
70
|
-
} | {
|
|
71
|
-
kind: 'coredump';
|
|
72
|
-
tag?: string;
|
|
73
|
-
} | {
|
|
74
|
-
kind: 'answer';
|
|
75
|
-
text: string;
|
|
76
|
-
} | {
|
|
77
|
-
kind: 'error';
|
|
78
|
-
message: string;
|
|
79
|
-
} | {
|
|
80
|
-
kind: 'prompt';
|
|
81
|
-
text: string;
|
|
82
|
-
};
|
|
83
|
-
/** UI facts the classification reads; everything else stays with the caller. */
|
|
84
|
-
export interface SubmissionContext {
|
|
85
|
-
/** Completion menu owns the draft while open. */
|
|
86
|
-
referenceOpen: boolean;
|
|
87
|
-
/** Copy mode ignores submissions entirely. */
|
|
88
|
-
copyMode: boolean;
|
|
89
|
-
/** A question or approval of the selected session is pending. */
|
|
90
|
-
pending: boolean;
|
|
91
|
-
/** The pending interaction is a question. */
|
|
92
|
-
question: boolean;
|
|
93
|
-
screen: State['screen'];
|
|
94
|
-
}
|
|
95
|
-
/** Classify one composer draft without performing any of its effects.
|
|
96
|
-
*
|
|
97
|
-
* The order of the checks is the command precedence: reference completion, copy mode, the panels
|
|
98
|
-
* that toggle in place, navigation and removal, then the session and host commands, then answers,
|
|
99
|
-
* then a plain prompt.
|
|
100
|
-
* @param raw - Draft exactly as submitted.
|
|
101
|
-
* @param context - Current UI facts.
|
|
102
|
-
* @returns The action to perform.
|
|
103
|
-
*/
|
|
104
|
-
export declare function classifySubmission(raw: string, context: SubmissionContext): Submission;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/** Classify one submitted composer line into the action the terminal performs. */
|
|
2
|
-
import { navigationCommand } from "../../session/navigation.js";
|
|
3
|
-
/** Classify one composer draft without performing any of its effects.
|
|
4
|
-
*
|
|
5
|
-
* The order of the checks is the command precedence: reference completion, copy mode, the panels
|
|
6
|
-
* that toggle in place, navigation and removal, then the session and host commands, then answers,
|
|
7
|
-
* then a plain prompt.
|
|
8
|
-
* @param raw - Draft exactly as submitted.
|
|
9
|
-
* @param context - Current UI facts.
|
|
10
|
-
* @returns The action to perform.
|
|
11
|
-
*/
|
|
12
|
-
export function classifySubmission(raw, context) {
|
|
13
|
-
if (context.referenceOpen)
|
|
14
|
-
return { kind: 'reference' };
|
|
15
|
-
if (context.copyMode)
|
|
16
|
-
return { kind: 'ignore' };
|
|
17
|
-
const value = raw.trim();
|
|
18
|
-
if (!value)
|
|
19
|
-
return { kind: 'ignore' };
|
|
20
|
-
// `!` runs on the machine this client is on; it never reaches the host or the model.
|
|
21
|
-
if (value.startsWith('!')) {
|
|
22
|
-
const command = value.slice(1).trim();
|
|
23
|
-
if (!command)
|
|
24
|
-
return { kind: 'error', message: 'Type a command after !' };
|
|
25
|
-
if (context.screen !== 'chat')
|
|
26
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
27
|
-
return { kind: 'shell', command };
|
|
28
|
-
}
|
|
29
|
-
if (value === '/copy')
|
|
30
|
-
return { kind: 'copy' };
|
|
31
|
-
if (value === '/quit')
|
|
32
|
-
return { kind: 'quit' };
|
|
33
|
-
if (value === '/cost')
|
|
34
|
-
return { kind: 'panel', panel: 'cost' };
|
|
35
|
-
if (value === '/status')
|
|
36
|
-
return { kind: 'panel', panel: 'status' };
|
|
37
|
-
if (value === '/help')
|
|
38
|
-
return { kind: 'panel', panel: 'help' };
|
|
39
|
-
const navigation = navigationCommand(value);
|
|
40
|
-
if (navigation && /^--(?:delete|archive)(?:\s|$)/.test(navigation.query ?? '')) {
|
|
41
|
-
const query = navigation.query.replace(/^--(?:delete|archive)\s*/, '');
|
|
42
|
-
if (!query)
|
|
43
|
-
return { kind: 'error', message: 'Specify the name or ID to remove' };
|
|
44
|
-
return { kind: 'remove', target: navigation.kind, query };
|
|
45
|
-
}
|
|
46
|
-
if (navigation)
|
|
47
|
-
return { kind: 'navigate', target: navigation.kind, query: navigation.query };
|
|
48
|
-
if (context.screen === 'path')
|
|
49
|
-
return { kind: 'path', value };
|
|
50
|
-
if (value === '/latest')
|
|
51
|
-
return { kind: 'latest' };
|
|
52
|
-
if (/^\/model(?: |$)/.test(value)) {
|
|
53
|
-
if (context.screen !== 'chat')
|
|
54
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
55
|
-
const args = value.split(/\s+/).slice(1);
|
|
56
|
-
if (args.length && (args.length < 2 || args.length > 3))
|
|
57
|
-
return { kind: 'error', message: 'Use /model [provider model [effort]]' };
|
|
58
|
-
return { kind: 'models', args };
|
|
59
|
-
}
|
|
60
|
-
if (value === '/queue') {
|
|
61
|
-
if (context.screen !== 'chat')
|
|
62
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
63
|
-
if (context.pending)
|
|
64
|
-
return { kind: 'error', message: 'Answer the pending question or approval first' };
|
|
65
|
-
return { kind: 'queue' };
|
|
66
|
-
}
|
|
67
|
-
if (value === '/new')
|
|
68
|
-
return { kind: 'newSession' };
|
|
69
|
-
if (value === '/history' || value.startsWith('/history ')) {
|
|
70
|
-
if (context.screen !== 'chat')
|
|
71
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
72
|
-
return { kind: 'history', query: value.slice(8).trim() };
|
|
73
|
-
}
|
|
74
|
-
if (/^\/(?:search|ssearch|wsearch)(?: |$)/.test(value)) {
|
|
75
|
-
const [command, ...words] = value.split(' ');
|
|
76
|
-
const query = words.join(' ').trim();
|
|
77
|
-
if (!query)
|
|
78
|
-
return { kind: 'error', message: `Use ${command} <text>` };
|
|
79
|
-
return command === '/search' ? { kind: 'historySearch', query }
|
|
80
|
-
: { kind: 'sessionSearch', command: command, query };
|
|
81
|
-
}
|
|
82
|
-
if (/^\/think(?: |$)/.test(value)) {
|
|
83
|
-
if (context.screen !== 'chat')
|
|
84
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
85
|
-
return { kind: 'think', target: value.slice(6).trim() };
|
|
86
|
-
}
|
|
87
|
-
if (value === '/older')
|
|
88
|
-
return { kind: 'older' };
|
|
89
|
-
if (/^\/compact(?: |$)/.test(value)) {
|
|
90
|
-
if (context.screen !== 'chat')
|
|
91
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
92
|
-
if (value !== '/compact')
|
|
93
|
-
return { kind: 'error', message: 'Use /compact (no arguments)' };
|
|
94
|
-
return { kind: 'compact' };
|
|
95
|
-
}
|
|
96
|
-
if (value === '/cancel')
|
|
97
|
-
return { kind: 'cancel' };
|
|
98
|
-
if (value === '/allow')
|
|
99
|
-
return { kind: 'approval', allowed: true };
|
|
100
|
-
if (value === '/deny')
|
|
101
|
-
return { kind: 'approval', allowed: false };
|
|
102
|
-
if (/^\/(?:plan|goal|permission|feedback)(?:\s|$)/.test(value)) {
|
|
103
|
-
if (context.screen !== 'chat')
|
|
104
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
105
|
-
if (context.pending)
|
|
106
|
-
return { kind: 'error', message: 'Answer the pending question or approval first' };
|
|
107
|
-
return { kind: 'hostCommand', line: value };
|
|
108
|
-
}
|
|
109
|
-
if (/^\/export(?:\s|$)/.test(value)) {
|
|
110
|
-
if (context.screen !== 'chat')
|
|
111
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
112
|
-
const destination = value.slice(7).trim().replace(/^(["'])(.*)\1$/, '$2');
|
|
113
|
-
return { kind: 'export', ...(destination ? { destination } : {}) };
|
|
114
|
-
}
|
|
115
|
-
if (/^\/export-html(?:\s|$)/.test(value)) {
|
|
116
|
-
if (context.screen !== 'chat')
|
|
117
|
-
return { kind: 'error', message: 'Select a session first' };
|
|
118
|
-
const destination = value.slice(12).trim().replace(/^(["'])(.*)\1$/, '$2');
|
|
119
|
-
return { kind: 'exportHtml', ...(destination ? { destination } : {}) };
|
|
120
|
-
}
|
|
121
|
-
if (/^\/coredump(?:\s|$)/.test(value)) {
|
|
122
|
-
// A diagnostic of this client's own heap needs neither a session nor a connected host.
|
|
123
|
-
const tag = value.slice(9).trim().replace(/^(["'])(.*)\1$/, '$2');
|
|
124
|
-
return { kind: 'coredump', ...(tag ? { tag } : {}) };
|
|
125
|
-
}
|
|
126
|
-
if (context.question)
|
|
127
|
-
return { kind: 'answer', text: value };
|
|
128
|
-
if (context.pending)
|
|
129
|
-
return { kind: 'error', message: 'Answer the approval with /allow or /deny' };
|
|
130
|
-
if (value.startsWith('/'))
|
|
131
|
-
return { kind: 'error', message: 'Unknown command. Use /help.' };
|
|
132
|
-
if (context.screen !== 'chat')
|
|
133
|
-
return { kind: 'error', message: 'Choose a session or type /ws or /resume' };
|
|
134
|
-
return { kind: 'prompt', text: value };
|
|
135
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** Slash-command catalog shared by completion, `/help` and the submission router. */
|
|
2
|
-
/** One slash command advertised by completion and `/help`. */
|
|
3
|
-
export interface CommandHint {
|
|
4
|
-
/** Slash command as typed without arguments. */
|
|
5
|
-
command: string;
|
|
6
|
-
/** Argument hint shown after the command; absent when it takes none. */
|
|
7
|
-
usage?: string;
|
|
8
|
-
/** One-line action description shown by `/help`. */
|
|
9
|
-
description: string;
|
|
10
|
-
}
|
|
11
|
-
/** Command discovery catalog shared by Tab completion and the `/help` panel. */
|
|
12
|
-
export declare const COMMAND_HINTS: readonly CommandHint[];
|
|
13
|
-
/** Command names only, in catalog order. */
|
|
14
|
-
export declare const COMMANDS: string[];
|
|
15
|
-
/** Command column text per hint, aligned in the `/help` panel. */
|
|
16
|
-
export declare const COMMAND_LABELS: string[];
|
|
17
|
-
/** Widest command column, so descriptions start on one column. */
|
|
18
|
-
export declare const COMMAND_LABEL_WIDTH: number;
|
|
19
|
-
/** Longest common prefix of the candidate commands, so Tab can extend an ambiguous draft.
|
|
20
|
-
* @param values - Command candidates.
|
|
21
|
-
* @returns The shared leading prefix.
|
|
22
|
-
*/
|
|
23
|
-
export declare function commonPrefix(values: string[]): string;
|
|
24
|
-
/** Complete the leading slash command; an ambiguous draft extends to the shared prefix.
|
|
25
|
-
* @param input - Current composer draft.
|
|
26
|
-
* @returns The completed draft, or undefined when nothing can be completed.
|
|
27
|
-
*/
|
|
28
|
-
export declare function completeCommand(input: string): string | undefined;
|
|
29
|
-
/** Commands matching the current draft, shown under the composer.
|
|
30
|
-
* @param input - Current composer draft.
|
|
31
|
-
* @returns Candidate command names.
|
|
32
|
-
*/
|
|
33
|
-
export declare function suggestedCommands(input: string): string[];
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/** Slash-command catalog shared by completion, `/help` and the submission router. */
|
|
2
|
-
/** Command discovery catalog shared by Tab completion and the `/help` panel. */
|
|
3
|
-
export const COMMAND_HINTS = [
|
|
4
|
-
{ command: '/ws', usage: '[name or ID]', description: 'List/switch workspaces; --delete name removes registration' },
|
|
5
|
-
{ command: '/resume', usage: '[title or ID]', description: 'List/switch sessions; --delete ID archives with confirmation' },
|
|
6
|
-
{ command: '/model', usage: '[provider model [effort]]', description: 'Choose a model and reasoning effort for subsequent requests' },
|
|
7
|
-
{ command: '/new', description: 'Create a session in the selected workspace' },
|
|
8
|
-
{ command: '/copy', description: 'Freeze for native selection; Esc resumes (Ctrl+S shortcut)' },
|
|
9
|
-
{ command: '/latest', description: 'Return to the live conversation' },
|
|
10
|
-
{ command: '/older', description: 'Load earlier history' },
|
|
11
|
-
{ command: '/history', usage: '[text]', description: 'List your prompts, optionally filtered' },
|
|
12
|
-
{ command: '/search', usage: 'text', description: 'Search history page by page and open a match' },
|
|
13
|
-
{ command: '/ssearch', usage: 'text', description: 'Search sessions in the current workspace' },
|
|
14
|
-
{ command: '/wsearch', usage: 'text', description: 'Search sessions across all workspaces' },
|
|
15
|
-
{ command: '/compact', description: 'Compact older history while the session is idle' },
|
|
16
|
-
{ command: '/cancel', description: 'Cancel the active turn' },
|
|
17
|
-
{ command: '/queue', description: 'View and remove pending input' },
|
|
18
|
-
{ command: '/plan', usage: '[off|message]', description: 'Enter or leave host plan mode' },
|
|
19
|
-
{ command: '/goal', usage: '[action|objective]', description: 'View or manage the host task goal' },
|
|
20
|
-
{ command: '/permission', usage: '[preset]', description: 'View or switch the host permission preset' },
|
|
21
|
-
{ command: '/feedback', usage: 'text', description: 'Record feedback about the session' },
|
|
22
|
-
{ command: '/export', usage: '[local.zip]', description: 'Save the session log ZIP to a new local file' },
|
|
23
|
-
{ command: '/export-html', usage: '[local.html]', description: 'Save loaded conversation with diagrams and math as offline HTML' },
|
|
24
|
-
{ command: '/coredump', usage: '[tag]', description: 'Write a V8 heap snapshot for memory diagnosis' },
|
|
25
|
-
{ command: '/allow', description: 'Approve the pending request once' },
|
|
26
|
-
{ command: '/deny', description: 'Reject the pending request' },
|
|
27
|
-
{ command: '/status', description: 'Show full session status details' },
|
|
28
|
-
{ command: '/cost', description: 'Show cost estimates and refresh usage' },
|
|
29
|
-
{ command: '/think', usage: '[seq or live]', description: 'Inspect reasoning with user prompt summaries' },
|
|
30
|
-
{ command: '/help', description: 'Show this command list' },
|
|
31
|
-
{ command: '/quit', description: 'Exit dsht' },
|
|
32
|
-
];
|
|
33
|
-
/** Command names only, in catalog order. */
|
|
34
|
-
export const COMMANDS = COMMAND_HINTS.map(hint => hint.command);
|
|
35
|
-
/** Command column text per hint, aligned in the `/help` panel. */
|
|
36
|
-
export const COMMAND_LABELS = COMMAND_HINTS.map(hint => hint.usage === undefined ? hint.command : `${hint.command} ${hint.usage}`);
|
|
37
|
-
/** Widest command column, so descriptions start on one column. */
|
|
38
|
-
export const COMMAND_LABEL_WIDTH = Math.max(...COMMAND_LABELS.map(label => label.length)) + 2;
|
|
39
|
-
/** Longest common prefix of the candidate commands, so Tab can extend an ambiguous draft.
|
|
40
|
-
* @param values - Command candidates.
|
|
41
|
-
* @returns The shared leading prefix.
|
|
42
|
-
*/
|
|
43
|
-
export function commonPrefix(values) {
|
|
44
|
-
let prefix = values[0] ?? '';
|
|
45
|
-
for (const value of values) {
|
|
46
|
-
let index = 0;
|
|
47
|
-
while (index < prefix.length && index < value.length && prefix[index] === value[index])
|
|
48
|
-
index++;
|
|
49
|
-
prefix = prefix.slice(0, index);
|
|
50
|
-
}
|
|
51
|
-
return prefix;
|
|
52
|
-
}
|
|
53
|
-
/** Complete the leading slash command; an ambiguous draft extends to the shared prefix.
|
|
54
|
-
* @param input - Current composer draft.
|
|
55
|
-
* @returns The completed draft, or undefined when nothing can be completed.
|
|
56
|
-
*/
|
|
57
|
-
export function completeCommand(input) {
|
|
58
|
-
if (!input.startsWith('/') || input.includes(' '))
|
|
59
|
-
return undefined;
|
|
60
|
-
const matches = COMMANDS.filter(command => command.startsWith(input));
|
|
61
|
-
const only = matches.length === 1 ? matches[0] : undefined;
|
|
62
|
-
if (only !== undefined)
|
|
63
|
-
return `${only} `;
|
|
64
|
-
const prefix = commonPrefix(matches);
|
|
65
|
-
return prefix.length > input.length ? prefix : undefined;
|
|
66
|
-
}
|
|
67
|
-
/** Commands matching the current draft, shown under the composer.
|
|
68
|
-
* @param input - Current composer draft.
|
|
69
|
-
* @returns Candidate command names.
|
|
70
|
-
*/
|
|
71
|
-
export function suggestedCommands(input) {
|
|
72
|
-
return COMMANDS.filter(command => input.startsWith('/') && !input.includes(' ') && command.startsWith(input));
|
|
73
|
-
}
|