@nudge-ui/mcp 0.2.0 → 0.2.1
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 +71 -53
- package/dist/bridge.d.ts +4 -2
- package/dist/bridge.js +237 -15
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +65 -12
- package/dist/cli.mjs +14741 -13959
- package/dist/discovery.d.ts +29 -0
- package/dist/discovery.js +112 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/internal/agent-protocol.d.ts +65 -1
- package/dist/internal/agent-protocol.js +183 -3
- package/dist/project.d.ts +54 -0
- package/dist/project.js +151 -0
- package/dist/projectSessionClient.d.ts +28 -0
- package/dist/projectSessionClient.js +93 -0
- package/dist/protocol.d.ts +13 -2
- package/dist/protocol.js +12 -1
- package/dist/server.d.ts +14 -0
- package/dist/server.js +90 -22
- package/dist/sessionRegistry.d.ts +8 -0
- package/dist/sessionRegistry.js +89 -0
- package/dist/sessionSelection.d.ts +15 -0
- package/dist/sessionSelection.js +41 -0
- package/package.json +6 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A workspace-root adapter can select any application in that exact workspace. */
|
|
2
|
+
export function matchesApplication(session, scope) {
|
|
3
|
+
return session.workspaceRoot === scope.workspaceRoot
|
|
4
|
+
&& (scope.applicationRoot === scope.workspaceRoot || session.appRoot === scope.applicationRoot);
|
|
5
|
+
}
|
|
6
|
+
/** Chooses a live session without accessing files, making requests, or claiming it. */
|
|
7
|
+
export function selectProjectSession(sessions, options) {
|
|
8
|
+
const candidates = sessions.filter((session) => matchesApplication(session, options));
|
|
9
|
+
const applicationScoped = options.applicationRoot !== options.workspaceRoot;
|
|
10
|
+
if (options.requestedSessionId) {
|
|
11
|
+
const requested = candidates.find((session) => session.sessionId === options.requestedSessionId);
|
|
12
|
+
if (requested)
|
|
13
|
+
return requested;
|
|
14
|
+
throw new Error(applicationScoped
|
|
15
|
+
? "The selected Nudge session is not live for this exact application."
|
|
16
|
+
: "The selected Nudge session is not live in this exact workspace.");
|
|
17
|
+
}
|
|
18
|
+
if (options.previousSession)
|
|
19
|
+
return restoreSelection(candidates, options.previousSession);
|
|
20
|
+
if (candidates.length === 1)
|
|
21
|
+
return candidates[0];
|
|
22
|
+
if (!sessions.some((session) => session.workspaceRoot === options.workspaceRoot)) {
|
|
23
|
+
throw new Error("No live Nudge project session matches this exact workspace. Start the project development server first.");
|
|
24
|
+
}
|
|
25
|
+
if (candidates.length === 0 && applicationScoped) {
|
|
26
|
+
throw new Error("No live Nudge project session matches this exact application. Start its development server first.");
|
|
27
|
+
}
|
|
28
|
+
throw new Error("Several Nudge apps are running in this workspace. Call nudge_list_sessions, then pass sessionId to nudge_listen.");
|
|
29
|
+
}
|
|
30
|
+
function restoreSelection(candidates, previous) {
|
|
31
|
+
const current = candidates.find((session) => session.sessionId === previous.sessionId);
|
|
32
|
+
if (current)
|
|
33
|
+
return current;
|
|
34
|
+
const replacements = candidates.filter((session) => session.appRoot === previous.appRoot);
|
|
35
|
+
if (replacements.length === 1)
|
|
36
|
+
return replacements[0];
|
|
37
|
+
if (replacements.length > 1) {
|
|
38
|
+
throw new Error("Several restarted Nudge sessions match the selected app. Pass sessionId explicitly.");
|
|
39
|
+
}
|
|
40
|
+
throw new Error("The previously selected Nudge app is no longer running.");
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nudge-ui/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Optional local MCP companion for pairing Nudge UI with coding agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"types": "./dist/server.d.ts",
|
|
43
43
|
"import": "./dist/server.js",
|
|
44
44
|
"default": "./dist/server.js"
|
|
45
|
+
},
|
|
46
|
+
"./project": {
|
|
47
|
+
"types": "./dist/project.d.ts",
|
|
48
|
+
"import": "./dist/project.js",
|
|
49
|
+
"default": "./dist/project.js"
|
|
45
50
|
}
|
|
46
51
|
},
|
|
47
52
|
"dependencies": {
|