@involvex/super-agent-cli 0.0.45 → 0.0.47

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 (140) hide show
  1. package/bunfig.toml +43 -0
  2. package/dist/index.js +9 -15
  3. package/dist/super-agent-cli.exe +0 -0
  4. package/package.json +4 -1
  5. package/.grok/settings.json +0 -3
  6. package/.super-agent/settings.json +0 -23
  7. package/dist/agent/grok-agent.d.ts +0 -54
  8. package/dist/agent/grok-agent.js +0 -638
  9. package/dist/agent/grok-agent.js.map +0 -1
  10. package/dist/agent/index.d.ts +0 -14
  11. package/dist/agent/index.js +0 -139
  12. package/dist/agent/index.js.map +0 -1
  13. package/dist/agent/super-agent.d.ts +0 -54
  14. package/dist/agent/super-agent.js +0 -638
  15. package/dist/agent/super-agent.js.map +0 -1
  16. package/dist/commands/mcp.d.ts +0 -2
  17. package/dist/commands/mcp.js +0 -247
  18. package/dist/commands/mcp.js.map +0 -1
  19. package/dist/core/client.d.ts +0 -49
  20. package/dist/core/client.js +0 -81
  21. package/dist/core/client.js.map +0 -1
  22. package/dist/core/tools.d.ts +0 -8
  23. package/dist/core/tools.js +0 -351
  24. package/dist/core/tools.js.map +0 -1
  25. package/dist/grok/client.d.ts +0 -49
  26. package/dist/grok/client.js +0 -81
  27. package/dist/grok/client.js.map +0 -1
  28. package/dist/grok/tools.d.ts +0 -8
  29. package/dist/grok/tools.js +0 -351
  30. package/dist/grok/tools.js.map +0 -1
  31. package/dist/hooks/use-enhanced-input.d.ts +0 -37
  32. package/dist/hooks/use-enhanced-input.js +0 -228
  33. package/dist/hooks/use-enhanced-input.js.map +0 -1
  34. package/dist/hooks/use-input-handler.d.ts +0 -34
  35. package/dist/hooks/use-input-handler.js +0 -607
  36. package/dist/hooks/use-input-handler.js.map +0 -1
  37. package/dist/hooks/use-input-history.d.ts +0 -9
  38. package/dist/hooks/use-input-history.js +0 -62
  39. package/dist/hooks/use-input-history.js.map +0 -1
  40. package/dist/index.d.ts +0 -2
  41. package/dist/index.js.map +0 -1
  42. package/dist/mcp/client.d.ts +0 -29
  43. package/dist/mcp/client.js +0 -127
  44. package/dist/mcp/client.js.map +0 -1
  45. package/dist/mcp/config.d.ts +0 -13
  46. package/dist/mcp/config.js +0 -45
  47. package/dist/mcp/config.js.map +0 -1
  48. package/dist/mcp/transports.d.ts +0 -51
  49. package/dist/mcp/transports.js +0 -229
  50. package/dist/mcp/transports.js.map +0 -1
  51. package/dist/tools/bash.d.ts +0 -10
  52. package/dist/tools/bash.js +0 -76
  53. package/dist/tools/bash.js.map +0 -1
  54. package/dist/tools/confirmation-tool.d.ts +0 -16
  55. package/dist/tools/confirmation-tool.js +0 -77
  56. package/dist/tools/confirmation-tool.js.map +0 -1
  57. package/dist/tools/index.d.ts +0 -6
  58. package/dist/tools/index.js +0 -7
  59. package/dist/tools/index.js.map +0 -1
  60. package/dist/tools/morph-editor.d.ts +0 -36
  61. package/dist/tools/morph-editor.js +0 -324
  62. package/dist/tools/morph-editor.js.map +0 -1
  63. package/dist/tools/search.d.ts +0 -69
  64. package/dist/tools/search.js +0 -307
  65. package/dist/tools/search.js.map +0 -1
  66. package/dist/tools/text-editor.d.ts +0 -26
  67. package/dist/tools/text-editor.js +0 -583
  68. package/dist/tools/text-editor.js.map +0 -1
  69. package/dist/tools/todo-tool.d.ts +0 -20
  70. package/dist/tools/todo-tool.js +0 -134
  71. package/dist/tools/todo-tool.js.map +0 -1
  72. package/dist/types/index.d.ts +0 -30
  73. package/dist/types/index.js +0 -2
  74. package/dist/types/index.js.map +0 -1
  75. package/dist/ui/app.d.ts +0 -6
  76. package/dist/ui/app.js +0 -76
  77. package/dist/ui/app.js.map +0 -1
  78. package/dist/ui/components/api-key-input.d.ts +0 -6
  79. package/dist/ui/components/api-key-input.js +0 -70
  80. package/dist/ui/components/api-key-input.js.map +0 -1
  81. package/dist/ui/components/chat-history.d.ts +0 -7
  82. package/dist/ui/components/chat-history.js +0 -136
  83. package/dist/ui/components/chat-history.js.map +0 -1
  84. package/dist/ui/components/chat-input.d.ts +0 -8
  85. package/dist/ui/components/chat-input.js +0 -47
  86. package/dist/ui/components/chat-input.js.map +0 -1
  87. package/dist/ui/components/chat-interface.d.ts +0 -7
  88. package/dist/ui/components/chat-interface.js +0 -213
  89. package/dist/ui/components/chat-interface.js.map +0 -1
  90. package/dist/ui/components/command-suggestions.d.ts +0 -16
  91. package/dist/ui/components/command-suggestions.js +0 -18
  92. package/dist/ui/components/command-suggestions.js.map +0 -1
  93. package/dist/ui/components/confirmation-dialog.d.ts +0 -10
  94. package/dist/ui/components/confirmation-dialog.js +0 -70
  95. package/dist/ui/components/confirmation-dialog.js.map +0 -1
  96. package/dist/ui/components/diff-renderer.d.ts +0 -13
  97. package/dist/ui/components/diff-renderer.js +0 -200
  98. package/dist/ui/components/diff-renderer.js.map +0 -1
  99. package/dist/ui/components/loading-spinner.d.ts +0 -7
  100. package/dist/ui/components/loading-spinner.js +0 -52
  101. package/dist/ui/components/loading-spinner.js.map +0 -1
  102. package/dist/ui/components/mcp-status.d.ts +0 -4
  103. package/dist/ui/components/mcp-status.js +0 -37
  104. package/dist/ui/components/mcp-status.js.map +0 -1
  105. package/dist/ui/components/model-selection.d.ts +0 -11
  106. package/dist/ui/components/model-selection.js +0 -9
  107. package/dist/ui/components/model-selection.js.map +0 -1
  108. package/dist/ui/shared/max-sized-box.d.ts +0 -8
  109. package/dist/ui/shared/max-sized-box.js +0 -6
  110. package/dist/ui/shared/max-sized-box.js.map +0 -1
  111. package/dist/ui/utils/code-colorizer.d.ts +0 -2
  112. package/dist/ui/utils/code-colorizer.js +0 -7
  113. package/dist/ui/utils/code-colorizer.js.map +0 -1
  114. package/dist/ui/utils/colors.d.ts +0 -14
  115. package/dist/ui/utils/colors.js +0 -15
  116. package/dist/ui/utils/colors.js.map +0 -1
  117. package/dist/ui/utils/markdown-renderer.d.ts +0 -3
  118. package/dist/ui/utils/markdown-renderer.js +0 -23
  119. package/dist/ui/utils/markdown-renderer.js.map +0 -1
  120. package/dist/utils/confirmation-service.d.ts +0 -33
  121. package/dist/utils/confirmation-service.js +0 -110
  122. package/dist/utils/confirmation-service.js.map +0 -1
  123. package/dist/utils/custom-instructions.d.ts +0 -1
  124. package/dist/utils/custom-instructions.js +0 -23
  125. package/dist/utils/custom-instructions.js.map +0 -1
  126. package/dist/utils/model-config.d.ts +0 -28
  127. package/dist/utils/model-config.js +0 -42
  128. package/dist/utils/model-config.js.map +0 -1
  129. package/dist/utils/settings-manager.d.ts +0 -99
  130. package/dist/utils/settings-manager.js +0 -286
  131. package/dist/utils/settings-manager.js.map +0 -1
  132. package/dist/utils/settings.d.ts +0 -1
  133. package/dist/utils/settings.js +0 -4
  134. package/dist/utils/settings.js.map +0 -1
  135. package/dist/utils/text-utils.d.ts +0 -80
  136. package/dist/utils/text-utils.js +0 -191
  137. package/dist/utils/text-utils.js.map +0 -1
  138. package/dist/utils/token-counter.d.ts +0 -33
  139. package/dist/utils/token-counter.js +0 -79
  140. package/dist/utils/token-counter.js.map +0 -1
@@ -1,76 +0,0 @@
1
- import { ConfirmationService } from "../utils/confirmation-service";
2
- import { exec } from "child_process";
3
- import { promisify } from "util";
4
- const execAsync = promisify(exec);
5
- export class BashTool {
6
- currentDirectory = process.cwd();
7
- confirmationService = ConfirmationService.getInstance();
8
- async execute(command, timeout = 30000) {
9
- try {
10
- // Check if user has already accepted bash commands for this session
11
- const sessionFlags = this.confirmationService.getSessionFlags();
12
- if (!sessionFlags.bashCommands && !sessionFlags.allOperations) {
13
- // Request confirmation showing the command
14
- const confirmationResult = await this.confirmationService.requestConfirmation({
15
- operation: "Run bash command",
16
- filename: command,
17
- showVSCodeOpen: false,
18
- content: `Command: ${command}\nWorking directory: ${this.currentDirectory}`,
19
- }, "bash");
20
- if (!confirmationResult.confirmed) {
21
- return {
22
- success: false,
23
- error: confirmationResult.feedback ||
24
- "Command execution cancelled by user",
25
- };
26
- }
27
- }
28
- if (command.startsWith("cd ")) {
29
- const newDir = command.substring(3).trim();
30
- try {
31
- process.chdir(newDir);
32
- this.currentDirectory = process.cwd();
33
- return {
34
- success: true,
35
- output: `Changed directory to: ${this.currentDirectory}`,
36
- };
37
- }
38
- catch (error) {
39
- return {
40
- success: false,
41
- error: `Cannot change directory: ${error.message}`,
42
- };
43
- }
44
- }
45
- const { stdout, stderr } = await execAsync(command, {
46
- cwd: this.currentDirectory,
47
- timeout,
48
- maxBuffer: 1024 * 1024,
49
- });
50
- const output = stdout + (stderr ? `\nSTDERR: ${stderr}` : "");
51
- return {
52
- success: true,
53
- output: output.trim() || "Command executed successfully (no output)",
54
- };
55
- }
56
- catch (error) {
57
- return {
58
- success: false,
59
- error: `Command failed: ${error.message}`,
60
- };
61
- }
62
- }
63
- getCurrentDirectory() {
64
- return this.currentDirectory;
65
- }
66
- async listFiles(directory = ".") {
67
- return this.execute(`ls -la ${directory}`);
68
- }
69
- async findFiles(pattern, directory = ".") {
70
- return this.execute(`find ${directory} -name "${pattern}" -type f`);
71
- }
72
- async grep(pattern, files = ".") {
73
- return this.execute(`grep -r "${pattern}" ${files}`);
74
- }
75
- }
76
- //# sourceMappingURL=bash.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bash.js","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,OAAO,QAAQ;IACX,gBAAgB,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,mBAAmB,GAAG,mBAAmB,CAAC,WAAW,EAAE,CAAC;IAEhE,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,UAAkB,KAAK;QACpD,IAAI,CAAC;YACH,oEAAoE;YACpE,MAAM,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,IAAI,CAAC,gBAAgB;gBAC1B,OAAO;gBACP,SAAS,EAAE,IAAI,GAAG,IAAI;aACvB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAE9D,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,2CAA2C;aACrE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,mBAAmB,KAAK,CAAC,OAAO,EAAE;aAC1C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,YAAoB,GAAG;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,SAAS,CACb,OAAe,EACf,YAAoB,GAAG;QAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,SAAS,WAAW,OAAO,WAAW,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAe,EAAE,QAAgB,GAAG;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -1,16 +0,0 @@
1
- import { ToolResult } from "../types/index";
2
- export interface ConfirmationRequest {
3
- operation: string;
4
- filename: string;
5
- description?: string;
6
- showVSCodeOpen?: boolean;
7
- autoAccept?: boolean;
8
- }
9
- export declare class ConfirmationTool {
10
- private confirmationService;
11
- constructor();
12
- requestConfirmation(request: ConfirmationRequest): Promise<ToolResult>;
13
- checkSessionAcceptance(): Promise<ToolResult>;
14
- resetSession(): void;
15
- isPending(): boolean;
16
- }
@@ -1,77 +0,0 @@
1
- import { ConfirmationService, } from "../utils/confirmation-service";
2
- export class ConfirmationTool {
3
- confirmationService;
4
- constructor() {
5
- this.confirmationService = ConfirmationService.getInstance();
6
- }
7
- async requestConfirmation(request) {
8
- try {
9
- // If autoAccept is true, skip the confirmation dialog
10
- if (request.autoAccept) {
11
- return {
12
- success: true,
13
- output: `Auto-accepted: ${request.operation}(${request.filename})${request.description ? ` - ${request.description}` : ""}`,
14
- };
15
- }
16
- const options = {
17
- operation: request.operation,
18
- filename: request.filename,
19
- showVSCodeOpen: request.showVSCodeOpen || false,
20
- };
21
- // Determine operation type based on operation name
22
- const operationType = request.operation.toLowerCase().includes("bash")
23
- ? "bash"
24
- : "file";
25
- const result = await this.confirmationService.requestConfirmation(options, operationType);
26
- if (result.confirmed) {
27
- return {
28
- success: true,
29
- output: `User confirmed: ${request.operation}(${request.filename})${request.description ? ` - ${request.description}` : ""}${result.dontAskAgain ? " (Don't ask again enabled)" : ""}`,
30
- };
31
- }
32
- else {
33
- return {
34
- success: false,
35
- error: result.feedback ||
36
- `User rejected: ${request.operation}(${request.filename})`,
37
- };
38
- }
39
- }
40
- catch (error) {
41
- return {
42
- success: false,
43
- error: `Confirmation error: ${error.message}`,
44
- };
45
- }
46
- }
47
- async checkSessionAcceptance() {
48
- try {
49
- const sessionFlags = this.confirmationService.getSessionFlags();
50
- // Return structured data without JSON output to avoid displaying raw JSON
51
- return {
52
- success: true,
53
- data: {
54
- fileOperationsAccepted: sessionFlags.fileOperations,
55
- bashCommandsAccepted: sessionFlags.bashCommands,
56
- allOperationsAccepted: sessionFlags.allOperations,
57
- hasAnyAcceptance: sessionFlags.fileOperations ||
58
- sessionFlags.bashCommands ||
59
- sessionFlags.allOperations,
60
- },
61
- };
62
- }
63
- catch (error) {
64
- return {
65
- success: false,
66
- error: `Error checking session acceptance: ${error.message}`,
67
- };
68
- }
69
- }
70
- resetSession() {
71
- this.confirmationService.resetSession();
72
- }
73
- isPending() {
74
- return this.confirmationService.isPending();
75
- }
76
- }
77
- //# sourceMappingURL=confirmation-tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"confirmation-tool.js","sourceRoot":"","sources":["../../src/tools/confirmation-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AAWvC,MAAM,OAAO,gBAAgB;IACnB,mBAAmB,CAAsB;IAEjD;QACE,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAA4B;QACpD,IAAI,CAAC;YACH,sDAAsD;YACtD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,kBAAkB,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;iBAC5H,CAAC;YACJ,CAAC;YAED,MAAM,OAAO,GAAwB;gBACnC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;aAChD,CAAC;YAEF,mDAAmD;YACnD,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACpE,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,MAAM,CAAC;YACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAC/D,OAAO,EACP,aAAa,CACd,CAAC;YAEF,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACrB,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,MAAM,EAA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IAC1C,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAC9C,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- export { BashTool } from "./bash";
2
- export { TextEditorTool } from "./text-editor";
3
- export { MorphEditorTool } from "./morph-editor";
4
- export { TodoTool } from "./todo-tool";
5
- export { ConfirmationTool } from "./confirmation-tool";
6
- export { SearchTool } from "./search";
@@ -1,7 +0,0 @@
1
- export { BashTool } from "./bash";
2
- export { TextEditorTool } from "./text-editor";
3
- export { MorphEditorTool } from "./morph-editor";
4
- export { TodoTool } from "./todo-tool";
5
- export { ConfirmationTool } from "./confirmation-tool";
6
- export { SearchTool } from "./search";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -1,36 +0,0 @@
1
- import { ToolResult } from "../types/index";
2
- export declare class MorphEditorTool {
3
- private confirmationService;
4
- private morphApiKey;
5
- private morphBaseUrl;
6
- constructor(apiKey?: string);
7
- /**
8
- * Use this tool to make an edit to an existing file.
9
- *
10
- * 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.
11
- * 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.
12
- *
13
- * For example:
14
- *
15
- * // ... existing code ...
16
- * FIRST_EDIT
17
- * // ... existing code ...
18
- * SECOND_EDIT
19
- * // ... existing code ...
20
- * THIRD_EDIT
21
- * // ... existing code ...
22
- *
23
- * You should still bias towards repeating as few lines of the original file as possible to convey the change.
24
- * But, each edit should contain sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
25
- * 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.
26
- * 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 ...```.
27
- * Make sure it is clear what the edit should be, and where it should be applied.
28
- * 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.
29
- */
30
- editFile(targetFile: string, instructions: string, codeEdit: string): Promise<ToolResult>;
31
- private callMorphApply;
32
- private generateDiff;
33
- view(filePath: string, viewRange?: [number, number]): Promise<ToolResult>;
34
- setApiKey(apiKey: string): void;
35
- getApiKey(): string;
36
- }
@@ -1,324 +0,0 @@
1
- import { ConfirmationService } from "../utils/confirmation-service";
2
- import * as path from "path";
3
- import fs from "fs-extra";
4
- import axios from "axios";
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 ||
108
- !response.data.choices[0] ||
109
- !response.data.choices[0].message) {
110
- throw new Error("Invalid response format from Morph API");
111
- }
112
- return response.data.choices[0].message.content;
113
- }
114
- catch (error) {
115
- if (error.response) {
116
- throw new Error(`Morph API error (${error.response.status}): ${error.response.data}`);
117
- }
118
- throw error;
119
- }
120
- }
121
- generateDiff(oldLines, newLines, filePath) {
122
- const CONTEXT_LINES = 3;
123
- const changes = [];
124
- let i = 0, j = 0;
125
- while (i < oldLines.length || j < newLines.length) {
126
- while (i < oldLines.length &&
127
- j < newLines.length &&
128
- oldLines[i] === newLines[j]) {
129
- i++;
130
- j++;
131
- }
132
- if (i < oldLines.length || j < newLines.length) {
133
- const changeStart = { old: i, new: j };
134
- let oldEnd = i;
135
- let newEnd = j;
136
- while (oldEnd < oldLines.length || newEnd < newLines.length) {
137
- let matchFound = false;
138
- let matchLength = 0;
139
- for (let k = 0; k < Math.min(2, oldLines.length - oldEnd, newLines.length - newEnd); k++) {
140
- if (oldEnd + k < oldLines.length &&
141
- newEnd + k < newLines.length &&
142
- oldLines[oldEnd + k] === newLines[newEnd + k]) {
143
- matchLength++;
144
- }
145
- else {
146
- break;
147
- }
148
- }
149
- if (matchLength >= 2 ||
150
- (oldEnd >= oldLines.length && newEnd >= newLines.length)) {
151
- matchFound = true;
152
- }
153
- if (matchFound) {
154
- break;
155
- }
156
- if (oldEnd < oldLines.length) {
157
- oldEnd++;
158
- }
159
- if (newEnd < newLines.length) {
160
- newEnd++;
161
- }
162
- }
163
- changes.push({
164
- oldStart: changeStart.old,
165
- oldEnd: oldEnd,
166
- newStart: changeStart.new,
167
- newEnd: newEnd,
168
- });
169
- i = oldEnd;
170
- j = newEnd;
171
- }
172
- }
173
- const hunks = [];
174
- let accumulatedOffset = 0;
175
- for (let changeIdx = 0; changeIdx < changes.length; changeIdx++) {
176
- const change = changes[changeIdx];
177
- let contextStart = Math.max(0, change.oldStart - CONTEXT_LINES);
178
- let contextEnd = Math.min(oldLines.length, change.oldEnd + CONTEXT_LINES);
179
- if (hunks.length > 0) {
180
- const lastHunk = hunks[hunks.length - 1];
181
- const lastHunkEnd = lastHunk.oldStart + lastHunk.oldCount;
182
- if (lastHunkEnd >= contextStart) {
183
- const oldHunkEnd = lastHunk.oldStart + lastHunk.oldCount;
184
- const newContextEnd = Math.min(oldLines.length, change.oldEnd + CONTEXT_LINES);
185
- for (let idx = oldHunkEnd; idx < change.oldStart; idx++) {
186
- lastHunk.lines.push({ type: " ", content: oldLines[idx] });
187
- }
188
- for (let idx = change.oldStart; idx < change.oldEnd; idx++) {
189
- lastHunk.lines.push({ type: "-", content: oldLines[idx] });
190
- }
191
- for (let idx = change.newStart; idx < change.newEnd; idx++) {
192
- lastHunk.lines.push({ type: "+", content: newLines[idx] });
193
- }
194
- for (let idx = change.oldEnd; idx < newContextEnd && idx < oldLines.length; idx++) {
195
- lastHunk.lines.push({ type: " ", content: oldLines[idx] });
196
- }
197
- lastHunk.oldCount = newContextEnd - lastHunk.oldStart;
198
- lastHunk.newCount =
199
- lastHunk.oldCount +
200
- (change.newEnd - change.newStart) -
201
- (change.oldEnd - change.oldStart);
202
- continue;
203
- }
204
- }
205
- const hunk = {
206
- oldStart: contextStart + 1,
207
- oldCount: contextEnd - contextStart,
208
- newStart: contextStart + 1 + accumulatedOffset,
209
- newCount: contextEnd -
210
- contextStart +
211
- (change.newEnd - change.newStart) -
212
- (change.oldEnd - change.oldStart),
213
- lines: [],
214
- };
215
- for (let idx = contextStart; idx < change.oldStart; idx++) {
216
- hunk.lines.push({ type: " ", content: oldLines[idx] });
217
- }
218
- for (let idx = change.oldStart; idx < change.oldEnd; idx++) {
219
- hunk.lines.push({ type: "-", content: oldLines[idx] });
220
- }
221
- for (let idx = change.newStart; idx < change.newEnd; idx++) {
222
- hunk.lines.push({ type: "+", content: newLines[idx] });
223
- }
224
- for (let idx = change.oldEnd; idx < contextEnd && idx < oldLines.length; idx++) {
225
- hunk.lines.push({ type: " ", content: oldLines[idx] });
226
- }
227
- hunks.push(hunk);
228
- accumulatedOffset +=
229
- change.newEnd - change.newStart - (change.oldEnd - change.oldStart);
230
- }
231
- let addedLines = 0;
232
- let removedLines = 0;
233
- for (const hunk of hunks) {
234
- for (const line of hunk.lines) {
235
- if (line.type === "+") {
236
- addedLines++;
237
- }
238
- if (line.type === "-") {
239
- removedLines++;
240
- }
241
- }
242
- }
243
- let summary = `Updated ${filePath} with Morph Fast Apply`;
244
- if (addedLines > 0 && removedLines > 0) {
245
- summary += ` - ${addedLines} addition${addedLines !== 1 ? "s" : ""} and ${removedLines} removal${removedLines !== 1 ? "s" : ""}`;
246
- }
247
- else if (addedLines > 0) {
248
- summary += ` - ${addedLines} addition${addedLines !== 1 ? "s" : ""}`;
249
- }
250
- else if (removedLines > 0) {
251
- summary += ` - ${removedLines} removal${removedLines !== 1 ? "s" : ""}`;
252
- }
253
- else if (changes.length === 0) {
254
- return `No changes applied to ${filePath}`;
255
- }
256
- let diff = summary + "\n";
257
- diff += `--- a/${filePath}\n`;
258
- diff += `+++ b/${filePath}\n`;
259
- for (const hunk of hunks) {
260
- diff += `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@\n`;
261
- for (const line of hunk.lines) {
262
- diff += `${line.type}${line.content}\n`;
263
- }
264
- }
265
- return diff.trim();
266
- }
267
- async view(filePath, viewRange) {
268
- try {
269
- const resolvedPath = path.resolve(filePath);
270
- if (await fs.pathExists(resolvedPath)) {
271
- const stats = await fs.stat(resolvedPath);
272
- if (stats.isDirectory()) {
273
- const files = await fs.readdir(resolvedPath);
274
- return {
275
- success: true,
276
- output: `Directory contents of ${filePath}:\n${files.join("\n")}`,
277
- };
278
- }
279
- const content = await fs.readFile(resolvedPath, "utf-8");
280
- const lines = content.split("\n");
281
- if (viewRange) {
282
- const [start, end] = viewRange;
283
- const selectedLines = lines.slice(start - 1, end);
284
- const numberedLines = selectedLines
285
- .map((line, idx) => `${start + idx}: ${line}`)
286
- .join("\n");
287
- return {
288
- success: true,
289
- output: `Lines ${start}-${end} of ${filePath}:\n${numberedLines}`,
290
- };
291
- }
292
- const totalLines = lines.length;
293
- const displayLines = totalLines > 10 ? lines.slice(0, 10) : lines;
294
- const numberedLines = displayLines
295
- .map((line, idx) => `${idx + 1}: ${line}`)
296
- .join("\n");
297
- const additionalLinesMessage = totalLines > 10 ? `\n... +${totalLines - 10} lines` : "";
298
- return {
299
- success: true,
300
- output: `Contents of ${filePath}:\n${numberedLines}${additionalLinesMessage}`,
301
- };
302
- }
303
- else {
304
- return {
305
- success: false,
306
- error: `File or directory not found: ${filePath}`,
307
- };
308
- }
309
- }
310
- catch (error) {
311
- return {
312
- success: false,
313
- error: `Error viewing ${filePath}: ${error.message}`,
314
- };
315
- }
316
- }
317
- setApiKey(apiKey) {
318
- this.morphApiKey = apiKey;
319
- }
320
- getApiKey() {
321
- return this.morphApiKey;
322
- }
323
- }
324
- //# 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,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,IA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AAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;gBAClE,MAAM,aAAa,GAAG,YAAY;qBAC/B,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,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,69 +0,0 @@
1
- import { ToolResult } from "../types/index";
2
- export interface SearchResult {
3
- file: string;
4
- line: number;
5
- column: number;
6
- text: string;
7
- match: string;
8
- }
9
- export interface FileSearchResult {
10
- path: string;
11
- name: string;
12
- score: number;
13
- }
14
- export interface UnifiedSearchResult {
15
- type: "text" | "file";
16
- file: string;
17
- line?: number;
18
- column?: number;
19
- text?: string;
20
- match?: string;
21
- score?: number;
22
- }
23
- export declare class SearchTool {
24
- private confirmationService;
25
- private currentDirectory;
26
- /**
27
- * Unified search method that can search for text content or find files
28
- */
29
- search(query: string, options?: {
30
- searchType?: "text" | "files" | "both";
31
- includePattern?: string;
32
- excludePattern?: string;
33
- caseSensitive?: boolean;
34
- wholeWord?: boolean;
35
- regex?: boolean;
36
- maxResults?: number;
37
- fileTypes?: string[];
38
- excludeFiles?: string[];
39
- includeHidden?: boolean;
40
- }): Promise<ToolResult>;
41
- /**
42
- * Execute ripgrep command with specified options
43
- */
44
- private executeRipgrep;
45
- /**
46
- * Parse ripgrep JSON output into SearchResult objects
47
- */
48
- private parseRipgrepOutput;
49
- /**
50
- * Find files by pattern using a simple file walking approach
51
- */
52
- private findFilesByPattern;
53
- /**
54
- * Calculate fuzzy match score for file names
55
- */
56
- private calculateFileScore;
57
- /**
58
- * Format unified search results for display
59
- */
60
- private formatUnifiedResults;
61
- /**
62
- * Update current working directory
63
- */
64
- setCurrentDirectory(directory: string): void;
65
- /**
66
- * Get current working directory
67
- */
68
- getCurrentDirectory(): string;
69
- }