@adhdev/daemon-core 0.6.51 → 0.6.52

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.d.ts CHANGED
@@ -981,6 +981,52 @@ declare class ProviderLoader {
981
981
  });
982
982
  private log;
983
983
  /**
984
+ * Ordered builtin roots used for local fallback/reference data.
985
+ */
986
+ getBuiltinDirs(): string[];
987
+ /**
988
+ * Primary builtin root used for local scaffolding/reference flows.
989
+ */
990
+ getPrimaryBuiltinDir(): string;
991
+ /**
992
+ * User override root (~/.adhdev/providers by default).
993
+ */
994
+ getUserDir(): string;
995
+ /**
996
+ * Auto-updated upstream root (~/.adhdev/providers/.upstream by default).
997
+ */
998
+ getUpstreamDir(): string;
999
+ /**
1000
+ * Provider search order for on-disk lookups.
1001
+ * Highest-priority editable overrides come first.
1002
+ */
1003
+ getProviderRoots(): string[];
1004
+ /**
1005
+ * Canonical provider directory shape for a given root.
1006
+ */
1007
+ getProviderDir(root: string, category: ProviderCategory, type: string): string;
1008
+ /**
1009
+ * Canonical user override directory for a provider.
1010
+ */
1011
+ getUserProviderDir(category: ProviderCategory, type: string): string;
1012
+ /**
1013
+ * Canonical upstream directory for a provider.
1014
+ */
1015
+ getUpstreamProviderDir(category: ProviderCategory, type: string): string;
1016
+ /**
1017
+ * Canonical builtin directory for a provider.
1018
+ */
1019
+ getBuiltinProviderDir(category: ProviderCategory, type: string): string;
1020
+ /**
1021
+ * Find the on-disk directory for a provider by type.
1022
+ * Search order: user override → upstream → builtin fallback.
1023
+ */
1024
+ findProviderDir(type: string): string | null;
1025
+ /**
1026
+ * Resolve a file within a provider directory.
1027
+ */
1028
+ resolveProviderFile(type: string, ...segments: string[]): string | null;
1029
+ /**
984
1030
  * Load all providers (3-tier priority)
985
1031
  * 1. .upstream/ (GitHub auto-download — primary source)
986
1032
  * 2. User custom (~/.adhdev/providers/ excluding .upstream)
@@ -1156,9 +1202,9 @@ declare class ProviderLoader {
1156
1202
  setSetting(type: string, key: string, value: any): boolean;
1157
1203
  /**
1158
1204
  * Find the on-disk directory for a provider by type.
1159
- * Checks builtinDir, upstreamDir, userDir in order.
1205
+ * Preferred shape: root/category/type. Legacy flat root/type is kept temporarily for compatibility.
1160
1206
  */
1161
- private findProviderDir;
1207
+ private findProviderDirInternal;
1162
1208
  /**
1163
1209
  * Build a scripts function map from individual .js files in a directory.
1164
1210
  * Each file is wrapped as: (params?) => fs.readFileSync(filePath, 'utf-8')
package/dist/index.js CHANGED
@@ -5849,6 +5849,76 @@ var ProviderLoader = class _ProviderLoader {
5849
5849
  }
5850
5850
  // ─── Public API ────────────────────────────────
5851
5851
  /**
5852
+ * Ordered builtin roots used for local fallback/reference data.
5853
+ */
5854
+ getBuiltinDirs() {
5855
+ return [...this.builtinDirs];
5856
+ }
5857
+ /**
5858
+ * Primary builtin root used for local scaffolding/reference flows.
5859
+ */
5860
+ getPrimaryBuiltinDir() {
5861
+ return this.builtinDirs[0];
5862
+ }
5863
+ /**
5864
+ * User override root (~/.adhdev/providers by default).
5865
+ */
5866
+ getUserDir() {
5867
+ return this.userDir;
5868
+ }
5869
+ /**
5870
+ * Auto-updated upstream root (~/.adhdev/providers/.upstream by default).
5871
+ */
5872
+ getUpstreamDir() {
5873
+ return this.upstreamDir;
5874
+ }
5875
+ /**
5876
+ * Provider search order for on-disk lookups.
5877
+ * Highest-priority editable overrides come first.
5878
+ */
5879
+ getProviderRoots() {
5880
+ return [this.userDir, this.upstreamDir, ...this.builtinDirs];
5881
+ }
5882
+ /**
5883
+ * Canonical provider directory shape for a given root.
5884
+ */
5885
+ getProviderDir(root, category, type) {
5886
+ return path6.join(root, category, type);
5887
+ }
5888
+ /**
5889
+ * Canonical user override directory for a provider.
5890
+ */
5891
+ getUserProviderDir(category, type) {
5892
+ return this.getProviderDir(this.userDir, category, type);
5893
+ }
5894
+ /**
5895
+ * Canonical upstream directory for a provider.
5896
+ */
5897
+ getUpstreamProviderDir(category, type) {
5898
+ return this.getProviderDir(this.upstreamDir, category, type);
5899
+ }
5900
+ /**
5901
+ * Canonical builtin directory for a provider.
5902
+ */
5903
+ getBuiltinProviderDir(category, type) {
5904
+ return this.getProviderDir(this.getPrimaryBuiltinDir(), category, type);
5905
+ }
5906
+ /**
5907
+ * Find the on-disk directory for a provider by type.
5908
+ * Search order: user override → upstream → builtin fallback.
5909
+ */
5910
+ findProviderDir(type) {
5911
+ return this.findProviderDirInternal(type);
5912
+ }
5913
+ /**
5914
+ * Resolve a file within a provider directory.
5915
+ */
5916
+ resolveProviderFile(type, ...segments) {
5917
+ const dir = this.findProviderDirInternal(type);
5918
+ if (!dir) return null;
5919
+ return path6.join(dir, ...segments);
5920
+ }
5921
+ /**
5852
5922
  * Load all providers (3-tier priority)
5853
5923
  * 1. .upstream/ (GitHub auto-download — primary source)
5854
5924
  * 2. User custom (~/.adhdev/providers/ excluding .upstream)
@@ -6174,7 +6244,7 @@ var ProviderLoader = class _ProviderLoader {
6174
6244
  * Tries scripts.js first, then individual .js files.
6175
6245
  */
6176
6246
  loadScriptsFromDir(type, scriptDir) {
6177
- const providerDir = this.findProviderDir(type);
6247
+ const providerDir = this.findProviderDirInternal(type);
6178
6248
  if (!providerDir) {
6179
6249
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
6180
6250
  return null;
@@ -6535,16 +6605,16 @@ var ProviderLoader = class _ProviderLoader {
6535
6605
  // ─── Private ───────────────────────────────────
6536
6606
  /**
6537
6607
  * Find the on-disk directory for a provider by type.
6538
- * Checks builtinDir, upstreamDir, userDir in order.
6608
+ * Preferred shape: root/category/type. Legacy flat root/type is kept temporarily for compatibility.
6539
6609
  */
6540
- findProviderDir(type) {
6610
+ findProviderDirInternal(type) {
6541
6611
  const provider = this.providers.get(type);
6542
6612
  if (!provider) return null;
6543
6613
  const cat = provider.category;
6544
- const searchRoots = [this.userDir, this.upstreamDir, ...this.builtinDirs];
6614
+ const searchRoots = this.getProviderRoots();
6545
6615
  for (const root of searchRoots) {
6546
6616
  if (!fs5.existsSync(root)) continue;
6547
- for (const candidate of [path6.join(root, type), path6.join(root, cat, type)]) {
6617
+ for (const candidate of [this.getProviderDir(root, cat, type), path6.join(root, type)]) {
6548
6618
  if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
6549
6619
  }
6550
6620
  const catDir = path6.join(root, cat);
@@ -11012,37 +11082,7 @@ var DevServer = class _DevServer {
11012
11082
  // ─── Provider File Explorer ───
11013
11083
  /** Find the provider directory on disk */
11014
11084
  findProviderDir(type) {
11015
- const provider = this.providerLoader.getMeta(type);
11016
- if (!provider) return null;
11017
- const cat = provider.category;
11018
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
11019
- const userDir = path12.join(os14.homedir(), ".adhdev", "providers");
11020
- const directCandidates = [
11021
- path12.join(userDir, type),
11022
- path12.join(builtinDir, cat, type),
11023
- path12.join(builtinDir, type)
11024
- ];
11025
- for (const d of directCandidates) {
11026
- if (fs9.existsSync(path12.join(d, "provider.json"))) return d;
11027
- }
11028
- const catDir = path12.join(builtinDir, cat);
11029
- if (fs9.existsSync(catDir)) {
11030
- try {
11031
- for (const entry of fs9.readdirSync(catDir, { withFileTypes: true })) {
11032
- if (!entry.isDirectory()) continue;
11033
- const jsonPath = path12.join(catDir, entry.name, "provider.json");
11034
- if (fs9.existsSync(jsonPath)) {
11035
- try {
11036
- const data = JSON.parse(fs9.readFileSync(jsonPath, "utf-8"));
11037
- if (data.type === type) return path12.join(catDir, entry.name);
11038
- } catch {
11039
- }
11040
- }
11041
- }
11042
- } catch {
11043
- }
11044
- }
11045
- return null;
11085
+ return this.providerLoader.findProviderDir(type);
11046
11086
  }
11047
11087
  /** GET /api/providers/:type/files — list all files in provider directory */
11048
11088
  async handleListFiles(type, _req, res) {
@@ -11437,10 +11477,9 @@ var DevServer = class _DevServer {
11437
11477
  }
11438
11478
  let targetDir;
11439
11479
  if (location === "user") {
11440
- targetDir = path12.join(os14.homedir(), ".adhdev", "providers", type);
11480
+ targetDir = this.providerLoader.getUserProviderDir(category, type);
11441
11481
  } else {
11442
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
11443
- targetDir = path12.join(builtinDir, category, type);
11482
+ targetDir = this.providerLoader.getBuiltinProviderDir(category, type);
11444
11483
  }
11445
11484
  const jsonPath = path12.join(targetDir, "provider.json");
11446
11485
  if (fs9.existsSync(jsonPath)) {
@@ -12249,7 +12288,7 @@ var DevServer = class _DevServer {
12249
12288
  const domContext = null;
12250
12289
  this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "loading_reference", message: `\uB808\uD37C\uB7F0\uC2A4 \uC2A4\uD06C\uB9BD\uD2B8 \uB85C\uB4DC \uC911 (${reference})...` } });
12251
12290
  let referenceScripts = {};
12252
- const builtinDir = this.providerLoader.builtinDirs?.[0] || path12.resolve(__dirname, "../providers/_builtin");
12291
+ const builtinDir = this.providerLoader.getPrimaryBuiltinDir();
12253
12292
  const refDir = path12.join(builtinDir, "ide", reference);
12254
12293
  if (fs9.existsSync(refDir)) {
12255
12294
  const scriptsDir = path12.join(refDir, "scripts");