@lexiaowen/md2wechat-new 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 ADDED
@@ -0,0 +1,236 @@
1
+ md2wechat Source Available License
2
+ Based on Business Source License 1.1
3
+
4
+ ===========================================================
5
+ PARAMETERS
6
+ ===========================================================
7
+
8
+ Licensor: geekjourneyx
9
+
10
+ Licensed Work: md2wechat
11
+ The Licensed Work is (c) 2024-2026 geekjourneyx.
12
+ "Licensed Work" includes the CLI source code, themes,
13
+ layout modules, prompt templates, skill definitions,
14
+ and all associated documentation and assets in this
15
+ repository.
16
+
17
+ Additional Use Grant: You may make production use of the Licensed Work
18
+ solely for the following Personal Non-Commercial
19
+ Purposes, free of charge and without further
20
+ authorization:
21
+
22
+ (a) Individual content creation: creating and
23
+ publishing articles, posts, or media for your own
24
+ personal WeChat Official Account, social media,
25
+ blogs, or other personal channels, provided you
26
+ do not receive direct commercial compensation for
27
+ that specific content. Passive income such as
28
+ platform advertising revenue shares (e.g., WeChat
29
+ Traffic Owner program) does not constitute direct
30
+ commercial compensation under this clause.
31
+
32
+ (b) Learning and research: reading, modifying, or
33
+ adapting the Licensed Work for your own
34
+ understanding or for academic/educational purposes.
35
+
36
+ (c) Evaluation: testing and evaluating the Licensed
37
+ Work for your own non-commercial assessment.
38
+
39
+ (d) Non-profit use: use by registered non-profit
40
+ organizations for non-commercial activities.
41
+
42
+ (e) Contributions: submitting modifications,
43
+ improvements, or bug fixes back to this project.
44
+
45
+ Any use not listed above — including any Commercial
46
+ Purpose as defined below — requires a separate written
47
+ commercial license from the Licensor.
48
+
49
+ "Commercial Purpose" means:
50
+
51
+ (i) offering the Licensed Work, or any product or
52
+ service substantially derived from or powered by
53
+ the Licensed Work (including its themes, layout
54
+ modules, or prompt templates), to third parties
55
+ for a fee or other commercial consideration;
56
+
57
+ (ii) using the Licensed Work internally within any
58
+ for-profit organization in connection with
59
+ revenue-generating activities;
60
+
61
+ (iii) incorporating the Licensed Work or its assets
62
+ (themes, layout modules, prompt templates) into
63
+ any paid software product, paid template, paid
64
+ subscription service, paid training course, or
65
+ paid private community;
66
+
67
+ (iv) using the Licensed Work to deliver services to
68
+ paying clients (design, formatting, publishing,
69
+ consulting, or similar services);
70
+
71
+ (v) rebranding, white-labeling, or redistributing
72
+ the Licensed Work or any substantially similar
73
+ product under a different name or brand, whether
74
+ or not the underlying code is modified, for any
75
+ commercial purpose;
76
+
77
+ (vi) using the Licensed Work, its documentation,
78
+ prompt templates, layout module definitions, or
79
+ theme assets as training data or fine-tuning
80
+ data for any machine learning or artificial
81
+ intelligence model intended for commercial use.
82
+
83
+ Change Date: 2030-01-01
84
+
85
+ Change License: Apache License, Version 2.0
86
+
87
+ Commercial Licensing: For commercial use authorization, please contact:
88
+ Email: skrphper@gmail.com
89
+ Website: https://jieni.ai
90
+ X: https://x.com/seekjourney
91
+ WeChat: search "极客杰尼", leave a message stating
92
+ "商业授权 / Commercial License"
93
+
94
+ ===========================================================
95
+ NOTICE
96
+ ===========================================================
97
+
98
+ Business Source License 1.1
99
+
100
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
101
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
102
+
103
+ This License does not grant you any right in any trademark, logo, or trade
104
+ name of the Licensor or its affiliates, including "md2wechat" and "极客杰尼".
105
+
106
+ ===========================================================
107
+ TERMS
108
+ ===========================================================
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first
116
+ publicly available distribution of a specific version of the Licensed Work
117
+ under this License, whichever comes first, the Licensor hereby grants you
118
+ rights under the terms of the Change License, and the rights granted in the
119
+ paragraph above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may
129
+ vary for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified
132
+ copy of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ ===========================================================
151
+ 中文说明(Chinese Summary)
152
+ ===========================================================
153
+
154
+ 本许可证基于 Business Source License 1.1(BUSL-1.1),并附加个人使用扩展条款。
155
+ 如本中文说明与上方英文条款存在歧义,以英文条款为准。
156
+
157
+ 本作品("Licensed Work")包含 md2wechat 的 CLI 源代码、主题、高级排版模块、
158
+ Prompt 模板、Skill 定义,及本仓库中全部相关文档与资产。
159
+
160
+ 版权所有 © 2024–2026 geekjourneyx
161
+
162
+ ─────────────────────────────────────────
163
+ 一、允许的使用(个人免费,无需授权)
164
+ ─────────────────────────────────────────
165
+
166
+ 以下场景无需申请授权,可免费使用:
167
+
168
+ • 个人内容创作:将 md2wechat 用于为自己的微信公众号、小红书、B站、
169
+ YouTube、个人博客等渠道创作内容,前提是该内容不直接产生商业收益。
170
+ 注:通过微信流量主、平台创作者激励计划获得的广告分成或打赏收入,
171
+ 视为非直接商业报酬,个人创作者可免费使用。若账号以企业或品牌名义
172
+ 运营并产生直接商业收益,则属于商业用途,须获得授权。
173
+
174
+ • 学习与研究:阅读源码、修改代码用于自我学习,或用于学术/教育目的。
175
+
176
+ • 评估与测试:非商业目的的功能体验和测试。
177
+
178
+ • 非营利组织:已登记注册的非营利组织用于非商业活动。
179
+
180
+ • 贡献代码:向本项目提交修改、改进或 Bug 修复。
181
+
182
+ ─────────────────────────────────────────
183
+ 二、禁止的使用(须事先获得书面商业授权)
184
+ ─────────────────────────────────────────
185
+
186
+ 以下场景属于商业用途,未经授权不得使用:
187
+
188
+ • 将本作品(或基于本作品的主题、排版模块、Prompt 模板等衍生成果)作为
189
+ 产品或服务对第三方收费提供;
190
+
191
+ • 在任何营利性组织中将本作品用于与商业运营直接相关的内部工作流;
192
+
193
+ • 基于本作品构建付费软件产品、付费模板、付费订阅服务、付费培训课程或
194
+ 付费私享社群;
195
+
196
+ • 使用本作品为付费客户提供设计、排版、发布等交付服务(外包、咨询等);
197
+
198
+ • 对本作品进行改名(Rebrand)、贴牌(White-label)或以不同品牌名义
199
+ 重新分发,无论底层代码是否经过修改,均须获得商业授权;
200
+
201
+ • 将本作品的源代码、文档、Prompt 模板、排版模块定义或主题资产用作任何
202
+ 以商业为目的的机器学习或人工智能模型的训练数据或微调数据。
203
+
204
+ 违反以上任一条款,即视为侵权,将自动终止你在本许可证下的全部权利。
205
+
206
+ ─────────────────────────────────────────
207
+ 三、自动开源日期(Change Date)
208
+ ─────────────────────────────────────────
209
+
210
+ 2030 年 1 月 1 日之后,本作品各版本将自动以 Apache License 2.0 授权发布。
211
+ 在此日期之前,上述商业用途限制持续有效。
212
+
213
+ ─────────────────────────────────────────
214
+ 四、商业授权联系方式
215
+ ─────────────────────────────────────────
216
+
217
+ 如需获得商业授权,请通过以下任一方式联系作者:
218
+
219
+ 邮件:skrphper@gmail.com
220
+ 官网:https://jieni.ai
221
+ X / Twitter:https://x.com/seekjourney
222
+ 微信公众号:极客杰尼(搜索「极客杰尼」,留言备注「商业授权」)
223
+
224
+ ─────────────────────────────────────────
225
+ 五、关于历史版本
226
+ ─────────────────────────────────────────
227
+
228
+ 本项目在此许可证生效前的历史版本以 MIT 许可证发布,该授权不受本许可证
229
+ 影响。本许可证自其生效提交(commit)起,适用于所有后续版本。
230
+
231
+ ─────────────────────────────────────────
232
+ 六、免责声明
233
+ ─────────────────────────────────────────
234
+
235
+ 本作品按「现状」提供,不附带任何明示或默示担保。作者不对因使用本作品
236
+ 造成的任何直接或间接损失承担责任。
package/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # md2wechat-new
2
+
3
+ `md2wechat-new` 是一个面向微信公众号创作和发布的命令行工具。它把 Markdown 转成适合微信公众号编辑器的 HTML,支持本地预览、图片上传、草稿创建、已有 HTML 上传,以及通过可配置的 OpenAI-compatible 文本 API 进行排版转换。
4
+
5
+ 这个分支保留原项目的 AI 模式,同时把旧的固定 API 服务替换为可配置 provider:
6
+
7
+ - OpenAI
8
+ - DeepSeek
9
+ - 硅基流动 SiliconFlow
10
+ - 任意 OpenAI-compatible API
11
+
12
+ ## 功能概览
13
+
14
+ | 能力 | 说明 |
15
+ | --- | --- |
16
+ | Markdown 转微信 HTML | `convert` 支持 API 模式和 AI 模式 |
17
+ | 可配置文本 API | 通过配置文件或环境变量切换 OpenAI、DeepSeek、SiliconFlow、custom |
18
+ | 本地预览 | `preview` 或 `convert --preview`,不上传图片、不创建草稿 |
19
+ | 微信草稿箱 | `convert --draft` 可转换后直接创建草稿 |
20
+ | 已有 HTML 上传 | `upload_html` 可把转换好的 HTML 直接创建为微信草稿 |
21
+ | 图片素材上传 | `upload_image`、`download_and_upload`、`--upload` |
22
+ | AI 图片 | `generate_cover`、`generate_infographic`、`generate_image` |
23
+ | 写作辅助 | `write`、`humanize` |
24
+ | Agent 友好 | `--json`、`capabilities`、`themes`、`providers`、`layout` |
25
+
26
+ ## 快速开始
27
+
28
+ ### 1. 本地构建
29
+
30
+ ```bash
31
+ cd /Users/leo/Desktop/project/md2wechat-new
32
+ go build -o md2wechat ./cmd/md2wechat
33
+ ./md2wechat version --json
34
+ ```
35
+
36
+ 如果你已经发布 npm 包,也可以安装:
37
+
38
+ ```bash
39
+ npm install -g @lexiaowen/md2wechat-new
40
+ md2wechat version --json
41
+ ```
42
+
43
+ npm 包安装时会从 GitHub Release 下载二进制。正式给别人使用前,需要先发布对应版本的 GitHub Release 资产。
44
+
45
+ 发布 Release 后,也可以用固定版本安装脚本:
46
+
47
+ ```bash
48
+ curl -fsSL https://github.com/LeXiaoWen/md2wechat-new/releases/download/v0.1.0/install.sh | bash
49
+ ```
50
+
51
+ macOS 用户如果维护了 Homebrew tap,也可以安装:
52
+
53
+ ```bash
54
+ brew install lexiaowenn/tap/md2wechat-new
55
+ ```
56
+
57
+ ### 2. 初始化配置
58
+
59
+ ```bash
60
+ ./md2wechat config init
61
+ ```
62
+
63
+ 默认生成:
64
+
65
+ ```text
66
+ ~/.config/md2wechat-new/config.yaml
67
+ ```
68
+
69
+ 如果文件已存在,直接编辑它即可。
70
+
71
+ ### 3. 配置文本 API
72
+
73
+ DeepSeek 示例:
74
+
75
+ ```yaml
76
+ api:
77
+ convert_mode: "api"
78
+ default_theme: "default"
79
+ text_provider: "deepseek"
80
+ text_key: "sk-..."
81
+ text_base_url: "https://api.deepseek.com"
82
+ text_model: "deepseek-chat"
83
+ text_temperature: 0.2
84
+ ```
85
+
86
+ 硅基流动示例:
87
+
88
+ ```yaml
89
+ api:
90
+ convert_mode: "api"
91
+ default_theme: "default"
92
+ text_provider: "siliconflow"
93
+ text_key: "sk-..."
94
+ text_base_url: "https://api.siliconflow.cn/v1"
95
+ text_model: "Qwen/Qwen2.5-72B-Instruct"
96
+ text_temperature: 0.2
97
+ ```
98
+
99
+ OpenAI 示例:
100
+
101
+ ```yaml
102
+ api:
103
+ convert_mode: "api"
104
+ default_theme: "default"
105
+ text_provider: "openai"
106
+ text_key: "sk-..."
107
+ text_base_url: "https://api.openai.com/v1"
108
+ text_model: "gpt-4.1-mini"
109
+ text_temperature: 0.2
110
+ ```
111
+
112
+ ### 4. 配置微信公众号
113
+
114
+ 如果要上传图片或创建草稿,还需要配置:
115
+
116
+ ```yaml
117
+ wechat:
118
+ appid: "你的微信公众号 AppID"
119
+ secret: "你的微信公众号 AppSecret"
120
+ ```
121
+
122
+ 并在微信公众号后台把当前机器公网 IP 加入 IP 白名单。详细说明见 [docs/WECHAT-CREDENTIALS.md](docs/WECHAT-CREDENTIALS.md)。
123
+
124
+ ### 5. 转换文章
125
+
126
+ ```bash
127
+ ./md2wechat inspect article.md
128
+ ./md2wechat convert article.md --preview
129
+ ./md2wechat convert article.md -o output.html
130
+ ```
131
+
132
+ 安装到 PATH 后,通用命令写法是:
133
+
134
+ ```bash
135
+ md2wechat inspect article.md
136
+ md2wechat preview article.md
137
+ md2wechat convert article.md --preview
138
+ ```
139
+
140
+ 创建微信草稿:
141
+
142
+ ```bash
143
+ ./md2wechat convert article.md --draft --cover cover.jpg
144
+ ```
145
+
146
+ 已有 HTML 直接上传:
147
+
148
+ ```bash
149
+ ./md2wechat upload_html output.html --title "文章标题" --cover cover.jpg
150
+ ```
151
+
152
+ ## 转换模式
153
+
154
+ ### API 模式
155
+
156
+ 默认模式。CLI 会调用你配置的 OpenAI-compatible `/chat/completions` 接口,把 Markdown 转成最终 HTML。
157
+
158
+ ```bash
159
+ ./md2wechat convert article.md --mode api -o output.html
160
+ ```
161
+
162
+ 特点:
163
+
164
+ - 需要 `TEXT_API_KEY` 或配置文件中的 `api.text_key`
165
+ - 支持 OpenAI、DeepSeek、SiliconFlow、custom
166
+ - 适合稳定、自动化、本地批处理
167
+ - 可直接配合 `--draft` 创建微信草稿
168
+
169
+ ### AI 模式
170
+
171
+ AI 模式不会调用文本 API,而是生成可交给外部 AI/Agent 的排版提示和结构化输出。
172
+
173
+ ```bash
174
+ ./md2wechat convert article.md --mode ai --theme autumn-warm --json
175
+ ```
176
+
177
+ 适合你想让 Claude、Codex 或其他 Agent 接管 HTML 生成的场景。
178
+
179
+ ## 常用命令
180
+
181
+ ```bash
182
+ # 查看当前配置
183
+ ./md2wechat config show --format json
184
+
185
+ # 校验配置
186
+ ./md2wechat config validate
187
+
188
+ # 检查文章 metadata 和发布风险
189
+ ./md2wechat inspect article.md --json
190
+
191
+ # 本地预览
192
+ ./md2wechat preview article.md
193
+
194
+ # 转换为 HTML
195
+ ./md2wechat convert article.md -o output.html
196
+
197
+ # 上传图片并替换 HTML 图片链接
198
+ ./md2wechat convert article.md --upload -o output.html
199
+
200
+ # 转换并创建微信草稿
201
+ ./md2wechat convert article.md --draft --cover cover.jpg
202
+
203
+ # 已有 HTML 创建草稿
204
+ ./md2wechat upload_html output.html --title "标题" --author "作者" --digest "摘要" --cover cover.jpg
205
+
206
+ # 上传单张图片到微信永久素材
207
+ ./md2wechat upload_image cover.jpg
208
+
209
+ # 发现可用主题、图片 provider、能力
210
+ ./md2wechat themes list --json
211
+ ./md2wechat providers list --json
212
+ ./md2wechat capabilities --json
213
+ ```
214
+
215
+ ## 配置优先级
216
+
217
+ 从高到低:
218
+
219
+ 1. 环境变量
220
+ 2. 配置文件
221
+ 3. 默认值
222
+
223
+ 默认配置文件搜索顺序:
224
+
225
+ 1. `~/.config/md2wechat-new/config.yaml`
226
+ 2. `~/.md2wechat.yaml`
227
+ 3. `./md2wechat-new.yaml`
228
+
229
+ 常用环境变量:
230
+
231
+ ```bash
232
+ export TEXT_PROVIDER="deepseek"
233
+ export TEXT_API_KEY="sk-..."
234
+ export TEXT_API_BASE="https://api.deepseek.com"
235
+ export TEXT_MODEL="deepseek-chat"
236
+ export TEXT_TEMPERATURE="0.2"
237
+
238
+ export WECHAT_APPID="..."
239
+ export WECHAT_SECRET="..."
240
+ ```
241
+
242
+ ## 文档入口
243
+
244
+ - [文档索引](docs/README.md)
245
+ - [新手快速开始](docs/QUICKSTART.md)
246
+ - [安装指南](docs/INSTALL.md)
247
+ - [配置指南](docs/CONFIG.md)
248
+ - [完整使用指南](docs/USAGE.md)
249
+ - [本地初始化到微信公众号草稿全流程](docs/LOCAL_TO_WECHAT_GUIDE.md)
250
+ - [微信凭证与 IP 白名单](docs/WECHAT-CREDENTIALS.md)
251
+ - [高级排版模块](docs/LAYOUT.md)
252
+ - [故障排查](docs/TROUBLESHOOTING.md)
253
+
254
+ ## 发布 npm 包
255
+
256
+ 当前 npm 包名:
257
+
258
+ ```text
259
+ @lexiaowen/md2wechat-new
260
+ ```
261
+
262
+ 本地发布:
263
+
264
+ ```bash
265
+ npm login
266
+ npm publish --access public --otp=你的6位验证码
267
+ ```
268
+
269
+ 发布后安装:
270
+
271
+ ```bash
272
+ npm install -g @lexiaowen/md2wechat-new
273
+ ```
274
+
275
+ 注意:npm 包的 `postinstall` 会下载 GitHub Release 里的二进制文件。发布 npm 前,应先推送 GitHub 仓库并创建同版本 Release。
276
+
277
+ ## License
278
+
279
+ See [LICENSE](LICENSE).
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@lexiaowen/md2wechat-new",
3
+ "version": "0.1.0",
4
+ "description": "Configurable-provider fork of the md2wechat CLI.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/LeXiaoWen/md2wechat-new.git"
9
+ },
10
+ "homepage": "https://github.com/LeXiaoWen/md2wechat-new#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/LeXiaoWen/md2wechat-new/issues"
13
+ },
14
+ "bin": {
15
+ "md2wechat": "scripts/run.js"
16
+ },
17
+ "scripts": {
18
+ "pack:check": "npm pack --json --dry-run",
19
+ "postinstall": "node scripts/install.js"
20
+ },
21
+ "files": [
22
+ "scripts/install.js",
23
+ "scripts/run.js",
24
+ "README.md",
25
+ "CHANGELOG.md",
26
+ "LICENSE"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
34
+ }