@qzhuli/qzhuli-cli 0.5.0 → 0.5.1

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
@@ -11234,7 +11234,7 @@ var commands = {
11234
11234
  },
11235
11235
  message: {
11236
11236
  desc: "Message operations",
11237
- sendDesc: "Send a message to a conversation via WebSocket IM",
11237
+ sendDesc: "Send a message to a conversation",
11238
11238
  historyDesc: "View message history from a conversation",
11239
11239
  fromOption: "Start from message ID",
11240
11240
  directionOption: "Direction to pull",
@@ -11381,7 +11381,7 @@ var commands2 = {
11381
11381
  },
11382
11382
  message: {
11383
11383
  desc: "\u6D88\u606F\u64CD\u4F5C",
11384
- sendDesc: "\u901A\u8FC7 WebSocket IM \u5411\u4F1A\u8BDD\u53D1\u9001\u6D88\u606F",
11384
+ sendDesc: "\u5411\u4F1A\u8BDD\u53D1\u9001\u6D88\u606F",
11385
11385
  historyDesc: "\u67E5\u770B\u4F1A\u8BDD\u6D88\u606F\u5386\u53F2",
11386
11386
  fromOption: "\u8D77\u59CB\u6D88\u606F ID",
11387
11387
  directionOption: "\u62C9\u53D6\u65B9\u5411",
@@ -14921,7 +14921,7 @@ async function main() {
14921
14921
  ${t("cli.banner")}` : t("cli.banner");
14922
14922
  program.addHelpText("beforeAll", `${banner}
14923
14923
  `);
14924
- program.name("qz").version(`v${"0.5.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"));
14924
+ program.name("qz").version(`v${"0.5.1"}`, "-v, --version", t("options.version")).helpOption("-h, --help", t("options.help")).option("-q, --jq <expr>", t("options.jq")).option("--dry-run", t("options.dryRun"));
14925
14925
  program.usage("<command> [subcommand] [options]");
14926
14926
  program.hook("preAction", () => {
14927
14927
  const opts = program.opts();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzhuli/qzhuli-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "CLI tool for Q助理 (QZhuli)",
5
5
  "main": "dist/cmd.js",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: qzhuli-cli
3
3
  description: Use when operating the QZhuli CLI (`qz`), including login, auth status, config, friends, relations, users, conversations, messages, cache management, JSON filtering, dry-run, command help, and interpreting test-environment banners or config files.
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  ---
6
6
 
7
7
  # QZhuli CLI
@@ -39,18 +39,11 @@ When ANY of the following applies, STOP and ask the user first:
39
39
  - **Friend operations**: Before `user add`, show the target profile and confirm.
40
40
  - **Relation changes**: Before `relation set`, show the current value and the new value, then confirm.
41
41
  - **Cache clearing**: Before `cache clear`, confirm scope (all tables vs single table).
42
+ - **Message without conversation**: Before `message send`, check if a conversation with the target user exists. If not,
43
+ ask the user whether to create one first.
42
44
  - **Any write operation** (`user add`, `relation set`, `conversation create`, `cache clear`): confirm
43
45
  with user.
44
46
 
45
- ### Use --dry-run for Preview
46
-
47
- Before any write operation the user hasn't explicitly confirmed, run with `--dry-run` first:
48
-
49
- ```bash
50
- qz --dry-run message send <id> "hello"
51
- qz --dry-run relation set <uid> --remark "New Name"
52
- ```
53
-
54
47
  ### Least-Surprise Principle
55
48
 
56
49
  - Never change a friend's remark without showing both old and new.
@@ -76,12 +69,6 @@ The CLI uses 4 distinct ID types. **Using the wrong type will fail silently or h
76
69
  | Conversation ID | `conversationId` | Base64-like long string | `9boGaR7iii2Jdjhmb5LSo37...` | `message send`, `message history`, `conversation profile` |
77
70
  | Agent ID | `agent.id` | Number | `5` | `conversation create --agent-id` |
78
71
 
79
- **Quick identification by format**:
80
-
81
- - A short integer → Q助号
82
- - A 32-char hex string → UID
83
- - A long Base64-like string → conversationId
84
-
85
72
  **Common mistake**: Using UID for `message send` instead of conversationId. Always resolve via `conversation search` or
86
73
  `conversation list` first.
87
74
 
@@ -116,9 +103,6 @@ qz --jq ".data" conversation list --limit 5
116
103
 
117
104
  `--jq` is not full jq. Prefer simple paths: `.data`, `.data.uid`, `.data.links`.
118
105
 
119
- Use `--dry-run` to preview without side effects. Wired through: output, HTTP API calls, IM WebSocket actions, auth
120
- login/logout, and preference writes.
121
-
122
106
  ## Command Map
123
107
 
124
108
  | Goal | Command |
@@ -160,8 +144,8 @@ Relation type values: `0=stranger`, `1=friend`, `2=family`, `3=colleague`.
160
144
 
161
145
  ### Update a Friend Relation
162
146
 
163
- 1. Resolve the exact `uid` with `friend list` or `friend profile`.
164
- 2. Show current value to user, confirm the change.
147
+ 1. Resolve the exact `uid` via `friend list` or `friend profile`.
148
+ 2. Show current value, confirm the change.
165
149
  3. Execute: `qz relation set <uid> --remark "New Name" --type 1`
166
150
  4. Verify: `qz relation get <uid>`
167
151
 
@@ -176,18 +160,22 @@ Relation type values: `0=stranger`, `1=friend`, `2=family`, `3=colleague`.
176
160
  ### Find All Conversations with a User
177
161
 
178
162
  ```bash
179
- qz conversation search 10000 # by Q助号 (default)
180
- qz conversation search d5b6308e3abad6bc96573c58 --uid # by UID
163
+ qz conversation search <q-number>
164
+ qz conversation search <uid> --uid
181
165
  ```
182
166
 
183
- Response includes `id` (Q助号), `uid` (internal user ID), and `conversations` with full profile data. Each conversation
184
- entry contains `conversationId`, `isGroup`, `users`, and `visitors`.
167
+ Response includes `id`, `uid`, and `conversations` with full profile data. Each entry contains `conversationId`,
168
+ `isGroup`, `users`, and `visitors`.
185
169
 
186
170
  ### Send a Message
187
171
 
188
172
  1. Confirm auth: `qz auth status`
189
- 2. Get conversations: `qz conversation list --limit 10`
190
- 3. Pick the conversation `id` (conversationId).
173
+ 2. **Check existing conversation**: Use `conversation search <q-number>` or `conversation search <uid> --uid` to find
174
+ conversations with the target user.
175
+ 3. **Decision**:
176
+ - If conversations exist → pick the relevant `conversationId`.
177
+ - If no conversation exists → **ask the user first** whether to create one, then
178
+ `qz conversation create <uid> --agent-id <id>`.
191
179
  4. Determine role: if the user says "以我的名义" / "帮我发给" / "替我发送" etc., add `--role 1`; otherwise omit (
192
180
  defaults to Assistant).
193
181
  5. Send: `qz message send <conversation-id> "message text"`
@@ -203,23 +191,7 @@ qz message history <conversation-id> --from <message-id> --direction newer --lim
203
191
 
204
192
  ### Pre-Sync Cache for Offline Speed
205
193
 
206
- ```bash
207
- qz cache sync # fetch all data into local SQLite
208
- qz cache status # verify record counts and sync time
209
- qz conversation search 10000 # now instant from cache
210
- ```
211
-
212
- ## Cache Architecture (Reference)
213
-
214
- Read operations use a **Repository Pattern** with SQLite-backed caching (`~/.qzhuli-cli/cache.db`):
215
-
216
- - **TTL**: conversations 30 min, contacts/relations 5 min, user profiles 1 hour
217
- - **Incremental sync**: only fetches profiles for *new* conversations
218
- - **Cache miss** → auto incremental sync (not full refetch)
219
- - **Write operations** bypass cache, invalidate relevant entries
220
-
221
- Tables: `conversations_index`, `conversation_profiles`, `contacts_cache`, `user_profiles`, `relations_cache`,
222
- `messages_cache`.
194
+ Run `qz cache sync` before heavy read operations. Verify with `qz cache status`.
223
195
 
224
196
  ## Troubleshooting
225
197
 
@@ -231,6 +203,7 @@ Tables: `conversations_index`, `conversation_profiles`, `contacts_cache`, `user_
231
203
  | Too much JSON | Use `--jq ".data"` or another simple dot path |
232
204
  | Need no-op preview | Use `--dry-run` |
233
205
  | Message send fails | Re-check `auth status`, verify conversationId via `conversation list` |
206
+ | Target has no conversation | Ask user to create one, then `conversation create <uid> --agent-id <id>` |
234
207
  | Slow queries | Run `qz cache sync` first (incremental, fast), then retry |
235
208
  | Cache corrupted | `qz cache clear` to reset, then retry (falls back to API) |
236
209
  | Ambiguous search | `status: "needs_resolution"` — refine query with `--uid` or `--remark` flag |