youknow 0.3.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 +361 -0
- package/dist/banner.d.ts +1 -0
- package/dist/banner.js +14 -0
- package/dist/banner.js.map +1 -0
- package/dist/channels/claude/action.d.ts +12 -0
- package/dist/channels/claude/action.js +71 -0
- package/dist/channels/claude/action.js.map +1 -0
- package/dist/channels/claude/fetch.d.ts +44 -0
- package/dist/channels/claude/fetch.js +182 -0
- package/dist/channels/claude/fetch.js.map +1 -0
- package/dist/channels/github/action.d.ts +18 -0
- package/dist/channels/github/action.js +79 -0
- package/dist/channels/github/action.js.map +1 -0
- package/dist/channels/github/fetch.d.ts +42 -0
- package/dist/channels/github/fetch.js +109 -0
- package/dist/channels/github/fetch.js.map +1 -0
- package/dist/channels/openai/action.d.ts +12 -0
- package/dist/channels/openai/action.js +59 -0
- package/dist/channels/openai/action.js.map +1 -0
- package/dist/channels/openai/fetch.d.ts +33 -0
- package/dist/channels/openai/fetch.js +90 -0
- package/dist/channels/openai/fetch.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/sources.d.ts +1 -0
- package/dist/commands/sources.js +40 -0
- package/dist/commands/sources.js.map +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/network.d.ts +7 -0
- package/dist/network.js +65 -0
- package/dist/network.js.map +1 -0
- package/dist/program.d.ts +2 -0
- package/dist/program.js +88 -0
- package/dist/program.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wanglsh97
|
|
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,361 @@
|
|
|
1
|
+
# youknow
|
|
2
|
+
|
|
3
|
+
`youknow` 是一个聚合技术热点与 AI 官方动态的 CLI,支持查询 GitHub
|
|
4
|
+
Trending、OpenAI 和 Anthropic/Claude 更新,并输出 JSON 或 Markdown。
|
|
5
|
+
|
|
6
|
+
## 快速开始
|
|
7
|
+
|
|
8
|
+
无需安装,直接通过 npx 运行:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# GitHub Trending
|
|
12
|
+
npx youknow github
|
|
13
|
+
|
|
14
|
+
# OpenAI 官方新闻
|
|
15
|
+
npx youknow openai
|
|
16
|
+
|
|
17
|
+
# Anthropic 与 Claude 官方动态
|
|
18
|
+
npx youknow claude
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
例如,获取 Python 今日热门前 5 名:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx youknow github --since daily --language python --limit 5
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 环境要求
|
|
28
|
+
|
|
29
|
+
- Node.js 20.18.1 或更高版本
|
|
30
|
+
- 能够访问 `github.com`、`openai.com`、`anthropic.com` 和 `claude.com`
|
|
31
|
+
|
|
32
|
+
## 可选:全局安装
|
|
33
|
+
|
|
34
|
+
如果不想每次通过 npx 调用,可以全局安装:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install --global youknow
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
全局安装会提供 `youknow`、`youKnow` 和 `trending-knowledge` 三个兼容入口;本文
|
|
41
|
+
后续统一使用无需安装的 `npx youknow` 演示。
|
|
42
|
+
|
|
43
|
+
## 获取 GitHub Trending
|
|
44
|
+
|
|
45
|
+
不带参数时,默认获取 TypeScript 本周热门仓库,最多返回 20 条,并输出 JSON:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx youknow github
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
常用示例:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Python 今日热门前 5 名
|
|
55
|
+
npx youknow github --since daily --language python --limit 5
|
|
56
|
+
|
|
57
|
+
# 中文项目月榜
|
|
58
|
+
npx youknow github --since monthly --spoken-language zh
|
|
59
|
+
|
|
60
|
+
# 输出 Markdown
|
|
61
|
+
npx youknow github --format md
|
|
62
|
+
|
|
63
|
+
# 输出 Markdown,并保存到指定文件
|
|
64
|
+
npx youknow github --format md --output output/github.md
|
|
65
|
+
|
|
66
|
+
# 将请求超时时间调整为 30 秒
|
|
67
|
+
npx youknow github --timeout 30000
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 参数
|
|
71
|
+
|
|
72
|
+
| 参数 | 简写 | 说明 | 默认值 |
|
|
73
|
+
| -------------------------- | ---- | -------------------------------------- | ------------ |
|
|
74
|
+
| `--language <language>` | `-l` | 开发语言,例如 `typescript`、`python` | `typescript` |
|
|
75
|
+
| `--since <since>` | `-s` | 时间范围:`daily`、`weekly`、`monthly` | `weekly` |
|
|
76
|
+
| `--spoken-language <code>` | — | 项目自然语言代码,例如 `zh`、`en` | 不限制 |
|
|
77
|
+
| `--limit <number>` | `-n` | 返回条数,必须大于 0 | `20` |
|
|
78
|
+
| `--format <format>` | `-f` | 输出格式:`json` 或 `md` | `json` |
|
|
79
|
+
| `--output <path>` | `-o` | 将结果同时保存到文件 | 不保存 |
|
|
80
|
+
| `--timeout <ms>` | — | 请求超时时间,单位为毫秒 | `20000` |
|
|
81
|
+
|
|
82
|
+
查看完整帮助:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx youknow github --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 获取 OpenAI 官方新闻
|
|
89
|
+
|
|
90
|
+
`openai` 命令读取 OpenAI 新闻页官方链接的 RSS Feed。默认返回最新 20 条新闻,
|
|
91
|
+
并输出 JSON:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx youknow openai
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
常用示例:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 最新 5 条官方发布
|
|
101
|
+
npx youknow openai --limit 5
|
|
102
|
+
|
|
103
|
+
# 筛选产品分类;分类名称来自 RSS,大小写不敏感
|
|
104
|
+
npx youknow openai --category Product
|
|
105
|
+
|
|
106
|
+
# 输出 Markdown 并保存
|
|
107
|
+
npx youknow openai --format md --output output/openai.md
|
|
108
|
+
|
|
109
|
+
# 将请求超时时间调整为 30 秒
|
|
110
|
+
npx youknow openai --timeout 30000
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 参数
|
|
114
|
+
|
|
115
|
+
| 参数 | 简写 | 说明 | 默认值 |
|
|
116
|
+
| ----------------------- | ---- | ---------------------------------- | ------- |
|
|
117
|
+
| `--category <category>` | `-c` | RSS 分类,如 `Product`、`Research` | 不限制 |
|
|
118
|
+
| `--limit <number>` | `-n` | 返回条数,必须大于 0 | `20` |
|
|
119
|
+
| `--format <format>` | `-f` | 输出格式:`json` 或 `md` | `json` |
|
|
120
|
+
| `--output <path>` | `-o` | 将结果同时保存到文件 | 不保存 |
|
|
121
|
+
| `--timeout <ms>` | — | 请求超时时间,单位为毫秒 | `20000` |
|
|
122
|
+
|
|
123
|
+
查看完整帮助:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npx youknow openai --help
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
OpenAI 新闻页面会根据地区显示本地化标题,但官方 RSS 当前主要提供英文标题和摘要;
|
|
130
|
+
CLI 保留 RSS 原文,不进行机器翻译。输出中的 `pageUrl` 指向中文新闻页面,`feedUrl`
|
|
131
|
+
指向实际采集使用的官方 RSS。
|
|
132
|
+
|
|
133
|
+
## 获取 Claude 官方动态
|
|
134
|
+
|
|
135
|
+
`claude` 命令并发读取 Anthropic Newsroom、Anthropic Research 和 Claude Platform
|
|
136
|
+
官方 RSS,合并后按发布时间从新到旧输出。默认返回最新 20 条:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npx youknow claude
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
常用示例:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# 只查看 Anthropic 新闻
|
|
146
|
+
npx youknow claude --scope news
|
|
147
|
+
|
|
148
|
+
# 最新 5 条研究动态
|
|
149
|
+
npx youknow claude --scope research --limit 5
|
|
150
|
+
|
|
151
|
+
# 只查看 Claude API、SDK 和 Console 发布说明
|
|
152
|
+
npx youknow claude --scope platform
|
|
153
|
+
|
|
154
|
+
# 输出 Markdown 并保存
|
|
155
|
+
npx youknow claude --format md --output output/claude.md
|
|
156
|
+
|
|
157
|
+
# 将每个官方源的请求超时时间调整为 30 秒
|
|
158
|
+
npx youknow claude --timeout 30000
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 参数
|
|
162
|
+
|
|
163
|
+
| 参数 | 简写 | 说明 | 默认值 |
|
|
164
|
+
| ------------------- | ---- | --------------------------------------------- | ------- |
|
|
165
|
+
| `--scope <scope>` | — | 范围:`all`、`news`、`research` 或 `platform` | `all` |
|
|
166
|
+
| `--limit <number>` | `-n` | 返回条数,必须大于 0 | `20` |
|
|
167
|
+
| `--format <format>` | `-f` | 输出格式:`json` 或 `md` | `json` |
|
|
168
|
+
| `--output <path>` | `-o` | 将结果同时保存到文件 | 不保存 |
|
|
169
|
+
| `--timeout <ms>` | — | 单个请求的超时时间,单位为毫秒 | `20000` |
|
|
170
|
+
|
|
171
|
+
查看完整帮助:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npx youknow claude --help
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Newsroom 和 Research 当前提供英文标题、分类和发布日期;Claude Platform RSS 还会
|
|
178
|
+
提供发布说明摘要。CLI 保留官方原文,不进行机器翻译。
|
|
179
|
+
|
|
180
|
+
## 输出格式
|
|
181
|
+
|
|
182
|
+
### JSON
|
|
183
|
+
|
|
184
|
+
默认输出包含筛选条件、采集时间和仓库列表:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"source": "github treeding",
|
|
189
|
+
"period": "weekly",
|
|
190
|
+
"language": "typescript",
|
|
191
|
+
"spokenLanguage": null,
|
|
192
|
+
"collectedAt": "2026-08-30T02:08:44.881Z",
|
|
193
|
+
"total": 1,
|
|
194
|
+
"items": [
|
|
195
|
+
{
|
|
196
|
+
"source": "github",
|
|
197
|
+
"type": "repository",
|
|
198
|
+
"rank": 1,
|
|
199
|
+
"id": "owner/repository",
|
|
200
|
+
"title": "owner/repository",
|
|
201
|
+
"url": "https://github.com/owner/repository",
|
|
202
|
+
"summary": "Repository description",
|
|
203
|
+
"author": "owner",
|
|
204
|
+
"language": "TypeScript",
|
|
205
|
+
"metrics": {
|
|
206
|
+
"stars": 1234,
|
|
207
|
+
"forks": 56,
|
|
208
|
+
"periodStars": 78
|
|
209
|
+
},
|
|
210
|
+
"contributors": ["owner"],
|
|
211
|
+
"period": "weekly",
|
|
212
|
+
"collectedAt": "2026-08-30T02:08:44.881Z"
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`periodStars` 表示所选时间范围内新增的 Star 数量。
|
|
219
|
+
|
|
220
|
+
### Markdown
|
|
221
|
+
|
|
222
|
+
使用 `--format md` 可以生成适合保存、分享或粘贴到文档中的 Markdown 表格。
|
|
223
|
+
搭配 `--output` 时,结果会输出到终端并写入文件。
|
|
224
|
+
|
|
225
|
+
### OpenAI JSON
|
|
226
|
+
|
|
227
|
+
OpenAI 新闻结果包含来源页面、RSS 地址、筛选分类和发布列表:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"source": "openai",
|
|
232
|
+
"type": "news-feed",
|
|
233
|
+
"pageUrl": "https://openai.com/zh-Hans-CN/news/",
|
|
234
|
+
"feedUrl": "https://openai.com/news/rss.xml",
|
|
235
|
+
"category": null,
|
|
236
|
+
"collectedAt": "2026-08-30T02:50:00.000Z",
|
|
237
|
+
"total": 1,
|
|
238
|
+
"items": [
|
|
239
|
+
{
|
|
240
|
+
"source": "openai",
|
|
241
|
+
"type": "news",
|
|
242
|
+
"rank": 1,
|
|
243
|
+
"id": "example-release",
|
|
244
|
+
"title": "Example release",
|
|
245
|
+
"url": "https://openai.com/index/example-release/",
|
|
246
|
+
"summary": "Official release summary.",
|
|
247
|
+
"category": "Product",
|
|
248
|
+
"publishedAt": "2026-08-30T00:00:00.000Z",
|
|
249
|
+
"collectedAt": "2026-08-30T02:50:00.000Z"
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Claude JSON
|
|
256
|
+
|
|
257
|
+
Claude 结果包含采集范围、各官方来源地址和合并后的动态列表:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"source": "claude",
|
|
262
|
+
"type": "updates-feed",
|
|
263
|
+
"scope": "all",
|
|
264
|
+
"sourceUrls": {
|
|
265
|
+
"news": "https://www.anthropic.com/news",
|
|
266
|
+
"research": "https://www.anthropic.com/research",
|
|
267
|
+
"platform": "https://platform.claude.com/docs/en/release-notes/overview",
|
|
268
|
+
"platformFeed": "https://platform.claude.com/docs/en/release-notes/feed.xml"
|
|
269
|
+
},
|
|
270
|
+
"collectedAt": "2026-08-30T03:00:00.000Z",
|
|
271
|
+
"total": 1,
|
|
272
|
+
"items": [
|
|
273
|
+
{
|
|
274
|
+
"source": "claude",
|
|
275
|
+
"type": "research",
|
|
276
|
+
"rank": 1,
|
|
277
|
+
"id": "research:example",
|
|
278
|
+
"title": "Example research",
|
|
279
|
+
"url": "https://www.anthropic.com/research/example",
|
|
280
|
+
"summary": "",
|
|
281
|
+
"category": "Alignment",
|
|
282
|
+
"publishedAt": "2026-08-29T00:00:00.000Z",
|
|
283
|
+
"collectedAt": "2026-08-30T03:00:00.000Z"
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## 网络代理
|
|
290
|
+
|
|
291
|
+
CLI 会自动使用以下代理环境变量:
|
|
292
|
+
|
|
293
|
+
- `HTTPS_PROXY` / `https_proxy`
|
|
294
|
+
- `HTTP_PROXY` / `http_proxy`
|
|
295
|
+
- `ALL_PROXY` / `all_proxy`,仅作为 HTTP/HTTPS 代理后备
|
|
296
|
+
- `NO_PROXY` / `no_proxy`
|
|
297
|
+
|
|
298
|
+
无需在命令前添加 `NODE_USE_ENV_PROXY=1`。
|
|
299
|
+
|
|
300
|
+
在 macOS 上,如果终端没有代理环境变量,CLI 会继续读取系统网络代理。
|
|
301
|
+
未检测到代理时使用直连。
|
|
302
|
+
|
|
303
|
+
## 错误输出
|
|
304
|
+
|
|
305
|
+
请求失败时,错误会写入标准错误流,并保持固定 JSON 结构:
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"name": "TimeoutError",
|
|
310
|
+
"message": "The operation was aborted due to timeout",
|
|
311
|
+
"code": 23
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
如果底层错误没有错误码,`code` 为 `"UNKNOWN_ERROR"`。
|
|
316
|
+
|
|
317
|
+
## 排查请求超时
|
|
318
|
+
|
|
319
|
+
先确认 GitHub 是否可以通过当前网络或代理访问:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
curl -L -sS \
|
|
323
|
+
-o /dev/null \
|
|
324
|
+
-w 'HTTP %{http_code}\n耗时 %{time_total}s\n' \
|
|
325
|
+
--max-time 20 \
|
|
326
|
+
'https://github.com/trending/typescript?since=weekly'
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
正常情况下应返回 `HTTP 200`。如果 `curl` 也超时,请检查网络或代理软件;如果
|
|
330
|
+
`curl` 成功但 CLI 失败,可以增加超时时间后重试:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
npx youknow github --timeout 30000
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## 查看数据源
|
|
337
|
+
|
|
338
|
+
查看已支持及规划中的数据源:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
npx youknow sources
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
GitHub Trending 数据来自 GitHub 的公开 Trending 页面,不需要 GitHub Token。
|
|
345
|
+
如果 GitHub 调整页面结构,仓库字段可能暂时无法解析。
|
|
346
|
+
|
|
347
|
+
OpenAI 数据来自官方 RSS,不需要 OpenAI API Key。RSS 是中文新闻页面公开链接的
|
|
348
|
+
订阅入口;如果 Feed 结构发生变化,命令会显式报错而不会返回伪造的空结果。
|
|
349
|
+
|
|
350
|
+
Claude 数据来自 Anthropic Newsroom、Anthropic Research 和 Claude Platform 官方
|
|
351
|
+
RSS,不需要 Anthropic API Key。任一选中的官方源返回成功但无法解析时,命令会
|
|
352
|
+
显式报错,避免把页面结构变化误报为空结果。
|
|
353
|
+
|
|
354
|
+
## 参与开发
|
|
355
|
+
|
|
356
|
+
本地开发、项目结构、测试和新增数据源说明见
|
|
357
|
+
[CONTRIBUTING.md](https://github.com/wanglsh97/trending-knowledge/blob/main/CONTRIBUTING.md)。
|
|
358
|
+
|
|
359
|
+
## License
|
|
360
|
+
|
|
361
|
+
本项目采用 [MIT License](https://github.com/wanglsh97/trending-knowledge/blob/main/LICENSE)。
|
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderBanner(color?: boolean): string;
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Chalk } from 'chalk';
|
|
2
|
+
const bannerLines = [
|
|
3
|
+
'██╗ ██╗ ██████╗ ██╗ ██╗██╗ ██╗███╗ ██╗ ██████╗ ██╗ ██╗',
|
|
4
|
+
'╚██╗ ██╔╝██╔═══██╗██║ ██║██║ ██╔╝████╗ ██║██╔═══██╗██║ ██║',
|
|
5
|
+
' ╚████╔╝ ██║ ██║██║ ██║█████╔╝ ██╔██╗ ██║██║ ██║██║ █╗ ██║',
|
|
6
|
+
' ╚██╔╝ ██║ ██║██║ ██║██╔═██╗ ██║╚██╗██║██║ ██║██║███╗██║',
|
|
7
|
+
' ██║ ╚██████╔╝╚██████╔╝██║ ██╗██║ ╚████║╚██████╔╝╚███╔███╔╝',
|
|
8
|
+
' ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══╝╚══╝',
|
|
9
|
+
];
|
|
10
|
+
export function renderBanner(color = Boolean(process.stdout.isTTY)) {
|
|
11
|
+
const paint = new Chalk({ level: color ? 1 : 0 });
|
|
12
|
+
return bannerLines.map((line) => paint.magenta.bold(line)).join('\n');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,WAAW,GAAG;IAClB,kEAAkE;IAClE,kEAAkE;IAClE,kEAAkE;IAClE,kEAAkE;IAClE,kEAAkE;IAClE,iEAAiE;CAClE,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClaudeScope, type ClaudeUpdatesResult } from './fetch.js';
|
|
2
|
+
export type ClaudeOutputFormat = 'json' | 'md';
|
|
3
|
+
export interface ClaudeCommandOptions {
|
|
4
|
+
scope: ClaudeScope;
|
|
5
|
+
limit: number;
|
|
6
|
+
format: ClaudeOutputFormat;
|
|
7
|
+
output?: string;
|
|
8
|
+
timeout: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function formatClaudeJson(result: ClaudeUpdatesResult): string;
|
|
11
|
+
export declare function formatClaudeMarkdown(result: ClaudeUpdatesResult): string;
|
|
12
|
+
export declare function runClaudeCommand(options: ClaudeCommandOptions): Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { fetchClaudeUpdates, } from './fetch.js';
|
|
5
|
+
const typeLabels = {
|
|
6
|
+
news: '新闻',
|
|
7
|
+
research: '研究',
|
|
8
|
+
'platform-release': 'Platform',
|
|
9
|
+
};
|
|
10
|
+
function escapeMarkdown(value) {
|
|
11
|
+
return (value ?? '—')
|
|
12
|
+
.replaceAll('\\', '\\\\')
|
|
13
|
+
.replaceAll('|', '\\|')
|
|
14
|
+
.replaceAll('\r', ' ')
|
|
15
|
+
.replaceAll('\n', ' ')
|
|
16
|
+
.trim();
|
|
17
|
+
}
|
|
18
|
+
function escapeLinkText(value) {
|
|
19
|
+
return escapeMarkdown(value).replaceAll('[', '\\[').replaceAll(']', '\\]');
|
|
20
|
+
}
|
|
21
|
+
export function formatClaudeJson(result) {
|
|
22
|
+
return JSON.stringify(result, null, 2);
|
|
23
|
+
}
|
|
24
|
+
export function formatClaudeMarkdown(result) {
|
|
25
|
+
const metadata = [
|
|
26
|
+
`- 范围:${escapeMarkdown(result.scope)}`,
|
|
27
|
+
`- 采集时间:${escapeMarkdown(result.collectedAt)}`,
|
|
28
|
+
`- 动态数量:${result.total}`,
|
|
29
|
+
];
|
|
30
|
+
const header = '| # | 标题 | 类型 | 分类 | 发布日期 | 摘要 |';
|
|
31
|
+
const divider = '|---:|---|---|---|---|---|';
|
|
32
|
+
const rows = result.items.map((item) => {
|
|
33
|
+
const title = `[${escapeLinkText(item.title)}](${item.url})`;
|
|
34
|
+
return `| ${item.rank} | ${title} | ${typeLabels[item.type]} | ${escapeMarkdown(item.category)} | ${item.publishedAt.slice(0, 10)} | ${escapeMarkdown(item.summary)} |`;
|
|
35
|
+
});
|
|
36
|
+
return [
|
|
37
|
+
'# Claude 官方动态',
|
|
38
|
+
'',
|
|
39
|
+
...metadata,
|
|
40
|
+
'',
|
|
41
|
+
header,
|
|
42
|
+
divider,
|
|
43
|
+
...rows,
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
function formatClaudeResult(result, format) {
|
|
47
|
+
return format === 'md'
|
|
48
|
+
? formatClaudeMarkdown(result)
|
|
49
|
+
: formatClaudeJson(result);
|
|
50
|
+
}
|
|
51
|
+
async function saveClaudeOutput(path, content) {
|
|
52
|
+
const absolutePath = resolve(path);
|
|
53
|
+
await mkdir(dirname(absolutePath), { recursive: true });
|
|
54
|
+
await writeFile(absolutePath, `${content}\n`, 'utf8');
|
|
55
|
+
return absolutePath;
|
|
56
|
+
}
|
|
57
|
+
export async function runClaudeCommand(options) {
|
|
58
|
+
const result = await fetchClaudeUpdates({
|
|
59
|
+
scope: options.scope,
|
|
60
|
+
timeout: options.timeout,
|
|
61
|
+
});
|
|
62
|
+
result.items = result.items.slice(0, options.limit);
|
|
63
|
+
result.total = result.items.length;
|
|
64
|
+
const content = formatClaudeResult(result, options.format);
|
|
65
|
+
process.stdout.write(`${content}\n`);
|
|
66
|
+
if (options.output) {
|
|
67
|
+
const savedTo = await saveClaudeOutput(options.output, content);
|
|
68
|
+
process.stderr.write(`${chalk.green('✓')} 已保存到 ${chalk.magenta(savedTo)}\n`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/channels/claude/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,kBAAkB,GAGnB,MAAM,YAAY,CAAC;AAYpB,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;IACd,kBAAkB,EAAE,UAAU;CACtB,CAAC;AAEX,SAAS,cAAc,CAAC,KAAgC;IACtD,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC;S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AAM,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CACvD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const ANTHROPIC_NEWS_URL = "https://www.anthropic.com/news";
|
|
2
|
+
export declare const ANTHROPIC_RESEARCH_URL = "https://www.anthropic.com/research";
|
|
3
|
+
export declare const CLAUDE_PLATFORM_RELEASES_URL = "https://platform.claude.com/docs/en/release-notes/overview";
|
|
4
|
+
export declare const CLAUDE_PLATFORM_FEED_URL = "https://platform.claude.com/docs/en/release-notes/feed.xml";
|
|
5
|
+
export type ClaudeScope = 'all' | 'news' | 'research' | 'platform';
|
|
6
|
+
export type ClaudeItemType = 'news' | 'research' | 'platform-release';
|
|
7
|
+
export interface ClaudeUpdateItem {
|
|
8
|
+
source: 'claude';
|
|
9
|
+
type: ClaudeItemType;
|
|
10
|
+
rank: number;
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
url: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
category: string | null;
|
|
16
|
+
publishedAt: string;
|
|
17
|
+
collectedAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ClaudeUpdatesResult {
|
|
20
|
+
source: 'claude';
|
|
21
|
+
type: 'updates-feed';
|
|
22
|
+
scope: ClaudeScope;
|
|
23
|
+
sourceUrls: {
|
|
24
|
+
news: string;
|
|
25
|
+
research: string;
|
|
26
|
+
platform: string;
|
|
27
|
+
platformFeed: string;
|
|
28
|
+
};
|
|
29
|
+
collectedAt: string;
|
|
30
|
+
total: number;
|
|
31
|
+
items: ClaudeUpdateItem[];
|
|
32
|
+
}
|
|
33
|
+
export interface ClaudeFetchOptions {
|
|
34
|
+
scope?: ClaudeScope;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ClaudeFetchContext {
|
|
38
|
+
fetch?: typeof globalThis.fetch;
|
|
39
|
+
}
|
|
40
|
+
type PageScope = Exclude<ClaudeScope, 'all' | 'platform'>;
|
|
41
|
+
export declare function parseAnthropicUpdatesPage(html: string, scope: PageScope, collectedAt?: string): ClaudeUpdateItem[];
|
|
42
|
+
export declare function parseClaudePlatformFeed(xml: string, collectedAt?: string): ClaudeUpdateItem[];
|
|
43
|
+
export declare function fetchClaudeUpdates(options?: ClaudeFetchOptions, context?: ClaudeFetchContext): Promise<ClaudeUpdatesResult>;
|
|
44
|
+
export {};
|