dsh-unreal-python-api 1.2.0 → 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,28 @@
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
+
3
26
  ## 1.2.0 — 2026-11-30
4
27
 
5
28
  - Split the tools into two tiers. **general** — `unreal_python_tools_list`,
package/README.md CHANGED
@@ -131,6 +131,7 @@ locale/, icon.svg Host display metadata
131
131
  | `promptSection` | `true` | Register the system-prompt section. |
132
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
137
  ### Two tiers, and workspace scoping
@@ -150,6 +151,23 @@ One profile install serves every workspace, so the tools come in two tiers:
150
151
  | `unreal-project` | the session's working directory, or a parent, holds a `*.uproject` |
151
152
  | `workspaces` | the working directory is inside one of the `workspaces` roots |
152
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
+
153
171
  ```yaml
154
172
  # the dsh-unreal-python-api row's config (profile cordis.patch.yml, or the
155
173
  # plugin's settings panel in the GUI when it offers one)
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
@@ -68,6 +68,7 @@ grounded starting point, not finished code.
68
68
  | `promptSection` | `true` | Adds one line to the system prompt naming the tools and the documentation root. |
69
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
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,
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.2.0",
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