scai 0.1.118 → 0.1.119

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 CHANGED
@@ -1,607 +1,192 @@
1
- # ⚙️ scaiSmart Commit AI
1
+ # ⚙️ SCAISource Code AI 🌿
2
2
 
3
- > AI-powered CLI tool for commit messages, pull request reviews, **and agent-driven workflows** using local models.
3
+ > **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.
4
4
 
5
- **scai** is your AI pair‑programmer in the terminal. Focus on coding while scai:
5
+ SCAI is your AI coding companion in the terminal. Focus on coding while Scai helps you understand, comment, and analyze your code. **Local Model Note:** Using local LLMs ensures privacy and offline usage, and **NO token cost, but capabilities are more limited compared to cloud-hosted AI.**
6
6
 
7
- * 💬 **Suggests intelligent Git commit messages** based on your staged diff
8
- * 🤖 **Reviews open pull requests** and provides AI‑driven feedback (BETA)
9
- * 📝 **Generates comments for multiple files** while you keep coding
10
- * 🤖 **Runs agent workflows** to automate repetitive tasks like summarizing, commenting, or running tests — run agents on single files or entire folders with custom goals
11
- * 📜 Auto‑updates your changelog
12
- * 🔍 (ALPHA) Search & ask questions across your codebase
13
- * 🔐 100% local — no API keys, no cloud, no telemetry
7
+ > ⚠️ **Alpha Version Notice:** If you have previously installed Scai, please run `scai db reset && scai index start` before using this version.
14
8
 
15
9
  ---
16
10
 
17
- ### 🧩 Agent Mode Examples
11
+ ## 💻 Getting Started
18
12
 
19
- Run an agent workflow with goals:
13
+ ### 1️⃣ Install & Initialize
20
14
 
21
15
  ```bash
22
- # Run comments and tests on a single file
23
- $ scai agent run comments tests -f path/to/myfile
24
-
25
- # Run summary on all files in a folder
26
- $ scai agent run summary -f path/to/myfolder
16
+ npm install -g scai
17
+ scai init
18
+ scai index start
27
19
  ```
28
20
 
29
- The agent mode allows you to chain goals (`summary → comments → tests`) while processing files or directories automatically, keeping your workflow fast and focused.
30
-
31
-
32
- ---
33
-
34
- ## 🚀 Features
35
-
36
- - ⚡ Powered by open-source models (e.g. `llama3`, `codellama`)
37
- - 🔍 Full-text indexing & semantic search (ALPHA)
38
- - 🛠️ Built with Node.js and TypeScript
39
- - ✅ Easily configurable via CLI or global flags
21
+ This will initialize local models (recommended: `qwen3-coder:30b`) and start indexing your code repository.
40
22
 
41
- ---
42
-
43
- ## ❤️ Why Local AI?
44
-
45
- **Your code stays yours.**
46
- scai runs entirely on your machine and doesn't require cloud APIs or API keys. That means:
47
-
48
- - ✅ **Privacy-first**: no telemetry, no server round-trips
49
- - ✅ **EU & GDPR-friendly**: designed with compliance in mind
50
- - ✅ **Developer control**: full transparency and override options
51
- - ✅ **Offline support**: works even without an internet connection
52
-
53
- ---
23
+ ### 2️⃣ Check Available Commands
54
24
 
55
- ## 📦 Installation
56
-
57
- 1. **Install Ollama (for local models)**
58
- - macOS: `brew install ollama`
59
- - Windows: [Download here](https://ollama.com/download)
60
- - Start Ollama after installing.
61
-
62
- 2. **Install scai globally:**
63
- ```bash
64
- npm install -g scai
65
- ```
66
-
67
- 3. **Initialize models:**
68
-
69
- ```bash
70
- scai init
71
- ```
25
+ ```bash
26
+ scai --help
27
+ ```
72
28
 
73
29
  ---
74
30
 
75
- ## 🤖 Agent Workflow Command
31
+ ## 🏠 REPL Mode (Local AI Queries)
76
32
 
77
- The `agent` command allows you to run a sequence of AI-powered workflows (goals) on one or multiple files or even an entire folder. This is useful for tasks like generating comments, summaries, or tests, while letting the AI work in the background as you continue coding.
78
-
79
- ### Usage
33
+ Start an interactive REPL to ask natural-language questions about your code:
80
34
 
81
35
  ```bash
82
- # Run agent with comments and tests on a single file
83
- scai agent run comments tests -f path/to/file.ts
84
-
85
- # Run agent on an entire folder
86
- scai agent run comments tests -f path/to/folder
36
+ scai shell
87
37
  ```
88
38
 
89
- You can provide multiple goals, which will be executed in the order specified. Currently supported example goals:
90
-
91
- * `summary` – Summarize a file
92
- * `comments` – Add inline comments to code
93
- * `tests` – Generate test stubs (ALPHA)
39
+ Once in the REPL, you can:
94
40
 
95
- #### Features
41
+ * Ask questions freely about your codebase:
96
42
 
97
- * ✅ Works on single files or entire folders recursively
98
- * Processes multiple files in the background, so you can continue coding
99
- * Modular design allows you to chain goals (e.g., `comments → tests → summary`)
100
-
101
- #### Notes
43
+ ```text
44
+ scai> How many functions in spatialmap.js are missing tests?
45
+ scai> Summarize utils/helpers.ts
46
+ scai> Where are all the database queries defined?
47
+ scai> List files involved in authentication
48
+ ```
102
49
 
103
- * Only `summary`, `comments`, and `tests` are currently fully supported. Other modules are experimental.
104
- * The agent resolves folders into all supported files (`.ts`, `.js`, etc.) automatically.
105
- * Background processing allows you to queue multiple files without waiting for each one to finish interactively.
50
+ * Run slash commands inside the REPL for standard CLI operations:
106
51
 
107
- ---
52
+ ```text
53
+ scai> /git commit
54
+ scai> /index list
55
+ scai> /index set /path/to/repo
56
+ scai> /index switch
57
+ scai> /index delete
58
+ ```
108
59
 
109
- ## AI Code Review, Powered by Your Terminal
60
+ * Execute shell commands directly:
110
61
 
111
- No more struggling to write pull request descriptions by hand. `scai git review` automatically generates a rich summary of your changes, complete with context, suggestions, and rationale.
62
+ ```text
63
+ scai> !ls -la
64
+ scai> !git status
65
+ ```
112
66
 
113
- > ⚠️ These features are in **beta** feedback welcome!
114
- Ping [@ticcr](https://bsky.app/profile/ticcr.xyz) on Bluesky — I'd love to hear your thoughts!
67
+ > Asking questions in the REPL is free, GDPR-friendly, and entirely local.
115
68
 
116
69
  ---
117
70
 
118
- ### 🔑 Setting Up Authentication (Required)
119
-
120
- To interact with GitHub and create pull requests, `scai` needs a personal access token with **repo** permissions.
121
-
122
- 1. **Create your GitHub Access Token**
123
- Follow this link to generate a token: [https://github.com/settings/personal-access-tokens](https://github.com/settings/personal-access-tokens)
124
-
125
- Make sure you enable at least:
126
-
127
- * `repo` (Full control of private repositories)
128
- * `workflow` (If you want PRs to trigger CI)
129
-
130
- 2. **Set the token in scai:**
131
-
132
- ```bash
133
- scai auth set
134
- ```
135
-
136
- This stores your token locally in a secure config file. You can inspect the setup at any time:
137
-
138
- ```bash
139
- scai auth check
140
- ```
71
+ ## 📦 Indexing Commands
141
72
 
142
- 3. **Set the index dir:**
73
+ Before asking questions, you should index your code repository:
143
74
 
144
- ```bash
145
- scai index set /path/to/repo
146
- ```
147
-
148
- This is the repo from which scai will look up pull requests that can be reviewed.
149
-
150
- ---
151
- ## ⚒️ Usage Overview
152
-
153
- ### 🔧 How to Use `scai git commit`
154
-
155
- Use AI to suggest a meaningful commit message based on your staged code:
75
+ * **Set index directory**
156
76
 
157
77
  ```bash
158
- git add .
159
- scai git commit
78
+ scai index set /path/to/repo
160
79
  ```
161
80
 
162
- You can also include a changelog entry along with the commit:
81
+ * **Start indexing**
163
82
 
164
83
  ```bash
165
- scai git commit --changelog
84
+ scai index start
166
85
  ```
167
86
 
168
- This will:
169
- 1. Suggest a commit message based on your `git diff --cached`
170
- 2. Propose a changelog entry (if relevant)
171
- 3. Allow you to approve, regenerate, or skip the changelog
172
- 4. Automatically stage and commit the changes
173
-
174
- ---
175
-
176
- ### 🧠 How to Use `scai git review`
87
+ * **List all indexed repositories**
177
88
 
178
89
  ```bash
179
- scai git review
180
- ```
181
-
182
- This will show you pull requests assigned to you for review:
183
-
184
- * Understand the diffs using a local model
185
- * Generate a structured pull request:
186
-
187
- * ✅ Title
188
- * ✅ Summary of changes
189
- * ✅ Explanation of why the changes matter
190
- * ✅ Optional changelog bullets
191
-
192
-
193
- SCAI supports an integrated review flow for GitHub pull requests. To get started:
194
-
195
- 1. **Set your working index directory (once per repo):**
196
-
197
- ```sh
198
- scai index set /path/to/repo
199
- ```
200
-
201
- 2. **Authenticate with GitHub:**
202
- ```sh
203
- scai git review
204
- ```
205
-
206
- This command will query you for the Personal Access Token and set it for you.
207
- You may also do this with the auth commands below
208
-
209
- ```sh
210
- scai auth set
211
- scai auth check
212
- ```
213
-
214
- 3. **Fetch and review pull requests:**
215
-
216
- ```sh
217
- scai git review
218
- ```
219
-
220
- Use `-a` to list all PRs that require a review:
221
-
222
- ```sh
223
- scai git review -a
224
- ```
225
-
226
- #### Example Workflow
227
-
228
- ```sh
229
- $ scai git review -a
230
- 📦 Resolving GitHub repo info from indexDir: ./
231
- 🔗 Git origin URL: git@github.com:org/repo.git
232
- ✅ Parsed: owner='org', repo='repo'
233
- 👤 Authenticated user: dev-user123
234
-
235
- 🔍 Fetching pull requests and diffs...
236
- ✅ Fetched 5 PR(s) with diffs.
237
-
238
- 📦 Open Pull Requests with review requested:
239
- | # | ID | TITLE | AUTHOR | STATUS | CREATED | REVIEWERS | REVIEWS |
240
- | - | ---- | ----------------------------- | ---------- | ------ | ---------- | ----------------------------- | ------------------- |
241
- | 1 | #120 | fix/session-timeout | dev-alice | Open | 2025-08-08 | code-analyzer\[bot], dev-bob | ✅ Approved |
242
- | 2 | #118 | feature/1482-support-wfs2 | dev-carol | Open | 2025-08-07 | code-analyzer\[bot], dev-dave | ✅ Approved |
243
- | 3 | #117 | refactor/win-server-support | dev-erin | Open | 2025-08-06 | dev-frank, dev-alice | ❌ Changes Requested |
244
- | 4 | #114 | bump/vue-i18n-9.14.5 | dependabot | Open | 2025-08-04 | code-analyzer\[bot] | ✅ Approved |
245
- | 5 | #113 | bugfix/null-navigator-check | dev-bob | Open | 2025-08-03 | dev-alice, dev-carol | ✅ Approved |
246
-
247
- 👉 Choose a PR to review [1-2]: 1
248
- ✅ Model response received.
249
-
250
- 💡 AI-suggested review:
251
-
252
- Solid improvement — this patch improves session stability and handles async state more reliably.
253
- You might consider renaming `sessionManager` to better reflect its dual role in auth and persistence.
254
-
255
- ---
256
- 1) ✅ Approve
257
- 2) ❌ Reject
258
- 3) ✍️ Edit
259
- 4) Write your own review
260
- 5) 🚪 Cancel
90
+ scai index list
261
91
  ```
262
92
 
263
- ### 📝 Generate a Standalone Changelog Entry
264
-
265
- If you want to generate a changelog entry without committing:
93
+ * **Switch active repository**
266
94
 
267
95
  ```bash
268
- scai gen changelog
96
+ scai index switch
269
97
  ```
270
98
 
271
- This will:
272
- - Analyze the current `git diff` (staged or unstaged)
273
- - Propose a list of **user-facing changes** in clean markdown bullet points
274
- - Let you accept, regenerate, or skip the update
275
- - Append the entry to `CHANGELOG.md` and stage it if accepted
276
-
277
-
278
- ### 🛠️ Code Generation Commands (`gen` group)
99
+ * **Delete a repository from index**
279
100
 
280
101
  ```bash
281
- scai gen comm <file|folder...>
282
- scai gen summ <file>
283
- scai gen changelog
284
- scai gen tests <file>
102
+ scai index delete
285
103
  ```
286
104
 
287
- * `comm`: Add comments to one or more files, or to all matching files in a folder (recursive).
288
-
289
- </br>
290
-
291
- ```bash
292
- scai gen comm src/ utils/helpers.ts
293
- ```
294
-
295
- </br>
296
-
297
- This will add comments to all `.ts` and `.js` files under `src/` and to `utils/helpers.ts`.
298
-
299
- </br>
300
-
301
- * `summ`: Summarize a file
302
-
303
- You can also pipe file content directly:
304
-
305
- ```bash
306
- cat src/utils/math.ts | scai gen summ
307
- ```
308
-
309
- </br>
310
-
311
-
312
- * `changelog`: Update or create `CHANGELOG.md` from Git diff
313
-
314
- * `tests`: Create Jest test stubs (ALPHA)
105
+ > Only indexed repositories can be queried by scai.
315
106
 
316
107
  ---
317
108
 
318
109
  ## ⚙️ Configuration
319
110
 
320
- scai stores settings in `~/.scai/config.json`. You can override or view them:
321
-
322
- * **Set model:**
323
-
324
- ```bash
325
- scai config set-model codellama:7b
326
- ```
327
- * **Set language:**
328
-
329
- ```bash
330
- scai config set-lang ts
331
- ```
332
- * **Show config:**
333
-
334
- To see the config for the active repo
335
- ```bash
336
- scai config show
337
- ```
338
-
339
- To see the config for all repos
340
-
341
- ```bash
342
- scai config show --raw
343
- ```
344
-
345
- ---
346
-
347
- ## Commands
348
-
349
- ### `index`
350
- The `index` command is used to manage and perform operations on the indexed files and repositories. It allows you to control which repository you're working with and have indexed.
351
-
352
- #### `scai index start`
353
-
354
- Index supported files in the configured index directory.
355
-
356
- ```bash
357
- scai index set <dir>
358
- ```
359
-
360
- Or just this for cwd (current working dir)
111
+ Set the AI model for local usage (recommended: `qwen3-coder:30b`):
361
112
 
362
113
  ```bash
363
- scai index set
114
+ scai config set-model qwen3-coder:30b
364
115
  ```
365
116
 
366
- Set and activate the index directory.
367
- ```bash
368
- scai index list
369
- ```
117
+ Check current configuration:
370
118
 
371
- List all indexed repositories.
372
119
  ```bash
373
- scai index switch
120
+ scai config show --raw
374
121
  ```
375
122
 
376
- Switch active repository (by key or indexDir). Run without input for an interactive list of repositories.
123
+ ---
377
124
 
378
- #### `scai index delete`
125
+ ## 🔧 Git Commit Assistant
379
126
 
380
- Delete a repository from the index (interactive).
381
- This removes the repository entry from the `config.json` file, but does **not** delete the repository folder on disk.
127
+ Use AI to suggest meaningful commit messages based on your staged changes:
382
128
 
383
129
  ```bash
384
- scai index delete
130
+ git add .
131
+ scai git commit
385
132
  ```
386
133
 
387
- ---
388
-
389
- ## 🛍️ Maintenance & Utilities
390
- # Database Commands
391
-
392
- Your CLI now supports a set of **database management commands** under the `db` namespace. These commands allow you to check the status of the database, reset it, or run migrations.
134
+ This generates a commit message reflecting your changes and context, entirely locally.
393
135
 
394
136
  ---
395
137
 
396
- ### 📋 Available Commands
397
-
398
- #### 🔍 Check Database
399
-
400
- ```bash
401
- scai db check
402
- ```
138
+ ## 🔑 GitHub Authentication
403
139
 
404
- Runs the **dbcheck** script to verify the database status.
140
+ To work with GitHub for repositories, scai needs a Personal Access Token:
405
141
 
406
- * Useful for quickly checking if the database is healthy.
407
- * Prints detailed output directly in the console.
408
-
409
- ---
410
-
411
- #### ♻️ Reset Database
142
+ * **Set your token:**
412
143
 
413
144
  ```bash
414
- scai db reset
145
+ scai auth set
415
146
  ```
416
147
 
417
- Deletes and resets the SQLite database.
418
-
419
- * Will ask for confirmation before proceeding.
420
- * Respond with `y` or `Y` to confirm.
421
- * Any other key (including `n`, `N`, or just pressing **Enter**) will cancel the reset.
422
-
423
- ---
424
-
425
- #### 📦 Run Migrations
148
+ * **Check your token:**
426
149
 
427
150
  ```bash
428
- scai db migrate
151
+ scai auth check
429
152
  ```
430
153
 
431
- Executes all database migration scripts.
432
-
433
- Note the **Migrate** command is for **internal use only**. Do **not** run it unless explicitly instructed, as it may delete existing data or corrupt your local database.
434
-
435
- If you're upgrading from an earlier version, please run the following commands to avoid indexing issues:
154
+ * **Reset your token:**
436
155
 
437
156
  ```bash
438
- scai db reset
439
- scai index
157
+ scai auth reset
440
158
  ```
441
- </br>
442
-
443
- ---
444
-
445
- ### ✅ Example Workflow
446
-
447
- 1. **Check** current database state:
448
-
449
- ```bash
450
- scai db check
451
- ```
452
-
453
- 2. Confirm you're in the correct repo.
454
-
455
- ```bash
456
- scai index list
457
- ```
458
-
459
- Use the switch command to switch if necessary.
460
-
461
- ```bash
462
- scai index switch
463
- ```
464
-
465
- 2. If necessary, **reset** the database:
466
-
467
- ```bash
468
- scai db reset
469
- ```
470
-
471
- → Confirm with `y` when prompted.
472
-
473
- </br>
474
159
 
475
160
  ---
476
161
 
477
- ## 🔁 Background Daemon and Indexing ⚠️ ALPHA Notice
478
-
479
- These features are experimental and subject to change:
480
-
481
- * `find`, `ask`
482
- * `daemon`, `stop-daemon`
483
- * `gen tests` (test generation)
484
-
485
- <br>
162
+ ## 🧠 Example Queries in REPL
486
163
 
487
- > **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.
488
-
489
- The `scai index` command **automatically** starts a background daemon that continuously:
490
-
491
- * Scans your target directory
492
- * Summarizes new or changed files
493
- * Updates embeddings and the search index
494
-
495
- You won't gain much value from the index unless you scope it to one repository.
164
+ * `Summarize spatialmap.js`
165
+ * `Explain utils/helpers.ts architecture`
166
+ * `List all functions without tests in services/`
167
+ * `Show where database queries are defined`
168
+ * `Highlight potential memory leaks`
169
+ * `Describe how authentication works`
170
+ * `Which files handle error handling in contextReview.ts`
171
+ * `Summarize repo architecture`
496
172
 
497
173
  ---
498
174
 
499
- > **Important:** You must `index` a **code repository** first or `find` and `ask` have no context to work with.
500
-
501
- 1. **Set index directory:**
502
-
503
- ```bash
504
- scai index set /path/to/repo
505
- ```
506
-
507
- 2. **Index your repo (once):**
508
-
509
- ```bash
510
- scai index start
511
- ```
512
-
513
- 3. The daemon is designed to **consume minimal resources** and run unobtrusively. You can control it with:
514
-
515
- ```bash
516
- scai daemon # Start or show daemon status
517
- scai stop-daemon # Stop the background indexer
518
- ```
519
-
520
-
521
- 4. **Keyword search:**
522
-
523
- ```bash
524
- scai find YourClassName
525
- ```
526
-
527
- 5. **Natural-language questions:**
528
-
529
- ### 🧠 Natural-language questions
530
-
531
- Ask questions about your codebase using `scai ask`.
532
-
533
- You can run it in two ways:
175
+ ## 🔐 Privacy & GDPR
534
176
 
535
- 1. **Inline question**
536
-
537
- ```bash
538
- scai ask "How does the controller work?"
539
- ```
540
-
541
- 2. **Interactive prompt**
542
-
543
- ```bash
544
- scai ask
545
- ```
546
-
547
- **Press enter**
548
- , then type your question when prompted:
549
-
550
- ```
551
- > How does the controller work?
552
- ```
553
-
554
- </br>
555
-
556
- ### 🚨 **OBS** 🚨
557
-
558
- `find` and `ask` rely on that index—without it they will return no useful results.
177
+ * Fully local — no API keys, no cloud
178
+ * GDPR-friendly, made in Denmark/EU with love ❤️
179
+ * Free to ask questions about your code
559
180
 
560
181
  ---
561
182
 
562
- ### Backup only of `~/.scai`:
563
-
564
- Creates a backup of the .scai folder in the user root dir.
565
-
566
- ```bash
567
- scai backup
568
- ```
569
-
570
- Results in this:
571
- ~/.scai_backup_2025-08-12T06-58-00-227Z/
183
+ ## 🙌 Feedback & Support
572
184
 
573
- </br>
185
+ Reach out with feedback or questions:
574
186
 
575
- ## 🔐 License & Fair Use
576
-
577
- **scai is free to use** for individuals, teams, and commercial projects.
578
-
579
- You may:
580
-
581
- * ✅ Use internally or commercially
582
- * ✅ Fork and improve
583
- * ✅ Recommend to others
584
-
585
- You may **not**:
586
-
587
- * ❌ Resell as a product or service
588
- * ❌ Claim ownership of the tool
589
-
590
- </br>
591
-
592
- ### 📄 License
593
-
594
- Free for personal and internal company use only.
595
- Commercial use (resale, SaaS, inclusion in paid tools) is prohibited.
596
- Contact me for commercial licensing.
187
+ * Threads: [@scai.dk](https://threads.net/@scai.dk)
188
+ * Bugs, feature requests, or ideas welcome!
597
189
 
598
190
  ---
599
191
 
600
- </br>
601
-
602
- ## 🙌 Feedback
603
-
604
- Questions, ideas, or bugs?
605
- Ping [@ticcr](https://bsky.app/profile/ticcr.xyz) on Bluesky — I'd love to hear your thoughts!
606
-
607
- ---
192
+ Enjoy your AI-powered coding companion, fully local, private, and developer-friendly!
@@ -9,7 +9,7 @@ import { readConfig, writeConfig } from './config.js';
9
9
  import { CONFIG_PATH } from './constants.js';
10
10
  // Constants
11
11
  const MODEL_PORT = 11434;
12
- const REQUIRED_MODELS = ['llama3:8b'];
12
+ const REQUIRED_MODELS = ['qwen3-coder:30b'];
13
13
  const OLLAMA_URL = 'https://ollama.com/download';
14
14
  const VSCODE_URL = 'https://code.visualstudio.com/download';
15
15
  const isYesMode = process.argv.includes('--yes') || process.env.SCAI_YES === '1';
@@ -117,7 +117,6 @@ export const cleanupModule = {
117
117
  // --- Parse JSON using simplified strategy ---
118
118
  const parsed = parseJsonWithFallback(content);
119
119
  if (parsed !== null) {
120
- console.log(chalk.green("[cleanupModule] JSON parsed successfully."));
121
120
  return {
122
121
  query: input.query,
123
122
  content,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scai",
3
- "version": "0.1.118",
3
+ "version": "0.1.119",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "scai": "./dist/index.js"