@qzhuli/qzhuli-cli 0.1.0-beta.2 → 0.2.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/dist/cmd.js CHANGED
@@ -13641,7 +13641,7 @@ async function main() {
13641
13641
  ${t("cli.banner")}` : t("cli.banner");
13642
13642
  program.addHelpText("beforeAll", `${banner}
13643
13643
  `);
13644
- program.name("qz").version(`v${"0.1.0-beta.2"}`, "-v, --version", t("options.version")).helpOption("-h, --help", t("options.help")).option("-q, --jq <expr>", t("options.jq")).option("--dry-run", t("options.dryRun"));
13644
+ program.name("qz").version(`v${"0.2.0"}`, "-v, --version", t("options.version")).helpOption("-h, --help", t("options.help")).option("-q, --jq <expr>", t("options.jq")).option("--dry-run", t("options.dryRun"));
13645
13645
  program.usage("<command> [subcommand] [options]");
13646
13646
  program.hook("preAction", () => {
13647
13647
  const opts = program.opts();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzhuli/qzhuli-cli",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.2.0",
4
4
  "description": "CLI tool for Q助理 (QZhuli)",
5
5
  "main": "dist/cmd.js",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
+ "skills",
11
12
  "README.md",
12
13
  "CONTRIBUTING.md"
13
14
  ],
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: qzhuli-cli
3
+ description: Use when operating the QZhuli CLI with qz, including login, auth status, config, friends, relations, users, conversations, messages, JSON filtering, dry-run, command help, and interpreting test-environment banners or config files.
4
+ version: 1
5
+ ---
6
+
7
+ # QZhuli CLI
8
+
9
+ Use this skill as a concise operating manual for the `qz` command.
10
+
11
+ ## First Checks
12
+
13
+ 1. Check whether the user is logged in:
14
+ ```bash
15
+ qz auth status
16
+ ```
17
+ 2. If auth is missing or expired, run QR login and ask the user to scan:
18
+ ```bash
19
+ qz auth login
20
+ ```
21
+ 3. For exact syntax, use command help:
22
+ ```bash
23
+ qz --help
24
+ qz <command> --help
25
+ qz <command> <subcommand> --help
26
+ ```
27
+
28
+ ## Environment and Config Files
29
+
30
+ If the CLI prints a `DEVELOPMENT BUILD` / `Running in TEST environment` banner, it is using the test environment and
31
+ stores config under `./.qzhuli-cli/` relative to the process working directory.
32
+
33
+ | Visible behavior | Environment | Config directory |
34
+ |-------------------|-------------|------------------|
35
+ | Shows test banner | test | `./.qzhuli-cli/` |
36
+ | No test banner | production | `~/.qzhuli-cli/` |
37
+
38
+ Treat `credentials.json` as secret. Preferences live in `preferences.json`.
39
+
40
+ ## Output and Global Options
41
+
42
+ Commands return JSON with `status`, `code`, `message`, and `data`. Check `status`, not only the exit code; ambiguous
43
+ friend lookups can return `status: "needs_resolution"`.
44
+
45
+ Use `--jq` for simple dot-path filtering:
46
+
47
+ ```bash
48
+ qz --jq ".data.uid" auth status
49
+ qz --jq ".data.links" friend list
50
+ qz --jq ".data" conversation list --limit 5
51
+ ```
52
+
53
+ `--jq` is not full jq. Prefer simple paths such as `.data`, `.data.uid`, `.data.links`.
54
+
55
+ Use `--dry-run` when you need to avoid side effects. It is wired through output handling, HTTP API calls, IM WebSocket
56
+ actions, auth login/logout, and preference writes.
57
+
58
+ ## Command Map
59
+
60
+ | Goal | Command |
61
+ |----------------------------|-----------------------------------------------------------------------------------------------|
62
+ | Check login | `qz auth status` |
63
+ | QR login | `qz auth login [--method qr-code]` |
64
+ | Clear credentials | `qz auth logout` |
65
+ | Show preferences | `qz config` |
66
+ | Update preferences | `qz config [--locale en\|zh] [--debug\|--no-debug]` |
67
+ | Search user (Q助号) | `qz user search <query>` |
68
+ | Search user (UID) | `qz user search <query> --uid` |
69
+ | Add friend (Q助号) | `qz user add <q-number>` |
70
+ | List friends | `qz friend list` |
71
+ | Resolve profile (nickname) | `qz friend profile <query>` |
72
+ | Resolve profile (UID) | `qz friend profile <query> --uid` |
73
+ | Resolve profile (remark) | `qz friend profile <query> --remark` |
74
+ | Read relation | `qz relation get <uid>` |
75
+ | Update relation | `qz relation set <uid> [-r, --remark <name>] [-t, --type <type>]` |
76
+ | List conversations | `qz conversation list [--limit <n>]` |
77
+ | Create conversation | `qz conversation create <uid> --agent-id <id>` |
78
+ | Send message | `qz message send <conversation-id> <target-cid> <content>` |
79
+ | Read message history | `qz message history <conversation-id> [--from <id>] [--direction newer\|older] [--limit <n>]` |
80
+
81
+ Relation type values are `0=stranger`, `1=friend`, `2=family`, `3=colleague`.
82
+
83
+ ## Common Workflows
84
+
85
+ ### Find a Friend and Inspect Relation
86
+
87
+ 1. List candidates:
88
+ ```bash
89
+ qz friend list
90
+ ```
91
+ 2. Resolve ambiguous names:
92
+ ```bash
93
+ qz friend profile "<nickname>"
94
+ ```
95
+ 3. Use the resolved `uid`:
96
+ ```bash
97
+ qz relation get <uid>
98
+ ```
99
+
100
+ ### Update a Friend Relation
101
+
102
+ 1. Resolve the exact `uid` first with `friend list` or `friend profile`.
103
+ 2. Confirm with the user before changing data.
104
+ 3. Execute one or both updates:
105
+ ```bash
106
+ qz relation set <uid> --remark "Product Manager" --type 1
107
+ ```
108
+ 4. Verify:
109
+ ```bash
110
+ qz relation get <uid>
111
+ ```
112
+
113
+ Do not run `relation set` without `--remark` or `--type`; the CLI returns `INVALID_ARGUMENT`.
114
+
115
+ ### Search and Add a Friend
116
+
117
+ 1. Search by Q助号:
118
+ ```bash
119
+ qz user search 10000
120
+ ```
121
+ 2. Add directly by Q助号:
122
+ ```bash
123
+ qz user add 10000
124
+ ```
125
+
126
+ ### Send a Message
127
+
128
+ 1. Confirm auth:
129
+ ```bash
130
+ qz auth status
131
+ ```
132
+ 2. Get conversations:
133
+ ```bash
134
+ qz conversation list --limit 10
135
+ ```
136
+ 3. Pick the conversation `id`.
137
+ 4. Pick `target-cid` from that conversation's `cids`; for one-to-one chats this is usually the other participant's cid,
138
+ not the current user's own `cid`.
139
+ 5. Confirm recipient and content with the user if there is any ambiguity.
140
+ 6. Send:
141
+ ```bash
142
+ qz message send <conversation-id> <target-cid> "message text"
143
+ ```
144
+ 7. Verify:
145
+ ```bash
146
+ qz message history <conversation-id> --limit 5
147
+ ```
148
+
149
+ ### Page Through Message History
150
+
151
+ ```bash
152
+ qz message history <conversation-id> --limit 20
153
+ qz message history <conversation-id> --from <message-id> --direction older --limit 20
154
+ qz message history <conversation-id> --from <message-id> --direction newer --limit 20
155
+ ```
156
+
157
+ ## Troubleshooting
158
+
159
+ | Symptom | Action |
160
+ |------------------------|--------------------------------------------------------------------------|
161
+ | Command not found | Confirm `qz` is installed or available on `PATH`. |
162
+ | Auth failure | Run `qz auth status`; then `qz auth login` if needed. |
163
+ | Unexpected language | Run `qz config --locale en` or `qz config --locale zh`. |
164
+ | Too much JSON | Use `--jq ".data"` or another simple dot path. |
165
+ | Need a no-op preview | Use `--dry-run`. |
166
+ | Message send cid error | Re-check `auth status` and choose `target-cid` from `conversation list`. |