@super-hands/connect 0.1.2 → 0.1.5

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 +90 -8
  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
@@ -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";
@@ -31,10 +32,58 @@ function codexConfigBlock(args) {
31
32
  return [
32
33
  `[mcp_servers.${MCP_SERVER_KEY}]`,
33
34
  `url = "${args.endpoint}"`,
34
- `bearer_token = "${args.token}"`
35
+ `http_headers = { "Authorization" = "${mcpAuthorizationHeader(args.token)}" }`
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}
@@ -71,12 +120,39 @@ function mergedCursorConfig(existing, args) {
71
120
  `, replaced };
72
121
  }
73
122
  function appendedCodexConfig(existing, args) {
123
+ const staleOwnBlock = new RegExp(
124
+ `\\[mcp_servers\\.${MCP_SERVER_KEY}\\]\\nurl = "[^"\\n]*"\\nbearer_token = "[^"\\n]*"`
125
+ );
126
+ if (staleOwnBlock.test(existing)) {
127
+ return {
128
+ text: existing.replace(staleOwnBlock, codexConfigBlock(args)),
129
+ alreadyPresent: false,
130
+ repaired: true
131
+ };
132
+ }
74
133
  if (existing.includes(`[mcp_servers.${MCP_SERVER_KEY}]`)) {
75
- return { text: existing, alreadyPresent: true };
134
+ return { text: existing, alreadyPresent: true, repaired: false };
76
135
  }
77
136
  const sep = existing === "" || existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
78
137
  return { text: `${existing}${sep}${codexConfigBlock(args)}
79
- `, alreadyPresent: false };
138
+ `, alreadyPresent: false, repaired: false };
139
+ }
140
+ function writeSkill(clientDir) {
141
+ const skillPath = join(clientDir, "skills", CONNECT_SKILL_DIR, CONNECT_SKILL_FILENAME);
142
+ try {
143
+ let existing = "";
144
+ try {
145
+ existing = readFileSync(skillPath, "utf8");
146
+ } catch {
147
+ existing = "";
148
+ }
149
+ if (existing !== "" && installedSkillVersion(existing) >= CONNECT_SKILL_VERSION) return;
150
+ mkdirSync(dirname(skillPath), { recursive: true });
151
+ writeFileSync(skillPath, CONNECT_SKILL_CONTENT);
152
+ say(` Wrote the ${CONNECT_SKILL_DIR} skill to ${skillPath} \u2014 it routes UI work through the team's guidance.`);
153
+ } catch {
154
+ say(` Could not write the ${CONNECT_SKILL_DIR} skill at ${skillPath}. The connection works without it.`);
155
+ }
80
156
  }
81
157
  function hasCli(bin) {
82
158
  try {
@@ -99,10 +175,10 @@ function openCursor() {
99
175
  }
100
176
  async function main() {
101
177
  const token = process.env[CONNECT_TOKEN_ENV]?.trim();
102
- const endpoint = process.env[CONNECT_URL_ENV]?.trim();
103
- if (!token || !endpoint) {
178
+ const endpoint = process.env[CONNECT_URL_ENV]?.trim() || CONNECT_DEFAULT_MCP_URL;
179
+ if (!token) {
104
180
  stop(
105
- `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.`
181
+ `this command needs ${CONNECT_TOKEN_ENV} set on the same line. Copy the whole command from Superhands setup and run it unchanged.`
106
182
  );
107
183
  }
108
184
  const flags = new Set(process.argv.slice(2));
@@ -136,6 +212,7 @@ async function main() {
136
212
  } else {
137
213
  say(` Open Cursor (restart it if it was running), then enable ${MCP_SERVER_KEY} under Settings \u2192 MCP.`);
138
214
  }
215
+ writeSkill(cursorDir);
139
216
  connected += 1;
140
217
  } catch {
141
218
  say(`Cursor \u2014 ${configPath} is not valid JSON, so it was left untouched.`);
@@ -169,6 +246,7 @@ async function main() {
169
246
  );
170
247
  say(`Claude Code \u2014 added the ${MCP_SERVER_KEY} server (user scope).`);
171
248
  say(" Open a new claude session and it connects on start.");
249
+ writeSkill(join(homedir(), ".claude"));
172
250
  connected += 1;
173
251
  } catch {
174
252
  say("Claude Code \u2014 `claude mcp add` failed. Run it by hand from the Superhands MCP page.");
@@ -187,13 +265,17 @@ async function main() {
187
265
  const result = appendedCodexConfig(existing, { endpoint, token });
188
266
  if (result.alreadyPresent) {
189
267
  say(`Codex \u2014 ${configPath} already names a ${MCP_SERVER_KEY} server, so it was left as it is.`);
190
- say(" If that connection is stale, update bearer_token there by hand.");
268
+ say(" If that connection is stale, update the http_headers Authorization value there by hand.");
269
+ writeSkill(codexDir);
191
270
  connected += 1;
192
271
  } else {
193
272
  mkdirSync(dirname(configPath), { recursive: true });
194
273
  writeFileSync(configPath, result.text);
195
- say(`Codex \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`);
274
+ say(
275
+ result.repaired ? `Codex \u2014 replaced the ${MCP_SERVER_KEY} entry in ${configPath}: its old bearer_token spelling makes current Codex reject the whole config.` : `Codex \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
276
+ );
196
277
  say(" The app and the CLI both read this config \u2014 open either and it connects when a session starts.");
278
+ writeSkill(codexDir);
197
279
  connected += 1;
198
280
  }
199
281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-hands/connect",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
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"