@zhushanwen/pi-evolve-daily 0.1.6 → 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 +1 -1
- package/src/problems.ts +24 -24
- package/src/trackers/core.ts +7 -7
- package/src/trackers/skill-execution.ts +21 -21
- package/src/trackers/types.ts +3 -3
package/package.json
CHANGED
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
|
-
"
|
|
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: "
|
|
79
|
-
description: "
|
|
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
|
-
"
|
|
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: "
|
|
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
|
|
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: "
|
|
129
|
-
description: "
|
|
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
|
-
"
|
|
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: "
|
|
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
|
-
"
|
|
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: "
|
|
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
|
|
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: "
|
|
220
|
-
description: "
|
|
219
|
+
title: "Optimize Goal Task Decomposition",
|
|
220
|
+
description: "Low task completion rate or poor evidence quality",
|
|
221
221
|
defaultSeverity: "high",
|
|
222
222
|
},
|
|
223
223
|
},
|
package/src/trackers/core.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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}
|
|
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:
|
|
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}]
|
|
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}"
|
|
36
|
-
|
|
37
|
-
|
|
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}"
|
|
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}"
|
|
51
|
-
|
|
52
|
-
`1.
|
|
53
|
-
`2.
|
|
54
|
-
`3.
|
|
55
|
-
|
|
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]
|
|
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
|
-
"
|
|
78
|
-
"\n\
|
|
79
|
-
"\n- list
|
|
80
|
-
"\n- update
|
|
81
|
-
promptSnippet: "
|
|
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
|
-
"[
|
|
84
|
-
"[
|
|
85
|
-
"[
|
|
86
|
-
"[
|
|
87
|
-
"[
|
|
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",
|
package/src/trackers/types.ts
CHANGED
|
@@ -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 ID
|
|
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: "
|
|
86
|
+
description: "Target status (required for update)",
|
|
87
87
|
}),
|
|
88
88
|
),
|
|
89
89
|
detail: Type.Optional(
|
|
90
|
-
Type.String({ description: "
|
|
90
|
+
Type.String({ description: "Additional notes (e.g. error reason)" }),
|
|
91
91
|
),
|
|
92
92
|
});
|
|
93
93
|
|