fraim-framework 2.0.26 → 2.0.30

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 (104) hide show
  1. package/.github/workflows/deploy-fraim.yml +1 -1
  2. package/dist/registry/scripts/build-scripts-generator.js +205 -0
  3. package/dist/registry/scripts/cleanup-branch.js +258 -0
  4. package/dist/registry/scripts/evaluate-code-quality.js +66 -0
  5. package/dist/registry/scripts/exec-with-timeout.js +142 -0
  6. package/dist/registry/scripts/fraim-config.js +61 -0
  7. package/dist/registry/scripts/generate-engagement-emails.js +630 -0
  8. package/dist/registry/scripts/generic-issues-api.js +100 -0
  9. package/dist/registry/scripts/newsletter-helpers.js +731 -0
  10. package/dist/registry/scripts/openapi-generator.js +664 -0
  11. package/dist/registry/scripts/performance/profile-server.js +390 -0
  12. package/dist/registry/scripts/run-thank-you-workflow.js +92 -0
  13. package/dist/registry/scripts/send-newsletter-simple.js +85 -0
  14. package/dist/registry/scripts/send-thank-you-emails.js +54 -0
  15. package/dist/registry/scripts/validate-openapi-limits.js +311 -0
  16. package/dist/registry/scripts/validate-test-coverage.js +262 -0
  17. package/dist/registry/scripts/verify-test-coverage.js +66 -0
  18. package/dist/src/cli/commands/init.js +14 -12
  19. package/dist/src/cli/commands/sync.js +19 -2
  20. package/dist/src/cli/fraim.js +24 -22
  21. package/dist/src/cli/setup/first-run.js +13 -6
  22. package/dist/src/fraim/config-loader.js +0 -8
  23. package/dist/src/fraim/db-service.js +26 -15
  24. package/dist/src/fraim/issues.js +67 -0
  25. package/dist/src/fraim/setup-wizard.js +1 -69
  26. package/dist/src/fraim/types.js +0 -11
  27. package/dist/src/fraim-mcp-server.js +272 -18
  28. package/dist/src/utils/git-utils.js +1 -1
  29. package/dist/src/utils/version-utils.js +32 -0
  30. package/dist/tests/debug-tools.js +79 -0
  31. package/dist/tests/esm-compat.js +11 -0
  32. package/dist/tests/test-chalk-esm-issue.js +159 -0
  33. package/dist/tests/test-chalk-real-world.js +265 -0
  34. package/dist/tests/test-chalk-regression.js +327 -0
  35. package/dist/tests/test-chalk-resolution-issue.js +304 -0
  36. package/dist/tests/test-cli.js +0 -2
  37. package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
  38. package/dist/tests/test-fraim-issues.js +59 -0
  39. package/dist/tests/test-genericization.js +1 -3
  40. package/dist/tests/test-mcp-connection.js +166 -0
  41. package/dist/tests/test-mcp-issue-integration.js +144 -0
  42. package/dist/tests/test-mcp-lifecycle-methods.js +312 -0
  43. package/dist/tests/test-node-compatibility.js +71 -0
  44. package/dist/tests/test-npm-install.js +66 -0
  45. package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
  46. package/dist/tests/test-session-rehydration.js +145 -0
  47. package/dist/tests/test-standalone.js +2 -8
  48. package/dist/tests/test-sync-version-update.js +93 -0
  49. package/dist/tests/test-telemetry.js +190 -0
  50. package/package.json +10 -8
  51. package/registry/agent-guardrails.md +62 -54
  52. package/registry/rules/agent-success-criteria.md +52 -0
  53. package/registry/rules/agent-testing-guidelines.md +502 -502
  54. package/registry/rules/communication.md +121 -121
  55. package/registry/rules/continuous-learning.md +54 -54
  56. package/registry/rules/ephemeral-execution.md +10 -5
  57. package/registry/rules/hitl-ppe-record-analysis.md +302 -302
  58. package/registry/rules/local-development.md +251 -251
  59. package/registry/rules/software-development-lifecycle.md +104 -104
  60. package/registry/rules/successful-debugging-patterns.md +482 -478
  61. package/registry/rules/telemetry.md +67 -0
  62. package/registry/scripts/build-scripts-generator.ts +216 -215
  63. package/registry/scripts/cleanup-branch.ts +303 -284
  64. package/registry/scripts/code-quality-check.sh +559 -559
  65. package/registry/scripts/detect-tautological-tests.sh +38 -38
  66. package/registry/scripts/evaluate-code-quality.ts +1 -1
  67. package/registry/scripts/generate-engagement-emails.ts +744 -744
  68. package/registry/scripts/generic-issues-api.ts +110 -150
  69. package/registry/scripts/newsletter-helpers.ts +874 -874
  70. package/registry/scripts/openapi-generator.ts +695 -693
  71. package/registry/scripts/performance/profile-server.ts +5 -3
  72. package/registry/scripts/prep-issue.sh +468 -455
  73. package/registry/scripts/validate-openapi-limits.ts +366 -365
  74. package/registry/scripts/validate-test-coverage.ts +280 -280
  75. package/registry/scripts/verify-pr-comments.sh +70 -70
  76. package/registry/scripts/verify-test-coverage.ts +1 -1
  77. package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +53 -53
  78. package/registry/templates/evidence/Implementation-BugEvidence.md +85 -85
  79. package/registry/templates/evidence/Implementation-FeatureEvidence.md +120 -120
  80. package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +66 -0
  81. package/registry/workflows/bootstrap/create-architecture.md +2 -2
  82. package/registry/workflows/bootstrap/evaluate-code-quality.md +3 -3
  83. package/registry/workflows/bootstrap/verify-test-coverage.md +2 -2
  84. package/registry/workflows/customer-development/insight-analysis.md +156 -156
  85. package/registry/workflows/customer-development/interview-preparation.md +421 -421
  86. package/registry/workflows/customer-development/strategic-brainstorming.md +146 -146
  87. package/registry/workflows/customer-development/thank-customers.md +193 -191
  88. package/registry/workflows/customer-development/weekly-newsletter.md +362 -352
  89. package/registry/workflows/improve-fraim/contribute.md +32 -0
  90. package/registry/workflows/improve-fraim/file-issue.md +32 -0
  91. package/registry/workflows/marketing/hbr-article.md +73 -0
  92. package/registry/workflows/performance/analyze-performance.md +63 -59
  93. package/registry/workflows/product-building/design.md +3 -2
  94. package/registry/workflows/product-building/implement.md +4 -3
  95. package/registry/workflows/product-building/prep-issue.md +28 -17
  96. package/registry/workflows/product-building/resolve.md +3 -2
  97. package/registry/workflows/product-building/retrospect.md +3 -2
  98. package/registry/workflows/product-building/spec.md +5 -4
  99. package/registry/workflows/product-building/test.md +3 -2
  100. package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +562 -562
  101. package/registry/workflows/replicate/website-discovery-analysis.md +3 -3
  102. package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +632 -632
  103. package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +669 -669
  104. package/tsconfig.json +2 -1
@@ -1,252 +1,252 @@
1
- # Local Development Guidelines
2
-
3
- ## INTENT
4
- Enable safe parallel development through strict workspace separation, preventing conflicts between agents and maintaining code integrity.
5
-
6
- ## PRINCIPLES
7
- - **Workspace Isolation**: Each agent works in their own cloned repository folder
8
- - **Branch Discipline**: Always work on feature branches, never push to master
9
- - **Timeout Management**: Use exec-with-timeout for all commands to prevent hangs
10
- - **Coordination**: Use GitHub issues and PRs for agent communication
11
-
12
- ## CORE RULES
13
-
14
- ### Development Environment
15
- - Use local file system for development work in your own cloned repository folder
16
- - Push to feature branches only; never push to master
17
- - Do NOT open PRs; push and let Actions open/update Draft PRs
18
- - Always work in your own cloned repository folder.
19
- All your work **MUST** be in your folder.
20
- - Coordinate with other agents through GitHub issues and PRs
21
- - Each agent works independently in their own folder to enable true parallel development
22
- - Run every command using `npx tsx .ai-agents/scripts/exec-with-timeout.ts --timeout 30 -- <your command>` to prevent hangs in the terminal. You can adjust the timeout if the task is expected to run longer, but always have a timeout.
23
-
24
- ## CRITICAL RULE: Absolute Workspace Separation
25
-
26
- ### Main Workspace: READ-ONLY
27
- - **Directory**: `{PROJECT_NAME}` (no issue number)
28
- - **Purpose**: Reference only - for reading existing code
29
- - **PROHIBITION**: **NEVER** create, edit, or modify ANY files here
30
-
31
- ### Local Clone: WORK-ONLY
32
- - **Directory**: `{PROJECT_NAME} - Issue {issue_number}` (includes issue number)
33
- - **Purpose**: All development work happens here exclusively
34
- - **Rule**: ALL file operations must be within this directory
35
-
36
- ## WORKSPACE OPERATIONS
37
-
38
- ### Safe Operations (READ-ONLY)
39
- - `read_file()` from main workspace for reference
40
- - `grep_search()` in main workspace for analysis
41
- - `list_dir()` in main workspace for exploration
42
- - `find_by_name()` in main workspace for discovery
43
-
44
- ### Work Operations (LOCAL CLONE ONLY)
45
- - `edit_file()` - ONLY in your local clone
46
- - `write_to_file()` - ONLY in your local clone
47
- - `delete_file()` - ONLY in your local clone
48
- - All git operations - ONLY in your local clone
49
-
50
- ### NEVER Use These Patterns:
51
- ```
52
- ❌ edit_file("{PROJECT_NAME}/...") # Main workspace
53
- ❌ edit_file("../{PROJECT_NAME}/...") # Main workspace via relative path
54
- ❌ edit_file(".windsurf/...") # Main workspace config
55
- ❌ Any path containing main workspace name
56
- ```
57
-
58
- ### ALWAYS Use These Patterns:
59
- ```
60
- ✅ edit_file("src/...") # Relative path in local clone
61
- ✅ edit_file("./src/...") # Explicit relative path
62
- ✅ read_file("../{PROJECT_NAME}/src/...") # Reference main workspace
63
- ✅ Working directory check before operations
64
- ```
65
-
66
- ## COMMAND EXECUTION
67
-
68
- ### Timeout Wrapper (MANDATORY)
69
- ALL commands must use the timeout wrapper:
70
-
71
- ```bash
72
- # Standard timeout (30 seconds)
73
- npx tsx .ai-agents/scripts/exec-with-timeout.ts --timeout 30 -- npm install
74
-
75
- # Extended timeout for long operations
76
- npx tsx .ai-agents/scripts/exec-with-timeout.ts --timeout 300 -- npm run build
77
-
78
- # Very long operations (tests, servers)
79
- npx tsx .ai-agents/scripts/exec-with-timeout.ts --timeout 1800 -- npm run test-all
80
- ```
81
-
82
- ### Timeout Guidelines
83
- - **Quick commands**: 30 seconds (npm install, git operations)
84
- - **Build operations**: 300 seconds (5 minutes)
85
- - **Test suites**: 1800 seconds (30 minutes)
86
- - **Development servers**: 3600 seconds (1 hour)
87
-
88
- ## DIRECTORY STRUCTURE RULES
89
-
90
- ### Correct Naming Convention:
91
- - **Main Workspace**: `{PROJECT_NAME}` (READ-ONLY)
92
- - **Local Clone**: `{PROJECT_NAME} - Issue {issue_number}` (WORK HERE)
93
-
94
- **The issue number in directory name is a visual reminder you're in the right place.**
95
-
96
- ### Directory Verification
97
- Before ANY file operation, verify you're in the correct directory:
98
-
99
- ```bash
100
- # Check current directory
101
- pwd
102
-
103
- # Verify you're in local clone (should contain issue number)
104
- basename "$(pwd)" | grep -q "Issue [0-9]"
105
- ```
106
-
107
- ## BRANCH MANAGEMENT
108
-
109
- ### Branch Naming Convention
110
- - Format: `feature/{issue_number}-{kebab-case-title}`
111
- - Example: `feature/123-fix-authentication-bug`
112
- - Always include issue number for traceability
113
-
114
- ### Branch Operations
115
- ```bash
116
- # Create and switch to feature branch
117
- git checkout -b feature/123-fix-authentication-bug
118
-
119
- # Push branch to origin
120
- git push -u origin feature/123-fix-authentication-bug
121
-
122
- # Never push to master
123
- git push origin master # ❌ FORBIDDEN
124
- ```
125
-
126
- ## COORDINATION PATTERNS
127
-
128
- ### Agent Communication
129
- - Use GitHub issues for task coordination
130
- - Use PR comments for code review feedback
131
- - Use issue labels for status tracking
132
- - Never directly modify another agent's work
133
-
134
- ### Status Updates
135
- - Update issue labels to reflect current phase
136
- - Add comments to issues with progress updates
137
- - Link PRs to issues for traceability
138
- - Use draft PRs for work-in-progress
139
-
140
- ## SAFETY CHECKS
141
-
142
- ### Pre-Operation Verification
143
- 1. **Directory Check**: Confirm you're in local clone
144
- 2. **Branch Check**: Confirm you're on feature branch
145
- 3. **File Path Check**: Confirm relative paths only
146
- 4. **Timeout Check**: Confirm command has timeout wrapper
147
-
148
- ### Example Verification Script
149
- ```bash
150
- # Verify safe working environment
151
- CURRENT_DIR=$(basename "$(pwd)")
152
- CURRENT_BRANCH=$(git branch --show-current)
153
-
154
- if [[ ! "$CURRENT_DIR" =~ "Issue [0-9]+" ]]; then
155
- echo "❌ Not in local clone directory"
156
- exit 1
157
- fi
158
-
159
- if [[ "$CURRENT_BRANCH" == "master" ]] || [[ "$CURRENT_BRANCH" == "main" ]]; then
160
- echo "❌ Working on main branch"
161
- exit 1
162
- fi
163
-
164
- echo "✅ Safe working environment confirmed"
165
- ```
166
-
167
- ## TESTING PATTERNS
168
-
169
- ### Mock Service Pattern
170
- **Use mocks to isolate components during testing**
171
-
172
- **Example**:
173
- ```typescript
174
- const mockApiService = {
175
- calls: [],
176
- updateResource: async (request) => {
177
- mockApiService.calls.push({ method: 'updateResource', request });
178
- return { success: true };
179
- }
180
- };
181
-
182
- // After running action, validate calls
183
- const updateCall = mockApiService.calls.find(call => call.method === 'updateResource');
184
- if (!updateCall) throw new Error('Expected updateResource to be called');
185
- if (updateCall.request.resourceId !== expectedId) throw new Error('Wrong resource ID');
186
- ```
187
-
188
- ## EXAMPLES
189
-
190
- ### Good: Proper Workspace Usage
191
- ```
192
- ✅ Working Directory: /path/to/{PROJECT_NAME} - Issue 84
193
- ✅ File Operation: edit_file("src/api-service.ts")
194
- ✅ Branch Check: feature/84-fix-api-sync
195
- ✅ Path Verification: Relative path, no "../" patterns
196
- ✅ Command: npx tsx .ai-agents/scripts/exec-with-timeout.ts --timeout 30 -- npm test
197
- ```
198
-
199
- ### Bad: Workspace Violations
200
- ```
201
- ❌ Working Directory: /path/to/{PROJECT_NAME} (main workspace)
202
- ❌ File Operation: edit_file("src/api-service.ts")
203
- ❌ Branch Check: main
204
- ❌ Path Verification: Working in main workspace
205
- ❌ Command: npm test (no timeout wrapper)
206
- ```
207
-
208
- ### Good: Reference Operations
209
- ```
210
- ✅ Read from main workspace: read_file("../{PROJECT_NAME}/docs/README.md")
211
- ✅ Search main workspace: grep("api", "../{PROJECT_NAME}/src/")
212
- ✅ List main workspace: list_dir("../{PROJECT_NAME}/")
213
- Result: Safe reference without modification
214
- ```
215
-
216
- ### Bad: Modification in Main Workspace
217
- ```
218
- ❌ Edit main workspace: edit_file("../{PROJECT_NAME}/src/api-service.ts")
219
- ❌ Delete main workspace: delete_file("../{PROJECT_NAME}/test-file.ts")
220
- ❌ Search replace main: search_replace("../{PROJECT_NAME}/...")
221
- Result: Violates workspace separation
222
- ```
223
-
224
- ## CLEANUP
225
-
226
- ### End of Work Session
227
- When work is complete, clean up your local clone:
228
-
229
- ```bash
230
- # Navigate out of local clone
231
- cd ..
232
-
233
- # Remove your local clone folder
234
- rm -rf "{PROJECT_NAME} - Issue {issue_number}"
235
- ```
236
-
237
- ## TROUBLESHOOTING
238
-
239
- ### Common Issues
240
- 1. **Permission Denied**: Check if you're in the right directory
241
- 2. **Git Conflicts**: Ensure you're on feature branch, not master
242
- 3. **Command Hangs**: Always use timeout wrapper
243
- 4. **File Not Found**: Verify relative paths and working directory
244
-
245
- ### Recovery Steps
246
- 1. Stop all running processes
247
- 2. Navigate to correct local clone directory
248
- 3. Check git status and current branch
249
- 4. Verify file paths are relative
250
- 5. Use timeout wrapper for all commands
251
-
1
+ # Local Development Guidelines
2
+
3
+ ## INTENT
4
+ Enable safe parallel development through strict workspace separation, preventing conflicts between agents and maintaining code integrity.
5
+
6
+ ## PRINCIPLES
7
+ - **Workspace Isolation**: Each agent works in their own cloned repository folder
8
+ - **Branch Discipline**: Always work on feature branches, never push to master
9
+ - **Timeout Management**: Use exec-with-timeout for all commands to prevent hangs
10
+ - **Coordination**: Use GitHub issues and PRs for agent communication
11
+
12
+ ## CORE RULES
13
+
14
+ ### Development Environment
15
+ - Use local file system for development work in your own cloned repository folder
16
+ - Push to feature branches only; never push to master
17
+ - Do NOT open PRs; push and let Actions open/update Draft PRs
18
+ - Always work in your own cloned repository folder.
19
+ All your work **MUST** be in your folder.
20
+ - Coordinate with other agents through GitHub issues and PRs
21
+ - Each agent works independently in their own folder to enable true parallel development
22
+ - Run every command using `npx tsx tmp/exec-with-timeout.ts --timeout 30 -- <your command>` (Retrieve script via `get_fraim_file({ path: "scripts/exec-with-timeout.ts" })`)
23
+
24
+ ## CRITICAL RULE: Absolute Workspace Separation
25
+
26
+ ### Main Workspace: READ-ONLY
27
+ - **Directory**: `{PROJECT_NAME}` (no issue number)
28
+ - **Purpose**: Reference only - for reading existing code
29
+ - **PROHIBITION**: **NEVER** create, edit, or modify ANY files here
30
+
31
+ ### Local Clone: WORK-ONLY
32
+ - **Directory**: `{PROJECT_NAME} - Issue {issue_number}` (includes issue number)
33
+ - **Purpose**: All development work happens here exclusively
34
+ - **Rule**: ALL file operations must be within this directory
35
+
36
+ ## WORKSPACE OPERATIONS
37
+
38
+ ### Safe Operations (READ-ONLY)
39
+ - `read_file()` from main workspace for reference
40
+ - `grep_search()` in main workspace for analysis
41
+ - `list_dir()` in main workspace for exploration
42
+ - `find_by_name()` in main workspace for discovery
43
+
44
+ ### Work Operations (LOCAL CLONE ONLY)
45
+ - `edit_file()` - ONLY in your local clone
46
+ - `write_to_file()` - ONLY in your local clone
47
+ - `delete_file()` - ONLY in your local clone
48
+ - All git operations - ONLY in your local clone
49
+
50
+ ### NEVER Use These Patterns:
51
+ ```
52
+ ❌ edit_file("{PROJECT_NAME}/...") # Main workspace
53
+ ❌ edit_file("../{PROJECT_NAME}/...") # Main workspace via relative path
54
+ ❌ edit_file(".windsurf/...") # Main workspace config
55
+ ❌ Any path containing main workspace name
56
+ ```
57
+
58
+ ### ALWAYS Use These Patterns:
59
+ ```
60
+ ✅ edit_file("src/...") # Relative path in local clone
61
+ ✅ edit_file("./src/...") # Explicit relative path
62
+ ✅ read_file("../{PROJECT_NAME}/src/...") # Reference main workspace
63
+ ✅ Working directory check before operations
64
+ ```
65
+
66
+ ## COMMAND EXECUTION
67
+
68
+ ### Timeout Wrapper (MANDATORY)
69
+ ALL commands must use the timeout wrapper:
70
+
71
+ ```bash
72
+ # Standard timeout (30 seconds)
73
+ npx tsx tmp/exec-with-timeout.ts --timeout 30 -- npm install
74
+
75
+ # Extended timeout for long operations
76
+ npx tsx tmp/exec-with-timeout.ts --timeout 300 -- npm run build
77
+
78
+ # Very long operations (tests, servers)
79
+ npx tsx tmp/exec-with-timeout.ts --timeout 1800 -- npm run test-all
80
+ ```
81
+
82
+ ### Timeout Guidelines
83
+ - **Quick commands**: 30 seconds (npm install, git operations)
84
+ - **Build operations**: 300 seconds (5 minutes)
85
+ - **Test suites**: 1800 seconds (30 minutes)
86
+ - **Development servers**: 3600 seconds (1 hour)
87
+
88
+ ## DIRECTORY STRUCTURE RULES
89
+
90
+ ### Correct Naming Convention:
91
+ - **Main Workspace**: `{PROJECT_NAME}` (READ-ONLY)
92
+ - **Local Clone**: `{PROJECT_NAME} - Issue {issue_number}` (WORK HERE)
93
+
94
+ **The issue number in directory name is a visual reminder you're in the right place.**
95
+
96
+ ### Directory Verification
97
+ Before ANY file operation, verify you're in the correct directory:
98
+
99
+ ```bash
100
+ # Check current directory
101
+ pwd
102
+
103
+ # Verify you're in local clone (should contain issue number)
104
+ basename "$(pwd)" | grep -q "Issue [0-9]"
105
+ ```
106
+
107
+ ## BRANCH MANAGEMENT
108
+
109
+ ### Branch Naming Convention
110
+ - Format: `feature/{issue_number}-{kebab-case-title}`
111
+ - Example: `feature/123-fix-authentication-bug`
112
+ - Always include issue number for traceability
113
+
114
+ ### Branch Operations
115
+ ```bash
116
+ # Create and switch to feature branch
117
+ git checkout -b feature/123-fix-authentication-bug
118
+
119
+ # Push branch to origin
120
+ git push -u origin feature/123-fix-authentication-bug
121
+
122
+ # Never push to master
123
+ git push origin master # ❌ FORBIDDEN
124
+ ```
125
+
126
+ ## COORDINATION PATTERNS
127
+
128
+ ### Agent Communication
129
+ - Use GitHub issues for task coordination
130
+ - Use PR comments for code review feedback
131
+ - Use issue labels for status tracking
132
+ - Never directly modify another agent's work
133
+
134
+ ### Status Updates
135
+ - Update issue labels to reflect current phase
136
+ - Add comments to issues with progress updates
137
+ - Link PRs to issues for traceability
138
+ - Use draft PRs for work-in-progress
139
+
140
+ ## SAFETY CHECKS
141
+
142
+ ### Pre-Operation Verification
143
+ 1. **Directory Check**: Confirm you're in local clone
144
+ 2. **Branch Check**: Confirm you're on feature branch
145
+ 3. **File Path Check**: Confirm relative paths only
146
+ 4. **Timeout Check**: Confirm command has timeout wrapper
147
+
148
+ ### Example Verification Script
149
+ ```bash
150
+ # Verify safe working environment
151
+ CURRENT_DIR=$(basename "$(pwd)")
152
+ CURRENT_BRANCH=$(git branch --show-current)
153
+
154
+ if [[ ! "$CURRENT_DIR" =~ "Issue [0-9]+" ]]; then
155
+ echo "❌ Not in local clone directory"
156
+ exit 1
157
+ fi
158
+
159
+ if [[ "$CURRENT_BRANCH" == "master" ]] || [[ "$CURRENT_BRANCH" == "main" ]]; then
160
+ echo "❌ Working on main branch"
161
+ exit 1
162
+ fi
163
+
164
+ echo "✅ Safe working environment confirmed"
165
+ ```
166
+
167
+ ## TESTING PATTERNS
168
+
169
+ ### Mock Service Pattern
170
+ **Use mocks to isolate components during testing**
171
+
172
+ **Example**:
173
+ ```typescript
174
+ const mockApiService = {
175
+ calls: [],
176
+ updateResource: async (request) => {
177
+ mockApiService.calls.push({ method: 'updateResource', request });
178
+ return { success: true };
179
+ }
180
+ };
181
+
182
+ // After running action, validate calls
183
+ const updateCall = mockApiService.calls.find(call => call.method === 'updateResource');
184
+ if (!updateCall) throw new Error('Expected updateResource to be called');
185
+ if (updateCall.request.resourceId !== expectedId) throw new Error('Wrong resource ID');
186
+ ```
187
+
188
+ ## EXAMPLES
189
+
190
+ ### Good: Proper Workspace Usage
191
+ ```
192
+ ✅ Working Directory: /path/to/{PROJECT_NAME} - Issue 84
193
+ ✅ File Operation: edit_file("src/api-service.ts")
194
+ ✅ Branch Check: feature/84-fix-api-sync
195
+ ✅ Path Verification: Relative path, no "../" patterns
196
+ ✅ Command: npx tsx scripts/exec-with-timeout.ts --timeout 30 -- npm test
197
+ ```
198
+
199
+ ### Bad: Workspace Violations
200
+ ```
201
+ ❌ Working Directory: /path/to/{PROJECT_NAME} (main workspace)
202
+ ❌ File Operation: edit_file("src/api-service.ts")
203
+ ❌ Branch Check: main
204
+ ❌ Path Verification: Working in main workspace
205
+ ❌ Command: npm test (no timeout wrapper)
206
+ ```
207
+
208
+ ### Good: Reference Operations
209
+ ```
210
+ ✅ Read from main workspace: read_file("../{PROJECT_NAME}/docs/README.md")
211
+ ✅ Search main workspace: grep("api", "../{PROJECT_NAME}/src/")
212
+ ✅ List main workspace: list_dir("../{PROJECT_NAME}/")
213
+ Result: Safe reference without modification
214
+ ```
215
+
216
+ ### Bad: Modification in Main Workspace
217
+ ```
218
+ ❌ Edit main workspace: edit_file("../{PROJECT_NAME}/src/api-service.ts")
219
+ ❌ Delete main workspace: delete_file("../{PROJECT_NAME}/test-file.ts")
220
+ ❌ Search replace main: search_replace("../{PROJECT_NAME}/...")
221
+ Result: Violates workspace separation
222
+ ```
223
+
224
+ ## CLEANUP
225
+
226
+ ### End of Work Session
227
+ When work is complete, clean up your local clone:
228
+
229
+ ```bash
230
+ # Navigate out of local clone
231
+ cd ..
232
+
233
+ # Remove your local clone folder
234
+ rm -rf "{PROJECT_NAME} - Issue {issue_number}"
235
+ ```
236
+
237
+ ## TROUBLESHOOTING
238
+
239
+ ### Common Issues
240
+ 1. **Permission Denied**: Check if you're in the right directory
241
+ 2. **Git Conflicts**: Ensure you're on feature branch, not master
242
+ 3. **Command Hangs**: Always use timeout wrapper
243
+ 4. **File Not Found**: Verify relative paths and working directory
244
+
245
+ ### Recovery Steps
246
+ 1. Stop all running processes
247
+ 2. Navigate to correct local clone directory
248
+ 3. Check git status and current branch
249
+ 4. Verify file paths are relative
250
+ 5. Use timeout wrapper for all commands
251
+
252
252
  Respect CODEOWNERS; don't modify auth/CI without approval.