nubase_cli 0.1.4 → 0.1.7
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 +47 -8
- package/dist/src/auth-config.d.ts +2 -0
- package/dist/src/auth-config.js +6 -0
- package/dist/src/authorize.d.ts +1 -0
- package/dist/src/authorize.js +7 -2
- package/dist/src/config.js +2 -2
- package/dist/src/index.js +19 -2
- package/dist/src/install-skills.d.ts +11 -0
- package/dist/src/install-skills.js +196 -11
- package/package.json +1 -1
- package/skills/nubase/SKILL.md +26 -8
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ Installing skills starts a one-time browser authorization session and prints an
|
|
|
16
16
|
npx -y nubase_cli@latest install-skills
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Open the printed URL, sign in to Studio, choose a project, and approve. The URL includes a per-session UUID and points back to the temporary localhost callback started by the install command. After approval, the CLI writes
|
|
19
|
+
This installs the bundled Claude/Codex skills into your user skill directories, writes a local project MCP bridge under `.nubase/mcp-bridge`, writes project MCP config for Claude Code, and starts browser authorization. Open the printed URL, sign in to Studio, choose a project, and approve. The URL includes a per-session UUID and points back to the temporary localhost callback started by the install command. After approval, the CLI writes project-local `.nubase/config.json` and closes the localhost callback server.
|
|
20
|
+
|
|
21
|
+
Restart Claude Code in the project after installing, then run `/mcp` and confirm `nubase` is connected.
|
|
20
22
|
|
|
21
23
|
For automation, skip the prompt:
|
|
22
24
|
|
|
@@ -24,6 +26,18 @@ For automation, skip the prompt:
|
|
|
24
26
|
npx -y nubase_cli@latest install-skills --no-authorize
|
|
25
27
|
```
|
|
26
28
|
|
|
29
|
+
To install project-local skill files instead of user-level skill files:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx -y nubase_cli@latest install-skills --skills-scope project
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To skip MCP config registration:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx -y nubase_cli@latest install-skills --no-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
27
41
|
You can also start a standalone authorization session:
|
|
28
42
|
|
|
29
43
|
```bash
|
|
@@ -55,10 +69,12 @@ node packages/mcp-bridge/dist/src/index.js
|
|
|
55
69
|
{
|
|
56
70
|
"mcpServers": {
|
|
57
71
|
"nubase": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
72
|
+
"type": "stdio",
|
|
73
|
+
"command": "node",
|
|
74
|
+
"args": ["/absolute/project/path/.nubase/mcp-bridge/dist/src/index.js"],
|
|
60
75
|
"env": {
|
|
61
|
-
"NUBASE_AGENT_ID": "claude-code"
|
|
76
|
+
"NUBASE_AGENT_ID": "claude-code",
|
|
77
|
+
"NUBASE_CONFIG": "/absolute/project/path/.nubase/config.json"
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
}
|
|
@@ -69,7 +85,7 @@ You may still set `NUBASE_URL` and `NUBASE_PROJECT_KEY` explicitly. Environment
|
|
|
69
85
|
|
|
70
86
|
## Install Agent Skills
|
|
71
87
|
|
|
72
|
-
Install the bundled Nubase skills
|
|
88
|
+
Install the bundled Nubase skills and project MCP config:
|
|
73
89
|
|
|
74
90
|
```bash
|
|
75
91
|
npx -y nubase_cli@latest install-skills
|
|
@@ -77,9 +93,31 @@ npx -y nubase_cli@latest install-skills
|
|
|
77
93
|
|
|
78
94
|
Targets:
|
|
79
95
|
|
|
80
|
-
- `claude`:
|
|
81
|
-
- `codex`:
|
|
82
|
-
- `both`:
|
|
96
|
+
- `claude`: installs `~/.claude/skills/nubase/**`
|
|
97
|
+
- `codex`: installs `~/.codex/skills/nubase/**`
|
|
98
|
+
- `both`: installs both
|
|
99
|
+
|
|
100
|
+
Use `--skills-scope project` to write `.claude/skills/nubase/**` and `.codex/skills/nubase/**` in the current project instead.
|
|
101
|
+
|
|
102
|
+
By default, when the target includes `claude`, the command also copies the local MCP bridge to `.nubase/mcp-bridge` and creates or merges project `.mcp.json`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"nubase": {
|
|
108
|
+
"type": "stdio",
|
|
109
|
+
"command": "node",
|
|
110
|
+
"args": ["/absolute/project/path/.nubase/mcp-bridge/dist/src/index.js"],
|
|
111
|
+
"env": {
|
|
112
|
+
"NUBASE_AGENT_ID": "claude-code",
|
|
113
|
+
"NUBASE_CONFIG": "/absolute/project/path/.nubase/config.json"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Use `--mcp both` to also write project `.codex/config.toml` for Codex. Use `--no-mcp` to skip MCP config.
|
|
83
121
|
|
|
84
122
|
Installed structure:
|
|
85
123
|
|
|
@@ -99,6 +137,7 @@ The bridge injects user and session context from environment variables:
|
|
|
99
137
|
```bash
|
|
100
138
|
NUBASE_URL=https://nubase.ai
|
|
101
139
|
NUBASE_PROJECT_KEY=YOUR_NUBASE_PROJECT_KEY
|
|
140
|
+
NUBASE_CONFIG=.nubase/config.json
|
|
102
141
|
NUBASE_USER_JWT=USER_ACCESS_TOKEN
|
|
103
142
|
NUBASE_USER_ID=USER_UUID
|
|
104
143
|
NUBASE_AGENT_ID=codex
|
|
@@ -8,6 +8,8 @@ export interface StoredAuthConfig {
|
|
|
8
8
|
savedAt: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function defaultConfigPath(env?: NodeJS.ProcessEnv): string;
|
|
11
|
+
export declare function projectConfigPath(projectDir?: string): string;
|
|
12
|
+
export declare function legacyConfigPath(): string;
|
|
11
13
|
export declare function loadStoredAuthConfig(configPath?: string): Promise<{
|
|
12
14
|
nubaseUrl: string;
|
|
13
15
|
projectKey: string;
|
package/dist/src/auth-config.js
CHANGED
|
@@ -4,6 +4,12 @@ import path from 'node:path';
|
|
|
4
4
|
export function defaultConfigPath(env = process.env) {
|
|
5
5
|
if (env.NUBASE_CONFIG)
|
|
6
6
|
return env.NUBASE_CONFIG;
|
|
7
|
+
return projectConfigPath();
|
|
8
|
+
}
|
|
9
|
+
export function projectConfigPath(projectDir = process.cwd()) {
|
|
10
|
+
return path.join(projectDir, '.nubase', 'config.json');
|
|
11
|
+
}
|
|
12
|
+
export function legacyConfigPath() {
|
|
7
13
|
return path.join(os.homedir(), '.nubase', 'config.json');
|
|
8
14
|
}
|
|
9
15
|
export async function loadStoredAuthConfig(configPath = defaultConfigPath()) {
|
package/dist/src/authorize.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface AuthorizeOptions {
|
|
|
6
6
|
openBrowser: boolean;
|
|
7
7
|
timeoutMs: number;
|
|
8
8
|
promptOnly: boolean;
|
|
9
|
+
configPath: string;
|
|
9
10
|
}
|
|
10
11
|
export declare function parseAuthorizeArgs(argv: string[], env?: NodeJS.ProcessEnv): AuthorizeOptions;
|
|
11
12
|
export declare function authorize(options: AuthorizeOptions): Promise<StoredAuthConfig>;
|
package/dist/src/authorize.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { saveStoredAuthConfig } from './auth-config.js';
|
|
4
|
+
import { defaultConfigPath, saveStoredAuthConfig } from './auth-config.js';
|
|
5
5
|
import { DEFAULT_NUBASE_URL } from './config.js';
|
|
6
6
|
const DEFAULT_STUDIO_URL = 'https://nubase.ai/studio';
|
|
7
7
|
export function parseAuthorizeArgs(argv, env = process.env) {
|
|
@@ -12,6 +12,7 @@ export function parseAuthorizeArgs(argv, env = process.env) {
|
|
|
12
12
|
openBrowser: true,
|
|
13
13
|
timeoutMs: 5 * 60 * 1000,
|
|
14
14
|
promptOnly: false,
|
|
15
|
+
configPath: defaultConfigPath(env),
|
|
15
16
|
};
|
|
16
17
|
for (let i = 0; i < argv.length; i += 1) {
|
|
17
18
|
const arg = argv[i];
|
|
@@ -24,6 +25,9 @@ export function parseAuthorizeArgs(argv, env = process.env) {
|
|
|
24
25
|
else if (arg === '--agent-id') {
|
|
25
26
|
options.agentId = requiredValue(argv, ++i, arg);
|
|
26
27
|
}
|
|
28
|
+
else if (arg === '--config') {
|
|
29
|
+
options.configPath = requiredValue(argv, ++i, arg);
|
|
30
|
+
}
|
|
27
31
|
else if (arg === '--timeout-seconds') {
|
|
28
32
|
const seconds = Number(requiredValue(argv, ++i, arg));
|
|
29
33
|
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
@@ -93,7 +97,7 @@ async function startAuthorization(options) {
|
|
|
93
97
|
if (req.method === 'POST' && req.url === '/callback') {
|
|
94
98
|
const payload = await readJson(req);
|
|
95
99
|
const config = validateCallbackPayload(payload, state, options.nubaseUrl);
|
|
96
|
-
const saved = await saveStoredAuthConfig(config);
|
|
100
|
+
const saved = await saveStoredAuthConfig(config, options.configPath);
|
|
97
101
|
sendJson(res, 200, { ok: true });
|
|
98
102
|
cleanup();
|
|
99
103
|
resolve(saved);
|
|
@@ -175,6 +179,7 @@ function corsHeaders() {
|
|
|
175
179
|
'Access-Control-Allow-Origin': '*',
|
|
176
180
|
'Access-Control-Allow-Methods': 'GET,POST,OPTIONS',
|
|
177
181
|
'Access-Control-Allow-Headers': 'Content-Type',
|
|
182
|
+
'Access-Control-Allow-Private-Network': 'true',
|
|
178
183
|
'Access-Control-Max-Age': '600',
|
|
179
184
|
};
|
|
180
185
|
}
|
package/dist/src/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultConfigPath, loadStoredAuthConfig } from './auth-config.js';
|
|
1
|
+
import { defaultConfigPath, legacyConfigPath, loadStoredAuthConfig } from './auth-config.js';
|
|
2
2
|
export const DEFAULT_NUBASE_URL = 'https://nubase.ai';
|
|
3
3
|
export function loadConfig(env = process.env) {
|
|
4
4
|
const nubaseUrl = stripTrailingSlash(env.NUBASE_URL || DEFAULT_NUBASE_URL);
|
|
@@ -21,7 +21,7 @@ export async function loadConfigAsync(env = process.env) {
|
|
|
21
21
|
const config = loadConfig(env);
|
|
22
22
|
if (config.projectKey)
|
|
23
23
|
return config;
|
|
24
|
-
const stored = await loadStoredAuthConfig(defaultConfigPath(env));
|
|
24
|
+
const stored = await loadStoredAuthConfig(defaultConfigPath(env)) ?? (env.NUBASE_CONFIG ? null : await loadStoredAuthConfig(legacyConfigPath()));
|
|
25
25
|
if (!stored)
|
|
26
26
|
return config;
|
|
27
27
|
return {
|
package/dist/src/index.js
CHANGED
|
@@ -6,12 +6,26 @@ import { installSkills, parseInstallArgs } from './install-skills.js';
|
|
|
6
6
|
import { McpStdioServer } from './mcp-stdio.js';
|
|
7
7
|
import { NubaseClient } from './nubase-client.js';
|
|
8
8
|
import { callTool, TOOLS } from './tools.js';
|
|
9
|
-
const CLI_VERSION = '0.1.
|
|
9
|
+
const CLI_VERSION = '0.1.7';
|
|
10
10
|
if (process.argv[2] === 'install-skills') {
|
|
11
11
|
const options = parseInstallArgs(process.argv.slice(3));
|
|
12
12
|
const installed = await installSkills(options);
|
|
13
13
|
for (const file of installed) {
|
|
14
|
-
|
|
14
|
+
if (file.endsWith('.mcp.json')) {
|
|
15
|
+
console.error(`Registered Nubase MCP server config: ${file}`);
|
|
16
|
+
}
|
|
17
|
+
else if (file.endsWith('.codex/config.toml')) {
|
|
18
|
+
console.error(`Registered Nubase Codex MCP config: ${file}`);
|
|
19
|
+
}
|
|
20
|
+
else if (file.endsWith('.gitignore')) {
|
|
21
|
+
console.error(`Ensured Nubase local config is ignored by git: ${file}`);
|
|
22
|
+
}
|
|
23
|
+
else if (file.includes(`${defaultPathSep()}.nubase${defaultPathSep()}mcp-bridge${defaultPathSep()}`)) {
|
|
24
|
+
console.error(`Installed Nubase local MCP bridge: ${file}`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.error(`Installed Nubase skill: ${file}`);
|
|
28
|
+
}
|
|
15
29
|
}
|
|
16
30
|
if (options.authorize) {
|
|
17
31
|
console.error('');
|
|
@@ -69,3 +83,6 @@ const server = new McpStdioServer(async (request) => {
|
|
|
69
83
|
}
|
|
70
84
|
});
|
|
71
85
|
server.start();
|
|
86
|
+
function defaultPathSep() {
|
|
87
|
+
return process.platform === 'win32' ? '\\' : '/';
|
|
88
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export type SkillTarget = 'claude' | 'codex' | 'both';
|
|
2
|
+
export type SkillInstallScope = 'user' | 'project';
|
|
3
|
+
export type McpInstallTarget = 'none' | 'claude' | 'codex' | 'both';
|
|
2
4
|
export interface InstallSkillsOptions {
|
|
3
5
|
target: SkillTarget;
|
|
4
6
|
projectDir: string;
|
|
5
7
|
authorize?: boolean;
|
|
6
8
|
authArgs?: string[];
|
|
9
|
+
skills?: boolean;
|
|
10
|
+
skillsScope?: SkillInstallScope;
|
|
11
|
+
mcp?: McpInstallTarget;
|
|
12
|
+
configPath?: string;
|
|
13
|
+
homeDir?: string;
|
|
7
14
|
}
|
|
8
15
|
export declare function installSkills(options: InstallSkillsOptions): Promise<string[]>;
|
|
9
16
|
export declare function parseInstallArgs(argv: string[]): {
|
|
@@ -11,4 +18,8 @@ export declare function parseInstallArgs(argv: string[]): {
|
|
|
11
18
|
projectDir: string;
|
|
12
19
|
authorize: boolean;
|
|
13
20
|
authArgs: string[];
|
|
21
|
+
skills: boolean;
|
|
22
|
+
skillsScope: SkillInstallScope;
|
|
23
|
+
mcp: McpInstallTarget;
|
|
24
|
+
configPath: string;
|
|
14
25
|
};
|
|
@@ -1,24 +1,46 @@
|
|
|
1
|
-
import { cp, mkdir } from 'node:fs/promises';
|
|
1
|
+
import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { projectConfigPath } from './auth-config.js';
|
|
4
6
|
export async function installSkills(options) {
|
|
5
7
|
const skillDir = bundledSkillDir();
|
|
6
8
|
const targets = options.target === 'both' ? ['claude', 'codex'] : [options.target];
|
|
7
9
|
const installed = [];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const skillsScope = options.skillsScope ?? 'user';
|
|
11
|
+
const configPath = path.resolve(options.configPath ?? projectConfigPath(options.projectDir));
|
|
12
|
+
const homeDir = options.homeDir ?? os.homedir();
|
|
13
|
+
if (options.skills !== false) {
|
|
14
|
+
for (const target of targets) {
|
|
15
|
+
const destDir = skillDestDir(target, skillsScope, options.projectDir, homeDir);
|
|
16
|
+
await mkdir(path.dirname(destDir), { recursive: true });
|
|
17
|
+
await cp(skillDir, destDir, { recursive: true, force: true });
|
|
18
|
+
installed.push(path.join(destDir, 'SKILL.md'));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const mcpTargets = resolveMcpTargets(options.mcp ?? 'claude', targets);
|
|
22
|
+
let mcpCommand = null;
|
|
23
|
+
if (mcpTargets.length > 0) {
|
|
24
|
+
mcpCommand = await installProjectMcpBridge(options.projectDir);
|
|
25
|
+
installed.push(mcpCommand.entrypoint);
|
|
26
|
+
}
|
|
27
|
+
if (mcpTargets.includes('claude')) {
|
|
28
|
+
installed.push(await installClaudeMcpConfig(options.projectDir, configPath, mcpCommand));
|
|
15
29
|
}
|
|
30
|
+
if (mcpTargets.includes('codex')) {
|
|
31
|
+
installed.push(await installCodexMcpConfig(options.projectDir, configPath, mcpCommand));
|
|
32
|
+
}
|
|
33
|
+
installed.push(await ensureProjectGitignore(options.projectDir));
|
|
16
34
|
return installed;
|
|
17
35
|
}
|
|
18
36
|
export function parseInstallArgs(argv) {
|
|
19
37
|
let target = 'both';
|
|
20
38
|
let projectDir = process.cwd();
|
|
21
39
|
let authorize = true;
|
|
40
|
+
let skills = true;
|
|
41
|
+
let skillsScope = 'user';
|
|
42
|
+
let mcp = 'claude';
|
|
43
|
+
let configPath;
|
|
22
44
|
const authArgs = ['--prompt-only'];
|
|
23
45
|
for (let i = 0; i < argv.length; i += 1) {
|
|
24
46
|
const arg = argv[i];
|
|
@@ -38,17 +60,180 @@ export function parseInstallArgs(argv) {
|
|
|
38
60
|
else if (arg === '--no-authorize') {
|
|
39
61
|
authorize = false;
|
|
40
62
|
}
|
|
63
|
+
else if (arg === '--no-skills') {
|
|
64
|
+
skills = false;
|
|
65
|
+
}
|
|
66
|
+
else if (arg === '--no-mcp-config') {
|
|
67
|
+
mcp = 'none';
|
|
68
|
+
}
|
|
69
|
+
else if (arg === '--no-mcp') {
|
|
70
|
+
mcp = 'none';
|
|
71
|
+
}
|
|
72
|
+
else if (arg === '--mcp') {
|
|
73
|
+
const value = argv[++i];
|
|
74
|
+
if (value !== 'none' && value !== 'claude' && value !== 'codex' && value !== 'both') {
|
|
75
|
+
throw new Error('--mcp must be none, claude, codex, or both');
|
|
76
|
+
}
|
|
77
|
+
mcp = value;
|
|
78
|
+
}
|
|
79
|
+
else if (arg === '--skills-scope') {
|
|
80
|
+
const value = argv[++i];
|
|
81
|
+
if (value !== 'user' && value !== 'project') {
|
|
82
|
+
throw new Error('--skills-scope must be user or project');
|
|
83
|
+
}
|
|
84
|
+
skillsScope = value;
|
|
85
|
+
}
|
|
86
|
+
else if (arg === '--config') {
|
|
87
|
+
const value = argv[++i];
|
|
88
|
+
if (!value)
|
|
89
|
+
throw new Error('--config requires a value');
|
|
90
|
+
configPath = path.resolve(projectDir, value);
|
|
91
|
+
}
|
|
41
92
|
else if (arg === '--studio-url' || arg === '--nubase-url' || arg === '--agent-id' || arg === '--timeout-seconds') {
|
|
42
93
|
const value = argv[++i];
|
|
43
94
|
if (!value)
|
|
44
95
|
throw new Error(`${arg} requires a value`);
|
|
45
96
|
authArgs.push(arg, value);
|
|
46
97
|
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error(`Unknown install-skills option: ${arg}`);
|
|
100
|
+
}
|
|
47
101
|
}
|
|
48
|
-
|
|
102
|
+
configPath = configPath ?? projectConfigPath(projectDir);
|
|
103
|
+
authArgs.push('--config', configPath);
|
|
104
|
+
return { target, projectDir, authorize, authArgs, skills, skillsScope, mcp, configPath };
|
|
49
105
|
}
|
|
50
106
|
function bundledSkillDir() {
|
|
107
|
+
return path.join(bundledPackageRoot(), 'skills', 'nubase');
|
|
108
|
+
}
|
|
109
|
+
function bundledPackageRoot() {
|
|
51
110
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
52
|
-
|
|
53
|
-
|
|
111
|
+
return path.resolve(here, '..', '..');
|
|
112
|
+
}
|
|
113
|
+
function skillDestDir(target, scope, projectDir, homeDir) {
|
|
114
|
+
if (scope === 'project') {
|
|
115
|
+
return target === 'claude'
|
|
116
|
+
? path.join(projectDir, '.claude', 'skills', 'nubase')
|
|
117
|
+
: path.join(projectDir, '.codex', 'skills', 'nubase');
|
|
118
|
+
}
|
|
119
|
+
return target === 'claude'
|
|
120
|
+
? path.join(homeDir, '.claude', 'skills', 'nubase')
|
|
121
|
+
: path.join(homeDir, '.codex', 'skills', 'nubase');
|
|
122
|
+
}
|
|
123
|
+
function resolveMcpTargets(mcp, skillTargets) {
|
|
124
|
+
if (mcp === 'none')
|
|
125
|
+
return [];
|
|
126
|
+
const requested = mcp === 'both' ? ['claude', 'codex'] : [mcp];
|
|
127
|
+
return requested.filter((target) => skillTargets.includes(target));
|
|
128
|
+
}
|
|
129
|
+
async function installProjectMcpBridge(projectDir) {
|
|
130
|
+
const packageRoot = bundledPackageRoot();
|
|
131
|
+
const destRoot = path.join(projectDir, '.nubase', 'mcp-bridge');
|
|
132
|
+
await rm(destRoot, { recursive: true, force: true });
|
|
133
|
+
await mkdir(destRoot, { recursive: true, mode: 0o700 });
|
|
134
|
+
await cp(path.join(packageRoot, 'dist', 'src'), path.join(destRoot, 'dist', 'src'), { recursive: true, force: true });
|
|
135
|
+
await cp(path.join(packageRoot, 'skills'), path.join(destRoot, 'skills'), { recursive: true, force: true });
|
|
136
|
+
await cp(path.join(packageRoot, 'package.json'), path.join(destRoot, 'package.json'), { force: true });
|
|
137
|
+
const entrypoint = path.join(destRoot, 'dist', 'src', 'index.js');
|
|
138
|
+
return {
|
|
139
|
+
command: 'node',
|
|
140
|
+
args: [entrypoint],
|
|
141
|
+
entrypoint,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function installClaudeMcpConfig(projectDir, nubaseConfigPath, mcpCommand) {
|
|
145
|
+
const mcpConfigPath = path.join(projectDir, '.mcp.json');
|
|
146
|
+
const config = await readProjectMcpConfig(mcpConfigPath);
|
|
147
|
+
config.mcpServers = {
|
|
148
|
+
...(config.mcpServers ?? {}),
|
|
149
|
+
nubase: {
|
|
150
|
+
type: 'stdio',
|
|
151
|
+
command: mcpCommand?.command ?? 'npx',
|
|
152
|
+
args: mcpCommand?.args ?? ['-y', 'nubase_cli@latest'],
|
|
153
|
+
env: {
|
|
154
|
+
NUBASE_AGENT_ID: 'claude-code',
|
|
155
|
+
NUBASE_CONFIG: nubaseConfigPath,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
await writeFile(mcpConfigPath, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
160
|
+
return mcpConfigPath;
|
|
161
|
+
}
|
|
162
|
+
async function installCodexMcpConfig(projectDir, nubaseConfigPath, mcpCommand) {
|
|
163
|
+
const configPath = path.join(projectDir, '.codex', 'config.toml');
|
|
164
|
+
await mkdir(path.dirname(configPath), { recursive: true });
|
|
165
|
+
const existing = await readTextIfExists(configPath);
|
|
166
|
+
const block = codexMcpBlock(nubaseConfigPath, mcpCommand);
|
|
167
|
+
const next = upsertCodexMcpBlock(existing, block);
|
|
168
|
+
await writeFile(configPath, next, 'utf8');
|
|
169
|
+
return configPath;
|
|
170
|
+
}
|
|
171
|
+
async function ensureProjectGitignore(projectDir) {
|
|
172
|
+
const gitignorePath = path.join(projectDir, '.gitignore');
|
|
173
|
+
const existing = await readTextIfExists(gitignorePath);
|
|
174
|
+
const lines = existing.split(/\r?\n/);
|
|
175
|
+
if (!lines.includes('.nubase/')) {
|
|
176
|
+
const next = `${existing.trimEnd()}${existing.trimEnd() ? '\n' : ''}.nubase/\n`;
|
|
177
|
+
await writeFile(gitignorePath, next, 'utf8');
|
|
178
|
+
}
|
|
179
|
+
return gitignorePath;
|
|
180
|
+
}
|
|
181
|
+
async function readTextIfExists(filePath) {
|
|
182
|
+
try {
|
|
183
|
+
return await readFile(filePath, 'utf8');
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
if (err.code === 'ENOENT')
|
|
187
|
+
return '';
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function codexMcpBlock(configPath, mcpCommand) {
|
|
192
|
+
const command = mcpCommand?.command ?? 'npx';
|
|
193
|
+
const args = mcpCommand?.args ?? ['-y', 'nubase_cli@latest'];
|
|
194
|
+
return [
|
|
195
|
+
'[mcp_servers.nubase]',
|
|
196
|
+
'type = "stdio"',
|
|
197
|
+
`command = "${escapeTomlString(command)}"`,
|
|
198
|
+
`args = [${args.map((arg) => `"${escapeTomlString(arg)}"`).join(', ')}]`,
|
|
199
|
+
'startup_timeout_sec = 30',
|
|
200
|
+
'',
|
|
201
|
+
'[mcp_servers.nubase.env]',
|
|
202
|
+
'NUBASE_AGENT_ID = "codex"',
|
|
203
|
+
`NUBASE_CONFIG = "${escapeTomlString(configPath)}"`,
|
|
204
|
+
'',
|
|
205
|
+
].join('\n');
|
|
206
|
+
}
|
|
207
|
+
function upsertCodexMcpBlock(existing, block) {
|
|
208
|
+
const pattern = /(?:^|\n)\[mcp_servers\.nubase\][\s\S]*?(?=\n\[mcp_servers\.(?!nubase(?:\.env)?\b)|\n\[[^\]]+\]|\s*$)/;
|
|
209
|
+
const trimmedBlock = `\n${block.trimEnd()}\n`;
|
|
210
|
+
if (pattern.test(existing)) {
|
|
211
|
+
return existing.replace(pattern, trimmedBlock).replace(/^\n/, '');
|
|
212
|
+
}
|
|
213
|
+
const prefix = existing.trimEnd();
|
|
214
|
+
return `${prefix}${prefix ? '\n\n' : ''}${block}`;
|
|
215
|
+
}
|
|
216
|
+
function escapeTomlString(value) {
|
|
217
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
218
|
+
}
|
|
219
|
+
async function readProjectMcpConfig(configPath) {
|
|
220
|
+
try {
|
|
221
|
+
const raw = await readFile(configPath, 'utf8');
|
|
222
|
+
const parsed = JSON.parse(raw);
|
|
223
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
224
|
+
throw new Error('.mcp.json must contain a JSON object');
|
|
225
|
+
}
|
|
226
|
+
if (parsed.mcpServers !== undefined && (!parsed.mcpServers || typeof parsed.mcpServers !== 'object' || Array.isArray(parsed.mcpServers))) {
|
|
227
|
+
throw new Error('.mcp.json mcpServers must be a JSON object');
|
|
228
|
+
}
|
|
229
|
+
return parsed;
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
if (err.code === 'ENOENT')
|
|
233
|
+
return {};
|
|
234
|
+
if (err instanceof SyntaxError) {
|
|
235
|
+
throw new Error(`Could not parse ${configPath}: ${err.message}`);
|
|
236
|
+
}
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
54
239
|
}
|
package/package.json
CHANGED
package/skills/nubase/SKILL.md
CHANGED
|
@@ -56,28 +56,46 @@ If a tool is unavailable, continue with REST/API guidance and tell the user what
|
|
|
56
56
|
|
|
57
57
|
## Setup
|
|
58
58
|
|
|
59
|
-
Install MCP
|
|
59
|
+
Install the Nubase skills and project MCP config:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx -y nubase_cli@latest install-skills
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
By default this writes:
|
|
66
|
+
|
|
67
|
+
- `~/.claude/skills/nubase/**`
|
|
68
|
+
- `~/.codex/skills/nubase/**`
|
|
69
|
+
- project `.mcp.json` with a `nubase` stdio MCP server for Claude Code
|
|
70
|
+
- project `.nubase/mcp-bridge/**` local MCP bridge runtime, so agent startup does not depend on `npx @latest`
|
|
71
|
+
- project `.nubase/config.json` after browser authorization
|
|
72
|
+
|
|
73
|
+
After installing, restart Claude Code in the project and run `/mcp`. The `nubase` server must be connected before this skill can call `nubase_overview`, `memory_context`, or other MCP tools.
|
|
74
|
+
|
|
75
|
+
Expected `.mcp.json` shape:
|
|
60
76
|
|
|
61
77
|
```json
|
|
62
78
|
{
|
|
63
79
|
"mcpServers": {
|
|
64
80
|
"nubase": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
81
|
+
"type": "stdio",
|
|
82
|
+
"command": "node",
|
|
83
|
+
"args": ["/absolute/project/path/.nubase/mcp-bridge/dist/src/index.js"],
|
|
67
84
|
"env": {
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"NUBASE_AGENT_ID": "codex"
|
|
85
|
+
"NUBASE_AGENT_ID": "claude-code",
|
|
86
|
+
"NUBASE_CONFIG": "/absolute/project/path/.nubase/config.json"
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
91
|
```
|
|
76
92
|
|
|
77
|
-
|
|
93
|
+
If `NUBASE_PROJECT_KEY` is not set, `nubase_cli` reads the browser authorization saved at the project `NUBASE_CONFIG` path.
|
|
94
|
+
|
|
95
|
+
To install project-local skill files instead of user-level skill files:
|
|
78
96
|
|
|
79
97
|
```bash
|
|
80
|
-
npx nubase_cli install-skills --
|
|
98
|
+
npx -y nubase_cli@latest install-skills --skills-scope project
|
|
81
99
|
```
|
|
82
100
|
|
|
83
101
|
This installs one Nubase skill directory containing:
|