Skip to content

Commit c482aa0

Browse files
committed
fix: improve prompt-file handling and token counting
- Count tokens from prompt file content (not showing 0) - Don't scan all files when using --prompt-file alone - Clean prompt formatting when no code context - Bump version to 0.4.4
1 parent a463ce9 commit c482aa0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "promptcode-cli",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "CLI tool for PromptCode - Generate AI-ready prompts from codebases",
55
"bin": {
66
"promptcode": "./dist/promptcode"

packages/cli/src/commands/expert.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,13 @@ export async function expertCommand(question: string | undefined, options: Exper
253253
});
254254
} else {
255255
// No files to scan - create minimal result for prompt-only queries
256+
// But we need to count tokens from the prompt/question itself
257+
const { countTokens } = await import('@promptcode/core');
258+
const promptTokens = countTokens(question || '');
259+
256260
result = {
257261
prompt: '',
258-
tokenCount: 0,
262+
tokenCount: promptTokens,
259263
fileCount: 0
260264
};
261265
}
@@ -343,8 +347,9 @@ export async function expertCommand(question: string | undefined, options: Exper
343347
}
344348

345349
// Prepare the prompt
346-
const fullPrompt =
347-
`Here is the codebase context:\n\n${result.prompt}\n\n${question}`;
350+
const fullPrompt = result.prompt
351+
? `Here is the codebase context:\n\n${result.prompt}\n\n${question}`
352+
: question || '';
348353

349354
if (spin) {
350355
spin.text = `Consulting ${modelConfig.name}...`;

0 commit comments

Comments
 (0)