cnhkmcp 2.1.9__py3-none-any.whl → 2.2.0__py3-none-any.whl

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 (55) hide show
  1. cnhkmcp/__init__.py +1 -1
  2. cnhkmcp/untracked/AI/321/206/320/231/320/243/321/205/342/225/226/320/265/321/204/342/225/221/342/225/221/BRAIN_AI/321/206/320/231/320/243/321/205/342/225/226/320/265/321/204/342/225/221/342/225/221Mac_Linux/321/207/320/231/320/230/321/206/320/254/320/274.zip +0 -0
  3. cnhkmcp/untracked/AI/321/206/320/231/320/243/321/205/342/225/226/320/265/321/204/342/225/221/342/225/221//321/205/320/237/320/234/321/205/320/227/342/225/227/321/205/320/276/320/231/321/210/320/263/320/225AI/321/206/320/231/320/243/321/205/342/225/226/320/265/321/204/342/225/221/342/225/221_Windows/321/207/320/231/320/230/321/206/320/254/320/274.exe +0 -0
  4. cnhkmcp/untracked/AI/321/206/320/261/320/234/321/211/320/255/320/262/321/206/320/237/320/242/321/204/342/225/227/342/225/242/vector_db/chroma.sqlite3 +0 -0
  5. cnhkmcp/untracked/skills/brain-data-feature-engineering/OUTPUT_TEMPLATE.md +325 -0
  6. cnhkmcp/untracked/skills/brain-data-feature-engineering/SKILL.md +263 -0
  7. cnhkmcp/untracked/skills/brain-data-feature-engineering/examples.md +244 -0
  8. cnhkmcp/untracked/skills/brain-data-feature-engineering/reference.md +493 -0
  9. cnhkmcp/untracked/skills/brain-feature-implementation/SKILL.md +87 -0
  10. cnhkmcp/untracked/skills/brain-feature-implementation/config.json +6 -0
  11. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/analyst15_GLB_delay1.csv +289 -0
  12. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/final_expressions.json +410 -0
  13. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588244.json +4 -0
  14. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588251.json +20 -0
  15. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588273.json +23 -0
  16. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588293.json +23 -0
  17. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588319.json +23 -0
  18. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588322.json +14 -0
  19. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588325.json +20 -0
  20. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588328.json +23 -0
  21. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588354.json +23 -0
  22. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588357.json +23 -0
  23. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588361.json +23 -0
  24. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588364.json +23 -0
  25. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588368.json +23 -0
  26. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588391.json +14 -0
  27. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588394.json +23 -0
  28. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588397.json +59 -0
  29. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588400.json +35 -0
  30. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588403.json +20 -0
  31. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588428.json +23 -0
  32. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588431.json +32 -0
  33. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588434.json +20 -0
  34. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588438.json +20 -0
  35. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588441.json +14 -0
  36. cnhkmcp/untracked/skills/brain-feature-implementation/data/analyst15_GLB_delay1/idea_1768588468.json +20 -0
  37. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/ace_lib.py +1514 -0
  38. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/fetch_dataset.py +107 -0
  39. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/helpful_functions.py +180 -0
  40. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/implement_idea.py +164 -0
  41. cnhkmcp/untracked/skills/brain-feature-implementation/scripts/merge_expression_list.py +88 -0
  42. cnhkmcp/untracked/skills/planning-with-files/SKILL.md +211 -0
  43. cnhkmcp/untracked/skills/planning-with-files/examples.md +202 -0
  44. cnhkmcp/untracked/skills/planning-with-files/reference.md +218 -0
  45. cnhkmcp/untracked/skills/planning-with-files/scripts/check-complete.sh +44 -0
  46. cnhkmcp/untracked/skills/planning-with-files/scripts/init-session.sh +120 -0
  47. cnhkmcp/untracked/skills/planning-with-files/templates/findings.md +95 -0
  48. cnhkmcp/untracked/skills/planning-with-files/templates/progress.md +114 -0
  49. cnhkmcp/untracked/skills/planning-with-files/templates/task_plan.md +132 -0
  50. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/METADATA +1 -1
  51. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/RECORD +55 -10
  52. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/WHEEL +0 -0
  53. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/entry_points.txt +0 -0
  54. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/licenses/LICENSE +0 -0
  55. {cnhkmcp-2.1.9.dist-info → cnhkmcp-2.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: planning-with-files
3
+ version: "2.1.0"
4
+ description: Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.
5
+ user-invocable: true
6
+ allowed-tools:
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Bash
11
+ - Glob
12
+ - Grep
13
+ - WebFetch
14
+ - WebSearch
15
+ hooks:
16
+ SessionStart:
17
+ - hooks:
18
+ - type: command
19
+ command: "echo '[planning-with-files] Ready. Auto-activates for complex tasks, or invoke manually with /planning-with-files'"
20
+ PreToolUse:
21
+ - matcher: "Write|Edit|Bash"
22
+ hooks:
23
+ - type: command
24
+ command: "cat task_plan.md 2>/dev/null | head -30 || true"
25
+ PostToolUse:
26
+ - matcher: "Write|Edit"
27
+ hooks:
28
+ - type: command
29
+ command: "echo '[planning-with-files] File updated. If this completes a phase, update task_plan.md status.'"
30
+ Stop:
31
+ - hooks:
32
+ - type: command
33
+ command: "$HOME/.claude/skills/planning-with-files/scripts/check-complete.sh"
34
+ ---
35
+
36
+ # Planning with Files
37
+
38
+ Work like Manus: Use persistent markdown files as your "working memory on disk."
39
+
40
+ ## Important: Where Files Go
41
+
42
+ When using this skill:
43
+
44
+ - **Templates** are stored in the skill directory at `$HOME/.claude/skills/planning-with-files/templates/`
45
+ - **Your planning files** (`task_plan.md`, `findings.md`, `progress.md`) should be created in **your project directory** — the folder where you're working
46
+
47
+ | Location | What Goes There |
48
+ |----------|-----------------|
49
+ | Skill directory (`$HOME/.claude/skills/planning-with-files/`) | Templates, scripts, reference docs |
50
+ | Your project directory | `task_plan.md`, `findings.md`, `progress.md` |
51
+
52
+ This ensures your planning files live alongside your code, not buried in the skill installation folder.
53
+
54
+ ## Quick Start
55
+
56
+ Before ANY complex task:
57
+
58
+ 1. **Create `task_plan.md`** in your project — Use [templates/task_plan.md](templates/task_plan.md) as reference
59
+ 2. **Create `findings.md`** in your project — Use [templates/findings.md](templates/findings.md) as reference
60
+ 3. **Create `progress.md`** in your project — Use [templates/progress.md](templates/progress.md) as reference
61
+ 4. **Re-read plan before decisions** — Refreshes goals in attention window
62
+ 5. **Update after each phase** — Mark complete, log errors
63
+
64
+ > **Note:** All three planning files should be created in your current working directory (your project root), not in the skill's installation folder.
65
+
66
+ ## The Core Pattern
67
+
68
+ ```
69
+ Context Window = RAM (volatile, limited)
70
+ Filesystem = Disk (persistent, unlimited)
71
+
72
+ → Anything important gets written to disk.
73
+ ```
74
+
75
+ ## File Purposes
76
+
77
+ | File | Purpose | When to Update |
78
+ |------|---------|----------------|
79
+ | `task_plan.md` | Phases, progress, decisions | After each phase |
80
+ | `findings.md` | Research, discoveries | After ANY discovery |
81
+ | `progress.md` | Session log, test results | Throughout session |
82
+
83
+ ## Critical Rules
84
+
85
+ ### 1. Create Plan First
86
+ Never start a complex task without `task_plan.md`. Non-negotiable.
87
+
88
+ ### 2. The 2-Action Rule
89
+ > "After every 2 view/browser/search operations, IMMEDIATELY save key findings to text files."
90
+
91
+ This prevents visual/multimodal information from being lost.
92
+
93
+ ### 3. Read Before Decide
94
+ Before major decisions, read the plan file. This keeps goals in your attention window.
95
+
96
+ ### 4. Update After Act
97
+ After completing any phase:
98
+ - Mark phase status: `in_progress` → `complete`
99
+ - Log any errors encountered
100
+ - Note files created/modified
101
+
102
+ ### 5. Log ALL Errors
103
+ Every error goes in the plan file. This builds knowledge and prevents repetition.
104
+
105
+ ```markdown
106
+ ## Errors Encountered
107
+ | Error | Attempt | Resolution |
108
+ |-------|---------|------------|
109
+ | FileNotFoundError | 1 | Created default config |
110
+ | API timeout | 2 | Added retry logic |
111
+ ```
112
+
113
+ ### 6. Never Repeat Failures
114
+ ```
115
+ if action_failed:
116
+ next_action != same_action
117
+ ```
118
+ Track what you tried. Mutate the approach.
119
+
120
+ ## The 3-Strike Error Protocol
121
+
122
+ ```
123
+ ATTEMPT 1: Diagnose & Fix
124
+ → Read error carefully
125
+ → Identify root cause
126
+ → Apply targeted fix
127
+
128
+ ATTEMPT 2: Alternative Approach
129
+ → Same error? Try different method
130
+ → Different tool? Different library?
131
+ → NEVER repeat exact same failing action
132
+
133
+ ATTEMPT 3: Broader Rethink
134
+ → Question assumptions
135
+ → Search for solutions
136
+ → Consider updating the plan
137
+
138
+ AFTER 3 FAILURES: Escalate to User
139
+ → Explain what you tried
140
+ → Share the specific error
141
+ → Ask for guidance
142
+ ```
143
+
144
+ ## Read vs Write Decision Matrix
145
+
146
+ | Situation | Action | Reason |
147
+ |-----------|--------|--------|
148
+ | Just wrote a file | DON'T read | Content still in context |
149
+ | Viewed image/PDF | Write findings NOW | Multimodal → text before lost |
150
+ | Browser returned data | Write to file | Screenshots don't persist |
151
+ | Starting new phase | Read plan/findings | Re-orient if context stale |
152
+ | Error occurred | Read relevant file | Need current state to fix |
153
+ | Resuming after gap | Read all planning files | Recover state |
154
+
155
+ ## The 5-Question Reboot Test
156
+
157
+ If you can answer these, your context management is solid:
158
+
159
+ | Question | Answer Source |
160
+ |----------|---------------|
161
+ | Where am I? | Current phase in task_plan.md |
162
+ | Where am I going? | Remaining phases |
163
+ | What's the goal? | Goal statement in plan |
164
+ | What have I learned? | findings.md |
165
+ | What have I done? | progress.md |
166
+
167
+ ## When to Use This Pattern
168
+
169
+ **Use for:**
170
+ - Multi-step tasks (3+ steps)
171
+ - Research tasks
172
+ - Building/creating projects
173
+ - Tasks spanning many tool calls
174
+ - Anything requiring organization
175
+
176
+ **Skip for:**
177
+ - Simple questions
178
+ - Single-file edits
179
+ - Quick lookups
180
+
181
+ ## Templates
182
+
183
+ Copy these templates to start:
184
+
185
+ - [templates/task_plan.md](templates/task_plan.md) — Phase tracking
186
+ - [templates/findings.md](templates/findings.md) — Research storage
187
+ - [templates/progress.md](templates/progress.md) — Session logging
188
+
189
+ ## Scripts
190
+
191
+ Helper scripts for automation:
192
+
193
+ - `scripts/init-session.sh` — Initialize all planning files
194
+ - `scripts/check-complete.sh` — Verify all phases complete
195
+
196
+ ## Advanced Topics
197
+
198
+ - **Manus Principles:** See [reference.md](reference.md)
199
+ - **Real Examples:** See [examples.md](examples.md)
200
+
201
+ ## Anti-Patterns
202
+
203
+ | Don't | Do Instead |
204
+ |-------|------------|
205
+ | Use TodoWrite for persistence | Create task_plan.md file |
206
+ | State goals once and forget | Re-read plan before decisions |
207
+ | Hide errors and retry silently | Log errors to plan file |
208
+ | Stuff everything in context | Store large content in files |
209
+ | Start executing immediately | Create plan file FIRST |
210
+ | Repeat failed actions | Track attempts, mutate approach |
211
+ | Create files in skill directory | Create files in your project |
@@ -0,0 +1,202 @@
1
+ # Examples: Planning with Files in Action
2
+
3
+ ## Example 1: Research Task
4
+
5
+ **User Request:** "Research the benefits of morning exercise and write a summary"
6
+
7
+ ### Loop 1: Create Plan
8
+ ```bash
9
+ Write task_plan.md
10
+ ```
11
+
12
+ ```markdown
13
+ # Task Plan: Morning Exercise Benefits Research
14
+
15
+ ## Goal
16
+ Create a research summary on the benefits of morning exercise.
17
+
18
+ ## Phases
19
+ - [ ] Phase 1: Create this plan ✓
20
+ - [ ] Phase 2: Search and gather sources
21
+ - [ ] Phase 3: Synthesize findings
22
+ - [ ] Phase 4: Deliver summary
23
+
24
+ ## Key Questions
25
+ 1. What are the physical health benefits?
26
+ 2. What are the mental health benefits?
27
+ 3. What scientific studies support this?
28
+
29
+ ## Status
30
+ **Currently in Phase 1** - Creating plan
31
+ ```
32
+
33
+ ### Loop 2: Research
34
+ ```bash
35
+ Read task_plan.md # Refresh goals
36
+ WebSearch "morning exercise benefits"
37
+ Write notes.md # Store findings
38
+ Edit task_plan.md # Mark Phase 2 complete
39
+ ```
40
+
41
+ ### Loop 3: Synthesize
42
+ ```bash
43
+ Read task_plan.md # Refresh goals
44
+ Read notes.md # Get findings
45
+ Write morning_exercise_summary.md
46
+ Edit task_plan.md # Mark Phase 3 complete
47
+ ```
48
+
49
+ ### Loop 4: Deliver
50
+ ```bash
51
+ Read task_plan.md # Verify complete
52
+ Deliver morning_exercise_summary.md
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Example 2: Bug Fix Task
58
+
59
+ **User Request:** "Fix the login bug in the authentication module"
60
+
61
+ ### task_plan.md
62
+ ```markdown
63
+ # Task Plan: Fix Login Bug
64
+
65
+ ## Goal
66
+ Identify and fix the bug preventing successful login.
67
+
68
+ ## Phases
69
+ - [x] Phase 1: Understand the bug report ✓
70
+ - [x] Phase 2: Locate relevant code ✓
71
+ - [ ] Phase 3: Identify root cause (CURRENT)
72
+ - [ ] Phase 4: Implement fix
73
+ - [ ] Phase 5: Test and verify
74
+
75
+ ## Key Questions
76
+ 1. What error message appears?
77
+ 2. Which file handles authentication?
78
+ 3. What changed recently?
79
+
80
+ ## Decisions Made
81
+ - Auth handler is in src/auth/login.ts
82
+ - Error occurs in validateToken() function
83
+
84
+ ## Errors Encountered
85
+ - [Initial] TypeError: Cannot read property 'token' of undefined
86
+ → Root cause: user object not awaited properly
87
+
88
+ ## Status
89
+ **Currently in Phase 3** - Found root cause, preparing fix
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Example 3: Feature Development
95
+
96
+ **User Request:** "Add a dark mode toggle to the settings page"
97
+
98
+ ### The 3-File Pattern in Action
99
+
100
+ **task_plan.md:**
101
+ ```markdown
102
+ # Task Plan: Dark Mode Toggle
103
+
104
+ ## Goal
105
+ Add functional dark mode toggle to settings.
106
+
107
+ ## Phases
108
+ - [x] Phase 1: Research existing theme system ✓
109
+ - [x] Phase 2: Design implementation approach ✓
110
+ - [ ] Phase 3: Implement toggle component (CURRENT)
111
+ - [ ] Phase 4: Add theme switching logic
112
+ - [ ] Phase 5: Test and polish
113
+
114
+ ## Decisions Made
115
+ - Using CSS custom properties for theme
116
+ - Storing preference in localStorage
117
+ - Toggle component in SettingsPage.tsx
118
+
119
+ ## Status
120
+ **Currently in Phase 3** - Building toggle component
121
+ ```
122
+
123
+ **notes.md:**
124
+ ```markdown
125
+ # Notes: Dark Mode Implementation
126
+
127
+ ## Existing Theme System
128
+ - Located in: src/styles/theme.ts
129
+ - Uses: CSS custom properties
130
+ - Current themes: light only
131
+
132
+ ## Files to Modify
133
+ 1. src/styles/theme.ts - Add dark theme colors
134
+ 2. src/components/SettingsPage.tsx - Add toggle
135
+ 3. src/hooks/useTheme.ts - Create new hook
136
+ 4. src/App.tsx - Wrap with ThemeProvider
137
+
138
+ ## Color Decisions
139
+ - Dark background: #1a1a2e
140
+ - Dark surface: #16213e
141
+ - Dark text: #eaeaea
142
+ ```
143
+
144
+ **dark_mode_implementation.md:** (deliverable)
145
+ ```markdown
146
+ # Dark Mode Implementation
147
+
148
+ ## Changes Made
149
+
150
+ ### 1. Added dark theme colors
151
+ File: src/styles/theme.ts
152
+ ...
153
+
154
+ ### 2. Created useTheme hook
155
+ File: src/hooks/useTheme.ts
156
+ ...
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Example 4: Error Recovery Pattern
162
+
163
+ When something fails, DON'T hide it:
164
+
165
+ ### Before (Wrong)
166
+ ```
167
+ Action: Read config.json
168
+ Error: File not found
169
+ Action: Read config.json # Silent retry
170
+ Action: Read config.json # Another retry
171
+ ```
172
+
173
+ ### After (Correct)
174
+ ```
175
+ Action: Read config.json
176
+ Error: File not found
177
+
178
+ # Update task_plan.md:
179
+ ## Errors Encountered
180
+ - config.json not found → Will create default config
181
+
182
+ Action: Write config.json (default config)
183
+ Action: Read config.json
184
+ Success!
185
+ ```
186
+
187
+ ---
188
+
189
+ ## The Read-Before-Decide Pattern
190
+
191
+ **Always read your plan before major decisions:**
192
+
193
+ ```
194
+ [Many tool calls have happened...]
195
+ [Context is getting long...]
196
+ [Original goal might be forgotten...]
197
+
198
+ → Read task_plan.md # This brings goals back into attention!
199
+ → Now make the decision # Goals are fresh in context
200
+ ```
201
+
202
+ This is why Manus can handle ~50 tool calls without losing track. The plan file acts as a "goal refresh" mechanism.
@@ -0,0 +1,218 @@
1
+ # Reference: Manus Context Engineering Principles
2
+
3
+ This skill is based on context engineering principles from Manus, the AI agent company acquired by Meta for $2 billion in December 2025.
4
+
5
+ ## The 6 Manus Principles
6
+
7
+ ### Principle 1: Design Around KV-Cache
8
+
9
+ > "KV-cache hit rate is THE single most important metric for production AI agents."
10
+
11
+ **Statistics:**
12
+ - ~100:1 input-to-output token ratio
13
+ - Cached tokens: $0.30/MTok vs Uncached: $3/MTok
14
+ - 10x cost difference!
15
+
16
+ **Implementation:**
17
+ - Keep prompt prefixes STABLE (single-token change invalidates cache)
18
+ - NO timestamps in system prompts
19
+ - Make context APPEND-ONLY with deterministic serialization
20
+
21
+ ### Principle 2: Mask, Don't Remove
22
+
23
+ Don't dynamically remove tools (breaks KV-cache). Use logit masking instead.
24
+
25
+ **Best Practice:** Use consistent action prefixes (e.g., `browser_`, `shell_`, `file_`) for easier masking.
26
+
27
+ ### Principle 3: Filesystem as External Memory
28
+
29
+ > "Markdown is my 'working memory' on disk."
30
+
31
+ **The Formula:**
32
+ ```
33
+ Context Window = RAM (volatile, limited)
34
+ Filesystem = Disk (persistent, unlimited)
35
+ ```
36
+
37
+ **Compression Must Be Restorable:**
38
+ - Keep URLs even if web content is dropped
39
+ - Keep file paths when dropping document contents
40
+ - Never lose the pointer to full data
41
+
42
+ ### Principle 4: Manipulate Attention Through Recitation
43
+
44
+ > "Creates and updates todo.md throughout tasks to push global plan into model's recent attention span."
45
+
46
+ **Problem:** After ~50 tool calls, models forget original goals ("lost in the middle" effect).
47
+
48
+ **Solution:** Re-read `task_plan.md` before each decision. Goals appear in the attention window.
49
+
50
+ ```
51
+ Start of context: [Original goal - far away, forgotten]
52
+ ...many tool calls...
53
+ End of context: [Recently read task_plan.md - gets ATTENTION!]
54
+ ```
55
+
56
+ ### Principle 5: Keep the Wrong Stuff In
57
+
58
+ > "Leave the wrong turns in the context."
59
+
60
+ **Why:**
61
+ - Failed actions with stack traces let model implicitly update beliefs
62
+ - Reduces mistake repetition
63
+ - Error recovery is "one of the clearest signals of TRUE agentic behavior"
64
+
65
+ ### Principle 6: Don't Get Few-Shotted
66
+
67
+ > "Uniformity breeds fragility."
68
+
69
+ **Problem:** Repetitive action-observation pairs cause drift and hallucination.
70
+
71
+ **Solution:** Introduce controlled variation:
72
+ - Vary phrasings slightly
73
+ - Don't copy-paste patterns blindly
74
+ - Recalibrate on repetitive tasks
75
+
76
+ ---
77
+
78
+ ## The 3 Context Engineering Strategies
79
+
80
+ Based on Lance Martin's analysis of Manus architecture.
81
+
82
+ ### Strategy 1: Context Reduction
83
+
84
+ **Compaction:**
85
+ ```
86
+ Tool calls have TWO representations:
87
+ ├── FULL: Raw tool content (stored in filesystem)
88
+ └── COMPACT: Reference/file path only
89
+
90
+ RULES:
91
+ - Apply compaction to STALE (older) tool results
92
+ - Keep RECENT results FULL (to guide next decision)
93
+ ```
94
+
95
+ **Summarization:**
96
+ - Applied when compaction reaches diminishing returns
97
+ - Generated using full tool results
98
+ - Creates standardized summary objects
99
+
100
+ ### Strategy 2: Context Isolation (Multi-Agent)
101
+
102
+ **Architecture:**
103
+ ```
104
+ ┌─────────────────────────────────┐
105
+ │ PLANNER AGENT │
106
+ │ └─ Assigns tasks to sub-agents │
107
+ ├─────────────────────────────────┤
108
+ │ KNOWLEDGE MANAGER │
109
+ │ └─ Reviews conversations │
110
+ │ └─ Determines filesystem store │
111
+ ├─────────────────────────────────┤
112
+ │ EXECUTOR SUB-AGENTS │
113
+ │ └─ Perform assigned tasks │
114
+ │ └─ Have own context windows │
115
+ └─────────────────────────────────┘
116
+ ```
117
+
118
+ **Key Insight:** Manus originally used `todo.md` for task planning but found ~33% of actions were spent updating it. Shifted to dedicated planner agent calling executor sub-agents.
119
+
120
+ ### Strategy 3: Context Offloading
121
+
122
+ **Tool Design:**
123
+ - Use <20 atomic functions total
124
+ - Store full results in filesystem, not context
125
+ - Use `glob` and `grep` for searching
126
+ - Progressive disclosure: load information only as needed
127
+
128
+ ---
129
+
130
+ ## The Agent Loop
131
+
132
+ Manus operates in a continuous 7-step loop:
133
+
134
+ ```
135
+ ┌─────────────────────────────────────────┐
136
+ │ 1. ANALYZE CONTEXT │
137
+ │ - Understand user intent │
138
+ │ - Assess current state │
139
+ │ - Review recent observations │
140
+ ├─────────────────────────────────────────┤
141
+ │ 2. THINK │
142
+ │ - Should I update the plan? │
143
+ │ - What's the next logical action? │
144
+ │ - Are there blockers? │
145
+ ├─────────────────────────────────────────┤
146
+ │ 3. SELECT TOOL │
147
+ │ - Choose ONE tool │
148
+ │ - Ensure parameters available │
149
+ ├─────────────────────────────────────────┤
150
+ │ 4. EXECUTE ACTION │
151
+ │ - Tool runs in sandbox │
152
+ ├─────────────────────────────────────────┤
153
+ │ 5. RECEIVE OBSERVATION │
154
+ │ - Result appended to context │
155
+ ├─────────────────────────────────────────┤
156
+ │ 6. ITERATE │
157
+ │ - Return to step 1 │
158
+ │ - Continue until complete │
159
+ ├─────────────────────────────────────────┤
160
+ │ 7. DELIVER OUTCOME │
161
+ │ - Send results to user │
162
+ │ - Attach all relevant files │
163
+ └─────────────────────────────────────────┘
164
+ ```
165
+
166
+ ---
167
+
168
+ ## File Types Manus Creates
169
+
170
+ | File | Purpose | When Created | When Updated |
171
+ |------|---------|--------------|--------------|
172
+ | `task_plan.md` | Phase tracking, progress | Task start | After completing phases |
173
+ | `findings.md` | Discoveries, decisions | After ANY discovery | After viewing images/PDFs |
174
+ | `progress.md` | Session log, what's done | At breakpoints | Throughout session |
175
+ | Code files | Implementation | Before execution | After errors |
176
+
177
+ ---
178
+
179
+ ## Critical Constraints
180
+
181
+ - **Single-Action Execution:** ONE tool call per turn. No parallel execution.
182
+ - **Plan is Required:** Agent must ALWAYS know: goal, current phase, remaining phases
183
+ - **Files are Memory:** Context = volatile. Filesystem = persistent.
184
+ - **Never Repeat Failures:** If action failed, next action MUST be different
185
+ - **Communication is a Tool:** Message types: `info` (progress), `ask` (blocking), `result` (terminal)
186
+
187
+ ---
188
+
189
+ ## Manus Statistics
190
+
191
+ | Metric | Value |
192
+ |--------|-------|
193
+ | Average tool calls per task | ~50 |
194
+ | Input-to-output token ratio | 100:1 |
195
+ | Acquisition price | $2 billion |
196
+ | Time to $100M revenue | 8 months |
197
+ | Framework refactors since launch | 5 times |
198
+
199
+ ---
200
+
201
+ ## Key Quotes
202
+
203
+ > "Context window = RAM (volatile, limited). Filesystem = Disk (persistent, unlimited). Anything important gets written to disk."
204
+
205
+ > "if action_failed: next_action != same_action. Track what you tried. Mutate the approach."
206
+
207
+ > "Error recovery is one of the clearest signals of TRUE agentic behavior."
208
+
209
+ > "KV-cache hit rate is the single most important metric for a production-stage AI agent."
210
+
211
+ > "Leave the wrong turns in the context."
212
+
213
+ ---
214
+
215
+ ## Source
216
+
217
+ Based on Manus's official context engineering documentation:
218
+ https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ # Check if all phases in task_plan.md are complete
3
+ # Exit 0 if complete, exit 1 if incomplete
4
+ # Used by Stop hook to verify task completion
5
+
6
+ PLAN_FILE="${1:-task_plan.md}"
7
+
8
+ if [ ! -f "$PLAN_FILE" ]; then
9
+ echo "ERROR: $PLAN_FILE not found"
10
+ echo "Cannot verify completion without a task plan."
11
+ exit 1
12
+ fi
13
+
14
+ echo "=== Task Completion Check ==="
15
+ echo ""
16
+
17
+ # Count phases by status (using -F for fixed string matching)
18
+ TOTAL=$(grep -c "### Phase" "$PLAN_FILE" || true)
19
+ COMPLETE=$(grep -cF "**Status:** complete" "$PLAN_FILE" || true)
20
+ IN_PROGRESS=$(grep -cF "**Status:** in_progress" "$PLAN_FILE" || true)
21
+ PENDING=$(grep -cF "**Status:** pending" "$PLAN_FILE" || true)
22
+
23
+ # Default to 0 if empty
24
+ : "${TOTAL:=0}"
25
+ : "${COMPLETE:=0}"
26
+ : "${IN_PROGRESS:=0}"
27
+ : "${PENDING:=0}"
28
+
29
+ echo "Total phases: $TOTAL"
30
+ echo "Complete: $COMPLETE"
31
+ echo "In progress: $IN_PROGRESS"
32
+ echo "Pending: $PENDING"
33
+ echo ""
34
+
35
+ # Check completion
36
+ if [ "$COMPLETE" -eq "$TOTAL" ] && [ "$TOTAL" -gt 0 ]; then
37
+ echo "ALL PHASES COMPLETE"
38
+ exit 0
39
+ else
40
+ echo "TASK NOT COMPLETE"
41
+ echo ""
42
+ echo "Do not stop until all phases are complete."
43
+ exit 1
44
+ fi