scai 0.1.24 โ 0.1.25
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 +7 -1
- 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,4 +1,3 @@
|
|
|
1
|
-
// src/config/IgnoredExtensions.ts
|
|
2
1
|
export const IGNORED_EXTENSIONS = [
|
|
3
2
|
// ๐ผ Media
|
|
4
3
|
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.ico',
|
|
@@ -43,4 +42,11 @@ export const IGNORED_EXTENSIONS = [
|
|
|
43
42
|
'.sap', '.sappkg', '.qbw', '.qbb',
|
|
44
43
|
// ๐ Lock files (but NOT lock *configs*)
|
|
45
44
|
'.lck', '.lockfile', '.db-lock', '.pid', '.socket',
|
|
45
|
+
// โ ๏ธ Added file types that are only kept by exception
|
|
46
|
+
'.xml', // Only specific XML files like pom.xml should be kept
|
|
47
|
+
'.json', // Kept only if exact filename is in exceptions
|
|
48
|
+
'.yaml', // Kept only if filename is explicitly whitelisted
|
|
49
|
+
'.yml',
|
|
50
|
+
'.md',
|
|
51
|
+
'.txt',
|
|
46
52
|
];
|
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
|
+
];
|