scai 0.1.29 → 0.1.31
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/README.md +162 -85
- package/dist/commands/BackupCmd.js +12 -0
- package/dist/commands/ResetDbCmd.js +4 -29
- package/dist/config/IgnoredExtensions.js +46 -49
- package/dist/config/StopWords.js +21 -15
- package/dist/db/backup.js +28 -0
- package/dist/index.js +13 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,146 +1,223 @@
|
|
|
1
|
-
# ⚙️ scai —
|
|
1
|
+
# ⚙️ scai — Semantic CLI Assistant ✨
|
|
2
2
|
|
|
3
|
-
> AI-powered CLI tool for
|
|
3
|
+
> AI-powered CLI tool for commits, summaries, search, questions, and more — using local models.
|
|
4
4
|
|
|
5
|
-
**scai**
|
|
5
|
+
**scai** is a privacy-first, local AI assistant for developers. It brings semantic understanding to your codebase, directly from the terminal:
|
|
6
6
|
|
|
7
|
-
- 💬 Suggest
|
|
8
|
-
- ✨
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- 💬 Suggest intelligent Git commit messages
|
|
8
|
+
- ✨ Comment and refactor code files
|
|
9
|
+
- 🧐 Summarize files in plain English
|
|
10
|
+
- 📜 Auto-update your changelog
|
|
11
|
+
- 🧪 Generate Jest tests (ALPHA)
|
|
12
|
+
- 🔍 Search and ask questions across your codebase (BETA)
|
|
13
|
+
- 🔐 100% local — no API keys, no cloud, no telemetry
|
|
13
14
|
|
|
14
15
|
---
|
|
15
16
|
|
|
16
17
|
## 🚀 Features
|
|
17
18
|
|
|
18
|
-
-
|
|
19
|
+
- ⚡ Powered by open-source models (e.g. `llama3`, `codellama`)
|
|
20
|
+
- 🔍 Full-text indexing & semantic search (BETA)
|
|
19
21
|
- 🛠️ Built with Node.js and TypeScript
|
|
20
|
-
-
|
|
21
|
-
- ✅ Global options to select model and programming language
|
|
22
|
+
- ✅ Easily configurable via CLI or global flags
|
|
22
23
|
|
|
23
24
|
---
|
|
24
25
|
|
|
25
26
|
## ❤️ Why Local AI?
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
**Your code stays yours.**
|
|
29
|
+
scai runs entirely on your machine and doesn't require cloud APIs or API keys. That means:
|
|
28
30
|
|
|
29
|
-
- ✅ **
|
|
30
|
-
- ✅ **
|
|
31
|
-
- ✅ **
|
|
32
|
-
|
|
33
|
-
By running everything locally, you can be sure that your sensitive code and workflows stay safe, private, and within your control.
|
|
31
|
+
- ✅ **Privacy-first**: no telemetry, no server round-trips
|
|
32
|
+
- ✅ **EU & GDPR-friendly**: designed with compliance in mind
|
|
33
|
+
- ✅ **Developer control**: full transparency and override options
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
37
|
## 📦 Installation
|
|
38
38
|
|
|
39
|
-
1. **Install Ollama
|
|
40
|
-
-
|
|
41
|
-
-
|
|
39
|
+
1. **Install Ollama (for local models)**
|
|
40
|
+
- macOS: `brew install ollama`
|
|
41
|
+
- Windows: [Download here](https://ollama.com/download)
|
|
42
|
+
- Start Ollama after installing.
|
|
42
43
|
|
|
43
44
|
2. **Install scai globally:**
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g scai
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
3. **Initialize
|
|
49
|
-
```bash
|
|
50
|
-
scai init
|
|
51
|
-
```
|
|
49
|
+
3. **Initialize models:**
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
```bash
|
|
52
|
+
scai init
|
|
53
|
+
```
|
|
54
54
|
|
|
55
|
-
---
|
|
56
55
|
|
|
57
|
-
## ⚒️ Usage
|
|
56
|
+
## ⚒️ Usage Overview
|
|
58
57
|
|
|
59
|
-
### 🔧 Git
|
|
58
|
+
### 🔧 Git Commit Suggestions
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
60
|
+
```bash
|
|
61
|
+
git add .
|
|
62
|
+
scai git sugg
|
|
63
|
+
```
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
feat(api): add error handling to user service
|
|
70
|
-
```
|
|
65
|
+
Suggests a meaningful commit message based on your staged code.
|
|
66
|
+
To auto-commit:
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```
|
|
68
|
+
```bash
|
|
69
|
+
scai git sugg --commit
|
|
70
|
+
```
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
---
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
scai gen summ <file>
|
|
82
|
-
```
|
|
74
|
+
### 🛠️ Code Generation Commands (`gen` group)
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
```bash
|
|
77
|
+
scai gen summ <file>
|
|
78
|
+
scai gen comm <file>
|
|
79
|
+
scai gen changelog
|
|
80
|
+
scai gen tests <file>
|
|
81
|
+
```
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
* `summ`: Summarize a file
|
|
84
|
+
* `comm`: Add comments or refactor suggestions
|
|
85
|
+
* `changelog`: Update or create `CHANGELOG.md` from Git diff
|
|
86
|
+
* `tests`: Create Jest test stubs (ALPHA)
|
|
93
87
|
|
|
94
|
-
|
|
88
|
+
You can also pipe file content directly:
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
90
|
+
```bash
|
|
91
|
+
cat src/utils/math.ts | scai gen summ
|
|
92
|
+
```
|
|
100
93
|
|
|
101
|
-
|
|
94
|
+
---
|
|
102
95
|
|
|
103
96
|
## ⚙️ Configuration
|
|
104
97
|
|
|
105
|
-
scai stores
|
|
98
|
+
scai stores settings in `~/.scai/config.json`. You can override or view them:
|
|
106
99
|
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
scai set model <model>
|
|
110
|
-
```
|
|
100
|
+
* **Set model:**
|
|
111
101
|
|
|
112
|
-
|
|
102
|
+
```bash
|
|
103
|
+
scai set model codellama:7b
|
|
104
|
+
```
|
|
105
|
+
* **Set language:**
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
```bash
|
|
108
|
+
scai set lang ts
|
|
109
|
+
```
|
|
110
|
+
* **Show config:**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
scai config
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<br>
|
|
117
|
+
|
|
118
|
+
## 🔁 Background Daemon and Indexing ⚠️ Beta Notice
|
|
119
|
+
|
|
120
|
+
These features are experimental and subject to change:
|
|
121
|
+
|
|
122
|
+
* `index`, `find`, `ask`
|
|
123
|
+
* `daemon`, `stop-daemon`
|
|
124
|
+
* `gen tests` (test generation)
|
|
125
|
+
|
|
126
|
+
<br>
|
|
127
|
+
|
|
128
|
+
> **Note:** Indexing very large repositories (millions of lines) may take **hours or days**. Please be patient, and only index huge codebases if you are ok with some extra processing taking place on your computer.
|
|
118
129
|
|
|
119
|
-
|
|
130
|
+
The `scai index` command **automatically** starts a background daemon that continuously:
|
|
131
|
+
|
|
132
|
+
* Scans your target directory
|
|
133
|
+
* Summarizes new or changed files
|
|
134
|
+
* Updates embeddings and the search index
|
|
135
|
+
|
|
136
|
+
You won't gain much value from the index unless you scope it to one repository.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### 🔍 Codebase Search & Ask (BETA)
|
|
141
|
+
|
|
142
|
+
> **Important:** You must `index` a **code repository** first or `find` and `ask` have no context to work with.
|
|
143
|
+
|
|
144
|
+
1. **Set index directory:**
|
|
120
145
|
|
|
121
|
-
- **Show current configuration:**
|
|
122
146
|
```bash
|
|
123
|
-
scai
|
|
147
|
+
scai set index-dir /path/to/repo
|
|
124
148
|
```
|
|
125
149
|
|
|
126
|
-
|
|
150
|
+
2. **Index your repo (once):**
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
scai index
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
3. The daemon is designed to **consume minimal resources** and run unobtrusively. You can control it with:
|
|
157
|
+
|
|
127
158
|
```bash
|
|
128
|
-
scai
|
|
159
|
+
scai daemon # Start or show daemon status
|
|
160
|
+
scai stop-daemon # Stop the background indexer
|
|
129
161
|
```
|
|
130
162
|
|
|
163
|
+
|
|
164
|
+
4. **Keyword search:**
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
scai find YourClassName
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
5. **Natural-language questions:**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
scai ask "How does mapcontrol work?"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`find` and `ask` rely on that index—without it they will return no useful results.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 🛍️ Maintenance & Utilities
|
|
182
|
+
|
|
183
|
+
* **Reset database (w/ backup):**
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
scai reset-db
|
|
187
|
+
```
|
|
188
|
+
* **Manual backup of `~/.scai`:**
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
scai backup
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 🧺 Module Pipeline Mode
|
|
197
|
+
|
|
198
|
+
For custom pipelines on a single file:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
scai src/file.ts -m summary,comments
|
|
202
|
+
```
|
|
203
|
+
|
|
131
204
|
---
|
|
132
205
|
|
|
133
206
|
## 🔐 License & Fair Use
|
|
134
207
|
|
|
135
|
-
**scai is free to use** for individuals, teams, and
|
|
208
|
+
**scai is free to use** for individuals, teams, and commercial projects.
|
|
136
209
|
|
|
137
210
|
You may:
|
|
138
|
-
- ✅ Use it internally in your projects
|
|
139
|
-
- ✅ Use it at work or in commercial development
|
|
140
|
-
- ✅ Share and recommend it
|
|
141
211
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
212
|
+
* ✅ Use internally or commercially
|
|
213
|
+
* ✅ Fork and improve
|
|
214
|
+
* ✅ Recommend to others
|
|
215
|
+
|
|
216
|
+
You may **not**:
|
|
217
|
+
|
|
218
|
+
* ❌ Resell as a product or service
|
|
219
|
+
* ❌ Claim ownership of the tool
|
|
145
220
|
|
|
146
221
|
See [LICENSE](./LICENSE) for full terms.
|
|
222
|
+
|
|
223
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/commands/BackupCmd.ts
|
|
2
|
+
import { backupScaiFolder } from '../db/backup.js';
|
|
3
|
+
export async function runBackupCommand() {
|
|
4
|
+
console.log('🔁 Backing up .scai folder...');
|
|
5
|
+
const result = await backupScaiFolder();
|
|
6
|
+
if (result) {
|
|
7
|
+
console.log('✅ Backup complete.');
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
console.error('❌ Backup failed.');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import fsp from 'fs/promises';
|
|
3
|
-
import { db } from '../db/client.js';
|
|
4
|
-
import { DB_PATH, SCAI_HOME } from '../constants.js';
|
|
5
|
-
import lockfile from 'proper-lockfile';
|
|
6
2
|
import path from 'path';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
async function backupScaiFolder() {
|
|
12
|
-
const backupDir = getBackupDir();
|
|
13
|
-
try {
|
|
14
|
-
await fsp.mkdir(backupDir, { recursive: true });
|
|
15
|
-
const files = await fsp.readdir(SCAI_HOME);
|
|
16
|
-
for (const file of files) {
|
|
17
|
-
const srcPath = path.join(SCAI_HOME, file);
|
|
18
|
-
const destPath = path.join(backupDir, file);
|
|
19
|
-
const stat = await fsp.stat(srcPath);
|
|
20
|
-
if (stat.isFile()) {
|
|
21
|
-
await fsp.copyFile(srcPath, destPath);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
console.log(`📦 Backed up .scai folder to: ${backupDir}`);
|
|
25
|
-
return backupDir;
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
console.warn('⚠️ Failed to back up .scai folder:', err instanceof Error ? err.message : err);
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
3
|
+
import lockfile from 'proper-lockfile';
|
|
4
|
+
import { db } from '../db/client.js';
|
|
5
|
+
import { DB_PATH } from '../constants.js';
|
|
6
|
+
import { backupScaiFolder } from '../db/backup.js'; // <-- New import
|
|
32
7
|
export async function resetDatabase() {
|
|
33
8
|
console.log('🔁 Backing up existing .scai folder...');
|
|
34
9
|
await backupScaiFolder();
|
|
@@ -1,68 +1,65 @@
|
|
|
1
1
|
export const IGNORED_EXTENSIONS = [
|
|
2
|
-
// Media
|
|
2
|
+
// ─── Media Files ─────────────────────────────────────────────
|
|
3
3
|
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.ico',
|
|
4
4
|
'.mp4', '.mp3', '.mov', '.avi', '.mkv', '.flv', '.wav', '.flac',
|
|
5
5
|
'.aac', '.m4a', '.wma', '.3gp', '.webm', '.ogg', '.aiff', '.au',
|
|
6
|
-
//
|
|
6
|
+
// ─── Archive & Install Packages ─────────────────────────────
|
|
7
7
|
'.zip', '.tar', '.gz', '.bz2', '.xz', '.rar', '.7z',
|
|
8
8
|
'.jar', '.war', '.ear', '.deb', '.rpm', '.pkg', '.msi', '.dmg', '.cab', '.apk',
|
|
9
9
|
'.tar.gz', '.tar.bz2', '.tar.xz', '.tar.lzma', '.tar.zst',
|
|
10
|
-
// Binaries &
|
|
10
|
+
// ─── Binaries & Executables ─────────────────────────────────
|
|
11
11
|
'.exe', '.dll', '.bin', '.so', '.dylib', '.a', '.lib',
|
|
12
|
-
'.iso', '.img', '.elf', '.o', '.obj', '.msm',
|
|
12
|
+
'.iso', '.img', '.elf', '.o', '.obj', '.msm',
|
|
13
13
|
'.cmd', '.bat', '.ps1', '.sh', '.bash', '.run',
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'.vbs', '.jscript',
|
|
15
|
+
// ─── Build / Runtime Cache ─────────────────────────────────
|
|
16
|
+
'.log', '.tmp', '.map', '.tsbuildinfo', '.coverage', '.eslintcache',
|
|
16
17
|
'.db', '.sqlite', '.pkl', '.sav', '.rdb', '.ldb',
|
|
17
|
-
'.pyc', '.class', '.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'.
|
|
21
|
-
|
|
22
|
-
// Certs, keys, credentials
|
|
18
|
+
'.pyc', '.class', '.yarn', '.webpack', '.babel', '.compilercache',
|
|
19
|
+
// ─── Fonts & Stylesheets ───────────────────────────────────
|
|
20
|
+
'.woff', '.woff2', '.ttf', '.eot', '.otf',
|
|
21
|
+
'.scss', '.sass', '.less', '.styl', '.css.map',
|
|
22
|
+
// ─── Certificates & Keys ───────────────────────────────────
|
|
23
23
|
'.crt', '.key', '.pem', '.pub', '.asc', '.gpg', '.p12', '.csr', '.der', '.pfx',
|
|
24
|
-
// Backups
|
|
25
|
-
'.bak', '.old', '.swp', '.swo', '.orig',
|
|
26
|
-
'.
|
|
27
|
-
|
|
28
|
-
'.
|
|
29
|
-
//
|
|
30
|
-
'.
|
|
31
|
-
|
|
24
|
+
// ─── Backups & Temp Files ──────────────────────────────────
|
|
25
|
+
'.bak', '.bakx', '.old', '.swp', '.swo', '.orig', '.~',
|
|
26
|
+
'.db-shm', '.db-wal',
|
|
27
|
+
'.log.old', '.log.1', '.log.2', '.log.3',
|
|
28
|
+
'.xml.bck', '.wbk', '.asd',
|
|
29
|
+
// ─── Editor / IDE Artifacts ────────────────────────────────
|
|
30
|
+
'.sublime-workspace', '.sublime-project',
|
|
31
|
+
'.iml', '.ipr', '.iws', '.idea', '.code-workspace', '.vscode',
|
|
32
|
+
'.ncb', '.suo', '.user', '.sdf',
|
|
33
|
+
'.classlist', '.nb-gradle', '.gradle',
|
|
34
|
+
// ─── System & OS Metadata ──────────────────────────────────
|
|
35
|
+
'.DS_Store', '.ds_store', '.thumb', '.ini', '.sys', '.lnk',
|
|
36
|
+
'.trash', '.trashes', '.localized', '.spotlight-v100',
|
|
37
|
+
'.~lock', '.appledouble',
|
|
38
|
+
// ─── GIS / Geospatial ──────────────────────────────────────
|
|
39
|
+
'.shp', '.shx', '.dbf', '.prj', '.qix', '.sbn', '.sbx',
|
|
40
|
+
'.shp.xml', '.cpg', '.gpkg', '.mif', '.mid',
|
|
41
|
+
// ─── Business Intelligence / Reporting ─────────────────────
|
|
32
42
|
'.pbix', '.rdl', '.rpt', '.bqy', '.iqy',
|
|
33
|
-
// ETL / DWH / Modeling
|
|
43
|
+
// ─── ETL / DWH / Modeling ──────────────────────────────────
|
|
34
44
|
'.abf', '.dtsx', '.bim', '.xmi',
|
|
35
|
-
// CAD / Engineering
|
|
45
|
+
// ─── CAD / Engineering ─────────────────────────────────────
|
|
36
46
|
'.dwg', '.dxf', '.step', '.stp', '.sldprt', '.sldasm',
|
|
37
47
|
'.iges', '.igs', '.3ds', '.fbx',
|
|
38
|
-
// Forms / Print / Publishing
|
|
48
|
+
// ─── Forms / Print / Publishing ────────────────────────────
|
|
39
49
|
'.xps', '.afpub', '.pub', '.indd', '.qxd', '.frm', '.frx', '.frl',
|
|
40
|
-
// ERP / Finance / Legacy DB
|
|
50
|
+
// ─── ERP / Finance / Legacy DB ─────────────────────────────
|
|
41
51
|
'.mbd', '.fdb', '.nav', '.accdb', '.mdb', '.gdb',
|
|
42
52
|
'.sap', '.sappkg', '.qbw', '.qbb',
|
|
43
|
-
// Lock
|
|
44
|
-
'.lck', '.lockfile', '.db-lock', '.pid', '.socket',
|
|
45
|
-
// Documentation
|
|
46
|
-
'.md',
|
|
47
|
-
|
|
48
|
-
'.
|
|
49
|
-
//
|
|
50
|
-
'.
|
|
51
|
-
'.
|
|
52
|
-
'.
|
|
53
|
-
|
|
54
|
-
|
|
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)
|
|
53
|
+
// ─── Lock Files (Exclude lock *data*, not lock *configs*) ──
|
|
54
|
+
'.lck', '.lock', '.lockfile', '.db-lock', '.pid', '.sock', '.socket',
|
|
55
|
+
// ─── Documentation & Readme ────────────────────────────────
|
|
56
|
+
'.md', '.rst', '.txt',
|
|
57
|
+
// ─── Configuration Files ───────────────────────────────────
|
|
58
|
+
'.json', '.yaml', '.yml', '.xml', '.properties',
|
|
59
|
+
// ─── Scientific & Data Serialization ───────────────────────
|
|
60
|
+
'.npy', '.npz', '.feather', '.parquet', '.orc', '.avro',
|
|
61
|
+
'.hdf5', '.h5', '.rda', '.rds',
|
|
62
|
+
'.csv.gz', '.dump',
|
|
63
|
+
// ─── Misc Hashes & Metadata ────────────────────────────────
|
|
64
|
+
'.md5', '.sha1', '.sha256', '.xlsb', '.xar',
|
|
68
65
|
];
|
package/dist/config/StopWords.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* These common words are ignored from search queries
|
|
3
|
-
* to reduce noise and improve FTS and embedding match quality.
|
|
4
|
-
*/
|
|
5
1
|
export const STOP_WORDS = new Set([
|
|
6
2
|
// Articles & conjunctions
|
|
7
|
-
'a', 'an', 'and', 'but', 'or', 'nor',
|
|
3
|
+
'a', 'an', 'the', 'and', 'but', 'or', 'nor', 'yet', 'so',
|
|
8
4
|
// Prepositions
|
|
9
|
-
'at', 'by', 'for', 'from', 'in', 'into', 'of', 'on', 'to', 'with', 'about', 'above',
|
|
5
|
+
'at', 'by', 'for', 'from', 'in', 'into', 'of', 'on', 'to', 'with', 'about', 'above',
|
|
6
|
+
'below', 'under', 'over', 'through', 'within', 'without', 'across', 'behind', 'near',
|
|
10
7
|
// Pronouns
|
|
11
|
-
'i', 'me', 'my', 'mine', 'you', 'your', 'yours', 'he', 'him', 'his', 'she', 'her', 'hers',
|
|
12
|
-
'we', 'us', 'our', 'ours', 'they', 'them', 'their', 'theirs',
|
|
13
|
-
// Determiners
|
|
8
|
+
'i', 'me', 'my', 'mine', 'you', 'your', 'yours', 'he', 'him', 'his', 'she', 'her', 'hers',
|
|
9
|
+
'it', 'its', 'we', 'us', 'our', 'ours', 'they', 'them', 'their', 'theirs', 'someone', 'something',
|
|
10
|
+
// Determiners & quantifiers
|
|
14
11
|
'this', 'that', 'these', 'those', 'some', 'any', 'each', 'every', 'either', 'neither',
|
|
12
|
+
'few', 'several', 'all', 'many', 'much', 'most', 'more', 'less', 'another',
|
|
15
13
|
// Auxiliary and modal verbs
|
|
16
14
|
'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
17
15
|
'do', 'does', 'did',
|
|
@@ -19,10 +17,18 @@ export const STOP_WORDS = new Set([
|
|
|
19
17
|
'can', 'could', 'shall', 'should', 'will', 'would', 'may', 'might', 'must',
|
|
20
18
|
// Wh-words and generic question words
|
|
21
19
|
'what', 'which', 'who', 'whom', 'whose', 'where', 'when', 'why', 'how',
|
|
22
|
-
//
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
//
|
|
27
|
-
'
|
|
20
|
+
// Common verbs (noisy or generic)
|
|
21
|
+
'use', 'get', 'set', 'make', 'need', 'want', 'let', 'help', 'work',
|
|
22
|
+
'see', 'look', 'like', 'know', 'tell', 'show', 'call', 'create', 'put', 'run',
|
|
23
|
+
'start', 'stop', 'begin', 'end', 'open', 'close',
|
|
24
|
+
// Functional & filler words
|
|
25
|
+
'as', 'if', 'than', 'then', 'there', 'here', 'because', 'so', 'just', 'only',
|
|
26
|
+
'not', 'no', 'also', 'again', 'really', 'actually', 'maybe', 'please',
|
|
27
|
+
'very', 'too', 'quite', 'rather', 'even', 'still', 'ever', 'never',
|
|
28
|
+
'though', 'although', 'indeed', 'perhaps', 'such',
|
|
29
|
+
// Command fluff
|
|
30
|
+
'explain', 'describe', 'define', 'find', 'give', 'provide', 'show',
|
|
31
|
+
'tell', 'check',
|
|
32
|
+
// Miscellaneous low-information words
|
|
33
|
+
'yes', 'no', 'okay', 'ok', 'thing', 'stuff', 'way', 'anything'
|
|
28
34
|
]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fsp from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { SCAI_HOME } from '../constants.js';
|
|
4
|
+
function getBackupDir() {
|
|
5
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
6
|
+
return path.join(SCAI_HOME, `backup-${timestamp}`);
|
|
7
|
+
}
|
|
8
|
+
export async function backupScaiFolder() {
|
|
9
|
+
const backupDir = getBackupDir();
|
|
10
|
+
try {
|
|
11
|
+
await fsp.mkdir(backupDir, { recursive: true });
|
|
12
|
+
const files = await fsp.readdir(SCAI_HOME);
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
const srcPath = path.join(SCAI_HOME, file);
|
|
15
|
+
const destPath = path.join(backupDir, file);
|
|
16
|
+
const stat = await fsp.stat(srcPath);
|
|
17
|
+
if (stat.isFile()) {
|
|
18
|
+
await fsp.copyFile(srcPath, destPath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
console.log(`📦 Backed up .scai folder to: ${backupDir}`);
|
|
22
|
+
return backupDir;
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
console.warn('⚠️ Failed to back up .scai folder:', err instanceof Error ? err.message : err);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { runFindCommand } from './commands/FindCmd.js';
|
|
|
19
19
|
import { startDaemon } from './commands/DaemonCmd.js';
|
|
20
20
|
import { runStopDaemonCommand } from "./commands/StopDaemonCmd.js";
|
|
21
21
|
import { runAskCommand } from './commands/AskCmd.js';
|
|
22
|
+
import { runBackupCommand } from './commands/BackupCmd.js';
|
|
22
23
|
// 🎛️ CLI Setup
|
|
23
24
|
const cmd = new Command('scai')
|
|
24
25
|
.version(version)
|
|
@@ -96,14 +97,6 @@ cmd
|
|
|
96
97
|
.action(() => {
|
|
97
98
|
Config.show();
|
|
98
99
|
});
|
|
99
|
-
// Add explanation about alpha features directly in the help menu
|
|
100
|
-
cmd.addHelpText('after', `
|
|
101
|
-
🚨 Alpha Features:
|
|
102
|
-
- The "index", "daemon", "stop-daemon", "reset-db" commands are considered alpha features.
|
|
103
|
-
- These commands are in active development and may change in the future.
|
|
104
|
-
|
|
105
|
-
💡 Use with caution and expect possible changes or instability.
|
|
106
|
-
`);
|
|
107
100
|
// 🔍 Indexing
|
|
108
101
|
cmd
|
|
109
102
|
.command('index [targetDir]')
|
|
@@ -112,6 +105,10 @@ cmd
|
|
|
112
105
|
.action((targetDir, options) => {
|
|
113
106
|
runIndexCommand(targetDir, { force: options.force });
|
|
114
107
|
});
|
|
108
|
+
cmd
|
|
109
|
+
.command('backup')
|
|
110
|
+
.description('Backup the current .scai folder')
|
|
111
|
+
.action(runBackupCommand);
|
|
115
112
|
// 🧠 Query and assistant
|
|
116
113
|
cmd
|
|
117
114
|
.command('find <query>')
|
|
@@ -150,6 +147,14 @@ cmd
|
|
|
150
147
|
}
|
|
151
148
|
runModulePipelineFromCLI(file, options);
|
|
152
149
|
});
|
|
150
|
+
// Add explanation about alpha features directly in the help menu
|
|
151
|
+
cmd.addHelpText('after', `
|
|
152
|
+
🚨 Alpha Features:
|
|
153
|
+
- The "index", "daemon", "stop-daemon", "reset-db" commands are considered alpha features.
|
|
154
|
+
- These commands are in active development and may change in the future.
|
|
155
|
+
|
|
156
|
+
💡 Use with caution and expect possible changes or instability.
|
|
157
|
+
`);
|
|
153
158
|
// ✅ Parse CLI args
|
|
154
159
|
cmd.parse(process.argv);
|
|
155
160
|
// 🔁 Apply global options post-parse
|