scai 0.1.24 β 0.1.26
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/dist/commands/DaemonCmd.js +22 -18
- package/dist/commands/StopDaemonCmd.js +14 -3
- package/dist/config/IgnoredExtensions.js +38 -16
- package/dist/config/StopWords.js +22 -9
- package/dist/utils/removeIgnoredFiles.js +43 -0
- package/dist/utils/shouldIgnoreFiles.js +8 -0
- package/dist/utils/specificFileExceptions.js +90 -0
- package/package.json +1 -1
|
@@ -4,25 +4,29 @@ import { log } from '../utils/log.js';
|
|
|
4
4
|
import { spawn } from 'child_process';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
// π Ensure daemon starts in the background
|
|
8
7
|
export async function startDaemon() {
|
|
8
|
+
// If there's a PID file, check if the process is still running
|
|
9
9
|
if (fsSync.existsSync(PID_PATH)) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const daemonWorkerPath = path.join(__dirname, '../daemon/daemonWorker.js');
|
|
21
|
-
// Spawn the daemonWorker.js file in the background
|
|
22
|
-
const child = spawn(process.execPath, [daemonWorkerPath], {
|
|
23
|
-
detached: true, // Detach the process so it runs independently
|
|
24
|
-
stdio: ['ignore', 'ignore', 'ignore'], // Suppress the output
|
|
25
|
-
});
|
|
26
|
-
child.unref(); // Allow the parent process to exit without waiting for the child
|
|
10
|
+
const pid = parseInt(fsSync.readFileSync(PID_PATH, 'utf8'));
|
|
11
|
+
try {
|
|
12
|
+
process.kill(pid, 0); // Check if process exists
|
|
13
|
+
log(`β οΈ Daemon already running with PID ${pid}.`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
log(`β οΈ Stale PID file found. Removing and restarting daemon...`);
|
|
18
|
+
fsSync.unlinkSync(PID_PATH);
|
|
19
|
+
}
|
|
27
20
|
}
|
|
21
|
+
log('π Starting summarizer daemon in background mode...');
|
|
22
|
+
log(`π Logs will be saved to: ${LOG_PATH}`);
|
|
23
|
+
process.env.BACKGROUND_MODE = 'true';
|
|
24
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
+
const __dirname = path.dirname(__filename);
|
|
26
|
+
const daemonWorkerPath = path.join(__dirname, '../daemon/daemonWorker.js');
|
|
27
|
+
const child = spawn(process.execPath, [daemonWorkerPath], {
|
|
28
|
+
detached: true,
|
|
29
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
30
|
+
});
|
|
31
|
+
child.unref();
|
|
28
32
|
}
|
|
@@ -9,15 +9,26 @@ export async function runStopDaemonCommand() {
|
|
|
9
9
|
}
|
|
10
10
|
const pid = parseInt(fs.readFileSync(PID_PATH, 'utf-8'), 10);
|
|
11
11
|
if (isNaN(pid)) {
|
|
12
|
-
console.error('β οΈ Invalid PID file.');
|
|
12
|
+
console.error('β οΈ Invalid PID file. Removing it...');
|
|
13
|
+
fs.unlinkSync(PID_PATH);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
// Check if process exists
|
|
18
|
+
process.kill(pid, 0);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
console.warn(`β οΈ No running process with PID ${pid}. Removing stale PID file.`);
|
|
22
|
+
fs.unlinkSync(PID_PATH);
|
|
13
23
|
return;
|
|
14
24
|
}
|
|
15
25
|
try {
|
|
16
|
-
process
|
|
26
|
+
// Attempt to terminate the process
|
|
27
|
+
process.kill(pid, 'SIGTERM');
|
|
17
28
|
fs.unlinkSync(PID_PATH);
|
|
18
29
|
console.log(`β
Daemon process ${pid} stopped.`);
|
|
19
30
|
}
|
|
20
31
|
catch (err) {
|
|
21
|
-
console.error(`β Failed to stop process ${pid}:`, err instanceof Error ? err.message : err);
|
|
32
|
+
console.error(`β Failed to stop daemon process ${pid}:`, err instanceof Error ? err.message : err);
|
|
22
33
|
}
|
|
23
34
|
}
|
|
@@ -1,46 +1,68 @@
|
|
|
1
|
-
// src/config/IgnoredExtensions.ts
|
|
2
1
|
export const IGNORED_EXTENSIONS = [
|
|
3
|
-
//
|
|
2
|
+
// Media
|
|
4
3
|
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.ico',
|
|
5
4
|
'.mp4', '.mp3', '.mov', '.avi', '.mkv', '.flv', '.wav', '.flac',
|
|
6
5
|
'.aac', '.m4a', '.wma', '.3gp', '.webm', '.ogg', '.aiff', '.au',
|
|
7
|
-
//
|
|
6
|
+
// Archives & install packages
|
|
8
7
|
'.zip', '.tar', '.gz', '.bz2', '.xz', '.rar', '.7z',
|
|
9
8
|
'.jar', '.war', '.ear', '.deb', '.rpm', '.pkg', '.msi', '.dmg', '.cab', '.apk',
|
|
10
9
|
'.tar.gz', '.tar.bz2', '.tar.xz', '.tar.lzma', '.tar.zst',
|
|
11
|
-
//
|
|
10
|
+
// Binaries & executables
|
|
12
11
|
'.exe', '.dll', '.bin', '.so', '.dylib', '.a', '.lib',
|
|
13
12
|
'.iso', '.img', '.elf', '.o', '.obj', '.msm', '.vbs', '.jscript',
|
|
14
13
|
'.cmd', '.bat', '.ps1', '.sh', '.bash', '.run',
|
|
15
|
-
//
|
|
14
|
+
// Runtime / build / cache
|
|
16
15
|
'.log', '.tmp', '.map',
|
|
17
16
|
'.db', '.sqlite', '.pkl', '.sav', '.rdb', '.ldb',
|
|
18
17
|
'.pyc', '.class', '.tsbuildinfo', '.coverage', '.eslintcache',
|
|
19
18
|
'.yarn', '.webpack', '.babel', '.compilercache',
|
|
20
|
-
//
|
|
19
|
+
// Fonts & styles
|
|
21
20
|
'.woff', '.woff2', '.ttf', '.eot', '.otf', '.css.map',
|
|
22
21
|
'.scss', '.sass', '.less', '.styl',
|
|
23
|
-
//
|
|
22
|
+
// Certs, keys, credentials
|
|
24
23
|
'.crt', '.key', '.pem', '.pub', '.asc', '.gpg', '.p12', '.csr', '.der', '.pfx',
|
|
25
|
-
//
|
|
24
|
+
// Backups / temp
|
|
26
25
|
'.bak', '.old', '.swp', '.swo', '.orig',
|
|
27
26
|
'.sublime-workspace', '.sublime-project', '.db-shm', '.db-wal',
|
|
28
|
-
//
|
|
27
|
+
// System/config folders (still ignored by path, not extension)
|
|
29
28
|
'.DS_Store', '.bundle', '.npmrc',
|
|
30
|
-
//
|
|
29
|
+
// GIS / Geospatial
|
|
31
30
|
'.shp', '.shx', '.dbf', '.prj', '.qix', '.sbn', '.sbx', '.shp.xml', '.cpg', '.gpkg', '.mif', '.mid',
|
|
32
|
-
//
|
|
31
|
+
// Enterprise BI / Reporting
|
|
33
32
|
'.pbix', '.rdl', '.rpt', '.bqy', '.iqy',
|
|
34
|
-
//
|
|
33
|
+
// ETL / DWH / Modeling
|
|
35
34
|
'.abf', '.dtsx', '.bim', '.xmi',
|
|
36
|
-
//
|
|
35
|
+
// CAD / Engineering
|
|
37
36
|
'.dwg', '.dxf', '.step', '.stp', '.sldprt', '.sldasm',
|
|
38
37
|
'.iges', '.igs', '.3ds', '.fbx',
|
|
39
|
-
//
|
|
38
|
+
// Forms / Print / Publishing
|
|
40
39
|
'.xps', '.afpub', '.pub', '.indd', '.qxd', '.frm', '.frx', '.frl',
|
|
41
|
-
//
|
|
40
|
+
// ERP / Finance / Legacy DB
|
|
42
41
|
'.mbd', '.fdb', '.nav', '.accdb', '.mdb', '.gdb',
|
|
43
42
|
'.sap', '.sappkg', '.qbw', '.qbb',
|
|
44
|
-
//
|
|
43
|
+
// Lock files (but NOT lock *configs*)
|
|
45
44
|
'.lck', '.lockfile', '.db-lock', '.pid', '.socket',
|
|
45
|
+
// Documentation and Readme Files
|
|
46
|
+
'.md', // Markdown files for documentation
|
|
47
|
+
'.rst', // reStructuredText files for documentation
|
|
48
|
+
'.txt', // Plain text files (can be used for documentation or notes)
|
|
49
|
+
// Configuration files (JSON/YAML/XML)
|
|
50
|
+
'.json', // General JSON config files
|
|
51
|
+
'.yaml', // YAML configuration files
|
|
52
|
+
'.yml', // YAML configuration files
|
|
53
|
+
'.xml', // XML configuration files
|
|
54
|
+
// Miscellaneous Important Files
|
|
55
|
+
'.properties', // Java properties files (configuration)
|
|
56
|
+
'.xml.bck', // Backup XML files
|
|
57
|
+
'.bak', // General backup files
|
|
58
|
+
'.swp', // Swap files (e.g., vim/sublime temp files)
|
|
59
|
+
'.swo', // Swap files
|
|
60
|
+
'.orig', // Original backup files
|
|
61
|
+
'.old', // Old version files
|
|
62
|
+
'.~', // Temp files generated by some editors (e.g., vim)
|
|
63
|
+
'.md5', // MD5 checksums
|
|
64
|
+
'.sha1', // SHA1 checksums
|
|
65
|
+
'.sha256', // SHA256 checksums
|
|
66
|
+
'.tmp', // Temporary files
|
|
67
|
+
'.bak', // Backup file (for various applications)
|
|
46
68
|
];
|
package/dist/config/StopWords.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
// src/config/StopWords.ts
|
|
2
1
|
/**
|
|
3
2
|
* These common words are ignored from search queries
|
|
4
3
|
* to reduce noise and improve FTS and embedding match quality.
|
|
5
4
|
*/
|
|
6
5
|
export const STOP_WORDS = new Set([
|
|
7
|
-
|
|
8
|
-
'
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
|
|
6
|
+
// Articles & conjunctions
|
|
7
|
+
'a', 'an', 'and', 'but', 'or', 'nor',
|
|
8
|
+
// Prepositions
|
|
9
|
+
'at', 'by', 'for', 'from', 'in', 'into', 'of', 'on', 'to', 'with', 'about', 'above', 'below', 'under', 'over', 'through',
|
|
10
|
+
// Pronouns
|
|
11
|
+
'i', 'me', 'my', 'mine', 'you', 'your', 'yours', 'he', 'him', 'his', 'she', 'her', 'hers', 'it', 'its',
|
|
12
|
+
'we', 'us', 'our', 'ours', 'they', 'them', 'their', 'theirs',
|
|
13
|
+
// Determiners
|
|
14
|
+
'this', 'that', 'these', 'those', 'some', 'any', 'each', 'every', 'either', 'neither',
|
|
15
|
+
// Auxiliary and modal verbs
|
|
16
|
+
'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
17
|
+
'do', 'does', 'did',
|
|
18
|
+
'have', 'has', 'had',
|
|
19
|
+
'can', 'could', 'shall', 'should', 'will', 'would', 'may', 'might', 'must',
|
|
20
|
+
// Wh-words and generic question words
|
|
21
|
+
'what', 'which', 'who', 'whom', 'whose', 'where', 'when', 'why', 'how',
|
|
22
|
+
// Misc common functional words
|
|
23
|
+
'as', 'if', 'than', 'then', 'there', 'because', 'so', 'just', 'only', 'not', 'no',
|
|
24
|
+
// Very common verbs to strip from noisy queries
|
|
25
|
+
'use', 'get', 'make', 'need', 'want', 'let', 'help', 'work', 'see', 'look', 'like', 'know',
|
|
26
|
+
// Other frequent noise
|
|
27
|
+
'all', 'more', 'most', 'many', 'much', 'such', 'also', 'again'
|
|
15
28
|
]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { IGNORED_EXTENSIONS } from '../config/IgnoredExtensions.js';
|
|
5
|
+
import { specificFileExceptions } from './specificFileExceptions.js';
|
|
6
|
+
// THIS FILE IS MEANT TO BE RUN AS A NODE JS SCRIPT. node dist/src/utilsremoveIgnoredFiles.js
|
|
7
|
+
// It removes wrongly indexed files that don't add value to the model.
|
|
8
|
+
const DB_PATH = path.join(os.homedir(), '.scai', 'db.sqlite');
|
|
9
|
+
const db = new Database(DB_PATH);
|
|
10
|
+
console.log('π§Ή Removing files with ignored extensions from the database...');
|
|
11
|
+
// === Remove Files with Ignored Extensions, Excluding Specific Exceptions ===
|
|
12
|
+
IGNORED_EXTENSIONS.forEach(ext => {
|
|
13
|
+
try {
|
|
14
|
+
const filesToDelete = db.prepare(`
|
|
15
|
+
SELECT path FROM files WHERE path LIKE ?
|
|
16
|
+
`).all(`%${ext}`);
|
|
17
|
+
;
|
|
18
|
+
let deletedCount = 0;
|
|
19
|
+
filesToDelete.forEach(file => {
|
|
20
|
+
// Check if the file is in the exception list
|
|
21
|
+
if (!specificFileExceptions.includes(file.path)) {
|
|
22
|
+
// Delete the file from the database
|
|
23
|
+
const deleted = db.prepare(`DELETE FROM files WHERE path = ?`).run(file.path);
|
|
24
|
+
if (deleted.changes > 0) {
|
|
25
|
+
deletedCount++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(`β οΈ Skipped file (exception): ${file.path}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (deletedCount > 0) {
|
|
33
|
+
console.log(`β
Removed ${deletedCount} files with extension: ${ext}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(`β οΈ No deletions for files with extension: ${ext}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error("β Failed to remove files with extension ${ext}:", err instanceof Error ? err.message : err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
console.log('π§Ή Finished removing ignored files.');
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { IGNORED_EXTENSIONS } from '../config/IgnoredExtensions.js';
|
|
3
|
+
import { specificFileExceptions } from '../utils/specificFileExceptions.js';
|
|
3
4
|
export function shouldIgnoreFile(filePath) {
|
|
5
|
+
// Get file extension
|
|
4
6
|
const ext = path.extname(filePath).toLowerCase();
|
|
7
|
+
// Check if the file is explicitly listed in the exceptions
|
|
8
|
+
const fileName = path.basename(filePath);
|
|
9
|
+
if (specificFileExceptions.includes(fileName)) {
|
|
10
|
+
return false; // Don't ignore if it's in the exceptions list
|
|
11
|
+
}
|
|
12
|
+
// If not in exceptions, check against ignored extensions
|
|
5
13
|
return IGNORED_EXTENSIONS.includes(ext);
|
|
6
14
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const specificFileExceptions = [
|
|
2
|
+
// π§βπ» Project Configuration Files
|
|
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
|
+
'tsconfig.json', // Keep TypeScript configuration file
|
|
8
|
+
'tsconfig.build.json', // Keep build-specific tsconfig file
|
|
9
|
+
'tsconfig.prod.json', // Keep production-specific tsconfig file
|
|
10
|
+
'tsconfig.dev.json', // Keep development-specific tsconfig file
|
|
11
|
+
'jsconfig.json', // Keep jsconfig.json for JavaScript projects
|
|
12
|
+
'eslint.json', // Keep eslint configuration
|
|
13
|
+
'eslint.config.js', // Keep eslint config file
|
|
14
|
+
'babel.config.js', // Keep Babel configuration
|
|
15
|
+
'webpack.config.js', // Keep Webpack configuration
|
|
16
|
+
'webpack.dev.config.js', // Keep development-specific Webpack config
|
|
17
|
+
'webpack.prod.config.js', // Keep production-specific Webpack config
|
|
18
|
+
'rollup.config.js', // Keep Rollup configuration file
|
|
19
|
+
'gulpfile.js', // Keep Gulp task runner file
|
|
20
|
+
'Makefile', // Keep Makefile for project builds
|
|
21
|
+
// π§ͺ Docker & CI/CD
|
|
22
|
+
'Dockerfile', // Keep Dockerfile
|
|
23
|
+
'Dockerfile.dev', // Keep Dockerfile for development
|
|
24
|
+
'docker-compose.yaml', // Keep docker-compose.yaml for container orchestration
|
|
25
|
+
'docker-compose.yml', // Keep docker-compose.yml (common variation)
|
|
26
|
+
'ci.yml', // Keep CI configuration file (e.g., GitHub Actions)
|
|
27
|
+
'gitlab-ci.yml', // Keep GitLab CI configuration file
|
|
28
|
+
'Jenkinsfile', // Keep Jenkins pipeline file
|
|
29
|
+
'circleci/config.yml', // Keep CircleCI configuration file
|
|
30
|
+
// π Documentation and Readme Files
|
|
31
|
+
'README.md', // Keep README file for project documentation
|
|
32
|
+
'README.rst', // Keep README in reStructuredText format
|
|
33
|
+
'CONTRIBUTING.md', // Keep contributing guidelines
|
|
34
|
+
'CHANGELOG.md', // Keep changelog for tracking project history
|
|
35
|
+
'LICENSE', // Keep project license
|
|
36
|
+
'LICENSE.txt', // Keep license in text format
|
|
37
|
+
'LICENSE.md', // Keep license in markdown format
|
|
38
|
+
'NOTICE.txt', // Keep NOTICE file
|
|
39
|
+
'INSTALL.md', // Keep installation instructions
|
|
40
|
+
// π οΈ Build and Deployment Configuration Files
|
|
41
|
+
'build.gradle', // Keep Gradle build file
|
|
42
|
+
'pom.xml', // Keep Maven Project Object Model (POM) file
|
|
43
|
+
'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
|
+
// π§ Other Project Files
|
|
49
|
+
'Makefile.am', // Keep Automake Makefile
|
|
50
|
+
'config.yaml', // Keep general config file in YAML format
|
|
51
|
+
'config.json', // Keep general config file in JSON format
|
|
52
|
+
'config.toml', // Keep TOML configuration file
|
|
53
|
+
'settings.json', // Keep settings configuration file
|
|
54
|
+
'settings.yml', // Keep settings configuration file in YAML format
|
|
55
|
+
'secrets.json', // Keep secrets (make sure they are handled securely)
|
|
56
|
+
// π Web Development & Frontend
|
|
57
|
+
'index.html', // Keep main HTML file
|
|
58
|
+
'index.php', // Keep main PHP file
|
|
59
|
+
'app.js', // Keep main JavaScript entry file
|
|
60
|
+
'app.ts', // Keep main TypeScript entry file
|
|
61
|
+
'styles.css', // Keep main CSS file
|
|
62
|
+
'main.scss', // Keep main SCSS file
|
|
63
|
+
'main.less', // Keep main LESS file
|
|
64
|
+
'style.css', // Keep style CSS
|
|
65
|
+
'app.vue', // Keep Vue.js file
|
|
66
|
+
'index.vue', // Keep Vue.js index file
|
|
67
|
+
// π οΈ Miscellaneous Important Files
|
|
68
|
+
'README.txt', // Keep documentation in text format
|
|
69
|
+
'data.json', // Keep data JSON file
|
|
70
|
+
'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
|
+
// π§ Test-related files
|
|
78
|
+
'test.config.js', // Keep test config for testing frameworks
|
|
79
|
+
'test-utils.js', // Keep test utility files
|
|
80
|
+
'test.setup.js', // Keep setup files for tests
|
|
81
|
+
'jest.setup.js', // Keep Jest setup files
|
|
82
|
+
'mocha.setup.js', // Keep Mocha setup files
|
|
83
|
+
'karma.conf.js', // Keep Karma configuration for tests
|
|
84
|
+
'cypress.json', // Keep Cypress config for end-to-end testing
|
|
85
|
+
'karma.conf.js', // Keep Karma test runner config
|
|
86
|
+
'tests.js', // Keep test file
|
|
87
|
+
'tests.ts', // Keep TypeScript test file
|
|
88
|
+
'test.js', // Keep JavaScript test file
|
|
89
|
+
'test.ts', // Keep TypeScript test file
|
|
90
|
+
];
|