@kirkchinese/harness-forge 0.0.0-stage → 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.
Files changed (279) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -2
  3. package/assets/icon.svg +12 -0
  4. package/cordis.patch.yml +28 -0
  5. package/docs/DETAIL.zh.md +47 -0
  6. package/lib/agents/presets.d.ts +98 -0
  7. package/lib/agents/presets.js +292 -0
  8. package/lib/agents/profiles.d.ts +58 -0
  9. package/lib/agents/profiles.js +279 -0
  10. package/lib/agents/row.d.ts +17 -0
  11. package/lib/agents/row.js +148 -0
  12. package/lib/client/paths.d.ts +12 -0
  13. package/lib/client/paths.js +68 -0
  14. package/lib/client/styles.d.ts +8 -0
  15. package/lib/client/styles.js +89 -0
  16. package/lib/client/typert.d.ts +25 -0
  17. package/lib/client/typert.js +158 -0
  18. package/lib/client.js +23823 -0
  19. package/lib/commands/definition.d.ts +40 -0
  20. package/lib/commands/definition.js +113 -0
  21. package/lib/commands/output-styles.d.ts +42 -0
  22. package/lib/commands/output-styles.js +152 -0
  23. package/lib/commands/row.d.ts +9 -0
  24. package/lib/commands/row.js +157 -0
  25. package/lib/context/instructions.d.ts +32 -0
  26. package/lib/context/instructions.js +88 -0
  27. package/lib/context/row.d.ts +16 -0
  28. package/lib/context/row.js +17 -0
  29. package/lib/dsh/commands.d.ts +30 -0
  30. package/lib/dsh/commands.js +61 -0
  31. package/lib/dsh/host.d.ts +110 -0
  32. package/lib/dsh/host.js +217 -0
  33. package/lib/dsh/model-route.d.ts +21 -0
  34. package/lib/dsh/model-route.js +37 -0
  35. package/lib/dsh/session-records.d.ts +78 -0
  36. package/lib/dsh/session-records.js +36 -0
  37. package/lib/dsh/subagents.d.ts +46 -0
  38. package/lib/dsh/subagents.js +14 -0
  39. package/lib/forge/contract.d.ts +271 -0
  40. package/lib/forge/contract.js +45 -0
  41. package/lib/forge/follow.d.ts +30 -0
  42. package/lib/forge/follow.js +73 -0
  43. package/lib/forge/ledger.d.ts +206 -0
  44. package/lib/forge/ledger.js +1005 -0
  45. package/lib/forge/live-mounts.d.ts +45 -0
  46. package/lib/forge/live-mounts.js +78 -0
  47. package/lib/forge/npm.d.ts +31 -0
  48. package/lib/forge/npm.js +60 -0
  49. package/lib/forge/projects.d.ts +97 -0
  50. package/lib/forge/projects.js +343 -0
  51. package/lib/forge/receipts.d.ts +5 -0
  52. package/lib/forge/receipts.js +31 -0
  53. package/lib/forge/remote/archive.d.ts +65 -0
  54. package/lib/forge/remote/archive.js +565 -0
  55. package/lib/forge/remote/code-parts.d.ts +18 -0
  56. package/lib/forge/remote/code-parts.js +76 -0
  57. package/lib/forge/remote/fetch.d.ts +265 -0
  58. package/lib/forge/remote/fetch.js +1133 -0
  59. package/lib/forge/remote/service.d.ts +256 -0
  60. package/lib/forge/remote/service.js +868 -0
  61. package/lib/forge/row.d.ts +32 -0
  62. package/lib/forge/row.js +59 -0
  63. package/lib/forge/service.d.ts +115 -0
  64. package/lib/forge/service.js +290 -0
  65. package/lib/forge/settings.d.ts +43 -0
  66. package/lib/forge/settings.js +122 -0
  67. package/lib/forge/state.d.ts +129 -0
  68. package/lib/forge/state.js +266 -0
  69. package/lib/forge/trust.d.ts +48 -0
  70. package/lib/forge/trust.js +107 -0
  71. package/lib/forge/turns.d.ts +13 -0
  72. package/lib/forge/turns.js +56 -0
  73. package/lib/hooks/broker/engine.d.ts +112 -0
  74. package/lib/hooks/broker/engine.js +722 -0
  75. package/lib/hooks/broker/helpers.d.ts +10 -0
  76. package/lib/hooks/broker/helpers.js +22 -0
  77. package/lib/hooks/broker/lifecycle.d.ts +65 -0
  78. package/lib/hooks/broker/lifecycle.js +342 -0
  79. package/lib/hooks/broker/session-events.d.ts +27 -0
  80. package/lib/hooks/broker/session-events.js +205 -0
  81. package/lib/hooks/broker/tools.d.ts +52 -0
  82. package/lib/hooks/broker/tools.js +424 -0
  83. package/lib/hooks/broker/types.d.ts +264 -0
  84. package/lib/hooks/broker/types.js +1 -0
  85. package/lib/hooks/broker.d.ts +80 -0
  86. package/lib/hooks/broker.js +95 -0
  87. package/lib/hooks/codex-user.d.ts +5 -0
  88. package/lib/hooks/codex-user.js +109 -0
  89. package/lib/hooks/condition.d.ts +87 -0
  90. package/lib/hooks/condition.js +602 -0
  91. package/lib/hooks/config.d.ts +85 -0
  92. package/lib/hooks/config.js +154 -0
  93. package/lib/hooks/glob.d.ts +41 -0
  94. package/lib/hooks/glob.js +114 -0
  95. package/lib/hooks/matcher.d.ts +20 -0
  96. package/lib/hooks/matcher.js +39 -0
  97. package/lib/hooks/notice.d.ts +17 -0
  98. package/lib/hooks/notice.js +39 -0
  99. package/lib/hooks/output.d.ts +56 -0
  100. package/lib/hooks/output.js +214 -0
  101. package/lib/hooks/permissions.d.ts +19 -0
  102. package/lib/hooks/permissions.js +202 -0
  103. package/lib/hooks/powershell-aliases.d.ts +19 -0
  104. package/lib/hooks/powershell-aliases.js +58 -0
  105. package/lib/hooks/process.d.ts +64 -0
  106. package/lib/hooks/process.js +289 -0
  107. package/lib/hooks/row.d.ts +17 -0
  108. package/lib/hooks/row.js +96 -0
  109. package/lib/hooks/runner.d.ts +98 -0
  110. package/lib/hooks/runner.js +322 -0
  111. package/lib/hooks/shell-commands.d.ts +28 -0
  112. package/lib/hooks/shell-commands.js +241 -0
  113. package/lib/hooks/shell.d.ts +44 -0
  114. package/lib/hooks/shell.js +129 -0
  115. package/lib/hooks/transcript.d.ts +28 -0
  116. package/lib/hooks/transcript.js +141 -0
  117. package/lib/hooks/vocabulary.d.ts +57 -0
  118. package/lib/hooks/vocabulary.js +366 -0
  119. package/lib/index.d.ts +31 -0
  120. package/lib/index.js +287 -0
  121. package/lib/mcp/auth.d.ts +35 -0
  122. package/lib/mcp/auth.js +178 -0
  123. package/lib/mcp/catalog.d.ts +39 -0
  124. package/lib/mcp/catalog.js +69 -0
  125. package/lib/mcp/mount.d.ts +113 -0
  126. package/lib/mcp/mount.js +317 -0
  127. package/lib/mcp/policy.d.ts +42 -0
  128. package/lib/mcp/policy.js +43 -0
  129. package/lib/mcp/remote.d.ts +45 -0
  130. package/lib/mcp/remote.js +133 -0
  131. package/lib/mcp/row.d.ts +9 -0
  132. package/lib/mcp/row.js +225 -0
  133. package/lib/mods/bundler.d.ts +38 -0
  134. package/lib/mods/bundler.js +157 -0
  135. package/lib/mods/chain.d.ts +103 -0
  136. package/lib/mods/chain.js +436 -0
  137. package/lib/mods/claude.d.ts +27 -0
  138. package/lib/mods/claude.js +56 -0
  139. package/lib/mods/engine.d.ts +160 -0
  140. package/lib/mods/engine.js +701 -0
  141. package/lib/mods/expect.d.ts +8 -0
  142. package/lib/mods/expect.js +248 -0
  143. package/lib/mods/host.d.ts +105 -0
  144. package/lib/mods/host.js +462 -0
  145. package/lib/mods/loader.d.ts +53 -0
  146. package/lib/mods/loader.js +231 -0
  147. package/lib/mods/ops.d.ts +13 -0
  148. package/lib/mods/ops.js +117 -0
  149. package/lib/mods/row.d.ts +9 -0
  150. package/lib/mods/row.js +77 -0
  151. package/lib/mods/runtime.d.ts +60 -0
  152. package/lib/mods/runtime.js +133 -0
  153. package/lib/mods/service/commands.d.ts +17 -0
  154. package/lib/mods/service/commands.js +121 -0
  155. package/lib/mods/service/drawings.d.ts +36 -0
  156. package/lib/mods/service/drawings.js +64 -0
  157. package/lib/mods/service/sessions.d.ts +63 -0
  158. package/lib/mods/service/sessions.js +345 -0
  159. package/lib/mods/service/tools.d.ts +32 -0
  160. package/lib/mods/service/tools.js +253 -0
  161. package/lib/mods/service/turns.d.ts +33 -0
  162. package/lib/mods/service/turns.js +136 -0
  163. package/lib/mods/service/types.d.ts +151 -0
  164. package/lib/mods/service/types.js +1 -0
  165. package/lib/mods/service.d.ts +72 -0
  166. package/lib/mods/service.js +104 -0
  167. package/lib/mods/surfaces.d.ts +93 -0
  168. package/lib/mods/surfaces.js +309 -0
  169. package/lib/mods/values.d.ts +30 -0
  170. package/lib/mods/values.js +95 -0
  171. package/lib/opencode/bun.d.ts +40 -0
  172. package/lib/opencode/bun.js +168 -0
  173. package/lib/opencode/convert.d.ts +53 -0
  174. package/lib/opencode/convert.js +255 -0
  175. package/lib/opencode/row.d.ts +22 -0
  176. package/lib/opencode/row.js +104 -0
  177. package/lib/opencode/runtime/core.d.ts +74 -0
  178. package/lib/opencode/runtime/core.js +249 -0
  179. package/lib/opencode/runtime/events.d.ts +80 -0
  180. package/lib/opencode/runtime/events.js +281 -0
  181. package/lib/opencode/runtime/mount.d.ts +27 -0
  182. package/lib/opencode/runtime/mount.js +283 -0
  183. package/lib/opencode/runtime/server.d.ts +27 -0
  184. package/lib/opencode/runtime/server.js +354 -0
  185. package/lib/opencode/runtime/types.d.ts +109 -0
  186. package/lib/opencode/runtime/types.js +1 -0
  187. package/lib/opencode/runtime.d.ts +55 -0
  188. package/lib/opencode/runtime.js +79 -0
  189. package/lib/porting/adapter-paths.d.ts +13 -0
  190. package/lib/porting/adapter-paths.js +120 -0
  191. package/lib/porting/port-gap.d.ts +36 -0
  192. package/lib/porting/port-gap.js +158 -0
  193. package/lib/porting/port-sessions.d.ts +41 -0
  194. package/lib/porting/port-sessions.js +98 -0
  195. package/lib/porting/prompt.d.ts +23 -0
  196. package/lib/porting/prompt.js +51 -0
  197. package/lib/porting/row.d.ts +16 -0
  198. package/lib/porting/row.js +27 -0
  199. package/lib/porting/verify-port.d.ts +46 -0
  200. package/lib/porting/verify-port.js +82 -0
  201. package/lib/presets/fs-search.d.ts +25 -0
  202. package/lib/presets/fs-search.js +17 -0
  203. package/lib/presets/tool-filter.d.ts +35 -0
  204. package/lib/presets/tool-filter.js +91 -0
  205. package/lib/sessions/chat-import.d.ts +48 -0
  206. package/lib/sessions/chat-import.js +44 -0
  207. package/lib/sessions/claude.d.ts +35 -0
  208. package/lib/sessions/claude.js +104 -0
  209. package/lib/sessions/codex-discover.d.ts +34 -0
  210. package/lib/sessions/codex-discover.js +205 -0
  211. package/lib/sessions/codex-meta.d.ts +63 -0
  212. package/lib/sessions/codex-meta.js +148 -0
  213. package/lib/sessions/codex-text.d.ts +9 -0
  214. package/lib/sessions/codex-text.js +44 -0
  215. package/lib/sessions/codex.d.ts +42 -0
  216. package/lib/sessions/codex.js +270 -0
  217. package/lib/sessions/opencode.d.ts +38 -0
  218. package/lib/sessions/opencode.js +339 -0
  219. package/lib/sessions/persist.d.ts +162 -0
  220. package/lib/sessions/persist.js +377 -0
  221. package/lib/sessions/row.d.ts +15 -0
  222. package/lib/sessions/row.js +101 -0
  223. package/lib/sessions/turns.d.ts +31 -0
  224. package/lib/sessions/turns.js +63 -0
  225. package/lib/sessions/zstd.d.ts +15 -0
  226. package/lib/sessions/zstd.js +152 -0
  227. package/lib/shared/invocation.d.ts +169 -0
  228. package/lib/shared/invocation.js +325 -0
  229. package/lib/shared/render.d.ts +101 -0
  230. package/lib/shared/render.js +1353 -0
  231. package/lib/shared/util.d.ts +21 -0
  232. package/lib/shared/util.js +32 -0
  233. package/lib/skills/bundled.d.ts +3 -0
  234. package/lib/skills/bundled.js +42 -0
  235. package/lib/skills/provider.d.ts +74 -0
  236. package/lib/skills/provider.js +346 -0
  237. package/lib/skills/row.d.ts +22 -0
  238. package/lib/skills/row.js +204 -0
  239. package/lib/workbench/adapter-coverage.d.ts +65 -0
  240. package/lib/workbench/adapter-coverage.js +141 -0
  241. package/lib/workbench/model-tools.d.ts +10 -0
  242. package/lib/workbench/model-tools.js +122 -0
  243. package/lib/workbench/overview.d.ts +153 -0
  244. package/lib/workbench/overview.js +246 -0
  245. package/lib/workbench/remote.d.ts +161 -0
  246. package/lib/workbench/remote.js +561 -0
  247. package/lib/workbench/row.d.ts +15 -0
  248. package/lib/workbench/row.js +16 -0
  249. package/lib/workbench/settings.d.ts +19 -0
  250. package/lib/workbench/settings.js +60 -0
  251. package/lib/workbench/workbench.d.ts +130 -0
  252. package/lib/workbench/workbench.js +361 -0
  253. package/locale/agents/en.json +6 -0
  254. package/locale/agents/zh.json +6 -0
  255. package/locale/commands/en.json +6 -0
  256. package/locale/commands/zh.json +6 -0
  257. package/locale/context/en.json +6 -0
  258. package/locale/context/zh.json +6 -0
  259. package/locale/en.json +6 -0
  260. package/locale/hooks/en.json +6 -0
  261. package/locale/hooks/zh.json +6 -0
  262. package/locale/mcp/en.json +6 -0
  263. package/locale/mcp/zh.json +6 -0
  264. package/locale/mods/en.json +6 -0
  265. package/locale/mods/zh.json +6 -0
  266. package/locale/opencode/en.json +6 -0
  267. package/locale/opencode/zh.json +6 -0
  268. package/locale/porter/en.json +6 -0
  269. package/locale/porter/zh.json +6 -0
  270. package/locale/sessions/en.json +6 -0
  271. package/locale/sessions/zh.json +6 -0
  272. package/locale/skills/en.json +6 -0
  273. package/locale/skills/zh.json +6 -0
  274. package/locale/workbench/en.json +6 -0
  275. package/locale/workbench/zh.json +6 -0
  276. package/locale/zh.json +7 -0
  277. package/package.json +247 -3
  278. package/runtime/opencode-host.mjs +270 -0
  279. package/skills/harness-forge/SKILL.md +47 -0
@@ -0,0 +1,120 @@
1
+ /**
2
+ * The `paths` check of `harness_verify_port`: the commonest way a generated
3
+ * adapter breaks the brief's data access rules, read from its source. It
4
+ * finds a DSH home written into the code (`~/.dsh`, `/home/<user>/.dsh`) and
5
+ * a listing of a `profiles` directory. Comments are skipped, so a source that
6
+ * documents the default `~/.dsh` beside `$DSH_HOME` passes; resolving the
7
+ * running profile as `join(home, 'profiles', name)` passes too, since only a
8
+ * listing reads other profiles.
9
+ * @module @kirkchinese/harness-forge/porting
10
+ */
11
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
12
+ import { extname, join, relative, sep } from 'node:path';
13
+ /** Source files an adapter runs: JavaScript and TypeScript, as written and as built. */
14
+ const SOURCE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx']);
15
+ /** Directories that hold others' code or history, not the adapter's. */
16
+ const SKIPPED_DIRS = new Set(['node_modules', '.git']);
17
+ /** Most source files read: an adapter is a small package, and a link to a large tree must not stall the tool. */
18
+ const FILE_LIMIT = 500;
19
+ /** Largest source file read, in bytes: bigger ones are bundles whose findings would be a dependency's. */
20
+ const SIZE_LIMIT = 1_000_000;
21
+ /** Most findings named in the check's detail; the rest are counted. */
22
+ const SHOWN_LIMIT = 8;
23
+ /** A DSH home written into the code: `~/.dsh`, or an absolute user home's `.dsh` on Linux, macOS or Windows. */
24
+ const HARD_CODED_HOME = /~[/\\]\.dsh\b|(?:\/home|\/Users|[A-Za-z]:[/\\]{1,2}Users)[/\\]{1,2}[^/\\'"`\s]+[/\\]{1,2}\.dsh\b/u;
25
+ /** A directory listing whose argument names `profiles`: a path literal or a variable named for them. */
26
+ const PROFILES_LISTING = /\b(?:readdir|readdirSync|opendir|opendirSync|glob|globSync)\s*\([^;\n]*(?:['"`/\\]profiles\b|\w*profiles\w*)/iu;
27
+ /** The source with comments blanked out (newlines kept), so findings name real code lines. */
28
+ export function withoutComments(source) {
29
+ let out = '';
30
+ let quote;
31
+ for (let index = 0; index < source.length; index++) {
32
+ const char = source[index];
33
+ const next = source[index + 1];
34
+ if (quote !== undefined) {
35
+ out += char;
36
+ if (char === '\\') {
37
+ out += next ?? '';
38
+ index++;
39
+ }
40
+ else if (char === quote)
41
+ quote = undefined;
42
+ continue;
43
+ }
44
+ if (char === '"' || char === "'" || char === '`') {
45
+ quote = char;
46
+ out += char;
47
+ continue;
48
+ }
49
+ if (char === '/' && next === '/') {
50
+ while (index < source.length && source[index] !== '\n')
51
+ index++;
52
+ out += '\n';
53
+ continue;
54
+ }
55
+ if (char === '/' && next === '*') {
56
+ const end = source.indexOf('*/', index + 2);
57
+ const stop = end === -1 ? source.length : end + 2;
58
+ out += source.slice(index, stop).replace(/[^\n]/gu, ' ');
59
+ index = stop - 1;
60
+ continue;
61
+ }
62
+ out += char;
63
+ }
64
+ return out;
65
+ }
66
+ function sourcesUnder(dir, out) {
67
+ let entries;
68
+ try {
69
+ entries = readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
70
+ }
71
+ catch {
72
+ return;
73
+ }
74
+ for (const entry of entries) {
75
+ if (out.length >= FILE_LIMIT)
76
+ return;
77
+ const path = join(dir, entry.name);
78
+ if (entry.isDirectory()) {
79
+ if (!SKIPPED_DIRS.has(entry.name))
80
+ sourcesUnder(path, out);
81
+ }
82
+ else if (entry.isFile() && SOURCE_EXTENSIONS.has(extname(entry.name))) {
83
+ out.push(path);
84
+ }
85
+ }
86
+ }
87
+ /** Where an adapter's source hard-codes the DSH home or lists the profiles. */
88
+ export function hardCodedPaths(dir) {
89
+ const files = [];
90
+ sourcesUnder(dir, files);
91
+ const findings = [];
92
+ for (const path of files) {
93
+ let text;
94
+ try {
95
+ if (statSync(path).size > SIZE_LIMIT)
96
+ continue;
97
+ text = withoutComments(readFileSync(path, 'utf8'));
98
+ }
99
+ catch {
100
+ continue;
101
+ }
102
+ const file = relative(dir, path).split(sep).join('/');
103
+ text.split('\n').forEach((line, index) => {
104
+ const home = HARD_CODED_HOME.exec(line);
105
+ if (home !== null)
106
+ findings.push({ file, line: index + 1, what: `hard-codes the DSH home (${home[0]})` });
107
+ if (PROFILES_LISTING.test(line))
108
+ findings.push({ file, line: index + 1, what: 'lists the profiles directory' });
109
+ });
110
+ }
111
+ return findings;
112
+ }
113
+ /** The check's detail for its findings. */
114
+ export function pathsDetail(findings) {
115
+ if (findings.length === 0)
116
+ return 'the source resolves DSH paths at run time: no hard-coded DSH home and no listing of profiles';
117
+ const shown = findings.slice(0, SHOWN_LIMIT).map(item => `${item.file}:${item.line} ${item.what}`);
118
+ const more = findings.length > SHOWN_LIMIT ? `; and ${findings.length - SHOWN_LIMIT} more` : '';
119
+ return `${shown.join('; ')}${more}. Resolve the DSH home at run time from $DSH_HOME (default ~/.dsh under os.homedir()) and the profile from profileContext or $DSH_PROFILE_DIR; never read or list other profiles (the brief's data access rules)`;
120
+ }
@@ -0,0 +1,36 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { type ForeignComponent, type ForeignPlugin, type Gap, type PortRuntime } from '@kirkchinese/harness-forge-core';
3
+ /** The preset of DSH's creation mode ("Let the agent create a plugin" in the Plugin Manager). */
4
+ export declare const CREATOR_PRESET = "cordis";
5
+ /** Where a creation session runs: a DSH Workspace or an explicit directory, otherwise the adapters directory. */
6
+ export interface PortLocation {
7
+ readonly workspaceId?: string;
8
+ readonly cwd?: string;
9
+ }
10
+ /** The session title for a brief: its heading, without the Markdown marker DSH would otherwise show in the sidebar. */
11
+ export declare function briefTitle(brief: string): string;
12
+ /**
13
+ * The files of one part on disk: its own files, and the whole directory of a
14
+ * skill or a code entry, whose neighbours it runs. A part declared in the
15
+ * plugin's manifest itself lists the manifest.
16
+ */
17
+ export declare function partFiles(plugin: ForeignPlugin, component: ForeignComponent): string[];
18
+ /**
19
+ * The DSH home and profile this Harness Forge runs in, resolved as DSH does:
20
+ * `$DSH_HOME` (a blank value is unset), else `~/.dsh`; the profile from the
21
+ * `profileContext` service, which only a profile-launched DSH composes.
22
+ */
23
+ export declare function portRuntime(ctx: Context, env?: NodeJS.ProcessEnv): PortRuntime;
24
+ /** The brief for one part of a plugin, or a failure naming what is missing. */
25
+ export declare function briefFor(plugin: ForeignPlugin, gaps: readonly Gap[], componentId: string, runtime?: PortRuntime): string;
26
+ /** The first message of a part's port session: the protocol, then the brief (see `prompt.ts`). */
27
+ export declare function taskFor(plugin: ForeignPlugin, gaps: readonly Gap[], componentId: string, language?: string, runtime?: PortRuntime): string;
28
+ /**
29
+ * Start a creation-mode session and send it the task, as the Plugin
30
+ * Manager's creation entry and a typed message would.
31
+ * @param title - the session's name; the task's first line when absent.
32
+ * @returns the new session's id.
33
+ */
34
+ export declare function startCreatorSession(ctx: Context, task: string, location?: PortLocation, title?: string): Promise<{
35
+ sessionId: string;
36
+ }>;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Porting a gap: Harness Forge writes the brief (see the core's
3
+ * `portBrief`), puts the working protocol before it (`prompt.ts`) and hands
4
+ * it to DSH's own creation mode, a new session on the
5
+ * `cordis` preset that has the dsh-doc skill, runtime inspection and the
6
+ * plugin manager. The authoring, testing and installing are that agent's.
7
+ * @module @kirkchinese/harness-forge/porting
8
+ */
9
+ import { randomUUID } from 'node:crypto';
10
+ import { existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
11
+ import { homedir } from 'node:os';
12
+ import { dirname, join, resolve } from 'node:path';
13
+ import { ADAPTERS_DIR, absolutePath, detectLicense, portBrief } from '@kirkchinese/harness-forge-core';
14
+ import { dshService } from '../dsh/host.js';
15
+ import { resolveDshHome } from '../forge/state.js';
16
+ import { portPrompt } from './prompt.js';
17
+ /** The preset of DSH's creation mode ("Let the agent create a plugin" in the Plugin Manager). */
18
+ export const CREATOR_PRESET = 'cordis';
19
+ /** Most files a brief lists for one part. */
20
+ const FILE_LIMIT = 200;
21
+ const SKIPPED_DIRS = new Set(['node_modules', '.git']);
22
+ /** The workspace of a directory (made when there is none), or undefined where the host has no workspace registry or refuses. */
23
+ async function workspaceOf(ctx, cwd) {
24
+ const registry = dshService(ctx, 'workspaceRegistry');
25
+ if (typeof registry?.create !== 'function')
26
+ return undefined;
27
+ try {
28
+ const id = (await registry.create(cwd)).id;
29
+ return typeof id === 'string' ? id : undefined;
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ }
35
+ /** The session title for a brief: its heading, without the Markdown marker DSH would otherwise show in the sidebar. */
36
+ export function briefTitle(brief) {
37
+ return (brief.split('\n', 1)[0] ?? '').replace(/^#+\s*/u, '').trim();
38
+ }
39
+ function filesUnder(path, out) {
40
+ if (out.length >= FILE_LIMIT || !existsSync(path))
41
+ return;
42
+ const stat = statSync(path);
43
+ if (stat.isFile()) {
44
+ if (!out.includes(path))
45
+ out.push(path);
46
+ return;
47
+ }
48
+ if (!stat.isDirectory())
49
+ return;
50
+ for (const entry of readdirSync(path, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
51
+ if (out.length >= FILE_LIMIT)
52
+ return;
53
+ if (entry.isDirectory() && SKIPPED_DIRS.has(entry.name))
54
+ continue;
55
+ filesUnder(join(path, entry.name), out);
56
+ }
57
+ }
58
+ /**
59
+ * The files of one part on disk: its own files, and the whole directory of a
60
+ * skill or a code entry, whose neighbours it runs. A part declared in the
61
+ * plugin's manifest itself lists the manifest.
62
+ */
63
+ export function partFiles(plugin, component) {
64
+ const out = [];
65
+ const paths = [component.path];
66
+ switch (component.kind) {
67
+ case 'skill':
68
+ paths.push(component.resourceBase, component.bodyPath);
69
+ break;
70
+ case 'command':
71
+ case 'agent':
72
+ paths.push(component.bodyPath);
73
+ break;
74
+ case 'hooks':
75
+ paths.push(component.configPath, ...component.modules);
76
+ break;
77
+ case 'code':
78
+ if (component.entryPath !== undefined)
79
+ paths.push(component.entryPath, dirname(absolutePath(plugin.root, component.entryPath)));
80
+ break;
81
+ case 'ui':
82
+ paths.push(component.specPath);
83
+ break;
84
+ case 'settings':
85
+ paths.push(...component.files);
86
+ break;
87
+ default: break;
88
+ }
89
+ for (const path of paths) {
90
+ if (path === undefined || path.length === 0)
91
+ continue;
92
+ const absolute = absolutePath(plugin.root, path);
93
+ // The plugin's root is not one part's files.
94
+ if (resolve(absolute) !== resolve(plugin.root))
95
+ filesUnder(absolute, out);
96
+ }
97
+ if (!out.includes(plugin.ref.manifestPath) && existsSync(plugin.ref.manifestPath))
98
+ out.push(plugin.ref.manifestPath);
99
+ return out;
100
+ }
101
+ /**
102
+ * The DSH home and profile this Harness Forge runs in, resolved as DSH does:
103
+ * `$DSH_HOME` (a blank value is unset), else `~/.dsh`; the profile from the
104
+ * `profileContext` service, which only a profile-launched DSH composes.
105
+ */
106
+ export function portRuntime(ctx, env = process.env) {
107
+ const profile = dshService(ctx, 'profileContext');
108
+ const named = typeof profile?.name === 'string' && profile.name.length > 0 && typeof profile.dir === 'string' && profile.dir.length > 0;
109
+ return {
110
+ dshHome: resolveDshHome(env),
111
+ dshHomeFromEnv: (env.DSH_HOME?.trim() ?? '').length > 0,
112
+ ...(named ? { profile: { name: profile.name, dir: profile.dir } } : {}),
113
+ };
114
+ }
115
+ /** The brief for one part of a plugin, or a failure naming what is missing. */
116
+ export function briefFor(plugin, gaps, componentId, runtime) {
117
+ const component = plugin.components.find(item => item.id === componentId);
118
+ if (component === undefined)
119
+ throw new Error(`${plugin.name} has no part ${componentId}`);
120
+ const license = plugin.license ?? detectLicense(plugin.root);
121
+ return portBrief({ plugin, component, gaps, files: partFiles(plugin, component), ...(license !== undefined ? { license } : {}), ...(runtime !== undefined ? { runtime } : {}) });
122
+ }
123
+ /** The first message of a part's port session: the protocol, then the brief (see `prompt.ts`). */
124
+ export function taskFor(plugin, gaps, componentId, language, runtime) {
125
+ const brief = briefFor(plugin, gaps, componentId, runtime);
126
+ const component = plugin.components.find(item => item.id === componentId);
127
+ return portPrompt({ plugin, component, brief, ...(language !== undefined && language.length > 0 ? { language } : {}) });
128
+ }
129
+ /**
130
+ * Start a creation-mode session and send it the task, as the Plugin
131
+ * Manager's creation entry and a typed message would.
132
+ * @param title - the session's name; the task's first line when absent.
133
+ * @returns the new session's id.
134
+ */
135
+ export async function startCreatorSession(ctx, task, location = {}, title = briefTitle(task)) {
136
+ const controller = dshService(ctx, 'sessionController');
137
+ if (controller === undefined)
138
+ throw new Error('this DSH profile composes no session controller, so no creation session can be started; copy the brief into a session in creation mode instead');
139
+ const presets = dshService(ctx, 'agentPresets');
140
+ const creator = presets?.list === undefined ? undefined : (await presets.list()).find(preset => preset.id === CREATOR_PRESET);
141
+ if (presets?.list !== undefined && (creator === undefined || creator.broken !== undefined)) {
142
+ throw new Error(`creation mode (agent preset "${CREATOR_PRESET}") is ${creator === undefined ? 'not in this DSH profile' : 'unavailable in this DSH profile'}; copy the brief into a session instead`);
143
+ }
144
+ const cwd = location.cwd ?? join(homedir(), ADAPTERS_DIR);
145
+ if (location.workspaceId === undefined && location.cwd === undefined)
146
+ mkdirSync(cwd, { recursive: true });
147
+ // DSH groups a session under the workspace whose path is its directory; without one the session lands in
148
+ // "Ungrouped" among the person's own. The adapters directory gets a workspace named after the folder, reused by
149
+ // every creation session.
150
+ const workspaceId = location.workspaceId ?? await workspaceOf(ctx, cwd);
151
+ const where = workspaceId !== undefined ? { workspaceId } : { cwd };
152
+ const { sessionId } = await controller.create({ ...where, agentPreset: CREATOR_PRESET });
153
+ // Named before the task is sent, so the sidebar shows the brief's heading rather than the protocol's first line. A title the host refuses only leaves DSH's own.
154
+ if (title.length > 0)
155
+ await controller.rename?.({ sessionId, title }).catch(() => undefined);
156
+ await controller.prompt({ requestId: randomUUID(), sessionId, mode: 'queue', content: [{ type: 'text', text: task }] }, AbortSignal.timeout(60_000));
157
+ return { sessionId };
158
+ }
@@ -0,0 +1,41 @@
1
+ /** One part being ported, or ported and verified. */
2
+ export interface PortRecord {
3
+ readonly pluginId: string;
4
+ readonly componentId: string;
5
+ /** The creation-mode session working on it; absent when it was verified without one. */
6
+ readonly sessionId?: string;
7
+ readonly startedAt?: string;
8
+ /** When `harness_verify_port` last confirmed an adapter covers the part. */
9
+ readonly verifiedAt?: string;
10
+ /** The package that covered it then. */
11
+ readonly adapter?: string;
12
+ }
13
+ /** What the Gaps screen shows for one part. */
14
+ export type PortState = 'in-progress' | 'verified';
15
+ /** The state a record stands for. */
16
+ export declare function stateOf(record: PortRecord): PortState;
17
+ /** The per-profile store of port sessions. */
18
+ export declare class PortSessions {
19
+ readonly path: string;
20
+ /** @param statePath - the ledger file; `ports.json` lives beside it. */
21
+ constructor(statePath: string);
22
+ /** Every record; an absent or unreadable file holds none. */
23
+ list(): PortRecord[];
24
+ get(pluginId: string, componentId: string): PortRecord | undefined;
25
+ private write;
26
+ private put;
27
+ /** A session started porting the part: it is in progress again, whatever was verified before. */
28
+ started(pluginId: string, componentId: string, sessionId: string, at?: Date): PortRecord;
29
+ /** `harness_verify_port` confirmed `adapter` covers the part; the session that ported it stays linked. */
30
+ verified(pluginId: string, componentId: string, adapter: string, at?: Date): PortRecord;
31
+ /** A verification failed: a confirmation recorded before no longer holds, the session (if any) is in progress. */
32
+ unverified(pluginId: string, componentId: string): void;
33
+ forget(pluginId: string, componentId: string): void;
34
+ /**
35
+ * Drop the sessions that no longer exist: an in-progress record goes (the
36
+ * part can be ported again), a verified one keeps its confirmation without
37
+ * the session link.
38
+ * @param exists - whether a session id is still a session of this DSH.
39
+ */
40
+ prune(exists: (sessionId: string) => boolean): PortRecord[];
41
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Which creation-mode session ports which part, and whether
3
+ * `harness_verify_port` has confirmed it: kept in `ports.json` beside the
4
+ * ledger (per DSH profile), so the Gaps screen shows the progress after a
5
+ * reload. A record whose session no longer exists is dropped when the screen
6
+ * reads it, so the part can be ported again.
7
+ * @module @kirkchinese/harness-forge/porting
8
+ */
9
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
10
+ import { dirname, join } from 'node:path';
11
+ /** The state a record stands for. */
12
+ export function stateOf(record) {
13
+ return record.verifiedAt !== undefined ? 'verified' : 'in-progress';
14
+ }
15
+ function isRecord(value) {
16
+ const record = value;
17
+ return typeof record === 'object' && record !== null && typeof record.pluginId === 'string' && typeof record.componentId === 'string';
18
+ }
19
+ const same = (record, pluginId, componentId) => record.pluginId === pluginId && record.componentId === componentId;
20
+ /** The per-profile store of port sessions. */
21
+ export class PortSessions {
22
+ path;
23
+ /** @param statePath - the ledger file; `ports.json` lives beside it. */
24
+ constructor(statePath) {
25
+ this.path = join(dirname(statePath), 'ports.json');
26
+ }
27
+ /** Every record; an absent or unreadable file holds none. */
28
+ list() {
29
+ try {
30
+ const raw = JSON.parse(readFileSync(this.path, 'utf8'));
31
+ return Array.isArray(raw?.ports) ? raw.ports.filter(isRecord) : [];
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ get(pluginId, componentId) {
38
+ return this.list().find(record => same(record, pluginId, componentId));
39
+ }
40
+ write(ports) {
41
+ mkdirSync(dirname(this.path), { recursive: true });
42
+ const temporary = `${this.path}.tmp`;
43
+ writeFileSync(temporary, `${JSON.stringify({ schemaVersion: 1, ports }, null, 2)}\n`, 'utf8');
44
+ renameSync(temporary, this.path);
45
+ }
46
+ put(record) {
47
+ this.write([...this.list().filter(item => !same(item, record.pluginId, record.componentId)), record]);
48
+ return record;
49
+ }
50
+ /** A session started porting the part: it is in progress again, whatever was verified before. */
51
+ started(pluginId, componentId, sessionId, at = new Date()) {
52
+ return this.put({ pluginId, componentId, sessionId, startedAt: at.toISOString() });
53
+ }
54
+ /** `harness_verify_port` confirmed `adapter` covers the part; the session that ported it stays linked. */
55
+ verified(pluginId, componentId, adapter, at = new Date()) {
56
+ const current = this.get(pluginId, componentId);
57
+ return this.put({ ...current, pluginId, componentId, verifiedAt: at.toISOString(), adapter });
58
+ }
59
+ /** A verification failed: a confirmation recorded before no longer holds, the session (if any) is in progress. */
60
+ unverified(pluginId, componentId) {
61
+ const current = this.get(pluginId, componentId);
62
+ if (current?.verifiedAt === undefined)
63
+ return;
64
+ const { verifiedAt: _verifiedAt, adapter: _adapter, ...rest } = current;
65
+ if (rest.sessionId === undefined)
66
+ this.forget(pluginId, componentId);
67
+ else
68
+ this.put(rest);
69
+ }
70
+ forget(pluginId, componentId) {
71
+ const ports = this.list();
72
+ const kept = ports.filter(item => !same(item, pluginId, componentId));
73
+ if (kept.length !== ports.length)
74
+ this.write(kept);
75
+ }
76
+ /**
77
+ * Drop the sessions that no longer exist: an in-progress record goes (the
78
+ * part can be ported again), a verified one keeps its confirmation without
79
+ * the session link.
80
+ * @param exists - whether a session id is still a session of this DSH.
81
+ */
82
+ prune(exists) {
83
+ const ports = this.list();
84
+ let changed = false;
85
+ const kept = ports.flatMap((record) => {
86
+ if (record.sessionId === undefined || exists(record.sessionId))
87
+ return [record];
88
+ changed = true;
89
+ if (record.verifiedAt === undefined)
90
+ return [];
91
+ const { sessionId: _sessionId, startedAt: _startedAt, ...rest } = record;
92
+ return [rest];
93
+ });
94
+ if (changed)
95
+ this.write(kept);
96
+ return kept;
97
+ }
98
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The first message of a creation-mode port session: the working protocol
3
+ * (ask once, build, verify, report), then the part's brief. The protocol is
4
+ * the same for every part and lives only here; what is specific to the part
5
+ * (its files, gaps, the questions it leaves open, its acceptance criteria) is
6
+ * the brief's. Written for the model, in English; it tells the agent to talk
7
+ * to the user in their own language.
8
+ * @module @kirkchinese/harness-forge/porting
9
+ */
10
+ import { type ForeignComponent, type ForeignPlugin } from '@kirkchinese/harness-forge-core';
11
+ /** The model tool that confirms an adapter covers the part (see `verify-port.ts`). */
12
+ export declare const VERIFY_TOOL = "harness_verify_port";
13
+ /** What the prompt is written for. */
14
+ export interface PortPromptInput {
15
+ readonly plugin: Pick<ForeignPlugin, 'id' | 'name'>;
16
+ readonly component: Pick<ForeignComponent, 'id' | 'name'>;
17
+ /** The part's brief (`portBrief`), appended after the protocol. */
18
+ readonly brief: string;
19
+ /** The user's interface language (`en`, `zh`, …), when the browser said. */
20
+ readonly language?: string;
21
+ }
22
+ /** The protocol and the brief, as the session's first message. */
23
+ export declare function portPrompt(input: PortPromptInput): string;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The first message of a creation-mode port session: the working protocol
3
+ * (ask once, build, verify, report), then the part's brief. The protocol is
4
+ * the same for every part and lives only here; what is specific to the part
5
+ * (its files, gaps, the questions it leaves open, its acceptance criteria) is
6
+ * the brief's. Written for the model, in English; it tells the agent to talk
7
+ * to the user in their own language.
8
+ * @module @kirkchinese/harness-forge/porting
9
+ */
10
+ import { adapterPackageName, defaultAdapterDir } from '@kirkchinese/harness-forge-core';
11
+ /** The model tool that confirms an adapter covers the part (see `verify-port.ts`). */
12
+ export const VERIFY_TOOL = 'harness_verify_port';
13
+ /** Language names for the user's interface language, as the prompt names it. */
14
+ const LANGUAGES = { en: 'English', zh: 'Chinese (简体中文)' };
15
+ /** The language line: the interface language when known, else whatever the user writes in. */
16
+ function languageLine(language) {
17
+ const named = language === undefined ? undefined : LANGUAGES[language.split('-')[0].toLowerCase()] ?? language;
18
+ return named === undefined
19
+ ? 'Talk to the user in the language they write in.'
20
+ : `Talk to the user in ${named}, the language of their DSH interface, unless they write in another language.`;
21
+ }
22
+ /** The protocol and the brief, as the session's first message. */
23
+ export function portPrompt(input) {
24
+ const { plugin, component } = input;
25
+ const packageName = adapterPackageName(plugin, component);
26
+ const verifyArgs = JSON.stringify({ pluginId: plugin.id, componentId: component.id });
27
+ const protocol = [
28
+ `You are in DSH's creation mode. Harness Forge asks you to port the part "${component.name}" of ${plugin.name} to DSH as a local adapter plugin \`${packageName}\`. The brief below has the facts; this is how to work. ${languageLine(input.language)}`,
29
+ '',
30
+ '## Protocol',
31
+ '',
32
+ '1. **Ask once, first.** Your first reply is ONE concise message with numbered questions, each with a default so the user can just reply "ok". Use only the brief: do not call tools, inspect files or the runtime, or plan the implementation before the answer. Ask:',
33
+ ` - where to put the adapter's source; default \`${defaultAdapterDir(packageName)}\`, under the creation session's default working directory and separate from the original plugin;`,
34
+ ' - each user choice under "Questions for the user" in the brief; describe placement and other choices in user-facing terms, not API names.',
35
+ ' Never ask what you can look up (DSH APIs, slot names, file contents). Write no file before the answer.',
36
+ '2. **Build without further questions.** Now read the original files and load the `dsh-doc` skill. If the skill tool is unavailable, find and read the installed dsh-doc references directly. Confirm the DSH APIs and slot names with runtime inspection. Scaffold the package in the agreed directory, implement it reusing the original\'s code and data where possible, install it into the current profile with `plugin_manager` `install_bundle` (absolute directory) and make sure it is enabled. Ask again only when blocked on a choice only the user can make.',
37
+ ' Follow the brief\'s "Data access rules" without exception: take session and profile data from DSH\'s runtime services and the context the adapter receives; resolve any DSH path at run time from `$DSH_HOME` (default `~/.dsh`) and the running profile, never from a home path written into the source; never read or iterate other profiles; read no private file of DSH or another harness beyond what the part needs. The profile and home under "Where DSH keeps its data" are for your checks, not for the source.',
38
+ ' Fallback: should `install_bundle` come back `"application": "failed"` with "pnpm printed nothing … and was terminated", call it once more with the same directory (a pnpm that did not exit; the second call completes). Do not run pnpm or `dsh plugin` from the shell on the running profile instead.',
39
+ '3. **Verify before you report.** All of these must pass:',
40
+ ' a. The adapter loaded without errors: `plugin_manager` `list_bundles` shows it enabled with no `error`, and `cordis_inspect_*` shows what it registered.',
41
+ ' b. Each behaviour the acceptance criteria name happens: exercise it and observe the result (the tool\'s answer, the command\'s output, the hook acting, the surface\'s value).',
42
+ ` c. \`${VERIFY_TOOL}\` with \`${verifyArgs}\` answers \`"covered": true\`, its \`paths\` check included.`,
43
+ ' When a check fails, fix the cause and run all three again.',
44
+ ' To check what the page shows, use runtime inspection: `cordis_inspect_list`, then `cordis_inspect_query` on the Client `Slots.listSubTree` (the live slot tree and props, when a page is connected); if that cannot show it, ask the user to look and confirm. Never read DSH\'s access token or logs, `/proc` of another process, or another process\'s files, and never drive a browser with credentials taken from them.',
45
+ '4. **Report immediately when step 3 passes.** Do not start or wait for optional reviews before sending the final report; give the result first, then mention any review still running. Say what now works, with the evidence (what each check showed, including the `' + VERIFY_TOOL + '` answer), where the source is, and what still differs from the original. If you cannot close the gap, say exactly what blocks it, what you tried, and what the user can do.',
46
+ '',
47
+ '---',
48
+ '',
49
+ ];
50
+ return `${protocol.join('\n')}\n${input.brief}`;
51
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The porter row: porting a plugin part Harness Forge cannot run. It writes
3
+ * the part's brief and hands it to DSH's own creation mode, which authors,
4
+ * tests and installs the adapter. With the row off, the workbench offers no
5
+ * porting.
6
+ * @module @kirkchinese/harness-forge/porter
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ import type { Disposer } from '../forge/contract.js';
10
+ import { type HarnessForge } from '../forge/service.js';
11
+ export declare const name = "harness-forge-porter";
12
+ export declare const inject: string[];
13
+ /** The porter row. */
14
+ export declare function apply(ctx: Context): void;
15
+ /** Start the porter row on the shared service. Returns its teardown. */
16
+ export declare function startPorter(ctx: Context, forge: HarnessForge): Disposer;
@@ -0,0 +1,27 @@
1
+ import { FORGE_SERVICE } from '../forge/service.js';
2
+ import { briefFor, briefTitle, portRuntime, startCreatorSession, taskFor } from './port-gap.js';
3
+ import { PortSessions } from './port-sessions.js';
4
+ import { rowEffect } from '../forge/row.js';
5
+ export const name = 'harness-forge-porter';
6
+ export const inject = [FORGE_SERVICE];
7
+ /** The porter row. */
8
+ export function apply(ctx) {
9
+ rowEffect(ctx, 'porter', forge => startPorter(ctx, forge));
10
+ }
11
+ /** Start the porter row on the shared service. Returns its teardown. */
12
+ export function startPorter(ctx, forge) {
13
+ const sessions = new PortSessions(forge.statePath);
14
+ const api = {
15
+ // Read for each brief: the facts are the profile and home of the session that asks.
16
+ brief: (plugin, gaps, componentId) => briefFor(plugin, gaps, componentId, portRuntime(ctx)),
17
+ task: (plugin, gaps, componentId, language) => taskFor(plugin, gaps, componentId, language, portRuntime(ctx)),
18
+ port: async (plugin, gaps, componentId, location, language) => {
19
+ const runtime = portRuntime(ctx);
20
+ const task = taskFor(plugin, gaps, componentId, language, runtime);
21
+ const started = await startCreatorSession(ctx, task, location, briefTitle(briefFor(plugin, gaps, componentId, runtime)));
22
+ sessions.started(plugin.id, componentId, started.sessionId);
23
+ return started;
24
+ },
25
+ };
26
+ return forge.provide('porter', api);
27
+ }
@@ -0,0 +1,46 @@
1
+ import { type ForeignPlugin } from '@kirkchinese/harness-forge-core';
2
+ import { type AdapterCoverage } from '../workbench/overview.js';
3
+ import { type PluginManagerLike, type ReadinessCheck } from '../workbench/adapter-coverage.js';
4
+ import { PortSessions, type PortRecord } from './port-sessions.js';
5
+ import type { HarnessForge } from '../forge/service.js';
6
+ import type { Workbench } from '../workbench/workbench.js';
7
+ export type { PluginManagerLike };
8
+ /** What verification reads. */
9
+ export interface VerifyDeps {
10
+ findPlugin(id: string): {
11
+ readonly plugin: ForeignPlugin;
12
+ };
13
+ adapters(): readonly AdapterCoverage[];
14
+ /** Absent when the profile composes no plugin manager. */
15
+ readonly pluginManager: PluginManagerLike | undefined;
16
+ readonly sessions: PortSessions;
17
+ }
18
+ /** One check of the answer: the adapter's readiness, then its source's paths. */
19
+ export interface PortCheck {
20
+ readonly check: ReadinessCheck['check'] | 'paths';
21
+ readonly ok: boolean;
22
+ readonly detail: string;
23
+ }
24
+ /** The tool's answer. */
25
+ export interface PortVerification {
26
+ /** All checks passed: the Gaps screen now shows the part as done. */
27
+ readonly covered: boolean;
28
+ readonly pluginId: string;
29
+ readonly componentId: string;
30
+ readonly plugin: string;
31
+ readonly part: string;
32
+ readonly adapter?: string;
33
+ readonly checks: readonly PortCheck[];
34
+ }
35
+ /**
36
+ * Verify that an adapter covers one part, and record the answer.
37
+ * @param callerSession - the session that asked, linked to the part when no port session was recorded for it.
38
+ */
39
+ export declare function verifyPort(deps: VerifyDeps, pluginId: string, componentId: string, callerSession?: string): Promise<PortVerification>;
40
+ /** Verification against this Harness Forge and the DSH it runs in. */
41
+ export declare function forgeVerifyDeps(forge: HarnessForge, workbench: Workbench): VerifyDeps;
42
+ /**
43
+ * The recorded port sessions, without those whose session was deleted (when
44
+ * the profile composes a session controller that can list them).
45
+ */
46
+ export declare function livePorts(forge: HarnessForge): Promise<PortRecord[]>;