webctx 0.2.1
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/AGENTS.md +97 -0
- package/CONTRIBUTORS.md +126 -0
- package/LICENSE +202 -0
- package/Makefile +69 -0
- package/README.md +121 -0
- package/bin/webctx.js +28 -0
- package/cmd/webctx/main.go +11 -0
- package/docs/porting-status.md +173 -0
- package/go.mod +3 -0
- package/internal/app/app.go +139 -0
- package/internal/app/app_test.go +194 -0
- package/internal/app/github.go +2084 -0
- package/internal/app/github_acceptance_test.go +166 -0
- package/internal/app/github_actions.go +1008 -0
- package/internal/app/github_actions_test.go +484 -0
- package/internal/app/github_activity_deployments.go +503 -0
- package/internal/app/github_activity_deployments_test.go +321 -0
- package/internal/app/github_commits.go +1004 -0
- package/internal/app/github_commits_test.go +503 -0
- package/internal/app/github_discussions_gists.go +1156 -0
- package/internal/app/github_discussions_gists_test.go +425 -0
- package/internal/app/github_issues.go +1616 -0
- package/internal/app/github_issues_test.go +731 -0
- package/internal/app/github_packages_projects.go +429 -0
- package/internal/app/github_packages_projects_test.go +168 -0
- package/internal/app/github_phase9_overview_stress_test.go +178 -0
- package/internal/app/github_pull_views.go +1141 -0
- package/internal/app/github_pull_views_test.go +603 -0
- package/internal/app/github_pulls.go +1459 -0
- package/internal/app/github_pulls_test.go +715 -0
- package/internal/app/github_refs.go +621 -0
- package/internal/app/github_refs_test.go +260 -0
- package/internal/app/github_search_profiles.go +505 -0
- package/internal/app/github_search_profiles_test.go +352 -0
- package/internal/app/github_test.go +888 -0
- package/internal/app/scrape.go +264 -0
- package/internal/app/tools.go +670 -0
- package/internal/buildinfo/buildinfo.go +16 -0
- package/package.json +66 -0
- package/scripts/postinstall.js +137 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Guidance for coding agents working in `webctx`.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This repo contains the pure Go port of the `webctx` CLI.
|
|
8
|
+
|
|
9
|
+
It is no longer a generic starter template. Treat the current CLI behavior as the source of truth unless the user explicitly asks to change it.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
- `cmd/webctx/main.go`: process entrypoint, exit-code based dispatch.
|
|
14
|
+
- `internal/app/app.go`: CLI parsing and top-level command routing.
|
|
15
|
+
- `internal/app/tools.go`: search provider clients, ranking, formatting, and HTTP helpers.
|
|
16
|
+
- `internal/app/scrape.go`: GitHub raw-content optimization, `.md` fetch path, Firecrawl queue, and env loading.
|
|
17
|
+
- `internal/app/app_test.go`: unit tests for CLI behavior and core helpers.
|
|
18
|
+
- `bin/webctx.js`: npm shim that invokes the packaged native binary.
|
|
19
|
+
- `scripts/postinstall.js`: downloads release binary on install, falls back to `go build`.
|
|
20
|
+
- `.github/workflows/release.yml`: tag-driven release pipeline.
|
|
21
|
+
- `docs/porting-status.md`: progress log and remaining work for future agents.
|
|
22
|
+
|
|
23
|
+
## Local commands
|
|
24
|
+
|
|
25
|
+
Use `make` targets:
|
|
26
|
+
|
|
27
|
+
- `make fmt`
|
|
28
|
+
- `make test`
|
|
29
|
+
- `make vet`
|
|
30
|
+
- `make lint`
|
|
31
|
+
- `make check`
|
|
32
|
+
- `make build`
|
|
33
|
+
- `make build-all`
|
|
34
|
+
- `make install-local`
|
|
35
|
+
|
|
36
|
+
Direct commands:
|
|
37
|
+
|
|
38
|
+
- `go test ./...`
|
|
39
|
+
- `go vet ./...`
|
|
40
|
+
- `npm run lint`
|
|
41
|
+
|
|
42
|
+
## Current CLI contract
|
|
43
|
+
|
|
44
|
+
Preserve these commands unless the user explicitly asks to change them:
|
|
45
|
+
|
|
46
|
+
- `webctx search <query> [--exclude domain1,domain2] [--keyword phrase]`
|
|
47
|
+
- `webctx read-link <url>`
|
|
48
|
+
- `webctx map-site <url>`
|
|
49
|
+
- `webctx --version`
|
|
50
|
+
|
|
51
|
+
Behavioral expectations:
|
|
52
|
+
|
|
53
|
+
- `search` combines Brave, Tavily, and Exa results, then re-ranks them with duplicate-aware scoring.
|
|
54
|
+
- `read-link` keeps the current GitHub raw-content fast path, `.md` fast path, and Firecrawl fallback settings.
|
|
55
|
+
- `map-site` keeps the current Firecrawl map request settings.
|
|
56
|
+
- The CLI should remain agent-friendly and emit plain markdown/text output.
|
|
57
|
+
|
|
58
|
+
## How to change things safely
|
|
59
|
+
|
|
60
|
+
1. Keep binary naming convention unchanged unless you also update postinstall/workflow:
|
|
61
|
+
- release assets: `<cli>_<goos>_<goarch>[.exe]`
|
|
62
|
+
- npm-installed binary path: `bin/<cli>-bin` (or `.exe` on Windows)
|
|
63
|
+
|
|
64
|
+
2. If changing search behavior, compare against the TypeScript porting notes in `docs/porting-status.md` first.
|
|
65
|
+
|
|
66
|
+
3. If adding dependencies, commit `go.sum` and make sure the workflow still passes on a clean checkout.
|
|
67
|
+
|
|
68
|
+
4. If you change release artifacts or version plumbing, update `Makefile`, `.github/workflows/release.yml`, and `scripts/postinstall.js` together.
|
|
69
|
+
|
|
70
|
+
## Release contract
|
|
71
|
+
|
|
72
|
+
Release pipeline triggers on `v*` tags and expects:
|
|
73
|
+
|
|
74
|
+
- `NPM_TOKEN` GitHub secret present.
|
|
75
|
+
- npm package name in `package.json` is publishable under your account/org.
|
|
76
|
+
- repository URL matches the release origin used by `scripts/postinstall.js`.
|
|
77
|
+
|
|
78
|
+
Release binaries should embed the tagged version into `internal/buildinfo.Version` so `webctx --version` matches the release tag.
|
|
79
|
+
|
|
80
|
+
## Guardrails
|
|
81
|
+
|
|
82
|
+
- Prefer additive changes and keep the CLI output stable.
|
|
83
|
+
- Do not silently change Firecrawl request settings unless the user explicitly wants behavioral changes.
|
|
84
|
+
- Do not reintroduce MCP/server code unless requested; this repo is intentionally CLI-only.
|
|
85
|
+
|
|
86
|
+
## Changelog Guidelines
|
|
87
|
+
|
|
88
|
+
When cutting a release, update `src/content/docs/changelog.md` before tagging.
|
|
89
|
+
|
|
90
|
+
- Add a new section for the exact version tag being released.
|
|
91
|
+
- Keep the newest version at the top.
|
|
92
|
+
- Skip versions that do not have git tags.
|
|
93
|
+
- Use commit history and diffs on `main` to summarize code changes.
|
|
94
|
+
- This is an OSS project, so internal code changes may be included when useful.
|
|
95
|
+
- Do not include docs-site-only changes such as site styling, Zuedocs/package bumps, deploy plumbing, footer/layout changes, or documentation navigation changes.
|
|
96
|
+
- Rewrite commit subjects into clear release notes instead of pasting raw commit messages.
|
|
97
|
+
- If a release contains only tagging/release metadata, write: `Maintenance release. No direct code behavior changes beyond release preparation.`
|
package/CONTRIBUTORS.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# CONTRIBUTORS.md
|
|
2
|
+
|
|
3
|
+
Maintainer notes for `webctx`.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Go `1.26+`
|
|
8
|
+
- Node `18+`
|
|
9
|
+
- npm account with publish rights for the package name in `package.json`
|
|
10
|
+
- GitHub repo admin access
|
|
11
|
+
|
|
12
|
+
## Build from source
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/amxv/webctx.git
|
|
16
|
+
cd webctx
|
|
17
|
+
make build
|
|
18
|
+
./dist/webctx --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Local development
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
make check
|
|
25
|
+
make build
|
|
26
|
+
./dist/webctx --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Example command checks:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
./dist/webctx --version
|
|
33
|
+
./dist/webctx search "golang http client"
|
|
34
|
+
./dist/webctx read-link https://github.com/amxv/webctx-ts/blob/main/cli.ts
|
|
35
|
+
./dist/webctx map-site https://example.com
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Install command locally:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
make install-local
|
|
42
|
+
webctx --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Release and distribution
|
|
46
|
+
|
|
47
|
+
This repo ships in two ways:
|
|
48
|
+
|
|
49
|
+
- GitHub Releases for native binaries
|
|
50
|
+
- npm for `npm i -g webctx`
|
|
51
|
+
|
|
52
|
+
The release workflow triggers on `v*` tags and does the following:
|
|
53
|
+
|
|
54
|
+
1. runs Go and Node quality checks
|
|
55
|
+
2. builds cross-platform binaries
|
|
56
|
+
3. creates a GitHub Release with those assets
|
|
57
|
+
4. publishes the npm package using the tag version
|
|
58
|
+
|
|
59
|
+
## Release process
|
|
60
|
+
|
|
61
|
+
1. Ensure `main` is green:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
make check
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. Confirm the release workflow is targeting `webctx` and that `package.json` still points to the correct GitHub repository.
|
|
68
|
+
|
|
69
|
+
3. Prepare release tag:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
make release-tag VERSION=x.y.z
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
4. GitHub Actions `release` workflow runs automatically:
|
|
76
|
+
- quality checks
|
|
77
|
+
- cross-platform binary build
|
|
78
|
+
- GitHub release publish
|
|
79
|
+
- npm publish
|
|
80
|
+
|
|
81
|
+
## Required GitHub secret
|
|
82
|
+
|
|
83
|
+
- `NPM_TOKEN`: npm automation token with publish rights for your package.
|
|
84
|
+
|
|
85
|
+
Set via GitHub CLI:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
gh secret set NPM_TOKEN --repo amxv/webctx
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## npm token setup
|
|
92
|
+
|
|
93
|
+
Create token at npm:
|
|
94
|
+
|
|
95
|
+
- Profile -> Access Tokens -> Create New Token
|
|
96
|
+
- Use an automation/granular token scoped to required package/org
|
|
97
|
+
|
|
98
|
+
Validate auth locally:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm whoami
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Project layout
|
|
105
|
+
|
|
106
|
+
- `cmd/webctx/main.go`: CLI entrypoint
|
|
107
|
+
- `internal/app/`: CLI parsing, search, ranking, scrape, env loading, and Firecrawl queue logic
|
|
108
|
+
- `internal/buildinfo/`: build-time version plumbing for `--version`
|
|
109
|
+
- `bin/webctx.js`: npm shim that invokes the packaged native binary
|
|
110
|
+
- `scripts/postinstall.js`: downloads the release binary on install and falls back to local `go build`
|
|
111
|
+
- `.github/workflows/release.yml`: tag-driven release pipeline
|
|
112
|
+
- `AGENTS.md`: guidance for coding agents
|
|
113
|
+
|
|
114
|
+
## Notes on package naming
|
|
115
|
+
|
|
116
|
+
`webctx` is already configured. If you ever rename or move the package, update all of the following together:
|
|
117
|
+
|
|
118
|
+
- `package.json`
|
|
119
|
+
- `bin/webctx.js`
|
|
120
|
+
- `scripts/postinstall.js`
|
|
121
|
+
- `.github/workflows/release.yml`
|
|
122
|
+
- `Makefile`
|
|
123
|
+
|
|
124
|
+
## Porting reference
|
|
125
|
+
|
|
126
|
+
The repo includes `docs/porting-status.md` as the running reference for what was ported from `webctx-ts`, what was intentionally excluded, and what future agents should verify before making behavior changes.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 amxv <a@ashray.xyz>
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/Makefile
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
SHELL := /bin/bash
|
|
2
|
+
|
|
3
|
+
GO ?= go
|
|
4
|
+
GOFMT ?= gofmt
|
|
5
|
+
BIN_NAME ?= webctx
|
|
6
|
+
CMD_PATH ?= ./cmd/$(BIN_NAME)
|
|
7
|
+
DIST_DIR ?= dist
|
|
8
|
+
BIN_PATH ?= $(DIST_DIR)/$(BIN_NAME)
|
|
9
|
+
VERSION ?= $(shell node -p "require('./package.json').version" 2>/dev/null)
|
|
10
|
+
LDFLAGS ?= -s -w -X github.com/amxv/webctx/internal/buildinfo.Version=$(if $(VERSION),$(VERSION),dev)
|
|
11
|
+
|
|
12
|
+
.PHONY: help fmt test vet lint check build build-all install-local clean release-tag
|
|
13
|
+
|
|
14
|
+
help:
|
|
15
|
+
@echo "webctx command runner"
|
|
16
|
+
@echo ""
|
|
17
|
+
@echo "Targets:"
|
|
18
|
+
@echo " make fmt - format Go files"
|
|
19
|
+
@echo " make test - run go test ./..."
|
|
20
|
+
@echo " make vet - run go vet ./..."
|
|
21
|
+
@echo " make lint - run Node script checks"
|
|
22
|
+
@echo " make check - fmt + test + vet + lint"
|
|
23
|
+
@echo " make build - build local binary to dist/webctx"
|
|
24
|
+
@echo " make build-all - build release binaries for 5 target platforms"
|
|
25
|
+
@echo " make install-local - install CLI to ~/.local/bin/webctx"
|
|
26
|
+
@echo " make clean - remove dist artifacts"
|
|
27
|
+
@echo " make release-tag - create and push git tag (requires VERSION=x.y.z)"
|
|
28
|
+
|
|
29
|
+
fmt:
|
|
30
|
+
@$(GOFMT) -w $$(find . -type f -name '*.go' -not -path './dist/*')
|
|
31
|
+
|
|
32
|
+
test:
|
|
33
|
+
@$(GO) test ./...
|
|
34
|
+
|
|
35
|
+
vet:
|
|
36
|
+
@$(GO) vet ./...
|
|
37
|
+
|
|
38
|
+
lint:
|
|
39
|
+
@npm run lint
|
|
40
|
+
|
|
41
|
+
check: fmt test vet lint
|
|
42
|
+
|
|
43
|
+
build:
|
|
44
|
+
@mkdir -p $(DIST_DIR)
|
|
45
|
+
@$(GO) build -trimpath -ldflags="$(LDFLAGS)" -o $(BIN_PATH) $(CMD_PATH)
|
|
46
|
+
|
|
47
|
+
build-all:
|
|
48
|
+
@mkdir -p $(DIST_DIR)
|
|
49
|
+
@for target in "darwin amd64" "darwin arm64" "linux amd64" "linux arm64" "windows amd64"; do \
|
|
50
|
+
set -- $$target; \
|
|
51
|
+
GOOS=$$1; GOARCH=$$2; \
|
|
52
|
+
EXT=""; \
|
|
53
|
+
if [ "$$GOOS" = "windows" ]; then EXT=".exe"; fi; \
|
|
54
|
+
echo "Building $(BIN_NAME) for $$GOOS/$$GOARCH"; \
|
|
55
|
+
CGO_ENABLED=0 GOOS=$$GOOS GOARCH=$$GOARCH $(GO) build -trimpath -ldflags="$(LDFLAGS)" -o "$(DIST_DIR)/$(BIN_NAME)_$${GOOS}_$${GOARCH}$${EXT}" $(CMD_PATH); \
|
|
56
|
+
done
|
|
57
|
+
|
|
58
|
+
install-local: build
|
|
59
|
+
@mkdir -p $$HOME/.local/bin
|
|
60
|
+
@install -m 755 $(BIN_PATH) $$HOME/.local/bin/$(BIN_NAME)
|
|
61
|
+
@echo "Installed $(BIN_NAME) to $$HOME/.local/bin/$(BIN_NAME)"
|
|
62
|
+
|
|
63
|
+
clean:
|
|
64
|
+
@rm -rf $(DIST_DIR)
|
|
65
|
+
|
|
66
|
+
release-tag:
|
|
67
|
+
@test -n "$(VERSION)" || (echo "Usage: make release-tag VERSION=x.y.z" && exit 1)
|
|
68
|
+
@git tag "v$(VERSION)"
|
|
69
|
+
@git push origin "v$(VERSION)"
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# webctx
|
|
2
|
+
|
|
3
|
+
Web context for agents, from the terminal.
|
|
4
|
+
|
|
5
|
+
`webctx` gives you three small commands:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
webctx search "agent web research"
|
|
9
|
+
webctx read-link <url>
|
|
10
|
+
webctx map-site <url>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The output is plain text or markdown, so it is easy to hand to ChatGPT, Codex, Claude Code, a shell script, or another tool.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i -g webctx
|
|
19
|
+
webctx --help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Prebuilt binaries are also available from GitHub Releases.
|
|
23
|
+
|
|
24
|
+
## Why `read-link` is useful
|
|
25
|
+
|
|
26
|
+
Paste the URL you already have. webctx tries to understand what that URL means and returns the useful part instead of browser chrome.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Repository overview + README preview
|
|
30
|
+
webctx read-link https://github.com/amxv/webctx
|
|
31
|
+
|
|
32
|
+
# Exact source lines
|
|
33
|
+
webctx read-link 'https://github.com/amxv/webctx/blob/main/README.md#L1-L20'
|
|
34
|
+
|
|
35
|
+
# One directory
|
|
36
|
+
webctx read-link https://github.com/amxv/webctx/tree/main/internal/app
|
|
37
|
+
|
|
38
|
+
# Issue conversation
|
|
39
|
+
webctx read-link https://github.com/amxv/webctx/issues/6
|
|
40
|
+
|
|
41
|
+
# Pull request conversation
|
|
42
|
+
webctx read-link https://github.com/amxv/webctx/pull/15
|
|
43
|
+
|
|
44
|
+
# A single inline review thread
|
|
45
|
+
webctx read-link 'https://github.com/cli/cli/pull/13250#discussion_r3118513169'
|
|
46
|
+
|
|
47
|
+
# Files changed, commits, or checks
|
|
48
|
+
webctx read-link https://github.com/amxv/webctx/pull/15/files
|
|
49
|
+
webctx read-link https://github.com/amxv/webctx/pull/15/commits
|
|
50
|
+
webctx read-link https://github.com/amxv/webctx/pull/15/checks
|
|
51
|
+
|
|
52
|
+
# Exact Actions job + log when GitHub allows it
|
|
53
|
+
webctx read-link https://github.com/amxv/webctx/actions/runs/<run-id>/job/<job-id>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The same idea works for commits, comparisons, path history, blame, releases, Discussions, Gists, GitHub Search, profiles, Projects, deployments, and other supported GitHub views.
|
|
57
|
+
|
|
58
|
+
Large GitHub roots are intentionally navigation-first: webctx keeps authoritative metadata plus bounded previews/indexes and prints the exact GitHub URLs needed to go deeper. Copied source/comment/thread/diff/check/Gist selectors read the selected item, while explicit `.diff`/`.patch` URLs remain bulk raw representations. Provider pagination/ceilings and webctx's own local omissions are reported as separate facts.
|
|
59
|
+
|
|
60
|
+
For normal websites, webctx tries a clean markdown path first and falls back to Firecrawl when it needs rendered-page extraction. Exact public GitHub Package pages have one explicit best-effort exception: if GitHub's Package API rejects the read for auth or permission reasons, webctx can crawl the public page with Firecrawl and clearly labels the result as best-effort.
|
|
61
|
+
|
|
62
|
+
Recognized native GitHub auth, private/not-found, and rate-limit failures stay authoritative rather than being hidden by a page crawl. GitHub routes outside the native grammar can still use the normal website fallback path.
|
|
63
|
+
|
|
64
|
+
## Search
|
|
65
|
+
|
|
66
|
+
Normal search asks Brave, Tavily, and Exa, removes duplicate URLs, and returns one useful list.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
webctx search "next.js server components"
|
|
70
|
+
webctx search "react hooks" --exclude youtube.com,medium.com
|
|
71
|
+
webctx search "drizzle orm" --keyword "migration guide"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Map a site
|
|
75
|
+
|
|
76
|
+
Use `map-site` when you want to discover the useful pages before reading them.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
webctx map-site https://docs.firecrawl.dev
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A common agent workflow is:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
webctx map-site https://some-docs.example
|
|
86
|
+
webctx read-link https://some-docs.example/getting-started
|
|
87
|
+
webctx read-link https://some-docs.example/api/reference
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Credentials
|
|
91
|
+
|
|
92
|
+
The simplest local setup is a `.env.local` file:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
BRAVE_API_KEY=...
|
|
96
|
+
TAVILY_API_KEY=...
|
|
97
|
+
EXA_API_KEY=...
|
|
98
|
+
FIRECRAWL_API_KEY=...
|
|
99
|
+
GH_TOKEN=...
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- `BRAVE_API_KEY`, `TAVILY_API_KEY`, and `EXA_API_KEY` power normal `search`.
|
|
103
|
+
- `FIRECRAWL_API_KEY` powers `map-site` and page-crawl fallbacks.
|
|
104
|
+
- `GH_TOKEN` or `GITHUB_TOKEN` is optional. It increases GitHub capacity and unlocks reads such as blame, Discussions, some Actions job logs, private resources the token can access, and richer PR review state.
|
|
105
|
+
|
|
106
|
+
Environment variables, `.env.local`, and macOS Keychain are supported. `GH_TOKEN` takes precedence over `GITHUB_TOKEN`.
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
Start with the guides in `src/content/docs`:
|
|
111
|
+
|
|
112
|
+
- **Quickstart** — get useful output immediately
|
|
113
|
+
- **Read a URL** — GitHub-aware reading and normal web pages
|
|
114
|
+
- **Use webctx with agents** — practical research, repo, PR, and CI workflows
|
|
115
|
+
- **Search the web** — federated search and filtering
|
|
116
|
+
- **Map a site** — discover pages before reading them
|
|
117
|
+
- **Credentials** — keys and optional GitHub auth
|
|
118
|
+
- **How URL reading works** — native/direct fast paths before Firecrawl
|
|
119
|
+
- **How search ranking works** — URL normalization, position scoring, and provider agreement
|
|
120
|
+
|
|
121
|
+
Maintainer notes, repository layout, development commands, and release steps live in [`CONTRIBUTORS.md`](CONTRIBUTORS.md).
|
package/bin/webctx.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
|
|
7
|
+
const pkg = require("../package.json");
|
|
8
|
+
const cliName = pkg.config?.cliBinaryName || "webctx";
|
|
9
|
+
const executableName = process.platform === "win32" ? `${cliName}.exe` : `${cliName}-bin`;
|
|
10
|
+
const executablePath = path.join(__dirname, executableName);
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(executablePath)) {
|
|
13
|
+
console.error(`${cliName} binary is not installed. Re-run: npm rebuild -g ${pkg.name}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const child = spawnSync(executablePath, process.argv.slice(2), { stdio: "inherit" });
|
|
18
|
+
|
|
19
|
+
if (child.error) {
|
|
20
|
+
console.error(child.error.message);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (child.signal) {
|
|
25
|
+
process.kill(process.pid, child.signal);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
process.exit(child.status ?? 1);
|