sharedthink 0.1.0 → 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 +12 -6
- package/cli/sharedthink.mjs +48 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,21 +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
|
|
27
|
+
sharedthink invite teammate@email.com
|
|
26
28
|
cd <repo> && sharedthink init <project>
|
|
27
29
|
|
|
28
|
-
# teammate
|
|
29
|
-
npx sharedthink
|
|
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
|
-
(this repo, this machine; the token stays out of the repo).
|
|
39
|
+
(this repo, this machine; the token stays out of the repo).
|
|
35
40
|
|
|
36
41
|
Other commands: `read [words]`, `send "<text>" --why .. --source ..`, `inbox`, `merge <id>`, `reject <id> "why"`, `rules`, `log`,
|
|
37
|
-
`members`, `remove <
|
|
42
|
+
`members`, `remove <email>` (owner: access ends at once), `rotate` (new token for this machine if it leaked).
|
|
38
43
|
|
|
39
44
|
## Run the server
|
|
40
45
|
|
|
@@ -42,7 +47,8 @@ Other commands: `read [words]`, `send "<text>" --why .. --source ..`, `inbox`, `
|
|
|
42
47
|
npm install
|
|
43
48
|
npx convex dev # dev deployment
|
|
44
49
|
npx convex deploy # prod
|
|
45
|
-
npx convex
|
|
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
|
|
46
52
|
```
|
|
47
53
|
|
|
48
54
|
The CLI talks to the prod URL by default. Override with `SHAREDTHINK_URL`.
|
package/cli/sharedthink.mjs
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
102
|
-
const r =
|
|
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,23 +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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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);
|
|
140
|
+
const until = Date.now() + 10 * 60_000;
|
|
141
|
+
while (Date.now() < until) {
|
|
142
|
+
await new Promise((ok) => setTimeout(ok, 2000));
|
|
143
|
+
const p = await api("login/poll", { secret: r.secret }, { auth: false });
|
|
144
|
+
if (p.status === "approved") {
|
|
145
|
+
saveLogin(p.token);
|
|
146
|
+
return console.log(`logged in as ${p.email}. Next: in a repo, run 'sharedthink init <project>'`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
die("login expired: run 'sharedthink login' again");
|
|
132
150
|
},
|
|
133
151
|
|
|
134
152
|
async create({ pos }) {
|
|
@@ -138,8 +156,13 @@ const commands = {
|
|
|
138
156
|
},
|
|
139
157
|
|
|
140
158
|
async invite({ pos, flags }) {
|
|
141
|
-
|
|
142
|
-
|
|
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
|
+
);
|
|
143
166
|
},
|
|
144
167
|
|
|
145
168
|
// Links this repo: .sharedthink.json (safe to commit) + MCP server in local scope.
|
|
@@ -211,7 +234,7 @@ const commands = {
|
|
|
211
234
|
|
|
212
235
|
// Owner: take someone out of the project. Their access ends immediately.
|
|
213
236
|
async remove({ pos, flags }) {
|
|
214
|
-
if (!pos[0]) die("usage: sharedthink remove <
|
|
237
|
+
if (!pos[0]) die("usage: sharedthink remove <email>");
|
|
215
238
|
const r = await api("remove", { project: project(flags.project), name: pos[0] });
|
|
216
239
|
console.log(`removed ${r.removed} from '${r.project}'`);
|
|
217
240
|
},
|
|
@@ -237,10 +260,9 @@ const [cmd, ...rest] = process.argv.slice(2);
|
|
|
237
260
|
if (!cmd || !commands[cmd]) {
|
|
238
261
|
console.log(`sharedthink: a team's shared brain for agents
|
|
239
262
|
|
|
240
|
-
|
|
241
|
-
login --token <token> use an existing token on this machine
|
|
263
|
+
login log in with Google (do it once per machine)
|
|
242
264
|
create <project> create a project, you are the owner
|
|
243
|
-
invite
|
|
265
|
+
invite <email> add someone to the project (owner)
|
|
244
266
|
init <project> link this repo: .sharedthink.json + MCP for this repo only
|
|
245
267
|
|
|
246
268
|
read [words] search the brain
|
|
@@ -250,7 +272,7 @@ if (!cmd || !commands[cmd]) {
|
|
|
250
272
|
rules [--set <file>] show or replace how this brain works (owner sets)
|
|
251
273
|
log [--n 20] recent notes
|
|
252
274
|
members who is in the project
|
|
253
|
-
remove <
|
|
275
|
+
remove <email> take someone out (owner)
|
|
254
276
|
rotate replace your token (if it leaked)
|
|
255
277
|
|
|
256
278
|
server: ${serverUrl()} (override with SHAREDTHINK_URL)`);
|