guanlan 0.1.1__tar.gz
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.
- guanlan-0.1.1/.env.example +15 -0
- guanlan-0.1.1/.github/workflows/pytest.yml +30 -0
- guanlan-0.1.1/.github/workflows/release-pypi.yml +223 -0
- guanlan-0.1.1/.gitignore +14 -0
- guanlan-0.1.1/AGENTS.md +27 -0
- guanlan-0.1.1/CHANGELOG.md +22 -0
- guanlan-0.1.1/CLAUDE.md +44 -0
- guanlan-0.1.1/CONTRIBUTING.md +107 -0
- guanlan-0.1.1/LICENSE +22 -0
- guanlan-0.1.1/NOTICE +27 -0
- guanlan-0.1.1/PKG-INFO +597 -0
- guanlan-0.1.1/README.md +553 -0
- guanlan-0.1.1/SECURITY.md +51 -0
- guanlan-0.1.1/config/mcporter.json +11 -0
- guanlan-0.1.1/constraints.txt +17 -0
- guanlan-0.1.1/docs/README_en.md +31 -0
- guanlan-0.1.1/docs/README_ja.md +29 -0
- guanlan-0.1.1/docs/README_ko.md +29 -0
- guanlan-0.1.1/docs/README_zh.md +30 -0
- guanlan-0.1.1/docs/SOURCE_ATTRIBUTION.md +43 -0
- guanlan-0.1.1/docs/agent-usage.md +373 -0
- guanlan-0.1.1/docs/assets/logo-1.png +0 -0
- guanlan-0.1.1/docs/assets/logo-1.svg +34 -0
- guanlan-0.1.1/docs/assets/logo-2.png +0 -0
- guanlan-0.1.1/docs/assets/logo-2.svg +51 -0
- guanlan-0.1.1/docs/assets/logo-3.png +0 -0
- guanlan-0.1.1/docs/assets/logo-3.svg +34 -0
- guanlan-0.1.1/docs/chinese-web-design.md +784 -0
- guanlan-0.1.1/docs/cookie-export.md +42 -0
- guanlan-0.1.1/docs/dependency-locking.md +30 -0
- guanlan-0.1.1/docs/install.md +215 -0
- guanlan-0.1.1/docs/release-automation.md +76 -0
- guanlan-0.1.1/docs/release-smoke-samples.md +56 -0
- guanlan-0.1.1/docs/troubleshooting.md +155 -0
- guanlan-0.1.1/docs/update.md +81 -0
- guanlan-0.1.1/guanlan/__init__.py +9 -0
- guanlan-0.1.1/guanlan/archive.py +522 -0
- guanlan-0.1.1/guanlan/channel_catalog.py +236 -0
- guanlan-0.1.1/guanlan/channels/__init__.py +76 -0
- guanlan-0.1.1/guanlan/channels/base.py +41 -0
- guanlan-0.1.1/guanlan/channels/bilibili.py +66 -0
- guanlan-0.1.1/guanlan/channels/douyin.py +57 -0
- guanlan-0.1.1/guanlan/channels/exa_search.py +39 -0
- guanlan-0.1.1/guanlan/channels/github.py +35 -0
- guanlan-0.1.1/guanlan/channels/hotnews.py +62 -0
- guanlan-0.1.1/guanlan/channels/linkedin.py +42 -0
- guanlan-0.1.1/guanlan/channels/open_websearch.py +46 -0
- guanlan-0.1.1/guanlan/channels/reddit.py +78 -0
- guanlan-0.1.1/guanlan/channels/rss.py +21 -0
- guanlan-0.1.1/guanlan/channels/twitter.py +87 -0
- guanlan-0.1.1/guanlan/channels/v2ex.py +213 -0
- guanlan-0.1.1/guanlan/channels/web.py +33 -0
- guanlan-0.1.1/guanlan/channels/wechat.py +64 -0
- guanlan-0.1.1/guanlan/channels/weibo.py +53 -0
- guanlan-0.1.1/guanlan/channels/xiaohongshu.py +165 -0
- guanlan-0.1.1/guanlan/channels/xiaoyuzhou.py +56 -0
- guanlan-0.1.1/guanlan/channels/xueqiu.py +235 -0
- guanlan-0.1.1/guanlan/channels/youtube.py +46 -0
- guanlan-0.1.1/guanlan/cli.py +2355 -0
- guanlan-0.1.1/guanlan/config.py +109 -0
- guanlan-0.1.1/guanlan/cookie_extract.py +264 -0
- guanlan-0.1.1/guanlan/core.py +42 -0
- guanlan-0.1.1/guanlan/doctor.py +304 -0
- guanlan-0.1.1/guanlan/guides/setup-exa.md +41 -0
- guanlan-0.1.1/guanlan/guides/setup-groq.md +47 -0
- guanlan-0.1.1/guanlan/guides/setup-reddit.md +54 -0
- guanlan-0.1.1/guanlan/guides/setup-twitter.md +84 -0
- guanlan-0.1.1/guanlan/guides/setup-wechat.md +40 -0
- guanlan-0.1.1/guanlan/guides/setup-xiaohongshu.md +85 -0
- guanlan-0.1.1/guanlan/hotnews.py +352 -0
- guanlan-0.1.1/guanlan/integrations/__init__.py +1 -0
- guanlan-0.1.1/guanlan/integrations/mcp_server.py +262 -0
- guanlan-0.1.1/guanlan/profiles.py +35 -0
- guanlan-0.1.1/guanlan/scripts/transcribe_xiaoyuzhou.sh +167 -0
- guanlan-0.1.1/guanlan/search_sources.py +259 -0
- guanlan-0.1.1/guanlan/skill/SKILL.md +136 -0
- guanlan-0.1.1/guanlan/skill/SKILL_en.md +290 -0
- guanlan-0.1.1/guanlan/skill/references/career.md +29 -0
- guanlan-0.1.1/guanlan/skill/references/dev.md +62 -0
- guanlan-0.1.1/guanlan/skill/references/search.md +175 -0
- guanlan-0.1.1/guanlan/skill/references/social.md +228 -0
- guanlan-0.1.1/guanlan/skill/references/video.md +115 -0
- guanlan-0.1.1/guanlan/skill/references/web.md +172 -0
- guanlan-0.1.1/guanlan/utils/paths.py +45 -0
- guanlan-0.1.1/guanlan/utils/text.py +14 -0
- guanlan-0.1.1/guanlan/webtools.py +1593 -0
- guanlan-0.1.1/llms.txt +25 -0
- guanlan-0.1.1/pyproject.toml +87 -0
- guanlan-0.1.1/scripts/sync-upstream.sh +72 -0
- guanlan-0.1.1/test.sh +93 -0
- guanlan-0.1.1/tests/test_archive.py +90 -0
- guanlan-0.1.1/tests/test_channel_contracts.py +157 -0
- guanlan-0.1.1/tests/test_channels.py +435 -0
- guanlan-0.1.1/tests/test_cli.py +232 -0
- guanlan-0.1.1/tests/test_config.py +84 -0
- guanlan-0.1.1/tests/test_core.py +29 -0
- guanlan-0.1.1/tests/test_doctor.py +202 -0
- guanlan-0.1.1/tests/test_hotnews.py +135 -0
- guanlan-0.1.1/tests/test_mcp_server.py +67 -0
- guanlan-0.1.1/tests/test_search_sources.py +50 -0
- guanlan-0.1.1/tests/test_skill_command.py +125 -0
- guanlan-0.1.1/tests/test_twitter_channel.py +108 -0
- guanlan-0.1.1/tests/test_webtools.py +765 -0
- guanlan-0.1.1/tests/test_xhs_format.py +133 -0
- guanlan-0.1.1/tests/test_xiaoyuzhou_install.py +21 -0
- guanlan-0.1.1/uv.lock +1644 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# 观澜 / Guanlan Configuration
|
|
2
|
+
# Copy to .env and fill in your values
|
|
3
|
+
# Or use: guanlan configure
|
|
4
|
+
|
|
5
|
+
# Exa Search (free 1000/month) — https://exa.ai
|
|
6
|
+
# EXA_API_KEY=exa-your-key-here
|
|
7
|
+
|
|
8
|
+
# GitHub Token (optional, for higher rate limits) — https://github.com/settings/tokens
|
|
9
|
+
# GITHUB_TOKEN=ghp_your_token_here
|
|
10
|
+
|
|
11
|
+
# Reddit ISP Proxy (optional, for full Reddit access)
|
|
12
|
+
# REDDIT_PROXY=http://user:pass@ip:port
|
|
13
|
+
|
|
14
|
+
# Groq Whisper (optional, for video transcription) — https://console.groq.com
|
|
15
|
+
# GROQ_API_KEY=gsk_your_key_here
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Setup Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install package and test deps
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install -c constraints.txt -e .[dev]
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: |
|
|
30
|
+
pytest -q
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Setup Python
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
|
|
20
|
+
- name: Build package
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
python -m pip install build twine
|
|
24
|
+
python -m build
|
|
25
|
+
twine check dist/*
|
|
26
|
+
|
|
27
|
+
- name: Upload dist artifact
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: python-dist
|
|
31
|
+
path: dist/*
|
|
32
|
+
|
|
33
|
+
publish-pypi:
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment: pypi
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write
|
|
39
|
+
steps:
|
|
40
|
+
- name: Download dist artifact
|
|
41
|
+
uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: python-dist
|
|
44
|
+
path: dist
|
|
45
|
+
|
|
46
|
+
- name: Publish to PyPI (Trusted Publisher)
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
|
|
49
|
+
update-homebrew-tap:
|
|
50
|
+
needs: publish-pypi
|
|
51
|
+
if: ${{ needs.publish-pypi.result == 'success' }}
|
|
52
|
+
runs-on: macos-latest
|
|
53
|
+
env:
|
|
54
|
+
HOMEBREW_TAP_REPO: shenyangs/homebrew-tap
|
|
55
|
+
FORMULA_PATH: Formula/guanlan.rb
|
|
56
|
+
PACKAGE_NAME: guanlan
|
|
57
|
+
FORMULA_CLASS: Guanlan
|
|
58
|
+
PACKAGE_HOMEPAGE: https://github.com/shenyangs/Guanlan
|
|
59
|
+
PACKAGE_DESC: China-aware source and platform router for AI agents
|
|
60
|
+
steps:
|
|
61
|
+
- name: Validate required secret
|
|
62
|
+
env:
|
|
63
|
+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
|
|
64
|
+
run: |
|
|
65
|
+
if [ -z "${HOMEBREW_TAP_GITHUB_TOKEN}" ]; then
|
|
66
|
+
echo "Missing secret: HOMEBREW_TAP_GITHUB_TOKEN"
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
- name: Setup Python
|
|
71
|
+
uses: actions/setup-python@v5
|
|
72
|
+
with:
|
|
73
|
+
python-version: "3.12"
|
|
74
|
+
|
|
75
|
+
- name: Download dist artifact
|
|
76
|
+
uses: actions/download-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
name: python-dist
|
|
79
|
+
path: dist
|
|
80
|
+
|
|
81
|
+
- name: Generate Homebrew formula
|
|
82
|
+
env:
|
|
83
|
+
RAW_TAG: ${{ github.ref_name }}
|
|
84
|
+
run: |
|
|
85
|
+
set -euo pipefail
|
|
86
|
+
python -m pip install --upgrade pip
|
|
87
|
+
python -m pip install dist/*.whl
|
|
88
|
+
|
|
89
|
+
python - <<'PY'
|
|
90
|
+
import json
|
|
91
|
+
import os
|
|
92
|
+
import subprocess
|
|
93
|
+
import sys
|
|
94
|
+
import time
|
|
95
|
+
import urllib.request
|
|
96
|
+
from pathlib import Path
|
|
97
|
+
|
|
98
|
+
package_name = os.environ["PACKAGE_NAME"]
|
|
99
|
+
version = os.environ["RAW_TAG"][1:] if os.environ["RAW_TAG"].startswith("v") else os.environ["RAW_TAG"]
|
|
100
|
+
formula_path = Path(os.environ["FORMULA_PATH"])
|
|
101
|
+
formula_class = os.environ["FORMULA_CLASS"]
|
|
102
|
+
homepage = os.environ["PACKAGE_HOMEPAGE"]
|
|
103
|
+
desc = os.environ["PACKAGE_DESC"]
|
|
104
|
+
|
|
105
|
+
def normalize(name: str) -> str:
|
|
106
|
+
return name.lower().replace("_", "-")
|
|
107
|
+
|
|
108
|
+
def pick_release_file(pkg: str, ver: str) -> tuple[str, str]:
|
|
109
|
+
url = f"https://pypi.org/pypi/{pkg}/{ver}/json"
|
|
110
|
+
last_error = None
|
|
111
|
+
for _ in range(20):
|
|
112
|
+
try:
|
|
113
|
+
with urllib.request.urlopen(url, timeout=30) as resp:
|
|
114
|
+
data = json.load(resp)
|
|
115
|
+
break
|
|
116
|
+
except Exception as err:
|
|
117
|
+
last_error = err
|
|
118
|
+
time.sleep(6)
|
|
119
|
+
else:
|
|
120
|
+
raise RuntimeError(f"Failed to fetch {url}: {last_error}")
|
|
121
|
+
|
|
122
|
+
files = data.get("urls", [])
|
|
123
|
+
sdist = next((f for f in files if f.get("packagetype") == "sdist"), None)
|
|
124
|
+
if sdist:
|
|
125
|
+
return sdist["url"], sdist["digests"]["sha256"]
|
|
126
|
+
wheel = next((f for f in files if f.get("packagetype") == "bdist_wheel"), None)
|
|
127
|
+
if wheel:
|
|
128
|
+
return wheel["url"], wheel["digests"]["sha256"]
|
|
129
|
+
raise RuntimeError(f"No release file found for {pkg}=={ver}")
|
|
130
|
+
|
|
131
|
+
main_url, main_sha = pick_release_file(package_name, version)
|
|
132
|
+
|
|
133
|
+
freeze_output = subprocess.check_output(
|
|
134
|
+
[sys.executable, "-m", "pip", "freeze", "--exclude-editable"],
|
|
135
|
+
text=True,
|
|
136
|
+
)
|
|
137
|
+
dependencies: list[tuple[str, str]] = []
|
|
138
|
+
for line in freeze_output.splitlines():
|
|
139
|
+
if "==" not in line:
|
|
140
|
+
continue
|
|
141
|
+
name, ver = line.split("==", 1)
|
|
142
|
+
if normalize(name) == normalize(package_name):
|
|
143
|
+
continue
|
|
144
|
+
if normalize(name) in {"pip", "setuptools", "wheel"}:
|
|
145
|
+
continue
|
|
146
|
+
dependencies.append((name, ver))
|
|
147
|
+
|
|
148
|
+
# De-duplicate and sort for stable formula output.
|
|
149
|
+
dedup = {(normalize(n), n, v) for n, v in dependencies}
|
|
150
|
+
sorted_deps = sorted(dedup, key=lambda item: item[0])
|
|
151
|
+
|
|
152
|
+
resources: list[str] = []
|
|
153
|
+
for _, dep_name, dep_ver in sorted_deps:
|
|
154
|
+
dep_url, dep_sha = pick_release_file(dep_name, dep_ver)
|
|
155
|
+
resources.append(
|
|
156
|
+
"\n".join(
|
|
157
|
+
[
|
|
158
|
+
f' resource "{dep_name}" do',
|
|
159
|
+
f' url "{dep_url}"',
|
|
160
|
+
f' sha256 "{dep_sha}"',
|
|
161
|
+
" end",
|
|
162
|
+
]
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
resources_block = "\n\n".join(resources)
|
|
167
|
+
lines = [
|
|
168
|
+
f"class {formula_class} < Formula",
|
|
169
|
+
" include Language::Python::Virtualenv",
|
|
170
|
+
"",
|
|
171
|
+
f' desc "{desc}"',
|
|
172
|
+
f' homepage "{homepage}"',
|
|
173
|
+
f' url "{main_url}"',
|
|
174
|
+
f' sha256 "{main_sha}"',
|
|
175
|
+
' license "MIT"',
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
if resources_block:
|
|
179
|
+
lines.append("")
|
|
180
|
+
lines.extend(resources_block.splitlines())
|
|
181
|
+
|
|
182
|
+
lines.extend(
|
|
183
|
+
[
|
|
184
|
+
"",
|
|
185
|
+
' depends_on "python@3.12"',
|
|
186
|
+
"",
|
|
187
|
+
" def install",
|
|
188
|
+
" virtualenv_install_with_resources",
|
|
189
|
+
" end",
|
|
190
|
+
"",
|
|
191
|
+
" test do",
|
|
192
|
+
' output = shell_output("#{bin}/guanlan --version")',
|
|
193
|
+
" assert_match version.to_s, output",
|
|
194
|
+
" end",
|
|
195
|
+
"end",
|
|
196
|
+
]
|
|
197
|
+
)
|
|
198
|
+
formula = "\n".join(lines)
|
|
199
|
+
|
|
200
|
+
formula_path.parent.mkdir(parents=True, exist_ok=True)
|
|
201
|
+
formula_path.write_text(formula + "\n", encoding="utf-8")
|
|
202
|
+
PY
|
|
203
|
+
|
|
204
|
+
- name: Push formula to tap
|
|
205
|
+
env:
|
|
206
|
+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
|
|
207
|
+
run: |
|
|
208
|
+
set -euo pipefail
|
|
209
|
+
git clone "https://x-access-token:${HOMEBREW_TAP_GITHUB_TOKEN}@github.com/${HOMEBREW_TAP_REPO}.git" tap
|
|
210
|
+
mkdir -p "tap/$(dirname "${FORMULA_PATH}")"
|
|
211
|
+
cp "${FORMULA_PATH}" "tap/${FORMULA_PATH}"
|
|
212
|
+
|
|
213
|
+
cd tap
|
|
214
|
+
if git diff --quiet -- "${FORMULA_PATH}"; then
|
|
215
|
+
echo "No formula changes detected."
|
|
216
|
+
exit 0
|
|
217
|
+
fi
|
|
218
|
+
|
|
219
|
+
git config user.name "github-actions[bot]"
|
|
220
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
221
|
+
git add "${FORMULA_PATH}"
|
|
222
|
+
git commit -m "guanlan ${GITHUB_REF_NAME#v}"
|
|
223
|
+
git push
|
guanlan-0.1.1/.gitignore
ADDED
guanlan-0.1.1/AGENTS.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This repository is designed as a CLI-first search productivity tool for AI agents.
|
|
4
|
+
|
|
5
|
+
When using Guanlan as an agent, prefer this minimal command set:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
guanlan search "query" --limit 8
|
|
9
|
+
guanlan search "中文问题" --profile china --limit 8
|
|
10
|
+
guanlan search "政策或产业问题" --profile china --scope party_central
|
|
11
|
+
guanlan search "电商零售问题" --profile china --scope ecommerce
|
|
12
|
+
guanlan search --list-scopes
|
|
13
|
+
guanlan read "https://example.com/article" --max-chars 12000
|
|
14
|
+
guanlan hotnews baidu --limit 10
|
|
15
|
+
guanlan hotnews v2ex --limit 10
|
|
16
|
+
guanlan doctor --trace
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Read [docs/agent-usage.md](docs/agent-usage.md) for the full agent routing guide.
|
|
20
|
+
|
|
21
|
+
Safety rules:
|
|
22
|
+
|
|
23
|
+
- Do not read browser cookies unless the user explicitly asks.
|
|
24
|
+
- Do not run `guanlan configure --from-browser ...` without user approval.
|
|
25
|
+
- Do not run `guanlan doctor --auth-check` unless the user wants deep auth checks.
|
|
26
|
+
- Do not post, comment, like, follow, or send messages automatically.
|
|
27
|
+
- Prefer public search/read/hotnews first, then ask for authorization only when needed.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog / 更新日志
|
|
2
|
+
|
|
3
|
+
All notable changes to Guanlan will be documented in this file.
|
|
4
|
+
|
|
5
|
+
观澜版本的重要变更从此处开始记录。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-05-01
|
|
10
|
+
|
|
11
|
+
### Added / 新增
|
|
12
|
+
|
|
13
|
+
- Established the Guanlan project baseline, package identity, and documentation set.
|
|
14
|
+
- Added a China-aware agent workflow centered on `guanlan search`, `guanlan read`, and `guanlan hotnews`.
|
|
15
|
+
- Added scoped source routing for `party_central`, `gov`, `local_official`, `business`, `ecommerce`, `tech_dev`, `finance`, and `social_web`.
|
|
16
|
+
- Added native hotnews aggregation and normalized Markdown output for Chinese trend tracking.
|
|
17
|
+
|
|
18
|
+
### Changed / 变更
|
|
19
|
+
|
|
20
|
+
- Standardized the CLI, package, config directory, and docs around the `guanlan` identity.
|
|
21
|
+
- Clarified safety defaults: public read-only access first, explicit approval for cookies, Keychain access, and deep auth checks.
|
|
22
|
+
- Reorganized install, troubleshooting, agent-usage, and source-attribution docs to reflect Guanlan's own positioning.
|
guanlan-0.1.1/CLAUDE.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
观澜 / Guanlan — Python CLI + library for AI-agent search, reading, hotnews, and source routing across the Chinese web.
|
|
5
|
+
Positioning: CLI-first, read-first router with explicit authorization boundaries.
|
|
6
|
+
Repo: local workspace, public remote not configured yet | License: MIT | Version: 0.1.0
|
|
7
|
+
|
|
8
|
+
## Commands
|
|
9
|
+
- `pip install -e .` — Dev install
|
|
10
|
+
- `pytest tests/ -v` — All tests
|
|
11
|
+
- `pytest tests/test_cli.py -v` — CLI tests only
|
|
12
|
+
- `bash test.sh` — Full integration test (creates venv, installs, runs doctor + channel tests)
|
|
13
|
+
- `python -m guanlan.cli doctor` — Run diagnostics
|
|
14
|
+
- `python -m guanlan.cli install --env=auto` — Auto-configure
|
|
15
|
+
|
|
16
|
+
## Structure
|
|
17
|
+
- `guanlan/cli.py` — CLI entry point (argparse)
|
|
18
|
+
- `guanlan/core.py` — Core read/search routing logic
|
|
19
|
+
- `guanlan/config.py` — Config management (YAML, env vars)
|
|
20
|
+
- `guanlan/doctor.py` — Diagnostics engine
|
|
21
|
+
- `guanlan/channels/` — One file per platform (twitter.py, reddit.py, youtube.py, etc.)
|
|
22
|
+
- `guanlan/channels/base.py` — Base channel class (all channels inherit from this)
|
|
23
|
+
- `guanlan/integrations/mcp_server.py` — MCP server integration
|
|
24
|
+
- `guanlan/skill/` — OpenClaw skill files
|
|
25
|
+
- `guanlan/guides/` — Usage guides
|
|
26
|
+
- `tests/` — pytest tests
|
|
27
|
+
- `config/mcporter.json` — MCP tool config
|
|
28
|
+
|
|
29
|
+
## Conventions
|
|
30
|
+
- Python 3.10+ with type hints
|
|
31
|
+
- Each channel is a single file in `channels/`, inherits from `BaseChannel`
|
|
32
|
+
- Channel contract: must implement `can_handle(url)`, `read(url)`, `search(query)`, `check()` methods
|
|
33
|
+
- Use `loguru` for logging, `rich` for CLI output
|
|
34
|
+
- Commit format: `type(scope): message` (one commit = one thing)
|
|
35
|
+
- All upstream tool calls go through public API/CLI, never hack internals
|
|
36
|
+
|
|
37
|
+
## Rules
|
|
38
|
+
- NEVER modify upstream open source projects' source code
|
|
39
|
+
- 观澜 / Guanlan keeps platform access modular: route, read, diagnose, and degrade cleanly.
|
|
40
|
+
- Version in THREE places must match: `pyproject.toml`, `__init__.py`, `tests/test_cli.py`
|
|
41
|
+
- Always new branch for changes, PR to main, never push to main directly
|
|
42
|
+
- Run `pytest tests/ -v` before committing — all tests must pass
|
|
43
|
+
- Cookie-based auth (Twitter, XHS): use Cookie-Editor export method only, no QR scan
|
|
44
|
+
- XHS login: Cookie-Editor browser export only (QR will hang)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Contributing to 观澜 / Guanlan
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to 观澜 / Guanlan! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Fork the repository on GitHub
|
|
8
|
+
2. Clone your fork locally
|
|
9
|
+
3. Create a new branch for your contribution
|
|
10
|
+
4. Make your changes
|
|
11
|
+
5. Run tests and linting
|
|
12
|
+
6. Submit a pull request
|
|
13
|
+
|
|
14
|
+
## Development Setup
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Clone your fork
|
|
18
|
+
git clone https://github.com/YOUR_USERNAME/Guanlan.git
|
|
19
|
+
cd Guanlan
|
|
20
|
+
|
|
21
|
+
# Install in development mode
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
|
|
24
|
+
# Install pre-commit hooks (optional but recommended)
|
|
25
|
+
pre-commit install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Code Style
|
|
29
|
+
|
|
30
|
+
We use the following tools to maintain code quality:
|
|
31
|
+
|
|
32
|
+
- **ruff**: Linting and import sorting
|
|
33
|
+
- **mypy**: Type checking
|
|
34
|
+
- **pytest**: Testing
|
|
35
|
+
|
|
36
|
+
Run all checks before submitting a PR:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Linting
|
|
40
|
+
ruff check guanlan tests
|
|
41
|
+
ruff format guanlan tests
|
|
42
|
+
|
|
43
|
+
# Type checking
|
|
44
|
+
mypy guanlan
|
|
45
|
+
|
|
46
|
+
# Tests
|
|
47
|
+
pytest
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Adding New Channels
|
|
51
|
+
|
|
52
|
+
观澜 / Guanlan uses a unified channel interface. To add a new platform:
|
|
53
|
+
|
|
54
|
+
1. Create a new file in `guanlan/channels/`
|
|
55
|
+
2. Implement the channel contract (see existing channels for examples)
|
|
56
|
+
3. Add tests in `tests/test_channels.py`
|
|
57
|
+
4. Update `guanlan/doctor.py` to include the new channel
|
|
58
|
+
5. Update documentation
|
|
59
|
+
|
|
60
|
+
## Pull Request Guidelines
|
|
61
|
+
|
|
62
|
+
- **Small, focused changes** are preferred over large refactors
|
|
63
|
+
- Include tests for new functionality
|
|
64
|
+
- Update documentation if needed
|
|
65
|
+
- Follow existing code style
|
|
66
|
+
- Reference any related issues
|
|
67
|
+
|
|
68
|
+
## Reporting Issues
|
|
69
|
+
|
|
70
|
+
When reporting bugs, please include:
|
|
71
|
+
|
|
72
|
+
- Python version
|
|
73
|
+
- Operating system
|
|
74
|
+
- Steps to reproduce
|
|
75
|
+
- Expected vs actual behavior
|
|
76
|
+
- Any error messages
|
|
77
|
+
|
|
78
|
+
## Questions?
|
|
79
|
+
|
|
80
|
+
Feel free to open an issue for questions or join discussions.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
感谢您对 观澜 / Guanlan 的贡献!本文档提供了贡献指南。
|
|
85
|
+
|
|
86
|
+
## 快速开始
|
|
87
|
+
|
|
88
|
+
1. 在 GitHub 上 fork 仓库
|
|
89
|
+
2. 本地 clone 您的 fork
|
|
90
|
+
3. 创建新分支
|
|
91
|
+
4. 提交更改
|
|
92
|
+
5. 运行测试和 lint
|
|
93
|
+
6. 提交 pull request
|
|
94
|
+
|
|
95
|
+
## 代码规范
|
|
96
|
+
|
|
97
|
+
- 使用 **ruff** 进行代码检查
|
|
98
|
+
- 使用 **mypy** 进行类型检查
|
|
99
|
+
- 使用 **pytest** 运行测试
|
|
100
|
+
|
|
101
|
+
## 添加新渠道
|
|
102
|
+
|
|
103
|
+
1. 在 `guanlan/channels/` 创建新文件
|
|
104
|
+
2. 实现渠道接口
|
|
105
|
+
3. 添加测试
|
|
106
|
+
4. 更新 doctor 检测
|
|
107
|
+
5. 更新文档
|
guanlan-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guanlan Team
|
|
4
|
+
Copyright (c) 2025 Agent Eyes
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
guanlan-0.1.1/NOTICE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Guanlan Third-Party Notices
|
|
2
|
+
===========================
|
|
3
|
+
|
|
4
|
+
Guanlan is released under the MIT License.
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2026 Guanlan Team
|
|
7
|
+
|
|
8
|
+
Portions of Guanlan reference or adapt ideas and implementation patterns from
|
|
9
|
+
the following MIT-licensed open-source projects:
|
|
10
|
+
|
|
11
|
+
Agent-Reach
|
|
12
|
+
-----------
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2025 Agent Eyes
|
|
15
|
+
License: MIT License
|
|
16
|
+
Source: https://github.com/Panniantong/Agent-Reach
|
|
17
|
+
License text: https://github.com/Panniantong/Agent-Reach/blob/main/LICENSE
|
|
18
|
+
|
|
19
|
+
NewsNow
|
|
20
|
+
-------
|
|
21
|
+
|
|
22
|
+
Copyright (c) 2024 ourongxing
|
|
23
|
+
License: MIT License
|
|
24
|
+
Source: https://github.com/ourongxing/newsnow
|
|
25
|
+
License text: https://github.com/ourongxing/newsnow/blob/main/LICENSE
|
|
26
|
+
|
|
27
|
+
See docs/SOURCE_ATTRIBUTION.md for the project-level source attribution notes.
|