@el-j/magic-helix-plugins 4.0.0-beta.2 → 4.0.0-beta.3

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 (120) hide show
  1. package/dist/architecture/codeowners.md +123 -0
  2. package/dist/architecture/monorepo.md +146 -0
  3. package/dist/architecture/nx.md +122 -0
  4. package/dist/architecture/turborepo.md +114 -0
  5. package/dist/ci/github-actions.md +268 -0
  6. package/dist/ci/gitlab-ci.md +330 -0
  7. package/dist/containers/docker-multistage.md +120 -0
  8. package/dist/containers/kubernetes-deploy.md +210 -0
  9. package/dist/cpp/index.cjs +79 -0
  10. package/dist/cpp/index.mjs +209 -0
  11. package/dist/csharp/index.cjs +2 -2
  12. package/dist/csharp/{index.js → index.mjs} +17 -11
  13. package/dist/csharp/templates/framework-aspnetcore.md +205 -0
  14. package/dist/csharp/templates/framework-blazor.md +271 -0
  15. package/dist/csharp/templates/lang-csharp.md +162 -0
  16. package/dist/devops/docker-compose.md +111 -0
  17. package/dist/devops/docker-dockerfile.md +94 -0
  18. package/dist/devops/github-actions.md +160 -0
  19. package/dist/devops/gitlab-ci.md +210 -0
  20. package/dist/generic/lang-typescript.md +57 -0
  21. package/dist/generic/state-redux.md +21 -0
  22. package/dist/generic/state-rxjs.md +6 -0
  23. package/dist/generic/style-mui.md +23 -0
  24. package/dist/generic/style-tailwind.md +76 -0
  25. package/dist/generic/test-cypress.md +21 -0
  26. package/dist/generic/test-jest.md +20 -0
  27. package/dist/generic/test-playwright.md +21 -0
  28. package/dist/generic/test-vitest.md +131 -0
  29. package/dist/go/index.cjs +3 -3
  30. package/dist/go/{index.js → index.mjs} +18 -15
  31. package/dist/go/templates/lang-go.md +571 -0
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.mjs +24 -0
  34. package/dist/java/index.cjs +2 -2
  35. package/dist/java/{index.js → index.mjs} +25 -19
  36. package/dist/java/templates/build-gradle.md +102 -0
  37. package/dist/java/templates/build-maven.md +86 -0
  38. package/dist/java/templates/framework-spring-boot.md +179 -0
  39. package/dist/java/templates/lang-java.md +78 -0
  40. package/dist/java/templates/lang-kotlin.md +88 -0
  41. package/dist/meta/magic-helix-meta.md +213 -0
  42. package/dist/meta/meta-debug.md +459 -0
  43. package/dist/meta/meta-implement.md +450 -0
  44. package/dist/meta/meta-roadmap.md +265 -0
  45. package/dist/nodejs/templates/angular-core.md +19 -0
  46. package/dist/nodejs/templates/lang-typescript.md +57 -0
  47. package/dist/nodejs/templates/nestjs-core.md +7 -0
  48. package/dist/nodejs/templates/react-core.md +677 -0
  49. package/dist/nodejs/templates/react-zustand.md +7 -0
  50. package/dist/nodejs/templates/state-redux.md +21 -0
  51. package/dist/nodejs/templates/state-rxjs.md +6 -0
  52. package/dist/nodejs/templates/style-primevue.md +6 -0
  53. package/dist/nodejs/templates/style-quasar.md +22 -0
  54. package/dist/nodejs/templates/style-tailwind.md +76 -0
  55. package/dist/nodejs/templates/test-cypress.md +21 -0
  56. package/dist/nodejs/templates/test-jest.md +20 -0
  57. package/dist/nodejs/templates/test-playwright.md +21 -0
  58. package/dist/nodejs/templates/test-vitest.md +131 -0
  59. package/dist/nodejs/templates/vue-core.md +108 -0
  60. package/dist/nodejs/templates/vue-pinia.md +5 -0
  61. package/dist/patterns/architecture/clean-architecture.md +469 -0
  62. package/dist/patterns/architecture/dependency-injection.md +517 -0
  63. package/dist/patterns/architecture/domain-driven-design.md +621 -0
  64. package/dist/patterns/architecture/layered-architecture.md +382 -0
  65. package/dist/patterns/architecture/repository-pattern.md +408 -0
  66. package/dist/patterns/domain-expertise/nextjs-rules.md +115 -0
  67. package/dist/patterns/domain-expertise/react-patterns.md +181 -0
  68. package/dist/patterns/domain-expertise/server-components.md +212 -0
  69. package/dist/patterns/domain-expertise/shadcn-ui.md +52 -0
  70. package/dist/patterns/domain-expertise/tailwind-patterns.md +52 -0
  71. package/dist/patterns/environment/container-awareness.md +17 -0
  72. package/dist/patterns/environment/ide-features.md +17 -0
  73. package/dist/patterns/environment/os-commands.md +17 -0
  74. package/dist/patterns/organization/heading-hierarchy.md +103 -0
  75. package/dist/patterns/organization/sequential-workflows.md +102 -0
  76. package/dist/patterns/organization/xml-rule-groups.md +64 -0
  77. package/dist/patterns/reasoning/agent-loop.md +151 -0
  78. package/dist/patterns/reasoning/confirmation-gates.md +141 -0
  79. package/dist/patterns/reasoning/dependency-analysis.md +132 -0
  80. package/dist/patterns/reasoning/one-tool-per-iteration.md +152 -0
  81. package/dist/patterns/reasoning/preview-before-action.md +194 -0
  82. package/dist/patterns/reasoning/reflection-checkpoints.md +166 -0
  83. package/dist/patterns/reasoning/result-verification.md +157 -0
  84. package/dist/patterns/reasoning/subtask-breakdown.md +131 -0
  85. package/dist/patterns/reasoning/thinking-tags.md +100 -0
  86. package/dist/patterns/role-definition/capability-declarations.md +72 -0
  87. package/dist/patterns/role-definition/expert-identity.md +45 -0
  88. package/dist/patterns/role-definition/scope-boundaries.md +61 -0
  89. package/dist/patterns/safety/code-safety-rules.md +17 -0
  90. package/dist/patterns/safety/credential-handling.md +17 -0
  91. package/dist/patterns/safety/destructive-warnings.md +17 -0
  92. package/dist/patterns/safety/refusal-messages.md +17 -0
  93. package/dist/patterns/tone/adaptive-tone.md +17 -0
  94. package/dist/patterns/tone/concise-communication.md +17 -0
  95. package/dist/patterns/tone/forbidden-phrases.md +17 -0
  96. package/dist/patterns/tool-guidelines/function-schemas.md +143 -0
  97. package/dist/patterns/tool-guidelines/parameter-examples.md +137 -0
  98. package/dist/patterns/tool-guidelines/usage-policies.md +105 -0
  99. package/dist/php/index.cjs +2 -2
  100. package/dist/php/{index.js → index.mjs} +12 -6
  101. package/dist/php/templates/framework-laravel.md +112 -0
  102. package/dist/php/templates/lang-php.md +94 -0
  103. package/dist/python/index.cjs +4 -4
  104. package/dist/python/{index.js → index.mjs} +10 -7
  105. package/dist/python/templates/lang-python.md +508 -0
  106. package/dist/ruby/index.cjs +2 -2
  107. package/dist/ruby/{index.js → index.mjs} +16 -10
  108. package/dist/ruby/templates/framework-rails.md +309 -0
  109. package/dist/ruby/templates/framework-sinatra.md +227 -0
  110. package/dist/ruby/templates/lang-ruby.md +216 -0
  111. package/dist/rust/index.cjs +3 -3
  112. package/dist/rust/{index.js → index.mjs} +24 -18
  113. package/dist/rust/templates/lang-rust.md +89 -0
  114. package/dist/swift/index.cjs +32 -0
  115. package/dist/swift/index.mjs +112 -0
  116. package/dist/swift/templates/framework-vapor.md +352 -0
  117. package/dist/swift/templates/lang-swift.md +291 -0
  118. package/package.json +31 -21
  119. package/dist/index.js +0 -20
  120. /package/dist/nodejs/{index.js → index.mjs} +0 -0
@@ -0,0 +1,151 @@
1
+ # Agent Loop Pattern
2
+
3
+ ## Purpose
4
+ Define iterative execution cycle for autonomous agents. From **Manus** pattern.
5
+
6
+ ## Template
7
+
8
+ ```markdown
9
+ ## Agent Execution Loop
10
+
11
+ Repeat the following cycle until goal is achieved:
12
+
13
+ ### 1. Observe
14
+ - Read current state: {WHAT_TO_CHECK}
15
+ - Identify changes: {WHAT_CHANGED_SINCE_LAST_ITERATION}
16
+ - Note user input: {NEW_REQUIREMENTS_OR_FEEDBACK}
17
+
18
+ ### 2. Orient
19
+ - Assess progress: {HOW_CLOSE_TO_GOAL}
20
+ - Identify blockers: {WHAT_IS_PREVENTING_COMPLETION}
21
+ - Update plan: {ADJUST_STRATEGY_IF_NEEDED}
22
+
23
+ ### 3. Decide
24
+ - Select next action: {WHICH_TOOL_OR_OPERATION}
25
+ - Validate feasibility: {CAN_THIS_ACTION_SUCCEED}
26
+ - Prepare parameters: {GATHER_REQUIRED_INPUTS}
27
+
28
+ ### 4. Act
29
+ - Execute selected action: {CALL_TOOL_OR_PERFORM_OPERATION}
30
+ - Capture results: {STORE_OUTPUT_FOR_NEXT_ITERATION}
31
+ - Handle errors: {RETRY_OR_FALLBACK_IF_FAILED}
32
+
33
+ ### 5. Reflect
34
+ - Evaluate outcome: {DID_ACTION_ACHIEVE_INTENDED_EFFECT}
35
+ - Learn from result: {UPDATE_KNOWLEDGE_OR_ASSUMPTIONS}
36
+ - Decide continuation: {REPEAT_LOOP_OR_TERMINATE}
37
+
38
+ **Termination Conditions**:
39
+ - Goal achieved: {SUCCESS_CRITERIA_MET}
40
+ - Unrecoverable error: {CANNOT_PROCEED_FURTHER}
41
+ - Max iterations reached: {SAFETY_LIMIT_HIT}
42
+ - User interruption: {USER_REQUESTED_STOP}
43
+ ```
44
+
45
+ ## Examples
46
+
47
+ ### Manus (Code Debugging Loop)
48
+ ```markdown
49
+ ## Agent Execution Loop: Debug and Fix Error
50
+
51
+ Repeat the following cycle until error is resolved:
52
+
53
+ ### 1. Observe
54
+ - Read current state: Error message, stack trace, failed test output
55
+ - Identify changes: What code was just modified?
56
+ - Note user input: Any hints or context provided?
57
+
58
+ ### 2. Orient
59
+ - Assess progress: Is error message clearer than before?
60
+ - Identify blockers: Missing dependencies? Syntax errors? Logic bugs?
61
+ - Update plan: Do we need to install packages, fix imports, or rewrite logic?
62
+
63
+ ### 3. Decide
64
+ - Select next action: Read error source file, check imports, run tests
65
+ - Validate feasibility: Do we have file path? Are tools available?
66
+ - Prepare parameters: File path, line numbers, test command
67
+
68
+ ### 4. Act
69
+ - Execute selected action: `read_file(errorFile, errorLine-5, errorLine+5)`
70
+ - Capture results: Store file contents, understand context
71
+ - Handle errors: If file not found, search for similar files
72
+
73
+ ### 5. Reflect
74
+ - Evaluate outcome: Does file content reveal the issue?
75
+ - Learn from result: Update mental model of codebase
76
+ - Decide continuation: If root cause found, apply fix; else investigate deeper
77
+
78
+ **Termination Conditions**:
79
+ - Goal achieved: Tests pass, error no longer occurs
80
+ - Unrecoverable error: Required file deleted, system-level issue
81
+ - Max iterations reached: 10 loops without progress (escalate to user)
82
+ - User interruption: User provides new direction or cancels
83
+ ```
84
+
85
+ ### same.new (Feature Implementation Loop)
86
+ ```markdown
87
+ ## Agent Execution Loop: Build Feature
88
+
89
+ Repeat the following cycle until feature is complete:
90
+
91
+ ### 1. Observe
92
+ - Read current state: Existing components, dependencies, file structure
93
+ - Identify changes: What was just created/modified?
94
+ - Note user input: Feature requirements, design preferences
95
+
96
+ ### 2. Orient
97
+ - Assess progress: Which components are done? What's remaining?
98
+ - Identify blockers: Missing libraries? Unclear requirements?
99
+ - Update plan: Break feature into smaller components if needed
100
+
101
+ ### 3. Decide
102
+ - Select next action: Create component, install package, write test
103
+ - Validate feasibility: Do we have design? Dependencies available?
104
+ - Prepare parameters: Component name, props, styling approach
105
+
106
+ ### 4. Act
107
+ - Execute selected action: `create_file(ComponentName.tsx, content)`
108
+ - Capture results: Store component path for imports
109
+ - Handle errors: If file exists, modify instead of create
110
+
111
+ ### 5. Reflect
112
+ - Evaluate outcome: Does component match requirements?
113
+ - Learn from result: Note patterns for similar components
114
+ - Decide continuation: If feature incomplete, build next piece; else finalize
115
+
116
+ **Termination Conditions**:
117
+ - Goal achieved: Feature works, tests pass, user approves
118
+ - Unrecoverable error: Conflicting requirements, impossible constraints
119
+ - Max iterations reached: 20 loops (feature too complex, break down further)
120
+ - User interruption: User requests changes or different feature
121
+ ```
122
+
123
+ ## Variables
124
+ - `{WHAT_TO_CHECK}`: State to examine each iteration
125
+ - `{WHAT_CHANGED_SINCE_LAST_ITERATION}`: Delta from previous cycle
126
+ - `{NEW_REQUIREMENTS_OR_FEEDBACK}`: User input to incorporate
127
+ - `{HOW_CLOSE_TO_GOAL}`: Progress measurement
128
+ - `{WHAT_IS_PREVENTING_COMPLETION}`: Blockers/dependencies
129
+ - `{ADJUST_STRATEGY_IF_NEEDED}`: Plan modifications
130
+ - `{WHICH_TOOL_OR_OPERATION}`: Next action to take
131
+ - `{CAN_THIS_ACTION_SUCCEED}`: Feasibility check
132
+ - `{GATHER_REQUIRED_INPUTS}`: Parameter preparation
133
+ - `{CALL_TOOL_OR_PERFORM_OPERATION}`: Execution step
134
+ - `{STORE_OUTPUT_FOR_NEXT_ITERATION}`: Result capture
135
+ - `{RETRY_OR_FALLBACK_IF_FAILED}`: Error handling
136
+ - `{DID_ACTION_ACHIEVE_INTENDED_EFFECT}`: Outcome evaluation
137
+ - `{UPDATE_KNOWLEDGE_OR_ASSUMPTIONS}`: Learning
138
+ - `{REPEAT_LOOP_OR_TERMINATE}`: Continuation decision
139
+ - `{SUCCESS_CRITERIA_MET}`: Goal achieved condition
140
+ - `{CANNOT_PROCEED_FURTHER}`: Unrecoverable error condition
141
+ - `{SAFETY_LIMIT_HIT}`: Max iterations condition
142
+ - `{USER_REQUESTED_STOP}`: User interruption condition
143
+
144
+ ## Best Practices
145
+ 1. Use OODA framework (Observe, Orient, Decide, Act) + Reflect
146
+ 2. One tool call per iteration (no parallel in loop)
147
+ 3. State termination conditions explicitly
148
+ 4. Include safety limit (max iterations)
149
+ 5. Capture learnings between iterations
150
+ 6. Allow user interruption at any point
151
+ 7. Benefits: Autonomous operation, adaptability, progress tracking, safety bounds
@@ -0,0 +1,141 @@
1
+ # Confirmation Gates Pattern
2
+
3
+ ## Purpose
4
+ Require user approval before destructive or high-impact operations. From **same.new** and **Cline** patterns.
5
+
6
+ ## Template
7
+
8
+ ```markdown
9
+ ## Confirmation Gates
10
+
11
+ Before executing {OPERATION_TYPE}, show preview and wait for approval:
12
+
13
+ ### Operations Requiring Confirmation
14
+ - **File Deletion**: {LIST_FILES_TO_DELETE}
15
+ - **Overwrite**: {SHOW_DIFF_OLD_VS_NEW}
16
+ - **Bulk Changes**: {SUMMARIZE_SCOPE_AND_IMPACT}
17
+ - **Destructive Commands**: {EXPLAIN_WHAT_WILL_BE_LOST}
18
+
19
+ ### Confirmation Format
20
+ ```
21
+ ⚠️ **Confirmation Required**
22
+
23
+ **Operation**: {OPERATION_NAME}
24
+ **Impact**: {WHAT_WILL_CHANGE}
25
+ **Files Affected**: {COUNT_AND_LIST}
26
+
27
+ **Preview**:
28
+ {SHOW_BEFORE_AFTER_OR_DIFF}
29
+
30
+ Proceed? (yes/no)
31
+ ```
32
+ ```
33
+
34
+ ## Examples
35
+
36
+ ### same.new (File Overwrite)
37
+ ```markdown
38
+ ## Confirmation Gates: File Operations
39
+
40
+ Before overwriting existing files, show diff and wait for approval:
41
+
42
+ ⚠️ **Confirmation Required**
43
+
44
+ **Operation**: Overwrite `src/components/Button.tsx`
45
+ **Impact**: Existing component will be replaced
46
+ **Files Affected**: 1 file
47
+
48
+ **Preview (diff)**:
49
+ ```diff
50
+ - export const Button = ({ label }: ButtonProps) => {
51
+ - return <button className="btn">{label}</button>;
52
+ + export const Button = ({ children, variant = 'primary' }: ButtonProps) => {
53
+ + return <button className={`btn btn-${variant}`}>{children}</button>;
54
+ };
55
+ ```
56
+
57
+ **Risk Assessment**:
58
+ - ✅ TypeScript types will catch breaking changes
59
+ - ⚠️ Existing usages with `label` prop will need updates
60
+ - ℹ️ Found 8 files importing this component
61
+
62
+ Proceed? (yes/no)
63
+ ```
64
+
65
+ ### Cline (Bulk Deletion)
66
+ ```markdown
67
+ ## Confirmation Gates: Destructive Operations
68
+
69
+ Before deleting multiple files, show impact and wait for approval:
70
+
71
+ ⚠️ **Confirmation Required**
72
+
73
+ **Operation**: Delete unused test fixtures
74
+ **Impact**: 12 files will be permanently deleted
75
+ **Files Affected**:
76
+ - tests/fixtures/user-data.json
77
+ - tests/fixtures/product-catalog.json
78
+ - tests/fixtures/old-api-response.json
79
+ - ... (9 more files)
80
+
81
+ **Risk Assessment**:
82
+ - ⚠️ **WARNING**: This cannot be undone unless files are in git
83
+ - ✅ Git status: All files committed (can recover from history)
84
+ - ℹ️ These files are not referenced in any test files
85
+
86
+ **Recommended Action**: Review list carefully before confirming
87
+
88
+ Proceed? (yes/no)
89
+ ```
90
+
91
+ ### ChatGPT (Credential Exposure)
92
+ ```markdown
93
+ ## Confirmation Gates: Security Risk
94
+
95
+ Before generating code with sensitive data, warn and request confirmation:
96
+
97
+ ⚠️ **Confirmation Required**
98
+
99
+ **Operation**: Generate API client with authentication
100
+ **Impact**: Code will include authentication logic
101
+ **Security Risk**: HIGH
102
+
103
+ **Warning**:
104
+ - ❌ NEVER hardcode API keys in code
105
+ - ❌ NEVER commit credentials to git
106
+ - ✅ Use environment variables (.env file)
107
+ - ✅ Add .env to .gitignore
108
+
109
+ **Proposed Implementation**:
110
+ ```typescript
111
+ const apiKey = process.env.API_KEY; // ✅ From environment
112
+ // NOT: const apiKey = 'sk-abc123...'; // ❌ Hardcoded
113
+ ```
114
+
115
+ I will generate code using environment variables. Proceed? (yes/no)
116
+ ```
117
+
118
+ ## Variables
119
+ - `{OPERATION_TYPE}`: Category of operation (delete, overwrite, bulk edit)
120
+ - `{LIST_FILES_TO_DELETE}`: Affected file paths
121
+ - `{SHOW_DIFF_OLD_VS_NEW}`: Side-by-side or unified diff
122
+ - `{SUMMARIZE_SCOPE_AND_IMPACT}`: How many files, what changes
123
+ - `{EXPLAIN_WHAT_WILL_BE_LOST}`: Data that can't be recovered
124
+ - `{OPERATION_NAME}`: Specific action (e.g., "Delete 12 test fixtures")
125
+ - `{WHAT_WILL_CHANGE}`: User-facing description
126
+ - `{COUNT_AND_LIST}`: Number and paths
127
+ - `{SHOW_BEFORE_AFTER_OR_DIFF}`: Visual comparison
128
+
129
+ ## Best Practices
130
+ 1. Always show confirmation for:
131
+ - File/directory deletion
132
+ - Overwriting existing files (unless explicitly replacing)
133
+ - Running commands with sudo/admin privileges
134
+ - Exposing credentials or secrets
135
+ - Bulk operations (>5 files)
136
+ 2. Include risk assessment (✅ safe, ⚠️ warning, ❌ danger)
137
+ 3. Explain what can't be undone vs. what's recoverable
138
+ 4. Show concrete preview (diff, file list, command output)
139
+ 5. Suggest safer alternatives when applicable
140
+ 6. Wait for explicit "yes" (don't proceed on silence)
141
+ 7. Benefits: Prevents accidents, builds trust, surfaces unintended consequences
@@ -0,0 +1,132 @@
1
+ # Dependency Analysis Pattern
2
+
3
+ ## Purpose
4
+ Identify prerequisites, conflicts, and ordering constraints. From **Bolt.new** and **same.new** patterns.
5
+
6
+ ## Template
7
+
8
+ ```markdown
9
+ ## Dependency Analysis
10
+
11
+ ### Direct Dependencies
12
+ - {COMPONENT_A} requires {COMPONENT_B}
13
+ - {COMPONENT_C} requires {COMPONENT_D}
14
+
15
+ ### Transitive Dependencies
16
+ - {COMPONENT_A} → {COMPONENT_B} → {COMPONENT_E}
17
+
18
+ ### Conflicts
19
+ - {PACKAGE_X} v{VERSION_1} conflicts with {PACKAGE_Y} v{VERSION_2}
20
+ - Resolution: {HOW_TO_RESOLVE}
21
+
22
+ ### Execution Order
23
+ ```mermaid
24
+ graph TD
25
+ A[{TASK_A}] --> B[{TASK_B}]
26
+ A --> C[{TASK_C}]
27
+ B --> D[{TASK_D}]
28
+ C --> D
29
+ ```
30
+ ```
31
+
32
+ ## Examples
33
+
34
+ ### Bolt.new (Package Dependencies)
35
+ ```markdown
36
+ ## Dependency Analysis: Adding Prisma ORM
37
+
38
+ ### Direct Dependencies
39
+ - Prisma Client requires `@prisma/client` package
40
+ - Prisma CLI requires `prisma` as dev dependency
41
+ - Database adapter requires PostgreSQL client
42
+
43
+ ### Transitive Dependencies
44
+ - `@prisma/client` → database driver (pg, mysql2, etc.)
45
+ - Prisma CLI → Node.js runtime (>= 16.13.0)
46
+ - Database migrations → existing database connection
47
+
48
+ ### Conflicts
49
+ - `@prisma/client` v5.x conflicts with Next.js v12 (uses CommonJS)
50
+ - Resolution: Upgrade to Next.js v13+ (supports ESM) or use Prisma v4.x
51
+
52
+ ### Installation Order
53
+ 1. Install Prisma CLI (`npm i -D prisma`)
54
+ 2. Initialize Prisma (`npx prisma init`)
55
+ 3. Define schema (`schema.prisma`)
56
+ 4. Run migrations (`npx prisma migrate dev`)
57
+ 5. Install client (`npm i @prisma/client`)
58
+ 6. Generate client (`npx prisma generate`)
59
+
60
+ ### Why This Order?
61
+ - CLI needed before `init` command
62
+ - Schema must exist before migrations
63
+ - Migrations create database tables
64
+ - Client generated from schema
65
+ ```
66
+
67
+ ### same.new (Component Dependencies)
68
+ ```markdown
69
+ ## Dependency Analysis: Building Dashboard Layout
70
+
71
+ ### Direct Dependencies
72
+ - `Dashboard` requires `Sidebar` component
73
+ - `Dashboard` requires `TopNav` component
74
+ - `Sidebar` requires `NavLink` component
75
+ - `TopNav` requires `UserMenu` component
76
+
77
+ ### Transitive Dependencies
78
+ - `Dashboard` → `Sidebar` → `NavLink` → `Icon` component
79
+ - `Dashboard` → `TopNav` → `UserMenu` → `Avatar` component
80
+ - All components → `ThemeProvider` context
81
+
82
+ ### Conflicts
83
+ - `Sidebar` uses fixed positioning (overlaps main content on mobile)
84
+ - `TopNav` uses sticky positioning (z-index conflict with modals)
85
+ - Resolution: Establish z-index scale (nav: 100, sidebar: 200, modal: 1000)
86
+
87
+ ### Build Order
88
+ ```mermaid
89
+ graph TD
90
+ A[Icon] --> B[NavLink]
91
+ C[Avatar] --> D[UserMenu]
92
+ B --> E[Sidebar]
93
+ D --> F[TopNav]
94
+ E --> G[Dashboard]
95
+ F --> G
96
+ H[ThemeProvider] --> G
97
+ ```
98
+
99
+ 1. Build leaf components (`Icon`, `Avatar`)
100
+ 2. Build composed components (`NavLink`, `UserMenu`)
101
+ 3. Build layout sections (`Sidebar`, `TopNav`)
102
+ 4. Build container (`Dashboard`)
103
+ 5. Wrap in `ThemeProvider`
104
+
105
+ ### Why This Order?
106
+ - Leaf components have no dependencies (can build first)
107
+ - Composed components need leaf components (build after)
108
+ - Layout sections need composed components (build after)
109
+ - Container orchestrates sections (build last)
110
+ - Provider wraps everything (applied at root)
111
+ ```
112
+
113
+ ## Variables
114
+ - `{COMPONENT_X}`: Module, package, or component
115
+ - `{VERSION_X}`: Specific version number
116
+ - `{TASK_X}`: Operation or build step
117
+ - `{HOW_TO_RESOLVE}`: Conflict resolution strategy
118
+
119
+ ## Best Practices
120
+ 1. Distinguish direct vs transitive dependencies
121
+ 2. Identify circular dependencies early (impossible to resolve)
122
+ 3. Document version constraints (>=, ^, ~)
123
+ 4. Explain *why* order matters (not just *what* order)
124
+ 5. Visualize complex dependency graphs (Mermaid, ASCII)
125
+ 6. Plan for missing dependencies (install, create, mock)
126
+ 7. Benefits: Prevents build failures, enables parallel work, surfaces conflicts early
127
+
128
+ ## Implementation Notes
129
+ - Run dependency analysis before starting multi-component builds
130
+ - Update analysis when adding new dependencies
131
+ - Use package manager output to verify constraints (`npm ls`, `pnpm why`)
132
+ - Check for peer dependency warnings (often indicate conflicts)
@@ -0,0 +1,152 @@
1
+ # One Tool Per Iteration Pattern
2
+
3
+ ## Purpose
4
+ Enforce sequential tool usage to maintain state consistency. From **Manus** and **Cline** patterns.
5
+
6
+ ## Template
7
+
8
+ ```markdown
9
+ ## Tool Execution Policy
10
+
11
+ Execute tools sequentially, one per iteration:
12
+
13
+ 1. **Select One Tool**: Choose single tool based on current state
14
+ 2. **Gather Parameters**: Collect all required inputs for that tool
15
+ 3. **Execute**: Call the tool and wait for completion
16
+ 4. **Process Results**: Analyze output before next action
17
+ 5. **Repeat**: Select next tool based on new state
18
+
19
+ **Never**:
20
+ - Call multiple tools in parallel within the agent loop
21
+ - Assume tool output without checking
22
+ - Chain tools without validating intermediate results
23
+ ```
24
+
25
+ ## Examples
26
+
27
+ ### Manus (File Analysis)
28
+ ```markdown
29
+ ## Tool Execution Policy: Analyze Codebase
30
+
31
+ Execute tools sequentially, one per iteration:
32
+
33
+ **Iteration 1**: Search for files
34
+ ```
35
+ tool: file_search
36
+ params: { pattern: "**/*.ts" }
37
+ result: [src/app.ts, src/utils.ts, src/config.ts]
38
+ next_action: Read first file
39
+ ```
40
+
41
+ **Iteration 2**: Read primary file
42
+ ```
43
+ tool: read_file
44
+ params: { path: "src/app.ts", startLine: 1, endLine: 100 }
45
+ result: Contains import from "./utils"
46
+ next_action: Read dependency
47
+ ```
48
+
49
+ **Iteration 3**: Read dependency file
50
+ ```
51
+ tool: read_file
52
+ params: { path: "src/utils.ts", startLine: 1, endLine: 50 }
53
+ result: Contains helper functions
54
+ next_action: Analyze config
55
+ ```
56
+
57
+ **Why Sequential?**
58
+ - Iteration 2 revealed dependency on utils.ts (couldn't predict before iteration 1)
59
+ - Iteration 3 needed based on imports found in iteration 2
60
+ - Parallel calls would miss these dependencies
61
+ ```
62
+
63
+ ### Cline (Debugging Workflow)
64
+ ```markdown
65
+ ## Tool Execution Policy: Fix Runtime Error
66
+
67
+ Execute tools sequentially, one per iteration:
68
+
69
+ **Iteration 1**: Search for error in logs
70
+ ```
71
+ tool: grep_search
72
+ params: { query: "Error: Module not found", isRegexp: false }
73
+ result: Found in src/components/Header.tsx line 5
74
+ next_action: Read file with error
75
+ ```
76
+
77
+ **Iteration 2**: Read file containing error
78
+ ```
79
+ tool: read_file
80
+ params: { path: "src/components/Header.tsx", startLine: 1, endLine: 20 }
81
+ result: import { Button } from '@/components/ui/button'
82
+ next_action: Check if file exists
83
+ ```
84
+
85
+ **Iteration 3**: Verify imported file exists
86
+ ```
87
+ tool: file_search
88
+ params: { pattern: "**/ui/button.*" }
89
+ result: src/components/ui/Button.tsx (capital B!)
90
+ next_action: Fix import path
91
+ ```
92
+
93
+ **Iteration 4**: Correct the import
94
+ ```
95
+ tool: replace_string_in_file
96
+ params: {
97
+ path: "src/components/Header.tsx",
98
+ oldString: "from '@/components/ui/button'",
99
+ newString: "from '@/components/ui/Button'"
100
+ }
101
+ result: File updated successfully
102
+ next_action: Verify build passes
103
+ ```
104
+
105
+ **Why Sequential?**
106
+ - Couldn't identify file path until grep found it (iteration 1)
107
+ - Couldn't determine fix until seeing actual import (iteration 2)
108
+ - Couldn't know correct path until searching filesystem (iteration 3)
109
+ - Each step informed the next action
110
+ ```
111
+
112
+ ## When to Break This Rule
113
+
114
+ ### Parallel Reads (Cline Exception)
115
+ ```markdown
116
+ **Allowed**: Reading multiple independent files
117
+ ```
118
+ tools: [
119
+ read_file({ path: "src/app.ts", startLine: 1, endLine: 50 }),
120
+ read_file({ path: "src/config.ts", startLine: 1, endLine: 30 }),
121
+ read_file({ path: "tests/app.test.ts", startLine: 1, endLine: 40 })
122
+ ]
123
+ ```
124
+
125
+ **Why Allowed?**
126
+ - Files are known to exist (from previous search)
127
+ - No dependencies between reads
128
+ - Just gathering context, not modifying state
129
+ - Significantly faster than 3 sequential iterations
130
+
131
+ **Not Allowed**: Reading files discovered during search
132
+ - Risk: Files might not exist or might not contain expected content
133
+ - Better: Read first file, validate, then read others if needed
134
+ ```
135
+
136
+ ## Variables
137
+ - N/A (this is a process pattern, not a template)
138
+
139
+ ## Best Practices
140
+ 1. One tool call per iteration in agent loops
141
+ 2. Validate tool output before next call
142
+ 3. Exception: Parallel reads when files are pre-validated
143
+ 4. Never parallelize: writes, terminal commands, state-changing operations
144
+ 5. Use tool output to inform next tool selection
145
+ 6. Document why each tool was chosen (reasoning chain)
146
+ 7. Benefits: Predictable state, easier debugging, adaptive execution
147
+
148
+ ## Implementation Notes
149
+ - Most models naturally follow this pattern
150
+ - Explicitly state in system prompt to prevent parallel tool abuse
151
+ - Useful for autonomous agents (Manus, Cline, Augment)
152
+ - Less critical for user-directed agents (v0, same.new) where user provides guidance between steps