@kirkchinese/harness-forge 0.4.0 → 0.5.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 +4 -0
- package/docs/DETAIL.zh.md +47 -0
- package/lib/agents/presets.d.ts +7 -0
- package/lib/agents/presets.js +11 -1
- package/lib/agents/profiles.js +3 -2
- package/lib/agents/row.js +3 -1
- package/lib/client/paths.d.ts +12 -0
- package/lib/client/paths.js +68 -0
- package/lib/client/typert.d.ts +12 -1
- package/lib/client/typert.js +54 -6
- package/lib/client.js +1593 -270
- package/lib/commands/row.js +1 -1
- package/lib/context/instructions.js +5 -5
- package/lib/dsh/host.d.ts +3 -0
- package/lib/dsh/host.js +3 -0
- package/lib/forge/contract.d.ts +42 -2
- package/lib/forge/contract.js +3 -1
- package/lib/forge/follow.d.ts +30 -0
- package/lib/forge/follow.js +73 -0
- package/lib/forge/ledger.d.ts +70 -7
- package/lib/forge/ledger.js +314 -42
- package/lib/forge/projects.d.ts +5 -2
- package/lib/forge/projects.js +23 -16
- package/lib/forge/remote/archive.d.ts +65 -0
- package/lib/forge/remote/archive.js +565 -0
- package/lib/forge/remote/code-parts.d.ts +18 -0
- package/lib/forge/remote/code-parts.js +76 -0
- package/lib/forge/remote/fetch.d.ts +265 -0
- package/lib/forge/remote/fetch.js +1133 -0
- package/lib/forge/remote/service.d.ts +256 -0
- package/lib/forge/remote/service.js +868 -0
- package/lib/forge/service.d.ts +19 -9
- package/lib/forge/service.js +47 -31
- package/lib/forge/settings.d.ts +5 -3
- package/lib/forge/settings.js +11 -4
- package/lib/forge/state.d.ts +60 -0
- package/lib/forge/state.js +174 -58
- package/lib/hooks/broker/engine.js +2 -8
- package/lib/hooks/broker/session-events.d.ts +5 -0
- package/lib/hooks/broker/session-events.js +12 -3
- package/lib/hooks/broker/types.d.ts +7 -5
- package/lib/hooks/condition.d.ts +78 -2
- package/lib/hooks/condition.js +494 -73
- package/lib/hooks/config.d.ts +1 -1
- package/lib/hooks/config.js +4 -0
- package/lib/hooks/glob.d.ts +41 -0
- package/lib/hooks/glob.js +114 -0
- package/lib/hooks/permissions.d.ts +8 -3
- package/lib/hooks/permissions.js +119 -26
- package/lib/hooks/powershell-aliases.d.ts +19 -0
- package/lib/hooks/powershell-aliases.js +58 -0
- package/lib/hooks/process.d.ts +17 -0
- package/lib/hooks/process.js +156 -1
- package/lib/hooks/row.js +2 -0
- package/lib/hooks/runner.d.ts +17 -4
- package/lib/hooks/runner.js +42 -13
- package/lib/hooks/shell-commands.d.ts +10 -1
- package/lib/hooks/shell-commands.js +74 -10
- package/lib/hooks/shell.d.ts +3 -2
- package/lib/hooks/shell.js +5 -2
- package/lib/hooks/vocabulary.js +3 -1
- package/lib/mcp/catalog.d.ts +5 -2
- package/lib/mcp/catalog.js +18 -10
- package/lib/mcp/mount.d.ts +40 -2
- package/lib/mcp/mount.js +131 -31
- package/lib/mcp/policy.d.ts +42 -0
- package/lib/mcp/policy.js +43 -0
- package/lib/mcp/remote.js +5 -15
- package/lib/mcp/row.js +111 -17
- package/lib/mods/loader.js +4 -0
- package/lib/mods/service/turns.d.ts +8 -7
- package/lib/mods/service/turns.js +10 -35
- package/lib/opencode/bun.js +14 -2
- package/lib/opencode/row.d.ts +14 -1
- package/lib/opencode/row.js +38 -20
- package/lib/opencode/runtime/server.js +2 -1
- package/lib/porting/adapter-paths.d.ts +13 -0
- package/lib/porting/adapter-paths.js +120 -0
- package/lib/porting/port-gap.d.ts +10 -4
- package/lib/porting/port-gap.js +43 -7
- package/lib/porting/prompt.js +9 -7
- package/lib/porting/row.js +7 -5
- package/lib/porting/verify-port.d.ts +3 -10
- package/lib/porting/verify-port.js +12 -34
- package/lib/sessions/chat-import.d.ts +48 -0
- package/lib/sessions/chat-import.js +44 -0
- package/lib/sessions/claude.d.ts +16 -10
- package/lib/sessions/claude.js +76 -55
- package/lib/sessions/codex-discover.d.ts +34 -0
- package/lib/sessions/codex-discover.js +205 -0
- package/lib/sessions/codex-meta.d.ts +63 -0
- package/lib/sessions/codex-meta.js +148 -0
- package/lib/sessions/codex-text.d.ts +9 -0
- package/lib/sessions/codex-text.js +44 -0
- package/lib/sessions/codex.d.ts +34 -22
- package/lib/sessions/codex.js +150 -183
- package/lib/sessions/opencode.d.ts +15 -9
- package/lib/sessions/opencode.js +77 -58
- package/lib/sessions/persist.d.ts +162 -0
- package/lib/sessions/persist.js +377 -0
- package/lib/sessions/row.d.ts +2 -1
- package/lib/sessions/row.js +75 -9
- package/lib/sessions/turns.d.ts +31 -0
- package/lib/sessions/turns.js +63 -0
- package/lib/sessions/zstd.d.ts +15 -0
- package/lib/sessions/zstd.js +152 -0
- package/lib/shared/render.d.ts +30 -1
- package/lib/shared/render.js +813 -48
- package/lib/skills/provider.d.ts +2 -0
- package/lib/skills/provider.js +8 -2
- package/lib/skills/row.js +1 -1
- package/lib/workbench/adapter-coverage.d.ts +20 -2
- package/lib/workbench/adapter-coverage.js +46 -7
- package/lib/workbench/overview.d.ts +77 -27
- package/lib/workbench/overview.js +99 -12
- package/lib/workbench/remote.d.ts +64 -21
- package/lib/workbench/remote.js +181 -42
- package/lib/workbench/settings.d.ts +5 -1
- package/lib/workbench/settings.js +6 -2
- package/lib/workbench/workbench.d.ts +34 -4
- package/lib/workbench/workbench.js +147 -46
- package/locale/zh.json +2 -1
- package/package.json +3 -2
- package/lib/forge/marketplace-install.d.ts +0 -3
- package/lib/forge/marketplace-install.js +0 -64
package/lib/workbench/remote.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The workbench's whole Host surface, as Typert Remote methods under the
|
|
3
|
+
* `harnessCompat` namespace: the browser reaches them through DSH's own
|
|
4
|
+
* Remote carrier, like every DSH service, and Harness Forge registers no HTTP
|
|
5
|
+
* routes of its own. Each method takes at most one `request` object, so the
|
|
6
|
+
* Gateway's source-mode reflection maps one named wire argument and no
|
|
7
|
+
* parameter name can collide with a Host lookup. Method names avoid the
|
|
8
|
+
* browser namespace service's own members (`install`, `remove`, `has`, …). Failures are RemoteErrors
|
|
9
|
+
* whose message is the reason the person reads.
|
|
10
|
+
*
|
|
11
|
+
* Methods are marked with the protocol's runtime marker helper rather than
|
|
12
|
+
* decorator syntax so Vitest can load the Host entry without a decorator
|
|
13
|
+
* transform.
|
|
14
|
+
* @module @kirkchinese/harness-forge
|
|
15
|
+
*/
|
|
16
|
+
import { homedir } from 'node:os';
|
|
17
|
+
import { assess, dialects } from '@kirkchinese/harness-forge-core';
|
|
2
18
|
import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
19
|
import { Workbench } from './workbench.js';
|
|
4
20
|
import { waitingParts } from '../forge/projects.js';
|
|
5
21
|
import { forgeVerifyDeps, livePorts, verifyPort } from '../porting/verify-port.js';
|
|
6
22
|
import { stateOf } from '../porting/port-sessions.js';
|
|
23
|
+
import { installChatImport, sessionImportStatus } from '../sessions/chat-import.js';
|
|
7
24
|
function sourceOf(value) {
|
|
8
25
|
return value === 'codex' || value === 'opencode' ? value : 'claude-code';
|
|
9
26
|
}
|
|
27
|
+
/** A Discover section's harness, any dialect Harness Forge reads (Agent Skills too); an unknown one is refused. */
|
|
28
|
+
function dialectOf(value) {
|
|
29
|
+
const dialect = dialects().find(candidate => candidate.id === value);
|
|
30
|
+
if (dialect === undefined)
|
|
31
|
+
throw new Error(`unknown harness ${JSON.stringify(value)}`);
|
|
32
|
+
return dialect.id;
|
|
33
|
+
}
|
|
10
34
|
function text(request, key) {
|
|
11
35
|
const value = request?.[key];
|
|
12
36
|
return typeof value === 'string' ? value : '';
|
|
@@ -24,7 +48,7 @@ function summary(plugin) {
|
|
|
24
48
|
counts.set(component.kind, (counts.get(component.kind) ?? 0) + 1);
|
|
25
49
|
return {
|
|
26
50
|
id: plugin.id,
|
|
27
|
-
name: plugin.name,
|
|
51
|
+
name: plugin.displayName ?? plugin.name,
|
|
28
52
|
source: plugin.source,
|
|
29
53
|
version: plugin.version,
|
|
30
54
|
license: plugin.license,
|
|
@@ -50,6 +74,46 @@ function reportOf(report) {
|
|
|
50
74
|
agents: report.agents,
|
|
51
75
|
};
|
|
52
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* An answer as plain JSON, the only kind DSH's Remote carrier passes: fields
|
|
79
|
+
* that are `undefined` (or functions) are dropped, an `undefined` list item
|
|
80
|
+
* becomes `null`, `-0` becomes `0`, and anything with `toJSON` is converted as
|
|
81
|
+
* JSON would. A number JSON cannot carry, a bigint or a cycle is refused with
|
|
82
|
+
* where it sits, instead of reaching the browser as something else.
|
|
83
|
+
*/
|
|
84
|
+
export function plainJson(value, at = 'answer', ancestors = new Set()) {
|
|
85
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
86
|
+
return value;
|
|
87
|
+
if (typeof value === 'number') {
|
|
88
|
+
if (!Number.isFinite(value))
|
|
89
|
+
throw new Error(`${at} is ${String(value)}, which JSON cannot carry`);
|
|
90
|
+
return value === 0 ? 0 : value;
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === 'bigint')
|
|
93
|
+
throw new Error(`${at} is a bigint, which JSON cannot carry`);
|
|
94
|
+
if (typeof value !== 'object')
|
|
95
|
+
return undefined;
|
|
96
|
+
if (ancestors.has(value))
|
|
97
|
+
throw new Error(`${at} refers to itself, which JSON cannot carry`);
|
|
98
|
+
const toJSON = value.toJSON;
|
|
99
|
+
if (typeof toJSON === 'function')
|
|
100
|
+
return plainJson(toJSON.call(value), at, ancestors);
|
|
101
|
+
ancestors.add(value);
|
|
102
|
+
try {
|
|
103
|
+
if (Array.isArray(value))
|
|
104
|
+
return value.map((item, index) => plainJson(item, `${at}[${String(index)}]`, ancestors) ?? null);
|
|
105
|
+
const plain = {};
|
|
106
|
+
for (const [key, item] of Object.entries(value)) {
|
|
107
|
+
const converted = plainJson(item, `${at}.${key}`, ancestors);
|
|
108
|
+
if (converted !== undefined)
|
|
109
|
+
plain[key] = converted;
|
|
110
|
+
}
|
|
111
|
+
return plain;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
ancestors.delete(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
53
117
|
/** The installation service as Remote methods. */
|
|
54
118
|
export class HarnessRemoteService extends TypertRemoteService {
|
|
55
119
|
forge;
|
|
@@ -68,14 +132,22 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
68
132
|
throw new RemoteError('harness-forge/failed', `the Harness Forge ${name} row is off; turn it on in Plugin Manager`, { operation });
|
|
69
133
|
return api;
|
|
70
134
|
}
|
|
71
|
-
/** Run one operation; anything it throws reaches the browser with its message. */
|
|
135
|
+
/** Run one operation and answer it as plain JSON; anything it throws reaches the browser with its message. */
|
|
72
136
|
async guard(operation, run) {
|
|
73
137
|
try {
|
|
74
|
-
return await run();
|
|
138
|
+
return plainJson(await run(), operation);
|
|
75
139
|
}
|
|
76
140
|
catch (error) {
|
|
77
141
|
if (typeof error === 'object' && error !== null && error.isDSHRemoteError === true)
|
|
78
142
|
throw error;
|
|
143
|
+
const code = error instanceof Error ? error.code : undefined;
|
|
144
|
+
if (code === 'session-too-large') {
|
|
145
|
+
const { limit, bytes } = error;
|
|
146
|
+
throw new RemoteError('harness-forge/session-too-large', error.message, { operation, limit: limit ?? 0, ...(bytes !== undefined ? { size: bytes } : {}) }, { cause: error });
|
|
147
|
+
}
|
|
148
|
+
if (code === 'session-maybe-imported') {
|
|
149
|
+
throw new RemoteError('harness-forge/session-maybe-imported', error.message, { operation, existingId: String(error.existingId) }, { cause: error });
|
|
150
|
+
}
|
|
79
151
|
throw new RemoteError('harness-forge/failed', error instanceof Error ? error.message : String(error), { operation }, { cause: error });
|
|
80
152
|
}
|
|
81
153
|
}
|
|
@@ -84,9 +156,17 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
84
156
|
contextStatus() {
|
|
85
157
|
return this.guard('contextStatus', () => this.forge.lookup('context')?.status() ?? { active: false, files: [] });
|
|
86
158
|
}
|
|
87
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* The overview, plus the home folder (the page shows paths under it as `~/…`), the workspaces of open sessions with
|
|
161
|
+
* their trust and the project parts that wait for it, and how many records are still being applied. It starts following the harnesses' changes without waiting for it:
|
|
162
|
+
* `applying` says it is under way, and the next overview shows the result.
|
|
163
|
+
*/
|
|
88
164
|
overview() {
|
|
89
|
-
return this.guard('overview', async () =>
|
|
165
|
+
return this.guard('overview', async () => {
|
|
166
|
+
void this.forge.follow();
|
|
167
|
+
const applying = this.forge.applying();
|
|
168
|
+
return { ...await this.workbench.overview(), home: homedir(), workspaces: await this.forge.projects.workspaces(), ...(applying !== undefined ? { applying } : {}) };
|
|
169
|
+
});
|
|
90
170
|
}
|
|
91
171
|
// --- workspace trust ----------------------------------------------------------
|
|
92
172
|
/** A workspace's trust (`{ workspace, trusted, sources, waiting }`): its project parts that run code wait until it is trusted. */
|
|
@@ -125,7 +205,10 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
125
205
|
return { ...state, waiting: waitingParts(cwd, state) };
|
|
126
206
|
}
|
|
127
207
|
discover() {
|
|
128
|
-
return this.guard('discover', () =>
|
|
208
|
+
return this.guard('discover', () => {
|
|
209
|
+
void this.forge.follow();
|
|
210
|
+
return this.workbench.discover();
|
|
211
|
+
});
|
|
129
212
|
}
|
|
130
213
|
diagnostics() {
|
|
131
214
|
return this.guard('diagnostics', () => this.workbench.diagnostics());
|
|
@@ -143,7 +226,7 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
143
226
|
});
|
|
144
227
|
}
|
|
145
228
|
migrate(request) {
|
|
146
|
-
return this.guard('migrate', () => this.workbench.migrate(
|
|
229
|
+
return this.guard('migrate', () => this.workbench.migrate(dialectOf(request['source'])));
|
|
147
230
|
}
|
|
148
231
|
setPartEnabled(request) {
|
|
149
232
|
return this.guard('setPartEnabled', async () => {
|
|
@@ -162,37 +245,64 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
162
245
|
return { removed: true };
|
|
163
246
|
});
|
|
164
247
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
description: index.description,
|
|
171
|
-
owner: index.owner,
|
|
172
|
-
manifestPath: index.manifestPath,
|
|
173
|
-
warnings: index.warnings,
|
|
174
|
-
entries: index.entries.map(entry => ({
|
|
175
|
-
name: entry.name,
|
|
176
|
-
description: entry.description,
|
|
177
|
-
version: entry.version,
|
|
178
|
-
license: entry.license,
|
|
179
|
-
category: entry.category,
|
|
180
|
-
tags: entry.tags,
|
|
181
|
-
source: {
|
|
182
|
-
kind: entry.source.kind,
|
|
183
|
-
...(entry.source.path !== undefined ? { path: entry.source.path } : {}),
|
|
184
|
-
...(entry.source.url !== undefined ? { url: entry.source.url } : {}),
|
|
185
|
-
...(entry.source.package !== undefined ? { package: entry.source.package } : {}),
|
|
186
|
-
},
|
|
187
|
-
})),
|
|
188
|
-
};
|
|
248
|
+
/** Keep a plugin its harness no longer runs as the person's own copy. */
|
|
249
|
+
keepPlugin(request) {
|
|
250
|
+
return this.guard('keepPlugin', async () => {
|
|
251
|
+
await this.forge.keep(required(request, 'id', 'keepPlugin'));
|
|
252
|
+
return { kept: true };
|
|
189
253
|
});
|
|
190
254
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
255
|
+
// --- plugins from the network ------------------------------------------------
|
|
256
|
+
/**
|
|
257
|
+
* The default marketplaces, the ones the person added, the local
|
|
258
|
+
* marketplaces the harnesses on this computer added, what was installed
|
|
259
|
+
* from the network, and whether git is installed.
|
|
260
|
+
*/
|
|
261
|
+
remoteSources() {
|
|
262
|
+
return this.guard('remoteSources', async () => ({ ...await this.forge.remote.sources(), local: this.workbench.localMarketplaces() }));
|
|
263
|
+
}
|
|
264
|
+
/** Open a pasted marketplace or plugin (`owner/repo`, a git URL, a marketplace.json URL, an npm package, a local folder): its entries, fetched now. */
|
|
265
|
+
remoteOpen(request) {
|
|
266
|
+
return this.guard('remoteOpen', () => this.forge.remote.open(required(request, 'input', 'remoteOpen')));
|
|
267
|
+
}
|
|
268
|
+
/** Stop listing a marketplace the person added. */
|
|
269
|
+
remoteForget(request) {
|
|
270
|
+
return this.guard('remoteForget', () => ({ forgotten: this.forge.remote.forget(required(request, 'input', 'remoteForget')) }));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fetch one plugin (a marketplace's `entry`, or the pasted `input` itself) and say what it contains, to confirm:
|
|
274
|
+
* `{ token, name, source, page?, revision, parts, codeParts, … }`. Nothing is installed yet.
|
|
275
|
+
*/
|
|
276
|
+
remotePrepare(request) {
|
|
277
|
+
return this.guard('remotePrepare', () => this.forge.remote.prepare(required(request, 'input', 'remotePrepare'), text(request, 'entry') || undefined));
|
|
278
|
+
}
|
|
279
|
+
/** Install (or, for an update, apply) exactly what `remotePrepare` or `remotePrepareUpdate` showed. */
|
|
280
|
+
remoteInstall(request) {
|
|
281
|
+
return this.guard('remoteInstall', async () => {
|
|
282
|
+
const result = await this.forge.remote.install(required(request, 'token', 'remoteInstall'));
|
|
283
|
+
if (result.report === undefined)
|
|
284
|
+
return { pluginId: result.pluginId, revision: result.revision, updated: result.updated };
|
|
285
|
+
return { ...reportOf(result.report), revision: result.revision, updated: result.updated };
|
|
194
286
|
});
|
|
195
287
|
}
|
|
288
|
+
/** Drop a confirmation the person declined, with the files it fetched. */
|
|
289
|
+
remoteCancel(request) {
|
|
290
|
+
return this.guard('remoteCancel', () => ({ cancelled: this.forge.remote.cancel(required(request, 'token', 'remoteCancel')) }));
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Compare what was installed from the network with its source now
|
|
294
|
+
* (`{ updates: [{ pluginId, current, latest?, update, token?, error? }] }`); `token` names the revision found.
|
|
295
|
+
*/
|
|
296
|
+
remoteCheckUpdates(request) {
|
|
297
|
+
return this.guard('remoteCheckUpdates', async () => ({ updates: await this.forge.remote.checkUpdates(text(request, 'pluginId') || undefined) }));
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Fetch the revision a check found (`{ pluginId, token }`) and say what it contains and what changed, to confirm
|
|
301
|
+
* like an install; `remoteInstall` with the returned token applies it.
|
|
302
|
+
*/
|
|
303
|
+
remotePrepareUpdate(request) {
|
|
304
|
+
return this.guard('remotePrepareUpdate', () => this.forge.remote.prepareUpdate(required(request, 'pluginId', 'remotePrepareUpdate'), required(request, 'token', 'remotePrepareUpdate')));
|
|
305
|
+
}
|
|
196
306
|
// --- sign-in, sessions ------------------------------------------------------
|
|
197
307
|
signIns() {
|
|
198
308
|
return this.guard('signIns', () => ({ waiting: this.row('mcp', 'signIns').pendingSignIns() }));
|
|
@@ -204,11 +314,30 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
204
314
|
});
|
|
205
315
|
}
|
|
206
316
|
sessions(request) {
|
|
207
|
-
return this.guard('sessions',
|
|
317
|
+
return this.guard('sessions', () => {
|
|
318
|
+
const cursor = request?.['cursor'];
|
|
319
|
+
const limit = request?.['limit'];
|
|
320
|
+
return this.row('sessions', 'sessions').sessions(undefined, sourceOf(request?.['source']), {
|
|
321
|
+
...(typeof cursor === 'number' && Number.isInteger(cursor) && cursor >= 0 ? { cursor } : {}),
|
|
322
|
+
...(typeof limit === 'number' && Number.isInteger(limit) && limit > 0 ? { limit: Math.min(limit, 200) } : {}),
|
|
323
|
+
});
|
|
324
|
+
});
|
|
208
325
|
}
|
|
209
326
|
importSession(request) {
|
|
210
327
|
return this.guard('importSession', () => this.row('sessions', 'importSession').importSession(required(request, 'path', 'importSession'), text(request, 'targetId') || undefined, sourceOf(request['source']), text(request, 'sourceId') || undefined));
|
|
211
328
|
}
|
|
329
|
+
/** Open a session an import stored: registered with DSH and out of its archive (`{ id, live, unarchived, archived }`). */
|
|
330
|
+
openImported(request) {
|
|
331
|
+
return this.guard('openImported', () => this.row('sessions', 'openImported').open(required(request, 'id', 'openImported')));
|
|
332
|
+
}
|
|
333
|
+
/** Who imports sessions (`{ provider: 'harness-forge' | 'dsh-chat-import', canInstall, command }`). */
|
|
334
|
+
sessionImport() {
|
|
335
|
+
return this.guard('sessionImport', () => sessionImportStatus(this.forge.ctx));
|
|
336
|
+
}
|
|
337
|
+
/** Install and enable dsh-chat-import through DSH's plugin manager; the browser asks the person first. */
|
|
338
|
+
installChatImport() {
|
|
339
|
+
return this.guard('installChatImport', () => installChatImport(this.forge.ctx));
|
|
340
|
+
}
|
|
212
341
|
// --- mod surfaces -------------------------------------------------------------
|
|
213
342
|
/**
|
|
214
343
|
* A session's mod drawings: the current one, then every new one, until the
|
|
@@ -232,7 +361,7 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
232
361
|
try {
|
|
233
362
|
while (signal?.aborted !== true) {
|
|
234
363
|
while (queue.length > 0)
|
|
235
|
-
yield queue.shift();
|
|
364
|
+
yield plainJson(queue.shift(), 'modSurfaces');
|
|
236
365
|
await Promise.race([new Promise((resolve) => { wake = resolve; }), aborted]);
|
|
237
366
|
wake = undefined;
|
|
238
367
|
}
|
|
@@ -313,7 +442,7 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
313
442
|
const source = this.adapterSurfaces.get(id);
|
|
314
443
|
if (source === undefined)
|
|
315
444
|
return;
|
|
316
|
-
yield await source.read(session, request);
|
|
445
|
+
yield plainJson(await source.read(session, request), 'adapterSurface');
|
|
317
446
|
continue;
|
|
318
447
|
}
|
|
319
448
|
await Promise.race([new Promise((resolve) => { wake = resolve; }), aborted]);
|
|
@@ -349,8 +478,8 @@ export class HarnessRemoteService extends TypertRemoteService {
|
|
|
349
478
|
}
|
|
350
479
|
/**
|
|
351
480
|
* Port one part of a plugin: start a session in DSH's creation mode working
|
|
352
|
-
* on its task
|
|
353
|
-
* and record it as the part's port session.
|
|
481
|
+
* on its task in the adapters directory by default (or the given `workspaceId`
|
|
482
|
+
* or `cwd`), and record it as the part's port session.
|
|
354
483
|
*/
|
|
355
484
|
portGap(request) {
|
|
356
485
|
return this.guard('portGap', async () => {
|
|
@@ -381,12 +510,22 @@ export const REMOTE_METHODS = [
|
|
|
381
510
|
['migrate', 'unary', true],
|
|
382
511
|
['setPartEnabled', 'unary', true],
|
|
383
512
|
['removePlugin', 'unary', true],
|
|
384
|
-
['
|
|
385
|
-
['
|
|
513
|
+
['keepPlugin', 'unary', true],
|
|
514
|
+
['remoteSources', 'unary', false],
|
|
515
|
+
['remoteOpen', 'unary', true],
|
|
516
|
+
['remoteForget', 'unary', true],
|
|
517
|
+
['remotePrepare', 'unary', true],
|
|
518
|
+
['remoteInstall', 'unary', true],
|
|
519
|
+
['remoteCancel', 'unary', true],
|
|
520
|
+
['remoteCheckUpdates', 'unary', true],
|
|
521
|
+
['remotePrepareUpdate', 'unary', true],
|
|
386
522
|
['signIns', 'unary', false],
|
|
387
523
|
['signIn', 'unary', true],
|
|
388
524
|
['sessions', 'unary', true],
|
|
389
525
|
['importSession', 'unary', true],
|
|
526
|
+
['openImported', 'unary', true],
|
|
527
|
+
['sessionImport', 'unary', false],
|
|
528
|
+
['installChatImport', 'unary', false],
|
|
390
529
|
['modSurfaces', 'stream', true],
|
|
391
530
|
['modAct', 'unary', true],
|
|
392
531
|
['modClose', 'unary', true],
|
|
@@ -5,7 +5,11 @@ export interface HarnessSettings {
|
|
|
5
5
|
readonly autoDiscover: boolean;
|
|
6
6
|
readonly contextBudgetTokens?: number;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Default roots: the folders where the harnesses keep their plugins and
|
|
10
|
+
* settings. Not the folder DSH was started from: that is arbitrary (often the
|
|
11
|
+
* home folder), and a workspace's own `.claude/` is read per session instead.
|
|
12
|
+
*/
|
|
9
13
|
export declare function defaultSettings(): HarnessSettings;
|
|
10
14
|
/** Settings file lives beside `state.json`/`receipts/`. */
|
|
11
15
|
export declare function settingsPathFor(statePath: string): string;
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
8
8
|
import { dirname, join, resolve } from 'node:path';
|
|
9
9
|
import { defaultDiscoveryRoots } from '@kirkchinese/harness-forge-core';
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Default roots: the folders where the harnesses keep their plugins and
|
|
12
|
+
* settings. Not the folder DSH was started from: that is arbitrary (often the
|
|
13
|
+
* home folder), and a workspace's own `.claude/` is read per session instead.
|
|
14
|
+
*/
|
|
11
15
|
export function defaultSettings() {
|
|
12
16
|
return {
|
|
13
17
|
schemaVersion: 1,
|
|
14
|
-
discoveryRoots:
|
|
18
|
+
discoveryRoots: defaultDiscoveryRoots(),
|
|
15
19
|
autoDiscover: true,
|
|
16
20
|
};
|
|
17
21
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import { type CompatibilityVector, type DiscoveredPlugin, type ForeignPlugin, type Gap } from '@kirkchinese/harness-forge-core';
|
|
2
|
+
import { type CompatibilityVector, type DiscoveredMarketplace, type DiscoveredPlugin, type DiscoveryWarning, type ForeignPlugin, type Gap, type SourceId } from '@kirkchinese/harness-forge-core';
|
|
3
3
|
import { type AdapterCoverage, type Overview } from './overview.js';
|
|
4
4
|
import { type HarnessSettings } from './settings.js';
|
|
5
5
|
import type { HarnessForge } from '../forge/service.js';
|
|
6
|
+
/**
|
|
7
|
+
* Harness Forge's own version, from its package.json: the nearest one up
|
|
8
|
+
* from this module (`lib/workbench/` when built, `src/workbench/` in tests).
|
|
9
|
+
*/
|
|
10
|
+
export declare function forgeVersion(from?: string): string | undefined;
|
|
6
11
|
/** One component exposed by an installed plugin. */
|
|
7
12
|
export interface CapabilityItem {
|
|
8
13
|
readonly pluginId: string;
|
|
@@ -64,14 +69,32 @@ export declare class Workbench {
|
|
|
64
69
|
readonly plugin: ForeignPlugin;
|
|
65
70
|
readonly gaps: readonly Gap[];
|
|
66
71
|
};
|
|
67
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Discover plugin roots using the saved settings: the plugins each harness
|
|
74
|
+
* installed and the person's own assets, never what a marketplace only offers.
|
|
75
|
+
*/
|
|
68
76
|
discover(): {
|
|
69
77
|
settings: HarnessSettings;
|
|
70
78
|
plugins: Array<DiscoveredPlugin & {
|
|
71
79
|
installed: boolean;
|
|
72
80
|
}>;
|
|
81
|
+
marketplaces: readonly DiscoveredMarketplace[];
|
|
73
82
|
missingRoots: readonly string[];
|
|
83
|
+
warnings: readonly DiscoveryWarning[];
|
|
74
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Whether a discovered plugin is migrated already. A record that follows a harness install counts for that install
|
|
87
|
+
* only, wherever either's folder is (an update moves it to the harness's new folder); one of an install the harness
|
|
88
|
+
* no longer runs, or of one read through another harness, never makes a current install look migrated. A record
|
|
89
|
+
* that follows no harness counts by its folder, and (unless the person kept it as their own copy) by its id.
|
|
90
|
+
*/
|
|
91
|
+
private migrated;
|
|
92
|
+
/** The local marketplaces the harnesses added: under "Get plugins", each plugin installed on its own after the confirmation. */
|
|
93
|
+
localMarketplaces(): Array<{
|
|
94
|
+
readonly input: string;
|
|
95
|
+
readonly name: string;
|
|
96
|
+
readonly harness: string;
|
|
97
|
+
}>;
|
|
75
98
|
/** Aggregate capabilities and context cost for installed plugins. */
|
|
76
99
|
capabilities(): CapabilityCatalog;
|
|
77
100
|
/** Current optional host services, for diagnostics. */
|
|
@@ -83,14 +106,21 @@ export declare class Workbench {
|
|
|
83
106
|
* left by a failed install covers nothing.
|
|
84
107
|
*/
|
|
85
108
|
enabledAdapters(): Promise<AdapterCoverage[]>;
|
|
109
|
+
/** Scan the roots the overview lists, and attribute the user's configured status line. */
|
|
110
|
+
private overviewSources;
|
|
111
|
+
/** Whether an installed plugin was fetched from the network: its files are in Harness Forge's own download folders. */
|
|
112
|
+
private fetched;
|
|
86
113
|
/** The workbench's plain-language view of every harness: see `overview.ts`. */
|
|
87
114
|
overview(): Promise<Overview>;
|
|
88
115
|
/** Read-only workbench diagnostics: host services, mounts, tool budget and row failures. */
|
|
89
116
|
diagnostics(): Record<string, unknown>;
|
|
90
117
|
/** List all skill roots the skills row serves (none while it is off). */
|
|
91
118
|
listSkillRoots(): readonly string[];
|
|
92
|
-
/**
|
|
93
|
-
|
|
119
|
+
/**
|
|
120
|
+
* "Migrate all" of one harness: its plugins and the person's own assets that {@link migratable} takes, the
|
|
121
|
+
* rule the overview counts by. A plugin switched off in its harness stays where it is; it can be migrated alone.
|
|
122
|
+
*/
|
|
123
|
+
migrate(source: SourceId): Promise<{
|
|
94
124
|
readonly installed: readonly string[];
|
|
95
125
|
readonly failed: ReadonlyArray<{
|
|
96
126
|
readonly name: string;
|