opencode-quick-links 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/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/tui.d.ts +6 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +102 -0
- package/dist/tui.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vimtor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# opencode-quick-links
|
|
2
|
+
|
|
3
|
+
OpenCode TUI plugin for searching and opening links from the active conversation.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Add the package to your OpenCode TUI config:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
12
|
+
"plugin": ["opencode-quick-links"]
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
OpenCode installs npm plugins automatically at startup.
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
The plugin scans the active conversation when you open the dialog. It includes HTTP and HTTPS links from user and assistant messages and removes duplicates.
|
|
23
|
+
|
|
24
|
+
## Configure
|
|
25
|
+
|
|
26
|
+
The plugin does not register a default shortcut. Add one through your OpenCode TUI config if wanted:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"$schema": "https://opencode.ai/tui.json",
|
|
31
|
+
"plugin": ["opencode-quick-links"],
|
|
32
|
+
"keybinds": {
|
|
33
|
+
"quick-links.open": "<leader>l"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Local Development
|
|
39
|
+
|
|
40
|
+
This package includes `.opencode/tui.json`, so OpenCode loads the local source when you run it from the package directory.
|
|
41
|
+
|
|
42
|
+
From the monorepo root:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install
|
|
46
|
+
npm run typecheck -w opencode-quick-links
|
|
47
|
+
npm run build -w opencode-quick-links
|
|
48
|
+
npm run smoke -w opencode-quick-links
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Restart OpenCode after changing plugin files or config.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
package/dist/tui.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":";;;;AA+DA,wBA4D2B"}
|
package/dist/tui.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import open from "open";
|
|
2
|
+
const URL_PATTERN = /https?:\/\/[^\s<>"'`]+/gi;
|
|
3
|
+
const TRAILING_PUNCTUATION = /[\],.;:!?}]+$/;
|
|
4
|
+
function currentSessionID(route) {
|
|
5
|
+
if (route.name !== "session")
|
|
6
|
+
return;
|
|
7
|
+
const sessionID = route.params?.sessionID;
|
|
8
|
+
return typeof sessionID === "string" ? sessionID : undefined;
|
|
9
|
+
}
|
|
10
|
+
function trimTrailingParentheses(url) {
|
|
11
|
+
let result = url;
|
|
12
|
+
while (result.endsWith(")")) {
|
|
13
|
+
const opening = (result.match(/\(/g) ?? []).length;
|
|
14
|
+
const closing = (result.match(/\)/g) ?? []).length;
|
|
15
|
+
if (closing <= opening)
|
|
16
|
+
break;
|
|
17
|
+
result = result.slice(0, -1);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function extractLinks(messages) {
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
const links = [];
|
|
24
|
+
for (const message of messages) {
|
|
25
|
+
for (const part of message.parts) {
|
|
26
|
+
if (part.type !== "text" || typeof part.text !== "string")
|
|
27
|
+
continue;
|
|
28
|
+
for (const match of part.text.matchAll(URL_PATTERN)) {
|
|
29
|
+
const candidate = trimTrailingParentheses(match[0].replace(TRAILING_PUNCTUATION, ""));
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
const parsed = new URL(candidate);
|
|
33
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
34
|
+
continue;
|
|
35
|
+
url = parsed.href;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (seen.has(url))
|
|
41
|
+
continue;
|
|
42
|
+
seen.add(url);
|
|
43
|
+
links.push({ url });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return links;
|
|
48
|
+
}
|
|
49
|
+
export default {
|
|
50
|
+
id: "opencode-quick-links",
|
|
51
|
+
tui: async (api) => {
|
|
52
|
+
async function showQuickLinks() {
|
|
53
|
+
const sessionID = currentSessionID(api.route.current);
|
|
54
|
+
if (!sessionID) {
|
|
55
|
+
api.ui.toast({ variant: "warning", message: "Start a session." });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const result = await api.client.session.messages({ sessionID });
|
|
59
|
+
if (result.error) {
|
|
60
|
+
api.ui.toast({ variant: "error", message: "Could not load session links." });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const links = extractLinks(result.data);
|
|
64
|
+
if (links.length === 0) {
|
|
65
|
+
api.ui.toast({ variant: "info", message: "No links found in this session." });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
api.ui.dialog.replace(() => api.ui.DialogSelect({
|
|
69
|
+
title: "Quick Links",
|
|
70
|
+
placeholder: "Search links",
|
|
71
|
+
options: links.map((link) => ({
|
|
72
|
+
title: link.url,
|
|
73
|
+
value: link.url,
|
|
74
|
+
})),
|
|
75
|
+
onSelect: (option) => {
|
|
76
|
+
api.ui.dialog.clear();
|
|
77
|
+
void open(option.value).catch(() => {
|
|
78
|
+
api.ui.toast({ variant: "warning", title: "Could not open browser", message: option.value });
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
function runQuickLinks() {
|
|
84
|
+
void showQuickLinks().catch(() => {
|
|
85
|
+
api.ui.toast({ variant: "error", message: "Could not load session links." });
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (!api.command)
|
|
89
|
+
throw new Error("opencode-quick-links requires the TUI command API");
|
|
90
|
+
const dispose = api.command.register(() => [
|
|
91
|
+
{
|
|
92
|
+
title: "Open session links",
|
|
93
|
+
value: "quick-links.open",
|
|
94
|
+
category: "Plugin",
|
|
95
|
+
slash: { name: "links" },
|
|
96
|
+
onSelect: runQuickLinks,
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
api.lifecycle.onDispose(dispose);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=tui.js.map
|
package/dist/tui.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../plugin/src/tui.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,WAAW,GAAG,0BAA0B,CAAA;AAC9C,MAAM,oBAAoB,GAAG,eAAe,CAAA;AAM5C,SAAS,gBAAgB,CAAC,KAAyD;IACjF,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAM;IACpC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAA;IACzC,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9D,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAW;IAC1C,IAAI,MAAM,GAAG,GAAG,CAAA;IAEhB,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAA;QAClD,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAA;QAClD,IAAI,OAAO,IAAI,OAAO;YAAE,MAAK;QAC7B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,YAA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AAC,KAAK,CAAC,GAAG,EAAE;wBACjC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;oBAC9F,CAAC,CAAC,CAAA;gBACJ,CAAC;aACF,CAAC,CACH,CAAA;QACH,CAAC;QAED,SAAS,aAAa;YACpB,KAAK,cAAc,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC/B,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAAA;YAC9E,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;QAEtF,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACzC;gBACE,KAAK,EAAE,oBAAoB;gBAC3B,KAAK,EAAE,kBAAkB;gBACzB,QAAQ,EAAE,QAAQ;gBAClB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;gBACxB,QAAQ,EAAE,aAAa;aACxB;SACF,CAAC,CAAA;QAEF,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;CACwB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "opencode-quick-links",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "OpenCode TUI plugin for searching and opening links from the active conversation.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./tui": {
|
|
9
|
+
"types": "./dist/tui.d.ts",
|
|
10
|
+
"import": "./dist/tui.js",
|
|
11
|
+
"default": "./dist/tui.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"smoke": "node -e \"import('./dist/tui.js').then((m) => { if (!m.default?.tui) throw new Error('missing tui plugin export') })\"",
|
|
23
|
+
"pack:dry-run": "npm pack --dry-run",
|
|
24
|
+
"prepack": "npm run build && npm run smoke",
|
|
25
|
+
"prepublishOnly": "npm run typecheck && npm run prepack"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"opencode",
|
|
29
|
+
"opencode-plugin",
|
|
30
|
+
"opencode-tui",
|
|
31
|
+
"plugin",
|
|
32
|
+
"links",
|
|
33
|
+
"browser",
|
|
34
|
+
"ai"
|
|
35
|
+
],
|
|
36
|
+
"author": "vimtor",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/vimtor/opencode-plugins.git",
|
|
41
|
+
"directory": "packages/opencode-quick-links"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/vimtor/opencode-plugins/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/vimtor/opencode-plugins/tree/main/packages/opencode-quick-links#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"provenance": true
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"opencode": ">=1.15.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"open": "^10.1.2"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@opencode-ai/plugin": ">=1.15.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@opencode-ai/plugin": "^1.15.1",
|
|
62
|
+
"typescript": "^5.9.3"
|
|
63
|
+
}
|
|
64
|
+
}
|