clanka 0.26.1 → 0.27.0

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 (101) hide show
  1. package/README.md +2 -3
  2. package/dist/Acp.test.js +0 -1
  3. package/dist/Acp.test.js.map +1 -1
  4. package/dist/AcpImage.test.js +0 -1
  5. package/dist/AcpImage.test.js.map +1 -1
  6. package/dist/Agent.d.ts.map +1 -1
  7. package/dist/Agent.js +1 -2
  8. package/dist/Agent.js.map +1 -1
  9. package/dist/Agent.test.js +0 -1
  10. package/dist/Agent.test.js.map +1 -1
  11. package/dist/AgentCallerConfig.test.js +0 -1
  12. package/dist/AgentCallerConfig.test.js.map +1 -1
  13. package/dist/AgentExecutor.d.ts +2 -3
  14. package/dist/AgentExecutor.d.ts.map +1 -1
  15. package/dist/AgentExecutor.js +4 -13
  16. package/dist/AgentExecutor.js.map +1 -1
  17. package/dist/AgentImage.test.js +0 -1
  18. package/dist/AgentImage.test.js.map +1 -1
  19. package/dist/AgentSkills.test.js +0 -2
  20. package/dist/AgentSkills.test.js.map +1 -1
  21. package/dist/AgentTools.d.ts +2 -235
  22. package/dist/AgentTools.d.ts.map +1 -1
  23. package/dist/AgentTools.js +2 -32
  24. package/dist/AgentTools.js.map +1 -1
  25. package/dist/ClaudeAgent.test.js +0 -1
  26. package/dist/ClaudeAgent.test.js.map +1 -1
  27. package/dist/ScriptFormatting.d.ts +5 -0
  28. package/dist/ScriptFormatting.d.ts.map +1 -1
  29. package/dist/ScriptFormatting.js +255 -53
  30. package/dist/ScriptFormatting.js.map +1 -1
  31. package/dist/ScriptFormatting.test.js +16 -0
  32. package/dist/ScriptFormatting.test.js.map +1 -1
  33. package/dist/bin/{Latch-DOdbsGMQ.mjs → Latch-BE6_TYRL.mjs} +1 -1
  34. package/dist/bin/{McpClient-B-FFG6Pg.mjs → McpClient-DCt4v5W5.mjs} +2 -2
  35. package/dist/bin/{OutputFormatter-DhhP2i-7.mjs → OutputFormatter-DaFv_C_I.mjs} +2 -3
  36. package/dist/bin/{Schema-CFdSO6iH.mjs → Schema-B3MiG1aD.mjs} +204 -568
  37. package/dist/bin/cli.mjs +5093 -2468
  38. package/dist/bin/{upgrade-C4aOEWJH.mjs → upgrade-WqgIU_21.mjs} +3 -3
  39. package/dist/cli.js +2 -25
  40. package/dist/cli.js.map +1 -1
  41. package/dist/index.d.ts +0 -8
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +0 -8
  44. package/dist/index.js.map +1 -1
  45. package/package.json +1 -7
  46. package/src/Acp.test.ts +0 -1
  47. package/src/AcpImage.test.ts +0 -1
  48. package/src/Agent.test.ts +0 -1
  49. package/src/Agent.ts +0 -4
  50. package/src/AgentCallerConfig.test.ts +0 -1
  51. package/src/AgentExecutor.ts +4 -16
  52. package/src/AgentImage.test.ts +0 -1
  53. package/src/AgentSkills.test.ts +0 -2
  54. package/src/AgentTools.ts +4 -41
  55. package/src/ClaudeAgent.test.ts +0 -1
  56. package/src/ScriptFormatting.test.ts +20 -0
  57. package/src/ScriptFormatting.ts +234 -47
  58. package/src/cli.ts +1 -56
  59. package/src/index.ts +0 -10
  60. package/dist/ChunkRepo.d.ts +0 -173
  61. package/dist/ChunkRepo.d.ts.map +0 -1
  62. package/dist/ChunkRepo.js +0 -168
  63. package/dist/ChunkRepo.js.map +0 -1
  64. package/dist/ChunkRepo.test.d.ts +0 -2
  65. package/dist/ChunkRepo.test.d.ts.map +0 -1
  66. package/dist/ChunkRepo.test.js +0 -63
  67. package/dist/ChunkRepo.test.js.map +0 -1
  68. package/dist/CodeChunker.d.ts +0 -84
  69. package/dist/CodeChunker.d.ts.map +0 -1
  70. package/dist/CodeChunker.js +0 -658
  71. package/dist/CodeChunker.js.map +0 -1
  72. package/dist/CodeChunker.test.d.ts +0 -2
  73. package/dist/CodeChunker.test.d.ts.map +0 -1
  74. package/dist/CodeChunker.test.js +0 -434
  75. package/dist/CodeChunker.test.js.map +0 -1
  76. package/dist/SemanticSearch/Service.d.ts +0 -31
  77. package/dist/SemanticSearch/Service.d.ts.map +0 -1
  78. package/dist/SemanticSearch/Service.js +0 -29
  79. package/dist/SemanticSearch/Service.js.map +0 -1
  80. package/dist/SemanticSearch.d.ts +0 -34
  81. package/dist/SemanticSearch.d.ts.map +0 -1
  82. package/dist/SemanticSearch.js +0 -171
  83. package/dist/SemanticSearch.js.map +0 -1
  84. package/dist/SemanticSearch.test.d.ts +0 -2
  85. package/dist/SemanticSearch.test.d.ts.map +0 -1
  86. package/dist/SemanticSearch.test.js +0 -34
  87. package/dist/SemanticSearch.test.js.map +0 -1
  88. package/dist/Sqlite.d.ts +0 -15
  89. package/dist/Sqlite.d.ts.map +0 -1
  90. package/dist/Sqlite.js +0 -44
  91. package/dist/Sqlite.js.map +0 -1
  92. package/dist/bin/AiError-DBaKz35C.mjs +0 -2723
  93. package/dist/bin/SemanticSearch-C3a7LAQr.mjs +0 -2558
  94. package/src/ChunkRepo.test.ts +0 -89
  95. package/src/ChunkRepo.ts +0 -260
  96. package/src/CodeChunker.test.ts +0 -493
  97. package/src/CodeChunker.ts +0 -1018
  98. package/src/SemanticSearch/Service.ts +0 -50
  99. package/src/SemanticSearch.test.ts +0 -51
  100. package/src/SemanticSearch.ts +0 -282
  101. package/src/Sqlite.ts +0 -60
@@ -1,57 +1,244 @@
1
- import TreeSitter, { type SyntaxNode } from "tree-sitter"
2
- import JavaScript from "tree-sitter-javascript"
1
+ /**
2
+ * Display-only line breaks for model-generated scripts. A small scanner finds
3
+ * statement boundaries, skipping literals and comments, so no parser is
4
+ * needed. Scripts it cannot scan are returned unchanged.
5
+ */
3
6
 
4
- const parser = new TreeSitter()
5
- parser.setLanguage(JavaScript)
7
+ type Frame =
8
+ | { readonly type: "block"; readonly start: number; readonly opener: string }
9
+ | { readonly type: "brace" | "paren" | "bracket" | "template" | "subst" }
6
10
 
7
- /** Adds display-only line breaks, leaving execution and model history untouched. */
8
- export const formatScript = (script: string): string => {
9
- try {
10
- const tree = parser.parse(script, undefined, {
11
- // Include room for the UTF-16 terminator, even for large file contents.
12
- bufferSize: Math.max(32 * 1024, script.length + 1),
13
- })
14
- if (tree.rootNode.hasError) return script
15
- const breaks = new Set<number>()
16
- const visit = (node: SyntaxNode): void => {
17
- // Treat literals as opaque, including code inside template substitutions.
18
- if (
19
- ["string", "template_string", "regex", "comment"].includes(node.type)
20
- ) {
21
- return
11
+ // Tokens after which `{` opens a statement block rather than an expression.
12
+ const blockOpeners = new Set([
13
+ "",
14
+ ";",
15
+ "{",
16
+ "}",
17
+ ")",
18
+ "=>",
19
+ "else",
20
+ "try",
21
+ "finally",
22
+ "do",
23
+ ])
24
+
25
+ // Tokens after which `/` starts a regular expression rather than a division.
26
+ const regexKeywords = new Set([
27
+ "return",
28
+ "typeof",
29
+ "instanceof",
30
+ "in",
31
+ "of",
32
+ "new",
33
+ "delete",
34
+ "void",
35
+ "throw",
36
+ "case",
37
+ "do",
38
+ "else",
39
+ "yield",
40
+ "await",
41
+ ])
42
+
43
+ // Words that continue the statement a block belongs to.
44
+ const continuations = new Set([
45
+ "else",
46
+ "catch",
47
+ "finally",
48
+ "instanceof",
49
+ "in",
50
+ "as",
51
+ "satisfies",
52
+ ])
53
+
54
+ const isWord = (char: string) => /[\w$]/.test(char) || char.charCodeAt(0) > 127
55
+
56
+ const isSpace = (char: string) => /\s/.test(char)
57
+
58
+ // `prev` is "" at the start, a punctuator, a word, "id" for a property name,
59
+ // or "str" for a literal. After ")" a slash is not decided here: see below.
60
+ const regexAllowed = (prev: string) =>
61
+ prev === "" ||
62
+ regexKeywords.has(prev) ||
63
+ (!isWord(prev[0]!) && !["]", "}o", "++", "--"].includes(prev))
64
+
65
+ /** Returns the positions of statement boundaries, or undefined if the script cannot be scanned. */
66
+ const findBreaks = (script: string): Set<number> | undefined => {
67
+ const breaks = new Set<number>()
68
+ const stack: Array<Frame> = []
69
+ // Inside a template literal, including its substitutions, nothing is broken.
70
+ let opaque = 0
71
+ let prev = ""
72
+ let prevEnd = 0
73
+ const top = () => stack.at(-1)?.type
74
+ const inStatements = () => {
75
+ const type = top()
76
+ return type === undefined || type === "block" || type === "brace"
77
+ }
78
+ // Skips whitespace and comments, or returns undefined for an unterminated comment.
79
+ const skipTrivia = (from: number): number | undefined => {
80
+ let i = from
81
+ while (i < script.length) {
82
+ if (isSpace(script[i]!)) i++
83
+ else if (script.startsWith("//", i)) {
84
+ const end = script.indexOf("\n", i)
85
+ i = end === -1 ? script.length : end
86
+ } else if (script.startsWith("/*", i)) {
87
+ const end = script.indexOf("*/", i + 2)
88
+ if (end === -1) return undefined
89
+ i = end + 2
90
+ } else break
91
+ }
92
+ return i
93
+ }
94
+ const nextToken = (from: number): string => {
95
+ const i = skipTrivia(from)
96
+ if (i === undefined || i >= script.length) return ""
97
+ if (!isWord(script[i]!)) return script[i]!
98
+ let end = i
99
+ while (end < script.length && isWord(script[end]!)) end++
100
+ return script.slice(i, end)
101
+ }
102
+
103
+ let i = 0
104
+ while (i < script.length) {
105
+ const char = script[i]!
106
+ if (top() === "template") {
107
+ if (char === "\\") i += 2
108
+ else if (char === "`") {
109
+ stack.pop()
110
+ opaque--
111
+ prev = "str"
112
+ prevEnd = ++i
113
+ } else if (script.startsWith("${", i)) {
114
+ stack.push({ type: "subst" })
115
+ prev = "("
116
+ i += 2
117
+ } else i++
118
+ continue
119
+ }
120
+ if (
121
+ isSpace(char) ||
122
+ script.startsWith("//", i) ||
123
+ script.startsWith("/*", i)
124
+ ) {
125
+ const end = skipTrivia(i)
126
+ if (end === undefined) return undefined
127
+ i = end
128
+ continue
129
+ }
130
+ const start = i
131
+ if (char === '"' || char === "'") {
132
+ i++
133
+ while (script[i] !== char) {
134
+ if (i >= script.length || script[i] === "\n") return undefined
135
+ i += script[i] === "\\" ? 2 : 1
22
136
  }
23
- if (node.type === "for_statement") {
24
- const body = node.childForFieldName("body")
25
- if (body) visit(body)
26
- return
137
+ i++
138
+ prev = "str"
139
+ } else if (char === "`") {
140
+ stack.push({ type: "template" })
141
+ opaque++
142
+ i++
143
+ continue
144
+ } else if (char === "/" && prev === ")") {
145
+ // After a control header such as `if (x)` it starts a regex, after a
146
+ // call or a parenthesized expression it divides. Telling these apart
147
+ // needs a parser, so leave the script unchanged.
148
+ return undefined
149
+ } else if (char === "/" && regexAllowed(prev)) {
150
+ let inClass = false
151
+ i++
152
+ while (inClass || script[i] !== "/") {
153
+ if (i >= script.length || script[i] === "\n") return undefined
154
+ if (script[i] === "[") inClass = true
155
+ else if (script[i] === "]") inClass = false
156
+ i += script[i] === "\\" ? 2 : 1
27
157
  }
28
- if (node.type === ";") breaks.add(node.endIndex)
29
- if (node.type === "statement_block") {
30
- breaks.add(node.startIndex + 1)
158
+ i++
159
+ while (i < script.length && isWord(script[i]!)) i++
160
+ prev = "str"
161
+ } else if (isWord(char)) {
162
+ while (i < script.length && isWord(script[i]!)) i++
163
+ // A name after "." is a property, even when it is spelled like a keyword.
164
+ prev = prev === "." ? "id" : script.slice(start, i)
165
+ } else if (char === "{") {
166
+ if (blockOpeners.has(prev)) {
167
+ stack.push({ type: "block", start: i, opener: prev })
168
+ if (opaque === 0) breaks.add(i + 1)
169
+ } else {
170
+ stack.push({ type: "brace" })
171
+ }
172
+ prev = "{"
173
+ i++
174
+ } else if (char === "}") {
175
+ const frame = stack.pop()
176
+ if (
177
+ frame === undefined ||
178
+ !["block", "brace", "subst"].includes(frame.type)
179
+ ) {
180
+ return undefined
31
181
  }
32
- if (node.type === "program" || node.type === "statement_block") {
33
- for (const child of node.namedChildren) {
34
- if (child.type !== "comment") breaks.add(child.endIndex)
182
+ i++
183
+ if (frame.type === "subst") continue
184
+ prev = "}o"
185
+ if (frame.type === "block") {
186
+ prev = "}"
187
+ if (opaque === 0) {
188
+ // End the block's last statement, then the statement the block ends.
189
+ if (prevEnd > frame.start + 1) breaks.add(prevEnd)
190
+ const next = nextToken(i)
191
+ if (
192
+ inStatements() &&
193
+ frame.opener !== "do" &&
194
+ (next === "" ||
195
+ next === "{" ||
196
+ next === '"' ||
197
+ next === "'" ||
198
+ (isWord(next[0]!) && !continuations.has(next)))
199
+ ) {
200
+ breaks.add(i)
201
+ }
35
202
  }
36
203
  }
37
- for (const child of node.children) visit(child)
204
+ } else if (char === "(" || char === "[") {
205
+ stack.push({ type: char === "(" ? "paren" : "bracket" })
206
+ prev = char
207
+ i++
208
+ } else if (char === ")" || char === "]") {
209
+ if (top() !== (char === ")" ? "paren" : "bracket")) return undefined
210
+ stack.pop()
211
+ prev = char
212
+ i++
213
+ } else if (char === ";") {
214
+ if (opaque === 0 && inStatements()) breaks.add(i + 1)
215
+ prev = char
216
+ i++
217
+ } else {
218
+ const pair = script.slice(i, i + 2)
219
+ prev = pair === "=>" || pair === "++" || pair === "--" ? pair : char
220
+ i += prev.length
38
221
  }
39
- visit(tree.rootNode)
40
-
41
- let output = ""
42
- let start = 0
43
- const newline = script.includes("\r\n") ? "\r\n" : "\n"
44
- for (const index of [...breaks].toSorted((a, b) => a - b)) {
45
- // Keep existing newlines / indentation, and avoid adding a trailing line.
46
- const rest = script.slice(index)
47
- if (/^[ \t]*(?:[\r\n]|$)/.test(rest)) continue
48
- output += script.slice(start, index) + newline
49
- start = index
50
- // Separators on the original line are not indentation for the new one.
51
- while (script[start] === " " || script[start] === "\t") start++
52
- }
53
- return output + script.slice(start)
54
- } catch {
55
- return script
222
+ prevEnd = i
223
+ }
224
+ return stack.length === 0 ? breaks : undefined
225
+ }
226
+
227
+ /** Adds display-only line breaks, leaving execution and model history untouched. */
228
+ export const formatScript = (script: string): string => {
229
+ const breaks = findBreaks(script)
230
+ if (breaks === undefined) return script
231
+ let output = ""
232
+ let start = 0
233
+ const newline = script.includes("\r\n") ? "\r\n" : "\n"
234
+ for (const index of [...breaks].toSorted((a, b) => a - b)) {
235
+ // Keep existing newlines / indentation, and avoid adding a trailing line.
236
+ const rest = script.slice(index)
237
+ if (/^[ \t]*(?:[\r\n]|$)/.test(rest)) continue
238
+ output += script.slice(start, index) + newline
239
+ start = index
240
+ // Separators on the original line are not indentation for the new one.
241
+ while (script[start] === " " || script[start] === "\t") start++
56
242
  }
243
+ return output + script.slice(start)
57
244
  }
package/src/cli.ts CHANGED
@@ -29,7 +29,6 @@ import * as Config from "effect/Config"
29
29
  import * as KeyValueStore from "effect/persistence/KeyValueStore"
30
30
  import * as Option from "effect/Option"
31
31
  import type * as Redacted from "effect/Redacted"
32
- import { OpenAiClient, OpenAiEmbeddingModel } from "@effect/ai-openai"
33
32
  import * as DeviceCodeHandler from "./DeviceCodeHandler.ts"
34
33
  import packageJson from "../package.json" with { type: "json" }
35
34
 
@@ -242,14 +241,6 @@ const fast = Flag.Boolean("fast").pipe(
242
241
  ),
243
242
  )
244
243
 
245
- const semantic = Flag.Directory("search").pipe(
246
- Flag.withDescription(
247
- "Directory for semantic search data (uses OPENAI_API_KEY env var)",
248
- ),
249
- Flag.withAlias("s"),
250
- Flag.optional,
251
- )
252
-
253
244
  const prompt = Flag.String("prompt").pipe(
254
245
  Flag.withDescription("Pass a prompt in non-interactive mode"),
255
246
  Flag.optional,
@@ -365,42 +356,6 @@ const AcpSessions = Layer.unwrap(
365
356
  }),
366
357
  ).pipe(Layer.provide(NodeServices.layer))
367
358
 
368
- const Search = (directory: string) =>
369
- Layer.unwrap(
370
- Effect.gen(function* () {
371
- const apiKey = yield* Config.Redacted("OPENAI_API_KEY").pipe(
372
- Config.option,
373
- )
374
-
375
- if (Option.isNone(apiKey)) {
376
- yield* Effect.logWarning("OPENAI_API_KEY is not set")
377
- return Layer.empty
378
- }
379
-
380
- const path = yield* Path.Path
381
-
382
- const SemanticSearch = yield* Effect.promise(
383
- () => import("./SemanticSearch.ts"),
384
- )
385
-
386
- return SemanticSearch.layer({
387
- directory: process.cwd(),
388
- database: path.join(directory, "search.sqlite"),
389
- }).pipe(
390
- Layer.provide(
391
- OpenAiEmbeddingModel.model("text-embedding-3-small", {
392
- dimensions: 1536,
393
- }),
394
- ),
395
- Layer.provide(
396
- OpenAiClient.layer({
397
- apiKey: apiKey.value,
398
- }),
399
- ),
400
- )
401
- }),
402
- ).pipe(Layer.provide([NodeServices.layer, HttpClientLive]))
403
-
404
359
  const acpModel = Flag.String("model").pipe(
405
360
  Flag.withAlias("m"),
406
361
  Flag.withDescription(
@@ -502,7 +457,6 @@ Command.make("clanka", {
502
457
  fetch,
503
458
  model,
504
459
  fast,
505
- semantic,
506
460
  prompt,
507
461
  compaction,
508
462
  compactionThreshold,
@@ -518,7 +472,6 @@ Command.make("clanka", {
518
472
  provider,
519
473
  model: modelRaw,
520
474
  fast,
521
- semantic,
522
475
  prompt: nonInteractivePrompt,
523
476
  apiKey,
524
477
  apiUrl,
@@ -587,15 +540,7 @@ Command.make("clanka", {
587
540
  Agent.layerLocal({
588
541
  directory: process.cwd(),
589
542
  excludeTools: flags.fetch ? [] : ["fetch"],
590
- }).pipe(
591
- Layer.provide(
592
- Option.match(semantic, {
593
- onNone: () => Layer.empty,
594
- onSome: Search,
595
- }),
596
- ),
597
- Layer.provideMerge(McpServers.layer(mcpServers)),
598
- ),
543
+ }).pipe(Layer.provideMerge(McpServers.layer(mcpServers))),
599
544
  Model,
600
545
  ]),
601
546
  )
package/src/index.ts CHANGED
@@ -44,11 +44,6 @@ export * as Codex from "./Codex.ts"
44
44
  */
45
45
  export * as ModelsRepo from "./ModelsRepo.ts"
46
46
 
47
- /**
48
- * @since 1.0.0
49
- */
50
- export * as CodeChunker from "./CodeChunker.ts"
51
-
52
47
  /**
53
48
  * @since 1.0.0
54
49
  */
@@ -84,11 +79,6 @@ export * as DeviceCodeHandler from "./DeviceCodeHandler.ts"
84
79
  */
85
80
  export * as OutputFormatter from "./OutputFormatter.ts"
86
81
 
87
- /**
88
- * @since 1.0.0
89
- */
90
- export * as SemanticSearch from "./SemanticSearch.ts"
91
-
92
82
  /**
93
83
  * @since 1.0.0
94
84
  */
@@ -1,173 +0,0 @@
1
- /** @effect-diagnostics schemaNumber:off */
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Schema from "effect/Schema";
5
- import * as Context from "effect/Context";
6
- import * as SqlClient from "effect/sql/SqlClient";
7
- import * as SqlError from "effect/sql/SqlError";
8
- import type * as Cause from "effect/Cause";
9
- import type * as Option from "effect/Option";
10
- import * as EmbeddingModel from "effect/ai/EmbeddingModel";
11
- /**
12
- * @since 1.0.0
13
- * @category Models
14
- */
15
- export declare const ChunkId: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
16
- /**
17
- * @since 1.0.0
18
- * @category Models
19
- */
20
- export type ChunkId = typeof ChunkId.Type;
21
- /**
22
- * @since 1.0.0
23
- * @category Models
24
- */
25
- export declare const SyncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
26
- /**
27
- * @since 1.0.0
28
- * @category Models
29
- */
30
- export type SyncId = typeof SyncId.Type;
31
- /**
32
- * @since 1.0.0
33
- * @category Models
34
- */
35
- export declare const Float32ArraySchema: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
36
- /**
37
- * @since 1.0.0
38
- * @category Models
39
- */
40
- export declare const Float32ArrayFromArray: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
41
- /**
42
- * @since 1.0.0
43
- * @category Models
44
- */
45
- export declare const Float32ArrayField: import("effect/schema/VariantSchema").Field<{
46
- readonly insert: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
47
- readonly update: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
48
- readonly jsonCreate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
49
- readonly jsonUpdate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
50
- }>;
51
- declare const Chunk_base: import("effect/schema/VariantSchema").Class<Chunk, {
52
- readonly id: import("effect/schema/VariantSchema").Field<{
53
- readonly json: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
54
- readonly jsonUpdate: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
55
- readonly select: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
56
- readonly update: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
57
- }>;
58
- readonly path: Schema.String;
59
- readonly content: Schema.String;
60
- readonly hash: Schema.String;
61
- readonly vector: import("effect/schema/VariantSchema").Field<{
62
- readonly insert: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
63
- readonly update: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
64
- readonly jsonCreate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
65
- readonly jsonUpdate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
66
- }>;
67
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
68
- }, Schema.Struct<import("effect/schema/VariantSchema").ExtractFields<"select", {
69
- readonly id: import("effect/schema/VariantSchema").Field<{
70
- readonly json: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
71
- readonly jsonUpdate: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
72
- readonly select: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
73
- readonly update: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
74
- }>;
75
- readonly path: Schema.String;
76
- readonly content: Schema.String;
77
- readonly hash: Schema.String;
78
- readonly vector: import("effect/schema/VariantSchema").Field<{
79
- readonly insert: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
80
- readonly update: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
81
- readonly jsonCreate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
82
- readonly jsonUpdate: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
83
- }>;
84
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
85
- }, true>>, "insert" | "json" | "jsonCreate" | "jsonUpdate" | "select" | "update", "select", {}> & {
86
- readonly insert: Schema.Struct<{
87
- readonly path: Schema.String;
88
- readonly content: Schema.String;
89
- readonly hash: Schema.String;
90
- readonly vector: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
91
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
92
- }>;
93
- readonly json: Schema.Struct<{
94
- readonly id: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
95
- readonly path: Schema.String;
96
- readonly content: Schema.String;
97
- readonly hash: Schema.String;
98
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
99
- }>;
100
- readonly jsonCreate: Schema.Struct<{
101
- readonly path: Schema.String;
102
- readonly content: Schema.String;
103
- readonly hash: Schema.String;
104
- readonly vector: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
105
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
106
- }>;
107
- readonly jsonUpdate: Schema.Struct<{
108
- readonly id: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
109
- readonly path: Schema.String;
110
- readonly content: Schema.String;
111
- readonly hash: Schema.String;
112
- readonly vector: Schema.decodeTo<Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>, Schema.$Array<Schema.Number>, never, never>;
113
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
114
- }>;
115
- readonly select: Schema.Struct<{
116
- readonly id: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
117
- readonly path: Schema.String;
118
- readonly content: Schema.String;
119
- readonly hash: Schema.String;
120
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
121
- }>;
122
- readonly update: Schema.Struct<{
123
- readonly id: Schema.brand<Schema.Number, "ChunkRepo/ChunkId">;
124
- readonly path: Schema.String;
125
- readonly content: Schema.String;
126
- readonly hash: Schema.String;
127
- readonly vector: Schema.instanceOf<Float32Array<ArrayBuffer>, Float32Array<ArrayBufferLike>>;
128
- readonly syncId: Schema.brand<Schema.String, "ChunkRepo/SyncId">;
129
- }>;
130
- };
131
- /**
132
- * @since 1.0.0
133
- * @category Models
134
- */
135
- export declare class Chunk extends Chunk_base {
136
- }
137
- declare const ChunkRepo_base: Context.ServiceClass<ChunkRepo, "clanka/ChunkRepo", {
138
- insert(chunk: typeof Chunk.insert.Type): Effect.Effect<Chunk, ChunkRepoError>;
139
- findById(id: ChunkId): Effect.Effect<Chunk, ChunkRepoError | Cause.NoSuchElementError>;
140
- exists(hash: string): Effect.Effect<Option.Option<ChunkId>, ChunkRepoError>;
141
- search(options: {
142
- readonly vector: Float32Array;
143
- readonly limit: number;
144
- }): Effect.Effect<Array<Chunk>, ChunkRepoError>;
145
- quantize: Effect.Effect<void, ChunkRepoError>;
146
- setSyncId(chunkId: ChunkId, syncId: SyncId): Effect.Effect<void, ChunkRepoError>;
147
- deleteByPath(path: string): Effect.Effect<void, ChunkRepoError>;
148
- deleteForSyncId(syncId: SyncId): Effect.Effect<void, ChunkRepoError>;
149
- }>;
150
- /**
151
- * @since 1.0.0
152
- * @category Services
153
- */
154
- export declare class ChunkRepo extends ChunkRepo_base {
155
- }
156
- declare const ChunkRepoError_base: Schema.Class<ChunkRepoError, Schema.TaggedStruct<"ChunkRepoError", {
157
- readonly reason: Schema.Union<readonly [typeof SqlError.SqlError]>;
158
- }>, Cause.YieldableError>;
159
- /**
160
- * @since 1.0.0
161
- * @category Errors
162
- */
163
- export declare class ChunkRepoError extends ChunkRepoError_base {
164
- readonly cause: SqlError.SqlError;
165
- readonly message: string;
166
- }
167
- /**
168
- * @since 1.0.0
169
- * @category Layers
170
- */
171
- export declare const layer: Layer.Layer<ChunkRepo, SqlError.SqlError, EmbeddingModel.Dimensions | SqlClient.SqlClient>;
172
- export {};
173
- //# sourceMappingURL=ChunkRepo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChunkRepo.d.ts","sourceRoot":"","sources":["../src/ChunkRepo.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAG/C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAI1D;;;GAGG;AACH,eAAO,MAAM,OAAO,kDAAwD,CAAA;AAC5E;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC;;;GAGG;AACH,eAAO,MAAM,MAAM,iDAAuD,CAAA;AAC1E;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6EAGhB,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,qBAAqB,0IAQjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;EAK5B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF;;;GAGG;AACH,qBAAa,KAAM,SAAQ,UAOzB;CAAG;;kBAUQ,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,GAC9B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC;iBAGjC,OAAO,GACV,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,CAAC,kBAAkB,CAAC;iBAErD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;oBAE3D;QACd,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;QAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KACvB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;cAErC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC;uBAGlC,OAAO,UACR,MAAM,GACb,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC;uBACnB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC;4BACvC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC;;AA7BxE;;;GAGG;AACH,qBAAa,SAAU,SAAQ,cA2BR;CAAG;;;;AAE1B;;;GAGG;AACH,qBAAa,cAAe,SAAQ,mBAKnC;IACC,QAAQ,CAAC,KAAK,oBAAc;IAC5B,QAAQ,CAAC,OAAO,SAAsB;CACvC;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,4FA0HjB,CAAA"}