@super-hands/connect 0.1.1 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.md +5 -1
  2. package/client.mjs +93 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,9 +6,13 @@ Connect the coding agents on this machine to your team's
6
6
  Superhands setup generates the command for you, credential included:
7
7
 
8
8
  ```
9
- SUPERHANDS_MCP_TOKEN="…" SUPERHANDS_MCP_URL="…" npx -y @super-hands/connect@latest
9
+ SUPERHANDS_MCP_TOKEN="…" npx -y @super-hands/connect@latest
10
10
  ```
11
11
 
12
+ It connects to `https://app.superhands.ai/api/mcp` unless `SUPERHANDS_MCP_URL`
13
+ says otherwise — a command from a preview or local deployment carries that
14
+ variable too.
15
+
12
16
  ## What it does
13
17
 
14
18
  - **Cursor** — merges the `superhands` server into `~/.cursor/mcp.json`.
package/client.mjs CHANGED
@@ -10,7 +10,7 @@
10
10
  // carries arrived in its own environment. Read on — it is not minified.
11
11
 
12
12
  // lib/connect-client-entry.ts
13
- import { execFileSync } from "node:child_process";
13
+ import { execFileSync, spawnSync } from "node:child_process";
14
14
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
15
15
  import { homedir } from "node:os";
16
16
  import { dirname, join } from "node:path";
@@ -21,6 +21,7 @@ var MCP_ACCESS_TOKEN_TTL_SECONDS = 30 * 24 * 60 * 60;
21
21
  // lib/mcp-clients.ts
22
22
  var CONNECT_TOKEN_ENV = "SUPERHANDS_MCP_TOKEN";
23
23
  var CONNECT_URL_ENV = "SUPERHANDS_MCP_URL";
24
+ var CONNECT_DEFAULT_MCP_URL = "https://app.superhands.ai/api/mcp";
24
25
  var CONNECT_CLIENT_PACKAGE = "@super-hands/connect";
25
26
  var CONNECT_CLIENT_SPEC = `${CONNECT_CLIENT_PACKAGE}@latest`;
26
27
  var MCP_SERVER_KEY = "superhands";
@@ -35,6 +36,54 @@ function codexConfigBlock(args) {
35
36
  ].join("\n");
36
37
  }
37
38
 
39
+ // lib/connect-skill.ts
40
+ var CONNECT_SKILL_VERSION = 2;
41
+ var CONNECT_SKILL_DIR = MCP_SERVER_KEY;
42
+ var CONNECT_SKILL_FILENAME = "SKILL.md";
43
+ var VERSION_MARKER = `[//]: # (superhands-skill-version: ${CONNECT_SKILL_VERSION})`;
44
+ var CONNECT_SKILL_DESCRIPTION = `Build UI the way this team has decided it should be built. Use BEFORE building, changing, or restyling any page, screen, view, form, or component \u2014 "build a page", "add a screen", "create a form", "make a dashboard", "redesign this", "new landing page" \u2014 and when asked how this product should look or behave. Reads the team's written product decisions from their Superhands MCP server.`;
45
+ var CONNECT_SKILL_CONTENT = `---
46
+ name: ${CONNECT_SKILL_DIR}
47
+ description: ${CONNECT_SKILL_DESCRIPTION}
48
+ ---
49
+
50
+ ${VERSION_MARKER}
51
+
52
+ # Superhands
53
+
54
+ This machine is connected to the team's Superhands server over MCP (server
55
+ key \`${MCP_SERVER_KEY}\`). It holds the decisions the team has written down
56
+ about how their product should look and behave \u2014 the same decisions their
57
+ engineers' pull requests are reviewed against.
58
+
59
+ Before you build, change, or restyle any UI:
60
+
61
+ 1. Call the \`superhands_get_guidance\` MCP tool with \`intent\` set to what
62
+ you have been asked to build, in plain language \u2014 for example "a sign-in
63
+ page with email and password and an error state". The decisions that govern
64
+ that work come back in full, ahead of the rest.
65
+ 2. Build to what comes back. Where a decision names a case it deliberately
66
+ does not govern, your own judgment resumes there.
67
+ 3. When you have finished \u2014 not part-way through \u2014 send the files you wrote or
68
+ changed with \`superhands_report_completed_build\`, naming the \`route\` if
69
+ you know it. The team looks at what their agents build there; it records
70
+ and does not review, so a failed report costs the work nothing.
71
+ 4. When you finish, say you followed the team's guidance \u2014 never that your
72
+ work passes it or was checked. Reading guidance is not a review, reporting
73
+ a build is not a review, and nothing has looked at what you built.
74
+
75
+ If the tool answers \`no-guidance\`, carry on with what you were asked for and
76
+ mention that the team writes its guidance on the Superhands Guidance page.
77
+
78
+ If the \`${MCP_SERVER_KEY}\` MCP server is not reachable in this session, say
79
+ so rather than guessing at the team's decisions \u2014 it is configured on this
80
+ machine, so a missing connection is worth telling the person about.
81
+ `;
82
+ function installedSkillVersion(contents) {
83
+ const match = contents.match(/superhands-skill-version:\s*(\d+)/);
84
+ return match ? Number.parseInt(match[1], 10) : 0;
85
+ }
86
+
38
87
  // lib/connect-client-entry.ts
39
88
  function say(line) {
40
89
  process.stdout.write(`superhands: ${line}
@@ -78,6 +127,23 @@ function appendedCodexConfig(existing, args) {
78
127
  return { text: `${existing}${sep}${codexConfigBlock(args)}
79
128
  `, alreadyPresent: false };
80
129
  }
130
+ function writeSkill(clientDir) {
131
+ const skillPath = join(clientDir, "skills", CONNECT_SKILL_DIR, CONNECT_SKILL_FILENAME);
132
+ try {
133
+ let existing = "";
134
+ try {
135
+ existing = readFileSync(skillPath, "utf8");
136
+ } catch {
137
+ existing = "";
138
+ }
139
+ if (existing !== "" && installedSkillVersion(existing) >= CONNECT_SKILL_VERSION) return;
140
+ mkdirSync(dirname(skillPath), { recursive: true });
141
+ writeFileSync(skillPath, CONNECT_SKILL_CONTENT);
142
+ say(` Wrote the ${CONNECT_SKILL_DIR} skill to ${skillPath} \u2014 it routes UI work through the team's guidance.`);
143
+ } catch {
144
+ say(` Could not write the ${CONNECT_SKILL_DIR} skill at ${skillPath}. The connection works without it.`);
145
+ }
146
+ }
81
147
  function hasCli(bin) {
82
148
  try {
83
149
  execFileSync(bin, ["--version"], { stdio: "ignore" });
@@ -86,12 +152,23 @@ function hasCli(bin) {
86
152
  return false;
87
153
  }
88
154
  }
155
+ function openCursor() {
156
+ const attempts = process.platform === "darwin" ? [
157
+ ["cursor", []],
158
+ ["open", ["-a", "Cursor"]]
159
+ ] : [["cursor", []]];
160
+ for (const [bin, args] of attempts) {
161
+ const result = spawnSync(bin, args, { stdio: "ignore" });
162
+ if (!result.error && result.status === 0) return true;
163
+ }
164
+ return false;
165
+ }
89
166
  async function main() {
90
167
  const token = process.env[CONNECT_TOKEN_ENV]?.trim();
91
- const endpoint = process.env[CONNECT_URL_ENV]?.trim();
92
- if (!token || !endpoint) {
168
+ const endpoint = process.env[CONNECT_URL_ENV]?.trim() || CONNECT_DEFAULT_MCP_URL;
169
+ if (!token) {
93
170
  stop(
94
- `this command needs ${CONNECT_TOKEN_ENV} and ${CONNECT_URL_ENV} set on the same line. Copy the whole command from Superhands setup and run it unchanged.`
171
+ `this command needs ${CONNECT_TOKEN_ENV} set on the same line. Copy the whole command from Superhands setup and run it unchanged.`
95
172
  );
96
173
  }
97
174
  const flags = new Set(process.argv.slice(2));
@@ -118,7 +195,14 @@ async function main() {
118
195
  say(
119
196
  merged.replaced ? `Cursor \u2014 updated the ${MCP_SERVER_KEY} server in ${configPath}.` : `Cursor \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
120
197
  );
121
- say(" Restart Cursor, then enable superhands under Settings \u2192 MCP.");
198
+ if (openCursor()) {
199
+ say(
200
+ ` Cursor is opening \u2014 enable ${MCP_SERVER_KEY} under Settings \u2192 MCP. If it was already running, restart it first.`
201
+ );
202
+ } else {
203
+ say(` Open Cursor (restart it if it was running), then enable ${MCP_SERVER_KEY} under Settings \u2192 MCP.`);
204
+ }
205
+ writeSkill(cursorDir);
122
206
  connected += 1;
123
207
  } catch {
124
208
  say(`Cursor \u2014 ${configPath} is not valid JSON, so it was left untouched.`);
@@ -152,6 +236,7 @@ async function main() {
152
236
  );
153
237
  say(`Claude Code \u2014 added the ${MCP_SERVER_KEY} server (user scope).`);
154
238
  say(" Open a new claude session and it connects on start.");
239
+ writeSkill(join(homedir(), ".claude"));
155
240
  connected += 1;
156
241
  } catch {
157
242
  say("Claude Code \u2014 `claude mcp add` failed. Run it by hand from the Superhands MCP page.");
@@ -171,12 +256,14 @@ async function main() {
171
256
  if (result.alreadyPresent) {
172
257
  say(`Codex \u2014 ${configPath} already names a ${MCP_SERVER_KEY} server, so it was left as it is.`);
173
258
  say(" If that connection is stale, update bearer_token there by hand.");
259
+ writeSkill(codexDir);
174
260
  connected += 1;
175
261
  } else {
176
262
  mkdirSync(dirname(configPath), { recursive: true });
177
263
  writeFileSync(configPath, result.text);
178
264
  say(`Codex \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`);
179
- say(" Start a new codex session and it connects on start.");
265
+ say(" The app and the CLI both read this config \u2014 open either and it connects when a session starts.");
266
+ writeSkill(codexDir);
180
267
  connected += 1;
181
268
  }
182
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-hands/connect",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Connect the coding agents on this machine to your team's Superhands MCP server. Writes each client's own config; reads no repository, uploads nothing.",
5
5
  "bin": {
6
6
  "superhands-connect": "client.mjs"