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

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,81 @@
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
+ ## [25.11.0-beta.10] - 2026-09-03
9
+
10
+ ### Added
11
+ - `api-job-patterns.md` — documented a known ordering bug: creating a child job before writing a
12
+ pending dataset causes the child to inherit the stale dataset, leading to a destructive
13
+ file-move race at `sendTo*()`. `api-job.md`'s dataset/child-job entries now note which calls
14
+ are immediate vs. deferred.
15
+
16
+ ## [25.11.0-beta.9] - 2026-08-26
17
+
18
+ ### Added
19
+ - `package.json` now declares `"main": "dist/init.js"`. Deliberately no `"exports"` field, so
20
+ `switch-scripting-context/package.json` also stays reachable for consumers that need to read the
21
+ package's own version (e.g. to compare against a script's target Switch version).
22
+
23
+ ### Changed
24
+ - Package now publishes to the public npm registry instead of GitHub Packages.
25
+
26
+ ## [25.11.0-beta.8] - 2026-08-25
27
+
28
+ ### Removed
29
+ - `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.
30
+ - `snippets/switch.code-snippets` and `scripts/scrape_switch_docs.py` (unused internal tooling) removed from the repo.
31
+
32
+ ## [25.11.0-beta.7] - 2026-08-25
33
+
34
+ ### Added
35
+ - README — "Using this with your coding agent" usage guide.
36
+
37
+ ### Fixed
38
+ - `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.
39
+
40
+ ## [25.11.0-beta.6] - 2026-08-25
41
+
42
+ ### Added
43
+ - `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.
44
+
45
+ ## [25.11.0-beta.5] - 2026-08-25
46
+
47
+ ### Added
48
+ - `docs/switch-api/api-tooling.md` — `--generate-translations` command, `ScriptID` character constraint, macOS fallback binary path.
49
+
50
+ ### Fixed
51
+ Corrections found by live-testing `SwitchScriptTool` (create/pack/unpack/list/verbose) against `api-tooling.md`:
52
+ - 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.
53
+ - 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).
54
+ - Documented that `--unpack` strips `main.js`/`main.js.map` back out for a TypeScript-sourced package and prints `Type`/`Protection`/`Status` metadata.
55
+ - Clarified `--create` scaffolds into a new `<Path>/<ScriptID>/` subfolder, not into `<Path>` directly.
56
+
57
+ ## [25.11.0-beta.4] - 2026-08-25
58
+
59
+ ### Added
60
+ - `docs/switch-api/api-execution-environment.md` — process/concurrency model, state persistence across job invocations, unhandled-rejection behavior, npm/native module constraints.
61
+
62
+ ### Known issue
63
+ - `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.
64
+
65
+ ### Fixed
66
+ Corrections found by auditing the docs against the actual API/runtime source:
67
+ - `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.
68
+ - `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).
69
+ - `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.
70
+ - `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.
71
+ - `api-http.md` / `api-switch.md` — fixed the `httpRequestSubscribe` example to use a leading-slash path; documented the path-format validation and `httpRequestUnsubscribe` example.
72
+ - `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.
73
+ - `api-document-classes.md` — documented `XmlDocument.evaluate()`'s `object` return case, the `jdf` default-namespace prefix, and `ImageDocument.getICCProfile()`'s EXIF fallback.
74
+ - `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.
75
+
76
+ ## [25.11.0-beta.3] - 2026-08-25
77
+
78
+ ### Added
79
+ - `docs/switch-api/api-logging.md` — log level semantics, logging practice, `console.log` limitation.
80
+ - `docs/switch-api/api-property-editors.md` — "Common practices" section recommending editor chains by property kind.
81
+ - `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,151 @@
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 (included in this package) for what's changed between versions.
8
+
9
+ ## Usage
10
+
11
+ Run `init` in any Switch scripting project:
12
+
13
+ ```bash
14
+ npx @enfocussw/switch-scripting-context init
15
+ ```
16
+
17
+ Or as a dev dependency, to pin the docs version:
18
+
19
+ ```bash
20
+ npm install --save-dev "@enfocussw/switch-scripting-context@~25.11.0"
21
+ npx switch-scripting-context init
22
+ ```
23
+
24
+ Re-run after upgrading the package to refresh docs and AI config files.
25
+
26
+ ## Versioning
27
+
28
+ The package version tracks the Switch release its docs describe:
29
+
30
+ ```
31
+ 25.11.0
32
+ └─┬─┘ │
33
+ │ └── package revision for that Switch release
34
+ └────── Switch version (25.11)
35
+ ```
36
+
37
+ - `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.
38
+ - The next Switch release moves the first two numbers (e.g. Switch 27.07 → `27.7.0`). Note that semver forbids leading zeros, so `27.07` is published as `27.7`.
39
+ - **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.
40
+
41
+ ### Prereleases
42
+
43
+ Beta builds append a prerelease suffix — `25.11.0-beta.1`. These sort *below* `25.11.0`,
44
+ so the beta line precedes GA and leaves `25.11.0` free for the first published release.
45
+
46
+ ## What it does
47
+
48
+ 1. Copies the Switch API reference docs to `switch-docs/` in your project
49
+ 2. Generates AI config files for each tool (see below)
50
+ 3. Appends `switch-docs/` to `.gitignore`
51
+
52
+ ### Generated files
53
+
54
+ | Tool | File | How context is loaded |
55
+ |---|---|---|
56
+ | Claude Code / ClawCode | `CLAUDE.md` | `@switch-docs/switch-scripting.md` import — hub file routes to specific API docs on demand |
57
+ | GitHub Copilot | `.github/copilot-instructions.md` | `#file:` reference to hub |
58
+ | GitHub Copilot (scoped) | `.github/instructions/switch-scripting.instructions.md` | `applyTo: "**/*.ts"` — auto-attaches to every TypeScript file edit |
59
+ | Cursor | `.cursor/rules/switch-scripting.mdc` | Inline key rules + full API file path list |
60
+ | Codex CLI / OpenCode | `AGENTS.md` | Inline key rules + full API file path list |
61
+ | Gemini CLI | `GEMINI.md` | `@switch-docs/switch-scripting.md` import |
62
+ | Windsurf | `.windsurfrules` | Inline key rules + full API file path list |
63
+ | Zed | `.rules` | Inline key rules + full API file path list |
64
+ | Cline | `.clinerules` | Inline key rules + full API file path list |
65
+
66
+ 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.
67
+
68
+ ## Using this with your coding agent
69
+
70
+ Once `init` has run, just work normally — describe what you want in plain terms and prompt as you
71
+ usually would. Your agent picks up the Switch context automatically (via `@import` for Claude
72
+ Code/Gemini, or the inlined rules + file list for the others) whenever it's working in the project,
73
+ and pulls in the specific API doc it needs for the task at hand on its own. You don't need to know
74
+ the doc file names or tell it which one to read.
75
+
76
+ A few things this gets you without asking for them by name:
77
+ - Scaffolding a new entry point, handling a webhook, or reading/creating datasets and jobs — the
78
+ agent consults the matching API reference before writing the code.
79
+ - Diagnosing why a script isn't behaving as expected — the agent knows it can locate and query
80
+ Switch's own log database (`ServerLogs.db3`) rather than only re-reasoning about the code.
81
+ - Creating, packing, or deploying a script — the agent uses `SwitchScriptTool` with the documented
82
+ flags and behavior, rather than hand-rolling the steps.
83
+ - Editing the script's XML declaration — the agent follows the documented rules and knows which
84
+ properties (app path/license) are off-limits and left to SwitchScripter's GUI instead.
85
+
86
+ Re-run `init` after upgrading this package so the copied docs and generated config files catch up —
87
+ see CHANGELOG.md for what changed.
88
+
89
+ ## Options
90
+
91
+ ```
92
+ npx switch-scripting-context init [options]
93
+
94
+ --tools <list> Tools to configure. Default: all
95
+ IDs: claude, copilot, cursor, codex, gemini, windsurf, zed, cline
96
+ Aliases: opencode (→ codex), clawcode (→ claude)
97
+ --docs-dir <dir> Destination folder for docs. Default: switch-docs
98
+ --force Overwrite existing AI config files instead of merging
99
+ --dry-run Print what would happen without writing any files
100
+ ```
101
+
102
+ Examples:
103
+
104
+ ```bash
105
+ # Configure Claude Code and Copilot only
106
+ npx switch-scripting-context init --tools claude,copilot
107
+
108
+ # Configure for OpenCode (alias for codex)
109
+ npx switch-scripting-context init --tools opencode
110
+
111
+ # Configure Claude Code, Cursor, and Zed
112
+ npx switch-scripting-context init --tools claude,cursor,zed
113
+
114
+ # Preview without writing
115
+ npx switch-scripting-context init --dry-run
116
+
117
+ # Use a different docs folder name
118
+ npx switch-scripting-context init --docs-dir ai-context
119
+ ```
120
+
121
+ ## TypeScript types
122
+
123
+ This package does not bundle `@types/switch-scripting`. Add the type declarations to your project manually:
124
+
125
+ ```bash
126
+ npm install --save-dev "https://github.com/enfocus-switch/types-switch-scripting/archive/refs/tags/v24.1.1-final.tar.gz"
127
+ ```
128
+
129
+ ## Included docs
130
+
131
+ The `switch-docs/` folder contains:
132
+
133
+ - `switch-scripting.md` — master index with execution environment rules and "load when" routing table
134
+ - `switch-api/api-entry-points.md` — all entry point signatures and when each is called
135
+ - `switch-api/api-job.md` — `Job` class: routing, file access, child jobs, private data, datasets
136
+ - `switch-api/api-flow-element.md` — `FlowElement`: properties, connections, job creation, logging
137
+ - `switch-api/api-switch.md` — `Switch` global: global data, webhooks, abort, server utilities
138
+ - `switch-api/api-connection.md` — `Connection`: type, properties, file count
139
+ - `switch-api/api-http.md` — `HttpRequest` / `HttpResponse` and webhook pattern
140
+ - `switch-api/api-enums.md` — all enums with string values (`LogLevel`, `AccessLevel`, `Scope`, etc.)
141
+ - `switch-api/api-document-classes.md` — `PdfDocument`, `ImageDocument`, `XmlDocument`, `XmpDocument`
142
+ - `switch-api/api-script-declaration.md` — XML declaration reference
143
+ - `switch-api/api-script-structure.md` — script folder/package structure and manifest format
144
+ - `switch-api/api-tooling.md` — SwitchScriptTool commands, script folder vs package, build and deployment
145
+ - `switch-api/api-debugging.md` — enabling debug mode, debuggable entry points, VS Code attach
146
+ - `switch-api/api-logging.md` — log levels, when/what to log, `console.log` limitation, common gotchas
147
+ - `switch-api/api-logs-and-dataroot.md` — locating the application data root, querying `ServerLogs.db3` directly to diagnose a script
148
+ - `switch-api/api-vscode.md` — type declarations, tsconfig for TypeScript 6, ESLint rules
149
+ - `switch-api/api-property-editors.md` — property editor types and string return values
150
+ - `switch-api/api-job-patterns.md` — file access semantics, routing rules, child jobs, executor limits
151
+ - `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>;