@defai.digital/ax-cli 3.4.6 → 3.5.4

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.
Files changed (223) hide show
  1. package/LICENSE +2 -6
  2. package/README.md +109 -2
  3. package/dist/analyzers/ast/index.d.ts +9 -0
  4. package/dist/analyzers/ast/index.js +10 -0
  5. package/dist/analyzers/ast/index.js.map +1 -0
  6. package/dist/analyzers/ast/node-helpers.d.ts +81 -0
  7. package/dist/analyzers/ast/node-helpers.js +128 -0
  8. package/dist/analyzers/ast/node-helpers.js.map +1 -0
  9. package/dist/analyzers/ast/parser.d.ts +59 -0
  10. package/dist/analyzers/ast/parser.js +293 -0
  11. package/dist/analyzers/ast/parser.js.map +1 -0
  12. package/dist/analyzers/ast/traverser.d.ts +67 -0
  13. package/dist/analyzers/ast/traverser.js +156 -0
  14. package/dist/analyzers/ast/traverser.js.map +1 -0
  15. package/dist/analyzers/ast/types.d.ts +107 -0
  16. package/dist/analyzers/ast/types.js +7 -0
  17. package/dist/analyzers/ast/types.js.map +1 -0
  18. package/dist/analyzers/best-practices/index.d.ts +10 -0
  19. package/dist/analyzers/best-practices/index.js +11 -0
  20. package/dist/analyzers/best-practices/index.js.map +1 -0
  21. package/dist/analyzers/code-smells/base-smell-detector.d.ts +30 -0
  22. package/dist/analyzers/code-smells/base-smell-detector.js +44 -0
  23. package/dist/analyzers/code-smells/base-smell-detector.js.map +1 -0
  24. package/dist/analyzers/code-smells/code-smell-analyzer.d.ts +30 -0
  25. package/dist/analyzers/code-smells/code-smell-analyzer.js +167 -0
  26. package/dist/analyzers/code-smells/code-smell-analyzer.js.map +1 -0
  27. package/dist/analyzers/code-smells/detectors/data-clumps-detector.d.ts +11 -0
  28. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js +66 -0
  29. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js.map +1 -0
  30. package/dist/analyzers/code-smells/detectors/dead-code-detector.d.ts +11 -0
  31. package/dist/analyzers/code-smells/detectors/dead-code-detector.js +53 -0
  32. package/dist/analyzers/code-smells/detectors/dead-code-detector.js.map +1 -0
  33. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.d.ts +11 -0
  34. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +51 -0
  35. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -0
  36. package/dist/analyzers/code-smells/detectors/feature-envy-detector.d.ts +11 -0
  37. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js +64 -0
  38. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js.map +1 -0
  39. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.d.ts +11 -0
  40. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js +56 -0
  41. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js.map +1 -0
  42. package/dist/analyzers/code-smells/detectors/large-class-detector.d.ts +13 -0
  43. package/dist/analyzers/code-smells/detectors/large-class-detector.js +58 -0
  44. package/dist/analyzers/code-smells/detectors/large-class-detector.js.map +1 -0
  45. package/dist/analyzers/code-smells/detectors/long-method-detector.d.ts +12 -0
  46. package/dist/analyzers/code-smells/detectors/long-method-detector.js +52 -0
  47. package/dist/analyzers/code-smells/detectors/long-method-detector.js.map +1 -0
  48. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.d.ts +12 -0
  49. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js +50 -0
  50. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js.map +1 -0
  51. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.d.ts +12 -0
  52. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js +54 -0
  53. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js.map +1 -0
  54. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.d.ts +13 -0
  55. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js +71 -0
  56. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js.map +1 -0
  57. package/dist/analyzers/code-smells/index.d.ts +16 -0
  58. package/dist/analyzers/code-smells/index.js +19 -0
  59. package/dist/analyzers/code-smells/index.js.map +1 -0
  60. package/dist/analyzers/code-smells/types.d.ts +82 -0
  61. package/dist/analyzers/code-smells/types.js +30 -0
  62. package/dist/analyzers/code-smells/types.js.map +1 -0
  63. package/dist/analyzers/dependency/circular-detector.d.ts +17 -0
  64. package/dist/analyzers/dependency/circular-detector.js +71 -0
  65. package/dist/analyzers/dependency/circular-detector.js.map +1 -0
  66. package/dist/analyzers/dependency/coupling-calculator.d.ts +24 -0
  67. package/dist/analyzers/dependency/coupling-calculator.js +86 -0
  68. package/dist/analyzers/dependency/coupling-calculator.js.map +1 -0
  69. package/dist/analyzers/dependency/dependency-analyzer.d.ts +40 -0
  70. package/dist/analyzers/dependency/dependency-analyzer.js +214 -0
  71. package/dist/analyzers/dependency/dependency-analyzer.js.map +1 -0
  72. package/dist/analyzers/dependency/dependency-graph.d.ts +57 -0
  73. package/dist/analyzers/dependency/dependency-graph.js +186 -0
  74. package/dist/analyzers/dependency/dependency-graph.js.map +1 -0
  75. package/dist/analyzers/dependency/index.d.ts +8 -0
  76. package/dist/analyzers/dependency/index.js +8 -0
  77. package/dist/analyzers/dependency/index.js.map +1 -0
  78. package/dist/analyzers/dependency/types.d.ts +105 -0
  79. package/dist/analyzers/dependency/types.js +5 -0
  80. package/dist/analyzers/dependency/types.js.map +1 -0
  81. package/dist/analyzers/git/churn-calculator.d.ts +34 -0
  82. package/dist/analyzers/git/churn-calculator.js +214 -0
  83. package/dist/analyzers/git/churn-calculator.js.map +1 -0
  84. package/dist/analyzers/git/git-analyzer.d.ts +19 -0
  85. package/dist/analyzers/git/git-analyzer.js +71 -0
  86. package/dist/analyzers/git/git-analyzer.js.map +1 -0
  87. package/dist/analyzers/git/hotspot-detector.d.ts +34 -0
  88. package/dist/analyzers/git/hotspot-detector.js +170 -0
  89. package/dist/analyzers/git/hotspot-detector.js.map +1 -0
  90. package/dist/analyzers/git/index.d.ts +7 -0
  91. package/dist/analyzers/git/index.js +7 -0
  92. package/dist/analyzers/git/index.js.map +1 -0
  93. package/dist/analyzers/git/types.d.ts +88 -0
  94. package/dist/analyzers/git/types.js +5 -0
  95. package/dist/analyzers/git/types.js.map +1 -0
  96. package/dist/analyzers/metrics/halstead-calculator.d.ts +30 -0
  97. package/dist/analyzers/metrics/halstead-calculator.js +150 -0
  98. package/dist/analyzers/metrics/halstead-calculator.js.map +1 -0
  99. package/dist/analyzers/metrics/index.d.ts +9 -0
  100. package/dist/analyzers/metrics/index.js +9 -0
  101. package/dist/analyzers/metrics/index.js.map +1 -0
  102. package/dist/analyzers/metrics/maintainability-calculator.d.ts +17 -0
  103. package/dist/analyzers/metrics/maintainability-calculator.js +46 -0
  104. package/dist/analyzers/metrics/maintainability-calculator.js.map +1 -0
  105. package/dist/analyzers/metrics/metrics-analyzer.d.ts +32 -0
  106. package/dist/analyzers/metrics/metrics-analyzer.js +140 -0
  107. package/dist/analyzers/metrics/metrics-analyzer.js.map +1 -0
  108. package/dist/analyzers/metrics/types.d.ts +67 -0
  109. package/dist/analyzers/metrics/types.js +5 -0
  110. package/dist/analyzers/metrics/types.js.map +1 -0
  111. package/dist/analyzers/security/base-detector.d.ts +58 -0
  112. package/dist/analyzers/security/base-detector.js +104 -0
  113. package/dist/analyzers/security/base-detector.js.map +1 -0
  114. package/dist/analyzers/security/detectors/command-injection-detector.d.ts +12 -0
  115. package/dist/analyzers/security/detectors/command-injection-detector.js +84 -0
  116. package/dist/analyzers/security/detectors/command-injection-detector.js.map +1 -0
  117. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.d.ts +16 -0
  118. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.js +140 -0
  119. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.js.map +1 -0
  120. package/dist/analyzers/security/detectors/insecure-deserialization-detector.d.ts +12 -0
  121. package/dist/analyzers/security/detectors/insecure-deserialization-detector.js +109 -0
  122. package/dist/analyzers/security/detectors/insecure-deserialization-detector.js.map +1 -0
  123. package/dist/analyzers/security/detectors/insecure-random-detector.d.ts +12 -0
  124. package/dist/analyzers/security/detectors/insecure-random-detector.js +61 -0
  125. package/dist/analyzers/security/detectors/insecure-random-detector.js.map +1 -0
  126. package/dist/analyzers/security/detectors/path-traversal-detector.d.ts +12 -0
  127. package/dist/analyzers/security/detectors/path-traversal-detector.js +82 -0
  128. package/dist/analyzers/security/detectors/path-traversal-detector.js.map +1 -0
  129. package/dist/analyzers/security/detectors/sql-injection-detector.d.ts +12 -0
  130. package/dist/analyzers/security/detectors/sql-injection-detector.js +88 -0
  131. package/dist/analyzers/security/detectors/sql-injection-detector.js.map +1 -0
  132. package/dist/analyzers/security/detectors/weak-crypto-detector.d.ts +12 -0
  133. package/dist/analyzers/security/detectors/weak-crypto-detector.js +104 -0
  134. package/dist/analyzers/security/detectors/weak-crypto-detector.js.map +1 -0
  135. package/dist/analyzers/security/detectors/xss-detector.d.ts +12 -0
  136. package/dist/analyzers/security/detectors/xss-detector.js +90 -0
  137. package/dist/analyzers/security/detectors/xss-detector.js.map +1 -0
  138. package/dist/analyzers/security/index.d.ts +16 -0
  139. package/dist/analyzers/security/index.js +18 -0
  140. package/dist/analyzers/security/index.js.map +1 -0
  141. package/dist/analyzers/security/security-analyzer.d.ts +38 -0
  142. package/dist/analyzers/security/security-analyzer.js +215 -0
  143. package/dist/analyzers/security/security-analyzer.js.map +1 -0
  144. package/dist/analyzers/security/types.d.ts +95 -0
  145. package/dist/analyzers/security/types.js +7 -0
  146. package/dist/analyzers/security/types.js.map +1 -0
  147. package/dist/hooks/use-enhanced-input.d.ts +0 -1
  148. package/dist/hooks/use-enhanced-input.js.map +1 -1
  149. package/dist/index.js +0 -0
  150. package/dist/mcp/validation.js +12 -6
  151. package/dist/mcp/validation.js.map +1 -1
  152. package/dist/tools/analysis-tools.d.ts +73 -0
  153. package/dist/tools/analysis-tools.js +422 -0
  154. package/dist/tools/analysis-tools.js.map +1 -0
  155. package/dist/tools/bash.js +2 -1
  156. package/dist/tools/bash.js.map +1 -1
  157. package/dist/ui/components/toast-notification.js +0 -1
  158. package/dist/ui/components/toast-notification.js.map +1 -1
  159. package/dist/ui/components/welcome-panel.js +1 -1
  160. package/dist/ui/components/welcome-panel.js.map +1 -1
  161. package/dist/ui/hooks/use-input-history.d.ts +9 -0
  162. package/dist/ui/hooks/use-input-history.js +117 -0
  163. package/dist/ui/hooks/use-input-history.js.map +1 -0
  164. package/dist/utils/parallel-analyzer.js +30 -17
  165. package/dist/utils/parallel-analyzer.js.map +1 -1
  166. package/eslint.config.js +3 -0
  167. package/package.json +5 -5
  168. package/vitest.config.ts +1 -0
  169. package/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +0 -69
  170. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +0 -24
  171. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +0 -69
  172. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +0 -44
  173. package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +0 -24
  174. package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +0 -44
  175. package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +0 -69
  176. package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +0 -24
  177. package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +0 -24
  178. package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +0 -69
  179. package/automatosx.config.json +0 -333
  180. package/config/messages.yaml +0 -75
  181. package/config/models.yaml +0 -66
  182. package/config/prompts.yaml +0 -156
  183. package/config/settings.yaml +0 -86
  184. package/dist/commands/weather.d.ts +0 -8
  185. package/dist/commands/weather.js +0 -160
  186. package/dist/commands/weather.js.map +0 -1
  187. package/dist/grok/client.d.ts +0 -144
  188. package/dist/grok/client.js +0 -237
  189. package/dist/grok/client.js.map +0 -1
  190. package/dist/grok/tools.d.ts +0 -8
  191. package/dist/grok/tools.js +0 -318
  192. package/dist/grok/tools.js.map +0 -1
  193. package/dist/grok/types.d.ts +0 -291
  194. package/dist/grok/types.js +0 -127
  195. package/dist/grok/types.js.map +0 -1
  196. package/dist/tools/morph-editor.d.ts +0 -36
  197. package/dist/tools/morph-editor.js +0 -308
  198. package/dist/tools/morph-editor.js.map +0 -1
  199. package/dist/ui/components/session-recovery.d.ts +0 -12
  200. package/dist/ui/components/session-recovery.js +0 -93
  201. package/dist/ui/components/session-recovery.js.map +0 -1
  202. package/dist/utils/model-config.d.ts +0 -28
  203. package/dist/utils/model-config.js +0 -43
  204. package/dist/utils/model-config.js.map +0 -1
  205. package/dist/utils/tool-helpers.d.ts +0 -25
  206. package/dist/utils/tool-helpers.js +0 -79
  207. package/dist/utils/tool-helpers.js.map +0 -1
  208. package/packages/schemas/dist/index.d.ts +0 -14
  209. package/packages/schemas/dist/index.d.ts.map +0 -1
  210. package/packages/schemas/dist/index.js +0 -19
  211. package/packages/schemas/dist/index.js.map +0 -1
  212. package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
  213. package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
  214. package/packages/schemas/dist/public/core/brand-types.js +0 -243
  215. package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
  216. package/packages/schemas/dist/public/core/enums.d.ts +0 -227
  217. package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
  218. package/packages/schemas/dist/public/core/enums.js +0 -222
  219. package/packages/schemas/dist/public/core/enums.js.map +0 -1
  220. package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
  221. package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
  222. package/packages/schemas/dist/public/core/id-types.js +0 -136
  223. package/packages/schemas/dist/public/core/id-types.js.map +0 -1
@@ -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;IACxD,WAAW,CAAS;IACpB,YAAY,GAAW,6BAA6B,CAAC;IAE7D,YAAY,MAAe;QACzB,IAAI,CAAC,WAAW,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,QAAQ,CACZ,UAAkB,EAClB,YA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,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,12 +0,0 @@
1
- /**
2
- * Session Recovery Component
3
- * Shows a prompt when a previous session is detected
4
- */
5
- import React from "react";
6
- interface SessionRecoveryProps {
7
- onResume: () => void;
8
- onNewSession: () => void;
9
- onViewHistory: () => void;
10
- }
11
- export declare function SessionRecovery({ onResume, onNewSession, onViewHistory, }: SessionRecoveryProps): React.JSX.Element | null;
12
- export default SessionRecovery;
@@ -1,93 +0,0 @@
1
- /**
2
- * Session Recovery Component
3
- * Shows a prompt when a previous session is detected
4
- */
5
- import React, { useState, useEffect } from "react";
6
- import { Box, Text, useInput } from "ink";
7
- import { getHistoryManager } from "../../utils/history-manager.js";
8
- function formatTimeAgo(date) {
9
- const now = new Date();
10
- const diffMs = now.getTime() - date.getTime();
11
- const diffMins = Math.floor(diffMs / 60000);
12
- const diffHours = Math.floor(diffMins / 60);
13
- const diffDays = Math.floor(diffHours / 24);
14
- if (diffMins < 1)
15
- return "just now";
16
- if (diffMins < 60)
17
- return `${diffMins}m ago`;
18
- if (diffHours < 24)
19
- return `${diffHours}h ago`;
20
- return `${diffDays}d ago`;
21
- }
22
- export function SessionRecovery({ onResume, onNewSession, onViewHistory, }) {
23
- const [selectedOption, setSelectedOption] = useState(0);
24
- const [sessionInfo, setSessionInfo] = useState(null);
25
- const options = [
26
- { key: "r", label: "Resume", description: "Continue previous session", action: onResume },
27
- { key: "n", label: "New", description: "Start fresh session", action: onNewSession },
28
- { key: "v", label: "View", description: "View history before deciding", action: onViewHistory },
29
- ];
30
- useEffect(() => {
31
- // Load session info
32
- const historyManager = getHistoryManager();
33
- const history = historyManager.loadHistory();
34
- if (history.length > 0) {
35
- const lastEntry = history[history.length - 1];
36
- setSessionInfo({
37
- messageCount: history.length,
38
- lastActive: new Date(lastEntry.timestamp),
39
- hasHistory: true,
40
- });
41
- }
42
- }, []);
43
- useInput((input, key) => {
44
- if (key.upArrow || (key.shift && key.tab)) {
45
- setSelectedOption((prev) => (prev > 0 ? prev - 1 : options.length - 1));
46
- return;
47
- }
48
- if (key.downArrow || key.tab) {
49
- setSelectedOption((prev) => (prev + 1) % options.length);
50
- return;
51
- }
52
- if (key.return) {
53
- options[selectedOption].action();
54
- return;
55
- }
56
- // Quick select by key
57
- const matchingOption = options.findIndex((opt) => opt.key.toLowerCase() === input.toLowerCase());
58
- if (matchingOption !== -1) {
59
- options[matchingOption].action();
60
- }
61
- });
62
- if (!sessionInfo?.hasHistory) {
63
- // No previous session, auto-continue to new session
64
- useEffect(() => {
65
- onNewSession();
66
- }, []);
67
- return null;
68
- }
69
- return (React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1 },
70
- React.createElement(Box, { borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 1, flexDirection: "column" },
71
- React.createElement(Box, { marginBottom: 1 },
72
- React.createElement(Text, { color: "cyan", bold: true }, "\u23EA Previous Session Detected")),
73
- React.createElement(Box, { flexDirection: "column", marginBottom: 1 },
74
- React.createElement(Box, null,
75
- React.createElement(Text, { color: "gray" }, "Last active: "),
76
- React.createElement(Text, { color: "white" }, formatTimeAgo(sessionInfo.lastActive))),
77
- React.createElement(Box, null,
78
- React.createElement(Text, { color: "gray" }, "Messages: "),
79
- React.createElement(Text, { color: "white" }, sessionInfo.messageCount))),
80
- React.createElement(Box, { flexDirection: "column", marginTop: 1 }, options.map((option, index) => (React.createElement(Box, { key: option.key, paddingLeft: 1 },
81
- React.createElement(Text, { color: selectedOption === index ? "black" : "white", backgroundColor: selectedOption === index ? "cyan" : undefined, bold: selectedOption === index },
82
- "[",
83
- option.key.toUpperCase(),
84
- "] ",
85
- option.label),
86
- React.createElement(Text, { color: "gray" },
87
- " - ",
88
- option.description))))),
89
- React.createElement(Box, { marginTop: 1 },
90
- React.createElement(Text, { color: "gray", dimColor: true }, "\u2191\u2193 navigate \u2022 Enter select \u2022 or press R/N/V")))));
91
- }
92
- export default SessionRecovery;
93
- //# sourceMappingURL=session-recovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-recovery.js","sourceRoot":"","sources":["../../../src/ui/components/session-recovery.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAcnE,SAAS,aAAa,CAAC,IAAU;IAC/B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;IAE5C,IAAI,QAAQ,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IACpC,IAAI,QAAQ,GAAG,EAAE;QAAE,OAAO,GAAG,QAAQ,OAAO,CAAC;IAC7C,IAAI,SAAS,GAAG,EAAE;QAAE,OAAO,GAAG,SAAS,O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,CAAC,CACE;YAGN,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;gBACf,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,4EAEpB,CACH,CACF,CACF,CACP,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -1,28 +0,0 @@
1
- import { UserSettings, ProjectSettings } from './settings-manager.js';
2
- export interface ModelOption {
3
- model: string;
4
- }
5
- export type ModelConfig = string;
6
- export { UserSettings, ProjectSettings };
7
- /**
8
- * Get the effective current model
9
- * Priority: project current model > user default model > system default
10
- */
11
- export declare function getCurrentModel(): string;
12
- /**
13
- * Load model configuration
14
- * Priority: user-settings.json models > default hardcoded
15
- */
16
- export declare function loadModelConfig(): ModelOption[];
17
- /**
18
- * Get default models list
19
- */
20
- export declare function getDefaultModels(): string[];
21
- /**
22
- * Update the current model in project settings
23
- */
24
- export declare function updateCurrentModel(modelName: string): void;
25
- /**
26
- * Update the user's default model preference
27
- */
28
- export declare function updateDefaultModel(modelName: string): void;
@@ -1,43 +0,0 @@
1
- import { getSettingsManager } from './settings-manager.js';
2
- import { ModelIdSchema } from '@ax-cli/schemas';
3
- /**
4
- * Get the effective current model
5
- * Priority: project current model > user default model > system default
6
- */
7
- export function getCurrentModel() {
8
- const manager = getSettingsManager();
9
- return manager.getCurrentModel();
10
- }
11
- /**
12
- * Load model configuration
13
- * Priority: user-settings.json models > default hardcoded
14
- */
15
- export function loadModelConfig() {
16
- const manager = getSettingsManager();
17
- const models = manager.getAvailableModels();
18
- return models.map(model => ({
19
- model: model.trim()
20
- }));
21
- }
22
- /**
23
- * Get default models list
24
- */
25
- export function getDefaultModels() {
26
- const manager = getSettingsManager();
27
- return manager.getAvailableModels();
28
- }
29
- /**
30
- * Update the current model in project settings
31
- */
32
- export function updateCurrentModel(modelName) {
33
- const manager = getSettingsManager();
34
- manager.setCurrentModel(modelName);
35
- }
36
- /**
37
- * Update the user's default model preference
38
- */
39
- export function updateDefaultModel(modelName) {
40
- const manager = getSettingsManager();
41
- manager.updateUserSetting('defaultModel', ModelIdSchema.parse(modelName));
42
- }
43
- //# sourceMappingURL=model-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/utils/model-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAiC,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAWhD;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO,OAAO,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAE5C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;KACpB,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO,OAAO,CAAC,kBAAkB,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO,CAAC,iBAAiB,CAAC,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { ToolResult } from "../types/index.js";
2
- /**
3
- * Execute a tool operation with standardized error handling
4
- *
5
- * @param operation - The async operation to execute
6
- * @param context - Context string for error messages (e.g., "View file", "Execute bash")
7
- * @returns ToolResult with success/failure status
8
- *
9
- * @example
10
- * ```typescript
11
- * return executeTool(async () => {
12
- * const content = await fs.readFile(path, 'utf-8');
13
- * return `File contents: ${content}`;
14
- * }, `View ${path}`);
15
- * ```
16
- */
17
- export declare function executeTool<T>(operation: () => Promise<T>, context: string): Promise<ToolResult>;
18
- /**
19
- * Execute a tool operation synchronously with standardized error handling
20
- *
21
- * @param operation - The sync operation to execute
22
- * @param context - Context string for error messages
23
- * @returns ToolResult with success/failure status
24
- */
25
- export declare function executeToolSync<T>(operation: () => T, context: string): ToolResult;
@@ -1,79 +0,0 @@
1
- /**
2
- * Execute a tool operation with standardized error handling
3
- *
4
- * @param operation - The async operation to execute
5
- * @param context - Context string for error messages (e.g., "View file", "Execute bash")
6
- * @returns ToolResult with success/failure status
7
- *
8
- * @example
9
- * ```typescript
10
- * return executeTool(async () => {
11
- * const content = await fs.readFile(path, 'utf-8');
12
- * return `File contents: ${content}`;
13
- * }, `View ${path}`);
14
- * ```
15
- */
16
- export async function executeTool(operation, context) {
17
- try {
18
- const result = await operation();
19
- let output;
20
- if (typeof result === 'string') {
21
- output = result;
22
- }
23
- else {
24
- try {
25
- output = JSON.stringify(result);
26
- }
27
- catch {
28
- // Fallback for circular references or non-serializable values
29
- output = String(result);
30
- }
31
- }
32
- return {
33
- success: true,
34
- output
35
- };
36
- }
37
- catch (error) {
38
- return {
39
- success: false,
40
- error: `${context}: ${error.message}`
41
- };
42
- }
43
- }
44
- /**
45
- * Execute a tool operation synchronously with standardized error handling
46
- *
47
- * @param operation - The sync operation to execute
48
- * @param context - Context string for error messages
49
- * @returns ToolResult with success/failure status
50
- */
51
- export function executeToolSync(operation, context) {
52
- try {
53
- const result = operation();
54
- let output;
55
- if (typeof result === 'string') {
56
- output = result;
57
- }
58
- else {
59
- try {
60
- output = JSON.stringify(result);
61
- }
62
- catch {
63
- // Fallback for circular references or non-serializable values
64
- output = String(result);
65
- }
66
- }
67
- return {
68
- success: true,
69
- output
70
- };
71
- }
72
- catch (error) {
73
- return {
74
- success: false,
75
- error: `${context}: ${error.message}`
76
- };
77
- }
78
- }
79
- //# sourceMappingURL=tool-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-helpers.js","sourceRoot":"","sources":["../../src/utils/tool-helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAA2B,EAC3B,OAAe;IAEf,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,MAAc,CAAC;QACnB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,MAAM,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;YAAC,MAAM,CAAC;gBACP,8DAA8D;gBAC9D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM;SACP,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE;SACtC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAkB,EAClB,OAAe;IAEf,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,MAAc,CAAC;QACnB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,MAAM,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;YAAC,MAAM,CAAC;gBACP,8DAA8D;gBAC9D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM;SACP,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE;SACtC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -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"}