codemaxxing 0.1.0
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 +209 -0
- package/dist/agent.d.ts +65 -0
- package/dist/agent.js +269 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.js +174 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +659 -0
- package/dist/tools/files.d.ts +9 -0
- package/dist/tools/files.js +227 -0
- package/dist/utils/context.d.ts +13 -0
- package/dist/utils/context.js +135 -0
- package/dist/utils/git.d.ts +27 -0
- package/dist/utils/git.js +113 -0
- package/dist/utils/repomap.d.ts +18 -0
- package/dist/utils/repomap.js +195 -0
- package/dist/utils/sessions.d.ts +51 -0
- package/dist/utils/sessions.js +174 -0
- package/dist/utils/treesitter.d.ts +20 -0
- package/dist/utils/treesitter.js +710 -0
- package/package.json +51 -0
- package/src/agent.ts +322 -0
- package/src/config.ts +211 -0
- package/src/index.tsx +858 -0
- package/src/tools/files.ts +247 -0
- package/src/utils/context.ts +146 -0
- package/src/utils/git.ts +117 -0
- package/src/utils/repomap.ts +220 -0
- package/src/utils/sessions.ts +222 -0
- package/tsconfig.json +16 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
const CONFIG_DIR = join(homedir(), ".codemaxxing");
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, "settings.json");
|
|
6
|
+
const DEFAULT_CONFIG = {
|
|
7
|
+
provider: {
|
|
8
|
+
baseUrl: "http://localhost:1234/v1",
|
|
9
|
+
apiKey: "not-needed",
|
|
10
|
+
model: "auto",
|
|
11
|
+
},
|
|
12
|
+
providers: {
|
|
13
|
+
local: {
|
|
14
|
+
name: "Local (LM Studio/Ollama)",
|
|
15
|
+
baseUrl: "http://localhost:1234/v1",
|
|
16
|
+
apiKey: "not-needed",
|
|
17
|
+
model: "auto",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaults: {
|
|
21
|
+
autoApprove: false,
|
|
22
|
+
contextFiles: 20,
|
|
23
|
+
maxTokens: 8192,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Parse CLI arguments
|
|
28
|
+
*/
|
|
29
|
+
export function parseCLIArgs() {
|
|
30
|
+
const args = {};
|
|
31
|
+
const argv = process.argv.slice(2);
|
|
32
|
+
for (let i = 0; i < argv.length; i++) {
|
|
33
|
+
const arg = argv[i];
|
|
34
|
+
const next = argv[i + 1];
|
|
35
|
+
if ((arg === "--model" || arg === "-m") && next) {
|
|
36
|
+
args.model = next;
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
else if ((arg === "--provider" || arg === "-p") && next) {
|
|
40
|
+
args.provider = next;
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
else if ((arg === "--api-key" || arg === "-k") && next) {
|
|
44
|
+
args.apiKey = next;
|
|
45
|
+
i++;
|
|
46
|
+
}
|
|
47
|
+
else if ((arg === "--base-url" || arg === "-u") && next) {
|
|
48
|
+
args.baseUrl = next;
|
|
49
|
+
i++;
|
|
50
|
+
}
|
|
51
|
+
else if (arg === "--help" || arg === "-h") {
|
|
52
|
+
console.log(`
|
|
53
|
+
codemaxxing — your code. your model. no excuses.
|
|
54
|
+
|
|
55
|
+
Usage:
|
|
56
|
+
codemaxxing [options]
|
|
57
|
+
|
|
58
|
+
Options:
|
|
59
|
+
-m, --model <model> Model name to use
|
|
60
|
+
-p, --provider <name> Provider profile from config (e.g. local, openrouter)
|
|
61
|
+
-k, --api-key <key> API key for the provider
|
|
62
|
+
-u, --base-url <url> Base URL for the provider API
|
|
63
|
+
-h, --help Show this help
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
codemaxxing # Auto-detect local LLM
|
|
67
|
+
codemaxxing -m gpt-4o -u https://api.openai.com/v1 -k sk-...
|
|
68
|
+
codemaxxing -p openrouter # Use saved provider profile
|
|
69
|
+
codemaxxing -m qwen3.5-35b # Override model only
|
|
70
|
+
|
|
71
|
+
Config: ~/.codemaxxing/settings.json
|
|
72
|
+
`);
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return args;
|
|
77
|
+
}
|
|
78
|
+
export function loadConfig() {
|
|
79
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
80
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
if (!existsSync(CONFIG_FILE)) {
|
|
83
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(DEFAULT_CONFIG, null, 2));
|
|
84
|
+
return DEFAULT_CONFIG;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const raw = readFileSync(CONFIG_FILE, "utf-8");
|
|
88
|
+
const parsed = JSON.parse(raw);
|
|
89
|
+
return { ...DEFAULT_CONFIG, ...parsed };
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return DEFAULT_CONFIG;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Apply CLI overrides to a provider config
|
|
97
|
+
*/
|
|
98
|
+
export function applyOverrides(config, args) {
|
|
99
|
+
const result = { ...config, provider: { ...config.provider } };
|
|
100
|
+
// If a named provider profile is specified, use it as the base
|
|
101
|
+
if (args.provider && config.providers?.[args.provider]) {
|
|
102
|
+
const profile = config.providers[args.provider];
|
|
103
|
+
result.provider = { ...profile };
|
|
104
|
+
}
|
|
105
|
+
// CLI flags override everything
|
|
106
|
+
if (args.model)
|
|
107
|
+
result.provider.model = args.model;
|
|
108
|
+
if (args.apiKey)
|
|
109
|
+
result.provider.apiKey = args.apiKey;
|
|
110
|
+
if (args.baseUrl)
|
|
111
|
+
result.provider.baseUrl = args.baseUrl;
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
export function getConfigPath() {
|
|
115
|
+
return CONFIG_FILE;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Auto-detect local LLM servers
|
|
119
|
+
*/
|
|
120
|
+
export async function detectLocalProvider() {
|
|
121
|
+
const endpoints = [
|
|
122
|
+
{ name: "LM Studio", url: "http://localhost:1234/v1" },
|
|
123
|
+
{ name: "Ollama", url: "http://localhost:11434/v1" },
|
|
124
|
+
{ name: "vLLM", url: "http://localhost:8000/v1" },
|
|
125
|
+
];
|
|
126
|
+
for (const endpoint of endpoints) {
|
|
127
|
+
try {
|
|
128
|
+
const controller = new AbortController();
|
|
129
|
+
const timeout = setTimeout(() => controller.abort(), 2000);
|
|
130
|
+
const res = await fetch(`${endpoint.url}/models`, {
|
|
131
|
+
signal: controller.signal,
|
|
132
|
+
});
|
|
133
|
+
clearTimeout(timeout);
|
|
134
|
+
if (res.ok) {
|
|
135
|
+
const data = (await res.json());
|
|
136
|
+
const models = data.data ?? [];
|
|
137
|
+
const model = models[0]?.id ?? "auto";
|
|
138
|
+
return {
|
|
139
|
+
baseUrl: endpoint.url,
|
|
140
|
+
apiKey: "not-needed",
|
|
141
|
+
model,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Server not running, try next
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* List available models from a provider endpoint
|
|
153
|
+
*/
|
|
154
|
+
export async function listModels(baseUrl, apiKey) {
|
|
155
|
+
try {
|
|
156
|
+
const controller = new AbortController();
|
|
157
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
158
|
+
const headers = {};
|
|
159
|
+
if (apiKey && apiKey !== "not-needed") {
|
|
160
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
161
|
+
}
|
|
162
|
+
const res = await fetch(`${baseUrl}/models`, {
|
|
163
|
+
signal: controller.signal,
|
|
164
|
+
headers,
|
|
165
|
+
});
|
|
166
|
+
clearTimeout(timeout);
|
|
167
|
+
if (res.ok) {
|
|
168
|
+
const data = (await res.json());
|
|
169
|
+
return (data.data ?? []).map(m => m.id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch { /* ignore */ }
|
|
173
|
+
return [];
|
|
174
|
+
}
|
package/dist/index.d.ts
ADDED