padrone 1.4.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 (141) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +108 -283
  3. package/dist/args-Cnq0nwSM.mjs +272 -0
  4. package/dist/args-Cnq0nwSM.mjs.map +1 -0
  5. package/dist/codegen/index.d.mts +28 -3
  6. package/dist/codegen/index.d.mts.map +1 -1
  7. package/dist/codegen/index.mjs +169 -19
  8. package/dist/codegen/index.mjs.map +1 -1
  9. package/dist/commands-B_gufyR9.mjs +514 -0
  10. package/dist/commands-B_gufyR9.mjs.map +1 -0
  11. package/dist/{completion.mjs → completion-BEuflbDO.mjs} +86 -108
  12. package/dist/completion-BEuflbDO.mjs.map +1 -0
  13. package/dist/docs/index.d.mts +22 -2
  14. package/dist/docs/index.d.mts.map +1 -1
  15. package/dist/docs/index.mjs +92 -7
  16. package/dist/docs/index.mjs.map +1 -1
  17. package/dist/errors-CL63UOzt.mjs +137 -0
  18. package/dist/errors-CL63UOzt.mjs.map +1 -0
  19. package/dist/{formatter-ClUK5hcQ.d.mts → formatter-DrvhDMrq.d.mts} +35 -6
  20. package/dist/formatter-DrvhDMrq.d.mts.map +1 -0
  21. package/dist/help-B5Kk83of.mjs +849 -0
  22. package/dist/help-B5Kk83of.mjs.map +1 -0
  23. package/dist/index-BaU3X6dY.d.mts +1178 -0
  24. package/dist/index-BaU3X6dY.d.mts.map +1 -0
  25. package/dist/index.d.mts +763 -36
  26. package/dist/index.d.mts.map +1 -1
  27. package/dist/index.mjs +3608 -1534
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/mcp-BM-d0nZi.mjs +377 -0
  30. package/dist/mcp-BM-d0nZi.mjs.map +1 -0
  31. package/dist/serve-Bk0JUlCj.mjs +402 -0
  32. package/dist/serve-Bk0JUlCj.mjs.map +1 -0
  33. package/dist/stream-DC4H8YTx.mjs +77 -0
  34. package/dist/stream-DC4H8YTx.mjs.map +1 -0
  35. package/dist/test.d.mts +5 -8
  36. package/dist/test.d.mts.map +1 -1
  37. package/dist/test.mjs +5 -27
  38. package/dist/test.mjs.map +1 -1
  39. package/dist/{update-check-EbNDkzyV.mjs → update-check-CZ2VqjnV.mjs} +16 -17
  40. package/dist/update-check-CZ2VqjnV.mjs.map +1 -0
  41. package/dist/zod.d.mts +32 -0
  42. package/dist/zod.d.mts.map +1 -0
  43. package/dist/zod.mjs +50 -0
  44. package/dist/zod.mjs.map +1 -0
  45. package/package.json +20 -9
  46. package/src/cli/completions.ts +14 -11
  47. package/src/cli/docs.ts +13 -16
  48. package/src/cli/doctor.ts +213 -24
  49. package/src/cli/index.ts +28 -82
  50. package/src/cli/init.ts +12 -10
  51. package/src/cli/link.ts +22 -18
  52. package/src/cli/wrap.ts +14 -11
  53. package/src/codegen/discovery.ts +80 -28
  54. package/src/codegen/index.ts +2 -1
  55. package/src/codegen/parsers/bash.ts +179 -0
  56. package/src/codegen/schema-to-code.ts +2 -1
  57. package/src/core/args.ts +296 -0
  58. package/src/core/commands.ts +373 -0
  59. package/src/core/create.ts +268 -0
  60. package/src/{runtime.ts → core/default-runtime.ts} +70 -135
  61. package/src/{errors.ts → core/errors.ts} +22 -0
  62. package/src/core/exec.ts +259 -0
  63. package/src/core/interceptors.ts +302 -0
  64. package/src/{parse.ts → core/parse.ts} +36 -89
  65. package/src/core/program-methods.ts +301 -0
  66. package/src/core/results.ts +229 -0
  67. package/src/core/runtime.ts +246 -0
  68. package/src/core/validate.ts +247 -0
  69. package/src/docs/index.ts +124 -11
  70. package/src/extension/auto-output.ts +95 -0
  71. package/src/extension/color.ts +38 -0
  72. package/src/extension/completion.ts +49 -0
  73. package/src/extension/config.ts +262 -0
  74. package/src/extension/env.ts +101 -0
  75. package/src/extension/help.ts +192 -0
  76. package/src/extension/index.ts +43 -0
  77. package/src/extension/ink.ts +93 -0
  78. package/src/extension/interactive.ts +106 -0
  79. package/src/extension/logger.ts +214 -0
  80. package/src/extension/man.ts +51 -0
  81. package/src/extension/mcp.ts +52 -0
  82. package/src/extension/progress-renderer.ts +338 -0
  83. package/src/extension/progress.ts +299 -0
  84. package/src/extension/repl.ts +94 -0
  85. package/src/extension/serve.ts +48 -0
  86. package/src/extension/signal.ts +87 -0
  87. package/src/extension/stdin.ts +62 -0
  88. package/src/extension/suggestions.ts +114 -0
  89. package/src/extension/timing.ts +81 -0
  90. package/src/extension/tracing.ts +175 -0
  91. package/src/extension/update-check.ts +77 -0
  92. package/src/extension/utils.ts +51 -0
  93. package/src/extension/version.ts +63 -0
  94. package/src/{completion.ts → feature/completion.ts} +130 -57
  95. package/src/{interactive.ts → feature/interactive.ts} +47 -6
  96. package/src/feature/mcp.ts +387 -0
  97. package/src/{repl-loop.ts → feature/repl-loop.ts} +26 -16
  98. package/src/feature/serve.ts +438 -0
  99. package/src/feature/test.ts +262 -0
  100. package/src/{update-check.ts → feature/update-check.ts} +16 -16
  101. package/src/{wrap.ts → feature/wrap.ts} +27 -27
  102. package/src/index.ts +120 -11
  103. package/src/output/colorizer.ts +154 -0
  104. package/src/{formatter.ts → output/formatter.ts} +281 -135
  105. package/src/{help.ts → output/help.ts} +62 -15
  106. package/src/{zod.d.ts → schema/zod.d.ts} +1 -1
  107. package/src/schema/zod.ts +50 -0
  108. package/src/test.ts +2 -285
  109. package/src/types/args-meta.ts +151 -0
  110. package/src/types/builder.ts +697 -0
  111. package/src/types/command.ts +157 -0
  112. package/src/types/index.ts +59 -0
  113. package/src/types/interceptor.ts +296 -0
  114. package/src/types/preferences.ts +83 -0
  115. package/src/types/result.ts +71 -0
  116. package/src/types/schema.ts +19 -0
  117. package/src/util/dotenv.ts +244 -0
  118. package/src/{shell-utils.ts → util/shell-utils.ts} +26 -9
  119. package/src/util/stream.ts +101 -0
  120. package/src/{type-helpers.ts → util/type-helpers.ts} +23 -16
  121. package/src/{type-utils.ts → util/type-utils.ts} +99 -37
  122. package/src/util/utils.ts +51 -0
  123. package/src/zod.ts +1 -0
  124. package/dist/args-CVDbyyzG.mjs +0 -199
  125. package/dist/args-CVDbyyzG.mjs.map +0 -1
  126. package/dist/chunk-y_GBKt04.mjs +0 -5
  127. package/dist/completion.d.mts +0 -64
  128. package/dist/completion.d.mts.map +0 -1
  129. package/dist/completion.mjs.map +0 -1
  130. package/dist/formatter-ClUK5hcQ.d.mts.map +0 -1
  131. package/dist/help-CcBe91bV.mjs +0 -1254
  132. package/dist/help-CcBe91bV.mjs.map +0 -1
  133. package/dist/types-DjIdJN5G.d.mts +0 -1059
  134. package/dist/types-DjIdJN5G.d.mts.map +0 -1
  135. package/dist/update-check-EbNDkzyV.mjs.map +0 -1
  136. package/src/args.ts +0 -461
  137. package/src/colorizer.ts +0 -41
  138. package/src/command-utils.ts +0 -532
  139. package/src/create.ts +0 -1477
  140. package/src/types.ts +0 -1109
  141. package/src/utils.ts +0 -140
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
- }