opencode-metrics-plugin 0.4.2 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.3(2026-09-16)
4
+
5
+ - **修复 AGC 上传 400**:Node 原生 http.request 默认不发送 `User-Agent`,AGC 云存储 2026-09-16 起强制校验该头(此前 0.4.2 及更早版本同缺陷,服务端新策略触发)——上传 PUT 显式携带 `User-Agent: opencode-metrics-plugin/<version>`。
6
+
3
7
  ## 0.4.2(2026-09-16)
4
8
 
5
9
  - **代码行多维统计**(工程全量扫描口径,替代 write 工具累计):`codeStats` 新增 `cLines` / `cppLines` / `testLines` / `businessCodeLines`,`etsLines` 改为鸿蒙工程全量扫描(排除测试)。根发现 = 会话工作目录 + bash workdir + write/edit 文件目录(向上提升到鸿蒙工程根 + 安卓工程的兄弟鸿蒙工程探测,mtime 时间窗防邻居混入);`.h` 计入 C、`.hpp` 等计入 C++(头文件统一归入语言维度);测试目录(ohosTest/test/mock 等)子树与 `.test.`/`.spec.` 命名文件计为测试维度(任意语言,不与语言维度重复计数);构建/配置文件(hvigorfile.ts、CMakeLists.txt、.json5)不计入。flush 时 30s 节流扫描,候选根集合变化立即重扫。配套 session-viewer Code Stats 卡片展示五维。
@@ -17,6 +17,8 @@ const REGION_DOMAINS = {
17
17
  const TOKEN_MARGIN_SECONDS = 60;
18
18
  const TOKEN_TIMEOUT_MS = 30_000;
19
19
  const UPLOAD_TIMEOUT_MS = 10 * 60_000;
20
+ /** 上传 UA:Node 原生 http.request 默认不发送 User-Agent,AGC 存储已开始强制校验(2026-09-16 起 400) */
21
+ const UPLOAD_USER_AGENT = "opencode-metrics-plugin/0.4.3";
20
22
  /** AGC 凭证默认文件:包内 assets/agc-apiclient.json(opencode.json 未配置 agcConfigPath 时使用) */
21
23
  export function defaultAgcConfigPath() {
22
24
  return fileURLToPath(new URL("../../../assets/agc-apiclient.json", import.meta.url));
@@ -172,6 +174,7 @@ async function uploadFile(credentials, token, localPath, remoteObject) {
172
174
  productId: credentials.project_id,
173
175
  Authorization: `Bearer ${token}`,
174
176
  "Content-Type": "application/octet-stream",
177
+ "User-Agent": UPLOAD_USER_AGENT,
175
178
  "X-Agc-File-Size": String(sizeBytes),
176
179
  "Content-Length": String(sizeBytes),
177
180
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-metrics-plugin",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "opencode plugin: auto-records every session's metrics (tokens/rounds/steps/sub-agents/hvigor builds) to snapshot JSON. Zero DB, zero config. Pair with session-viewer for visualization.",
5
5
  "type": "module",
6
6
  "license": "MIT",