scai 0.1.116 → 0.1.118

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 (96) hide show
  1. package/dist/agents/MainAgent.js +255 -0
  2. package/dist/agents/contextReviewStep.js +104 -0
  3. package/dist/agents/finalPlanGenStep.js +123 -0
  4. package/dist/agents/infoPlanGenStep.js +126 -0
  5. package/dist/agents/planGeneratorStep.js +118 -0
  6. package/dist/agents/planResolverStep.js +95 -0
  7. package/dist/agents/planTargetFilesStep.js +48 -0
  8. package/dist/agents/preFileSearchCheckStep.js +95 -0
  9. package/dist/agents/selectRelevantSourcesStep.js +100 -0
  10. package/dist/agents/semanticAnalysisStep.js +144 -0
  11. package/dist/agents/structuralAnalysisStep.js +46 -0
  12. package/dist/agents/transformPlanGenStep.js +107 -0
  13. package/dist/agents/understandIntentStep.js +72 -0
  14. package/dist/agents/validationAnalysisStep.js +87 -0
  15. package/dist/commands/AskCmd.js +47 -116
  16. package/dist/commands/ChangeLogUpdateCmd.js +11 -5
  17. package/dist/commands/CommitSuggesterCmd.js +50 -75
  18. package/dist/commands/DaemonCmd.js +119 -29
  19. package/dist/commands/IndexCmd.js +41 -24
  20. package/dist/commands/InspectCmd.js +0 -1
  21. package/dist/commands/ReadlineSingleton.js +18 -0
  22. package/dist/commands/ResetDbCmd.js +20 -21
  23. package/dist/commands/ReviewCmd.js +89 -54
  24. package/dist/commands/SummaryCmd.js +12 -18
  25. package/dist/commands/WorkflowCmd.js +41 -0
  26. package/dist/commands/factory.js +254 -0
  27. package/dist/config.js +67 -15
  28. package/dist/constants.js +20 -4
  29. package/dist/context.js +10 -11
  30. package/dist/daemon/daemonQueues.js +63 -0
  31. package/dist/daemon/daemonWorker.js +40 -63
  32. package/dist/daemon/generateSummaries.js +58 -0
  33. package/dist/daemon/runFolderCapsuleBatch.js +247 -0
  34. package/dist/daemon/runIndexingBatch.js +147 -0
  35. package/dist/daemon/runKgBatch.js +104 -0
  36. package/dist/db/fileIndex.js +168 -63
  37. package/dist/db/functionExtractors/extractFromJava.js +210 -6
  38. package/dist/db/functionExtractors/extractFromJs.js +186 -198
  39. package/dist/db/functionExtractors/extractFromTs.js +181 -192
  40. package/dist/db/functionExtractors/index.js +7 -5
  41. package/dist/db/schema.js +55 -20
  42. package/dist/db/sqlTemplates.js +50 -19
  43. package/dist/fileRules/builtins.js +31 -0
  44. package/dist/fileRules/codeAllowedExtensions.js +4 -0
  45. package/dist/fileRules/fileExceptions.js +0 -13
  46. package/dist/fileRules/ignoredExtensions.js +10 -0
  47. package/dist/index.js +128 -325
  48. package/dist/lib/generate.js +37 -14
  49. package/dist/lib/generateFolderCapsules.js +109 -0
  50. package/dist/lib/spinner.js +12 -5
  51. package/dist/modelSetup.js +35 -6
  52. package/dist/pipeline/modules/changeLogModule.js +16 -19
  53. package/dist/pipeline/modules/chunkManagerModule.js +24 -0
  54. package/dist/pipeline/modules/cleanupModule.js +96 -91
  55. package/dist/pipeline/modules/codeTransformModule.js +208 -0
  56. package/dist/pipeline/modules/commentModule.js +20 -11
  57. package/dist/pipeline/modules/commitSuggesterModule.js +36 -14
  58. package/dist/pipeline/modules/contextReviewModule.js +52 -0
  59. package/dist/pipeline/modules/fileReaderModule.js +72 -0
  60. package/dist/pipeline/modules/fileSearchModule.js +136 -0
  61. package/dist/pipeline/modules/finalAnswerModule.js +53 -0
  62. package/dist/pipeline/modules/gatherInfoModule.js +176 -0
  63. package/dist/pipeline/modules/generateTestsModule.js +63 -54
  64. package/dist/pipeline/modules/kgModule.js +26 -11
  65. package/dist/pipeline/modules/preserveCodeModule.js +91 -49
  66. package/dist/pipeline/modules/refactorModule.js +19 -7
  67. package/dist/pipeline/modules/repairTestsModule.js +44 -36
  68. package/dist/pipeline/modules/reviewModule.js +23 -13
  69. package/dist/pipeline/modules/summaryModule.js +27 -35
  70. package/dist/pipeline/modules/writeFileModule.js +86 -0
  71. package/dist/pipeline/registry/moduleRegistry.js +38 -93
  72. package/dist/pipeline/runModulePipeline.js +22 -19
  73. package/dist/scripts/dbcheck.js +156 -91
  74. package/dist/utils/buildContextualPrompt.js +245 -164
  75. package/dist/utils/debugContext.js +24 -0
  76. package/dist/utils/fileTree.js +16 -6
  77. package/dist/utils/loadRelevantFolderCapsules.js +64 -0
  78. package/dist/utils/log.js +2 -0
  79. package/dist/utils/normalizeData.js +23 -0
  80. package/dist/utils/planActions.js +60 -0
  81. package/dist/utils/promptBuilderHelper.js +67 -0
  82. package/dist/utils/promptLogHelper.js +52 -0
  83. package/dist/utils/sanitizeQuery.js +20 -8
  84. package/dist/utils/sharedUtils.js +8 -0
  85. package/dist/utils/sleep.js +3 -0
  86. package/dist/utils/splitCodeIntoChunk.js +65 -32
  87. package/dist/utils/vscode.js +49 -0
  88. package/dist/workflow/workflowResolver.js +14 -0
  89. package/dist/workflow/workflowRunner.js +103 -0
  90. package/package.json +6 -5
  91. package/dist/agent/agentManager.js +0 -39
  92. package/dist/agent/workflowManager.js +0 -95
  93. package/dist/commands/ModulePipelineCmd.js +0 -31
  94. package/dist/daemon/daemonBatch.js +0 -186
  95. package/dist/fileRules/scoreFiles.js +0 -71
  96. package/dist/lib/generateEmbedding.js +0 -22
@@ -1,8 +1,8 @@
1
1
  // --- Files ---
2
2
  // Upsert file metadata into `files`
3
3
  export const upsertFileTemplate = `
4
- INSERT INTO files (path, filename, summary, type, last_modified, indexed_at, embedding)
5
- VALUES (:path, :filename, :summary, :type, :lastModified, :indexedAt, :embedding)
4
+ INSERT INTO files (path, filename, summary, type, last_modified, indexed_at)
5
+ VALUES (:path, :filename, :summary, :type, :lastModified, :indexedAt)
6
6
  ON CONFLICT(path) DO UPDATE SET
7
7
  filename = excluded.filename,
8
8
  summary = CASE
@@ -12,17 +12,12 @@ export const upsertFileTemplate = `
12
12
  END,
13
13
  type = excluded.type,
14
14
  last_modified = excluded.last_modified,
15
- indexed_at = excluded.indexed_at,
16
- embedding = CASE
17
- WHEN excluded.embedding IS NOT NULL AND excluded.embedding != files.embedding
18
- THEN excluded.embedding
19
- ELSE files.embedding
20
- END
15
+ indexed_at = excluded.indexed_at
21
16
  `;
22
17
  // Insert or replace into FTS
23
18
  export const upsertFileFtsTemplate = `
24
- INSERT OR REPLACE INTO files_fts (rowid, filename, summary, path)
25
- VALUES ((SELECT id FROM files WHERE path = :path), :filename, :summary, :path)
19
+ INSERT OR REPLACE INTO files_fts (rowid, filename, summary, path, content_text)
20
+ VALUES ((SELECT id FROM files WHERE path = :path), :filename, :summary, :path, :contentText)
26
21
  `;
27
22
  // Simple file query (no scoring)
28
23
  export const queryFilesTemplate = `
@@ -35,7 +30,7 @@ export const queryFilesTemplate = `
35
30
  // FTS search with bm25 scoring
36
31
  export const searchFilesTemplate = `
37
32
  SELECT fts.rowid AS id, f.path, f.filename, f.summary, f.type,
38
- bm25(files_fts) AS bm25Score, f.embedding
33
+ bm25(files_fts) AS bm25Score
39
34
  FROM files f
40
35
  JOIN files_fts fts ON f.id = fts.rowid
41
36
  WHERE fts.files_fts MATCH ?
@@ -44,13 +39,13 @@ export const searchFilesTemplate = `
44
39
  `;
45
40
  // --- Functions ---
46
41
  export const insertFunctionTemplate = `
47
- INSERT INTO functions (file_id, name, start_line, end_line, content, embedding, lang)
48
- VALUES (:file_id, :name, :start_line, :end_line, :content, :embedding, :lang)
42
+ INSERT INTO functions (file_id, name, start_line, end_line, content, lang, unique_id)
43
+ VALUES (:file_id, :name, :start_line, :end_line, :content, :lang, :unique_id)
49
44
  `;
50
45
  // --- Graph ---
51
46
  export const insertGraphClassTemplate = `
52
- INSERT INTO graph_classes (file_id, name, start_line, end_line, content, embedding, lang)
53
- VALUES (:file_id, :name, :start_line, :end_line, :content, :embedding, :lang)
47
+ INSERT INTO graph_classes (file_id, name, start_line, end_line, content, lang)
48
+ VALUES (:file_id, :name, :start_line, :end_line, :content, :lang)
54
49
  `;
55
50
  export const insertEdgeTemplate = `
56
51
  INSERT INTO graph_edges (
@@ -89,6 +84,36 @@ export const insertGraphEntityTagTemplate = `
89
84
  ON CONFLICT(entity_type, entity_unique_id, tag_id) DO NOTHING
90
85
  `;
91
86
  // --- File Processing Status ---
87
+ /* processing_status values:
88
+ "unprocessed" → newly discovered, not yet indexed
89
+ "indexed" → content read and inserted into FTS
90
+ "capsuled" → folder capsule created
91
+ "extracted" → functions/classes extracted for knowledge graph
92
+ "kg_done" → knowledge graph updated
93
+ "skipped" → ignored (invalid, missing, or binary)
94
+ "failed" → could not be processed due to error
95
+ */
96
+ export const markFileAsProcessedByPath = `
97
+ UPDATE files
98
+ SET processing_status = 'processed'
99
+ WHERE path = @path
100
+ `;
101
+ export const markFileAsIndexed = `
102
+ UPDATE files
103
+ SET processing_status = 'indexed',
104
+ indexed_at = datetime('now')
105
+ WHERE path = @path
106
+ `;
107
+ export const markFileAsCapsuled = `
108
+ UPDATE files
109
+ SET processing_status = 'capsulized'
110
+ WHERE path LIKE ?
111
+ `;
112
+ export const markFileAsKgDone = `
113
+ UPDATE files
114
+ SET processing_status = 'kg_done'
115
+ WHERE path = @path
116
+ `;
92
117
  export const markFileAsExtractedTemplate = `
93
118
  UPDATE files
94
119
  SET processing_status = 'extracted',
@@ -108,9 +133,9 @@ export const markFileAsFailedTemplate = `
108
133
  WHERE id = :id
109
134
  `;
110
135
  export const selectUnprocessedFiles = `
111
- SELECT id, path, type, summary, indexed_at, last_modified, processing_status
136
+ SELECT id, path, type, content_text, indexed_at, last_modified, processing_status
112
137
  FROM files
113
- WHERE processing_status = 'unprocessed' OR summary IS NULL OR summary = ''
138
+ WHERE processing_status = 'unprocessed'
114
139
  ORDER BY last_modified DESC
115
140
  LIMIT ?
116
141
  `;
@@ -120,10 +145,16 @@ export const markFileAsSkippedByPath = `
120
145
  functions_extracted_at = NULL
121
146
  WHERE path = @path
122
147
  `;
123
- export const updateFileWithSummaryAndEmbedding = `
148
+ export const updateFileWithSummary = `
124
149
  UPDATE files
125
150
  SET summary = @summary,
126
- embedding = @embedding,
151
+ content_text = @contentText,
127
152
  indexed_at = datetime('now')
128
153
  WHERE path = @path
129
154
  `;
155
+ // --- File Processing Status Checks ---
156
+ export const countUnprocessedFiles = `
157
+ SELECT COUNT(*) as count
158
+ FROM files
159
+ WHERE processing_status = 'unprocessed'
160
+ `;
@@ -0,0 +1,31 @@
1
+ export const BUILTINS = {
2
+ ts: new Set([
3
+ // String methods
4
+ "trim", "toLowerCase", "toUpperCase", "includes", "startsWith", "endsWith", "replace", "match", "split",
5
+ // Array methods
6
+ "map", "forEach", "filter", "reduce", "some", "every", "find", "findIndex", "push", "pop", "shift", "unshift", "slice", "splice",
7
+ // Object methods
8
+ "keys", "values", "entries", "assign",
9
+ // Number/Math
10
+ "parseInt", "parseFloat", "isNaN", "isFinite", "floor", "ceil", "round", "abs", "max", "min", "random",
11
+ // JSON / Promise / RegExp
12
+ "stringify", "parse", "then", "catch", "finally", "test",
13
+ // Console
14
+ "log", "error", "warn", "info",
15
+ ]),
16
+ java: new Set([
17
+ // Object methods
18
+ "equals", "hashCode", "toString", "clone", "finalize", "notify", "notifyAll", "wait",
19
+ // String methods
20
+ "charAt", "compareTo", "contains", "endsWith", "equalsIgnoreCase", "indexOf", "isEmpty",
21
+ "length", "replace", "split", "startsWith", "substring", "toLowerCase", "toUpperCase", "trim",
22
+ // Math methods
23
+ "abs", "max", "min", "floor", "ceil", "round", "sqrt", "pow", "random",
24
+ // Collections (common)
25
+ "add", "addAll", "remove", "removeAll", "contains", "containsAll", "size", "clear", "get", "put",
26
+ // System
27
+ "exit", "currentTimeMillis", "arraycopy",
28
+ // Misc
29
+ "format", "parseInt", "parseDouble",
30
+ ]),
31
+ };
@@ -0,0 +1,4 @@
1
+ // src/fileRules/codeAllowedExtensions.ts
2
+ export const CODE_ALLOWED_EXTENSIONS = [
3
+ 'js', 'javascript', 'ts', 'typescript', 'java',
4
+ ];
@@ -1,9 +1,6 @@
1
1
  export const specificFileExceptions = [
2
2
  // 🧑‍💻 Project Configuration Files
3
3
  'package.json', // Keep package.json for NPM/Yarn dependency management
4
- 'package-lock.json', // Keep package-lock.json for npm lockfile
5
- 'yarn.lock', // Keep yarn.lock for Yarn dependency lockfile
6
- 'pnpm-lock.yaml', // Keep pnpm-lock.yaml for pnpm lockfile
7
4
  'tsconfig.json', // Keep TypeScript configuration file
8
5
  'tsconfig.build.json', // Keep build-specific tsconfig file
9
6
  'tsconfig.prod.json', // Keep production-specific tsconfig file
@@ -41,10 +38,6 @@ export const specificFileExceptions = [
41
38
  'build.gradle', // Keep Gradle build file
42
39
  'pom.xml', // Keep Maven Project Object Model (POM) file
43
40
  'settings.gradle', // Keep Gradle settings file
44
- 'build.sh', // Keep shell script for building the project
45
- 'build.bash', // Keep bash build script
46
- 'deploy.sh', // Keep shell script for deployment
47
- 'ci.sh', // Keep shell script for CI
48
41
  // 🔧 Other Project Files
49
42
  'Makefile.am', // Keep Automake Makefile
50
43
  'config.yaml', // Keep general config file in YAML format
@@ -68,12 +61,6 @@ export const specificFileExceptions = [
68
61
  'README.txt', // Keep documentation in text format
69
62
  'data.json', // Keep data JSON file
70
63
  'data.yml', // Keep data YAML file
71
- 'env.json', // Keep environment JSON file
72
- 'env.yml', // Keep environment YAML file
73
- '.env', // Keep environment variable files
74
- '.env.local', // Keep local environment variables
75
- '.env.production', // Keep production environment variables
76
- '.env.development', // Keep development environment variables
77
64
  // 🚧 Test-related files
78
65
  'test.config.js', // Keep test config for testing frameworks
79
66
  'test-utils.js', // Keep test utility files
@@ -63,3 +63,13 @@ export const IGNORED_EXTENSIONS = [
63
63
  // ─── Misc Hashes & Metadata ────────────────────────────────
64
64
  '.md5', '.sha1', '.sha256', '.xlsb', '.xar',
65
65
  ];
66
+ // ─── Knowledge Graph Ignored Extensions ─────────────────────
67
+ export const KG_IGNORED_EXTENSIONS = [
68
+ // ─── Frequently ignored / useless for KG ─────────────────
69
+ '.json',
70
+ // ─── Executables / Binaries ───────────────────────────────
71
+ '.html', '.htm', '.xml', '.exe', '.dll', '.bin', '.iso', '.img', '.o', '.obj', '.so', '.dylib', '.a', '.lib',
72
+ '.cmd', '.bat', '.ps1', '.sh', '.bash', '.run', '.vbs', '.jscript',
73
+ // ─── Other meaningless files for KG ───────────────────────
74
+ '.msm', '.lock', '.lockfile', '.lck', '.db-lock', '.pid', '.sock', '.socket',
75
+ ];