saeeol 1.2.1 → 1.2.3

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 (151) hide show
  1. package/bin/saeeol.cjs +187 -0
  2. package/npm/bin/saeeol +0 -0
  3. package/package.json +12 -12
  4. package/src/cli/cmd/tui/component/dialog/dialog-agent.tsx +32 -0
  5. package/src/cli/cmd/tui/component/dialog/dialog-command.tsx +190 -0
  6. package/src/cli/cmd/tui/component/dialog/dialog-console-org.tsx +103 -0
  7. package/src/cli/cmd/tui/component/dialog/dialog-go-upsell.tsx +159 -0
  8. package/src/cli/cmd/tui/component/dialog/dialog-mcp.tsx +86 -0
  9. package/src/cli/cmd/tui/component/dialog/dialog-model.tsx +238 -0
  10. package/src/cli/cmd/tui/component/dialog/dialog-provider.tsx +343 -0
  11. package/src/cli/cmd/tui/component/dialog/dialog-session-delete-failed.tsx +103 -0
  12. package/src/cli/cmd/tui/component/dialog/dialog-session-list.tsx +301 -0
  13. package/src/cli/cmd/tui/component/dialog/dialog-session-rename.tsx +35 -0
  14. package/src/cli/cmd/tui/component/dialog/dialog-skill.tsx +37 -0
  15. package/src/cli/cmd/tui/component/dialog/dialog-stash.tsx +87 -0
  16. package/src/cli/cmd/tui/component/dialog/dialog-status.tsx +190 -0
  17. package/src/cli/cmd/tui/component/dialog/dialog-tag.tsx +44 -0
  18. package/src/cli/cmd/tui/component/dialog/dialog-theme-list.tsx +50 -0
  19. package/src/cli/cmd/tui/component/dialog/dialog-variant.tsx +39 -0
  20. package/src/cli/cmd/tui/component/dialog/dialog-workspace-create.tsx +200 -0
  21. package/src/cli/cmd/tui/component/dialog/dialog-workspace-unavailable.tsx +81 -0
  22. package/src/cli/cmd/tui/component/dialog-agent.tsx +1 -32
  23. package/src/cli/cmd/tui/component/dialog-command.tsx +1 -190
  24. package/src/cli/cmd/tui/component/dialog-console-org.tsx +1 -103
  25. package/src/cli/cmd/tui/component/dialog-go-upsell.tsx +1 -159
  26. package/src/cli/cmd/tui/component/dialog-mcp.tsx +1 -86
  27. package/src/cli/cmd/tui/component/dialog-model.tsx +1 -238
  28. package/src/cli/cmd/tui/component/dialog-provider.tsx +1 -343
  29. package/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx +1 -103
  30. package/src/cli/cmd/tui/component/dialog-session-list.tsx +1 -301
  31. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +1 -35
  32. package/src/cli/cmd/tui/component/dialog-skill.tsx +1 -37
  33. package/src/cli/cmd/tui/component/dialog-stash.tsx +1 -87
  34. package/src/cli/cmd/tui/component/dialog-status.tsx +1 -190
  35. package/src/cli/cmd/tui/component/dialog-tag.tsx +1 -44
  36. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +1 -50
  37. package/src/cli/cmd/tui/component/dialog-variant.tsx +1 -39
  38. package/src/cli/cmd/tui/component/dialog-workspace-create.tsx +1 -200
  39. package/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx +1 -81
  40. package/src/cli/cmd/tui/context/app/args.tsx +15 -0
  41. package/src/cli/cmd/tui/context/app/directory.ts +15 -0
  42. package/src/cli/cmd/tui/context/app/editor-zed.ts +281 -0
  43. package/src/cli/cmd/tui/context/app/editor.ts +425 -0
  44. package/src/cli/cmd/tui/context/app/helper.tsx +25 -0
  45. package/src/cli/cmd/tui/context/app/project.tsx +109 -0
  46. package/src/cli/cmd/tui/context/app/route.tsx +67 -0
  47. package/src/cli/cmd/tui/context/app/sdk.tsx +142 -0
  48. package/src/cli/cmd/tui/context/app/sync.tsx +713 -0
  49. package/src/cli/cmd/tui/context/app/theme.tsx +307 -0
  50. package/src/cli/cmd/tui/context/app/tui-config.tsx +9 -0
  51. package/src/cli/cmd/tui/context/args.tsx +1 -15
  52. package/src/cli/cmd/tui/context/directory.ts +1 -15
  53. package/src/cli/cmd/tui/context/editor-zed.ts +1 -281
  54. package/src/cli/cmd/tui/context/editor.ts +1 -425
  55. package/src/cli/cmd/tui/context/event.ts +1 -45
  56. package/src/cli/cmd/tui/context/exit.tsx +1 -67
  57. package/src/cli/cmd/tui/context/helper.tsx +1 -25
  58. package/src/cli/cmd/tui/context/keybind.tsx +1 -105
  59. package/src/cli/cmd/tui/context/kv.tsx +1 -76
  60. package/src/cli/cmd/tui/context/local.tsx +1 -478
  61. package/src/cli/cmd/tui/context/plugin-keybinds.ts +1 -41
  62. package/src/cli/cmd/tui/context/project.tsx +1 -109
  63. package/src/cli/cmd/tui/context/prompt.tsx +1 -18
  64. package/src/cli/cmd/tui/context/route.tsx +1 -67
  65. package/src/cli/cmd/tui/context/runtime/event.ts +45 -0
  66. package/src/cli/cmd/tui/context/runtime/exit.tsx +67 -0
  67. package/src/cli/cmd/tui/context/runtime/keybind.tsx +105 -0
  68. package/src/cli/cmd/tui/context/runtime/kv.tsx +76 -0
  69. package/src/cli/cmd/tui/context/runtime/local.tsx +478 -0
  70. package/src/cli/cmd/tui/context/runtime/plugin-keybinds.ts +41 -0
  71. package/src/cli/cmd/tui/context/sdk.tsx +1 -142
  72. package/src/cli/cmd/tui/context/session/prompt.tsx +18 -0
  73. package/src/cli/cmd/tui/context/sync.tsx +1 -713
  74. package/src/cli/cmd/tui/context/theme.tsx +1 -307
  75. package/src/cli/cmd/tui/context/tui-config.tsx +1 -9
  76. package/src/tool/apply_patch.ts +1 -334
  77. package/src/tool/bash.ts +1 -656
  78. package/src/tool/core/external-directory.ts +55 -0
  79. package/src/tool/core/invalid.ts +21 -0
  80. package/src/tool/core/recall.ts +164 -0
  81. package/src/tool/core/recall.txt +12 -0
  82. package/src/tool/core/schema.ts +16 -0
  83. package/src/tool/core/tool.ts +162 -0
  84. package/src/tool/core/truncate.ts +160 -0
  85. package/src/tool/core/truncation-dir.ts +4 -0
  86. package/src/tool/diagnostics.ts +1 -20
  87. package/src/tool/edit-replacers.ts +1 -288
  88. package/src/tool/edit-utils.ts +1 -86
  89. package/src/tool/edit.ts +1 -262
  90. package/src/tool/external-directory.ts +1 -55
  91. package/src/tool/file/apply_patch.ts +334 -0
  92. package/src/tool/file/apply_patch.txt +33 -0
  93. package/src/tool/file/bash.ts +656 -0
  94. package/src/tool/file/bash.txt +119 -0
  95. package/src/tool/file/edit-replacers.ts +288 -0
  96. package/src/tool/file/edit-utils.ts +86 -0
  97. package/src/tool/file/edit.ts +262 -0
  98. package/src/tool/file/edit.txt +10 -0
  99. package/src/tool/file/read.ts +389 -0
  100. package/src/tool/file/read.txt +14 -0
  101. package/src/tool/file/write.ts +114 -0
  102. package/src/tool/file/write.txt +8 -0
  103. package/src/tool/glob.ts +1 -115
  104. package/src/tool/grep.ts +1 -151
  105. package/src/tool/integration/diagnostics.ts +20 -0
  106. package/src/tool/integration/lsp.ts +113 -0
  107. package/src/tool/integration/lsp.txt +24 -0
  108. package/src/tool/integration/mcp-exa.ts +73 -0
  109. package/src/tool/integration/package.ts +168 -0
  110. package/src/tool/integration/registry.ts +375 -0
  111. package/src/tool/invalid.ts +1 -21
  112. package/src/tool/lsp.ts +1 -113
  113. package/src/tool/mcp-exa.ts +1 -73
  114. package/src/tool/package.ts +1 -168
  115. package/src/tool/plan.ts +1 -30
  116. package/src/tool/question.ts +1 -52
  117. package/src/tool/read.ts +1 -389
  118. package/src/tool/recall.ts +1 -164
  119. package/src/tool/registry.ts +1 -375
  120. package/src/tool/schema.ts +1 -16
  121. package/src/tool/search/glob.ts +115 -0
  122. package/src/tool/search/glob.txt +6 -0
  123. package/src/tool/search/grep.ts +151 -0
  124. package/src/tool/search/grep.txt +8 -0
  125. package/src/tool/search/warpgrep.ts +107 -0
  126. package/src/tool/search/warpgrep.txt +10 -0
  127. package/src/tool/search/webfetch.ts +202 -0
  128. package/src/tool/search/webfetch.txt +13 -0
  129. package/src/tool/search/websearch.ts +71 -0
  130. package/src/tool/search/websearch.txt +14 -0
  131. package/src/tool/skill.ts +1 -91
  132. package/src/tool/task.ts +1 -197
  133. package/src/tool/todo.ts +1 -62
  134. package/src/tool/tool.ts +1 -162
  135. package/src/tool/truncate.ts +1 -160
  136. package/src/tool/truncation-dir.ts +1 -4
  137. package/src/tool/warpgrep.ts +1 -107
  138. package/src/tool/webfetch.ts +1 -202
  139. package/src/tool/websearch.ts +1 -71
  140. package/src/tool/workflow/plan-enter.txt +14 -0
  141. package/src/tool/workflow/plan-exit.txt +13 -0
  142. package/src/tool/workflow/plan.ts +30 -0
  143. package/src/tool/workflow/question.ts +52 -0
  144. package/src/tool/workflow/question.txt +11 -0
  145. package/src/tool/workflow/skill.ts +91 -0
  146. package/src/tool/workflow/skill.txt +5 -0
  147. package/src/tool/workflow/task.ts +197 -0
  148. package/src/tool/workflow/task.txt +57 -0
  149. package/src/tool/workflow/todo.ts +62 -0
  150. package/src/tool/workflow/todowrite.txt +167 -0
  151. package/src/tool/write.ts +1 -114
@@ -1,107 +1 @@
1
- import { Effect, Schema } from "effect"
2
- import * as Tool from "./tool"
3
- import { WarpGrepClient } from "@morphllm/morphsdk/tools/warp-grep/client"
4
- import { Telemetry } from "@saeeol/telemetry"
5
- import { Instance } from "../project/instance"
6
- import { Bus } from "../bus"
7
- import { TuiEvent } from "../cli/cmd/tui/event"
8
- import DESCRIPTION from "./warpgrep.txt"
9
-
10
- // FREE_PERIOD_TODO: Remove SAEEOL_WARPGREP_PROXY_URL constant and the proxy
11
- // fallback below. After the free period ends, require MORPH_API_KEY and
12
- // return an error when it is missing.
13
- const SAEEOL_WARPGREP_PROXY_URL = "https://api.saeeol.ai/api/gateway"
14
-
15
- const Parameters = Schema.Struct({
16
- query: Schema.String.annotate({
17
- description: "Search query describing what code you are looking for. Be specific and descriptive for best results.",
18
- }),
19
- })
20
-
21
- export const CodebaseSearchTool = Tool.define(
22
- "codebase_search",
23
- Effect.gen(function* () {
24
- return {
25
- description: DESCRIPTION,
26
- parameters: Parameters,
27
- execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
28
- Effect.gen(function* () {
29
- yield* ctx.ask({
30
- permission: "codebase_search",
31
- patterns: [params.query],
32
- always: ["*"],
33
- metadata: { query: params.query },
34
- })
35
- Telemetry.trackToolUsed("codebase_search", ctx.sessionID)
36
-
37
- const apiKey = process.env["MORPH_API_KEY"]
38
-
39
- // FREE_PERIOD_TODO: Remove proxy fallback — require apiKey, error if missing:
40
- // if (!apiKey) return { title: ..., output: "Set MORPH_API_KEY to use codebase search.", metadata: {} }
41
- const client = new WarpGrepClient({
42
- morphApiKey: apiKey ?? "saeeol-free",
43
- ...(apiKey ? {} : { morphApiUrl: SAEEOL_WARPGREP_PROXY_URL }),
44
- timeout: 60_000,
45
- })
46
-
47
- const result = yield* Effect.promise(() =>
48
- client.execute({
49
- searchTerm: params.query,
50
- repoRoot: Instance.directory,
51
- }),
52
- )
53
-
54
- if (!result.success || !result.contexts?.length) {
55
- // FREE_PERIOD_TODO: When the proxy stops serving free requests, errors
56
- // from the proxy (401/402/429) will surface here. The message below
57
- // tells the user exactly what to do.
58
- const isAuthOrRateLimit =
59
- result.error && /401|402|429|rate.limit|free.period|unauthorized/i.test(result.error)
60
- const apiKeyMsg =
61
- "Codebase search unavailable: free period ended. Set MORPH_API_KEY to continue. Get your key at https://www.morphllm.com/"
62
- if (isAuthOrRateLimit) {
63
- yield* Effect.promise(() =>
64
- Bus.publish(TuiEvent.ToastShow, {
65
- title: "Codebase Search Unavailable",
66
- message: "Free period has ended. Set MORPH_API_KEY to continue. Get your key at morphllm.com",
67
- variant: "error",
68
- duration: 10000,
69
- }).catch(() => {}),
70
- )
71
- }
72
- return {
73
- title: `Codebase Search: ${params.query}`,
74
- output: isAuthOrRateLimit ? apiKeyMsg : (result.error ?? "No relevant code found."),
75
- metadata: { count: 0 },
76
- }
77
- }
78
-
79
- const MAX_OUTPUT_CHARS = 45_000
80
- const fullOutput = result.contexts.map((c) => `### ${c.file}\n\`\`\`\n${c.content}\n\`\`\``).join("\n\n")
81
-
82
- let output: string
83
- if (fullOutput.length > MAX_OUTPUT_CHARS) {
84
- const summary = result.contexts
85
- .map((c) => {
86
- const lineInfo = !c.lines
87
- ? ""
88
- : c.lines === "*"
89
- ? " (full file)"
90
- : ` (lines ${c.lines.map((r) => r.join("-")).join(", ")})`
91
- return `- ${c.file}${lineInfo}`
92
- })
93
- .join("\n")
94
- output = `Results too large to show inline. Showing file paths and line ranges. Use Read tool to view specific files.\n\n${summary}`
95
- } else {
96
- output = fullOutput
97
- }
98
-
99
- return {
100
- title: `Codebase Search: ${params.query}`,
101
- output,
102
- metadata: { count: result.contexts.length },
103
- }
104
- }).pipe(Effect.orDie),
105
- }
106
- }),
107
- )
1
+ export * from "./search/warpgrep"
@@ -1,202 +1 @@
1
- import { Effect, Schema } from "effect"
2
- import { HttpClient, HttpClientRequest } from "effect/unstable/http"
3
- import * as Tool from "./tool"
4
- import TurndownService from "turndown"
5
- import DESCRIPTION from "./webfetch.txt"
6
- import { isImageAttachment } from "@/util/media"
7
- import { normalizeUrls } from "@/saeeol/util/url"
8
-
9
- const MAX_RESPONSE_SIZE = 5 * 1024 * 1024 // 5MB
10
- const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
11
- const MAX_TIMEOUT = 120 * 1000 // 2 minutes
12
-
13
- export const Parameters = Schema.Struct({
14
- url: Schema.String.annotate({ description: "The URL to fetch content from" }),
15
- format: Schema.Literals(["text", "markdown", "html"])
16
- .pipe(Schema.optional, Schema.withDecodingDefault(Effect.succeed("markdown" as const)))
17
- .annotate({
18
- description: "The format to return the content in (text, markdown, or html). Defaults to markdown.",
19
- }),
20
- timeout: Schema.optional(Schema.Number).annotate({ description: "Optional timeout in seconds (max 120)" }),
21
- })
22
-
23
- export const WebFetchTool = Tool.define(
24
- "webfetch",
25
- Effect.gen(function* () {
26
- const http = yield* HttpClient.HttpClient
27
- const httpOk = HttpClient.filterStatusOk(http)
28
-
29
- return {
30
- description: DESCRIPTION,
31
- parameters: Parameters,
32
- execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
33
- Effect.gen(function* () {
34
- if (!params.url.startsWith("http://") && !params.url.startsWith("https://")) {
35
- throw new Error("URL must start with http:// or https://")
36
- }
37
-
38
- const url = normalizeUrls(params.url)
39
-
40
- yield* ctx.ask({
41
- permission: "webfetch",
42
- patterns: [url],
43
- always: ["*"],
44
- metadata: {
45
- url,
46
- format: params.format,
47
- timeout: params.timeout,
48
- },
49
- })
50
-
51
- const timeout = Math.min((params.timeout ?? DEFAULT_TIMEOUT / 1000) * 1000, MAX_TIMEOUT)
52
-
53
- // Build Accept header based on requested format with q parameters for fallbacks
54
- let acceptHeader = "*/*"
55
- switch (params.format) {
56
- case "markdown":
57
- acceptHeader = "text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1"
58
- break
59
- case "text":
60
- acceptHeader = "text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1"
61
- break
62
- case "html":
63
- acceptHeader =
64
- "text/html;q=1.0, application/xhtml+xml;q=0.9, text/plain;q=0.8, text/markdown;q=0.7, */*;q=0.1"
65
- break
66
- default:
67
- acceptHeader =
68
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
69
- }
70
- const headers = {
71
- "User-Agent":
72
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
73
- Accept: acceptHeader,
74
- "Accept-Language": "en-US,en;q=0.9",
75
- }
76
-
77
- const request = HttpClientRequest.get(url).pipe(HttpClientRequest.setHeaders(headers))
78
-
79
- // Retry with honest UA if blocked by Cloudflare bot detection (TLS fingerprint mismatch)
80
- const response = yield* httpOk.execute(request).pipe(
81
- Effect.catchIf(
82
- (err) =>
83
- err.reason._tag === "StatusCodeError" &&
84
- err.reason.response.status === 403 &&
85
- err.reason.response.headers["cf-mitigated"] === "challenge",
86
- () =>
87
- httpOk.execute(
88
- HttpClientRequest.get(url).pipe(
89
- HttpClientRequest.setHeaders({ ...headers, "User-Agent": "saeeol" }),
90
- ),
91
- ),
92
- ),
93
- Effect.timeoutOrElse({ duration: timeout, orElse: () => Effect.die(new Error("Request timed out")) }),
94
- )
95
-
96
- // Check content length
97
- const contentLength = response.headers["content-length"]
98
- if (contentLength && parseInt(contentLength) > MAX_RESPONSE_SIZE) {
99
- throw new Error("Response too large (exceeds 5MB limit)")
100
- }
101
-
102
- const arrayBuffer = yield* response.arrayBuffer
103
- if (arrayBuffer.byteLength > MAX_RESPONSE_SIZE) {
104
- throw new Error("Response too large (exceeds 5MB limit)")
105
- }
106
-
107
- const contentType = response.headers["content-type"] || ""
108
- const mime = contentType.split(";")[0]?.trim().toLowerCase() || ""
109
- const title = `${url} (${contentType})`
110
-
111
- if (isImageAttachment(mime)) {
112
- const base64Content = Buffer.from(arrayBuffer).toString("base64")
113
- return {
114
- title,
115
- output: "Image fetched successfully",
116
- metadata: {},
117
- attachments: [
118
- {
119
- type: "file" as const,
120
- mime,
121
- url: `data:${mime};base64,${base64Content}`,
122
- },
123
- ],
124
- }
125
- }
126
-
127
- const content = new TextDecoder().decode(arrayBuffer)
128
-
129
- // Handle content based on requested format and actual content type
130
- switch (params.format) {
131
- case "markdown":
132
- if (contentType.includes("text/html")) {
133
- const markdown = convertHTMLToMarkdown(content)
134
- return {
135
- output: markdown,
136
- title,
137
- metadata: {},
138
- }
139
- }
140
- return { output: content, title, metadata: {} }
141
-
142
- case "text":
143
- if (contentType.includes("text/html")) {
144
- const text = yield* Effect.promise(() => extractTextFromHTML(content))
145
- return { output: text, title, metadata: {} }
146
- }
147
- return { output: content, title, metadata: {} }
148
-
149
- case "html":
150
- return { output: content, title, metadata: {} }
151
-
152
- default:
153
- return { output: content, title, metadata: {} }
154
- }
155
- }).pipe(Effect.orDie),
156
- }
157
- }),
158
- )
159
-
160
- async function extractTextFromHTML(html: string) {
161
- let text = ""
162
- let skipContent = false
163
-
164
- const rewriter = new HTMLRewriter()
165
- .on("script, style, noscript, iframe, object, embed", {
166
- element() {
167
- skipContent = true
168
- },
169
- text() {
170
- // Skip text content inside these elements
171
- },
172
- })
173
- .on("*", {
174
- element(element) {
175
- // Reset skip flag when entering other elements
176
- if (!["script", "style", "noscript", "iframe", "object", "embed"].includes(element.tagName)) {
177
- skipContent = false
178
- }
179
- },
180
- text(input) {
181
- if (!skipContent) {
182
- text += input.text
183
- }
184
- },
185
- })
186
- .transform(new Response(html))
187
-
188
- await rewriter.text()
189
- return text.trim()
190
- }
191
-
192
- function convertHTMLToMarkdown(html: string): string {
193
- const turndownService = new TurndownService({
194
- headingStyle: "atx",
195
- hr: "---",
196
- bulletListMarker: "-",
197
- codeBlockStyle: "fenced",
198
- emDelimiter: "*",
199
- })
200
- turndownService.remove(["script", "style", "meta", "link"])
201
- return turndownService.turndown(html)
202
- }
1
+ export * from "./search/webfetch"
@@ -1,71 +1 @@
1
- import { Effect, Schema } from "effect"
2
- import { HttpClient } from "effect/unstable/http"
3
- import * as Tool from "./tool"
4
- import * as McpExa from "./mcp-exa"
5
- import DESCRIPTION from "./websearch.txt"
6
-
7
- export const Parameters = Schema.Struct({
8
- query: Schema.String.annotate({ description: "Websearch query" }),
9
- numResults: Schema.optional(Schema.Number).annotate({
10
- description: "Number of search results to return (default: 8)",
11
- }),
12
- livecrawl: Schema.optional(Schema.Literals(["fallback", "preferred"])).annotate({
13
- description:
14
- "Live crawl mode - 'fallback': use live crawling as backup if cached content unavailable, 'preferred': prioritize live crawling (default: 'fallback')",
15
- }),
16
- type: Schema.optional(Schema.Literals(["auto", "fast", "deep"])).annotate({
17
- description: "Search type - 'auto': balanced search (default), 'fast': quick results, 'deep': comprehensive search",
18
- }),
19
- contextMaxCharacters: Schema.optional(Schema.Number).annotate({
20
- description: "Maximum characters for context string optimized for LLMs (default: 10000)",
21
- }),
22
- })
23
-
24
- export const WebSearchTool = Tool.define(
25
- "websearch",
26
- Effect.gen(function* () {
27
- const http = yield* HttpClient.HttpClient
28
-
29
- return {
30
- get description() {
31
- return DESCRIPTION.replace("{{year}}", new Date().getFullYear().toString())
32
- },
33
- parameters: Parameters,
34
- execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
35
- Effect.gen(function* () {
36
- yield* ctx.ask({
37
- permission: "websearch",
38
- patterns: [params.query],
39
- always: ["*"],
40
- metadata: {
41
- query: params.query,
42
- numResults: params.numResults,
43
- livecrawl: params.livecrawl,
44
- type: params.type,
45
- contextMaxCharacters: params.contextMaxCharacters,
46
- },
47
- })
48
-
49
- const result = yield* McpExa.call(
50
- http,
51
- "web_search_exa",
52
- McpExa.SearchArgs,
53
- {
54
- query: params.query,
55
- type: params.type || "auto",
56
- numResults: params.numResults || 8,
57
- livecrawl: params.livecrawl || "fallback",
58
- contextMaxCharacters: params.contextMaxCharacters,
59
- },
60
- "25 seconds",
61
- )
62
-
63
- return {
64
- output: result ?? "No search results found. Please try a different query.",
65
- title: `Web search: ${params.query}`,
66
- metadata: {},
67
- }
68
- }).pipe(Effect.orDie),
69
- }
70
- }),
71
- )
1
+ export * from "./search/websearch"
@@ -0,0 +1,14 @@
1
+ Use this tool to suggest switching to plan agent when the user's request would benefit from planning before implementation.
2
+
3
+ If they explicitly mention wanting to create a plan ALWAYS call this tool first.
4
+
5
+ This tool will ask the user if they want to switch to plan agent.
6
+
7
+ Call this tool when:
8
+ - The user's request is complex and would benefit from planning first
9
+ - You want to research and design before making changes
10
+ - The task involves multiple files or significant architectural decisions
11
+
12
+ Do NOT call this tool:
13
+ - For simple, straightforward tasks
14
+ - When the user explicitly wants immediate implementation
@@ -0,0 +1,13 @@
1
+ Signal that planning is complete and the plan is ready for implementation.
2
+
3
+ Call this tool once you have finalized the plan file and are confident it is ready. This ends your planning turn and hands control back to the user.
4
+
5
+ Call this tool:
6
+ - After you have written a complete plan to the plan file
7
+ - After you have clarified any questions with the user
8
+ - When you are confident the plan is ready for implementation
9
+
10
+ Do NOT call this tool:
11
+ - Before you have created or finalized the plan
12
+ - If you still have unanswered questions about the implementation
13
+ - If the user has indicated they want to continue planning
@@ -0,0 +1,30 @@
1
+ import path from "path"
2
+ import { Effect, Schema } from "effect"
3
+ import * as Tool from "../core/tool"
4
+ import { Session } from "@/session/session"
5
+ import { InstanceState } from "@/effect/instance-state"
6
+ import EXIT_DESCRIPTION from "./plan-exit.txt"
7
+
8
+ export const Parameters = Schema.Struct({})
9
+ export const PlanExitTool = Tool.define(
10
+ "plan_exit",
11
+ Effect.gen(function* () {
12
+ const session = yield* Session.Service
13
+
14
+ return {
15
+ description: EXIT_DESCRIPTION,
16
+ parameters: Parameters,
17
+ execute: (_params: {}, ctx: Tool.Context) =>
18
+ Effect.gen(function* () {
19
+ const instance = yield* InstanceState.context
20
+ const info = yield* session.get(ctx.sessionID)
21
+ const plan = path.relative(instance.worktree, Session.plan(info, instance))
22
+ return {
23
+ title: "Planning complete",
24
+ output: `Plan is ready at ${plan}. Ending planning turn.`,
25
+ metadata: { plan },
26
+ }
27
+ }).pipe(Effect.orDie),
28
+ }
29
+ }),
30
+ )
@@ -0,0 +1,52 @@
1
+ import { Effect, Schema } from "effect"
2
+ import { plural } from "@saeeol/boxes/plural"
3
+ import * as Tool from "../core/tool"
4
+ import { Question } from "../../question"
5
+ import DESCRIPTION from "./question.txt"
6
+ import { SaeeolQuestionTool } from "@/saeeol/tool/question"
7
+
8
+ export const Parameters = Schema.Struct({
9
+ questions: Schema.mutable(Schema.Array(Question.Prompt)).annotate({ description: "Questions to ask" }),
10
+ })
11
+
12
+ type Metadata = {
13
+ answers: ReadonlyArray<Question.Answer>
14
+ dismissed?: boolean
15
+ }
16
+
17
+ export const QuestionTool = Tool.define<typeof Parameters, Metadata, Question.Service>(
18
+ "question",
19
+ Effect.gen(function* () {
20
+ const question = yield* Question.Service
21
+
22
+ return {
23
+ description: DESCRIPTION,
24
+ parameters: Parameters,
25
+ execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
26
+ Effect.gen(function* () {
27
+ // tool result via SaeeolQuestionTool helpers, so Effect.orDie below does not turn
28
+ // it into a defect and kill the in-flight stream.
29
+ const answers = yield* question
30
+ .ask({
31
+ sessionID: ctx.sessionID,
32
+ questions: params.questions,
33
+ tool: ctx.callID ? { messageID: ctx.messageID, callID: ctx.callID } : undefined,
34
+ })
35
+ .pipe(SaeeolQuestionTool.catchDismissed)
36
+ if (SaeeolQuestionTool.isDismissed(answers)) return SaeeolQuestionTool.dismissedResult()
37
+
38
+ const formatted = params.questions
39
+ .map((q, i) => `"${q.question}"="${answers[i]?.length ? answers[i].join(", ") : "Unanswered"}"`)
40
+ .join(", ")
41
+
42
+ return {
43
+ title: plural(params.questions.length, `Asked {} question`, `Asked {} questions`),
44
+ output: `User has answered your questions: ${formatted}. You can now continue with the user's answers in mind.`,
45
+ metadata: {
46
+ answers,
47
+ },
48
+ }
49
+ }).pipe(Effect.orDie),
50
+ }
51
+ }),
52
+ )
@@ -0,0 +1,11 @@
1
+ Use this tool when you need to ask the user questions during execution. This allows you to:
2
+ 1. Gather user preferences or requirements
3
+ 2. Clarify ambiguous instructions
4
+ 3. Get decisions on implementation choices as you work
5
+ 4. Offer choices to the user about what direction to take.
6
+
7
+ Usage notes:
8
+ - When `custom` is enabled (default), a "Type your own answer" option is added automatically; don't include "Other" or catch-all options
9
+ - Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one
10
+ - If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
11
+ - Header must be 30 characters or less (maxLength: 30)
@@ -0,0 +1,91 @@
1
+ import path from "path"
2
+ import { pathToFileURL } from "url"
3
+ import { Effect, Schema } from "effect"
4
+ import * as Stream from "effect/Stream"
5
+ import { Ripgrep } from "../../file/ripgrep"
6
+ import { Skill } from "../../skill"
7
+ import * as Tool from "../core/tool"
8
+ import DESCRIPTION from "./skill.txt"
9
+
10
+ export const Parameters = Schema.Struct({
11
+ name: Schema.String.annotate({ description: "The name of the skill from available_skills" }),
12
+ })
13
+
14
+ export const SkillTool = Tool.define(
15
+ "skill",
16
+ Effect.gen(function* () {
17
+ const skill = yield* Skill.Service
18
+ const rg = yield* Ripgrep.Service
19
+
20
+ return {
21
+ description: DESCRIPTION,
22
+ parameters: Parameters,
23
+ execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
24
+ Effect.gen(function* () {
25
+ const info = yield* skill.get(params.name)
26
+ if (!info) {
27
+ const all = yield* skill.all()
28
+ const available = all.map((item) => item.name).join(", ")
29
+ throw new Error(`Skill "${params.name}" not found. Available skills: ${available || "none"}`)
30
+ }
31
+
32
+ yield* ctx.ask({
33
+ permission: "skill",
34
+ patterns: [params.name],
35
+ always: [params.name],
36
+ metadata: {},
37
+ })
38
+ if (info.location === Skill.BUILTIN_LOCATION) {
39
+ return {
40
+ title: `Loaded skill: ${info.name}`,
41
+ output: [
42
+ `<skill_content name="${info.name}">`,
43
+ `# Skill: ${info.name}`,
44
+ "",
45
+ info.content.trim(),
46
+ "</skill_content>",
47
+ ].join("\n"),
48
+ metadata: {
49
+ name: info.name,
50
+ dir: Skill.BUILTIN_LOCATION,
51
+ },
52
+ }
53
+ }
54
+
55
+ const dir = path.dirname(info.location)
56
+ const base = pathToFileURL(dir).href
57
+ const limit = 10
58
+ const files = yield* rg.files({ cwd: dir, follow: false, hidden: true, signal: ctx.abort }).pipe(
59
+ Stream.filter((file) => !file.includes("SKILL.md")),
60
+ Stream.map((file) => path.resolve(dir, file)),
61
+ Stream.take(limit),
62
+ Stream.runCollect,
63
+ Effect.map((chunk) => [...chunk].map((file) => `<file>${file}</file>`).join("\n")),
64
+ )
65
+
66
+ return {
67
+ title: `Loaded skill: ${info.name}`,
68
+ output: [
69
+ `<skill_content name="${info.name}">`,
70
+ `# Skill: ${info.name}`,
71
+ "",
72
+ info.content.trim(),
73
+ "",
74
+ `Base directory for this skill: ${base}`,
75
+ "Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.",
76
+ "Note: file list is sampled.",
77
+ "",
78
+ "<skill_files>",
79
+ files,
80
+ "</skill_files>",
81
+ "</skill_content>",
82
+ ].join("\n"),
83
+ metadata: {
84
+ name: info.name,
85
+ dir,
86
+ },
87
+ }
88
+ }).pipe(Effect.orDie),
89
+ }
90
+ }),
91
+ )
@@ -0,0 +1,5 @@
1
+ Load a specialized skill when the task at hand matches one of the skills listed in the system prompt.
2
+
3
+ Use this tool to inject the skill's instructions and resources into current conversation. The output may contain detailed workflow guidance as well as references to scripts, files, etc in the same directory as the skill.
4
+
5
+ The skill name must match one of the skills listed in your system prompt.