Skip to content

Commit 4180504

Browse files
committed
fix: add formatArg wraps any arg that contains a space in double quotes
1 parent 0a627de commit 4180504

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ekaone/json-cli",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "AI-powered CLI task runner with JSON command plans",
55
"keywords": ["ai", "agent", "cli", "task-runner", "llm"],
66
"author": {

src/catalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const StepSchema = z.object({
3636
command: z.string(),
3737
args: z.array(z.string()).default([]),
3838
description: z.string(),
39-
cwd: z.string().optional(), // optional working directory override
39+
cwd: z.string().nullable().optional(), // optional working directory override
4040
});
4141

4242
export const PlanSchema = z.object({

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ function parseArgs(): {
7474
// Format a step for display
7575
// ---------------------------------------------------------------------------
7676
function formatStep(step: Step): string {
77+
const formatArg = (arg: string) => (arg.includes(" ") ? `"${arg}"` : arg);
7778
const cmd =
7879
step.type === "shell"
79-
? `${step.command} ${step.args.join(" ")}`
80-
: `${step.type} ${step.command} ${step.args.join(" ")}`.trim();
80+
? `${step.command} ${step.args.map(formatArg).join(" ")}`
81+
: `${step.type} ${step.command} ${step.args.map(formatArg).join(" ")}`.trim();
8182
return `${cmd.padEnd(35)}${step.description}`;
8283
}
8384

src/planner.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,27 @@ Rules:
1818
- Each step must have a clear, short description
1919
- NEVER generate a "cd" step — each step runs in a separate process so "cd" has no effect
2020
- If subsequent steps need to run inside a cloned directory, set the "cwd" field instead
21+
- For commands that take a message or value argument (like git commit -m), always keep the full message as a single array element, e.g. args: ["-m", "Update changes"] never args: ["-m", "Update", "changes"]
2122
2223
Respond ONLY with valid JSON matching this exact shape, no markdown, no explanation:
2324
{
2425
"goal": "string describing the overall goal",
2526
"steps": [
2627
{
2728
"id": 1,
29+
"type": "git",
30+
"command": "commit",
31+
"args": ["-m", "Update changes"],
32+
"description": "Commit staged changes",
33+
"cwd": null
34+
},
35+
{
36+
"id": 2,
2837
"type": "pnpm",
2938
"command": "run",
30-
"args": ["dev"],
31-
"description": "Start dev server"
39+
"args": ["dev", "--port", "3000"],
40+
"description": "Start dev server",
41+
"cwd": "my-repo"
3242
}
3343
]
3444
}`;

src/providers/claude.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ import Anthropic from "@anthropic-ai/sdk";
22
import type { AIProvider } from "./types.js";
33

44
export function createClaudeProvider(apiKey?: string): AIProvider {
5-
const client = new Anthropic({ apiKey: apiKey ?? process.env.ANTHROPIC_API_KEY });
5+
const client = new Anthropic({
6+
apiKey: apiKey ?? process.env.ANTHROPIC_API_KEY,
7+
});
68

79
return {
810
name: "claude",
911
async generate(userPrompt, systemPrompt) {
1012
const message = await client.messages.create({
11-
model: "claude-opus-4-5",
13+
model: "claude-sonnet-4-6",
1214
max_tokens: 1024,
13-
system: systemPrompt,
14-
messages: [{ role: "user", content: userPrompt }],
15+
system: systemPrompt,
16+
messages: [{ role: "user", content: userPrompt }],
1517
});
1618

1719
const block = message.content[0];
18-
if (block.type !== "text") throw new Error("Unexpected response type from Claude");
20+
if (block.type !== "text")
21+
throw new Error("Unexpected response type from Claude");
1922
return block.text;
2023
},
2124
};

0 commit comments

Comments
 (0)