@askance/cli 0.2.0 → 0.2.2
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/dist/cli/index.js +29 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -105,9 +105,13 @@ function initClaude() {
|
|
|
105
105
|
const hookHandlerPath = path_1.default.join(pkgRoot, "dist", "hook-handler", "index.js").replace(/\\/g, "/");
|
|
106
106
|
const stopHookPath = path_1.default.join(pkgRoot, "dist", "hook-handler", "stop-hook.js").replace(/\\/g, "/");
|
|
107
107
|
const mcpServerPath = path_1.default.join(pkgRoot, "dist", "mcp-server", "index.js").replace(/\\/g, "/");
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
let settings = {};
|
|
109
|
+
if (fs_1.default.existsSync(settingsPath)) {
|
|
110
|
+
try {
|
|
111
|
+
settings = JSON.parse(fs_1.default.readFileSync(settingsPath, "utf-8"));
|
|
112
|
+
}
|
|
113
|
+
catch { }
|
|
114
|
+
}
|
|
111
115
|
// Set hooks
|
|
112
116
|
const hooks = (settings.hooks ?? {});
|
|
113
117
|
hooks.PreToolUse = [
|
|
@@ -156,9 +160,13 @@ function initCursor() {
|
|
|
156
160
|
const settingsPath = path_1.default.join(cursorDir, "settings.json");
|
|
157
161
|
const hookHandlerPath = path_1.default.join(pkgRoot, "dist", "hook-handler", "index.js").replace(/\\/g, "/");
|
|
158
162
|
const mcpServerPath = path_1.default.join(pkgRoot, "dist", "mcp-server", "index.js").replace(/\\/g, "/");
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
let settings = {};
|
|
164
|
+
if (fs_1.default.existsSync(settingsPath)) {
|
|
165
|
+
try {
|
|
166
|
+
settings = JSON.parse(fs_1.default.readFileSync(settingsPath, "utf-8"));
|
|
167
|
+
}
|
|
168
|
+
catch { }
|
|
169
|
+
}
|
|
162
170
|
// Set Cursor hooks
|
|
163
171
|
const cursorHooks = (settings["cursor.hooks"] ?? {});
|
|
164
172
|
cursorHooks.preToolUse = {
|
|
@@ -190,9 +198,13 @@ function initCopilot() {
|
|
|
190
198
|
}
|
|
191
199
|
const configPath = path_1.default.join(githubDir, "copilot-config.json");
|
|
192
200
|
const hookHandlerPath = path_1.default.join(pkgRoot, "dist", "hook-handler", "index.js").replace(/\\/g, "/");
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
let config = {};
|
|
202
|
+
if (fs_1.default.existsSync(configPath)) {
|
|
203
|
+
try {
|
|
204
|
+
config = JSON.parse(fs_1.default.readFileSync(configPath, "utf-8"));
|
|
205
|
+
}
|
|
206
|
+
catch { }
|
|
207
|
+
}
|
|
196
208
|
// Set Copilot agent hooks
|
|
197
209
|
const copilotAgent = (config["copilot.agent"] ?? {});
|
|
198
210
|
const hooks = (copilotAgent.hooks ?? {});
|
|
@@ -428,6 +440,14 @@ async function login() {
|
|
|
428
440
|
}
|
|
429
441
|
catch { }
|
|
430
442
|
}
|
|
443
|
+
// Check if a project is linked — if not, set one up
|
|
444
|
+
if (!config.projectId) {
|
|
445
|
+
console.log("\n No project linked. Setting up project...");
|
|
446
|
+
await setupProject();
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
console.log(` Project: ${config.projectId}`);
|
|
450
|
+
}
|
|
431
451
|
console.log("\n To log in as a different user, delete .askance/credentials and run login again.");
|
|
432
452
|
return;
|
|
433
453
|
}
|