@enfocussw/switch-scripting-context 25.11.0-beta.8

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 ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are documented here. Format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+ - `package.json` now declares `"main": "dist/init.js"`. Deliberately no `"exports"` field, so
10
+ `switch-scripting-context/package.json` also stays reachable for consumers that need to read the
11
+ package's own version (e.g. to compare against a script's target Switch version).
12
+
13
+ ## [25.11.0-beta.8] - 2026-08-25
14
+
15
+ ### Removed
16
+ - `init` no longer copies `.vscode/switch.code-snippets` (or removes it on `remove`) — Switch script folders already come with these snippets via `SwitchScriptTool --create`, so this package's own copy was redundant.
17
+ - `snippets/switch.code-snippets` and `scripts/scrape_switch_docs.py` (unused internal tooling) removed from the repo.
18
+
19
+ ## [25.11.0-beta.7] - 2026-08-25
20
+
21
+ ### Added
22
+ - README — "Using this with your coding agent" usage guide.
23
+
24
+ ### Fixed
25
+ - `switch-scripting.md`'s routing table and the two hardcoded doc-list arrays in `src/init.ts` (used for Cursor's rules and the shared inline block for Codex/Windsurf/Zed/Cline) were missing `api-execution-environment.md`, `api-logging.md`, and `api-logs-and-dataroot.md` — those three docs were copied to `switch-docs/` but never referenced in 5 of the 8 tools' generated config, making them undiscoverable.
26
+
27
+ ## [25.11.0-beta.6] - 2026-08-25
28
+
29
+ ### Added
30
+ - `docs/switch-api/api-logs-and-dataroot.md` — locating the Application Data Root, querying `ServerLogs.db3` directly (schema, `%N` placeholder reconstruction, retention, and the debug-level logging gate) to diagnose or validate a script from its actual log output.
31
+
32
+ ## [25.11.0-beta.5] - 2026-08-25
33
+
34
+ ### Added
35
+ - `docs/switch-api/api-tooling.md` — `--generate-translations` command, `ScriptID` character constraint, macOS fallback binary path.
36
+
37
+ ### Fixed
38
+ Corrections found by live-testing `SwitchScriptTool` (create/pack/unpack/list/verbose) against `api-tooling.md`:
39
+ - Clarified `--transpile` is only needed for testing a script folder in Switch, not before packing — `--pack` always transpiles `main.ts` fresh and never touches an existing `main.js` in the source folder.
40
+ - Documented that `--pack` always excludes `package.json`/`.vscode/` from the package, and strengthened the `npm prune --production` advice with the concrete reason (unpruned `devDependencies`, especially `@types/*`, get bundled for no runtime benefit).
41
+ - Documented that `--unpack` strips `main.js`/`main.js.map` back out for a TypeScript-sourced package and prints `Type`/`Protection`/`Status` metadata.
42
+ - Clarified `--create` scaffolds into a new `<Path>/<ScriptID>/` subfolder, not into `<Path>` directly.
43
+
44
+ ## [25.11.0-beta.4] - 2026-08-25
45
+
46
+ ### Added
47
+ - `docs/switch-api/api-execution-environment.md` — process/concurrency model, state persistence across job invocations, unhandled-rejection behavior, npm/native module constraints.
48
+
49
+ ### Known issue
50
+ - `docs/switch-api/api-document-classes.md` — flagged that `PdfPage.getArtBoxHeight`/`getArtBoxWidth` (and the `PdfDocument` static equivalents) currently return the crop box value instead of the art box, due to a bug on the Switch side.
51
+
52
+ ### Fixed
53
+ Corrections found by auditing the docs against the actual API/runtime source:
54
+ - `api-execution-environment.md` — corrected the concurrency model: `NumberOfSlots`/`ExecutionGroup` gate job dispatch on the Switch Server per flow-element instance (or via a cross-element named lock for `Serialized` mode); they do not map to a dedicated Node.js OS process per slot. The executor process pool is sized independently and reused across jobs/elements.
55
+ - `api-connection.md` — `getFileCount`'s `nested` parameter is optional (defaults to `true`), not required. Tightened `getId()`'s stability description (renaming the flow is safe; renaming the flow element is not).
56
+ - `api-job.md` — `processLater`'s `seconds` parameter is optional (defaults to `300`). `sendToChannel` throws synchronously on no-subscriber/empty args rather than failing the job. Documented that `getPrivateData`/`listDatasets`/`getDataset` throw on jobs from `getJobs()`, while `setPrivateData`/`removePrivateData` are not restricted. Documented that `getxmlData`/`getxmpData`/`getJdfData`/`getJSONData` resolve to `undefined` on error rather than throwing.
57
+ - `api-flow-element.md` — `createPathWithName`'s `createFolder` parameter is required, not optional; corrected its return-value description (empty string only on a caught exception, not because the path already exists). `getFileCount`'s `nested` parameter is optional (defaults to `true`). Documented `failProcess`'s and `getJobs`'s throw conditions. Corrected `createJob`'s supported entry points (`jobArrived`/`timerFired` only). Documented `getPluginResourcesPath`'s local-only `.sscript` behavior and throw case.
58
+ - `api-http.md` / `api-switch.md` — fixed the `httpRequestSubscribe` example to use a leading-slash path; documented the path-format validation and `httpRequestUnsubscribe` example.
59
+ - `api-switch.md` — `getGlobalData` returns `''` for a missing tag, not `undefined`; documented the 100-call advisory warning. Documented `getPreferenceSetting`'s field redaction and JSON-stringify behavior, and `getServerVersion`'s `major + minor/100` numeric format.
60
+ - `api-document-classes.md` — documented `XmlDocument.evaluate()`'s `object` return case, the `jdf` default-namespace prefix, and `ImageDocument.getICCProfile()`'s EXIF fallback.
61
+ - `api-property-editors.md` / `api-script-declaration.md` — corrected `getPropertyType()`'s description (returns one of several `PropertyType` values, not a literal-vs-user-entered flag) and noted the XML `Type` vocabulary doesn't map one-to-one onto the runtime `PropertyType` enum.
62
+
63
+ ## [25.11.0-beta.3] - 2026-08-25
64
+
65
+ ### Added
66
+ - `docs/switch-api/api-logging.md` — log level semantics, logging practice, `console.log` limitation.
67
+ - `docs/switch-api/api-property-editors.md` — "Common practices" section recommending editor chains by property kind.
68
+ - `docs/switch-api/api-script-declaration.md` — clarified that `ApplicationPath`/`ApplicationLicense` are app-only properties set by the user via the Switch Scripter GUI after packing, not by editing the declaration file.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # switch-scripting-context
2
+
3
+ AI coding assistant context for [Enfocus Switch](https://www.enfocus.com/en/switch) scripting projects (Node.js/TypeScript).
4
+
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
+
7
+ See [CHANGELOG.md](CHANGELOG.md) for what's changed between versions.
8
+
9
+ ## Usage
10
+
11
+ > **Private beta.** This package is not on npm yet. Beta testers install from a
12
+ > tarball supplied directly; the npm commands below apply once it is published.
13
+
14
+ Install the tarball you were given, then run `init` in any Switch scripting project:
15
+
16
+ ```bash
17
+ npm install --save-dev ./enfocussw-switch-scripting-context-25.11.0-beta.1.tgz
18
+ npx switch-scripting-context init
19
+ ```
20
+
21
+ After publication, install straight from npm instead:
22
+
23
+ ```bash
24
+ npx @enfocussw/switch-scripting-context init
25
+ ```
26
+
27
+ Or as a dev dependency, to pin the docs version:
28
+
29
+ ```bash
30
+ npm install --save-dev "@enfocussw/switch-scripting-context@~25.11.0"
31
+ npx switch-scripting-context init
32
+ ```
33
+
34
+ Re-run after upgrading the package to refresh docs and AI config files.
35
+
36
+ ## Versioning
37
+
38
+ The package version tracks the Switch release its docs describe:
39
+
40
+ ```
41
+ 25.11.0
42
+ └─┬─┘ │
43
+ │ └── package revision for that Switch release
44
+ └────── Switch version (25.11)
45
+ ```
46
+
47
+ - `25.11.x` — every release of this package documenting **Switch 25.11**. Patch increments are doc updates, fixes, and new features of the CLI itself.
48
+ - The next Switch release moves the first two numbers (e.g. Switch 26.05 → `26.5.0`). Note that semver forbids leading zeros, so `26.05` is published as `26.5`.
49
+ - **Pin with `~`, not `^`.** `~25.11.0` stays on Switch 25.11; `^25.11.0` would happily install `25.12.0`, which targets a different Switch release.
50
+
51
+ ### Prereleases
52
+
53
+ Beta builds append a prerelease suffix — `25.11.0-beta.1`. These sort *below* `25.11.0`,
54
+ so the beta line precedes GA and leaves `25.11.0` free for the first published release.
55
+ During the beta these are distributed as tarballs rather than published, so the suffix is
56
+ purely a label telling testers which build they have.
57
+
58
+ ## What it does
59
+
60
+ 1. Copies the Switch API reference docs to `switch-docs/` in your project
61
+ 2. Generates AI config files for each tool (see below)
62
+ 3. Appends `switch-docs/` to `.gitignore`
63
+
64
+ ### Generated files
65
+
66
+ | Tool | File | How context is loaded |
67
+ |---|---|---|
68
+ | Claude Code / ClawCode | `CLAUDE.md` | `@switch-docs/switch-scripting.md` import — hub file routes to specific API docs on demand |
69
+ | GitHub Copilot | `.github/copilot-instructions.md` | `#file:` reference to hub |
70
+ | GitHub Copilot (scoped) | `.github/instructions/switch-scripting.instructions.md` | `applyTo: "**/*.ts"` — auto-attaches to every TypeScript file edit |
71
+ | Cursor | `.cursor/rules/switch-scripting.mdc` | Inline key rules + full API file path list |
72
+ | Codex CLI / OpenCode | `AGENTS.md` | Inline key rules + full API file path list |
73
+ | Gemini CLI | `GEMINI.md` | `@switch-docs/switch-scripting.md` import |
74
+ | Windsurf | `.windsurfrules` | Inline key rules + full API file path list |
75
+ | Zed | `.rules` | Inline key rules + full API file path list |
76
+ | Cline | `.clinerules` | Inline key rules + full API file path list |
77
+
78
+ All files use `<!-- switch-scripting-context begin -->` / `<!-- switch-scripting-context end -->` markers. Re-running `init` replaces only the Switch section in existing files — project-specific rules outside the markers are untouched.
79
+
80
+ ## Using this with your coding agent
81
+
82
+ Once `init` has run, just work normally — describe what you want in plain terms and prompt as you
83
+ usually would. Your agent picks up the Switch context automatically (via `@import` for Claude
84
+ Code/Gemini, or the inlined rules + file list for the others) whenever it's working in the project,
85
+ and pulls in the specific API doc it needs for the task at hand on its own. You don't need to know
86
+ the doc file names or tell it which one to read.
87
+
88
+ A few things this gets you without asking for them by name:
89
+ - Scaffolding a new entry point, handling a webhook, or reading/creating datasets and jobs — the
90
+ agent consults the matching API reference before writing the code.
91
+ - Diagnosing why a script isn't behaving as expected — the agent knows it can locate and query
92
+ Switch's own log database (`ServerLogs.db3`) rather than only re-reasoning about the code.
93
+ - Creating, packing, or deploying a script — the agent uses `SwitchScriptTool` with the documented
94
+ flags and behavior, rather than hand-rolling the steps.
95
+ - Editing the script's XML declaration — the agent follows the documented rules and knows which
96
+ properties (app path/license) are off-limits and left to SwitchScripter's GUI instead.
97
+
98
+ Re-run `init` after upgrading this package so the copied docs and generated config files catch up —
99
+ see [CHANGELOG.md](CHANGELOG.md) for what changed.
100
+
101
+ ## Options
102
+
103
+ ```
104
+ npx switch-scripting-context init [options]
105
+
106
+ --tools <list> Tools to configure. Default: all
107
+ IDs: claude, copilot, cursor, codex, gemini, windsurf, zed, cline
108
+ Aliases: opencode (→ codex), clawcode (→ claude)
109
+ --docs-dir <dir> Destination folder for docs. Default: switch-docs
110
+ --force Overwrite existing AI config files instead of merging
111
+ --dry-run Print what would happen without writing any files
112
+ ```
113
+
114
+ Examples:
115
+
116
+ ```bash
117
+ # Configure Claude Code and Copilot only
118
+ npx switch-scripting-context init --tools claude,copilot
119
+
120
+ # Configure for OpenCode (alias for codex)
121
+ npx switch-scripting-context init --tools opencode
122
+
123
+ # Configure Claude Code, Cursor, and Zed
124
+ npx switch-scripting-context init --tools claude,cursor,zed
125
+
126
+ # Preview without writing
127
+ npx switch-scripting-context init --dry-run
128
+
129
+ # Use a different docs folder name
130
+ npx switch-scripting-context init --docs-dir ai-context
131
+ ```
132
+
133
+ ## TypeScript types
134
+
135
+ This package does not bundle `@types/switch-scripting`. Add the type declarations to your project manually:
136
+
137
+ ```bash
138
+ npm install --save-dev "https://github.com/enfocus-switch/types-switch-scripting/archive/refs/tags/v24.1.1-final.tar.gz"
139
+ ```
140
+
141
+ ## Included docs
142
+
143
+ The `switch-docs/` folder contains:
144
+
145
+ - `switch-scripting.md` — master index with execution environment rules and "load when" routing table
146
+ - `switch-api/api-entry-points.md` — all entry point signatures and when each is called
147
+ - `switch-api/api-job.md` — `Job` class: routing, file access, child jobs, private data, datasets
148
+ - `switch-api/api-flow-element.md` — `FlowElement`: properties, connections, job creation, logging
149
+ - `switch-api/api-switch.md` — `Switch` global: global data, webhooks, abort, server utilities
150
+ - `switch-api/api-connection.md` — `Connection`: type, properties, file count
151
+ - `switch-api/api-http.md` — `HttpRequest` / `HttpResponse` and webhook pattern
152
+ - `switch-api/api-enums.md` — all enums with string values (`LogLevel`, `AccessLevel`, `Scope`, etc.)
153
+ - `switch-api/api-document-classes.md` — `PdfDocument`, `ImageDocument`, `XmlDocument`, `XmpDocument`
154
+ - `switch-api/api-script-declaration.md` — XML declaration reference
155
+ - `switch-api/api-script-structure.md` — script folder/package structure and manifest format
156
+ - `switch-api/api-tooling.md` — SwitchScriptTool commands, script folder vs package, build and deployment
157
+ - `switch-api/api-debugging.md` — enabling debug mode, debuggable entry points, VS Code attach
158
+ - `switch-api/api-logging.md` — log levels, when/what to log, `console.log` limitation, common gotchas
159
+ - `switch-api/api-logs-and-dataroot.md` — locating the application data root, querying `ServerLogs.db3` directly to diagnose a script
160
+ - `switch-api/api-vscode.md` — type declarations, tsconfig for TypeScript 6, ESLint rules
161
+ - `switch-api/api-property-editors.md` — property editor types and string return values
162
+ - `switch-api/api-job-patterns.md` — file access semantics, routing rules, child jobs, executor limits
163
+ - `switch-api/api-execution-environment.md` — process model, state persistence across jobs, error handling, npm/native module constraints
package/bin/cli.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { run } = require('../dist/init.js');
5
+ run().catch(err => {
6
+ console.error(err);
7
+ process.exit(1);
8
+ });
package/dist/init.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export interface ToolFile {
2
+ targetPath: (root: string, docsDir: string) => string;
3
+ generate: (docsDir: string) => string;
4
+ }
5
+ export interface ToolDefinition {
6
+ id: string;
7
+ label: string;
8
+ aliases?: string[];
9
+ altIds?: string[];
10
+ files: ToolFile[];
11
+ }
12
+ export declare function generateAgentsMd(docsDir: string): string;
13
+ export declare function generateGeminiMd(docsDir: string): string;
14
+ export declare function generateWindsurfRules(docsDir: string): string;
15
+ export declare function generateZedRules(docsDir: string): string;
16
+ export declare function generateClineRules(docsDir: string): string;
17
+ export declare function buildIdMap(registry: ToolDefinition[]): Map<string, string>;
18
+ export declare function findMarkerRange(content: string): [number, number] | null;
19
+ export declare function run(argv?: string[]): Promise<void>;