forge-setup 1.0.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/bin/index.js +112 -0
- package/package.json +21 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Defaults — update ENDPOINT before publishing for paid users
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const DEFAULTS = {
|
|
11
|
+
endpoint : 'http://localhost:8000',
|
|
12
|
+
model : 'qwen3.6-27b-q4km',
|
|
13
|
+
context : 102400,
|
|
14
|
+
key : 'none',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Arg parsing (--key sk-xxx --endpoint https://... etc.)
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
function parseArgs(argv) {
|
|
21
|
+
const out = {};
|
|
22
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23
|
+
if (argv[i].startsWith('--')) {
|
|
24
|
+
const k = argv[i].slice(2);
|
|
25
|
+
const v = argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[++i] : true;
|
|
26
|
+
out[k] = v;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const args = parseArgs(process.argv.slice(2));
|
|
33
|
+
|
|
34
|
+
if (args.help || args.h) {
|
|
35
|
+
console.log([
|
|
36
|
+
'',
|
|
37
|
+
'Usage:',
|
|
38
|
+
' npx forge-setup --key <api-key>',
|
|
39
|
+
' npx forge-setup --key <api-key> --endpoint https://api.example.com',
|
|
40
|
+
'',
|
|
41
|
+
'Options:',
|
|
42
|
+
' --key API key issued by Forge (required for hosted; use "none" for local)',
|
|
43
|
+
' --endpoint Inference server base URL (default: http://localhost:8000)',
|
|
44
|
+
' --model Model ID (default: qwen3.6-27b-q4km)',
|
|
45
|
+
' --context Context window in tokens (default: 102400)',
|
|
46
|
+
'',
|
|
47
|
+
].join('\n'));
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const cfg = {
|
|
52
|
+
endpoint : args.endpoint || DEFAULTS.endpoint,
|
|
53
|
+
key : args.key || DEFAULTS.key,
|
|
54
|
+
model : args.model || DEFAULTS.model,
|
|
55
|
+
context : parseInt(args.context || String(DEFAULTS.context), 10),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Read existing .vscode/settings.json (preserve unrelated keys)
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
const vscodeDir = path.join(process.cwd(), '.vscode');
|
|
62
|
+
const settingsPath = path.join(vscodeDir, 'settings.json');
|
|
63
|
+
|
|
64
|
+
let existing = {};
|
|
65
|
+
if (fs.existsSync(settingsPath)) {
|
|
66
|
+
try {
|
|
67
|
+
existing = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
68
|
+
} catch (_) {
|
|
69
|
+
console.error('Warning: could not parse existing .vscode/settings.json — Cline keys will be merged in.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Merge only cline.* keys
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
const merged = {
|
|
77
|
+
...existing,
|
|
78
|
+
'cline.apiProvider' : 'openai',
|
|
79
|
+
'cline.openAiBaseUrl' : cfg.endpoint,
|
|
80
|
+
'cline.openAiApiKey' : cfg.key,
|
|
81
|
+
'cline.openAiModelId' : cfg.model,
|
|
82
|
+
'cline.contextWindow' : cfg.context,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
fs.mkdirSync(vscodeDir, { recursive: true });
|
|
86
|
+
fs.writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + '\n');
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Warn if .vscode/settings.json is not gitignored (contains the API key)
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
const gitignorePath = path.join(process.cwd(), '.gitignore');
|
|
92
|
+
let gitignored = false;
|
|
93
|
+
if (fs.existsSync(gitignorePath)) {
|
|
94
|
+
const gi = fs.readFileSync(gitignorePath, 'utf8');
|
|
95
|
+
gitignored = gi.split('\n').some(l => l.trim() === '.vscode/settings.json' || l.trim() === '.vscode/');
|
|
96
|
+
}
|
|
97
|
+
if (!gitignored && cfg.key !== 'none') {
|
|
98
|
+
console.warn('\nWarning: .vscode/settings.json contains your API key.');
|
|
99
|
+
console.warn('Add it to .gitignore to avoid committing it:\n');
|
|
100
|
+
console.warn(' echo ".vscode/settings.json" >> .gitignore\n');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Done
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
console.log('Forge AI configured for Cline.');
|
|
107
|
+
console.log(' Endpoint : ' + cfg.endpoint);
|
|
108
|
+
console.log(' Model : ' + cfg.model);
|
|
109
|
+
console.log(' Context : ' + cfg.context.toLocaleString() + ' tokens');
|
|
110
|
+
console.log(' File : .vscode/settings.json');
|
|
111
|
+
console.log('');
|
|
112
|
+
console.log('Reload VS Code window to apply (Cmd+Shift+P -> "Reload Window").');
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "forge-setup",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Configure Cline for Forge AI — zero-clone setup for any project",
|
|
5
|
+
"bin": {
|
|
6
|
+
"forge-setup": "./bin/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cline",
|
|
16
|
+
"ai",
|
|
17
|
+
"coding-assistant",
|
|
18
|
+
"forge"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT"
|
|
21
|
+
}
|