@openclaw/plugin-inspector 0.3.14 → 0.3.16

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
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.3.16 - 2026-06-23
6
+
7
+ ### Fixed
8
+
9
+ - Write `package.json` updates atomically for `init --scripts` and `prune-workspace-dev-deps`, including symlink-preserving target rewrites and temp-file cleanup on staging failures. Thanks @KrasimirKralev.
10
+ - Mock the Lark SDK HTTP interceptor surface during runtime capture so Feishu plugin bundles load successfully.
11
+
12
+ ## 0.3.15 - 2026-06-12
13
+
14
+ ### Fixed
15
+
16
+ - Detect deprecated `loadSessionStore(...)` usage when plugin code calls it through a runtime session API alias.
17
+
3
18
  ## 0.3.14 - 2026-06-11
4
19
 
5
20
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/plugin-inspector",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": false,
5
5
  "description": "Offline compatibility inspector for OpenClaw plugins.",
6
6
  "type": "module",
@@ -151,7 +151,7 @@ export function createCaptureContext(options = {}) {
151
151
  resolvePath: options.resolvePath ?? ((value) => value),
152
152
  runtime: options.runtime ?? createRuntimeContext(options),
153
153
  secrets: options.secrets ?? createSecretContext(options),
154
- store: options.store ?? createStoreContext(options),
154
+ store: options.store ?? createStoreContext(),
155
155
  paths: options.paths ?? {
156
156
  cacheDir: ".plugin-inspector/cache",
157
157
  configDir: ".plugin-inspector/config",
package/src/cli.js CHANGED
@@ -38,7 +38,7 @@ try {
38
38
  await runConfig(commandArgs);
39
39
  } else if (command === "inspect" || command === "report") {
40
40
  if (command === "inspect" && !commandArgs.includes("--config")) {
41
- await runCheck(commandArgs);
41
+ await runCheck(commandArgs, { check: commandArgs.includes("--check") });
42
42
  } else {
43
43
  await runReport(command, commandArgs);
44
44
  }
@@ -100,7 +100,7 @@ async function runConfig(commandArgs) {
100
100
  }
101
101
  }
102
102
 
103
- async function runCheck(commandArgs) {
103
+ async function runCheck(commandArgs, options = {}) {
104
104
  const configPath = readFlag(commandArgs, "--config");
105
105
  const pluginRoot = readFlag(commandArgs, "--plugin-root") ?? readFlag(commandArgs, "--root");
106
106
  const outDir = readFlag(commandArgs, "--out") ?? "reports";
@@ -133,7 +133,7 @@ async function runCheck(commandArgs) {
133
133
  console.log(renderTextSummary(report, { artifacts: paths }));
134
134
  }
135
135
 
136
- if (report.status !== "pass") {
136
+ if ((options.check ?? true) && report.status !== "pass") {
137
137
  throw new Error(`plugin-inspector found ${report.summary.breakageCount} breakages`);
138
138
  }
139
139
  }
@@ -288,7 +288,7 @@ async function runCapture(commandArgs) {
288
288
  const entrypoint = findCaptureEntrypoint(commandArgs);
289
289
  const outputPath = readFlag(commandArgs, "--output");
290
290
  const pluginRoot = readFlag(commandArgs, "--plugin-root");
291
- const mockSdk = readMockSdkFlag(commandArgs) ?? commandArgs.includes("--mock-sdk");
291
+ const mockSdk = readMockSdkFlag(commandArgs) ?? true;
292
292
  const allowExecution = readAllowExecutionFlag(commandArgs);
293
293
  if (!entrypoint) {
294
294
  throw new Error("capture requires an entrypoint path");
package/src/init.js CHANGED
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { inferPluginSeams, packageId } from "./config.js";
5
+ import { writeJsonFileAtomic } from "./json-file.js";
5
6
 
6
7
  export const defaultInitConfigPath = "plugin-inspector.config.json";
7
8
  export const defaultInitWorkflowPath = ".github/workflows/plugin-inspector.yml";
@@ -59,7 +60,7 @@ export async function writePluginInspectorInit(options = {}) {
59
60
  ...defaultInitPackageScripts,
60
61
  };
61
62
  if (!dryRun) {
62
- await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf8");
63
+ await writeJsonFileAtomic(packageJsonPath, packageJson);
63
64
  }
64
65
  written.push(packageJsonPath);
65
66
  }
package/src/issues.js CHANGED
@@ -48,7 +48,7 @@ export const knownIssueCodes = new Set([
48
48
 
49
49
  const authorRemediationDocsUrl = (code) => `https://docs.openclaw.ai/clawhub/plugin-validation-fixes#${code}`;
50
50
 
51
- const authorRemediation = (summary) => ({ summary });
51
+ const authorRemediation = (summary, ..._details) => ({ summary });
52
52
 
53
53
  const migrationRemediation = authorRemediation;
54
54
 
@@ -462,10 +462,7 @@ export function buildIssues({ breakages = [], warnings = [], suggestions = [], t
462
462
  runtimeCoverage: finding.runtimeCoverage ?? null,
463
463
  ...(finding.authorRemediation
464
464
  ? {
465
- authorRemediation: {
466
- summary: finding.authorRemediation.summary,
467
- docsUrl: authorRemediationDocsUrl(finding.code),
468
- },
465
+ authorRemediation: withAuthorRemediationDocs(finding.code, finding.authorRemediation),
469
466
  }
470
467
  : {}),
471
468
  }));
@@ -491,10 +488,7 @@ export function issueMetadata(finding, targetOpenClaw) {
491
488
  };
492
489
  const authorMetadata = metadata.authorRemediation
493
490
  ? {
494
- authorRemediation: {
495
- summary: metadata.authorRemediation.summary,
496
- docsUrl: authorRemediationDocsUrl(finding.code),
497
- },
491
+ authorRemediation: withAuthorRemediationDocs(finding.code, metadata.authorRemediation),
498
492
  }
499
493
  : {};
500
494
  return {
@@ -505,6 +499,13 @@ export function issueMetadata(finding, targetOpenClaw) {
505
499
  };
506
500
  }
507
501
 
502
+ function withAuthorRemediationDocs(code, remediation) {
503
+ return {
504
+ ...remediation,
505
+ docsUrl: authorRemediationDocsUrl(code),
506
+ };
507
+ }
508
+
508
509
  export function classifyIssueFinding(finding, targetOpenClaw, metadata = {}) {
509
510
  const compatStatus = compatStatusFor(finding, targetOpenClaw);
510
511
  const deprecated = compatStatus === "deprecated";
package/src/json-file.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { existsSync } from "node:fs";
2
- import { readFile } from "node:fs/promises";
3
+ import { lstat, open, readFile, readlink, realpath, rename, stat, unlink } from "node:fs/promises";
4
+ import { basename, dirname, join, resolve } from "node:path";
3
5
 
4
6
  export async function readJsonFile(jsonPath) {
5
7
  return JSON.parse(await readFile(jsonPath, "utf8"));
@@ -8,3 +10,98 @@ export async function readJsonFile(jsonPath) {
8
10
  export async function readOptionalJsonFile(jsonPath) {
9
11
  return existsSync(jsonPath) ? readJsonFile(jsonPath) : null;
10
12
  }
13
+
14
+ // Writes JSON.stringify(value, null, 2) + newline atomically: stage to a sibling
15
+ // temp file, fsync, then rename over the destination. A crash mid-write can only
16
+ // truncate the temp file, so an interrupted run never corrupts an existing
17
+ // manifest. The destination file mode is preserved exactly (including any
18
+ // special bits) so the atomic replace stays permission-neutral. Existing
19
+ // symlinked manifests resolve to their target before staging so the link itself
20
+ // is never replaced.
21
+ export async function writeJsonFileAtomic(jsonPath, value) {
22
+ const writePath = await resolveJsonWritePath(jsonPath);
23
+ const data = `${JSON.stringify(value, null, 2)}\n`;
24
+ const tempPath = join(dirname(writePath), `.${basename(writePath)}.${process.pid}.${randomUUID()}.tmp`);
25
+
26
+ let existingMode;
27
+ try {
28
+ existingMode = (await stat(writePath)).mode & 0o7777;
29
+ } catch (error) {
30
+ if (error.code !== "ENOENT") {
31
+ throw error;
32
+ }
33
+ }
34
+
35
+ const handle = await open(tempPath, "wx");
36
+ let stagingError = null;
37
+ try {
38
+ await handle.writeFile(data, "utf8");
39
+ await handle.sync();
40
+ if (existingMode !== undefined) {
41
+ await handle.chmod(existingMode);
42
+ }
43
+ } catch (error) {
44
+ stagingError = error;
45
+ } finally {
46
+ try {
47
+ await handle.close();
48
+ } catch (error) {
49
+ stagingError ??= error;
50
+ }
51
+ }
52
+
53
+ if (stagingError) {
54
+ await unlink(tempPath).catch(() => {});
55
+ throw stagingError;
56
+ }
57
+
58
+ try {
59
+ await rename(tempPath, writePath);
60
+ } catch (error) {
61
+ await unlink(tempPath).catch(() => {});
62
+ throw error;
63
+ }
64
+ }
65
+
66
+ async function resolveJsonWritePath(jsonPath) {
67
+ try {
68
+ return await realpath(jsonPath);
69
+ } catch (error) {
70
+ if (error.code !== "ENOENT") {
71
+ throw error;
72
+ }
73
+ }
74
+
75
+ let writePath = jsonPath;
76
+ const seen = new Set();
77
+ for (let hops = 0; hops < 40; hops += 1) {
78
+ const normalizedPath = resolve(writePath);
79
+ if (seen.has(normalizedPath)) {
80
+ const error = new Error(`too many symbolic links resolving ${jsonPath}`);
81
+ error.code = "ELOOP";
82
+ throw error;
83
+ }
84
+ seen.add(normalizedPath);
85
+
86
+ let entry;
87
+ try {
88
+ entry = await lstat(writePath);
89
+ } catch (error) {
90
+ if (error.code === "ENOENT") {
91
+ return writePath;
92
+ }
93
+ throw error;
94
+ }
95
+
96
+ if (!entry.isSymbolicLink()) {
97
+ return writePath;
98
+ }
99
+
100
+ const target = await readlink(writePath);
101
+ writePath = resolve(dirname(writePath), target);
102
+ }
103
+
104
+ const error = new Error(`too many symbolic links resolving ${jsonPath}`);
105
+ error.code = "ELOOP";
106
+ throw error;
107
+ }
@@ -194,12 +194,16 @@ function registrySurfaceChecks(baseline, current) {
194
194
  action: "pass",
195
195
  metric,
196
196
  message: "registry surface delta is tracked as context",
197
- baseline: baseline.targetOpenClaw[metric],
198
- current: current.targetOpenClaw[metric],
199
- delta: current.targetOpenClaw[metric] - baseline.targetOpenClaw[metric],
197
+ baseline: registrySurfaceCount(baseline.targetOpenClaw[metric]),
198
+ current: registrySurfaceCount(current.targetOpenClaw[metric]),
199
+ delta: registrySurfaceCount(current.targetOpenClaw[metric]) - registrySurfaceCount(baseline.targetOpenClaw[metric]),
200
200
  }));
201
201
  }
202
202
 
203
+ function registrySurfaceCount(value) {
204
+ return Array.isArray(value) ? value.length : Number(value ?? 0);
205
+ }
206
+
203
207
  function commandWall(profile, commandId) {
204
208
  return profile.commands.find((command) => command.id === commandId)?.wallMs?.median ?? 0;
205
209
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { readFile, writeFile } from "node:fs/promises";
2
+ import { readFile } from "node:fs/promises";
3
+ import { writeJsonFileAtomic } from "./json-file.js";
3
4
  import path from "node:path";
4
5
 
5
6
  const packageJsonPath = path.resolve(process.cwd(), "package.json");
@@ -19,5 +20,5 @@ if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).leng
19
20
  }
20
21
 
21
22
  if (changed) {
22
- await writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf8");
23
+ await writeJsonFileAtomic(packageJsonPath, packageJson);
23
24
  }
package/src/report.js CHANGED
@@ -450,6 +450,7 @@ function emptyFixtureReport(fixture) {
450
450
  registrations: [],
451
451
  manifestContracts: [],
452
452
  sdkImports: [],
453
+ sdkDeprecations: [],
453
454
  sourceFiles: [],
454
455
  manifestFiles: [],
455
456
  packageFiles: [],
@@ -35,6 +35,7 @@ function collectLoadSessionStoreDeprecations(findings, context) {
35
35
  collectNamespaceUsageDeprecations(findings, context);
36
36
  collectNamespaceRequireDeprecations(findings, context);
37
37
  collectRuntimeUsageDeprecations(findings, context);
38
+ collectRuntimeAliasUsageDeprecations(findings, context);
38
39
  }
39
40
 
40
41
  function collectNamedImportDeprecations(findings, context) {
@@ -298,6 +299,172 @@ function collectRuntimeUsageDeprecations(findings, context) {
298
299
  });
299
300
  }
300
301
 
302
+ function collectRuntimeAliasUsageDeprecations(findings, context) {
303
+ const aliases = collectRuntimeSessionAliases(context.text);
304
+ if (aliases.size === 0) {
305
+ return;
306
+ }
307
+ collectMemberCallDeprecations(findings, context, {
308
+ receiverMatcher: (receiver) => aliases.has(receiver),
309
+ surface: "api.runtime.agent.session alias",
310
+ });
311
+ }
312
+
313
+ function collectRuntimeSessionAliases(text) {
314
+ const aliases = new Set();
315
+ const factories = collectRuntimeSessionFactoryNames(text);
316
+ collectDirectRuntimeSessionAliases(text, aliases);
317
+ collectFactoryCallRuntimeSessionAliases(text, aliases, factories);
318
+ return aliases;
319
+ }
320
+
321
+ function collectRuntimeSessionFactoryNames(text) {
322
+ const factories = new Set();
323
+ for (const fn of findNamedFunctionBodies(text)) {
324
+ const aliases = new Set();
325
+ collectDirectRuntimeSessionAliases(fn.body, aliases);
326
+ if (aliases.size === 0) {
327
+ continue;
328
+ }
329
+ const returnRegex = /\breturn\s+([A-Za-z_$][\w$]*)\b/g;
330
+ for (const match of fn.body.matchAll(returnRegex)) {
331
+ if (aliases.has(match[1])) {
332
+ factories.add(fn.name);
333
+ }
334
+ }
335
+ }
336
+ return factories;
337
+ }
338
+
339
+ function findNamedFunctionBodies(text) {
340
+ const functions = [];
341
+ let searchStart = 0;
342
+ while (searchStart < text.length) {
343
+ const keywordOffset = text.indexOf("function", searchStart);
344
+ if (keywordOffset === -1) {
345
+ break;
346
+ }
347
+ searchStart = keywordOffset + "function".length;
348
+ if (!isIdentifierBoundary(text, keywordOffset - 1) || !isIdentifierBoundary(text, searchStart)) {
349
+ continue;
350
+ }
351
+ let cursor = skipWhitespaceForward(text, searchStart);
352
+ const name = readIdentifierAt(text, cursor);
353
+ if (!name) {
354
+ continue;
355
+ }
356
+ cursor = skipWhitespaceForward(text, name.end);
357
+ if (text[cursor] !== "(") {
358
+ continue;
359
+ }
360
+ const paramsEnd = findMatchingDelimiter(text, cursor, "(", ")");
361
+ if (paramsEnd === -1) {
362
+ continue;
363
+ }
364
+ cursor = skipWhitespaceForward(text, paramsEnd + 1);
365
+ while (cursor < text.length && text[cursor] !== "{") {
366
+ cursor += 1;
367
+ }
368
+ if (text[cursor] !== "{") {
369
+ break;
370
+ }
371
+ const bodyStart = cursor + 1;
372
+ const bodyEnd = findMatchingBrace(text, cursor);
373
+ if (bodyEnd === -1) {
374
+ continue;
375
+ }
376
+ functions.push({
377
+ name: name.value,
378
+ body: text.slice(bodyStart, bodyEnd),
379
+ });
380
+ searchStart = bodyEnd + 1;
381
+ }
382
+ return functions;
383
+ }
384
+
385
+ function readIdentifierAt(text, startOffset) {
386
+ const first = text[startOffset];
387
+ if (!/[A-Za-z_$]/.test(first)) {
388
+ return null;
389
+ }
390
+ let end = startOffset + 1;
391
+ while (end < text.length && /[A-Za-z0-9_$]/.test(text[end])) {
392
+ end += 1;
393
+ }
394
+ return {
395
+ value: text.slice(startOffset, end),
396
+ end,
397
+ };
398
+ }
399
+
400
+ function findMatchingDelimiter(text, openOffset, openChar, closeChar) {
401
+ let depth = 0;
402
+ for (let index = openOffset; index < text.length; index += 1) {
403
+ const char = text[index];
404
+ if (char === openChar) {
405
+ depth += 1;
406
+ } else if (char === closeChar) {
407
+ depth -= 1;
408
+ if (depth === 0) {
409
+ return index;
410
+ }
411
+ }
412
+ }
413
+ return -1;
414
+ }
415
+
416
+ function findMatchingBrace(text, openOffset) {
417
+ return findMatchingDelimiter(text, openOffset, "{", "}");
418
+ }
419
+
420
+ function collectDirectRuntimeSessionAliases(text, aliases) {
421
+ const runtimeAliases = collectRuntimeObjectAliases(text);
422
+ const declarationRegex = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+)/g;
423
+ for (const match of text.matchAll(declarationRegex)) {
424
+ const local = match[1];
425
+ const initializer = normalizeReceiverExpression(match[2]);
426
+ if (isRuntimeSessionExpression(initializer, runtimeAliases)) {
427
+ aliases.add(local);
428
+ }
429
+ }
430
+ }
431
+
432
+ function collectRuntimeObjectAliases(text) {
433
+ const aliases = new Set();
434
+ const declarationRegex = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:\([^)]*\)\s*)?(?:[A-Za-z_$][\w$]*|this)\.runtime\b/g;
435
+ for (const match of text.matchAll(declarationRegex)) {
436
+ aliases.add(match[1]);
437
+ }
438
+ return aliases;
439
+ }
440
+
441
+ function isRuntimeSessionExpression(expression, runtimeAliases) {
442
+ for (const part of expression.split("??")) {
443
+ const candidate = part.trim();
444
+ if (isRuntimeSessionReceiver(candidate)) {
445
+ return true;
446
+ }
447
+ for (const alias of runtimeAliases) {
448
+ if (candidate === `${alias}.agent.session` || candidate === `${alias}.channel.session`) {
449
+ return true;
450
+ }
451
+ }
452
+ }
453
+ return false;
454
+ }
455
+
456
+ function collectFactoryCallRuntimeSessionAliases(text, aliases, factories) {
457
+ if (factories.size === 0) {
458
+ return;
459
+ }
460
+ const declarationRegex = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*)\s*\(/g;
461
+ for (const match of text.matchAll(declarationRegex)) {
462
+ if (factories.has(match[2])) {
463
+ aliases.add(match[1]);
464
+ }
465
+ }
466
+ }
467
+
301
468
  function parseNamedBindings(rawBindings, options = {}) {
302
469
  const aliasSeparator = options.aliasSeparator ?? "as";
303
470
  return rawBindings
package/src/sdk-mock.js CHANGED
@@ -273,7 +273,10 @@ export async function createMockSdkPackage(rootDir, options = {}) {
273
273
  if (specifier === "openclaw/plugin-sdk") {
274
274
  continue;
275
275
  }
276
- const relative = specifier.slice("openclaw/plugin-sdk/".length);
276
+ const relative = safePluginSdkSubpath(specifier.slice("openclaw/plugin-sdk/".length));
277
+ if (!relative) {
278
+ continue;
279
+ }
277
280
  if (mockSdkSubpathExports[relative]) {
278
281
  continue;
279
282
  }
@@ -443,7 +446,12 @@ export async function resolve(specifier, context, nextResolve) {
443
446
  return moduleUrl(path.join(pluginSdkDir, "index.js"));
444
447
  }
445
448
  if (specifier.startsWith("openclaw/plugin-sdk/")) {
446
- const subpath = specifier.slice("openclaw/plugin-sdk/".length);
449
+ const subpath = safePluginSdkSubpath(specifier.slice("openclaw/plugin-sdk/".length));
450
+ if (!subpath) {
451
+ throw Object.assign(new Error(\`invalid OpenClaw plugin SDK subpath: \${specifier}\`), {
452
+ code: "ERR_INVALID_MODULE_SPECIFIER",
453
+ });
454
+ }
447
455
  return moduleUrl(path.join(pluginSdkDir, \`\${subpath}.js\`));
448
456
  }
449
457
  if (externalMap.has(specifier)) {
@@ -514,9 +522,25 @@ function isMockableBareSpecifier(specifier) {
514
522
  !specifier.startsWith("data:") &&
515
523
  !specifier.startsWith("file:");
516
524
  }
525
+
526
+ function safePluginSdkSubpath(value) {
527
+ const normalized = path.posix.normalize(String(value).replaceAll("\\\\", "/"));
528
+ if (!normalized || normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/")) {
529
+ return null;
530
+ }
531
+ return normalized;
532
+ }
517
533
  `;
518
534
  }
519
535
 
536
+ function safePluginSdkSubpath(value) {
537
+ const normalized = path.posix.normalize(String(value).replaceAll("\\", "/"));
538
+ if (!normalized || normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/")) {
539
+ return null;
540
+ }
541
+ return normalized;
542
+ }
543
+
520
544
  function dynamicMockModuleSource(exportNames, options = {}) {
521
545
  const names = new Set([...exportNames].filter(isValidExportName));
522
546
  if (options.zod) {
@@ -530,6 +554,9 @@ export default ${options.zod ? "createZNamespace()" : 'createMockValue("default"
530
554
  }
531
555
 
532
556
  function externalMockModuleSource(specifier, exportNames) {
557
+ if (specifier === "@larksuiteoapi/node-sdk") {
558
+ return larkSdkMockModuleSource(exportNames);
559
+ }
533
560
  const names = new Set([...exportNames].filter(isValidExportName));
534
561
  if (specifier === "zod") {
535
562
  addZodExports(names);
@@ -537,6 +564,52 @@ function externalMockModuleSource(specifier, exportNames) {
537
564
  return dynamicMockModuleSource(names, { zod: specifier === "zod" });
538
565
  }
539
566
 
567
+ function larkSdkMockModuleSource(exportNames) {
568
+ const larkExports = new Set([
569
+ "AppType",
570
+ "Client",
571
+ "Domain",
572
+ "EventDispatcher",
573
+ "LoggerLevel",
574
+ "WSClient",
575
+ ...exportNames,
576
+ ]);
577
+ larkExports.delete("defaultHttpInstance");
578
+ return `${genericMockRuntimeSource()}
579
+ const requestInterceptors = {
580
+ handlers: [],
581
+ use(handler) {
582
+ this.handlers.push(handler);
583
+ return this.handlers.length - 1;
584
+ },
585
+ };
586
+
587
+ export const defaultHttpInstance = {
588
+ interceptors: {
589
+ request: requestInterceptors,
590
+ response: {
591
+ handlers: [],
592
+ use(handler) {
593
+ this.handlers.push(handler);
594
+ return this.handlers.length - 1;
595
+ },
596
+ },
597
+ },
598
+ request: createMockValue("defaultHttpInstance.request"),
599
+ get: createMockValue("defaultHttpInstance.get"),
600
+ post: createMockValue("defaultHttpInstance.post"),
601
+ put: createMockValue("defaultHttpInstance.put"),
602
+ patch: createMockValue("defaultHttpInstance.patch"),
603
+ delete: createMockValue("defaultHttpInstance.delete"),
604
+ head: createMockValue("defaultHttpInstance.head"),
605
+ options: createMockValue("defaultHttpInstance.options"),
606
+ };
607
+ ${[...larkExports].filter(isValidExportName).map(genericExportStatement).join("\n")}
608
+
609
+ export default createMockValue("default");
610
+ `;
611
+ }
612
+
540
613
  function addZodExports(names) {
541
614
  for (const name of ["z", "any", "array", "boolean", "enum", "literal", "number", "object", "record", "string", "unknown"]) {
542
615
  names.add(name);
@@ -1,5 +1,5 @@
1
1
  import { existsSync } from "node:fs";
2
- import { mkdir, readFile } from "node:fs/promises";
2
+ import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { renderPaddedMarkdownTable, writeJsonMarkdownArtifacts } from "./artifacts.js";
@@ -229,13 +229,13 @@ async function buildEntrypointPlan({ fixtureId, entrypoint, packageSummary, pack
229
229
 
230
230
  steps.push({
231
231
  kind: "prepare",
232
- command: `mkdir -p ${workspacePath} && rsync -a --delete ${packageDir}/ ${workspacePath}/`,
232
+ command: `mkdir -p ${shellQuote(workspacePath)} && rsync -a --delete ${shellQuote(`${packageDir}/`)} ${shellQuote(`${workspacePath}/`)}`,
233
233
  cwd: repoRelative("."),
234
234
  reason: "copy fixture package into an isolated mutable workspace",
235
235
  });
236
236
  steps.push({
237
237
  kind: "prepare-artifacts",
238
- command: `mkdir -p ${resultPath}`,
238
+ command: `mkdir -p ${shellQuote(resultPath)}`,
239
239
  cwd: repoRelative("."),
240
240
  reason: "create a stable result directory for capture and synthetic probe artifacts",
241
241
  });
@@ -243,7 +243,7 @@ async function buildEntrypointPlan({ fixtureId, entrypoint, packageSummary, pack
243
243
  if (requiredCapabilities.includes("target-openclaw-link")) {
244
244
  steps.push({
245
245
  kind: "link-openclaw",
246
- command: `${packageManager} pkg set dependencies.openclaw="file:${targetOpenClawWorkspacePath(settings, fixtureId, targetOpenClawPath)}"`,
246
+ command: `${shellQuote(packageManager)} pkg set ${shellQuote(`dependencies.openclaw=file:${targetOpenClawWorkspacePath(settings, fixtureId, targetOpenClawPath)}`)}`,
247
247
  cwd: workspacePath,
248
248
  reason: "link the plugin's openclaw peer dependency to the target checkout under test",
249
249
  });
@@ -253,7 +253,7 @@ async function buildEntrypointPlan({ fixtureId, entrypoint, packageSummary, pack
253
253
  if (hasWorkspaceProtocolDevDependencies(packageJson)) {
254
254
  steps.push({
255
255
  kind: "prune-dev-workspace-deps",
256
- command: `node ${helperScript(settings, workspacePath, settings.pruneWorkspaceDevDepsScript, "prune-workspace-dev-deps-cli.js")}`,
256
+ command: `node ${shellQuote(helperScript(settings, workspacePath, settings.pruneWorkspaceDevDepsScript, "prune-workspace-dev-deps-cli.js"))}`,
257
257
  cwd: workspacePath,
258
258
  reason: "remove workspace: devDependencies from the isolated runtime install; the mock SDK supplies OpenClaw host imports",
259
259
  });
@@ -361,6 +361,7 @@ function requiredCapabilitiesFor(entrypoint, packageSummary = {}) {
361
361
  }
362
362
  if (blocker.code === "build-required") {
363
363
  capabilities.add("build");
364
+ capabilities.add("dependency-install");
364
365
  }
365
366
  if (blocker.code === "ts-loader-required") {
366
367
  capabilities.add("ts-loader");
@@ -453,35 +454,35 @@ function installCommand(packageManager) {
453
454
  function auditCommand(settings, packageManager, fixtureId, workspacePath) {
454
455
  const output = workspaceRelativeArtifactPath(settings, fixtureId, workspacePath, "package-audit.json");
455
456
  if (packageManager === "npm") {
456
- return `npm audit --json > ${output} || true`;
457
+ return `npm audit --json > ${shellQuote(output)} || true`;
457
458
  }
458
459
  if (packageManager === "pnpm") {
459
- return `pnpm audit --json > ${output} || true`;
460
+ return `pnpm audit --json > ${shellQuote(output)} || true`;
460
461
  }
461
462
  if (packageManager === "yarn") {
462
- return `yarn npm audit --json > ${output} || true`;
463
+ return `yarn npm audit --json > ${shellQuote(output)} || true`;
463
464
  }
464
465
  if (packageManager === "bun") {
465
- return `bun audit --json > ${output} || true`;
466
+ return `bun audit --json > ${shellQuote(output)} || true`;
466
467
  }
467
- return `${packageManager} audit --json > ${output} || true`;
468
+ return `${shellQuote(packageManager)} audit --json > ${shellQuote(output)} || true`;
468
469
  }
469
470
 
470
471
  function runCommand(packageManager, script) {
471
472
  if (packageManager === "npm") {
472
- return `npm run ${script}`;
473
+ return `npm run ${shellQuote(script)}`;
473
474
  }
474
- return `${packageManager} run ${script}`;
475
+ return `${shellQuote(packageManager)} run ${shellQuote(script)}`;
475
476
  }
476
477
 
477
478
  function captureCommand(settings, fixtureId, entrypoint, workspacePath) {
478
479
  const script = helperScript(settings, workspacePath, settings.captureScript, "capture-cli.js");
479
- return `${settings.optInEnv} node ${script} ${entrypoint.specifier} --mock-sdk --output ${workspaceArtifactPath(settings, fixtureId, entrypoint, workspacePath, "capture")}`;
480
+ return `${settings.optInEnv} node ${shellQuote(script)} ${shellQuote(entrypoint.specifier)} --mock-sdk --output ${shellQuote(workspaceArtifactPath(settings, fixtureId, entrypoint, workspacePath, "capture"))}`;
480
481
  }
481
482
 
482
483
  function syntheticProbeCommand(settings, fixtureId, entrypoint, workspacePath) {
483
484
  const script = helperScript(settings, workspacePath, settings.syntheticProbeScript, "synthetic-probes-cli.js");
484
- return `${settings.optInEnv} node ${script} --entrypoint ${entrypoint.specifier} --mock-sdk --output ${workspaceArtifactPath(settings, fixtureId, entrypoint, workspacePath, "synthetic")}`;
485
+ return `${settings.optInEnv} node ${shellQuote(script)} --entrypoint ${shellQuote(entrypoint.specifier)} --mock-sdk --output ${shellQuote(workspaceArtifactPath(settings, fixtureId, entrypoint, workspacePath, "synthetic"))}`;
485
486
  }
486
487
 
487
488
  function helperScript(settings, workspacePath, configuredScript, helperFileName) {
@@ -526,6 +527,14 @@ function auditArtifactPath(settings, fixtureId) {
526
527
  return posixJoin(settings.resultsRoot, fixtureId, "package-audit.json");
527
528
  }
528
529
 
530
+ function shellQuote(value) {
531
+ const text = String(value);
532
+ if (/^[A-Za-z0-9_./:=@%+-]+$/u.test(text)) {
533
+ return text;
534
+ }
535
+ return `'${text.replaceAll("'", "'\\''")}'`;
536
+ }
537
+
529
538
  function markdownTable(rows, headers) {
530
539
  return renderPaddedMarkdownTable(rows, headers);
531
540
  }