engine7 7.1.120 → 7.1.121

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.
Files changed (50) hide show
  1. package/dist/cli.mjs +39910 -26359
  2. package/dist/engine-startup.mjs +51118 -25041
  3. package/dist/main.mjs +61139 -35062
  4. package/dist/mem7-worker.mjs +22969 -0
  5. package/dist/prompts/atomic-facts-memcell.md +80 -0
  6. package/dist/prompts/atomic-facts.md +108 -0
  7. package/dist/prompts/boundary.md +88 -0
  8. package/dist/prompts/case-compress.md +73 -0
  9. package/dist/prompts/case-filter.md +34 -0
  10. package/dist/prompts/case-rerank.md +12 -0
  11. package/dist/prompts/cluster-assign.md +25 -0
  12. package/dist/prompts/episode.md +65 -0
  13. package/dist/prompts/episodic-rerank.md +12 -0
  14. package/dist/prompts/foresight.md +148 -0
  15. package/dist/prompts/multi-query.md +61 -0
  16. package/dist/prompts/profile-compact.md +30 -0
  17. package/dist/prompts/profile-update.md +66 -0
  18. package/dist/prompts/profile.md +43 -0
  19. package/dist/prompts/refined-query.md +43 -0
  20. package/dist/prompts/skill-failure.md +84 -0
  21. package/dist/prompts/skill-maturity.md +49 -0
  22. package/dist/prompts/skill-rerank.md +23 -0
  23. package/dist/prompts/skill-success.md +103 -0
  24. package/dist/prompts/sufficiency.md +41 -0
  25. package/dist/prompts/tool-pre-compress.md +39 -0
  26. package/package.json +110 -95
  27. package/templates/config.template.json +25 -0
  28. package/templates/skills/email/LICENSE.txt +22 -0
  29. package/templates/skills/email/SKILL.md +115 -0
  30. package/templates/skills/email/assets/1-account-menu.jpg +0 -0
  31. package/templates/skills/email/assets/163/1-settings-menu.jpg +0 -0
  32. package/templates/skills/email/assets/163/2-service-closed.jpg +0 -0
  33. package/templates/skills/email/assets/163/3-security-warning.jpg +0 -0
  34. package/templates/skills/email/assets/163/5-imap-code.jpg +0 -0
  35. package/templates/skills/email/assets/2-security-settings-generate.jpg +0 -0
  36. package/templates/skills/email/assets/3-sms-verify.jpg +0 -0
  37. package/templates/skills/email/assets/4-wechat-send-confirm.jpg +0 -0
  38. package/templates/skills/email/assets/5-code-generated.jpg +0 -0
  39. package/templates/skills/email/package.json +12 -0
  40. package/templates/skills/email/scripts/email-config.js +114 -0
  41. package/templates/skills/email/scripts/email-config.test.js +93 -0
  42. package/templates/skills/email/scripts/email-gate.js +124 -0
  43. package/templates/skills/email/scripts/email-gate.test.js +62 -0
  44. package/templates/skills/email/scripts/imap.js +540 -0
  45. package/templates/skills/email/scripts/imap.test.js +86 -0
  46. package/templates/skills/email/scripts/smtp.js +238 -0
  47. package/templates/skills/email/scripts/smtp.test.js +44 -0
  48. package/templates/workspace/scripts/emotion_state_machine.mjs +13 -13
  49. package/src/memory/everos/python/__pycache__/agentic_search.cpython-314.pyc +0 -0
  50. package/templates/workspace/scripts/__pycache__/emotion_state_machine.cpython-310.pyc +0 -0
@@ -0,0 +1,148 @@
1
+
2
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
3
+
4
+ You are an advanced personal foresight analysis agent. Your task is to predict the specific impacts that a user's latest MemCell event might have on their future personal behaviors, habits, decisions, and lifestyle.
5
+
6
+ ## Task Objectives:
7
+ 1. **Personal-Level Association**: Analyze the event's potential impact on the user's future behavior, thinking patterns, life habits, or decision preferences from the personal perspective.
8
+ 2. **Associative Prediction, Not Summary**: Based on event content, predict potential personal changes rather than repeating or summarizing the original content.
9
+ 3. **Scenario Style Matching**: Predictions must match the scenario style of the event:
10
+ - Life scenarios (e.g., health, family, leisure, learning) → Use casual language, focus on personal habits, emotional states, lifestyle, personal growth, etc.
11
+ - Work scenarios (e.g., career development, skill improvement, work style) → Use professional language, focus on career planning, capability enhancement, work habits, professional development, etc.
12
+ 4. **Personal Behavior-Oriented**: Each association should reflect the user's "potential changes" or "behavioral tendencies," focusing on individual-level future development.
13
+ 5. **Reasonable Time Dimension**: Each prediction should include a reasonable time dimension, inferred based on event type and personal status.
14
+ 6. **Specific and Actionable**: Each prediction should not exceed 40 words; generate up to 10 predictions (recommended 4-8). Content must be specific and verifiable.
15
+ 7. **Prefer user_name**: Prefer using user_name when provided; otherwise use user_id (e.g., user_1). Avoid using generic terms like "the user."
16
+ 8. **Semantic Grounding**: Predictions must remain semantically related to the input; store grounded supporting facts in evidence so the system can trace back the source.
17
+ ## Output Format:
18
+ Return as a JSON object with a "foresights" array; each association includes time information and evidence:
19
+ {{
20
+ "foresights": [
21
+ {{
22
+ "content": "XiaoMing will avoid hot/spicy food for the next week",
23
+ "evidence": "Doctor advice: keep oral hygiene; avoid hot/spicy food for a week",
24
+ "start_time": "2025-10-21",
25
+ "end_time": "2025-10-28",
26
+ "duration_days": 7
27
+ }},
28
+ ...
29
+ ]
30
+ }}
31
+
32
+ ## Example Input (Life Scenario):
33
+ - user_id: xiaoming-001
34
+ - user_name: XiaoMing
35
+ - conversation:
36
+ ```text
37
+ [2025-10-21T14:05:00Z] XiaoMing: The extraction went fine, but it's still sore.
38
+ [2025-10-21T14:06:10Z] Doctor: Keep oral hygiene, avoid hot/spicy food for a week, and follow up if swelling worsens.
39
+ [2025-10-21T14:07:30Z] XiaoMing: Got it, I'll follow the instructions and watch for symptoms.
40
+ ```
41
+
42
+ ## Example Output (Life Scenario):
43
+ {{
44
+ "foresights": [
45
+ {{
46
+ "content": "XiaoMing will avoid hot/spicy food for the next week",
47
+ "evidence": "Doctor advice: avoid hot/spicy food; keep oral hygiene for a week",
48
+ "start_time": "2025-10-21",
49
+ "end_time": "2025-10-28",
50
+ "duration_days": 7
51
+ }},
52
+ {{
53
+ "content": "XiaoMing will pay more attention to oral hygiene this week",
54
+ "evidence": "Doctor advice: keep oral hygiene for a week",
55
+ "start_time": "2025-10-21",
56
+ "end_time": "2025-10-28",
57
+ "duration_days": 7
58
+ }},
59
+ {{
60
+ "content": "If swelling/pain worsens, XiaoMing will seek a follow-up soon",
61
+ "evidence": "Doctor: follow up if swelling worsens",
62
+ "start_time": "2025-10-21",
63
+ "end_time": "2025-11-04",
64
+ "duration_days": 14
65
+ }},
66
+ {{
67
+ "content": "XiaoMing will avoid hard chewing for the next few days",
68
+ "evidence": "XiaoMing said it is still sore after the extraction",
69
+ "start_time": "2025-10-21",
70
+ "end_time": "2025-10-25",
71
+ "duration_days": 4
72
+ }}
73
+ ...
74
+ ]
75
+ }}
76
+
77
+ ## Example Input (Work Scenario):
78
+ - user_id: LiHua-001
79
+ - user_name: LiHua
80
+ - conversation:
81
+ ```text
82
+ [2025-10-21T10:00:00Z] Trainer: Today we'll cover agile planning and sprint rituals.
83
+ [2025-10-21T11:15:20Z] LiHua: The daily standup structure is clearer—I can apply it to my team.
84
+ [2025-10-23T16:40:05Z] Trainer: Review metrics and improve collaboration after each sprint.
85
+ ```
86
+
87
+ ## Example Output (Work Scenario):
88
+ {{
89
+ "foresights": [
90
+ {{
91
+ "content": "LiHua will trial a more structured standup in the team over the next two weeks",
92
+ "evidence": "LiHua: the daily standup structure is clearer and can be applied to the team",
93
+ "start_time": "2025-10-21",
94
+ "end_time": "2025-11-04",
95
+ "duration_days": 14
96
+ }},
97
+ {{
98
+ "content": "LiHua will try to introduce sprint rituals in the next month",
99
+ "evidence": "Training covered sprint rituals; LiHua intends to apply learnings",
100
+ "start_time": "2025-10-21",
101
+ "end_time": "2025-11-21",
102
+ "duration_days": 31
103
+ }},
104
+ {{
105
+ "content": "After the next iteration, LiHua will try to review metrics and do a retrospective",
106
+ "evidence": "Trainer: review metrics and improve collaboration after each sprint",
107
+ "start_time": "2025-10-21",
108
+ "end_time": "2025-11-21",
109
+ "duration_days": 31
110
+ }},
111
+ {{
112
+ "content": "LiHua will pay more attention to concrete collaboration improvement actions this month",
113
+ "evidence": "Trainer emphasized improving collaboration after each sprint",
114
+ "start_time": "2025-10-21",
115
+ "end_time": "2025-11-21",
116
+ "duration_days": 31
117
+ }}
118
+ ...
119
+ ]
120
+ }}
121
+
122
+ ## Important Notes:
123
+ - **Personal-Oriented**: Focus on "personal-level future changes," content can cover life, learning, work, emotions, habits, and other personal development areas.
124
+ - **Associative Innovation**: Don't repeat original content; generate personal behavioral, habitual, or decision-making changes that the event might trigger.
125
+ - **Scenario Adaptation**: Language style must match the event scenario - use casual expressions for life scenarios, professional expressions for work scenarios.
126
+ - **Time Inference**: Reasonably infer time ranges based on event type, personal status, and common sense - don't rigidly apply fixed times.
127
+ - **Content Practicality**: Content must be specific, reasonable, practical, and usable by the system for personal foresight modeling.
128
+ - **Semantic Retrieval Friendly**: content should be the prediction result (e.g., "will choose soft food"), evidence stores the original fact (e.g., "wisdom tooth extraction"), enabling AI to retrieve relevant foresights based on user queries (e.g., "recommend food") and trace back reasons.
129
+ - **Time Information Extraction Rules:**
130
+ - start_time: Extract the specific date when the event occurred from the MemCell's timestamp field, format: YYYY-MM-DD
131
+ - end_time: Extract the specific end time from the original content. If there's an explicit end time (e.g., "before October 24", "2025-11-15"), extract the specific date; otherwise, reasonably infer based on event content and common sense
132
+ - duration_days: Extract duration from the original content. If there's explicit time description (e.g., "within a week", "7 days", "one month"), extract days; otherwise, reasonably infer based on event content and common sense
133
+ - evidence: Provide a short grounded summary (1–2 sentences) of the key supporting facts (can merge multiple lines from the transcript/summary); do not introduce new facts; keep it concise (≤40 words)
134
+ - **Important**: Prioritize extracting explicit time information from the original text; if not available, make reasonable inferences based on event content and common sense. Time cannot be null
135
+
136
+ ## Input (Markdown):
137
+ You will receive the following Markdown structure:
138
+ - user_id: {USER_ID}
139
+ - user_name: {USER_NAME}
140
+ - conversation:
141
+ ```text
142
+ {CONVERSATION_TEXT}
143
+ ```
144
+
145
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
146
+
147
+ ## Please generate 4-8 (up to 10) associations that may impact the user's future life and decisions based on the above content:
148
+
@@ -0,0 +1,61 @@
1
+ You are an expert at query reformulation for conversational memory retrieval.
2
+ Your goal is to generate 2-3 complementary queries to find the MISSING information.
3
+
4
+ --------------------------
5
+ Original Query:
6
+ {original_query}
7
+
8
+ Key Information Found:
9
+ {key_info}
10
+
11
+ Missing Information:
12
+ {missing_info}
13
+
14
+ Retrieved Documents (Context):
15
+ {retrieved_docs}
16
+ --------------------------
17
+
18
+ ### Strategy Selection (Choose based on WHY info is missing):
19
+
20
+ **[A] Pivot / Entity Association (If entity is missing)**
21
+ - If the specific entity is not found, search for related entities or broader categories.
22
+ - Example: "manager's feedback" not found → try "performance review", "work evaluation".
23
+
24
+ **[B] Temporal Calculation (If time is missing/unclear)**
25
+ - Use `Date` from Retrieved Documents to anchor relative times.
26
+ - Example: doc dated 2024-03-15 mentions "last month" → search for "February 2024".
27
+ - Search for the *event* to find its timestamp: "When did the deadline change?"
28
+
29
+ **[C] Concept Expansion (If vocabulary mismatch)**
30
+ - Synonyms: "residence" → "living", "staying at", "moved to".
31
+ - General/Specific: "Italian cuisine" ↔ "pasta", "pizza", "restaurant".
32
+
33
+ **[D] Constraint Relaxation (If too specific)**
34
+ - If "quarterly sales report from Q3" fails, try "sales report", "Q3 results".
35
+ - Remove one constraint at a time.
36
+
37
+ ### Query Style Requirements (Use DIFFERENT styles):
38
+
39
+ 1. **Keyword Combo** (2-5 words): Key entities only. High recall.
40
+ - e.g., "project deadline", "vacation plans summer"
41
+ 2. **Natural Question** (5-10 words): Rephrased question.
42
+ - e.g., "When was the meeting scheduled?", "What was discussed about the budget?"
43
+ 3. **Hypothetical Statement** (HyDE, 5-10 words): A likely sentence in the memory.
44
+ - e.g., "We decided to postpone the launch", "The client requested changes"
45
+
46
+ ### Requirements:
47
+ - Generate 2-3 queries.
48
+ - **CRITICAL**: Use the strategies above to target the *Missing Information*.
49
+ - Keep queries SHORT and SEARCHABLE.
50
+
51
+ ### Output Format (STRICT JSON):
52
+ {{
53
+ "queries": [
54
+ "Query 1",
55
+ "Query 2",
56
+ "Query 3"
57
+ ],
58
+ "reasoning": "Strategy used for each query (e.g., Q1: Pivot, Q2: Temporal)"
59
+ }}
60
+
61
+ Now generate:
@@ -0,0 +1,30 @@
1
+
2
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
3
+
4
+ The current user profile has {total_items} items (explicit_info + implicit_traits combined), exceeding the limit of {max_items}.
5
+
6
+ Please compact the profile to **{max_items} items TOTAL** (explicit_info + implicit_traits combined, NOT {max_items} each).
7
+
8
+ Compaction strategies:
9
+ 1. **Merge Similar Items**: Combine multiple records of the same dimension into one "Current State + Trend" description.
10
+ 2. **Refine Tags**: Implicit traits should be summarized as personality tags (e.g., [Risk-Averse]), removing repetitive or shallow descriptions.
11
+ 3. Delete unimportant, outdated, or short-term statuses.
12
+ 4. Preserve item fields (especially evidence).
13
+
14
+ Current Profile:
15
+ {profile_text}
16
+
17
+ **IMPORTANT**: Output must have explicit_info + implicit_traits ≤ {max_items} items TOTAL.
18
+ ```json
19
+ {{
20
+ "explicit_info": [
21
+ {{"category": "...", "description": "...", "evidence": "..."}}
22
+ ],
23
+ "implicit_traits": [
24
+ {{"trait": "...", "description": "...", "basis": "...", "evidence": "..."}}
25
+ ],
26
+ "compact_note": "Explain what was deleted/merged"
27
+ }}
28
+ ```
29
+
30
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
@@ -0,0 +1,66 @@
1
+
2
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
3
+
4
+ You are a user profile updater. Based on conversation records, determine what operations to perform on the user profile.
5
+
6
+ 【Current User Profile】(Each item has an index number)
7
+ {current_profile}
8
+
9
+ 【Conversation Records】(Multiple conversations from the same topic)
10
+ {conversations}
11
+
12
+ 【Task】
13
+ Analyze conversations and output a list of operations (can have multiple). Available action types:
14
+ - **update**: Modify existing items (specify by index)
15
+ - **add**: Add profile items
16
+ - **delete**: Delete existing items
17
+ - **none**: No operation needed (use when conversation contains no user info)
18
+
19
+ 【Operation Guide】
20
+ - **update**: Existing item has updates, supplements, or corrections
21
+ - **add**: Discovered completely new user information (unrelated to existing items)
22
+ - **delete**: Should delete in these cases:
23
+ - User explicitly negates (e.g., "I'm no longer vegetarian")
24
+ - Info is outdated (e.g., "traveling next week" but it's already passed)
25
+ - Too trivial/useless (e.g., "want pizza today")
26
+ - Directly contradicts new info
27
+
28
+ 【Important Rules】
29
+ 1. **Tag Mining**: Implicit traits must include [Personality Tags], e.g., [Risk-Averse], [Socially-Driven], [Data-Oriented].
30
+ 2. Only extract user info, don't treat AI assistant suggestions as user traits
31
+ 3. evidence should include time info - e.g., "In Oct 2024 user mentioned..."
32
+ 4. Index numbers for explicit_info and implicit_traits are independent
33
+ 5. **Deduplication**: Before using "add", carefully check ALL existing items. If a similar trait/info already exists (even with different wording), use "update" to enrich it instead of adding a duplicate. Only use "add" for genuinely NEW information not covered by any existing item.
34
+
35
+ 【Profile Definitions & Analysis Framework】
36
+ - **explicit_info (Explicit Information)**: User facts that can be directly extracted from conversations.
37
+ - *Content*: Basic info, health status, skills, clear preferences.
38
+
39
+ - **implicit_traits (Implicit Traits)**: Psychological profile, personality tags, and decision styles inferred from behavior.
40
+ - *Extraction Requirement*: Freely analyze from dimensions like decision patterns, social preferences, and life philosophy.
41
+ - *Naming Convention*:
42
+ 1. Keep tags short, readable, and reusable for retrieval/comparison (prefer 2–6 words).
43
+ 2. Avoid stitching multiple dimensions into one long label; if multiple dimensions exist, split into multiple implicit traits.
44
+ 3. Tags should describe stable behavioral/psychological tendencies, not one-off events or short-term states.
45
+ - Make reasonable inferences to extract the user's deep traits
46
+
47
+ 【Output Format】
48
+ No operations:
49
+ ```json
50
+ {{"operations": [{{"action": "none"}}], "update_note": "conversation contains no user info"}}
51
+ ```
52
+
53
+ With operations (can combine multiple add/update/delete):
54
+ ```json
55
+ {{
56
+ "operations": [
57
+ {{"action": "add", "type": "explicit_info", "data": {{"category": "...", "description": "...", "evidence": "..."}}}},
58
+ {{"action": "add", "type": "implicit_traits", "data": {{"trait": "...", "description": "...", "basis": "...", "evidence": "..."}}}},
59
+ {{"action": "update", "type": "explicit_info", "index": 0, "data": {{"description": "..."}}}},
60
+ {{"action": "delete", "type": "implicit_traits", "index": 1, "reason": "..."}}
61
+ ],
62
+ "update_note": "added 2 explicit info and 1 implicit trait, updated 1, deleted 1"
63
+ }}
64
+ ```
65
+
66
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
@@ -0,0 +1,43 @@
1
+
2
+ **CRITICAL LANGUAGE RULE**: You MUST output in the SAME language as the input conversation content. If the conversation content is in Chinese, ALL output MUST be in Chinese. If in English, output in English. This is mandatory.
3
+
4
+ You are a "User Profile Analyst". Please read the conversation below and build a user profile.
5
+
6
+ 【Part 1: Explicit Information (explicit_info)】
7
+ Objective facts and current status.
8
+
9
+ 【Part 2: Implicit Traits (implicit_traits)】
10
+ Psychological profile, personality tags, and decision styles inferred from behavior.
11
+ *Extraction Requirement*: Freely analyze decision making, social patterns, and values. Trait field must be a highly summarized [Adjective/Noun Phrase Tag].
12
+
13
+ 【Extraction Principles】
14
+ 1. Only extract information about the user themselves, not assistant suggestions
15
+ 2. Implicit traits must be supported by multiple evidence: each implicit trait must have evidence corroborated by multiple signals from the conversations and/or existing profile; do not infer from a single data point alone
16
+ 3. Describe each piece of information in one natural sentence, easy to understand
17
+
18
+ 【Output Format】
19
+ Output JSON directly in the following format:
20
+ ```json
21
+ {{
22
+ "explicit_info": [
23
+ {{
24
+ "category": "category name",
25
+ "description": "one sentence description",
26
+ "evidence": "one-sentence evidence grounded in the conversations"
27
+ }}
28
+ ],
29
+ "implicit_traits": [
30
+ {{
31
+ "trait": "trait name",
32
+ "description": "one sentence description of this trait",
33
+ "basis": "inferred from which behaviors/conversations",
34
+ "evidence": "one-sentence evidence grounded in the conversations"
35
+ }}
36
+ ]
37
+ }}
38
+ ```
39
+
40
+ LANGUAGE RULE: Detect the language of the input conversation and respond in the SAME language. If the conversation is in Chinese, output in Chinese. If in English, output in English.
41
+
42
+ 【Original Conversation】
43
+ {conversation_text}
@@ -0,0 +1,43 @@
1
+ You are an expert at query reformulation for information retrieval.
2
+
3
+ **Task**: Generate a refined query that targets the missing information in the retrieved results.
4
+
5
+ **Original Query**:
6
+ {original_query}
7
+
8
+ **Retrieved Documents** (insufficient):
9
+ {retrieved_docs}
10
+
11
+ **Missing Information**:
12
+ {missing_info}
13
+
14
+ **Instructions**:
15
+ 1. Keep the core intent of the original query unchanged.
16
+ 2. Add specific keywords or rephrase to target the missing information.
17
+ 3. Make the query more specific and focused.
18
+ 4. The refined query should be a direct question that seeks to extract the missing facts.
19
+ 5. Do NOT change the query's meaning or make it too broad.
20
+ 6. Keep it concise (1-2 sentences maximum).
21
+
22
+ **Examples**:
23
+
24
+ Example 1:
25
+ Original Query: "What happened at the conference?"
26
+ Missing Info: ["specific sessions attended", "key takeaways"]
27
+ Refined Query: "Which sessions were attended at the conference and what were the main takeaways?"
28
+
29
+ Example 2:
30
+ Original Query: "Tell me about the deadline"
31
+ Missing Info: ["deadline date", "deliverables", "responsible team"]
32
+ Refined Query: "When is the deadline, what needs to be delivered, and who is responsible?"
33
+
34
+ Example 3:
35
+ Original Query: "The new policy"
36
+ Missing Info: ["policy details", "effective date", "affected departments"]
37
+ Refined Query: "What are the details of the new policy, when does it take effect, and which departments are affected?"
38
+
39
+ Now generate the refined query (output only the refined query, no additional text):
40
+ Original Query: {original_query}
41
+ Missing Info: {missing_info}
42
+
43
+ Refined Query:
@@ -0,0 +1,84 @@
1
+ You are an expert at extracting failure insights and partial progress from failed agent task cases.
2
+
3
+ You will receive:
4
+ 1. **New case(s)** from a cluster of semantically similar tasks — all with quality_score < 0.5. Each case represents a failed or mostly failed attempt, with steps that were tried and why they failed.
5
+ 2. **Existing skills** previously extracted for this cluster (each item has an index number; may be empty). Existing skills may include `supporting_cases` — summaries of prior cases (task_intent, approach, key_insight, quality_score) that contributed to the skill. Use these as historical evidence when deciding whether to update or keep a skill.
6
+
7
+ Your job is to distill **what NOT to do** and **partial progress** from failed cases into reusable knowledge via incremental operations.
8
+
9
+ **Extraction principle for failed cases:**
10
+ - Do NOT adopt unverified steps as proven SOP. Only include steps in Potential Steps where exploration **demonstrably succeeded** (produced correct intermediate results or clear forward progress toward the goal).
11
+ - Extract **specific failure patterns, dead ends, and mistakes** into the Pitfalls section. These cases teach what NOT to do.
12
+ - A failed step that reveals a root cause is valuable — it helps future agents avoid the same path.
13
+
14
+ **Field-level requirements:**
15
+
16
+ - **description** (HARD LIMIT: max 150 tokens, must be under 500 characters):
17
+ - One-sentence summary of the **abstract problem class** and the known failure patterns — describe the general pattern, NOT specific cases.
18
+ - Do NOT list multiple scenarios, entity names, or case-specific details.
19
+ - Append `Keywords:` with up to 10 general terms (no specific names, numbers, or case-specific phrases).
20
+
21
+ - **content**: Output in **Markdown format** using this template:
22
+ ```markdown
23
+ ## Potential Steps
24
+ > Extracted from a failed/incomplete case. Only steps that demonstrably succeeded (produced correct intermediate results or clear forward progress) are listed. Treat as unverified hypotheses until confirmed by a successful case.
25
+
26
+ 1. <action verb + object — only steps where exploration succeeded>
27
+ - How: <concrete method or command pattern from the case>
28
+ - e.g., `<exact command/code that worked>`
29
+ - Check: <what output confirmed this step progressed correctly>
30
+ 2. ...
31
+
32
+ ## Pitfalls
33
+ - <specific dead end, failed approach, or mistake> — <what went wrong and how to avoid it>
34
+ ```
35
+
36
+ Rules:
37
+ - **Markdown formatting**: `##` headings, numbered steps, bullet sub-items, backtick code fences. Mandatory.
38
+ - **Length limit**: MUST stay within **2000 tokens**.
39
+ - **Potential Steps**: Include ONLY steps with demonstrable forward progress. If NO steps clearly progressed, omit the numbered list and keep only the `> Extracted from...` note.
40
+ - **Pitfalls**: MUST be included and populated. Every failed case must contribute at least one specific, traceable pitfall. FORBIDDEN: generic warnings, speculative risks, best-practice reminders not directly traceable to a failure in this case.
41
+
42
+ [New AgentCase(s) to integrate]
43
+ {new_case_json}
44
+
45
+ [Existing skills for this cluster](Each item has an index number)
46
+ {existing_skills_json}
47
+
48
+ [Task]
49
+ Analyze the failed case(s) and output operations (add / update / none).
50
+
51
+ [Operation Guide]
52
+ - **update**: If an existing skill covers the same problem class, integrate failure insights by index:
53
+ - If existing skill has `## Steps` (verified): preserve Steps intact — only append new entries to `## Pitfalls`.
54
+ - If existing skill has `## Potential Steps` (hypothesis): you may also enrich `## Potential Steps` with any steps from this case that demonstrably succeeded, in addition to appending to `## Pitfalls`.
55
+ - **CRITICAL: The updated content MUST stay within 2000 tokens. Do NOT simply append — if Pitfalls exceed 4 entries, replace the most generic one. If Potential Steps are already sufficient, do NOT add redundant ones. Aggressively condense existing content if it is already long.**
56
+ - **CRITICAL: The updated description MUST stay under 500 characters. Generalize — do NOT accumulate case-specific details.**
57
+ - **No parenthetical catalogs**: FORBIDDEN to stuff dozens of case-specific terms (names, dates, compounds, etc.) inside parentheses. Keep each field concise — generalize the pattern, illustrate with 1-2 examples only.
58
+ - **add**: If no existing skill covers this problem class, create a new skill using the Potential Steps + Pitfalls template above.
59
+ - **none**: The case is completely irrelevant to all existing skills and too isolated to form a useful pattern. Use very sparingly.
60
+
61
+ [Confidence Anchoring Rules]
62
+ - **New skill (add)**: confidence = `0.5`
63
+ - **Update existing skill with pitfall only**: confidence unchanged (failure insight doesn't validate the SOP steps).
64
+ - **Update existing hypothesis skill with new Potential Steps**: confidence = existing + 0.05 (slight bump for additional partial evidence).
65
+ - If the failure directly contradicts an existing skill's recommended approach: confidence = existing - 0.15~0.25, and add the specific contradiction to Pitfalls.
66
+
67
+ **CRITICAL LANGUAGE RULE**: Output in the SAME language as the input conversation content.
68
+
69
+ [Output Format]
70
+ No operations:
71
+ ```json
72
+ {{"operations": [{{"action": "none"}}], "update_note": "failed case adds no new failure patterns to existing skills"}}
73
+ ```
74
+
75
+ With operations:
76
+ ```json
77
+ {{
78
+ "operations": [
79
+ {{"action": "add", "data": {{"name": "Short descriptive name (max 10 words)", "description": "One-sentence abstract summary of problem class. Keywords: term1, term2 (max 150 tokens, under 500 chars)", "content": "## Potential Steps\n> Extracted from a failed case. Only steps that demonstrably progressed correctly are listed.\n1. <action where exploration succeeded>\n - How: <method>\n - e.g., `<exact command that worked>`\n - Check: <what confirmed progress>\n\n## Pitfalls\n- <dead end or failed approach> — <what went wrong and how to avoid>", "confidence": 0.5}}}},
80
+ {{"action": "update", "index": 0, "data": {{"content": "## Steps\n<existing steps preserved>\n\n## Pitfalls\n<existing pitfalls>\n- <new pitfall from this failed case> — <what went wrong and how to avoid>"}}}}
81
+ ],
82
+ "update_note": "added pitfall from failed case to skill[0]; created new skill from partial exploration"
83
+ }}
84
+ ```
@@ -0,0 +1,49 @@
1
+ You are a quality evaluator for agent skill documents (SOPs).
2
+
3
+ Skills come in two forms — detect which type before scoring:
4
+ - **Verified skill** (`## Steps`): Extracted from successful cases (quality_score >= 0.5). Evaluated as a full SOP.
5
+ - **Hypothesis skill** (`## Potential Steps`): Extracted from failed cases (quality_score < 0.5). Evaluated on a lower baseline — completeness is intentionally limited; a good Pitfalls section is the primary value.
6
+
7
+ Score the skill across 4 quality dimensions (each 1-5):
8
+
9
+ 1. **Completeness**: Does the skill cover the procedure adequately for its type?
10
+ - For `## Steps` skills: Does it cover the full procedure end-to-end without missing critical steps?
11
+ - 1: Missing most steps or only a vague outline
12
+ - 3: Covers the main flow but missing some steps or edge cases
13
+ - 5: Complete end-to-end procedure with all necessary steps
14
+ - For `## Potential Steps` skills: Does it cover what was known to work, plus a populated Pitfalls section?
15
+ - 1: No steps and no pitfalls — nothing useful extracted
16
+ - 3: Either partial steps OR pitfalls, but not both
17
+ - 5: Clear partial steps from verified progress AND substantive Pitfalls section
18
+
19
+ 2. **Executability**: Can an agent follow this skill without guessing? Combines concreteness of actions with supporting detail.
20
+ - 1: Vague suggestions like "investigate the issue" with no concrete actions, no examples, no checkpoints
21
+ - 2: Steps name an action but lack How methods, no inline examples
22
+ - 3: Mix of concrete and vague steps; some have How/commands/examples, others do not
23
+ - 4: Most steps have concrete verb+object actions with How methods; some inline examples and decision branches
24
+ - 5: Every step is a concrete verb+object action with How method, inline examples from real cases, explicit decision branches where needed, and verification checkpoints
25
+
26
+ 3. **Evidence**: Is the skill supported by sufficient case evidence?
27
+ - For `## Steps` skills:
28
+ - 1: No inline examples; reads like a guess or untested procedure
29
+ - 3: One or two inline examples; moderate confidence
30
+ - 5: Rich inline examples across multiple steps from different scenarios; high confidence backed by repeated validation
31
+ - For `## Potential Steps` skills:
32
+ - 1: Steps and pitfalls are generic or untraced
33
+ - 3: Some steps/pitfalls are clearly traced to real attempts
34
+ - 5: All listed steps have verifiable progress markers; all pitfalls cite specific failures
35
+
36
+ 4. **Clarity**: Is the skill well-organized with proper Markdown structure, concise prose, and logical flow?
37
+ - 1: Unstructured wall of text, no formatting
38
+ - 3: Has some structure but inconsistent formatting or verbose
39
+ - 5: Clean Markdown with appropriate `##` headings, numbered steps, consistent sub-items, concise and scannable
40
+
41
+ Skill to evaluate:
42
+ - Name: {name}
43
+ - Description: {description}
44
+ - Content:
45
+ {content}
46
+ - Confidence: {confidence}
47
+
48
+ Return ONLY valid JSON (no markdown fences):
49
+ {{"completeness": 1-5, "executability": 1-5, "evidence": 1-5, "clarity": 1-5, "reason": "brief justification for the scores"}}
@@ -0,0 +1,23 @@
1
+ Determine whether each agent skill's methodology and domain are applicable to the user query, preferring same-domain skills with directly relevant steps. Score each skill from 0.0 (not applicable at all) to 1.0 (methodology and domain both strongly apply).
2
+
3
+ Evaluate each skill considering:
4
+ - Whether the skill's steps or approach are applicable to the query's problem type
5
+ - Whether the skill's target domain (shown in its description, trigger scenarios, and keywords) overlaps with the query's subject matter — same-domain skills should be scored higher
6
+
7
+ Score bands:
8
+ - **0.0**: Completely irrelevant — no applicable methodology or domain connection
9
+ - **0.1-0.3**: Weakly related — methodology could loosely apply but domain is different
10
+ - **0.4-0.6**: Moderately helpful — useful methodology with partial domain overlap
11
+ - **0.7-0.8**: Helpful — applicable approach with good domain alignment
12
+ - **0.9-1.0**: Highly relevant — strong fit in both approach and domain
13
+
14
+ User query:
15
+ {query}
16
+
17
+ Candidates (JSON array; each item has `id`, `score`, plus metadata like `name`, `description`, `content`, `confidence`):
18
+ {candidates_json}
19
+
20
+ Return at most {top_k} items, sorted by score descending. Drop candidates whose score would be near 0.
21
+
22
+ Output strictly the following JSON, no prose:
23
+ {{"ranked": [{{"id": "<candidate_id>", "score": <float in 0..1>}}]}}