xcodebug 1.1.0 → 1.1.2
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 +13 -9
- package/index.ts +2 -0
- package/mcp/server.ts +63 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,24 +68,27 @@ extension rather than a parallel implementation.
|
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
npm i -g xcodebug # >= 1.1.0, the first release that ships mcp/
|
|
71
|
-
codex mcp add xcodebug --
|
|
72
|
-
claude mcp add xcodebug --
|
|
71
|
+
codex mcp add xcodebug -- bun "$(npm root -g)/xcodebug/mcp/server.ts"
|
|
72
|
+
claude mcp add xcodebug -- bun "$(npm root -g)/xcodebug/mcp/server.ts"
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Working from a checkout instead? Point both at `mcp/server.ts` in the repo:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
|
-
codex mcp add xcodebug --
|
|
79
|
-
claude mcp add xcodebug --
|
|
78
|
+
codex mcp add xcodebug -- bun /path/to/xcodebug/mcp/server.ts
|
|
79
|
+
claude mcp add xcodebug -- bun /path/to/xcodebug/mcp/server.ts
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
Bun is required ([bun.sh](https://bun.sh)). The sources are TypeScript, and Node
|
|
83
|
+
refuses to strip types for files under `node_modules`
|
|
84
|
+
(`ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING`) - which is exactly where npm
|
|
85
|
+
installs the package, so `node` cannot start an installed copy. Bun loads the
|
|
86
|
+
same file from either location, so one command covers both.
|
|
84
87
|
|
|
85
88
|
Check that the client picked it up:
|
|
86
89
|
|
|
87
90
|
```bash
|
|
88
|
-
codex mcp list # xcodebug
|
|
91
|
+
codex mcp list # xcodebug bun …
|
|
89
92
|
claude mcp list # xcodebug: … ✔ Connected
|
|
90
93
|
```
|
|
91
94
|
|
|
@@ -146,9 +149,10 @@ run is over.
|
|
|
146
149
|
| `idevicesyslog` from libimobiledevice | optional; only `syslog` and the dual-channel safety net |
|
|
147
150
|
| git | change detection; without a repo every run rebuilds |
|
|
148
151
|
| CocoaPods | optional; only projects with a `Podfile` |
|
|
149
|
-
|
|
|
152
|
+
| Bun | only for the MCP clients (Claude Code, Codex); pi runs the extension itself |
|
|
150
153
|
|
|
151
|
-
`xcodebug action=doctor` reports
|
|
154
|
+
`xcodebug action=doctor` reports the Xcode toolchain, the capture tools, the
|
|
155
|
+
active config and the log directory.
|
|
152
156
|
|
|
153
157
|
## Imports
|
|
154
158
|
|
package/index.ts
CHANGED
|
@@ -1691,6 +1691,7 @@ export default function xcodebug(pi: ExtensionAPI): void {
|
|
|
1691
1691
|
|
|
1692
1692
|
if (!appPath) throw new Error("launch requires appPath, or a scheme to build.");
|
|
1693
1693
|
executable ??= params.processName ?? (await readBundleExecutable(appPath));
|
|
1694
|
+
setRunPhase(`installing on ${device.name}`);
|
|
1694
1695
|
const install = await installApp(device, appPath, { timeoutMs: 180_000, signal });
|
|
1695
1696
|
if (!install.ok) {
|
|
1696
1697
|
return { content: [{ type: "text", text: install.message }], details: install, isError: true };
|
|
@@ -1714,6 +1715,7 @@ export default function xcodebug(pi: ExtensionAPI): void {
|
|
|
1714
1715
|
// stdout/stderr (plus os_log via OS_ACTIVITY_DT_MODE) and keeps running
|
|
1715
1716
|
// until the app exits. A second plain launch would create a second,
|
|
1716
1717
|
// short-lived instance and leave a stale pid behind.
|
|
1718
|
+
setRunPhase(`launching ${resolvedBundleId}`);
|
|
1717
1719
|
const capture = new Capture({
|
|
1718
1720
|
mode: "console",
|
|
1719
1721
|
deviceId: device.id,
|
package/mcp/server.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* tool's execute. index.ts stays untouched, which is what keeps the pi path
|
|
8
8
|
* behaving exactly as verified across pi, omp and omo.
|
|
9
9
|
*
|
|
10
|
-
* Run it with
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Run it with bun. Node can load this file from a checkout, but not from
|
|
11
|
+
* node_modules: it refuses to strip types there
|
|
12
|
+
* (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING), and that is where npm installs
|
|
13
|
+
* the package.
|
|
13
14
|
*
|
|
14
|
-
* codex mcp add xcodebug --
|
|
15
|
+
* codex mcp add xcodebug -- bun /path/to/xcodebug/mcp/server.ts
|
|
15
16
|
*
|
|
16
17
|
* The protocol is hand-written JSON-RPC over stdio because only three methods are
|
|
17
18
|
* needed (initialize, tools/list, tools/call); the official SDK would add ~97
|
|
@@ -26,7 +27,9 @@ import { createInterface } from "node:readline";
|
|
|
26
27
|
interface ExtensionContextLike {
|
|
27
28
|
cwd: string;
|
|
28
29
|
agentDir: string;
|
|
29
|
-
|
|
30
|
+
/** The status ticker in index.ts only runs when this is set. */
|
|
31
|
+
hasUI?: boolean;
|
|
32
|
+
ui: { notify(): void; setStatus(key: string, text?: string): void; setWidget(): void };
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
interface ToolResult {
|
|
@@ -93,11 +96,44 @@ if (!registered) {
|
|
|
93
96
|
}
|
|
94
97
|
const tool = registered;
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
function sendNotification(method: string, params: unknown): void {
|
|
100
|
+
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", method, params })}\n`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// While an action runs, index.ts repaints its status line once a second. That is
|
|
104
|
+
// the same cadence MCP progress wants, so the status text becomes the progress
|
|
105
|
+
// message instead of being dropped. `hasUI` is what makes that ticker run at all.
|
|
106
|
+
function makeCtx(progressToken: unknown): { ctx: ExtensionContextLike; close(): void } {
|
|
107
|
+
let step = 0;
|
|
108
|
+
let active = true;
|
|
109
|
+
const report = (text: string | undefined): void => {
|
|
110
|
+
if (!active) return;
|
|
111
|
+
if (progressToken === undefined || progressToken === null) return;
|
|
112
|
+
if (text === undefined || text === "") return;
|
|
113
|
+
step += 1;
|
|
114
|
+
sendNotification("notifications/progress", { progressToken, progress: step, message: text });
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
ctx: {
|
|
118
|
+
cwd: process.cwd(),
|
|
119
|
+
agentDir: AGENT_DIR,
|
|
120
|
+
hasUI: true,
|
|
121
|
+
ui: {
|
|
122
|
+
notify() {},
|
|
123
|
+
setStatus(_key, text) {
|
|
124
|
+
report(text);
|
|
125
|
+
},
|
|
126
|
+
setWidget() {},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
// The status ticker keeps running while a capture is alive, which outlives
|
|
130
|
+
// the call that started it. Without closing, the adapter would keep
|
|
131
|
+
// reporting progress for a request that already answered.
|
|
132
|
+
close() {
|
|
133
|
+
active = false;
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
101
137
|
|
|
102
138
|
// Typebox attaches symbol metadata; JSON round-tripping leaves a plain schema.
|
|
103
139
|
const inputSchema = JSON.parse(JSON.stringify(tool.parameters)) as Record<string, unknown>;
|
|
@@ -110,7 +146,11 @@ function replyError(id: unknown, code: number, message: string): void {
|
|
|
110
146
|
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } })}\n`);
|
|
111
147
|
}
|
|
112
148
|
|
|
113
|
-
async function callTool(
|
|
149
|
+
async function callTool(
|
|
150
|
+
args: Record<string, unknown>,
|
|
151
|
+
signal: AbortSignal,
|
|
152
|
+
progressToken: unknown,
|
|
153
|
+
): Promise<ToolResult> {
|
|
114
154
|
// `defaultPushMode` defaults to "context", but this transport cannot deliver
|
|
115
155
|
// pushed lines. Refusing an explicit request beats accepting it and going quiet.
|
|
116
156
|
if (args.push !== undefined && args.push !== "off") {
|
|
@@ -119,7 +159,12 @@ async function callTool(args: Record<string, unknown>, signal: AbortSignal): Pro
|
|
|
119
159
|
isError: true,
|
|
120
160
|
};
|
|
121
161
|
}
|
|
122
|
-
|
|
162
|
+
const progress = makeCtx(progressToken);
|
|
163
|
+
try {
|
|
164
|
+
return await tool.execute("mcp", { ...args, push: "off" }, signal, undefined, progress.ctx);
|
|
165
|
+
} finally {
|
|
166
|
+
progress.close();
|
|
167
|
+
}
|
|
123
168
|
}
|
|
124
169
|
|
|
125
170
|
async function handle(message: Record<string, unknown>): Promise<void> {
|
|
@@ -146,7 +191,11 @@ async function handle(message: Record<string, unknown>): Promise<void> {
|
|
|
146
191
|
return;
|
|
147
192
|
}
|
|
148
193
|
if (method === "tools/call") {
|
|
149
|
-
const params = (message.params ?? {}) as {
|
|
194
|
+
const params = (message.params ?? {}) as {
|
|
195
|
+
name?: string;
|
|
196
|
+
arguments?: Record<string, unknown>;
|
|
197
|
+
_meta?: { progressToken?: unknown };
|
|
198
|
+
};
|
|
150
199
|
if (params.name !== "xcodebug") {
|
|
151
200
|
replyError(id, -32602, `Unknown tool "${params.name ?? ""}"`);
|
|
152
201
|
return;
|
|
@@ -156,7 +205,7 @@ async function handle(message: Record<string, unknown>): Promise<void> {
|
|
|
156
205
|
const controller = new AbortController();
|
|
157
206
|
inflight.set(id, controller);
|
|
158
207
|
try {
|
|
159
|
-
reply(id, await callTool(params.arguments ?? {}, controller.signal));
|
|
208
|
+
reply(id, await callTool(params.arguments ?? {}, controller.signal, params._meta?.progressToken));
|
|
160
209
|
} catch (error) {
|
|
161
210
|
reply(id, { content: [{ type: "text", text: (error as Error).message }], isError: true });
|
|
162
211
|
} finally {
|
package/package.json
CHANGED