@prompd/cli 0.4.11 → 0.5.0-beta.10

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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/compile.d.ts.map +1 -1
  3. package/dist/commands/compile.js +8 -1
  4. package/dist/commands/compile.js.map +1 -1
  5. package/dist/commands/package.d.ts.map +1 -1
  6. package/dist/commands/package.js +319 -34
  7. package/dist/commands/package.js.map +1 -1
  8. package/dist/commands/registry.d.ts.map +1 -1
  9. package/dist/commands/registry.js +58 -4
  10. package/dist/commands/registry.js.map +1 -1
  11. package/dist/commands/run.d.ts.map +1 -1
  12. package/dist/commands/run.js +9 -5
  13. package/dist/commands/run.js.map +1 -1
  14. package/dist/commands/uninstall.d.ts.map +1 -1
  15. package/dist/commands/uninstall.js +52 -18
  16. package/dist/commands/uninstall.js.map +1 -1
  17. package/dist/commands/workflow.d.ts.map +1 -1
  18. package/dist/commands/workflow.js +10 -4
  19. package/dist/commands/workflow.js.map +1 -1
  20. package/dist/lib/auth.d.ts +0 -9
  21. package/dist/lib/auth.d.ts.map +1 -1
  22. package/dist/lib/auth.js +0 -14
  23. package/dist/lib/auth.js.map +1 -1
  24. package/dist/lib/commandExecutor.d.ts +2 -2
  25. package/dist/lib/commandExecutor.d.ts.map +1 -1
  26. package/dist/lib/commandExecutor.js +2 -2
  27. package/dist/lib/commandExecutor.js.map +1 -1
  28. package/dist/lib/compiler/file-system.d.ts.map +1 -1
  29. package/dist/lib/compiler/file-system.js +10 -0
  30. package/dist/lib/compiler/file-system.js.map +1 -1
  31. package/dist/lib/compiler/index.d.ts +1 -0
  32. package/dist/lib/compiler/index.d.ts.map +1 -1
  33. package/dist/lib/compiler/index.js +10 -1
  34. package/dist/lib/compiler/index.js.map +1 -1
  35. package/dist/lib/compiler/package-resolver.d.ts +38 -3
  36. package/dist/lib/compiler/package-resolver.d.ts.map +1 -1
  37. package/dist/lib/compiler/package-resolver.js +181 -40
  38. package/dist/lib/compiler/package-resolver.js.map +1 -1
  39. package/dist/lib/compiler/pipeline.d.ts.map +1 -1
  40. package/dist/lib/compiler/pipeline.js +9 -3
  41. package/dist/lib/compiler/pipeline.js.map +1 -1
  42. package/dist/lib/compiler/stages/semantic.d.ts +7 -0
  43. package/dist/lib/compiler/stages/semantic.d.ts.map +1 -1
  44. package/dist/lib/compiler/stages/semantic.js +78 -2
  45. package/dist/lib/compiler/stages/semantic.js.map +1 -1
  46. package/dist/lib/compiler/stages/template.d.ts +12 -0
  47. package/dist/lib/compiler/stages/template.d.ts.map +1 -1
  48. package/dist/lib/compiler/stages/template.js +117 -12
  49. package/dist/lib/compiler/stages/template.js.map +1 -1
  50. package/dist/lib/config.d.ts.map +1 -1
  51. package/dist/lib/config.js +20 -8
  52. package/dist/lib/config.js.map +1 -1
  53. package/dist/lib/executor.d.ts.map +1 -1
  54. package/dist/lib/executor.js +25 -14
  55. package/dist/lib/executor.js.map +1 -1
  56. package/dist/lib/index.d.ts +2 -0
  57. package/dist/lib/index.d.ts.map +1 -1
  58. package/dist/lib/index.js +5 -1
  59. package/dist/lib/index.js.map +1 -1
  60. package/dist/lib/nodeTypeRegistry.d.ts +1 -1
  61. package/dist/lib/nodeTypeRegistry.d.ts.map +1 -1
  62. package/dist/lib/providers/base.d.ts +6 -1
  63. package/dist/lib/providers/base.d.ts.map +1 -1
  64. package/dist/lib/providers/base.js +51 -8
  65. package/dist/lib/providers/base.js.map +1 -1
  66. package/dist/lib/providers/index.d.ts +1 -1
  67. package/dist/lib/providers/index.d.ts.map +1 -1
  68. package/dist/lib/providers/index.js.map +1 -1
  69. package/dist/lib/providers/types.d.ts +29 -0
  70. package/dist/lib/providers/types.d.ts.map +1 -1
  71. package/dist/lib/providers/types.js +26 -16
  72. package/dist/lib/providers/types.js.map +1 -1
  73. package/dist/lib/registry.d.ts +42 -3
  74. package/dist/lib/registry.d.ts.map +1 -1
  75. package/dist/lib/registry.js +451 -86
  76. package/dist/lib/registry.js.map +1 -1
  77. package/dist/lib/testHarness.d.ts +101 -0
  78. package/dist/lib/testHarness.d.ts.map +1 -0
  79. package/dist/lib/testHarness.js +45 -0
  80. package/dist/lib/testHarness.js.map +1 -0
  81. package/dist/lib/validation.d.ts.map +1 -1
  82. package/dist/lib/validation.js +10 -2
  83. package/dist/lib/validation.js.map +1 -1
  84. package/dist/lib/workflowExecutor.d.ts +7 -1
  85. package/dist/lib/workflowExecutor.d.ts.map +1 -1
  86. package/dist/lib/workflowExecutor.js +756 -346
  87. package/dist/lib/workflowExecutor.js.map +1 -1
  88. package/dist/lib/workflowTypes.d.ts +5 -1
  89. package/dist/lib/workflowTypes.d.ts.map +1 -1
  90. package/dist/lib/workflowTypes.js.map +1 -1
  91. package/dist/types/index.d.ts +54 -1
  92. package/dist/types/index.d.ts.map +1 -1
  93. package/dist/types/index.js +54 -1
  94. package/dist/types/index.js.map +1 -1
  95. package/package.json +125 -124
package/README.md CHANGED
@@ -215,7 +215,7 @@ npm run test:watch
215
215
  ## Architecture
216
216
 
217
217
  ```
218
- cli/npm/
218
+ typescript/
219
219
  ├── bin/ # Executable wrapper
220
220
  ├── src/
221
221
  │ ├── commands/ # CLI command implementations
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,IAAI,OAAO,CA4E9C"}
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,oBAAoB,IAAI,OAAO,CAmF9C"}
@@ -11,6 +11,7 @@ const commander_1 = require("commander");
11
11
  const fs_1 = require("fs");
12
12
  const path_1 = require("path");
13
13
  const compiler_1 = require("../lib/compiler");
14
+ const package_resolver_1 = require("../lib/compiler/package-resolver");
14
15
  function createCompileCommand() {
15
16
  const cmd = new commander_1.Command('compile');
16
17
  cmd
@@ -23,6 +24,7 @@ function createCompileCommand() {
23
24
  .option('-f, --params-file <file>', 'JSON parameter file')
24
25
  .option('-o, --output <file>', 'Output file path')
25
26
  .option('-v, --verbose', 'Verbose output with compilation details', false)
27
+ .option('-d, --dir <path>', 'Workspace root directory (default: auto-detect from prompd.json)')
26
28
  .action(async (source, options) => {
27
29
  try {
28
30
  // Collect parameters from different sources
@@ -57,12 +59,17 @@ function createCompileCommand() {
57
59
  console.log(`Parameters: ${Object.keys(parameters).length} parameter(s)`);
58
60
  console.log('');
59
61
  }
62
+ // Resolve workspace root: explicit --dir, or auto-detect from source file
63
+ const workspaceRoot = options.dir
64
+ ? (0, path_1.resolve)(options.dir)
65
+ : (0, package_resolver_1.findProjectRoot)((0, path_1.dirname)((0, path_1.resolve)(source)));
60
66
  // Compile with the 6-stage pipeline
61
67
  const result = await compiler.compile(source, {
62
68
  outputFormat,
63
69
  parameters,
64
70
  outputFile: options.output,
65
- verbose: options.verbose
71
+ verbose: options.verbose,
72
+ workspaceRoot
66
73
  });
67
74
  // Output result (if not written to file)
68
75
  if (!options.output) {
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/commands/compile.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAOH,oDA4EC;AAjFD,yCAAoC;AACpC,2BAAkC;AAClC,+BAA+B;AAC/B,8CAAiD;AAEjD,SAAgB,oBAAoB;IAClC,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC,CAAC;IAEnC,GAAG;SACA,WAAW,CAAC,yEAAyE,CAAC;SACtF,QAAQ,CAAC,UAAU,EAAE,mEAAmE,CAAC;SACzF,MAAM,CAAC,eAAe,EAAE,0EAA0E,EAAE,UAAU,CAAC;SAC/G,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;SACtD,MA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OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA8HD,wBAAsB,2BAA2B,CAC/C,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CA2W9B"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/commands/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsEpC,wBAAgB,oBAAoB,IAAI,OAAO,CAqE9C;AAoSD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CA0B3C;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4ND,wBAAsB,2BAA2B,CAC/C,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAme9B"}
@@ -43,10 +43,14 @@ const commander_1 = require("commander");
43
43
  const chalk_1 = __importDefault(require("chalk"));
44
44
  const fs = __importStar(require("fs-extra"));
45
45
  const path = __importStar(require("path"));
46
+ const yaml = __importStar(require("js-yaml"));
46
47
  const archiver_1 = __importDefault(require("archiver"));
47
48
  const crypto_1 = require("crypto");
49
+ const xlsx = __importStar(require("xlsx"));
50
+ const mammoth_1 = __importDefault(require("mammoth"));
48
51
  const security_1 = require("../lib/security");
49
52
  const compiler_1 = require("../lib/compiler");
53
+ const parser_1 = require("../lib/parser");
50
54
  const types_1 = require("../types");
51
55
  /**
52
56
  * Shared package creation logic (used by both 'package create' and 'pack')
@@ -69,6 +73,12 @@ async function handlePackageCreate(source, output, options) {
69
73
  console.error(chalk_1.default.red('Package creation requires -n/--name, -v/--pkg-version, and -d/--description options'));
70
74
  process.exit(1);
71
75
  }
76
+ // Validate --type if provided
77
+ if (options.type && !(0, types_1.isValidPackageType)(options.type)) {
78
+ console.error(chalk_1.default.red(`Invalid package type: '${options.type}'`));
79
+ console.error(chalk_1.default.dim(`Valid types: ${types_1.VALID_PACKAGE_TYPES.join(', ')}`));
80
+ process.exit(1);
81
+ }
72
82
  await packageFromDirectory(sourcePath, output, options);
73
83
  }
74
84
  function createPackageCommand() {
@@ -84,6 +94,7 @@ function createPackageCommand() {
84
94
  .option('-v, --pkg-version <version>', 'Package version')
85
95
  .option('-d, --description <description>', 'Package description')
86
96
  .option('-a, --author <author>', 'Package author')
97
+ .option('-t, --type <type>', 'Package type (package, workflow, skill, node-template)', 'package')
87
98
  .action(async (source, output, options) => {
88
99
  try {
89
100
  // Map pkgVersion to version for backwards compatibility
@@ -93,7 +104,8 @@ function createPackageCommand() {
93
104
  await handlePackageCreate(source, output, options);
94
105
  }
95
106
  catch (error) {
96
- console.error(chalk_1.default.red(`❌ Package creation failed: ${error.message}`));
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ console.error(chalk_1.default.red(`Package creation failed: ${message}`));
97
109
  process.exit(1);
98
110
  }
99
111
  });
@@ -134,6 +146,25 @@ function createPackageCommand() {
134
146
  }
135
147
  async function packageFromDirectory(sourceDir, outputPath, options = {}) {
136
148
  const { name, version, description, author } = options;
149
+ // Resolve package type: explicit --type flag > prompd.json type field > default 'package'
150
+ let packageType = options.type;
151
+ if (!packageType || packageType === 'package') {
152
+ const prompdJsonPath = path.join(sourceDir, 'prompd.json');
153
+ if (await fs.pathExists(prompdJsonPath)) {
154
+ try {
155
+ const prompdJson = await fs.readJson(prompdJsonPath);
156
+ if (prompdJson.type && (0, types_1.isValidPackageType)(prompdJson.type)) {
157
+ packageType = prompdJson.type;
158
+ }
159
+ }
160
+ catch {
161
+ // Ignore parse errors - fall through to default
162
+ }
163
+ }
164
+ }
165
+ if (!packageType) {
166
+ packageType = 'package';
167
+ }
137
168
  // Generate output path if not provided
138
169
  if (!outputPath) {
139
170
  outputPath = `${name.toLowerCase().replace(/\s+/g, '-')}-v${version}.pdpkg`;
@@ -147,7 +178,7 @@ async function packageFromDirectory(sourceDir, outputPath, options = {}) {
147
178
  version,
148
179
  description,
149
180
  author,
150
- type: 'package'
181
+ type: packageType
151
182
  };
152
183
  // Create package with default exclusions
153
184
  const exclusions = {
@@ -367,12 +398,14 @@ function createPackCommand() {
367
398
  .option('-d, --description <description>', 'Package description (overrides .pdproj)')
368
399
  .option('--author <author>', 'Package author (overrides .pdproj)')
369
400
  .option('-a, --author <author>', 'Package author (overrides .pdproj)')
401
+ .option('-t, --type <type>', 'Package type (package, workflow, skill, node-template)', 'package')
370
402
  .action(async (source, output, options) => {
371
403
  try {
372
404
  await handlePackageCreate(source, output, options);
373
405
  }
374
406
  catch (error) {
375
- console.error(chalk_1.default.red(`❌ Package creation failed: ${error.message}`));
407
+ const message = error instanceof Error ? error.message : String(error);
408
+ console.error(chalk_1.default.red(`Package creation failed: ${message}`));
376
409
  process.exit(1);
377
410
  }
378
411
  });
@@ -386,6 +419,7 @@ const PACKABLE_EXTENSIONS = [
386
419
  '.js', '.ts', '.mjs', '.cjs', // JavaScript/TypeScript
387
420
  '.py', '.sh', '.bash', // Scripts
388
421
  '.csv', '.xml', // Data files
422
+ '.xlsx', '.xls', '.docx', '.pdf', // Binary assets (pre-extracted to text during packaging)
389
423
  ];
390
424
  /** Directories to always exclude */
391
425
  const DEFAULT_EXCLUDE_DIRS = [
@@ -482,6 +516,96 @@ async function discoverPackableFiles(workspacePath, ignorePatterns = []) {
482
516
  await walkDir(workspacePath);
483
517
  return files.sort();
484
518
  }
519
+ /**
520
+ * Parse a single .prmd file and return all local file dependencies as
521
+ * workspace-relative paths. Traces:
522
+ * - system:, user:, task:, assistant:, response:, output: (file path values)
523
+ * - context: / contexts: (string or array of strings)
524
+ * - override: (object whose values are file paths)
525
+ * - inherits: (local .prmd path — excludes @scope/pkg references)
526
+ * - {% include "..." %} directives in the body
527
+ *
528
+ * Only paths starting with ./ or ../ are treated as file references.
529
+ * Returns workspace-relative forward-slash paths.
530
+ */
531
+ async function tracePrmdFileDependencies(prmdRelativePath, workspacePath) {
532
+ const deps = new Set();
533
+ const prmdDir = path.dirname(path.join(workspacePath, prmdRelativePath));
534
+ let content;
535
+ try {
536
+ content = (await fs.readFile(path.join(workspacePath, prmdRelativePath), 'utf-8')).replace(/\r\n/g, '\n');
537
+ }
538
+ catch {
539
+ return [];
540
+ }
541
+ // Parse YAML frontmatter
542
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
543
+ if (!fmMatch)
544
+ return [];
545
+ let frontmatter;
546
+ try {
547
+ frontmatter = yaml.load(fmMatch[1]) || {};
548
+ }
549
+ catch {
550
+ return [];
551
+ }
552
+ /** Resolve a ref relative to the .prmd file and return workspace-relative path, or null if out-of-workspace or not a path ref */
553
+ function resolve(ref) {
554
+ if (typeof ref !== 'string')
555
+ return null;
556
+ if (!ref.startsWith('./') && !ref.startsWith('../'))
557
+ return null;
558
+ const abs = path.resolve(prmdDir, ref);
559
+ const wsRoot = path.resolve(workspacePath);
560
+ if (!abs.startsWith(wsRoot + path.sep) && abs !== wsRoot)
561
+ return null;
562
+ return path.relative(workspacePath, abs).replace(/\\/g, '/');
563
+ }
564
+ // system:, user:, task:, assistant:, response:, output:
565
+ const sectionFields = ['system', 'user', 'task', 'assistant', 'response', 'output'];
566
+ for (const field of sectionFields) {
567
+ const val = frontmatter[field];
568
+ const refs = Array.isArray(val) ? val : [val];
569
+ for (const ref of refs) {
570
+ const r = resolve(ref);
571
+ if (r)
572
+ deps.add(r);
573
+ }
574
+ }
575
+ // context: / contexts:
576
+ const ctxVal = frontmatter['context'] ?? frontmatter['contexts'];
577
+ const ctxRefs = Array.isArray(ctxVal) ? ctxVal : ctxVal !== undefined ? [ctxVal] : [];
578
+ for (const ref of ctxRefs) {
579
+ const r = resolve(ref);
580
+ if (r)
581
+ deps.add(r);
582
+ }
583
+ // override: { key: "path" }
584
+ if (frontmatter['override'] && typeof frontmatter['override'] === 'object' && !Array.isArray(frontmatter['override'])) {
585
+ for (const val of Object.values(frontmatter['override'])) {
586
+ const r = resolve(val);
587
+ if (r)
588
+ deps.add(r);
589
+ }
590
+ }
591
+ // inherits: (local only — skip @scope/pkg refs)
592
+ const inherits = frontmatter['inherits'];
593
+ if (typeof inherits === 'string' && !inherits.startsWith('@')) {
594
+ const r = resolve(inherits.startsWith('./') || inherits.startsWith('../') ? inherits : './' + inherits);
595
+ if (r)
596
+ deps.add(r);
597
+ }
598
+ // {% include "..." %} in body
599
+ const body = content.slice(fmMatch[0].length);
600
+ const includeRe = /\{%-?\s*include\s+["']([^"']+)["']\s*-?%\}/g;
601
+ let m;
602
+ while ((m = includeRe.exec(body)) !== null) {
603
+ const r = resolve(m[1].startsWith('./') || m[1].startsWith('../') ? m[1] : './' + m[1]);
604
+ if (r)
605
+ deps.add(r);
606
+ }
607
+ return Array.from(deps);
608
+ }
485
609
  async function createPackageFromPrompdJson(workspacePath, outputDir) {
486
610
  const prompdJsonPath = path.join(workspacePath, 'prompd.json');
487
611
  // 1. Check prompd.json exists
@@ -515,6 +639,10 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
515
639
  if (!prompdJson.main) {
516
640
  return { success: false, error: 'prompd.json is missing required field: main (main .prmd entry point)' };
517
641
  }
642
+ // Validate package type if specified
643
+ if (prompdJson.type && !(0, types_1.isValidPackageType)(prompdJson.type)) {
644
+ return { success: false, error: `Invalid package type '${prompdJson.type}' in prompd.json. Valid types: package, workflow, skill, node-template` };
645
+ }
518
646
  // 4. Auto-discover files if files array is empty or missing
519
647
  let filesToPackage = prompdJson.files || [];
520
648
  let autoDiscovered = false;
@@ -623,6 +751,57 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
623
751
  error: `Validation errors in .prmd files:\n${errorList}`
624
752
  };
625
753
  }
754
+ // 6d. Validate that all relative file references in .prmd frontmatter are included in the package.
755
+ // This catches missing dependencies when an explicit files list is used in prompd.json.
756
+ if (!autoDiscovered) {
757
+ const parser = new parser_1.PrompdParser();
758
+ const missingDependencies = [];
759
+ const fileReferenceFields = ['system', 'context', 'task', 'user', 'assistant', 'response', 'output'];
760
+ const normalizedFilesToPackage = new Set(filesToPackage.map(f => f.replace(/\\/g, '/')));
761
+ for (const filePath of filesToPackage) {
762
+ if (!filePath.endsWith('.prmd'))
763
+ continue;
764
+ const fullPath = path.join(workspacePath, filePath);
765
+ try {
766
+ const content = await fs.readFile(fullPath, 'utf8');
767
+ const parsed = parser.parseContent(content);
768
+ if (!parsed.metadata)
769
+ continue;
770
+ const prmdDir = path.dirname(filePath).replace(/\\/g, '/');
771
+ for (const field of fileReferenceFields) {
772
+ const fieldValue = parsed.metadata[field];
773
+ if (!fieldValue)
774
+ continue;
775
+ const refs = Array.isArray(fieldValue)
776
+ ? fieldValue.filter((v) => typeof v === 'string')
777
+ : typeof fieldValue === 'string' ? [fieldValue] : [];
778
+ for (const ref of refs) {
779
+ if (!ref.startsWith('./') && !ref.startsWith('../'))
780
+ continue;
781
+ // Resolve relative to the .prmd file's directory (within workspace)
782
+ const resolvedRelative = path.posix.normalize(prmdDir === '.' ? ref : `${prmdDir}/${ref}`).replace(/\\/g, '/');
783
+ if (!normalizedFilesToPackage.has(resolvedRelative)) {
784
+ // Check if the file actually exists on disk
785
+ const fullReferencedPath = path.join(workspacePath, resolvedRelative);
786
+ if (await fs.pathExists(fullReferencedPath)) {
787
+ missingDependencies.push({ prmd: filePath, field, ref, resolvedRelative });
788
+ }
789
+ }
790
+ }
791
+ }
792
+ }
793
+ catch {
794
+ // Parsing errors are already caught by step 6b — skip here
795
+ }
796
+ }
797
+ if (missingDependencies.length > 0) {
798
+ const depList = missingDependencies.map(d => ` ${d.prmd}: ${d.field}: "${d.ref}" (missing "${d.resolvedRelative}" from prompd.json files)`).join('\n');
799
+ return {
800
+ success: false,
801
+ error: `Missing file dependencies — add these to your prompd.json "files" list:\n${depList}`
802
+ };
803
+ }
804
+ }
626
805
  // 6c. Validate all .pdflow workflow files for structural integrity and referenced files
627
806
  const workflowValidationErrors = [];
628
807
  for (const filePath of filesToPackage) {
@@ -750,6 +929,46 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
750
929
  error: `Validation errors in .pdflow workflow files:\n${errorList}`
751
930
  };
752
931
  }
932
+ // 6d. Trace .prmd file dependencies and verify all are present and included in package
933
+ const depErrors = [];
934
+ for (const filePath of filesToPackage) {
935
+ if (!filePath.endsWith('.prmd'))
936
+ continue;
937
+ const deps = await tracePrmdFileDependencies(filePath, workspacePath);
938
+ if (deps.length === 0)
939
+ continue;
940
+ const missing = [];
941
+ const excluded = [];
942
+ for (const dep of deps) {
943
+ const depFullPath = path.join(workspacePath, dep);
944
+ if (!await fs.pathExists(depFullPath)) {
945
+ missing.push(dep);
946
+ }
947
+ else if (!filesToPackage.includes(dep)) {
948
+ excluded.push(dep);
949
+ // Auto-include so the package is self-contained
950
+ filesToPackage.push(dep);
951
+ }
952
+ }
953
+ if (missing.length > 0 || excluded.length > 0) {
954
+ depErrors.push({ file: filePath, missing, excluded });
955
+ }
956
+ }
957
+ if (depErrors.length > 0) {
958
+ // Missing files are a hard error; auto-included files are warnings surfaced in the log
959
+ const hardErrors = depErrors.filter(e => e.missing.length > 0);
960
+ if (hardErrors.length > 0) {
961
+ const errorList = hardErrors.map(e => ` ${e.file}:\n${e.missing.map(f => ` - missing: ${f}`).join('\n')}`).join('\n');
962
+ return {
963
+ success: false,
964
+ error: `Missing dependency files referenced in .prmd frontmatter:\n${errorList}`
965
+ };
966
+ }
967
+ // Soft warnings (auto-included) — continue, they've been added to filesToPackage
968
+ for (const e of depErrors.filter(d => d.excluded.length > 0)) {
969
+ console.warn(`[Package] Auto-included dependencies for ${e.file}:\n${e.excluded.map(f => ` + ${f}`).join('\n')}`);
970
+ }
971
+ }
753
972
  // 7. Create output directory
754
973
  const distDir = outputDir || path.join(workspacePath, 'dist');
755
974
  await fs.ensureDir(distDir);
@@ -760,11 +979,20 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
760
979
  const outputFileName = `${packageName}-v${prompdJson.version}.pdpkg`;
761
980
  const outputPath = path.join(distDir, outputFileName);
762
981
  // 9. Create manifest for package (includes files array for archive only)
982
+ // Preserve all metadata fields from prompd.json so the registry stores them correctly
763
983
  const manifest = {
764
984
  name: prompdJson.name,
765
985
  version: prompdJson.version,
766
986
  description: prompdJson.description,
767
- author: prompdJson.author
987
+ author: prompdJson.author,
988
+ ...(prompdJson.type ? { type: prompdJson.type } : {}),
989
+ ...(Array.isArray(prompdJson.keywords) && prompdJson.keywords.length > 0 ? { keywords: prompdJson.keywords } : {}),
990
+ ...(Array.isArray(prompdJson.tools) && prompdJson.tools.length > 0 ? { tools: prompdJson.tools } : {}),
991
+ ...(Array.isArray(prompdJson.mcps) && prompdJson.mcps.length > 0 ? { mcps: prompdJson.mcps } : {}),
992
+ ...(prompdJson.license ? { license: prompdJson.license } : {}),
993
+ ...(prompdJson.homepage ? { homepage: prompdJson.homepage } : {}),
994
+ ...(prompdJson.repository ? { repository: prompdJson.repository } : {}),
995
+ ...(prompdJson.dependencies ? { dependencies: prompdJson.dependencies } : {}),
768
996
  };
769
997
  // 10. Create the package
770
998
  try {
@@ -806,56 +1034,113 @@ async function createPackageFromPrompdJson(workspacePath, outputDir) {
806
1034
  */
807
1035
  function addContentFrontmatter(content, filename) {
808
1036
  const contentType = (0, types_1.getContentType)(filename);
809
- const frontmatter = `---
810
- prompd_content_file: true
811
- original_filename: ${filename}
812
- content_type: ${contentType}
813
- ---
1037
+ const frontmatter = `---
1038
+ prompd_content_file: true
1039
+ original_filename: ${filename}
1040
+ content_type: ${contentType}
1041
+ ---
814
1042
  `;
815
1043
  return frontmatter + content;
816
1044
  }
1045
+ /** Binary asset extensions that must be pre-extracted to text during packaging */
1046
+ const BINARY_ASSET_EXTENSIONS = new Set(['.xlsx', '.xls', '.docx', '.pdf']);
1047
+ /**
1048
+ * Pre-extract a binary asset to text content for safe packaging.
1049
+ * Returns { content, newExtension } or null if not a binary asset.
1050
+ */
1051
+ async function extractBinaryAsset(fullPath) {
1052
+ const ext = path.extname(fullPath).toLowerCase();
1053
+ if (!BINARY_ASSET_EXTENSIONS.has(ext))
1054
+ return null;
1055
+ switch (ext) {
1056
+ case '.xlsx':
1057
+ case '.xls': {
1058
+ const workbook = xlsx.readFile(fullPath);
1059
+ const sheets = [];
1060
+ for (const sheetName of workbook.SheetNames) {
1061
+ const sheet = workbook.Sheets[sheetName];
1062
+ const csv = xlsx.utils.sheet_to_csv(sheet);
1063
+ if (csv.trim()) {
1064
+ sheets.push(`### Sheet: ${sheetName}\n\n\`\`\`csv\n${csv}\n\`\`\``);
1065
+ }
1066
+ }
1067
+ return { content: sheets.join('\n\n'), newExtension: '.csv.txt' };
1068
+ }
1069
+ case '.docx': {
1070
+ const buffer = await fs.readFile(fullPath);
1071
+ const result = await mammoth_1.default.extractRawText({ buffer });
1072
+ const maxSize = 1024 * 1024;
1073
+ const text = result.value.length > maxSize
1074
+ ? result.value.substring(0, maxSize) + '\n\n[Content truncated...]'
1075
+ : result.value;
1076
+ return { content: text, newExtension: '.txt' };
1077
+ }
1078
+ case '.pdf': {
1079
+ const buffer = await fs.readFile(fullPath);
1080
+ const pdfModule = await Promise.resolve().then(() => __importStar(require('pdf-parse')));
1081
+ const pdfParseFn = pdfModule.default || pdfModule;
1082
+ const data = await pdfParseFn(buffer, { max: 100 });
1083
+ const maxSize = 1024 * 1024;
1084
+ const text = data.text.length > maxSize
1085
+ ? data.text.substring(0, maxSize) + '\n\n[Content truncated...]'
1086
+ : data.text;
1087
+ return { content: text, newExtension: '.txt' };
1088
+ }
1089
+ default:
1090
+ return null;
1091
+ }
1092
+ }
817
1093
  /**
818
1094
  * Create package from specific file list (not directory walk)
819
1095
  * The files array is written to the archive's prompd.json (not the filesystem)
820
1096
  */
821
1097
  async function createPackageFromFiles(workspacePath, outputPath, manifest, files, mainFile, readmeFile, ignorePatterns) {
1098
+ // Pre-process files: extract binary assets to text, apply frontmatter protection
1099
+ const normalizedFiles = files.map(f => f.replace(/\\/g, '/'));
1100
+ const fileHashes = {};
1101
+ const fileContents = [];
1102
+ const pathRenames = {};
1103
+ for (const filePath of files) {
1104
+ const fullPath = path.join(workspacePath, filePath);
1105
+ let zipPath = filePath.replace(/\\/g, '/');
1106
+ // Pre-extract binary assets to text for safe packaging
1107
+ const extracted = await extractBinaryAsset(fullPath);
1108
+ if (extracted) {
1109
+ const baseName = path.basename(zipPath, path.extname(zipPath));
1110
+ const dirName = path.dirname(zipPath);
1111
+ const newZipPath = (dirName === '.' ? '' : dirName + '/') + baseName + extracted.newExtension;
1112
+ pathRenames[zipPath] = newZipPath;
1113
+ zipPath = newZipPath;
1114
+ fileHashes[zipPath] = (0, crypto_1.createHash)('sha256').update(extracted.content).digest('hex');
1115
+ fileContents.push({ zipPath, content: extracted.content });
1116
+ }
1117
+ else if ((0, types_1.needsFrontmatterProtection)(filePath)) {
1118
+ const content = fs.readFileSync(fullPath, 'utf-8');
1119
+ const filename = path.basename(filePath);
1120
+ const protectedContent = addContentFrontmatter(content, filename);
1121
+ fileHashes[zipPath] = (0, crypto_1.createHash)('sha256').update(protectedContent).digest('hex');
1122
+ fileContents.push({ zipPath, content: protectedContent });
1123
+ }
1124
+ else {
1125
+ const content = fs.readFileSync(fullPath);
1126
+ fileHashes[zipPath] = (0, crypto_1.createHash)('sha256').update(content).digest('hex');
1127
+ fileContents.push({ zipPath, content });
1128
+ }
1129
+ }
1130
+ const finalFiles = normalizedFiles.map(f => pathRenames[f] || f);
822
1131
  return new Promise((resolve, reject) => {
823
1132
  const output = fs.createWriteStream(outputPath);
824
1133
  const archive = (0, archiver_1.default)('zip', { zlib: { level: 9 } });
825
1134
  output.on('close', () => resolve());
826
1135
  archive.on('error', (err) => reject(err));
827
1136
  archive.pipe(output);
828
- // Files array uses original paths (no transformation needed with frontmatter approach)
829
- const normalizedFiles = files.map(f => f.replace(/\\/g, '/'));
830
- // Collect file contents and compute integrity hashes
831
- const fileHashes = {};
832
- const fileContents = [];
833
- for (const filePath of files) {
834
- const fullPath = path.join(workspacePath, filePath);
835
- const zipPath = filePath.replace(/\\/g, '/');
836
- // For code files, add frontmatter protection
837
- if ((0, types_1.needsFrontmatterProtection)(filePath)) {
838
- const content = fs.readFileSync(fullPath, 'utf-8');
839
- const filename = path.basename(filePath);
840
- const protectedContent = addContentFrontmatter(content, filename);
841
- // Hash the protected content (with frontmatter) - matches what's in archive
842
- fileHashes[zipPath] = (0, crypto_1.createHash)('sha256').update(protectedContent).digest('hex');
843
- fileContents.push({ zipPath, content: protectedContent });
844
- }
845
- else {
846
- // For non-code files, read content for hashing
847
- const content = fs.readFileSync(fullPath);
848
- fileHashes[zipPath] = (0, crypto_1.createHash)('sha256').update(content).digest('hex');
849
- fileContents.push({ zipPath, content });
850
- }
851
- }
852
1137
  // Add prompd.json (inside the package) with files array and integrity hashes
853
1138
  // This writes the files array to the archive only, not the filesystem
854
1139
  const fullManifest = {
855
1140
  ...manifest,
856
1141
  main: mainFile,
857
1142
  readme: readmeFile,
858
- files: normalizedFiles,
1143
+ files: finalFiles,
859
1144
  integrity: {
860
1145
  algorithm: 'sha256',
861
1146
  files: fileHashes