@itookit/dsht 0.3.0 → 0.3.3
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 +39 -23
- package/README.zh.md +40 -24
- package/dist/catalog/controller.d.ts +32 -0
- package/dist/catalog/controller.js +88 -0
- package/dist/catalog/index.d.ts +2 -0
- package/dist/catalog/index.js +2 -0
- package/dist/{cli.js → cli/index.js} +42 -29
- package/dist/controller/connection.d.ts +80 -0
- package/dist/controller/connection.js +190 -0
- package/dist/controller/controller.d.ts +269 -0
- package/dist/controller/controller.js +372 -0
- package/dist/controller/index.d.ts +5 -0
- package/dist/controller/index.js +3 -0
- package/dist/controller/memory-log.d.ts +35 -0
- package/dist/controller/memory-log.js +95 -0
- package/dist/cost/config.d.ts +17 -0
- package/dist/cost/config.js +68 -0
- package/dist/cost/controller.d.ts +41 -0
- package/dist/cost/controller.js +115 -0
- package/dist/cost/index.d.ts +10 -0
- package/dist/cost/index.js +8 -0
- package/dist/cost/ledger-files.d.ts +16 -0
- package/dist/cost/ledger-files.js +103 -0
- package/dist/cost/ledger.d.ts +78 -0
- package/dist/cost/ledger.js +146 -0
- package/dist/cost/pricing.d.ts +86 -0
- package/dist/cost/pricing.js +223 -0
- package/dist/cost/records.d.ts +17 -0
- package/dist/cost/records.js +79 -0
- package/dist/cost/scanner.d.ts +22 -0
- package/dist/cost/scanner.js +95 -0
- package/dist/cost/types.d.ts +85 -0
- package/dist/cost/types.js +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/session/connection-view.d.ts +18 -0
- package/dist/session/connection-view.js +1 -0
- package/dist/{controller.d.ts → session/controller.d.ts} +102 -136
- package/dist/session/controller.js +616 -0
- package/dist/session/export-html.d.ts +9 -0
- package/dist/session/export-html.js +39 -0
- package/dist/{export.d.ts → session/export.d.ts} +1 -1
- package/dist/{export.js → session/export.js} +6 -20
- package/dist/{history.d.ts → session/history.d.ts} +17 -0
- package/dist/{history.js → session/history.js} +163 -2
- package/dist/session/index.d.ts +17 -0
- package/dist/session/index.js +10 -0
- package/dist/session/markdown.d.ts +39 -0
- package/dist/session/markdown.js +255 -0
- package/dist/session/math.d.ts +11 -0
- package/dist/session/math.js +82 -0
- package/dist/session/navigation.d.ts +37 -0
- package/dist/session/navigation.js +84 -0
- package/dist/{references.js → session/references.js} +1 -1
- package/dist/{telemetry.d.ts → session/telemetry.d.ts} +1 -1
- package/dist/{telemetry.js → session/telemetry.js} +1 -1
- package/dist/{transcript.d.ts → session/transcript.d.ts} +65 -1
- package/dist/{transcript.js → session/transcript.js} +141 -20
- package/dist/session/types.d.ts +18 -0
- package/dist/session/types.js +2 -0
- package/dist/state.d.ts +41 -0
- package/dist/state.js +9 -0
- package/dist/storage/directories.d.ts +14 -0
- package/dist/storage/directories.js +24 -0
- package/dist/storage/files.d.ts +51 -0
- package/dist/storage/files.js +152 -0
- package/dist/storage/heap-snapshot.d.ts +19 -0
- package/dist/storage/heap-snapshot.js +29 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.js +4 -0
- package/dist/transport/auth.js +65 -0
- package/dist/transport/host.d.ts +13 -0
- package/dist/transport/host.js +1 -0
- package/dist/ui/app.d.ts +11 -0
- package/dist/ui/app.js +790 -0
- package/dist/ui/chat/header.d.ts +11 -0
- package/dist/ui/chat/header.js +14 -0
- package/dist/ui/chat/history-view.d.ts +12 -0
- package/dist/ui/chat/history-view.js +17 -0
- package/dist/ui/chat/status.d.ts +91 -0
- package/dist/ui/chat/status.js +386 -0
- package/dist/ui/chat/viewport.d.ts +17 -0
- package/dist/ui/chat/viewport.js +14 -0
- package/dist/ui/commands/parse.d.ts +99 -0
- package/dist/ui/commands/parse.js +126 -0
- package/dist/ui/commands/registry.d.ts +33 -0
- package/dist/ui/commands/registry.js +73 -0
- package/dist/ui/copy-mode.d.ts +4 -0
- package/dist/ui/copy-mode.js +6 -0
- package/dist/{cost-view.d.ts → ui/dialogs/cost.d.ts} +1 -1
- package/dist/{cost-view.js → ui/dialogs/cost.js} +6 -6
- package/dist/ui/dialogs/index.d.ts +120 -0
- package/dist/ui/dialogs/index.js +113 -0
- package/dist/ui/dialogs/picker.d.ts +18 -0
- package/dist/ui/dialogs/picker.js +38 -0
- package/dist/ui/frozen.d.ts +8 -0
- package/dist/ui/frozen.js +7 -0
- package/dist/ui/input/references.d.ts +12 -0
- package/dist/ui/input/references.js +15 -0
- package/dist/ui/mount.d.ts +6 -0
- package/dist/ui/mount.js +11 -0
- package/dist/{theme.d.ts → ui/theme/index.d.ts} +1 -1
- package/package.json +19 -13
- package/dist/app.d.ts +0 -21
- package/dist/app.js +0 -805
- package/dist/auth.js +0 -108
- package/dist/controller.js +0 -961
- package/dist/cost.d.ts +0 -119
- package/dist/cost.js +0 -313
- package/dist/history-view.d.ts +0 -8
- package/dist/history-view.js +0 -12
- package/dist/navigation.d.ts +0 -11
- package/dist/navigation.js +0 -36
- package/dist/status.d.ts +0 -28
- package/dist/status.js +0 -157
- /package/dist/{cli.d.ts → cli/index.d.ts} +0 -0
- /package/dist/{memory.d.ts → session/memory.d.ts} +0 -0
- /package/dist/{memory.js → session/memory.js} +0 -0
- /package/dist/{references.d.ts → session/references.d.ts} +0 -0
- /package/dist/{auth.d.ts → transport/auth.d.ts} +0 -0
- /package/dist/{client.d.ts → transport/client.d.ts} +0 -0
- /package/dist/{client.js → transport/client.js} +0 -0
- /package/dist/{endpoint.d.ts → transport/endpoint.d.ts} +0 -0
- /package/dist/{endpoint.js → transport/endpoint.js} +0 -0
- /package/dist/{wire.d.ts → transport/wire.d.ts} +0 -0
- /package/dist/{wire.js → transport/wire.js} +0 -0
- /package/dist/{input-history.d.ts → ui/input/history.d.ts} +0 -0
- /package/dist/{input-history.js → ui/input/history.js} +0 -0
- /package/dist/{input.d.ts → ui/input/input.d.ts} +0 -0
- /package/dist/{input.js → ui/input/input.js} +0 -0
- /package/dist/{mouse.d.ts → ui/input/mouse.d.ts} +0 -0
- /package/dist/{mouse.js → ui/input/mouse.js} +0 -0
- /package/dist/{theme.js → ui/theme/index.js} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** Shared list selector used by every picker and dialog. */
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Box, Text, useInput, useStdin } from 'ink';
|
|
5
|
+
import { safeText } from "../../transport/wire.js";
|
|
6
|
+
import { useCopyMode } from "../copy-mode.js";
|
|
7
|
+
import { useTheme } from "../theme/index.js";
|
|
8
|
+
/** Keyboard-driven list with paging and optional removal.
|
|
9
|
+
* @param props - Choices, availability, page size and hint text.
|
|
10
|
+
* @returns The rendered list rows and its navigation hint.
|
|
11
|
+
*/
|
|
12
|
+
export function Picker({ choices, enabled, canSelect, pageSize = 12, hint }) {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const copyMode = useCopyMode();
|
|
15
|
+
const [selected, setSelected] = useState(0);
|
|
16
|
+
const current = Math.min(selected, choices.length - 1);
|
|
17
|
+
const { internal_eventEmitter } = useStdin();
|
|
18
|
+
const rawKey = useRef('');
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const remember = (raw) => { rawKey.current = raw; };
|
|
21
|
+
internal_eventEmitter.prependListener('input', remember);
|
|
22
|
+
return () => { internal_eventEmitter.removeListener('input', remember); };
|
|
23
|
+
}, [internal_eventEmitter]);
|
|
24
|
+
useInput((_input, key) => {
|
|
25
|
+
if (!canSelect() || key.eventType === 'release')
|
|
26
|
+
return;
|
|
27
|
+
if (key.upArrow)
|
|
28
|
+
setSelected(Math.max(0, current - 1));
|
|
29
|
+
else if (key.downArrow)
|
|
30
|
+
setSelected(Math.min(choices.length - 1, current + 1));
|
|
31
|
+
else if (_input === 'd' && !key.ctrl && !key.meta || key.delete && /^\x1b\[3(?:;\d+)?~$/.test(rawKey.current))
|
|
32
|
+
choices[current]?.remove?.();
|
|
33
|
+
else if (key.return)
|
|
34
|
+
choices[current]?.action();
|
|
35
|
+
}, { isActive: enabled && !copyMode });
|
|
36
|
+
const start = Math.max(0, current - Math.max(0, pageSize - 1));
|
|
37
|
+
return _jsxs(Box, { flexDirection: "column", children: [choices.slice(start, start + pageSize).map((choice, index) => _jsxs(Text, { color: start + index === current ? theme.accent : undefined, children: [start + index === current ? '❯ ' : ' ', safeText(choice.label)] }, choice.key)), _jsx(Text, { dimColor: true, children: hint ?? `↑ ↓ select · Enter open${choices.some(choice => choice.remove) ? ' · d/Delete remove / archive' : ''} · Ctrl+C stop / exit` })] });
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Retain rendered subtrees while the display is paused for reading or selection. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
/** Retain rendered children while frozen; local dialog interactions remain outside this wrapper. */
|
|
4
|
+
export declare const Frozen: import("react").NamedExoticComponent<{
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
frozen: boolean;
|
|
7
|
+
identity: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** Retain rendered subtrees while the display is paused for reading or selection. */
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
/** Retain rendered children while frozen; local dialog interactions remain outside this wrapper. */
|
|
5
|
+
export const Frozen = memo(function Frozen({ children }) {
|
|
6
|
+
return _jsx(_Fragment, { children: children });
|
|
7
|
+
}, (previous, next) => previous.frozen && next.frozen && previous.identity === next.identity);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FileReference } from '../../session/references.ts';
|
|
2
|
+
/** Candidates for the unfinished reference at the end of the draft.
|
|
3
|
+
* @param props - Lookup result and the highlighted candidate.
|
|
4
|
+
* @returns The completion menu.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ReferenceMenu({ matches, index }: {
|
|
7
|
+
matches?: {
|
|
8
|
+
items: FileReference[];
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
index: number;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** Trailing `@` host-path completion menu. */
|
|
3
|
+
import { Box, Text } from 'ink';
|
|
4
|
+
import { useTheme } from "../theme/index.js";
|
|
5
|
+
/** Candidates for the unfinished reference at the end of the draft.
|
|
6
|
+
* @param props - Lookup result and the highlighted candidate.
|
|
7
|
+
* @returns The completion menu.
|
|
8
|
+
*/
|
|
9
|
+
export function ReferenceMenu({ matches, index }) {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const start = Math.max(0, index - 5);
|
|
12
|
+
return _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Host files \u00B7 \u2191 \u2193 select \u00B7 Tab/Enter insert \u00B7 Esc close" }), !matches ? _jsx(Text, { dimColor: true, children: "Searching\u2026" }) : matches.error ? _jsx(Text, { color: theme.colors.error, children: matches.error })
|
|
13
|
+
: matches.items.length === 0 ? _jsx(Text, { dimColor: true, children: "No matching host files" })
|
|
14
|
+
: matches.items.slice(start, start + 6).map((item, offset) => _jsxs(Text, { color: offset + start === index ? theme.accent : undefined, children: [offset + start === index ? '❯ ' : ' ', item.path, item.kind === 'directory' ? '/' : ''] }, `${item.kind}:${item.path}`))] });
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Controller } from '../controller/index.ts';
|
|
2
|
+
/** Render the application and return the Ink instance that owns its lifetime.
|
|
3
|
+
* @param controller - Application controller.
|
|
4
|
+
* @returns The mounted Ink instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mount(controller: Controller): import("ink").Instance;
|
package/dist/ui/mount.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** The only module that touches Ink's renderer; the CLI mounts the interface through it. */
|
|
3
|
+
import { render } from 'ink';
|
|
4
|
+
import { App } from "./app.js";
|
|
5
|
+
/** Render the application and return the Ink instance that owns its lifetime.
|
|
6
|
+
* @param controller - Application controller.
|
|
7
|
+
* @returns The mounted Ink instance.
|
|
8
|
+
*/
|
|
9
|
+
export function mount(controller) {
|
|
10
|
+
return render(_jsx(App, { controller: controller }), { exitOnCtrlC: false });
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itookit/dsht",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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": {
|
|
7
7
|
"node": ">=22.19"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"dsht": "dist/cli.js"
|
|
10
|
+
"dsht": "dist/cli/index.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -15,26 +15,27 @@
|
|
|
15
15
|
"README.zh.md",
|
|
16
16
|
"dsht-m.png"
|
|
17
17
|
],
|
|
18
|
-
"main": "dist/
|
|
19
|
-
"types": "dist/
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
|
-
".": "./dist/
|
|
22
|
-
"./auth": "./dist/auth.js"
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./auth": "./dist/transport/auth.js"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
|
-
"start": "tsx src/cli.tsx",
|
|
29
|
-
"
|
|
28
|
+
"start": "tsx src/cli/index.tsx",
|
|
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.tsx",
|
|
30
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
|
|
30
31
|
"typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json",
|
|
31
|
-
"test": "tsx --test tests
|
|
32
|
-
"test:terminal": "node scripts/test
|
|
33
|
-
"test:package": "node scripts/test
|
|
32
|
+
"test": "tsx --test tests/*/*.test.ts tests/*/*.test.tsx",
|
|
33
|
+
"test:terminal": "node scripts/test/terminal.mjs",
|
|
34
|
+
"test:package": "node scripts/test/package.mjs",
|
|
34
35
|
"prepack": "npm run build",
|
|
35
36
|
"prepublishOnly": "npm run typecheck && npm run test:terminal",
|
|
36
|
-
"bench:input": "tsx scripts/
|
|
37
|
-
"bench:history": "node --import tsx scripts/
|
|
37
|
+
"bench:input": "tsx scripts/benchmarks/input.tsx",
|
|
38
|
+
"bench:history": "node --import tsx scripts/benchmarks/history.tsx"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [
|
|
40
41
|
"deepseek",
|
|
@@ -66,9 +67,14 @@
|
|
|
66
67
|
},
|
|
67
68
|
"homepage": "https://github.com/mushuanli/dsht#readme",
|
|
68
69
|
"dependencies": {
|
|
70
|
+
"@mathjax/src": "^4.1.3",
|
|
71
|
+
"beautiful-mermaid": "^1.1.3",
|
|
72
|
+
"entities": "^8.1.0",
|
|
69
73
|
"ink": "^6.8.0",
|
|
74
|
+
"marked": "^18.0.12",
|
|
70
75
|
"react": "^19.2.0",
|
|
71
76
|
"slice-ansi": "^8.0.0",
|
|
77
|
+
"string-width": "^8.2.2",
|
|
72
78
|
"wrap-ansi": "^9.0.2",
|
|
73
79
|
"ws": "^8.21.0"
|
|
74
80
|
},
|
package/dist/app.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type Theme } from './theme.ts';
|
|
2
|
-
import { Controller } from './controller.ts';
|
|
3
|
-
/** One slash command advertised by completion and `/help`. */
|
|
4
|
-
export interface CommandHint {
|
|
5
|
-
/** Slash command as typed without arguments. */
|
|
6
|
-
command: string;
|
|
7
|
-
/** Argument hint shown after the command; absent when it takes none. */
|
|
8
|
-
usage?: string;
|
|
9
|
-
/** One-line action description shown by `/help`. */
|
|
10
|
-
description: string;
|
|
11
|
-
}
|
|
12
|
-
/** Command discovery catalog shared by Tab completion and the `/help` panel. */
|
|
13
|
-
export declare const COMMAND_HINTS: readonly CommandHint[];
|
|
14
|
-
/** Longest common prefix of the candidate commands, so Tab can extend an ambiguous draft. */
|
|
15
|
-
export declare function commonPrefix(values: string[]): string;
|
|
16
|
-
/** The caller owns starting and stopping the controller around the Ink render lifetime. */
|
|
17
|
-
export declare function App({ controller, panelLifetimeMs, theme }: {
|
|
18
|
-
controller: Controller;
|
|
19
|
-
panelLifetimeMs?: number;
|
|
20
|
-
theme?: Theme;
|
|
21
|
-
}): import("react").JSX.Element;
|