opencastle 1.6.2 → 1.6.4

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 (275) hide show
  1. package/README.md +9 -9
  2. package/bin/cli.mjs +19 -12
  3. package/dist/cli/adapters/adapter-contract.test.js +1 -1
  4. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  5. package/dist/cli/adapters/single-file-base.js +2 -12
  6. package/dist/cli/adapters/single-file-base.js.map +1 -1
  7. package/dist/cli/add.js +7 -7
  8. package/dist/cli/add.js.map +1 -1
  9. package/dist/cli/baseline.js +6 -6
  10. package/dist/cli/baseline.js.map +1 -1
  11. package/dist/cli/bootstrap.d.ts.map +1 -1
  12. package/dist/cli/bootstrap.js +15 -6
  13. package/dist/cli/bootstrap.js.map +1 -1
  14. package/dist/cli/bootstrap.test.js +8 -0
  15. package/dist/cli/bootstrap.test.js.map +1 -1
  16. package/dist/cli/ci.d.ts.map +1 -1
  17. package/dist/cli/ci.js +19 -9
  18. package/dist/cli/ci.js.map +1 -1
  19. package/dist/cli/command-namespace.test.js +4 -21
  20. package/dist/cli/command-namespace.test.js.map +1 -1
  21. package/dist/cli/convoy/engine.js +3 -3
  22. package/dist/cli/convoy/engine.js.map +1 -1
  23. package/dist/cli/convoy/engine.test.js +1 -1
  24. package/dist/cli/convoy/engine.test.js.map +1 -1
  25. package/dist/cli/convoy/read-model.d.ts +8 -15
  26. package/dist/cli/convoy/read-model.d.ts.map +1 -1
  27. package/dist/cli/convoy/read-model.js +9 -68
  28. package/dist/cli/convoy/read-model.js.map +1 -1
  29. package/dist/cli/convoy/read-model.test.js +6 -25
  30. package/dist/cli/convoy/read-model.test.js.map +1 -1
  31. package/dist/cli/convoy/spec-builder.d.ts +2 -2
  32. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  33. package/dist/cli/convoy/spec-builder.js +3 -3
  34. package/dist/cli/convoy/spec-builder.js.map +1 -1
  35. package/dist/cli/convoy/spec-builder.test.js +2 -2
  36. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  37. package/dist/cli/convoy-cmd.js +16 -16
  38. package/dist/cli/convoy-cmd.js.map +1 -1
  39. package/dist/cli/convoy-cmd.test.js +11 -11
  40. package/dist/cli/convoy-cmd.test.js.map +1 -1
  41. package/dist/cli/dashboard.js +3 -3
  42. package/dist/cli/dashboard.js.map +1 -1
  43. package/dist/cli/dashboard.test.js +10 -2
  44. package/dist/cli/dashboard.test.js.map +1 -1
  45. package/dist/cli/dispatcher.test.js +7 -4
  46. package/dist/cli/dispatcher.test.js.map +1 -1
  47. package/dist/cli/docs-accuracy.test.js +5 -1
  48. package/dist/cli/docs-accuracy.test.js.map +1 -1
  49. package/dist/cli/doctor.d.ts.map +1 -1
  50. package/dist/cli/doctor.js +17 -42
  51. package/dist/cli/doctor.js.map +1 -1
  52. package/dist/cli/explain.js +2 -2
  53. package/dist/cli/explain.js.map +1 -1
  54. package/dist/cli/fleet.js +1 -1
  55. package/dist/cli/github-report.js +5 -5
  56. package/dist/cli/github-report.js.map +1 -1
  57. package/dist/cli/gitignore.js +1 -1
  58. package/dist/cli/gitignore.js.map +1 -1
  59. package/dist/cli/init.d.ts.map +1 -1
  60. package/dist/cli/init.js +27 -10
  61. package/dist/cli/init.js.map +1 -1
  62. package/dist/cli/layers.js +4 -4
  63. package/dist/cli/layers.js.map +1 -1
  64. package/dist/cli/lesson.js +12 -12
  65. package/dist/cli/lesson.js.map +1 -1
  66. package/dist/cli/lessons.d.ts.map +1 -1
  67. package/dist/cli/lessons.js +11 -7
  68. package/dist/cli/lessons.js.map +1 -1
  69. package/dist/cli/managed-block.js +1 -1
  70. package/dist/cli/managed-block.js.map +1 -1
  71. package/dist/cli/mcp-audit.js +6 -6
  72. package/dist/cli/mcp-audit.js.map +1 -1
  73. package/dist/cli/mcp-audit.test.js +5 -5
  74. package/dist/cli/mcp-audit.test.js.map +1 -1
  75. package/dist/cli/pipeline.d.ts +1 -1
  76. package/dist/cli/pipeline.flow.test.js +77 -77
  77. package/dist/cli/pipeline.flow.test.js.map +1 -1
  78. package/dist/cli/pipeline.js +30 -30
  79. package/dist/cli/pipeline.js.map +1 -1
  80. package/dist/cli/plan.d.ts +8 -2
  81. package/dist/cli/plan.d.ts.map +1 -1
  82. package/dist/cli/plan.js +18 -12
  83. package/dist/cli/plan.js.map +1 -1
  84. package/dist/cli/plan.test.js +17 -19
  85. package/dist/cli/plan.test.js.map +1 -1
  86. package/dist/cli/plugin.js +8 -8
  87. package/dist/cli/plugin.js.map +1 -1
  88. package/dist/cli/promote.js +5 -5
  89. package/dist/cli/promote.js.map +1 -1
  90. package/dist/cli/prompt.d.ts.map +1 -1
  91. package/dist/cli/prompt.js +15 -2
  92. package/dist/cli/prompt.js.map +1 -1
  93. package/dist/cli/prompt.test.js +33 -8
  94. package/dist/cli/prompt.test.js.map +1 -1
  95. package/dist/cli/remove.js +1 -1
  96. package/dist/cli/review.js +3 -3
  97. package/dist/cli/review.js.map +1 -1
  98. package/dist/cli/run/adapters/index.js +3 -3
  99. package/dist/cli/run/adapters/index.js.map +1 -1
  100. package/dist/cli/run/adapters/index.test.js +3 -3
  101. package/dist/cli/run/adapters/index.test.js.map +1 -1
  102. package/dist/cli/run/schema.js +3 -3
  103. package/dist/cli/run/schema.js.map +1 -1
  104. package/dist/cli/run.js +21 -21
  105. package/dist/cli/run.js.map +1 -1
  106. package/dist/cli/run.test.js +3 -3
  107. package/dist/cli/run.test.js.map +1 -1
  108. package/dist/cli/stack-config-update.test.js +18 -1
  109. package/dist/cli/stack-config-update.test.js.map +1 -1
  110. package/dist/cli/stack-config.d.ts.map +1 -1
  111. package/dist/cli/stack-config.js +10 -1
  112. package/dist/cli/stack-config.js.map +1 -1
  113. package/dist/cli/status.js +9 -9
  114. package/dist/cli/status.js.map +1 -1
  115. package/dist/cli/status.test.js +3 -3
  116. package/dist/cli/status.test.js.map +1 -1
  117. package/dist/cli/sync-check.js +16 -16
  118. package/dist/cli/sync-check.js.map +1 -1
  119. package/dist/cli/sync.js +1 -1
  120. package/dist/cli/team-ci.test.js +3 -3
  121. package/dist/cli/team-ci.test.js.map +1 -1
  122. package/dist/cli/team-commands.test.js +30 -1
  123. package/dist/cli/team-commands.test.js.map +1 -1
  124. package/dist/cli/update.d.ts.map +1 -1
  125. package/dist/cli/update.js +34 -66
  126. package/dist/cli/update.js.map +1 -1
  127. package/package.json +1 -1
  128. package/src/cli/adapters/adapter-contract.test.ts +1 -1
  129. package/src/cli/adapters/single-file-base.ts +2 -11
  130. package/src/cli/add.ts +7 -7
  131. package/src/cli/baseline.ts +6 -6
  132. package/src/cli/bootstrap.test.ts +9 -0
  133. package/src/cli/bootstrap.ts +16 -6
  134. package/src/cli/ci.ts +17 -9
  135. package/src/cli/command-namespace.test.ts +5 -22
  136. package/src/cli/convoy/engine.test.ts +1 -1
  137. package/src/cli/convoy/engine.ts +3 -3
  138. package/src/{orchestrator/prompts/assess-complexity.prompt.md → cli/convoy/prompts/convoy-assess.prompt.md} +0 -3
  139. package/src/{orchestrator/prompts/fix-convoy.prompt.md → cli/convoy/prompts/convoy-plan-fix.prompt.md} +0 -3
  140. package/src/{orchestrator/prompts/validate-convoy.prompt.md → cli/convoy/prompts/convoy-plan-review.prompt.md} +0 -3
  141. package/src/{orchestrator/prompts/generate-convoy.prompt.md → cli/convoy/prompts/convoy-plan.prompt.md} +0 -2
  142. package/src/{orchestrator/prompts/fix-prd.prompt.md → cli/convoy/prompts/convoy-prd-fix.prompt.md} +0 -3
  143. package/src/{orchestrator/prompts/validate-prd.prompt.md → cli/convoy/prompts/convoy-prd-review.prompt.md} +0 -3
  144. package/src/{orchestrator/prompts/generate-prd.prompt.md → cli/convoy/prompts/convoy-prd.prompt.md} +0 -3
  145. package/src/cli/convoy/read-model.test.ts +5 -29
  146. package/src/cli/convoy/read-model.ts +11 -71
  147. package/src/cli/convoy/spec-builder.test.ts +2 -2
  148. package/src/cli/convoy/spec-builder.ts +4 -4
  149. package/src/cli/convoy-cmd.test.ts +11 -11
  150. package/src/cli/convoy-cmd.ts +18 -18
  151. package/src/cli/dashboard/dashboard.js +2 -4
  152. package/src/cli/dashboard.test.ts +10 -2
  153. package/src/cli/dashboard.ts +3 -3
  154. package/src/cli/dispatcher.test.ts +8 -4
  155. package/src/cli/docs-accuracy.test.ts +5 -1
  156. package/src/cli/doctor.ts +17 -43
  157. package/src/cli/explain.ts +2 -2
  158. package/src/cli/fleet.ts +1 -1
  159. package/src/cli/github-report.ts +5 -5
  160. package/src/cli/gitignore.ts +1 -1
  161. package/src/cli/init.ts +26 -10
  162. package/src/cli/layers.ts +4 -4
  163. package/src/cli/lesson.ts +12 -12
  164. package/src/cli/lessons.ts +11 -7
  165. package/src/cli/managed-block.ts +1 -1
  166. package/src/cli/mcp-audit.test.ts +5 -5
  167. package/src/cli/mcp-audit.ts +6 -6
  168. package/src/cli/pipeline.flow.test.ts +78 -78
  169. package/src/cli/pipeline.ts +31 -31
  170. package/src/cli/plan.test.ts +18 -20
  171. package/src/cli/plan.ts +18 -12
  172. package/src/cli/plugin.ts +8 -8
  173. package/src/cli/promote.ts +5 -5
  174. package/src/cli/prompt.test.ts +41 -13
  175. package/src/cli/prompt.ts +14 -2
  176. package/src/cli/remove.ts +1 -1
  177. package/src/cli/review.ts +3 -3
  178. package/src/cli/run/adapters/index.test.ts +3 -3
  179. package/src/cli/run/adapters/index.ts +3 -3
  180. package/src/cli/run/schema.ts +3 -3
  181. package/src/cli/run.test.ts +3 -3
  182. package/src/cli/run.ts +21 -21
  183. package/src/cli/stack-config-update.test.ts +22 -1
  184. package/src/cli/stack-config.ts +9 -1
  185. package/src/cli/status.test.ts +3 -3
  186. package/src/cli/status.ts +9 -9
  187. package/src/cli/sync-check.ts +16 -16
  188. package/src/cli/sync.ts +1 -1
  189. package/src/cli/team-ci.test.ts +3 -3
  190. package/src/cli/team-commands.test.ts +32 -1
  191. package/src/cli/update.ts +32 -74
  192. package/src/orchestrator/agent-workflows/README.md +10 -18
  193. package/src/orchestrator/agent-workflows/data-pipeline.md +7 -140
  194. package/src/orchestrator/agent-workflows/database-migration.md +7 -153
  195. package/src/orchestrator/agent-workflows/performance-optimization.md +6 -119
  196. package/src/orchestrator/agent-workflows/refactoring.md +8 -137
  197. package/src/orchestrator/agent-workflows/schema-changes.md +8 -159
  198. package/src/orchestrator/agent-workflows/security-audit.md +7 -142
  199. package/src/orchestrator/agent-workflows/shared-delivery-phase.md +8 -25
  200. package/src/orchestrator/agents/architect.agent.md +2 -14
  201. package/src/orchestrator/agents/content-engineer.agent.md +8 -10
  202. package/src/orchestrator/agents/data-engineer.agent.md +8 -8
  203. package/src/orchestrator/agents/developer.agent.md +3 -10
  204. package/src/orchestrator/agents/devops-expert.agent.md +0 -3
  205. package/src/orchestrator/agents/performance-expert.agent.md +2 -3
  206. package/src/orchestrator/agents/security-expert.agent.md +10 -12
  207. package/src/orchestrator/agents/team-lead.agent.md +31 -75
  208. package/src/orchestrator/agents/testing-expert.agent.md +3 -6
  209. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -4
  210. package/src/orchestrator/agents/writer.agent.md +0 -3
  211. package/src/orchestrator/customizations/LESSONS-LEARNED.md +5 -3
  212. package/src/orchestrator/customizations/README.md +3 -4
  213. package/src/orchestrator/customizations/agents/agent-registry.md +3 -3
  214. package/src/orchestrator/customizations/agents/skill-matrix.json +6 -42
  215. package/src/orchestrator/instructions/general.instructions.md +10 -37
  216. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -6
  217. package/src/orchestrator/prompts/brainstorm.prompt.md +7 -12
  218. package/src/orchestrator/prompts/bug-fix.prompt.md +19 -100
  219. package/src/orchestrator/prompts/convoy.prompt.md +20 -0
  220. package/src/orchestrator/prompts/create-skill.prompt.md +1 -5
  221. package/src/orchestrator/prompts/implement-feature.prompt.md +22 -93
  222. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +1 -5
  223. package/src/orchestrator/skills/api-patterns/SKILL.md +21 -18
  224. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
  225. package/src/orchestrator/skills/fast-review/SKILL.md +28 -65
  226. package/src/orchestrator/skills/frontend-design/REFERENCE.md +0 -1
  227. package/src/orchestrator/skills/frontend-design/SKILL.md +3 -1
  228. package/src/orchestrator/skills/git-workflow/SKILL.md +18 -34
  229. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +16 -46
  230. package/src/orchestrator/skills/security-hardening/SKILL.md +20 -19
  231. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +2 -2
  232. package/src/orchestrator/skills/self-improvement/SKILL.md +21 -46
  233. package/src/orchestrator/skills/technical-writing/SKILL.md +3 -1
  234. package/src/orchestrator/skills/technical-writing/TEMPLATES.md +23 -0
  235. package/src/orchestrator/skills/testing-workflow/SKILL.md +21 -23
  236. package/src/orchestrator/skills/validation-gates/REFERENCE.md +2 -14
  237. package/src/orchestrator/skills/validation-gates/SKILL.md +10 -88
  238. package/dist/cli/log.d.ts +0 -44
  239. package/dist/cli/log.d.ts.map +0 -1
  240. package/dist/cli/log.js +0 -336
  241. package/dist/cli/log.js.map +0 -1
  242. package/dist/cli/log.test.d.ts +0 -2
  243. package/dist/cli/log.test.d.ts.map +0 -1
  244. package/dist/cli/log.test.js +0 -208
  245. package/dist/cli/log.test.js.map +0 -1
  246. package/src/cli/log.test.ts +0 -228
  247. package/src/cli/log.ts +0 -374
  248. package/src/orchestrator/agent-workflows/bug-fix.md +0 -130
  249. package/src/orchestrator/agent-workflows/feature-implementation.md +0 -232
  250. package/src/orchestrator/instructions/ai-optimization.instructions.md +0 -17
  251. package/src/orchestrator/prompts/quick-refinement.prompt.md +0 -110
  252. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +0 -44
  253. package/src/orchestrator/skills/agent-hooks/SKILL.md +0 -80
  254. package/src/orchestrator/skills/agent-memory/KNOWLEDGE-GRAPH.md +0 -49
  255. package/src/orchestrator/skills/agent-memory/SKILL.md +0 -50
  256. package/src/orchestrator/skills/code-commenting/SKILL.md +0 -18
  257. package/src/orchestrator/skills/context-map/REFERENCE.md +0 -67
  258. package/src/orchestrator/skills/context-map/SKILL.md +0 -71
  259. package/src/orchestrator/skills/decomposition/SKILL.md +0 -103
  260. package/src/orchestrator/skills/documentation-standards/SKILL.md +0 -33
  261. package/src/orchestrator/skills/fast-review/REFERENCE.md +0 -28
  262. package/src/orchestrator/skills/memory-merger/SKILL.md +0 -77
  263. package/src/orchestrator/skills/observability-logging/LOG-SCHEMA.md +0 -238
  264. package/src/orchestrator/skills/observability-logging/SKILL.md +0 -73
  265. package/src/orchestrator/skills/orchestration-protocols/REFERENCE.md +0 -38
  266. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +0 -120
  267. package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +0 -49
  268. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +0 -38
  269. package/src/orchestrator/skills/performance-optimization/SKILL.md +0 -23
  270. package/src/orchestrator/skills/project-consistency/SKILL.md +0 -80
  271. package/src/orchestrator/skills/project-consistency/TEMPLATES.md +0 -35
  272. package/src/orchestrator/skills/react-development/SKILL.md +0 -24
  273. package/src/orchestrator/skills/session-checkpoints/CHECKPOINT-TEMPLATE.md +0 -56
  274. package/src/orchestrator/skills/session-checkpoints/SKILL.md +0 -40
  275. package/src/orchestrator/skills/team-lead-reference/SKILL.md +0 -126
@@ -2,147 +2,14 @@
2
2
 
3
3
  # Workflow: Data Pipeline
4
4
 
5
- Standard execution plan for crawling, processing, and importing data.
5
+ For crawling, converting and importing data into the project's database or CMS. Project-specific sources, paths and rules: `.opencastle/stack/data-pipeline-config.md`, when there is one, and the **data-engineering** skill.
6
6
 
7
- > **Project config:** For project-specific paths, data schema, CLI commands, and processing rules, see `data-pipeline-config.md`. For data model docs, see Key Documentation in `.opencastle/project.instructions.md`.
7
+ 1. **Analyse the source** (Data Engineer). What it offers, how its fields map to the target schema, how many records, its terms and rate limits, and any scraper the project already has to follow.
8
+ 2. **Crawl** (Data Engineer). Raw records to files (NDJSON), with pagination, rate limiting and recovery from errors; log pages visited, records found and errors. Raw data is not committed.
9
+ 3. **Process** (Data Engineer). Convert to the target schema, enrich and normalize by the project's rules, and validate every record against the schema; a bad record is skipped and logged with its reason, never dropped silently.
10
+ 4. **Validate** (Team Lead). Spot-check 10–20 records by hand, run the validation over the whole set, and check for duplicates of what already exists.
11
+ 5. **Import** (Data Engineer). A test batch of 5–10 records first, checked in the target; then the rest, idempotently, so a re-run changes nothing. Report created, updated, skipped and failed — counts that add up.
8
12
 
9
- ## Phases
10
-
11
- ```
12
- Phase 1: Source Analysis (sub-agent, inline)
13
- Phase 2: Crawling (background agent)
14
- Phase 3: Processing (sub-agent, sequential)
15
- Phase 4: Validation (sub-agent, inline)
16
- Phase 5: Import (sub-agent, inline)
17
- Phase 6: Delivery (direct, Team Lead)
18
- ```
19
-
20
- ---
21
-
22
- ## Branch & Delivery Strategy
23
-
24
- The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `feat/<ticket-id>-<short-description>`. Only code changes are committed — NDJSON data files in `tmp/` are NOT committed to Git.
25
-
26
- ---
27
-
28
- ## Phase 1: Source Analysis
29
-
30
- **Agent:** Data Engineer (via sub-agent)
31
- **Type:** Sub-agent (inline)
32
-
33
- ### Steps
34
-
35
- 1. Analyze the target data source (website, API, file)
36
- 2. Identify data fields available and their mapping to the place schema
37
- 3. Check the data model documentation (Key Documentation in `.opencastle/project.instructions.md`) for required fields
38
- 4. Estimate record count
39
- 5. Check for existing scraper patterns (see **data-engineering** skill)
40
- 6. Create tracker issue with data source details
41
-
42
- ### Exit Criteria
43
-
44
- - [ ] Source structure documented
45
- - [ ] Field mapping defined (source field → target field)
46
- - [ ] Estimated record count
47
- - [ ] Tracker issue created
48
- - [ ] Scraper approach decided (browser-based, fetch, API)
49
-
50
- ---
51
-
52
- ## Phase 2: Crawling
53
-
54
- **Agent:** Data Engineer
55
- **Type:** Background agent (may be long-running)
56
-
57
- ### Steps
58
-
59
- 1. Implement crawler following existing patterns (see `data-pipeline-config.md`)
60
- 2. Output raw data as NDJSON
61
- 3. Handle pagination, rate limiting, and error recovery
62
- 4. Log crawling statistics (pages visited, records extracted, errors)
63
-
64
- ### Exit Criteria
65
-
66
- - [ ] Raw NDJSON file produced
67
- - [ ] Crawling statistics logged
68
- - [ ] No duplicate records
69
- - [ ] Output contract returned
70
-
71
- ---
72
-
73
- ## Phase 3: Processing
74
-
75
- **Agent:** Data Engineer (via sub-agent)
76
- **Type:** Sub-agent (sequential — depends on Phase 2 output)
77
-
78
- ### Steps
79
-
80
- 1. Convert raw data to the target schema format
81
- 2. Enrich with appropriate metadata (geocoding, slug generation)
82
- 3. Images optimization
83
- 4. Normalize text fields (see data-pipeline-config.md for rules)
84
- 5. Validate against schema
85
- 6. Output processed NDJSON
86
-
87
- ### Exit Criteria
88
-
89
- - [ ] Processed NDJSON matches schema
90
- - [ ] All required fields present
91
- - [ ] Slugs are unique
92
- - [ ] Metadata complete
93
- - [ ] Pipeline tests pass (run the project's test command — see **codebase-tool** skill)
94
- - [ ] Output contract returned with quality metrics
95
-
96
- ---
97
-
98
- ## Phase 4: Validation
99
-
100
- **Agent:** Team Lead (self)
101
- **Type:** Sub-agent (inline)
102
-
103
- ### Steps
104
-
105
- 1. Spot-check 10-20 records manually
106
- 2. Run validation script against full dataset
107
- 3. Check for duplicates against existing data
108
- 4. Verify image URLs are accessible
109
- 5. Confirm field mapping accuracy
110
-
111
- ### Exit Criteria
112
-
113
- - [ ] Spot check passed
114
- - [ ] Validation script reports <1% error rate
115
- - [ ] No duplicates with existing data
116
- - [ ] Images accessible
117
-
118
- ---
119
-
120
- ## Phase 5: Import
121
-
122
- **Agent:** Data Engineer (via sub-agent)
123
- **Type:** Sub-agent (inline — need immediate feedback)
124
-
125
- ### Steps
126
-
127
- 1. Import small test batch (5-10 records) first
128
- 2. Verify in CMS
129
- 3. Import full dataset
130
- 4. Log import statistics (created, updated, skipped, failed)
131
- 5. Update tracker issue and roadmap
132
-
133
- ### Exit Criteria
134
-
135
- - [ ] Test batch verified in CMS
136
- - [ ] Full import complete
137
- - [ ] Import statistics logged
138
- - [ ] <0.1% failure rate
139
- - [ ] Output contract returned
140
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
141
-
142
- ---
143
-
144
- ### Phase 6: Delivery
13
+ ## Delivery
145
14
 
146
15
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
147
- >
148
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.
@@ -2,160 +2,14 @@
2
2
 
3
3
  # Workflow: Database Migration
4
4
 
5
- Structured workflow for database schema changes, RLS policies, and data migrations.
5
+ For a schema change, an access-policy change or a data migration. The database's own syntax and tools are in its skill and in `.opencastle/stack/<database>-config.md`.
6
6
 
7
- > **Project config:** For database-specific paths, schema details, and migration conventions, see the relevant database customization file in `.opencastle/stack/`.
7
+ 1. **Plan** (Data Engineer). Read the current schema, its access policies and the known issues. Write down the tables and columns affected, the policy changes, what happens to existing rows, and how to roll it back.
8
+ 2. **Migrate** (Data Engineer). A new migration in the project's naming convention — never a hand edit of the schema. Re-runnable; every new table guarded by its access control, deny by default and allow explicitly; an index for each column you query by; the rollback written with it. Apply it locally, then apply it again: the second run changes nothing.
9
+ 3. **Regenerate the types** (Data Engineer), when the project generates them from the schema, and check they compile.
10
+ 4. **Integrate** (Developer). Update the handlers and components that read or write the changed tables; run the tests, lint and build; check the affected pages in a browser.
11
+ 5. **Verify** (Team Lead). Exercise each access policy from every role that should and should not see the rows; spot-check the data; walk the feature end to end. A change to auth or to access policies gets **panel-majority-vote**.
8
12
 
9
- ## Phases
10
-
11
- ```
12
- Phase 1: Migration Planning (sub-agent, inline)
13
- Phase 2: Migration Implementation (sub-agent or background)
14
- Phase 3: Type Generation (sub-agent, sequential)
15
- Phase 4: Code Integration (sub-agent, sequential)
16
- Phase 5: Verification & Rollback Test (sub-agent, inline)
17
- Phase 6: Delivery (direct, Team Lead)
18
- ```
19
-
20
- ---
21
-
22
- ## Branch & Delivery Strategy
23
-
24
- The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `feat/<ticket-id>-<short-description>` or `fix/<ticket-id>-<short-description>`.
25
-
26
- ---
27
-
28
- ## Phase 1: Migration Planning
29
-
30
- **Agent:** Data Engineer (via sub-agent)
31
- **Type:** Sub-agent (inline)
32
-
33
- ### Steps
34
-
35
- 1. Read current schema in the migrations directory (see database customization) to understand existing tables
36
- 2. Check existing RLS policies using the database query tool
37
- 3. Read `.opencastle/project.instructions.md` for database architecture
38
- 4. Check `.opencastle/KNOWN-ISSUES.md` for database-related limitations
39
- 5. Document the migration plan: tables affected, columns added/removed, RLS changes
40
- 6. Write rollback strategy (how to reverse the migration)
41
- 7. Create tracker issue with migration details and rollback plan
42
-
43
- ### Exit Criteria
44
-
45
- - [ ] Current schema understood
46
- - [ ] Migration plan documented
47
- - [ ] Rollback strategy defined
48
- - [ ] Impact on existing data assessed
49
- - [ ] Tracker issue created with rollback plan
50
-
51
- ---
52
-
53
- ## Phase 2: Migration Implementation
54
-
55
- **Agent:** Data Engineer
56
- **Type:** Sub-agent (simple changes) or Background (complex migrations)
57
-
58
- ### File Partition
59
-
60
- > See the database customization file for project-specific migration paths.
61
-
62
- - Migrations directory — migration SQL files
63
-
64
- ### Steps
65
-
66
- 1. Create migration file following naming convention: `YYYYMMDDHHMMSS_description.sql`
67
- 2. Write idempotent SQL (can safely re-run)
68
- 3. Include RLS policies for any new tables — default deny, explicit allow
69
- 4. Add indexes for frequently queried columns
70
- 5. Include SQL comments documenting the purpose
71
- 6. Apply migration using the database MCP tool
72
- 7. Verify migration applied successfully
73
-
74
- ### Exit Criteria
75
-
76
- - [ ] Migration file created with idempotent SQL
77
- - [ ] RLS policies included for new tables
78
- - [ ] Indexes added for query columns
79
- - [ ] Migration applied successfully
80
- - [ ] Rollback SQL tested (or documented)
81
- - [ ] Output contract returned
82
-
83
- ---
84
-
85
- ## Phase 3: Type Generation
86
-
87
- **Agent:** Data Engineer (via sub-agent)
88
- **Type:** Sub-agent (sequential — depends on Phase 2)
89
-
90
- ### Steps
91
-
92
- 1. Generate updated TypeScript types using the database MCP tool
93
- 2. Update any local type files that reference the changed tables
94
- 3. Verify types compile correctly
95
-
96
- ### Exit Criteria
97
-
98
- - [ ] TypeScript types regenerated
99
- - [ ] Types compile without errors
100
- - [ ] Output contract returned
101
-
102
- ---
103
-
104
- ## Phase 4: Code Integration
105
-
106
- **Agent:** Developer (via sub-agent)
107
- **Type:** Sub-agent (sequential — depends on Phase 3)
108
-
109
- ### File Partition
110
-
111
- - Varies by feature — typically Server Actions, API routes, React components
112
-
113
- ### Steps
114
-
115
- 1. Update Server Actions / API routes to use new schema
116
- 2. Update components to handle new data fields
117
- 3. Run lint + test + build for affected projects
118
- 4. Start dev server and test in browser
119
-
120
- ### Exit Criteria
121
-
122
- - [ ] Server Actions updated
123
- - [ ] Components updated
124
- - [ ] Lint + test + build pass
125
- - [ ] Browser verification complete
126
- - [ ] Output contract returned
127
-
128
- ---
129
-
130
- ## Phase 5: Verification & Rollback Test
131
-
132
- **Agent:** Team Lead (self)
133
- **Type:** Direct verification
134
-
135
- ### Steps
136
-
137
- 1. Review all output contracts from Phases 2–4
138
- 2. Verify RLS policies from different user roles (anon, authenticated, admin)
139
- 3. Spot-check data using the database query tool
140
- 4. Start dev server and verify end-to-end functionality
141
- 5. **Security check:** If the migration touches auth or RLS, schedule panel review
142
- 6. Document rollback procedure in tracker issue
143
- 7. Move tracker issue to Done
144
-
145
- ### Exit Criteria
146
-
147
- - [ ] RLS policies tested from multiple roles
148
- - [ ] Data integrity verified
149
- - [ ] End-to-end flow works in browser
150
- - [ ] Panel review passed (if auth/RLS changes)
151
- - [ ] Rollback procedure documented
152
- - [ ] Tracker issue moved to Done
153
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
154
-
155
- ---
156
-
157
- ### Phase 6: Delivery
13
+ ## Delivery
158
14
 
159
15
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
160
- >
161
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.
@@ -2,126 +2,13 @@
2
2
 
3
3
  # Workflow: Performance Optimization
4
4
 
5
- Measure-first optimization workflow. Never optimize without profiling data.
5
+ For making something measurably faster. Never optimize without a measurement.
6
6
 
7
- ## Phases
7
+ 1. **Measure the baseline** (Performance Expert). A production build of the affected apps; Lighthouse on the key pages — the most traffic, the heaviest rendering — at least three runs, the median; the bundle size; the Core Web Vitals (LCP, INP, CLS) and TTFB; server render time.
8
+ 2. **Find the bottlenecks** (Performance Expert). The top three, ranked by what the user feels: the largest chunks, client-side JavaScript that need not ship, images, caching headers, slow queries.
9
+ 3. **Optimize** — in parallel where the files do not overlap: bundle and code splitting (Performance Expert), images (UI/UX Expert), data fetching and caching (Developer), indexes and query plans (Data Engineer).
10
+ 4. **Verify** (Performance Expert). The same pages, the same build, the same runs: before against after, with no visual regression (browser) and no functional one (the test suite). Keep a change only if it measurably helps.
8
11
 
9
- ```
10
- Phase 1: Baseline Measurement (sub-agent, inline)
11
- Phase 2: Analysis (sub-agent, inline)
12
- Phase 3: Optimization (background agents, parallel)
13
- Phase 4: Verification (sub-agent, inline)
14
- Phase 5: Delivery (direct, Team Lead)
15
- ```
16
-
17
- ---
18
-
19
- ## Branch & Delivery Strategy
20
-
21
- The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `perf/<ticket-id>-<short-description>` or `feat/<ticket-id>-<short-description>`.
22
-
23
- ---
24
-
25
- ## Phase 1: Baseline Measurement
26
-
27
- **Agent:** Performance Expert (via sub-agent)
28
- **Type:** Sub-agent (inline)
29
-
30
- ### Steps
31
-
32
- 1. Build the affected app(s) with production config
33
- 2. Run Lighthouse audit on key pages
34
- 3. Measure bundle size (production build output — see the **codebase-tool** skill for the build command)
35
- 4. Record Core Web Vitals: LCP, FID/INP, CLS, TTFB
36
- 5. Profile server-side rendering time
37
- 6. Document baseline metrics
38
-
39
- ### Key Pages to Measure
40
-
41
- > See `.opencastle/project.instructions.md` for the app inventory and key routes. Prioritize pages with the most traffic and the most complex rendering.
42
-
43
- ### Exit Criteria
44
-
45
- - [ ] Baseline metrics recorded for all key pages
46
- - [ ] Bundle size documented
47
- - [ ] Lighthouse scores saved
48
- - [ ] Tracker issue created with targets
49
-
50
- ---
51
-
52
- ## Phase 2: Analysis
53
-
54
- **Agent:** Performance Expert (via sub-agent)
55
- **Type:** Sub-agent (inline)
56
-
57
- ### Steps
58
-
59
- 1. Identify the top 3 performance bottlenecks
60
- 2. Analyze bundle composition (largest chunks)
61
- 3. Check for unnecessary client-side JavaScript
62
- 4. Review image optimization (WebP/AVIF, lazy loading, sizing)
63
- 5. Check caching headers and ISR configuration
64
- 6. Review database query performance (if applicable)
65
- 7. Prioritize optimizations by impact/effort
66
-
67
- ### Exit Criteria
68
-
69
- - [ ] Top 3 bottlenecks identified with evidence
70
- - [ ] Optimization plan created (ordered by impact)
71
- - [ ] Each optimization has expected improvement estimate
72
- - [ ] File partitions mapped for parallel work
73
-
74
- ---
75
-
76
- ## Phase 3: Optimization (Parallel)
77
-
78
- **Agents:** Varies by optimization type
79
- **Type:** Background agents (parallel where file partitions allow)
80
-
81
- ### Typical Tracks
82
-
83
- | Track | Agent | Focus | Files |
84
- |-------|-------|-------|-------|
85
- | A: Bundle | Performance Expert | Code splitting, tree shaking, dynamic imports | `app/`, `libs/` |
86
- | B: Images | UI/UX Expert | Image optimization, lazy loading, srcset | `components/`, `public/` |
87
- | C: Queries | Developer | Query optimization, caching | Query library, framework config |
88
- | D: Database | Data Engineer | Index optimization, query planning | Database migrations |
89
-
90
- ### Exit Criteria (per track)
91
-
92
- - [ ] Optimization implemented
93
- - [ ] Lint + test + build pass
94
- - [ ] Output contract with before/after metrics
95
-
96
- ---
97
-
98
- ## Phase 4: Verification
99
-
100
- **Agent:** Performance Expert (via sub-agent)
101
- **Type:** Sub-agent (inline)
102
-
103
- ### Steps
104
-
105
- 1. Rebuild with production config
106
- 2. Re-run Lighthouse on same pages as Phase 1
107
- 3. Compare metrics: before vs. after
108
- 4. Verify no visual regressions (browser test)
109
- 5. Confirm no functional regressions (test suite)
110
- 6. Document results
111
-
112
- ### Exit Criteria
113
-
114
- - [ ] Metrics improved (or justified why not)
115
- - [ ] No visual regressions
116
- - [ ] No functional regressions
117
- - [ ] Results documented in tracker issue
118
- - [ ] Roadmap updated
119
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
120
-
121
- ---
122
-
123
- ### Phase 5: Delivery
12
+ ## Delivery
124
13
 
125
14
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
126
- >
127
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.
@@ -1,144 +1,15 @@
1
1
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
2
2
 
3
- # Workflow: Code Refactoring
3
+ # Workflow: Refactoring
4
4
 
5
- Structured workflow for safe code refactoring — improving code quality without changing behavior.
5
+ For improving code without changing what it does.
6
6
 
7
- ## Phases
7
+ 1. **Scope and baseline** (Team Lead). Every file and module in scope; the current behaviour (test output, API responses, screenshots for UI); the test count, coverage, lint and bundle size, run now.
8
+ 2. **Close the coverage gap** (Testing Expert). Tests for the existing behaviour of everything in scope, written *before* the refactor, all passing.
9
+ 3. **Refactor** (the specialist for the area). Inside the scoped files only; public interfaces and behaviour unchanged; lint and type-check after each significant step; one concern per commit.
10
+ 4. **Verify** (Team Lead and Testing Expert). The full test suite, lint and build; the metrics against the baseline; a UI refactor checked in the browser at every breakpoint; nothing that depends on the code broken.
11
+ 5. **Panel** — over 10 files, a shared library's interface, or auth and security code: **panel-majority-vote**, asking "Does this refactoring keep all existing behaviour?"
8
12
 
9
- ```
10
- Phase 1: Scope & Baseline (sub-agent, inline)
11
- Phase 2: Test Coverage Gap (sub-agent or background)
12
- Phase 3: Refactor Implementation (sub-agent or background)
13
- Phase 4: Verification (sub-agent, inline)
14
- Phase 5: Panel Review (sub-agent, for large refactors)
15
- Phase 6: Delivery (direct, Team Lead)
16
- ```
17
-
18
- ---
19
-
20
- ## Branch & Delivery Strategy
21
-
22
- The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `refactor/<ticket-id>-<short-description>`.
23
-
24
- ---
25
-
26
- ## Phase 1: Scope & Baseline
27
-
28
- **Agent:** Team Lead (self)
29
- **Type:** Direct research
30
-
31
- ### Steps
32
-
33
- 1. Identify all files and modules in scope for refactoring
34
- 2. Document current behavior (screenshots, test outputs, API responses)
35
- 3. Run baseline tests (with coverage) for the project — see the **codebase-tool** skill for commands
36
- 4. Run baseline lint for the project
37
- 5. Record baseline metrics (test count, coverage %, lint errors, bundle size)
38
- 6. Create tracker issues for the refactoring scope
39
-
40
- ### Exit Criteria
41
-
42
- - [ ] Scope documented with file list
43
- - [ ] Baseline metrics recorded
44
- - [ ] Tracker issues created
45
-
46
- ---
47
-
48
- ## Phase 2: Test Coverage Gap
49
-
50
- **Agent:** Testing Expert
51
- **Type:** Sub-agent (inline) or background
52
-
53
- ### Steps
54
-
55
- 1. Analyze test coverage for all files in scope
56
- 2. Write missing tests to cover existing behavior BEFORE refactoring
57
- 3. Ensure every function/component being refactored has test coverage
58
- 4. Run full test suite to confirm all new tests pass
59
-
60
- ### Exit Criteria
61
-
62
- - [ ] All in-scope code has test coverage for existing behavior
63
- - [ ] No test failures
64
- - [ ] Coverage report saved
65
-
66
- ---
67
-
68
- ## Phase 3: Refactor Implementation
69
-
70
- **Agent:** Appropriate specialist (Developer, UI/UX Expert, etc.)
71
- **Type:** Sub-agent or background (depending on scope)
72
-
73
- ### Steps
74
-
75
- 1. Apply refactoring changes following project conventions
76
- 2. Maintain all existing public APIs and behavior
77
- 3. Run lint and type-check after each significant change
78
- 4. Commit atomic changes (one concern per commit when possible)
79
-
80
- ### File Partition
81
-
82
- The refactoring agent owns only the scoped files. No changes outside the partition.
83
-
84
- ### Exit Criteria
85
-
86
- - [ ] Refactoring complete per scope
87
- - [ ] No lint or type errors
88
- - [ ] All tests still pass (same count, same behavior)
89
-
90
- ---
91
-
92
- ## Phase 4: Verification
93
-
94
- **Agent:** Team Lead (self) + Testing Expert
95
- **Type:** Sub-agent (inline)
96
-
97
- ### Steps
98
-
99
- 1. Run full test suite for the project
100
- 2. Run lint for the project
101
- 3. Run build for the project
102
- 4. Compare metrics against Phase 1 baseline (test count, coverage, bundle size)
103
- 5. For UI refactors: start dev server and visually verify at all breakpoints
104
- 6. Verify no regressions in dependent code
105
-
106
- ### Exit Criteria
107
-
108
- - [ ] All tests pass (count >= baseline)
109
- - [ ] Coverage >= baseline
110
- - [ ] No new lint errors
111
- - [ ] Build succeeds
112
- - [ ] visual verification passed (for UI changes)
113
-
114
- ---
115
-
116
- ## Phase 5: Panel Review (Large Refactors)
117
-
118
- **Agent:** Panel (3 reviewers)
119
- **Type:** Sub-agent (inline)
120
-
121
- ### When to use
122
-
123
- - Refactoring touches >10 files
124
- - Refactoring changes shared library interfaces
125
- - Refactoring affects authentication or security code
126
-
127
- ### Steps
128
-
129
- 1. Load **panel-majority-vote** skill
130
- 2. Run panel with question: "Does this refactoring preserve all existing behavior while improving code quality?"
131
- 3. On BLOCK: extract MUST-FIX items and re-delegate
132
-
133
- ### Exit Criteria
134
-
135
- - [ ] Panel PASS (2/3 majority)
136
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
137
-
138
- ---
139
-
140
- ### Phase 6: Delivery
13
+ ## Delivery
141
14
 
142
15
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
143
- >
144
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.