@link-assistant/agent 0.0.9 → 0.0.12

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 (104) hide show
  1. package/EXAMPLES.md +36 -0
  2. package/MODELS.md +72 -24
  3. package/README.md +59 -2
  4. package/TOOLS.md +20 -0
  5. package/package.json +35 -2
  6. package/src/agent/agent.ts +68 -54
  7. package/src/auth/claude-oauth.ts +426 -0
  8. package/src/auth/index.ts +28 -26
  9. package/src/auth/plugins.ts +876 -0
  10. package/src/bun/index.ts +53 -43
  11. package/src/bus/global.ts +5 -5
  12. package/src/bus/index.ts +59 -53
  13. package/src/cli/bootstrap.js +12 -12
  14. package/src/cli/bootstrap.ts +6 -6
  15. package/src/cli/cmd/agent.ts +97 -92
  16. package/src/cli/cmd/auth.ts +469 -0
  17. package/src/cli/cmd/cmd.ts +2 -2
  18. package/src/cli/cmd/export.ts +41 -41
  19. package/src/cli/cmd/mcp.ts +144 -119
  20. package/src/cli/cmd/models.ts +30 -29
  21. package/src/cli/cmd/run.ts +269 -213
  22. package/src/cli/cmd/stats.ts +185 -146
  23. package/src/cli/error.ts +17 -13
  24. package/src/cli/ui.ts +39 -24
  25. package/src/command/index.ts +26 -26
  26. package/src/config/config.ts +528 -288
  27. package/src/config/markdown.ts +15 -15
  28. package/src/file/ripgrep.ts +201 -169
  29. package/src/file/time.ts +21 -18
  30. package/src/file/watcher.ts +51 -42
  31. package/src/file.ts +1 -1
  32. package/src/flag/flag.ts +26 -11
  33. package/src/format/formatter.ts +206 -162
  34. package/src/format/index.ts +61 -61
  35. package/src/global/index.ts +21 -21
  36. package/src/id/id.ts +47 -33
  37. package/src/index.js +346 -199
  38. package/src/json-standard/index.ts +67 -51
  39. package/src/mcp/index.ts +135 -128
  40. package/src/patch/index.ts +336 -267
  41. package/src/project/bootstrap.ts +15 -15
  42. package/src/project/instance.ts +43 -36
  43. package/src/project/project.ts +47 -47
  44. package/src/project/state.ts +37 -33
  45. package/src/provider/models-macro.ts +5 -5
  46. package/src/provider/models.ts +32 -32
  47. package/src/provider/opencode.js +19 -19
  48. package/src/provider/provider.ts +518 -277
  49. package/src/provider/transform.ts +143 -102
  50. package/src/server/project.ts +21 -21
  51. package/src/server/server.ts +111 -105
  52. package/src/session/agent.js +66 -60
  53. package/src/session/compaction.ts +136 -111
  54. package/src/session/index.ts +189 -156
  55. package/src/session/message-v2.ts +312 -268
  56. package/src/session/message.ts +73 -57
  57. package/src/session/processor.ts +180 -166
  58. package/src/session/prompt.ts +678 -533
  59. package/src/session/retry.ts +26 -23
  60. package/src/session/revert.ts +76 -62
  61. package/src/session/status.ts +26 -26
  62. package/src/session/summary.ts +97 -76
  63. package/src/session/system.ts +77 -63
  64. package/src/session/todo.ts +22 -16
  65. package/src/snapshot/index.ts +92 -76
  66. package/src/storage/storage.ts +157 -120
  67. package/src/tool/bash.ts +116 -106
  68. package/src/tool/batch.ts +73 -59
  69. package/src/tool/codesearch.ts +60 -53
  70. package/src/tool/edit.ts +319 -263
  71. package/src/tool/glob.ts +32 -28
  72. package/src/tool/grep.ts +72 -53
  73. package/src/tool/invalid.ts +7 -7
  74. package/src/tool/ls.ts +77 -64
  75. package/src/tool/multiedit.ts +30 -21
  76. package/src/tool/patch.ts +121 -94
  77. package/src/tool/read.ts +140 -122
  78. package/src/tool/registry.ts +38 -38
  79. package/src/tool/task.ts +93 -60
  80. package/src/tool/todo.ts +16 -16
  81. package/src/tool/tool.ts +45 -36
  82. package/src/tool/webfetch.ts +97 -74
  83. package/src/tool/websearch.ts +78 -64
  84. package/src/tool/write.ts +21 -15
  85. package/src/util/binary.ts +27 -19
  86. package/src/util/context.ts +8 -8
  87. package/src/util/defer.ts +7 -5
  88. package/src/util/error.ts +24 -19
  89. package/src/util/eventloop.ts +16 -10
  90. package/src/util/filesystem.ts +37 -33
  91. package/src/util/fn.ts +11 -8
  92. package/src/util/iife.ts +1 -1
  93. package/src/util/keybind.ts +44 -44
  94. package/src/util/lazy.ts +7 -7
  95. package/src/util/locale.ts +20 -16
  96. package/src/util/lock.ts +43 -38
  97. package/src/util/log.ts +95 -85
  98. package/src/util/queue.ts +8 -8
  99. package/src/util/rpc.ts +35 -23
  100. package/src/util/scrap.ts +4 -4
  101. package/src/util/signal.ts +5 -5
  102. package/src/util/timeout.ts +6 -6
  103. package/src/util/token.ts +2 -2
  104. package/src/util/wildcard.ts +38 -27
@@ -1,44 +1,44 @@
1
- import z from "zod"
2
- import { Tool } from "./tool"
3
- import DESCRIPTION from "./codesearch.txt"
1
+ import z from 'zod';
2
+ import { Tool } from './tool';
3
+ import DESCRIPTION from './codesearch.txt';
4
4
 
5
5
  const API_CONFIG = {
6
- BASE_URL: "https://mcp.exa.ai",
6
+ BASE_URL: 'https://mcp.exa.ai',
7
7
  ENDPOINTS: {
8
- CONTEXT: "/mcp",
8
+ CONTEXT: '/mcp',
9
9
  },
10
- } as const
10
+ } as const;
11
11
 
12
12
  interface McpCodeRequest {
13
- jsonrpc: string
14
- id: number
15
- method: string
13
+ jsonrpc: string;
14
+ id: number;
15
+ method: string;
16
16
  params: {
17
- name: string
17
+ name: string;
18
18
  arguments: {
19
- query: string
20
- tokensNum: number
21
- }
22
- }
19
+ query: string;
20
+ tokensNum: number;
21
+ };
22
+ };
23
23
  }
24
24
 
25
25
  interface McpCodeResponse {
26
- jsonrpc: string
26
+ jsonrpc: string;
27
27
  result: {
28
28
  content: Array<{
29
- type: string
30
- text: string
31
- }>
32
- }
29
+ type: string;
30
+ text: string;
31
+ }>;
32
+ };
33
33
  }
34
34
 
35
- export const CodeSearchTool = Tool.define("codesearch", {
35
+ export const CodeSearchTool = Tool.define('codesearch', {
36
36
  description: DESCRIPTION,
37
37
  parameters: z.object({
38
38
  query: z
39
39
  .string()
40
40
  .describe(
41
- "Search query to find relevant context for APIs, Libraries, and SDKs. For example, 'React useState hook examples', 'Python pandas dataframe filtering', 'Express.js middleware', 'Next js partial prerendering configuration'",
41
+ "Search query to find relevant context for APIs, Libraries, and SDKs. For example, 'React useState hook examples', 'Python pandas dataframe filtering', 'Express.js middleware', 'Next js partial prerendering configuration'"
42
42
  ),
43
43
  tokensNum: z
44
44
  .number()
@@ -46,78 +46,85 @@ export const CodeSearchTool = Tool.define("codesearch", {
46
46
  .max(50000)
47
47
  .default(5000)
48
48
  .describe(
49
- "Number of tokens to return (1000-50000). Default is 5000 tokens. Adjust this value based on how much context you need - use lower values for focused queries and higher values for comprehensive documentation.",
49
+ 'Number of tokens to return (1000-50000). Default is 5000 tokens. Adjust this value based on how much context you need - use lower values for focused queries and higher values for comprehensive documentation.'
50
50
  ),
51
51
  }),
52
52
  async execute(params, ctx) {
53
53
  // No restrictions - unrestricted code search
54
54
  const codeRequest: McpCodeRequest = {
55
- jsonrpc: "2.0",
55
+ jsonrpc: '2.0',
56
56
  id: 1,
57
- method: "tools/call",
57
+ method: 'tools/call',
58
58
  params: {
59
- name: "get_code_context_exa",
59
+ name: 'get_code_context_exa',
60
60
  arguments: {
61
61
  query: params.query,
62
62
  tokensNum: params.tokensNum || 5000,
63
63
  },
64
64
  },
65
- }
65
+ };
66
66
 
67
- const controller = new AbortController()
68
- const timeoutId = setTimeout(() => controller.abort(), 30000)
67
+ const controller = new AbortController();
68
+ const timeoutId = setTimeout(() => controller.abort(), 30000);
69
69
 
70
70
  try {
71
71
  const headers: Record<string, string> = {
72
- accept: "application/json, text/event-stream",
73
- "content-type": "application/json",
74
- }
72
+ accept: 'application/json, text/event-stream',
73
+ 'content-type': 'application/json',
74
+ };
75
75
 
76
- const response = await fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.CONTEXT}`, {
77
- method: "POST",
78
- headers,
79
- body: JSON.stringify(codeRequest),
80
- signal: AbortSignal.any([controller.signal, ctx.abort]),
81
- })
76
+ const response = await fetch(
77
+ `${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.CONTEXT}`,
78
+ {
79
+ method: 'POST',
80
+ headers,
81
+ body: JSON.stringify(codeRequest),
82
+ signal: AbortSignal.any([controller.signal, ctx.abort]),
83
+ }
84
+ );
82
85
 
83
- clearTimeout(timeoutId)
86
+ clearTimeout(timeoutId);
84
87
 
85
88
  if (!response.ok) {
86
- const errorText = await response.text()
87
- throw new Error(`Code search error (${response.status}): ${errorText}`)
89
+ const errorText = await response.text();
90
+ throw new Error(`Code search error (${response.status}): ${errorText}`);
88
91
  }
89
92
 
90
- const responseText = await response.text()
93
+ const responseText = await response.text();
91
94
 
92
95
  // Parse SSE response
93
- const lines = responseText.split("\n")
96
+ const lines = responseText.split('\n');
94
97
  for (const line of lines) {
95
- if (line.startsWith("data: ")) {
96
- const data: McpCodeResponse = JSON.parse(line.substring(6))
97
- if (data.result && data.result.content && data.result.content.length > 0) {
98
+ if (line.startsWith('data: ')) {
99
+ const data: McpCodeResponse = JSON.parse(line.substring(6));
100
+ if (
101
+ data.result &&
102
+ data.result.content &&
103
+ data.result.content.length > 0
104
+ ) {
98
105
  return {
99
106
  output: data.result.content[0].text,
100
107
  title: `Code search: ${params.query}`,
101
108
  metadata: {},
102
- }
109
+ };
103
110
  }
104
111
  }
105
112
  }
106
113
 
107
114
  return {
108
115
  output:
109
- "No code snippets or documentation found. Please try a different query, be more specific about the library or programming concept, or check the spelling of framework names.",
116
+ 'No code snippets or documentation found. Please try a different query, be more specific about the library or programming concept, or check the spelling of framework names.',
110
117
  title: `Code search: ${params.query}`,
111
118
  metadata: {},
112
- }
119
+ };
113
120
  } catch (error) {
114
- clearTimeout(timeoutId)
121
+ clearTimeout(timeoutId);
115
122
 
116
- if (error instanceof Error && error.name === "AbortError") {
117
- throw new Error("Code search request timed out")
123
+ if (error instanceof Error && error.name === 'AbortError') {
124
+ throw new Error('Code search request timed out');
118
125
  }
119
126
 
120
- throw error
127
+ throw error;
121
128
  }
122
129
  },
123
- })
130
+ });