@grepai/cli 0.7.3 → 0.7.5
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/index.js +179 -17
- package/index.js.map +15 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -89672,7 +89672,7 @@ class AgentFs extends Service()("@grepai/core/internal/services/agentfs", {
|
|
|
89672
89672
|
}
|
|
89673
89673
|
|
|
89674
89674
|
// ../core/src/domain/index.ts
|
|
89675
|
-
var SupportedLanguage = Literal2("typescript", "tsx");
|
|
89675
|
+
var SupportedLanguage = Literal2("typescript", "tsx", "json", "javascript");
|
|
89676
89676
|
|
|
89677
89677
|
// ../core/src/domain/embedding.ts
|
|
89678
89678
|
var Embedding2 = transformOrFail(Union2(NonEmptyArray(Number$), String$), String$, {
|
|
@@ -100710,17 +100710,27 @@ var LanceDbLive = Migrations.Default.pipe(provideMerge2(LanceDb.Default));
|
|
|
100710
100710
|
var ChunkStorageLanceDb = effect(ChunkStorage, gen2(function* () {
|
|
100711
100711
|
const db = yield* LanceDb;
|
|
100712
100712
|
const embedder = yield* Embedder;
|
|
100713
|
+
const config3 = yield* Config;
|
|
100714
|
+
function withNormalizedFilePath(input) {
|
|
100715
|
+
if (config3.experimental__agentFs) {
|
|
100716
|
+
return {
|
|
100717
|
+
...input,
|
|
100718
|
+
filePath: `/${input.filePath}`
|
|
100719
|
+
};
|
|
100720
|
+
}
|
|
100721
|
+
return input;
|
|
100722
|
+
}
|
|
100713
100723
|
const search = fnUntraced2(function* (input) {
|
|
100714
100724
|
const { query, topK = 10 } = input;
|
|
100715
100725
|
const queryEmbedding = yield* embedder.embedQuery(query).pipe(flatMap10(decode3(EmbeddingA)));
|
|
100716
|
-
return yield* db.useTable((t) => t.vectorSearch(fromIterable(queryEmbedding)).distanceType("cosine").limit(topK).select(["filePath", "startLine", "endLine", "_distance"]).toArray()).pipe(flatMap10(decodeUnknown2(Array$(ChunkSearchResult))));
|
|
100726
|
+
return yield* db.useTable((t) => t.vectorSearch(fromIterable(queryEmbedding)).distanceType("cosine").limit(topK).select(["filePath", "startLine", "endLine", "_distance"]).toArray()).pipe(flatMap10(decodeUnknown2(Array$(ChunkSearchResult))), map16(map4(withNormalizedFilePath)));
|
|
100717
100727
|
}, catchTags2({
|
|
100718
100728
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
100719
100729
|
LanceDbError: (cause2) => new ChunkStorageError({ cause: cause2 })
|
|
100720
100730
|
}));
|
|
100721
100731
|
const grep = fnUntraced2(function* (input) {
|
|
100722
100732
|
const { pattern: pattern2, limit = 100 } = input;
|
|
100723
|
-
return yield* db.useTable((t) => t.query().where(`content LIKE '%${pattern2}%'`).select(["filePath", "startLine", "endLine", "content"]).limit(limit).toArray()).pipe(flatMap10(decodeUnknown2(Array$(GrepResult))));
|
|
100733
|
+
return yield* db.useTable((t) => t.query().where(`content LIKE '%${pattern2}%'`).select(["filePath", "startLine", "endLine", "content"]).limit(limit).toArray()).pipe(flatMap10(decodeUnknown2(Array$(GrepResult))), map16(map4(withNormalizedFilePath)));
|
|
100724
100734
|
}, catchTags2({
|
|
100725
100735
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
100726
100736
|
LanceDbError: (cause2) => new ChunkStorageError({ cause: cause2 })
|
|
@@ -100758,6 +100768,16 @@ class SqlError extends (/* @__PURE__ */ TypeIdError(SqlErrorTypeId, "SqlError"))
|
|
|
100758
100768
|
var ChunkStorageSql = effect(ChunkStorage, gen2(function* () {
|
|
100759
100769
|
const db = yield* exports_SqlClient.SqlClient;
|
|
100760
100770
|
const embedder = yield* Embedder;
|
|
100771
|
+
const config3 = yield* Config;
|
|
100772
|
+
function withNormalizedFilePath(input) {
|
|
100773
|
+
if (config3.experimental__agentFs) {
|
|
100774
|
+
return {
|
|
100775
|
+
...input,
|
|
100776
|
+
filePath: `/${input.filePath}`
|
|
100777
|
+
};
|
|
100778
|
+
}
|
|
100779
|
+
return input;
|
|
100780
|
+
}
|
|
100761
100781
|
const search = fnUntraced2(function* (input) {
|
|
100762
100782
|
const { query, topK = 10 } = input;
|
|
100763
100783
|
const queryEmbedding = yield* embedder.embedQuery(query);
|
|
@@ -100790,7 +100810,7 @@ var ChunkStorageSql = effect(ChunkStorage, gen2(function* () {
|
|
|
100790
100810
|
INNER JOIN
|
|
100791
100811
|
chunks c ON c.id = ce.chunk_id
|
|
100792
100812
|
`
|
|
100793
|
-
}).pipe(flatMap10(decodeUnknown2(Array$(ChunkSearchResult))));
|
|
100813
|
+
}).pipe(flatMap10(decodeUnknown2(Array$(ChunkSearchResult))), map16(map4(withNormalizedFilePath)));
|
|
100794
100814
|
}, catchTags2({
|
|
100795
100815
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
100796
100816
|
SqlError: (cause2) => new ChunkStorageError({ cause: cause2 })
|
|
@@ -100822,7 +100842,7 @@ var ChunkStorageSql = effect(ChunkStorage, gen2(function* () {
|
|
|
100822
100842
|
INSTR(c.content, ${pattern2}) > 0
|
|
100823
100843
|
LIMIT ${limit}
|
|
100824
100844
|
`
|
|
100825
|
-
}).pipe(flatMap10(decodeUnknown2(Array$(GrepResult))));
|
|
100845
|
+
}).pipe(flatMap10(decodeUnknown2(Array$(GrepResult))), map16(map4(withNormalizedFilePath)));
|
|
100826
100846
|
}, catchTags2({
|
|
100827
100847
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
100828
100848
|
SqlError: (cause2) => new ChunkStorageError({ cause: cause2 })
|
|
@@ -104198,7 +104218,9 @@ class AstParser extends Service()("@grepai/core/internal/services/chunker-ast/as
|
|
|
104198
104218
|
}
|
|
104199
104219
|
var languageMap2 = {
|
|
104200
104220
|
typescript: "./tree-sitter-typescript.wasm",
|
|
104201
|
-
tsx: "./tree-sitter-tsx.wasm"
|
|
104221
|
+
tsx: "./tree-sitter-tsx.wasm",
|
|
104222
|
+
json: "./tree-sitter-json.wasm",
|
|
104223
|
+
javascript: "./tree-sitter-javascript.wasm"
|
|
104202
104224
|
};
|
|
104203
104225
|
|
|
104204
104226
|
// ../core/src/internal/services/chunker-ast/context-header-builder.ts
|
|
@@ -104220,10 +104242,122 @@ class ContextHeaderBuilder extends Service()("@grepai/core/internal/services/chu
|
|
|
104220
104242
|
}) {
|
|
104221
104243
|
}
|
|
104222
104244
|
|
|
104245
|
+
// ../core/src/internal/services/chunker-ast/language-config/javascript.ts
|
|
104246
|
+
var javascript = {
|
|
104247
|
+
isClosingSyntax: (text13) => /^[\s)\]}>]+$/.test(text13),
|
|
104248
|
+
extractNodeName,
|
|
104249
|
+
wantedNodes: new Set([
|
|
104250
|
+
"function_declaration",
|
|
104251
|
+
"function_expression",
|
|
104252
|
+
"generator_function_declaration",
|
|
104253
|
+
"generator_function",
|
|
104254
|
+
"arrow_function",
|
|
104255
|
+
"method_definition",
|
|
104256
|
+
"class_declaration",
|
|
104257
|
+
"class",
|
|
104258
|
+
"field_definition",
|
|
104259
|
+
"class_static_block",
|
|
104260
|
+
"lexical_declaration",
|
|
104261
|
+
"variable_declaration",
|
|
104262
|
+
"export_statement",
|
|
104263
|
+
"import_statement"
|
|
104264
|
+
]),
|
|
104265
|
+
scopeNodes: new Set([
|
|
104266
|
+
"function_declaration",
|
|
104267
|
+
"generator_function_declaration",
|
|
104268
|
+
"method_definition",
|
|
104269
|
+
"class_declaration",
|
|
104270
|
+
"class",
|
|
104271
|
+
"lexical_declaration",
|
|
104272
|
+
"variable_declaration"
|
|
104273
|
+
]),
|
|
104274
|
+
importNodes: new Set(["import_statement", "export_statement"])
|
|
104275
|
+
};
|
|
104276
|
+
function extractNodeName(node) {
|
|
104277
|
+
const nameChild = node.childForFieldName("name");
|
|
104278
|
+
if (nameChild) {
|
|
104279
|
+
return nameChild.text;
|
|
104280
|
+
}
|
|
104281
|
+
if (node.type === "lexical_declaration" || node.type === "variable_declaration") {
|
|
104282
|
+
const declarator = node.namedChildren.find((child) => child.type === "variable_declarator");
|
|
104283
|
+
if (declarator) {
|
|
104284
|
+
const varName = declarator.childForFieldName("name");
|
|
104285
|
+
if (varName) {
|
|
104286
|
+
return varName.text;
|
|
104287
|
+
}
|
|
104288
|
+
}
|
|
104289
|
+
}
|
|
104290
|
+
const identifierChild = node.namedChildren.find((child) => child.type === "identifier" || child.type === "property_identifier");
|
|
104291
|
+
if (identifierChild) {
|
|
104292
|
+
return identifierChild.text;
|
|
104293
|
+
}
|
|
104294
|
+
if (node.type === "arrow_function" || node.type === "function_expression" || node.type === "generator_function") {
|
|
104295
|
+
let ancestor = node.parent;
|
|
104296
|
+
while (ancestor) {
|
|
104297
|
+
if (ancestor.type === "variable_declarator") {
|
|
104298
|
+
const varName = ancestor.childForFieldName("name");
|
|
104299
|
+
if (varName) {
|
|
104300
|
+
return varName.text;
|
|
104301
|
+
}
|
|
104302
|
+
}
|
|
104303
|
+
if (ancestor.type === "pair") {
|
|
104304
|
+
const key = ancestor.childForFieldName("key");
|
|
104305
|
+
if (key) {
|
|
104306
|
+
return key.text;
|
|
104307
|
+
}
|
|
104308
|
+
}
|
|
104309
|
+
if (ancestor.type === "lexical_declaration" || ancestor.type === "variable_declaration" || ancestor.type === "expression_statement") {
|
|
104310
|
+
break;
|
|
104311
|
+
}
|
|
104312
|
+
ancestor = ancestor.parent;
|
|
104313
|
+
}
|
|
104314
|
+
}
|
|
104315
|
+
return "<anonymous>";
|
|
104316
|
+
}
|
|
104317
|
+
|
|
104318
|
+
// ../core/src/internal/services/chunker-ast/language-config/json.ts
|
|
104319
|
+
var json4 = {
|
|
104320
|
+
isClosingSyntax: (text13) => /^[\s\]},]+$/.test(text13),
|
|
104321
|
+
extractNodeName: extractNodeName2,
|
|
104322
|
+
wantedNodes: new Set(["pair"]),
|
|
104323
|
+
scopeNodes: new Set(["pair"]),
|
|
104324
|
+
importNodes: new Set([])
|
|
104325
|
+
};
|
|
104326
|
+
function extractNodeName2(node) {
|
|
104327
|
+
if (node.type === "pair") {
|
|
104328
|
+
const key = node.childForFieldName("key");
|
|
104329
|
+
if (key) {
|
|
104330
|
+
return stripQuotes(key.text);
|
|
104331
|
+
}
|
|
104332
|
+
return "<pair>";
|
|
104333
|
+
}
|
|
104334
|
+
if (node.type === "object" || node.type === "array") {
|
|
104335
|
+
let ancestor = node.parent;
|
|
104336
|
+
while (ancestor) {
|
|
104337
|
+
if (ancestor.type === "pair") {
|
|
104338
|
+
const key = ancestor.childForFieldName("key");
|
|
104339
|
+
if (key) {
|
|
104340
|
+
return stripQuotes(key.text);
|
|
104341
|
+
}
|
|
104342
|
+
break;
|
|
104343
|
+
}
|
|
104344
|
+
ancestor = ancestor.parent;
|
|
104345
|
+
}
|
|
104346
|
+
return node.type === "object" ? "<object>" : "<array>";
|
|
104347
|
+
}
|
|
104348
|
+
return "<anonymous>";
|
|
104349
|
+
}
|
|
104350
|
+
function stripQuotes(text13) {
|
|
104351
|
+
if (text13.length >= 2 && text13[0] === '"' && text13[text13.length - 1] === '"') {
|
|
104352
|
+
return text13.slice(1, -1);
|
|
104353
|
+
}
|
|
104354
|
+
return text13;
|
|
104355
|
+
}
|
|
104356
|
+
|
|
104223
104357
|
// ../core/src/internal/services/chunker-ast/language-config/tsx.ts
|
|
104224
104358
|
var tsx = {
|
|
104225
104359
|
isClosingSyntax: (text13) => /^[\s)}\]>]+$/.test(text13) || /^\s*\/>/.test(text13) || /^\s*<\/[a-zA-Z_$][\w$.:-]*\s*>/.test(text13),
|
|
104226
|
-
extractNodeName,
|
|
104360
|
+
extractNodeName: extractNodeName3,
|
|
104227
104361
|
wantedNodes: new Set([
|
|
104228
104362
|
"function_declaration",
|
|
104229
104363
|
"function_expression",
|
|
@@ -104275,7 +104409,7 @@ var tsx = {
|
|
|
104275
104409
|
"import_alias"
|
|
104276
104410
|
])
|
|
104277
104411
|
};
|
|
104278
|
-
function
|
|
104412
|
+
function extractNodeName3(node) {
|
|
104279
104413
|
if (node.type === "jsx_element") {
|
|
104280
104414
|
const openTag = node.childForFieldName("open_tag");
|
|
104281
104415
|
if (openTag) {
|
|
@@ -104337,7 +104471,7 @@ function extractNodeName(node) {
|
|
|
104337
104471
|
// ../core/src/internal/services/chunker-ast/language-config/typescript.ts
|
|
104338
104472
|
var typescript = {
|
|
104339
104473
|
isClosingSyntax: (text13) => /^[\s)\]}>]+$/.test(text13),
|
|
104340
|
-
extractNodeName:
|
|
104474
|
+
extractNodeName: extractNodeName4,
|
|
104341
104475
|
wantedNodes: new Set([
|
|
104342
104476
|
"function_declaration",
|
|
104343
104477
|
"function_expression",
|
|
@@ -104387,7 +104521,7 @@ var typescript = {
|
|
|
104387
104521
|
"import_alias"
|
|
104388
104522
|
])
|
|
104389
104523
|
};
|
|
104390
|
-
function
|
|
104524
|
+
function extractNodeName4(node) {
|
|
104391
104525
|
const nameChild = node.childForFieldName("name");
|
|
104392
104526
|
if (nameChild) {
|
|
104393
104527
|
return nameChild.text;
|
|
@@ -104432,7 +104566,9 @@ function extractNodeName2(node) {
|
|
|
104432
104566
|
// ../core/src/internal/services/chunker-ast/language-config/index.ts
|
|
104433
104567
|
var languageConfig = {
|
|
104434
104568
|
typescript,
|
|
104435
|
-
tsx
|
|
104569
|
+
tsx,
|
|
104570
|
+
json: json4,
|
|
104571
|
+
javascript
|
|
104436
104572
|
};
|
|
104437
104573
|
|
|
104438
104574
|
// ../core/src/internal/services/chunker-ast/index.ts
|
|
@@ -104446,13 +104582,13 @@ var ChunkerAst = effect(Chunker, gen2(function* () {
|
|
|
104446
104582
|
wantedNodes,
|
|
104447
104583
|
scopeNodes,
|
|
104448
104584
|
importNodes,
|
|
104449
|
-
extractNodeName:
|
|
104585
|
+
extractNodeName: extractNodeName5
|
|
104450
104586
|
} = languageConfig[language];
|
|
104451
104587
|
const tokenCount = yield* tokenCounter.count(node.text);
|
|
104452
104588
|
const isWanted = wantedNodes.has(node.type);
|
|
104453
104589
|
const isScope = scopeNodes.has(node.type);
|
|
104454
104590
|
const isImport = importNodes.has(node.type);
|
|
104455
|
-
const nextScope = isScope && !isImport ? [...scopeStack,
|
|
104591
|
+
const nextScope = isScope && !isImport ? [...scopeStack, extractNodeName5(node)] : scopeStack;
|
|
104456
104592
|
if (isWanted) {
|
|
104457
104593
|
if (tokenCount <= config3.embedding.maxChunkSize || node.childCount === 0) {
|
|
104458
104594
|
return [
|
|
@@ -104627,6 +104763,18 @@ var CodebaseScannerAgentFs = scoped3(CodebaseScanner, gen2(function* () {
|
|
|
104627
104763
|
})), when5("tsx", () => ({
|
|
104628
104764
|
filePath,
|
|
104629
104765
|
language: "tsx"
|
|
104766
|
+
})), when5("json", () => ({
|
|
104767
|
+
filePath,
|
|
104768
|
+
language: "json"
|
|
104769
|
+
})), when5("js", () => ({
|
|
104770
|
+
filePath,
|
|
104771
|
+
language: "javascript"
|
|
104772
|
+
})), when5("mjs", () => ({
|
|
104773
|
+
filePath,
|
|
104774
|
+
language: "javascript"
|
|
104775
|
+
})), when5("cjs", () => ({
|
|
104776
|
+
filePath,
|
|
104777
|
+
language: "javascript"
|
|
104630
104778
|
})), option4);
|
|
104631
104779
|
}
|
|
104632
104780
|
const toScanResults = fnUntraced2(function* (files) {
|
|
@@ -104734,6 +104882,18 @@ var CodebaseScannerFs = effect(CodebaseScanner, gen2(function* () {
|
|
|
104734
104882
|
})), when5("tsx", () => ({
|
|
104735
104883
|
filePath,
|
|
104736
104884
|
language: "tsx"
|
|
104885
|
+
})), when5("json", () => ({
|
|
104886
|
+
filePath,
|
|
104887
|
+
language: "json"
|
|
104888
|
+
})), when5("js", () => ({
|
|
104889
|
+
filePath,
|
|
104890
|
+
language: "javascript"
|
|
104891
|
+
})), when5("mjs", () => ({
|
|
104892
|
+
filePath,
|
|
104893
|
+
language: "javascript"
|
|
104894
|
+
})), when5("cjs", () => ({
|
|
104895
|
+
filePath,
|
|
104896
|
+
language: "javascript"
|
|
104737
104897
|
})), option4))), flatMap10(forEach5(({ filePath, language }) => fs2.readFileString(filePath).pipe(map16((content) => ({
|
|
104738
104898
|
filePath,
|
|
104739
104899
|
language,
|
|
@@ -104776,6 +104936,7 @@ var Document2 = Struct({
|
|
|
104776
104936
|
// ../core/src/internal/services/document-storage-lancedb.ts
|
|
104777
104937
|
var DocumentStorageLanceDb = effect(DocumentStorage, gen2(function* () {
|
|
104778
104938
|
const db = yield* LanceDb;
|
|
104939
|
+
const config3 = yield* Config;
|
|
104779
104940
|
const getByFilePath = fnUntraced2(function* (filePath) {
|
|
104780
104941
|
return yield* db.useTable((t) => t.query().where(`filePath = "${filePath}"`).select(["id", "filePath", "fileHash", "createdAt", "updatedAt"]).limit(1).toArray()).pipe(map16(map4((doc2) => ({
|
|
104781
104942
|
...doc2,
|
|
@@ -104800,7 +104961,7 @@ var DocumentStorageLanceDb = effect(DocumentStorage, gen2(function* () {
|
|
|
104800
104961
|
const matcher = new Glob(pattern2);
|
|
104801
104962
|
return yield* db.useTable((t) => t.query().select(["filePath"]).toArray()).pipe(flatMap10(decodeUnknown2(Array$(Struct({
|
|
104802
104963
|
filePath: String$
|
|
104803
|
-
})))), map16(
|
|
104964
|
+
})))), map16(filterMap2(({ filePath }) => matcher.match(filePath) ? some2(filePath) : none2())), map16(dedupe), map16(map4((filePath) => config3.experimental__agentFs ? `/${filePath}` : filePath)));
|
|
104804
104965
|
}, catchTags2({
|
|
104805
104966
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
104806
104967
|
LanceDbError: (cause2) => new DocumentStorageError({ cause: cause2 })
|
|
@@ -104824,6 +104985,7 @@ var DocumentStorageLanceDb = effect(DocumentStorage, gen2(function* () {
|
|
|
104824
104985
|
var {Glob: Glob2 } = globalThis.Bun;
|
|
104825
104986
|
var DocumentStorageSql = effect(DocumentStorage, gen2(function* () {
|
|
104826
104987
|
const db = yield* exports_SqlClient.SqlClient;
|
|
104988
|
+
const config3 = yield* Config;
|
|
104827
104989
|
const getByFilePath = fnUntraced2(function* (filePath) {
|
|
104828
104990
|
return yield* db.onDialectOrElse({
|
|
104829
104991
|
orElse: () => db`
|
|
@@ -104872,7 +105034,7 @@ var DocumentStorageSql = effect(DocumentStorage, gen2(function* () {
|
|
|
104872
105034
|
FROM
|
|
104873
105035
|
documents d
|
|
104874
105036
|
`
|
|
104875
|
-
}).pipe(flatMap10(decodeUnknown2(Array$(Struct({ filePath: String$ })))), map16(filterMap2(({ filePath }) => matcher.match(filePath) ? some2(filePath) : none2())));
|
|
105037
|
+
}).pipe(flatMap10(decodeUnknown2(Array$(Struct({ filePath: String$ })))), map16(filterMap2(({ filePath }) => matcher.match(filePath) ? some2(filePath) : none2())), map16(map4((filePath) => config3.experimental__agentFs ? `/${filePath}` : filePath)));
|
|
104876
105038
|
}, catchTags2({
|
|
104877
105039
|
ParseError: (cause2) => new SchemaValidationFailed({ cause: cause2 }),
|
|
104878
105040
|
SqlError: (cause2) => new DocumentStorageError({ cause: cause2 })
|
|
@@ -112687,11 +112849,11 @@ var program = gen2(function* () {
|
|
|
112687
112849
|
]));
|
|
112688
112850
|
const cli = exports_Command.run(command, {
|
|
112689
112851
|
name: "GREP AI",
|
|
112690
|
-
version: "v0.7.
|
|
112852
|
+
version: "v0.7.5"
|
|
112691
112853
|
});
|
|
112692
112854
|
yield* cli(process.argv);
|
|
112693
112855
|
});
|
|
112694
112856
|
program.pipe(provide2(mergeAll5(GrepAi.Default).pipe(provideMerge2(Clack.Default), provideMerge2(exports_BunContext.layer))), exports_BunRuntime.runMain);
|
|
112695
112857
|
|
|
112696
|
-
//# debugId=
|
|
112858
|
+
//# debugId=502498F845B3BA6F64756E2164756E21
|
|
112697
112859
|
//# sourceMappingURL=index.js.map
|