@kanon-pm/setup 0.2.0 → 0.4.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/dist/auth.d.ts +22 -8
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +162 -18
- package/dist/auth.js.map +1 -1
- package/dist/detect.d.ts +15 -1
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +44 -2
- package/dist/detect.js.map +1 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +96 -57
- package/dist/index.js.map +1 -1
- package/dist/mcp-config.d.ts +21 -4
- package/dist/mcp-config.d.ts.map +1 -1
- package/dist/mcp-config.js +77 -6
- package/dist/mcp-config.js.map +1 -1
- package/dist/registry.d.ts +3 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +87 -61
- package/dist/registry.js.map +1 -1
- package/dist/types.d.ts +40 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/auth.d.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
apiUrl: string;
|
|
3
|
-
apiKey: string;
|
|
4
|
-
}
|
|
1
|
+
import type { AuthResult, AuthDeps, PlatformContext } from "./types.js";
|
|
5
2
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Check if a URL points to a localhost address.
|
|
4
|
+
* Matches: localhost, 127.0.0.1, ::1, 0.0.0.0
|
|
5
|
+
*/
|
|
6
|
+
export declare function isLocalhost(url: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Auto-generate an API key by logging in with dev credentials.
|
|
9
|
+
* Only works against localhost URLs — returns null for remote or on any error.
|
|
10
|
+
*/
|
|
11
|
+
export declare function autoGenerateApiKey(apiUrl: string, fetchFn?: typeof globalThis.fetch): Promise<string | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve API URL and key with a 5-step cascade:
|
|
14
|
+
* 1. CLI flags
|
|
15
|
+
* 2. Environment variables
|
|
16
|
+
* 3. Existing MCP config extraction
|
|
17
|
+
* 4. Auto-generation (localhost only)
|
|
18
|
+
* 5. Interactive prompt
|
|
19
|
+
*
|
|
20
|
+
* URL is resolved first (steps 1-5), then key (steps 1-5),
|
|
21
|
+
* because auto-generating a key requires a resolved URL.
|
|
8
22
|
*/
|
|
9
23
|
export declare function resolveAuth(options: {
|
|
10
24
|
apiUrl?: string;
|
|
11
25
|
apiKey?: string;
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
yes?: boolean;
|
|
27
|
+
}, ctx: PlatformContext, deps?: AuthDeps): Promise<AuthResult>;
|
|
14
28
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGxE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAchD;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,UAAU,CAAC,KAAwB,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsCxB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,EAC5D,GAAG,EAAE,eAAe,EACpB,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,UAAU,CAAC,CAgHrB"}
|
package/dist/auth.js
CHANGED
|
@@ -1,33 +1,177 @@
|
|
|
1
1
|
// ─── Auth Resolution ─────────────────────────────────────────────────────────
|
|
2
|
-
import
|
|
2
|
+
import { input, password } from "@inquirer/prompts";
|
|
3
|
+
import { extractExistingAuth } from "./mcp-config.js";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Check if a URL points to a localhost address.
|
|
6
|
+
* Matches: localhost, 127.0.0.1, ::1, 0.0.0.0
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export function isLocalhost(url) {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = new URL(url);
|
|
11
|
+
const host = parsed.hostname;
|
|
12
|
+
return (host === "localhost" ||
|
|
13
|
+
host === "127.0.0.1" ||
|
|
14
|
+
host === "::1" ||
|
|
15
|
+
host === "[::1]" ||
|
|
16
|
+
host === "0.0.0.0");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Auto-generate an API key by logging in with dev credentials.
|
|
24
|
+
* Only works against localhost URLs — returns null for remote or on any error.
|
|
25
|
+
*/
|
|
26
|
+
export async function autoGenerateApiKey(apiUrl, fetchFn = globalThis.fetch) {
|
|
27
|
+
if (!isLocalhost(apiUrl)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
// Step 1: Login with dev credentials
|
|
32
|
+
const loginResp = await fetchFn(`${apiUrl}/api/auth/login`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
email: "dev@kanon.io",
|
|
37
|
+
password: "Password1!",
|
|
38
|
+
workspaceId: "kanon-dev",
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
if (!loginResp.ok)
|
|
42
|
+
return null;
|
|
43
|
+
const loginData = (await loginResp.json());
|
|
44
|
+
const accessToken = loginData.accessToken;
|
|
45
|
+
if (!accessToken)
|
|
46
|
+
return null;
|
|
47
|
+
// Step 2: Generate API key
|
|
48
|
+
const keyResp = await fetchFn(`${apiUrl}/api/auth/api-key`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
51
|
+
});
|
|
52
|
+
if (!keyResp.ok)
|
|
53
|
+
return null;
|
|
54
|
+
const keyData = (await keyResp.json());
|
|
55
|
+
return keyData.apiKey ?? null;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve API URL and key with a 5-step cascade:
|
|
63
|
+
* 1. CLI flags
|
|
64
|
+
* 2. Environment variables
|
|
65
|
+
* 3. Existing MCP config extraction
|
|
66
|
+
* 4. Auto-generation (localhost only)
|
|
67
|
+
* 5. Interactive prompt
|
|
68
|
+
*
|
|
69
|
+
* URL is resolved first (steps 1-5), then key (steps 1-5),
|
|
70
|
+
* because auto-generating a key requires a resolved URL.
|
|
71
|
+
*/
|
|
72
|
+
export async function resolveAuth(options, ctx, deps) {
|
|
73
|
+
const _extractExisting = deps?.extractExisting ?? extractExistingAuth;
|
|
74
|
+
const _autoGenerateKey = deps?.autoGenerateKey ?? autoGenerateApiKey;
|
|
75
|
+
const _promptUrl = deps?.promptUrl ?? defaultPromptUrl;
|
|
76
|
+
const _promptKey = deps?.promptKey ?? defaultPromptKey;
|
|
77
|
+
const _fetchFn = deps?.fetchFn ?? globalThis.fetch;
|
|
78
|
+
let apiUrl;
|
|
79
|
+
let urlSource = "flag";
|
|
80
|
+
// ── Resolve URL ────────────────────────────────────────────────────
|
|
81
|
+
// Step 1: Flag
|
|
82
|
+
if (options.apiUrl) {
|
|
83
|
+
apiUrl = options.apiUrl;
|
|
84
|
+
urlSource = "flag";
|
|
85
|
+
}
|
|
86
|
+
// Step 2: Env
|
|
87
|
+
if (!apiUrl && process.env["KANON_API_URL"]) {
|
|
88
|
+
apiUrl = process.env["KANON_API_URL"];
|
|
89
|
+
urlSource = "env";
|
|
90
|
+
}
|
|
91
|
+
// Step 3: Existing config
|
|
92
|
+
if (!apiUrl) {
|
|
93
|
+
const existing = _extractExisting(ctx);
|
|
94
|
+
if (existing.apiUrl) {
|
|
95
|
+
apiUrl = existing.apiUrl;
|
|
96
|
+
urlSource = "existing-config";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Step 4: Auto-detect localhost
|
|
10
100
|
if (!apiUrl) {
|
|
11
|
-
|
|
101
|
+
try {
|
|
102
|
+
const healthResp = await _fetchFn("http://localhost:3000/health");
|
|
103
|
+
if (healthResp.ok) {
|
|
104
|
+
apiUrl = "http://localhost:3000";
|
|
105
|
+
urlSource = "auto-generated";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// localhost not running — fall through
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Step 5: Interactive prompt
|
|
113
|
+
if (!apiUrl) {
|
|
114
|
+
if (options.yes || !process.stdin.isTTY) {
|
|
115
|
+
throw new Error("API URL could not be resolved automatically. " +
|
|
116
|
+
"Provide via --api-url flag or KANON_API_URL env var.");
|
|
117
|
+
}
|
|
118
|
+
apiUrl = await _promptUrl();
|
|
119
|
+
urlSource = "prompt";
|
|
12
120
|
}
|
|
13
121
|
if (!apiUrl) {
|
|
14
122
|
throw new Error("API URL is required. Provide via --api-url, KANON_API_URL env var, or enter it when prompted.");
|
|
15
123
|
}
|
|
124
|
+
// ── Resolve Key ────────────────────────────────────────────────────
|
|
125
|
+
let apiKey;
|
|
126
|
+
let keySource = "flag";
|
|
127
|
+
// Step 1: Flag
|
|
128
|
+
if (options.apiKey) {
|
|
129
|
+
apiKey = options.apiKey;
|
|
130
|
+
keySource = "flag";
|
|
131
|
+
}
|
|
132
|
+
// Step 2: Env
|
|
133
|
+
if (!apiKey && process.env["KANON_API_KEY"]) {
|
|
134
|
+
apiKey = process.env["KANON_API_KEY"];
|
|
135
|
+
keySource = "env";
|
|
136
|
+
}
|
|
137
|
+
// Step 3: Existing config
|
|
16
138
|
if (!apiKey) {
|
|
17
|
-
|
|
139
|
+
const existing = _extractExisting(ctx);
|
|
140
|
+
if (existing.apiKey) {
|
|
141
|
+
apiKey = existing.apiKey;
|
|
142
|
+
keySource = "existing-config";
|
|
143
|
+
}
|
|
18
144
|
}
|
|
19
|
-
|
|
145
|
+
// Step 4: Auto-generate (localhost only)
|
|
146
|
+
if (!apiKey) {
|
|
147
|
+
const generated = await _autoGenerateKey(apiUrl);
|
|
148
|
+
if (generated) {
|
|
149
|
+
apiKey = generated;
|
|
150
|
+
keySource = "auto-generated";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Step 5: Interactive prompt
|
|
154
|
+
if (!apiKey) {
|
|
155
|
+
if (options.yes || !process.stdin.isTTY) {
|
|
156
|
+
throw new Error("API key could not be resolved automatically. " +
|
|
157
|
+
"Provide via --api-key flag or KANON_API_KEY env var.");
|
|
158
|
+
}
|
|
159
|
+
apiKey = await _promptKey();
|
|
160
|
+
keySource = "prompt";
|
|
161
|
+
}
|
|
162
|
+
return { apiUrl, apiKey: apiKey ?? "", urlSource, keySource };
|
|
20
163
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
164
|
+
// ── Default prompt implementations ──────────────────────────────────────────
|
|
165
|
+
async function defaultPromptUrl() {
|
|
166
|
+
return input({
|
|
167
|
+
message: "Kanon API URL:",
|
|
168
|
+
default: "http://localhost:3000",
|
|
25
169
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
170
|
+
}
|
|
171
|
+
async function defaultPromptKey() {
|
|
172
|
+
return password({
|
|
173
|
+
message: "Kanon API Key:",
|
|
174
|
+
mask: "*",
|
|
31
175
|
});
|
|
32
176
|
}
|
|
33
177
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC7B,OAAO,CACL,IAAI,KAAK,WAAW;YACpB,IAAI,KAAK,WAAW;YACpB,IAAI,KAAK,KAAK;YACd,IAAI,KAAK,OAAO;YAChB,IAAI,KAAK,SAAS,CACnB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,UAAmC,UAAU,CAAC,KAAK;IAEnD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,qCAAqC;QACrC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,MAAM,iBAAiB,EAAE;YAC1D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,KAAK,EAAE,cAAc;gBACrB,QAAQ,EAAE,YAAY;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AAC;IACvB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAChE,CAAC;AAED,+EAA+E;AAE/E,KAAK,UAAU,gBAAgB;IAC7B,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,uBAAuB;KACjC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,gBAAgB;IAC7B,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,GAAG;KACV,CAAC,CAAC;AACL,CAAC"}
|
package/dist/detect.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Platform, PlatformContext } from "./types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Check if running inside WSL by reading /proc/version.
|
|
3
4
|
*/
|
|
@@ -7,8 +8,21 @@ export declare function isWsl(): boolean;
|
|
|
7
8
|
* Uses cmd.exe to get %USERNAME% and constructs /mnt/c/Users/<user>.
|
|
8
9
|
*/
|
|
9
10
|
export declare function resolveWinHome(): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Detect the current platform as a tri-state: win32, wsl, or linux.
|
|
13
|
+
* Accepts an optional override for testing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectPlatform(override?: Platform): Platform;
|
|
16
|
+
/**
|
|
17
|
+
* Build a PlatformContext once at startup. All downstream functions receive
|
|
18
|
+
* this context instead of threading winHome/wslMode booleans.
|
|
19
|
+
*
|
|
20
|
+
* Overrides allow test injection without mocking globals.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildPlatformContext(overrides?: Partial<PlatformContext>): Promise<PlatformContext>;
|
|
10
23
|
/**
|
|
11
24
|
* Check if a command exists on the system.
|
|
25
|
+
* Uses `where` on win32 and `which` on linux/wsl.
|
|
12
26
|
*/
|
|
13
|
-
export declare function commandExists(cmd: string): boolean;
|
|
27
|
+
export declare function commandExists(cmd: string, platform?: Platform): boolean;
|
|
14
28
|
//# sourceMappingURL=detect.d.ts.map
|
package/dist/detect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAO/B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAiBnD;AAED
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI5D;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAO/B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAiBnD;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAM5D;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAQvE"}
|
package/dist/detect.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// ─── Detection Utilities ─────────────────────────────────────────────────────
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
3
4
|
import { execSync } from "node:child_process";
|
|
5
|
+
// ─── Internal Helpers ────────────────────────────────────────────────────────
|
|
4
6
|
/**
|
|
5
7
|
* Check if running inside WSL by reading /proc/version.
|
|
6
8
|
*/
|
|
@@ -35,12 +37,52 @@ export function resolveWinHome() {
|
|
|
35
37
|
return undefined;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
40
|
+
// ─── Platform Detection ──────────────────────────────────────────────────────
|
|
41
|
+
/**
|
|
42
|
+
* Detect the current platform as a tri-state: win32, wsl, or linux.
|
|
43
|
+
* Accepts an optional override for testing.
|
|
44
|
+
*/
|
|
45
|
+
export function detectPlatform(override) {
|
|
46
|
+
if (override)
|
|
47
|
+
return override;
|
|
48
|
+
if (process.platform === "win32")
|
|
49
|
+
return "win32";
|
|
50
|
+
if (isWsl())
|
|
51
|
+
return "wsl";
|
|
52
|
+
return "linux";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build a PlatformContext once at startup. All downstream functions receive
|
|
56
|
+
* this context instead of threading winHome/wslMode booleans.
|
|
57
|
+
*
|
|
58
|
+
* Overrides allow test injection without mocking globals.
|
|
59
|
+
*/
|
|
60
|
+
export async function buildPlatformContext(overrides) {
|
|
61
|
+
const platform = overrides?.platform ?? detectPlatform();
|
|
62
|
+
const homedir = overrides?.homedir ?? os.homedir();
|
|
63
|
+
const ctx = { platform, homedir };
|
|
64
|
+
switch (platform) {
|
|
65
|
+
case "win32":
|
|
66
|
+
ctx.appDataDir = overrides?.appDataDir ?? process.env["APPDATA"];
|
|
67
|
+
break;
|
|
68
|
+
case "wsl":
|
|
69
|
+
ctx.winHome = overrides?.winHome ?? resolveWinHome();
|
|
70
|
+
break;
|
|
71
|
+
case "linux":
|
|
72
|
+
// No extra fields needed
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return ctx;
|
|
76
|
+
}
|
|
77
|
+
// ─── Command Existence ───────────────────────────────────────────────────────
|
|
38
78
|
/**
|
|
39
79
|
* Check if a command exists on the system.
|
|
80
|
+
* Uses `where` on win32 and `which` on linux/wsl.
|
|
40
81
|
*/
|
|
41
|
-
export function commandExists(cmd) {
|
|
82
|
+
export function commandExists(cmd, platform) {
|
|
83
|
+
const whichCmd = platform === "win32" ? "where" : "which";
|
|
42
84
|
try {
|
|
43
|
-
execSync(
|
|
85
|
+
execSync(`${whichCmd} ${cmd}`, { stdio: ["pipe", "pipe", "pipe"] });
|
|
44
86
|
return true;
|
|
45
87
|
}
|
|
46
88
|
catch {
|
package/dist/detect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QACzD,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,8BAA8B,EAAE;YACxD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAE3B,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAEhC,MAAM,OAAO,GAAG,gBAAgB,QAAQ,EAAE,CAAC;QAC3C,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC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CAAC,GAAG,QAAQ,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import type { ToolDefinition, PlatformContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Select which tools to configure based on flags or interactive checkbox.
|
|
5
|
+
*
|
|
6
|
+
* - --tool <name> → single tool (validated against registry)
|
|
7
|
+
* - --all or --yes → all detected tools
|
|
8
|
+
* - interactive (TTY, no flags) → checkbox with all pre-selected
|
|
9
|
+
* - non-interactive (no TTY, no flags) → all detected tools
|
|
10
|
+
*/
|
|
11
|
+
export declare function selectTools(detected: ToolDefinition[], flags: {
|
|
12
|
+
tool?: string;
|
|
13
|
+
all?: boolean;
|
|
14
|
+
yes?: boolean;
|
|
15
|
+
}, isInteractive: boolean, ctx: PlatformContext, deps?: {
|
|
16
|
+
promptTools?: (choices: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
checked: boolean;
|
|
20
|
+
}>) => Promise<string[]>;
|
|
21
|
+
}): Promise<ToolDefinition[]>;
|
|
3
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAc,MAAM,YAAY,CAAC;AA4R9E;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,cAAc,EAAE,EAC1B,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,EACtD,aAAa,EAAE,OAAO,EACtB,GAAG,EAAE,eAAe,EACpB,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GAChH,OAAO,CAAC,cAAc,EAAE,CAAC,CAoD3B"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// ─── Kanon Setup ───────────────────────────────────────────────────────────────
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import {
|
|
5
|
+
import { checkbox } from "@inquirer/prompts";
|
|
6
|
+
import { buildPlatformContext } from "./detect.js";
|
|
6
7
|
import { resolveAuth } from "./auth.js";
|
|
7
8
|
import { detectTools, getToolByName } from "./registry.js";
|
|
8
9
|
import { buildMcpEntry, mergeConfig, removeConfig, resolveMcpServerPath, resolveNodeBin, } from "./mcp-config.js";
|
|
@@ -29,7 +30,8 @@ program
|
|
|
29
30
|
.option("--api-key <key>", "Kanon API key")
|
|
30
31
|
.option("--tool <name>", "Target a specific tool (claude-code, cursor, antigravity)")
|
|
31
32
|
.option("--all", "Configure all detected tools")
|
|
32
|
-
.option("--remove", "Remove Kanon configuration from tools")
|
|
33
|
+
.option("--remove", "Remove Kanon configuration from tools")
|
|
34
|
+
.option("-y, --yes", "Accept all defaults without interactive prompts");
|
|
33
35
|
program.action(async (options) => {
|
|
34
36
|
try {
|
|
35
37
|
await run(options);
|
|
@@ -43,56 +45,35 @@ program.action(async (options) => {
|
|
|
43
45
|
async function run(options) {
|
|
44
46
|
const removeMode = options.remove === true;
|
|
45
47
|
const assetsDir = getAssetsDir();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const isInteractive = !options.yes && !options.tool && !options.all && !!process.stdin.isTTY;
|
|
49
|
+
// ── 1. Platform Detection ──────────────────────────────────────────
|
|
50
|
+
const ctx = await buildPlatformContext();
|
|
51
|
+
const platformLabel = ctx.platform === "wsl" ? "WSL2" : ctx.platform.charAt(0).toUpperCase() + ctx.platform.slice(1);
|
|
52
|
+
console.log(chalk.cyan("[info]") + ` Detected platform: ${chalk.bold(platformLabel)}`);
|
|
53
|
+
if (ctx.platform === "wsl") {
|
|
54
|
+
if (ctx.winHome) {
|
|
52
55
|
console.log(chalk.cyan("[info]") +
|
|
53
|
-
`
|
|
56
|
+
` Windows home: ${chalk.bold(ctx.winHome)}`);
|
|
54
57
|
}
|
|
55
58
|
else {
|
|
56
59
|
console.log(chalk.yellow("[warn]") +
|
|
57
60
|
" WSL detected but could not resolve Windows home directory");
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
|
-
// ──
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
throw new Error(`Unknown tool: '${options.tool}'. Supported: claude-code, cursor, antigravity`);
|
|
66
|
-
}
|
|
67
|
-
selectedTools = [tool];
|
|
68
|
-
}
|
|
69
|
-
else if (options.all) {
|
|
70
|
-
selectedTools = await detectTools(wslMode, winHome);
|
|
71
|
-
if (selectedTools.length === 0) {
|
|
72
|
-
throw new Error("No supported tools detected. Install at least one supported AI coding tool.");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Detect and show what's available
|
|
77
|
-
selectedTools = await detectTools(wslMode, winHome);
|
|
78
|
-
if (selectedTools.length === 0) {
|
|
79
|
-
throw new Error("No supported tools detected. Install at least one supported AI coding tool.");
|
|
80
|
-
}
|
|
81
|
-
console.log("");
|
|
82
|
-
console.log(chalk.bold("Detected AI coding tools:"));
|
|
83
|
-
for (const tool of selectedTools) {
|
|
84
|
-
console.log(` ${chalk.cyan("-")} ${tool.displayName}`);
|
|
85
|
-
}
|
|
86
|
-
console.log("");
|
|
87
|
-
}
|
|
88
|
-
// ── Auth Resolution (skip for --remove) ────────────────────────────
|
|
63
|
+
// ── 2. Detect all tools ────────────────────────────────────────────
|
|
64
|
+
const detectedTools = await detectTools(ctx);
|
|
65
|
+
// ── 3. Select tools (interactive or flag-based) ────────────────────
|
|
66
|
+
const selectedTools = await selectTools(detectedTools, { tool: options.tool, all: options.all, yes: options.yes }, isInteractive, ctx);
|
|
67
|
+
// ── 4. Auth Resolution (skip for --remove) ─────────────────────────
|
|
89
68
|
let apiUrl = "";
|
|
90
69
|
let apiKey = "";
|
|
70
|
+
let auth;
|
|
91
71
|
if (!removeMode) {
|
|
92
|
-
|
|
72
|
+
auth = await resolveAuth({
|
|
93
73
|
apiUrl: options.apiUrl,
|
|
94
74
|
apiKey: options.apiKey,
|
|
95
|
-
|
|
75
|
+
yes: options.yes,
|
|
76
|
+
}, ctx);
|
|
96
77
|
apiUrl = auth.apiUrl;
|
|
97
78
|
apiKey = auth.apiKey;
|
|
98
79
|
}
|
|
@@ -110,11 +91,18 @@ async function run(options) {
|
|
|
110
91
|
console.log("");
|
|
111
92
|
let successCount = 0;
|
|
112
93
|
for (const tool of selectedTools) {
|
|
113
|
-
const
|
|
114
|
-
|
|
94
|
+
const platformPaths = tool.platforms[ctx.platform];
|
|
95
|
+
if (!platformPaths) {
|
|
96
|
+
console.log(chalk.yellow(" ⚠") +
|
|
97
|
+
` ${tool.displayName} is not supported on ${ctx.platform} — skipping`);
|
|
98
|
+
console.log("");
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const configPath = platformPaths.config(ctx);
|
|
102
|
+
const skillDir = platformPaths.skills(ctx);
|
|
103
|
+
const templatePath = platformPaths.template(ctx);
|
|
115
104
|
if (removeMode) {
|
|
116
105
|
// ── Remove Mode ──────────────────────────────────────────────
|
|
117
|
-
const configPath = tool.configPath(pathArg);
|
|
118
106
|
const removed = removeConfig(configPath, tool.rootKey);
|
|
119
107
|
if (removed) {
|
|
120
108
|
console.log(chalk.green(" ✓") +
|
|
@@ -125,22 +113,20 @@ async function run(options) {
|
|
|
125
113
|
` MCP config not found for ${tool.displayName} — nothing to remove`);
|
|
126
114
|
}
|
|
127
115
|
// Remove skills
|
|
128
|
-
const skillDir = tool.skillDest(pathArg);
|
|
129
116
|
const removedSkills = removeSkills(skillDir);
|
|
130
117
|
if (removedSkills.length > 0) {
|
|
131
118
|
console.log(chalk.green(" ✓") +
|
|
132
119
|
` Removed ${removedSkills.length} skills from ${chalk.bold(tool.displayName)}`);
|
|
133
120
|
}
|
|
134
121
|
// Remove template
|
|
135
|
-
const templatePath = tool.templateTarget(pathArg);
|
|
136
122
|
const removedTemplate = removeTemplate(templatePath, tool.templateMode);
|
|
137
123
|
if (removedTemplate) {
|
|
138
124
|
console.log(chalk.green(" ✓") +
|
|
139
125
|
` Removed template from ${chalk.bold(tool.displayName)}`);
|
|
140
126
|
}
|
|
141
127
|
// Remove workflows
|
|
142
|
-
if (
|
|
143
|
-
const wfDir =
|
|
128
|
+
if (platformPaths.workflows) {
|
|
129
|
+
const wfDir = platformPaths.workflows(ctx);
|
|
144
130
|
const removedWfs = removeWorkflows(wfDir);
|
|
145
131
|
if (removedWfs.length > 0) {
|
|
146
132
|
console.log(chalk.green(" ✓") +
|
|
@@ -151,27 +137,24 @@ async function run(options) {
|
|
|
151
137
|
}
|
|
152
138
|
else {
|
|
153
139
|
// ── Install Mode ─────────────────────────────────────────────
|
|
154
|
-
const
|
|
155
|
-
const entry = buildMcpEntry(mcpResolution, apiUrl, apiKey, wslMode, tool.isWindowsNative, nodeBin);
|
|
140
|
+
const entry = buildMcpEntry(mcpResolution, apiUrl, apiKey, ctx, platformPaths.mcpMode, nodeBin);
|
|
156
141
|
// 1. MCP config
|
|
157
142
|
mergeConfig(configPath, tool.rootKey, entry);
|
|
158
143
|
console.log(chalk.green(" ✓") +
|
|
159
144
|
` Configured MCP for ${chalk.bold(tool.displayName)} (${configPath})`);
|
|
160
145
|
// 2. Skills
|
|
161
|
-
const skillDir = tool.skillDest(pathArg);
|
|
162
146
|
const installedSkills = installSkills(skillDir, assetsDir);
|
|
163
147
|
if (installedSkills.length > 0) {
|
|
164
148
|
console.log(chalk.green(" ✓") +
|
|
165
149
|
` Installed ${installedSkills.length} skills to ${chalk.cyan(skillDir)}`);
|
|
166
150
|
}
|
|
167
151
|
// 3. Template
|
|
168
|
-
const templatePath = tool.templateTarget(pathArg);
|
|
169
152
|
installTemplate(templatePath, tool.templateSource, assetsDir, tool.templateMode);
|
|
170
153
|
console.log(chalk.green(" ✓") +
|
|
171
154
|
` Installed template for ${chalk.bold(tool.displayName)} (${templatePath})`);
|
|
172
155
|
// 4. Workflows
|
|
173
|
-
if (
|
|
174
|
-
const wfDir =
|
|
156
|
+
if (platformPaths.workflows) {
|
|
157
|
+
const wfDir = platformPaths.workflows(ctx);
|
|
175
158
|
const installedWfs = installWorkflows(wfDir, assetsDir);
|
|
176
159
|
if (installedWfs.length > 0) {
|
|
177
160
|
console.log(chalk.green(" ✓") +
|
|
@@ -182,19 +165,75 @@ async function run(options) {
|
|
|
182
165
|
}
|
|
183
166
|
console.log("");
|
|
184
167
|
}
|
|
185
|
-
// ── Summary
|
|
168
|
+
// ── 6. Summary ─────────────────────────────────────────────────────
|
|
186
169
|
if (removeMode) {
|
|
187
170
|
console.log(chalk.green(`✓ Removed Kanon configuration from ${successCount} tool(s).`));
|
|
188
171
|
}
|
|
189
172
|
else {
|
|
190
|
-
console.log(chalk.green(`✓
|
|
173
|
+
console.log(chalk.green(`✓ Configured ${successCount} tool(s)!`));
|
|
191
174
|
console.log("");
|
|
192
|
-
|
|
193
|
-
|
|
175
|
+
if (auth) {
|
|
176
|
+
const maskKey = (key) => key.length > 4 ? "****" + key.slice(-4) : "****";
|
|
177
|
+
console.log(` API URL: ${chalk.cyan(apiUrl)} ${chalk.dim(`(from ${auth.urlSource})`)}`);
|
|
178
|
+
console.log(` API Key: ${chalk.cyan(maskKey(apiKey))} ${chalk.dim(`(${auth.keySource})`)}`);
|
|
179
|
+
}
|
|
194
180
|
console.log("");
|
|
195
181
|
console.log(chalk.yellow(" Restart your AI coding tool(s) to pick up the new configuration."));
|
|
196
182
|
}
|
|
197
183
|
console.log("");
|
|
198
184
|
}
|
|
185
|
+
// ─── Tool Selection ──────────────────────────────────────────────────────────
|
|
186
|
+
/**
|
|
187
|
+
* Select which tools to configure based on flags or interactive checkbox.
|
|
188
|
+
*
|
|
189
|
+
* - --tool <name> → single tool (validated against registry)
|
|
190
|
+
* - --all or --yes → all detected tools
|
|
191
|
+
* - interactive (TTY, no flags) → checkbox with all pre-selected
|
|
192
|
+
* - non-interactive (no TTY, no flags) → all detected tools
|
|
193
|
+
*/
|
|
194
|
+
export async function selectTools(detected, flags, isInteractive, ctx, deps) {
|
|
195
|
+
// --tool flag: single tool by name
|
|
196
|
+
if (flags.tool) {
|
|
197
|
+
const tool = getToolByName(flags.tool);
|
|
198
|
+
if (!tool) {
|
|
199
|
+
throw new Error(`Unknown tool: '${flags.tool}'. Supported: claude-code, cursor, antigravity`);
|
|
200
|
+
}
|
|
201
|
+
if (!tool.platforms[ctx.platform]) {
|
|
202
|
+
throw new Error(`${tool.displayName} is not supported on ${ctx.platform}`);
|
|
203
|
+
}
|
|
204
|
+
return [tool];
|
|
205
|
+
}
|
|
206
|
+
// No tools detected → error
|
|
207
|
+
if (detected.length === 0) {
|
|
208
|
+
throw new Error("No supported tools detected. Install at least one supported AI coding tool.");
|
|
209
|
+
}
|
|
210
|
+
// --all or --yes → all detected
|
|
211
|
+
if (flags.all || flags.yes) {
|
|
212
|
+
return detected;
|
|
213
|
+
}
|
|
214
|
+
// Non-interactive (no TTY) → all detected
|
|
215
|
+
if (!isInteractive) {
|
|
216
|
+
return detected;
|
|
217
|
+
}
|
|
218
|
+
// Interactive → checkbox with all pre-selected
|
|
219
|
+
const _promptTools = deps?.promptTools ?? defaultPromptTools;
|
|
220
|
+
console.log("");
|
|
221
|
+
const selectedNames = await _promptTools(detected.map((t) => ({
|
|
222
|
+
name: t.displayName,
|
|
223
|
+
value: t.name,
|
|
224
|
+
checked: true,
|
|
225
|
+
})));
|
|
226
|
+
if (selectedNames.length === 0) {
|
|
227
|
+
console.log(chalk.yellow("No tools selected — nothing to do."));
|
|
228
|
+
process.exit(0);
|
|
229
|
+
}
|
|
230
|
+
return detected.filter((t) => selectedNames.includes(t.name));
|
|
231
|
+
}
|
|
232
|
+
async function defaultPromptTools(choices) {
|
|
233
|
+
return checkbox({
|
|
234
|
+
message: "Select tools to configure:",
|
|
235
|
+
choices,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
199
238
|
program.parse();
|
|
200
239
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,kFAAkF;AAElF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,kFAAkF;AAElF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,a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J,CAAC;IAEF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,OAAiE;IAEjE,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,4BAA4B;QACrC,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/mcp-config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { McpServerEntry } from "./types.js";
|
|
1
|
+
import type { McpServerEntry, McpMode, PlatformContext } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Merge a Kanon MCP server entry into a tool's JSON config file.
|
|
4
4
|
* Creates the file and parent directories if they don't exist.
|
|
@@ -18,10 +18,12 @@ export type McpResolution = {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Build the MCP server entry for Kanon.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
*
|
|
22
|
+
* Uses PlatformContext + McpMode to determine the entry format:
|
|
23
|
+
* - 'direct': linux, wsl-native tools, or win32 — uses node/npx directly
|
|
24
|
+
* - 'wsl-bridge': Windows-side tools invoked from WSL — uses `wsl` wrapper
|
|
23
25
|
*/
|
|
24
|
-
export declare function buildMcpEntry(resolution: McpResolution, apiUrl: string, apiKey: string,
|
|
26
|
+
export declare function buildMcpEntry(resolution: McpResolution, apiUrl: string, apiKey: string, ctx: PlatformContext, mcpMode: McpMode, nodeBin: string): McpServerEntry;
|
|
25
27
|
/**
|
|
26
28
|
* Resolve how to invoke the Kanon MCP server.
|
|
27
29
|
* When running from the monorepo or with @kanon/mcp installed locally,
|
|
@@ -32,4 +34,19 @@ export declare function resolveMcpServerPath(): McpResolution;
|
|
|
32
34
|
* Resolve the path to the node binary.
|
|
33
35
|
*/
|
|
34
36
|
export declare function resolveNodeBin(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Extract auth credentials from existing kanon-mcp entries across all tool configs.
|
|
39
|
+
*
|
|
40
|
+
* Scans each tool in the registry that supports the current platform, reads its
|
|
41
|
+
* MCP config file, and looks for a "kanon-mcp" entry. Extracts KANON_API_URL and
|
|
42
|
+
* KANON_API_KEY from:
|
|
43
|
+
* - Direct mode: `entry.env.KANON_API_URL` / `entry.env.KANON_API_KEY`
|
|
44
|
+
* - WSL bridge mode: parses `entry.args` array for `KANON_API_URL=xxx` patterns
|
|
45
|
+
*
|
|
46
|
+
* Returns the first values found. Missing files/entries are handled gracefully.
|
|
47
|
+
*/
|
|
48
|
+
export declare function extractExistingAuth(ctx: PlatformContext): {
|
|
49
|
+
apiUrl?: string;
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
};
|
|
35
52
|
//# sourceMappingURL=mcp-config.d.ts.map
|
package/dist/mcp-config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,eAAe,EAChB,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,cAAc,GACpB,IAAI,CAqBN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAsBzE;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,cAAc,CAwChB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,aAAa,CAwBpD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,eAAe,GACnB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CA2DtC"}
|
package/dist/mcp-config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// ─── MCP Config Merger ───────────────────────────────────────────────────────
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { toolRegistry } from "./registry.js";
|
|
4
6
|
/**
|
|
5
7
|
* Merge a Kanon MCP server entry into a tool's JSON config file.
|
|
6
8
|
* Creates the file and parent directories if they don't exist.
|
|
@@ -52,13 +54,15 @@ export function removeConfig(configPath, rootKey) {
|
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Build the MCP server entry for Kanon.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* Uses PlatformContext + McpMode to determine the entry format:
|
|
59
|
+
* - 'direct': linux, wsl-native tools, or win32 — uses node/npx directly
|
|
60
|
+
* - 'wsl-bridge': Windows-side tools invoked from WSL — uses `wsl` wrapper
|
|
57
61
|
*/
|
|
58
|
-
export function buildMcpEntry(resolution, apiUrl, apiKey,
|
|
62
|
+
export function buildMcpEntry(resolution, apiUrl, apiKey, ctx, mcpMode, nodeBin) {
|
|
59
63
|
const isNpx = resolution.mode === "npx";
|
|
60
|
-
if (
|
|
61
|
-
// Windows-
|
|
64
|
+
if (mcpMode === "wsl-bridge") {
|
|
65
|
+
// Windows-side tools invoked via WSL wrapper
|
|
62
66
|
const envArgs = [`KANON_API_URL=${apiUrl}`];
|
|
63
67
|
if (apiKey) {
|
|
64
68
|
envArgs.push(`KANON_API_KEY=${apiKey}`);
|
|
@@ -74,6 +78,7 @@ export function buildMcpEntry(resolution, apiUrl, apiKey, wslMode, isWindowsNati
|
|
|
74
78
|
args: ["env", ...envArgs, nodeBin, resolution.path],
|
|
75
79
|
};
|
|
76
80
|
}
|
|
81
|
+
// Direct mode (linux, wsl-native tools, or win32)
|
|
77
82
|
const env = { KANON_API_URL: apiUrl };
|
|
78
83
|
if (apiKey) {
|
|
79
84
|
env["KANON_API_KEY"] = apiKey;
|
|
@@ -98,7 +103,8 @@ export function buildMcpEntry(resolution, apiUrl, apiKey, wslMode, isWindowsNati
|
|
|
98
103
|
*/
|
|
99
104
|
export function resolveMcpServerPath() {
|
|
100
105
|
// Try to find the local monorepo MCP dist
|
|
101
|
-
|
|
106
|
+
// Use fileURLToPath() instead of .pathname to handle Windows drive letters correctly
|
|
107
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
102
108
|
const localMcp = path.resolve(scriptDir, "../../mcp/dist/index.js");
|
|
103
109
|
if (fs.existsSync(localMcp)) {
|
|
104
110
|
return { mode: "local", path: localMcp };
|
|
@@ -122,4 +128,69 @@ export function resolveMcpServerPath() {
|
|
|
122
128
|
export function resolveNodeBin() {
|
|
123
129
|
return process.execPath;
|
|
124
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Extract auth credentials from existing kanon-mcp entries across all tool configs.
|
|
133
|
+
*
|
|
134
|
+
* Scans each tool in the registry that supports the current platform, reads its
|
|
135
|
+
* MCP config file, and looks for a "kanon-mcp" entry. Extracts KANON_API_URL and
|
|
136
|
+
* KANON_API_KEY from:
|
|
137
|
+
* - Direct mode: `entry.env.KANON_API_URL` / `entry.env.KANON_API_KEY`
|
|
138
|
+
* - WSL bridge mode: parses `entry.args` array for `KANON_API_URL=xxx` patterns
|
|
139
|
+
*
|
|
140
|
+
* Returns the first values found. Missing files/entries are handled gracefully.
|
|
141
|
+
*/
|
|
142
|
+
export function extractExistingAuth(ctx) {
|
|
143
|
+
let apiUrl;
|
|
144
|
+
let apiKey;
|
|
145
|
+
for (const tool of toolRegistry) {
|
|
146
|
+
const platformPaths = tool.platforms[ctx.platform];
|
|
147
|
+
if (!platformPaths)
|
|
148
|
+
continue;
|
|
149
|
+
const configPath = platformPaths.config(ctx);
|
|
150
|
+
let config;
|
|
151
|
+
try {
|
|
152
|
+
const content = fs.readFileSync(configPath, "utf8");
|
|
153
|
+
config = JSON.parse(content);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// File doesn't exist or is invalid JSON — skip
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const servers = config[tool.rootKey];
|
|
160
|
+
if (!servers)
|
|
161
|
+
continue;
|
|
162
|
+
const entry = servers["kanon-mcp"];
|
|
163
|
+
if (!entry)
|
|
164
|
+
continue;
|
|
165
|
+
// Try direct mode: env object
|
|
166
|
+
if (entry.env) {
|
|
167
|
+
if (!apiUrl && entry.env["KANON_API_URL"]) {
|
|
168
|
+
apiUrl = entry.env["KANON_API_URL"];
|
|
169
|
+
}
|
|
170
|
+
if (!apiKey && entry.env["KANON_API_KEY"]) {
|
|
171
|
+
apiKey = entry.env["KANON_API_KEY"];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Try WSL bridge mode: parse args array for KEY=VALUE patterns
|
|
175
|
+
if (entry.args) {
|
|
176
|
+
for (const arg of entry.args) {
|
|
177
|
+
if (!apiUrl && arg.startsWith("KANON_API_URL=")) {
|
|
178
|
+
apiUrl = arg.slice("KANON_API_URL=".length);
|
|
179
|
+
}
|
|
180
|
+
if (!apiKey && arg.startsWith("KANON_API_KEY=")) {
|
|
181
|
+
apiKey = arg.slice("KANON_API_KEY=".length);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Stop early if we have both values
|
|
186
|
+
if (apiUrl && apiKey)
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
const result = {};
|
|
190
|
+
if (apiUrl)
|
|
191
|
+
result.apiUrl = apiUrl;
|
|
192
|
+
if (apiKey)
|
|
193
|
+
result.apiKey = apiKey;
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
125
196
|
//# sourceMappingURL=mcp-config.js.map
|
package/dist/mcp-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,UAAkB,EAClB,OAAe,EACf,KAAqB;IAErB,IAAI,MAAM,GAA4B,EAAE,CAAC;IAEzC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,GAAG,I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K,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC9C,CAAC;gBACD,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;oBAChD,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;QAED,oCAAoC;QACpC,IAAI,MAAM,IAAI,MAAM;YAAE,MAAM;IAC9B,CAAC;IAED,MAAM,MAAM,GAAyC,EAAE,CAAC;IACxD,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACnC,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACnC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ToolDefinition } from "./types.js";
|
|
1
|
+
import type { ToolDefinition, PlatformContext } from "./types.js";
|
|
2
2
|
export declare const toolRegistry: ToolDefinition[];
|
|
3
3
|
/**
|
|
4
4
|
* Detect which tools are available on the system.
|
|
5
|
-
*
|
|
5
|
+
* Uses the per-platform paths map to check support and run detection.
|
|
6
6
|
*/
|
|
7
|
-
export declare function detectTools(
|
|
7
|
+
export declare function detectTools(ctx: PlatformContext): Promise<ToolDefinition[]>;
|
|
8
8
|
/**
|
|
9
9
|
* Find a tool by name from the registry.
|
|
10
10
|
*/
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,eAAO,MAAM,YAAY,EAAE,cAAc,EA2HxC,CAAC;AAEF;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC,CAiB3B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEtE"}
|
package/dist/registry.js
CHANGED
|
@@ -1,99 +1,125 @@
|
|
|
1
1
|
// ─── Tool Registry ───────────────────────────────────────────────────────────
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import { commandExists } from "./detect.js";
|
|
5
|
-
const home = os.homedir();
|
|
6
4
|
export const toolRegistry = [
|
|
7
5
|
// ── Claude Code ──────────────────────────────────────────────────────
|
|
8
6
|
{
|
|
9
7
|
name: "claude-code",
|
|
10
8
|
displayName: "Claude Code",
|
|
11
|
-
configPath: () => `${home}/.claude.json`,
|
|
12
9
|
rootKey: "mcpServers",
|
|
13
|
-
detect: async () => {
|
|
14
|
-
return fs.existsSync(`${home}/.claude`) || commandExists("claude");
|
|
15
|
-
},
|
|
16
|
-
skillDest: () => `${home}/.claude/skills`,
|
|
17
|
-
workflowDest: () => `${home}/.claude/workflows`,
|
|
18
10
|
templateSource: "claude-code-snippet.md",
|
|
19
|
-
templateTarget: () => `${home}/.claude/CLAUDE.md`,
|
|
20
11
|
templateMode: "marker-inject",
|
|
21
|
-
|
|
12
|
+
platforms: {
|
|
13
|
+
// Claude Code is NOT supported on win32 — no entry
|
|
14
|
+
wsl: {
|
|
15
|
+
detect: async (ctx) => fs.existsSync(`${ctx.homedir}/.claude`) ||
|
|
16
|
+
commandExists("claude", ctx.platform),
|
|
17
|
+
config: (ctx) => `${ctx.homedir}/.claude.json`,
|
|
18
|
+
skills: (ctx) => `${ctx.homedir}/.claude/skills`,
|
|
19
|
+
workflows: (ctx) => `${ctx.homedir}/.claude/workflows`,
|
|
20
|
+
template: (ctx) => `${ctx.homedir}/.claude/CLAUDE.md`,
|
|
21
|
+
mcpMode: "direct",
|
|
22
|
+
},
|
|
23
|
+
linux: {
|
|
24
|
+
detect: async (ctx) => fs.existsSync(`${ctx.homedir}/.claude`) ||
|
|
25
|
+
commandExists("claude", ctx.platform),
|
|
26
|
+
config: (ctx) => `${ctx.homedir}/.claude.json`,
|
|
27
|
+
skills: (ctx) => `${ctx.homedir}/.claude/skills`,
|
|
28
|
+
workflows: (ctx) => `${ctx.homedir}/.claude/workflows`,
|
|
29
|
+
template: (ctx) => `${ctx.homedir}/.claude/CLAUDE.md`,
|
|
30
|
+
mcpMode: "direct",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
22
33
|
},
|
|
23
34
|
// ── Cursor ───────────────────────────────────────────────────────────
|
|
24
35
|
{
|
|
25
36
|
name: "cursor",
|
|
26
37
|
displayName: "Cursor",
|
|
27
|
-
configPath: (winHome) => {
|
|
28
|
-
const base = winHome || home;
|
|
29
|
-
return `${base}/.cursor/mcp.json`;
|
|
30
|
-
},
|
|
31
38
|
rootKey: "mcpServers",
|
|
32
|
-
detect: async () => {
|
|
33
|
-
return fs.existsSync(`${home}/.cursor`);
|
|
34
|
-
},
|
|
35
|
-
wslDetect: async (winHome) => {
|
|
36
|
-
return fs.existsSync(`${winHome}/.cursor`);
|
|
37
|
-
},
|
|
38
|
-
skillDest: (winHome) => {
|
|
39
|
-
const base = winHome || home;
|
|
40
|
-
return `${base}/.cursor/skills`;
|
|
41
|
-
},
|
|
42
|
-
// Cursor has no global workflows
|
|
43
39
|
templateSource: "cursor-rules.mdc",
|
|
44
|
-
templateTarget: (winHome) => {
|
|
45
|
-
const base = winHome || home;
|
|
46
|
-
return `${base}/.cursor/rules/kanon.mdc`;
|
|
47
|
-
},
|
|
48
40
|
templateMode: "file-copy",
|
|
49
|
-
|
|
41
|
+
platforms: {
|
|
42
|
+
win32: {
|
|
43
|
+
detect: async (ctx) => {
|
|
44
|
+
const appData = ctx.appDataDir;
|
|
45
|
+
return !!appData && fs.existsSync(`${appData}\\Cursor\\User`);
|
|
46
|
+
},
|
|
47
|
+
config: (ctx) => {
|
|
48
|
+
const appData = ctx.appDataDir;
|
|
49
|
+
return `${appData}\\Cursor\\User\\mcp.json`;
|
|
50
|
+
},
|
|
51
|
+
skills: (ctx) => `${ctx.homedir}\\.cursor\\skills`,
|
|
52
|
+
template: (ctx) => `${ctx.homedir}\\.cursor\\rules\\kanon.mdc`,
|
|
53
|
+
mcpMode: "direct",
|
|
54
|
+
},
|
|
55
|
+
wsl: {
|
|
56
|
+
detect: async (ctx) => {
|
|
57
|
+
return !!ctx.winHome && fs.existsSync(`${ctx.winHome}/.cursor`);
|
|
58
|
+
},
|
|
59
|
+
config: (ctx) => `${ctx.winHome}/.cursor/mcp.json`,
|
|
60
|
+
skills: (ctx) => `${ctx.winHome}/.cursor/skills`,
|
|
61
|
+
template: (ctx) => `${ctx.winHome}/.cursor/rules/kanon.mdc`,
|
|
62
|
+
mcpMode: "wsl-bridge",
|
|
63
|
+
},
|
|
64
|
+
linux: {
|
|
65
|
+
detect: async (ctx) => fs.existsSync(`${ctx.homedir}/.cursor`),
|
|
66
|
+
config: (ctx) => `${ctx.homedir}/.cursor/mcp.json`,
|
|
67
|
+
skills: (ctx) => `${ctx.homedir}/.cursor/skills`,
|
|
68
|
+
template: (ctx) => `${ctx.homedir}/.cursor/rules/kanon.mdc`,
|
|
69
|
+
mcpMode: "direct",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
50
72
|
},
|
|
51
73
|
// ── Antigravity (Gemini) ─────────────────────────────────────────────
|
|
52
74
|
{
|
|
53
75
|
name: "antigravity",
|
|
54
76
|
displayName: "Antigravity",
|
|
55
|
-
configPath: (winHome) => {
|
|
56
|
-
const base = winHome || home;
|
|
57
|
-
return `${base}/.gemini/antigravity/mcp_config.json`;
|
|
58
|
-
},
|
|
59
77
|
rootKey: "mcpServers",
|
|
60
|
-
detect: async () => {
|
|
61
|
-
return fs.existsSync(`${home}/.gemini`);
|
|
62
|
-
},
|
|
63
|
-
wslDetect: async (winHome) => {
|
|
64
|
-
return fs.existsSync(`${winHome}/.gemini`);
|
|
65
|
-
},
|
|
66
|
-
skillDest: (winHome) => {
|
|
67
|
-
const base = winHome || home;
|
|
68
|
-
return `${base}/.gemini/antigravity/skills`;
|
|
69
|
-
},
|
|
70
|
-
workflowDest: (winHome) => {
|
|
71
|
-
const base = winHome || home;
|
|
72
|
-
return `${base}/.gemini/antigravity/global_workflows`;
|
|
73
|
-
},
|
|
74
78
|
templateSource: "gemini-instructions.md",
|
|
75
|
-
templateTarget: (winHome) => {
|
|
76
|
-
const base = winHome || home;
|
|
77
|
-
return `${base}/.gemini/GEMINI.md`;
|
|
78
|
-
},
|
|
79
79
|
templateMode: "marker-inject",
|
|
80
|
-
|
|
80
|
+
platforms: {
|
|
81
|
+
win32: {
|
|
82
|
+
detect: async (ctx) => fs.existsSync(`${ctx.homedir}\\.gemini`),
|
|
83
|
+
config: (ctx) => `${ctx.homedir}\\.gemini\\antigravity\\mcp_config.json`,
|
|
84
|
+
skills: (ctx) => `${ctx.homedir}\\.gemini\\antigravity\\skills`,
|
|
85
|
+
workflows: (ctx) => `${ctx.homedir}\\.gemini\\antigravity\\global_workflows`,
|
|
86
|
+
template: (ctx) => `${ctx.homedir}\\.gemini\\GEMINI.md`,
|
|
87
|
+
mcpMode: "direct",
|
|
88
|
+
},
|
|
89
|
+
wsl: {
|
|
90
|
+
detect: async (ctx) => {
|
|
91
|
+
return !!ctx.winHome && fs.existsSync(`${ctx.winHome}/.gemini`);
|
|
92
|
+
},
|
|
93
|
+
config: (ctx) => `${ctx.winHome}/.gemini/antigravity/mcp_config.json`,
|
|
94
|
+
skills: (ctx) => `${ctx.winHome}/.gemini/antigravity/skills`,
|
|
95
|
+
workflows: (ctx) => `${ctx.winHome}/.gemini/antigravity/global_workflows`,
|
|
96
|
+
template: (ctx) => `${ctx.winHome}/.gemini/GEMINI.md`,
|
|
97
|
+
mcpMode: "wsl-bridge",
|
|
98
|
+
},
|
|
99
|
+
linux: {
|
|
100
|
+
detect: async (ctx) => fs.existsSync(`${ctx.homedir}/.gemini`),
|
|
101
|
+
config: (ctx) => `${ctx.homedir}/.gemini/antigravity/mcp_config.json`,
|
|
102
|
+
skills: (ctx) => `${ctx.homedir}/.gemini/antigravity/skills`,
|
|
103
|
+
workflows: (ctx) => `${ctx.homedir}/.gemini/antigravity/global_workflows`,
|
|
104
|
+
template: (ctx) => `${ctx.homedir}/.gemini/GEMINI.md`,
|
|
105
|
+
mcpMode: "direct",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
81
108
|
},
|
|
82
109
|
];
|
|
83
110
|
/**
|
|
84
111
|
* Detect which tools are available on the system.
|
|
85
|
-
*
|
|
112
|
+
* Uses the per-platform paths map to check support and run detection.
|
|
86
113
|
*/
|
|
87
|
-
export async function detectTools(
|
|
114
|
+
export async function detectTools(ctx) {
|
|
88
115
|
const detected = [];
|
|
89
116
|
for (const tool of toolRegistry) {
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
else if (!tool.isWindowsNative || !wslMode) {
|
|
95
|
-
found = await tool.detect();
|
|
117
|
+
const platformPaths = tool.platforms[ctx.platform];
|
|
118
|
+
if (!platformPaths) {
|
|
119
|
+
// Tool doesn't support this platform — skip silently
|
|
120
|
+
continue;
|
|
96
121
|
}
|
|
122
|
+
const found = await platformPaths.detect(ctx);
|
|
97
123
|
if (found) {
|
|
98
124
|
detected.push(tool);
|
|
99
125
|
}
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE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I,CAAC,aAAa,EAAE,CAAC;YACnB,qDAAqD;YACrD,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,28 +1,53 @@
|
|
|
1
|
+
export type Platform = "win32" | "wsl" | "linux";
|
|
2
|
+
export interface PlatformContext {
|
|
3
|
+
platform: Platform;
|
|
4
|
+
homedir: string;
|
|
5
|
+
winHome?: string;
|
|
6
|
+
appDataDir?: string;
|
|
7
|
+
}
|
|
8
|
+
export type McpMode = "direct" | "wsl-bridge";
|
|
9
|
+
export interface PlatformPaths {
|
|
10
|
+
detect: (ctx: PlatformContext) => Promise<boolean>;
|
|
11
|
+
config: (ctx: PlatformContext) => string;
|
|
12
|
+
skills: (ctx: PlatformContext) => string;
|
|
13
|
+
workflows?: (ctx: PlatformContext) => string;
|
|
14
|
+
template: (ctx: PlatformContext) => string;
|
|
15
|
+
mcpMode: McpMode;
|
|
16
|
+
}
|
|
1
17
|
export interface ToolDefinition {
|
|
2
18
|
name: string;
|
|
3
19
|
displayName: string;
|
|
4
|
-
configPath: (winHome?: string) => string;
|
|
5
20
|
rootKey: string;
|
|
6
|
-
detect: () => Promise<boolean>;
|
|
7
|
-
wslDetect?: (winHome: string) => Promise<boolean>;
|
|
8
|
-
skillDest: (winHome?: string) => string;
|
|
9
|
-
workflowDest?: (winHome?: string) => string;
|
|
10
21
|
templateSource: string;
|
|
11
|
-
templateTarget: (winHome?: string) => string;
|
|
12
22
|
templateMode: "marker-inject" | "file-copy";
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
export interface SetupOptions {
|
|
16
|
-
apiUrl: string;
|
|
17
|
-
apiKey: string;
|
|
18
|
-
tools: ToolDefinition[];
|
|
19
|
-
remove: boolean;
|
|
20
|
-
wslMode: boolean;
|
|
21
|
-
winHome?: string;
|
|
23
|
+
platforms: Partial<Record<Platform, PlatformPaths>>;
|
|
22
24
|
}
|
|
23
25
|
export interface McpServerEntry {
|
|
24
26
|
command: string;
|
|
25
27
|
args: string[];
|
|
26
28
|
env?: Record<string, string>;
|
|
27
29
|
}
|
|
30
|
+
/** Source that resolved an auth field, for logging */
|
|
31
|
+
export type AuthSource = "flag" | "env" | "existing-config" | "auto-generated" | "prompt";
|
|
32
|
+
export interface AuthResult {
|
|
33
|
+
apiUrl: string;
|
|
34
|
+
apiKey: string;
|
|
35
|
+
urlSource: AuthSource;
|
|
36
|
+
keySource: AuthSource;
|
|
37
|
+
}
|
|
38
|
+
/** Injectable dependencies for resolveAuth — enables testing without mocks */
|
|
39
|
+
export interface AuthDeps {
|
|
40
|
+
extractExisting?: (ctx: PlatformContext) => {
|
|
41
|
+
apiUrl?: string;
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
};
|
|
44
|
+
autoGenerateKey?: (apiUrl: string) => Promise<string | null>;
|
|
45
|
+
promptUrl?: () => Promise<string>;
|
|
46
|
+
promptKey?: () => Promise<string>;
|
|
47
|
+
fetchFn?: typeof globalThis.fetch;
|
|
48
|
+
}
|
|
49
|
+
export interface InteractiveOptions {
|
|
50
|
+
yes: boolean;
|
|
51
|
+
interactive: boolean;
|
|
52
|
+
}
|
|
28
53
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"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GACL,iBAAiB,GACjB,gBAAgB,GAChB,QAAQ,CAAC;AAEb,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB;AAED,8EAA8E;AAC9E,MAAM,WAAW,QAAQ;IACvB,eAAe,CAAC,EAAE,CAChB,GAAG,EAAE,eAAe,KACjB;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACnC;AAID,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanon-pm/setup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Setup and configure Kanon AI tool integrations (Claude Code, Cursor, Antigravity)",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"assets/"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@inquirer/prompts": "^8.3.2",
|
|
21
22
|
"chalk": "^5.3.0",
|
|
22
23
|
"commander": "^12.0.0"
|
|
23
24
|
},
|