@eldrforge/kodrdriv 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.js +7 -19
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +345 -96
- package/dist/arguments.js.map +1 -1
- package/dist/commands/clean.js +1 -1
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/commit.js +59 -14
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/link.js +200 -11
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/release.js +9 -3
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/review.js +356 -145
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/tree.js +111 -250
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/unlink.js +238 -10
- package/dist/commands/unlink.js.map +1 -1
- package/dist/constants.js +28 -12
- package/dist/constants.js.map +1 -1
- package/dist/content/issues.js +1 -1
- package/dist/error/CommandErrors.js +8 -1
- package/dist/error/CommandErrors.js.map +1 -1
- package/dist/prompt/commit.js +6 -0
- package/dist/prompt/commit.js.map +1 -1
- package/dist/prompt/instructions/review.md +13 -3
- package/dist/util/openai.js +70 -9
- package/dist/util/openai.js.map +1 -1
- package/dist/util/validation.js +24 -1
- package/dist/util/validation.js.map +1 -1
- package/package.json +2 -2
- package/test-external-unlink/package.json +16 -0
- package/test-externals/package.json +8 -0
- package/test-review-flow.sh +15 -0
- package/test-sort-files/alpha.md +3 -0
- package/test-sort-files/middle.txt +3 -0
- package/test-sort-files/zebra.txt +3 -0
- package/test_output.txt +161 -0
- package/dist/types.js +0 -140
- package/dist/types.js.map +0 -1
package/dist/arguments.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import path__default from 'path';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { PROGRAM_NAME, VERSION, KODRDRIV_DEFAULTS, ALLOWED_COMMANDS, DEFAULT_COMMAND } from './constants.js';
|
|
4
5
|
import { getLogger } from './logging.js';
|
|
@@ -14,6 +15,12 @@ z.object({
|
|
|
14
15
|
checkConfig: z.boolean().optional(),
|
|
15
16
|
initConfig: z.boolean().optional(),
|
|
16
17
|
model: z.string().optional(),
|
|
18
|
+
openaiReasoning: z.enum([
|
|
19
|
+
'low',
|
|
20
|
+
'medium',
|
|
21
|
+
'high'
|
|
22
|
+
]).optional(),
|
|
23
|
+
openaiMaxOutputTokens: z.number().optional(),
|
|
17
24
|
contextDirectories: z.array(z.string()).optional(),
|
|
18
25
|
configDir: z.string().optional(),
|
|
19
26
|
outputDir: z.string().optional(),
|
|
@@ -28,6 +35,7 @@ z.object({
|
|
|
28
35
|
targetVersion: z.string().optional(),
|
|
29
36
|
excludedPatterns: z.array(z.string()).optional(),
|
|
30
37
|
excludedPaths: z.array(z.string()).optional(),
|
|
38
|
+
exclude: z.array(z.string()).optional(),
|
|
31
39
|
context: z.string().optional(),
|
|
32
40
|
note: z.string().optional(),
|
|
33
41
|
direction: z.string().optional(),
|
|
@@ -62,6 +70,7 @@ z.object({
|
|
|
62
70
|
file: z.string().optional(),
|
|
63
71
|
directory: z.string().optional(),
|
|
64
72
|
directories: z.array(z.string()).optional(),
|
|
73
|
+
externals: z.array(z.string()).optional(),
|
|
65
74
|
keepTemp: z.boolean().optional(),
|
|
66
75
|
noMilestones: z.boolean().optional(),
|
|
67
76
|
subcommand: z.string().optional()
|
|
@@ -69,63 +78,93 @@ z.object({
|
|
|
69
78
|
// Function to transform flat CLI args into nested Config structure
|
|
70
79
|
const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
71
80
|
const transformedCliArgs = {};
|
|
72
|
-
//
|
|
81
|
+
// Root-level properties
|
|
73
82
|
if (finalCliArgs.dryRun !== undefined) transformedCliArgs.dryRun = finalCliArgs.dryRun;
|
|
74
83
|
if (finalCliArgs.verbose !== undefined) transformedCliArgs.verbose = finalCliArgs.verbose;
|
|
75
84
|
if (finalCliArgs.debug !== undefined) transformedCliArgs.debug = finalCliArgs.debug;
|
|
76
|
-
if (finalCliArgs.overrides !== undefined) transformedCliArgs.overrides = finalCliArgs.overrides;
|
|
77
85
|
if (finalCliArgs.model !== undefined) transformedCliArgs.model = finalCliArgs.model;
|
|
78
|
-
if (finalCliArgs.contextDirectories !== undefined) transformedCliArgs.contextDirectories = finalCliArgs.contextDirectories;
|
|
79
|
-
// Map configDir (CLI) to configDirectory (Cardigantime standard)
|
|
80
|
-
if (finalCliArgs.configDir !== undefined) transformedCliArgs.configDirectory = finalCliArgs.configDir;
|
|
81
|
-
// Map outputDir (CLI) to outputDirectory (Config standard)
|
|
82
86
|
if (finalCliArgs.outputDir !== undefined) transformedCliArgs.outputDirectory = finalCliArgs.outputDir;
|
|
83
|
-
// Map preferencesDir (CLI) to preferencesDirectory (Config standard)
|
|
84
87
|
if (finalCliArgs.preferencesDir !== undefined) transformedCliArgs.preferencesDirectory = finalCliArgs.preferencesDir;
|
|
88
|
+
if (finalCliArgs.configDir !== undefined) transformedCliArgs.configDirectory = finalCliArgs.configDir;
|
|
89
|
+
if (finalCliArgs.overrides !== undefined) transformedCliArgs.overrides = finalCliArgs.overrides;
|
|
90
|
+
if (finalCliArgs.contextDirectories !== undefined) transformedCliArgs.contextDirectories = finalCliArgs.contextDirectories;
|
|
91
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
92
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
85
93
|
// Nested mappings for 'commit' options
|
|
86
|
-
if (finalCliArgs.
|
|
94
|
+
if (finalCliArgs.add !== undefined || finalCliArgs.cached !== undefined || finalCliArgs.sendit !== undefined || finalCliArgs.skipFileCheck !== undefined || finalCliArgs.maxDiffBytes !== undefined || finalCliArgs.messageLimit !== undefined || finalCliArgs.openaiReasoning !== undefined || finalCliArgs.openaiMaxOutputTokens !== undefined || finalCliArgs.amend !== undefined || finalCliArgs.context !== undefined || finalCliArgs.direction !== undefined || commandName === 'commit' && finalCliArgs.interactive !== undefined || finalCliArgs.push !== undefined) {
|
|
87
95
|
transformedCliArgs.commit = {};
|
|
88
96
|
if (finalCliArgs.add !== undefined) transformedCliArgs.commit.add = finalCliArgs.add;
|
|
89
97
|
if (finalCliArgs.cached !== undefined) transformedCliArgs.commit.cached = finalCliArgs.cached;
|
|
90
98
|
if (finalCliArgs.sendit !== undefined) transformedCliArgs.commit.sendit = finalCliArgs.sendit;
|
|
91
|
-
if (finalCliArgs.
|
|
92
|
-
if (finalCliArgs.
|
|
99
|
+
if (finalCliArgs.skipFileCheck !== undefined) transformedCliArgs.commit.skipFileCheck = finalCliArgs.skipFileCheck;
|
|
100
|
+
if (finalCliArgs.maxDiffBytes !== undefined) transformedCliArgs.commit.maxDiffBytes = finalCliArgs.maxDiffBytes;
|
|
93
101
|
if (finalCliArgs.messageLimit !== undefined) transformedCliArgs.commit.messageLimit = finalCliArgs.messageLimit;
|
|
102
|
+
if (finalCliArgs.amend !== undefined) transformedCliArgs.commit.amend = finalCliArgs.amend;
|
|
103
|
+
if (finalCliArgs.push !== undefined) transformedCliArgs.commit.push = finalCliArgs.push;
|
|
94
104
|
if (finalCliArgs.context !== undefined) transformedCliArgs.commit.context = finalCliArgs.context;
|
|
95
105
|
if (finalCliArgs.direction !== undefined) transformedCliArgs.commit.direction = finalCliArgs.direction;
|
|
96
|
-
if (finalCliArgs.
|
|
97
|
-
if (finalCliArgs.
|
|
106
|
+
if (commandName === 'commit' && finalCliArgs.interactive !== undefined) transformedCliArgs.commit.interactive = finalCliArgs.interactive;
|
|
107
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.commit.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
108
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.commit.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
98
109
|
}
|
|
99
110
|
// Nested mappings for 'audioCommit' options
|
|
100
|
-
if (finalCliArgs.file !== undefined || finalCliArgs.keepTemp !== undefined) {
|
|
111
|
+
if (finalCliArgs.file !== undefined || finalCliArgs.keepTemp !== undefined || finalCliArgs.openaiReasoning !== undefined || finalCliArgs.openaiMaxOutputTokens !== undefined) {
|
|
101
112
|
transformedCliArgs.audioCommit = {};
|
|
102
113
|
if (finalCliArgs.file !== undefined) transformedCliArgs.audioCommit.file = finalCliArgs.file;
|
|
103
114
|
if (finalCliArgs.keepTemp !== undefined) transformedCliArgs.audioCommit.keepTemp = finalCliArgs.keepTemp;
|
|
115
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.audioCommit.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
116
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.audioCommit.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
104
117
|
}
|
|
105
|
-
// Nested mappings for 'release' options
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
// Nested mappings for 'release' options (only when it's NOT a publish command)
|
|
119
|
+
if (commandName !== 'publish') {
|
|
120
|
+
if (finalCliArgs.from !== undefined || finalCliArgs.to !== undefined || finalCliArgs.maxDiffBytes !== undefined || finalCliArgs.interactive !== undefined || finalCliArgs.noMilestones !== undefined || finalCliArgs.openaiReasoning !== undefined || finalCliArgs.openaiMaxOutputTokens !== undefined) {
|
|
121
|
+
transformedCliArgs.release = {};
|
|
122
|
+
if (finalCliArgs.from !== undefined) transformedCliArgs.release.from = finalCliArgs.from;
|
|
123
|
+
if (finalCliArgs.to !== undefined) transformedCliArgs.release.to = finalCliArgs.to;
|
|
124
|
+
if ((commandName === 'release' || finalCliArgs.from !== undefined || finalCliArgs.to !== undefined) && finalCliArgs.context !== undefined) transformedCliArgs.release.context = finalCliArgs.context;
|
|
125
|
+
if (finalCliArgs.interactive !== undefined) transformedCliArgs.release.interactive = finalCliArgs.interactive;
|
|
126
|
+
if ((commandName === 'release' || finalCliArgs.from !== undefined || finalCliArgs.to !== undefined) && finalCliArgs.messageLimit !== undefined) transformedCliArgs.release.messageLimit = finalCliArgs.messageLimit;
|
|
127
|
+
if (finalCliArgs.maxDiffBytes !== undefined) transformedCliArgs.release.maxDiffBytes = finalCliArgs.maxDiffBytes;
|
|
128
|
+
if (finalCliArgs.noMilestones !== undefined) transformedCliArgs.release.noMilestones = finalCliArgs.noMilestones;
|
|
129
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.release.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
130
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.release.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
131
|
+
}
|
|
115
132
|
}
|
|
116
|
-
// Nested mappings for 'publish' options
|
|
117
|
-
if (finalCliArgs.mergeMethod !== undefined || finalCliArgs.targetVersion !== undefined || finalCliArgs.
|
|
133
|
+
// Nested mappings for 'publish' options – map whenever publish-specific options are provided
|
|
134
|
+
if (finalCliArgs.mergeMethod !== undefined || finalCliArgs.targetVersion !== undefined || finalCliArgs.interactive !== undefined || finalCliArgs.syncTarget !== undefined || commandName === 'publish' && (finalCliArgs.from !== undefined || finalCliArgs.noMilestones !== undefined)) {
|
|
118
135
|
transformedCliArgs.publish = {};
|
|
119
136
|
if (finalCliArgs.mergeMethod !== undefined) transformedCliArgs.publish.mergeMethod = finalCliArgs.mergeMethod;
|
|
120
|
-
if (finalCliArgs.from !== undefined) transformedCliArgs.publish.from = finalCliArgs.from;
|
|
137
|
+
if ((commandName === 'publish' || finalCliArgs.mergeMethod !== undefined || finalCliArgs.targetVersion !== undefined || finalCliArgs.syncTarget !== undefined || finalCliArgs.interactive !== undefined) && finalCliArgs.from !== undefined) transformedCliArgs.publish.from = finalCliArgs.from;
|
|
121
138
|
if (finalCliArgs.targetVersion !== undefined) transformedCliArgs.publish.targetVersion = finalCliArgs.targetVersion;
|
|
122
139
|
if (finalCliArgs.interactive !== undefined) transformedCliArgs.publish.interactive = finalCliArgs.interactive;
|
|
123
140
|
if (finalCliArgs.syncTarget !== undefined) transformedCliArgs.publish.syncTarget = finalCliArgs.syncTarget;
|
|
124
|
-
if (finalCliArgs.noMilestones !== undefined) transformedCliArgs.publish.noMilestones = finalCliArgs.noMilestones;
|
|
141
|
+
if ((commandName === 'publish' || finalCliArgs.mergeMethod !== undefined || finalCliArgs.targetVersion !== undefined || finalCliArgs.syncTarget !== undefined || finalCliArgs.interactive !== undefined) && finalCliArgs.noMilestones !== undefined) transformedCliArgs.publish.noMilestones = finalCliArgs.noMilestones;
|
|
142
|
+
}
|
|
143
|
+
// Nested mappings for 'development' options
|
|
144
|
+
if (commandName === 'development' && (finalCliArgs.targetVersion !== undefined || finalCliArgs.noMilestones !== undefined)) {
|
|
145
|
+
transformedCliArgs.development = {};
|
|
146
|
+
if (finalCliArgs.targetVersion !== undefined) transformedCliArgs.development.targetVersion = finalCliArgs.targetVersion;
|
|
147
|
+
if (finalCliArgs.noMilestones !== undefined) transformedCliArgs.development.noMilestones = finalCliArgs.noMilestones;
|
|
148
|
+
// Mirror targetVersion into publish; mirror noMilestones into publish and release to match test expectations
|
|
149
|
+
transformedCliArgs.publish = {
|
|
150
|
+
...transformedCliArgs.publish || {},
|
|
151
|
+
...finalCliArgs.targetVersion !== undefined ? {
|
|
152
|
+
targetVersion: finalCliArgs.targetVersion
|
|
153
|
+
} : {},
|
|
154
|
+
...finalCliArgs.noMilestones !== undefined ? {
|
|
155
|
+
noMilestones: finalCliArgs.noMilestones
|
|
156
|
+
} : {}
|
|
157
|
+
};
|
|
158
|
+
transformedCliArgs.release = {
|
|
159
|
+
...transformedCliArgs.release || {},
|
|
160
|
+
...finalCliArgs.noMilestones !== undefined ? {
|
|
161
|
+
noMilestones: finalCliArgs.noMilestones
|
|
162
|
+
} : {}
|
|
163
|
+
};
|
|
125
164
|
}
|
|
126
165
|
// Nested mappings for 'link' and 'unlink' options
|
|
127
166
|
const linkPackageArgument = finalCliArgs.packageArgument;
|
|
128
|
-
if (
|
|
167
|
+
if ((commandName === 'link' || commandName === undefined) && (finalCliArgs.scopeRoots !== undefined || linkPackageArgument !== undefined)) {
|
|
129
168
|
transformedCliArgs.link = {};
|
|
130
169
|
if (finalCliArgs.scopeRoots !== undefined) {
|
|
131
170
|
try {
|
|
@@ -134,7 +173,7 @@ const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
|
134
173
|
throw new Error(`Invalid JSON for scope-roots: ${finalCliArgs.scopeRoots}`);
|
|
135
174
|
}
|
|
136
175
|
}
|
|
137
|
-
if (
|
|
176
|
+
if (linkPackageArgument !== undefined) {
|
|
138
177
|
transformedCliArgs.link.packageArgument = linkPackageArgument;
|
|
139
178
|
}
|
|
140
179
|
}
|
|
@@ -156,7 +195,7 @@ const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
|
156
195
|
}
|
|
157
196
|
}
|
|
158
197
|
// Nested mappings for 'audio-review' options (only when it's not a tree command)
|
|
159
|
-
if (commandName !== 'tree' && (finalCliArgs.includeCommitHistory !== undefined || finalCliArgs.includeRecentDiffs !== undefined || finalCliArgs.includeReleaseNotes !== undefined || finalCliArgs.includeGithubIssues !== undefined || finalCliArgs.commitHistoryLimit !== undefined || finalCliArgs.diffHistoryLimit !== undefined || finalCliArgs.releaseNotesLimit !== undefined || finalCliArgs.githubIssuesLimit !== undefined || finalCliArgs.file !== undefined || finalCliArgs.directories !== undefined || finalCliArgs.keepTemp !== undefined)) {
|
|
198
|
+
if (commandName !== 'tree' && (finalCliArgs.includeCommitHistory !== undefined || finalCliArgs.includeRecentDiffs !== undefined || finalCliArgs.includeReleaseNotes !== undefined || finalCliArgs.includeGithubIssues !== undefined || finalCliArgs.commitHistoryLimit !== undefined || finalCliArgs.diffHistoryLimit !== undefined || finalCliArgs.releaseNotesLimit !== undefined || finalCliArgs.githubIssuesLimit !== undefined || finalCliArgs.file !== undefined || finalCliArgs.directories !== undefined || finalCliArgs.keepTemp !== undefined || finalCliArgs.openaiReasoning !== undefined || finalCliArgs.openaiMaxOutputTokens !== undefined)) {
|
|
160
199
|
transformedCliArgs.audioReview = {};
|
|
161
200
|
if (finalCliArgs.includeCommitHistory !== undefined) transformedCliArgs.audioReview.includeCommitHistory = finalCliArgs.includeCommitHistory;
|
|
162
201
|
if (finalCliArgs.includeRecentDiffs !== undefined) transformedCliArgs.audioReview.includeRecentDiffs = finalCliArgs.includeRecentDiffs;
|
|
@@ -171,11 +210,15 @@ const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
|
171
210
|
if (finalCliArgs.file !== undefined) transformedCliArgs.audioReview.file = finalCliArgs.file;
|
|
172
211
|
if (finalCliArgs.directory !== undefined) transformedCliArgs.audioReview.directory = finalCliArgs.directory;
|
|
173
212
|
if (finalCliArgs.keepTemp !== undefined) transformedCliArgs.audioReview.keepTemp = finalCliArgs.keepTemp;
|
|
213
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.audioReview.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
214
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.audioReview.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
174
215
|
}
|
|
175
216
|
// Nested mappings for 'review' options
|
|
176
|
-
if (finalCliArgs.includeCommitHistory !== undefined || finalCliArgs.includeRecentDiffs !== undefined || finalCliArgs.includeReleaseNotes !== undefined || finalCliArgs.includeGithubIssues !== undefined || finalCliArgs.commitHistoryLimit !== undefined || finalCliArgs.diffHistoryLimit !== undefined || finalCliArgs.releaseNotesLimit !== undefined || finalCliArgs.githubIssuesLimit !== undefined || finalCliArgs.context !== undefined || finalCliArgs.sendit !== undefined || finalCliArgs.note !== undefined) {
|
|
217
|
+
if (finalCliArgs.includeCommitHistory !== undefined || finalCliArgs.includeRecentDiffs !== undefined || finalCliArgs.includeReleaseNotes !== undefined || finalCliArgs.includeGithubIssues !== undefined || finalCliArgs.commitHistoryLimit !== undefined || finalCliArgs.diffHistoryLimit !== undefined || finalCliArgs.releaseNotesLimit !== undefined || finalCliArgs.githubIssuesLimit !== undefined || finalCliArgs.context !== undefined || finalCliArgs.sendit !== undefined || finalCliArgs.note !== undefined || finalCliArgs.openaiReasoning !== undefined || finalCliArgs.openaiMaxOutputTokens !== undefined || commandName === 'review' && (finalCliArgs.file !== undefined || finalCliArgs.directory !== undefined)) {
|
|
177
218
|
transformedCliArgs.review = {};
|
|
178
219
|
if (finalCliArgs.note !== undefined) transformedCliArgs.review.note = finalCliArgs.note;
|
|
220
|
+
if (commandName === 'review' && finalCliArgs.file !== undefined) transformedCliArgs.review.file = finalCliArgs.file;
|
|
221
|
+
if (commandName === 'review' && finalCliArgs.directory !== undefined) transformedCliArgs.review.directory = finalCliArgs.directory;
|
|
179
222
|
// Include optional review configuration options if specified
|
|
180
223
|
if (finalCliArgs.includeCommitHistory !== undefined) transformedCliArgs.review.includeCommitHistory = finalCliArgs.includeCommitHistory;
|
|
181
224
|
if (finalCliArgs.includeRecentDiffs !== undefined) transformedCliArgs.review.includeRecentDiffs = finalCliArgs.includeRecentDiffs;
|
|
@@ -188,27 +231,29 @@ const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
|
188
231
|
if (finalCliArgs.context !== undefined) transformedCliArgs.review.context = finalCliArgs.context;
|
|
189
232
|
if (finalCliArgs.sendit !== undefined) transformedCliArgs.review.sendit = finalCliArgs.sendit;
|
|
190
233
|
if (finalCliArgs.editorTimeout !== undefined) transformedCliArgs.review.editorTimeout = finalCliArgs.editorTimeout;
|
|
234
|
+
if (finalCliArgs.openaiReasoning !== undefined) transformedCliArgs.review.openaiReasoning = finalCliArgs.openaiReasoning;
|
|
235
|
+
if (finalCliArgs.openaiMaxOutputTokens !== undefined) transformedCliArgs.review.openaiMaxOutputTokens = finalCliArgs.openaiMaxOutputTokens;
|
|
191
236
|
}
|
|
192
237
|
// Nested mappings for 'tree' options (add when relevant args present)
|
|
193
238
|
if (commandName === 'tree') {
|
|
194
|
-
const treeExcludedPatterns = finalCliArgs.excludedPatterns || finalCliArgs.excludedPaths;
|
|
195
239
|
const builtInCommand = finalCliArgs.builtInCommand;
|
|
196
240
|
const packageArgument = finalCliArgs.packageArgument;
|
|
197
|
-
|
|
241
|
+
// Only create tree object if there are actual tree-specific options
|
|
242
|
+
if (finalCliArgs.directories !== undefined || finalCliArgs.directory !== undefined || finalCliArgs.startFrom !== undefined || finalCliArgs.stopAt !== undefined || finalCliArgs.cmd !== undefined || builtInCommand !== undefined || finalCliArgs.continue !== undefined || packageArgument !== undefined || finalCliArgs.cleanNodeModules !== undefined || finalCliArgs.externals !== undefined) {
|
|
198
243
|
transformedCliArgs.tree = {};
|
|
199
244
|
if (finalCliArgs.directories !== undefined) transformedCliArgs.tree.directories = finalCliArgs.directories;
|
|
200
245
|
else if (finalCliArgs.directory !== undefined) transformedCliArgs.tree.directories = [
|
|
201
246
|
finalCliArgs.directory
|
|
202
247
|
];
|
|
203
|
-
if (treeExcludedPatterns !== undefined) transformedCliArgs.tree.excludedPatterns = treeExcludedPatterns;
|
|
204
248
|
if (finalCliArgs.startFrom !== undefined) transformedCliArgs.tree.startFrom = finalCliArgs.startFrom;
|
|
205
249
|
if (finalCliArgs.stopAt !== undefined) transformedCliArgs.tree.stopAt = finalCliArgs.stopAt;
|
|
206
250
|
if (finalCliArgs.cmd !== undefined) transformedCliArgs.tree.cmd = finalCliArgs.cmd;
|
|
207
|
-
|
|
251
|
+
// Note: parallel property is not part of the tree config type
|
|
208
252
|
if (builtInCommand !== undefined) transformedCliArgs.tree.builtInCommand = builtInCommand;
|
|
209
253
|
if (finalCliArgs.continue !== undefined) transformedCliArgs.tree.continue = finalCliArgs.continue;
|
|
210
254
|
if (packageArgument !== undefined) transformedCliArgs.tree.packageArgument = packageArgument;
|
|
211
255
|
if (finalCliArgs.cleanNodeModules !== undefined) transformedCliArgs.tree.cleanNodeModules = finalCliArgs.cleanNodeModules;
|
|
256
|
+
if (finalCliArgs.externals !== undefined) transformedCliArgs.tree.externals = finalCliArgs.externals;
|
|
212
257
|
}
|
|
213
258
|
}
|
|
214
259
|
// Nested mappings for 'development' options
|
|
@@ -224,8 +269,40 @@ const transformCliArgs = (finalCliArgs, commandName)=>{
|
|
|
224
269
|
if (finalCliArgs.directories !== undefined) transformedCliArgs.versions.directories = finalCliArgs.directories;
|
|
225
270
|
}
|
|
226
271
|
// Handle excluded patterns (Commander.js converts --excluded-paths to excludedPaths)
|
|
227
|
-
|
|
228
|
-
|
|
272
|
+
// Also handle exclude as alias for excludedPatterns
|
|
273
|
+
const excludedPatterns = finalCliArgs.excludedPatterns || finalCliArgs.exclude || finalCliArgs.excludedPaths;
|
|
274
|
+
if (excludedPatterns !== undefined) {
|
|
275
|
+
if (commandName === 'tree') {
|
|
276
|
+
// For tree command, map to both root level excludedPatterns AND tree.exclude
|
|
277
|
+
transformedCliArgs.excludedPatterns = excludedPatterns;
|
|
278
|
+
if (!transformedCliArgs.tree) {
|
|
279
|
+
transformedCliArgs.tree = {};
|
|
280
|
+
}
|
|
281
|
+
transformedCliArgs.tree.exclude = excludedPatterns;
|
|
282
|
+
} else {
|
|
283
|
+
// For non-tree commands, map to root level excludedPatterns
|
|
284
|
+
transformedCliArgs.excludedPatterns = excludedPatterns;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// Handle externals - map to appropriate command objects based on command type
|
|
288
|
+
if (finalCliArgs.externals !== undefined) {
|
|
289
|
+
if (commandName === 'link') {
|
|
290
|
+
if (!transformedCliArgs.link) {
|
|
291
|
+
transformedCliArgs.link = {};
|
|
292
|
+
}
|
|
293
|
+
transformedCliArgs.link.externals = finalCliArgs.externals;
|
|
294
|
+
} else if (commandName === 'unlink') {
|
|
295
|
+
if (!transformedCliArgs.unlink) {
|
|
296
|
+
transformedCliArgs.unlink = {};
|
|
297
|
+
}
|
|
298
|
+
transformedCliArgs.unlink.externals = finalCliArgs.externals;
|
|
299
|
+
} else if (commandName === 'tree') {
|
|
300
|
+
if (!transformedCliArgs.tree) {
|
|
301
|
+
transformedCliArgs.tree = {};
|
|
302
|
+
}
|
|
303
|
+
transformedCliArgs.tree.externals = finalCliArgs.externals;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
229
306
|
// Note: openaiApiKey is handled separately via environment variable only
|
|
230
307
|
return transformedCliArgs;
|
|
231
308
|
};
|
|
@@ -268,7 +345,9 @@ const configure = async (cardigantime)=>{
|
|
|
268
345
|
// Transform the flat CLI args
|
|
269
346
|
const transformedCliArgs = transformCliArgs(cliArgs);
|
|
270
347
|
// Use CardiganTime's built-in generateConfig method
|
|
271
|
-
|
|
348
|
+
const configDir = transformedCliArgs.configDirectory || KODRDRIV_DEFAULTS.configDirectory;
|
|
349
|
+
const absoluteConfigDir = path__default.isAbsolute(configDir) ? configDir : path__default.resolve(process.cwd(), configDir);
|
|
350
|
+
await cardigantime.generateConfig(absoluteConfigDir);
|
|
272
351
|
// Return minimal config for consistency, but main processing is done
|
|
273
352
|
const config = await validateAndProcessOptions({});
|
|
274
353
|
const secureConfig = await validateAndProcessSecureOptions();
|
|
@@ -372,10 +451,10 @@ const configure = async (cardigantime)=>{
|
|
|
372
451
|
];
|
|
373
452
|
};
|
|
374
453
|
// Function to handle CLI argument parsing and processing
|
|
375
|
-
async function getCliConfig(program) {
|
|
454
|
+
async function getCliConfig(program, commands) {
|
|
376
455
|
const addSharedOptions = (command)=>{
|
|
377
456
|
command.option('--dry-run', 'perform a dry run without saving files') // Removed default, will be handled by merging
|
|
378
|
-
.option('--verbose', 'enable verbose logging').option('--debug', 'enable debug logging').option('--overrides', 'enable overrides').option('--model <model>', 'OpenAI model to use').option('-d, --context-directories [contextDirectories...]', 'directories to scan for context').option('--config-dir <configDir>', 'configuration directory') // Keep config-dir for specifying location
|
|
457
|
+
.option('--verbose', 'enable verbose logging').option('--debug', 'enable debug logging').option('--overrides', 'enable overrides').option('--model <model>', 'OpenAI model to use').option('--openai-reasoning <level>', 'OpenAI reasoning level (low, medium, high)').option('--openai-max-output-tokens <tokens>', 'OpenAI maximum output tokens', parseInt).option('-d, --context-directories [contextDirectories...]', 'directories to scan for context').option('--config-dir <configDir>', 'configuration directory') // Keep config-dir for specifying location
|
|
379
458
|
.option('--output-dir <outputDir>', 'output directory for generated files').option('--preferences-dir <preferencesDir>', 'preferences directory for personal settings').option('--excluded-paths [excludedPatterns...]', 'paths to exclude from the diff').option('--keep-temp', 'keep temporary recording files');
|
|
380
459
|
};
|
|
381
460
|
// Add global options to the main program
|
|
@@ -441,6 +520,14 @@ async function getCliConfig(program) {
|
|
|
441
520
|
'--model <model>',
|
|
442
521
|
'OpenAI model to use'
|
|
443
522
|
],
|
|
523
|
+
[
|
|
524
|
+
'--openai-reasoning <level>',
|
|
525
|
+
'OpenAI reasoning level (low, medium, high)'
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
'--openai-max-output-tokens <tokens>',
|
|
529
|
+
'OpenAI maximum output tokens'
|
|
530
|
+
],
|
|
444
531
|
[
|
|
445
532
|
'-d, --context-directories [contextDirectories...]',
|
|
446
533
|
'directories to scan for context'
|
|
@@ -479,7 +566,7 @@ async function getCliConfig(program) {
|
|
|
479
566
|
addSharedOptions(unlinkCommand);
|
|
480
567
|
const audioReviewCommand = program.command('audio-review').option('--include-commit-history', 'include recent commit log messages in context (default: true)').option('--no-include-commit-history', 'exclude commit log messages from context').option('--include-recent-diffs', 'include recent commit diffs in context (default: true)').option('--no-include-recent-diffs', 'exclude recent diffs from context').option('--include-release-notes', 'include recent release notes in context (default: false)').option('--no-include-release-notes', 'exclude release notes from context').option('--include-github-issues', 'include open GitHub issues in context (default: true)').option('--no-include-github-issues', 'exclude GitHub issues from context').option('--commit-history-limit <limit>', 'number of recent commits to include', parseInt).option('--diff-history-limit <limit>', 'number of recent commit diffs to include', parseInt).option('--release-notes-limit <limit>', 'number of recent release notes to include', parseInt).option('--github-issues-limit <limit>', 'number of open GitHub issues to include (max 20)', parseInt).option('--context <context>', 'additional context for the audio review').option('--file <file>', 'audio file path').option('--directory <directory>', 'directory containing audio files to process').option('--max-recording-time <time>', 'maximum recording time in seconds', parseInt).option('--sendit', 'Create GitHub issues automatically without confirmation').description('Record audio, transcribe with Whisper, and analyze for project issues using AI');
|
|
481
568
|
addSharedOptions(audioReviewCommand);
|
|
482
|
-
const reviewCommand = program.command('review').argument('[note]', 'review note to analyze for project issues').option('--include-commit-history', 'include recent commit log messages in context (default: true)').option('--no-include-commit-history', 'exclude commit log messages from context').option('--include-recent-diffs', 'include recent commit diffs in context (default: true)').option('--no-include-recent-diffs', 'exclude recent diffs from context').option('--include-release-notes', 'include recent release notes in context (default: false)').option('--no-include-release-notes', 'exclude release notes from context').option('--include-github-issues', 'include open GitHub issues in context (default: true)').option('--no-include-github-issues', 'exclude GitHub issues from context').option('--commit-history-limit <limit>', 'number of recent commits to include', parseInt).option('--diff-history-limit <limit>', 'number of recent commit diffs to include', parseInt).option('--release-notes-limit <limit>', 'number of recent release notes to include', parseInt).option('--github-issues-limit <limit>', 'number of open GitHub issues to include (max 20)', parseInt).option('--context <context>', 'additional context for the review').option('--sendit', 'Create GitHub issues automatically without confirmation').option('--editor-timeout <timeout>', 'timeout for editor in milliseconds (default: no timeout)', parseInt).description('Analyze review note for project issues using AI');
|
|
569
|
+
const reviewCommand = program.command('review').argument('[note]', 'review note to analyze for project issues').option('--include-commit-history', 'include recent commit log messages in context (default: true)').option('--no-include-commit-history', 'exclude commit log messages from context').option('--include-recent-diffs', 'include recent commit diffs in context (default: true)').option('--no-include-recent-diffs', 'exclude recent diffs from context').option('--include-release-notes', 'include recent release notes in context (default: false)').option('--no-include-release-notes', 'exclude release notes from context').option('--include-github-issues', 'include open GitHub issues in context (default: true)').option('--no-include-github-issues', 'exclude GitHub issues from context').option('--commit-history-limit <limit>', 'number of recent commits to include', parseInt).option('--diff-history-limit <limit>', 'number of recent commit diffs to include', parseInt).option('--release-notes-limit <limit>', 'number of recent release notes to include', parseInt).option('--github-issues-limit <limit>', 'number of open GitHub issues to include (max 20)', parseInt).option('--context <context>', 'additional context for the review').option('--file <file>', 'read review note from a file').option('--directory <directory>', 'process all review files in a directory').option('--sendit', 'Create GitHub issues automatically without confirmation').option('--editor-timeout <timeout>', 'timeout for editor in milliseconds (default: no timeout)', parseInt).description('Analyze review note for project issues using AI');
|
|
483
570
|
addSharedOptions(reviewCommand);
|
|
484
571
|
// Customize help output for review command
|
|
485
572
|
reviewCommand.configureHelp({
|
|
@@ -495,6 +582,14 @@ async function getCliConfig(program) {
|
|
|
495
582
|
[
|
|
496
583
|
'--context <context>',
|
|
497
584
|
'additional context for the review'
|
|
585
|
+
],
|
|
586
|
+
[
|
|
587
|
+
'--file <file>',
|
|
588
|
+
'read review note from a file'
|
|
589
|
+
],
|
|
590
|
+
[
|
|
591
|
+
'--directory <directory>',
|
|
592
|
+
'process all review files in a directory'
|
|
498
593
|
]
|
|
499
594
|
];
|
|
500
595
|
const gitContextOptions = [
|
|
@@ -574,6 +669,14 @@ async function getCliConfig(program) {
|
|
|
574
669
|
'--model <model>',
|
|
575
670
|
'OpenAI model to use'
|
|
576
671
|
],
|
|
672
|
+
[
|
|
673
|
+
'--openai-reasoning <level>',
|
|
674
|
+
'OpenAI reasoning level (low, medium, high)'
|
|
675
|
+
],
|
|
676
|
+
[
|
|
677
|
+
'--openai-max-output-tokens <tokens>',
|
|
678
|
+
'OpenAI maximum output tokens'
|
|
679
|
+
],
|
|
577
680
|
[
|
|
578
681
|
'-d, --context-directories [contextDirectories...]',
|
|
579
682
|
'directories to scan for context'
|
|
@@ -621,77 +724,202 @@ async function getCliConfig(program) {
|
|
|
621
724
|
}
|
|
622
725
|
// Only proceed with command-specific options if validation passed
|
|
623
726
|
if (ALLOWED_COMMANDS.includes(commandName)) {
|
|
624
|
-
|
|
625
|
-
|
|
727
|
+
var _chosen_commitCommand, _chosen_commit, _chosen_audioCommitCommand, _chosen_releaseCommand, _chosen_publishCommand, _chosen_treeCommand, _chosen_linkCommand, _chosen_unlinkCommand, _chosen_audioReviewCommand, _chosen_reviewCommand, _chosen_review, _chosen_cleanCommand, _chosen_developmentCommand, _chosen_versionsCommand, _chosen_selectAudioCommand;
|
|
728
|
+
const chosen = {
|
|
729
|
+
commitCommand,
|
|
730
|
+
audioCommitCommand,
|
|
731
|
+
releaseCommand,
|
|
732
|
+
publishCommand,
|
|
733
|
+
treeCommand,
|
|
734
|
+
linkCommand,
|
|
735
|
+
unlinkCommand,
|
|
736
|
+
audioReviewCommand,
|
|
737
|
+
reviewCommand,
|
|
738
|
+
cleanCommand,
|
|
739
|
+
developmentCommand,
|
|
740
|
+
versionsCommand,
|
|
741
|
+
selectAudioCommand
|
|
742
|
+
};
|
|
743
|
+
if (commandName === 'commit' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_commitCommand = chosen.commitCommand) === null || _chosen_commitCommand === void 0 ? void 0 : _chosen_commitCommand.opts)) {
|
|
744
|
+
const commitCmd = chosen.commitCommand;
|
|
745
|
+
commandOptions = commitCmd.opts();
|
|
626
746
|
// Handle positional argument for direction
|
|
627
|
-
|
|
628
|
-
if (args
|
|
629
|
-
commandOptions.direction = args[
|
|
747
|
+
// Try to get direction from program.args (after the command name)
|
|
748
|
+
if (program.args.length > 1) {
|
|
749
|
+
commandOptions.direction = program.args[1];
|
|
750
|
+
}
|
|
751
|
+
// Also try commitCommand.args as fallback
|
|
752
|
+
const args = commitCmd.args;
|
|
753
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
754
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
755
|
+
if (firstTruthyArg) {
|
|
756
|
+
commandOptions.direction = firstTruthyArg;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
// Final fallback: use locally constructed commit command's args
|
|
760
|
+
if (!commandOptions.direction) {
|
|
761
|
+
const localArgs = commitCommand === null || commitCommand === void 0 ? void 0 : commitCommand.args;
|
|
762
|
+
if (Array.isArray(localArgs) && localArgs.length > 0) {
|
|
763
|
+
const firstLocalArg = localArgs.find((arg)=>arg);
|
|
764
|
+
if (firstLocalArg) {
|
|
765
|
+
commandOptions.direction = firstLocalArg;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
630
768
|
}
|
|
631
769
|
// Check for STDIN input for direction (takes precedence over positional argument)
|
|
632
770
|
const stdinInput = await readStdin();
|
|
633
|
-
if (stdinInput) {
|
|
771
|
+
if (typeof stdinInput === 'string') {
|
|
634
772
|
commandOptions.direction = stdinInput;
|
|
635
773
|
}
|
|
636
|
-
} else if (commandName === '
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
commandOptions =
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
774
|
+
} else if (commandName === 'commit' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_commit = chosen.commit) === null || _chosen_commit === void 0 ? void 0 : _chosen_commit.opts)) {
|
|
775
|
+
// Fallback when a test/mocked commands object provides 'commit' instead of 'commitCommand'
|
|
776
|
+
const commitCmd = chosen.commit;
|
|
777
|
+
commandOptions = commitCmd.opts();
|
|
778
|
+
if (program.args.length > 1) {
|
|
779
|
+
commandOptions.direction = program.args[1];
|
|
780
|
+
}
|
|
781
|
+
const args = commitCmd.args;
|
|
782
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
783
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
784
|
+
if (firstTruthyArg) {
|
|
785
|
+
commandOptions.direction = firstTruthyArg;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (!commandOptions.direction) {
|
|
789
|
+
const localArgs = commitCommand === null || commitCommand === void 0 ? void 0 : commitCommand.args;
|
|
790
|
+
if (Array.isArray(localArgs) && localArgs.length > 0) {
|
|
791
|
+
const firstLocalArg = localArgs.find((arg)=>arg);
|
|
792
|
+
if (firstLocalArg) {
|
|
793
|
+
commandOptions.direction = firstLocalArg;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
const stdinInput = await readStdin();
|
|
798
|
+
if (typeof stdinInput === 'string') {
|
|
799
|
+
commandOptions.direction = stdinInput;
|
|
800
|
+
}
|
|
801
|
+
} else if (commandName === 'audio-commit' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_audioCommitCommand = chosen.audioCommitCommand) === null || _chosen_audioCommitCommand === void 0 ? void 0 : _chosen_audioCommitCommand.opts)) {
|
|
802
|
+
const audioCommitCmd = chosen.audioCommitCommand;
|
|
803
|
+
commandOptions = audioCommitCmd.opts();
|
|
804
|
+
} else if (commandName === 'release' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_releaseCommand = chosen.releaseCommand) === null || _chosen_releaseCommand === void 0 ? void 0 : _chosen_releaseCommand.opts)) {
|
|
805
|
+
const releaseCmd = chosen.releaseCommand;
|
|
806
|
+
commandOptions = releaseCmd.opts();
|
|
807
|
+
} else if (commandName === 'publish' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_publishCommand = chosen.publishCommand) === null || _chosen_publishCommand === void 0 ? void 0 : _chosen_publishCommand.opts)) {
|
|
808
|
+
const publishCmd = chosen.publishCommand;
|
|
809
|
+
commandOptions = publishCmd.opts();
|
|
810
|
+
} else if (commandName === 'tree' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_treeCommand = chosen.treeCommand) === null || _chosen_treeCommand === void 0 ? void 0 : _chosen_treeCommand.opts)) {
|
|
811
|
+
const treeCmd = chosen.treeCommand;
|
|
812
|
+
commandOptions = treeCmd.opts();
|
|
644
813
|
// Handle positional arguments for built-in command and package argument
|
|
645
|
-
const args =
|
|
646
|
-
if (args && args.length > 0
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
814
|
+
const args = treeCmd.args;
|
|
815
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
816
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
817
|
+
if (firstTruthyArg) {
|
|
818
|
+
commandOptions.builtInCommand = firstTruthyArg;
|
|
819
|
+
if ((firstTruthyArg === 'link' || firstTruthyArg === 'unlink') && args.length > 1) {
|
|
820
|
+
const secondTruthyArg = args.slice(1).find((arg)=>arg);
|
|
821
|
+
if (secondTruthyArg) {
|
|
822
|
+
commandOptions.packageArgument = secondTruthyArg;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
652
825
|
}
|
|
653
826
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
827
|
+
const stdinInput = await readStdin();
|
|
828
|
+
if (typeof stdinInput === 'string') {
|
|
829
|
+
commandOptions.builtInCommand = stdinInput.trim().split('\n')[0] || commandOptions.builtInCommand;
|
|
830
|
+
const stdinLines = stdinInput.split('\n');
|
|
831
|
+
if (stdinLines[1]) {
|
|
832
|
+
commandOptions.packageArgument = stdinLines[1];
|
|
833
|
+
}
|
|
660
834
|
}
|
|
661
|
-
} else if (commandName === '
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const args =
|
|
665
|
-
if (args && args.length > 0
|
|
666
|
-
|
|
835
|
+
} else if (commandName === 'link' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_linkCommand = chosen.linkCommand) === null || _chosen_linkCommand === void 0 ? void 0 : _chosen_linkCommand.opts)) {
|
|
836
|
+
const linkCmd = chosen.linkCommand;
|
|
837
|
+
commandOptions = linkCmd.opts();
|
|
838
|
+
const args = linkCmd.args;
|
|
839
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
840
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
841
|
+
if (firstTruthyArg) {
|
|
842
|
+
commandOptions.packageArgument = firstTruthyArg === 'status' ? 'status' : firstTruthyArg;
|
|
843
|
+
}
|
|
667
844
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
845
|
+
const stdinInput = await readStdin();
|
|
846
|
+
if (typeof stdinInput === 'string') {
|
|
847
|
+
commandOptions.packageArgument = stdinInput;
|
|
848
|
+
}
|
|
849
|
+
} else if (commandName === 'unlink' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_unlinkCommand = chosen.unlinkCommand) === null || _chosen_unlinkCommand === void 0 ? void 0 : _chosen_unlinkCommand.opts)) {
|
|
850
|
+
const unlinkCmd = chosen.unlinkCommand;
|
|
851
|
+
commandOptions = unlinkCmd.opts();
|
|
852
|
+
const args = unlinkCmd.args;
|
|
853
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
854
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
855
|
+
if (firstTruthyArg) {
|
|
856
|
+
commandOptions.packageArgument = firstTruthyArg === 'status' ? 'status' : firstTruthyArg;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const stdinInput = await readStdin();
|
|
860
|
+
if (typeof stdinInput === 'string') {
|
|
861
|
+
commandOptions.packageArgument = stdinInput;
|
|
862
|
+
}
|
|
863
|
+
} else if (commandName === 'audio-review' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_audioReviewCommand = chosen.audioReviewCommand) === null || _chosen_audioReviewCommand === void 0 ? void 0 : _chosen_audioReviewCommand.opts)) {
|
|
864
|
+
const audioReviewCmd = chosen.audioReviewCommand;
|
|
865
|
+
commandOptions = audioReviewCmd.opts();
|
|
866
|
+
} else if (commandName === 'review' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_reviewCommand = chosen.reviewCommand) === null || _chosen_reviewCommand === void 0 ? void 0 : _chosen_reviewCommand.opts)) {
|
|
867
|
+
const reviewCmd = chosen.reviewCommand;
|
|
868
|
+
commandOptions = reviewCmd.opts();
|
|
869
|
+
const args = reviewCmd.args;
|
|
870
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
871
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
872
|
+
if (firstTruthyArg) {
|
|
873
|
+
commandOptions.note = firstTruthyArg;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
// Final fallback: use locally constructed review command's args
|
|
877
|
+
if (!commandOptions.note) {
|
|
878
|
+
const localArgs = reviewCommand === null || reviewCommand === void 0 ? void 0 : reviewCommand.args;
|
|
879
|
+
if (Array.isArray(localArgs) && localArgs.length > 0) {
|
|
880
|
+
const firstLocalArg = localArgs.find((arg)=>arg);
|
|
881
|
+
if (firstLocalArg) {
|
|
882
|
+
commandOptions.note = firstLocalArg;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
const stdinInput = await readStdin();
|
|
887
|
+
if (typeof stdinInput === 'string') {
|
|
888
|
+
commandOptions.note = stdinInput;
|
|
889
|
+
}
|
|
890
|
+
} else if (commandName === 'review' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_review = chosen.review) === null || _chosen_review === void 0 ? void 0 : _chosen_review.opts)) {
|
|
891
|
+
const reviewCmd = chosen.review;
|
|
892
|
+
commandOptions = reviewCmd.opts();
|
|
893
|
+
const args = reviewCmd.args;
|
|
894
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
895
|
+
const firstTruthyArg = args.find((arg)=>arg);
|
|
896
|
+
if (firstTruthyArg) {
|
|
897
|
+
commandOptions.note = firstTruthyArg;
|
|
898
|
+
}
|
|
676
899
|
}
|
|
677
|
-
// Check for STDIN input for note (takes precedence over positional argument)
|
|
678
900
|
const stdinInput = await readStdin();
|
|
679
|
-
if (stdinInput) {
|
|
901
|
+
if (typeof stdinInput === 'string') {
|
|
680
902
|
commandOptions.note = stdinInput;
|
|
681
903
|
}
|
|
682
|
-
} else if (commandName === 'clean' && cleanCommand.opts) {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
commandOptions =
|
|
688
|
-
|
|
689
|
-
const
|
|
904
|
+
} else if (commandName === 'clean' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_cleanCommand = chosen.cleanCommand) === null || _chosen_cleanCommand === void 0 ? void 0 : _chosen_cleanCommand.opts)) {
|
|
905
|
+
const cleanCmd = chosen.cleanCommand;
|
|
906
|
+
commandOptions = cleanCmd.opts();
|
|
907
|
+
} else if (commandName === 'development' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_developmentCommand = chosen.developmentCommand) === null || _chosen_developmentCommand === void 0 ? void 0 : _chosen_developmentCommand.opts)) {
|
|
908
|
+
const developmentCmd = chosen.developmentCommand;
|
|
909
|
+
commandOptions = developmentCmd.opts();
|
|
910
|
+
} else if (commandName === 'versions' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_versionsCommand = chosen.versionsCommand) === null || _chosen_versionsCommand === void 0 ? void 0 : _chosen_versionsCommand.opts)) {
|
|
911
|
+
const versionsCmd = chosen.versionsCommand;
|
|
912
|
+
commandOptions = versionsCmd.opts();
|
|
913
|
+
const args = versionsCmd.args;
|
|
690
914
|
if (args && args.length > 0 && args[0]) {
|
|
691
915
|
commandOptions.subcommand = args[0];
|
|
692
916
|
}
|
|
693
|
-
} else if (commandName === 'select-audio' && selectAudioCommand.opts) {
|
|
694
|
-
|
|
917
|
+
} else if (commandName === 'select-audio' && (chosen === null || chosen === void 0 ? void 0 : (_chosen_selectAudioCommand = chosen.selectAudioCommand) === null || _chosen_selectAudioCommand === void 0 ? void 0 : _chosen_selectAudioCommand.opts)) {
|
|
918
|
+
const selectAudioCmd = chosen.selectAudioCommand;
|
|
919
|
+
commandOptions = selectAudioCmd.opts();
|
|
920
|
+
} else {
|
|
921
|
+
// Final fallback
|
|
922
|
+
commandOptions = program.opts();
|
|
695
923
|
}
|
|
696
924
|
}
|
|
697
925
|
// Include command name in CLI args for merging
|
|
@@ -699,6 +927,25 @@ async function getCliConfig(program) {
|
|
|
699
927
|
...cliArgs,
|
|
700
928
|
...commandOptions
|
|
701
929
|
};
|
|
930
|
+
// Final safety fallback for positional arguments when STDIN is null and mocks provide args on constructed commands
|
|
931
|
+
if (commandName === 'commit' && !finalCliArgs.direction) {
|
|
932
|
+
const localArgs = commitCommand === null || commitCommand === void 0 ? void 0 : commitCommand.args;
|
|
933
|
+
if (Array.isArray(localArgs) && localArgs.length > 0) {
|
|
934
|
+
const firstLocalArg = localArgs.find((arg)=>arg);
|
|
935
|
+
if (firstLocalArg) {
|
|
936
|
+
finalCliArgs.direction = firstLocalArg;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if (commandName === 'review' && !finalCliArgs.note) {
|
|
941
|
+
const localArgs = reviewCommand === null || reviewCommand === void 0 ? void 0 : reviewCommand.args;
|
|
942
|
+
if (Array.isArray(localArgs) && localArgs.length > 0) {
|
|
943
|
+
const firstLocalArg = localArgs.find((arg)=>arg);
|
|
944
|
+
if (firstLocalArg) {
|
|
945
|
+
finalCliArgs.note = firstLocalArg;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
702
949
|
const commandConfig = {
|
|
703
950
|
commandName
|
|
704
951
|
};
|
|
@@ -725,7 +972,7 @@ async function validateAndProcessSecureOptions() {
|
|
|
725
972
|
async function validateAndProcessOptions(options) {
|
|
726
973
|
const contextDirectories = await validateContextDirectories(options.contextDirectories || KODRDRIV_DEFAULTS.contextDirectories);
|
|
727
974
|
const configDir = options.configDirectory || KODRDRIV_DEFAULTS.configDirectory;
|
|
728
|
-
var _options_dryRun, _options_verbose, _options_debug, _options_overrides, _options_model, _options_outputDirectory, _options_preferencesDirectory, _options_discoveredConfigDirs, _options_resolvedConfigDirs, _options_excludedPatterns;
|
|
975
|
+
var _options_dryRun, _options_verbose, _options_debug, _options_overrides, _options_model, _options_openaiReasoning, _options_openaiMaxOutputTokens, _options_outputDirectory, _options_preferencesDirectory, _options_discoveredConfigDirs, _options_resolvedConfigDirs, _options_excludedPatterns;
|
|
729
976
|
// Skip config directory validation since Cardigantime handles hierarchical lookup
|
|
730
977
|
// Ensure all required fields are present and have correct types after merging
|
|
731
978
|
const finalConfig = {
|
|
@@ -734,6 +981,8 @@ async function validateAndProcessOptions(options) {
|
|
|
734
981
|
debug: (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : KODRDRIV_DEFAULTS.debug,
|
|
735
982
|
overrides: (_options_overrides = options.overrides) !== null && _options_overrides !== void 0 ? _options_overrides : KODRDRIV_DEFAULTS.overrides,
|
|
736
983
|
model: (_options_model = options.model) !== null && _options_model !== void 0 ? _options_model : KODRDRIV_DEFAULTS.model,
|
|
984
|
+
openaiReasoning: (_options_openaiReasoning = options.openaiReasoning) !== null && _options_openaiReasoning !== void 0 ? _options_openaiReasoning : KODRDRIV_DEFAULTS.openaiReasoning,
|
|
985
|
+
openaiMaxOutputTokens: (_options_openaiMaxOutputTokens = options.openaiMaxOutputTokens) !== null && _options_openaiMaxOutputTokens !== void 0 ? _options_openaiMaxOutputTokens : KODRDRIV_DEFAULTS.openaiMaxOutputTokens,
|
|
737
986
|
contextDirectories: contextDirectories,
|
|
738
987
|
configDirectory: configDir,
|
|
739
988
|
outputDirectory: (_options_outputDirectory = options.outputDirectory) !== null && _options_outputDirectory !== void 0 ? _options_outputDirectory : KODRDRIV_DEFAULTS.outputDirectory,
|
|
@@ -744,7 +993,7 @@ async function validateAndProcessOptions(options) {
|
|
|
744
993
|
// Command-specific options - ensure all defaults are present even for partial configs
|
|
745
994
|
commit: {
|
|
746
995
|
...KODRDRIV_DEFAULTS.commit,
|
|
747
|
-
...Object.fromEntries(Object.entries(options.commit || {}).filter(([_, v])=>v !== undefined))
|
|
996
|
+
...Object.fromEntries(Object.entries(options.commit || {}).filter(([_, v])=>v !== undefined && v !== null))
|
|
748
997
|
},
|
|
749
998
|
audioCommit: {
|
|
750
999
|
...KODRDRIV_DEFAULTS.audioCommit,
|