Skip to content

Commit 877f64f

Browse files
CSCSoftwareclaude
andcommitted
feat: add global-init CLI command
Exposes globalInit as CLI command: node build/index.js global-init <path> Supports --index-unindexed and --show-progress flags. Used by CodeRunner to sync projects on button click. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a56bf68 commit 877f64f

1 file changed

Lines changed: 58 additions & 4 deletions

File tree

src/index.ts

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* Provides persistent code indexing for Claude Code.
66
*
77
* Usage:
8-
* node build/index.js - Start MCP server (default)
9-
* node build/index.js scan <path> - Scan for .aidex directories
10-
* node build/index.js init <path> - Index a project
8+
* node build/index.js - Start MCP server (default)
9+
* node build/index.js scan <path> - Scan for .aidex directories
10+
* node build/index.js init <path> - Index a project
11+
* node build/index.js global-init <path> - Scan, index unindexed, register in global DB
1112
*/
1213

1314
import { createServer } from './server/mcp-server.js';
14-
import { scan, init } from './commands/index.js';
15+
import { scan, init, globalInit } from './commands/index.js';
1516
import { setupMcpClients, unsetupMcpClients } from './commands/setup.js';
1617
import { PRODUCT_NAME, PRODUCT_NAME_LOWER } from './constants.js';
1718
import { stopViewer } from './viewer/server.js';
@@ -79,6 +80,59 @@ async function main() {
7980
return;
8081
}
8182

83+
// CLI mode: global-init
84+
if (args[0] === 'global-init') {
85+
const searchPath = args[1];
86+
if (!searchPath) {
87+
console.error(`Usage: ${PRODUCT_NAME_LOWER} global-init <path> [--index-unindexed]`);
88+
process.exit(1);
89+
}
90+
91+
const indexUnindexed = args.includes('--index-unindexed');
92+
const showProgress = args.includes('--show-progress');
93+
94+
console.log(`Scanning: ${searchPath}${indexUnindexed ? ' (will index unindexed projects)' : ''}${showProgress ? ' (with progress UI)' : ''}`);
95+
const result = await globalInit({
96+
path: searchPath,
97+
indexUnindexed,
98+
showProgress,
99+
});
100+
101+
if (!result.success) {
102+
console.error(`Error: ${result.error}`);
103+
process.exit(1);
104+
}
105+
106+
console.log(`Done!`);
107+
console.log(` Registered: ${result.registered}`);
108+
console.log(` New: ${result.newProjects}`);
109+
console.log(` Updated: ${result.updatedProjects}`);
110+
console.log(` Removed: ${result.removedProjects}`);
111+
112+
if (result.indexedResults && result.indexedResults.length > 0) {
113+
const ok = result.indexedResults.filter(r => r.success).length;
114+
const fail = result.indexedResults.filter(r => !r.success).length;
115+
console.log(` Indexed: ${ok} succeeded, ${fail} failed`);
116+
}
117+
118+
if (result.unindexedProjects.length > 0) {
119+
console.log(`\n Unindexed projects found: ${result.unindexedProjects.length}`);
120+
for (const p of result.unindexedProjects) {
121+
console.log(` ${p.name} (${p.path}) ~${p.estimatedFiles} files`);
122+
}
123+
}
124+
125+
if (result.largeProjects && result.largeProjects.length > 0) {
126+
console.log(`\n Large projects skipped (>500 files): ${result.largeProjects.length}`);
127+
for (const p of result.largeProjects) {
128+
console.log(` ${p.name} (${p.path}) ~${p.estimatedFiles} files`);
129+
}
130+
}
131+
132+
console.log(`\n Totals: ${result.totals.projects} projects | ${result.totals.files} files | ${result.totals.methods} methods | ${result.totals.types} types`);
133+
return;
134+
}
135+
82136
// CLI mode: setup
83137
if (args[0] === 'setup') {
84138
setupMcpClients();

0 commit comments

Comments
 (0)