dsh-over-ssh 0.1.0 → 0.2.0
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 +19 -17
- package/agents/agent-manifest.json +6 -6
- package/agents/linux-amd64/dsh-over-ssh-agent +0 -0
- package/agents/linux-arm64/dsh-over-ssh-agent +0 -0
- package/lib/client.js +422 -337
- package/lib/file-references.js +92 -35
- package/lib/fs.js +295 -113
- package/lib/index.js +6912 -4330
- package/lib/terminal-wrapper.js +9 -4
- package/lib/types/src/config.d.ts +156 -9
- package/lib/types/src/file-references.d.ts +0 -1
- package/lib/types/src/host/app/backend.d.ts +44 -3
- package/lib/types/src/host/app/recycle-bin/recycle-bin-contract.d.ts +0 -1
- package/lib/types/src/host/app/recycle-bin/recycle-bin-service.d.ts +0 -1
- package/lib/types/src/host/app/session-admin/session-admin-contract.d.ts +12 -1
- package/lib/types/src/host/app/session-admin/session-admin-service.d.ts +0 -1
- package/lib/types/src/host/app/transport/transport-selector.d.ts +0 -1
- package/lib/types/src/host/app/transport/transport-service.d.ts +0 -1
- package/lib/types/src/host/domain/capability.d.ts +0 -1
- package/lib/types/src/host/domain/errors.d.ts +0 -1
- package/lib/types/src/host/domain/roots/connection.d.ts +0 -1
- package/lib/types/src/host/domain/roots/root.d.ts +24 -9
- package/lib/types/src/host/domain/roots/session-roots.d.ts +23 -1
- package/lib/types/src/host/domain/roots/ssh-config.d.ts +0 -1
- package/lib/types/src/host/domain/session/session-admin.d.ts +0 -1
- package/lib/types/src/host/domain/transfer/recycle-bin.d.ts +0 -1
- package/lib/types/src/host/domain/transfer/transfer.d.ts +0 -1
- package/lib/types/src/host/infra/transport/agent/agent-installer.d.ts +0 -1
- package/lib/types/src/host/infra/transport/forward.d.ts +75 -0
- package/lib/types/src/host/infra/transport/ssh/ssh2-transport.d.ts +5 -1
- package/lib/types/src/host/infra/transport/transport-base.d.ts +0 -1
- package/lib/types/src/host/infra/transport/transport.d.ts +42 -2
- package/lib/types/src/host/integration/agent/agent-preflight.d.ts +0 -1
- package/lib/types/src/host/integration/fs/file-reference-provider.d.ts +0 -1
- package/lib/types/src/host/integration/fs/fs-provider.d.ts +18 -3
- package/lib/types/src/host/integration/transfer/transfer-service.d.ts +0 -1
- package/lib/types/src/index.d.ts +23 -1
- package/lib/types/src/local-bridge-refs.d.ts +0 -1
- package/lib/types/src/local-bridge.d.ts +0 -1
- package/lib/types/src/shared/root-keys.d.ts +120 -0
- package/lib/types/src/wiring/helpers.d.ts +0 -1
- package/package.json +5 -3
- package/lib/types/src/client/controls.d.ts +0 -131
- package/lib/types/src/client/core/card-focus-trap.d.ts +0 -45
- package/lib/types/src/client/core/controls.d.ts +0 -164
- package/lib/types/src/client/core/latest.d.ts +0 -48
- package/lib/types/src/client/core/locale.d.ts +0 -38
- package/lib/types/src/client/core/message.d.ts +0 -37
- package/lib/types/src/client/core/panel-model.d.ts +0 -134
- package/lib/types/src/client/core/portal.d.ts +0 -266
- package/lib/types/src/client/core/remote.d.ts +0 -84
- package/lib/types/src/client/core/styles.d.ts +0 -458
- package/lib/types/src/client/file-tree-io.d.ts +0 -19
- package/lib/types/src/client/file-tree.d.ts +0 -271
- package/lib/types/src/client/flows/directory-browser.d.ts +0 -587
- package/lib/types/src/client/flows/session-directory.d.ts +0 -415
- package/lib/types/src/client/flows/workspace-directory-flow.d.ts +0 -480
- package/lib/types/src/client/locale.d.ts +0 -31
- package/lib/types/src/client/panel-model.d.ts +0 -37
- package/lib/types/src/client/panel.d.ts +0 -77
- package/lib/types/src/client/roots/connection-test.d.ts +0 -69
- package/lib/types/src/client/roots/roots-panel-state.d.ts +0 -307
- package/lib/types/src/client/roots/roots-panel-view.d.ts +0 -280
- package/lib/types/src/client/roots/roots-panel.d.ts +0 -364
- package/lib/types/src/client/roots/transfer-panel-view.d.ts +0 -35
- package/lib/types/src/client/roots/transfer-panel.d.ts +0 -241
- package/lib/types/src/client/roots/transfer-progress.d.ts +0 -67
- package/lib/types/src/client/roots-panel-view.d.ts +0 -236
- package/lib/types/src/client/roots-panel.d.ts +0 -347
- package/lib/types/src/client/session/session-panel-view.d.ts +0 -336
- package/lib/types/src/client/session/session-panel.d.ts +0 -322
- package/lib/types/src/client/session/session-remote-mark.d.ts +0 -110
- package/lib/types/src/client/session/session-row-actions.d.ts +0 -398
- package/lib/types/src/client/session-panel.d.ts +0 -152
- package/lib/types/src/client/styles.d.ts +0 -252
- package/lib/types/src/client/workspace-directory-flow.d.ts +0 -342
- package/lib/types/src/fs.d.ts +0 -46
- package/lib/types/src/host/app/recycle-bin/recycle-bin-move.d.ts +0 -18
- package/lib/types/src/host/app/recycle-bin/recycle-bin-world.d.ts +0 -38
- package/lib/types/src/host/app/recycle-bin-contract.d.ts +0 -215
- package/lib/types/src/host/app/recycle-bin-move.d.ts +0 -18
- package/lib/types/src/host/app/recycle-bin-service.d.ts +0 -45
- package/lib/types/src/host/app/recycle-bin-world.d.ts +0 -35
- package/lib/types/src/host/app/roots/roots-api-connections.d.ts +0 -49
- package/lib/types/src/host/app/roots/roots-api-contract.d.ts +0 -369
- package/lib/types/src/host/app/roots/roots-api-directories.d.ts +0 -13
- package/lib/types/src/host/app/roots/roots-api-http.d.ts +0 -77
- package/lib/types/src/host/app/roots/roots-api-long-poll.d.ts +0 -130
- package/lib/types/src/host/app/roots/roots-api-projections.d.ts +0 -102
- package/lib/types/src/host/app/roots/roots-api-roots.d.ts +0 -13
- package/lib/types/src/host/app/roots/roots-api-state.d.ts +0 -22
- package/lib/types/src/host/app/roots/roots-api-transfers.d.ts +0 -26
- package/lib/types/src/host/app/roots/roots-api.d.ts +0 -55
- package/lib/types/src/host/app/roots/user-roots.d.ts +0 -552
- package/lib/types/src/host/app/roots-api-connections.d.ts +0 -49
- package/lib/types/src/host/app/roots-api-contract.d.ts +0 -339
- package/lib/types/src/host/app/roots-api-directories.d.ts +0 -13
- package/lib/types/src/host/app/roots-api-http.d.ts +0 -77
- package/lib/types/src/host/app/roots-api-projections.d.ts +0 -102
- package/lib/types/src/host/app/roots-api-roots.d.ts +0 -13
- package/lib/types/src/host/app/roots-api-state.d.ts +0 -22
- package/lib/types/src/host/app/roots-api-support.d.ts +0 -182
- package/lib/types/src/host/app/roots-api-transfers.d.ts +0 -13
- package/lib/types/src/host/app/roots-api.d.ts +0 -55
- package/lib/types/src/host/app/routed-fs.d.ts +0 -239
- package/lib/types/src/host/app/serialize.d.ts +0 -37
- package/lib/types/src/host/app/session-admin/session-admin-context.d.ts +0 -36
- package/lib/types/src/host/app/session-admin/session-admin-delete.d.ts +0 -34
- package/lib/types/src/host/app/session-admin-context.d.ts +0 -36
- package/lib/types/src/host/app/session-admin-contract.d.ts +0 -214
- package/lib/types/src/host/app/session-admin-delete.d.ts +0 -34
- package/lib/types/src/host/app/session-admin-service.d.ts +0 -38
- package/lib/types/src/host/app/takeover/takeover-plan.d.ts +0 -227
- package/lib/types/src/host/app/takeover/takeover-rows.d.ts +0 -55
- package/lib/types/src/host/app/transport-selector.d.ts +0 -98
- package/lib/types/src/host/app/transport-service.d.ts +0 -75
- package/lib/types/src/host/app/user-roots.d.ts +0 -461
- package/lib/types/src/host/domain/bin-location.d.ts +0 -79
- package/lib/types/src/host/domain/connection.d.ts +0 -95
- package/lib/types/src/host/domain/glob-pattern.d.ts +0 -62
- package/lib/types/src/host/domain/literal-text.d.ts +0 -63
- package/lib/types/src/host/domain/path-grammar.d.ts +0 -84
- package/lib/types/src/host/domain/recycle-bin.d.ts +0 -337
- package/lib/types/src/host/domain/root.d.ts +0 -74
- package/lib/types/src/host/domain/roots/bin-location.d.ts +0 -91
- package/lib/types/src/host/domain/roots/route-table.d.ts +0 -102
- package/lib/types/src/host/domain/route-table.d.ts +0 -80
- package/lib/types/src/host/domain/session/terminal-target.d.ts +0 -136
- package/lib/types/src/host/domain/session-admin.d.ts +0 -330
- package/lib/types/src/host/domain/shell.d.ts +0 -47
- package/lib/types/src/host/domain/ssh-config.d.ts +0 -73
- package/lib/types/src/host/domain/terminal-target.d.ts +0 -132
- package/lib/types/src/host/domain/tool-requests.d.ts +0 -369
- package/lib/types/src/host/domain/transfer.d.ts +0 -260
- package/lib/types/src/host/infra/backend/local-backend.d.ts +0 -84
- package/lib/types/src/host/infra/backend/local-version.d.ts +0 -43
- package/lib/types/src/host/infra/backend/platform-local-backend.d.ts +0 -89
- package/lib/types/src/host/infra/backend/remote-backend.d.ts +0 -239
- package/lib/types/src/host/infra/cache/lru.d.ts +0 -52
- package/lib/types/src/host/infra/cache/versioned.d.ts +0 -77
- package/lib/types/src/host/infra/temp-name.d.ts +0 -19
- package/lib/types/src/host/infra/transport/agent/agent-protocol-client.d.ts +0 -132
- package/lib/types/src/host/infra/transport/agent/agent-protocol-codec.d.ts +0 -140
- package/lib/types/src/host/infra/transport/agent/agent-protocol-errors.d.ts +0 -41
- package/lib/types/src/host/infra/transport/agent/agent-protocol-frames.d.ts +0 -197
- package/lib/types/src/host/infra/transport/agent/agent-protocol-types.d.ts +0 -564
- package/lib/types/src/host/infra/transport/agent/agent-transport.d.ts +0 -418
- package/lib/types/src/host/infra/transport/agent-installer.d.ts +0 -121
- package/lib/types/src/host/infra/transport/agent-protocol-client.d.ts +0 -123
- package/lib/types/src/host/infra/transport/agent-protocol-codec.d.ts +0 -131
- package/lib/types/src/host/infra/transport/agent-protocol-errors.d.ts +0 -41
- package/lib/types/src/host/infra/transport/agent-protocol-frames.d.ts +0 -197
- package/lib/types/src/host/infra/transport/agent-protocol-types.d.ts +0 -509
- package/lib/types/src/host/infra/transport/agent-transport.d.ts +0 -353
- package/lib/types/src/host/infra/transport/alias-transport.d.ts +0 -206
- package/lib/types/src/host/infra/transport/askpass-fs.d.ts +0 -20
- package/lib/types/src/host/infra/transport/askpass.d.ts +0 -133
- package/lib/types/src/host/infra/transport/command-pool.d.ts +0 -61
- package/lib/types/src/host/infra/transport/fs-commands.d.ts +0 -140
- package/lib/types/src/host/infra/transport/git-status-route.d.ts +0 -63
- package/lib/types/src/host/infra/transport/git-status.d.ts +0 -101
- package/lib/types/src/host/infra/transport/node-spawn.d.ts +0 -26
- package/lib/types/src/host/infra/transport/session-window.d.ts +0 -51
- package/lib/types/src/host/infra/transport/shell-quote.d.ts +0 -59
- package/lib/types/src/host/infra/transport/ssh/alias-transport.d.ts +0 -206
- package/lib/types/src/host/infra/transport/ssh/askpass-fs.d.ts +0 -20
- package/lib/types/src/host/infra/transport/ssh/askpass.d.ts +0 -133
- package/lib/types/src/host/infra/transport/ssh/shell-quote.d.ts +0 -62
- package/lib/types/src/host/infra/transport/ssh/ssh-argv.d.ts +0 -43
- package/lib/types/src/host/infra/transport/ssh-argv.d.ts +0 -43
- package/lib/types/src/host/infra/transport/ssh2-transport.d.ts +0 -302
- package/lib/types/src/host/integration/agent/agent-install-io.d.ts +0 -33
- package/lib/types/src/host/integration/agent/askpass-registry.d.ts +0 -66
- package/lib/types/src/host/integration/agent-install-io.d.ts +0 -33
- package/lib/types/src/host/integration/agent-preflight.d.ts +0 -56
- package/lib/types/src/host/integration/anchor-directory.d.ts +0 -56
- package/lib/types/src/host/integration/askpass-registry.d.ts +0 -59
- package/lib/types/src/host/integration/bin-root-resolver.d.ts +0 -81
- package/lib/types/src/host/integration/connection-test.d.ts +0 -73
- package/lib/types/src/host/integration/file-reference-provider.d.ts +0 -115
- package/lib/types/src/host/integration/fs/git-status-wiring.d.ts +0 -21
- package/lib/types/src/host/integration/fs/platform-errors.d.ts +0 -94
- package/lib/types/src/host/integration/fs/remote-file-tools.d.ts +0 -369
- package/lib/types/src/host/integration/fs/remote-index.d.ts +0 -177
- package/lib/types/src/host/integration/fs-provider.d.ts +0 -226
- package/lib/types/src/host/integration/lsp/lsp-framing.d.ts +0 -38
- package/lib/types/src/host/integration/lsp/lsp-registry.d.ts +0 -67
- package/lib/types/src/host/integration/lsp/lsp-session.d.ts +0 -130
- package/lib/types/src/host/integration/management-tools.d.ts +0 -64
- package/lib/types/src/host/integration/recycle-bin-service.d.ts +0 -247
- package/lib/types/src/host/integration/remote/connection-test.d.ts +0 -73
- package/lib/types/src/host/integration/remote/remote-face.d.ts +0 -127
- package/lib/types/src/host/integration/remote/remote-tool-backend.d.ts +0 -108
- package/lib/types/src/host/integration/remote-face.d.ts +0 -127
- package/lib/types/src/host/integration/remote-file-tools.d.ts +0 -241
- package/lib/types/src/host/integration/remote-home.d.ts +0 -69
- package/lib/types/src/host/integration/remote-index.d.ts +0 -165
- package/lib/types/src/host/integration/remote-job-tools.d.ts +0 -295
- package/lib/types/src/host/integration/remote-tool-backend.d.ts +0 -97
- package/lib/types/src/host/integration/remote-tools.d.ts +0 -206
- package/lib/types/src/host/integration/root-registry.d.ts +0 -115
- package/lib/types/src/host/integration/roots/anchor-directory.d.ts +0 -56
- package/lib/types/src/host/integration/roots/bin-root-resolver.d.ts +0 -81
- package/lib/types/src/host/integration/roots/remote-home.d.ts +0 -69
- package/lib/types/src/host/integration/roots/root-registry.d.ts +0 -144
- package/lib/types/src/host/integration/roots/roots-wiring.d.ts +0 -219
- package/lib/types/src/host/integration/roots/session-root-index.d.ts +0 -52
- package/lib/types/src/host/integration/roots-api.d.ts +0 -407
- package/lib/types/src/host/integration/roots-wiring.d.ts +0 -211
- package/lib/types/src/host/integration/session/session-api.d.ts +0 -88
- package/lib/types/src/host/integration/session/session-bin-lock.d.ts +0 -80
- package/lib/types/src/host/integration/session/session-header.d.ts +0 -151
- package/lib/types/src/host/integration/session/session-labels.d.ts +0 -56
- package/lib/types/src/host/integration/session/session-route-wiring.d.ts +0 -50
- package/lib/types/src/host/integration/session-admin-service.d.ts +0 -236
- package/lib/types/src/host/integration/session-api.d.ts +0 -81
- package/lib/types/src/host/integration/session-bin-lock.d.ts +0 -80
- package/lib/types/src/host/integration/session-header.d.ts +0 -118
- package/lib/types/src/host/integration/session-labels.d.ts +0 -56
- package/lib/types/src/host/integration/session-route-wiring.d.ts +0 -50
- package/lib/types/src/host/integration/session-scope.d.ts +0 -113
- package/lib/types/src/host/integration/session-tools.d.ts +0 -44
- package/lib/types/src/host/integration/strict-arguments.d.ts +0 -79
- package/lib/types/src/host/integration/takeover/takeover-api.d.ts +0 -62
- package/lib/types/src/host/integration/takeover/takeover-route-wiring.d.ts +0 -60
- package/lib/types/src/host/integration/takeover/takeover-service.d.ts +0 -167
- package/lib/types/src/host/integration/terminal-manifest.d.ts +0 -94
- package/lib/types/src/host/integration/tools/management-tools.d.ts +0 -245
- package/lib/types/src/host/integration/tools/remote-job-tools.d.ts +0 -316
- package/lib/types/src/host/integration/tools/remote-lsp-tools.d.ts +0 -43
- package/lib/types/src/host/integration/tools/remote-tools.d.ts +0 -236
- package/lib/types/src/host/integration/tools/session-target.d.ts +0 -52
- package/lib/types/src/host/integration/tools/session-tools.d.ts +0 -46
- package/lib/types/src/host/integration/tools/strict-arguments.d.ts +0 -79
- package/lib/types/src/host/integration/tools/terminal-manifest.d.ts +0 -94
- package/lib/types/src/host/integration/transfer/remote-copy.d.ts +0 -66
- package/lib/types/src/host/integration/transfer/transfer-adapters.d.ts +0 -48
- package/lib/types/src/host/integration/transfer/transfer-tracker.d.ts +0 -106
- package/lib/types/src/host/integration/transfer-adapters.d.ts +0 -44
- package/lib/types/src/host/integration/transfer-service.d.ts +0 -164
- package/lib/types/src/host/integration/transfer-tracker.d.ts +0 -106
- package/lib/types/src/host/integration/user-roots.d.ts +0 -461
- package/lib/types/src/wiring/connections.d.ts +0 -189
- package/lib/types/src/wiring/fs.d.ts +0 -13
- package/lib/types/src/wiring/install-memo.d.ts +0 -32
- package/lib/types/src/wiring/legacy-dirs.d.ts +0 -62
- package/lib/types/src/wiring/package-paths.d.ts +0 -35
- package/lib/types/src/wiring/roots.d.ts +0 -21
- package/lib/types/src/wiring/state-dir.d.ts +0 -29
- package/lib/types/src/wiring/tools.d.ts +0 -35
package/lib/file-references.js
CHANGED
|
@@ -49,7 +49,26 @@ var DEFAULTS = {
|
|
|
49
49
|
function rankMatches(paths, query, limit) {
|
|
50
50
|
const needle = query.trim().toLowerCase();
|
|
51
51
|
if (needle === "") {
|
|
52
|
-
|
|
52
|
+
const top = [];
|
|
53
|
+
const better = (left, right) => {
|
|
54
|
+
const leftDepth = depth(paths[left]);
|
|
55
|
+
const rightDepth = depth(paths[right]);
|
|
56
|
+
if (leftDepth !== rightDepth) return leftDepth < rightDepth;
|
|
57
|
+
return paths[left] < paths[right];
|
|
58
|
+
};
|
|
59
|
+
for (let index = 0; index < paths.length; index += 1) {
|
|
60
|
+
if (top.length >= limit && !better(index, top[top.length - 1])) continue;
|
|
61
|
+
let low = 0;
|
|
62
|
+
let high = top.length;
|
|
63
|
+
while (low < high) {
|
|
64
|
+
const middle = low + high >> 1;
|
|
65
|
+
if (better(index, top[middle])) high = middle;
|
|
66
|
+
else low = middle + 1;
|
|
67
|
+
}
|
|
68
|
+
top.splice(low, 0, index);
|
|
69
|
+
if (top.length > limit) top.pop();
|
|
70
|
+
}
|
|
71
|
+
return top.map((index) => paths[index]);
|
|
53
72
|
}
|
|
54
73
|
const scored = [];
|
|
55
74
|
for (const path of paths) {
|
|
@@ -69,30 +88,27 @@ function rankMatches(paths, query, limit) {
|
|
|
69
88
|
return scored.slice(0, limit).map((entry) => entry.path);
|
|
70
89
|
}
|
|
71
90
|
function depth(path) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
let segments = 0;
|
|
92
|
+
let inSegment = false;
|
|
93
|
+
for (let index = 0; index < path.length; index += 1) {
|
|
94
|
+
if (path.charCodeAt(index) === 47) {
|
|
95
|
+
inSegment = false;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!inSegment) {
|
|
99
|
+
segments += 1;
|
|
100
|
+
inSegment = true;
|
|
101
|
+
}
|
|
80
102
|
}
|
|
81
|
-
return
|
|
82
|
-
location: "local",
|
|
83
|
-
path: normalized,
|
|
84
|
-
writable: options.writable ?? true,
|
|
85
|
-
...options.label === void 0 ? {} : { label: options.label },
|
|
86
|
-
...options.workspaces === void 0 ? {} : { workspaces: options.workspaces },
|
|
87
|
-
...options.sessions === void 0 ? {} : { sessions: options.sessions },
|
|
88
|
-
...options.shared === void 0 ? {} : { shared: options.shared }
|
|
89
|
-
};
|
|
103
|
+
return segments;
|
|
90
104
|
}
|
|
105
|
+
|
|
106
|
+
// src/shared/root-keys.ts
|
|
91
107
|
function isAbsoluteLocalPath(path) {
|
|
92
|
-
return /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("
|
|
108
|
+
return /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("/") || path.startsWith("\\\\");
|
|
93
109
|
}
|
|
94
110
|
function normalizeLocalPath(path, options = {}) {
|
|
95
|
-
const caseInsensitive = options.caseInsensitive ??
|
|
111
|
+
const caseInsensitive = options.caseInsensitive ?? false;
|
|
96
112
|
const unified = path.replace(/\\/g, "/");
|
|
97
113
|
const unc = unified.startsWith("//");
|
|
98
114
|
const posixAbsolute = unified.startsWith("/");
|
|
@@ -118,15 +134,46 @@ function normalizeLocalPath(path, options = {}) {
|
|
|
118
134
|
return caseInsensitive ? normalized.toLowerCase() : normalized;
|
|
119
135
|
}
|
|
120
136
|
|
|
137
|
+
// src/host/domain/roots/root.ts
|
|
138
|
+
function makeLocalRoot(path, options = {}) {
|
|
139
|
+
const normalized = normalizeLocalPath2(path, { caseInsensitive: false });
|
|
140
|
+
if (!isAbsoluteLocalPath(normalized)) {
|
|
141
|
+
throw new SshDevError("ROOT_INVALID", `\u672C\u5730\u6839\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF1A${path}`, { path });
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
location: "local",
|
|
145
|
+
path: normalized,
|
|
146
|
+
writable: options.writable ?? true,
|
|
147
|
+
...options.label === void 0 ? {} : { label: options.label },
|
|
148
|
+
...options.workspaces === void 0 ? {} : { workspaces: options.workspaces },
|
|
149
|
+
...options.sessions === void 0 ? {} : { sessions: options.sessions },
|
|
150
|
+
...options.shared === void 0 ? {} : { shared: options.shared }
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function normalizeLocalPath2(path, options = {}) {
|
|
154
|
+
return normalizeLocalPath(path, { caseInsensitive: options.caseInsensitive ?? process.platform === "win32" });
|
|
155
|
+
}
|
|
156
|
+
|
|
121
157
|
// src/host/integration/session-scope.ts
|
|
122
158
|
var MAX_FORK_DEPTH = 32;
|
|
123
159
|
var ancestorCache = /* @__PURE__ */ new Map();
|
|
124
160
|
var ANCESTOR_CACHE_MAX = 256;
|
|
125
161
|
function readSessionAncestors(ctx, sessionId) {
|
|
126
162
|
const cached = ancestorCache.get(sessionId);
|
|
127
|
-
if (cached !== void 0)
|
|
163
|
+
if (cached !== void 0) {
|
|
164
|
+
ancestorCache.delete(sessionId);
|
|
165
|
+
ancestorCache.set(sessionId, cached);
|
|
166
|
+
return cached;
|
|
167
|
+
}
|
|
128
168
|
const walked = walkAncestors(ctx, sessionId);
|
|
129
|
-
if (walked.settled
|
|
169
|
+
if (walked.settled) {
|
|
170
|
+
ancestorCache.set(sessionId, walked.ancestors);
|
|
171
|
+
while (ancestorCache.size > ANCESTOR_CACHE_MAX) {
|
|
172
|
+
const oldest = ancestorCache.keys().next();
|
|
173
|
+
if (oldest.done === true) break;
|
|
174
|
+
ancestorCache.delete(oldest.value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
130
177
|
return walked.ancestors;
|
|
131
178
|
}
|
|
132
179
|
function walkAncestors(ctx, sessionId) {
|
|
@@ -220,16 +267,18 @@ var RemoteFileReferenceService = class extends FileReferenceService {
|
|
|
220
267
|
if (registry === void 0) return [];
|
|
221
268
|
const identity = sessionIdentityOf(this.ctx, agent.session.header.id);
|
|
222
269
|
const gated = identity.sessionId === void 0 ? registry.routed.tryResolve(cwd) : registry.routed.tryResolve(cwd, { session: identity });
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
270
|
+
const addedTask = this.#addedRemoteCandidates(cwd, identity, query, signal);
|
|
271
|
+
const ungated = gated.ok ? void 0 : registry.routed.tryResolve(cwd);
|
|
272
|
+
const implicit = gated.ok || ungated?.ok === true ? void 0 : sessionLocalRoot(cwd);
|
|
273
|
+
const namedTask = gated.ok ? this.#namedCandidates(gated.target.root, query, signal) : implicit === void 0 ? void 0 : this.#localCandidates(implicit.path, query, signal);
|
|
274
|
+
const [added, named] = await Promise.all([addedTask, namedTask]);
|
|
275
|
+
if (gated.ok) return this.#merge(added, named ?? []);
|
|
276
|
+
if (ungated?.ok === true) return added ?? [];
|
|
277
|
+
return this.#merge(added, named ?? []);
|
|
278
|
+
}
|
|
279
|
+
/** cwd 命名的那个根自己的候选:远端走索引,本地走有界走查。 */
|
|
280
|
+
#namedCandidates(root, query, signal) {
|
|
281
|
+
return root.location === "remote" && root.connectionId !== void 0 ? this.#remoteCandidates(root.connectionId, root.path, query, signal) : this.#localCandidates(root.path, query, signal);
|
|
233
282
|
}
|
|
234
283
|
/** Remote candidates for one root, or `[]` when the composition has no index. */
|
|
235
284
|
async #remoteCandidates(connectionId, root, query, signal) {
|
|
@@ -241,12 +290,20 @@ var RemoteFileReferenceService = class extends FileReferenceService {
|
|
|
241
290
|
async #localCandidates(rootPath, query, signal) {
|
|
242
291
|
const walk = this.#options.walk ?? ((root, walkSignal) => this.#walkLocal(root, walkSignal));
|
|
243
292
|
const entries = await this.#walkCached(rootPath, walk, signal);
|
|
244
|
-
const
|
|
245
|
-
return rankMatches(
|
|
293
|
+
const ranked = rankMatches(
|
|
246
294
|
entries.map((entry) => entry.path),
|
|
247
295
|
query,
|
|
248
296
|
this.#options.maxResults ?? DEFAULT_MAX_RESULTS
|
|
249
|
-
)
|
|
297
|
+
);
|
|
298
|
+
if (ranked.length === 0) return [];
|
|
299
|
+
const wanted = new Set(ranked);
|
|
300
|
+
const kinds = /* @__PURE__ */ new Map();
|
|
301
|
+
for (const entry of entries) {
|
|
302
|
+
if (!wanted.has(entry.path)) continue;
|
|
303
|
+
kinds.set(entry.path, entry.kind);
|
|
304
|
+
if (kinds.size === wanted.size) break;
|
|
305
|
+
}
|
|
306
|
+
return ranked.map((path) => ({ path, kind: kinds.get(path) ?? "file" }));
|
|
250
307
|
}
|
|
251
308
|
/**
|
|
252
309
|
* Candidates from the remote directory this conversation added with 「添加目录」, when there is one.
|