@thingd/cli 0.77.0 → 0.77.3
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/dist/commands/cloud.d.ts +3 -0
- package/dist/commands/cloud.d.ts.map +1 -0
- package/dist/commands/cloud.js +669 -0
- package/dist/commands/mcp-connect.d.ts +3 -0
- package/dist/commands/mcp-connect.d.ts.map +1 -0
- package/dist/commands/mcp-connect.js +154 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +197 -0
- package/dist/dashboard/public/assets/favicon-CgGFvG_0.svg +4 -0
- package/dist/dashboard/public/assets/index-C6PkDB7y.css +1 -0
- package/dist/dashboard/public/assets/index-DrpfyClj.js +4 -0
- package/dist/dashboard/public/index.html +19 -0
- package/dist/dashboard/server.d.ts +6 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +684 -0
- package/dist/data-movement.d.ts +6 -0
- package/dist/data-movement.d.ts.map +1 -0
- package/dist/data-movement.js +475 -0
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +108 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1446 -0
- package/dist/install.d.ts +3 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +229 -0
- package/dist/interactive.d.ts +2 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +3039 -0
- package/dist/lib/cloud-api.d.ts +143 -0
- package/dist/lib/cloud-api.d.ts.map +1 -0
- package/dist/lib/cloud-api.js +207 -0
- package/dist/lib/cloud-config.d.ts +33 -0
- package/dist/lib/cloud-config.d.ts.map +1 -0
- package/dist/lib/cloud-config.js +42 -0
- package/dist/lib/mcp-config-writer.d.ts +26 -0
- package/dist/lib/mcp-config-writer.d.ts.map +1 -0
- package/dist/lib/mcp-config-writer.js +86 -0
- package/dist/lib/sync-config.d.ts +22 -0
- package/dist/lib/sync-config.d.ts.map +1 -0
- package/dist/lib/sync-config.js +25 -0
- package/dist/logo.d.ts +3 -0
- package/dist/logo.d.ts.map +1 -0
- package/dist/logo.js +8 -0
- package/dist/mcp/cluster.d.ts +69 -0
- package/dist/mcp/cluster.d.ts.map +1 -0
- package/dist/mcp/cluster.js +304 -0
- package/dist/mcp/config.d.ts +14 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +67 -0
- package/dist/mcp/http.d.ts +35 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/http.js +957 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp-http.d.ts +3 -0
- package/dist/mcp-http.d.ts.map +1 -0
- package/dist/mcp-http.js +42 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +28 -0
- package/dist/paths.d.ts +4 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqB7C,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwJnE"}
|
package/dist/install.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { NativeThingStore } from "@thingd/sdk";
|
|
6
|
+
import pc from "picocolors";
|
|
7
|
+
import { printMcpConfigJson, updateAntigravityConfig, updateClaudeDesktopConfig, } from "./lib/mcp-config-writer.js";
|
|
8
|
+
import { defaultThingdDbPath, ensureThingdDir } from "./paths.js";
|
|
9
|
+
async function askQuestion(query) {
|
|
10
|
+
const rl = createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stderr,
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
return await rl.question(query);
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
rl.close();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function runInstall(context) {
|
|
22
|
+
const nodePath = process.execPath;
|
|
23
|
+
const cliPath = resolveCliPath();
|
|
24
|
+
const dbPathDefault = defaultThingdDbPath();
|
|
25
|
+
const driverDefault = detectDriver();
|
|
26
|
+
ensureThingdDir();
|
|
27
|
+
const isRaw = context.parsed.booleans.has("raw") || context.parsed.flags.has("raw");
|
|
28
|
+
const isClaude = context.parsed.booleans.has("claude") || context.parsed.flags.has("claude");
|
|
29
|
+
const isCursor = context.parsed.booleans.has("cursor") || context.parsed.flags.has("cursor");
|
|
30
|
+
const isAntigravity = context.parsed.booleans.has("antigravity") || context.parsed.flags.has("antigravity");
|
|
31
|
+
if (!isRaw) {
|
|
32
|
+
context.stderr.write(`\n${pc.bold("thingd install")}\n\n`);
|
|
33
|
+
}
|
|
34
|
+
let choice = "1";
|
|
35
|
+
let dbPath = dbPathDefault;
|
|
36
|
+
let driver = driverDefault;
|
|
37
|
+
if (isRaw) {
|
|
38
|
+
choice = "5";
|
|
39
|
+
}
|
|
40
|
+
else if (isClaude && isCursor && isAntigravity) {
|
|
41
|
+
choice = "1";
|
|
42
|
+
}
|
|
43
|
+
else if (isClaude) {
|
|
44
|
+
choice = "2";
|
|
45
|
+
}
|
|
46
|
+
else if (isCursor) {
|
|
47
|
+
choice = "3";
|
|
48
|
+
}
|
|
49
|
+
else if (isAntigravity) {
|
|
50
|
+
choice = "4";
|
|
51
|
+
}
|
|
52
|
+
else if (process.stdin.isTTY) {
|
|
53
|
+
// 1. Where to install
|
|
54
|
+
context.stderr.write(`${pc.bold("Where would you like to install the MCP configuration?")}\n`);
|
|
55
|
+
context.stderr.write(` [1] Claude Desktop, Cursor & Antigravity (Default)\n`);
|
|
56
|
+
context.stderr.write(` [2] Claude Desktop only\n`);
|
|
57
|
+
context.stderr.write(` [3] Cursor only\n`);
|
|
58
|
+
context.stderr.write(` [4] Antigravity only\n`);
|
|
59
|
+
context.stderr.write(` [5] Print raw JSON configuration only\n\n`);
|
|
60
|
+
const answerInstall = await askQuestion(`Select option [1-5] (default 1): `);
|
|
61
|
+
choice = answerInstall.trim() || "1";
|
|
62
|
+
context.stderr.write("\n");
|
|
63
|
+
// 2. Database Path
|
|
64
|
+
const answerPath = await askQuestion(`Database path (default ${pc.cyan(dbPathDefault)}): `);
|
|
65
|
+
const chosenPath = answerPath.trim();
|
|
66
|
+
if (chosenPath) {
|
|
67
|
+
dbPath = chosenPath;
|
|
68
|
+
}
|
|
69
|
+
// 3. Driver
|
|
70
|
+
const answerDriver = await askQuestion(`Driver [native / memory] (default ${pc.cyan(driverDefault)}): `);
|
|
71
|
+
const chosenDriver = answerDriver.trim().toLowerCase();
|
|
72
|
+
if (chosenDriver === "native" || chosenDriver === "memory") {
|
|
73
|
+
driver = chosenDriver;
|
|
74
|
+
}
|
|
75
|
+
context.stderr.write("\n");
|
|
76
|
+
}
|
|
77
|
+
// Honor command line options if explicitly passed
|
|
78
|
+
const cliPathOption = context.parsed.flags.get("path")?.at(-1);
|
|
79
|
+
const cliDriverOption = context.parsed.flags.get("driver")?.at(-1);
|
|
80
|
+
if (cliPathOption) {
|
|
81
|
+
dbPath = cliPathOption;
|
|
82
|
+
}
|
|
83
|
+
if (cliDriverOption === "native" || cliDriverOption === "memory") {
|
|
84
|
+
driver = cliDriverOption;
|
|
85
|
+
}
|
|
86
|
+
const globalBin = findGlobalBinPath();
|
|
87
|
+
const config = globalBin
|
|
88
|
+
? {
|
|
89
|
+
command: globalBin,
|
|
90
|
+
args: ["mcp", "--path", dbPath, "--driver", driver],
|
|
91
|
+
}
|
|
92
|
+
: generateMcpConfig(nodePath, cliPath, dbPath, driver);
|
|
93
|
+
if (!isRaw) {
|
|
94
|
+
const hasNative = await NativeThingStore.isAvailable();
|
|
95
|
+
const bindingStatus = hasNative
|
|
96
|
+
? pc.green("Available/Loaded")
|
|
97
|
+
: pc.red("Unavailable/Not Found");
|
|
98
|
+
context.stderr.write(` ${pc.bold("Configuration Details:")}\n`);
|
|
99
|
+
context.stderr.write(` ${pc.green("✓")} Database path: ${pc.cyan(dbPath)}\n`);
|
|
100
|
+
context.stderr.write(` ${pc.green("✓")} Driver: ${pc.cyan(driver)}\n`);
|
|
101
|
+
context.stderr.write(` ${hasNative ? pc.green("✓") : pc.yellow("⚠")} Native Addon: ${bindingStatus}\n`);
|
|
102
|
+
if (globalBin) {
|
|
103
|
+
context.stderr.write(` ${pc.green("✓")} Command: ${pc.cyan(globalBin)}\n\n`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
context.stderr.write(` ${pc.green("✓")} Node: ${pc.cyan(nodePath)}\n`);
|
|
107
|
+
context.stderr.write(` ${pc.green("✓")} CLI: ${pc.cyan(cliPath)}\n\n`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const showClaude = choice === "1" || choice === "2";
|
|
111
|
+
const showCursor = choice === "1" || choice === "3";
|
|
112
|
+
const showAntigravity = choice === "1" || choice === "4";
|
|
113
|
+
const showRaw = choice === "5";
|
|
114
|
+
if (showClaude) {
|
|
115
|
+
const claudeResult = updateClaudeDesktopConfig(config);
|
|
116
|
+
if (claudeResult.updated) {
|
|
117
|
+
context.stderr.write(` ${pc.bold("Claude Desktop:")}\n`);
|
|
118
|
+
context.stderr.write(` ${pc.green("✓")} Updated ${pc.cyan(claudeResult.path)}\n\n`);
|
|
119
|
+
}
|
|
120
|
+
else if (claudeResult.skipped) {
|
|
121
|
+
context.stderr.write(` ${pc.bold("Claude Desktop:")}\n`);
|
|
122
|
+
context.stderr.write(` ${pc.yellow("⊘")} Skipped: ${claudeResult.reason}\n\n`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (showAntigravity) {
|
|
126
|
+
const antigravityResult = updateAntigravityConfig(config);
|
|
127
|
+
if (antigravityResult.updated) {
|
|
128
|
+
context.stderr.write(` ${pc.bold("Antigravity IDE:")}\n`);
|
|
129
|
+
context.stderr.write(` ${pc.green("✓")} Updated ${pc.cyan(antigravityResult.path)}\n\n`);
|
|
130
|
+
}
|
|
131
|
+
else if (antigravityResult.skipped) {
|
|
132
|
+
context.stderr.write(` ${pc.bold("Antigravity IDE:")}\n`);
|
|
133
|
+
context.stderr.write(` ${pc.yellow("⊘")} Skipped: ${antigravityResult.reason}\n\n`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (showCursor) {
|
|
137
|
+
context.stderr.write(` ${pc.bold("Cursor:")}\n`);
|
|
138
|
+
context.stderr.write(` Paste this into Cursor Settings → Features → MCP → Add New MCP Server:\n\n`);
|
|
139
|
+
context.stdout.write(`${printMcpConfigJson(config)}\n`);
|
|
140
|
+
}
|
|
141
|
+
if (showRaw) {
|
|
142
|
+
context.stdout.write(`${printMcpConfigJson(config)}\n`);
|
|
143
|
+
}
|
|
144
|
+
if (choice === "1") {
|
|
145
|
+
context.stderr.write(`\n Restart Claude Desktop or Antigravity to activate. Cursor activates immediately.\n\n`);
|
|
146
|
+
}
|
|
147
|
+
else if (choice === "2") {
|
|
148
|
+
context.stderr.write(`\n Restart Claude Desktop to activate.\n\n`);
|
|
149
|
+
}
|
|
150
|
+
else if (choice === "3") {
|
|
151
|
+
context.stderr.write(`\n Cursor activates immediately after pasting.\n\n`);
|
|
152
|
+
}
|
|
153
|
+
else if (choice === "4") {
|
|
154
|
+
context.stderr.write(`\n Restart Antigravity IDE to activate.\n\n`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function findGlobalBinPath() {
|
|
158
|
+
try {
|
|
159
|
+
const cliPath = resolveCliPath();
|
|
160
|
+
// In standard npm/nvm/pnpm global installations:
|
|
161
|
+
// CLI is at <prefix>/lib/node_modules/thingd-cli/dist/index.js
|
|
162
|
+
// Binary is at <prefix>/bin/thingd
|
|
163
|
+
const candidate = resolve(cliPath, "../../../../../bin/thingd");
|
|
164
|
+
if (existsSync(candidate)) {
|
|
165
|
+
return candidate;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// Ignore
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function resolveCliPath() {
|
|
174
|
+
try {
|
|
175
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
176
|
+
const dir = dirname(currentFile);
|
|
177
|
+
// In compiled dist folder: dist/install.js -> dist/index.js
|
|
178
|
+
let candidate = join(dir, "index.js");
|
|
179
|
+
if (existsSync(candidate)) {
|
|
180
|
+
return realpathSync(candidate);
|
|
181
|
+
}
|
|
182
|
+
// In dev src folder: src/install.ts -> src/index.ts
|
|
183
|
+
candidate = join(dir, "index.ts");
|
|
184
|
+
if (existsSync(candidate)) {
|
|
185
|
+
return realpathSync(candidate);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// Ignore and fallback
|
|
190
|
+
}
|
|
191
|
+
const scriptPath = process.argv[1];
|
|
192
|
+
if (!scriptPath) {
|
|
193
|
+
throw new Error("Could not detect thingd CLI path.");
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
return realpathSync(resolve(scriptPath));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return resolve(scriptPath);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function detectDriver() {
|
|
203
|
+
try {
|
|
204
|
+
// Check if the native .node binary exists relative to the CLI entry point.
|
|
205
|
+
// When installed globally via npm, thingd-native is typically a sibling package.
|
|
206
|
+
const cliDir = join(resolveCliPath(), "..", "..");
|
|
207
|
+
const nativePaths = [
|
|
208
|
+
join(cliDir, "node_modules", "@thingd/native", "dist", "thingd_native.node"),
|
|
209
|
+
join(cliDir, "..", "thingd-native", "dist", "thingd_native.node"),
|
|
210
|
+
];
|
|
211
|
+
for (const candidate of nativePaths) {
|
|
212
|
+
if (existsSync(candidate)) {
|
|
213
|
+
return "native";
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Ignore detection errors.
|
|
219
|
+
}
|
|
220
|
+
// Default to native since most global installs will have it.
|
|
221
|
+
// If it's not available, the SDK will produce a clear error at open time.
|
|
222
|
+
return "native";
|
|
223
|
+
}
|
|
224
|
+
function generateMcpConfig(nodePath, cliPath, dbPath, driver) {
|
|
225
|
+
return {
|
|
226
|
+
command: nodePath,
|
|
227
|
+
args: [cliPath, "mcp", "--path", dbPath, "--driver", driver],
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAqwGA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CA0FvD"}
|