holycodex 0.10.6-dev.30770925419.1 → 0.10.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +118 -21
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -4252,7 +4252,7 @@ function superRefine(fn, params) {
4252
4252
  }
4253
4253
  //#endregion
4254
4254
  //#region packages/cli/src/catalog.ts
4255
- var VERSION = "0.10.6-dev.30770925419.1";
4255
+ var VERSION = "0.10.7";
4256
4256
  var SKILLS = [
4257
4257
  "ast-grep",
4258
4258
  "caveman",
@@ -5781,9 +5781,11 @@ function deduplicate(candidates) {
5781
5781
  //#endregion
5782
5782
  //#region packages/cli/src/codex-security.ts
5783
5783
  var CODEX_SECURITY_PLUGIN = "codex-security@openai-curated";
5784
+ var CODEX_SECURITY_MARKETPLACE = "openai-curated";
5784
5785
  var CODEX_PLUGIN_OPERATIONAL_TIMEOUT_MS = 15e3;
5785
5786
  var CODEX_PACKAGE_BOOTSTRAP_TIMEOUT_MS = 12e4;
5786
5787
  var MAX_CODEX_OUTPUT_CHARS = 64 * 1024;
5788
+ var MAX_JSON_DOCUMENTS = 16;
5787
5789
  var SPAWN_UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
5788
5790
  "EACCES",
5789
5791
  "ENOENT",
@@ -5829,23 +5831,50 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
5829
5831
  const fallbackReasons = [];
5830
5832
  for (const launcher of candidates) {
5831
5833
  attemptedLaunchers.push(launcher.source);
5832
- const listOutcome = inspectListResult(await runCodexPlugin(runProcess, launcher, [
5834
+ const installedOutcome = inspectListResult(await runCodexPlugin(runProcess, launcher, [
5833
5835
  "plugin",
5834
5836
  "list",
5835
- "--available",
5836
5837
  "--json"
5837
5838
  ], platform, env, "list"), launcher);
5838
- if (listOutcome.kind === "fallback") {
5839
- fallbackReasons.push(listOutcome.reason);
5839
+ if (installedOutcome.kind === "fallback") {
5840
+ fallbackReasons.push(installedOutcome.reason);
5840
5841
  continue;
5841
5842
  }
5842
- if (listOutcome.kind === "fatal") return skipped(listOutcome.reason, attemptedLaunchers);
5843
- const plugin = listOutcome.catalog.plugins.find(({ id }) => id === CODEX_SECURITY_PLUGIN);
5844
- if (plugin?.installed === true && plugin.enabled === true) return {
5843
+ if (installedOutcome.kind === "fatal") return skipped(installedOutcome.reason, attemptedLaunchers);
5844
+ const installedPlugin = findPlugin(installedOutcome.catalog);
5845
+ if (installedPlugin?.installed === true && installedPlugin.enabled === true) return {
5845
5846
  status: "already-installed",
5846
5847
  launcherSource: launcher.source
5847
5848
  };
5848
- const wasDisabled = plugin?.installed === true;
5849
+ const wasDisabled = installedPlugin?.installed === true;
5850
+ if (!wasDisabled) {
5851
+ const catalogOutcome = inspectListResult(await runCodexPlugin(runProcess, launcher, [
5852
+ "plugin",
5853
+ "list",
5854
+ "--available",
5855
+ "--json"
5856
+ ], platform, env, "list"), launcher);
5857
+ if (catalogOutcome.kind === "fallback") {
5858
+ fallbackReasons.push(catalogOutcome.reason);
5859
+ continue;
5860
+ }
5861
+ if (catalogOutcome.kind === "fatal") return skipped(catalogOutcome.reason, attemptedLaunchers);
5862
+ if (findPlugin(catalogOutcome.catalog) === void 0) {
5863
+ const marketplaceOutcome = inspectMarketplaceResult(await runCodexPlugin(runProcess, launcher, [
5864
+ "plugin",
5865
+ "marketplace",
5866
+ "list",
5867
+ "--json"
5868
+ ], platform, env, "list"), launcher);
5869
+ if (marketplaceOutcome.kind === "fallback") {
5870
+ fallbackReasons.push(marketplaceOutcome.reason);
5871
+ continue;
5872
+ }
5873
+ if (marketplaceOutcome.kind === "fatal") return skipped(marketplaceOutcome.reason, attemptedLaunchers);
5874
+ fallbackReasons.push(marketplaceOutcome.marketplaces.includes(CODEX_SECURITY_MARKETPLACE) ? "plugin-not-offered" : "marketplace-unavailable");
5875
+ continue;
5876
+ }
5877
+ }
5849
5878
  const addOutcome = inspectAddResult(await runCodexPlugin(runProcess, launcher, [
5850
5879
  "plugin",
5851
5880
  "add",
@@ -5860,7 +5889,6 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
5860
5889
  const verification = inspectListResult(await runCodexPlugin(runProcess, launcher, [
5861
5890
  "plugin",
5862
5891
  "list",
5863
- "--available",
5864
5892
  "--json"
5865
5893
  ], platform, env, "list"), launcher);
5866
5894
  if (verification.kind === "fallback") {
@@ -5868,9 +5896,9 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
5868
5896
  continue;
5869
5897
  }
5870
5898
  if (verification.kind === "fatal") return skipped(verification.reason, attemptedLaunchers);
5871
- const verifiedPlugin = verification.catalog.plugins.find(({ id }) => id === CODEX_SECURITY_PLUGIN);
5899
+ const verifiedPlugin = findPlugin(verification.catalog);
5872
5900
  if (verifiedPlugin?.installed !== true || verifiedPlugin.enabled !== true) {
5873
- fallbackReasons.push("plugin-unavailable");
5901
+ fallbackReasons.push("verification-failed");
5874
5902
  continue;
5875
5903
  }
5876
5904
  return {
@@ -5929,11 +5957,26 @@ function inspectAddResult(result, launcher) {
5929
5957
  };
5930
5958
  const failure = classifyFailure(result, launcher);
5931
5959
  if (failure !== void 0) return failure;
5932
- if (!isRecord(parseUnknownJson(result.stdout))) return {
5960
+ return { kind: "added" };
5961
+ }
5962
+ function inspectMarketplaceResult(result, launcher) {
5963
+ if (result.timedOut) return {
5964
+ kind: "fallback",
5965
+ reason: "timeout"
5966
+ };
5967
+ const failure = classifyFailure(result, launcher);
5968
+ if (failure !== void 0) return failure;
5969
+ const marketplaces = parseMarketplaceNames(result.stdout);
5970
+ return marketplaces === void 0 ? {
5933
5971
  kind: "fallback",
5934
5972
  reason: "invalid-response"
5973
+ } : {
5974
+ kind: "selected",
5975
+ marketplaces
5935
5976
  };
5936
- return { kind: "added" };
5977
+ }
5978
+ function findPlugin(catalog) {
5979
+ return catalog.plugins.find(({ id }) => id === CODEX_SECURITY_PLUGIN);
5937
5980
  }
5938
5981
  function classifyFailure(result, launcher) {
5939
5982
  if (result.error !== void 0) {
@@ -5947,7 +5990,7 @@ function classifyFailure(result, launcher) {
5947
5990
  };
5948
5991
  }
5949
5992
  if (result.exitCode === 0) return void 0;
5950
- const failureReason = classifyFailureReason(structuredErrorCode(parseUnknownJson(result.stderr) ?? parseUnknownJson(result.stdout)), sanitizeDiagnostic(result.stderr));
5993
+ const failureReason = classifyFailureReason(structuredErrorCodeFromOutput(result.stderr) ?? structuredErrorCodeFromOutput(result.stdout), sanitizeDiagnostic(result.stderr));
5951
5994
  if (failureReason === "unauthenticated" || failureReason === "installation-rejected") return {
5952
5995
  kind: "fatal",
5953
5996
  reason: failureReason
@@ -5984,6 +6027,9 @@ function classifyFailureReason(code, diagnostic) {
5984
6027
  return "invalid-response";
5985
6028
  }
5986
6029
  function finalFallbackReason(reasons) {
6030
+ if (reasons.length > 0 && reasons.every((reason) => reason === "plugin-not-offered")) return "all-launchers-lacked-plugin";
6031
+ if (reasons.includes("verification-failed")) return "verification-failed";
6032
+ if (reasons.includes("plugin-not-offered")) return "plugin-not-offered";
5987
6033
  if (reasons.includes("timeout")) return "timeout";
5988
6034
  if (reasons.includes("unsupported")) return "unsupported";
5989
6035
  if (reasons.includes("download-failed")) return "download-failed";
@@ -6000,10 +6046,29 @@ function isPackageLauncher(launcher) {
6000
6046
  }
6001
6047
  /** Normalizes supported flat and marketplace-oriented Codex catalogs. */
6002
6048
  function parsePluginCatalog(input) {
6003
- const value = parseUnknownJson(input);
6004
- if (value === void 0) return void 0;
6005
- const plugins = parseCatalogValue(value);
6006
- return plugins === void 0 ? void 0 : { plugins };
6049
+ for (const value of parseJsonDocuments(input) ?? []) {
6050
+ const plugins = parseCatalogValue(value);
6051
+ if (plugins !== void 0) return { plugins };
6052
+ }
6053
+ }
6054
+ function parseMarketplaceNames(input) {
6055
+ for (const value of parseJsonDocuments(input) ?? []) {
6056
+ if (!isRecord(value) || !Array.isArray(value.marketplaces)) continue;
6057
+ const names = [];
6058
+ for (const marketplace of value.marketplaces) {
6059
+ if (!isRecord(marketplace)) {
6060
+ names.length = 0;
6061
+ break;
6062
+ }
6063
+ const name = stringField(marketplace, ["name"]);
6064
+ if (name === void 0) {
6065
+ names.length = 0;
6066
+ break;
6067
+ }
6068
+ names.push(name);
6069
+ }
6070
+ if (names.length > 0 || value.marketplaces.length === 0) return names;
6071
+ }
6007
6072
  }
6008
6073
  function parseCatalogValue(value) {
6009
6074
  if (Array.isArray(value)) return parseMarketplaceEntries(value);
@@ -6108,13 +6173,42 @@ function enabledFromState(value) {
6108
6173
  if (state === "enabled") return true;
6109
6174
  if (state === "disabled") return false;
6110
6175
  }
6111
- function parseUnknownJson(input) {
6176
+ function parseJsonDocuments(input) {
6177
+ const wholeDocument = tryParseJson(input);
6178
+ if (wholeDocument !== void 0) return [wholeDocument];
6179
+ const lines = input.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6180
+ if (lines.length === 0) return void 0;
6181
+ for (let index = 1; index < lines.length; index += 1) {
6182
+ const document = tryParseJson(lines.slice(index).join("\n"));
6183
+ if (document !== void 0) return [document];
6184
+ }
6185
+ const documents = [];
6186
+ let parsedDocument = false;
6187
+ for (const line of lines) {
6188
+ const document = tryParseJson(line);
6189
+ if (document === void 0) {
6190
+ if (parsedDocument) return void 0;
6191
+ continue;
6192
+ }
6193
+ documents.push(document);
6194
+ if (documents.length > MAX_JSON_DOCUMENTS) return void 0;
6195
+ parsedDocument = true;
6196
+ }
6197
+ return documents.length === 0 ? void 0 : documents;
6198
+ }
6199
+ function tryParseJson(input) {
6112
6200
  try {
6113
6201
  return JSON.parse(input);
6114
6202
  } catch {
6115
6203
  return;
6116
6204
  }
6117
6205
  }
6206
+ function structuredErrorCodeFromOutput(input) {
6207
+ for (const value of parseJsonDocuments(input) ?? []) {
6208
+ const code = structuredErrorCode(value);
6209
+ if (code !== void 0) return code;
6210
+ }
6211
+ }
6118
6212
  function structuredErrorCode(value) {
6119
6213
  if (!isRecord(value)) return void 0;
6120
6214
  if (value.error !== void 0) {
@@ -6491,8 +6585,11 @@ function renderCodexSecurity(result) {
6491
6585
  var CODEX_SECURITY_SKIP_MESSAGES = {
6492
6586
  "codex-unavailable": "no usable Codex launcher was found.",
6493
6587
  unauthenticated: "Codex authentication is required.",
6494
- "marketplace-unavailable": "the plugin marketplace could not be reached.",
6588
+ "marketplace-unavailable": "the official plugin marketplace was unavailable.",
6589
+ "plugin-not-offered": "the configured marketplace does not offer the official plugin.",
6590
+ "all-launchers-lacked-plugin": "no usable Codex launcher offered the official plugin.",
6495
6591
  "plugin-unavailable": "the plugin was unavailable from every usable Codex launcher.",
6592
+ "verification-failed": "Codex did not confirm the plugin was installed and enabled.",
6496
6593
  "installation-rejected": "the account or workspace policy rejected installation.",
6497
6594
  timeout: "all usable Codex launchers timed out.",
6498
6595
  "invalid-response": "Codex returned an unsupported or malformed response.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holycodex",
3
- "version": "0.10.6-dev.30770925419.1",
3
+ "version": "0.10.7",
4
4
  "description": "Lean Codex-only agent toolkit installer and doctor",
5
5
  "keywords": [
6
6
  "agents",
@@ -39,7 +39,7 @@
39
39
  "prepack": "vp run --workspace-root build"
40
40
  },
41
41
  "dependencies": {
42
- "@holycodex/plugin": "0.10.6-dev.30770925419.1",
42
+ "@holycodex/plugin": "0.10.7",
43
43
  "zod": "^4.4.3"
44
44
  },
45
45
  "engines": {