sharedthink 0.1.1 → 0.2.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/README.md CHANGED
@@ -20,24 +20,26 @@ The server runs no model: it stores, checks access, and serves the project's rul
20
20
  ## Use it
21
21
 
22
22
  ```sh
23
+ npx sharedthink login # Google sign-in in the browser, once per machine
24
+
23
25
  # owner
24
26
  sharedthink create <project>
25
- sharedthink invite <project> # prints a single-use code
27
+ sharedthink invite teammate@email.com
26
28
  cd <repo> && sharedthink init <project>
27
29
 
28
- # teammate
29
- npx sharedthink join <code> --name <you>
30
+ # teammate (after the invite)
31
+ npx sharedthink login
30
32
  cd <repo> && npx sharedthink init <project>
31
33
  ```
32
34
 
35
+ `login` opens Google in your browser. sharedthink only gets your email. The terminal and the browser show the same
36
+ 4-letter code: confirm only if they match. Same Google account on every machine = same sharedthink account.
37
+
33
38
  `init` writes `.sharedthink.json` (safe to commit) and adds the `sharedthink` MCP server in local scope
34
39
  (this repo, this machine; the token stays out of the repo).
35
40
 
36
- Your other machines: run `npx sharedthink pair` there, then `sharedthink approve <words>` on a machine
37
- that is already logged in. No token is copied between machines.
38
-
39
41
  Other commands: `read [words]`, `send "<text>" --why .. --source ..`, `inbox`, `merge <id>`, `reject <id> "why"`, `rules`, `log`,
40
- `members`, `remove <name>` (owner: access ends at once), `rotate` (new token if yours leaked).
42
+ `members`, `remove <email>` (owner: access ends at once), `rotate` (new token for this machine if it leaked).
41
43
 
42
44
  ## Run the server
43
45
 
@@ -45,7 +47,8 @@ Other commands: `read [words]`, `send "<text>" --why .. --source ..`, `inbox`, `
45
47
  npm install
46
48
  npx convex dev # dev deployment
47
49
  npx convex deploy # prod
48
- npx convex run --prod admin:createUser '{"name":"<you>"}' # first account, prints the token once
50
+ npx convex env set --prod GOOGLE_CLIENT_ID ... # Google OAuth web client,
51
+ npx convex env set --prod GOOGLE_CLIENT_SECRET ... # redirect URI <site>/auth/google/callback
49
52
  ```
50
53
 
51
54
  The CLI talks to the prod URL by default. Override with `SHAREDTHINK_URL`.
@@ -52,7 +52,7 @@ const serverUrl = () => (process.env.SHAREDTHINK_URL || readJson(CONFIG)?.url ||
52
52
  const token = () => process.env.SHAREDTHINK_TOKEN || readJson(CONFIG)?.token;
53
53
  function needToken() {
54
54
  const t = token();
55
- if (!t) die("not logged in: 'sharedthink join <invite-code> --name <you>' or 'sharedthink login --token <token>'");
55
+ if (!t) die("not logged in: run 'sharedthink login'");
56
56
  return t;
57
57
  }
58
58
 
@@ -95,12 +95,27 @@ function saveLogin(t) {
95
95
  writeJson(CONFIG, { url: serverUrl(), token: t }, 0o600);
96
96
  }
97
97
 
98
+ // On Windows `claude` is a .cmd shim, which only runs through the shell.
99
+ function claude(args, opts) {
100
+ if (process.platform !== "win32") return spawnSync("claude", args, opts);
101
+ return spawnSync("claude " + args.map((a) => `"${a}"`).join(" "), { ...opts, shell: true });
102
+ }
103
+
104
+ function openBrowser(url) {
105
+ const [cmd, args] =
106
+ process.platform === "darwin" ? ["open", [url]]
107
+ : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]]
108
+ : ["xdg-open", [url]];
109
+ try {
110
+ spawnSync(cmd, args, { stdio: "ignore" });
111
+ } catch {}
112
+ }
113
+
98
114
  // Adds the MCP server for this repo only (local scope). The token lives in Claude's local config, never in the repo.
99
115
  function addMcp(root, slug) {
100
116
  const url = `${serverUrl()}/mcp?project=${encodeURIComponent(slug)}`;
101
- spawnSync("claude", ["mcp", "remove", "--scope", "local", "sharedthink"], { cwd: root, stdio: "ignore" });
102
- const r = spawnSync(
103
- "claude",
117
+ claude(["mcp", "remove", "--scope", "local", "sharedthink"], { cwd: root, stdio: "ignore" });
118
+ const r = claude(
104
119
  ["mcp", "add", "--transport", "http", "--scope", "local", "sharedthink", url, "--header", `Authorization: Bearer ${needToken()}`],
105
120
  { cwd: root, stdio: "pipe" },
106
121
  );
@@ -112,47 +127,26 @@ function addMcp(root, slug) {
112
127
  }
113
128
 
114
129
  const commands = {
130
+ // Log in with Google in the browser. Same account on every machine, nothing to copy.
115
131
  async login({ flags }) {
116
- const t = flags.token || process.env.SHAREDTHINK_TOKEN;
117
- if (!t || t === true) die("usage: sharedthink login --token <token> [--url <server>]");
118
- if (flags.url) process.env.SHAREDTHINK_URL = flags.url;
119
- saveLogin(t);
120
- console.log(`saved ${CONFIG}`);
121
- },
122
-
123
- // Redeem an invite. New here: --name creates your account. Already logged in: adds the project to it.
124
- async join({ pos, flags }) {
125
- const code = pos[0];
126
- if (!code) die("usage: sharedthink join <invite-code> [--name <you>]");
127
132
  if (flags.url) process.env.SHAREDTHINK_URL = flags.url;
128
- const r = await api("join", { code, name: flags.name }, { auth: false });
129
- if (r.token) saveLogin(r.token);
130
- console.log(`joined '${r.project}' as ${r.name}${r.created ? ` (new account, token saved to ${CONFIG})` : ""}`);
131
- console.log(`next: in the project's repo, run 'sharedthink init ${r.project}'`);
132
- },
133
-
134
- // On a NEW machine: log in as yourself. Approve the words from a machine that is already logged in.
135
- async pair({ flags }) {
136
- if (flags.url) process.env.SHAREDTHINK_URL = flags.url;
137
- const r = await api("pair/start", {}, { auth: false });
138
- console.log(`on a machine where you are logged in, run:\n\n sharedthink approve ${r.words}\n\nwaiting (10 minutes)...`);
133
+ if (flags.token) {
134
+ saveLogin(flags.token);
135
+ return console.log(`saved ${CONFIG}`);
136
+ }
137
+ const r = await api("login/start", {}, { auth: false });
138
+ console.log(`opening your browser to log in with Google. If it doesn't open, go to:\n\n ${r.url}\n\ncode: ${r.code} (the browser shows it too: check they match)\nwaiting...`);
139
+ openBrowser(r.url);
139
140
  const until = Date.now() + 10 * 60_000;
140
141
  while (Date.now() < until) {
141
- await new Promise((ok) => setTimeout(ok, 3000));
142
- const p = await api("pair/poll", { secret: r.secret }, { auth: false });
142
+ await new Promise((ok) => setTimeout(ok, 2000));
143
+ const p = await api("login/poll", { secret: r.secret }, { auth: false });
143
144
  if (p.status === "approved") {
144
145
  saveLogin(p.token);
145
- return console.log(`this machine is now logged in as ${p.name}. Next: in a repo, run 'sharedthink init <project>'`);
146
+ return console.log(`logged in as ${p.email}. Next: in a repo, run 'sharedthink init <project>'`);
146
147
  }
147
148
  }
148
- die("pairing expired: run 'sharedthink pair' again");
149
- },
150
-
151
- // On a logged-in machine: let a new machine in as you.
152
- async approve({ pos }) {
153
- if (!pos[0]) die("usage: sharedthink approve <words>");
154
- const r = await api("pair/approve", { words: pos[0] });
155
- console.log(`approved: that machine is now logged in as ${r.name}`);
149
+ die("login expired: run 'sharedthink login' again");
156
150
  },
157
151
 
158
152
  async create({ pos }) {
@@ -162,8 +156,13 @@ const commands = {
162
156
  },
163
157
 
164
158
  async invite({ pos, flags }) {
165
- const r = await api("invite", { project: project(pos[0]), days: flags.days });
166
- console.log(`invite for '${r.project}', single use, expires ${new Date(r.expiresAt).toISOString().slice(0, 10)}:\n npx sharedthink join ${r.code} --name <their-name>`);
159
+ if (!pos[0]) die("usage: sharedthink invite <email> [--project <project>]");
160
+ const r = await api("invite", { project: project(flags.project), email: pos[0] });
161
+ console.log(
162
+ r.added
163
+ ? `${r.email} is now in '${r.project}'`
164
+ : `invited ${r.email} to '${r.project}'. They run 'npx sharedthink login' and it's there.`,
165
+ );
167
166
  },
168
167
 
169
168
  // Links this repo: .sharedthink.json (safe to commit) + MCP server in local scope.
@@ -235,7 +234,7 @@ const commands = {
235
234
 
236
235
  // Owner: take someone out of the project. Their access ends immediately.
237
236
  async remove({ pos, flags }) {
238
- if (!pos[0]) die("usage: sharedthink remove <name>");
237
+ if (!pos[0]) die("usage: sharedthink remove <email>");
239
238
  const r = await api("remove", { project: project(flags.project), name: pos[0] });
240
239
  console.log(`removed ${r.removed} from '${r.project}'`);
241
240
  },
@@ -261,12 +260,9 @@ const [cmd, ...rest] = process.argv.slice(2);
261
260
  if (!cmd || !commands[cmd]) {
262
261
  console.log(`sharedthink: a team's shared brain for agents
263
262
 
264
- join <invite-code> --name <you> join a project (creates your account if new)
265
- login --token <token> use an existing token on this machine
266
- pair on a new machine: log in as you (approve it from another)
267
- approve <words> let that new machine in
263
+ login log in with Google (do it once per machine)
268
264
  create <project> create a project, you are the owner
269
- invite [project] make a single-use invite code (owner)
265
+ invite <email> add someone to the project (owner)
270
266
  init <project> link this repo: .sharedthink.json + MCP for this repo only
271
267
 
272
268
  read [words] search the brain
@@ -276,7 +272,7 @@ if (!cmd || !commands[cmd]) {
276
272
  rules [--set <file>] show or replace how this brain works (owner sets)
277
273
  log [--n 20] recent notes
278
274
  members who is in the project
279
- remove <name> take someone out (owner)
275
+ remove <email> take someone out (owner)
280
276
  rotate replace your token (if it leaked)
281
277
 
282
278
  server: ${serverUrl()} (override with SHAREDTHINK_URL)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sharedthink",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A team's shared brain for AI agents: one live place your agents read from, send to, and you approve.",
5
5
  "keywords": [
6
6
  "ai",