@buzzni/saycode-cli 0.9.2 → 0.9.4

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.
@@ -48,6 +48,18 @@ function contributionList(value, path2, allowedKeys, parse) {
48
48
  return parse(entry, entryPath);
49
49
  });
50
50
  }
51
+ function parseExtensionFileViewers(value, apiVersion) {
52
+ if (apiVersion < 4) fail$5("manifest.contributes.fileViewers", "requires Extension API version 4");
53
+ return contributionList(value, "manifest.contributes.fileViewers", ["id", "title", "extensions", "panelId"], (entry, path2) => {
54
+ if (!Array.isArray(entry.extensions) || !entry.extensions.length || entry.extensions.length > 30 || entry.extensions.some((extension) => typeof extension !== "string" || !/^[a-z0-9]{1,12}$/.test(extension)) || new Set(entry.extensions).size !== entry.extensions.length) fail$5(`${path2}.extensions`, "expected unique lowercase file extensions");
55
+ return { id: id(entry.id, `${path2}.id`), title: string(entry.title, `${path2}.title`), extensions: entry.extensions, panelId: id(entry.panelId, `${path2}.panelId`) };
56
+ });
57
+ }
58
+ function assertExtensionFileViewers(extensionId2, viewers, panels, permissions) {
59
+ for (const viewer of viewers) {
60
+ if (!permissions.includes("filePreviews.read") || !viewer.id.startsWith(`${extensionId2}.`) || !viewer.panelId.startsWith(`${extensionId2}.`) || !panels.some((panel) => panel.id === viewer.panelId)) fail$5("manifest.contributes.fileViewers", "requires filePreviews.read and an owned panel");
61
+ }
62
+ }
51
63
  function parseMachineCommands(value, extensionId2, apiVersion) {
52
64
  if (apiVersion < 3) fail$5("manifest.machineCommands", "requires Extension API version 3");
53
65
  const root = record$1(value, "manifest.machineCommands");
@@ -501,6 +513,7 @@ const EXTENSION_PERMISSIONS = [
501
513
  "browserViewer.install",
502
514
  "browserViewer.installChrome",
503
515
  "artifacts.publishPublic",
516
+ "filePreviews.read",
504
517
  // One permission per channel wire method (`src/domain/channelProtocol.ts`), deliberately not a
505
518
  // single adapter grant. Receiving and acking messages is transport work; reading a session,
506
519
  // driving it, or approving a tool call once are three larger and separately-refusable
@@ -515,7 +528,7 @@ const EXTENSION_PERMISSIONS = [
515
528
  "sessions.control",
516
529
  "sessions.approveOnce"
517
530
  ];
518
- const SAYCODE_EXTENSION_API_VERSION = 3;
531
+ const SAYCODE_EXTENSION_API_VERSION = 4;
519
532
  const SAYCODE_EXTENSION_MINIMUM_API_VERSION = 2;
520
533
  const MAX_EXTENSION_API_WINDOW_WIDTH = 2;
521
534
  const SAYCODE_EXTENSION_ENGINE_VERSION = "1.2.0";
@@ -541,7 +554,7 @@ const SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$
541
554
  const ENGINE_RANGE_PATTERN = /^(?:\^|~|>=|<=|>|<)?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
542
555
  const ENTRYPOINT_PATTERN = /\.(?:cjs|mjs|js)$/;
543
556
  const LOCALE_PATTERN = /^[a-z]{2,3}(?:-[A-Z]{2})?$/;
544
- const CONTRIBUTION_KEYS = /* @__PURE__ */ new Set(["commands", "settings", "panels", "projectTemplates", "machineActions", "projectTools", "artifactActions", "channels"]);
557
+ const CONTRIBUTION_KEYS = /* @__PURE__ */ new Set(["commands", "settings", "panels", "projectTemplates", "machineActions", "projectTools", "artifactActions", "channels", "fileViewers"]);
545
558
  const V2_PERMISSIONS = /* @__PURE__ */ new Set([
546
559
  "browserViewer.open",
547
560
  "browserViewer.install",
@@ -602,7 +615,7 @@ function engineSupports(range, version) {
602
615
  function parseApiVersion(value, options) {
603
616
  const current = options.supportedApiVersion;
604
617
  const floor = options.minimumSupportedApiVersion ?? current;
605
- if (floor > current || current - floor + 1 > MAX_EXTENSION_API_WINDOW_WIDTH) {
618
+ if (floor > current || current - floor + 1 > (current === 4 && floor === 2 ? 3 : MAX_EXTENSION_API_WINDOW_WIDTH)) {
606
619
  fail$5(
607
620
  "manifest.apiVersion",
608
621
  `invalid Desktop API support window [${floor}, ${current}]`
@@ -643,6 +656,7 @@ function parseContributions(value, apiVersion, channelApiVersion) {
643
656
  fail$5("manifest.contributes.artifactActions", "requires Extension API version 3");
644
657
  }
645
658
  const result = {};
659
+ if (parsed.fileViewers !== void 0) result.fileViewers = parseExtensionFileViewers(parsed.fileViewers, apiVersion);
646
660
  if (parsed.commands !== void 0) {
647
661
  result.commands = contributionList(
648
662
  parsed.commands,
@@ -794,6 +808,7 @@ function parseExtensionManifest(value, options) {
794
808
  fail$5("manifest.permissions", `unknown permission ${parsed}`);
795
809
  }
796
810
  const typed = parsed;
811
+ if (typed === "filePreviews.read" && apiVersion < 4) fail$5("manifest.permissions", "filePreviews.read requires Extension API version 4");
797
812
  if (apiVersion < 2 && V2_PERMISSIONS.has(typed)) {
798
813
  fail$5(`manifest.permissions[${index}]`, "requires Extension API version 2");
799
814
  }
@@ -865,6 +880,7 @@ function parseExtensionManifest(value, options) {
865
880
  );
866
881
  }
867
882
  }
883
+ assertExtensionFileViewers(parsedId, contributes.fileViewers ?? [], contributes.panels ?? [], permissions);
868
884
  assertExtensionProjectToolTargets(parsedId, contributes.projectTools ?? [], contributes.commands ?? []);
869
885
  return {
870
886
  id: parsedId,