pupt-lib 1.3.6 → 1.3.8

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
@@ -3857,6 +3857,9 @@ function createRuntimeConfig() {
3857
3857
  function isWarningCode(code) {
3858
3858
  return code.startsWith("warn_") || code === "validation_warning";
3859
3859
  }
3860
+ function isResolvedModuleEntry(value) {
3861
+ return value !== null && typeof value === "object" && "type" in value && "source" in value && "name" in value && typeof value.type === "string" && typeof value.source === "string" && typeof value.name === "string" && ["git", "npm", "local", "url"].includes(value.type);
3862
+ }
3860
3863
  function isPromptSource(value) {
3861
3864
  return value !== null && typeof value === "object" && "getPrompts" in value && typeof value.getPrompts === "function";
3862
3865
  }
@@ -43259,22 +43262,8 @@ class ModuleLoader {
43259
43262
  __publicField(this, "versions", /* @__PURE__ */ new Map());
43260
43263
  }
43261
43264
  /**
43262
- * Determine the source type from a source string
43263
- */
43264
- resolveSourceType(source) {
43265
- if (source.startsWith("https://") || source.startsWith("http://") || source.startsWith("data:")) {
43266
- return "url";
43267
- }
43268
- if (source.startsWith("github:")) {
43269
- return "github";
43270
- }
43271
- if (source.startsWith("./") || source.startsWith("/") || source.startsWith("../")) {
43272
- return "local";
43273
- }
43274
- return "npm";
43275
- }
43276
- /**
43277
- * Parse a package source string into name and version
43265
+ * Parse a package source string into name and version.
43266
+ * Handles scoped packages (@scope/name@version) and regular packages (name@version).
43278
43267
  */
43279
43268
  parsePackageSource(source) {
43280
43269
  if (source.startsWith("@")) {
@@ -43297,55 +43286,57 @@ class ModuleLoader {
43297
43286
  return { name: source };
43298
43287
  }
43299
43288
  /**
43300
- * Load a module from the given source.
43301
- * Handles deduplication and version conflict detection.
43289
+ * Load a module entry (ResolvedModuleEntry, PromptSource, or package reference).
43290
+ * Dispatches to the appropriate loading strategy based on entry type.
43302
43291
  */
43303
- async load(source) {
43304
- const normalizedSource = this.normalizeSource(source);
43305
- const parsed = this.parsePackageSource(source);
43306
- if (parsed.version) {
43307
- const existingVersion = this.versions.get(parsed.name);
43308
- if (existingVersion && existingVersion !== parsed.version) {
43309
- throw new Error(
43310
- `Version conflict for ${parsed.name}: trying to load ${parsed.version} but ${existingVersion} is already loaded`
43311
- );
43312
- }
43292
+ async loadEntry(entry) {
43293
+ if (isPromptSource(entry)) {
43294
+ return this.loadPromptSource(entry);
43313
43295
  }
43296
+ if (isResolvedModuleEntry(entry)) {
43297
+ return this.loadResolvedEntry(entry);
43298
+ }
43299
+ if (typeof entry === "object" && entry !== null && "source" in entry && "config" in entry) {
43300
+ return this.loadPackageReference(entry);
43301
+ }
43302
+ throw new Error("Invalid module entry: must be a ResolvedModuleEntry, PromptSource, or { source, config } object");
43303
+ }
43304
+ /**
43305
+ * Load a module from a ResolvedModuleEntry.
43306
+ * Uses the explicit `type` field for routing and passes `promptDirs` through
43307
+ * to the appropriate prompt source.
43308
+ */
43309
+ async loadResolvedEntry(entry) {
43310
+ const { name, type, source, promptDirs, version, branch } = entry;
43311
+ const normalizedSource = this.normalizeSource(source, type);
43314
43312
  if (this.loaded.has(normalizedSource)) {
43315
43313
  return this.loaded.get(normalizedSource);
43316
43314
  }
43317
43315
  if (this.loading.has(normalizedSource)) {
43318
43316
  return this.loading.get(normalizedSource);
43319
43317
  }
43320
- const promise = this.doLoad(source);
43318
+ if (version) {
43319
+ const existingVersion = this.versions.get(name);
43320
+ if (existingVersion && existingVersion !== version) {
43321
+ throw new Error(
43322
+ `Version conflict for ${name}: trying to load ${version} but ${existingVersion} is already loaded`
43323
+ );
43324
+ }
43325
+ }
43326
+ const promise = this.doLoad(type, source, promptDirs, branch);
43321
43327
  this.loading.set(normalizedSource, promise);
43322
43328
  try {
43323
43329
  const library = await promise;
43330
+ library.name = name;
43324
43331
  this.loaded.set(normalizedSource, library);
43325
- if (parsed.version) {
43326
- this.versions.set(parsed.name, parsed.version);
43332
+ if (version) {
43333
+ this.versions.set(name, version);
43327
43334
  }
43328
43335
  return library;
43329
43336
  } finally {
43330
43337
  this.loading.delete(normalizedSource);
43331
43338
  }
43332
43339
  }
43333
- /**
43334
- * Load a module entry of any type (string, PromptSource, or package reference).
43335
- * Dispatches to the appropriate loading strategy based on entry type.
43336
- */
43337
- async loadEntry(entry) {
43338
- if (typeof entry === "string") {
43339
- return this.load(entry);
43340
- }
43341
- if (isPromptSource(entry)) {
43342
- return this.loadPromptSource(entry);
43343
- }
43344
- if (typeof entry === "object" && entry !== null && "source" in entry && "config" in entry) {
43345
- return this.loadPackageReference(entry);
43346
- }
43347
- throw new Error("Invalid module entry: must be a string, PromptSource, or { source, config } object");
43348
- }
43349
43340
  /**
43350
43341
  * Load prompts from a PromptSource instance.
43351
43342
  */
@@ -43415,23 +43406,12 @@ class ModuleLoader {
43415
43406
  }
43416
43407
  return prompts;
43417
43408
  }
43418
- /**
43419
- * Check if a value is a PuptElement with a name prop (indicates a Prompt)
43420
- */
43421
- isPromptElement(value) {
43422
- if (!isPuptElement(value)) {
43423
- return false;
43424
- }
43425
- const props = value[PROPS];
43426
- return props !== null && typeof props === "object" && "name" in props;
43427
- }
43428
43409
  /**
43429
43410
  * Normalize a source string for consistent deduplication.
43430
43411
  * Resolves relative paths to absolute, normalizes package names to lowercase.
43431
43412
  */
43432
- normalizeSource(source) {
43433
- const sourceType = this.resolveSourceType(source);
43434
- if (sourceType === "local" && isNode) {
43413
+ normalizeSource(source, type) {
43414
+ if (type === "local" && isNode) {
43435
43415
  try {
43436
43416
  if (source.startsWith("./") || source.startsWith("../")) {
43437
43417
  const cwd = process.cwd();
@@ -43440,32 +43420,13 @@ class ModuleLoader {
43440
43420
  } catch {
43441
43421
  }
43442
43422
  }
43443
- if (sourceType === "npm") {
43423
+ if (type === "npm") {
43444
43424
  const parsed = this.parsePackageSource(source);
43445
43425
  const normalizedName = parsed.name.toLowerCase();
43446
43426
  return parsed.version ? `${normalizedName}@${parsed.version}` : normalizedName;
43447
43427
  }
43448
43428
  return source;
43449
43429
  }
43450
- /**
43451
- * Actually load the module from the source.
43452
- * This is the internal implementation that can be mocked in tests.
43453
- */
43454
- async doLoad(source) {
43455
- const sourceType = this.resolveSourceType(source);
43456
- switch (sourceType) {
43457
- case "local":
43458
- return this.loadLocal(source);
43459
- case "npm":
43460
- return this.loadNpm(source);
43461
- case "url":
43462
- return this.loadUrl(source);
43463
- case "github":
43464
- return this.loadGithub(source);
43465
- default:
43466
- throw new Error(`Unsupported source type: ${sourceType}`);
43467
- }
43468
- }
43469
43430
  /**
43470
43431
  * Discover and compile .prompt files from a PromptSource.
43471
43432
  * Each file is compiled through createPromptFromSource() and metadata extracted.
@@ -43474,6 +43435,43 @@ class ModuleLoader {
43474
43435
  const files = await source.getPrompts();
43475
43436
  return this.compilePromptFiles(files);
43476
43437
  }
43438
+ /**
43439
+ * Clear all loaded modules (useful for testing)
43440
+ */
43441
+ clear() {
43442
+ this.loaded.clear();
43443
+ this.loading.clear();
43444
+ this.versions.clear();
43445
+ }
43446
+ /**
43447
+ * Convert detected PuptElement prompts from JS exports into CompiledPrompt records.
43448
+ */
43449
+ convertDetectedPrompts(detectedPrompts) {
43450
+ const prompts = {};
43451
+ for (const [exportName, element] of Object.entries(detectedPrompts)) {
43452
+ const props = element[PROPS];
43453
+ const name = (props == null ? void 0 : props.name) ?? exportName;
43454
+ prompts[name] = {
43455
+ element,
43456
+ id: crypto.randomUUID(),
43457
+ name,
43458
+ description: (props == null ? void 0 : props.description) ?? "",
43459
+ tags: (props == null ? void 0 : props.tags) ?? [],
43460
+ version: props == null ? void 0 : props.version
43461
+ };
43462
+ }
43463
+ return prompts;
43464
+ }
43465
+ /**
43466
+ * Check if a value is a PuptElement with a name prop (indicates a Prompt)
43467
+ */
43468
+ isPromptElement(value) {
43469
+ if (!isPuptElement(value)) {
43470
+ return false;
43471
+ }
43472
+ const props = value[PROPS];
43473
+ return props !== null && typeof props === "object" && "name" in props;
43474
+ }
43477
43475
  /**
43478
43476
  * Compile an array of discovered prompt files into CompiledPrompt records.
43479
43477
  */
@@ -43494,10 +43492,27 @@ class ModuleLoader {
43494
43492
  }
43495
43493
  return prompts;
43496
43494
  }
43495
+ /**
43496
+ * Internal load dispatch using explicit type and passing promptDirs to prompt sources.
43497
+ */
43498
+ async doLoad(type, source, promptDirs, branch) {
43499
+ switch (type) {
43500
+ case "local":
43501
+ return this.loadLocal(source, promptDirs);
43502
+ case "npm":
43503
+ return this.loadNpm(source, promptDirs);
43504
+ case "url":
43505
+ return this.loadUrl(source);
43506
+ case "git":
43507
+ return this.loadGit(source, promptDirs, branch);
43508
+ default:
43509
+ throw new Error(`Unsupported module type: ${type}`);
43510
+ }
43511
+ }
43497
43512
  /**
43498
43513
  * Load a local module
43499
43514
  */
43500
- async loadLocal(source) {
43515
+ async loadLocal(source, promptDirs) {
43501
43516
  let components = {};
43502
43517
  let dependencies = [];
43503
43518
  let prompts = {};
@@ -43509,13 +43524,16 @@ class ModuleLoader {
43509
43524
  );
43510
43525
  components = this.detectComponents(module);
43511
43526
  dependencies = module.dependencies ?? [];
43527
+ const jsPrompts = this.detectPrompts(module);
43528
+ prompts = this.convertDetectedPrompts(jsPrompts);
43512
43529
  } catch {
43513
43530
  }
43514
43531
  if (isNode) {
43515
43532
  try {
43516
43533
  const { LocalPromptSource: LocalPromptSource2 } = await Promise.resolve().then(() => localPromptSource);
43517
- const promptSource = new LocalPromptSource2(source);
43518
- prompts = await this.discoverAndCompilePrompts(promptSource);
43534
+ const promptSource = new LocalPromptSource2(source, { promptDirs });
43535
+ const filePrompts = await this.discoverAndCompilePrompts(promptSource);
43536
+ prompts = { ...prompts, ...filePrompts };
43519
43537
  } catch {
43520
43538
  }
43521
43539
  }
@@ -43535,7 +43553,7 @@ class ModuleLoader {
43535
43553
  * Load an npm package.
43536
43554
  * Tries to import as a JS module and additionally discovers .prompt files.
43537
43555
  */
43538
- async loadNpm(source) {
43556
+ async loadNpm(source, promptDirs) {
43539
43557
  const parsed = this.parsePackageSource(source);
43540
43558
  let components = {};
43541
43559
  let dependencies = [];
@@ -43546,13 +43564,16 @@ class ModuleLoader {
43546
43564
  components = this.detectComponents(module);
43547
43565
  dependencies = module.dependencies ?? [];
43548
43566
  jsLoaded = true;
43567
+ const jsPrompts = this.detectPrompts(module);
43568
+ prompts = this.convertDetectedPrompts(jsPrompts);
43549
43569
  } catch {
43550
43570
  }
43551
43571
  if (isNode) {
43552
43572
  try {
43553
43573
  const { NpmLocalPromptSource: NpmLocalPromptSource2 } = await Promise.resolve().then(() => npmLocalPromptSource);
43554
- const promptSource = new NpmLocalPromptSource2(parsed.name);
43555
- prompts = await this.discoverAndCompilePrompts(promptSource);
43574
+ const promptSource = new NpmLocalPromptSource2(parsed.name, { promptDirs });
43575
+ const filePrompts = await this.discoverAndCompilePrompts(promptSource);
43576
+ prompts = { ...prompts, ...filePrompts };
43556
43577
  } catch {
43557
43578
  }
43558
43579
  }
@@ -43622,20 +43643,23 @@ class ModuleLoader {
43622
43643
  };
43623
43644
  }
43624
43645
  /**
43625
- * Load a module from GitHub.
43626
- * Tries to import index.js and additionally discovers .prompt files via GitHubPromptSource.
43646
+ * Load a module from a Git source (GitHub URL).
43647
+ * Extracts owner/repo from the URL, tries JS import and .prompt file discovery.
43627
43648
  */
43628
- async loadGithub(source) {
43629
- const match = source.match(/^github:([^/]+)\/([^#]+)(?:#(.+))?$/);
43649
+ async loadGit(source, promptDirs, branch) {
43650
+ const match = source.match(/github\.com[/:]([^/]+)\/([^/.#]+)/);
43630
43651
  if (!match) {
43631
- throw new Error(`Invalid GitHub source format: ${source}`);
43652
+ throw new Error(`Cannot extract GitHub owner/repo from source: ${source}`);
43632
43653
  }
43633
- const [, user, repo, ref] = match;
43654
+ const [, owner, repo] = match;
43655
+ const hashIndex = source.indexOf("#");
43656
+ const fragmentRef = hashIndex !== -1 ? source.slice(hashIndex + 1) : void 0;
43657
+ const ref = branch ?? fragmentRef;
43634
43658
  let components = {};
43635
43659
  let dependencies = [];
43636
43660
  let prompts = {};
43637
43661
  try {
43638
- const url = `https://raw.githubusercontent.com/${user}/${repo}/${ref ?? "main"}/index.js`;
43662
+ const url = `https://raw.githubusercontent.com/${owner}/${repo}/${ref ?? "master"}/index.js`;
43639
43663
  const library = await this.loadUrl(url);
43640
43664
  components = library.components;
43641
43665
  dependencies = library.dependencies;
@@ -43643,8 +43667,8 @@ class ModuleLoader {
43643
43667
  }
43644
43668
  try {
43645
43669
  const { GitHubPromptSource: GitHubPromptSource2 } = await Promise.resolve().then(() => githubPromptSource);
43646
- const ownerRepo = `${user}/${repo}`;
43647
- const options = ref ? { ref } : void 0;
43670
+ const ownerRepo = `${owner}/${repo}`;
43671
+ const options = { ref, promptDirs };
43648
43672
  const promptSource = new GitHubPromptSource2(ownerRepo, options);
43649
43673
  prompts = await this.discoverAndCompilePrompts(promptSource);
43650
43674
  } catch {
@@ -43655,7 +43679,7 @@ class ModuleLoader {
43655
43679
  );
43656
43680
  }
43657
43681
  return {
43658
- name: `${user}/${repo}`,
43682
+ name: `${owner}/${repo}`,
43659
43683
  components,
43660
43684
  prompts,
43661
43685
  dependencies
@@ -43682,19 +43706,13 @@ class ModuleLoader {
43682
43706
  return "unknown";
43683
43707
  }
43684
43708
  }
43685
- /**
43686
- * Clear all loaded modules (useful for testing)
43687
- */
43688
- clear() {
43689
- this.loaded.clear();
43690
- this.loading.clear();
43691
- this.versions.clear();
43692
- }
43693
43709
  }
43694
43710
  class LocalPromptSource {
43695
- constructor(dirPath) {
43711
+ constructor(dirPath, options) {
43696
43712
  __publicField(this, "dirPath");
43713
+ __publicField(this, "promptDirs");
43697
43714
  this.dirPath = dirPath;
43715
+ this.promptDirs = options == null ? void 0 : options.promptDirs;
43698
43716
  }
43699
43717
  async getPrompts() {
43700
43718
  const fs = await import("fs/promises");
@@ -43705,6 +43723,9 @@ class LocalPromptSource {
43705
43723
  } catch {
43706
43724
  throw new Error(`Directory not found: ${resolvedPath}`);
43707
43725
  }
43726
+ if (this.promptDirs && this.promptDirs.length > 0) {
43727
+ return this.scanPromptDirs(resolvedPath, this.promptDirs);
43728
+ }
43708
43729
  let scanDir = resolvedPath;
43709
43730
  const entries = await fs.readdir(resolvedPath);
43710
43731
  const hasPromptFiles = entries.some((e) => e.endsWith(".prompt"));
@@ -43717,6 +43738,32 @@ class LocalPromptSource {
43717
43738
  return [];
43718
43739
  }
43719
43740
  }
43741
+ return this.scanDirectory(scanDir);
43742
+ }
43743
+ /**
43744
+ * Scan explicit prompt directories relative to the base path.
43745
+ */
43746
+ async scanPromptDirs(basePath, promptDirs) {
43747
+ const path = await import("path");
43748
+ const fs = await import("fs/promises");
43749
+ const results = [];
43750
+ for (const dir of promptDirs) {
43751
+ const fullDir = path.join(basePath, dir);
43752
+ try {
43753
+ await fs.access(fullDir);
43754
+ const dirResults = await this.scanDirectory(fullDir);
43755
+ results.push(...dirResults);
43756
+ } catch {
43757
+ }
43758
+ }
43759
+ return results;
43760
+ }
43761
+ /**
43762
+ * Scan a single directory for .prompt files.
43763
+ */
43764
+ async scanDirectory(scanDir) {
43765
+ const fs = await import("fs/promises");
43766
+ const path = await import("path");
43720
43767
  const dirEntries = await fs.readdir(scanDir);
43721
43768
  const promptFiles = dirEntries.filter((e) => e.endsWith(".prompt"));
43722
43769
  const results = [];
@@ -43733,27 +43780,32 @@ const localPromptSource = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.d
43733
43780
  LocalPromptSource
43734
43781
  }, Symbol.toStringTag, { value: "Module" }));
43735
43782
  class NpmLocalPromptSource {
43736
- constructor(packageName) {
43783
+ constructor(packageName, options) {
43737
43784
  __publicField(this, "packageName");
43785
+ __publicField(this, "promptDirs");
43738
43786
  this.packageName = packageName;
43787
+ this.promptDirs = options == null ? void 0 : options.promptDirs;
43739
43788
  }
43740
43789
  async getPrompts() {
43741
43790
  const packageDir = await this.resolvePackagePath(this.packageName);
43742
43791
  const fs = await import("fs/promises");
43743
43792
  const path = await import("path");
43744
- const promptsDir = path.join(packageDir, "prompts");
43745
- try {
43746
- await fs.access(promptsDir);
43747
- } catch {
43748
- return [];
43749
- }
43750
- const entries = await fs.readdir(promptsDir);
43751
- const promptFiles = entries.filter((e) => e.endsWith(".prompt"));
43793
+ const dirs = this.promptDirs ?? ["prompts"];
43752
43794
  const results = [];
43753
- for (const filename of promptFiles) {
43754
- const filePath = path.join(promptsDir, filename);
43755
- const content = await fs.readFile(filePath, "utf-8");
43756
- results.push({ filename, content });
43795
+ for (const dir of dirs) {
43796
+ const promptsDir = path.join(packageDir, dir);
43797
+ try {
43798
+ await fs.access(promptsDir);
43799
+ } catch {
43800
+ continue;
43801
+ }
43802
+ const entries = await fs.readdir(promptsDir);
43803
+ const promptFiles = entries.filter((e) => e.endsWith(".prompt"));
43804
+ for (const filename of promptFiles) {
43805
+ const filePath = path.join(promptsDir, filename);
43806
+ const content = await fs.readFile(filePath, "utf-8");
43807
+ results.push({ filename, content });
43808
+ }
43757
43809
  }
43758
43810
  return results;
43759
43811
  }
@@ -43814,11 +43866,13 @@ class GitHubPromptSource {
43814
43866
  __publicField(this, "repo");
43815
43867
  __publicField(this, "ref");
43816
43868
  __publicField(this, "token");
43869
+ __publicField(this, "promptDirs");
43817
43870
  const parsed = parseGitHubSource(ownerRepo);
43818
43871
  this.owner = parsed.owner;
43819
43872
  this.repo = parsed.repo;
43820
- this.ref = (options == null ? void 0 : options.ref) ?? parsed.ref ?? "main";
43873
+ this.ref = (options == null ? void 0 : options.ref) ?? parsed.ref ?? "master";
43821
43874
  this.token = options == null ? void 0 : options.token;
43875
+ this.promptDirs = options == null ? void 0 : options.promptDirs;
43822
43876
  }
43823
43877
  async getPrompts() {
43824
43878
  const tree = await this.fetchTree();
@@ -43861,8 +43915,12 @@ class GitHubPromptSource {
43861
43915
  return data.tree;
43862
43916
  }
43863
43917
  filterPromptFiles(tree) {
43918
+ const dirs = this.promptDirs ?? ["prompts"];
43864
43919
  return tree.filter(
43865
- (entry) => entry.type === "blob" && entry.path.startsWith("prompts/") && entry.path.endsWith(".prompt")
43920
+ (entry) => entry.type === "blob" && entry.path.endsWith(".prompt") && dirs.some((dir) => {
43921
+ const prefix = dir.endsWith("/") ? dir : `${dir}/`;
43922
+ return entry.path.startsWith(prefix);
43923
+ })
43866
43924
  );
43867
43925
  }
43868
43926
  async fetchFileContent(path) {
@@ -48544,7 +48602,6 @@ class Pupt {
48544
48602
  return [...this.warnings];
48545
48603
  }
48546
48604
  async discoverPrompts() {
48547
- var _a2;
48548
48605
  const discovered = [];
48549
48606
  const processedLibraries = /* @__PURE__ */ new Set();
48550
48607
  for (const entry of this.config.modules ?? []) {
@@ -48568,29 +48625,8 @@ class Pupt {
48568
48625
  );
48569
48626
  discovered.push(prompt);
48570
48627
  }
48571
- if (typeof entry === "string" && !isPromptSource(entry)) {
48572
- try {
48573
- const moduleExports = await this.loadModuleExports(entry);
48574
- for (const [, value] of Object.entries(moduleExports)) {
48575
- if (this.isPromptElement(value)) {
48576
- const element = value;
48577
- const props = element[PROPS];
48578
- const prompt = this.createDiscoveredPrompt(
48579
- crypto.randomUUID(),
48580
- props.name,
48581
- props.description ?? "",
48582
- props.tags ?? [],
48583
- library.name,
48584
- element
48585
- );
48586
- discovered.push(prompt);
48587
- }
48588
- }
48589
- } catch {
48590
- }
48591
- }
48592
48628
  } catch (error) {
48593
- const sourceId = typeof entry === "string" ? entry : isPromptSource(entry) ? ((_a2 = entry.constructor) == null ? void 0 : _a2.name) ?? "PromptSource" : `{ source: ${entry.source} }`;
48629
+ const sourceId = this.getEntryDisplayName(entry);
48594
48630
  const message = error instanceof Error ? error.message : String(error);
48595
48631
  this.warnings.push(`Failed to load module "${sourceId}": ${message}`);
48596
48632
  }
@@ -48602,32 +48638,33 @@ class Pupt {
48602
48638
  * Returns null for PromptSource instances (cannot be deduplicated).
48603
48639
  */
48604
48640
  getEntryDedupKey(entry) {
48605
- if (typeof entry === "string") {
48606
- return this.moduleLoader.normalizeSource(entry);
48607
- }
48608
48641
  if (isPromptSource(entry)) {
48609
48642
  return null;
48610
48643
  }
48644
+ if (isResolvedModuleEntry(entry)) {
48645
+ return this.moduleLoader.normalizeSource(entry.source, entry.type);
48646
+ }
48611
48647
  if (typeof entry === "object" && entry !== null && "source" in entry && "config" in entry) {
48612
48648
  const ref = entry;
48613
48649
  return `pkg:${ref.source}:${JSON.stringify(ref.config)}`;
48614
48650
  }
48615
48651
  return null;
48616
48652
  }
48617
- async loadModuleExports(source) {
48653
+ /**
48654
+ * Get a human-readable display name for a module entry (used in error messages).
48655
+ */
48656
+ getEntryDisplayName(entry) {
48618
48657
  var _a2;
48619
- const isNode2 = typeof process !== "undefined" && ((_a2 = process.versions) == null ? void 0 : _a2.node);
48620
- if (isNode2 && (source.startsWith("./") || source.startsWith("/") || source.startsWith("../"))) {
48621
- const path = await import("path");
48622
- const url = await import("url");
48623
- const absolutePath = path.resolve(process.cwd(), source);
48624
- const fileUrl = url.pathToFileURL(absolutePath).href;
48625
- return await import(
48626
- /* @vite-ignore */
48627
- fileUrl
48628
- );
48658
+ if (isPromptSource(entry)) {
48659
+ return ((_a2 = entry.constructor) == null ? void 0 : _a2.name) ?? "PromptSource";
48660
+ }
48661
+ if (isResolvedModuleEntry(entry)) {
48662
+ return entry.name;
48663
+ }
48664
+ if (typeof entry === "object" && entry !== null && "source" in entry) {
48665
+ return `{ source: ${entry.source} }`;
48629
48666
  }
48630
- return await import(source);
48667
+ return "unknown";
48631
48668
  }
48632
48669
  isPromptElement(value) {
48633
48670
  if (!isPuptElement(value)) {
package/dist/src/api.d.ts CHANGED
@@ -40,7 +40,10 @@ export declare class Pupt {
40
40
  * Returns null for PromptSource instances (cannot be deduplicated).
41
41
  */
42
42
  private getEntryDedupKey;
43
- private loadModuleExports;
43
+ /**
44
+ * Get a human-readable display name for a module entry (used in error messages).
45
+ */
46
+ private getEntryDisplayName;
44
47
  private isPromptElement;
45
48
  private createDiscoveredPrompt;
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY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AS;IAIlE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,YAAY,EAAE;IAI9E,OAAO,IAAI,MAAM,EAAE;IAInB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,EAAE;IAI3D,WAAW,IAAI,MAAM,EAAE;YAIT,eAAe;IAwC7B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,sBAAsB;CAgC/B"}
@@ -24,7 +24,7 @@ export { preprocessSource, isPromptFile } from './services/preprocessor';
24
24
  export type { PreprocessOptions } from './services/preprocessor';
25
25
  export { getBuiltinComponents, getAskComponents, getAskShorthand, getStructuralComponents, } from './services/component-discovery';
26
26
  export { ModuleLoader } from './services/module-loader';
27
- export type { SourceType, LoadedLibrary, CompiledPrompt, ParsedPackageSource } from './services/module-loader';
27
+ export type { LoadedLibrary, CompiledPrompt, ParsedPackageSource } from './services/module-loader';
28
28
  export { LocalPromptSource, NpmLocalPromptSource, GitHubPromptSource, parseGitHubSource, NpmRegistryPromptSource } from './services/prompt-sources';
29
29
  export type { GitHubPromptSourceOptions } from './services/prompt-sources';
30
30
  export { resolveCdn, generateImportMap, serializeImportMap, generateImportMapScript, generatePuptLibImportMap, generatePuptLibImportMapScript, } from './services/browser-support';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,sBAAsB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG/D,YAAY,EACV,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,SA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,CAAC;AAC1G,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC"}
@@ -1,9 +1,5 @@
1
- import { ComponentType, PuptElement, ModuleEntry } from '../types';
1
+ import { ComponentType, PuptElement, ModuleEntry, ResolvedModuleEntry } from '../types';
2
2
  import { PromptSource } from '../types/prompt-source';
3
- /**
4
- * Represents the source type of a module
5
- */
6
- export type SourceType = 'npm' | 'url' | 'github' | 'local';
7
3
  /** A compiled prompt from a discovered .prompt file */
8
4
  export interface CompiledPrompt {
9
5
  element: PuptElement;
@@ -38,23 +34,21 @@ export declare class ModuleLoader {
38
34
  private loading;
39
35
  private versions;
40
36
  /**
41
- * Determine the source type from a source string
42
- */
43
- resolveSourceType(source: string): SourceType;
44
- /**
45
- * Parse a package source string into name and version
37
+ * Parse a package source string into name and version.
38
+ * Handles scoped packages (@scope/name@version) and regular packages (name@version).
46
39
  */
47
40
  parsePackageSource(source: string): ParsedPackageSource;
48
41
  /**
49
- * Load a module from the given source.
50
- * Handles deduplication and version conflict detection.
51
- */
52
- load(source: string): Promise<LoadedLibrary>;
53
- /**
54
- * Load a module entry of any type (string, PromptSource, or package reference).
42
+ * Load a module entry (ResolvedModuleEntry, PromptSource, or package reference).
55
43
  * Dispatches to the appropriate loading strategy based on entry type.
56
44
  */
57
45
  loadEntry(entry: ModuleEntry): Promise<LoadedLibrary>;
46
+ /**
47
+ * Load a module from a ResolvedModuleEntry.
48
+ * Uses the explicit `type` field for routing and passes `promptDirs` through
49
+ * to the appropriate prompt source.
50
+ */
51
+ loadResolvedEntry(entry: ResolvedModuleEntry): Promise<LoadedLibrary>;
58
52
  /**
59
53
  * Load prompts from a PromptSource instance.
60
54
  */
@@ -76,29 +70,36 @@ export declare class ModuleLoader {
76
70
  * Detect Prompt elements in module exports
77
71
  */
78
72
  detectPrompts(exports: Record<string, unknown>): Record<string, PuptElement>;
79
- /**
80
- * Check if a value is a PuptElement with a name prop (indicates a Prompt)
81
- */
82
- private isPromptElement;
83
73
  /**
84
74
  * Normalize a source string for consistent deduplication.
85
75
  * Resolves relative paths to absolute, normalizes package names to lowercase.
86
76
  */
87
- normalizeSource(source: string): string;
88
- /**
89
- * Actually load the module from the source.
90
- * This is the internal implementation that can be mocked in tests.
91
- */
92
- private doLoad;
77
+ normalizeSource(source: string, type: ResolvedModuleEntry['type']): string;
93
78
  /**
94
79
  * Discover and compile .prompt files from a PromptSource.
95
80
  * Each file is compiled through createPromptFromSource() and metadata extracted.
96
81
  */
97
82
  discoverAndCompilePrompts(source: PromptSource): Promise<Record<string, CompiledPrompt>>;
83
+ /**
84
+ * Clear all loaded modules (useful for testing)
85
+ */
86
+ clear(): void;
87
+ /**
88
+ * Convert detected PuptElement prompts from JS exports into CompiledPrompt records.
89
+ */
90
+ private convertDetectedPrompts;
91
+ /**
92
+ * Check if a value is a PuptElement with a name prop (indicates a Prompt)
93
+ */
94
+ private isPromptElement;
98
95
  /**
99
96
  * Compile an array of discovered prompt files into CompiledPrompt records.
100
97
  */
101
98
  private compilePromptFiles;
99
+ /**
100
+ * Internal load dispatch using explicit type and passing promptDirs to prompt sources.
101
+ */
102
+ private doLoad;
102
103
  /**
103
104
  * Load a local module
104
105
  */
@@ -123,10 +124,10 @@ export declare class ModuleLoader {
123
124
  */
124
125
  private loadUrlAsPromptSource;
125
126
  /**
126
- * Load a module from GitHub.
127
- * Tries to import index.js and additionally discovers .prompt files via GitHubPromptSource.
127
+ * Load a module from a Git source (GitHub URL).
128
+ * Extracts owner/repo from the URL, tries JS import and .prompt file discovery.
128
129
  */
129
- private loadGithub;
130
+ private loadGit;
130
131
  /**
131
132
  * Extract a module name from a file path
132
133
  */
@@ -135,9 +136,5 @@ export declare class ModuleLoader {
135
136
  * Extract a module name from a URL
136
137
  */
137
138
  private extractNameFromUrl;
138
- /**
139
- * Clear all loaded modules (useful for testing)
140
- */
141
- clear(): void;
142
139
  }
143
140
  //# sourceMappingURL=module-loader.d.ts.map
@@ -1 +1 @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;;OAIG;IACG,oBAAoB,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IA+B5G;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAcjF;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;IAY5E;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,MAAM;IAqB1E;;;OAGG;IACG,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAK9F;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAmB9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;YACW,kBAAkB;IAoBhC;;OAEG;YACW,MAAM;IAoBpB;;OAEG;YACW,SAAS;IA6CvB;;;OAGG;YACW,OAAO;IA+CrB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;;;OAIG;YACW,OAAO;IAuBrB;;OAEG;YACW,qBAAqB;IAanC;;;OAGG;YACW,OAAO;IAqDrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAU3B"}
@@ -5,6 +5,8 @@ export interface GitHubPromptSourceOptions {
5
5
  ref?: string;
6
6
  /** GitHub personal access token for private repos or to avoid rate limiting. */
7
7
  token?: string;
8
+ /** Explicit prompt directories to scan (relative to repo root). Overrides default 'prompts/'. */
9
+ promptDirs?: string[];
8
10
  }
9
11
  /**
10
12
  * Parse a "owner/repo" string into its parts.
@@ -25,6 +27,7 @@ export declare class GitHubPromptSource implements PromptSource {
25
27
  private repo;
26
28
  private ref;
27
29
  private token?;
30
+ private promptDirs?;
28
31
  constructor(ownerRepo: string, options?: GitHubPromptSourceOptions);
29
32
  getPrompts(): Promise<DiscoveredPromptFile[]>;
30
33
  private fetchTree;
@@ -1 +1 @@
1
- {"version":3,"file":"github-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/github-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB/F;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,KAAK,CAAC,CAAS;gBAEX,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAQ5D,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAkBrC,SAAS;IA8BvB,OAAO,CAAC,iBAAiB;YAQX,gBAAgB;IAqB9B,OAAO,CAAC,UAAU;CAWnB"}
1
+ {"version":3,"file":"github-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/github-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAeD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB/F;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,UAAU,CAAC,CAAW;gBAElB,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAS5D,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAkBrC,SAAS;IA8BvB,OAAO,CAAC,iBAAiB;YAYX,gBAAgB;IAqB9B,OAAO,CAAC,UAAU;CAWnB"}
@@ -1,13 +1,30 @@
1
1
  import { PromptSource, DiscoveredPromptFile } from '../../types/prompt-source';
2
+ /** Options for LocalPromptSource */
3
+ export interface LocalPromptSourceOptions {
4
+ /** Explicit prompt directories to scan (relative to dirPath). Overrides default discovery. */
5
+ promptDirs?: string[];
6
+ }
2
7
  /**
3
8
  * Discovers .prompt files from a local filesystem directory.
4
9
  *
5
10
  * Accepts either a direct path to a directory containing .prompt files,
6
11
  * or a package root path that has a `prompts/` subdirectory.
12
+ *
13
+ * When `promptDirs` is provided, scans those specific subdirectories
14
+ * instead of using the default discovery heuristic.
7
15
  */
8
16
  export declare class LocalPromptSource implements PromptSource {
9
17
  private dirPath;
10
- constructor(dirPath: string);
18
+ private promptDirs?;
19
+ constructor(dirPath: string, options?: LocalPromptSourceOptions);
11
20
  getPrompts(): Promise<DiscoveredPromptFile[]>;
21
+ /**
22
+ * Scan explicit prompt directories relative to the base path.
23
+ */
24
+ private scanPromptDirs;
25
+ /**
26
+ * Scan a single directory for .prompt files.
27
+ */
28
+ private scanDirectory;
12
29
  }
13
30
  //# sourceMappingURL=local-prompt-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/local-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAIrB,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;CA6CpD"}
1
+ {"version":3,"file":"local-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/local-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,oCAAoC;AACpC,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAW;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAKzD,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAwCnD;;OAEG;YACW,cAAc;IAmB5B;;OAEG;YACW,aAAa;CAgB5B"}
@@ -1,13 +1,22 @@
1
1
  import { PromptSource, DiscoveredPromptFile } from '../../types/prompt-source';
2
+ /** Options for NpmLocalPromptSource */
3
+ export interface NpmLocalPromptSourceOptions {
4
+ /** Explicit prompt directories to scan (relative to package root). Overrides default 'prompts/'. */
5
+ promptDirs?: string[];
6
+ }
2
7
  /**
3
8
  * Discovers .prompt files from locally installed npm packages.
4
9
  *
5
10
  * Resolves the package to its location in node_modules/,
6
11
  * then looks for a `prompts/` subdirectory containing .prompt files.
12
+ *
13
+ * When `promptDirs` is provided, scans those specific subdirectories
14
+ * instead of the default `prompts/`.
7
15
  */
8
16
  export declare class NpmLocalPromptSource implements PromptSource {
9
17
  private packageName;
10
- constructor(packageName: string);
18
+ private promptDirs?;
19
+ constructor(packageName: string, options?: NpmLocalPromptSourceOptions);
11
20
  getPrompts(): Promise<DiscoveredPromptFile[]>;
12
21
  /**
13
22
  * Resolve a bare package name to its directory path in node_modules.
@@ -1 +1 @@
1
- {"version":3,"file":"npm-local-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/npm-local-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,WAAW,CAAS;gBAEhB,WAAW,EAAE,MAAM;IAIzB,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IA8BnD;;;OAGG;IACG,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA8B/D"}
1
+ {"version":3,"file":"npm-local-prompt-source.d.ts","sourceRoot":"","sources":["../../../../src/services/prompt-sources/npm-local-prompt-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,uCAAuC;AACvC,MAAM,WAAW,2BAA2B;IAC1C,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAC,CAAW;gBAElB,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,2BAA2B;IAKhE,UAAU,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAiCnD;;;OAGG;IACG,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA8B/D"}
@@ -7,7 +7,8 @@ export type { RenderOptions, RenderResult, RenderSuccess, RenderFailure, RenderE
7
7
  export { isWarningCode } from './render';
8
8
  export type { InputRequirement, ValidationResult, ValidationError, } from './input';
9
9
  export type { SearchablePrompt, SearchOptions, SearchResult, SearchResultMatch, SearchEngineConfig, } from './search';
10
- export type { ModuleEntry, PuptConfig, PuptLibrary, DiscoveredPrompt, LibraryLoadResult, PuptInitConfig, } from './module';
10
+ export type { ModuleEntry, ResolvedModuleEntry, PuptConfig, PuptLibrary, DiscoveredPrompt, LibraryLoadResult, PuptInitConfig, } from './module';
11
+ export { isResolvedModuleEntry } from './module';
11
12
  export type { DiscoveredPromptFile, PromptSource, } from './prompt-source';
12
13
  export { isPromptSource } from './prompt-source';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGhE,YAAY,EACV,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGzD,YAAY,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EAEvB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,oBAAoB,EACpB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGhE,YAAY,EACV,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGzD,YAAY,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EAEvB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD,YAAY,EACV,oBAAoB,EACpB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,12 +1,36 @@
1
1
  import { ComponentType } from './element';
2
2
  import { PromptSource } from './prompt-source';
3
+ /**
4
+ * A resolved module entry with explicit type and metadata.
5
+ * This is the richer format that tools like `pupt` can produce after
6
+ * installing/tracking libraries, providing explicit source type,
7
+ * version, and prompt directory information.
8
+ */
9
+ export interface ResolvedModuleEntry {
10
+ /** Display name for the module */
11
+ name: string;
12
+ /** Explicit source type — avoids heuristic string parsing */
13
+ type: 'git' | 'npm' | 'local' | 'url';
14
+ /** The source identifier (git URL, npm package name, local path, or URL) */
15
+ source: string;
16
+ /** Relative paths to prompt directories within the module (overrides default 'prompts/') */
17
+ promptDirs?: string[];
18
+ /** Version string (semver for npm, commit hash for git, etc.) */
19
+ version?: string;
20
+ /** Git branch name (only used for type: 'git'). Defaults to 'master'. */
21
+ branch?: string;
22
+ }
23
+ /**
24
+ * Type guard for ResolvedModuleEntry
25
+ */
26
+ export declare function isResolvedModuleEntry(value: unknown): value is ResolvedModuleEntry;
3
27
  /**
4
28
  * A module entry can be:
5
- * - A string (routed to built-in sources: local path, npm, URL, or GitHub)
29
+ * - A ResolvedModuleEntry with explicit type, source, and metadata
6
30
  * - A PromptSource instance (self-resolving prompt discovery)
7
31
  * - A package reference with dynamic source loader and config
8
32
  */
9
- export type ModuleEntry = string | PromptSource | {
33
+ export type ModuleEntry = ResolvedModuleEntry | PromptSource | {
10
34
  source: string;
11
35
  config: Record<string, unknown>;
12
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/types/module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,YAAY,GACZ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,C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AM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pupt-lib",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "TypeScript library for creating AI prompts using JSX syntax",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -114,8 +114,8 @@
114
114
  "typescript": "^5.7.3",
115
115
  "typescript-eslint": "^8.22.0",
116
116
  "vite": "^6.0.11",
117
- "vitepress": "^1.6.4",
118
117
  "vite-plugin-dts": "^4.5.0",
118
+ "vitepress": "^1.6.4",
119
119
  "vitest": "^3.0.4",
120
120
  "zod": "^3.22.0"
121
121
  }