@deepseek-harness-tui/dsh-tui 0.20.0 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/bin/dsh-tui.js +26 -8
- package/guide/dsh-tui-guide/claude-backend.en.md +6 -5
- package/guide/dsh-tui-guide/claude-backend.md +5 -5
- package/guide/dsh-tui-guide/configuration.en.md +26 -12
- package/guide/dsh-tui-guide/configuration.md +18 -9
- package/guide/dsh-tui-guide/getting-started.en.md +17 -9
- package/guide/dsh-tui-guide/getting-started.md +11 -7
- package/guide/dsh-tui-guide/interaction.en.md +1 -0
- package/guide/dsh-tui-guide/interaction.md +1 -0
- package/guide/dsh-tui-guide/migrate.en.md +5 -0
- package/guide/dsh-tui-guide/migrate.md +4 -0
- package/guide/dsh-tui-guide/plugins.en.md +17 -1
- package/guide/dsh-tui-guide/plugins.md +12 -1
- package/guide/dsh-tui-guide/themes.en.md +1 -1
- package/guide/dsh-tui-guide/themes.md +1 -1
- package/guide/dsh-tui-guide/user-guide.en.md +8 -2
- package/guide/dsh-tui-guide/user-guide.md +8 -2
- package/lib/settings.json +19 -3
- package/lib/types/adapter/kernel/host-facade.d.ts +3 -1
- package/lib/types/adapter/kernel/host-facade.d.ts.map +1 -1
- package/lib/types/adapter/kernel/host-facade.js +6 -0
- package/lib/types/adapter/kernel/runtime.d.ts.map +1 -1
- package/lib/types/adapter/kernel/runtime.js +5 -0
- package/lib/types/adapter/kernel/slices/extensions.d.ts +1 -0
- package/lib/types/adapter/kernel/slices/extensions.d.ts.map +1 -1
- package/lib/types/adapter/kernel/slices/extensions.js +6 -1
- package/lib/types/adapter/kernel/slices/index.d.ts +1 -1
- package/lib/types/adapter/kernel/slices/index.d.ts.map +1 -1
- package/lib/types/adapter/kernel/slices/index.js +3 -2
- package/lib/types/adapter/ports/channel-catalog.d.ts +19 -0
- package/lib/types/adapter/ports/channel-catalog.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-settings.d.ts +6 -0
- package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +28 -2
- package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
- package/lib/types/adapter/ports/extensions.d.ts +9 -0
- package/lib/types/adapter/ports/extensions.d.ts.map +1 -1
- package/lib/types/adapter/ports/index.d.ts +1 -1
- package/lib/types/adapter/ports/index.d.ts.map +1 -1
- package/lib/types/adapter/upstream/extensions-driver.d.ts +4 -1
- package/lib/types/adapter/upstream/extensions-driver.d.ts.map +1 -1
- package/lib/types/adapter/upstream/extensions-driver.js +111 -1
- package/lib/types/adapter/upstream/index.d.ts +1 -1
- package/lib/types/adapter/upstream/index.d.ts.map +1 -1
- package/lib/types/adapter/upstream/index.js +1 -1
- package/lib/types/api.d.ts +1 -1
- package/lib/types/api.d.ts.map +1 -1
- package/lib/types/backends/claude/backend.d.ts.map +1 -1
- package/lib/types/backends/claude/backend.js +7 -2
- package/lib/types/backends/claude/session/lifecycle.d.ts.map +1 -1
- package/lib/types/backends/claude/session/lifecycle.js +11 -9
- package/lib/types/backends/claude/side-query.d.ts +2 -0
- package/lib/types/backends/claude/side-query.d.ts.map +1 -1
- package/lib/types/backends/claude/side-query.js +30 -13
- package/lib/types/components/FileSuggestions.d.ts +2 -2
- package/lib/types/components/FileSuggestions.d.ts.map +1 -1
- package/lib/types/components/FileSuggestions.js +25 -5
- package/lib/types/components/PromptInput.d.ts +7 -1
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +81 -23
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +228 -27
- package/lib/types/components/messages/presentCardBackground.d.ts +28 -0
- package/lib/types/components/messages/presentCardBackground.d.ts.map +1 -0
- package/lib/types/components/messages/presentCardBackground.js +23 -0
- package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/translate.js +28 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/file-actions.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/file-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/file-actions.js +11 -4
- package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/settings-host.js +78 -12
- package/lib/types/dsh-adapter/channel/state.d.ts +4 -3
- package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/state.js +4 -3
- package/lib/types/dsh-adapter/channel/types.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.d.ts +1 -1
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/childStderr.d.ts +1 -1
- package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
- package/lib/types/dsh-adapter/childStderr.js +5 -0
- package/lib/types/dsh-adapter/contract.d.ts +23 -8
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +27 -7
- package/lib/types/dsh-adapter/extensions.d.ts +3 -2
- package/lib/types/dsh-adapter/extensions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/extensions.js +5 -2
- package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
- package/lib/types/dsh-adapter/host-contract.js +1 -1
- package/lib/types/dsh-adapter/host-dsh.d.ts +4 -0
- package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-dsh.js +26 -0
- package/lib/types/dsh-adapter/host-entry.js +4 -2
- package/lib/types/dsh-adapter/host-service-diagnostics.d.ts +61 -0
- package/lib/types/dsh-adapter/host-service-diagnostics.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-service-diagnostics.js +103 -0
- package/lib/types/dsh-adapter/index.d.ts +5 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/mention-providers.d.ts +91 -0
- package/lib/types/dsh-adapter/mention-providers.d.ts.map +1 -0
- package/lib/types/dsh-adapter/mention-providers.js +214 -0
- package/lib/types/dsh-adapter/migrate/entry.d.ts +2 -0
- package/lib/types/dsh-adapter/migrate/entry.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/entry.js +46 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +42 -2
- package/lib/types/dsh-adapter/present-tool.d.ts +20 -0
- package/lib/types/dsh-adapter/present-tool.d.ts.map +1 -0
- package/lib/types/dsh-adapter/present-tool.js +96 -0
- package/lib/types/extensions.d.ts +2 -0
- package/lib/types/extensions.d.ts.map +1 -1
- package/lib/types/extensions.js +4 -1
- package/lib/types/i18n.d.ts +21 -2
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +9 -1
- package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
- package/lib/types/ink/components/ScrollBox.js +13 -0
- package/lib/types/ink/dom.d.ts +3 -0
- package/lib/types/ink/dom.d.ts.map +1 -1
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +30 -34
- package/lib/types/ink/render-node-to-output.d.ts +3 -0
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
- package/lib/types/ink/render-node-to-output.js +54 -40
- package/lib/types/ink/selection.d.ts +38 -28
- package/lib/types/ink/selection.d.ts.map +1 -1
- package/lib/types/ink/selection.js +201 -130
- package/lib/types/kernelPrefs.d.ts +5 -2
- package/lib/types/kernelPrefs.d.ts.map +1 -1
- package/lib/types/kernelPrefs.js +5 -2
- package/lib/types/screens/Chat.d.ts +4 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +2 -2
- package/lib/types/settings/definitions.d.ts +12 -0
- package/lib/types/settings/definitions.d.ts.map +1 -1
- package/lib/types/settings/definitions.js +10 -2
- package/lib/types/theme.d.ts +4 -0
- package/lib/types/theme.d.ts.map +1 -1
- package/lib/types/theme.js +20 -2
- package/lib/types/tuiDisplayPrefs.d.ts +3 -0
- package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
- package/lib/types/tuiDisplayPrefs.js +10 -0
- package/lib/types/update.d.ts +74 -5
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +297 -46
- package/lib/types/updateHost.d.ts.map +1 -1
- package/lib/types/updateHost.js +16 -5
- package/lib/types/usageStats.d.ts +6 -0
- package/lib/types/usageStats.d.ts.map +1 -1
- package/lib/types/usageStats.js +8 -0
- package/lib/types/utils/colorMix.d.ts +19 -0
- package/lib/types/utils/colorMix.d.ts.map +1 -0
- package/lib/types/utils/colorMix.js +51 -0
- package/lib/types/utils/commandLine.d.ts +8 -0
- package/lib/types/utils/commandLine.d.ts.map +1 -0
- package/lib/types/utils/commandLine.js +37 -0
- package/lib/types/utils/desktopEntry.d.ts +32 -0
- package/lib/types/utils/desktopEntry.d.ts.map +1 -0
- package/lib/types/utils/desktopEntry.js +302 -0
- package/lib/types/utils/externalEditor.d.ts +2 -5
- package/lib/types/utils/externalEditor.d.ts.map +1 -1
- package/lib/types/utils/externalEditor.js +4 -36
- package/lib/types/utils/fileSuggestions.d.ts +14 -3
- package/lib/types/utils/fileSuggestions.d.ts.map +1 -1
- package/lib/types/utils/fileSuggestions.js +33 -0
- package/lib/types/utils/openExternal.d.ts +9 -0
- package/lib/types/utils/openExternal.d.ts.map +1 -1
- package/lib/types/utils/openExternal.js +87 -3
- package/lib/types/utils/terminalLaunch.d.ts +16 -0
- package/lib/types/utils/terminalLaunch.d.ts.map +1 -0
- package/lib/types/utils/terminalLaunch.js +121 -0
- package/package.json +116 -110
- package/tui-profile/feed/README.md +1 -1
- package/tui-profile/feed/first-party.json +1 -1
|
@@ -214,6 +214,32 @@ export async function loadHostDsh(packageDir = undefined) {
|
|
|
214
214
|
httpProxy: module('httpProxy'),
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
+
/** Install only package resolution for a child command, without composing or
|
|
218
|
+
* rewriting its profile. Even loadProfileDirectory can migrate the manifest,
|
|
219
|
+
* so use the resolver's supported synthetic profile instead. */
|
|
220
|
+
export async function prepareHostModuleResolution(host, profileDir) {
|
|
221
|
+
const profile = {
|
|
222
|
+
name: basename(profileDir),
|
|
223
|
+
dir: profileDir,
|
|
224
|
+
layers: [],
|
|
225
|
+
patchPath: join(profileDir, 'cordis.patch.yml'),
|
|
226
|
+
patches: [],
|
|
227
|
+
skippedBundles: [],
|
|
228
|
+
};
|
|
229
|
+
const resolution = await host.appBoot.createRuntimeResolution({
|
|
230
|
+
installAnchor: host.profileBoot.INSTALL_ANCHOR,
|
|
231
|
+
profile,
|
|
232
|
+
});
|
|
233
|
+
const ctx = new host.Context();
|
|
234
|
+
try {
|
|
235
|
+
await ctx.plugin(host.appBoot.PluginPackages, { resolution });
|
|
236
|
+
return ctx;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
await ctx.fiber.dispose().catch(() => undefined);
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
217
243
|
/**
|
|
218
244
|
* Build the entry's root from the host's `cordis` and install the host's
|
|
219
245
|
* module resolution on it before any TUI module is imported, so the TUI and
|
|
@@ -10,7 +10,7 @@ import { spawn } from 'node:child_process';
|
|
|
10
10
|
import { markBoot } from '../utils/bootTrace.js';
|
|
11
11
|
import { configuredBackend, delegatesToProfile, entryKernel, hostProfile } from '../hostEntryRoute.js';
|
|
12
12
|
import { HANDOFF_ACK_FD_ENV } from '../handoffAck.js';
|
|
13
|
-
import { HOST_NOTICE_ENV } from '../kernelPrefs.js';
|
|
13
|
+
import { HOST_ENTRY_DELEGATED_ENV, HOST_NOTICE_ENV } from '../kernelPrefs.js';
|
|
14
14
|
import { logForDebugging } from '../utils/debug.js';
|
|
15
15
|
import { setProcessName } from '../utils/processName.js';
|
|
16
16
|
import { cmdEscapeArgument } from '../utils/shellQuote.js';
|
|
@@ -22,6 +22,8 @@ markBoot('entry-start');
|
|
|
22
22
|
// #1831: process listings show the inherited main-thread name ("MainThread");
|
|
23
23
|
// the process that becomes the screen names itself as early as it can.
|
|
24
24
|
setProcessName('dsh-tui');
|
|
25
|
+
// A new entry boot decides its own route; only delegateToDsh marks its child.
|
|
26
|
+
delete process.env[HOST_ENTRY_DELEGATED_ENV];
|
|
25
27
|
// DSH's native flock loader reads `process.report.getReport()`; with sockets
|
|
26
28
|
// already open, the network section's reverse lookups block the event loop.
|
|
27
29
|
if (process.report !== undefined)
|
|
@@ -51,7 +53,7 @@ function delegateToDsh() {
|
|
|
51
53
|
// prompt with `&`, `|`, `<` or `>` stays one argument.
|
|
52
54
|
const child = spawn('dsh', windows ? args.map(arg => cmdEscapeArgument(arg, true)) : args, {
|
|
53
55
|
stdio: ack ? ['inherit', 'inherit', 'inherit', 3] : 'inherit',
|
|
54
|
-
env: process.env,
|
|
56
|
+
env: { ...process.env, [HOST_ENTRY_DELEGATED_ENV]: '1' },
|
|
55
57
|
...(windows ? { shell: true } : {}),
|
|
56
58
|
});
|
|
57
59
|
// The terminal's own signals reach dsh through the process group; one sent
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explain a missing Host-scope service when the row that would provide it is
|
|
3
|
+
* disabled in the profile (issue #1842).
|
|
4
|
+
*
|
|
5
|
+
* dsh's compatibility gate can disable every row of an incompatible plugin,
|
|
6
|
+
* print one `disabling profile plugin row` line on stderr, and keep booting.
|
|
7
|
+
* A preset that switched the capability on then fails inside `agents.create`
|
|
8
|
+
* naming only the missing service — never the plugin. The Loader still holds
|
|
9
|
+
* the disabled row (or several rows sharing one specifier), but it does not
|
|
10
|
+
* record *why* a row was disabled, so the diagnostic states only what it can
|
|
11
|
+
* see and gives each cause its own fix.
|
|
12
|
+
*
|
|
13
|
+
* Failure diagnostics, not policy: this never re-evaluates compatibility and
|
|
14
|
+
* never suppresses the original error — including when reading the row itself
|
|
15
|
+
* fails, because `Entry.disabled` evaluates `!!js` expressions. The long text is
|
|
16
|
+
* only guaranteed on the stderr boot-failure path; the startup notice renders a
|
|
17
|
+
* truncated first line plus `StartupOpenError.hint`, and the `/new` toast renders
|
|
18
|
+
* only the first line of `message` — so callers build their own one-line hint
|
|
19
|
+
* from {@link MissingHostService.packageName} through the i18n dictionary
|
|
20
|
+
* (`startup-host-row-disabled-hint`) instead of reusing the English text.
|
|
21
|
+
*/
|
|
22
|
+
/** The Loader fields read here; `disabled`/`options.name` follow bundled-presets.ts. */
|
|
23
|
+
export interface LoaderRow {
|
|
24
|
+
readonly disabled: boolean;
|
|
25
|
+
readonly options?: {
|
|
26
|
+
readonly id?: unknown;
|
|
27
|
+
readonly name?: unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** The slice of a Cordis context this needs; {@link describeMissingHostService} stays testable. */
|
|
31
|
+
export interface HostServiceLookup {
|
|
32
|
+
readonly baseUrl?: string;
|
|
33
|
+
get(name: string): unknown;
|
|
34
|
+
}
|
|
35
|
+
/** A disabled provider of the missing service, and the package a caller aligns. */
|
|
36
|
+
export interface MissingHostService {
|
|
37
|
+
/** English boot-failure text: stderr keeps it whole, the TUI keeps its first line. */
|
|
38
|
+
readonly detail: string;
|
|
39
|
+
/** The plugin package the row belongs to; the localized one-line hint builds on it. */
|
|
40
|
+
readonly packageName: string;
|
|
41
|
+
}
|
|
42
|
+
/** The package a specifier belongs to: `@scope/pkg/sub` → `@scope/pkg`, `pkg/sub` → `pkg`. */
|
|
43
|
+
export declare function packageNameOf(specifier: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* The version installed where the profile resolves it, undefined when unreadable.
|
|
46
|
+
* `findPackageJSON` walks node_modules instead of the exports map, so a package
|
|
47
|
+
* that hides `./package.json` still reports its version.
|
|
48
|
+
*/
|
|
49
|
+
export declare function installedVersion(ctx: HostServiceLookup, packageName: string): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Explain a missing Host-scope service when the row naming it is disabled.
|
|
52
|
+
*
|
|
53
|
+
* One Loader walk per call: `disabled` is a getter that re-evaluates the row's
|
|
54
|
+
* `!!js` expression, so the row list and the disabled state are read once and
|
|
55
|
+
* both the long text and the caller's hint are derived from that result.
|
|
56
|
+
* @param ctx - the TUI plugin context (profile resolution base + Loader service).
|
|
57
|
+
* @param message - the original failure message; left untouched otherwise.
|
|
58
|
+
* @returns the diagnostic and owning package, or undefined when this is not the case.
|
|
59
|
+
*/
|
|
60
|
+
export declare function describeMissingHostService(ctx: HostServiceLookup, message: string): MissingHostService | undefined;
|
|
61
|
+
//# sourceMappingURL=host-service-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-service-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/host-service-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CACtE;AAyBD,mGAAmG;AACnG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAC3B;AAED,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,uFAAuF;IACvF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUhG;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,GACd,kBAAkB,GAAG,SAAS,CAyChC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explain a missing Host-scope service when the row that would provide it is
|
|
3
|
+
* disabled in the profile (issue #1842).
|
|
4
|
+
*
|
|
5
|
+
* dsh's compatibility gate can disable every row of an incompatible plugin,
|
|
6
|
+
* print one `disabling profile plugin row` line on stderr, and keep booting.
|
|
7
|
+
* A preset that switched the capability on then fails inside `agents.create`
|
|
8
|
+
* naming only the missing service — never the plugin. The Loader still holds
|
|
9
|
+
* the disabled row (or several rows sharing one specifier), but it does not
|
|
10
|
+
* record *why* a row was disabled, so the diagnostic states only what it can
|
|
11
|
+
* see and gives each cause its own fix.
|
|
12
|
+
*
|
|
13
|
+
* Failure diagnostics, not policy: this never re-evaluates compatibility and
|
|
14
|
+
* never suppresses the original error — including when reading the row itself
|
|
15
|
+
* fails, because `Entry.disabled` evaluates `!!js` expressions. The long text is
|
|
16
|
+
* only guaranteed on the stderr boot-failure path; the startup notice renders a
|
|
17
|
+
* truncated first line plus `StartupOpenError.hint`, and the `/new` toast renders
|
|
18
|
+
* only the first line of `message` — so callers build their own one-line hint
|
|
19
|
+
* from {@link MissingHostService.packageName} through the i18n dictionary
|
|
20
|
+
* (`startup-host-row-disabled-hint`) instead of reusing the English text.
|
|
21
|
+
*/
|
|
22
|
+
import { readFileSync } from 'node:fs';
|
|
23
|
+
import { findPackageJSON } from 'node:module';
|
|
24
|
+
const HOST_SCOPE_REQUIREMENT = /requires (\S+) in the Host scope/u;
|
|
25
|
+
/** The package a specifier belongs to: `@scope/pkg/sub` → `@scope/pkg`, `pkg/sub` → `pkg`. */
|
|
26
|
+
export function packageNameOf(specifier) {
|
|
27
|
+
const [head, second] = specifier.split('/');
|
|
28
|
+
return specifier.startsWith('@') && second !== undefined ? `${head}/${second}` : head;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The version installed where the profile resolves it, undefined when unreadable.
|
|
32
|
+
* `findPackageJSON` walks node_modules instead of the exports map, so a package
|
|
33
|
+
* that hides `./package.json` still reports its version.
|
|
34
|
+
*/
|
|
35
|
+
export function installedVersion(ctx, packageName) {
|
|
36
|
+
try {
|
|
37
|
+
const manifestPath = findPackageJSON(packageName, ctx.baseUrl ?? import.meta.url);
|
|
38
|
+
if (manifestPath === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
41
|
+
return typeof manifest === 'object' && manifest !== null && 'version' in manifest
|
|
42
|
+
&& typeof manifest.version === 'string' ? manifest.version : undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Explain a missing Host-scope service when the row naming it is disabled.
|
|
50
|
+
*
|
|
51
|
+
* One Loader walk per call: `disabled` is a getter that re-evaluates the row's
|
|
52
|
+
* `!!js` expression, so the row list and the disabled state are read once and
|
|
53
|
+
* both the long text and the caller's hint are derived from that result.
|
|
54
|
+
* @param ctx - the TUI plugin context (profile resolution base + Loader service).
|
|
55
|
+
* @param message - the original failure message; left untouched otherwise.
|
|
56
|
+
* @returns the diagnostic and owning package, or undefined when this is not the case.
|
|
57
|
+
*/
|
|
58
|
+
export function describeMissingHostService(ctx, message) {
|
|
59
|
+
const specifier = HOST_SCOPE_REQUIREMENT.exec(message)?.[1];
|
|
60
|
+
if (specifier === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
let rows;
|
|
63
|
+
try {
|
|
64
|
+
const loader = ctx.get('loader');
|
|
65
|
+
rows = [...(loader?.entries() ?? [])].filter(row => row.options?.name === specifier);
|
|
66
|
+
if (rows.length === 0)
|
|
67
|
+
return undefined;
|
|
68
|
+
// Reading `disabled` evaluates the row's `!!js` expression and walks its
|
|
69
|
+
// parents; a throwing expression must not replace the failure being explained.
|
|
70
|
+
if (rows.some(row => row.disabled !== true))
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
// Same-name rows are a real configuration — the patch row and the official row
|
|
77
|
+
// can share one specifier — so name every disabled one: pointing at the first
|
|
78
|
+
// would send the user to the wrong row. `options.id` is the id the user edits
|
|
79
|
+
// in the profile (the Loader's qualified `Entry.id` can gain a subtree prefix
|
|
80
|
+
// and would not match the yml); the current Loader always fills it in, and the
|
|
81
|
+
// unnamed fallback only guards a future shape change.
|
|
82
|
+
const ids = [...new Set(rows.flatMap(row => typeof row.options?.id === 'string' ? [row.options.id] : []))].sort();
|
|
83
|
+
const pkg = packageNameOf(specifier);
|
|
84
|
+
const named = ids.length === 0
|
|
85
|
+
? `the Host row for "${specifier}"`
|
|
86
|
+
: ids.length === 1
|
|
87
|
+
? `the Host row "${ids[0]}" ("${specifier}")`
|
|
88
|
+
: `the Host rows ${ids.map(id => `"${id}"`).join(', ')} ("${specifier}")`;
|
|
89
|
+
const subject = `${named} ${ids.length > 1 ? 'are' : 'is'}`;
|
|
90
|
+
const version = installedVersion(ctx, pkg);
|
|
91
|
+
// The Loader does not record why the row was disabled, so never assert a cause
|
|
92
|
+
// or an installation the profile could not resolve.
|
|
93
|
+
const installed = version === undefined
|
|
94
|
+
? 'Its installed version could not be read.'
|
|
95
|
+
: `${pkg}@${version} is installed there.`;
|
|
96
|
+
const detail = `dsh-tui: ${subject} disabled in this profile, so nothing provides that service. `
|
|
97
|
+
+ `${installed} `
|
|
98
|
+
+ `Align ${pkg} with the running dsh first: upgrade the plugin, or upgrade dsh if the installed plugin is newer. `
|
|
99
|
+
+ 'If dsh\'s compatibility gate disabled it, the "disabling profile plugin row" line above names the mismatch, '
|
|
100
|
+
+ 'and re-enabling the row alone will be rejected again. '
|
|
101
|
+
+ 'If the profile disabled the row itself, re-enable it only once the condition its row checks no longer fails.';
|
|
102
|
+
return { detail, packageName: pkg };
|
|
103
|
+
}
|
|
@@ -190,6 +190,11 @@ export interface Config {
|
|
|
190
190
|
* than the viewport or of an unsupported type keeps the fenced source.
|
|
191
191
|
* On by default; off always shows the source. */
|
|
192
192
|
mermaidDiagrams?: boolean;
|
|
193
|
+
/** Nerd Font file icons (settings `dsh-tui.nerdFontIcons`): the `present`
|
|
194
|
+
* delivery card renders file-type icons instead of four-cell badges.
|
|
195
|
+
* Off by default; requires a Nerd Font Mono, otherwise the glyphs are
|
|
196
|
+
* boxes. */
|
|
197
|
+
nerdFontIcons?: boolean;
|
|
193
198
|
/** Code-frame shape (settings `dsh-tui.codeFrameStyle`): `light`
|
|
194
199
|
* (default) is the open rail frame — corner + language label on top,
|
|
195
200
|
* a left rail with one padding column per row, no right wall or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAE5F,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAA2Q,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,c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CAAA;AAC3G,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -91,6 +91,7 @@ export const Config = editableConfig(Schema.object({
|
|
|
91
91
|
// config.jumpBack ?? false` at the read site.
|
|
92
92
|
jumpBack: Schema.boolean(),
|
|
93
93
|
mermaidDiagrams: Schema.boolean().default(true),
|
|
94
|
+
nerdFontIcons: Schema.boolean().default(false),
|
|
94
95
|
codeFrameStyle: Schema.union(['light', 'full']),
|
|
95
96
|
mathRendering: Schema.union(['auto', 'image', 'unicode', 'source']),
|
|
96
97
|
mathImageScale: Schema.union(['auto', 'large', 'xlarge']),
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin `@`-mention providers (`ctx.tuiMentions`): optional plugins add rows
|
|
3
|
+
* to the composer's `@` completion popup next to the workspace files — a
|
|
4
|
+
* Blender bridge offering scene objects, an issue tracker offering tickets.
|
|
5
|
+
*
|
|
6
|
+
* The seam is completion-only. A chosen row replaces the typed `@query` with
|
|
7
|
+
* the provider's plain `insertText`; nothing is resolved or attached at submit
|
|
8
|
+
* time, so the file-mention expander never sees provider rows (an item whose
|
|
9
|
+
* `insertText` would itself parse as an `@` mention is dropped at ingress).
|
|
10
|
+
*
|
|
11
|
+
* Same split as the command-tree seam: a host-only facade the composer
|
|
12
|
+
* queries, plus a thin cordis service that validates untrusted registrations
|
|
13
|
+
* and binds each provider to its caller's activation, so a disposed or
|
|
14
|
+
* hot-reloaded plugin leaves no rows behind.
|
|
15
|
+
*
|
|
16
|
+
* Provider calls are untrusted and optional UI: every call gets its own
|
|
17
|
+
* AbortSignal (aborted when the query moves on or the call times out), late
|
|
18
|
+
* results are dropped, a throwing or rejecting provider contributes nothing,
|
|
19
|
+
* and the failure goes to the opt-in `DSH_TUI_DEBUG` log, never the screen.
|
|
20
|
+
*/
|
|
21
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
22
|
+
import type { ProvidedMentionCandidate } from '../adapter/ports/channel-catalog.js';
|
|
23
|
+
/** One completion row a provider offers for the current query. */
|
|
24
|
+
export interface TuiMentionItem {
|
|
25
|
+
/** Row text; single line, at most 80 cells after sanitization. */
|
|
26
|
+
readonly label: string;
|
|
27
|
+
/** Dim trailing hint (kind, location); at most 40 cells. */
|
|
28
|
+
readonly detail?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Plain single-line text that replaces the typed `@query` (the host adds
|
|
31
|
+
* the trailing space). At most 200 characters, and it must not contain an
|
|
32
|
+
* `@` mention token of its own — such an item is dropped.
|
|
33
|
+
*/
|
|
34
|
+
readonly insertText: string;
|
|
35
|
+
}
|
|
36
|
+
/** A plugin's `@` completion source. */
|
|
37
|
+
export interface TuiMentionProvider {
|
|
38
|
+
/** Unique provider id, `^[a-z][a-z0-9_-]*$`. */
|
|
39
|
+
readonly id: string;
|
|
40
|
+
/** Shown beside every row this provider contributes; at most 40 cells. */
|
|
41
|
+
readonly title: string;
|
|
42
|
+
/**
|
|
43
|
+
* Rows for `query` (the text after `@`, possibly empty). `signal` aborts
|
|
44
|
+
* when the user keeps typing or the call outlives its time budget; results
|
|
45
|
+
* that arrive after that are ignored.
|
|
46
|
+
*/
|
|
47
|
+
complete(query: string, signal: AbortSignal): readonly TuiMentionItem[] | Promise<readonly TuiMentionItem[]>;
|
|
48
|
+
}
|
|
49
|
+
/** Admission and per-call bounds, exported so docs and the battery agree. */
|
|
50
|
+
export declare const MENTION_PROVIDER_LIMITS: Readonly<{
|
|
51
|
+
/** Providers one plugin activation may hold at once. */
|
|
52
|
+
perActivation: 4;
|
|
53
|
+
/** Providers the whole host holds at once. */
|
|
54
|
+
total: 16;
|
|
55
|
+
/** Rows taken from one provider per query. */
|
|
56
|
+
itemsPerProvider: 50;
|
|
57
|
+
/** Per-call budget; a slower provider contributes nothing for that query. */
|
|
58
|
+
timeoutMs: 300;
|
|
59
|
+
titleCells: 40;
|
|
60
|
+
labelCells: 80;
|
|
61
|
+
detailCells: 40;
|
|
62
|
+
insertTextChars: 200;
|
|
63
|
+
}>;
|
|
64
|
+
/** Host-only access. Plugins see only `register` on the traceable service;
|
|
65
|
+
* the composer queries every provider through this facade. */
|
|
66
|
+
export interface TuiMentionHost {
|
|
67
|
+
register(provider: TuiMentionProvider): () => void;
|
|
68
|
+
/** Registered provider count; the composer skips the query at zero. */
|
|
69
|
+
size(): number;
|
|
70
|
+
/** Every provider's rows for `query`, in registration order. */
|
|
71
|
+
complete(query: string, signal: AbortSignal): Promise<readonly ProvidedMentionCandidate[]>;
|
|
72
|
+
}
|
|
73
|
+
declare module '@deepseek-ai/cordis' {
|
|
74
|
+
interface Context {
|
|
75
|
+
tuiMentions: TuiMentionRuntime;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export declare const name = "dsh-tui-mentions";
|
|
79
|
+
/**
|
|
80
|
+
* `ctx.tuiMentions` — plugin `@` completion providers. `register` throws on a
|
|
81
|
+
* malformed provider, a duplicate id or an exhausted budget (registration is
|
|
82
|
+
* a programming error, unlike a per-query failure, which only logs).
|
|
83
|
+
*/
|
|
84
|
+
export declare class TuiMentionRuntime extends Service {
|
|
85
|
+
constructor(ctx: Context);
|
|
86
|
+
register(provider: TuiMentionProvider): () => void;
|
|
87
|
+
}
|
|
88
|
+
/** Host-only facade accessor; not part of the package export map. */
|
|
89
|
+
export declare function getHostMentions(runtime: TuiMentionRuntime | undefined): TuiMentionHost | undefined;
|
|
90
|
+
export default TuiMentionRuntime;
|
|
91
|
+
//# sourceMappingURL=mention-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-providers.d.ts","sourceRoot":"","sources":["../../../src/dsh-adapter/mention-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAWnF,kEAAkE;AA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gB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAOlG;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin `@`-mention providers (`ctx.tuiMentions`): optional plugins add rows
|
|
3
|
+
* to the composer's `@` completion popup next to the workspace files — a
|
|
4
|
+
* Blender bridge offering scene objects, an issue tracker offering tickets.
|
|
5
|
+
*
|
|
6
|
+
* The seam is completion-only. A chosen row replaces the typed `@query` with
|
|
7
|
+
* the provider's plain `insertText`; nothing is resolved or attached at submit
|
|
8
|
+
* time, so the file-mention expander never sees provider rows (an item whose
|
|
9
|
+
* `insertText` would itself parse as an `@` mention is dropped at ingress).
|
|
10
|
+
*
|
|
11
|
+
* Same split as the command-tree seam: a host-only facade the composer
|
|
12
|
+
* queries, plus a thin cordis service that validates untrusted registrations
|
|
13
|
+
* and binds each provider to its caller's activation, so a disposed or
|
|
14
|
+
* hot-reloaded plugin leaves no rows behind.
|
|
15
|
+
*
|
|
16
|
+
* Provider calls are untrusted and optional UI: every call gets its own
|
|
17
|
+
* AbortSignal (aborted when the query moves on or the call times out), late
|
|
18
|
+
* results are dropped, a throwing or rejecting provider contributes nothing,
|
|
19
|
+
* and the failure goes to the opt-in `DSH_TUI_DEBUG` log, never the screen.
|
|
20
|
+
*/
|
|
21
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
22
|
+
import { extractMentions } from '../utils/mentions.js';
|
|
23
|
+
import { logForDebugging } from '../utils/debug.js';
|
|
24
|
+
import { cleanStatusFieldText } from './sanitize.js';
|
|
25
|
+
import { activationFiber, bindCallerEffect, compositionRoot, concreteService, requirePluginCaller } from './host-access.js';
|
|
26
|
+
import { adapterRuntimeFor } from '../adapter/kernel/runtime-context.js';
|
|
27
|
+
import { assertCapabilityShadowPolicy, } from '../adapter/kernel/runtime.js';
|
|
28
|
+
/** Admission and per-call bounds, exported so docs and the battery agree. */
|
|
29
|
+
export const MENTION_PROVIDER_LIMITS = Object.freeze({
|
|
30
|
+
/** Providers one plugin activation may hold at once. */
|
|
31
|
+
perActivation: 4,
|
|
32
|
+
/** Providers the whole host holds at once. */
|
|
33
|
+
total: 16,
|
|
34
|
+
/** Rows taken from one provider per query. */
|
|
35
|
+
itemsPerProvider: 50,
|
|
36
|
+
/** Per-call budget; a slower provider contributes nothing for that query. */
|
|
37
|
+
timeoutMs: 300,
|
|
38
|
+
titleCells: 40,
|
|
39
|
+
labelCells: 80,
|
|
40
|
+
detailCells: 40,
|
|
41
|
+
insertTextChars: 200,
|
|
42
|
+
});
|
|
43
|
+
const PROVIDER_ID = /^[a-z][a-z0-9_-]*$/u;
|
|
44
|
+
export const name = 'dsh-tui-mentions';
|
|
45
|
+
const mentionStates = new WeakMap();
|
|
46
|
+
/**
|
|
47
|
+
* `ctx.tuiMentions` — plugin `@` completion providers. `register` throws on a
|
|
48
|
+
* malformed provider, a duplicate id or an exhausted budget (registration is
|
|
49
|
+
* a programming error, unlike a per-query failure, which only logs).
|
|
50
|
+
*/
|
|
51
|
+
export class TuiMentionRuntime extends Service {
|
|
52
|
+
constructor(ctx) {
|
|
53
|
+
super(ctx, 'tuiMentions');
|
|
54
|
+
compositionRoot(ctx);
|
|
55
|
+
const runtime = this;
|
|
56
|
+
const state = { runtime: adapterRuntimeFor(ctx), providers: new Map(), host: undefined };
|
|
57
|
+
state.host = Object.freeze({
|
|
58
|
+
register: (provider) => {
|
|
59
|
+
const state = mentionStateFor(runtime);
|
|
60
|
+
const entry = admit(state, provider, undefined);
|
|
61
|
+
state.providers.set(entry.id, entry);
|
|
62
|
+
return () => release(state, entry);
|
|
63
|
+
},
|
|
64
|
+
size: () => mentionStateFor(runtime).providers.size,
|
|
65
|
+
complete: (query, signal) => completeAll(mentionStateFor(runtime), query, signal),
|
|
66
|
+
});
|
|
67
|
+
mentionStates.set(this, state);
|
|
68
|
+
}
|
|
69
|
+
register(provider) {
|
|
70
|
+
const state = mentionStateFor(this);
|
|
71
|
+
assertCapabilityShadowPolicy('host.mentions.register', state.runtime.mode, state.runtime.slices);
|
|
72
|
+
const caller = requirePluginCaller(this.ctx, 'tuiMentions.register', this);
|
|
73
|
+
const owner = activationFiber(caller);
|
|
74
|
+
if (owner === undefined)
|
|
75
|
+
throw new Error('dsh-tui: tuiMentions.register requires a live activation');
|
|
76
|
+
const entry = admit(state, provider, owner);
|
|
77
|
+
state.providers.set(entry.id, entry);
|
|
78
|
+
const dispose = () => release(state, entry);
|
|
79
|
+
bindCallerEffect(caller, dispose);
|
|
80
|
+
return dispose;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Validate one registration against shape and budgets; throws on refusal. */
|
|
84
|
+
function admit(state, provider, owner) {
|
|
85
|
+
if (provider === null || typeof provider !== 'object')
|
|
86
|
+
throw new TypeError('tuiMentions.register expects a provider object');
|
|
87
|
+
const id = typeof provider.id === 'string' ? provider.id : '';
|
|
88
|
+
if (!PROVIDER_ID.test(id))
|
|
89
|
+
throw new TypeError(`invalid TUI mention provider id: ${String(provider.id)}`);
|
|
90
|
+
if (typeof provider.complete !== 'function')
|
|
91
|
+
throw new TypeError(`TUI mention provider "${id}" needs a complete() function`);
|
|
92
|
+
const title = cleanStatusFieldText(provider.title, MENTION_PROVIDER_LIMITS.titleCells);
|
|
93
|
+
if (title === '')
|
|
94
|
+
throw new TypeError(`TUI mention provider "${id}" needs a non-empty title`);
|
|
95
|
+
if (state.providers.has(id))
|
|
96
|
+
throw new Error(`TUI mention provider "${id}" is already registered`);
|
|
97
|
+
if (state.providers.size >= MENTION_PROVIDER_LIMITS.total) {
|
|
98
|
+
throw new Error(`TUI mention providers are capped at ${MENTION_PROVIDER_LIMITS.total}; "${id}" was refused`);
|
|
99
|
+
}
|
|
100
|
+
if (owner !== undefined) {
|
|
101
|
+
let held = 0;
|
|
102
|
+
for (const entry of state.providers.values())
|
|
103
|
+
if (entry.owner === owner)
|
|
104
|
+
held += 1;
|
|
105
|
+
if (held >= MENTION_PROVIDER_LIMITS.perActivation) {
|
|
106
|
+
throw new Error(`TUI mention providers are capped at ${MENTION_PROVIDER_LIMITS.perActivation} per plugin; "${id}" was refused`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { id, title, provider, owner };
|
|
110
|
+
}
|
|
111
|
+
function release(state, entry) {
|
|
112
|
+
if (state.providers.get(entry.id) === entry)
|
|
113
|
+
state.providers.delete(entry.id);
|
|
114
|
+
}
|
|
115
|
+
async function completeAll(state, query, signal) {
|
|
116
|
+
if (state.providers.size === 0 || signal.aborted)
|
|
117
|
+
return [];
|
|
118
|
+
const settled = await Promise.all([...state.providers.values()].map(entry => completeOne(entry, query, signal)));
|
|
119
|
+
return signal.aborted ? [] : settled.flat();
|
|
120
|
+
}
|
|
121
|
+
/** One provider call under its own signal and time budget. Never rejects. */
|
|
122
|
+
async function completeOne(entry, query, outer) {
|
|
123
|
+
const controller = new AbortController();
|
|
124
|
+
const abort = () => controller.abort();
|
|
125
|
+
outer.addEventListener('abort', abort, { once: true });
|
|
126
|
+
let timer;
|
|
127
|
+
try {
|
|
128
|
+
const timeout = new Promise(resolve => {
|
|
129
|
+
timer = setTimeout(() => {
|
|
130
|
+
controller.abort();
|
|
131
|
+
resolve(undefined);
|
|
132
|
+
}, MENTION_PROVIDER_LIMITS.timeoutMs);
|
|
133
|
+
});
|
|
134
|
+
// `then` turns a synchronous throw into a rejection the catch below sees.
|
|
135
|
+
const call = Promise.resolve().then(() => entry.provider.complete(query, controller.signal));
|
|
136
|
+
const result = await Promise.race([call, timeout]);
|
|
137
|
+
if (controller.signal.aborted) {
|
|
138
|
+
if (!outer.aborted)
|
|
139
|
+
logForDebugging('tuiMentions provider timed out', { id: entry.id, timeoutMs: MENTION_PROVIDER_LIMITS.timeoutMs });
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
return normalizeItems(entry, result);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (!controller.signal.aborted) {
|
|
146
|
+
logForDebugging('tuiMentions provider failed', { id: entry.id, error: error instanceof Error ? error.message : String(error) });
|
|
147
|
+
}
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
outer.removeEventListener('abort', abort);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Sanitize one provider's rows; malformed rows are skipped, not fatal. */
|
|
156
|
+
function normalizeItems(entry, result) {
|
|
157
|
+
if (!Array.isArray(result)) {
|
|
158
|
+
logForDebugging('tuiMentions provider returned a non-array', { id: entry.id });
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
const out = [];
|
|
162
|
+
const seen = new Set();
|
|
163
|
+
for (const raw of result.slice(0, MENTION_PROVIDER_LIMITS.itemsPerProvider)) {
|
|
164
|
+
try {
|
|
165
|
+
if (raw === null || typeof raw !== 'object')
|
|
166
|
+
continue;
|
|
167
|
+
const item = raw;
|
|
168
|
+
const label = cleanStatusFieldText(item.label, MENTION_PROVIDER_LIMITS.labelCells);
|
|
169
|
+
const insertText = cleanStatusFieldText(item.insertText, Number.POSITIVE_INFINITY);
|
|
170
|
+
if (label === '' || insertText === '')
|
|
171
|
+
continue;
|
|
172
|
+
if (insertText.length > MENTION_PROVIDER_LIMITS.insertTextChars)
|
|
173
|
+
continue;
|
|
174
|
+
if (extractMentions(insertText).length > 0)
|
|
175
|
+
continue;
|
|
176
|
+
const detail = item.detail === undefined ? '' : cleanStatusFieldText(item.detail, MENTION_PROVIDER_LIMITS.detailCells);
|
|
177
|
+
const id = `${entry.id}\u0000${label}\u0000${insertText}`;
|
|
178
|
+
if (seen.has(id))
|
|
179
|
+
continue;
|
|
180
|
+
seen.add(id);
|
|
181
|
+
out.push({
|
|
182
|
+
id,
|
|
183
|
+
kind: 'provided',
|
|
184
|
+
providerId: entry.id,
|
|
185
|
+
section: entry.title,
|
|
186
|
+
label,
|
|
187
|
+
...(detail === '' ? {} : { detail }),
|
|
188
|
+
insertText,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// A throwing getter on one row must not cost the provider its others.
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
function mentionStateFor(runtime) {
|
|
198
|
+
const state = mentionStates.get(concreteService(runtime));
|
|
199
|
+
if (state === undefined)
|
|
200
|
+
throw new Error('tuiMentions host state is unavailable');
|
|
201
|
+
return state;
|
|
202
|
+
}
|
|
203
|
+
/** Host-only facade accessor; not part of the package export map. */
|
|
204
|
+
export function getHostMentions(runtime) {
|
|
205
|
+
if (runtime === undefined)
|
|
206
|
+
return undefined;
|
|
207
|
+
try {
|
|
208
|
+
return mentionStateFor(runtime).host;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export default TuiMentionRuntime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/migrate/entry.ts"],"names":[],"mappings":"AAYA,wBAAsB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC7F"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Child processes do not inherit the TUI's package resolution hooks. Install
|
|
3
|
+
* the host resolver before the first import of migration's framework peers.
|
|
4
|
+
*/
|
|
5
|
+
import { loadHostDsh, prepareHostModuleResolution } from '../host-dsh.js';
|
|
6
|
+
const reasonOf = (value) => value instanceof Error ? value.message : String(value);
|
|
7
|
+
/** Keep a directly written diagnostic on one line. */
|
|
8
|
+
const flat = (value) => reasonOf(value).replace(/[\x00-\x1f\x7f-\x9f]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
9
|
+
export async function cliMigrate(argv, profileDir) {
|
|
10
|
+
let root;
|
|
11
|
+
let hostError;
|
|
12
|
+
try {
|
|
13
|
+
root = await prepareHostModuleResolution(await loadHostDsh(), profileDir);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
// Development installs and older hosts may already resolve their peers
|
|
17
|
+
// directly. Try that path once: a failed ESM import cannot be retried
|
|
18
|
+
// reliably because Node caches rejected module jobs.
|
|
19
|
+
hostError = error;
|
|
20
|
+
}
|
|
21
|
+
let failed = false;
|
|
22
|
+
let exitCode;
|
|
23
|
+
try {
|
|
24
|
+
const { cliMigrate: run } = await import('./cli.js');
|
|
25
|
+
exitCode = await run(argv);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
failed = true;
|
|
29
|
+
if (hostError === undefined)
|
|
30
|
+
throw error;
|
|
31
|
+
throw new Error(`${reasonOf(error)}; host module resolution: ${reasonOf(hostError)}`, { cause: error });
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
await root?.fiber.dispose();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// The migration already ran: a cleanup failure must not turn a finished
|
|
39
|
+
// run into "could not run". Keep the original error on the failure path.
|
|
40
|
+
if (!failed) {
|
|
41
|
+
process.stderr.write(`dsh-tui: migrate finished; host module resolution cleanup failed: ${flat(error)}\n`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return exitCode;
|
|
46
|
+
}
|