@enfocussw/switch-scripting-context 25.11.1-beta.0 → 25.11.1-beta.1
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 +15 -0
- package/README.md +17 -2
- package/dist/init.js +53 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this package are documented here. Format follows
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [25.11.1-beta.1] - 2026-09-17
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `remove --tools <list>` removes the Switch section only from the named tools' AI config files.
|
|
13
|
+
The docs folder, the `.gitignore` entry and other tools' config stay in place. Without
|
|
14
|
+
`--tools`, or with every tool listed, `remove` still removes everything.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `remove` now deletes the Cursor rule file and the scoped GitHub Copilot instructions file,
|
|
19
|
+
plus their folders if nothing else is in them. Before, it left both files behind containing
|
|
20
|
+
only their frontmatter. A file whose frontmatter you edited or wrote yourself is kept, with only
|
|
21
|
+
the Switch section removed.
|
|
22
|
+
|
|
8
23
|
## [25.11.1-beta.0] - 2026-09-15
|
|
9
24
|
|
|
10
25
|
### 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.
|
|
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.
|
|
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.
|
|
87
|
+
See [CHANGELOG.md](https://cdn.jsdelivr.net/npm/@enfocussw/switch-scripting-context@25.11.1-beta.1/CHANGELOG.md) for what changed.
|
|
88
88
|
|
|
89
89
|
## Options
|
|
90
90
|
|
|
@@ -118,6 +118,21 @@ npx switch-scripting-context init --dry-run
|
|
|
118
118
|
npx switch-scripting-context init --docs-dir ai-context
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
To undo `init`, run `remove`. By default it deletes the docs folder, the Switch section in every AI config file, and the `.gitignore` entry. With `--tools`, it only removes those tools' config sections and leaves the docs folder and other tools in place. Listing every tool is the same as a plain `remove`:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
npx switch-scripting-context remove [options]
|
|
125
|
+
|
|
126
|
+
--tools <list> Only remove these tools' config. Default: remove everything
|
|
127
|
+
--docs-dir <dir> Docs folder to remove. Default: switch-docs
|
|
128
|
+
--dry-run Print what would happen without writing any files
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Stop configuring Cursor, keep everything else
|
|
133
|
+
npx switch-scripting-context remove --tools cursor
|
|
134
|
+
```
|
|
135
|
+
|
|
121
136
|
## TypeScript types
|
|
122
137
|
|
|
123
138
|
This package does not bundle `@types/switch-scripting`. Add the type declarations to your project manually:
|
package/dist/init.js
CHANGED
|
@@ -381,20 +381,46 @@ function updateGitignore(targetRoot, docsDir, dryRun) {
|
|
|
381
381
|
fs.appendFileSync(gitignorePath, entry, 'utf8');
|
|
382
382
|
console.log(` .gitignore → appended ${docsDir}/ entry`);
|
|
383
383
|
}
|
|
384
|
-
/**
|
|
385
|
-
function
|
|
386
|
-
return TOOL_REGISTRY
|
|
384
|
+
/** AI config files that init may have created, for all tools or only the given tool ids. */
|
|
385
|
+
function aiConfigFiles(targetRoot, docsDir, tools) {
|
|
386
|
+
return TOOL_REGISTRY
|
|
387
|
+
.filter(t => !tools || tools.includes(t.id))
|
|
388
|
+
.flatMap(t => t.files.map(file => ({ filePath: file.targetPath(targetRoot, docsDir), file })));
|
|
387
389
|
}
|
|
388
|
-
|
|
390
|
+
/** The frontmatter a generator writes above the marker, trimmed; empty if it writes none. */
|
|
391
|
+
function generatedFrontmatter(file, docsDir) {
|
|
392
|
+
const generated = file.generate(docsDir);
|
|
393
|
+
return generated.slice(0, generated.indexOf(MARKER_BEGIN)).trim();
|
|
394
|
+
}
|
|
395
|
+
/** Deletes now-empty folders from dir upwards, stopping at targetRoot. */
|
|
396
|
+
function removeEmptyDirs(dir, targetRoot) {
|
|
397
|
+
while (dir !== targetRoot && dir.startsWith(targetRoot + path.sep) && fs.readdirSync(dir).length === 0) {
|
|
398
|
+
fs.rmdirSync(dir);
|
|
399
|
+
dir = path.dirname(dir);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function removeAiConfig(filePath, file, docsDir, targetRoot, dryRun) {
|
|
389
403
|
if (!fs.existsSync(filePath))
|
|
390
404
|
return;
|
|
391
|
-
const
|
|
405
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
406
|
+
const eol = raw.includes('\r\n') ? '\r\n' : '\n';
|
|
407
|
+
const content = raw.replace(/\r\n/g, '\n');
|
|
392
408
|
const range = findMarkerRange(content);
|
|
393
409
|
if (!range)
|
|
394
410
|
return; // nothing from us in this file
|
|
395
411
|
const rel = path.relative(process.cwd(), filePath);
|
|
396
|
-
|
|
412
|
+
let before = content.slice(0, range[0]).trim();
|
|
397
413
|
const after = content.slice(range[1]).trim();
|
|
414
|
+
// Copilot scoped instructions and Cursor .mdc put frontmatter above the marker. Only an exact
|
|
415
|
+
// copy of what the generator writes counts as ours; edited or user-written frontmatter stays.
|
|
416
|
+
const ours = generatedFrontmatter(file, docsDir);
|
|
417
|
+
if (ours && before === ours) {
|
|
418
|
+
before = '';
|
|
419
|
+
}
|
|
420
|
+
else if (ours && before.endsWith('\n' + ours)) {
|
|
421
|
+
// init appended our block, frontmatter included, below the user's own content
|
|
422
|
+
before = before.slice(0, -ours.length).trim();
|
|
423
|
+
}
|
|
398
424
|
if (!before && !after) {
|
|
399
425
|
// File is entirely our content — delete it
|
|
400
426
|
if (dryRun) {
|
|
@@ -402,6 +428,7 @@ function removeAiConfig(filePath, dryRun) {
|
|
|
402
428
|
return;
|
|
403
429
|
}
|
|
404
430
|
fs.unlinkSync(filePath);
|
|
431
|
+
removeEmptyDirs(path.dirname(filePath), targetRoot);
|
|
405
432
|
console.log(` ${rel} → deleted`);
|
|
406
433
|
}
|
|
407
434
|
else {
|
|
@@ -411,7 +438,7 @@ function removeAiConfig(filePath, dryRun) {
|
|
|
411
438
|
console.log(` [dry-run] ${rel} → removed Switch section`);
|
|
412
439
|
return;
|
|
413
440
|
}
|
|
414
|
-
fs.writeFileSync(filePath, stripped, 'utf8');
|
|
441
|
+
fs.writeFileSync(filePath, stripped.replace(/\n/g, eol), 'utf8');
|
|
415
442
|
console.log(` ${rel} → removed Switch section`);
|
|
416
443
|
}
|
|
417
444
|
}
|
|
@@ -438,6 +465,18 @@ function remove(options) {
|
|
|
438
465
|
const docsDestDir = path.join(targetRoot, options.docsDir);
|
|
439
466
|
if (options.dryRun)
|
|
440
467
|
console.log('\nDry run — no files will be written.\n');
|
|
468
|
+
const tools = options.tools;
|
|
469
|
+
const partial = tools && !TOOL_REGISTRY.every(t => tools.includes(t.id));
|
|
470
|
+
if (partial) {
|
|
471
|
+
// Removing some tools leaves the rest configured, and they still reference the docs folder.
|
|
472
|
+
// Listing every tool leaves nothing referencing it, so that falls through to a full remove.
|
|
473
|
+
console.log('Cleaning AI config files...');
|
|
474
|
+
for (const { filePath, file } of aiConfigFiles(targetRoot, options.docsDir, options.tools)) {
|
|
475
|
+
removeAiConfig(filePath, file, options.docsDir, targetRoot, options.dryRun);
|
|
476
|
+
}
|
|
477
|
+
console.log('\nDone.\n');
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
441
480
|
// 1. Remove docs dir
|
|
442
481
|
console.log('Removing docs...');
|
|
443
482
|
if (fs.existsSync(docsDestDir)) {
|
|
@@ -454,8 +493,8 @@ function remove(options) {
|
|
|
454
493
|
}
|
|
455
494
|
// 2. Remove AI config sections / files
|
|
456
495
|
console.log('\nCleaning AI config files...');
|
|
457
|
-
for (const filePath of
|
|
458
|
-
removeAiConfig(filePath, options.dryRun);
|
|
496
|
+
for (const { filePath, file } of aiConfigFiles(targetRoot, options.docsDir)) {
|
|
497
|
+
removeAiConfig(filePath, file, options.docsDir, targetRoot, options.dryRun);
|
|
459
498
|
}
|
|
460
499
|
// 3. Update .gitignore
|
|
461
500
|
console.log('\nUpdating .gitignore...');
|
|
@@ -530,6 +569,7 @@ function parseArgs(argv) {
|
|
|
530
569
|
process.exit(1);
|
|
531
570
|
}
|
|
532
571
|
initOptions.tools = raw.map(t => idMap.get(t));
|
|
572
|
+
removeOptions.tools = initOptions.tools;
|
|
533
573
|
toolsExplicit = true;
|
|
534
574
|
}
|
|
535
575
|
else if (arg === '--docs-dir' && args[i + 1]) {
|
|
@@ -580,7 +620,7 @@ Usage: switch-scripting-context <command> [options]
|
|
|
580
620
|
|
|
581
621
|
Commands:
|
|
582
622
|
init Copy docs and generate AI context config files
|
|
583
|
-
remove Remove
|
|
623
|
+
remove Remove files and config added by init (all of it, or only some tools' config)
|
|
584
624
|
|
|
585
625
|
Options (init):
|
|
586
626
|
--tools <list> Comma-separated tools to configure
|
|
@@ -593,6 +633,8 @@ Options (init):
|
|
|
593
633
|
--help Show this help message
|
|
594
634
|
|
|
595
635
|
Options (remove):
|
|
636
|
+
--tools <list> Only remove these tools' config; keeps the docs folder and other tools
|
|
637
|
+
Default: remove everything, same as listing every tool
|
|
596
638
|
--docs-dir <dir> Docs folder to remove (default: switch-docs)
|
|
597
639
|
--dry-run Print what would happen without writing any files
|
|
598
640
|
|
|
@@ -602,6 +644,7 @@ Examples:
|
|
|
602
644
|
npx switch-scripting-context init --docs-dir ai-docs --dry-run
|
|
603
645
|
npx switch-scripting-context remove
|
|
604
646
|
npx switch-scripting-context remove --dry-run
|
|
647
|
+
npx switch-scripting-context remove --tools cursor
|
|
605
648
|
`);
|
|
606
649
|
}
|
|
607
650
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|