earshot-cli 0.2.0__tar.gz → 0.3.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.
Files changed (34) hide show
  1. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/PKG-INFO +98 -5
  2. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/README.md +97 -4
  3. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/pyproject.toml +1 -1
  4. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/cli.py +21 -0
  5. earshot_cli-0.3.1/tests/test_me.py +51 -0
  6. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/.github/workflows/ci.yml +0 -0
  7. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/.github/workflows/publish.yml +0 -0
  8. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/.gitignore +0 -0
  9. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/LICENSE +0 -0
  10. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/scripts/download_models.sh +0 -0
  11. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/__init__.py +0 -0
  12. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/auth.py +0 -0
  13. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/capture.py +0 -0
  14. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/compose.py +0 -0
  15. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/config.py +0 -0
  16. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/deliver.py +0 -0
  17. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/extract.py +0 -0
  18. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/live.py +0 -0
  19. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/models.py +0 -0
  20. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/subtitle.py +0 -0
  21. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/transcribe.py +0 -0
  22. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/src/earshot/transcribe_cloud.py +0 -0
  23. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/conftest.py +0 -0
  24. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_auth.py +0 -0
  25. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_compose.py +0 -0
  26. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_config.py +0 -0
  27. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_deliver.py +0 -0
  28. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_deliver_api.py +0 -0
  29. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_do_deliver.py +0 -0
  30. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_extract.py +0 -0
  31. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_live.py +0 -0
  32. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_subtitle.py +0 -0
  33. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/tests/test_wizard.py +0 -0
  34. {earshot_cli-0.2.0 → earshot_cli-0.3.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: earshot-cli
3
- Version: 0.2.0
3
+ Version: 0.3.1
4
4
  Summary: 旁听剪藏:跨平台桌面端系统声录制 → 本地转写 → 投递知识库(默认 ExoMind,可插拔)
5
5
  Project-URL: Homepage, https://github.com/helloworldtang/earshot
6
6
  Project-URL: Repository, https://github.com/helloworldtang/earshot
@@ -44,11 +44,103 @@ Description-Content-Type: text/markdown
44
44
 
45
45
  ## 安装(开箱即用)
46
46
 
47
+ 唯一的依赖是 [uv](https://docs.astral.sh/uv/)(Python 的包管理器)。**不需要预装 Python**——uv 会自动下载并管理所需版本(earshot 需要 Python ≥3.12,uv 全程代劳)。
48
+
49
+ 按顺序三步:
50
+
51
+ **第 1 步:安装 uv**(已装可跳过,`uv --version` 可验证)
52
+
53
+ ```bash
54
+ # macOS / Linux
55
+ curl -LsSf https://astral.sh/uv/install.sh | sh
56
+
57
+ # Windows(PowerShell)
58
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
59
+ ```
60
+
61
+ 装完**重开一个终端**(或按安装器提示把 uv 加进 PATH),再验证:
62
+
63
+ ```bash
64
+ uv --version
65
+ ```
66
+
67
+ <details>
68
+ <summary><b>国内网络看这里</b>(直连 GitHub/PyPI 慢或超时;两条路线均已在 macOS 实测通过,Windows 命令来自镜像官方文档)</summary>
69
+
70
+ **路线 A(推荐——什么都不用预装,一条命令搞定)**
71
+
72
+ A1. 用国内镜像安装 uv([uv.agentsmirror.com](https://github.com/Wangnov/uv-custom) 公益镜像,分发的是官方原版安装脚本,只把下载源切到国内):
73
+
74
+ ```bash
75
+ # macOS / Linux
76
+ curl -LsSf https://uv.agentsmirror.com/install-cn.sh | sh
77
+ # Windows(PowerShell)
78
+ powershell -ExecutionPolicy ByPass -c "irm https://uv.agentsmirror.com/install-cn.ps1 | iex"
79
+ ```
80
+
81
+ A2. **重开一个终端**(关键:镜像的 PyPI 源配置写在 shell 配置里,不重开终端不生效),验证 uv:
82
+
83
+ ```bash
84
+ uv --version # 输出版本号(如 uv 0.13.7)即成功
85
+ ```
86
+
87
+ A3. 安装 earshot(Python 与全部依赖自动下载,均走国内源):
88
+
89
+ ```bash
90
+ uv tool install earshot-cli
91
+ ```
92
+
93
+ A4. 验证命令可用:
94
+
47
95
  ```bash
48
- uv tool install earshot-cli # 或 pipx install earshot-cli
49
- earshot doctor # 环境自检;earshot 与 earshot-cli 两个命令名等价可用
96
+ earshot me # 看到「凭据:未配置(earshot login …)」即安装成功,接着看下方第 3 步登录
50
97
  ```
51
98
 
99
+ **路线 B(机器上已有 Python 和 pip)**
100
+
101
+ B1. 用清华源装 uv:
102
+
103
+ ```bash
104
+ pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
105
+ ```
106
+
107
+ B2. 写入国内源配置(包索引走清华、Python 下载走 agentsmirror,一劳永逸):
108
+
109
+ ```bash
110
+ mkdir -p ~/.config/uv
111
+ printf '[[index]]\nurl = "https://pypi.tuna.tsinghua.edu.cn/simple"\ndefault = true\n\npython-install-mirror = "https://uv.agentsmirror.com/python-build-standalone/releases/download"\n' > ~/.config/uv/uv.toml
112
+ ```
113
+
114
+ (Windows 路径为 `%APPDATA%\uv\uv.toml`,内容相同)
115
+
116
+ B3. 安装并验证:
117
+
118
+ ```bash
119
+ uv tool install earshot-cli
120
+ earshot me
121
+ ```
122
+
123
+ </details>
124
+
125
+ **第 2 步:安装 earshot**(uv 自动下载 Python ≥3.12 与全部依赖,含内置 ffmpeg)
126
+
127
+ ```bash
128
+ uv tool install earshot-cli
129
+ ```
130
+
131
+ > 若提示 `command not found: earshot`:uv 把命令装到了 `~/.local/bin`(Windows 为 `%USERPROFILE%\.local\bin`),按提示把它加入 PATH 或重开终端。
132
+
133
+ **第 3 步:登录并自检**
134
+
135
+ ```bash
136
+ earshot login # 浏览器打开授权页,点「授权登录」即完成(已登录过 exomind 则免)
137
+ earshot me # 显示凭据状态与服务连通性(「凭据状态:有效」即就绪)
138
+ ```
139
+
140
+ 没有 ExoMind 账号?投递可换任意 webhook(`--deliver webhook --webhook <url>`),或 `--deliver none` 只本地存档,两者都不需要登录。
141
+
142
+ `earshot` 与 `earshot-cli` 两个命令名等价可用;`earshot doctor` 可做完整环境自检。
143
+
52
144
  升级:
53
145
 
54
146
  ```bash
@@ -60,7 +152,7 @@ uv tool upgrade earshot-cli
60
152
  源码安装请**锁版本 tag**,不要引滚动的 `main`(消费方 `uv sync`/`pip install` 会隐性升级到未审阅代码;升级应当是显式改版本号的决策):
61
153
 
62
154
  ```bash
63
- uv tool install "earshot-cli @ https://github.com/helloworldtang/earshot/archive/refs/tags/v0.2.0.tar.gz"
155
+ uv tool install "earshot-cli @ https://github.com/helloworldtang/earshot/archive/refs/tags/v0.3.1.tar.gz"
64
156
  ```
65
157
 
66
158
  - **零系统依赖**:ffmpeg 已随 Python wheel 内置([imageio-ffmpeg](https://pypi.org/project/imageio-ffmpeg),MoviePy 同款),无需 brew/apt。
@@ -104,7 +196,8 @@ earshot audio recording.mp4 --title "通勤听书笔记" --deliver none
104
196
  # 补投/重投 outbox 里的笔记(如环境问题当时没投出去)
105
197
  earshot deliver ~/.earshot/outbox/20261030-xxxx.md
106
198
 
107
- # 列出采集设备 / 环境自检 / 清理过期留档
199
+ # 查看凭据状态 / 列出采集设备 / 环境自检 / 清理过期留档
200
+ earshot me
108
201
  earshot devices
109
202
  earshot doctor
110
203
  earshot clean --days 30
@@ -11,11 +11,103 @@
11
11
 
12
12
  ## 安装(开箱即用)
13
13
 
14
+ 唯一的依赖是 [uv](https://docs.astral.sh/uv/)(Python 的包管理器)。**不需要预装 Python**——uv 会自动下载并管理所需版本(earshot 需要 Python ≥3.12,uv 全程代劳)。
15
+
16
+ 按顺序三步:
17
+
18
+ **第 1 步:安装 uv**(已装可跳过,`uv --version` 可验证)
19
+
20
+ ```bash
21
+ # macOS / Linux
22
+ curl -LsSf https://astral.sh/uv/install.sh | sh
23
+
24
+ # Windows(PowerShell)
25
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
26
+ ```
27
+
28
+ 装完**重开一个终端**(或按安装器提示把 uv 加进 PATH),再验证:
29
+
30
+ ```bash
31
+ uv --version
32
+ ```
33
+
34
+ <details>
35
+ <summary><b>国内网络看这里</b>(直连 GitHub/PyPI 慢或超时;两条路线均已在 macOS 实测通过,Windows 命令来自镜像官方文档)</summary>
36
+
37
+ **路线 A(推荐——什么都不用预装,一条命令搞定)**
38
+
39
+ A1. 用国内镜像安装 uv([uv.agentsmirror.com](https://github.com/Wangnov/uv-custom) 公益镜像,分发的是官方原版安装脚本,只把下载源切到国内):
40
+
41
+ ```bash
42
+ # macOS / Linux
43
+ curl -LsSf https://uv.agentsmirror.com/install-cn.sh | sh
44
+ # Windows(PowerShell)
45
+ powershell -ExecutionPolicy ByPass -c "irm https://uv.agentsmirror.com/install-cn.ps1 | iex"
46
+ ```
47
+
48
+ A2. **重开一个终端**(关键:镜像的 PyPI 源配置写在 shell 配置里,不重开终端不生效),验证 uv:
49
+
50
+ ```bash
51
+ uv --version # 输出版本号(如 uv 0.13.7)即成功
52
+ ```
53
+
54
+ A3. 安装 earshot(Python 与全部依赖自动下载,均走国内源):
55
+
56
+ ```bash
57
+ uv tool install earshot-cli
58
+ ```
59
+
60
+ A4. 验证命令可用:
61
+
14
62
  ```bash
15
- uv tool install earshot-cli # 或 pipx install earshot-cli
16
- earshot doctor # 环境自检;earshot 与 earshot-cli 两个命令名等价可用
63
+ earshot me # 看到「凭据:未配置(earshot login …)」即安装成功,接着看下方第 3 步登录
17
64
  ```
18
65
 
66
+ **路线 B(机器上已有 Python 和 pip)**
67
+
68
+ B1. 用清华源装 uv:
69
+
70
+ ```bash
71
+ pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
72
+ ```
73
+
74
+ B2. 写入国内源配置(包索引走清华、Python 下载走 agentsmirror,一劳永逸):
75
+
76
+ ```bash
77
+ mkdir -p ~/.config/uv
78
+ printf '[[index]]\nurl = "https://pypi.tuna.tsinghua.edu.cn/simple"\ndefault = true\n\npython-install-mirror = "https://uv.agentsmirror.com/python-build-standalone/releases/download"\n' > ~/.config/uv/uv.toml
79
+ ```
80
+
81
+ (Windows 路径为 `%APPDATA%\uv\uv.toml`,内容相同)
82
+
83
+ B3. 安装并验证:
84
+
85
+ ```bash
86
+ uv tool install earshot-cli
87
+ earshot me
88
+ ```
89
+
90
+ </details>
91
+
92
+ **第 2 步:安装 earshot**(uv 自动下载 Python ≥3.12 与全部依赖,含内置 ffmpeg)
93
+
94
+ ```bash
95
+ uv tool install earshot-cli
96
+ ```
97
+
98
+ > 若提示 `command not found: earshot`:uv 把命令装到了 `~/.local/bin`(Windows 为 `%USERPROFILE%\.local\bin`),按提示把它加入 PATH 或重开终端。
99
+
100
+ **第 3 步:登录并自检**
101
+
102
+ ```bash
103
+ earshot login # 浏览器打开授权页,点「授权登录」即完成(已登录过 exomind 则免)
104
+ earshot me # 显示凭据状态与服务连通性(「凭据状态:有效」即就绪)
105
+ ```
106
+
107
+ 没有 ExoMind 账号?投递可换任意 webhook(`--deliver webhook --webhook <url>`),或 `--deliver none` 只本地存档,两者都不需要登录。
108
+
109
+ `earshot` 与 `earshot-cli` 两个命令名等价可用;`earshot doctor` 可做完整环境自检。
110
+
19
111
  升级:
20
112
 
21
113
  ```bash
@@ -27,7 +119,7 @@ uv tool upgrade earshot-cli
27
119
  源码安装请**锁版本 tag**,不要引滚动的 `main`(消费方 `uv sync`/`pip install` 会隐性升级到未审阅代码;升级应当是显式改版本号的决策):
28
120
 
29
121
  ```bash
30
- uv tool install "earshot-cli @ https://github.com/helloworldtang/earshot/archive/refs/tags/v0.2.0.tar.gz"
122
+ uv tool install "earshot-cli @ https://github.com/helloworldtang/earshot/archive/refs/tags/v0.3.1.tar.gz"
31
123
  ```
32
124
 
33
125
  - **零系统依赖**:ffmpeg 已随 Python wheel 内置([imageio-ffmpeg](https://pypi.org/project/imageio-ffmpeg),MoviePy 同款),无需 brew/apt。
@@ -71,7 +163,8 @@ earshot audio recording.mp4 --title "通勤听书笔记" --deliver none
71
163
  # 补投/重投 outbox 里的笔记(如环境问题当时没投出去)
72
164
  earshot deliver ~/.earshot/outbox/20261030-xxxx.md
73
165
 
74
- # 列出采集设备 / 环境自检 / 清理过期留档
166
+ # 查看凭据状态 / 列出采集设备 / 环境自检 / 清理过期留档
167
+ earshot me
75
168
  earshot devices
76
169
  earshot doctor
77
170
  earshot clean --days 30
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "earshot-cli"
3
- version = "0.2.0"
3
+ version = "0.3.1"
4
4
  description = "旁听剪藏:跨平台桌面端系统声录制 → 本地转写 → 投递知识库(默认 ExoMind,可插拔)"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -78,6 +78,8 @@ def build_parser() -> argparse.ArgumentParser:
78
78
  )
79
79
  p_deliver.add_argument("--webhook", help="webhook 地址(--deliver webhook 时必填)")
80
80
 
81
+ sub.add_parser("me", help="显示凭据状态与服务连通性")
82
+
81
83
  p_login = sub.add_parser("login", help="设备流登录 exomind(免装 emcli,写入 ~/.exomind/config.json)")
82
84
  p_login.add_argument("--base-url", default=DEFAULT_EXOMIND_BASE_URL, help="exomind API 地址")
83
85
  p_login.add_argument("--force", action="store_true", help="跳过「凭据仍有效」检查,无条件重新登录")
@@ -513,6 +515,24 @@ def cmd_clean(args: argparse.Namespace, settings: Settings) -> int:
513
515
  return EXIT_OK
514
516
 
515
517
 
518
+ def cmd_me(_args: argparse.Namespace, settings: Settings) -> int:
519
+ """显示凭据状态与服务连通性(与 wxpub/emcli me 对齐)。"""
520
+ print(f"服务地址:{settings.exomind_base_url}")
521
+ if not settings.exomind_api_key:
522
+ print("凭据:未配置(earshot login,或设 EXOMIND_API_KEY 环境变量)")
523
+ return EXIT_FAIL
524
+ key = settings.exomind_api_key
525
+ masked = f"{key[:8]}…{key[-4:]}" if len(key) > 12 else key
526
+ print(f"凭据:{masked}")
527
+ if verify_key(settings.exomind_base_url, key):
528
+ # 设备流签发的是长期 API Key(无 expires_at),与 wxpub 委托票的 15 分钟 TTL 不同——
529
+ # 一致性口径对齐 wxpub me 的 sk_ 分支:「长期有效」;失效才需要重登
530
+ print("凭据状态:有效(长期 API Key,无到期时间)")
531
+ return EXIT_OK
532
+ print("凭据状态:无效或服务不可达(重登用: earshot login --force)")
533
+ return EXIT_FAIL
534
+
535
+
516
536
  def cmd_login(args: argparse.Namespace, settings: Settings) -> int:
517
537
  """设备流登录 exomind:已有凭据探活仍有效则直接返回(与 emcli/wxpub 同款智能登录)。"""
518
538
  base_url = args.base_url
@@ -543,6 +563,7 @@ def main(argv: list[str] | None = None) -> int:
543
563
  "video": cmd_video,
544
564
  "deliver": cmd_deliver,
545
565
  "login": cmd_login,
566
+ "me": cmd_me,
546
567
  "devices": cmd_devices,
547
568
  "doctor": cmd_doctor,
548
569
  "clean": cmd_clean,
@@ -0,0 +1,51 @@
1
+ """cmd_me 测试:凭据状态展示三分支(有效/无效/未配置),探活注入不联网。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ from pathlib import Path
7
+
8
+ import pytest
9
+
10
+ from earshot.cli import cmd_me
11
+ from earshot.config import Settings
12
+
13
+
14
+ def _settings(api_key: str = "") -> Settings:
15
+ return Settings(
16
+ home=Path("/tmp/earshot-test"),
17
+ model_root=Path("/tmp/earshot-test/models"),
18
+ exomind_base_url="https://exomind.example",
19
+ exomind_api_key=api_key,
20
+ )
21
+
22
+
23
+ def test_me_valid_key(
24
+ monkeypatch: pytest.MonkeyPatch,
25
+ capsys: pytest.CaptureFixture[str],
26
+ ) -> None:
27
+ monkeypatch.setattr("earshot.cli.verify_key", lambda base, key: True)
28
+ code = cmd_me(argparse.Namespace(), _settings("sk_live_valid_key"))
29
+ out = capsys.readouterr().out
30
+ assert code == 0
31
+ assert "https://exomind.example" in out
32
+ assert "sk_live_…_key" in out, "凭据掩码展示"
33
+ assert "凭据状态:有效(长期 API Key,无到期时间)" in out, "长期 key 无 TTL,口径对齐 wxpub sk_ 分支"
34
+
35
+
36
+ def test_me_invalid_key(
37
+ monkeypatch: pytest.MonkeyPatch,
38
+ capsys: pytest.CaptureFixture[str],
39
+ ) -> None:
40
+ monkeypatch.setattr("earshot.cli.verify_key", lambda base, key: False)
41
+ code = cmd_me(argparse.Namespace(), _settings("sk_live_invalid_"))
42
+ out = capsys.readouterr().out
43
+ assert code == 1
44
+ assert "earshot login --force" in out, "无效要指路重登"
45
+
46
+
47
+ def test_me_no_key(capsys: pytest.CaptureFixture[str]) -> None:
48
+ code = cmd_me(argparse.Namespace(), _settings(""))
49
+ out = capsys.readouterr().out
50
+ assert code == 1
51
+ assert "未配置" in out and "earshot login" in out
File without changes
File without changes
File without changes