@chen_hu_hu/pi-qq 1.2.2 → 1.2.3

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/README-zh.md CHANGED
@@ -114,6 +114,20 @@ QQ 侧命令:
114
114
 
115
115
  启用日志后,日志写入 `<cwd>/.pi/pi-qq/logs/pi-qq-YYYY-MM-DD.log`。可用 `PI_QQ_LOG_DIR` 覆盖目录。`info` 只记录元数据;`debug` 记录完整事件、附件、提示词和工具参数/结果。旧配置 `debug: true` 会映射为 `logLevel: "debug"`。
116
116
 
117
+ ## 开发
118
+
119
+ 需要 Node.js 22.19 或更高版本(与 pi 的要求一致)。安装依赖后运行:
120
+
121
+ ```bash
122
+ npm ci
123
+ npm run lint
124
+ npm run typecheck
125
+ npm test
126
+ npm run format:check
127
+ ```
128
+
129
+ `eslint.config.ts` 使用 Node.js 原生 TypeScript 剥离能力加载,不需要 `jiti`。
130
+
117
131
  ## 说明
118
132
 
119
133
  - 仅支持 C2C(QQ 私聊)。
package/README.md CHANGED
@@ -114,6 +114,20 @@ Create `~/.pi/agent/pi-qq.json` to override defaults. This file contains setting
114
114
 
115
115
  When enabled, logs are written to `<cwd>/.pi/pi-qq/logs/pi-qq-YYYY-MM-DD.log`. `PI_QQ_LOG_DIR` overrides the directory. `info` records metadata only; `debug` records full events, attachments, prompts, and tool payloads. Legacy `debug: true` maps to `logLevel: "debug"`.
116
116
 
117
+ ## Development
118
+
119
+ Node.js 22.19 or newer is required, matching pi. Install dependencies and run:
120
+
121
+ ```bash
122
+ npm ci
123
+ npm run lint
124
+ npm run typecheck
125
+ npm test
126
+ npm run format:check
127
+ ```
128
+
129
+ `eslint.config.ts` is loaded through Node.js native TypeScript stripping; `jiti` is not required.
130
+
117
131
  ## Notes
118
132
 
119
133
  - Only C2C (QQ private chat) is supported.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chen_hu_hu/pi-qq",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Connect pi to QQ private chats.",
5
5
  "license": "MIT",
6
6
  "author": "CQ-Developer",
@@ -39,7 +39,9 @@
39
39
  "LICENSE"
40
40
  ],
41
41
  "scripts": {
42
- "typecheck": "npx -y -p typescript tsc --noEmit",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "npx --node-options=\"--experimental-strip-types\" eslint --flag unstable_native_nodejs_ts_config .",
44
+ "lint:fix": "npx --node-options=\"--experimental-strip-types\" eslint --flag unstable_native_nodejs_ts_config . --fix",
43
45
  "test": "vitest run",
44
46
  "format": "prettier --write .",
45
47
  "format:check": "prettier --check ."
@@ -59,8 +61,12 @@
59
61
  },
60
62
  "devDependencies": {
61
63
  "@earendil-works/pi-coding-agent": "^1.4.0",
64
+ "@eslint/js": "^10.0.1",
62
65
  "@types/node": "^22.20.5",
66
+ "eslint": "^10.14.0",
63
67
  "prettier": "^3.9.10",
68
+ "typescript": "^5.9.3",
69
+ "typescript-eslint": "^8.72.1",
64
70
  "vitest": "^5.0.5"
65
71
  }
66
72
  }
package/src/config.ts CHANGED
@@ -62,7 +62,7 @@ export function readConfig(): { config: PiQQConfig; error?: string } {
62
62
  }
63
63
  }
64
64
 
65
- export interface ResolvedSettings extends Required<Omit<PiQQSettings, "debug">> {}
65
+ export type ResolvedSettings = Required<Omit<PiQQSettings, "debug">>;
66
66
 
67
67
  /** Settings with defaults applied (features-v1.md §4). */
68
68
  export function getSettings(config: PiQQConfig): ResolvedSettings {
package/src/download.ts CHANGED
@@ -79,7 +79,7 @@ export async function downloadLimited(opts: DownloadOptions): Promise<Buffer> {
79
79
  return await readBodyLimited(response, limit, opts.kind);
80
80
  } catch (err) {
81
81
  if (controller.signal.aborted) {
82
- throw new Error(`download timed out after ${opts.timeoutMs / 1000}s`);
82
+ throw new Error(`download timed out after ${opts.timeoutMs / 1000}s`, { cause: err });
83
83
  }
84
84
  throw err;
85
85
  } finally {
package/src/files.ts CHANGED
@@ -55,6 +55,8 @@ export function uploadIndexPath(uploadDir: string): string {
55
55
  export function sanitizeFilename(filename: string | undefined, fallback: string): string {
56
56
  const raw = basename((filename ?? "").trim());
57
57
  const cleaned = raw
58
+ // Control characters are rejected intentionally when normalizing a filename.
59
+ // eslint-disable-next-line no-control-regex
58
60
  .replace(/[\u0000-\u001f\u007f<>:"|?*]/g, "_")
59
61
  .replace(/^[.\s]+|[.\s]+$/g, "")
60
62
  .trim();
@@ -152,7 +154,6 @@ async function saveOrReuse(
152
154
  // A stale index entry must not make a missing file look reusable.
153
155
  if (index[filename]) {
154
156
  delete index[filename];
155
- changed = true;
156
157
  }
157
158
  await writeFile(target, body, { flag: "wx" });
158
159
  index[filename] = hash;
@@ -187,7 +188,6 @@ async function saveOrReuse(
187
188
 
188
189
  if (index[candidate]) {
189
190
  delete index[candidate];
190
- changed = true;
191
191
  }
192
192
  await writeFile(candidatePath, body, { flag: "wx" });
193
193
  index[candidate] = hash;
@@ -97,7 +97,6 @@ export function formatHeartbeat(elapsedMs: number, tools: Map<string, ToolStat2>
97
97
  return `⏱ Running for ${elapsedText} · ${parts.join(" · ")}${suffix}`;
98
98
  }
99
99
 
100
- const STREAM_LIVENESS_MS = 60_000; // Add a liveness row after this much silence
101
100
  const TYPING_INTERVAL_MS = 50_000; // Platform typing window ~60s; renew early
102
101
  const PENDING_TTL_MS = 15_000; // QQ trigger TTL (older means a local run)
103
102