@octen.ai/cli 0.1.7 → 0.1.8
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 +6 -2
- package/dist/commands/configureMcp.d.ts +2 -0
- package/dist/commands/configureMcp.js +32 -4
- package/dist/commands/configureSkills.d.ts +2 -0
- package/dist/commands/configureSkills.js +32 -4
- package/dist/util/detectClient.d.ts +16 -0
- package/dist/util/detectClient.js +57 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,7 +123,9 @@ octen configure-mcp --all --pin 0.2.1
|
|
|
123
123
|
|
|
124
124
|
Supported clients: Claude Code, Claude Desktop, Cursor, Windsurf, VS Code, Codex.
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
Only clients detected as installed are configured; `--all` skips the rest, and an explicitly-named client that isn't detected is skipped unless you pass `--force`.
|
|
127
|
+
|
|
128
|
+
Options: `--all`, `--claude-code`, `--cursor`, `--claude-desktop`, `--windsurf`, `--vscode`, `--codex`, `--scope` (user|project), `--pin <version>`, `--force` (configure even if the client is not detected).
|
|
127
129
|
|
|
128
130
|
Run without flags to print current status for each client.
|
|
129
131
|
|
|
@@ -151,7 +153,9 @@ Supported clients: Claude Code, Cursor, Codex, OpenClaw, Hermes.
|
|
|
151
153
|
|
|
152
154
|
`--set-key` also writes OCTEN_API_KEY into the client's env config (Claude Code `~/.claude/settings.json`, Codex `config.toml`, OpenClaw `.env`); Cursor/Hermes print a shell-profile hint. The key comes from `--api-key` or the `OCTEN_API_KEY` environment variable.
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
Only clients detected as installed are configured; `--all` skips the rest, and an explicitly-named client that isn't detected is skipped unless you pass `--force`.
|
|
157
|
+
|
|
158
|
+
Options: `--all`, `--claude-code`, `--cursor`, `--codex`, `--openclaw`, `--hermes`, `--scope` (user|project), `--ref <ref>` (default: main), `--bundled`/`--offline` (use vendored skills), `--only <names>` (comma-separated skill names), `--skills-dir <path>` (custom source directory), `--set-key` (write OCTEN_API_KEY into the client's env config), `--force` (configure even if the client is not detected).
|
|
155
159
|
|
|
156
160
|
Run without flags to show installed skills per client.
|
|
157
161
|
|
|
@@ -6,6 +6,8 @@ interface ConfigureMcpInternalOpts {
|
|
|
6
6
|
cwd?: string;
|
|
7
7
|
/** Override claude CLI detection (for testing) */
|
|
8
8
|
hasClaudeCli?: boolean;
|
|
9
|
+
/** Override client-installed detection (for testing) */
|
|
10
|
+
isInstalled?: (id: string) => boolean;
|
|
9
11
|
}
|
|
10
12
|
export declare function registerConfigureMcp(program: Command, internal?: ConfigureMcpInternalOpts): void;
|
|
11
13
|
export {};
|
|
@@ -4,6 +4,7 @@ import { MCP_CLIENTS } from "../mcp/clients.js";
|
|
|
4
4
|
import { installMcp } from "../mcp/install.js";
|
|
5
5
|
import { mcpStatus } from "../mcp/detect.js";
|
|
6
6
|
import { resolveApiKey } from "../config/resolve.js";
|
|
7
|
+
import { isClientInstalled } from "../util/detectClient.js";
|
|
7
8
|
// Exported so tests can call with injected dirs
|
|
8
9
|
export function registerConfigureMcp(program, internal = {}) {
|
|
9
10
|
program
|
|
@@ -18,6 +19,7 @@ export function registerConfigureMcp(program, internal = {}) {
|
|
|
18
19
|
.option("--codex", "configure Codex")
|
|
19
20
|
.option("--scope <s>", "config scope: user | project (default: user)", "user")
|
|
20
21
|
.option("--pin <ver>", "pin octen-mcp to a specific version, e.g. 0.2.1")
|
|
22
|
+
.option("--force", "configure even if the client is not detected")
|
|
21
23
|
.action(async (_opts, command) => {
|
|
22
24
|
const g = command.optsWithGlobals();
|
|
23
25
|
const opts = command.opts();
|
|
@@ -42,6 +44,7 @@ export function registerConfigureMcp(program, internal = {}) {
|
|
|
42
44
|
// Determine the effective home/cwd
|
|
43
45
|
const home = internal.home ?? os.homedir();
|
|
44
46
|
const cwd = internal.cwd ?? process.cwd();
|
|
47
|
+
const isInstalled = internal.isInstalled ?? ((id) => isClientInstalled(id, { home }));
|
|
45
48
|
const installOpts = { hasClaudeCli: internal.hasClaudeCli };
|
|
46
49
|
// Determine selected clients
|
|
47
50
|
const clientFlagMap = {
|
|
@@ -67,13 +70,38 @@ export function registerConfigureMcp(program, internal = {}) {
|
|
|
67
70
|
}
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
|
-
// INSTALL MODE
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
// INSTALL MODE — determine which clients to act on, gated by detection.
|
|
74
|
+
let selected;
|
|
75
|
+
if (opts.all) {
|
|
76
|
+
// Start from the full registry, then filter to installed ones.
|
|
77
|
+
const skipped = [];
|
|
78
|
+
selected = MCP_CLIENTS.filter((c) => {
|
|
79
|
+
if (isInstalled(c.id))
|
|
80
|
+
return true;
|
|
81
|
+
skipped.push(c.label);
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
if (skipped.length > 0) {
|
|
85
|
+
process.stdout.write(`skipped (not installed): ${skipped.join(", ")}\n`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Explicit per-client flags: warn + skip not-installed unless --force.
|
|
90
|
+
const requested = MCP_CLIENTS.filter((c) => {
|
|
74
91
|
const flagName = clientFlagMap[c.id];
|
|
75
92
|
return flagName ? Boolean(opts[flagName]) : false;
|
|
76
93
|
});
|
|
94
|
+
selected = requested.filter((c) => {
|
|
95
|
+
if (opts.force || isInstalled(c.id))
|
|
96
|
+
return true;
|
|
97
|
+
process.stderr.write(`warning: ${c.label} not detected — skipping (use --force to configure anyway)\n`);
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (selected.length === 0) {
|
|
102
|
+
process.stdout.write("no installed clients to configure\n");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
77
105
|
let anyFailed = false;
|
|
78
106
|
for (const client of selected) {
|
|
79
107
|
try {
|
|
@@ -6,6 +6,8 @@ interface ConfigureSkillsInternalOpts {
|
|
|
6
6
|
cwd?: string;
|
|
7
7
|
/** Injected fetch implementation (for testing); defaults to global fetch */
|
|
8
8
|
fetchImpl?: typeof fetch;
|
|
9
|
+
/** Override client-installed detection (for testing) */
|
|
10
|
+
isInstalled?: (id: string) => boolean;
|
|
9
11
|
}
|
|
10
12
|
export declare function registerConfigureSkills(program: Command, internal?: ConfigureSkillsInternalOpts): void;
|
|
11
13
|
export {};
|
|
@@ -7,6 +7,7 @@ import { resolveSkillsDir } from "../skills/source.js";
|
|
|
7
7
|
import { installSkills, skillStatus } from "../skills/install.js";
|
|
8
8
|
import { setClientEnvKey } from "../skills/setkey.js";
|
|
9
9
|
import { OctenValidationError } from "../api/errors.js";
|
|
10
|
+
import { isClientInstalled } from "../util/detectClient.js";
|
|
10
11
|
// Exported so tests can call with injected dirs
|
|
11
12
|
export function registerConfigureSkills(program, internal = {}) {
|
|
12
13
|
program
|
|
@@ -25,6 +26,7 @@ export function registerConfigureSkills(program, internal = {}) {
|
|
|
25
26
|
.option("--bundled", "force use of bundled (vendored) skills — no network")
|
|
26
27
|
.option("--offline", "alias for --bundled")
|
|
27
28
|
.option("--set-key", "also write OCTEN_API_KEY into each selected client's env config")
|
|
29
|
+
.option("--force", "configure even if the client is not detected")
|
|
28
30
|
.action(async (_opts, command) => {
|
|
29
31
|
const opts = command.opts();
|
|
30
32
|
const scope = (opts.scope === "project" ? "project" : "user");
|
|
@@ -35,6 +37,7 @@ export function registerConfigureSkills(program, internal = {}) {
|
|
|
35
37
|
: undefined;
|
|
36
38
|
const home = internal.home ?? os.homedir();
|
|
37
39
|
const cwd = internal.cwd ?? process.cwd();
|
|
40
|
+
const isInstalled = internal.isInstalled ?? ((id) => isClientInstalled(id, { home }));
|
|
38
41
|
// Both dist/commands/ (published) and src/commands/ (tsx tests) are two levels below the
|
|
39
42
|
// package root, so ../../skills resolves to the package-root skills/ dir in both.
|
|
40
43
|
const bundledDir = fileURLToPath(new URL("../../skills", import.meta.url));
|
|
@@ -71,15 +74,40 @@ export function registerConfigureSkills(program, internal = {}) {
|
|
|
71
74
|
}
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
|
-
// INSTALL MODE
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// INSTALL MODE — determine which clients to act on, gated by detection.
|
|
78
|
+
let selected;
|
|
79
|
+
if (opts.all) {
|
|
80
|
+
// Start from the full registry, then filter to installed ones.
|
|
81
|
+
const skipped = [];
|
|
82
|
+
selected = SKILL_CLIENTS.filter((c) => {
|
|
83
|
+
if (isInstalled(c.id))
|
|
84
|
+
return true;
|
|
85
|
+
skipped.push(c.label);
|
|
86
|
+
return false;
|
|
87
|
+
});
|
|
88
|
+
if (skipped.length > 0) {
|
|
89
|
+
process.stdout.write(`skipped (not installed): ${skipped.join(", ")}\n`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Explicit per-client flags: warn + skip not-installed unless --force.
|
|
94
|
+
const requested = SKILL_CLIENTS.filter((c) => {
|
|
78
95
|
const flagName = clientFlagMap[c.id];
|
|
79
96
|
return flagName
|
|
80
97
|
? Boolean(opts[flagName])
|
|
81
98
|
: false;
|
|
82
99
|
});
|
|
100
|
+
selected = requested.filter((c) => {
|
|
101
|
+
if (opts.force || isInstalled(c.id))
|
|
102
|
+
return true;
|
|
103
|
+
process.stderr.write(`warning: ${c.label} not detected — skipping (use --force to configure anyway)\n`);
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (selected.length === 0) {
|
|
108
|
+
process.stdout.write("no installed clients to configure\n");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
83
111
|
// Resolve skills source (custom dir, or remote/bundled)
|
|
84
112
|
let srcDir;
|
|
85
113
|
let source;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DetectOpts {
|
|
2
|
+
/** Test injection: explicit installed map keyed by client id */
|
|
3
|
+
installed?: Record<string, boolean>;
|
|
4
|
+
/** Injected home dir (for testing); defaults to os.homedir() */
|
|
5
|
+
home?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Detect whether a given client is installed on this machine.
|
|
9
|
+
*
|
|
10
|
+
* Detection deliberately relies on the client's own binary, app bundle, or a
|
|
11
|
+
* config file the client itself creates — never on directories that octen-cli
|
|
12
|
+
* creates (e.g. ~/.cursor/skills), which would produce false positives.
|
|
13
|
+
*
|
|
14
|
+
* Unknown ids return true so we never block clients we don't have a signal for.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isClientInstalled(id: string, opts?: DetectOpts): boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
/** Returns true if `bin` is resolvable on PATH (via `which`). */
|
|
6
|
+
function binOnPath(bin) {
|
|
7
|
+
try {
|
|
8
|
+
execFileSync("which", [bin], { stdio: "ignore" });
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Returns true if a macOS app bundle named `<name>.app` exists in /Applications. */
|
|
16
|
+
function appExists(name) {
|
|
17
|
+
return existsSync(`/Applications/${name}.app`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Detect whether a given client is installed on this machine.
|
|
21
|
+
*
|
|
22
|
+
* Detection deliberately relies on the client's own binary, app bundle, or a
|
|
23
|
+
* config file the client itself creates — never on directories that octen-cli
|
|
24
|
+
* creates (e.g. ~/.cursor/skills), which would produce false positives.
|
|
25
|
+
*
|
|
26
|
+
* Unknown ids return true so we never block clients we don't have a signal for.
|
|
27
|
+
*/
|
|
28
|
+
export function isClientInstalled(id, opts) {
|
|
29
|
+
if (opts?.installed && Object.prototype.hasOwnProperty.call(opts.installed, id)) {
|
|
30
|
+
return opts.installed[id];
|
|
31
|
+
}
|
|
32
|
+
const home = opts?.home ?? os.homedir();
|
|
33
|
+
switch (id) {
|
|
34
|
+
case "claude-code":
|
|
35
|
+
return binOnPath("claude") || existsSync(join(home, ".claude.json"));
|
|
36
|
+
case "cursor":
|
|
37
|
+
return binOnPath("cursor") || appExists("Cursor");
|
|
38
|
+
case "codex":
|
|
39
|
+
return binOnPath("codex") || existsSync(join(home, ".codex/config.toml"));
|
|
40
|
+
case "openclaw":
|
|
41
|
+
return binOnPath("openclaw") || binOnPath("claw");
|
|
42
|
+
case "hermes":
|
|
43
|
+
return binOnPath("hermes");
|
|
44
|
+
case "claude-desktop":
|
|
45
|
+
return (appExists("Claude") ||
|
|
46
|
+
existsSync(join(home, "Library/Application Support/Claude")));
|
|
47
|
+
case "windsurf":
|
|
48
|
+
return (binOnPath("windsurf") ||
|
|
49
|
+
appExists("Windsurf") ||
|
|
50
|
+
existsSync(join(home, ".codeium/windsurf")));
|
|
51
|
+
case "vscode":
|
|
52
|
+
return binOnPath("code") || appExists("Visual Studio Code");
|
|
53
|
+
default:
|
|
54
|
+
// Unknown id — don't block.
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|