cursor-keys 1.2.4 → 1.3.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/README.md +34 -8
- package/package.json +2 -4
- package/src/commands.mjs +66 -13
- package/src/config.mjs +5 -6
- package/src/detect.mjs +2 -2
- package/src/profile.mjs +45 -7
- package/scripts/postinstall.mjs +0 -58
package/README.md
CHANGED
|
@@ -48,7 +48,29 @@ npm install -g cursor-keys
|
|
|
48
48
|
|
|
49
49
|
Requires Node ≥18, the Cursor CLI (`Shell Command: Install 'cursor' in PATH`), and sqlite3 (preinstalled on macOS). Key injection is macOS-only; everything else is cross-platform shaped.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
The package runs **no install scripts** (`ignore-scripts=true` safe). Link the companion extension once yourself:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cursor-keys install-extension # or install "cursor-keys" from the Open VSX marketplace in Cursor
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Restart Cursor, then `Cmd+Shift+P` → "cursor-keys: Open Project...".
|
|
58
|
+
|
|
59
|
+
## No terminal? Let Cursor's agent set it up
|
|
60
|
+
|
|
61
|
+
Open your project in Cursor, paste this into the agent chat (`Cmd+L`), and it runs the whole setup for you. Your API key goes into a hidden terminal prompt, never into the chat:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
Set up cursor-keys (github.com/L-ubu/cursor-keys) for this project, step by step:
|
|
65
|
+
1. Run `npm install -g cursor-keys`.
|
|
66
|
+
2. Run `cursor-keys config baseUrl <your-gateway-url>` (replace with my gateway URL, e.g. https://gateway.example.com/v1).
|
|
67
|
+
3. Register this workspace: `cursor-keys add <folder-name> --path <this workspace's path>`.
|
|
68
|
+
4. Run `cursor-keys clone <folder-name>` to inherit my Cursor sign-in and settings.
|
|
69
|
+
5. Run `cursor-keys set-key <folder-name>` and ask me to paste the project API key at the hidden terminal prompt. Never write the key into files, chat, or logs.
|
|
70
|
+
6. Run `cursor-keys doctor <folder-name>` and fix what it flags.
|
|
71
|
+
7. Run `cursor-keys aliases --install` and `cursor-keys wrap --install` for the shell extras.
|
|
72
|
+
8. Open the project in its profile with `cursor-keys open <folder-name>`, then explain how I can tell it worked.
|
|
73
|
+
```
|
|
52
74
|
|
|
53
75
|
## Quick start
|
|
54
76
|
|
|
@@ -72,7 +94,7 @@ One-time extras for the full experience:
|
|
|
72
94
|
```bash
|
|
73
95
|
cursor-keys wrap --install # plain `cursor <path>` auto-picks the profile
|
|
74
96
|
cursor-keys aliases --install # per-project aliases, `ck` shortcut, zsh tab completion
|
|
75
|
-
cursor-keys install-extension # status bar + wrong-window guard
|
|
97
|
+
cursor-keys install-extension # status bar + wrong-window guard
|
|
76
98
|
```
|
|
77
99
|
|
|
78
100
|
## How it works
|
|
@@ -81,7 +103,7 @@ One window, one profile, one key. Each project gets an isolated `--user-data-dir
|
|
|
81
103
|
|
|
82
104
|
Settings flow one way, main to profiles: `sync` re-copies your main `settings.json` into every profile and re-applies that profile's title bar color on top. `open` does this automatically before every launch, and open windows hot-reload the file, so tweaks in your main Cursor show up everywhere. Changes made inside a profile window are overwritten on the next sync.
|
|
83
105
|
|
|
84
|
-
`clone` copies your main Cursor state (SQLite backup) so profiles open signed-in with your theme and model config. `set-key` encrypts your project key with Cursor's own safeStorage (Chromium OSCrypt, key from the "Cursor Safe Storage" macOS Keychain item) and writes it into the profile's secret store, round-trip verified. macOS asks for Keychain permission
|
|
106
|
+
`clone` copies your main Cursor state (SQLite backup) so profiles open signed-in with your theme and model config, then scrubs donor secrets (`secret://` rows, MCP OAuth tokens, extension secrets) out of the copy. The sign-in session itself is the one thing that does carry over, see [Security](#security). `set-key` encrypts your project key with Cursor's own safeStorage (Chromium OSCrypt, key from the "Cursor Safe Storage" macOS Keychain item) and writes it into the profile's secret store, round-trip verified. When macOS asks for Keychain permission, click **Allow**: one run, one prompt. Always Allow also works, but it permanently grants the calling binary access to that Keychain item, which is the same pattern infostealers abuse against browser safe storage.
|
|
85
107
|
|
|
86
108
|
## "Which key am I on?" in three layers
|
|
87
109
|
|
|
@@ -96,7 +118,7 @@ Settings flow one way, main to profiles: `sync` re-copies your main `settings.js
|
|
|
96
118
|
| `init [--root DIR] [--all]` | Discover git repos and register them |
|
|
97
119
|
| `add <name> [--path] [--color] [--clone main]` | Create a project profile |
|
|
98
120
|
| `clone <name> [--from main]` | Copy sign-in + settings + model config from a donor profile |
|
|
99
|
-
| `set-key <name
|
|
121
|
+
| `set-key <name>` | Inject the project API key (hidden prompt or stdin, encrypted) |
|
|
100
122
|
| `color <name> [#hex]` | Show or set the project title bar color |
|
|
101
123
|
| `open [name]` | Launch Cursor with the profile (auto-detect from cwd) |
|
|
102
124
|
| `status` | Projects, colors, running windows, key configured |
|
|
@@ -107,7 +129,7 @@ Settings flow one way, main to profiles: `sync` re-copies your main `settings.js
|
|
|
107
129
|
| `wrap [--install]` | zsh function so plain `cursor <path>` auto-picks the profile |
|
|
108
130
|
| `aliases [--install]` | Per-project shell aliases (also `ck` shortcut + tab completion) |
|
|
109
131
|
| `completion` | Print zsh tab completion (auto-sourced by `aliases --install`) |
|
|
110
|
-
| `install-extension` | Link the Cursor extension (
|
|
132
|
+
| `install-extension` | Link the Cursor extension (status bar + wrong-window guard) |
|
|
111
133
|
| `rm <name> [--delete]` | Unregister (optionally delete the profile) |
|
|
112
134
|
|
|
113
135
|
`cursor-keys ls` prints registered project names one per line for scripts and tab completion; it is hidden from `--help`.
|
|
@@ -137,9 +159,13 @@ cursor-keys config get profilesRoot
|
|
|
137
159
|
|
|
138
160
|
## Security
|
|
139
161
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
-
|
|
162
|
+
Full threat model in [SECURITY.md](SECURITY.md). The short version:
|
|
163
|
+
|
|
164
|
+
- Keys go **straight into Cursor's own encrypted store** (`secret://cursorAuth/openAIKey`), encrypted with the same safeStorage mechanism Cursor uses. Never in config files, logs, or stdout. `set-key` takes the key from a hidden prompt or stdin, so it never appears in shell history or a process list.
|
|
165
|
+
- `set-key` reads the "Cursor Safe Storage" Keychain item to encrypt, the same key Cursor itself uses. Nothing leaves your machine. Click **Allow** at the prompt; Always Allow permanently ACLs the calling binary to that item.
|
|
166
|
+
- `clone` copies `state.vscdb` locally via SQLite backup, then **scrubs donor secrets from the copy**: all `secret://` rows (the donor's API key, extension secrets) and MCP OAuth tokens are deleted. MCP servers re-auth once per profile.
|
|
167
|
+
- What clone deliberately keeps is your Cursor **sign-in session** (so profiles open signed-in). That means N profiles hold N+1 copies of the session tokens, stored exactly as Cursor stores them. Delete profiles you no longer use: `cursor-keys rm <name> --delete`.
|
|
168
|
+
- Supply chain: zero runtime dependencies, **no install scripts**, and releases are published from GitHub Actions with [npm provenance](https://docs.npmjs.com/generating-provenance-statements) over OIDC trusted publishing (no long-lived npm token).
|
|
143
169
|
|
|
144
170
|
## Known limitations
|
|
145
171
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-keys",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Per-project Cursor profiles so each window uses the correct BYOK API key. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
15
|
"src",
|
|
16
|
-
"extension"
|
|
17
|
-
"scripts"
|
|
16
|
+
"extension"
|
|
18
17
|
],
|
|
19
18
|
"keywords": [
|
|
20
19
|
"cursor",
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
},
|
|
33
32
|
"scripts": {
|
|
34
33
|
"test": "node --test",
|
|
35
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
36
34
|
"prepublishOnly": "npm test"
|
|
37
35
|
}
|
|
38
36
|
}
|
package/src/commands.mjs
CHANGED
|
@@ -215,7 +215,9 @@ async function cmdConfig(args) {
|
|
|
215
215
|
console.log(
|
|
216
216
|
`${bold}Config${reset} ${dim}(${collapseHome(CONFIG_FILE)})${reset}`,
|
|
217
217
|
);
|
|
218
|
-
console.log(
|
|
218
|
+
console.log(
|
|
219
|
+
` baseUrl: ${config.baseUrl || `${dim}(not set: cursor-keys config baseUrl <url>)${reset}`}`,
|
|
220
|
+
);
|
|
219
221
|
console.log(` profilesRoot: ${config.profilesRoot}`);
|
|
220
222
|
console.log(
|
|
221
223
|
` projects: ${count} registered ${dim}(see cursor-keys status)${reset}`,
|
|
@@ -382,7 +384,7 @@ async function cmdAdd(args) {
|
|
|
382
384
|
}
|
|
383
385
|
}
|
|
384
386
|
|
|
385
|
-
createProfile({
|
|
387
|
+
const { scrubbed } = createProfile({
|
|
386
388
|
profileDir: project.profileDir,
|
|
387
389
|
projectName: name,
|
|
388
390
|
color,
|
|
@@ -392,6 +394,11 @@ async function cmdAdd(args) {
|
|
|
392
394
|
console.log(ok(`Profile ready: ${collapseHome(project.profileDir)}`));
|
|
393
395
|
console.log(` Repo: ${collapseHome(project.path)}`);
|
|
394
396
|
console.log(` Color: ${color} ${blockSwatch(color)}`);
|
|
397
|
+
if (cloneFrom) {
|
|
398
|
+
console.log(
|
|
399
|
+
` ${dim}Scrubbed ${scrubbed} donor secret row(s) from the clone; sign-in retained.${reset}`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
395
402
|
if (shouldShowFirstRunChecklist(project.profileDir)) {
|
|
396
403
|
printFirstRunChecklist(name, config.baseUrl);
|
|
397
404
|
}
|
|
@@ -483,6 +490,26 @@ async function cmdStatus() {
|
|
|
483
490
|
});
|
|
484
491
|
|
|
485
492
|
printTable(["Project", "Color", "Windows", "Key", "Repo"], rows);
|
|
493
|
+
if (!companionExtensionLinked()) {
|
|
494
|
+
console.log(
|
|
495
|
+
`\n${dim}Companion extension not linked: cursor-keys install-extension (status bar + wrong-window guard)${reset}`,
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Best-effort check that the companion extension is linked into Cursor.
|
|
502
|
+
* Looks for the lubu.cursor-keys-* folder the extension manifest produces.
|
|
503
|
+
*/
|
|
504
|
+
function companionExtensionLinked() {
|
|
505
|
+
try {
|
|
506
|
+
const extDir = path.join(os.homedir(), ".cursor", "extensions");
|
|
507
|
+
return fs
|
|
508
|
+
.readdirSync(extDir)
|
|
509
|
+
.some((d) => d.startsWith("lubu.cursor-keys"));
|
|
510
|
+
} catch {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
486
513
|
}
|
|
487
514
|
|
|
488
515
|
async function cmdCurrent() {
|
|
@@ -562,9 +589,16 @@ async function cmdDoctor(args) {
|
|
|
562
589
|
console.log(
|
|
563
590
|
` ${stateDbHasKey(db, SUBAGENT_OVERRIDES_KEY) ? ok("✓") : warn("✗")} Explore subagent overrides present`,
|
|
564
591
|
);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
592
|
+
const fragment = baseUrlFragment(config);
|
|
593
|
+
if (fragment) {
|
|
594
|
+
console.log(
|
|
595
|
+
` ${stateDbValueContains(db, fragment) ? ok("✓") : warn("✗")} Base URL (${fragment}) in profile state`,
|
|
596
|
+
);
|
|
597
|
+
} else {
|
|
598
|
+
console.log(
|
|
599
|
+
` ${dim}- baseUrl not set, skipping gateway check: cursor-keys config baseUrl <url>${reset}`,
|
|
600
|
+
);
|
|
601
|
+
}
|
|
568
602
|
} else {
|
|
569
603
|
console.log(` ${warn("✗")} Open profile once: cursor-keys open ${name}`);
|
|
570
604
|
}
|
|
@@ -814,10 +848,13 @@ async function cmdClone(args) {
|
|
|
814
848
|
donorRoot = donor.profileDir;
|
|
815
849
|
}
|
|
816
850
|
|
|
817
|
-
cloneStateDb(donorRoot, project.profileDir);
|
|
851
|
+
const scrubbed = cloneStateDb(donorRoot, project.profileDir);
|
|
818
852
|
console.log(ok(`Cloned state from ${from} into ${name}`));
|
|
819
853
|
console.log(
|
|
820
|
-
`${dim}
|
|
854
|
+
`${dim}Scrubbed ${scrubbed} donor secret row(s) from the copy (API keys, MCP OAuth, extension secrets); sign-in retained.${reset}`,
|
|
855
|
+
);
|
|
856
|
+
console.log(
|
|
857
|
+
`${dim}Settings and model config carried over. Now set the project key:${reset}`,
|
|
821
858
|
);
|
|
822
859
|
console.log(` cursor-keys set-key ${name}`);
|
|
823
860
|
}
|
|
@@ -879,6 +916,14 @@ async function cmdColor(args) {
|
|
|
879
916
|
console.log(`${dim}Open Cursor windows reload settings automatically.${reset}`);
|
|
880
917
|
}
|
|
881
918
|
|
|
919
|
+
/**
|
|
920
|
+
* Read the API key from piped stdin. Only called when stdin is not an
|
|
921
|
+
* interactive TTY; interactive runs get the hidden prompt instead.
|
|
922
|
+
*/
|
|
923
|
+
function readStdinKey() {
|
|
924
|
+
return fs.readFileSync(0, "utf8").trim();
|
|
925
|
+
}
|
|
926
|
+
|
|
882
927
|
function promptHidden(question) {
|
|
883
928
|
return new Promise((resolve) => {
|
|
884
929
|
const rl = readline.createInterface({
|
|
@@ -899,18 +944,24 @@ function promptHidden(question) {
|
|
|
899
944
|
async function cmdSetKey(args) {
|
|
900
945
|
const { flags, positional } = parseFlags(args);
|
|
901
946
|
if (flags.help) {
|
|
902
|
-
console.log("Usage: cursor-keys set-key <name>
|
|
947
|
+
console.log("Usage: cursor-keys set-key <name>");
|
|
903
948
|
console.log(
|
|
904
949
|
"Writes the key into the profile's encrypted store (Cursor must",
|
|
905
950
|
);
|
|
906
951
|
console.log(
|
|
907
|
-
"not have that profile window open).
|
|
952
|
+
"not have that profile window open). Hidden prompt when interactive;",
|
|
908
953
|
);
|
|
954
|
+
console.log("reads stdin when piped. No inline key flag exists:");
|
|
955
|
+
console.log("shell history and process lists are not secret-safe.");
|
|
909
956
|
return;
|
|
910
957
|
}
|
|
911
958
|
const name = positional[0];
|
|
912
|
-
if (!name)
|
|
913
|
-
|
|
959
|
+
if (!name) throw new Error("Usage: cursor-keys set-key <name>");
|
|
960
|
+
if (flags.key !== undefined) {
|
|
961
|
+
throw new Error(
|
|
962
|
+
`Inline --key is not accepted: shell history and process lists are not secret-safe. Use the hidden prompt or pipe stdin instead: op read op://vault/item/password | cursor-keys set-key ${name}`,
|
|
963
|
+
);
|
|
964
|
+
}
|
|
914
965
|
|
|
915
966
|
const config = loadConfig();
|
|
916
967
|
const project = getProject(config, name);
|
|
@@ -926,8 +977,10 @@ async function cmdSetKey(args) {
|
|
|
926
977
|
throw new Error(`Close the "${name}" Cursor window first, then retry.`);
|
|
927
978
|
}
|
|
928
979
|
|
|
929
|
-
let key
|
|
930
|
-
if (!
|
|
980
|
+
let key;
|
|
981
|
+
if (!process.stdin.isTTY) {
|
|
982
|
+
key = readStdinKey();
|
|
983
|
+
} else {
|
|
931
984
|
console.log(
|
|
932
985
|
`\nPaste the API key for ${bold}${name}${reset} below, then press Enter.`,
|
|
933
986
|
);
|
package/src/config.mjs
CHANGED
|
@@ -48,7 +48,9 @@ export function collapseHome(p) {
|
|
|
48
48
|
export function defaultConfig() {
|
|
49
49
|
return {
|
|
50
50
|
profilesRoot: collapseHome(DEFAULT_PROFILES_ROOT),
|
|
51
|
-
|
|
51
|
+
// No built-in gateway URL: every install sets its own via
|
|
52
|
+
// `cursor-keys config baseUrl <url>`.
|
|
53
|
+
baseUrl: "",
|
|
52
54
|
projects: {},
|
|
53
55
|
};
|
|
54
56
|
}
|
|
@@ -97,10 +99,7 @@ export function validateConfig(data) {
|
|
|
97
99
|
typeof data.profilesRoot === "string"
|
|
98
100
|
? data.profilesRoot
|
|
99
101
|
: collapseHome(DEFAULT_PROFILES_ROOT);
|
|
100
|
-
const baseUrl =
|
|
101
|
-
typeof data.baseUrl === "string" && data.baseUrl
|
|
102
|
-
? data.baseUrl
|
|
103
|
-
: "https://connect.iobonzai.com/cursor";
|
|
102
|
+
const baseUrl = typeof data.baseUrl === "string" ? data.baseUrl : "";
|
|
104
103
|
const projects = {};
|
|
105
104
|
if (data.projects && typeof data.projects === "object") {
|
|
106
105
|
for (const [name, entry] of Object.entries(data.projects)) {
|
|
@@ -120,7 +119,7 @@ export function validateConfig(data) {
|
|
|
120
119
|
return { profilesRoot, baseUrl, projects };
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
/** "https://
|
|
122
|
+
/** "https://gateway.example.com/v1" -> "gateway.example.com/v1" */
|
|
124
123
|
export function baseUrlFragment(config) {
|
|
125
124
|
return String(config.baseUrl || "").replace(/^https?:\/\//, "");
|
|
126
125
|
}
|
package/src/detect.mjs
CHANGED
|
@@ -166,7 +166,8 @@ export function stateDbKeysLike(stateDbPath, likePattern) {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
|
-
* Check if
|
|
169
|
+
* Check if a URL fragment (e.g. the configured gateway base URL) appears in
|
|
170
|
+
* any ItemTable value (substring, no key dump)
|
|
170
171
|
* @param {string} stateDbPath
|
|
171
172
|
* @param {string} urlFragment
|
|
172
173
|
*/
|
|
@@ -211,4 +212,3 @@ function shellQuote(s) {
|
|
|
211
212
|
|
|
212
213
|
export const SECRET_OPENAI_KEY = "secret://cursorAuth/openAIKey";
|
|
213
214
|
export const SUBAGENT_OVERRIDES_KEY = "cursor/subagentModelOverrides";
|
|
214
|
-
export const BONZAI_BASE_URL_FRAGMENT = "connect.iobonzai.com/cursor";
|
package/src/profile.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
1
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import {
|
|
@@ -80,9 +80,18 @@ export function symlinkSharedUserFiles(profileDir) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Row patterns scrubbed from every cloned state DB. Donor secrets (API keys,
|
|
85
|
+
* MCP OAuth tokens, extension secrets) never propagate into project profiles.
|
|
86
|
+
* The Cursor sign-in session (cursorAuth/*) intentionally stays: profiles
|
|
87
|
+
* open signed-in, which is the whole point of clone.
|
|
88
|
+
*/
|
|
89
|
+
export const CLONE_SCRUB_LIKE_PATTERNS = ["secret://%", "mcpOAuth.%"];
|
|
90
|
+
|
|
83
91
|
/**
|
|
84
92
|
* @param {string} donorProfileDir - main Cursor or another profile root (parent of User)
|
|
85
93
|
* @param {string} targetProfileDir
|
|
94
|
+
* @returns {number} how many donor secret rows were scrubbed from the copy
|
|
86
95
|
*/
|
|
87
96
|
export function cloneStateDb(donorProfileDir, targetProfileDir) {
|
|
88
97
|
const runningProfiles = listRunningCursorProfiles();
|
|
@@ -126,6 +135,29 @@ export function cloneStateDb(donorProfileDir, targetProfileDir) {
|
|
|
126
135
|
execSync(`sqlite3 ${shellQuote(src)} "VACUUM INTO ${shellQuote(dest)}"`, {
|
|
127
136
|
stdio: "ignore",
|
|
128
137
|
});
|
|
138
|
+
|
|
139
|
+
return scrubClonedSecrets(dest);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Delete donor secret rows from a freshly cloned state DB (keys only, values
|
|
144
|
+
* are never read). Returns the number of deleted rows.
|
|
145
|
+
* @param {string} stateDbPath
|
|
146
|
+
*/
|
|
147
|
+
export function scrubClonedSecrets(stateDbPath) {
|
|
148
|
+
let scrubbed = 0;
|
|
149
|
+
for (const pattern of CLONE_SCRUB_LIKE_PATTERNS) {
|
|
150
|
+
const out = execFileSync(
|
|
151
|
+
"sqlite3",
|
|
152
|
+
[
|
|
153
|
+
stateDbPath,
|
|
154
|
+
`DELETE FROM ItemTable WHERE key LIKE '${pattern}'; SELECT changes();`,
|
|
155
|
+
],
|
|
156
|
+
{ encoding: "utf8" },
|
|
157
|
+
);
|
|
158
|
+
scrubbed += parseInt(out.trim(), 10) || 0;
|
|
159
|
+
}
|
|
160
|
+
return scrubbed;
|
|
129
161
|
}
|
|
130
162
|
|
|
131
163
|
function shellQuote(s) {
|
|
@@ -150,19 +182,23 @@ export function needsFirstRunChecklist(profileDir) {
|
|
|
150
182
|
*/
|
|
151
183
|
export function buildFirstRunChecklist(
|
|
152
184
|
projectName,
|
|
153
|
-
baseUrl = "
|
|
185
|
+
baseUrl = "",
|
|
154
186
|
platform = process.platform,
|
|
155
187
|
) {
|
|
188
|
+
const gateway = baseUrl || "https://gateway.example.com/v1";
|
|
189
|
+
const gatewayStep = baseUrl
|
|
190
|
+
? ""
|
|
191
|
+
: ` cursor-keys config baseUrl <your-gateway-url> # one-time, e.g. ${gateway}\n`;
|
|
156
192
|
if (platform === "darwin") {
|
|
157
193
|
return `
|
|
158
194
|
First-time setup for "${projectName}" · copy-paste in order:
|
|
159
195
|
|
|
160
|
-
cursor-keys clone ${projectName} # inherit sign-in, settings, model config from main Cursor
|
|
196
|
+
${gatewayStep} cursor-keys clone ${projectName} # inherit sign-in, settings, model config from main Cursor
|
|
161
197
|
cursor-keys set-key ${projectName} # inject the project API key (encrypted, hidden prompt)
|
|
162
198
|
cursor-keys doctor ${projectName} # verify the profile
|
|
163
199
|
|
|
164
200
|
Manual alternative: Cursor Settings → Models → API keys, paste the key under
|
|
165
|
-
OpenAI API Key, enable "Override OpenAI Base URL" with: ${
|
|
201
|
+
OpenAI API Key, enable "Override OpenAI Base URL" with: ${gateway}
|
|
166
202
|
|
|
167
203
|
Already inside this profile's window? Close it before running clone or set-key.
|
|
168
204
|
`;
|
|
@@ -171,12 +207,12 @@ Already inside this profile's window? Close it before running clone or set-key.
|
|
|
171
207
|
return `
|
|
172
208
|
First-time setup for "${projectName}" · copy-paste in order:
|
|
173
209
|
|
|
174
|
-
cursor-keys clone ${projectName} # inherit sign-in, settings, model config from main Cursor
|
|
210
|
+
${gatewayStep} cursor-keys clone ${projectName} # inherit sign-in, settings, model config from main Cursor
|
|
175
211
|
cursor-keys open ${projectName} # open once so Cursor creates its state
|
|
176
212
|
cursor-keys doctor ${projectName} # verify the profile
|
|
177
213
|
|
|
178
214
|
Then in that window: Cursor Settings → Models → API keys, paste the key under
|
|
179
|
-
OpenAI API Key, enable "Override OpenAI Base URL" with: ${
|
|
215
|
+
OpenAI API Key, enable "Override OpenAI Base URL" with: ${gateway}
|
|
180
216
|
|
|
181
217
|
Already inside this profile's window? Close it before running clone.
|
|
182
218
|
`;
|
|
@@ -193,9 +229,11 @@ export function createProfile({ profileDir, projectName, color, cloneFrom }) {
|
|
|
193
229
|
fs.mkdirSync(profileDir, { recursive: true });
|
|
194
230
|
writeProfileSettings(profileDir, projectName, color);
|
|
195
231
|
symlinkSharedUserFiles(profileDir);
|
|
232
|
+
let scrubbed = 0;
|
|
196
233
|
if (cloneFrom) {
|
|
197
|
-
cloneStateDb(cloneFrom, profileDir);
|
|
234
|
+
scrubbed = cloneStateDb(cloneFrom, profileDir);
|
|
198
235
|
}
|
|
236
|
+
return { scrubbed };
|
|
199
237
|
}
|
|
200
238
|
|
|
201
239
|
export function profileIntegrityChecks(profileDir) {
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Postinstall: one-time hint + best-effort companion extension install.
|
|
2
|
-
// Never breaks the install: the whole body is guarded and exits 0.
|
|
3
|
-
// Quiet installs: CURSOR_KEYS_NO_POSTINSTALL=1
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
if (process.env.CURSOR_KEYS_NO_POSTINSTALL) process.exit(0);
|
|
11
|
-
const yellow = "\x1b[33m";
|
|
12
|
-
const dim = "\x1b[2m";
|
|
13
|
-
const reset = "\x1b[0m";
|
|
14
|
-
|
|
15
|
-
const pkgRoot = path.join(
|
|
16
|
-
path.dirname(fileURLToPath(import.meta.url)),
|
|
17
|
-
"..",
|
|
18
|
-
);
|
|
19
|
-
const extSrc = path.join(pkgRoot, "extension");
|
|
20
|
-
const extPkgPath = path.join(extSrc, "package.json");
|
|
21
|
-
const cursorDir = path.join(os.homedir(), ".cursor");
|
|
22
|
-
|
|
23
|
-
// Auto-link the companion extension on global installs when Cursor exists.
|
|
24
|
-
let extLine = "";
|
|
25
|
-
const isGlobal = process.env.npm_config_global === "true";
|
|
26
|
-
if (isGlobal && fs.existsSync(cursorDir) && fs.existsSync(extPkgPath)) {
|
|
27
|
-
try {
|
|
28
|
-
const extPkg = JSON.parse(fs.readFileSync(extPkgPath, "utf8"));
|
|
29
|
-
const extDir = path.join(cursorDir, "extensions");
|
|
30
|
-
fs.mkdirSync(extDir, { recursive: true });
|
|
31
|
-
const target = path.join(
|
|
32
|
-
extDir,
|
|
33
|
-
`${extPkg.publisher || "lubu"}.${extPkg.name}-${extPkg.version}`,
|
|
34
|
-
);
|
|
35
|
-
fs.rmSync(target, { recursive: true, force: true });
|
|
36
|
-
try {
|
|
37
|
-
fs.symlinkSync(extSrc, target, "dir");
|
|
38
|
-
} catch {
|
|
39
|
-
fs.cpSync(extSrc, target, { recursive: true });
|
|
40
|
-
}
|
|
41
|
-
extLine = `\n Cursor extension linked ${dim}· restart Cursor, then Cmd+Shift+P: "cursor-keys: Open Project..."${reset}`;
|
|
42
|
-
} catch {
|
|
43
|
-
extLine = `\n cursor-keys install-extension link the Cursor extension (status bar + warnings)`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
console.log(`
|
|
48
|
-
${yellow}cursor-keys installed${reset}
|
|
49
|
-
|
|
50
|
-
cursor-keys --help commands
|
|
51
|
-
cursor-keys aliases --install aliases, 'ck' shortcut, tab completion
|
|
52
|
-
cursor-keys wrap --install plain 'cursor <path>' picks the profile
|
|
53
|
-
${extLine}
|
|
54
|
-
${dim}Quiet installs: CURSOR_KEYS_NO_POSTINSTALL=1${reset}
|
|
55
|
-
`);
|
|
56
|
-
} catch {
|
|
57
|
-
/* postinstall must never break install */
|
|
58
|
-
}
|