cprofile 0.4.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.
@@ -0,0 +1,24 @@
1
+ # 命名规则(Naming V2)
2
+
3
+ ## 核心
4
+
5
+ - 用户可见名:`slug`
6
+ - 内部唯一:`profile_id`
7
+ - 兼容旧名:`aliases`
8
+
9
+ ## 自动命名
10
+
11
+ `<email_short>_<space_short>_<h4>`
12
+
13
+ 其中:
14
+ - `email_short`:邮箱简写
15
+ - `space_short`:空间名简写
16
+ - `h4`:`sha256(tool|account_key|space_key)` 前 4 位
17
+
18
+ ## 多空间支持
19
+
20
+ 同一账号在不同空间会得到不同 `space_key`,因此 slug 天然可并存。
21
+
22
+ ## 兼容策略
23
+
24
+ 旧 `name` 会自动写入 `aliases`,旧命令可继续使用。
@@ -0,0 +1,25 @@
1
+ # Quickstart(中文)
2
+
3
+ ## 步骤 1:打开账号列表
4
+
5
+ 运行:
6
+
7
+ `cprofile`
8
+
9
+ ## 步骤 2:快速切换并启动
10
+
11
+ - 输入关键词可过滤账号
12
+ - 方向键选择,回车启动 codex/claude
13
+
14
+ ## 步骤 3:低频操作(仍在同一页)
15
+
16
+ - `A`:添加账号
17
+ - `D`:诊断
18
+ - `I`:导入旧目录
19
+ - `R`:刷新用量
20
+ - `?`:查看快捷键帮助
21
+
22
+ ## 常见补充
23
+
24
+ - 查看诊断:`cprofile doctor`
25
+ - 查看全部命令:`cprofile --advanced-help`
@@ -0,0 +1,39 @@
1
+ # cprofile 使用说明(中文)
2
+
3
+ ## 什么是 cprofile
4
+
5
+ cprofile 是一个“终端账号切换台”,用于本机管理和切换 Codex / Claude 多账号。
6
+
7
+ ## 3 步上手
8
+
9
+ 1. 输入 `cprofile` 直接进入账号列表。
10
+ 2. 方向键选择账号,回车立刻启动对应 CLI。
11
+ 3. 需要低频操作时,在列表页按快捷键(A/D/I/R/?)。
12
+
13
+ ## 使用特点
14
+
15
+ - 默认主链路就是切换账号,不再先选功能菜单。
16
+ - 列表只保留核心信息:账号 + 工作空间(Codex)+ 用量。
17
+ - 用量口径统一为“已用/剩余”。
18
+
19
+ ## 列表快捷键
20
+
21
+ - `A` 添加账号
22
+ - `D` 诊断
23
+ - `I` 导入旧目录
24
+ - `R` 刷新用量
25
+ - `Tab` 切换排序
26
+ - `Ctrl+P` 收藏账号
27
+ - `Ctrl+A` 显示/隐藏异常账号
28
+ - `?` 查看帮助
29
+
30
+ ## 文档入口
31
+
32
+ - `cprofile guide`:查看文档主题
33
+ - `cprofile guide quickstart`
34
+ - `cprofile guide troubleshooting`
35
+ - `cprofile guide naming`
36
+
37
+ ## 高级命令入口
38
+
39
+ - `cprofile --advanced-help`
@@ -0,0 +1,83 @@
1
+ # 故障排查(Troubleshooting)
2
+
3
+ ## 网络或代理问题
4
+
5
+ 现象:
6
+ - 登录页打不开、卡住或超时
7
+
8
+ 一键动作:
9
+ - 检查 `HTTP_PROXY` / `HTTPS_PROXY`
10
+ - 重新执行首页“添加账号”向导
11
+
12
+ 预期结果:
13
+ - 能正常弹出并完成登录
14
+
15
+ ## 登录失败
16
+
17
+ 现象:
18
+ - 完成授权后仍提示未登录
19
+
20
+ 一键动作:
21
+ - 执行 `cprofile` -> “添加账号”重新走向导登录
22
+
23
+ 预期结果:
24
+ - `快速切换` 中状态显示“可用”
25
+
26
+ ## Token 失效
27
+
28
+ 现象:
29
+ - 请求未授权、额度异常、突然掉线
30
+
31
+ 一键动作:
32
+ - 用首页“添加账号”重新登录,覆盖旧凭证
33
+
34
+ 预期结果:
35
+ - 同一账号恢复可用
36
+
37
+ ## 账号重复
38
+
39
+ 现象:
40
+ - 列表里看起来是同一账号的重复项
41
+
42
+ 一键动作:
43
+ - 先执行 `cprofile doctor`
44
+ - 再执行 `cprofile rm <slug> --tool <tool>`
45
+
46
+ 预期结果:
47
+ - 重复项被清理,`doctor` 不再报重复
48
+
49
+ ## 命名冲突
50
+
51
+ 现象:
52
+ - 自定义短名提示已存在
53
+
54
+ 一键动作:
55
+ - 在向导中换一个短名
56
+ - 或使用 `cprofile name suggest ...` 预览建议名
57
+
58
+ 预期结果:
59
+ - 新短名保存成功,可直接切换
60
+
61
+ ## 权限问题
62
+
63
+ 现象:
64
+ - 报权限不足、文件写入失败
65
+
66
+ 一键动作:
67
+ - 检查 `~/.cprofile` 权限应为 `700`
68
+ - 敏感文件应为 `600`
69
+
70
+ 预期结果:
71
+ - 命令恢复正常
72
+
73
+ ## 导入后仍显示旧账号
74
+
75
+ 现象:
76
+ - 导入后分不清哪个是目标账号
77
+
78
+ 一键动作:
79
+ - 执行 `cprofile use`,输入邮箱或空间名过滤
80
+ - 必要时执行 `cprofile rename <id> <new_slug> --tool <tool>`
81
+
82
+ 预期结果:
83
+ - 目标账号能被快速定位并切换
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "cprofile",
3
+ "version": "0.4.0",
4
+ "description": "Local multi-profile manager for Codex + Claude (interactive Chinese-first CLI)",
5
+ "keywords": [
6
+ "codex",
7
+ "claude",
8
+ "cli",
9
+ "profile",
10
+ "account-switch",
11
+ "terminal"
12
+ ],
13
+ "homepage": "https://github.com/WilsonLiu95/cprofile",
14
+ "bugs": {
15
+ "url": "https://github.com/WilsonLiu95/cprofile/issues"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Wilson Liu",
19
+ "type": "commonjs",
20
+ "bin": {
21
+ "cprofile": "bin/cprofile",
22
+ "cprofile-cli": "bin/cprofile-cli"
23
+ },
24
+ "files": [
25
+ "bin/",
26
+ "shell/",
27
+ "docs/",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/WilsonLiu95/cprofile.git"
37
+ },
38
+ "publishConfig": {
39
+ "registry": "https://registry.npmjs.org",
40
+ "access": "public"
41
+ }
42
+ }
@@ -0,0 +1,46 @@
1
+ # cprofile shell integration
2
+ # Source this file in your shell rc to make `cprofile use` affect current shell.
3
+
4
+ cprofile() {
5
+ if [ "$#" -gt 0 ] && [ "$1" = "use" ]; then
6
+ local _cprofile_out
7
+ if ! _cprofile_out="$(command cprofile-cli env "$@")"; then
8
+ return $?
9
+ fi
10
+ eval "${_cprofile_out}"
11
+
12
+ # Auto-open the selected CLI after profile switch.
13
+ # Set CPROFILE_AUTO_OPEN=0 to disable this behavior.
14
+ if [ "${CPROFILE_AUTO_OPEN:-1}" = "0" ]; then
15
+ echo "✓ 已切换到 ${CPROFILE_ACTIVE_TOOL}/${CPROFILE_ACTIVE_PROFILE}"
16
+ return 0
17
+ fi
18
+
19
+ case "${CPROFILE_ACTIVE_TOOL:-}" in
20
+ codex)
21
+ if command -v codex >/dev/null 2>&1; then
22
+ echo "✓ 已切换并启动 codex/${CPROFILE_ACTIVE_PROFILE}"
23
+ command codex
24
+ return $?
25
+ fi
26
+ echo "cprofile: 'codex' command not found in PATH" >&2
27
+ return 127
28
+ ;;
29
+ claude)
30
+ if command -v claude >/dev/null 2>&1; then
31
+ echo "✓ 已切换并启动 claude/${CPROFILE_ACTIVE_PROFILE}"
32
+ command claude
33
+ return $?
34
+ fi
35
+ echo "cprofile: 'claude' command not found in PATH" >&2
36
+ return 127
37
+ ;;
38
+ *)
39
+ echo "cprofile: unknown active tool: ${CPROFILE_ACTIVE_TOOL:-<empty>}" >&2
40
+ return 2
41
+ ;;
42
+ esac
43
+ fi
44
+
45
+ command cprofile-cli "$@"
46
+ }