padrone 1.5.0 → 1.6.0

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 (138) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +15 -11
  3. package/dist/{args-D5PNDyNu.mjs → args-Cnq0nwSM.mjs} +91 -41
  4. package/dist/args-Cnq0nwSM.mjs.map +1 -0
  5. package/dist/codegen/index.mjs +4 -4
  6. package/dist/codegen/index.mjs.map +1 -1
  7. package/dist/commands-B_gufyR9.mjs +514 -0
  8. package/dist/commands-B_gufyR9.mjs.map +1 -0
  9. package/dist/{completion.mjs → completion-BEuflbDO.mjs} +12 -82
  10. package/dist/completion-BEuflbDO.mjs.map +1 -0
  11. package/dist/docs/index.d.mts +4 -4
  12. package/dist/docs/index.d.mts.map +1 -1
  13. package/dist/docs/index.mjs +10 -12
  14. package/dist/docs/index.mjs.map +1 -1
  15. package/dist/{errors-BiVrBgi6.mjs → errors-CL63UOzt.mjs} +26 -3
  16. package/dist/errors-CL63UOzt.mjs.map +1 -0
  17. package/dist/{formatter-DtHzbP22.d.mts → formatter-DrvhDMrq.d.mts} +3 -3
  18. package/dist/formatter-DrvhDMrq.d.mts.map +1 -0
  19. package/dist/{help-bbmu9-qd.mjs → help-B5Kk83of.mjs} +151 -37
  20. package/dist/help-B5Kk83of.mjs.map +1 -0
  21. package/dist/{types-Ch8Mk6Qb.d.mts → index-BaU3X6dY.d.mts} +621 -750
  22. package/dist/index-BaU3X6dY.d.mts.map +1 -0
  23. package/dist/index.d.mts +735 -37
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +3409 -1563
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{mcp-mLWIdUIu.mjs → mcp-BM-d0nZi.mjs} +13 -15
  28. package/dist/mcp-BM-d0nZi.mjs.map +1 -0
  29. package/dist/{serve-B0u43DK7.mjs → serve-Bk0JUlCj.mjs} +12 -14
  30. package/dist/serve-Bk0JUlCj.mjs.map +1 -0
  31. package/dist/{stream-BcC146Ud.mjs → stream-DC4H8YTx.mjs} +24 -3
  32. package/dist/stream-DC4H8YTx.mjs.map +1 -0
  33. package/dist/test.d.mts +5 -8
  34. package/dist/test.d.mts.map +1 -1
  35. package/dist/test.mjs +2 -13
  36. package/dist/test.mjs.map +1 -1
  37. package/dist/{update-check-CFX1FV3v.mjs → update-check-CZ2VqjnV.mjs} +16 -17
  38. package/dist/update-check-CZ2VqjnV.mjs.map +1 -0
  39. package/dist/zod.d.mts +2 -2
  40. package/dist/zod.d.mts.map +1 -1
  41. package/dist/zod.mjs +2 -2
  42. package/dist/zod.mjs.map +1 -1
  43. package/package.json +15 -12
  44. package/src/cli/completions.ts +14 -11
  45. package/src/cli/docs.ts +13 -10
  46. package/src/cli/doctor.ts +22 -18
  47. package/src/cli/index.ts +28 -82
  48. package/src/cli/init.ts +10 -7
  49. package/src/cli/link.ts +20 -16
  50. package/src/cli/wrap.ts +14 -11
  51. package/src/codegen/schema-to-code.ts +2 -2
  52. package/src/{args.ts → core/args.ts} +32 -225
  53. package/src/core/commands.ts +373 -0
  54. package/src/core/create.ts +268 -0
  55. package/src/core/default-runtime.ts +239 -0
  56. package/src/{errors.ts → core/errors.ts} +22 -0
  57. package/src/core/exec.ts +259 -0
  58. package/src/core/interceptors.ts +302 -0
  59. package/src/{parse.ts → core/parse.ts} +36 -89
  60. package/src/core/program-methods.ts +301 -0
  61. package/src/core/results.ts +229 -0
  62. package/src/core/runtime.ts +246 -0
  63. package/src/core/validate.ts +247 -0
  64. package/src/docs/index.ts +12 -13
  65. package/src/extension/auto-output.ts +95 -0
  66. package/src/extension/color.ts +38 -0
  67. package/src/extension/completion.ts +49 -0
  68. package/src/extension/config.ts +262 -0
  69. package/src/extension/env.ts +101 -0
  70. package/src/extension/help.ts +192 -0
  71. package/src/extension/index.ts +43 -0
  72. package/src/extension/ink.ts +93 -0
  73. package/src/extension/interactive.ts +106 -0
  74. package/src/extension/logger.ts +214 -0
  75. package/src/extension/man.ts +51 -0
  76. package/src/extension/mcp.ts +52 -0
  77. package/src/extension/progress-renderer.ts +338 -0
  78. package/src/extension/progress.ts +299 -0
  79. package/src/extension/repl.ts +94 -0
  80. package/src/extension/serve.ts +48 -0
  81. package/src/extension/signal.ts +87 -0
  82. package/src/extension/stdin.ts +62 -0
  83. package/src/extension/suggestions.ts +114 -0
  84. package/src/extension/timing.ts +81 -0
  85. package/src/extension/tracing.ts +175 -0
  86. package/src/extension/update-check.ts +77 -0
  87. package/src/extension/utils.ts +51 -0
  88. package/src/extension/version.ts +63 -0
  89. package/src/{completion.ts → feature/completion.ts} +12 -12
  90. package/src/{interactive.ts → feature/interactive.ts} +4 -4
  91. package/src/{mcp.ts → feature/mcp.ts} +12 -15
  92. package/src/{repl-loop.ts → feature/repl-loop.ts} +10 -13
  93. package/src/{serve.ts → feature/serve.ts} +11 -15
  94. package/src/feature/test.ts +262 -0
  95. package/src/{update-check.ts → feature/update-check.ts} +16 -16
  96. package/src/{wrap.ts → feature/wrap.ts} +10 -8
  97. package/src/index.ts +111 -30
  98. package/src/{formatter.ts → output/formatter.ts} +131 -31
  99. package/src/{help.ts → output/help.ts} +22 -8
  100. package/src/{zod.d.ts → schema/zod.d.ts} +1 -1
  101. package/src/schema/zod.ts +50 -0
  102. package/src/test.ts +2 -276
  103. package/src/types/args-meta.ts +151 -0
  104. package/src/types/builder.ts +697 -0
  105. package/src/types/command.ts +157 -0
  106. package/src/types/index.ts +59 -0
  107. package/src/types/interceptor.ts +296 -0
  108. package/src/types/preferences.ts +83 -0
  109. package/src/types/result.ts +71 -0
  110. package/src/types/schema.ts +19 -0
  111. package/src/util/dotenv.ts +244 -0
  112. package/src/{shell-utils.ts → util/shell-utils.ts} +26 -9
  113. package/src/{stream.ts → util/stream.ts} +27 -1
  114. package/src/{type-helpers.ts → util/type-helpers.ts} +23 -16
  115. package/src/{type-utils.ts → util/type-utils.ts} +71 -33
  116. package/src/util/utils.ts +51 -0
  117. package/src/zod.ts +1 -50
  118. package/dist/args-D5PNDyNu.mjs.map +0 -1
  119. package/dist/chunk-CjcI7cDX.mjs +0 -15
  120. package/dist/command-utils-B1D-HqCd.mjs +0 -1117
  121. package/dist/command-utils-B1D-HqCd.mjs.map +0 -1
  122. package/dist/completion.d.mts +0 -64
  123. package/dist/completion.d.mts.map +0 -1
  124. package/dist/completion.mjs.map +0 -1
  125. package/dist/errors-BiVrBgi6.mjs.map +0 -1
  126. package/dist/formatter-DtHzbP22.d.mts.map +0 -1
  127. package/dist/help-bbmu9-qd.mjs.map +0 -1
  128. package/dist/mcp-mLWIdUIu.mjs.map +0 -1
  129. package/dist/serve-B0u43DK7.mjs.map +0 -1
  130. package/dist/stream-BcC146Ud.mjs.map +0 -1
  131. package/dist/types-Ch8Mk6Qb.d.mts.map +0 -1
  132. package/dist/update-check-CFX1FV3v.mjs.map +0 -1
  133. package/src/command-utils.ts +0 -882
  134. package/src/create.ts +0 -1829
  135. package/src/runtime.ts +0 -497
  136. package/src/types.ts +0 -1291
  137. package/src/utils.ts +0 -140
  138. /package/src/{colorizer.ts → output/colorizer.ts} +0 -0
package/src/utils.ts DELETED
@@ -1,140 +0,0 @@
1
- import type { AnyPadroneCommand } from './types.ts';
2
-
3
- export function getRootCommand(cmd: AnyPadroneCommand): AnyPadroneCommand {
4
- let current = cmd;
5
- while (current.parent) current = current.parent;
6
- return current;
7
- }
8
-
9
- /**
10
- * Attempts to get the version from various sources:
11
- * 1. Explicit version set on the command
12
- * 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)
13
- * 3. package.json in current or parent directories
14
- * @param explicitVersion - Version explicitly set via .version()
15
- * @returns The version string or '0.0.0' if not found
16
- */
17
- export function getVersion(explicitVersion?: string): string {
18
- // 1. Use explicit version if provided
19
- if (explicitVersion) return explicitVersion;
20
-
21
- // 2. Check npm_package_version env var (set by npm/yarn/pnpm during script execution)
22
- if (typeof process !== 'undefined' && process.env?.npm_package_version) {
23
- return process.env.npm_package_version;
24
- }
25
-
26
- // 3. Try to read from package.json
27
- if (typeof process !== 'undefined') {
28
- try {
29
- const fs = require('node:fs');
30
- const path = require('node:path');
31
- let dir = process.cwd();
32
-
33
- // Walk up the directory tree looking for package.json
34
- for (let i = 0; i < 10; i++) {
35
- const pkgPath = path.join(dir, 'package.json');
36
- if (fs.existsSync(pkgPath)) {
37
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
38
- if (pkg.version) return pkg.version;
39
- }
40
- const parentDir = path.dirname(dir);
41
- if (parentDir === dir) break; // Reached root
42
- dir = parentDir;
43
- }
44
- } catch {
45
- // Ignore errors (e.g., fs not available in browser)
46
- }
47
- }
48
-
49
- return '0.0.0';
50
- }
51
-
52
- /**
53
- * Loads and parses a config file from the given path.
54
- * Supports JSON, JSONC (JSON with comments), and attempts to parse other formats.
55
- * @param configPath - Path to the config file
56
- * @returns Parsed config data or undefined if loading fails
57
- */
58
- export function loadConfigFile(configPath: string): Record<string, unknown> | undefined {
59
- if (typeof process === 'undefined') return undefined;
60
-
61
- try {
62
- const fs = require('node:fs');
63
- const path = require('node:path');
64
-
65
- // Resolve to absolute path
66
- const absolutePath = path.isAbsolute(configPath) ? configPath : path.resolve(process.cwd(), configPath);
67
-
68
- if (!fs.existsSync(absolutePath)) {
69
- console.error(`Config file not found: ${absolutePath}`);
70
- return undefined;
71
- }
72
-
73
- const getContent = () => fs.readFileSync(absolutePath, 'utf-8');
74
- const ext = path.extname(absolutePath).toLowerCase();
75
-
76
- if (ext === '.yaml' || ext === '.yml') {
77
- return Bun.YAML.parse(getContent()) as any;
78
- }
79
-
80
- if (ext === '.toml') {
81
- return Bun.TOML.parse(getContent()) as any;
82
- }
83
-
84
- if (ext === '.json') {
85
- if (Bun.JSONC) return Bun.JSONC.parse(getContent()) as any;
86
- try {
87
- return JSON.parse(getContent());
88
- } catch {
89
- return Bun.JSONC.parse(getContent()) as any;
90
- }
91
- }
92
-
93
- if (ext === '.jsonc') {
94
- return Bun.JSONC.parse(getContent()) as any;
95
- }
96
-
97
- if (ext === '.js' || ext === '.cjs' || ext === '.mjs' || ext === '.ts' || ext === '.cts' || ext === '.mts') {
98
- // For JS files, require them
99
- return require(absolutePath);
100
- }
101
-
102
- // For unknown extensions, try to parse as JSON
103
- try {
104
- return JSON.parse(getContent());
105
- } catch {
106
- console.error(`Unable to parse config file: ${absolutePath}`);
107
- return undefined;
108
- }
109
- } catch (error) {
110
- console.error(`Error loading config file: ${error}`);
111
- return undefined;
112
- }
113
- }
114
-
115
- /**
116
- * Searches for a config file from a list of possible file names.
117
- * Searches in the current working directory.
118
- * @param configFiles - Array of possible config file names to search for
119
- * @returns The path to the first found config file, or undefined if none found
120
- */
121
- export function findConfigFile(configFiles: string[]): string | undefined {
122
- if (typeof process === 'undefined' || !configFiles?.length) return undefined;
123
-
124
- try {
125
- const fs = require('node:fs');
126
- const path = require('node:path');
127
- const cwd = process.cwd();
128
-
129
- for (const configFile of configFiles) {
130
- const configPath = path.isAbsolute(configFile) ? configFile : path.resolve(cwd, configFile);
131
- if (fs.existsSync(configPath)) {
132
- return configPath;
133
- }
134
- }
135
- } catch {
136
- // Ignore errors (e.g., fs not available in browser)
137
- }
138
-
139
- return undefined;
140
- }
File without changes