opencode-quick-links 1.0.1 → 1.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/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +34 -22
- package/dist/tui.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,22 +21,28 @@ OpenCode installs npm plugins automatically at startup.
|
|
|
21
21
|
|
|
22
22
|
Select **Open session links** from the command palette or run `/links`. Search the dialog and press Enter to open the selected URL in your browser.
|
|
23
23
|
|
|
24
|
-
The plugin scans the active conversation when you open the dialog. It includes HTTP and HTTPS links from user
|
|
24
|
+
The plugin scans the active conversation when you open the dialog. It includes HTTP and HTTPS links from user messages, assistant messages, and tool outputs, lists the most recent first, and removes duplicates.
|
|
25
25
|
|
|
26
26
|
## Configure
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
No shortcut is assigned by default. Set `options.keybind` on the plugin entry in `cli.json`:
|
|
29
29
|
|
|
30
30
|
```json
|
|
31
31
|
{
|
|
32
32
|
"$schema": "https://opencode.ai/v2/cli.json",
|
|
33
|
-
"plugins": [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
"plugins": [
|
|
34
|
+
{
|
|
35
|
+
"package": "opencode-quick-links",
|
|
36
|
+
"options": { "keybind": "ctrl+shift+o" }
|
|
37
|
+
}
|
|
38
|
+
]
|
|
37
39
|
}
|
|
38
40
|
```
|
|
39
41
|
|
|
42
|
+
Use any OpenCode key sequence, such as `alt+l` or `<leader>o`. Omit `keybind`, or set it to `false` or `"none"`, to disable the shortcut. `/links` and the command palette remain available.
|
|
43
|
+
|
|
44
|
+
OpenCode's top-level `keybinds` configuration currently accepts built-in command IDs only; configure this plugin's shortcut through `options.keybind` instead.
|
|
45
|
+
|
|
40
46
|
## Local Development
|
|
41
47
|
|
|
42
48
|
OpenCode auto-loads the local source from `.opencode/plugins/quick-links/` when run from the package directory.
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;;AA6D7C,wBAwDE"}
|
package/dist/tui.js
CHANGED
|
@@ -15,40 +15,52 @@ function trimLink(url) {
|
|
|
15
15
|
}
|
|
16
16
|
return url.replace(TRAILING_PUNCTUATION, "");
|
|
17
17
|
}
|
|
18
|
+
function messageTexts(message) {
|
|
19
|
+
if (message.type === "user")
|
|
20
|
+
return [message.text];
|
|
21
|
+
if (message.type !== "assistant")
|
|
22
|
+
return [];
|
|
23
|
+
return message.content.flatMap((part) => {
|
|
24
|
+
if (part.type === "text")
|
|
25
|
+
return [part.text];
|
|
26
|
+
if (part.type !== "tool")
|
|
27
|
+
return [];
|
|
28
|
+
if (part.state.status !== "completed" && part.state.status !== "error")
|
|
29
|
+
return [];
|
|
30
|
+
return (part.state.content ?? []).flatMap((content) => content.type === "text" ? [content.text] : []);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
18
33
|
function extractLinks(messages) {
|
|
19
|
-
const
|
|
20
|
-
const links = [];
|
|
34
|
+
const urls = [];
|
|
21
35
|
for (const message of messages) {
|
|
22
|
-
const
|
|
23
|
-
? [message.text]
|
|
24
|
-
: message.type === "assistant"
|
|
25
|
-
? message.content.flatMap((part) => part.type === "text" ? [part.text] : [])
|
|
26
|
-
: [];
|
|
27
|
-
for (const text of texts) {
|
|
36
|
+
for (const text of messageTexts(message)) {
|
|
28
37
|
for (const match of text.matchAll(URL_PATTERN)) {
|
|
29
|
-
const candidate = trimLink(match[0]);
|
|
30
|
-
let url;
|
|
31
38
|
try {
|
|
32
|
-
const parsed = new URL(
|
|
33
|
-
if (parsed.protocol
|
|
34
|
-
|
|
35
|
-
url = parsed.href;
|
|
39
|
+
const parsed = new URL(trimLink(match[0]));
|
|
40
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:")
|
|
41
|
+
urls.push(parsed.href);
|
|
36
42
|
}
|
|
37
|
-
catch {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (seen.has(url))
|
|
41
|
-
continue;
|
|
42
|
-
seen.add(url);
|
|
43
|
-
links.push({ url });
|
|
43
|
+
catch { }
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
const links = [];
|
|
49
|
+
for (const url of urls.reverse()) {
|
|
50
|
+
if (seen.has(url))
|
|
51
|
+
continue;
|
|
52
|
+
seen.add(url);
|
|
53
|
+
links.push({ url });
|
|
54
|
+
}
|
|
47
55
|
return links;
|
|
48
56
|
}
|
|
49
57
|
export default Plugin.define({
|
|
50
58
|
id: "opencode-quick-links",
|
|
51
59
|
setup(ctx) {
|
|
60
|
+
const keybind = ctx.options.keybind ?? false;
|
|
61
|
+
if (keybind !== false && (typeof keybind !== "string" || keybind.trim() === "")) {
|
|
62
|
+
throw new Error("opencode-quick-links keybind option must be a non-empty string or false");
|
|
63
|
+
}
|
|
52
64
|
async function showQuickLinks() {
|
|
53
65
|
const route = ctx.ui.router.current();
|
|
54
66
|
if (route.type !== "session") {
|
|
@@ -80,6 +92,7 @@ export default Plugin.define({
|
|
|
80
92
|
commands: [
|
|
81
93
|
{
|
|
82
94
|
id: "quick-links.open",
|
|
95
|
+
bind: keybind === "none" ? false : keybind,
|
|
83
96
|
title: "Open session links",
|
|
84
97
|
group: "Plugin",
|
|
85
98
|
palette: true,
|
|
@@ -89,7 +102,6 @@ export default Plugin.define({
|
|
|
89
102
|
}),
|
|
90
103
|
},
|
|
91
104
|
],
|
|
92
|
-
bindings: ["quick-links.open"],
|
|
93
105
|
}));
|
|
94
106
|
return null;
|
|
95
107
|
},
|
package/dist/tui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,WAAW,GAAG,0BAA0B,CAAA;AAC9C,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAM7C,SAAS,QAAQ,CAAC,GAAW;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAChD,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG;YAAE,KAAK,EAAE,CAAA;QAC/B,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG;YAAE,SAAQ;QAChC,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;QAC7E,KAAK,EAAE,CAAA;IACT,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;AAC9C,CAAC;
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,WAAW,GAAG,0BAA0B,CAAA;AAC9C,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAM7C,SAAS,QAAQ,CAAC,GAAW;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,IAAI,KAAK,GAAG,CAAC,EAA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IAAI,CAAC,GAAG;gBAAE,OAAM;YAChB,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;YAC1F,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE,KAAK;YACb,MAAM;gBACJ,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;oBACtB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE;wBACR;4BACE,EAAE,EAAE,kBAAkB;4BACtB,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;4BAC1C,KAAK,EAAE,oBAAoB;4BAC3B,KAAK,EAAE,QAAQ;4BACf,OAAO,EAAE,IAAI;4BACb,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;4BACxB,GAAG,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gCACrC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAAA;4BACnF,CAAC,CAAC;yBACH;qBACF;iBACF,CAAC,CAAC,CAAA;gBACH,OAAO,IAAI,CAAA;YACb,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "opencode-quick-links",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "OpenCode TUI plugin for searching and opening links from the active conversation.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|