promptscout 1.1.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.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/claude-plugin/.claude-plugin/plugin.json +5 -0
- package/claude-plugin/hooks/hooks.json +16 -0
- package/claude-plugin/hooks/scripts/user-prompt-submit.sh +47 -0
- package/dist/commands/history.d.ts +3 -0
- package/dist/commands/history.js +56 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/rewrite.d.ts +3 -0
- package/dist/commands/rewrite.js +25 -0
- package/dist/commands/rewrite.js.map +1 -0
- package/dist/commands/setup.d.ts +2 -0
- package/dist/commands/setup.js +38 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/system-prompt.d.ts +3 -0
- package/dist/commands/system-prompt.js +36 -0
- package/dist/commands/system-prompt.js.map +1 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +114 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/history-service.d.ts +15 -0
- package/dist/core/history-service.js +25 -0
- package/dist/core/history-service.js.map +1 -0
- package/dist/core/orchestrator.d.ts +11 -0
- package/dist/core/orchestrator.js +48 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/rewriter.d.ts +7 -0
- package/dist/core/rewriter.js +62 -0
- package/dist/core/rewriter.js.map +1 -0
- package/dist/core/system-prompt-service.d.ts +15 -0
- package/dist/core/system-prompt-service.js +30 -0
- package/dist/core/system-prompt-service.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/inference.d.ts +2 -0
- package/dist/llm/inference.js +52 -0
- package/dist/llm/inference.js.map +1 -0
- package/dist/llm/model-manager.d.ts +1 -0
- package/dist/llm/model-manager.js +5 -0
- package/dist/llm/model-manager.js.map +1 -0
- package/dist/llm/prompts/tool-calling.d.ts +3 -0
- package/dist/llm/prompts/tool-calling.js +46 -0
- package/dist/llm/prompts/tool-calling.js.map +1 -0
- package/dist/llm/tokenizer.d.ts +1 -0
- package/dist/llm/tokenizer.js +30 -0
- package/dist/llm/tokenizer.js.map +1 -0
- package/dist/output/clipboard.d.ts +1 -0
- package/dist/output/clipboard.js +12 -0
- package/dist/output/clipboard.js.map +1 -0
- package/dist/output/file-writer.d.ts +1 -0
- package/dist/output/file-writer.js +8 -0
- package/dist/output/file-writer.js.map +1 -0
- package/dist/storage/config-repo.d.ts +11 -0
- package/dist/storage/config-repo.js +42 -0
- package/dist/storage/config-repo.js.map +1 -0
- package/dist/storage/database.d.ts +4 -0
- package/dist/storage/database.js +54 -0
- package/dist/storage/database.js.map +1 -0
- package/dist/storage/history-repo.d.ts +10 -0
- package/dist/storage/history-repo.js +48 -0
- package/dist/storage/history-repo.js.map +1 -0
- package/dist/storage/schema.d.ts +183 -0
- package/dist/storage/schema.js +16 -0
- package/dist/storage/schema.js.map +1 -0
- package/dist/tools/implementations.d.ts +6 -0
- package/dist/tools/implementations.js +96 -0
- package/dist/tools/implementations.js.map +1 -0
- package/dist/tools/index.d.ts +24 -0
- package/dist/tools/index.js +119 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/search-utils.d.ts +7 -0
- package/dist/tools/search-utils.js +73 -0
- package/dist/tools/search-utils.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/editor.d.ts +1 -0
- package/dist/utils/editor.js +25 -0
- package/dist/utils/editor.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.js +15 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/text.d.ts +2 -0
- package/dist/utils/text.js +11 -0
- package/dist/utils/text.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
|
2
|
+
export declare class ConfigRepo {
|
|
3
|
+
private db;
|
|
4
|
+
constructor(db: BetterSQLite3Database);
|
|
5
|
+
get(key: string): string | undefined;
|
|
6
|
+
set(key: string, value: string): void;
|
|
7
|
+
delete(key: string): boolean;
|
|
8
|
+
getSystemPrompt(): string;
|
|
9
|
+
getModelHfUri(): string;
|
|
10
|
+
getModelContextSize(): number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { config } from "./schema.js";
|
|
3
|
+
import { DEFAULT_SYSTEM_PROMPT, SYSTEM_PROMPT_KEY, MODEL_HF_URI, MODEL_HF_URI_KEY, MODEL_CONTEXT_SIZE_KEY, LLM_CONTEXT_SIZE, } from "../constants.js";
|
|
4
|
+
export class ConfigRepo {
|
|
5
|
+
db;
|
|
6
|
+
constructor(db) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
const row = this.db
|
|
11
|
+
.select()
|
|
12
|
+
.from(config)
|
|
13
|
+
.where(eq(config.key, key))
|
|
14
|
+
.get();
|
|
15
|
+
return row?.value;
|
|
16
|
+
}
|
|
17
|
+
set(key, value) {
|
|
18
|
+
this.db
|
|
19
|
+
.insert(config)
|
|
20
|
+
.values({ key, value })
|
|
21
|
+
.onConflictDoUpdate({ target: config.key, set: { value } })
|
|
22
|
+
.run();
|
|
23
|
+
}
|
|
24
|
+
delete(key) {
|
|
25
|
+
const result = this.db
|
|
26
|
+
.delete(config)
|
|
27
|
+
.where(eq(config.key, key))
|
|
28
|
+
.run();
|
|
29
|
+
return result.changes > 0;
|
|
30
|
+
}
|
|
31
|
+
getSystemPrompt() {
|
|
32
|
+
return this.get(SYSTEM_PROMPT_KEY) ?? DEFAULT_SYSTEM_PROMPT;
|
|
33
|
+
}
|
|
34
|
+
getModelHfUri() {
|
|
35
|
+
return this.get(MODEL_HF_URI_KEY) ?? MODEL_HF_URI;
|
|
36
|
+
}
|
|
37
|
+
getModelContextSize() {
|
|
38
|
+
const val = this.get(MODEL_CONTEXT_SIZE_KEY);
|
|
39
|
+
return val ? Number(val) : LLM_CONTEXT_SIZE;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=config-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-repo.js","sourceRoot":"","sources":["../../src/storage/config-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,OAAO,UAAU;IACD;IAApB,YAAoB,EAAyB;QAAzB,OAAE,GAAF,EAAE,CAAuB;IAAG,CAAC;IAEjD,GAAG,CAAC,GAAW;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,MAAM,EAAE;aACR,IAAI,CAAC,MAAM,CAAC;aACZ,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aAC1B,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,EAAE,KAAK,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,CAAC,EAAE;aACJ,MAAM,CAAC,MAAM,CAAC;aACd,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;aACtB,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;aAC1D,GAAG,EAAE,CAAC;IACX,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE;aACnB,MAAM,CAAC,MAAM,CAAC;aACd,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aAC1B,GAAG,EAAE,CAAC;QACT,OAAO,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,qBAAqB,CAAC;IAC9D,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,YAAY,CAAC;IACpD,CAAC;IAED,mBAAmB;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC9C,CAAC;CAEF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
3
|
+
import { resolveDbPath } from "../utils/paths.js";
|
|
4
|
+
import { DEFAULT_SYSTEM_PROMPT, SYSTEM_PROMPT_KEY } from "../constants.js";
|
|
5
|
+
let db = null;
|
|
6
|
+
let drizzleDb = null;
|
|
7
|
+
function migrate(database) {
|
|
8
|
+
const version = database.pragma("user_version", { simple: true });
|
|
9
|
+
if (version < 1) {
|
|
10
|
+
database.exec(`
|
|
11
|
+
CREATE TABLE IF NOT EXISTS history (
|
|
12
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
13
|
+
directory TEXT NOT NULL,
|
|
14
|
+
raw_input TEXT NOT NULL,
|
|
15
|
+
improved_output TEXT NOT NULL,
|
|
16
|
+
final_output TEXT NOT NULL,
|
|
17
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS config (
|
|
21
|
+
key TEXT PRIMARY KEY,
|
|
22
|
+
value TEXT NOT NULL
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
PRAGMA user_version = 1;
|
|
26
|
+
`);
|
|
27
|
+
database
|
|
28
|
+
.prepare("INSERT OR IGNORE INTO config (key, value) VALUES (?, ?)")
|
|
29
|
+
.run(SYSTEM_PROMPT_KEY, DEFAULT_SYSTEM_PROMPT);
|
|
30
|
+
}
|
|
31
|
+
if (version < 2) {
|
|
32
|
+
database.exec(`
|
|
33
|
+
ALTER TABLE history ADD COLUMN model_name TEXT;
|
|
34
|
+
PRAGMA user_version = 2;
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function getDatabase() {
|
|
39
|
+
if (db)
|
|
40
|
+
return db;
|
|
41
|
+
const dbPath = resolveDbPath();
|
|
42
|
+
db = new Database(dbPath);
|
|
43
|
+
db.pragma("journal_mode = WAL");
|
|
44
|
+
migrate(db);
|
|
45
|
+
return db;
|
|
46
|
+
}
|
|
47
|
+
export function getDrizzle() {
|
|
48
|
+
if (drizzleDb)
|
|
49
|
+
return drizzleDb;
|
|
50
|
+
const sqlite = getDatabase();
|
|
51
|
+
drizzleDb = drizzle({ client: sqlite });
|
|
52
|
+
return drizzleDb;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/storage/database.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,IAAI,EAAE,GAA6B,IAAI,CAAC;AACxC,IAAI,SAAS,GAAiC,IAAI,CAAC;AAEnD,SAAS,OAAO,CAAC,QAA2B;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAW,CAAC;IAE5E,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;KAgBb,CAAC,CAAC;QAEH,QAAQ;aACL,OAAO,CAAC,yDAAyD,CAAC;aAClE,GAAG,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC;;;KAGb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAElB,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,SAAS,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
|
2
|
+
import type { HistoryEntry } from "../types.js";
|
|
3
|
+
export declare class HistoryRepo {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: BetterSQLite3Database);
|
|
6
|
+
create(entry: Omit<HistoryEntry, "id" | "created_at">): HistoryEntry;
|
|
7
|
+
list(directory?: string, limit?: number): HistoryEntry[];
|
|
8
|
+
findById(id: number): HistoryEntry | undefined;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { eq, desc } from "drizzle-orm";
|
|
2
|
+
import { history } from "./schema.js";
|
|
3
|
+
import { DEFAULT_HISTORY_LIMIT } from "../constants.js";
|
|
4
|
+
export class HistoryRepo {
|
|
5
|
+
db;
|
|
6
|
+
constructor(db) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
}
|
|
9
|
+
create(entry) {
|
|
10
|
+
const result = this.db
|
|
11
|
+
.insert(history)
|
|
12
|
+
.values({
|
|
13
|
+
directory: entry.directory,
|
|
14
|
+
raw_input: entry.raw_input,
|
|
15
|
+
improved_output: entry.improved_output,
|
|
16
|
+
final_output: entry.final_output,
|
|
17
|
+
model_name: entry.model_name,
|
|
18
|
+
})
|
|
19
|
+
.run();
|
|
20
|
+
return this.db
|
|
21
|
+
.select()
|
|
22
|
+
.from(history)
|
|
23
|
+
.where(eq(history.id, Number(result.lastInsertRowid)))
|
|
24
|
+
.get();
|
|
25
|
+
}
|
|
26
|
+
list(directory, limit = DEFAULT_HISTORY_LIMIT) {
|
|
27
|
+
const query = this.db
|
|
28
|
+
.select()
|
|
29
|
+
.from(history)
|
|
30
|
+
.orderBy(desc(history.created_at))
|
|
31
|
+
.limit(limit);
|
|
32
|
+
if (directory) {
|
|
33
|
+
return query.where(eq(history.directory, directory)).all();
|
|
34
|
+
}
|
|
35
|
+
return query.all();
|
|
36
|
+
}
|
|
37
|
+
findById(id) {
|
|
38
|
+
return this.db
|
|
39
|
+
.select()
|
|
40
|
+
.from(history)
|
|
41
|
+
.where(eq(history.id, id))
|
|
42
|
+
.get();
|
|
43
|
+
}
|
|
44
|
+
clear() {
|
|
45
|
+
this.db.delete(history).run();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=history-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-repo.js","sourceRoot":"","sources":["../../src/storage/history-repo.ts"],"names":[],"mappings":"A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AC;IACvC,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,EAAE;aACX,MAAM,EAAE;aACR,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aACzB,GAAG,EAA8B,CAAC;IACvC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export declare const history: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
2
|
+
name: "history";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "history";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "SQLiteInteger";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
directory: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23
|
+
name: "directory";
|
|
24
|
+
tableName: "history";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "SQLiteText";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {
|
|
39
|
+
length: number | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
raw_input: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
42
|
+
name: "raw_input";
|
|
43
|
+
tableName: "history";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "SQLiteText";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {
|
|
58
|
+
length: number | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
improved_output: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
61
|
+
name: "improved_output";
|
|
62
|
+
tableName: "history";
|
|
63
|
+
dataType: "string";
|
|
64
|
+
columnType: "SQLiteText";
|
|
65
|
+
data: string;
|
|
66
|
+
driverParam: string;
|
|
67
|
+
notNull: true;
|
|
68
|
+
hasDefault: false;
|
|
69
|
+
isPrimaryKey: false;
|
|
70
|
+
isAutoincrement: false;
|
|
71
|
+
hasRuntimeDefault: false;
|
|
72
|
+
enumValues: [string, ...string[]];
|
|
73
|
+
baseColumn: never;
|
|
74
|
+
identity: undefined;
|
|
75
|
+
generated: undefined;
|
|
76
|
+
}, {}, {
|
|
77
|
+
length: number | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
final_output: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
80
|
+
name: "final_output";
|
|
81
|
+
tableName: "history";
|
|
82
|
+
dataType: "string";
|
|
83
|
+
columnType: "SQLiteText";
|
|
84
|
+
data: string;
|
|
85
|
+
driverParam: string;
|
|
86
|
+
notNull: true;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
isPrimaryKey: false;
|
|
89
|
+
isAutoincrement: false;
|
|
90
|
+
hasRuntimeDefault: false;
|
|
91
|
+
enumValues: [string, ...string[]];
|
|
92
|
+
baseColumn: never;
|
|
93
|
+
identity: undefined;
|
|
94
|
+
generated: undefined;
|
|
95
|
+
}, {}, {
|
|
96
|
+
length: number | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
model_name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
99
|
+
name: "model_name";
|
|
100
|
+
tableName: "history";
|
|
101
|
+
dataType: "string";
|
|
102
|
+
columnType: "SQLiteText";
|
|
103
|
+
data: string;
|
|
104
|
+
driverParam: string;
|
|
105
|
+
notNull: false;
|
|
106
|
+
hasDefault: false;
|
|
107
|
+
isPrimaryKey: false;
|
|
108
|
+
isAutoincrement: false;
|
|
109
|
+
hasRuntimeDefault: false;
|
|
110
|
+
enumValues: [string, ...string[]];
|
|
111
|
+
baseColumn: never;
|
|
112
|
+
identity: undefined;
|
|
113
|
+
generated: undefined;
|
|
114
|
+
}, {}, {
|
|
115
|
+
length: number | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
118
|
+
name: "created_at";
|
|
119
|
+
tableName: "history";
|
|
120
|
+
dataType: "string";
|
|
121
|
+
columnType: "SQLiteText";
|
|
122
|
+
data: string;
|
|
123
|
+
driverParam: string;
|
|
124
|
+
notNull: false;
|
|
125
|
+
hasDefault: true;
|
|
126
|
+
isPrimaryKey: false;
|
|
127
|
+
isAutoincrement: false;
|
|
128
|
+
hasRuntimeDefault: false;
|
|
129
|
+
enumValues: [string, ...string[]];
|
|
130
|
+
baseColumn: never;
|
|
131
|
+
identity: undefined;
|
|
132
|
+
generated: undefined;
|
|
133
|
+
}, {}, {
|
|
134
|
+
length: number | undefined;
|
|
135
|
+
}>;
|
|
136
|
+
};
|
|
137
|
+
dialect: "sqlite";
|
|
138
|
+
}>;
|
|
139
|
+
export declare const config: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
140
|
+
name: "config";
|
|
141
|
+
schema: undefined;
|
|
142
|
+
columns: {
|
|
143
|
+
key: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
144
|
+
name: "key";
|
|
145
|
+
tableName: "config";
|
|
146
|
+
dataType: "string";
|
|
147
|
+
columnType: "SQLiteText";
|
|
148
|
+
data: string;
|
|
149
|
+
driverParam: string;
|
|
150
|
+
notNull: true;
|
|
151
|
+
hasDefault: false;
|
|
152
|
+
isPrimaryKey: true;
|
|
153
|
+
isAutoincrement: false;
|
|
154
|
+
hasRuntimeDefault: false;
|
|
155
|
+
enumValues: [string, ...string[]];
|
|
156
|
+
baseColumn: never;
|
|
157
|
+
identity: undefined;
|
|
158
|
+
generated: undefined;
|
|
159
|
+
}, {}, {
|
|
160
|
+
length: number | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
value: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
163
|
+
name: "value";
|
|
164
|
+
tableName: "config";
|
|
165
|
+
dataType: "string";
|
|
166
|
+
columnType: "SQLiteText";
|
|
167
|
+
data: string;
|
|
168
|
+
driverParam: string;
|
|
169
|
+
notNull: true;
|
|
170
|
+
hasDefault: false;
|
|
171
|
+
isPrimaryKey: false;
|
|
172
|
+
isAutoincrement: false;
|
|
173
|
+
hasRuntimeDefault: false;
|
|
174
|
+
enumValues: [string, ...string[]];
|
|
175
|
+
baseColumn: never;
|
|
176
|
+
identity: undefined;
|
|
177
|
+
generated: undefined;
|
|
178
|
+
}, {}, {
|
|
179
|
+
length: number | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
};
|
|
182
|
+
dialect: "sqlite";
|
|
183
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
+
import { sql } from "drizzle-orm";
|
|
3
|
+
export const history = sqliteTable("history", {
|
|
4
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
5
|
+
directory: text("directory").notNull(),
|
|
6
|
+
raw_input: text("raw_input").notNull(),
|
|
7
|
+
improved_output: text("improved_output").notNull(),
|
|
8
|
+
final_output: text("final_output").notNull(),
|
|
9
|
+
model_name: text("model_name"),
|
|
10
|
+
created_at: text("created_at").default(sql `(datetime('now'))`),
|
|
11
|
+
});
|
|
12
|
+
export const config = sqliteTable("config", {
|
|
13
|
+
key: text("key").primaryKey(),
|
|
14
|
+
value: text("value").notNull(),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/storage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE;IAC5C,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrD,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;IACtC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;IACtC,eAAe,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE;IAClD,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC5C,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;IAC9B,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA,mBAAmB,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,EAAE;IAC1C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE;IAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ignore } from "ignore";
|
|
2
|
+
export declare function fileFinder(query: string, dir: string, ig: Ignore): string;
|
|
3
|
+
export declare function sectionFinder(query: string, dir: string, ig: Ignore): string;
|
|
4
|
+
export declare function definitionFinder(query: string, dir: string, ig: Ignore): string;
|
|
5
|
+
export declare function importTracer(query: string, dir: string, ig: Ignore): string;
|
|
6
|
+
export declare function gitHistory(query: string, dir: string): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { escapeRegex, filterLines, stripDirPrefix, grepSync, gitSync, } from "./search-utils.js";
|
|
2
|
+
const MAX_FILES = 10;
|
|
3
|
+
const MAX_LINES = 20;
|
|
4
|
+
const MAX_COMMITS = 10;
|
|
5
|
+
// Multi-language definition patterns:
|
|
6
|
+
// JS/TS: export, function, class, interface, type, const, enum
|
|
7
|
+
// Python: def, class, async def
|
|
8
|
+
// Go: func, type, var, const
|
|
9
|
+
// Rust: pub fn, pub struct, pub enum, pub type, pub trait, fn, struct, enum, trait
|
|
10
|
+
// Swift: func, class, struct, enum, protocol
|
|
11
|
+
// Ruby: def, class, module
|
|
12
|
+
// Java/Kotlin: public class, public interface, abstract class
|
|
13
|
+
const DEFINITION_PATTERN = "(export\\s+(default\\s+)?)?(pub\\s+)?(async\\s+)?" +
|
|
14
|
+
"(function|class|interface|type|const|enum|struct|trait|protocol|module|def|func|fn|var|let|val)\\s+";
|
|
15
|
+
function scoreFilePath(filePath, lowerQuery) {
|
|
16
|
+
const lower = filePath.toLowerCase();
|
|
17
|
+
const basename = lower.split("/").pop() ?? "";
|
|
18
|
+
let score = 1; // base score for content match
|
|
19
|
+
if (basename.includes(lowerQuery))
|
|
20
|
+
score += 3;
|
|
21
|
+
else if (lower.includes(lowerQuery))
|
|
22
|
+
score += 1;
|
|
23
|
+
return score;
|
|
24
|
+
}
|
|
25
|
+
export function fileFinder(query, dir, ig) {
|
|
26
|
+
const escaped = escapeRegex(query);
|
|
27
|
+
const output = grepSync(["-rli", "-E", escaped, dir], dir);
|
|
28
|
+
if (!output)
|
|
29
|
+
return "No matching files found.";
|
|
30
|
+
const filtered = filterLines(output.split("\n"), dir, ig);
|
|
31
|
+
if (filtered.length === 0)
|
|
32
|
+
return "No matching files found.";
|
|
33
|
+
const lowerQuery = query.toLowerCase();
|
|
34
|
+
const scored = filtered
|
|
35
|
+
.map((l) => ({ path: stripDirPrefix(l, dir), score: scoreFilePath(l, lowerQuery) }))
|
|
36
|
+
.sort((a, b) => b.score - a.score)
|
|
37
|
+
.slice(0, MAX_FILES);
|
|
38
|
+
return scored.map((s) => s.path).join("\n");
|
|
39
|
+
}
|
|
40
|
+
export function sectionFinder(query, dir, ig) {
|
|
41
|
+
const escaped = escapeRegex(query);
|
|
42
|
+
const output = grepSync(["-rni", "-E", escaped, dir], dir);
|
|
43
|
+
if (!output)
|
|
44
|
+
return "No matching code found.";
|
|
45
|
+
const filtered = filterLines(output.split("\n"), dir, ig);
|
|
46
|
+
if (filtered.length === 0)
|
|
47
|
+
return "No matching code found.";
|
|
48
|
+
const lowerQuery = query.toLowerCase();
|
|
49
|
+
const scored = filtered
|
|
50
|
+
.map((l) => ({ line: stripDirPrefix(l, dir), score: scoreFilePath(l, lowerQuery) }))
|
|
51
|
+
.sort((a, b) => b.score - a.score)
|
|
52
|
+
.slice(0, MAX_LINES);
|
|
53
|
+
return scored.map((s) => s.line).join("\n");
|
|
54
|
+
}
|
|
55
|
+
export function definitionFinder(query, dir, ig) {
|
|
56
|
+
const output = grepSync(["-rnE", DEFINITION_PATTERN, dir], dir);
|
|
57
|
+
if (!output)
|
|
58
|
+
return "No definitions found.";
|
|
59
|
+
const lowerQuery = query.toLowerCase();
|
|
60
|
+
const filtered = filterLines(output.split("\n"), dir, ig)
|
|
61
|
+
.filter((line) => line.toLowerCase().includes(lowerQuery))
|
|
62
|
+
.slice(0, MAX_LINES);
|
|
63
|
+
if (filtered.length === 0)
|
|
64
|
+
return "No matching definitions found.";
|
|
65
|
+
return filtered.map((l) => stripDirPrefix(l, dir)).join("\n");
|
|
66
|
+
}
|
|
67
|
+
export function importTracer(query, dir, ig) {
|
|
68
|
+
const escaped = escapeRegex(query);
|
|
69
|
+
const output = grepSync(["-rnE", `(import|from|require|include|use).*${escaped}`, dir], dir);
|
|
70
|
+
if (!output)
|
|
71
|
+
return "No matching imports found.";
|
|
72
|
+
const lines = filterLines(output.split("\n"), dir, ig).slice(0, MAX_LINES);
|
|
73
|
+
if (lines.length === 0)
|
|
74
|
+
return "No matching imports found.";
|
|
75
|
+
return lines.map((l) => stripDirPrefix(l, dir)).join("\n");
|
|
76
|
+
}
|
|
77
|
+
export function gitHistory(query, dir) {
|
|
78
|
+
const output = gitSync(["log", "--format=>> %h %s", "--name-only", "-n", String(MAX_COMMITS), "-S", query], dir);
|
|
79
|
+
if (!output)
|
|
80
|
+
return "No commits found matching this keyword.";
|
|
81
|
+
const commits = [];
|
|
82
|
+
for (const line of output.split("\n")) {
|
|
83
|
+
if (line.startsWith(">> ")) {
|
|
84
|
+
commits.push({ header: line.slice(3), files: [] });
|
|
85
|
+
}
|
|
86
|
+
else if (line && commits.length > 0) {
|
|
87
|
+
commits[commits.length - 1].files.push(line);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return commits
|
|
91
|
+
.map((c) => c.files.length > 0
|
|
92
|
+
? `${c.header}\n ${c.files.join("\n ")}`
|
|
93
|
+
: c.header)
|
|
94
|
+
.join("\n");
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=implementations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementations.js","sourceRoot":"","sources":["../../src/tools/implementations.ts"],"names":[],"mappings":"AACA,OAAO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G,CAAC,EAAE,CAAC;YACtC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC1C,CAAC,CAAC,CAAC,CAAC,MAAM,CACb;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Ignore } from "ignore";
|
|
2
|
+
export { loadIgnoreFilter } from "./search-utils.js";
|
|
3
|
+
export interface ToolCall {
|
|
4
|
+
name: string;
|
|
5
|
+
arguments: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export declare function executeToolCall(call: ToolCall, dir: string, ig: Ignore): Promise<string>;
|
|
8
|
+
export declare const TOOL_DEFINITIONS: {
|
|
9
|
+
type: string;
|
|
10
|
+
function: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
parameters: {
|
|
14
|
+
type: string;
|
|
15
|
+
properties: {
|
|
16
|
+
query: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { fileFinder, sectionFinder, definitionFinder, importTracer, gitHistory, } from "./implementations.js";
|
|
2
|
+
export { loadIgnoreFilter } from "./search-utils.js";
|
|
3
|
+
export async function executeToolCall(call, dir, ig) {
|
|
4
|
+
switch (call.name) {
|
|
5
|
+
case "file_finder":
|
|
6
|
+
return fileFinder(call.arguments.query, dir, ig);
|
|
7
|
+
case "section_finder":
|
|
8
|
+
return sectionFinder(call.arguments.query, dir, ig);
|
|
9
|
+
case "definition_finder":
|
|
10
|
+
return definitionFinder(call.arguments.query, dir, ig);
|
|
11
|
+
case "import_tracer":
|
|
12
|
+
return importTracer(call.arguments.query, dir, ig);
|
|
13
|
+
case "git_history":
|
|
14
|
+
return gitHistory(call.arguments.query, dir);
|
|
15
|
+
default:
|
|
16
|
+
return `Unknown tool: ${call.name}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const TOOL_DEFINITIONS = [
|
|
20
|
+
{
|
|
21
|
+
type: "function",
|
|
22
|
+
function: {
|
|
23
|
+
name: "file_finder",
|
|
24
|
+
description: "Find files matching a keyword. Returns file paths. " +
|
|
25
|
+
"Pair with section_finder using a different keyword to also get code snippets.",
|
|
26
|
+
parameters: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
query: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "A single keyword to search for in file contents. Use concise, specific terms " +
|
|
32
|
+
"(e.g., 'camera', 'auth', 'Router'). Avoid multi-word phrases.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["query"],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "function",
|
|
41
|
+
function: {
|
|
42
|
+
name: "section_finder",
|
|
43
|
+
description: "Find code snippets matching a keyword. Returns file:line:code entries. " +
|
|
44
|
+
"Use alongside file_finder with a different keyword for complete context.",
|
|
45
|
+
parameters: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
query: {
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "A single keyword to find in source code. Use specific identifiers " +
|
|
51
|
+
"(e.g., 'handleSubmit', 'CameraView', 'fetchUser'). Case-insensitive.",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ["query"],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "function",
|
|
60
|
+
function: {
|
|
61
|
+
name: "definition_finder",
|
|
62
|
+
description: "Find function, class, type, interface, struct, enum, and other definition declarations " +
|
|
63
|
+
"matching a keyword. Works across languages (JS/TS, Python, Go, Rust, Swift, Ruby, Java). " +
|
|
64
|
+
"Returns up to 15 results. Use this to find where something is defined, not where it is used.",
|
|
65
|
+
parameters: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
query: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "A single keyword matching the name of a function, class, type, or other definition " +
|
|
71
|
+
"(e.g., 'Camera', 'UserService', 'parse_config'). Case-insensitive.",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
required: ["query"],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "function",
|
|
80
|
+
function: {
|
|
81
|
+
name: "import_tracer",
|
|
82
|
+
description: "Find import, require, include, and use statements that reference a module or keyword. " +
|
|
83
|
+
"Shows the dependency graph — which files depend on the given module. " +
|
|
84
|
+
"Returns up to 15 results. Use this to understand how modules are connected.",
|
|
85
|
+
parameters: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
query: {
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "A module name or keyword to search for in import statements " +
|
|
91
|
+
"(e.g., 'camera', 'utils', 'express'). Case-sensitive for import paths.",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ["query"],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: "function",
|
|
100
|
+
function: {
|
|
101
|
+
name: "git_history",
|
|
102
|
+
description: "Search git commit history for the 10 most recent commits that added or removed " +
|
|
103
|
+
"code containing the given keyword. Use this when the user references a recent change, " +
|
|
104
|
+
"regression, or wants to understand what changed recently related to a topic.",
|
|
105
|
+
parameters: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
query: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "A keyword to search in commit diffs (e.g., 'camera', 'auth'). " +
|
|
111
|
+
"Git searches for commits where this string was added or removed.",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
required: ["query"],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAc,EACd,GAAW,EACX,EAAU;IAEV,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACnD,KAAK,gBAAgB;YACnB,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACtD,KAAK,mBAAmB;YACtB,OAAO,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACzD,KAAK,eAAe;YAClB,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACrD,KAAK,aAAa;YAChB,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C;YACE,OA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