@thegitai/cli 1.0.0-preview.3 → 1.0.0-preview.31

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 (58) hide show
  1. package/README.md +39 -6
  2. package/dist/bin/ai.js +142 -383
  3. package/dist/src/agent-mode.js +1 -6
  4. package/dist/src/api/auth.js +6 -4
  5. package/dist/src/api/browser-login.js +152 -37
  6. package/dist/src/api/chat.js +258 -38
  7. package/dist/src/api/contracts.js +55 -1
  8. package/dist/src/api/default-host.js +1 -0
  9. package/dist/src/api/http.js +69 -7
  10. package/dist/src/api/models.js +19 -10
  11. package/dist/src/background-jobs.js +2 -2
  12. package/dist/src/cli-args.js +19 -5
  13. package/dist/src/core/clipboard.js +7 -13
  14. package/dist/src/core/image-limits.js +56 -0
  15. package/dist/src/core/image-path-extractor.js +70 -3
  16. package/dist/src/core/session-image-store.js +199 -0
  17. package/dist/src/executor.js +25 -3
  18. package/dist/src/help-text.js +67 -18
  19. package/dist/src/permissions.js +243 -0
  20. package/dist/src/session-safety.js +0 -12
  21. package/dist/src/session-store.js +121 -20
  22. package/dist/src/session.js +14 -3
  23. package/dist/src/signin.js +58 -0
  24. package/dist/src/tool-executor.js +11 -46
  25. package/dist/src/tools/delete-file.js +15 -3
  26. package/dist/src/tools/index.js +13 -10
  27. package/dist/src/tools/patch-file.js +12 -26
  28. package/dist/src/tools/read-image-file.js +85 -0
  29. package/dist/src/tools/replace-document-text.js +28 -18
  30. package/dist/src/tools/restore-checkpoint.js +0 -1
  31. package/dist/src/tools/run-command.js +14 -71
  32. package/dist/src/tools/run-node-script.js +12 -81
  33. package/dist/src/tools/save-generated-image.js +120 -0
  34. package/dist/src/tools/str-replace.js +12 -26
  35. package/dist/src/tools/undo-edit.js +1 -6
  36. package/dist/src/tools/write-file.js +67 -11
  37. package/dist/src/turn-failure-marker.js +11 -0
  38. package/dist/src/ui/prompt-history-store.js +1 -1
  39. package/dist/src/ui/repl.js +649 -164
  40. package/dist/src/ui/tui/bridge.js +10 -0
  41. package/dist/src/ui/tui/build-frame.js +453 -115
  42. package/dist/src/ui/tui/markdown-render.js +81 -73
  43. package/dist/src/ui/tui/shell-input.js +206 -63
  44. package/dist/src/ui/tui/terminal-theme.js +28 -0
  45. package/dist/src/ui/tui/terminal-title.js +3 -0
  46. package/dist/src/ui/tui/terminal-writes.js +48 -0
  47. package/dist/src/ui/tui/text.js +158 -4
  48. package/dist/src/ui/tui/user-input.js +568 -0
  49. package/dist/src/utils.js +9 -0
  50. package/package.json +29 -6
  51. package/dist/src/markdown-renderer.js +0 -112
  52. package/dist/src/project-index.js +0 -221
  53. package/dist/src/tools/code-intel.js +0 -472
  54. package/dist/src/tools/find-symbol.js +0 -70
  55. package/dist/src/tools/hover-symbol.js +0 -95
  56. package/dist/src/tools/list-symbols.js +0 -55
  57. package/dist/src/tools/search-code.js +0 -37
  58. package/dist/src/tools/signature-help.js +0 -118
@@ -1,37 +0,0 @@
1
- import { formatIndexResults, searchIndex, } from '../project-index.js';
2
- import { clampInteger } from '../utils.js';
3
- export async function searchCode(projectIndex, args) {
4
- const query = String(args.query ?? '').trim();
5
- if (!query) {
6
- return { ok: false, error: 'query is required' };
7
- }
8
- const limit = clampInteger(args.limit, 5, 20);
9
- let searchResult;
10
- try {
11
- searchResult = await searchIndex(projectIndex, query, limit);
12
- }
13
- catch (error) {
14
- const message = error instanceof Error ? error.message : String(error);
15
- if (/semantic index/i.test(message)) {
16
- return {
17
- ok: false,
18
- skipped: true,
19
- failureCategory: 'tool_exception',
20
- failureDetails: {
21
- category: 'tool_exception',
22
- tool: 'search_code',
23
- action: 'Search is temporarily unavailable.',
24
- },
25
- error: 'Search is temporarily unavailable.',
26
- };
27
- }
28
- throw error;
29
- }
30
- const { results, retrievalTokensUsed } = searchResult;
31
- return {
32
- ok: true,
33
- query,
34
- results: formatIndexResults(results),
35
- retrievalTokensUsed,
36
- };
37
- }
@@ -1,118 +0,0 @@
1
- import { readProjectText, searchTextMatches } from './code-intel.js';
2
- const SIGNATURE_PATTERNS = [
3
- /(?:pub\s+)?(?:async\s+)?fn\s+(\w+)\s*(?:<[^>]*>\s*)?\([^)]*\)/,
4
- /func\s+(?:\([^)]+\)\s+)?(\w+)\s*\([^)]*\)/,
5
- /(?:async\s+)?def\s+(\w+)\s*\([^)]*\)/,
6
- /(?:export\s+)?(?:async\s+)?function\s*\*?\s+(\w+)\s*(?:<[^>]*>\s*)?\([^)]*\)/,
7
- /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*[^=]+)?\s*=\s*(?:async\s+)?(?:\([^)]*\)|[^=])\s*=>/,
8
- ];
9
- function extractCalledFunction(content, line, column) {
10
- const lines = content.split('\n');
11
- if (line < 1 || line > lines.length)
12
- return null;
13
- const text = lines[line - 1];
14
- const prefix = text.slice(0, column);
15
- const m = prefix.match(/(\w+)\s*\(\s*[^)]*$/);
16
- if (m)
17
- return m[1];
18
- if (line > 1) {
19
- const prevLine = lines[line - 2];
20
- const pm = prevLine.match(/(\w+)\s*\(\s*$/);
21
- if (pm)
22
- return pm[1];
23
- }
24
- return null;
25
- }
26
- async function findSignature(rootDir, funcName) {
27
- const matches = await searchTextMatches(rootDir, funcName, { limit: 40 });
28
- for (const match of matches) {
29
- for (const pattern of SIGNATURE_PATTERNS) {
30
- const sigMatch = match.content.match(pattern);
31
- if (sigMatch && sigMatch[1] === funcName) {
32
- return extractFullSignature(rootDir, match.filePath, match.line);
33
- }
34
- }
35
- }
36
- return null;
37
- }
38
- function extractFullSignature(rootDir, filePath, lineNum) {
39
- let fileContent;
40
- try {
41
- fileContent = readProjectText(rootDir, filePath);
42
- }
43
- catch {
44
- return null;
45
- }
46
- const lines = fileContent.split('\n');
47
- const startIdx = lineNum - 1;
48
- if (startIdx >= lines.length)
49
- return null;
50
- const signatureLines = [];
51
- let openParens = 0;
52
- let foundOpen = false;
53
- for (let i = startIdx; i < Math.min(lines.length, startIdx + 20); i++) {
54
- signatureLines.push(lines[i]);
55
- for (const ch of lines[i]) {
56
- if (ch === '(') {
57
- openParens++;
58
- foundOpen = true;
59
- }
60
- else if (ch === ')')
61
- openParens--;
62
- }
63
- if (foundOpen && openParens <= 0)
64
- break;
65
- }
66
- const signature = signatureLines.join('\n');
67
- const bodyStart = signature.match(/\)\s*(?:->.*?)?\s*[{:]/) ??
68
- signature.match(/\)\s*[{:]/) ??
69
- signature.match(/\)\s*$/m);
70
- const display = bodyStart
71
- ? signature
72
- .slice(0, bodyStart.index + bodyStart[0].length)
73
- .replace(/\s*[{:]\s*$/, '')
74
- : signature;
75
- return `${filePath}:${lineNum}\n\`\`\`\n${display.trim()}\n\`\`\``;
76
- }
77
- export async function getSignatureHelp(context, args) {
78
- const filePath = String(args.filePath ?? '').trim();
79
- const line = Number(args.line ?? 0);
80
- const column = Number(args.column ?? 0);
81
- if (!filePath || !line || !column) {
82
- return {
83
- ok: false,
84
- error: 'signature_help requires filePath, line, and column.',
85
- };
86
- }
87
- let content;
88
- try {
89
- content = readProjectText(context.rootDir, filePath);
90
- }
91
- catch {
92
- return { ok: false, error: `Could not read ${filePath}.` };
93
- }
94
- const funcName = extractCalledFunction(content, line, column);
95
- if (!funcName) {
96
- return {
97
- ok: false,
98
- error: 'No function call found at the given position. Use hover_symbol or read_file.',
99
- };
100
- }
101
- const signature = await findSignature(context.rootDir, funcName);
102
- if (!signature) {
103
- return {
104
- ok: false,
105
- error: `Could not find definition for "${funcName}". Use find_symbol or grep_code.`,
106
- };
107
- }
108
- return {
109
- ok: true,
110
- provider: 'text_search',
111
- available: true,
112
- filePath,
113
- line,
114
- column,
115
- functionName: funcName,
116
- output: signature,
117
- };
118
- }