dsh-unreal-python-api 0.0.0-stage → 1.1.1

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/link-deps.ps1 ADDED
@@ -0,0 +1,36 @@
1
+ # Recreates the node_modules links this plugin needs to import the DSH runtime
2
+ # packages (@deepseek-ai/dsh-tools, @deepseek-ai/schemastery).
3
+ #
4
+ # Why this exists: the profile installs the plugin as a junction, so Node resolves
5
+ # index.js through its real path on this checkout. Node's lookup walks up from the
6
+ # checkout directory and therefore never reaches the DSH install on C:, so the two
7
+ # packages are linked into the checkout's own node_modules instead.
8
+ #
9
+ # Run this after moving the checkout or after a DSH reinstall.
10
+ [CmdletBinding()]
11
+ param(
12
+ [string]$InstallRoot = $env:DSH_INSTALL_DIR
13
+ )
14
+
15
+ $ErrorActionPreference = 'Stop'
16
+
17
+ if (-not $InstallRoot) { $InstallRoot = Join-Path $env:USERPROFILE 'node_modules\@deepseek-ai\dsh' }
18
+ $scope = Split-Path -Parent $InstallRoot
19
+ $packageRoot = $PSScriptRoot
20
+ $modules = Join-Path $packageRoot 'node_modules\@deepseek-ai'
21
+
22
+ New-Item -ItemType Directory -Force -Path $modules | Out-Null
23
+
24
+ foreach ($name in @('dsh-tools', 'schemastery')) {
25
+ $target = Join-Path $scope $name
26
+ if (-not (Test-Path (Join-Path $target 'package.json'))) {
27
+ throw "DSH package not found: $target (pass -InstallRoot pointing at the dsh package)"
28
+ }
29
+ $link = Join-Path $modules $name
30
+ if (Test-Path $link) { Remove-Item $link -Force -Recurse }
31
+ New-Item -ItemType Junction -Path $link -Target $target | Out-Null
32
+ Write-Host "linked $name -> $target"
33
+ }
34
+
35
+ Write-Host "Import check:"
36
+ node -e "console.log(' dsh-tools ', require.resolve('@deepseek-ai/dsh-tools/package.json')); console.log(' schemastery ', require.resolve('@deepseek-ai/schemastery/package.json'))"
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Unreal Python API context",
4
+ "description": "Gives agents the Unreal Engine Python API: list and search the documented symbols, read exact signatures from the Epic documentation, and scaffold ToolsetRegistry tools whose Unreal API calls are verified against the published symbol inventory.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Unreal Python API 上下文",
4
+ "description": "为 Agent 提供 Unreal Engine Python API:列出并搜索已收录的符号、从 Epic 文档读取精确签名,并基于已校验的符号清单生成 ToolsetRegistry 工具骨架。",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "dsh-unreal-python-api",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.1",
4
+ "type": "module",
5
+ "description": "Unreal Engine Python API context for DSH agents: symbol inventory listing, symbol search, exact syntax from the Epic docs, and tool scaffolding in four styles (ToolsetRegistry toolset, editor script, MCP tool descriptors, DSH defineTool module).",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "dsh",
9
+ "dsh-plugin",
10
+ "deepseek-harness",
11
+ "unreal-engine",
12
+ "unreal-python",
13
+ "toolset",
14
+ "mcp"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "exports": {
23
+ ".": "./index.js",
24
+ "./locale/*.json": "./locale/*.json",
25
+ "./icon": "./icon.svg"
26
+ },
27
+ "files": [
28
+ "index.js",
29
+ "lib",
30
+ "cordis.patch.yml",
31
+ "locale/*.json",
32
+ "docs",
33
+ "test",
34
+ "icon.svg",
35
+ "README.md",
36
+ "LICENSE",
37
+ "CHANGELOG.md",
38
+ "link-deps.ps1"
39
+ ],
40
+ "dsh": {
41
+ "bundle": {
42
+ "patch": "./cordis.patch.yml"
43
+ }
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/TaimoorSiddiquiOfficial/dsh-unreal-python-api.git"
48
+ },
49
+ "homepage": "https://github.com/TaimoorSiddiquiOfficial/dsh-unreal-python-api#readme",
50
+ "bugs": {
51
+ "url": "https://github.com/TaimoorSiddiquiOfficial/dsh-unreal-python-api/issues"
52
+ }
53
+ }
package/test/smoke.mjs ADDED
@@ -0,0 +1,343 @@
1
+ /**
2
+ * Exercises the plugin's data path against the live documentation, without the
3
+ * DSH runtime: download and parse the inventory, search it, list members, read
4
+ * a page's syntax, and build a scaffold from verified symbols.
5
+ *
6
+ * Run: node test/smoke.mjs
7
+ */
8
+
9
+ import assert from 'node:assert/strict'
10
+ import { listChildren, loadInventory, pageUrl, resolveCacheDir, searchSymbols, summarize } from '../lib/inventory.js'
11
+ import { readSymbolDoc } from '../lib/docs.js'
12
+ import { buildToolset } from '../lib/builder.js'
13
+ import { execFileSync } from 'node:child_process'
14
+ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs'
15
+ import { tmpdir } from 'node:os'
16
+ import { join } from 'node:path'
17
+
18
+ /** Parse a generated artifact with its own language's compiler. */
19
+ function assertParses(label, text, extension) {
20
+ if (text === '') return
21
+ const file = join(mkdtempSync(join(tmpdir(), 'unreal-python-api-')), `artifact.${extension}`)
22
+ writeFileSync(file, text)
23
+ if (extension === 'mjs') {
24
+ execFileSync(process.execPath, ['--check', file], { stdio: 'pipe' })
25
+ } else {
26
+ try {
27
+ execFileSync('python', ['-c', `import ast, pathlib; ast.parse(pathlib.Path(${JSON.stringify(file)}).read_text(encoding="utf-8"))`], { stdio: 'pipe' })
28
+ } catch (error) {
29
+ if (error.code === 'ENOENT') {
30
+ console.log(` ${label}: python is not on PATH, parse check skipped`)
31
+ return
32
+ }
33
+ throw error
34
+ }
35
+ }
36
+ console.log(` ${label}: parses as ${extension}`)
37
+ }
38
+
39
+ const DOC_BASE_URL = 'https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/'
40
+ const cacheDir = resolveCacheDir()
41
+ console.log(`cache dir: ${cacheDir}`)
42
+
43
+ const startedAt = Date.now()
44
+ const loaded = await loadInventory({ docBaseUrl: DOC_BASE_URL, cacheDir, refreshHours: 24, timeoutMs: 60_000 })
45
+ const { inventory, version, source } = loaded
46
+ console.log(`inventory: version=${version} symbols=${inventory.names.length} source=${source} in ${Date.now() - startedAt}ms`)
47
+ console.log(`inventory url: ${loaded.url}`)
48
+ const counts = summarize(inventory).map((entry) => `${entry.kind}=${entry.count}`).join(' ')
49
+ console.log(`kinds: ${counts}`)
50
+
51
+ assert.equal(version, '5.8', 'published inventory reports 5.8')
52
+ assert.ok(inventory.names.length > 60_000, `expected the full inventory, saw ${inventory.names.length}`)
53
+ assert.ok(summarize(inventory).some((entry) => entry.kind === 'class'), 'inventory carries classes')
54
+
55
+ const search = searchSymbols(inventory, { query: 'set_actor_scale3d', limit: 5 })
56
+ console.log(`\nsearch "set_actor_scale3d": ${search.total} matches`)
57
+ for (const match of search.matches) console.log(` ${match.name} [${match.kind}] ${match.url}`)
58
+ assert.ok(search.matches.some((match) => match.name === 'unreal.Actor.set_actor_scale3d'), 'exact member found')
59
+ assert.ok(search.matches[0].name === 'unreal.Actor.set_actor_scale3d', 'exact match ranks first')
60
+ assert.ok(search.matches[0].url.endsWith('#unreal.Actor.set_actor_scale3d'), `url points at the member anchor: ${search.matches[0].url}`)
61
+
62
+ const broad = searchSymbols(inventory, { query: 'save_asset', kind: 'method', limit: 5 })
63
+ console.log(`\nsearch "save_asset" (methods only): ${broad.total} matches, first=${broad.matches[0]?.name}`)
64
+ assert.ok(broad.total > 0, 'found documented save_asset methods')
65
+ assert.ok(broad.matches.every((match) => match.kind === 'method'), 'kind filter holds')
66
+
67
+ const members = listChildren(inventory, { parent: 'unreal.EditorAssetLibrary', limit: 8 })
68
+ console.log(`\nunreal.EditorAssetLibrary: ${members.total} direct members (${members.counts.map((entry) => `${entry.kind}=${entry.count}`).join(' ')})`)
69
+ for (const row of members.rows) console.log(` ${row.name} [${row.kind}]`)
70
+ assert.ok(members.total > 20, 'EditorAssetLibrary exposes members')
71
+ assert.ok(members.rows.every((row) => !row.name.slice('unreal.EditorAssetLibrary.'.length).includes('.')), 'direct members only')
72
+
73
+ const position = inventory.index.get('unreal.Actor.set_actor_scale3d')
74
+ assert.ok(position !== undefined, 'inventory indexes the symbol for page lookup')
75
+ const syntax = await readSymbolDoc({
76
+ docBaseUrl: DOC_BASE_URL,
77
+ symbol: 'unreal.Actor.set_actor_scale3d',
78
+ uri: inventory.uris[position],
79
+ kind: 'method',
80
+ timeoutMs: 60_000,
81
+ })
82
+ console.log(`\nsyntax ${syntax.symbol} (resolved=${syntax.resolved})`)
83
+ console.log(` signature: ${syntax.signature}`)
84
+ console.log(` summary: ${syntax.description}`)
85
+ for (const parameter of syntax.parameters) console.log(` param: ${parameter.name} - ${parameter.text}`)
86
+ console.log(` returns: ${syntax.returns}`)
87
+ console.log(` url: ${syntax.url}`)
88
+ assert.equal(syntax.resolved, true, 'page carries an anchor for the symbol')
89
+ assert.ok(syntax.signature.includes('set_actor_scale3d'), 'signature names the symbol')
90
+ assert.ok(syntax.url.startsWith(DOC_BASE_URL), 'url is absolute')
91
+ assert.ok(syntax.url.endsWith('#unreal.Actor.set_actor_scale3d'), `syntax url is anchored to the symbol: ${syntax.url}`)
92
+
93
+ const missing = await readSymbolDoc({
94
+ docBaseUrl: DOC_BASE_URL,
95
+ symbol: 'unreal.Nothing.here',
96
+ uri: inventory.uris[position],
97
+ kind: 'method',
98
+ timeoutMs: 60_000,
99
+ })
100
+ assert.equal(missing.resolved, false, 'an absent symbol is reported unresolved, never invented')
101
+ console.log(`\nabsent symbol reported unresolved: ${missing.note}`)
102
+
103
+ const resolveSymbol = (symbol) => {
104
+ const at = inventory.index.get(symbol)
105
+ if (at === undefined) return { found: false }
106
+ return { found: true, kind: inventory.kinds[at].replace('py:', ''), url: pageUrl(DOC_BASE_URL, inventory.uris[at], symbol) }
107
+ }
108
+
109
+ const built = buildToolset(
110
+ {
111
+ toolsetName: 'SmokeTestTools',
112
+ description: 'Smoke-test toolset for the Unreal Python API plugin.',
113
+ tools: [
114
+ {
115
+ name: 'read_actor_scale',
116
+ description: 'Reads an actor scale through the documented API.',
117
+ parameters: [{ name: 'actor', type: 'unreal.Actor', description: 'Actor to read.' }],
118
+ returns: 'unreal.Vector',
119
+ symbols: ['unreal.Actor.get_actor_scale3d', 'unreal.Actor.get_actor_scale3d_nonexistent'],
120
+ },
121
+ {
122
+ name: 'save_dirty',
123
+ description: 'Saves every dirty package.',
124
+ symbols: ['unreal.EditorAssetLibrary.save_asset'],
125
+ },
126
+ ],
127
+ },
128
+ resolveSymbol,
129
+ )
130
+
131
+ const frozen = buildToolset(
132
+ Object.freeze({
133
+ toolsetName: 'FrozenArgs',
134
+ description: 'Regression: tool arguments arrive non-extensible.',
135
+ tools: Object.freeze([
136
+ Object.freeze({
137
+ name: 'read_scale',
138
+ description: 'Reads an actor scale.',
139
+ parameters: Object.freeze([Object.freeze({ name: 'actor', type: 'unreal.Actor', description: 'Actor to read.' })]),
140
+ returns: 'unreal.Vector',
141
+ symbols: Object.freeze(['unreal.Actor.get_actor_scale3d']),
142
+ }),
143
+ ]),
144
+ }),
145
+ resolveSymbol,
146
+ )
147
+ assert.ok(
148
+ frozen.code.includes('def read_scale(actor: unreal.Actor) -> unreal.Vector:'),
149
+ 'frozen tool arguments build without mutating the caller input',
150
+ )
151
+ console.log('frozen-argument regression: ok')
152
+
153
+ console.log(`\nscaffold: verified=${built.verified.length} unresolved=${built.unresolved.length}`)
154
+ for (const note of built.notes) console.log(` note: ${note}`)
155
+ assert.equal(built.unresolved.length, 1, 'the invented symbol is reported, not written')
156
+ assert.ok(built.unresolved[0].startsWith('unreal.Actor.get_actor_scale3d_nonexistent'), 'the invented symbol is named')
157
+ assert.ok(built.code.includes('class SmokeTestTools(unreal.ToolsetDefinition)'), 'toolset class emitted')
158
+ assert.ok(built.code.includes('@toolset_registry.tool_call'), 'tools are decorated')
159
+ assert.ok(built.code.includes('def read_actor_scale(actor: unreal.Actor) -> unreal.Vector:'), 'annotated signature emitted')
160
+ assert.ok(built.code.includes('unreal.Actor.get_actor_scale3d https://'), 'verified symbol recorded with its page')
161
+ assert.ok(built.code.includes('#unreal.Actor.get_actor_scale3d'), 'verified symbol deep-links to its anchor')
162
+ assert.ok(!built.code.includes('nonexistent'), 'unresolved symbol kept out of the code')
163
+ assert.ok(built.code.includes('register_toolset_class'), 'registration emitted')
164
+ assert.ok(built.testCode.includes('class SmokeTestToolsTestCase(ToolCallTestCase)'), 'test skeleton emitted')
165
+
166
+ // --- the two market-facing styles: MCP descriptors and a DSH tool module -------
167
+ const builderInput = (style) => ({
168
+ toolsetName: 'TerritoryTools',
169
+ description: 'Manage TerritoryFramework territory state from the editor.',
170
+ style,
171
+ testModule: 'territory_tools',
172
+ tools: [
173
+ {
174
+ name: 'save_dirty_assets',
175
+ description: 'Save every dirty asset in the project.',
176
+ parameters: [{ name: 'only_if_is_dirty', type: 'bool', description: 'Skip clean assets.' }],
177
+ returns: 'bool',
178
+ symbols: ['unreal.EditorAssetLibrary.save_asset', 'unreal.NotARealSymbol'],
179
+ },
180
+ ],
181
+ })
182
+
183
+ const mcp = buildToolset(builderInput('mcp_tool'), resolveSymbol)
184
+ assert.equal(mcp.style, 'mcp_tool')
185
+ const descriptor = JSON.parse(mcp.code)
186
+ assert.equal(descriptor.tools.length, 1)
187
+ assert.equal(descriptor.tools[0].name, 'save_dirty_assets')
188
+ assert.equal(descriptor.tools[0].inputSchema.additionalProperties, false)
189
+ assert.deepEqual(descriptor.tools[0].inputSchema.required, ['only_if_is_dirty'])
190
+ assert.equal(descriptor.tools[0].inputSchema.properties.only_if_is_dirty.type, 'boolean')
191
+ assert.ok(!mcp.code.includes('NotARealSymbol'), 'unverified symbol stays out of the descriptor')
192
+ assert.ok(mcp.testCode.includes('TOOL_SPEC = json.loads'), 'handler module carries the descriptors')
193
+ assert.ok(mcp.testCode.includes('raise NotImplementedError'), 'handler body is unimplemented')
194
+
195
+ const dsh = buildToolset(builderInput('dsh_tool'), resolveSymbol)
196
+ assert.equal(dsh.style, 'dsh_tool')
197
+ assert.ok(dsh.code.includes("from '@deepseek-ai/dsh-tools'"), 'DSH module imports defineTool')
198
+ assert.ok(dsh.code.includes('additionalProperties: false'), 'DSH output schema is closed')
199
+ assert.ok(dsh.code.includes('export function registerTools(ctx)'), 'DSH module registers through ctx.tools')
200
+ assert.ok(!dsh.code.includes('NotARealSymbol'), 'unverified symbol stays out of the DSH module')
201
+ assert.ok(dsh.testCode.includes('registerTools'), 'DSH test exercises registration')
202
+ assert.ok(!/object path/.test(dsh.code), 'an undescribed primitive parameter gets no invented description')
203
+ assert.ok(!/object path/.test(built.code), 'the toolset module invents no description either')
204
+
205
+ assert.throws(() => buildToolset(builderInput('nope'), resolveSymbol), /unsupported style/)
206
+
207
+ // --- workspace scope: the setting that makes the plugin workspace specific ----
208
+ import { createScopeGate, describeScope, inScope, resolveScope } from '../lib/scope.js'
209
+
210
+ const TDA = 'D:\\HOP TRENDY UNREAL\\Unreal Projects\\TDA'
211
+ const anywhere = resolveScope({ scope: 'anywhere' })
212
+ assert.equal(inScope('D:/anywhere/at/all', anywhere), true, 'anywhere admits every directory')
213
+ assert.equal(inScope(undefined, anywhere), true, 'anywhere admits even an unknown directory')
214
+
215
+ const listed = resolveScope({ scope: 'workspaces', workspaces: [TDA] })
216
+ assert.equal(inScope(join(TDA, 'Source'), listed), true, 'a subdirectory of a listed workspace is admitted')
217
+ assert.equal(inScope(TDA, listed), true, 'the workspace root is admitted')
218
+ assert.equal(inScope('D:\\HOP TRENDY UNREAL\\Unreal Projects\\TDA2', listed), false, 'a sibling with a shared prefix is not admitted')
219
+ assert.equal(inScope('D:\\HOP TRENDY UNREAL\\DSH Plugins', listed), false, 'an unrelated directory is not admitted')
220
+ assert.equal(inScope(undefined, listed), false, 'an unknown directory is not admitted')
221
+ assert.throws(() => resolveScope({ scope: 'workspaces' }), /needs at least one entry/, 'workspaces scope needs roots')
222
+ assert.throws(() => resolveScope({ scope: 'sometimes' }), /unsupported scope/, 'unknown scopes are rejected')
223
+
224
+ const projectRoot = mkdtempSync(join(tmpdir(), 'unreal-project-'))
225
+ writeFileSync(join(projectRoot, 'Smoke.uproject'), '{}')
226
+ const nested = join(projectRoot, 'Source', 'Smoke')
227
+ mkdirSync(nested, { recursive: true })
228
+ const projectScope = resolveScope({ scope: 'unreal-project' })
229
+ assert.equal(inScope(nested, projectScope), true, 'a directory inside an Unreal project is admitted')
230
+ assert.equal(inScope(projectRoot, projectScope), true, 'the project root is admitted')
231
+ assert.equal(inScope(mkdtempSync(join(tmpdir(), 'unreal-plain-')), projectScope), false, 'a directory without a .uproject is not admitted')
232
+ assert.equal(inScope(projectRoot, resolveScope({ scope: 'unreal-project', projectMarkers: ['MyPlugin.uplugin'] })), false, 'a configured marker list replaces the default')
233
+
234
+ let fakeDirectory = TDA
235
+ const gate = createScopeGate({ resolved: listed, directoryOf: () => fakeDirectory })
236
+ const agent = { session: { id: 'smoke' } }
237
+ assert.equal(gate.admits(agent), true, 'the gate admits the configured workspace')
238
+ fakeDirectory = 'D:\\somewhere\\else'
239
+ assert.equal(gate.admits(agent), false, 'the gate rejects another workspace')
240
+ const broken = createScopeGate({
241
+ resolved: listed,
242
+ directoryOf: () => {
243
+ throw new Error('no directory')
244
+ },
245
+ })
246
+ assert.equal(broken.admits(agent), false, 'a failing directory lookup rejects instead of throwing')
247
+ console.log(`scope: ${describeScope(projectScope)}`)
248
+
249
+ // --- the plugin module itself: exports and configuration defaults -------------
250
+ // The module imports the host-provided '@deepseek-ai/*' packages, which are not
251
+ // present on a bare checkout or in CI, so these checks run only where the harness
252
+ // is installed.
253
+ import { createRequire } from 'node:module'
254
+
255
+ const requireHost = createRequire(import.meta.url)
256
+
257
+ /** Whether the host packages this module imports can be resolved. */
258
+ function hostPackagesAvailable() {
259
+ try {
260
+ requireHost.resolve('@deepseek-ai/dsh-tools/package.json')
261
+ requireHost.resolve('@deepseek-ai/schemastery/package.json')
262
+ return true
263
+ } catch {
264
+ return false
265
+ }
266
+ }
267
+
268
+ const hostReady = hostPackagesAvailable()
269
+ if (!hostReady) {
270
+ console.log('host packages (@deepseek-ai/*) are not installed here; export, configuration and apply() checks skipped')
271
+ }
272
+
273
+ if (hostReady) {
274
+ const plugin = await import('../index.js')
275
+ assert.equal(plugin.name, 'unreal-python-api')
276
+ assert.deepEqual(plugin.inject, ['tools', 'systemPrompt', 'workingDirectory'])
277
+ assert.equal(typeof plugin.apply, 'function')
278
+ const defaults = plugin.Config({})
279
+ assert.equal(defaults.scope, 'anywhere', 'tools stay available everywhere by default')
280
+ assert.deepEqual(defaults.workspaces, [])
281
+ assert.deepEqual(defaults.projectMarkers, ['.uproject'])
282
+ const configured = plugin.Config({ scope: 'workspaces', workspaces: [TDA] })
283
+ assert.equal(configured.scope, 'workspaces')
284
+ assert.deepEqual(configured.workspaces, [TDA])
285
+ console.log('scope + configuration defaults: OK')
286
+
287
+ // --- apply(): the registration path, with and without a scope ----------------
288
+ function fakeContext(directoryOf) {
289
+ const registered = []
290
+ const sections = []
291
+ return {
292
+ registered,
293
+ sections,
294
+ tools: {
295
+ register(definition, options = {}) {
296
+ registered.push({ definition, options })
297
+ },
298
+ },
299
+ systemPrompt: {
300
+ section(section) {
301
+ sections.push(section)
302
+ return () => {}
303
+ },
304
+ },
305
+ workingDirectory: { get: directoryOf },
306
+ }
307
+ }
308
+
309
+ const openContext = fakeContext(() => TDA)
310
+ plugin.apply(openContext, plugin.Config({}))
311
+ assert.equal(openContext.registered.length, 4, 'default scope registers four tools')
312
+ assert.ok(openContext.registered.every((entry) => entry.options.when === undefined), 'default scope attaches no condition')
313
+ assert.equal(openContext.sections.length, 1, 'default scope registers one prompt section')
314
+
315
+ const scopedContext = fakeContext((session) => (session.id === 'inside' ? join(TDA, 'Source') : 'D:\\elsewhere'))
316
+ plugin.apply(scopedContext, plugin.Config({ scope: 'workspaces', workspaces: [TDA] }))
317
+ assert.equal(scopedContext.registered.length, 4, 'a scoped install still registers four tools')
318
+ assert.ok(scopedContext.registered.every((entry) => typeof entry.options.when === 'function'), 'a scoped install attaches a condition')
319
+ const condition = scopedContext.registered[0].options.when
320
+ assert.equal(await condition({ agent: { session: { id: 'inside' } } }), true, 'the condition admits the configured workspace')
321
+ assert.equal(await condition({ agent: { session: { id: 'outside' } } }), false, 'the condition rejects another workspace')
322
+ assert.match(scopedContext.sections[0].text, /admitted only inside/, 'the prompt section says where the tools apply')
323
+ console.log('apply(): default and scoped registration: OK')
324
+ }
325
+
326
+ // --- every generated artifact must parse in its own language -------------------
327
+ console.log('parse checks:')
328
+ assertParses('toolset module', built.code, 'py')
329
+ assertParses('toolset test module', built.testCode, 'py')
330
+ assertParses('mcp handler module', mcp.testCode, 'py')
331
+ assertParses('dsh tool module', dsh.code, 'mjs')
332
+ assertParses('dsh test module', dsh.testCode, 'mjs')
333
+ console.log('extra styles: mcp_tool + dsh_tool OK')
334
+ console.log('\n--- generated MCP descriptors ---')
335
+ console.log(mcp.code)
336
+ console.log('--- generated DSH tool module ---')
337
+ console.log(dsh.code)
338
+
339
+ console.log('\n--- generated toolset code ---')
340
+ console.log(built.code)
341
+ console.log('--- generated test code ---')
342
+ console.log(built.testCode)
343
+ console.log('\nSMOKE OK')