@defai.digital/ax-cli 1.2.2 → 2.0.1
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 +13 -0
- package/config/messages.yaml +0 -1
- package/config/prompts.yaml +1 -6
- package/dist/agent/context-manager.d.ts +9 -8
- package/dist/agent/context-manager.js +25 -15
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/{grok-agent.d.ts → llm-agent.d.ts} +48 -8
- package/dist/agent/{grok-agent.js → llm-agent.js} +265 -192
- package/dist/agent/llm-agent.js.map +1 -0
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.js +105 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/hooks/use-input-handler.d.ts +3 -3
- package/dist/hooks/use-input-handler.js +2 -2
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/{grok → llm}/client.d.ts +11 -11
- package/dist/{grok → llm}/client.js +6 -6
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/tools.d.ts +8 -0
- package/dist/{grok → llm}/tools.js +2 -33
- package/dist/llm/tools.js.map +1 -0
- package/dist/{grok → llm}/types.d.ts +3 -3
- package/dist/llm/types.js.map +1 -0
- package/dist/schemas/api-schemas.d.ts +9 -9
- package/dist/schemas/api-schemas.js +13 -13
- package/dist/schemas/api-schemas.js.map +1 -1
- package/dist/tools/bash.js +25 -15
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.js +21 -13
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +85 -59
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/tools/todo-tool.js +14 -0
- package/dist/tools/todo-tool.js.map +1 -1
- package/dist/ui/app.js +1 -1
- package/dist/ui/app.js.map +1 -1
- package/dist/ui/components/api-key-input.d.ts +2 -2
- package/dist/ui/components/api-key-input.js +2 -2
- package/dist/ui/components/api-key-input.js.map +1 -1
- package/dist/ui/components/chat-history.d.ts +1 -1
- package/dist/ui/components/chat-interface.d.ts +2 -2
- package/dist/ui/components/chat-interface.js +1 -1
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/mcp-status.js +1 -1
- package/dist/ui/components/mcp-status.js.map +1 -1
- package/dist/ui/components/model-selection.js +1 -1
- package/dist/ui/components/model-selection.js.map +1 -1
- package/dist/utils/confirmation-service.d.ts +8 -0
- package/dist/utils/confirmation-service.js +26 -0
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/path-validator.d.ts +36 -0
- package/dist/utils/path-validator.js +61 -0
- package/dist/utils/path-validator.js.map +1 -1
- package/dist/utils/prompt-builder.d.ts +0 -1
- package/dist/utils/prompt-builder.js +1 -1
- package/dist/utils/prompt-builder.js.map +1 -1
- package/dist/utils/settings-manager.js +21 -5
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/tool-helpers.d.ts +25 -0
- package/dist/utils/tool-helpers.js +53 -0
- package/dist/utils/tool-helpers.js.map +1 -0
- package/package.json +13 -4
- package/automatosx.config.json +0 -333
- package/dist/agent/grok-agent.js.map +0 -1
- package/dist/grok/client.js.map +0 -1
- package/dist/grok/tools.d.ts +0 -8
- package/dist/grok/tools.js.map +0 -1
- package/dist/grok/types.js.map +0 -1
- package/dist/tools/morph-editor.d.ts +0 -36
- package/dist/tools/morph-editor.js +0 -308
- package/dist/tools/morph-editor.js.map +0 -1
- package/packages/schemas/dist/index.d.ts +0 -14
- package/packages/schemas/dist/index.d.ts.map +0 -1
- package/packages/schemas/dist/index.js +0 -19
- package/packages/schemas/dist/index.js.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
- package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.js +0 -243
- package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
- package/packages/schemas/dist/public/core/enums.d.ts +0 -227
- package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/enums.js +0 -222
- package/packages/schemas/dist/public/core/enums.js.map +0 -1
- package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
- package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/id-types.js +0 -136
- package/packages/schemas/dist/public/core/id-types.js.map +0 -1
- /package/dist/{grok → llm}/types.js +0 -0
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs-extra";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
import { ConfirmationService } from "../utils/confirmation-service.js";
|
|
5
|
-
export class MorphEditorTool {
|
|
6
|
-
confirmationService = ConfirmationService.getInstance();
|
|
7
|
-
morphApiKey;
|
|
8
|
-
morphBaseUrl = "https://api.morphllm.com/v1";
|
|
9
|
-
constructor(apiKey) {
|
|
10
|
-
this.morphApiKey = apiKey || process.env.MORPH_API_KEY || "";
|
|
11
|
-
if (!this.morphApiKey) {
|
|
12
|
-
console.warn("MORPH_API_KEY not found. Morph editor functionality will be limited.");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Use this tool to make an edit to an existing file.
|
|
17
|
-
*
|
|
18
|
-
* This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
|
|
19
|
-
* When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.
|
|
20
|
-
*
|
|
21
|
-
* For example:
|
|
22
|
-
*
|
|
23
|
-
* // ... existing code ...
|
|
24
|
-
* FIRST_EDIT
|
|
25
|
-
* // ... existing code ...
|
|
26
|
-
* SECOND_EDIT
|
|
27
|
-
* // ... existing code ...
|
|
28
|
-
* THIRD_EDIT
|
|
29
|
-
* // ... existing code ...
|
|
30
|
-
*
|
|
31
|
-
* You should still bias towards repeating as few lines of the original file as possible to convey the change.
|
|
32
|
-
* But, each edit should contain sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
|
|
33
|
-
* DO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.
|
|
34
|
-
* If you plan on deleting a section, you must provide context before and after to delete it. If the initial code is ```code \n Block 1 \n Block 2 \n Block 3 \n code```, and you want to remove Block 2, you would output ```// ... existing code ... \n Block 1 \n Block 3 \n // ... existing code ...```.
|
|
35
|
-
* Make sure it is clear what the edit should be, and where it should be applied.
|
|
36
|
-
* Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.
|
|
37
|
-
*/
|
|
38
|
-
async editFile(targetFile, instructions, codeEdit) {
|
|
39
|
-
try {
|
|
40
|
-
const resolvedPath = path.resolve(targetFile);
|
|
41
|
-
if (!(await fs.pathExists(resolvedPath))) {
|
|
42
|
-
return {
|
|
43
|
-
success: false,
|
|
44
|
-
error: `File not found: ${targetFile}`,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (!this.morphApiKey) {
|
|
48
|
-
return {
|
|
49
|
-
success: false,
|
|
50
|
-
error: "MORPH_API_KEY not configured. Please set your Morph API key.",
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
// Read the initial code
|
|
54
|
-
const initialCode = await fs.readFile(resolvedPath, "utf-8");
|
|
55
|
-
// Check user confirmation before proceeding
|
|
56
|
-
const sessionFlags = this.confirmationService.getSessionFlags();
|
|
57
|
-
if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
|
|
58
|
-
const confirmationResult = await this.confirmationService.requestConfirmation({
|
|
59
|
-
operation: "Edit file with Morph Fast Apply",
|
|
60
|
-
filename: targetFile,
|
|
61
|
-
showVSCodeOpen: false,
|
|
62
|
-
content: `Instructions: ${instructions}\n\nEdit:\n${codeEdit}`,
|
|
63
|
-
}, "file");
|
|
64
|
-
if (!confirmationResult.confirmed) {
|
|
65
|
-
return {
|
|
66
|
-
success: false,
|
|
67
|
-
error: confirmationResult.feedback || "File edit cancelled by user",
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Call Morph Fast Apply API
|
|
72
|
-
const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
|
|
73
|
-
// Write the merged code back to file
|
|
74
|
-
await fs.writeFile(resolvedPath, mergedCode, "utf-8");
|
|
75
|
-
// Generate diff for display
|
|
76
|
-
const oldLines = initialCode.split("\n");
|
|
77
|
-
const newLines = mergedCode.split("\n");
|
|
78
|
-
const diff = this.generateDiff(oldLines, newLines, targetFile);
|
|
79
|
-
return {
|
|
80
|
-
success: true,
|
|
81
|
-
output: diff,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return {
|
|
86
|
-
success: false,
|
|
87
|
-
error: `Error editing ${targetFile} with Morph: ${error.message}`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async callMorphApply(instructions, initialCode, editSnippet) {
|
|
92
|
-
try {
|
|
93
|
-
const response = await axios.post(`${this.morphBaseUrl}/chat/completions`, {
|
|
94
|
-
model: "morph-v3-large",
|
|
95
|
-
messages: [
|
|
96
|
-
{
|
|
97
|
-
role: "user",
|
|
98
|
-
content: `<instruction>${instructions}</instruction>\n<code>${initialCode}</code>\n<update>${editSnippet}</update>`,
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
}, {
|
|
102
|
-
headers: {
|
|
103
|
-
"Authorization": `Bearer ${this.morphApiKey}`,
|
|
104
|
-
"Content-Type": "application/json",
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
if (!response.data.choices || !response.data.choices[0] || !response.data.choices[0].message) {
|
|
108
|
-
throw new Error("Invalid response format from Morph API");
|
|
109
|
-
}
|
|
110
|
-
return response.data.choices[0].message.content;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
if (error.response) {
|
|
114
|
-
throw new Error(`Morph API error (${error.response.status}): ${error.response.data}`);
|
|
115
|
-
}
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
generateDiff(oldLines, newLines, filePath) {
|
|
120
|
-
const CONTEXT_LINES = 3;
|
|
121
|
-
const changes = [];
|
|
122
|
-
let i = 0, j = 0;
|
|
123
|
-
while (i < oldLines.length || j < newLines.length) {
|
|
124
|
-
while (i < oldLines.length && j < newLines.length && oldLines[i] === newLines[j]) {
|
|
125
|
-
i++;
|
|
126
|
-
j++;
|
|
127
|
-
}
|
|
128
|
-
if (i < oldLines.length || j < newLines.length) {
|
|
129
|
-
const changeStart = { old: i, new: j };
|
|
130
|
-
let oldEnd = i;
|
|
131
|
-
let newEnd = j;
|
|
132
|
-
while (oldEnd < oldLines.length || newEnd < newLines.length) {
|
|
133
|
-
let matchFound = false;
|
|
134
|
-
let matchLength = 0;
|
|
135
|
-
for (let k = 0; k < Math.min(2, oldLines.length - oldEnd, newLines.length - newEnd); k++) {
|
|
136
|
-
if (oldEnd + k < oldLines.length &&
|
|
137
|
-
newEnd + k < newLines.length &&
|
|
138
|
-
oldLines[oldEnd + k] === newLines[newEnd + k]) {
|
|
139
|
-
matchLength++;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (matchLength >= 2 || (oldEnd >= oldLines.length && newEnd >= newLines.length)) {
|
|
146
|
-
matchFound = true;
|
|
147
|
-
}
|
|
148
|
-
if (matchFound) {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
if (oldEnd < oldLines.length)
|
|
152
|
-
oldEnd++;
|
|
153
|
-
if (newEnd < newLines.length)
|
|
154
|
-
newEnd++;
|
|
155
|
-
}
|
|
156
|
-
changes.push({
|
|
157
|
-
oldStart: changeStart.old,
|
|
158
|
-
oldEnd: oldEnd,
|
|
159
|
-
newStart: changeStart.new,
|
|
160
|
-
newEnd: newEnd
|
|
161
|
-
});
|
|
162
|
-
i = oldEnd;
|
|
163
|
-
j = newEnd;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const hunks = [];
|
|
167
|
-
let accumulatedOffset = 0;
|
|
168
|
-
for (let changeIdx = 0; changeIdx < changes.length; changeIdx++) {
|
|
169
|
-
const change = changes[changeIdx];
|
|
170
|
-
let contextStart = Math.max(0, change.oldStart - CONTEXT_LINES);
|
|
171
|
-
let contextEnd = Math.min(oldLines.length, change.oldEnd + CONTEXT_LINES);
|
|
172
|
-
if (hunks.length > 0) {
|
|
173
|
-
const lastHunk = hunks[hunks.length - 1];
|
|
174
|
-
const lastHunkEnd = lastHunk.oldStart + lastHunk.oldCount;
|
|
175
|
-
if (lastHunkEnd >= contextStart) {
|
|
176
|
-
const oldHunkEnd = lastHunk.oldStart + lastHunk.oldCount;
|
|
177
|
-
const newContextEnd = Math.min(oldLines.length, change.oldEnd + CONTEXT_LINES);
|
|
178
|
-
for (let idx = oldHunkEnd; idx < change.oldStart; idx++) {
|
|
179
|
-
lastHunk.lines.push({ type: ' ', content: oldLines[idx] });
|
|
180
|
-
}
|
|
181
|
-
for (let idx = change.oldStart; idx < change.oldEnd; idx++) {
|
|
182
|
-
lastHunk.lines.push({ type: '-', content: oldLines[idx] });
|
|
183
|
-
}
|
|
184
|
-
for (let idx = change.newStart; idx < change.newEnd; idx++) {
|
|
185
|
-
lastHunk.lines.push({ type: '+', content: newLines[idx] });
|
|
186
|
-
}
|
|
187
|
-
for (let idx = change.oldEnd; idx < newContextEnd && idx < oldLines.length; idx++) {
|
|
188
|
-
lastHunk.lines.push({ type: ' ', content: oldLines[idx] });
|
|
189
|
-
}
|
|
190
|
-
lastHunk.oldCount = newContextEnd - lastHunk.oldStart;
|
|
191
|
-
lastHunk.newCount = lastHunk.oldCount + (change.newEnd - change.newStart) - (change.oldEnd - change.oldStart);
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const hunk = {
|
|
196
|
-
oldStart: contextStart + 1,
|
|
197
|
-
oldCount: contextEnd - contextStart,
|
|
198
|
-
newStart: contextStart + 1 + accumulatedOffset,
|
|
199
|
-
newCount: contextEnd - contextStart + (change.newEnd - change.newStart) - (change.oldEnd - change.oldStart),
|
|
200
|
-
lines: []
|
|
201
|
-
};
|
|
202
|
-
for (let idx = contextStart; idx < change.oldStart; idx++) {
|
|
203
|
-
hunk.lines.push({ type: ' ', content: oldLines[idx] });
|
|
204
|
-
}
|
|
205
|
-
for (let idx = change.oldStart; idx < change.oldEnd; idx++) {
|
|
206
|
-
hunk.lines.push({ type: '-', content: oldLines[idx] });
|
|
207
|
-
}
|
|
208
|
-
for (let idx = change.newStart; idx < change.newEnd; idx++) {
|
|
209
|
-
hunk.lines.push({ type: '+', content: newLines[idx] });
|
|
210
|
-
}
|
|
211
|
-
for (let idx = change.oldEnd; idx < contextEnd && idx < oldLines.length; idx++) {
|
|
212
|
-
hunk.lines.push({ type: ' ', content: oldLines[idx] });
|
|
213
|
-
}
|
|
214
|
-
hunks.push(hunk);
|
|
215
|
-
accumulatedOffset += (change.newEnd - change.newStart) - (change.oldEnd - change.oldStart);
|
|
216
|
-
}
|
|
217
|
-
let addedLines = 0;
|
|
218
|
-
let removedLines = 0;
|
|
219
|
-
for (const hunk of hunks) {
|
|
220
|
-
for (const line of hunk.lines) {
|
|
221
|
-
if (line.type === '+')
|
|
222
|
-
addedLines++;
|
|
223
|
-
if (line.type === '-')
|
|
224
|
-
removedLines++;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
let summary = `Updated ${filePath} with Morph Fast Apply`;
|
|
228
|
-
if (addedLines > 0 && removedLines > 0) {
|
|
229
|
-
summary += ` - ${addedLines} addition${addedLines !== 1 ? "s" : ""} and ${removedLines} removal${removedLines !== 1 ? "s" : ""}`;
|
|
230
|
-
}
|
|
231
|
-
else if (addedLines > 0) {
|
|
232
|
-
summary += ` - ${addedLines} addition${addedLines !== 1 ? "s" : ""}`;
|
|
233
|
-
}
|
|
234
|
-
else if (removedLines > 0) {
|
|
235
|
-
summary += ` - ${removedLines} removal${removedLines !== 1 ? "s" : ""}`;
|
|
236
|
-
}
|
|
237
|
-
else if (changes.length === 0) {
|
|
238
|
-
return `No changes applied to ${filePath}`;
|
|
239
|
-
}
|
|
240
|
-
let diff = summary + "\n";
|
|
241
|
-
diff += `--- a/${filePath}\n`;
|
|
242
|
-
diff += `+++ b/${filePath}\n`;
|
|
243
|
-
for (const hunk of hunks) {
|
|
244
|
-
diff += `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@\n`;
|
|
245
|
-
for (const line of hunk.lines) {
|
|
246
|
-
diff += `${line.type}${line.content}\n`;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return diff.trim();
|
|
250
|
-
}
|
|
251
|
-
async view(filePath, viewRange) {
|
|
252
|
-
try {
|
|
253
|
-
const resolvedPath = path.resolve(filePath);
|
|
254
|
-
if (await fs.pathExists(resolvedPath)) {
|
|
255
|
-
const stats = await fs.stat(resolvedPath);
|
|
256
|
-
if (stats.isDirectory()) {
|
|
257
|
-
const files = await fs.readdir(resolvedPath);
|
|
258
|
-
return {
|
|
259
|
-
success: true,
|
|
260
|
-
output: `Directory contents of ${filePath}:\n${files.join("\n")}`,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const content = await fs.readFile(resolvedPath, "utf-8");
|
|
264
|
-
const lines = content.split("\n");
|
|
265
|
-
if (viewRange) {
|
|
266
|
-
const [start, end] = viewRange;
|
|
267
|
-
const selectedLines = lines.slice(start - 1, end);
|
|
268
|
-
const numberedLines = selectedLines
|
|
269
|
-
.map((line, idx) => `${start + idx}: ${line}`)
|
|
270
|
-
.join("\n");
|
|
271
|
-
return {
|
|
272
|
-
success: true,
|
|
273
|
-
output: `Lines ${start}-${end} of ${filePath}:\n${numberedLines}`,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
const totalLines = lines.length;
|
|
277
|
-
const displayLines = totalLines > 10 ? lines.slice(0, 10) : lines;
|
|
278
|
-
const numberedLines = displayLines
|
|
279
|
-
.map((line, idx) => `${idx + 1}: ${line}`)
|
|
280
|
-
.join("\n");
|
|
281
|
-
const additionalLinesMessage = totalLines > 10 ? `\n... +${totalLines - 10} lines` : "";
|
|
282
|
-
return {
|
|
283
|
-
success: true,
|
|
284
|
-
output: `Contents of ${filePath}:\n${numberedLines}${additionalLinesMessage}`,
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
return {
|
|
289
|
-
success: false,
|
|
290
|
-
error: `File or directory not found: ${filePath}`,
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
catch (error) {
|
|
295
|
-
return {
|
|
296
|
-
success: false,
|
|
297
|
-
error: `Error viewing ${filePath}: ${error.message}`,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
setApiKey(apiKey) {
|
|
302
|
-
this.morphApiKey = apiKey;
|
|
303
|
-
}
|
|
304
|
-
getApiKey() {
|
|
305
|
-
return this.morphApiKey;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
//# sourceMappingURL=morph-editor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"morph-editor.js","sourceRoot":"","sources":["../../src/tools/morph-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,MAAM,OAAO,eAAe;IAClB,mBAAmB,GAAG,mBAAmB,CAAC,WAAW,EAAE,CAAC;I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,EAAE,CAAC;qBACzC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,MAAM,sBAAsB,GAC1B,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,UAAU,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBAE3D,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,eAAe,QAAQ,MAAM,aAAa,GAAG,sBAAsB,EAAE;iBAC9E,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,gCAAgC,QAAQ,EAAE;iBAClD,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,iBAAiB,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE;aACrD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ax-cli/schemas - Single Source of Truth Type System
|
|
3
|
-
*
|
|
4
|
-
* This package provides centralized Zod schemas, brand types, and enums
|
|
5
|
-
* for the entire ax-cli ecosystem.
|
|
6
|
-
*
|
|
7
|
-
* SECURITY: All exports are controlled. Internal helpers are not exposed.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
export { brand, unbrand, isBranded, createBrandFactory, type __brand, type Brand, type ExtractBrand, type ExtractBase, } from './public/core/brand-types.js';
|
|
12
|
-
export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, type ApiResponseId as ApiResponseIdType, type ToolCallId as ToolCallIdType, type ModelId as ModelIdType, type TenantId as TenantIdType, type ApiKeyId as ApiKeyIdType, type MCPServerId as MCPServerIdType, type UsageRecordId as UsageRecordIdType, type PlanId as PlanIdType, type SessionId as SessionIdType, type RequestId as RequestIdType, } from './public/core/id-types.js';
|
|
13
|
-
export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, type MessageRole, type FinishReason, type Transport, type EditorCommand, } from './public/core/enums.js';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACT,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,UAAU,IAAI,cAAc,EACjC,KAAK,OAAO,IAAI,WAAW,EAC3B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,WAAW,IAAI,eAAe,EACnC,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,SAAS,IAAI,aAAa,GAChC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ax-cli/schemas - Single Source of Truth Type System
|
|
3
|
-
*
|
|
4
|
-
* This package provides centralized Zod schemas, brand types, and enums
|
|
5
|
-
* for the entire ax-cli ecosystem.
|
|
6
|
-
*
|
|
7
|
-
* SECURITY: All exports are controlled. Internal helpers are not exposed.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
// Core brand type utilities
|
|
12
|
-
export { brand, unbrand, isBranded, createBrandFactory, } from './public/core/brand-types.js';
|
|
13
|
-
// ID Brand Types
|
|
14
|
-
export { ApiResponseId, ToolCallId, ToolCallIdSchema, ModelId, ModelIdSchema, TenantId, ApiKeyId, MCPServerId, MCPServerIdSchema, UsageRecordId, PlanId, SessionId, RequestId, } from './public/core/id-types.js';
|
|
15
|
-
// Centralized Enums
|
|
16
|
-
export { MessageRoleEnum, FinishReasonEnum, TransportEnum, EditorCommandEnum, } from './public/core/enums.js';
|
|
17
|
-
// Additional exports will be added as we implement them:
|
|
18
|
-
// - Domain schemas (Usage, API, MCP)
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,4BAA4B;AAC5B,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GAKnB,MAAM,8BAA8B,CAAC;AAEtC,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,GAWV,MAAM,2BAA2B,CAAC;AAEnC,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAKlB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,qCAAqC"}
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Brand Types Utilities for @ax-cli/schemas
|
|
3
|
-
*
|
|
4
|
-
* CRITICAL SECURITY WARNING:
|
|
5
|
-
* =========================
|
|
6
|
-
* Brand types are COMPILE-TIME ONLY markers. They provide ZERO runtime validation.
|
|
7
|
-
*
|
|
8
|
-
* **YOU MUST VALIDATE ALL INPUTS AT SYSTEM BOUNDARIES**
|
|
9
|
-
*
|
|
10
|
-
* Unsafe usage (WILL FAIL IN PRODUCTION):
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const tenantId = userInput as TenantId; // ❌ NO RUNTIME VALIDATION!
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* Safe usage (REQUIRED):
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const result = TenantId.parse(userInput); // ✅ Validates with Zod
|
|
18
|
-
* if (result.success) {
|
|
19
|
-
* const tenantId = result.data; // Type-safe AND runtime-safe
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* WHEN TO USE BRAND TYPES:
|
|
24
|
-
* - Preventing ID mixing at compile time (ApiKeyId vs TenantId)
|
|
25
|
-
* - Enforcing domain boundaries in function signatures
|
|
26
|
-
* - Type-level documentation of intent
|
|
27
|
-
*
|
|
28
|
-
* WHEN TO VALIDATE:
|
|
29
|
-
* - API boundaries (HTTP requests, MCP inputs)
|
|
30
|
-
* - File I/O (reading configs, user settings)
|
|
31
|
-
* - Database queries (WHERE clauses with user IDs)
|
|
32
|
-
* - Environment variables
|
|
33
|
-
* - Command-line arguments
|
|
34
|
-
*
|
|
35
|
-
* PERFORMANCE:
|
|
36
|
-
* Brand types have ZERO runtime cost. They are erased during compilation.
|
|
37
|
-
*
|
|
38
|
-
* @module brand-types
|
|
39
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/4895|TypeScript Nominal Types}
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Unique symbol used as a phantom type marker for branding.
|
|
43
|
-
* This symbol is exported for type compatibility but cannot be accessed at runtime,
|
|
44
|
-
* making it impossible to forge branded types without using the
|
|
45
|
-
* provided constructor functions.
|
|
46
|
-
*
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
export declare const __brand: unique symbol;
|
|
50
|
-
/**
|
|
51
|
-
* Brand<T, B> creates a "nominal type" from a structural type.
|
|
52
|
-
*
|
|
53
|
-
* TypeScript uses structural typing by default:
|
|
54
|
-
* ```typescript
|
|
55
|
-
* type UserId = string;
|
|
56
|
-
* type TenantId = string;
|
|
57
|
-
*
|
|
58
|
-
* const user: UserId = "user-123";
|
|
59
|
-
* const tenant: TenantId = user; // ✅ No error! Strings are compatible.
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Brand types enforce nominal typing:
|
|
63
|
-
* ```typescript
|
|
64
|
-
* type UserId = Brand<string, 'UserId'>;
|
|
65
|
-
* type TenantId = Brand<string, 'TenantId'>;
|
|
66
|
-
*
|
|
67
|
-
* const user = brand<string, 'UserId'>("user-123");
|
|
68
|
-
* const tenant: TenantId = user; // ❌ Compile error! Incompatible brands.
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @template T - The base type (string, number, etc.)
|
|
72
|
-
* @template B - The brand identifier (unique string literal)
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* type ApiKeyId = Brand<string, 'ApiKeyId'>;
|
|
77
|
-
* type TenantId = Brand<string, 'TenantId'>;
|
|
78
|
-
*
|
|
79
|
-
* function updateUsage(apiKeyId: ApiKeyId, tenantId: TenantId) {
|
|
80
|
-
* // This function signature makes it impossible to swap arguments
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* const apiKey = brand<string, 'ApiKeyId'>("ak_123");
|
|
84
|
-
* const tenant = brand<string, 'TenantId'>("tn_456");
|
|
85
|
-
*
|
|
86
|
-
* updateUsage(apiKey, tenant); // ✅ Correct
|
|
87
|
-
* updateUsage(tenant, apiKey); // ❌ Compile error!
|
|
88
|
-
* updateUsage("ak_123", "tn_456"); // ❌ Compile error!
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export type Brand<T, B extends string> = T & {
|
|
92
|
-
readonly [__brand]: B;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Creates a branded value.
|
|
96
|
-
*
|
|
97
|
-
* WARNING: This function performs NO VALIDATION. It is a type-level assertion only.
|
|
98
|
-
*
|
|
99
|
-
* Use this ONLY in trusted contexts after validation:
|
|
100
|
-
* - Inside schema .transform() after Zod validation
|
|
101
|
-
* - After database queries that return validated data
|
|
102
|
-
* - In test fixtures with known-good values
|
|
103
|
-
*
|
|
104
|
-
* DO NOT use with user input directly:
|
|
105
|
-
* ```typescript
|
|
106
|
-
* // ❌ UNSAFE - No validation!
|
|
107
|
-
* const userId = brand<string, 'UserId'>(req.body.userId);
|
|
108
|
-
*
|
|
109
|
-
* // ✅ SAFE - Validated first
|
|
110
|
-
* const result = UserIdSchema.safeParse(req.body.userId);
|
|
111
|
-
* if (result.success) {
|
|
112
|
-
* const userId = result.data; // Already branded by schema
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* @template T - The base type
|
|
117
|
-
* @template B - The brand identifier
|
|
118
|
-
* @param value - The value to brand
|
|
119
|
-
* @returns The same value, but with a brand type
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* // Safe usage in tests
|
|
124
|
-
* const mockTenantId = brand<string, 'TenantId'>("test-tenant-123");
|
|
125
|
-
*
|
|
126
|
-
* // Safe usage after validation
|
|
127
|
-
* const schema = z.string().uuid().transform(v => brand<string, 'TenantId'>(v));
|
|
128
|
-
* const tenantId = schema.parse(userInput); // Validated AND branded
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export declare function brand<T, B extends string>(value: T): Brand<T, B>;
|
|
132
|
-
/**
|
|
133
|
-
* Type guard to check if a value is already branded with a specific brand.
|
|
134
|
-
*
|
|
135
|
-
* NOTE: This only works if the value was created using the brand() function.
|
|
136
|
-
* It CANNOT detect fake brands created with `as` casts.
|
|
137
|
-
*
|
|
138
|
-
* @template T - The base type
|
|
139
|
-
* @template B - The brand identifier
|
|
140
|
-
* @param value - The value to check
|
|
141
|
-
* @returns true if the value has the correct brand (compile-time only)
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```typescript
|
|
145
|
-
* const value: string | TenantId = getTenantId();
|
|
146
|
-
*
|
|
147
|
-
* if (isBranded<string, 'TenantId'>(value)) {
|
|
148
|
-
* const tenantId: TenantId = value; // TypeScript knows it's branded
|
|
149
|
-
* }
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
export declare function isBranded<T, B extends string>(_value: unknown): _value is Brand<T, B>;
|
|
153
|
-
/**
|
|
154
|
-
* Removes the brand from a branded type, returning the base type.
|
|
155
|
-
*
|
|
156
|
-
* Use this when you need to pass a branded value to a function that
|
|
157
|
-
* expects the base type (e.g., logging, serialization).
|
|
158
|
-
*
|
|
159
|
-
* @template T - The base type
|
|
160
|
-
* @template B - The brand identifier
|
|
161
|
-
* @param value - The branded value
|
|
162
|
-
* @returns The same value, but with the brand removed
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* const tenantId: TenantId = getTenantId();
|
|
167
|
-
*
|
|
168
|
-
* // Pass to function expecting plain string
|
|
169
|
-
* console.log(unbrand(tenantId)); // string, not TenantId
|
|
170
|
-
*
|
|
171
|
-
* // Serialize to JSON
|
|
172
|
-
* const json = JSON.stringify({ id: unbrand(tenantId) });
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
export declare function unbrand<T, B extends string>(value: Brand<T, B>): T;
|
|
176
|
-
/**
|
|
177
|
-
* Utility type to extract the brand identifier from a branded type.
|
|
178
|
-
*
|
|
179
|
-
* @template T - The branded type
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* type TenantId = Brand<string, 'TenantId'>;
|
|
184
|
-
* type BrandName = ExtractBrand<TenantId>; // 'TenantId'
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
export type ExtractBrand<T> = T extends Brand<unknown, infer B> ? B : never;
|
|
188
|
-
/**
|
|
189
|
-
* Utility type to extract the base type from a branded type.
|
|
190
|
-
*
|
|
191
|
-
* @template T - The branded type
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```typescript
|
|
195
|
-
* type TenantId = Brand<string, 'TenantId'>;
|
|
196
|
-
* type BaseType = ExtractBase<TenantId>; // string
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
export type ExtractBase<T> = T extends Brand<infer U, string> ? U : T;
|
|
200
|
-
/**
|
|
201
|
-
* Creates a type-safe brand factory with validation.
|
|
202
|
-
*
|
|
203
|
-
* This is the RECOMMENDED way to create brand types with runtime validation.
|
|
204
|
-
*
|
|
205
|
-
* @template T - The base type
|
|
206
|
-
* @template B - The brand identifier
|
|
207
|
-
* @param schema - Zod schema for validation
|
|
208
|
-
* @param brandName - The brand identifier
|
|
209
|
-
* @returns Object with parse, create, and is methods
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```typescript
|
|
213
|
-
* import { z } from 'zod';
|
|
214
|
-
*
|
|
215
|
-
* const TenantId = createBrandFactory(
|
|
216
|
-
* z.string().uuid(),
|
|
217
|
-
* 'TenantId'
|
|
218
|
-
* );
|
|
219
|
-
*
|
|
220
|
-
* // Type-safe parsing with validation
|
|
221
|
-
* const result = TenantId.parse(userInput);
|
|
222
|
-
* if (result.success) {
|
|
223
|
-
* const tenantId = result.data; // Brand<string, 'TenantId'>
|
|
224
|
-
* }
|
|
225
|
-
*
|
|
226
|
-
* // Create new ID
|
|
227
|
-
* const newId = TenantId.create(); // Generates UUID
|
|
228
|
-
*
|
|
229
|
-
* // Type guard
|
|
230
|
-
* if (TenantId.is(value)) {
|
|
231
|
-
* // value is Brand<string, 'TenantId'>
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
export declare function createBrandFactory<T, B extends string>(schema: {
|
|
236
|
-
parse: (input: unknown) => T;
|
|
237
|
-
safeParse: (input: unknown) => {
|
|
238
|
-
success: boolean;
|
|
239
|
-
data?: T;
|
|
240
|
-
error?: unknown;
|
|
241
|
-
};
|
|
242
|
-
}, brandName: B): {
|
|
243
|
-
/**
|
|
244
|
-
* The Zod schema with brand transformation.
|
|
245
|
-
*/
|
|
246
|
-
schema: {
|
|
247
|
-
parse: (input: unknown) => Brand<T, B>;
|
|
248
|
-
safeParse: (input: unknown) => {
|
|
249
|
-
success: true;
|
|
250
|
-
data: Brand<T, B>;
|
|
251
|
-
} | {
|
|
252
|
-
success: false;
|
|
253
|
-
error: unknown;
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Parse and validate input, returning branded value.
|
|
258
|
-
* Throws on validation failure.
|
|
259
|
-
*/
|
|
260
|
-
parse: (input: unknown) => Brand<T, B>;
|
|
261
|
-
/**
|
|
262
|
-
* Type guard to check if a value is this brand.
|
|
263
|
-
*/
|
|
264
|
-
is: (value: unknown) => value is Brand<T, B>;
|
|
265
|
-
/**
|
|
266
|
-
* Brand name identifier.
|
|
267
|
-
*/
|
|
268
|
-
brandName: B;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* BEST PRACTICES SUMMARY:
|
|
272
|
-
* =======================
|
|
273
|
-
*
|
|
274
|
-
* 1. ALWAYS validate at boundaries:
|
|
275
|
-
* - API inputs: Use Zod schemas
|
|
276
|
-
* - Database outputs: Use Zod schemas
|
|
277
|
-
* - File I/O: Use Zod schemas
|
|
278
|
-
* - CLI args: Use Zod schemas
|
|
279
|
-
*
|
|
280
|
-
* 2. NEVER cast to brand types:
|
|
281
|
-
* ❌ const id = userInput as TenantId;
|
|
282
|
-
* ✅ const id = TenantIdSchema.parse(userInput);
|
|
283
|
-
*
|
|
284
|
-
* 3. Use createBrandFactory for all brand types:
|
|
285
|
-
* - Provides validation
|
|
286
|
-
* - Provides type guards
|
|
287
|
-
* - Centralizes brand creation
|
|
288
|
-
*
|
|
289
|
-
* 4. Document which functions validate:
|
|
290
|
-
* ```typescript
|
|
291
|
-
* // @validates TenantId - performs Zod validation
|
|
292
|
-
* function parseTenantId(input: string): TenantId {
|
|
293
|
-
* return TenantIdSchema.parse(input);
|
|
294
|
-
* }
|
|
295
|
-
*
|
|
296
|
-
* // @assumes TenantId - no validation, requires validated input
|
|
297
|
-
* function formatTenantId(id: TenantId): string {
|
|
298
|
-
* return `tenant:${unbrand(id)}`;
|
|
299
|
-
* }
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
|
-
* 5. Test brand type enforcement:
|
|
303
|
-
* ```typescript
|
|
304
|
-
* // Should fail to compile
|
|
305
|
-
* const apiKey: ApiKeyId = getTenantId(); // ❌
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
//# sourceMappingURL=brand-types.d.ts.map
|