@guanlin4924/devflow-pi 0.1.11 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanlin4924/devflow-pi",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "description": "Devflow 专项研发 Pi,基于固定版本 OMP Runtime 组装研发状态机、代码智能、设计、实现与质量门禁。",
6
6
  "license": "UNLICENSED",
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI, ExtensionUIContext } from "@oh-my-pi/pi-coding-agent";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
+ import { spawn } from "node:child_process";
3
4
  import path from "node:path";
4
5
 
5
6
  import { devflowHome } from "./paths.ts";
@@ -43,6 +44,13 @@ function daysAgo(days: number): string {
43
44
  return date.toISOString().slice(0, 10);
44
45
  }
45
46
 
47
+ function openHtmlReport(file: string): void {
48
+ const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
49
+ const args = process.platform === "win32" ? ["/c", "start", "", file] : [file];
50
+ const child = spawn(command, args, { detached: true, stdio: "ignore" });
51
+ child.unref();
52
+ }
53
+
46
54
  export function createPlatformExtension(options: PlatformExtensionOptions) {
47
55
  return function devflowPlatform(pi: ExtensionAPI) {
48
56
  const { z } = pi.zod;
@@ -86,7 +94,7 @@ export function createPlatformExtension(options: PlatformExtensionOptions) {
86
94
  ...usageTool,
87
95
  });
88
96
  }
89
- async function pickUsageInput(ctx: { ui: ExtensionUIContext }): Promise<UsageInput | undefined> {
97
+ async function pickUsageInput(ctx: { ui: ExtensionUIContext; modelRegistry: { getAvailable(): Array<{ provider: string; id: string }> } }): Promise<UsageInput | undefined> {
90
98
  const sourceChoice = await ctx.ui.select("使用统计:数据范围", [
91
99
  { label: "当前 Devflow 项目", description: "只读取当前项目会话(推荐)" },
92
100
  { label: "OMP 历史", description: "读取 ~/.omp/agent/sessions" },
@@ -97,7 +105,10 @@ export function createPlatformExtension(options: PlatformExtensionOptions) {
97
105
  const overview = await aggregateUsageReport(root, source);
98
106
  const sessionChoice = await ctx.ui.select("使用统计:会话", ["全部会话", ...Object.keys(overview.perSession)]);
99
107
  if (!sessionChoice) return undefined;
100
- const modelChoice = await ctx.ui.select("使用统计:模型", ["全部模型", ...Object.keys(overview.perModel)]);
108
+ // The selector is for filtering a report, so it must list every model
109
+ // configured in OMP — not merely the model names found in old sessions.
110
+ const registeredModels = [...new Set(ctx.modelRegistry.getAvailable().map(model => `${model.provider}/${model.id}`))].sort();
111
+ const modelChoice = await ctx.ui.select("使用统计:模型", ["全部模型", ...registeredModels]);
101
112
  if (!modelChoice) return undefined;
102
113
  const period = await ctx.ui.select("使用统计:时间范围", ["全部时间", "今天", "最近 7 天", "最近 30 天", "自定义日期"]);
103
114
  if (!period) return undefined;
@@ -129,7 +140,8 @@ export function createPlatformExtension(options: PlatformExtensionOptions) {
129
140
  const destination = path.join(reportDir, `usage-${new Date().toISOString().replaceAll(":", "-")}.html`);
130
141
  await mkdir(reportDir, { recursive: true });
131
142
  await writeFile(destination, renderUsageHtml(report), "utf8");
132
- ctx.ui.notify(`已生成 HTML 使用报告:${destination}`, "info");
143
+ openHtmlReport(destination);
144
+ ctx.ui.notify(`已生成并在默认浏览器打开 HTML 使用报告:${destination}`, "info");
133
145
  return;
134
146
  }
135
147
  ctx.ui.notify(input.format === "json" ? JSON.stringify({ projectId: options.projectId, ...report }, null, 2).slice(0, 12000) : renderUsageReport(report).slice(0, 12000), "info");