scai 0.1.89 → 0.1.90

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
@@ -301,6 +301,14 @@ scai index switch
301
301
 
302
302
  Switch active repository (by key or indexDir). Run without input for an interactive list of repositories.
303
303
 
304
+ #### `scai index delete`
305
+
306
+ Delete a repository from the index (interactive).
307
+ This removes the repository entry from the `config.json` file, but does **not** delete the repository folder on disk.
308
+
309
+ ```bash
310
+ scai index delete
311
+ ```
304
312
 
305
313
  ---
306
314
 
package/dist/CHANGELOG.md CHANGED
@@ -112,4 +112,9 @@ Type handling with the module pipeline
112
112
  ## 2025-08-16
113
113
 
114
114
  • Update preserveCodeModule to compare blocks correctly and handle duplicate blocks
115
- • Normalize line endings and detect comments in preserveCodeModule
115
+ • Normalize line endings and detect comments in preserveCodeModule
116
+
117
+ ## 2025-08-18
118
+
119
+ • Add interactive delete repository command
120
+ • Refactor DeleteIndex command to handle repository deletion correctly
@@ -0,0 +1,48 @@
1
+ // File: src/commands/delete.ts
2
+ import readline from 'readline';
3
+ import { Config, writeConfig } from '../config.js';
4
+ import chalk from 'chalk';
5
+ export async function runInteractiveDelete() {
6
+ const config = Config.getRaw();
7
+ const keys = Object.keys(config.repos || {});
8
+ if (!keys.length) {
9
+ console.log('⚠️ No repositories configured.');
10
+ return;
11
+ }
12
+ console.log('\n🗑️ Repositories Available for Deletion:\n');
13
+ keys.forEach((key, i) => {
14
+ const isActive = config.activeRepo === key ? chalk.green('(active)') : '';
15
+ const dir = config.repos[key]?.indexDir ?? '';
16
+ console.log(`${chalk.blue(`${i + 1})`)} ${key} ${isActive}`);
17
+ console.log(` ↳ ${chalk.grey(dir)}`);
18
+ });
19
+ const rl = readline.createInterface({
20
+ input: process.stdin,
21
+ output: process.stdout,
22
+ });
23
+ rl.question('\n👉 Select a repository number to delete: ', (answer) => {
24
+ rl.close();
25
+ const index = parseInt(answer.trim(), 10) - 1;
26
+ if (isNaN(index) || index < 0 || index >= keys.length) {
27
+ console.log('❌ Invalid selection.');
28
+ return;
29
+ }
30
+ const selectedKey = keys[index];
31
+ console.log(`\n⚠️ Deleting repository: ${chalk.red(selectedKey)}\n`);
32
+ // Build update: remove repo by setting it to null
33
+ const update = { repos: { [selectedKey]: null } };
34
+ // Reset activeRepo if it pointed to the deleted one
35
+ if (config.activeRepo === selectedKey) {
36
+ const remainingKeys = keys.filter((k) => k !== selectedKey);
37
+ update.activeRepo = remainingKeys[0] || undefined;
38
+ console.log(`ℹ️ Active repo reset to: ${chalk.green(update.activeRepo ?? 'none')}`);
39
+ }
40
+ try {
41
+ writeConfig(update); // only pass the diff
42
+ console.log(`✅ Repository "${selectedKey}" removed from config.json.`);
43
+ }
44
+ catch (err) {
45
+ console.error('❌ Failed to update config.json:', err instanceof Error ? err.message : err);
46
+ }
47
+ });
48
+ }
package/dist/config.js CHANGED
@@ -30,7 +30,7 @@ export function readConfig() {
30
30
  export function writeConfig(newCfg) {
31
31
  ensureConfigDir();
32
32
  const current = readConfig();
33
- const merged = {
33
+ let merged = {
34
34
  ...current,
35
35
  ...newCfg,
36
36
  repos: {
@@ -38,6 +38,14 @@ export function writeConfig(newCfg) {
38
38
  ...(newCfg.repos || {}),
39
39
  },
40
40
  };
41
+ // Special handling: remove repos explicitly set to null
42
+ if (newCfg.repos) {
43
+ for (const [key, value] of Object.entries(newCfg.repos)) {
44
+ if (value === null) {
45
+ delete merged.repos[key];
46
+ }
47
+ }
48
+ }
41
49
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(merged, null, 2));
42
50
  }
43
51
  export const Config = {
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ import { handleAgentRun } from './agentManager.js';
30
30
  import { addCommentsModule } from './pipeline/modules/commentModule.js';
31
31
  import { generateTestsModule } from './pipeline/modules/generateTestsModule.js';
32
32
  import { preserveCodeModule } from './pipeline/modules/preserveCodeModule.js';
33
+ import { runInteractiveDelete } from './commands/DeleteIndex.js';
33
34
  // 🎛️ CLI Setup
34
35
  const cmd = new Command('scai')
35
36
  .version(version)
@@ -177,6 +178,12 @@ index
177
178
  .action(() => {
178
179
  runInteractiveSwitch();
179
180
  });
181
+ index
182
+ .command('delete')
183
+ .description('Delete a repository from the index (interactive)')
184
+ .action(() => {
185
+ runInteractiveDelete();
186
+ });
180
187
  // This will help resolve the current directory in an ES Module
181
188
  cmd
182
189
  .command('check-db')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scai",
3
- "version": "0.1.89",
3
+ "version": "0.1.90",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "scai": "./dist/index.js"