@gengjiawen/os-init 1.23.1 → 1.25.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/CHANGELOG.md +19 -0
- package/README.md +18 -0
- package/bin/bin.js +31 -5
- package/build/all-agents.d.ts +1 -2
- package/build/all-agents.js +3 -9
- package/build/claude-code.js +2 -7
- package/build/codex.d.ts +2 -3
- package/build/codex.js +11 -37
- package/build/cursor.d.ts +24 -0
- package/build/cursor.js +110 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +6 -1
- package/build/mihomo.js +1 -1
- package/libs/all-agents.test.ts +4 -17
- package/libs/all-agents.ts +5 -11
- package/libs/claude-code.test.ts +0 -1
- package/libs/claude-code.ts +2 -7
- package/libs/codex.test.ts +29 -108
- package/libs/codex.ts +14 -54
- package/libs/cursor.test.ts +204 -0
- package/libs/cursor.ts +205 -0
- package/libs/index.ts +8 -0
- package/libs/mihomo.test.ts +1 -1
- package/libs/mihomo.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.25.0](https://github.com/gengjiawen/os-init/compare/v1.24.0...v1.25.0) (2026-05-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add disable-ts-extension command ([26c8d38](https://github.com/gengjiawen/os-init/commit/26c8d389f5524eebf27fb0e16f92f1a800d53b73))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **codex:** Windows TOML parse failure in model_catalog_json merge ([#38](https://github.com/gengjiawen/os-init/issues/38)) ([86375a8](https://github.com/gengjiawen/os-init/commit/86375a89aff460d3b367a4f2af9a5205abc0570e))
|
|
14
|
+
|
|
15
|
+
## [1.24.0](https://github.com/gengjiawen/os-init/compare/v1.23.1...v1.24.0) (2026-04-29)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add CLAUDE_CODE_EFFORT_LEVEL setting to user settings template ([a32c352](https://github.com/gengjiawen/os-init/commit/a32c3520236bb5511a33ddc586107861ea6dfabb))
|
|
21
|
+
|
|
3
22
|
## [1.23.1](https://github.com/gengjiawen/os-init/compare/v1.23.0...v1.23.1) (2026-04-24)
|
|
4
23
|
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -72,6 +72,24 @@ Example:
|
|
|
72
72
|
pnpx @gengjiawen/os-init set-fish
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
### Disable VS Code TypeScript Extension in Cursor
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpx @gengjiawen/os-init disable-ts-extension
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Disables `vscode.typescript-language-features`, the VS Code TypeScript language
|
|
82
|
+
features extension bundled with Cursor, because it can consume too much memory.
|
|
83
|
+
The command writes Cursor's UI disabled-extension state so it stays disabled
|
|
84
|
+
across restarts, updates Cursor's `state.vscdb` with Node's built-in
|
|
85
|
+
`node:sqlite` module, and preserves any other disabled extensions.
|
|
86
|
+
|
|
87
|
+
Use a custom Cursor state database path when needed:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpx @gengjiawen/os-init disable-ts-extension --db "$HOME/Library/Application Support/Cursor/User/globalStorage/state.vscdb"
|
|
91
|
+
```
|
|
92
|
+
|
|
75
93
|
### Generate Mihomo Config
|
|
76
94
|
|
|
77
95
|
```bash
|
package/bin/bin.js
CHANGED
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
setupAndroidEnvironment,
|
|
17
17
|
writeMihomoConfig,
|
|
18
18
|
downloadMihomoBinary,
|
|
19
|
+
disableCursorTypescriptExtension,
|
|
19
20
|
} = require('../build')
|
|
20
21
|
const { appendFishImportScript } = require('../build/fish-shell-utils')
|
|
21
22
|
|
|
@@ -63,11 +64,9 @@ program
|
|
|
63
64
|
return
|
|
64
65
|
}
|
|
65
66
|
try {
|
|
66
|
-
const { configPath, authPath
|
|
67
|
-
await writeCodexConfig(apiKey)
|
|
67
|
+
const { configPath, authPath } = writeCodexConfig(apiKey)
|
|
68
68
|
console.log(`Codex config written to: ${configPath}`)
|
|
69
69
|
console.log(`Codex auth written to: ${authPath}`)
|
|
70
|
-
console.log(`Codex model catalog written to: ${catalogPath}`)
|
|
71
70
|
await installCodexDeps()
|
|
72
71
|
} catch (err) {
|
|
73
72
|
console.error('Failed to setup Codex:', err.message)
|
|
@@ -122,7 +121,7 @@ program
|
|
|
122
121
|
: 'Setting up Claude Code + Codex...\n'
|
|
123
122
|
)
|
|
124
123
|
|
|
125
|
-
const result =
|
|
124
|
+
const result = writeAllAgentsConfig(apiKey, { full })
|
|
126
125
|
|
|
127
126
|
console.log('Claude Code:')
|
|
128
127
|
console.log(` Settings written to: ${result.claude.settingsPath}`)
|
|
@@ -133,7 +132,6 @@ program
|
|
|
133
132
|
console.log('\nCodex:')
|
|
134
133
|
console.log(` Config written to: ${result.codex.configPath}`)
|
|
135
134
|
console.log(` Auth written to: ${result.codex.authPath}`)
|
|
136
|
-
console.log(` Model catalog written to: ${result.codex.catalogPath}`)
|
|
137
135
|
|
|
138
136
|
if (result.opencode) {
|
|
139
137
|
console.log('\nOpenCode:')
|
|
@@ -236,6 +234,34 @@ program
|
|
|
236
234
|
}
|
|
237
235
|
})
|
|
238
236
|
|
|
237
|
+
program
|
|
238
|
+
.command('disable-ts-extension')
|
|
239
|
+
.description(
|
|
240
|
+
'disable VS Code TypeScript extension in Cursor to avoid excessive memory use'
|
|
241
|
+
)
|
|
242
|
+
.option('--db <path>', 'Cursor state.vscdb path')
|
|
243
|
+
.action(async (options) => {
|
|
244
|
+
try {
|
|
245
|
+
const result = await disableCursorTypescriptExtension({
|
|
246
|
+
dbPath: options.db,
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
console.log(
|
|
250
|
+
result.changed
|
|
251
|
+
? `Cursor extension disabled: ${result.extensionId}`
|
|
252
|
+
: `Cursor extension already disabled: ${result.extensionId}`
|
|
253
|
+
)
|
|
254
|
+
console.log(`Cursor state DB: ${result.dbPath}`)
|
|
255
|
+
console.log(`Cursor storage key: ${result.key}`)
|
|
256
|
+
} catch (err) {
|
|
257
|
+
console.error(
|
|
258
|
+
'Failed to disable VS Code TypeScript extension in Cursor:',
|
|
259
|
+
err.message
|
|
260
|
+
)
|
|
261
|
+
process.exit(1)
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
|
|
239
265
|
program
|
|
240
266
|
.command('set-clash')
|
|
241
267
|
.description('generate clash/mihomo config.yml in current directory')
|
package/build/all-agents.d.ts
CHANGED
|
@@ -9,11 +9,10 @@ export interface AllAgentsResult {
|
|
|
9
9
|
codex: {
|
|
10
10
|
configPath: string;
|
|
11
11
|
authPath: string;
|
|
12
|
-
catalogPath: string;
|
|
13
12
|
};
|
|
14
13
|
opencode?: {
|
|
15
14
|
configPath: string;
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
export declare function writeAllAgentsConfig(apiKey: string, options?: AllAgentsOptions):
|
|
17
|
+
export declare function writeAllAgentsConfig(apiKey: string, options?: AllAgentsOptions): AllAgentsResult;
|
|
19
18
|
export declare function installAllAgentsDeps(options?: AllAgentsOptions): Promise<void>;
|
package/build/all-agents.js
CHANGED
|
@@ -7,9 +7,9 @@ const codex_1 = require("./codex");
|
|
|
7
7
|
const opencode_1 = require("./opencode");
|
|
8
8
|
const execa_1 = require("execa");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
|
-
|
|
10
|
+
function writeAllAgentsConfig(apiKey, options = {}) {
|
|
11
11
|
const claudeResult = (0, claude_code_1.writeClaudeConfig)(apiKey);
|
|
12
|
-
const codexResult =
|
|
12
|
+
const codexResult = (0, codex_1.writeCodexConfig)(apiKey);
|
|
13
13
|
const result = {
|
|
14
14
|
claude: claudeResult,
|
|
15
15
|
codex: codexResult,
|
|
@@ -27,13 +27,7 @@ async function installAllAgentsDeps(options = {}) {
|
|
|
27
27
|
const usePnpm = await (0, utils_1.commandExists)('pnpm');
|
|
28
28
|
if (usePnpm) {
|
|
29
29
|
console.log('pnpm detected. Installing agent dependencies with pnpm...');
|
|
30
|
-
await (0, execa_1.execa)('pnpm', [
|
|
31
|
-
'--allow-build=@anthropic-ai/claude-code',
|
|
32
|
-
'add',
|
|
33
|
-
'-g',
|
|
34
|
-
'--force',
|
|
35
|
-
...packages,
|
|
36
|
-
], {
|
|
30
|
+
await (0, execa_1.execa)('pnpm', ['--allow-build=@anthropic-ai/claude-code', 'add', '-g', ...packages], {
|
|
37
31
|
stdio: 'inherit',
|
|
38
32
|
env: utils_1.PNPM_INSTALL_ENV,
|
|
39
33
|
});
|
package/build/claude-code.js
CHANGED
|
@@ -28,6 +28,7 @@ function getVSCodeUserSettingsPath() {
|
|
|
28
28
|
const CLAUDE_SETTINGS_TEMPLATE = `{
|
|
29
29
|
"env": {
|
|
30
30
|
"DISABLE_TELEMETRY": "1",
|
|
31
|
+
"CLAUDE_CODE_EFFORT_LEVEL": "max",
|
|
31
32
|
"OTEL_METRICS_EXPORTER": "otlp",
|
|
32
33
|
"ANTHROPIC_API_KEY": "API_KEY_PLACEHOLDER",
|
|
33
34
|
"ANTHROPIC_BASE_URL": "${CLAUDE_BASE_URL}",
|
|
@@ -103,13 +104,7 @@ async function installDeps() {
|
|
|
103
104
|
const usePnpm = await (0, utils_1.commandExists)('pnpm');
|
|
104
105
|
if (usePnpm) {
|
|
105
106
|
console.log('pnpm detected. Installing dependencies with pnpm...');
|
|
106
|
-
await (0, execa_1.execa)('pnpm', [
|
|
107
|
-
'--allow-build=@anthropic-ai/claude-code',
|
|
108
|
-
'add',
|
|
109
|
-
'-g',
|
|
110
|
-
'--force',
|
|
111
|
-
...packages,
|
|
112
|
-
], {
|
|
107
|
+
await (0, execa_1.execa)('pnpm', ['--allow-build=@anthropic-ai/claude-code', 'add', '-g', ...packages], {
|
|
113
108
|
stdio: 'inherit',
|
|
114
109
|
env: utils_1.PNPM_INSTALL_ENV,
|
|
115
110
|
});
|
package/build/codex.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare function writeCodexConfig(apiKey: string):
|
|
1
|
+
export declare function writeCodexConfig(apiKey: string): {
|
|
2
2
|
configPath: string;
|
|
3
3
|
authPath: string;
|
|
4
|
-
|
|
5
|
-
}>;
|
|
4
|
+
};
|
|
6
5
|
export declare function installCodexDeps(): Promise<void>;
|
package/build/codex.js
CHANGED
|
@@ -9,19 +9,9 @@ const TOML = require("@iarna/toml");
|
|
|
9
9
|
const execa_1 = require("execa");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
const CODEX_BASE_URL = 'https://ai.gengjiawen.com/api/openai';
|
|
12
|
-
const CODEX_MODEL_CATALOG_CONFIG_PATH = '~/.codex/remote-model-catalog.json';
|
|
13
|
-
const CODEX_MODEL_CATALOG_FILENAME = 'remote-model-catalog.json';
|
|
14
12
|
function getCodexConfigDir() {
|
|
15
13
|
return path.join(os.homedir(), '.codex');
|
|
16
14
|
}
|
|
17
|
-
function getCodexModelCatalogPath() {
|
|
18
|
-
return path.join(getCodexConfigDir(), CODEX_MODEL_CATALOG_FILENAME);
|
|
19
|
-
}
|
|
20
|
-
function getCodexModelCatalogConfigPath() {
|
|
21
|
-
return os.platform() === 'win32'
|
|
22
|
-
? getCodexModelCatalogPath()
|
|
23
|
-
: CODEX_MODEL_CATALOG_CONFIG_PATH;
|
|
24
|
-
}
|
|
25
15
|
function getCodexConfigTomlTemplate() {
|
|
26
16
|
return `model_provider = "jw"
|
|
27
17
|
model = "gpt-5.5"
|
|
@@ -30,7 +20,6 @@ plan_mode_reasoning_effort = "xhigh"
|
|
|
30
20
|
model_auto_compact_token_limit = 131072
|
|
31
21
|
disable_response_storage = true
|
|
32
22
|
preferred_auth_method = "apikey"
|
|
33
|
-
model_catalog_json = ${JSON.stringify(getCodexModelCatalogConfigPath())}
|
|
34
23
|
|
|
35
24
|
[model_providers.jw]
|
|
36
25
|
name = "jw"
|
|
@@ -55,38 +44,23 @@ function mergeTomlTables(existingConfig, templateConfig) {
|
|
|
55
44
|
}
|
|
56
45
|
return mergedConfig;
|
|
57
46
|
}
|
|
47
|
+
function stripModelCatalogJsonFromToml(content) {
|
|
48
|
+
return content
|
|
49
|
+
.split('\n')
|
|
50
|
+
.filter((line) => !/^\s*model_catalog_json\s*=/.test(line))
|
|
51
|
+
.join('\n');
|
|
52
|
+
}
|
|
58
53
|
function getMergedCodexConfig(existingContent) {
|
|
59
|
-
const
|
|
54
|
+
const sanitizedContent = stripModelCatalogJsonFromToml(existingContent);
|
|
55
|
+
const existingConfig = TOML.parse(sanitizedContent);
|
|
60
56
|
const templateConfig = TOML.parse(getCodexConfigTomlTemplate());
|
|
61
57
|
delete existingConfig.service_tier;
|
|
58
|
+
delete existingConfig.model_catalog_json;
|
|
62
59
|
return TOML.stringify(mergeTomlTables(existingConfig, templateConfig));
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
if (typeof fetch !== 'function') {
|
|
66
|
-
throw new Error('Global fetch API is unavailable in this Node.js runtime.');
|
|
67
|
-
}
|
|
68
|
-
const response = await fetch(`${CODEX_BASE_URL}/models`, {
|
|
69
|
-
headers: {
|
|
70
|
-
Accept: 'application/json',
|
|
71
|
-
Authorization: `Bearer ${apiKey}`,
|
|
72
|
-
'User-Agent': '@gengjiawen/os-init',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
if (!response.ok) {
|
|
76
|
-
throw new Error(`Failed to refresh Codex model catalog: ${response.status} ${response.statusText}`);
|
|
77
|
-
}
|
|
78
|
-
const catalog = (await response.json());
|
|
79
|
-
if (!Array.isArray(catalog?.models) || catalog.models.length === 0) {
|
|
80
|
-
throw new Error('Failed to refresh Codex model catalog: response does not contain any models.');
|
|
81
|
-
}
|
|
82
|
-
const catalogPath = getCodexModelCatalogPath();
|
|
83
|
-
fs.writeFileSync(catalogPath, `${JSON.stringify(catalog, null, 2)}\n`);
|
|
84
|
-
return catalogPath;
|
|
85
|
-
}
|
|
86
|
-
async function writeCodexConfig(apiKey) {
|
|
61
|
+
function writeCodexConfig(apiKey) {
|
|
87
62
|
const configDir = getCodexConfigDir();
|
|
88
63
|
(0, utils_1.ensureDir)(configDir);
|
|
89
|
-
const catalogPath = await refreshCodexModelCatalog(apiKey);
|
|
90
64
|
const configPath = path.join(configDir, 'config.toml');
|
|
91
65
|
const configContent = fs.existsSync(configPath)
|
|
92
66
|
? getMergedCodexConfig(fs.readFileSync(configPath, 'utf8'))
|
|
@@ -95,7 +69,7 @@ async function writeCodexConfig(apiKey) {
|
|
|
95
69
|
const authPath = path.join(configDir, 'auth.json');
|
|
96
70
|
const authContent = JSON.stringify({ OPENAI_API_KEY: apiKey }, null, 2);
|
|
97
71
|
fs.writeFileSync(authPath, authContent);
|
|
98
|
-
return { configPath, authPath
|
|
72
|
+
return { configPath, authPath };
|
|
99
73
|
}
|
|
100
74
|
async function installCodexDeps() {
|
|
101
75
|
const packages = ['@openai/codex'];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const CURSOR_TYPESCRIPT_EXTENSION_ID = "vscode.typescript-language-features";
|
|
2
|
+
interface DisabledExtensionIdentifier {
|
|
3
|
+
id: string;
|
|
4
|
+
uuid?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DisableCursorExtensionOptions {
|
|
7
|
+
dbPath?: string;
|
|
8
|
+
extensionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DisableCursorExtensionResult {
|
|
11
|
+
dbPath: string;
|
|
12
|
+
key: string;
|
|
13
|
+
extensionId: string;
|
|
14
|
+
changed: boolean;
|
|
15
|
+
disabledExtensions: DisabledExtensionIdentifier[];
|
|
16
|
+
}
|
|
17
|
+
export declare function getCursorStateDbPath(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, homeDir?: string): string;
|
|
18
|
+
export declare function mergeDisabledExtension(rawValue: string | null | undefined, extensionId?: string): {
|
|
19
|
+
changed: boolean;
|
|
20
|
+
value: string;
|
|
21
|
+
disabledExtensions: DisabledExtensionIdentifier[];
|
|
22
|
+
};
|
|
23
|
+
export declare function disableCursorTypescriptExtension(options?: DisableCursorExtensionOptions): Promise<DisableCursorExtensionResult>;
|
|
24
|
+
export {};
|
package/build/cursor.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURSOR_TYPESCRIPT_EXTENSION_ID = void 0;
|
|
4
|
+
exports.getCursorStateDbPath = getCursorStateDbPath;
|
|
5
|
+
exports.mergeDisabledExtension = mergeDisabledExtension;
|
|
6
|
+
exports.disableCursorTypescriptExtension = disableCursorTypescriptExtension;
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const os = require("os");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const node_buffer_1 = require("node:buffer");
|
|
11
|
+
const node_sqlite_1 = require("node:sqlite");
|
|
12
|
+
exports.CURSOR_TYPESCRIPT_EXTENSION_ID = 'vscode.typescript-language-features';
|
|
13
|
+
const DISABLED_EXTENSIONS_STORAGE_KEY = 'extensionsIdentifiers/disabled';
|
|
14
|
+
function getCursorStateDbPath(platform = process.platform, env = process.env, homeDir = os.homedir()) {
|
|
15
|
+
switch (platform) {
|
|
16
|
+
case 'darwin':
|
|
17
|
+
return path.join(homeDir, 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage', 'state.vscdb');
|
|
18
|
+
case 'linux':
|
|
19
|
+
return path.join(homeDir, '.config', 'Cursor', 'User', 'globalStorage', 'state.vscdb');
|
|
20
|
+
case 'win32':
|
|
21
|
+
return path.join(env.APPDATA || path.join(homeDir, 'AppData', 'Roaming'), 'Cursor', 'User', 'globalStorage', 'state.vscdb');
|
|
22
|
+
default:
|
|
23
|
+
return path.join(homeDir, '.config', 'Cursor', 'User', 'globalStorage', 'state.vscdb');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function isDisabledExtensionIdentifier(value) {
|
|
27
|
+
return (typeof value === 'object' &&
|
|
28
|
+
value !== null &&
|
|
29
|
+
'id' in value &&
|
|
30
|
+
typeof value.id === 'string');
|
|
31
|
+
}
|
|
32
|
+
function mergeDisabledExtension(rawValue, extensionId = exports.CURSOR_TYPESCRIPT_EXTENSION_ID) {
|
|
33
|
+
const trimmedValue = rawValue?.trim();
|
|
34
|
+
const parsedValue = trimmedValue ? JSON.parse(trimmedValue) : [];
|
|
35
|
+
if (!Array.isArray(parsedValue)) {
|
|
36
|
+
throw new Error(`${DISABLED_EXTENSIONS_STORAGE_KEY} must contain a JSON array`);
|
|
37
|
+
}
|
|
38
|
+
const disabledExtensions = parsedValue.map((item) => {
|
|
39
|
+
if (!isDisabledExtensionIdentifier(item)) {
|
|
40
|
+
throw new Error(`${DISABLED_EXTENSIONS_STORAGE_KEY} contains an invalid extension identifier`);
|
|
41
|
+
}
|
|
42
|
+
return item;
|
|
43
|
+
});
|
|
44
|
+
const hasExtension = disabledExtensions.some((item) => item.id.toLowerCase() === extensionId.toLowerCase());
|
|
45
|
+
if (hasExtension) {
|
|
46
|
+
return {
|
|
47
|
+
changed: false,
|
|
48
|
+
value: JSON.stringify(disabledExtensions),
|
|
49
|
+
disabledExtensions,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const nextDisabledExtensions = [
|
|
53
|
+
...disabledExtensions,
|
|
54
|
+
{
|
|
55
|
+
id: extensionId,
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
return {
|
|
59
|
+
changed: true,
|
|
60
|
+
value: JSON.stringify(nextDisabledExtensions),
|
|
61
|
+
disabledExtensions: nextDisabledExtensions,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function storageValueToString(value) {
|
|
65
|
+
if (value === null || value === undefined) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (typeof value === 'string') {
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
if (node_buffer_1.Buffer.isBuffer(value)) {
|
|
72
|
+
return value.toString('utf8');
|
|
73
|
+
}
|
|
74
|
+
if (value instanceof Uint8Array) {
|
|
75
|
+
return node_buffer_1.Buffer.from(value).toString('utf8');
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`${DISABLED_EXTENSIONS_STORAGE_KEY} must be stored as text`);
|
|
78
|
+
}
|
|
79
|
+
async function disableCursorTypescriptExtension(options = {}) {
|
|
80
|
+
const dbPath = options.dbPath || getCursorStateDbPath();
|
|
81
|
+
const extensionId = options.extensionId || exports.CURSOR_TYPESCRIPT_EXTENSION_ID;
|
|
82
|
+
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
|
83
|
+
if (fs.existsSync(dbPath)) {
|
|
84
|
+
const stat = fs.statSync(dbPath);
|
|
85
|
+
if (!stat.isFile()) {
|
|
86
|
+
throw new Error(`Cursor state DB path is not a file: ${dbPath}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const db = new node_sqlite_1.DatabaseSync(dbPath);
|
|
90
|
+
try {
|
|
91
|
+
db.exec('create table if not exists ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB)');
|
|
92
|
+
const row = db
|
|
93
|
+
.prepare('select value from ItemTable where key = ?')
|
|
94
|
+
.get(DISABLED_EXTENSIONS_STORAGE_KEY);
|
|
95
|
+
const merged = mergeDisabledExtension(storageValueToString(row?.value), extensionId);
|
|
96
|
+
if (merged.changed) {
|
|
97
|
+
db.prepare('insert or replace into ItemTable(key,value) values (?, ?)').run(DISABLED_EXTENSIONS_STORAGE_KEY, merged.value);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
dbPath,
|
|
101
|
+
key: DISABLED_EXTENSIONS_STORAGE_KEY,
|
|
102
|
+
extensionId,
|
|
103
|
+
changed: merged.changed,
|
|
104
|
+
disabledExtensions: merged.disabledExtensions,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
db.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { writeAllAgentsConfig, installAllAgentsDeps } from './all-agents';
|
|
|
8
8
|
export { setupDevEnvironment } from './dev-setup';
|
|
9
9
|
export { setupAndroidEnvironment } from './android-setup';
|
|
10
10
|
export { writeMihomoConfig, downloadMihomoBinary } from './mihomo';
|
|
11
|
+
export { CURSOR_TYPESCRIPT_EXTENSION_ID, disableCursorTypescriptExtension, getCursorStateDbPath, mergeDisabledExtension, } from './cursor';
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadMihomoBinary = exports.writeMihomoConfig = exports.setupAndroidEnvironment = exports.setupDevEnvironment = exports.installAllAgentsDeps = exports.writeAllAgentsConfig = exports.installOpencodeDeps = exports.writeOpencodeConfig = exports.installCodexDeps = exports.writeCodexConfig = exports.installDeps = exports.writeClaudeConfig = void 0;
|
|
3
|
+
exports.mergeDisabledExtension = exports.getCursorStateDbPath = exports.disableCursorTypescriptExtension = exports.CURSOR_TYPESCRIPT_EXTENSION_ID = exports.downloadMihomoBinary = exports.writeMihomoConfig = exports.setupAndroidEnvironment = exports.setupDevEnvironment = exports.installAllAgentsDeps = exports.writeAllAgentsConfig = exports.installOpencodeDeps = exports.writeOpencodeConfig = exports.installCodexDeps = exports.writeCodexConfig = exports.installDeps = exports.writeClaudeConfig = void 0;
|
|
4
4
|
exports.writeRaycastConfig = writeRaycastConfig;
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -57,3 +57,8 @@ Object.defineProperty(exports, "setupAndroidEnvironment", { enumerable: true, ge
|
|
|
57
57
|
var mihomo_1 = require("./mihomo");
|
|
58
58
|
Object.defineProperty(exports, "writeMihomoConfig", { enumerable: true, get: function () { return mihomo_1.writeMihomoConfig; } });
|
|
59
59
|
Object.defineProperty(exports, "downloadMihomoBinary", { enumerable: true, get: function () { return mihomo_1.downloadMihomoBinary; } });
|
|
60
|
+
var cursor_1 = require("./cursor");
|
|
61
|
+
Object.defineProperty(exports, "CURSOR_TYPESCRIPT_EXTENSION_ID", { enumerable: true, get: function () { return cursor_1.CURSOR_TYPESCRIPT_EXTENSION_ID; } });
|
|
62
|
+
Object.defineProperty(exports, "disableCursorTypescriptExtension", { enumerable: true, get: function () { return cursor_1.disableCursorTypescriptExtension; } });
|
|
63
|
+
Object.defineProperty(exports, "getCursorStateDbPath", { enumerable: true, get: function () { return cursor_1.getCursorStateDbPath; } });
|
|
64
|
+
Object.defineProperty(exports, "mergeDisabledExtension", { enumerable: true, get: function () { return cursor_1.mergeDisabledExtension; } });
|
package/build/mihomo.js
CHANGED
|
@@ -50,7 +50,7 @@ rules:
|
|
|
50
50
|
- IP-CIDR6,fe80::/10,DIRECT
|
|
51
51
|
- DOMAIN-SUFFIX,local,DIRECT
|
|
52
52
|
- DOMAIN-SUFFIX,cn,DIRECT
|
|
53
|
-
- GEOIP,CN,DIRECT
|
|
53
|
+
# - GEOIP,CN,DIRECT
|
|
54
54
|
- MATCH,PROXY
|
|
55
55
|
`;
|
|
56
56
|
const MIHOMO_LATEST_RELEASE_API_URL = 'https://api.github.com/repos/MetaCubeX/mihomo/releases/latest';
|
package/libs/all-agents.test.ts
CHANGED
|
@@ -13,7 +13,6 @@ describe('writeAllAgentsConfig', () => {
|
|
|
13
13
|
let tempHome: string
|
|
14
14
|
let homedirSpy: jest.SpiedFunction<typeof os.homedir>
|
|
15
15
|
let originalAppData: string | undefined
|
|
16
|
-
let originalFetch: typeof global.fetch | undefined
|
|
17
16
|
const execaMock = jest.mocked(execa)
|
|
18
17
|
|
|
19
18
|
beforeEach(() => {
|
|
@@ -21,12 +20,7 @@ describe('writeAllAgentsConfig', () => {
|
|
|
21
20
|
tempHome = fs.mkdtempSync(path.join(os.tmpdir(), 'os-init-all-agents-'))
|
|
22
21
|
homedirSpy = jest.spyOn(os, 'homedir').mockReturnValue(tempHome)
|
|
23
22
|
originalAppData = process.env.APPDATA
|
|
24
|
-
originalFetch = global.fetch
|
|
25
23
|
process.env.APPDATA = path.join(tempHome, 'AppData', 'Roaming')
|
|
26
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
27
|
-
ok: true,
|
|
28
|
-
json: async () => ({ models: [{ id: 'gpt-5.5' }] }),
|
|
29
|
-
}) as unknown as typeof global.fetch
|
|
30
24
|
})
|
|
31
25
|
|
|
32
26
|
afterEach(() => {
|
|
@@ -36,26 +30,20 @@ describe('writeAllAgentsConfig', () => {
|
|
|
36
30
|
} else {
|
|
37
31
|
process.env.APPDATA = originalAppData
|
|
38
32
|
}
|
|
39
|
-
if (originalFetch === undefined) {
|
|
40
|
-
global.fetch = undefined as unknown as typeof global.fetch
|
|
41
|
-
} else {
|
|
42
|
-
global.fetch = originalFetch
|
|
43
|
-
}
|
|
44
33
|
fs.rmSync(tempHome, { recursive: true, force: true })
|
|
45
34
|
})
|
|
46
35
|
|
|
47
|
-
test('writes Claude and Codex config by default',
|
|
48
|
-
const result =
|
|
36
|
+
test('writes Claude and Codex config by default', () => {
|
|
37
|
+
const result = writeAllAgentsConfig('test-api-key')
|
|
49
38
|
|
|
50
39
|
expect(fs.existsSync(result.claude.settingsPath)).toBe(true)
|
|
51
40
|
expect(fs.existsSync(result.codex.configPath)).toBe(true)
|
|
52
41
|
expect(fs.existsSync(result.codex.authPath)).toBe(true)
|
|
53
|
-
expect(fs.existsSync(result.codex.catalogPath)).toBe(true)
|
|
54
42
|
expect(result.opencode).toBeUndefined()
|
|
55
43
|
})
|
|
56
44
|
|
|
57
|
-
test('includes OpenCode config when full option is enabled',
|
|
58
|
-
const result =
|
|
45
|
+
test('includes OpenCode config when full option is enabled', () => {
|
|
46
|
+
const result = writeAllAgentsConfig('test-api-key', { full: true })
|
|
59
47
|
|
|
60
48
|
expect(result.opencode).toBeDefined()
|
|
61
49
|
expect(fs.existsSync(result.opencode!.configPath)).toBe(true)
|
|
@@ -79,7 +67,6 @@ describe('writeAllAgentsConfig', () => {
|
|
|
79
67
|
'--allow-build=@anthropic-ai/claude-code',
|
|
80
68
|
'add',
|
|
81
69
|
'-g',
|
|
82
|
-
'--force',
|
|
83
70
|
'@anthropic-ai/claude-code',
|
|
84
71
|
'@openai/codex',
|
|
85
72
|
],
|
package/libs/all-agents.ts
CHANGED
|
@@ -11,17 +11,17 @@ export interface AllAgentsOptions {
|
|
|
11
11
|
|
|
12
12
|
export interface AllAgentsResult {
|
|
13
13
|
claude: { settingsPath: string; vscodeSettingsPath: string }
|
|
14
|
-
codex: { configPath: string; authPath: string
|
|
14
|
+
codex: { configPath: string; authPath: string }
|
|
15
15
|
opencode?: { configPath: string }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** Write configuration for the combined setup (Claude Code + Codex; optional OpenCode with --full). */
|
|
19
|
-
export
|
|
19
|
+
export function writeAllAgentsConfig(
|
|
20
20
|
apiKey: string,
|
|
21
21
|
options: AllAgentsOptions = {}
|
|
22
|
-
):
|
|
22
|
+
): AllAgentsResult {
|
|
23
23
|
const claudeResult = writeClaudeConfig(apiKey)
|
|
24
|
-
const codexResult =
|
|
24
|
+
const codexResult = writeCodexConfig(apiKey)
|
|
25
25
|
|
|
26
26
|
const result: AllAgentsResult = {
|
|
27
27
|
claude: claudeResult,
|
|
@@ -50,13 +50,7 @@ export async function installAllAgentsDeps(
|
|
|
50
50
|
console.log('pnpm detected. Installing agent dependencies with pnpm...')
|
|
51
51
|
await execa(
|
|
52
52
|
'pnpm',
|
|
53
|
-
[
|
|
54
|
-
'--allow-build=@anthropic-ai/claude-code',
|
|
55
|
-
'add',
|
|
56
|
-
'-g',
|
|
57
|
-
'--force',
|
|
58
|
-
...packages,
|
|
59
|
-
],
|
|
53
|
+
['--allow-build=@anthropic-ai/claude-code', 'add', '-g', ...packages],
|
|
60
54
|
{
|
|
61
55
|
stdio: 'inherit',
|
|
62
56
|
env: PNPM_INSTALL_ENV,
|
package/libs/claude-code.test.ts
CHANGED
package/libs/claude-code.ts
CHANGED
|
@@ -42,6 +42,7 @@ function getVSCodeUserSettingsPath(): string {
|
|
|
42
42
|
const CLAUDE_SETTINGS_TEMPLATE = `{
|
|
43
43
|
"env": {
|
|
44
44
|
"DISABLE_TELEMETRY": "1",
|
|
45
|
+
"CLAUDE_CODE_EFFORT_LEVEL": "max",
|
|
45
46
|
"OTEL_METRICS_EXPORTER": "otlp",
|
|
46
47
|
"ANTHROPIC_API_KEY": "API_KEY_PLACEHOLDER",
|
|
47
48
|
"ANTHROPIC_BASE_URL": "${CLAUDE_BASE_URL}",
|
|
@@ -154,13 +155,7 @@ export async function installDeps(): Promise<void> {
|
|
|
154
155
|
console.log('pnpm detected. Installing dependencies with pnpm...')
|
|
155
156
|
await execa(
|
|
156
157
|
'pnpm',
|
|
157
|
-
[
|
|
158
|
-
'--allow-build=@anthropic-ai/claude-code',
|
|
159
|
-
'add',
|
|
160
|
-
'-g',
|
|
161
|
-
'--force',
|
|
162
|
-
...packages,
|
|
163
|
-
],
|
|
158
|
+
['--allow-build=@anthropic-ai/claude-code', 'add', '-g', ...packages],
|
|
164
159
|
{
|
|
165
160
|
stdio: 'inherit',
|
|
166
161
|
env: PNPM_INSTALL_ENV,
|