codebakers 2.0.4 ā 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advisors-J3S64IZK.js +7 -0
- package/dist/chunk-FWQNLNTI.js +565 -0
- package/dist/chunk-RCC7FYEU.js +319 -0
- package/dist/chunk-YGVDLNXY.js +326 -0
- package/dist/index.js +2817 -1896
- package/dist/prd-HBUCYLVG.js +7 -0
- package/package.json +1 -1
- package/src/commands/build.ts +989 -0
- package/src/commands/code.ts +102 -5
- package/src/commands/prd-maker.ts +587 -0
- package/src/index.ts +122 -4
- package/src/utils/files.ts +418 -0
- package/src/utils/nlp.ts +312 -0
- package/src/utils/voice.ts +323 -0
package/src/commands/code.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { execa } from 'execa';
|
|
|
7
7
|
import { Config } from '../utils/config.js';
|
|
8
8
|
import { loadPatterns } from '../patterns/loader.js';
|
|
9
9
|
import { runPatternCheck } from './check.js';
|
|
10
|
+
import { textWithVoice, checkVoiceAvailability } from '../utils/voice.js';
|
|
11
|
+
import { readClipboard, readFile, formatFilesForContext, looksLikePaste, handlePastedContent } from '../utils/files.js';
|
|
10
12
|
|
|
11
13
|
interface CodeOptions {
|
|
12
14
|
watch?: boolean;
|
|
@@ -82,11 +84,22 @@ export async function codeCommand(prompt?: string, options: CodeOptions = {}): P
|
|
|
82
84
|
await processUserInput(prompt, messages, anthropic, systemPrompt, projectContext, config);
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
// Check for voice support
|
|
88
|
+
const hasVoice = await checkVoiceAvailability();
|
|
89
|
+
|
|
90
|
+
console.log(chalk.dim(' š” Tips:'));
|
|
91
|
+
if (hasVoice) {
|
|
92
|
+
console.log(chalk.dim(' ⢠Type "v" for voice input'));
|
|
93
|
+
}
|
|
94
|
+
console.log(chalk.dim(' ⢠Type "clip" to read from clipboard'));
|
|
95
|
+
console.log(chalk.dim(' ⢠Drag & drop files or paste file paths'));
|
|
96
|
+
console.log(chalk.dim(' ⢠Paste code directly and I\'ll detect it\n'));
|
|
97
|
+
|
|
85
98
|
// Interactive loop
|
|
86
99
|
while (true) {
|
|
87
|
-
const input = await
|
|
100
|
+
const input = await textWithVoice({
|
|
88
101
|
message: '',
|
|
89
|
-
placeholder: 'What do you want to build?',
|
|
102
|
+
placeholder: 'What do you want to build? (or paste code/file path)',
|
|
90
103
|
});
|
|
91
104
|
|
|
92
105
|
if (p.isCancel(input)) {
|
|
@@ -94,7 +107,8 @@ export async function codeCommand(prompt?: string, options: CodeOptions = {}): P
|
|
|
94
107
|
break;
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
|
|
110
|
+
let userInput = (input as string).trim();
|
|
111
|
+
let fileContext = '';
|
|
98
112
|
|
|
99
113
|
if (!userInput) continue;
|
|
100
114
|
|
|
@@ -114,8 +128,91 @@ export async function codeCommand(prompt?: string, options: CodeOptions = {}): P
|
|
|
114
128
|
continue;
|
|
115
129
|
}
|
|
116
130
|
|
|
117
|
-
//
|
|
118
|
-
|
|
131
|
+
// Check for clipboard command
|
|
132
|
+
if (userInput.toLowerCase() === 'clip' || userInput.toLowerCase() === 'clipboard' || userInput.toLowerCase() === 'paste') {
|
|
133
|
+
const clipContent = await readClipboard();
|
|
134
|
+
if (clipContent) {
|
|
135
|
+
console.log(chalk.green(`\nš Read ${clipContent.length} characters from clipboard\n`));
|
|
136
|
+
|
|
137
|
+
// Check if clipboard is a file path
|
|
138
|
+
if (await fs.pathExists(clipContent.trim())) {
|
|
139
|
+
const file = await readFile(clipContent.trim());
|
|
140
|
+
if (file) {
|
|
141
|
+
fileContext = formatFilesForContext([file]);
|
|
142
|
+
console.log(chalk.green(`š Loaded file: ${file.name}\n`));
|
|
143
|
+
|
|
144
|
+
const instruction = await p.text({
|
|
145
|
+
message: `What should I do with ${file.name}?`,
|
|
146
|
+
placeholder: 'Fix any issues in this code',
|
|
147
|
+
});
|
|
148
|
+
if (p.isCancel(instruction)) continue;
|
|
149
|
+
userInput = instruction as string;
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
// Clipboard contains code/text
|
|
153
|
+
fileContext = `\n\n--- CLIPBOARD CONTENT ---\n\`\`\`\n${clipContent}\n\`\`\`\n--- END ---\n\n`;
|
|
154
|
+
|
|
155
|
+
const action = await p.select({
|
|
156
|
+
message: 'What should I do with this?',
|
|
157
|
+
options: [
|
|
158
|
+
{ value: 'analyze', label: 'š Analyze this' },
|
|
159
|
+
{ value: 'fix', label: 'š§ Fix issues' },
|
|
160
|
+
{ value: 'explain', label: 'š Explain' },
|
|
161
|
+
{ value: 'improve', label: '⨠Improve' },
|
|
162
|
+
{ value: 'custom', label: 'āļø Custom' },
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (p.isCancel(action)) continue;
|
|
167
|
+
|
|
168
|
+
if (action === 'custom') {
|
|
169
|
+
const custom = await p.text({ message: 'What should I do?', placeholder: 'Add TypeScript types' });
|
|
170
|
+
if (p.isCancel(custom)) continue;
|
|
171
|
+
userInput = custom as string;
|
|
172
|
+
} else {
|
|
173
|
+
const actions: Record<string, string> = {
|
|
174
|
+
analyze: 'Analyze this code and explain what it does',
|
|
175
|
+
fix: 'Fix any bugs or issues in this code',
|
|
176
|
+
explain: 'Explain this code step by step',
|
|
177
|
+
improve: 'Improve and refactor this code',
|
|
178
|
+
};
|
|
179
|
+
userInput = actions[action as string];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
console.log(chalk.yellow('Clipboard is empty'));
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Check if input is a file path
|
|
189
|
+
else if (await fs.pathExists(userInput)) {
|
|
190
|
+
const file = await readFile(userInput);
|
|
191
|
+
if (file) {
|
|
192
|
+
fileContext = formatFilesForContext([file]);
|
|
193
|
+
console.log(chalk.green(`\nš Loaded file: ${file.name}\n`));
|
|
194
|
+
|
|
195
|
+
const instruction = await p.text({
|
|
196
|
+
message: `What should I do with ${file.name}?`,
|
|
197
|
+
placeholder: 'Analyze and improve this code',
|
|
198
|
+
});
|
|
199
|
+
if (p.isCancel(instruction)) continue;
|
|
200
|
+
userInput = instruction as string;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Check if input looks like pasted code
|
|
205
|
+
else if (looksLikePaste(userInput)) {
|
|
206
|
+
const result = await handlePastedContent(userInput);
|
|
207
|
+
if (result) {
|
|
208
|
+
userInput = result.prompt;
|
|
209
|
+
fileContext = result.context;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Process input with AI (include file context if any)
|
|
214
|
+
const fullInput = fileContext ? userInput + fileContext : userInput;
|
|
215
|
+
await processUserInput(fullInput, messages, anthropic, systemPrompt, projectContext, config);
|
|
119
216
|
}
|
|
120
217
|
}
|
|
121
218
|
|