@wix/ditto-codegen-public 1.0.438 → 1.0.439

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/out.js +61 -12
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -23768,8 +23768,39 @@ var require_skills_installer = __commonJS({
23768
23768
  var path_12 = require("path");
23769
23769
  var ditto_codegen_types_12 = require_dist4();
23770
23770
  var skills_override_12 = require_skills_override();
23771
- function hasSkills(dir) {
23772
- return (0, fs_1.existsSync)(dir) && (0, fs_1.readdirSync)(dir).length > 0;
23771
+ var STARTUP_SKILLS_PACKAGE = "@wix/agent-skills";
23772
+ var SKILLS_READY_TIMEOUT_MS = 3 * 6e4;
23773
+ var UNRESOLVED_GRACE_MS = 3e4;
23774
+ function discoverSkills(dir) {
23775
+ try {
23776
+ return (0, fs_1.readdirSync)(dir).filter((name) => (0, fs_1.existsSync)((0, path_12.join)(dir, name, "SKILL.md")));
23777
+ } catch (error) {
23778
+ if (error.code === void 0) {
23779
+ throw error;
23780
+ }
23781
+ return [];
23782
+ }
23783
+ }
23784
+ function tryResolveStartupPackage(outputPath) {
23785
+ try {
23786
+ return (0, path_12.dirname)(require.resolve(`${STARTUP_SKILLS_PACKAGE}/package.json`, {
23787
+ paths: [outputPath]
23788
+ }));
23789
+ } catch (error) {
23790
+ const code = error.code;
23791
+ if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
23792
+ return null;
23793
+ }
23794
+ throw error;
23795
+ }
23796
+ }
23797
+ function startupSkills(outputPath) {
23798
+ const packageRoot = tryResolveStartupPackage(outputPath);
23799
+ if (!packageRoot) {
23800
+ return [];
23801
+ }
23802
+ const nested = discoverSkills((0, path_12.join)(packageRoot, "skills"));
23803
+ return nested.length > 0 ? nested : discoverSkills(packageRoot);
23773
23804
  }
23774
23805
  var delay2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
23775
23806
  async function applySkillsOverride(outputPath, log) {
@@ -23789,32 +23820,50 @@ var require_skills_installer = __commonJS({
23789
23820
  });
23790
23821
  }
23791
23822
  }
23792
- async function ensureSkillsReady(outputPath, log, { timeoutMs = 6e4, intervalMs = 1e3 } = {}) {
23823
+ async function ensureSkillsReady(outputPath, log, { timeoutMs = SKILLS_READY_TIMEOUT_MS, intervalMs = 1e3, graceMs = UNRESOLVED_GRACE_MS, skillsDir = skills_override_12.SKILLS_DIR } = {}) {
23793
23824
  const projectSkillsDir = (0, path_12.join)(outputPath, ".agents", "skills");
23794
- const skillsPresent = () => hasSkills(skills_override_12.SKILLS_DIR) || hasSkills(projectSkillsDir);
23795
- if (skillsPresent()) {
23825
+ const start = Date.now();
23826
+ const inspect = (candidates) => {
23827
+ const present = [
23828
+ .../* @__PURE__ */ new Set([
23829
+ ...discoverSkills(skillsDir),
23830
+ ...discoverSkills(projectSkillsDir)
23831
+ ])
23832
+ ];
23833
+ const found = startupSkills(outputPath);
23834
+ const required = found.length > 0 ? found : candidates;
23835
+ const ready = present.length > 0 && (required.length > 0 ? required.some((name) => present.includes(name)) : Date.now() - start >= graceMs);
23836
+ return { present, candidates: required, ready };
23837
+ };
23838
+ let state = inspect([]);
23839
+ if (state.ready) {
23796
23840
  return;
23797
23841
  }
23798
- log.info("[Skills] Not present yet \u2014 waiting for the startup install", {
23799
- globalSkillsDir: skills_override_12.SKILLS_DIR,
23842
+ log.info(`[Skills] Not ready yet \u2014 waiting for any ${STARTUP_SKILLS_PACKAGE} skill`, {
23843
+ candidates: state.candidates,
23844
+ present: state.present,
23845
+ globalSkillsDir: skillsDir,
23800
23846
  projectSkillsDir,
23801
23847
  timeoutMs
23802
23848
  });
23803
23849
  const deadline = Date.now() + timeoutMs;
23804
23850
  while (Date.now() < deadline) {
23805
23851
  await delay2(intervalMs);
23806
- if (skillsPresent()) {
23807
- log.info("[Skills] Skills became available");
23852
+ state = inspect(state.candidates);
23853
+ if (state.ready) {
23854
+ log.info("[Skills] Skills became available", { present: state.present });
23808
23855
  return;
23809
23856
  }
23810
23857
  }
23811
- log.error("[Skills] No skills available after waiting", {
23812
- globalSkillsDir: skills_override_12.SKILLS_DIR,
23858
+ log.error("[Skills] Skills still not ready after waiting", {
23859
+ candidates: state.candidates,
23860
+ present: state.present,
23861
+ globalSkillsDir: skillsDir,
23813
23862
  projectSkillsDir,
23814
23863
  environment: process.env.CODEGEN_ENVIRONMENT,
23815
23864
  timeoutMs
23816
23865
  });
23817
- throw new ditto_codegen_types_12.ProcessExecutionError("Skills not available \u2014 verify the install-skills step (codegen-install --phase startup) ran and populated /root/.agents/skills.", { processType: ditto_codegen_types_12.ProcessType.INITIALIZATION });
23866
+ throw new ditto_codegen_types_12.ProcessExecutionError(`Skills not ready after ${timeoutMs}ms \u2014 no ${STARTUP_SKILLS_PACKAGE} skill reached ${skillsDir}. It provides [${state.candidates.join(", ")}]; the store has [${state.present.join(", ")}]. Verify the install-skills step (codegen-install --phase startup) ran.`, { processType: ditto_codegen_types_12.ProcessType.INITIALIZATION });
23818
23867
  }
23819
23868
  }
23820
23869
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.438",
3
+ "version": "1.0.439",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -29,5 +29,5 @@
29
29
  "esbuild": "^0.27.2",
30
30
  "vitest": "^4.0.16"
31
31
  },
32
- "falconPackageHash": "505e7fd77b8402842416d269ee4d6800b6ad3e313ae5d985dfd48792"
32
+ "falconPackageHash": "48343c7d8a2d3fb18094776d1e5d4acc5ac0d288071c300a89c145ab"
33
33
  }