adhdev 0.6.51 → 0.6.53

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/index.js CHANGED
@@ -5074,6 +5074,76 @@ var init_provider_loader = __esm({
5074
5074
  }
5075
5075
  // ─── Public API ────────────────────────────────
5076
5076
  /**
5077
+ * Ordered builtin roots used for local fallback/reference data.
5078
+ */
5079
+ getBuiltinDirs() {
5080
+ return [...this.builtinDirs];
5081
+ }
5082
+ /**
5083
+ * Primary builtin root used for local scaffolding/reference flows.
5084
+ */
5085
+ getPrimaryBuiltinDir() {
5086
+ return this.builtinDirs[0];
5087
+ }
5088
+ /**
5089
+ * User override root (~/.adhdev/providers by default).
5090
+ */
5091
+ getUserDir() {
5092
+ return this.userDir;
5093
+ }
5094
+ /**
5095
+ * Auto-updated upstream root (~/.adhdev/providers/.upstream by default).
5096
+ */
5097
+ getUpstreamDir() {
5098
+ return this.upstreamDir;
5099
+ }
5100
+ /**
5101
+ * Provider search order for on-disk lookups.
5102
+ * Highest-priority editable overrides come first.
5103
+ */
5104
+ getProviderRoots() {
5105
+ return [this.userDir, this.upstreamDir, ...this.builtinDirs];
5106
+ }
5107
+ /**
5108
+ * Canonical provider directory shape for a given root.
5109
+ */
5110
+ getProviderDir(root, category, type) {
5111
+ return path6.join(root, category, type);
5112
+ }
5113
+ /**
5114
+ * Canonical user override directory for a provider.
5115
+ */
5116
+ getUserProviderDir(category, type) {
5117
+ return this.getProviderDir(this.userDir, category, type);
5118
+ }
5119
+ /**
5120
+ * Canonical upstream directory for a provider.
5121
+ */
5122
+ getUpstreamProviderDir(category, type) {
5123
+ return this.getProviderDir(this.upstreamDir, category, type);
5124
+ }
5125
+ /**
5126
+ * Canonical builtin directory for a provider.
5127
+ */
5128
+ getBuiltinProviderDir(category, type) {
5129
+ return this.getProviderDir(this.getPrimaryBuiltinDir(), category, type);
5130
+ }
5131
+ /**
5132
+ * Find the on-disk directory for a provider by type.
5133
+ * Search order: user override → upstream → builtin fallback.
5134
+ */
5135
+ findProviderDir(type) {
5136
+ return this.findProviderDirInternal(type);
5137
+ }
5138
+ /**
5139
+ * Resolve a file within a provider directory.
5140
+ */
5141
+ resolveProviderFile(type, ...segments) {
5142
+ const dir = this.findProviderDirInternal(type);
5143
+ if (!dir) return null;
5144
+ return path6.join(dir, ...segments);
5145
+ }
5146
+ /**
5077
5147
  * Load all providers (3-tier priority)
5078
5148
  * 1. .upstream/ (GitHub auto-download — primary source)
5079
5149
  * 2. User custom (~/.adhdev/providers/ excluding .upstream)
@@ -5399,7 +5469,7 @@ var init_provider_loader = __esm({
5399
5469
  * Tries scripts.js first, then individual .js files.
5400
5470
  */
5401
5471
  loadScriptsFromDir(type, scriptDir) {
5402
- const providerDir = this.findProviderDir(type);
5472
+ const providerDir = this.findProviderDirInternal(type);
5403
5473
  if (!providerDir) {
5404
5474
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
5405
5475
  return null;
@@ -5760,18 +5830,17 @@ var init_provider_loader = __esm({
5760
5830
  // ─── Private ───────────────────────────────────
5761
5831
  /**
5762
5832
  * Find the on-disk directory for a provider by type.
5763
- * Checks builtinDir, upstreamDir, userDir in order.
5833
+ * Canonical shape: root/category/type.
5764
5834
  */
5765
- findProviderDir(type) {
5835
+ findProviderDirInternal(type) {
5766
5836
  const provider = this.providers.get(type);
5767
5837
  if (!provider) return null;
5768
5838
  const cat = provider.category;
5769
- const searchRoots = [this.userDir, this.upstreamDir, ...this.builtinDirs];
5839
+ const searchRoots = this.getProviderRoots();
5770
5840
  for (const root of searchRoots) {
5771
5841
  if (!fs5.existsSync(root)) continue;
5772
- for (const candidate of [path6.join(root, type), path6.join(root, cat, type)]) {
5773
- if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
5774
- }
5842
+ const candidate = this.getProviderDir(root, cat, type);
5843
+ if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
5775
5844
  const catDir = path6.join(root, cat);
5776
5845
  if (fs5.existsSync(catDir)) {
5777
5846
  try {
@@ -27300,37 +27369,7 @@ var init_dev_server = __esm({
27300
27369
  // ─── Provider File Explorer ───
27301
27370
  /** Find the provider directory on disk */
27302
27371
  findProviderDir(type) {
27303
- const provider = this.providerLoader.getMeta(type);
27304
- if (!provider) return null;
27305
- const cat = provider.category;
27306
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
27307
- const userDir = path12.join(os14.homedir(), ".adhdev", "providers");
27308
- const directCandidates = [
27309
- path12.join(userDir, type),
27310
- path12.join(builtinDir, cat, type),
27311
- path12.join(builtinDir, type)
27312
- ];
27313
- for (const d of directCandidates) {
27314
- if (fs9.existsSync(path12.join(d, "provider.json"))) return d;
27315
- }
27316
- const catDir = path12.join(builtinDir, cat);
27317
- if (fs9.existsSync(catDir)) {
27318
- try {
27319
- for (const entry of fs9.readdirSync(catDir, { withFileTypes: true })) {
27320
- if (!entry.isDirectory()) continue;
27321
- const jsonPath = path12.join(catDir, entry.name, "provider.json");
27322
- if (fs9.existsSync(jsonPath)) {
27323
- try {
27324
- const data = JSON.parse(fs9.readFileSync(jsonPath, "utf-8"));
27325
- if (data.type === type) return path12.join(catDir, entry.name);
27326
- } catch {
27327
- }
27328
- }
27329
- }
27330
- } catch {
27331
- }
27332
- }
27333
- return null;
27372
+ return this.providerLoader.findProviderDir(type);
27334
27373
  }
27335
27374
  /** GET /api/providers/:type/files — list all files in provider directory */
27336
27375
  async handleListFiles(type, _req, res) {
@@ -27725,10 +27764,9 @@ var init_dev_server = __esm({
27725
27764
  }
27726
27765
  let targetDir;
27727
27766
  if (location === "user") {
27728
- targetDir = path12.join(os14.homedir(), ".adhdev", "providers", type);
27767
+ targetDir = this.providerLoader.getUserProviderDir(category, type);
27729
27768
  } else {
27730
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
27731
- targetDir = path12.join(builtinDir, category, type);
27769
+ targetDir = this.providerLoader.getBuiltinProviderDir(category, type);
27732
27770
  }
27733
27771
  const jsonPath = path12.join(targetDir, "provider.json");
27734
27772
  if (fs9.existsSync(jsonPath)) {
@@ -28537,7 +28575,7 @@ var init_dev_server = __esm({
28537
28575
  const domContext = null;
28538
28576
  this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "loading_reference", message: `\uB808\uD37C\uB7F0\uC2A4 \uC2A4\uD06C\uB9BD\uD2B8 \uB85C\uB4DC \uC911 (${reference})...` } });
28539
28577
  let referenceScripts = {};
28540
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
28578
+ const builtinDir = this.providerLoader.getPrimaryBuiltinDir();
28541
28579
  const refDir = path12.join(builtinDir, "ide", reference);
28542
28580
  if (fs9.existsSync(refDir)) {
28543
28581
  const scriptsDir = path12.join(refDir, "scripts");
@@ -30944,7 +30982,7 @@ var init_adhdev_daemon = __esm({
30944
30982
  fs11 = __toESM(require("fs"));
30945
30983
  path14 = __toESM(require("path"));
30946
30984
  import_chalk2 = __toESM(require("chalk"));
30947
- pkgVersion = "0.6.51";
30985
+ pkgVersion = "0.6.53";
30948
30986
  if (pkgVersion === "unknown") {
30949
30987
  try {
30950
30988
  const possiblePaths = [