superduck-cli 0.1.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 +45 -0
- package/SKILL.md +52 -0
- package/bin/superduck.js +41 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# superduck
|
|
2
|
+
|
|
3
|
+
> Your browser's session, callable as a tool.
|
|
4
|
+
|
|
5
|
+
`superduck` is a CLI that lets agents (Claude Code, Codex, etc.) read from and fetch as the user's currently-running Chrome — same login state, same cookies, same active tab.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g superduck
|
|
11
|
+
superduck setup
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then in Chrome: install the SuperDuck extension, reload, and run:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
superduck doctor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
All green → you're ready.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
superduck context # see what the user is reading
|
|
26
|
+
superduck fetch https://api.example.com # using their cookies
|
|
27
|
+
superduck tabs
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See [SKILL.md](./SKILL.md) for the agent-facing usage doc.
|
|
31
|
+
|
|
32
|
+
## Architecture
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
agent CLI ──► superduck (this binary)
|
|
36
|
+
│ UDS /tmp/chrome-native-host.sock
|
|
37
|
+
▼
|
|
38
|
+
chrome-native-host (Go) ──Chrome Native Messaging──► SuperDuck extension ──► active tab
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The native binary is shipped via npm `optionalDependencies` (one platform package per arch) so install never runs a `postinstall` download script.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: SuperDuck
|
|
3
|
+
description: When the user is doing something in their Chrome browser and needs an agent (Claude Code/Codex) to read or fetch from it as the logged-in user — use the `superduck` CLI to read the active tab's url/title/selection/visible text, or to fetch a URL using the user's existing cookies/session.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SuperDuck
|
|
7
|
+
|
|
8
|
+
Use the `superduck` CLI when:
|
|
9
|
+
- You need to know **what the user is currently looking at** in Chrome (URL, page title, selection, visible text).
|
|
10
|
+
- You need to **fetch data from an authenticated endpoint** that the user is already logged into in Chrome (Jira, Gmail, internal OA, GitHub Enterprise, etc.) — you do not need to ask for credentials.
|
|
11
|
+
|
|
12
|
+
The CLI talks to the user's own Chrome through a small browser extension. It is **not** a headless browser; it borrows the user's session.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
superduck context # url + title + selection + viewport text from active tab
|
|
18
|
+
superduck context --full # whole-page innerText (large; head/less recommended)
|
|
19
|
+
superduck context --json # machine-readable
|
|
20
|
+
|
|
21
|
+
superduck fetch <url> # GET; cookies of the active tab's origin auto-included
|
|
22
|
+
superduck fetch <url> -X POST -H 'Content-Type: application/json' -d '{"x":1}'
|
|
23
|
+
superduck fetch <url> --allow-cross-origin # fetch outside current eTLD+1
|
|
24
|
+
|
|
25
|
+
superduck open <url> # navigate active tab; --new-tab to open new
|
|
26
|
+
superduck click "Login" # click by visible text
|
|
27
|
+
superduck click --selector 'button[type=submit]'
|
|
28
|
+
superduck fill 'input[name=q]' "claude code" # set value + dispatch input/change
|
|
29
|
+
superduck press Enter --selector 'input[name=q]'
|
|
30
|
+
|
|
31
|
+
superduck tabs # list all Chrome tabs (debug; rarely needed)
|
|
32
|
+
superduck doctor # health check
|
|
33
|
+
superduck log --tail 20 # ~/.superduck/audit.jsonl
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Conventions
|
|
37
|
+
|
|
38
|
+
- **Default same-domain:** `fetch` rejects targets outside the active tab's eTLD+1. Add `--allow-cross-origin` if the user is OK with it.
|
|
39
|
+
- **Active tab semantics:** "active tab" = the focused tab of the last focused Chrome window. Override with `--tab <id>`.
|
|
40
|
+
- **Act commands act on the live page** the user can see — be explicit with the user before running `open`/`click`/`fill`/`press` if the action is irreversible (submitting forms, sending messages, deleting). For `press Enter` on search forms, prefer `click` on the submit button: synthetic KeyboardEvents are untrusted and many sites ignore them.
|
|
41
|
+
- **No headless:** if `superduck doctor` says the native host is not reachable, ask the user to open Chrome / install the SuperDuck extension. Do not fall back to other browser automation.
|
|
42
|
+
|
|
43
|
+
## Self-bootstrap
|
|
44
|
+
|
|
45
|
+
If the `superduck` command is not found, it can be installed with:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g superduck
|
|
49
|
+
superduck setup # registers the native messaging manifest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
After that, the user opens Chrome, installs the SuperDuck extension, and `superduck doctor` should be all green.
|
package/bin/superduck.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 平台 shim: 找到当前平台的二进制并 spawn 它,完整透传 stdio + exit code。
|
|
3
|
+
"use strict";
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
const { platform, arch } = process;
|
|
9
|
+
const exeName = platform === "win32" ? "superduck.exe" : "superduck";
|
|
10
|
+
const pkg = `superduck-${platform}-${arch}`;
|
|
11
|
+
|
|
12
|
+
let binPath;
|
|
13
|
+
try {
|
|
14
|
+
binPath = require.resolve(`${pkg}/bin/${exeName}`);
|
|
15
|
+
} catch {
|
|
16
|
+
// 回退: 同 repo 自带二进制(开发场景)
|
|
17
|
+
const dev = path.resolve(__dirname, "..", "..", "chrome-native-host", "build", "superduck");
|
|
18
|
+
if (fs.existsSync(dev)) binPath = dev;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!binPath) {
|
|
22
|
+
console.error(`superduck: no prebuilt binary found for ${platform}-${arch}.`);
|
|
23
|
+
console.error(`expected optional dependency '${pkg}'.`);
|
|
24
|
+
console.error(`if you are on a supported platform, try: npm install -g --force superduck`);
|
|
25
|
+
process.exit(127);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// --postinstall 仅 chmod, 不实际跑二进制
|
|
29
|
+
if (process.argv[2] === "--postinstall") {
|
|
30
|
+
try {
|
|
31
|
+
if (platform !== "win32") fs.chmodSync(binPath, 0o755);
|
|
32
|
+
} catch (e) {}
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
37
|
+
if (result.error) {
|
|
38
|
+
console.error("superduck:", result.error.message);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
process.exit(result.status ?? 0);
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "superduck-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Your browser's session, callable as a tool. CLI bridge from Claude Code/Codex/etc to your active Chrome tab.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"superduck": "bin/superduck.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"SKILL.md",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"postinstall": "node bin/superduck.js --postinstall || true"
|
|
15
|
+
},
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"superduck-darwin-arm64": "0.1.0",
|
|
18
|
+
"superduck-darwin-x64": "0.1.0",
|
|
19
|
+
"superduck-linux-arm64": "0.1.0",
|
|
20
|
+
"superduck-linux-x64": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=16"
|
|
24
|
+
},
|
|
25
|
+
"keywords": ["claude-code", "agent", "browser", "chrome", "cli"],
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|