scripting-cli 1.6.0 → 2.0.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/dist/util.js CHANGED
@@ -124,7 +124,8 @@ function createTsConfig() {
124
124
  },
125
125
  "include": [
126
126
  "./dts/*.d.ts",
127
- "scripts"
127
+ "scripts",
128
+ "skills"
128
129
  ],
129
130
  "exclude": [
130
131
  "./dts/${const_1.scriptingDtsFileName}"
@@ -151,6 +152,8 @@ function createTsConfig() {
151
152
  nextInclude.unshift('./dts/*.d.ts');
152
153
  if (!nextInclude.includes('scripts'))
153
154
  nextInclude.push('scripts');
155
+ if (!nextInclude.includes('skills'))
156
+ nextInclude.push('skills');
154
157
  const nextExclude = exclude.includes(`./dts/${const_1.scriptingDtsFileName}`)
155
158
  ? exclude
156
159
  : [...exclude, `./dts/${const_1.scriptingDtsFileName}`];
@@ -182,7 +185,7 @@ function ensureDirectoryExistence(filePath) {
182
185
  fs_1.default.mkdirSync(dirname, { recursive: true });
183
186
  }
184
187
  }
185
- async function writeDtsFiles(files) {
188
+ async function writeDtsFiles(files, workspace = process.cwd()) {
186
189
  await Promise.all(Object.entries(files).map(async ([filename, content]) => {
187
190
  // These names arrive over the wire; only allow a plain `.d.ts` basename so
188
191
  // a crafted name can't escape the dts/ directory.
@@ -192,7 +195,7 @@ async function writeDtsFiles(files) {
192
195
  console.log(chalk_1.default.red(`Skipped writing dts file with unexpected name: ${filename}`));
193
196
  return;
194
197
  }
195
- const filePath = getPath(`dts/${filename}`);
198
+ const filePath = path_1.default.join(workspace, 'dts', filename);
196
199
  ensureDirectoryExistence(filePath);
197
200
  await fs_1.default
198
201
  .promises
@@ -248,7 +251,7 @@ async function migrateOldFiles() {
248
251
  const list = await fs_1.default.promises.readdir(process.cwd());
249
252
  let hasMigrated = false;
250
253
  for (const file of list) {
251
- if (file === 'dts' || file == "scripts" || file === 'tsconfig.json' || file === 'package.json' || file === 'node_modules' || file.startsWith('.')) {
254
+ if (file === 'dts' || file == "scripts" || file === "skills" || file === 'tsconfig.json' || file === 'package.json' || file === 'node_modules' || file.startsWith('.')) {
252
255
  continue;
253
256
  }
254
257
  const filePath = path_1.default.join(process.cwd(), file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripting-cli",
3
- "version": "1.6.0",
3
+ "version": "2.0.0",
4
4
  "description": "This plugin integrates the desktop editor synchronization feature of the Scripting app.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,33 +5,33 @@ description: Develop and debug Scripting App scripts or widgets from a desktop w
5
5
 
6
6
  # Scripting development
7
7
 
8
- Use the connected App as the source of API documentation and runtime/rendering evidence. Run commands from the workspace where `scripting-cli start` is already running; its projects live under `scripts/<project>/`. A local CLI checkout can be invoked with `node /absolute/path/to/scripting-cli/dist/cli.js` instead of a published binary.
8
+ Use the connected App as the source of API documentation and runtime/rendering evidence. Run commands from the workspace where `scripting-cli start` is already running; its scripts live under `scripts/<script>/`. A local CLI checkout can be invoked with `node /absolute/path/to/scripting-cli/dist/cli.js` instead of a published binary.
9
9
 
10
10
  ## Establish context
11
11
 
12
- - Read the workspace's instructions and the intended project's existing files before changing code.
13
- - Run `scripting-cli devices --json`, select `--device <id>` when several devices exist, then query `status --json`. Inspect `responsive`, capabilities, current project, foreground state and `activeRunId`; connection alone does not prove execution.
12
+ - Read the workspace's instructions and the intended script's existing files before changing code.
13
+ - Run `scripting-cli devices --json`, select `--device <id>` when several devices exist, then query `status --json`. Inspect `responsive`, capabilities, current script, foreground state and `activeRunId`; connection alone does not prove execution.
14
14
  - Search with `docs search "<topic>" --json`, read the exact returned ID with `docs get <id> --lang en|zh --json`, and use `api get <symbol> --json` for declarations. Do not invent APIs from a screenshot or substitute stale offline docs for the connected App version.
15
15
 
16
- ## Bind a project deliberately
16
+ ## Bind a script deliberately
17
17
 
18
- - `projects list --json` lists App projects. `projects inspect "Project" --json` returns source file hashes and the current App revision without modifying it.
19
- - `projects create "Project" --json` creates from an existing desktop project, or scaffolds a minimal desktop script if absent; App name collisions are rejected. It does not overwrite a colliding App project.
20
- - `projects attach "Project" --json` syncs the desktop snapshot and selects that App debug project. Matching source needs no replacement flag. If source differs, `project_conflict` returns the current App revision. Inspect both versions and resolve the user's intended source before replacing anything. Only when the user has authorized that overwrite, use `projects attach "Project" --replace --expected-revision <inspected-App-revision> --json`. A changed revision is a fresh conflict, not a reason to retry blindly.
21
- - Project changes need App foreground and refuse an existing manual run or preview. Do not stop unrelated work, overwrite projects, install the skill globally, or publish packages merely to make a command succeed.
18
+ - `scripts list --json` lists App scripts. `scripts inspect "Script" --json` returns source file hashes and the current App revision without modifying it.
19
+ - `scripts create "Script" --json` creates from an existing desktop script, or scaffolds a minimal desktop script if absent; App name collisions are rejected. It does not overwrite a colliding App script.
20
+ - `scripts attach "Script" --json` syncs the desktop snapshot and selects that App debug script. Matching source needs no replacement flag. If source differs, `script_conflict` returns the current App revision. Inspect both versions and resolve the user's intended source before replacing anything. Only when the user has authorized that overwrite, use `scripts attach "Script" --replace --expected-revision <inspected-App-revision> --json`. A changed revision is a fresh conflict, not a reason to retry blindly.
21
+ - Script changes need App foreground and refuse an existing manual run or preview. Do not stop unrelated work, overwrite scripts, install the skill globally, or publish packages merely to make a command succeed.
22
22
 
23
23
  ## Iterate using evidence
24
24
 
25
- - Edit only the requested project. `run "Project" --query-parameters '{"sample":true}' --json` takes a bounded snapshot and executes only after the App confirms its revision. Use `requestedRevision` versus `revision` to distinguish attempted from applied source. Changes after snapshot capture belong to another run.
26
- - Ordinary scripts should call `Script.exit(result)` to finish. Inspect `status`, `error.code`, `result.value`, stdout/stderr and diagnostics; a nonzero result is not success because a page once appeared. Diagnostic paths are project-relative, lines/columns are one-based. Runtime errors and TypeScript diagnostics are distinct evidence.
25
+ - Edit only the requested script. `run "Script" --query-parameters '{"sample":true}' --json` takes a bounded snapshot and executes only after the App confirms its revision. Use `requestedRevision` versus `revision` to distinguish attempted from applied source. Changes after snapshot capture belong to another run.
26
+ - Ordinary scripts should call `Script.exit(result)` to finish. Inspect `status`, `error.code`, `result.value`, stdout/stderr and diagnostics; a nonzero result is not success because a page once appeared. Diagnostic paths are script-relative, lines/columns are one-based. Runtime errors and TypeScript diagnostics are distinct evidence.
27
27
  - Use `--stream` for JSONL stage/log/diagnostic events followed by one `type: result` record. It replaces single-result stdout formatting; never parse the entire stream as one JSON value. A `gap` means retained events were lost; final logs may also report `logsTruncated`.
28
- - Use `run "Project" --screenshot --output ./artifacts --json` for a finite UI preview. The App must be foreground. The screenshot belongs to this run, then the run ends; `preview_capture` does not mean the script called `Script.exit`.
28
+ - Use `run "Script" --screenshot --output ./artifacts --json` for a finite UI preview. The App must be foreground. The screenshot belongs to this run, then the run ends; `preview_capture` does not mean the script called `Script.exit`.
29
29
  - For asynchronous UI, emit a distinctive exact `console.log("SCREENSHOT_READY")` after the intended data/state is ready and invoke `--screenshot --ready-log SCREENSHOT_READY --capture-after 1`. Only the current run's matching non-error log counts. The marker is the script author's readiness contract, not automatic proof all remote work is complete. Missing signal/view or background transition must remain a failure.
30
30
  - Open the actual PNG listed in `result.artifacts` using the host's image-viewing tool. Compare the requested layout and content, fix specific discrepancies, and rerun the affected case. A file path alone does not prove rendering correctness. Keep requested final output files; clean only disposable artifacts you created.
31
31
 
32
32
  ## Widgets and batches
33
33
 
34
- `widget "Project" --family systemMedium --parameter demo --screenshot --output ./artifacts --json` renders `widget.tsx` in foreground, captures if requested, then closes. Omit `--screenshot` for render-and-close without an image. This does not install a home-screen widget or verify WidgetKit timeline delivery, and it does not overwrite normal preview preferences.
34
+ `widget "Script" --family systemMedium --parameter demo --screenshot --output ./artifacts --json` renders `widget.tsx` in foreground, captures if requested, then closes. Omit `--screenshot` for render-and-close without an image. This does not install a home-screen widget or verify WidgetKit timeline delivery, and it does not overwrite normal preview preferences.
35
35
 
36
36
  For multiple sizes or parameters, create a JSON array such as:
37
37
 
@@ -43,7 +43,7 @@ For multiple sizes or parameters, create a JSON array such as:
43
43
  ]
44
44
  ```
45
45
 
46
- Invoke `widget-batch "Project" --cases ./cases.json --timeout 60 --output ./artifacts --stream`. At most eight unique safe case IDs run serially from one source snapshot. Inspect each case's status, skipped count, and corresponding `<output>/<run-id>/<case-id>.png`. A failed/cancelled batch may contain earlier completed cases; never claim all cases passed from partial results.
46
+ Invoke `widget-batch "Script" --cases ./cases.json --timeout 60 --output ./artifacts --stream`. At most eight unique safe case IDs run serially from one source snapshot. Inspect each case's status, skipped count, and corresponding `<output>/<run-id>/<case-id>.png`. A failed/cancelled batch may contain earlier completed cases; never claim all cases passed from partial results.
47
47
 
48
48
  ## Failure and cancellation
49
49
 
@@ -51,4 +51,10 @@ The overall deadline is finite (`--timeout` 1–120 seconds, default 30). Do not
51
51
 
52
52
  Ctrl-C or `jobs cancel <run-id> --json` requests cancellation of that owned run. `cancelling` is not confirmed termination. Inspect `jobs show <run-id> --json` until a terminal state; a disconnect/timeout is failure with potentially uncertain side effects, so do not replay mutating scripts automatically. `jobs events <run-id> --after <cursor> --json` reads recent events. Results expire; absence is not proof of no execution.
53
53
 
54
- Preserve App permission checks. Handle `needs_foreground`, `busy`, `unsupported_capability`, `project_conflict`, `execution_timeout` and `screenshot_unavailable` according to their actual meaning. Report unavailable device, VoiceOver, long-background, audio interruption or real WidgetKit evidence as pending. Do not claim those from desktop mocks or Simulator success.
54
+ Preserve App permission checks. Handle `needs_foreground`, `busy`, `unsupported_capability`, `script_conflict`, `execution_timeout` and `screenshot_unavailable` according to their actual meaning. Report unavailable device, VoiceOver, long-background, audio interruption or real WidgetKit evidence as pending. Do not claim those from desktop mocks or Simulator success.
55
+
56
+ ## Develop a Skill package
57
+
58
+ Ask the user to select Skill mode and the intended package in the connected App development page. Work only inside `skills/<name>/`; do not use script commands to attach a Skill. Preserve `SKILL.md` name/description and App-managed `skill.json`. Desktop saves sync the selected package without executing it. Resolve source conflicts by stopping and reselecting the source in the App.
59
+
60
+ Use `scripting-cli skills run <name> <relative-entry.tsx> --check --json` first, then `scripting-cli skills run <name> <relative-entry.tsx> --stream` for explicit execution and logs. Pass test inputs with `--query-parameters` and finish using `Script.exit(result)`. Runtime identity, storage and permissions are the Skill’s own; do not bypass permission prompts, run unrequested side effects or delete App packages to resolve conflicts. Use the returned source revision, log events and final result as evidence; connection status alone is not test success. Cancel with Ctrl-C or `jobs cancel`; disconnects do not replay execution.