@pupt/cli 0.0.1 → 2.3.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.
- package/LICENSE +21 -0
- package/README.md +54 -29
- package/dist/annotations/annotation-analyzer.d.ts +17 -0
- package/dist/annotations/annotation-analyzer.d.ts.map +1 -0
- package/dist/annotations/annotation-analyzer.js +145 -0
- package/dist/annotations/annotation-analyzer.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +435 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +5 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +164 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/annotate.d.ts +2 -0
- package/dist/commands/annotate.d.ts.map +1 -0
- package/dist/commands/annotate.js +99 -0
- package/dist/commands/annotate.js.map +1 -0
- package/dist/commands/base-command.d.ts +23 -0
- package/dist/commands/base-command.d.ts.map +1 -0
- package/dist/commands/base-command.js +41 -0
- package/dist/commands/base-command.js.map +1 -0
- package/dist/commands/cache.d.ts +9 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +31 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +93 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/edit.d.ts +2 -0
- package/dist/commands/edit.d.ts.map +1 -0
- package/dist/commands/edit.js +35 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +26 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/history.d.ts +12 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +317 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +137 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +16 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +263 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/review.d.ts +3 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +160 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +32 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +367 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +45 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +113 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config/config-manager.d.ts +19 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +221 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/global-paths.d.ts +5 -0
- package/dist/config/global-paths.d.ts.map +1 -0
- package/dist/config/global-paths.js +16 -0
- package/dist/config/global-paths.js.map +1 -0
- package/dist/config/migration.d.ts +12 -0
- package/dist/config/migration.d.ts.map +1 -0
- package/dist/config/migration.js +270 -0
- package/dist/config/migration.js.map +1 -0
- package/dist/history/enhanced-history-manager.d.ts +27 -0
- package/dist/history/enhanced-history-manager.d.ts.map +1 -0
- package/dist/history/enhanced-history-manager.js +116 -0
- package/dist/history/enhanced-history-manager.js.map +1 -0
- package/dist/history/history-manager.d.ts +43 -0
- package/dist/history/history-manager.d.ts.map +1 -0
- package/dist/history/history-manager.js +229 -0
- package/dist/history/history-manager.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/input-types/file-search-prompt.d.ts +11 -0
- package/dist/prompts/input-types/file-search-prompt.d.ts.map +1 -0
- package/dist/prompts/input-types/file-search-prompt.js +53 -0
- package/dist/prompts/input-types/file-search-prompt.js.map +1 -0
- package/dist/prompts/input-types/review-file-prompt.d.ts +3 -0
- package/dist/prompts/input-types/review-file-prompt.d.ts.map +1 -0
- package/dist/prompts/input-types/review-file-prompt.js +9 -0
- package/dist/prompts/input-types/review-file-prompt.js.map +1 -0
- package/dist/schemas/config-schema.d.ts +1637 -0
- package/dist/schemas/config-schema.d.ts.map +1 -0
- package/dist/schemas/config-schema.js +136 -0
- package/dist/schemas/config-schema.js.map +1 -0
- package/dist/search/search-engine.d.ts +8 -0
- package/dist/search/search-engine.d.ts.map +1 -0
- package/dist/search/search-engine.js +53 -0
- package/dist/search/search-engine.js.map +1 -0
- package/dist/services/git-service.d.ts +28 -0
- package/dist/services/git-service.d.ts.map +1 -0
- package/dist/services/git-service.js +157 -0
- package/dist/services/git-service.js.map +1 -0
- package/dist/services/input-collector.d.ts +9 -0
- package/dist/services/input-collector.d.ts.map +1 -0
- package/dist/services/input-collector.js +162 -0
- package/dist/services/input-collector.js.map +1 -0
- package/dist/services/logging-service.d.ts +49 -0
- package/dist/services/logging-service.d.ts.map +1 -0
- package/dist/services/logging-service.js +203 -0
- package/dist/services/logging-service.js.map +1 -0
- package/dist/services/module-cache.d.ts +42 -0
- package/dist/services/module-cache.d.ts.map +1 -0
- package/dist/services/module-cache.js +205 -0
- package/dist/services/module-cache.js.map +1 -0
- package/dist/services/module-entry-builder.d.ts +20 -0
- package/dist/services/module-entry-builder.d.ts.map +1 -0
- package/dist/services/module-entry-builder.js +71 -0
- package/dist/services/module-entry-builder.js.map +1 -0
- package/dist/services/output-capture-service.d.ts +28 -0
- package/dist/services/output-capture-service.d.ts.map +1 -0
- package/dist/services/output-capture-service.js +348 -0
- package/dist/services/output-capture-service.js.map +1 -0
- package/dist/services/package-manager.d.ts +18 -0
- package/dist/services/package-manager.d.ts.map +1 -0
- package/dist/services/package-manager.js +141 -0
- package/dist/services/package-manager.js.map +1 -0
- package/dist/services/pattern-detector.d.ts +15 -0
- package/dist/services/pattern-detector.d.ts.map +1 -0
- package/dist/services/pattern-detector.js +228 -0
- package/dist/services/pattern-detector.js.map +1 -0
- package/dist/services/prompt-resolver.d.ts +32 -0
- package/dist/services/prompt-resolver.d.ts.map +1 -0
- package/dist/services/prompt-resolver.js +73 -0
- package/dist/services/prompt-resolver.js.map +1 -0
- package/dist/services/pupt-prompt-source.d.ts +16 -0
- package/dist/services/pupt-prompt-source.d.ts.map +1 -0
- package/dist/services/pupt-prompt-source.js +74 -0
- package/dist/services/pupt-prompt-source.js.map +1 -0
- package/dist/services/pupt-service.d.ts +33 -0
- package/dist/services/pupt-service.d.ts.map +1 -0
- package/dist/services/pupt-service.js +119 -0
- package/dist/services/pupt-service.js.map +1 -0
- package/dist/services/review-data-builder.d.ts +25 -0
- package/dist/services/review-data-builder.d.ts.map +1 -0
- package/dist/services/review-data-builder.js +333 -0
- package/dist/services/review-data-builder.js.map +1 -0
- package/dist/services/suggestion-generator.d.ts +11 -0
- package/dist/services/suggestion-generator.d.ts.map +1 -0
- package/dist/services/suggestion-generator.js +158 -0
- package/dist/services/suggestion-generator.js.map +1 -0
- package/dist/services/ui-service.d.ts +49 -0
- package/dist/services/ui-service.d.ts.map +1 -0
- package/dist/services/ui-service.js +196 -0
- package/dist/services/ui-service.js.map +1 -0
- package/dist/types/annotations.d.ts +50 -0
- package/dist/types/annotations.d.ts.map +1 -0
- package/dist/types/annotations.js +2 -0
- package/dist/types/annotations.js.map +1 -0
- package/dist/types/config.d.ts +110 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +12 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/history.d.ts +36 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/history.js +2 -0
- package/dist/types/history.js.map +1 -0
- package/dist/types/patterns.d.ts +25 -0
- package/dist/types/patterns.d.ts.map +1 -0
- package/dist/types/patterns.js +2 -0
- package/dist/types/patterns.js.map +1 -0
- package/dist/types/prompt.d.ts +29 -0
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/types/prompt.js +24 -0
- package/dist/types/prompt.js.map +1 -0
- package/dist/types/review.d.ts +81 -0
- package/dist/types/review.d.ts.map +1 -0
- package/dist/types/review.js +2 -0
- package/dist/types/review.js.map +1 -0
- package/dist/ui/console-ui.d.ts +30 -0
- package/dist/ui/console-ui.d.ts.map +1 -0
- package/dist/ui/console-ui.js +88 -0
- package/dist/ui/console-ui.js.map +1 -0
- package/dist/ui/interactive-search.d.ts +8 -0
- package/dist/ui/interactive-search.d.ts.map +1 -0
- package/dist/ui/interactive-search.js +29 -0
- package/dist/ui/interactive-search.js.map +1 -0
- package/dist/utils/annotation-migration.d.ts +12 -0
- package/dist/utils/annotation-migration.d.ts.map +1 -0
- package/dist/utils/annotation-migration.js +88 -0
- package/dist/utils/annotation-migration.js.map +1 -0
- package/dist/utils/date-formatter.d.ts +10 -0
- package/dist/utils/date-formatter.d.ts.map +1 -0
- package/dist/utils/date-formatter.js +46 -0
- package/dist/utils/date-formatter.js.map +1 -0
- package/dist/utils/editor.d.ts +14 -0
- package/dist/utils/editor.d.ts.map +1 -0
- package/dist/utils/editor.js +52 -0
- package/dist/utils/editor.js.map +1 -0
- package/dist/utils/errors.d.ts +58 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +275 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/git-info.d.ts +10 -0
- package/dist/utils/git-info.d.ts.map +1 -0
- package/dist/utils/git-info.js +44 -0
- package/dist/utils/git-info.js.map +1 -0
- package/dist/utils/gitignore.d.ts +10 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +72 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/logger.d.ts +39 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +143 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/platform.d.ts +9 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +45 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/project-root.d.ts +22 -0
- package/dist/utils/project-root.d.ts.map +1 -0
- package/dist/utils/project-root.js +226 -0
- package/dist/utils/project-root.js.map +1 -0
- package/dist/utils/prompt-dir-resolver.d.ts +5 -0
- package/dist/utils/prompt-dir-resolver.d.ts.map +1 -0
- package/dist/utils/prompt-dir-resolver.js +25 -0
- package/dist/utils/prompt-dir-resolver.js.map +1 -0
- package/dist/utils/security.d.ts +5 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +57 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/tool-detection.d.ts +14 -0
- package/dist/utils/tool-detection.d.ts.map +1 -0
- package/dist/utils/tool-detection.js +43 -0
- package/dist/utils/tool-detection.js.map +1 -0
- package/package.json +79 -7
- package/prompts/prompts/ad-hoc-long.prompt +60 -0
- package/prompts/prompts/ad-hoc.prompt +29 -0
- package/prompts/prompts/code-review.prompt +99 -0
- package/prompts/prompts/debugging-error-message.prompt +81 -0
- package/prompts/prompts/fix-github-actions.prompt +62 -0
- package/prompts/prompts/fix-test-errors.prompt +73 -0
- package/prompts/prompts/git-commit-comment.prompt +61 -0
- package/prompts/prompts/implementation-phase.prompt +53 -0
- package/prompts/prompts/implementation-plan.prompt +101 -0
- package/prompts/prompts/new-feature.prompt +89 -0
- package/prompts/prompts/new-project.prompt +9 -0
- package/prompts/prompts/one-shot-change.prompt +79 -0
- package/prompts/prompts/pupt-prompt-improvement.prompt +270 -0
- package/prompts/prompts/simple-test.prompt +8 -0
- package/prompts/prompts/update-design.prompt +71 -0
- package/prompts/prompts/update-documentation.prompt +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAG3B,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Helper configurations
|
|
3
|
+
const HelperConfigSchema = z.object({
|
|
4
|
+
type: z.enum(['inline', 'file']),
|
|
5
|
+
value: z.string().optional(),
|
|
6
|
+
path: z.string().optional()
|
|
7
|
+
}).refine((data) => {
|
|
8
|
+
if (data.type === 'inline') {
|
|
9
|
+
return !!data.value;
|
|
10
|
+
}
|
|
11
|
+
if (data.type === 'file') {
|
|
12
|
+
return !!data.path;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}, {
|
|
16
|
+
message: 'Inline helpers must have a value, file helpers must have a path'
|
|
17
|
+
});
|
|
18
|
+
// Output capture configuration schema
|
|
19
|
+
export const OutputCaptureConfigSchema = z.object({
|
|
20
|
+
enabled: z.boolean(),
|
|
21
|
+
directory: z.string().optional(),
|
|
22
|
+
maxSizeMB: z.number().optional(),
|
|
23
|
+
retentionDays: z.number().optional()
|
|
24
|
+
});
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Environment configuration schemas (mirrors pupt-lib's explicit config)
|
|
27
|
+
// Note: Runtime config (hostname, cwd, platform, etc.) is auto-detected
|
|
28
|
+
// by pupt-lib and should NOT be stored in the config file.
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/** LLM configuration schema */
|
|
31
|
+
const LlmConfigSchema = z.object({
|
|
32
|
+
model: z.string().optional(),
|
|
33
|
+
provider: z.string().optional(),
|
|
34
|
+
maxTokens: z.number().positive().optional(),
|
|
35
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
36
|
+
});
|
|
37
|
+
/** Output formatting configuration schema */
|
|
38
|
+
const OutputConfigSchema = z.object({
|
|
39
|
+
format: z.enum(['xml', 'markdown', 'json', 'text', 'unspecified']).optional(),
|
|
40
|
+
trim: z.boolean().optional(),
|
|
41
|
+
indent: z.string().optional(),
|
|
42
|
+
});
|
|
43
|
+
/** Code-related configuration schema */
|
|
44
|
+
const CodeConfigSchema = z.object({
|
|
45
|
+
language: z.string().optional(),
|
|
46
|
+
highlight: z.boolean().optional(),
|
|
47
|
+
});
|
|
48
|
+
/** User context configuration schema */
|
|
49
|
+
const UserContextConfigSchema = z.object({
|
|
50
|
+
editor: z.string().optional(),
|
|
51
|
+
});
|
|
52
|
+
/** Full environment configuration schema */
|
|
53
|
+
const EnvironmentConfigSchema = z.object({
|
|
54
|
+
llm: LlmConfigSchema.optional(),
|
|
55
|
+
output: OutputConfigSchema.optional(),
|
|
56
|
+
code: CodeConfigSchema.optional(),
|
|
57
|
+
user: UserContextConfigSchema.optional(),
|
|
58
|
+
});
|
|
59
|
+
// Git library entry schema
|
|
60
|
+
const GitLibraryEntrySchema = z.object({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
type: z.literal('git'),
|
|
63
|
+
source: z.string(),
|
|
64
|
+
promptDirs: z.array(z.string()),
|
|
65
|
+
installedAt: z.string(),
|
|
66
|
+
version: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
// npm library entry schema
|
|
69
|
+
const NpmLibraryEntrySchema = z.object({
|
|
70
|
+
name: z.string(),
|
|
71
|
+
type: z.literal('npm'),
|
|
72
|
+
source: z.string(),
|
|
73
|
+
promptDirs: z.array(z.string()),
|
|
74
|
+
installedAt: z.string(),
|
|
75
|
+
version: z.string(),
|
|
76
|
+
});
|
|
77
|
+
const LibraryEntrySchema = z.discriminatedUnion('type', [
|
|
78
|
+
GitLibraryEntrySchema,
|
|
79
|
+
NpmLibraryEntrySchema,
|
|
80
|
+
]);
|
|
81
|
+
// Main config schema (v8)
|
|
82
|
+
export const ConfigSchema = z.object({
|
|
83
|
+
promptDirs: z.array(z.string()).min(1, 'At least one prompt directory is required'),
|
|
84
|
+
historyDir: z.string().optional(),
|
|
85
|
+
annotationDir: z.string().optional(),
|
|
86
|
+
defaultCmd: z.string().optional(),
|
|
87
|
+
defaultCmdArgs: z.array(z.string()).optional(),
|
|
88
|
+
defaultCmdOptions: z.record(z.string()).optional(),
|
|
89
|
+
autoReview: z.boolean().optional(),
|
|
90
|
+
autoRun: z.boolean().optional(),
|
|
91
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must be in semver format (x.y.z)').optional(),
|
|
92
|
+
helpers: z.record(HelperConfigSchema).optional(),
|
|
93
|
+
outputCapture: OutputCaptureConfigSchema.optional(),
|
|
94
|
+
logLevel: z.string().optional(),
|
|
95
|
+
libraries: z.array(LibraryEntrySchema).optional(),
|
|
96
|
+
environment: EnvironmentConfigSchema.optional(),
|
|
97
|
+
}).passthrough();
|
|
98
|
+
// Partial config for updates
|
|
99
|
+
const _PartialConfigSchema = ConfigSchema.partial();
|
|
100
|
+
// Pre-v8 schema (v1-v7) - allows all deprecated fields that migration will remove.
|
|
101
|
+
// Covers v1 (promptDirectory), v2 (codingTool), and v3-v7 configs.
|
|
102
|
+
// Note: Global config is always created at v8+, but this schema is still needed
|
|
103
|
+
// for migration validation when loading older configs.
|
|
104
|
+
const ConfigPreV8Schema = z.object({
|
|
105
|
+
// v2+ uses promptDirs; v1 uses promptDirectory (handled by migration)
|
|
106
|
+
promptDirs: z.array(z.string()).min(1).optional(),
|
|
107
|
+
promptDirectory: z.union([z.string(), z.array(z.string())]).optional(),
|
|
108
|
+
historyDir: z.string().optional(),
|
|
109
|
+
historyDirectory: z.string().optional(), // v1 field name
|
|
110
|
+
annotationDir: z.string().optional(),
|
|
111
|
+
annotationDirectory: z.string().optional(), // v1 field name
|
|
112
|
+
defaultCmd: z.string().optional(),
|
|
113
|
+
defaultCmdArgs: z.array(z.string()).optional(),
|
|
114
|
+
defaultCmdOptions: z.record(z.string()).optional(),
|
|
115
|
+
autoReview: z.boolean().optional(),
|
|
116
|
+
autoRun: z.boolean().optional(),
|
|
117
|
+
gitPromptDir: z.string().optional(),
|
|
118
|
+
version: z.string().optional(),
|
|
119
|
+
helpers: z.record(HelperConfigSchema).optional(),
|
|
120
|
+
outputCapture: OutputCaptureConfigSchema.optional(),
|
|
121
|
+
logLevel: z.string().optional(),
|
|
122
|
+
libraries: z.union([z.array(z.string()), z.array(LibraryEntrySchema)]).optional(),
|
|
123
|
+
environment: EnvironmentConfigSchema.optional(),
|
|
124
|
+
codingTool: z.string().optional(),
|
|
125
|
+
codingToolArgs: z.array(z.string()).optional(),
|
|
126
|
+
codingToolOptions: z.record(z.string()).optional(),
|
|
127
|
+
targetLlm: z.string().optional(),
|
|
128
|
+
}).passthrough();
|
|
129
|
+
// Config file schemas (what's actually in the file)
|
|
130
|
+
// Only includes pre-v8 (for migration from v3-v7) and current v8 schema.
|
|
131
|
+
// Old v1/v2 schemas removed — global config is always created at v8+.
|
|
132
|
+
export const ConfigFileSchema = z.union([
|
|
133
|
+
ConfigPreV8Schema,
|
|
134
|
+
ConfigSchema
|
|
135
|
+
]);
|
|
136
|
+
//# sourceMappingURL=config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../../src/schemas/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAwB;AACxB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC,MAAM,CACP,CAAC,IAAI,EAAE,EAAE;IACP,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAAA,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAAA,CAAC;IAClD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAAA,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAAA,CAAC;IAC/C,OAAO,KAAK,CAAC;AACf,CAAC,EACD;IACE,OAAO,EAAE,iEAAiE;CAC3E,CACF,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,aAAa,EAAE,CAAC,CA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,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACjF,WAAW,EAAE,uBAAuB,CAAC,QAAQ,EAAE;IAC/C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC9C,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAClD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC,WAAW,EAAE,CAAC;AAEjB,oDAAoD;AACpD,yEAAyE;AACzE,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IACtC,iBAAiB;IACjB,YAAY;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-engine.d.ts","sourceRoot":"","sources":["../../src/search/search-engine.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQ5C,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,OAAO,CAAW;gBAEd,OAAO,EAAE,MAAM,EAAE;IA+B7B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAsBhC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import MiniSearch from 'minisearch';
|
|
2
|
+
export class SearchEngine {
|
|
3
|
+
miniSearch;
|
|
4
|
+
prompts;
|
|
5
|
+
constructor(prompts) {
|
|
6
|
+
this.prompts = prompts;
|
|
7
|
+
this.miniSearch = new MiniSearch({
|
|
8
|
+
fields: ['title', 'filename', 'tags', 'content'], // filename allows searching by kebab-case name
|
|
9
|
+
storeFields: [
|
|
10
|
+
'path',
|
|
11
|
+
'relativePath',
|
|
12
|
+
'filename',
|
|
13
|
+
'title',
|
|
14
|
+
'tags',
|
|
15
|
+
'content',
|
|
16
|
+
'frontmatter',
|
|
17
|
+
'variables',
|
|
18
|
+
'originalTags',
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
if (prompts.length > 0) {
|
|
22
|
+
// Process prompts to ensure tags is searchable as a string
|
|
23
|
+
const processedPrompts = prompts.map((prompt, index) => ({
|
|
24
|
+
...prompt,
|
|
25
|
+
id: index,
|
|
26
|
+
tags: prompt.tags.join(' '),
|
|
27
|
+
originalTags: prompt.tags,
|
|
28
|
+
}));
|
|
29
|
+
this.miniSearch.addAll(processedPrompts);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
search(query) {
|
|
33
|
+
if (!query || query.trim() === '') {
|
|
34
|
+
return this.prompts;
|
|
35
|
+
}
|
|
36
|
+
const searchResults = this.miniSearch.search(query, {
|
|
37
|
+
boost: {
|
|
38
|
+
title: 3,
|
|
39
|
+
filename: 3, // Same weight as title for kebab-case name matching
|
|
40
|
+
tags: 2,
|
|
41
|
+
content: 1,
|
|
42
|
+
},
|
|
43
|
+
fuzzy: 0.2,
|
|
44
|
+
prefix: true,
|
|
45
|
+
combineWith: 'AND',
|
|
46
|
+
});
|
|
47
|
+
return searchResults.map(result => {
|
|
48
|
+
const originalPrompt = this.prompts[result.id];
|
|
49
|
+
return originalPrompt;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=search-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-engine.js","sourceRoot":"","sources":["../../src/search/search-engine.ts"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EAAE,CAAC;aACX;YACD,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YAChC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC/C,OAAO,cAAc,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LogResult, StatusResult } from 'simple-git';
|
|
2
|
+
interface CloneOptions {
|
|
3
|
+
depth?: number;
|
|
4
|
+
branch?: string;
|
|
5
|
+
singleBranch?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface PullOptions {
|
|
8
|
+
remote?: string;
|
|
9
|
+
branch?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class GitService {
|
|
12
|
+
private git;
|
|
13
|
+
constructor(workingDirectory?: string);
|
|
14
|
+
isRepository(path?: string): Promise<boolean>;
|
|
15
|
+
cloneRepository(url: string, destination: string, options?: CloneOptions): Promise<void>;
|
|
16
|
+
pullRepository(path: string, options?: PullOptions): Promise<void>;
|
|
17
|
+
validateGitUrl(url: string): void;
|
|
18
|
+
extractRepoName(url: string): string;
|
|
19
|
+
getCurrentBranch(): Promise<string | null>;
|
|
20
|
+
getStatus(): Promise<StatusResult | null>;
|
|
21
|
+
getRemoteUrl(remote?: string): Promise<string | null>;
|
|
22
|
+
getRecentCommits(limit?: number): Promise<LogResult | null>;
|
|
23
|
+
hasUncommittedChanges(): Promise<boolean>;
|
|
24
|
+
getRepositoryRoot(): Promise<string | null>;
|
|
25
|
+
setWorkingDirectory(path: string): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=git-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-service.d.ts","sourceRoot":"","sources":["../../src/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0 +1,157 @@
|
|
|
1
|
+
import simpleGit from 'simple-git';
|
|
2
|
+
import { errors } from '../utils/errors.js';
|
|
3
|
+
export class GitService {
|
|
4
|
+
git;
|
|
5
|
+
constructor(workingDirectory) {
|
|
6
|
+
this.git = simpleGit(workingDirectory);
|
|
7
|
+
}
|
|
8
|
+
async isRepository(path) {
|
|
9
|
+
try {
|
|
10
|
+
const git = path ? simpleGit(path) : this.git;
|
|
11
|
+
return await git.checkIsRepo();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async cloneRepository(url, destination, options = {}) {
|
|
18
|
+
try {
|
|
19
|
+
const args = [];
|
|
20
|
+
if (options.depth !== undefined) {
|
|
21
|
+
args.push('--depth', options.depth.toString());
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
args.push('--depth', '1'); // Default to shallow clone
|
|
25
|
+
}
|
|
26
|
+
if (options.branch) {
|
|
27
|
+
args.push('--branch', options.branch);
|
|
28
|
+
}
|
|
29
|
+
if (options.singleBranch !== false) {
|
|
30
|
+
args.push('--single-branch');
|
|
31
|
+
}
|
|
32
|
+
await this.git.clone(url, destination, args);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw errors.gitError(`Failed to clone repository: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async pullRepository(path, options = {}) {
|
|
39
|
+
try {
|
|
40
|
+
const git = simpleGit(path);
|
|
41
|
+
if (options.remote && options.branch) {
|
|
42
|
+
await git.pull(options.remote, options.branch);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
await git.pull();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw errors.gitError(`Failed to pull repository: ${error instanceof Error ? error.message : String(error)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
validateGitUrl(url) {
|
|
53
|
+
if (!url || typeof url !== 'string' || url.trim() === '') {
|
|
54
|
+
throw errors.validationError('URL', 'non-empty string', url);
|
|
55
|
+
}
|
|
56
|
+
// Support common git URL formats
|
|
57
|
+
const gitUrlPatterns = [
|
|
58
|
+
// HTTPS URLs
|
|
59
|
+
/^https:\/\/[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+(?:\.git)?$/,
|
|
60
|
+
// SSH URLs (git@)
|
|
61
|
+
/^git@[a-zA-Z0-9.-]+:[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+(?:\.git)?$/,
|
|
62
|
+
// SSH URLs (ssh://)
|
|
63
|
+
/^ssh:\/\/git@[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+(?:\.git)?$/,
|
|
64
|
+
// Git protocol
|
|
65
|
+
/^git:\/\/[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+(?:\.git)?$/,
|
|
66
|
+
// File protocol (for testing and local repos)
|
|
67
|
+
/^file:\/\/\/.+$/
|
|
68
|
+
];
|
|
69
|
+
const isValidGitUrl = gitUrlPatterns.some(pattern => pattern.test(url));
|
|
70
|
+
if (!isValidGitUrl) {
|
|
71
|
+
throw errors.validationError('git URL format', 'valid git URL', url);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
extractRepoName(url) {
|
|
75
|
+
// Remove .git suffix if present
|
|
76
|
+
const cleanUrl = url.replace(/\.git$/, '');
|
|
77
|
+
// Extract repo name from different URL formats
|
|
78
|
+
let repoName;
|
|
79
|
+
if (url.includes('://')) {
|
|
80
|
+
// HTTPS, git://, or file:// URLs
|
|
81
|
+
const parts = cleanUrl.split('/');
|
|
82
|
+
repoName = parts[parts.length - 1];
|
|
83
|
+
// For file:// URLs that might end with a slash
|
|
84
|
+
if (!repoName && parts.length > 1) {
|
|
85
|
+
repoName = parts[parts.length - 2];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (url.startsWith('git@')) {
|
|
89
|
+
// SSH URLs (git@host:user/repo)
|
|
90
|
+
const parts = cleanUrl.split(':')[1].split('/');
|
|
91
|
+
repoName = parts[parts.length - 1];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw errors.validationError('repository URL', 'URL with repository name', url);
|
|
95
|
+
}
|
|
96
|
+
if (!repoName) {
|
|
97
|
+
throw errors.validationError('repository URL', 'URL with repository name', url);
|
|
98
|
+
}
|
|
99
|
+
return repoName;
|
|
100
|
+
}
|
|
101
|
+
async getCurrentBranch() {
|
|
102
|
+
try {
|
|
103
|
+
const branchSummary = await this.git.branch();
|
|
104
|
+
return branchSummary.current;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async getStatus() {
|
|
111
|
+
try {
|
|
112
|
+
return await this.git.status();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async getRemoteUrl(remote = 'origin') {
|
|
119
|
+
try {
|
|
120
|
+
const url = await this.git.remote(['get-url', remote]);
|
|
121
|
+
return url ? url.trim() : null;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async getRecentCommits(limit = 10) {
|
|
128
|
+
try {
|
|
129
|
+
return await this.git.log(['-n', limit.toString()]);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async hasUncommittedChanges() {
|
|
136
|
+
try {
|
|
137
|
+
const status = await this.git.status();
|
|
138
|
+
return !status.isClean();
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async getRepositoryRoot() {
|
|
145
|
+
try {
|
|
146
|
+
const root = await this.git.revparse(['--show-toplevel']);
|
|
147
|
+
return root.trim();
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
setWorkingDirectory(path) {
|
|
154
|
+
this.git = simpleGit(path);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=git-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-service.js","sourceRoot":"","sources":["../../src/services/git-service.ts"],"names":[],"mappings":"AAAA,OAAO,SAAgD,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAa5C,MAAM,OAAO,UAAU;IACb,GAAG,CAAY;IAEvB,YAAY,gBAAyB;QACnC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAa;QAC9B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAC9C,OAAO,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,GAAW,EAAE,WAAmB,EAAE,UAAwB,EAAE;QAChF,IAAI,CAAC;YACH,MAAM,IAAI,GAAa,EAAE,CAAC;YAE1B,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC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AK,CAAC,gBAAgB,CAAC,QAAgB,EAAE;QACvC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,IAAY;QAC9B,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InputIterator } from '@pupt/lib';
|
|
2
|
+
/**
|
|
3
|
+
* Collect inputs from a pupt-lib InputIterator by prompting the user
|
|
4
|
+
* with Inquirer prompts mapped from each InputRequirement type.
|
|
5
|
+
*
|
|
6
|
+
* Returns the collected values as a Map<string, unknown>.
|
|
7
|
+
*/
|
|
8
|
+
export declare function collectInputs(iterator: InputIterator, noInteractive?: boolean): Promise<Map<string, unknown>>;
|
|
9
|
+
//# sourceMappingURL=input-collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-collector.d.ts","sourceRoot":"","sources":["../../src/services/input-collector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,WAAW,CAAC;AAIjE;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,aAAa,EACvB,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqC/B"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { checkbox, confirm, editor, input, password, select } from '@inquirer/prompts';
|
|
2
|
+
import { fileSearchPrompt } from '../prompts/input-types/file-search-prompt.js';
|
|
3
|
+
/**
|
|
4
|
+
* Collect inputs from a pupt-lib InputIterator by prompting the user
|
|
5
|
+
* with Inquirer prompts mapped from each InputRequirement type.
|
|
6
|
+
*
|
|
7
|
+
* Returns the collected values as a Map<string, unknown>.
|
|
8
|
+
*/
|
|
9
|
+
export async function collectInputs(iterator, noInteractive) {
|
|
10
|
+
await iterator.start();
|
|
11
|
+
while (!iterator.isDone()) {
|
|
12
|
+
const req = iterator.current();
|
|
13
|
+
if (!req) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
let value;
|
|
17
|
+
if (noInteractive) {
|
|
18
|
+
if (req.default !== undefined) {
|
|
19
|
+
value = req.default;
|
|
20
|
+
}
|
|
21
|
+
else if (!req.required) {
|
|
22
|
+
value = '';
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error(`No default value for '${req.name}' - cannot run in non-interactive mode`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
value = await promptForInput(req);
|
|
30
|
+
}
|
|
31
|
+
const result = await iterator.submit(value);
|
|
32
|
+
if (result.valid) {
|
|
33
|
+
await iterator.advance();
|
|
34
|
+
}
|
|
35
|
+
else if (noInteractive) {
|
|
36
|
+
// In non-interactive mode, retrying with the same default will always
|
|
37
|
+
// produce the same validation failure, so throw instead of looping forever.
|
|
38
|
+
const errorMessages = result.errors.map(e => e.message).join('; ');
|
|
39
|
+
throw new Error(`Validation failed for '${req.name}' in non-interactive mode: ${errorMessages}`);
|
|
40
|
+
}
|
|
41
|
+
// If invalid in interactive mode, the loop re-prompts the current requirement
|
|
42
|
+
}
|
|
43
|
+
return iterator.getValues();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Map a pupt-lib InputRequirement to the appropriate Inquirer prompt
|
|
47
|
+
* and collect the user's response.
|
|
48
|
+
*/
|
|
49
|
+
async function promptForInput(req) {
|
|
50
|
+
const message = req.label || formatLabel(req.name);
|
|
51
|
+
switch (req.type) {
|
|
52
|
+
case 'string':
|
|
53
|
+
// Ask.Editor always includes the language key; Ask.Text does not
|
|
54
|
+
if ('language' in req) {
|
|
55
|
+
return editor({
|
|
56
|
+
message,
|
|
57
|
+
default: req.default,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return input({
|
|
61
|
+
message,
|
|
62
|
+
default: req.default,
|
|
63
|
+
});
|
|
64
|
+
case 'number': {
|
|
65
|
+
const raw = await input({
|
|
66
|
+
message,
|
|
67
|
+
default: req.default !== undefined ? String(req.default) : undefined,
|
|
68
|
+
validate: (val) => {
|
|
69
|
+
if (val === '' && !req.required) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return !isNaN(Number(val)) || 'Please enter a valid number';
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return Number(raw);
|
|
76
|
+
}
|
|
77
|
+
case 'boolean':
|
|
78
|
+
return confirm({
|
|
79
|
+
message,
|
|
80
|
+
default: req.default,
|
|
81
|
+
});
|
|
82
|
+
case 'select':
|
|
83
|
+
return select({
|
|
84
|
+
message,
|
|
85
|
+
choices: (req.options ?? []).map(o => ({
|
|
86
|
+
value: o.value,
|
|
87
|
+
name: o.label,
|
|
88
|
+
})),
|
|
89
|
+
default: req.default,
|
|
90
|
+
});
|
|
91
|
+
case 'multiselect':
|
|
92
|
+
return checkbox({
|
|
93
|
+
message,
|
|
94
|
+
choices: (req.options ?? []).map(o => ({
|
|
95
|
+
value: o.value,
|
|
96
|
+
name: o.label,
|
|
97
|
+
})),
|
|
98
|
+
});
|
|
99
|
+
case 'secret':
|
|
100
|
+
return password({ message });
|
|
101
|
+
case 'file':
|
|
102
|
+
return fileSearchPrompt({
|
|
103
|
+
message,
|
|
104
|
+
basePath: undefined,
|
|
105
|
+
filter: req.extensions?.length
|
|
106
|
+
? `*.{${req.extensions.join(',')}}`
|
|
107
|
+
: undefined,
|
|
108
|
+
default: req.default,
|
|
109
|
+
});
|
|
110
|
+
case 'path':
|
|
111
|
+
return fileSearchPrompt({
|
|
112
|
+
message,
|
|
113
|
+
basePath: undefined,
|
|
114
|
+
default: req.default,
|
|
115
|
+
});
|
|
116
|
+
case 'date':
|
|
117
|
+
return input({
|
|
118
|
+
message,
|
|
119
|
+
default: req.default,
|
|
120
|
+
});
|
|
121
|
+
case 'rating': {
|
|
122
|
+
const min = req.min ?? 1;
|
|
123
|
+
const max = req.max ?? 5;
|
|
124
|
+
const choices = [];
|
|
125
|
+
for (let i = min; i <= max; i++) {
|
|
126
|
+
choices.push({
|
|
127
|
+
value: String(i),
|
|
128
|
+
name: req.labels?.[i] ?? String(i),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const val = await select({ message, choices });
|
|
132
|
+
return Number(val);
|
|
133
|
+
}
|
|
134
|
+
case 'object':
|
|
135
|
+
case 'array':
|
|
136
|
+
// Fall back to editor for complex types
|
|
137
|
+
return editor({
|
|
138
|
+
message: `${message} (JSON)`,
|
|
139
|
+
default: req.default !== undefined
|
|
140
|
+
? JSON.stringify(req.default, null, 2)
|
|
141
|
+
: undefined,
|
|
142
|
+
});
|
|
143
|
+
default:
|
|
144
|
+
// Unknown types fall back to text input
|
|
145
|
+
return input({
|
|
146
|
+
message,
|
|
147
|
+
default: req.default,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Convert a camelCase or snake_case name to a human-readable label.
|
|
153
|
+
*/
|
|
154
|
+
function formatLabel(name) {
|
|
155
|
+
const humanized = name
|
|
156
|
+
.replace(/([A-Z])/g, ' $1')
|
|
157
|
+
.replace(/_/g, ' ')
|
|
158
|
+
.trim()
|
|
159
|
+
.toLowerCase();
|
|
160
|
+
return humanized.charAt(0).toUpperCase() + humanized.slice(1);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=input-collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-collector.js","sourceRoot":"","sources":["../../src/services/input-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAC,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAuB,EACvB,aAAuB;IAEvB,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;YAAA,MAAM;QAAA,CAAC;QAElB,IAAI,KAAc,CAAC;QACnB,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC9B,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC;YACtB,CAAC;iBAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACzB,KAAK,GAAG,EAAE,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,yBAAyB,GAAG,CAAC,IAAI,wCAAwC,CAC1E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OAAO,SAAS;gBAC5B,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS;oBAChC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;oBACtC,CAAC,CAAC,SAAS;aACd,CAAC,CAAC;QAEL;YACE,wCAAwC;YACxC,OAAO,KAAK,CAAC;gBACX,OAAO;gBACP,OAAO,EAAE,GAAG,CAAC,OAA6B;aAC3C,CAAC,CAAC;IACP,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,SAAS,GAAG,IAAI;SACnB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;SAClB,IAAI,EAAE;SACN,WAAW,EAAE,CAAC;IACjB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Logger } from 'pino';
|
|
2
|
+
import type { Config } from '../types/config.js';
|
|
3
|
+
export declare enum LogLevel {
|
|
4
|
+
TRACE = "trace",
|
|
5
|
+
DEBUG = "debug",
|
|
6
|
+
INFO = "info",
|
|
7
|
+
WARN = "warn",
|
|
8
|
+
ERROR = "error",
|
|
9
|
+
FATAL = "fatal"
|
|
10
|
+
}
|
|
11
|
+
interface LogContext {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
interface TimeOperationOptions {
|
|
15
|
+
slowThreshold?: number;
|
|
16
|
+
context?: LogContext;
|
|
17
|
+
}
|
|
18
|
+
export declare function createLogger(config: Config): Logger;
|
|
19
|
+
export declare class LoggingService {
|
|
20
|
+
private logger;
|
|
21
|
+
constructor(logger: Logger);
|
|
22
|
+
trace(msg: string): void;
|
|
23
|
+
trace(obj: LogContext, msg: string): void;
|
|
24
|
+
debug(msg: string): void;
|
|
25
|
+
debug(obj: LogContext, msg: string): void;
|
|
26
|
+
info(msg: string): void;
|
|
27
|
+
info(obj: LogContext, msg: string): void;
|
|
28
|
+
warn(msg: string): void;
|
|
29
|
+
warn(obj: LogContext, msg: string): void;
|
|
30
|
+
error(msg: string): void;
|
|
31
|
+
error(obj: LogContext, msg: string): void;
|
|
32
|
+
fatal(msg: string): void;
|
|
33
|
+
fatal(obj: LogContext, msg: string): void;
|
|
34
|
+
child(bindings: LogContext): LoggingService;
|
|
35
|
+
timeOperation<T>(operation: string, fn: () => Promise<T>, options?: TimeOperationOptions): Promise<T>;
|
|
36
|
+
}
|
|
37
|
+
export declare function formatLogContext(command: string, options: Record<string, unknown>): LogContext;
|
|
38
|
+
export declare function createChildLogger(parentLogger: Logger, context: LogContext): Logger;
|
|
39
|
+
interface CommandWithContext {
|
|
40
|
+
execute(): Promise<unknown>;
|
|
41
|
+
context?: {
|
|
42
|
+
logger?: Logger;
|
|
43
|
+
};
|
|
44
|
+
name?: string;
|
|
45
|
+
}
|
|
46
|
+
type CommandConstructor<T> = new (...args: unknown[]) => T;
|
|
47
|
+
export declare function enhanceWithLogging<T extends CommandWithContext>(CommandClass: CommandConstructor<T>): CommandConstructor<T>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=logging-service.d.ts.map
|