codemaxxing 1.0.0 → 1.0.2
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/README.md +18 -12
- package/dist/agent.d.ts +4 -0
- package/dist/agent.js +91 -16
- package/dist/commands/git.d.ts +2 -0
- package/dist/commands/git.js +50 -0
- package/dist/commands/ollama.d.ts +27 -0
- package/dist/commands/ollama.js +171 -0
- package/dist/commands/output.d.ts +2 -0
- package/dist/commands/output.js +18 -0
- package/dist/commands/registry.d.ts +2 -0
- package/dist/commands/registry.js +8 -0
- package/dist/commands/skills.d.ts +18 -0
- package/dist/commands/skills.js +121 -0
- package/dist/commands/types.d.ts +5 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/ui.d.ts +16 -0
- package/dist/commands/ui.js +79 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +13 -3
- package/dist/exec.js +4 -1
- package/dist/index.js +75 -401
- package/dist/tools/files.js +58 -3
- package/dist/utils/context.js +6 -0
- package/dist/utils/mcp.d.ts +7 -2
- package/dist/utils/mcp.js +34 -6
- package/package.json +8 -5
- package/src/agent.ts +0 -894
- package/src/auth-cli.ts +0 -287
- package/src/cli.ts +0 -37
- package/src/config.ts +0 -352
- package/src/exec.ts +0 -183
- package/src/index.tsx +0 -2647
- package/src/skills/registry.ts +0 -1436
- package/src/themes.ts +0 -335
- package/src/tools/files.ts +0 -374
- package/src/utils/auth.ts +0 -606
- package/src/utils/context.ts +0 -174
- package/src/utils/git.ts +0 -117
- package/src/utils/hardware.ts +0 -131
- package/src/utils/lint.ts +0 -116
- package/src/utils/mcp.ts +0 -307
- package/src/utils/models.ts +0 -218
- package/src/utils/ollama.ts +0 -352
- package/src/utils/repomap.ts +0 -220
- package/src/utils/sessions.ts +0 -254
- package/src/utils/skills.ts +0 -241
- package/tsconfig.json +0 -16
package/src/exec.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Headless/CI execution mode — runs agent without TUI
|
|
3
|
-
* Usage: codemaxxing exec "your prompt here"
|
|
4
|
-
* Flags: --auto-approve, --json, --model <model>, --provider <name>
|
|
5
|
-
* Supports stdin pipe: echo "fix the tests" | codemaxxing exec
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { CodingAgent } from "./agent.js";
|
|
9
|
-
import { loadConfig, applyOverrides, detectLocalProvider } from "./config.js";
|
|
10
|
-
import { getCredential } from "./utils/auth.js";
|
|
11
|
-
import { disconnectAll } from "./utils/mcp.js";
|
|
12
|
-
|
|
13
|
-
interface ExecArgs {
|
|
14
|
-
prompt: string;
|
|
15
|
-
autoApprove: boolean;
|
|
16
|
-
json: boolean;
|
|
17
|
-
model?: string;
|
|
18
|
-
provider?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function parseExecArgs(argv: string[]): ExecArgs {
|
|
22
|
-
const args: ExecArgs = {
|
|
23
|
-
prompt: "",
|
|
24
|
-
autoApprove: false,
|
|
25
|
-
json: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const positional: string[] = [];
|
|
29
|
-
|
|
30
|
-
for (let i = 0; i < argv.length; i++) {
|
|
31
|
-
const arg = argv[i];
|
|
32
|
-
const next = argv[i + 1];
|
|
33
|
-
|
|
34
|
-
if (arg === "--auto-approve") {
|
|
35
|
-
args.autoApprove = true;
|
|
36
|
-
} else if (arg === "--json") {
|
|
37
|
-
args.json = true;
|
|
38
|
-
} else if ((arg === "--model" || arg === "-m") && next) {
|
|
39
|
-
args.model = next;
|
|
40
|
-
i++;
|
|
41
|
-
} else if ((arg === "--provider" || arg === "-p") && next) {
|
|
42
|
-
args.provider = next;
|
|
43
|
-
i++;
|
|
44
|
-
} else if (!arg.startsWith("-")) {
|
|
45
|
-
positional.push(arg);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
args.prompt = positional.join(" ");
|
|
50
|
-
return args;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function readStdin(): Promise<string> {
|
|
54
|
-
// Check if stdin has data (piped input)
|
|
55
|
-
if (process.stdin.isTTY) return "";
|
|
56
|
-
|
|
57
|
-
return new Promise((resolve) => {
|
|
58
|
-
let data = "";
|
|
59
|
-
process.stdin.setEncoding("utf-8");
|
|
60
|
-
process.stdin.on("data", (chunk) => { data += chunk; });
|
|
61
|
-
process.stdin.on("end", () => resolve(data.trim()));
|
|
62
|
-
// Timeout after 1s if no data arrives
|
|
63
|
-
setTimeout(() => resolve(data.trim()), 1000);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function runExec(argv: string[]): Promise<void> {
|
|
68
|
-
const args = parseExecArgs(argv);
|
|
69
|
-
|
|
70
|
-
// Read from stdin if no prompt provided
|
|
71
|
-
if (!args.prompt) {
|
|
72
|
-
args.prompt = await readStdin();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!args.prompt) {
|
|
76
|
-
process.stderr.write("Error: No prompt provided.\n");
|
|
77
|
-
process.stderr.write("Usage: codemaxxing exec \"your prompt here\"\n");
|
|
78
|
-
process.stderr.write(" echo \"fix tests\" | codemaxxing exec\n");
|
|
79
|
-
process.stderr.write("\nFlags:\n");
|
|
80
|
-
process.stderr.write(" --auto-approve Skip approval prompts\n");
|
|
81
|
-
process.stderr.write(" --json JSON output\n");
|
|
82
|
-
process.stderr.write(" -m, --model Model to use\n");
|
|
83
|
-
process.stderr.write(" -p, --provider Provider profile\n");
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Resolve provider config
|
|
88
|
-
const rawConfig = loadConfig();
|
|
89
|
-
const cliArgs = {
|
|
90
|
-
model: args.model,
|
|
91
|
-
provider: args.provider,
|
|
92
|
-
};
|
|
93
|
-
const config = applyOverrides(rawConfig, cliArgs);
|
|
94
|
-
let provider = config.provider;
|
|
95
|
-
|
|
96
|
-
// Auto-detect local provider if needed
|
|
97
|
-
if (provider.model === "auto" || (provider.baseUrl === "http://localhost:1234/v1" && !args.provider)) {
|
|
98
|
-
const detected = await detectLocalProvider();
|
|
99
|
-
if (detected) {
|
|
100
|
-
if (args.model) detected.model = args.model;
|
|
101
|
-
provider = detected;
|
|
102
|
-
} else if (!args.provider) {
|
|
103
|
-
process.stderr.write("Error: No LLM provider found. Start a local server or use --provider.\n");
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
process.stderr.write(`Provider: ${provider.baseUrl}\n`);
|
|
109
|
-
process.stderr.write(`Model: ${provider.model}\n`);
|
|
110
|
-
process.stderr.write(`Prompt: ${args.prompt.slice(0, 100)}${args.prompt.length > 100 ? "..." : ""}\n`);
|
|
111
|
-
process.stderr.write("---\n");
|
|
112
|
-
|
|
113
|
-
const cwd = process.cwd();
|
|
114
|
-
let hasChanges = false;
|
|
115
|
-
let fullResponse = "";
|
|
116
|
-
const toolResults: Array<{ tool: string; args: Record<string, unknown>; result: string }> = [];
|
|
117
|
-
|
|
118
|
-
const agent = new CodingAgent({
|
|
119
|
-
provider,
|
|
120
|
-
cwd,
|
|
121
|
-
maxTokens: config.defaults.maxTokens,
|
|
122
|
-
autoApprove: args.autoApprove,
|
|
123
|
-
onToken: (token) => {
|
|
124
|
-
if (!args.json) {
|
|
125
|
-
process.stdout.write(token);
|
|
126
|
-
}
|
|
127
|
-
fullResponse += token;
|
|
128
|
-
},
|
|
129
|
-
onToolCall: (name, toolArgs) => {
|
|
130
|
-
process.stderr.write(`Tool: ${name}(${Object.values(toolArgs).map(v => String(v).slice(0, 60)).join(", ")})\n`);
|
|
131
|
-
if (name === "write_file") hasChanges = true;
|
|
132
|
-
},
|
|
133
|
-
onToolResult: (name, result) => {
|
|
134
|
-
const lines = result.split("\n").length;
|
|
135
|
-
process.stderr.write(` └ ${lines} lines\n`);
|
|
136
|
-
toolResults.push({ tool: name, args: {}, result });
|
|
137
|
-
},
|
|
138
|
-
onToolApproval: async (name, toolArgs, diff) => {
|
|
139
|
-
if (args.autoApprove) return "yes";
|
|
140
|
-
// In non-interactive mode without auto-approve, deny dangerous tools
|
|
141
|
-
process.stderr.write(`⚠ Denied ${name} (use --auto-approve to allow)\n`);
|
|
142
|
-
return "no";
|
|
143
|
-
},
|
|
144
|
-
onMCPStatus: (server, status) => {
|
|
145
|
-
process.stderr.write(`MCP ${server}: ${status}\n`);
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
try {
|
|
150
|
-
await agent.init();
|
|
151
|
-
|
|
152
|
-
const mcpCount = agent.getMCPServerCount();
|
|
153
|
-
if (mcpCount > 0) {
|
|
154
|
-
process.stderr.write(`MCP: ${mcpCount} server${mcpCount > 1 ? "s" : ""} connected\n`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
await agent.send(args.prompt);
|
|
158
|
-
|
|
159
|
-
if (!args.json) {
|
|
160
|
-
// Ensure newline at end of output
|
|
161
|
-
process.stdout.write("\n");
|
|
162
|
-
} else {
|
|
163
|
-
// JSON output mode
|
|
164
|
-
const output = {
|
|
165
|
-
response: fullResponse,
|
|
166
|
-
model: provider.model,
|
|
167
|
-
tools_used: toolResults.length,
|
|
168
|
-
has_changes: hasChanges,
|
|
169
|
-
};
|
|
170
|
-
process.stdout.write(JSON.stringify(output, null, 2) + "\n");
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
await disconnectAll();
|
|
174
|
-
process.exit(hasChanges ? 0 : 2);
|
|
175
|
-
} catch (err: any) {
|
|
176
|
-
await disconnectAll();
|
|
177
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
178
|
-
if (args.json) {
|
|
179
|
-
process.stdout.write(JSON.stringify({ error: err.message }, null, 2) + "\n");
|
|
180
|
-
}
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
}
|