dsh-unreal-python-api 1.1.1 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 — 2026-11-30
4
+
5
+ - New `exclude` setting: a list of directories that never get the development
6
+ tier, in **every** `scope` mode. `scope: anywhere` plus `exclude` now means
7
+ "everywhere except these roots", which is how a non-Unreal workspace such as a
8
+ Shopify app stays clean without naming every included project. An exclusion
9
+ also beats `unreal-project` detection and an inclusion list, and it is checked
10
+ without touching the filesystem.
11
+ - Fixed the generated registry import. UE 5.8's `toolset_registry` package
12
+ exports `tool_call`, `tool_raising_exceptions` and `reload_module` — it does
13
+ **not** export a `toolset_registry` object, so `from toolset_registry import
14
+ toolset_registry` failed with `ImportError`. The default is now
15
+ `from toolset_registry import tool_call` with `@tool_call`, and an explicit
16
+ `registry_import` of a module/object still yields the `@<name>.tool_call` form.
17
+ Verified against `Engine/Plugins/Experimental/ToolsetRegistry/Content/Python`.
18
+ - The build notes now say a Python-defined toolset registers as
19
+ `PythonTypes.<ClassName>_<hex>` and how to look the name up.
20
+ - Proven end to end inside a running UE 5.8 editor: the generated toolset
21
+ registered as `PythonTypes.UnrealPythonApiSmokeTools_0x19CC95C7` and
22
+ `unreal.ToolsetRegistry.execute_tool(<name>, 'list_assets',
23
+ '{"folder": "/Game/HOPTRENDY"}')` returned `{"returnValue":[...]}` with 1 370
24
+ asset paths, with `error == ''`.
25
+
26
+ ## 1.2.0 — 2026-11-30
27
+
28
+ - Split the tools into two tiers. **general** — `unreal_python_tools_list`,
29
+ `unreal_python_search`, `unreal_python_syntax` — register unconditionally and
30
+ are offered in every workspace. **development** — `unreal_python_tool_builder`
31
+ — is admitted only inside `scope`, so a normal workspace keeps the lookups and
32
+ the code-generating tool appears only where you develop. `scope: anywhere`
33
+ (the default) still offers everything everywhere.
34
+ - The prompt section now names the general tier and says where the development
35
+ tier applies instead of implying all four tools behave alike.
36
+ - Tests assert the tier split: three unconditional tools, exactly one gated, and
37
+ the gated one is the builder.
38
+
3
39
  ## 1.1.1 — 2026-11-30
4
40
 
5
41
  - Fixed the test suite on a machine without the harness packages: the export,
package/README.md CHANGED
@@ -129,39 +129,61 @@ locale/, icon.svg Host display metadata
129
129
  | `maxResults` | `30` | Upper bound on rows a tool returns. |
130
130
  | `fetchTimeoutMs` | `30000` | Page and inventory timeout. |
131
131
  | `promptSection` | `true` | Register the system-prompt section. |
132
- | `scope` | `anywhere` | Where the tools are offered: `anywhere`, `unreal-project`, or `workspaces`. |
132
+ | `scope` | `anywhere` | Where the development tier is offered: `anywhere`, `unreal-project`, or `workspaces`. |
133
133
  | `workspaces` | `[]` | Absolute roots admitted by `scope: workspaces`. |
134
+ | `exclude` | `[]` | Absolute roots that never get the development tier, in every `scope` mode. |
134
135
  | `projectMarkers` | `['.uproject']` | Files that identify a project root; replaces the default list. |
135
136
 
136
- ### Workspace scoping
137
+ ### Two tiers, and workspace scoping
137
138
 
138
- One profile install serves every workspace, so the four tools are offered
139
- everywhere by default. Set `scope` to make them appear only where they are
140
- useful:
139
+ One profile install serves every workspace, so the tools come in two tiers:
141
140
 
142
- | `scope` | Tools are offered when |
141
+ | Tier | Tools | Offered |
142
+ |---|---|---|
143
+ | general | `unreal_python_tools_list`, `unreal_python_search`, `unreal_python_syntax` | every workspace, always |
144
+ | development | `unreal_python_tool_builder` | only inside `scope` |
145
+
146
+ `scope` decides where the development tier is admitted:
147
+
148
+ | `scope` | The development tier is offered when |
143
149
  |---|---|
144
- | `anywhere` (default) | always — unchanged from 1.0.0 |
150
+ | `anywhere` (default) | always — the 1.0/1.1 behaviour, nothing gated |
145
151
  | `unreal-project` | the session's working directory, or a parent, holds a `*.uproject` |
146
152
  | `workspaces` | the working directory is inside one of the `workspaces` roots |
147
153
 
154
+ `exclude` wins over `scope` in every mode, so the usual setup for one Unreal
155
+ project among non-Unreal workspaces is to leave `scope: anywhere` and name the
156
+ worktrees to skip:
157
+
158
+ ```yaml
159
+ - id: unreal-python-api
160
+ name: 'dsh-unreal-python-api'
161
+ config:
162
+ exclude:
163
+ - D:\HOPRELAY
164
+ - D:\ShopifyApp
165
+ ```
166
+
167
+ An exclusion is a path check with no filesystem access, so it also settles the
168
+ "this project has no `.uproject` yet" case that `scope: unreal-project` cannot
169
+ judge.
170
+
148
171
  ```yaml
149
172
  # the dsh-unreal-python-api row's config (profile cordis.patch.yml, or the
150
173
  # plugin's settings panel in the GUI when it offers one)
151
174
  config:
152
- scope: unreal-project
153
- # or name the roots yourself:
154
- # scope: workspaces
155
- # workspaces:
156
- # - D:\HOP TRENDY UNREAL\Unreal Projects\TDA
175
+ scope: workspaces
176
+ workspaces:
177
+ - D:\HOP TRENDY UNREAL\Unreal Projects\TDA
157
178
  ```
158
179
 
159
180
  The check runs once per prepared step against the session's committed working
160
181
  directory, is cached for ten seconds, and never throws: an unknown directory or
161
- a failing lookup counts as not admitted. Path comparison is segment-aware and
182
+ a failing lookup counts as not admitted. Comparison is segment-aware and
162
183
  case-insensitive, so `…\TDA` admits `…\TDA\Source` but not `…\TDA2`. Outside the
163
- scope the tools are absent from the model's tool list entirely rather than
164
- refused at call time, and the prompt section says where they apply.
184
+ scope the development tool is absent from the model's tool list entirely rather
185
+ than refused at call time, and the prompt section says so. The general tier is
186
+ never gated, so documentation lookups keep working in every workspace.
165
187
 
166
188
  ## Publishing to the market
167
189
 
package/docs/DETAIL.md CHANGED
@@ -46,7 +46,7 @@ returned with `resolved: false` and a note instead of a guess.
46
46
  **`unreal_python_tool_builder`** — scaffolds an Unreal Python tool from a
47
47
  description and a list of API symbols per tool. It emits either a ToolsetRegistry
48
48
  toolset class (`@unreal.uclass()` on `unreal.ToolsetDefinition`,
49
- `@toolset_registry.tool_call` static methods with annotated parameters,
49
+ `@tool_call` static methods with annotated parameters,
50
50
  docstring, registration and unregistration functions) or a plain editor script,
51
51
  plus a test module skeleton. Each requested symbol is verified against the
52
52
  inventory: verified ones are recorded beside the tool body with their
@@ -66,13 +66,19 @@ grounded starting point, not finished code.
66
66
  | `maxResults` | `30` | Default row cap per call; a caller may ask for fewer or more, up to 200. |
67
67
  | `fetchTimeoutMs` | `30000` | Per-request timeout for the inventory and documentation pages. |
68
68
  | `promptSection` | `true` | Adds one line to the system prompt naming the tools and the documentation root. |
69
- | `scope` | `anywhere` | `anywhere`, `unreal-project`, or `workspaces`; see the scope gate below. |
69
+ | `scope` | `anywhere` | `anywhere`, `unreal-project`, or `workspaces`; where the development tier is admitted. |
70
70
  | `workspaces` | `[]` | Absolute roots admitted by `scope: workspaces`; required by that mode. |
71
+ | `exclude` | `[]` | Absolute roots that never get the development tier, in every `scope` mode. Checked before anything else and with no filesystem access. |
71
72
  | `projectMarkers` | `['.uproject']` | File names (or `.extension` suffixes) that mark a project root. Replaces, never extends, the default. |
72
73
 
73
74
  ### Scope gate
74
75
 
75
- `scope` is enforced with the tool runtime's step-time activation condition —
76
+ The tools form two tiers. `unreal_python_tools_list`, `unreal_python_search` and
77
+ `unreal_python_syntax` are general: they register unconditionally and stay
78
+ available in every workspace. `unreal_python_tool_builder` is development: it
79
+ writes code, so it is the tool `scope` gates.
80
+
81
+ Gating uses the tool runtime's step-time activation condition —
76
82
  `ctx.tools.register(definition, { when })`, where `when` receives the preparing
77
83
  agent. The plugin reads the session's committed working directory through the
78
84
  `workingDirectory` service (`ctx.workingDirectory.get(agent.session)`), so the
package/index.js CHANGED
@@ -45,6 +45,7 @@ export const Config = z.object({
45
45
  scope: z.string().default(DEFAULT_SCOPE),
46
46
  workspaces: z.array(z.string()).default([]),
47
47
  projectMarkers: z.array(z.string()).default(DEFAULT_PROJECT_MARKERS),
48
+ exclude: z.array(z.string()).default([]),
48
49
  })
49
50
 
50
51
  /** Largest row count any tool returns, whatever a caller asks for. */
@@ -145,6 +146,7 @@ export function apply(ctx, config) {
145
146
  scope: config.scope,
146
147
  workspaces: config.workspaces,
147
148
  projectMarkers: config.projectMarkers,
149
+ exclude: config.exclude,
148
150
  })
149
151
  const gate = createScopeGate({
150
152
  resolved: scope,
@@ -156,11 +158,14 @@ export function apply(ctx, config) {
156
158
  }
157
159
  },
158
160
  })
159
- // A scope condition must never fail step preparation, so only a non-default
160
- // scope attaches one; the default registers exactly as before.
161
- const register =
161
+ // Two tiers: the general lookup tools are offered in every workspace, the
162
+ // development tools (scaffold generation) only inside the configured scope.
163
+ // A condition must never fail step preparation, so the default scope attaches
164
+ // none and the general tier never carries one.
165
+ const registerGeneral = (definition) => ctx.tools.register(definition)
166
+ const registerDevelopment =
162
167
  scope.scope === 'anywhere'
163
- ? (definition) => ctx.tools.register(definition)
168
+ ? registerGeneral
164
169
  : (definition) => ctx.tools.register(definition, { when: (context) => gate.admits(context.agent) })
165
170
 
166
171
  let loaded = null
@@ -185,7 +190,7 @@ export function apply(ctx, config) {
185
190
  return loaded
186
191
  }
187
192
 
188
- register(defineTool({
193
+ registerGeneral(defineTool({
189
194
  name: 'unreal_python_tools_list',
190
195
  description: 'List Unreal Engine Python API symbols. Without a parent it reports how many symbols the published documentation holds and their kinds; with a parent such as unreal.Actor it lists that namespace or class direct members.',
191
196
  parameters: {
@@ -250,7 +255,7 @@ export function apply(ctx, config) {
250
255
  },
251
256
  }))
252
257
 
253
- register(defineTool({
258
+ registerGeneral(defineTool({
254
259
  name: 'unreal_python_search',
255
260
  description: 'Search Unreal Python API symbol names. Ranks an exact name first, then a member name that starts with the query, then any containing name, and returns each match with its documentation URL.',
256
261
  parameters: {
@@ -301,7 +306,7 @@ export function apply(ctx, config) {
301
306
  },
302
307
  }))
303
308
 
304
- register(defineTool({
309
+ registerGeneral(defineTool({
305
310
  name: 'unreal_python_syntax',
306
311
  description: 'Return the exact documented syntax of Unreal Python symbols: signature, description, parameters, and return value, read from the published documentation page that carries the symbol.',
307
312
  parameters: {
@@ -409,7 +414,7 @@ export function apply(ctx, config) {
409
414
  },
410
415
  }))
411
416
 
412
- register(defineTool({
417
+ registerDevelopment(defineTool({
413
418
  name: 'unreal_python_tool_builder',
414
419
  description: 'Scaffold an Unreal Python tool from a description plus verified API symbols. Styles: toolset (a ToolsetRegistry toolset class with its test module), editor_script (a plain editor script), mcp_tool (MCP tool descriptors in JSON plus the Python handler module that serves them), and dsh_tool (a DSH plugin tool module whose definitions register through defineTool, with a Node test module). Every Unreal API symbol the tool asks for is verified against the published inventory and recorded with its documentation URL; unverified symbols are reported instead of written into the code.',
415
420
  parameters: {
@@ -532,7 +537,7 @@ export function apply(ctx, config) {
532
537
  text:
533
538
  scope.scope === 'anywhere'
534
539
  ? `Unreal Python API (published 5.8 documentation): unreal_python_tools_list and unreal_python_search find documented symbols, unreal_python_syntax returns their exact signatures and parameters, and unreal_python_tool_builder scaffolds a tool from verified symbols in one of four styles — a ToolsetRegistry toolset, an editor script, MCP tool descriptors with their Python handlers, or a DSH tool module built on defineTool. Documentation root: ${docBaseUrl}`
535
- : `Unreal Python API (published 5.8 documentation). The unreal_python_* tools are admitted only inside ${describeScope(scope)}; in other workspaces they are not offered. Inside one they list documented symbols, search them, return exact signatures and parameters, and scaffold tools from verified symbols in four styles. Documentation root: ${docBaseUrl}`,
540
+ : `Unreal Python API (published 5.8 documentation): unreal_python_tools_list, unreal_python_search and unreal_python_syntax are available here; unreal_python_tool_builder is admitted only inside ${describeScope(scope)}, so it is absent when you work elsewhere. Documentation root: ${docBaseUrl}`,
536
541
  })
537
542
  }
538
543
  }
package/lib/builder.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Scaffolds Unreal Python tools from a description plus verified API symbols.
3
3
  *
4
4
  * The emitted code follows the ToolsetRegistry shape: one `@unreal.uclass()`
5
- * class inheriting `unreal.ToolsetDefinition`, one `@toolset_registry.tool_call`
5
+ * class inheriting `unreal.ToolsetDefinition`, one `@tool_call`
6
6
  * static method per tool, annotated parameters, and manual registration. Tool
7
7
  * bodies are deliberately unimplemented, and every Unreal symbol the tool needs
8
8
  * is recorded next to the body with the documentation page it was verified in.
@@ -30,7 +30,29 @@ const TYPE_MAP = new Map([
30
30
  ])
31
31
 
32
32
  /** Import line assumed for the ToolsetRegistry Python decorator module. */
33
- export const DEFAULT_REGISTRY_IMPORT = 'from toolset_registry import toolset_registry'
33
+ export const DEFAULT_REGISTRY_IMPORT = 'from toolset_registry import tool_call'
34
+
35
+ /**
36
+ * The decorator text implied by a registry import line. The UE 5.8 module ships
37
+ * `tool_call` directly, so the default import yields `@tool_call`; an import of
38
+ * the module or registry object keeps its `.tool_call` attribute form.
39
+ * @param {unknown} importLine
40
+ * @returns {string} decorator text such as `@tool_call`
41
+ */
42
+ export function registryDecoratorName(importLine) {
43
+ const line = String(importLine ?? '').trim()
44
+ if (line === '') return '@tool_call'
45
+ const fromImport = /^from\s+[A-Za-z0-9_.]+\s+import\s+([A-Za-z0-9_]+)$/.exec(line)
46
+ if (fromImport) {
47
+ return fromImport[1] === 'tool_call' ? '@tool_call' : `@${fromImport[1]}.tool_call`
48
+ }
49
+ const plainImport = /^(?:import\s+)?([A-Za-z0-9_.]+)(?:\s+as\s+([A-Za-z0-9_]+))?$/.exec(line)
50
+ if (plainImport) {
51
+ const name = plainImport[2] ?? plainImport[1].split('.').pop()
52
+ return name === 'tool_call' ? '@tool_call' : `@${name}.tool_call`
53
+ }
54
+ return '@tool_call'
55
+ }
34
56
 
35
57
  /** Base class assumed for a generated toolset. */
36
58
  export const DEFAULT_BASE_CLASS = 'unreal.ToolsetDefinition'
@@ -200,11 +222,12 @@ function symbolComments(symbols, urls, indent, prefix = '#') {
200
222
  * Render one tool method.
201
223
  * @param {object} tool Tool definition.
202
224
  * @param {Map<string, string>} urls Verified symbol URLs.
225
+ * @param {string} [decorator] Registry decorator text, such as `@tool_call`.
203
226
  * @returns {string[]} Method lines.
204
227
  */
205
- function renderTool(tool, urls) {
228
+ function renderTool(tool, urls, decorator = '@tool_call') {
206
229
  const lines = []
207
- lines.push(' @toolset_registry.tool_call')
230
+ lines.push(` ${decorator}`)
208
231
  lines.push(' @staticmethod')
209
232
  const parameters = (tool.parameters ?? []).map((parameter) => {
210
233
  const name = requireIdentifier(`parameter name in tool '${tool.name}'`, snakeCase(parameter.name))
@@ -252,12 +275,13 @@ function renderToolset(input, urls) {
252
275
  lines.push(input.registryImport)
253
276
  lines.push('')
254
277
  }
278
+ const decorator = registryDecoratorName(input.registryImport)
255
279
  lines.push('')
256
280
  lines.push('@unreal.uclass()')
257
281
  lines.push(`class ${className}(${input.baseClass}):`)
258
282
  lines.push(` """${input.description}"""`)
259
283
  lines.push('')
260
- for (const tool of input.tools) lines.push(...renderTool(tool, urls))
284
+ for (const tool of input.tools) lines.push(...renderTool(tool, urls, decorator))
261
285
  lines.push('')
262
286
  lines.push(`def register_toolsets() -> None:`)
263
287
  lines.push(` """Register ${className} with the ToolsetRegistry."""`)
@@ -565,6 +589,7 @@ export function buildToolset(input, resolve) {
565
589
 
566
590
  const notes = [
567
591
  'Tool bodies raise NotImplementedError; implement them before registering.',
592
+ 'A Python-defined toolset registers as PythonTypes.<ClassName>_<hex>; find the exact name with unreal.ToolsetRegistry.get_all_toolset_json_schemas().',
568
593
  `Registry decorator import: ${normalized.registryImport === '' ? 'omitted (supply the line for your ToolsetRegistry plugin)' : normalized.registryImport}.`,
569
594
  `Base class: ${normalized.baseClass}.`,
570
595
  ]
@@ -578,7 +603,7 @@ export function buildToolset(input, resolve) {
578
603
  testLabel: 'Test module (Python)',
579
604
  code: renderToolset,
580
605
  tests: renderTests,
581
- note: 'Registry decorator import and base class are the ToolsetRegistry defaults; change registry_import or base_class when your plugin differs.',
606
+ note: 'Registry decorator import and base class are the UE 5.8 ToolsetRegistry defaults (from toolset_registry import tool_call); change registry_import or base_class when your plugin differs.',
582
607
  },
583
608
  editor_script: {
584
609
  codeLabel: 'Editor script (Python)',
package/lib/scope.js CHANGED
@@ -104,8 +104,8 @@ export function findProjectRoot(directory, options = {}) {
104
104
 
105
105
  /**
106
106
  * Validate and normalize the scope configuration.
107
- * @param {{ scope?: unknown, workspaces?: unknown, projectMarkers?: unknown }} [input]
108
- * @returns {{ scope: string, workspaces: string[], projectMarkers: string[] }}
107
+ * @param {{ scope?: unknown, workspaces?: unknown, projectMarkers?: unknown, exclude?: unknown }} [input]
108
+ * @returns {{ scope: string, workspaces: string[], projectMarkers: string[], exclude: string[] }}
109
109
  */
110
110
  export function resolveScope(input = {}) {
111
111
  const scope = String(input.scope ?? DEFAULT_SCOPE).trim()
@@ -122,31 +122,44 @@ export function resolveScope(input = {}) {
122
122
  const projectMarkers = (configured.length > 0 ? configured : DEFAULT_PROJECT_MARKERS)
123
123
  .map((marker) => String(marker).trim())
124
124
  .filter((marker) => marker !== '')
125
- return { scope, workspaces, projectMarkers }
125
+ const exclude = (Array.isArray(input.exclude) ? input.exclude : [])
126
+ .map((value) => String(value ?? '').trim())
127
+ .filter((value) => value !== '')
128
+ return { scope, workspaces, projectMarkers, exclude }
126
129
  }
127
130
 
128
131
  /**
129
132
  * Human-readable description of an effective scope, used in the prompt
130
133
  * section so the model knows why the tools may be missing.
131
- * @param {{ scope: string, workspaces: string[], projectMarkers: string[] }} resolved
134
+ * @param {{ scope: string, workspaces: string[], projectMarkers: string[], exclude?: string[] }} resolved
132
135
  * @returns {string}
133
136
  */
134
137
  export function describeScope(resolved) {
135
- if (!resolved || resolved.scope === 'anywhere') return 'every workspace'
136
- if (resolved.scope === 'workspaces') return `a configured workspace (${resolved.workspaces.join(', ')})`
137
- return `an Unreal project (a ${resolved.projectMarkers.join(' or ')} file in the working directory or one of its parents)`
138
+ if (!resolved) return 'every workspace'
139
+ const excluded = Array.isArray(resolved.exclude) ? resolved.exclude : []
140
+ const suffix = excluded.length > 0 ? `, excluding ${excluded.join(', ')}` : ''
141
+ if (resolved.scope === 'anywhere') {
142
+ return excluded.length > 0 ? `every workspace except ${excluded.join(', ')}` : 'every workspace'
143
+ }
144
+ if (resolved.scope === 'workspaces') return `a configured workspace (${resolved.workspaces.join(', ')})${suffix}`
145
+ return `an Unreal project (a ${resolved.projectMarkers.join(' or ')} file in the working directory or one of its parents)${suffix}`
138
146
  }
139
147
 
140
148
  /**
141
- * Whether a directory is admitted by the effective scope.
149
+ * Whether a directory is admitted by the effective scope. An exclusion always
150
+ * wins, in every mode, so a non-Unreal workspace can be kept out by name.
142
151
  * @param {unknown} directory
143
- * @param {{ scope: string, workspaces: string[], projectMarkers: string[] }} resolved
152
+ * @param {{ scope: string, workspaces: string[], projectMarkers: string[], exclude?: string[] }} resolved
144
153
  * @param {{ fs?: { readdirSync: (dir: string) => readonly string[] }, maxDepth?: number }} [options]
145
154
  * @returns {boolean}
146
155
  */
147
156
  export function inScope(directory, resolved, options = {}) {
148
- if (!resolved || resolved.scope === 'anywhere') return true
157
+ if (!resolved) return true
158
+ const excluded = Array.isArray(resolved.exclude) ? resolved.exclude : []
159
+ if (resolved.scope === 'anywhere' && excluded.length === 0) return true
149
160
  if (typeof directory !== 'string' || directory.trim() === '') return false
161
+ if (inWorkspaces(directory, excluded)) return false
162
+ if (resolved.scope === 'anywhere') return true
150
163
  if (resolved.scope === 'workspaces') return inWorkspaces(directory, resolved.workspaces)
151
164
  return Boolean(
152
165
  findProjectRoot(directory, {
@@ -160,7 +173,7 @@ export function inScope(directory, resolved, options = {}) {
160
173
  /**
161
174
  * Build a per-step gate that caches its answer briefly.
162
175
  * @param {{
163
- * resolved: { scope: string, workspaces: string[], projectMarkers: string[] },
176
+ * resolved: { scope: string, workspaces: string[], projectMarkers: string[], exclude?: string[] },
164
177
  * directoryOf: (agent: unknown) => string | undefined,
165
178
  * fs?: { readdirSync: (dir: string) => readonly string[] },
166
179
  * ttlMs?: number,
@@ -178,7 +191,9 @@ export function createScopeGate(options) {
178
191
  scope: resolved.scope,
179
192
  describe: () => describeScope(resolved),
180
193
  admits(agent) {
181
- if (!resolved || resolved.scope === 'anywhere') return true
194
+ if (!resolved) return true
195
+ const excluded = Array.isArray(resolved.exclude) ? resolved.exclude.length : 0
196
+ if (resolved.scope === 'anywhere' && excluded === 0) return true
182
197
  let directory
183
198
  try {
184
199
  directory = directoryOf(agent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unreal-python-api",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
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
6
  "license": "MIT",
package/test/smoke.mjs CHANGED
@@ -155,7 +155,9 @@ for (const note of built.notes) console.log(` note: ${note}`)
155
155
  assert.equal(built.unresolved.length, 1, 'the invented symbol is reported, not written')
156
156
  assert.ok(built.unresolved[0].startsWith('unreal.Actor.get_actor_scale3d_nonexistent'), 'the invented symbol is named')
157
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')
158
+ assert.ok(built.code.includes('@tool_call'), 'tools are decorated with the UE 5.8 tool_call decorator')
159
+ assert.ok(built.code.includes('from toolset_registry import tool_call'), 'the generated import matches the shipped module')
160
+ assert.ok(built.code.includes('@tool_call') && !built.code.includes('@toolset_registry.tool_call'), 'no stale registry object decorator')
159
161
  assert.ok(built.code.includes('def read_actor_scale(actor: unreal.Actor) -> unreal.Vector:'), 'annotated signature emitted')
160
162
  assert.ok(built.code.includes('unreal.Actor.get_actor_scale3d https://'), 'verified symbol recorded with its page')
161
163
  assert.ok(built.code.includes('#unreal.Actor.get_actor_scale3d'), 'verified symbol deep-links to its anchor')
@@ -246,6 +248,37 @@ const broken = createScopeGate({
246
248
  assert.equal(broken.admits(agent), false, 'a failing directory lookup rejects instead of throwing')
247
249
  console.log(`scope: ${describeScope(projectScope)}`)
248
250
 
251
+ // --- exclusions: a named workspace is never offered the development tier -----
252
+ const excluded = resolveScope({ scope: 'anywhere', exclude: ['D:\\\\HOPRELAY'] })
253
+ assert.equal(inScope('D:\\\\HOPRELAY', excluded), false, 'an excluded root is not admitted even when scope is anywhere')
254
+ assert.equal(inScope('D:\\\\HOPRELAY\\\\Install', excluded), false, 'an excluded subdirectory is not admitted')
255
+ assert.equal(inScope(TDA, excluded), true, 'other workspaces are still admitted')
256
+ assert.equal(inScope('D:\\\\HOPRELAY2', excluded), true, 'a sibling sharing the prefix stays admitted')
257
+ assert.match(describeScope(excluded), /except D:\\\\HOPRELAY/, 'the prompt text names the exclusion')
258
+
259
+ const includedThenExcluded = resolveScope({
260
+ scope: 'workspaces',
261
+ workspaces: [TDA],
262
+ exclude: [join(TDA, 'Intermediate')],
263
+ })
264
+ assert.equal(inScope(join(TDA, 'Source'), includedThenExcluded), true, 'included paths stay admitted')
265
+ assert.equal(inScope(join(TDA, 'Intermediate'), includedThenExcluded), false, 'an exclusion inside an included root wins')
266
+
267
+ const projectExcluded = resolveScope({ scope: 'unreal-project', exclude: [projectRoot] })
268
+ assert.equal(inScope(nested, projectExcluded), false, 'an exclusion beats Unreal project detection')
269
+
270
+ const noStatGate = createScopeGate({
271
+ resolved: excluded,
272
+ directoryOf: () => 'D:\\\\HOPRELAY',
273
+ fs: {
274
+ readdirSync: () => {
275
+ throw new Error('must not list the disk')
276
+ },
277
+ },
278
+ })
279
+ assert.equal(noStatGate.admits(agent), false, 'an exclusion rejects without listing the disk')
280
+ assert.equal(describeScope(excluded), 'every workspace except D:\\\\HOPRELAY', 'the exclusion is described plainly')
281
+
249
282
  // --- the plugin module itself: exports and configuration defaults -------------
250
283
  // The module imports the host-provided '@deepseek-ai/*' packages, which are not
251
284
  // present on a bare checkout or in CI, so these checks run only where the harness
@@ -315,12 +348,19 @@ assert.equal(openContext.sections.length, 1, 'default scope registers one prompt
315
348
  const scopedContext = fakeContext((session) => (session.id === 'inside' ? join(TDA, 'Source') : 'D:\\elsewhere'))
316
349
  plugin.apply(scopedContext, plugin.Config({ scope: 'workspaces', workspaces: [TDA] }))
317
350
  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
351
+ const gated = scopedContext.registered.filter((entry) => typeof entry.options.when === 'function')
352
+ assert.equal(gated.length, 1, 'only the development tier is gated')
353
+ assert.equal(gated[0].definition.name, 'unreal_python_tool_builder', 'the development tier is the tool builder')
354
+ const general = scopedContext.registered
355
+ .filter((entry) => entry.options.when === undefined)
356
+ .map((entry) => entry.definition.name)
357
+ .sort()
358
+ assert.deepEqual(general, ['unreal_python_search', 'unreal_python_syntax', 'unreal_python_tools_list'], 'the general tier carries no condition')
359
+ const condition = gated[0].options.when
320
360
  assert.equal(await condition({ agent: { session: { id: 'inside' } } }), true, 'the condition admits the configured workspace')
321
361
  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')
362
+ assert.match(scopedContext.sections[0].text, /admitted only inside/, 'the prompt section says where the development tool applies')
363
+ console.log('apply(): general tier always on, development tier scoped: OK')
324
364
  }
325
365
 
326
366
  // --- every generated artifact must parse in its own language -------------------