@zhushanwen/pi-evolve-daily 0.1.5 → 0.1.7

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": "@zhushanwen/pi-evolve-daily",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Daily evolution data collector — runs Python analyzer on first session of the day.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -69,7 +69,7 @@ export default function evolveDailyExtension(pi: ExtensionAPI) {
69
69
  PROBLEM_REGISTRY.find((p) => p.id === "compact-frequency")!
70
70
  );
71
71
 
72
- pi.on("session_compact", async (event: Record<string, unknown>) => {
72
+ (pi.on as any)("session_compact", async (event: Record<string, unknown>) => {
73
73
  try {
74
74
  const item = compactDetector.createItem(event);
75
75
  pi.appendEntry("evolve-feedback", {
@@ -101,7 +101,7 @@ export default function evolveDailyExtension(pi: ExtensionAPI) {
101
101
  ),
102
102
  ];
103
103
 
104
- pi.on(
104
+ (pi.on as any)(
105
105
  "tool_result",
106
106
  async (event: Record<string, unknown>, _ctx?: unknown) => {
107
107
  for (const detector of toolDetectors) {
package/src/problems.ts CHANGED
@@ -52,7 +52,7 @@ interface TrackedItemTemplate {
52
52
  export const PROBLEM_REGISTRY: ProblemDefinition[] = [
53
53
  {
54
54
  id: "compact-frequency",
55
- name: "Compact 频率",
55
+ name: "Compact Frequency",
56
56
  category: "context",
57
57
  severity: {
58
58
  metric: "custom",
@@ -68,21 +68,21 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
68
68
  match: { custom: "compactDetector" },
69
69
  template: { category: "context-pressure" },
70
70
  steering:
71
- "检测到 Compact 触发(id={{id}})。请评估是否丢失了关键上下文。如有丢失,update status=error, detail='丢失的内容'。如无影响,update status=completed",
71
+ "Compact triggered (id={{id}}). Evaluate whether critical context was lost. If lost, update status=error, detail='what was lost'. If unaffected, update status=completed.",
72
72
  },
73
73
  analysis: {
74
74
  extractor: "compact",
75
75
  minerRules: ["compact-high-frequency", "compact-early-trigger"],
76
76
  },
77
77
  suggestion: {
78
- title: "优化 Compact 频率",
79
- description: "Compact 频率过高,说明上下文管理效率低",
78
+ title: "Optimize Compact Frequency",
79
+ description: "High compact frequency indicates inefficient context management",
80
80
  defaultSeverity: "medium",
81
81
  },
82
82
  },
83
83
  {
84
84
  id: "context-utilization",
85
- name: "上下文窗口利用率",
85
+ name: "Context Window Utilization",
86
86
  category: "context",
87
87
  severity: {
88
88
  metric: "rate",
@@ -93,21 +93,21 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
93
93
  match: { custom: "contextUtilizationMatcher" },
94
94
  template: { category: "context-pressure" },
95
95
  steering:
96
- "当前上下文利用率 {{usageRate}}(id={{id}})。如接近上限,update status=completed, detail='需要 compact'。如充足,update status=dismissed",
96
+ "Current context utilization {{usageRate}} (id={{id}}). If near limit, update status=completed, detail='needs compact'. If sufficient, update status=dismissed.",
97
97
  },
98
98
  analysis: {
99
99
  extractor: "context",
100
100
  minerRules: ["context-high-utilization"],
101
101
  },
102
102
  suggestion: {
103
- title: "优化上下文利用率",
104
- description: "上下文利用率持续偏高,会触发频繁 compact",
103
+ title: "Optimize Context Utilization",
104
+ description: "Persistently high context utilization triggers frequent compacts",
105
105
  defaultSeverity: "medium",
106
106
  },
107
107
  },
108
108
  {
109
109
  id: "subagent-efficiency",
110
- name: "Subagent 调度效率",
110
+ name: "Subagent Scheduling Efficiency",
111
111
  category: "subagent",
112
112
  severity: {
113
113
  metric: "rate",
@@ -118,21 +118,21 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
118
118
  match: { toolName: "subagent", custom: "subagentResultMatcher" },
119
119
  template: { category: "subagent" },
120
120
  steering:
121
- "Subagent 任务完成(id={{id}})exitCode={{exitCode}}, 耗时={{duration}}。如结果满意,update status=completed。如需重做,update status=error, detail='问题原因'",
121
+ "Subagent task completed (id={{id}}). exitCode={{exitCode}}, duration={{duration}}. If satisfactory, update status=completed. If retry needed, update status=error, detail='reason'.",
122
122
  },
123
123
  analysis: {
124
124
  extractor: "subagent",
125
125
  minerRules: ["subagent-failure-rate", "subagent-high-retry"],
126
126
  },
127
127
  suggestion: {
128
- title: "优化 Subagent 调度效率",
129
- description: "Subagent 失败率或重试率过高",
128
+ title: "Optimize Subagent Scheduling",
129
+ description: "High subagent failure or retry rate",
130
130
  defaultSeverity: "medium",
131
131
  },
132
132
  },
133
133
  {
134
134
  id: "tool-param-validation",
135
- name: "工具参数校验失败",
135
+ name: "Tool Parameter Validation Failure",
136
136
  category: "tool",
137
137
  severity: {
138
138
  metric: "rate",
@@ -143,21 +143,21 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
143
143
  match: { isError: true, custom: "paramErrorMatcher" },
144
144
  template: { category: "tool-error" },
145
145
  steering:
146
- "检测到 {{toolName}} 参数错误(id={{id}})。错误: {{errorPreview}}。如已理解原因,update status=completed, detail='错误原因和修正方式'。如不确定,update status=error",
146
+ "Detected {{toolName}} parameter error (id={{id}}). Error: {{errorPreview}}. If cause understood, update status=completed, detail='cause and fix'. If unclear, update status=error.",
147
147
  },
148
148
  analysis: {
149
149
  extractor: "tool_errors",
150
150
  minerRules: ["param-error-rate", "edit-match-failure", "low-self-correction"],
151
151
  },
152
152
  suggestion: {
153
- title: "降低工具参数错误率",
154
- description: "参数错误率高,说明 AI 不理解工具用法",
153
+ title: "Reduce Tool Parameter Error Rate",
154
+ description: "High parameter error rate suggests the AI does not understand tool usage",
155
155
  defaultSeverity: "high",
156
156
  },
157
157
  },
158
158
  {
159
159
  id: "workflow-phase-duration",
160
- name: "工作流阶段耗时",
160
+ name: "Workflow Phase Duration",
161
161
  category: "workflow",
162
162
  severity: {
163
163
  metric: "custom",
@@ -173,21 +173,21 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
173
173
  match: { toolName: ["coding-workflow-gate", "coding-workflow-phase-start"] },
174
174
  template: { category: "workflow" },
175
175
  steering:
176
- "工作流阶段 {{phase}} 完成(id={{id}})gate={{gateResult}}, 耗时={{duration}}。如阶段顺利,update status=completed。如有问题,update status=error, detail='问题描述'",
176
+ "Workflow phase {{phase}} completed (id={{id}}). gate={{gateResult}}, duration={{duration}}. If smooth, update status=completed. If issues, update status=error, detail='issue description'.",
177
177
  },
178
178
  analysis: {
179
179
  extractor: "workflow",
180
180
  minerRules: ["workflow-slow-phase", "workflow-gate-retry"],
181
181
  },
182
182
  suggestion: {
183
- title: "优化工作流阶段效率",
184
- description: "某阶段耗时占比过高或 gate 重试频繁",
183
+ title: "Optimize Workflow Phase Efficiency",
184
+ description: "Disproportionate phase duration or frequent gate retries",
185
185
  defaultSeverity: "medium",
186
186
  },
187
187
  },
188
188
  {
189
189
  id: "goal-task-quality",
190
- name: "Goal 任务拆分质量",
190
+ name: "Goal Task Decomposition Quality",
191
191
  category: "workflow",
192
192
  severity: {
193
193
  metric: "custom",
@@ -204,7 +204,7 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
204
204
  match: { toolName: "goal_manager", custom: "goalQualityMatcher" },
205
205
  template: { category: "workflow" },
206
206
  steering:
207
- "Goal 任务更新(id={{id}})。任务完成率={{completionRate}}。如目标达成,update status=completed, detail='目标完成情况'。如遇到困难,update status=error, detail='困难描述'",
207
+ "Goal task updated (id={{id}}). Completion rate={{completionRate}}. If objective met, update status=completed, detail='completion summary'. If blocked, update status=error, detail='blocker description'.",
208
208
  },
209
209
  analysis: {
210
210
  extractor: "goal_quality",
@@ -216,8 +216,8 @@ export const PROBLEM_REGISTRY: ProblemDefinition[] = [
216
216
  ],
217
217
  },
218
218
  suggestion: {
219
- title: "优化 Goal 任务拆分质量",
220
- description: "任务完成率低或 Evidence 质量低",
219
+ title: "Optimize Goal Task Decomposition",
220
+ description: "Low task completion rate or poor evidence quality",
221
221
  defaultSeverity: "high",
222
222
  },
223
223
  },
@@ -78,7 +78,7 @@ function formatItemList<TMeta>(
78
78
  items: TrackedItem<TMeta>[],
79
79
  trackerName: string,
80
80
  ): string {
81
- if (items.length === 0) return `无活跃追踪(${trackerName})。`;
81
+ if (items.length === 0) return `No active tracked items (${trackerName}).`;
82
82
  return items
83
83
  .map(
84
84
  (item) =>
@@ -340,22 +340,22 @@ export function createTracker<TMeta>(
340
340
 
341
341
  // ── update ──
342
342
  if (params.id === undefined) {
343
- return { content: [{ type: "text", text: "update 操作需要 id 参数" }], isError: true };
343
+ return { content: [{ type: "text", text: "update action requires id parameter" }], isError: true };
344
344
  }
345
345
  if (params.status === undefined) {
346
- return { content: [{ type: "text", text: "update 操作需要 status 参数" }], isError: true };
346
+ return { content: [{ type: "text", text: "update action requires status parameter" }], isError: true };
347
347
  }
348
348
 
349
349
  const itemIndex = state.items.findIndex(
350
350
  (item) => item.id === params.id,
351
351
  );
352
352
  if (itemIndex === -1) {
353
- return { content: [{ type: "text", text: `TrackedItem id=${params.id} 不存在` }], isError: true };
353
+ return { content: [{ type: "text", text: `TrackedItem id=${params.id} not found` }], isError: true };
354
354
  }
355
355
 
356
356
  const item = state.items[itemIndex];
357
357
  if (!canTransition(item.status, params.status)) {
358
- return { content: [{ type: "text", text: `非法转换: ${item.status} → ${params.status}(当前 ${item.status},终态不可变更或该路径不允许)` }], isError: true };
358
+ return { content: [{ type: "text", text: `Invalid transition: ${item.status} → ${params.status} (current: ${item.status}, terminal states are immutable or path not allowed)` }], isError: true };
359
359
  }
360
360
 
361
361
  // 执行转换
@@ -373,7 +373,7 @@ export function createTracker<TMeta>(
373
373
 
374
374
  persistState(ctx);
375
375
 
376
- const statusText = isTerminalStatus(item.status) ? "(终态)" : "";
376
+ const statusText = isTerminalStatus(item.status) ? " (terminal)" : "";
377
377
  return {
378
378
  content: [
379
379
  {
@@ -428,7 +428,7 @@ export function createTracker<TMeta>(
428
428
  const details = result.details as TrackerDetails<TMeta>;
429
429
  if (details.error) {
430
430
  return new Text(
431
- theme.fg("error", `[${config.name}] 错误: ${details.error}`),
431
+ theme.fg("error", `[${config.name}] Error: ${details.error}`),
432
432
  0,
433
433
  0,
434
434
  );
@@ -32,9 +32,9 @@ export function extractSkillName(path: string): string | null {
32
32
 
33
33
  function loadedSteeringPrompt(name: string, id: number): string {
34
34
  return (
35
- `[SKILL-STATE] skill "${name}" 已加载并开始追踪(id=${id})。\n` +
36
- `执行完成后调用 skill_state(action=update, id=${id}, status=completed)。\n` +
37
- `遇到困难时调用 skill_state(action=update, id=${id}, status=error, detail="原因")。`
35
+ `[SKILL-STATE] skill "${name}" loaded and tracking started (id=${id}).\n` +
36
+ `When done, call skill_state(action=update, id=${id}, status=completed).\n` +
37
+ `If blocked, call skill_state(action=update, id=${id}, status=error, detail="reason").`
38
38
  );
39
39
  }
40
40
 
@@ -42,17 +42,17 @@ function remindSteeringPrompt(
42
42
  name: string,
43
43
  turnsSinceLoad: number,
44
44
  ): string {
45
- return `[SKILL-STATE] skill "${name}" 已加载 ${turnsSinceLoad} turn 未终态,请调用 skill_state 工具流转状态。`;
45
+ return `[SKILL-STATE] skill "${name}" loaded ${turnsSinceLoad} turns ago without reaching terminal state. Please call skill_state to update its status.`;
46
46
  }
47
47
 
48
48
  function errorForceRecordPrompt(item: TrackedItem<SkillMeta>): string {
49
49
  return (
50
- `[SKILL-STATE] skill "${item.name}" 异常次数已达 ${item.errorCount} 次,需要记录问题。\n` +
51
- `请立即调用 subagent 工具(background 模式),任务如下:\n` +
52
- `1. 读取 ${item.metadata.skillMdPath}\n` +
53
- `2. 根据当前 session 上下文分析 skill "${item.name}" 执行中遇到的问题\n` +
54
- `3. 生成结构化问题记录(skill 名称、异常次数、问题描述、改进建议)\n` +
55
- `完成后调用 skill_state(action=update, id=${item.id}, status=recorded) 标记记录完成。`
50
+ `[SKILL-STATE] skill "${item.name}" has reached ${item.errorCount} errors — issue recording required.\n` +
51
+ `Immediately call the subagent tool (background mode) with this task:\n` +
52
+ `1. Read ${item.metadata.skillMdPath}\n` +
53
+ `2. Analyze issues encountered during skill "${item.name}" execution based on current session context\n` +
54
+ `3. Generate a structured issue record (skill name, error count, issue description, improvement suggestions)\n` +
55
+ `After completion, call skill_state(action=update, id=${item.id}, status=recorded).`
56
56
  );
57
57
  }
58
58
 
@@ -62,7 +62,7 @@ function agentStartContextPrompt(items: TrackedItem<SkillMeta>[]): string {
62
62
  (item) => ` - "${item.name}" (id=${item.id}, status=${item.status})`,
63
63
  );
64
64
  return (
65
- `[SKILL-STATE] 以下 skill 正在追踪中,请适时调用 skill_state 工具流转状态:\n` +
65
+ `[SKILL-STATE] The following skills are being tracked — call skill_state to update their status when appropriate:\n` +
66
66
  lines.join("\n")
67
67
  );
68
68
  }
@@ -74,17 +74,17 @@ export const skillExecutionConfig: TrackerConfig<SkillMeta> = {
74
74
  toolName: "skill_state",
75
75
  label: "Skill State",
76
76
  description:
77
- "管理 skill 执行追踪状态。" +
78
- "\n\n可用 action:" +
79
- "\n- list:查看所有 TrackedItem" +
80
- "\n- update:更新 TrackedItem 状态(需要 id status",
81
- promptSnippet: "追踪 skill 执行状态,自动检测 skill 加载",
77
+ "Manage skill execution tracking state." +
78
+ "\n\nAvailable actions:" +
79
+ "\n- list: View all TrackedItems" +
80
+ "\n- update: Update TrackedItem status (requires id and status)",
81
+ promptSnippet: "Track skill execution status with automatic skill load detection",
82
82
  promptGuidelines: [
83
- "[触发] skill 加载时自动创建追踪,无需手动创建",
84
- "[流转] 执行完成后用 update status=completed 标记成功",
85
- "[异常] 遇到困难时用 update status=error 标记异常",
86
- "[记录] 异常累积 2 次后系统会要求记录问题,完成后 update status=recorded",
87
- "[查询] 随时用 list 查看所有追踪状态",
83
+ "[Trigger] Tracking is auto-created when a skill loads — no manual creation needed",
84
+ "[Transition] After execution, use update status=completed to mark success",
85
+ "[Error] When blocked, use update status=error to mark the exception",
86
+ "[Record] After 2 accumulated errors, the system requests issue recording — when done, update status=recorded",
87
+ "[Query] Use list anytime to view all tracking states",
88
88
  ],
89
89
 
90
90
  triggerEvent: "tool_call",
@@ -79,15 +79,15 @@ export interface TrackerDetails<
79
79
  export const TrackerParams = Type.Object({
80
80
  action: StringEnum(["update", "list"] as const),
81
81
  id: Type.Optional(
82
- Type.Number({ description: "TrackedItem IDupdate 必填)" }),
82
+ Type.Number({ description: "TrackedItem ID (required for update)" }),
83
83
  ),
84
84
  status: Type.Optional(
85
85
  StringEnum(["completed", "error", "recorded"] as const, {
86
- description: "目标状态(update 必填)",
86
+ description: "Target status (required for update)",
87
87
  }),
88
88
  ),
89
89
  detail: Type.Optional(
90
- Type.String({ description: "附加说明(如 error 原因)" }),
90
+ Type.String({ description: "Additional notes (e.g. error reason)" }),
91
91
  ),
92
92
  });
93
93