@craftspace/cli 0.9.0 → 0.10.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/dist/index.js +265 -148
- package/dist/machine.d.ts +30 -5
- package/dist/machine.js +231 -113
- package/dist/migrate.d.ts +1 -0
- package/dist/migrate.js +18 -15
- package/dist/probe.d.ts +2 -1
- package/dist/probe.js +5 -4
- package/package.json +1 -1
package/dist/migrate.js
CHANGED
|
@@ -4,6 +4,23 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export const migrate = {
|
|
7
|
+
async stripGlobalMcp() {
|
|
8
|
+
const target = path.join(os.homedir(), '.mcp.json');
|
|
9
|
+
const raw = await readFile(target, 'utf8').catch(() => null);
|
|
10
|
+
if (raw === null)
|
|
11
|
+
return;
|
|
12
|
+
const parsed = JSON.parse(raw);
|
|
13
|
+
const servers = parsed.mcpServers;
|
|
14
|
+
if (typeof servers !== 'object' || servers === null || !('craftspace' in servers))
|
|
15
|
+
return;
|
|
16
|
+
delete servers.craftspace;
|
|
17
|
+
const emptied = Object.keys(servers).length === 0 && Object.keys(parsed).length === 1;
|
|
18
|
+
const ours = (await readFile(`${target}.craftspace-backup`, 'utf8').catch(() => null)) === null;
|
|
19
|
+
if (emptied && ours)
|
|
20
|
+
await rm(target, { force: true });
|
|
21
|
+
else
|
|
22
|
+
await writeFile(target, `${JSON.stringify(parsed, null, 2)}\n`, { mode: 0o600 });
|
|
23
|
+
},
|
|
7
24
|
async toLatest({ home, workDir }) {
|
|
8
25
|
const done = new Set(await alreadyRan(home));
|
|
9
26
|
const ran = [];
|
|
@@ -48,21 +65,7 @@ const STEPS = [
|
|
|
48
65
|
{
|
|
49
66
|
id: '0002-mcp-out-of-home',
|
|
50
67
|
async run() {
|
|
51
|
-
|
|
52
|
-
const raw = await readFile(target, 'utf8').catch(() => null);
|
|
53
|
-
if (raw === null)
|
|
54
|
-
return true;
|
|
55
|
-
const parsed = JSON.parse(raw);
|
|
56
|
-
const servers = parsed.mcpServers;
|
|
57
|
-
if (typeof servers !== 'object' || servers === null || !('craftspace' in servers))
|
|
58
|
-
return true;
|
|
59
|
-
delete servers.craftspace;
|
|
60
|
-
const emptied = Object.keys(servers).length === 0 && Object.keys(parsed).length === 1;
|
|
61
|
-
const ours = (await readFile(`${target}.craftspace-backup`, 'utf8').catch(() => null)) === null;
|
|
62
|
-
if (emptied && ours)
|
|
63
|
-
await rm(target, { force: true });
|
|
64
|
-
else
|
|
65
|
-
await writeFile(target, `${JSON.stringify(parsed, null, 2)}\n`, { mode: 0o600 });
|
|
68
|
+
await migrate.stripGlobalMcp();
|
|
66
69
|
return true;
|
|
67
70
|
},
|
|
68
71
|
},
|
package/dist/probe.d.ts
CHANGED
package/dist/probe.js
CHANGED
|
@@ -3,16 +3,17 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
export const probe = {
|
|
6
|
-
async tools({ dirs }) {
|
|
7
|
-
return Promise.all([brainWired(dirs), sshListening()]);
|
|
6
|
+
async tools({ dirs, organization }) {
|
|
7
|
+
return Promise.all([brainWired({ dirs, organization }), sshListening()]);
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
|
-
async function brainWired(dirs) {
|
|
10
|
+
async function brainWired({ dirs, organization }) {
|
|
11
11
|
if (dirs.length === 0) {
|
|
12
12
|
return { id: 'brain', ok: false, detail: 'no repos cloned here yet, so there is nothing to wire it into' };
|
|
13
13
|
}
|
|
14
14
|
const projects = await claudeProjects();
|
|
15
|
-
const
|
|
15
|
+
const wanted = `craftspace-${organization}`;
|
|
16
|
+
const unwired = dirs.filter((dir) => !(wanted in mcpServersIn(projects[dir])));
|
|
16
17
|
return unwired.length === 0
|
|
17
18
|
? { id: 'brain', ok: true, detail: `wired into ${dirs.length} repo${dirs.length === 1 ? '' : 's'}` }
|
|
18
19
|
: { id: 'brain', ok: false, detail: `not wired into ${unwired.map(short).join(', ')}`.slice(0, DETAIL_MAX) };
|