Skip to content

Commit 4996b68

Browse files
committed
新增仓内独立密语 CLI 子项目
添加 CipherTalk-CLI 子项目、斜杠交互模式、独立 CI/发布工作流,并确保桌面端打包排除 CLI 目录。
1 parent f93fc19 commit 4996b68

64 files changed

Lines changed: 6119 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CipherTalk CLI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'CipherTalk-CLI/**'
7+
- '.github/workflows/ciphertalk-cli.yml'
8+
push:
9+
branches:
10+
- main
11+
- master
12+
paths:
13+
- 'CipherTalk-CLI/**'
14+
- '.github/workflows/ciphertalk-cli.yml'
15+
workflow_dispatch:
16+
inputs:
17+
publish:
18+
description: '是否发布 ciphertalk-cli 到 npm 官方公开包仓库'
19+
required: true
20+
type: boolean
21+
default: false
22+
23+
permissions:
24+
contents: read
25+
26+
defaults:
27+
run:
28+
working-directory: CipherTalk-CLI
29+
30+
jobs:
31+
validate:
32+
name: 验证 CLI
33+
runs-on: windows-latest
34+
steps:
35+
- name: 拉取代码
36+
uses: actions/checkout@v5
37+
38+
- name: 设置 Node.js
39+
uses: actions/setup-node@v6
40+
with:
41+
node-version: 22.12.0
42+
cache: npm
43+
cache-dependency-path: CipherTalk-CLI/package-lock.json
44+
45+
- name: 安装 CLI 依赖
46+
run: npm ci
47+
48+
- name: 类型检查
49+
run: npm run typecheck
50+
51+
- name: 测试
52+
run: npm test -- --run
53+
54+
publish-npm:
55+
name: 发布 CLI
56+
runs-on: windows-latest
57+
needs: validate
58+
if: github.event_name == 'workflow_dispatch' && inputs.publish == true
59+
permissions:
60+
contents: read
61+
id-token: write
62+
steps:
63+
- name: 拉取代码
64+
uses: actions/checkout@v5
65+
66+
- name: 设置 Node.js
67+
uses: actions/setup-node@v6
68+
with:
69+
node-version: 22.12.0
70+
registry-url: https://registry.npmjs.org
71+
cache: npm
72+
cache-dependency-path: CipherTalk-CLI/package-lock.json
73+
74+
- name: 安装 CLI 依赖
75+
run: npm ci
76+
77+
- name: 构建 CLI 包
78+
run: npm run build
79+
80+
- name: 发布到 npm
81+
env:
82+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
run: npm publish --access public

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ xkey
6767
.claude/
6868
.tmp
6969
Agent示例UI/
70+
71+
# Embedded CLI local outputs
72+
CipherTalk-CLI/node_modules/
73+
CipherTalk-CLI/dist/
74+
CipherTalk-CLI/coverage/
75+
CipherTalk-CLI/.miyu-test/

CipherTalk-CLI/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.miyu-test/
5+
*.log

CipherTalk-CLI/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 ILoveBingLu
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.

CipherTalk-CLI/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CipherTalk-CLI
2+
3+
`ciphertalk-cli` 提供 `miyu` 命令,用于在命令行、脚本和自动化任务中读取 CipherTalk 兼容的微信本地数据。
4+
5+
这是密语仓库内的独立 Node/TypeScript 子项目。它和桌面版共享同一个 Git 仓库,但拥有自己的 `package.json`、锁文件、依赖、测试、构建产物和发布工作流。CLI 不启动 Electron,配置文件存放在 `~/.miyu/config.json`
6+
7+
桌面版和 CLI 在运行时互不依赖。需要同步数据层能力时,通过 `npm run sync:upstream` 做人工移植,不直接引用 Electron 模块。
8+
9+
## 开发
10+
11+
```bash
12+
npm install
13+
npm run dev -- status
14+
npm run typecheck
15+
npm test -- --run
16+
```
17+
18+
从密语仓库根目录运行:
19+
20+
```bash
21+
npm run cli -- status
22+
npm run cli:typecheck
23+
npm run cli:test
24+
```
25+
26+
除非明确要做 CLI 发布构建,否则不要运行 `npm run build`
27+
28+
## 交互模式
29+
30+
在终端中执行 `miyu status` 会先检查状态,然后进入交互式 CLI。进入后所有命令都使用 `/命令` 形式:
31+
32+
```bash
33+
miyu status
34+
miyu> /sessions --limit 20
35+
miyu> /messages "张三" --limit 50
36+
miyu> /exit
37+
```
38+
39+
输入 `/` 会自动显示所有可用命令供选择;输入 `/help` 也可以再次查看命令列表。脚本或管道场景可以显式指定 `--format``--quiet`,此时 `status` 只输出结果,不进入交互模式:
40+
41+
```bash
42+
miyu --format json status
43+
miyu --quiet status
44+
```
45+
46+
## 发布
47+
48+
CLI 的验证和发布由父仓库中的 `.github/workflows/ciphertalk-cli.yml` 单独处理。该工作流只监听 `CipherTalk-CLI/**` 相关改动,不参与桌面版打包。
49+
50+
发布目标是 npm 官方公开包仓库:`https://registry.npmjs.org`。手动触发工作流并启用 `publish` 后,会以公开 npm 包 `ciphertalk-cli` 发布,用户安装后使用 `miyu` 命令。国内用户可以等待 npmmirror 等镜像同步,或配置 npm 官方源安装。
51+
52+
## 命令
53+
54+
当前已注册的命令入口:
55+
56+
- `/status`:检查配置和数据库连接状态
57+
- `/sessions`:列出会话
58+
- `/messages <session>`:查询会话消息
59+
- `/contacts`:列出联系人
60+
- `/contact <contact>`:查看联系人详情
61+
- `/key get|test|set`:密钥管理
62+
- `/search`:全文搜索
63+
- `/stats global|contacts|time|session|keywords|group`:统计分析
64+
- `/export`:导出聊天数据
65+
- `/moments`:朋友圈数据
66+
- `/report`:年度报告数据
67+
- `/mcp serve`:独立 MCP Server 模式
68+
- `/help`:显示命令列表
69+
- `/exit`:退出交互模式
70+
71+
部分高级命令目前只保留公开接口,会返回 `NOT_IMPLEMENTED`,等待对应服务完成移植。

CipherTalk-CLI/bin/miyu.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
import { existsSync } from 'node:fs'
3+
import { dirname, join } from 'node:path'
4+
import { fileURLToPath, pathToFileURL } from 'node:url'
5+
6+
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
7+
const distEntry = join(root, 'dist', 'index.js')
8+
9+
if (existsSync(distEntry)) {
10+
await import(pathToFileURL(distEntry).href)
11+
} else {
12+
await import('tsx/esm')
13+
await import(pathToFileURL(join(root, 'src', 'index.ts')).href)
14+
}
Binary file not shown.
4.87 MB
Binary file not shown.
148 KB
Binary file not shown.
1.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)