ai-lens 0.1.0 → 0.2.0
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/.commithash +1 -1
- package/bin/ai-lens.js +14 -0
- package/cli/init.js +51 -52
- package/package.json +1 -1
package/.commithash
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
15b6445
|
package/bin/ai-lens.js
CHANGED
|
@@ -17,6 +17,19 @@ switch (command) {
|
|
|
17
17
|
await import('../mcp-server/index.js');
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
20
|
+
case 'version':
|
|
21
|
+
case '--version':
|
|
22
|
+
case '-v': {
|
|
23
|
+
const { readFileSync } = await import('node:fs');
|
|
24
|
+
const { fileURLToPath } = await import('node:url');
|
|
25
|
+
const { dirname, join } = await import('node:path');
|
|
26
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
27
|
+
const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
28
|
+
let commit = 'unknown';
|
|
29
|
+
try { commit = readFileSync(join(root, '.commithash'), 'utf8').trim(); } catch {}
|
|
30
|
+
console.log(`ai-lens v${version} (${commit})`);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
20
33
|
default:
|
|
21
34
|
console.log('Usage: ai-lens <command>');
|
|
22
35
|
console.log('');
|
|
@@ -24,5 +37,6 @@ switch (command) {
|
|
|
24
37
|
console.log(' init Configure AI tool hooks for event capture');
|
|
25
38
|
console.log(' remove Remove AI Lens hooks and client files');
|
|
26
39
|
console.log(' mcp Start the MCP server (stdio transport)');
|
|
40
|
+
console.log(' version Show package version and commit hash');
|
|
27
41
|
process.exit(command ? 1 : 0);
|
|
28
42
|
}
|
package/cli/init.js
CHANGED
|
@@ -111,66 +111,65 @@ export default async function init() {
|
|
|
111
111
|
|
|
112
112
|
if (pending.length === 0) {
|
|
113
113
|
success('Everything is up-to-date. Nothing to do.');
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
blank();
|
|
126
|
-
|
|
127
|
-
// Confirm
|
|
128
|
-
const answer = await ask('Proceed? [Y/n] ');
|
|
129
|
-
if (answer && answer.toLowerCase() !== 'y') {
|
|
130
|
-
info('Aborted.');
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
blank();
|
|
134
|
-
|
|
135
|
-
// Install client files to ~/.ai-lens/client/
|
|
136
|
-
heading('Installing client files...');
|
|
137
|
-
try {
|
|
138
|
-
installClientFiles();
|
|
139
|
-
success(' Copied client files to ~/.ai-lens/client/');
|
|
140
|
-
} catch (err) {
|
|
141
|
-
error(` Failed to install client files: ${err.message}`);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
blank();
|
|
114
|
+
} else {
|
|
115
|
+
// Show plan
|
|
116
|
+
heading('Plan:');
|
|
117
|
+
for (const { tool, analysis } of pending) {
|
|
118
|
+
const plan = describePlan(tool, analysis);
|
|
119
|
+
if (!plan) continue;
|
|
120
|
+
info(` ${plan.description}`);
|
|
121
|
+
detail(`hooks: ${plan.hooks.join(', ')}`);
|
|
122
|
+
}
|
|
123
|
+
blank();
|
|
145
124
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
// Confirm
|
|
126
|
+
const answer = await ask('Proceed? [Y/n] ');
|
|
127
|
+
if (answer && answer.toLowerCase() !== 'y') {
|
|
128
|
+
info('Aborted.');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
blank();
|
|
149
132
|
|
|
150
|
-
|
|
133
|
+
// Install client files to ~/.ai-lens/client/
|
|
134
|
+
heading('Installing client files...');
|
|
151
135
|
try {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
writeHooksConfig(tool, merged);
|
|
155
|
-
success(` ${tool.name}: done`);
|
|
156
|
-
results.push({ tool: tool.name, ok: true });
|
|
136
|
+
installClientFiles();
|
|
137
|
+
success(' Copied client files to ~/.ai-lens/client/');
|
|
157
138
|
} catch (err) {
|
|
158
|
-
error(`
|
|
159
|
-
|
|
139
|
+
error(` Failed to install client files: ${err.message}`);
|
|
140
|
+
return;
|
|
160
141
|
}
|
|
161
|
-
|
|
162
|
-
blank();
|
|
142
|
+
blank();
|
|
163
143
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
144
|
+
// Apply
|
|
145
|
+
heading('Applying changes...');
|
|
146
|
+
const results = [];
|
|
147
|
+
|
|
148
|
+
for (const { tool, analysis } of pending) {
|
|
149
|
+
try {
|
|
150
|
+
const existingConfig = analysis.config || null;
|
|
151
|
+
const merged = buildMergedConfig(tool, existingConfig);
|
|
152
|
+
writeHooksConfig(tool, merged);
|
|
153
|
+
success(` ${tool.name}: done`);
|
|
154
|
+
results.push({ tool: tool.name, ok: true });
|
|
155
|
+
} catch (err) {
|
|
156
|
+
error(` ${tool.name}: failed — ${err.message}`);
|
|
157
|
+
results.push({ tool: tool.name, ok: false, error: err.message });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
blank();
|
|
161
|
+
|
|
162
|
+
// Summary
|
|
163
|
+
heading('Summary');
|
|
164
|
+
for (const r of results) {
|
|
165
|
+
if (r.ok) {
|
|
166
|
+
success(` ${r.tool}: configured`);
|
|
167
|
+
} else {
|
|
168
|
+
error(` ${r.tool}: failed (${r.error})`);
|
|
169
|
+
}
|
|
171
170
|
}
|
|
171
|
+
blank();
|
|
172
172
|
}
|
|
173
|
-
blank();
|
|
174
173
|
|
|
175
174
|
// MCP setup (only if Claude Code is installed)
|
|
176
175
|
const claudeDir = join(homedir(), '.claude');
|