@enfocussw/switch-scripting-context 25.11.1-beta.1 → 25.11.1-beta.2

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
@@ -5,6 +5,24 @@ All notable changes to this package are documented here. Format follows
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [25.11.1-beta.2] - 2026-09-17
9
+
10
+ ### Added
11
+
12
+ - Planning now has agents check whether a design needs more than one flow element, and propose
13
+ one script folder per element before creating files. The script structure docs describe laying
14
+ out several script folders side by side, and creating them without deleting the folder you
15
+ work in.
16
+
17
+ ### Fixed
18
+
19
+ - The tooling docs now warn that `SwitchScriptTool --create` deletes an existing target folder
20
+ and everything in it, including git history, without asking. Agents are told to check that the
21
+ target doesn't exist first.
22
+ - The tooling docs now list the files `--pack` actually includes. Pack copies a fixed set of files,
23
+ not the whole folder, so a script that imports a local module fails to pack. Before, the docs
24
+ said pack only left out the npm manifest and VS Code settings.
25
+
8
26
  ## [25.11.1-beta.1] - 2026-09-17
9
27
 
10
28
  ### Added
package/README.md CHANGED
@@ -4,7 +4,7 @@ AI coding assistant context for [Enfocus Switch](https://www.enfocus.com/en/swit
4
4
 
5
5
  Installs curated API reference docs and generates config files for 8 AI coding agents (Claude Code, GitHub Copilot, Cursor, Codex CLI/OpenCode, Gemini CLI, Windsurf, Zed, and Cline) so AI assistants understand the Switch scripting API out of the box.
6
6
 
7
- See [CHANGELOG.md](https://cdn.jsdelivr.net/npm/@enfocussw/switch-scripting-context@25.11.1-beta.1/CHANGELOG.md) (also included in this package) for what's changed between versions.
7
+ See [CHANGELOG.md](https://cdn.jsdelivr.net/npm/@enfocussw/switch-scripting-context@25.11.1-beta.2/CHANGELOG.md) (also included in this package) for what's changed between versions.
8
8
 
9
9
  ## Usage
10
10
 
@@ -84,7 +84,7 @@ A few things this gets you without asking for them by name:
84
84
  properties (app path/licence) are off-limits and left to SwitchScripter's GUI instead.
85
85
 
86
86
  Re-run `init` after upgrading this package so the copied docs and generated config files catch up.
87
- See [CHANGELOG.md](https://cdn.jsdelivr.net/npm/@enfocussw/switch-scripting-context@25.11.1-beta.1/CHANGELOG.md) for what changed.
87
+ See [CHANGELOG.md](https://cdn.jsdelivr.net/npm/@enfocussw/switch-scripting-context@25.11.1-beta.2/CHANGELOG.md) for what changed.
88
88
 
89
89
  ## Options
90
90
 
@@ -147,7 +147,7 @@ The `switch-docs/` folder contains:
147
147
 
148
148
  - `switch-scripting.md`: master index with execution environment rules and "load when" routing table
149
149
  <!-- docs-index:readme begin -->
150
- - `switch-project/project-planning.md`: Pre-scaffolding checklist: Script vs App, job-processing approach, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk
150
+ - `switch-project/project-planning.md`: Pre-scaffolding checklist: Script vs App, job-processing approach, one script folder or several, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk
151
151
  - `switch-api/entry-points.md`: All entry point signatures, constraints, and when each is called
152
152
  - `switch-api/switch.md`: `Switch` (`s`): global data, webhooks, abort, server utilities
153
153
  - `switch-api/flow-element.md`: `FlowElement`: properties, connections, job creation, logging
@@ -156,7 +156,7 @@ The `switch-docs/` folder contains:
156
156
  - `switch-api/http.md`: `HttpRequest` / `HttpResponse` + webhook pattern
157
157
  - `switch-api/enums.md`: All enums with string values (`LogLevel`, `AccessLevel`, `DatasetModel`, `Scope`, `Priority`, `Connection.Level`, etc.)
158
158
  - `switch-api/document-classes.md`: `PdfDocument`, `PdfPage`, `ImageDocument`, `XmlDocument`, `XmpDocument`: read-only file introspection
159
- - `switch-project/script-structure.md`: What files a script folder contains, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App
159
+ - `switch-project/script-structure.md`: What files a script folder contains, laying out several script folders side by side, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App
160
160
  - `switch-project/tooling.md`: SwitchScriptTool commands and install paths, folder vs `.sscript` trade-offs, deployment
161
161
  - `switch-project/debugging.md`: Enabling debug mode in Switch Designer, debuggable entry points, VS Code attach
162
162
  - `switch-project/vscode.md`: Type declarations, tsconfig for TypeScript 6, ESLint rules
@@ -2,7 +2,7 @@
2
2
  id: project-planning
3
3
  category: switch-project
4
4
  order: 1
5
- summary: "Pre-scaffolding checklist: Script vs App, job-processing approach, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk"
5
+ summary: "Pre-scaffolding checklist: Script vs App, job-processing approach, one script folder or several, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk"
6
6
  triggers:
7
7
  - "Starting a new script or app, before scaffolding any files"
8
8
  ---
@@ -58,6 +58,18 @@ an already-registered job quickly, or a large backlog is slow to clear, see
58
58
 
59
59
  ## Evaluate and flag, don't ask upfront
60
60
 
61
+ ### One script folder or several
62
+
63
+ One script folder produces one flow element. Once the job-processing design from question 2 is
64
+ clear, check whether it needs more than one flow element: distinct steps a flow builder should
65
+ place and configure as separate elements, or several related apps meant to ship as an app bundle.
66
+ Most designs need one, so don't ask about this upfront.
67
+
68
+ If the design needs several, propose the split before creating any files: the Script ID and
69
+ purpose of each script folder and, for apps, whether they form an app bundle. Wait for the user to
70
+ confirm. Then lay them out and create them as described in
71
+ [script-structure.md § Several script folders side by side](script-structure.md#several-script-folders-side-by-side).
72
+
61
73
  ### Target OS
62
74
 
63
75
  Switch Server runs on Windows and macOS. Default to writing platform-independent code (the `path`
@@ -2,7 +2,7 @@
2
2
  id: script-structure
3
3
  category: switch-project
4
4
  order: 10
5
- summary: "What files a script folder contains, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App"
5
+ summary: "What files a script folder contains, laying out several script folders side by side, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App"
6
6
  triggers:
7
7
  - "Setting up a new script project, converting a Script to an App, or working out which Node.js version a script or app will run on"
8
8
  ---
@@ -33,6 +33,31 @@ A Switch script project lives in a **script folder** during development and is d
33
33
 
34
34
  > After editing `main.ts`, transpile with SwitchScriptTool to regenerate `main.js` before testing in Switch.
35
35
 
36
+ ## Several script folders side by side
37
+
38
+ One script folder produces one flow element. A design that needs several flow elements, such as
39
+ the apps in an app bundle, needs one script folder per element. Keep them in one parent folder, a
40
+ **script collection**:
41
+
42
+ ```
43
+ my-collection/ the folder the user works in; AI agent config and docs live here
44
+ ├── FirstElement/ script folder (manifest.xml, FirstElement.xml, main.ts, ...)
45
+ └── SecondElement/ script folder
46
+ ```
47
+
48
+ - Put each script folder directly under the collection, one level down. Don't nest a script folder
49
+ inside another script folder, and don't add grouping folders in between.
50
+ - Create each one with `SwitchScriptTool --create <ScriptID> <CollectionFolder>`. First check that
51
+ `<CollectionFolder>/<ScriptID>/` doesn't exist: `--create` deletes an existing target folder and
52
+ everything in it without asking.
53
+ - Never use `--create` to turn the collection folder itself into a script folder
54
+ (`--create <CollectionFolderName> <ParentFolder>`). That deletes the whole collection, including
55
+ `.git/` and AI agent config. If the user wants a script folder at the top level of the folder
56
+ they work in, or wants an existing top-level script folder moved down into a subfolder, stop and
57
+ leave that step to the user.
58
+ - Each script folder keeps its own `package.json`, `node_modules/` and `tsconfig.json`. Run npm,
59
+ transpile and pack per script folder.
60
+
36
61
  ## manifest.xml format
37
62
 
38
63
  ```xml
@@ -36,16 +36,24 @@ location for the current OS if the bare command isn't found.
36
36
  |---|---|---|
37
37
  | Create | `SwitchScriptTool --create <ScriptID> <Path> [--JavaScript]` | Scaffold a new script folder with all required files |
38
38
  | Transpile | `SwitchScriptTool --transpile <Path>` | Compile `main.ts` → `main.js`. **Must use this, not `tsc` directly** |
39
- | Pack | `SwitchScriptTool --pack <Folder> <Output> [--password <pwd>] [--verbose]` | Create `.sscript` package for deployment |
39
+ | Pack | `SwitchScriptTool --pack <Folder> <OutputFolder> [--password <pwd>] [--verbose]` | Create `<OutputFolder>/<ScriptID>.sscript` for deployment. `<OutputFolder>` is a directory, created if missing, not the package's file path |
40
40
  | Unpack | `SwitchScriptTool --unpack <file.sscript> <Folder> [--password <pwd>]` | Extract package to folder |
41
41
  | List | `SwitchScriptTool --list <file.sscript>` | List package contents (no password needed) |
42
42
  | Generate translations | `SwitchScriptTool --generate-translations <ScriptFolder> <ResultFolder>` | Generate translation files for the script package |
43
43
 
44
44
  **Create** scaffolds: `manifest.xml`, `<ScriptID>.xml`, `<ScriptID>.sscript`, `main.ts` (or `main.js` with `--JavaScript`), `.vscode/launch.json`, `Resources/`, plus `package.json`, `tsconfig.json`, `.vscode/switch.code-snippets`, and type declarations for TypeScript. Creates `<Path>/<ScriptID>/` — it does not write into `<Path>` directly. `ScriptID` may only contain letters, digits, hyphens, and underscores.
45
45
 
46
+ **Gotcha: `--create` deletes an existing target folder.** If `<Path>/<ScriptID>/` already exists, `--create` removes it and everything in it (including `.git/`, a README, or AI agent config files) without prompting, then scaffolds a fresh folder. The only sign is an `Info: Removed existing target folder` line in its output. Never run `--create` where `<Path>/<ScriptID>/` exists, and never use it to turn the folder you're already working in into a script folder: `--create <FolderName> <ParentOfFolder>` wipes that folder. Check that the target doesn't exist first.
47
+
46
48
  **Transpile** is required after every edit to `main.ts` before testing a **script folder** directly in Switch. Switch executes `main.js` only — `main.ts` is never run directly. Using SwitchScriptTool (not `tsc`) ensures the same transpile options as SwitchScripter, which is required for consistent behavior. This step is **not** needed before packing — see Pack below.
47
49
 
48
- **Pack** transpiles `main.ts` fresh into the package on every run; it never reads or modifies any `main.js` already sitting in the source folder (a stale hand-edited `main.js` there is ignored and left untouched — see the excluded-files note below). It always excludes `package.json` and `.vscode/` from the packed output, printed as an "Info: will not be packed" list even without `--verbose`; `--verbose` additionally prints the full list of what *will* be packed. `node_modules` is packed as-is, so run `npm prune --production` first (see Deployment) — otherwise `devDependencies` (including `@types/*` packages, which the scaffolded `package.json` puts there) get bundled into the package for no runtime benefit. One harmless quirk: the placeholder `<ScriptID>.sscript` file scaffolded by `--create` is not excluded and ends up packed inside the real `.sscript` too. Pack also replaces `SwitchVersion` in the packed `manifest.xml` with SwitchScriptTool's own version (`--create` writes it too), and that value picks the Node.js version the package runs on. See [script-structure.md § What writes `SwitchVersion`](script-structure.md#what-writes-switchversion).
50
+ **Pack** transpiles `main.ts` fresh into the package on every run; it never reads or modifies any `main.js` already sitting in the source folder (a stale hand-edited `main.js` there is ignored and left untouched).
51
+
52
+ Pack copies an allowlist of files, not the whole folder. Only these end up in the `.sscript`: `manifest.xml`, the declaration file named in `ScriptDeclarationFile`, the program file named in `ScriptProgramFiles` plus the `main.js` and `main.js.map` pack transpiles from it, the icon named in `ScriptIconFile`, `tsconfig.json`, the placeholder `<ScriptID>.sscript`, `Resources/`, and `node_modules/`. Everything else in the folder is left out and printed in an "Info: ... will not be packed" list, even without `--verbose`. That includes `package.json`, `package-lock.json`, `.vscode/`, a README, other `.ts`/`.js` files, subfolders other than `Resources/` and `node_modules/`, and AI agent config and docs folders. `--verbose` additionally prints the full list of what *will* be packed. Translation files were not part of this test. Verified with SwitchScriptTool 26.07.
53
+
54
+ `node_modules` is packed as-is, so run `npm prune --production` first (see Deployment) — otherwise `devDependencies` (including `@types/*` packages, which the scaffolded `package.json` puts there) get bundled into the package for no runtime benefit. One harmless quirk: the placeholder `<ScriptID>.sscript` file scaffolded by `--create` is on the allowlist and ends up packed inside the real `.sscript` too. Pack also replaces `SwitchVersion` in the packed `manifest.xml` with SwitchScriptTool's own version (`--create` writes it too), and that value picks the Node.js version the package runs on. See [script-structure.md § What writes `SwitchVersion`](script-structure.md#what-writes-switchversion).
55
+
56
+ **Gotcha: local modules break pack.** A `main.ts` that imports a local module (`import { x } from './helper'` or `'./lib/helper'`) fails to pack with TypeScript error TS2307 (`Cannot find module`), and no `.sscript` is written. Pack's own output shows why: `helper.ts` and `lib/helper.ts` appear in its "will not be packed" list, and the TS2307 error points at pack's temporary copy of the folder, which doesn't contain them. A `main.js` that `require`s a local file was not tested, but that file isn't packed either. The manifest also accepts only one `ScriptProgramFile` (pack errors with `The manifest must contain only one script program file`), so listing the helper there doesn't work. The verified option is to keep script code in the single program file. Shared code in an npm package under `node_modules/` might work, since `node_modules/` is packed, but that was not tested, and neither was a `file:` dependency, which npm installs as a symlink.
49
57
 
50
58
  **Unpack** prints package metadata (`Type`, `Protection`, `Status`) before extracting. For a TypeScript-sourced package it extracts only `main.ts` — the compiled `main.js`/`main.js.map` are not written back out, so a pack → unpack round trip returns a clean, editable script folder rather than a compiled snapshot.
51
59
 
@@ -15,7 +15,7 @@ publishing guidance).
15
15
  <!-- docs-index:table begin -->
16
16
  | File | Contents | Load when |
17
17
  |---|---|---|
18
- | `switch-project/project-planning.md` | Pre-scaffolding checklist: Script vs App, job-processing approach, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk | Starting a new script or app, before scaffolding any files |
18
+ | `switch-project/project-planning.md` | Pre-scaffolding checklist: Script vs App, job-processing approach, one script folder or several, target OS, Switch version baseline, concurrency, native/binary npm dependencies, Appstore competition risk | Starting a new script or app, before scaffolding any files |
19
19
  | `switch-api/entry-points.md` | All entry point signatures, constraints, and when each is called | Scaffolding a script, adding/editing an entry point, or making any edit to main.ts/main.js |
20
20
  | `switch-api/switch.md` | `Switch` (`s`): global data, webhooks, abort, server utilities | Using global data, webhooks, abort, or server settings |
21
21
  | `switch-api/flow-element.md` | `FlowElement`: properties, connections, job creation, logging | Reading properties, creating jobs, logging, connections |
@@ -24,7 +24,7 @@ publishing guidance).
24
24
  | `switch-api/http.md` | `HttpRequest` / `HttpResponse` + webhook pattern | Handling incoming HTTP webhooks |
25
25
  | `switch-api/enums.md` | All enums with string values (`LogLevel`, `AccessLevel`, `DatasetModel`, `Scope`, `Priority`, `Connection.Level`, etc.) | Looking up enum values |
26
26
  | `switch-api/document-classes.md` | `PdfDocument`, `PdfPage`, `ImageDocument`, `XmlDocument`, `XmpDocument`: read-only file introspection | Inspecting PDF, image, XML, or XMP file contents |
27
- | `switch-project/script-structure.md` | What files a script folder contains, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App | Setting up a new script project, converting a Script to an App, or working out which Node.js version a script or app will run on |
27
+ | `switch-project/script-structure.md` | What files a script folder contains, laying out several script folders side by side, `manifest.xml` format, how `SwitchVersion` selects the Node.js version and which tools overwrite it, Script vs App | Setting up a new script project, converting a Script to an App, or working out which Node.js version a script or app will run on |
28
28
  | `switch-project/tooling.md` | SwitchScriptTool commands and install paths, folder vs `.sscript` trade-offs, deployment | Running SwitchScriptTool: transpiling, packing, unpacking, or deploying |
29
29
  | `switch-project/debugging.md` | Enabling debug mode in Switch Designer, debuggable entry points, VS Code attach | Debugging a script |
30
30
  | `switch-project/vscode.md` | Type declarations, tsconfig for TypeScript 6, ESLint rules | Setting up VS Code or fixing type errors |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enfocussw/switch-scripting-context",
3
- "version": "25.11.1-beta.1",
3
+ "version": "25.11.1-beta.2",
4
4
  "description": "AI coding assistant context for Enfocus Switch scripting (Node.js/TypeScript)",
5
5
  "keywords": [
6
6
  "switch",