opencastle 1.6.3 → 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 (155) hide show
  1. package/README.md +9 -9
  2. package/bin/cli.mjs +6 -4
  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/bootstrap.js +1 -1
  8. package/dist/cli/bootstrap.js.map +1 -1
  9. package/dist/cli/command-namespace.test.js +4 -21
  10. package/dist/cli/command-namespace.test.js.map +1 -1
  11. package/dist/cli/convoy/engine.js +2 -2
  12. package/dist/cli/convoy/engine.js.map +1 -1
  13. package/dist/cli/convoy/read-model.d.ts +8 -15
  14. package/dist/cli/convoy/read-model.d.ts.map +1 -1
  15. package/dist/cli/convoy/read-model.js +9 -68
  16. package/dist/cli/convoy/read-model.js.map +1 -1
  17. package/dist/cli/convoy/read-model.test.js +6 -25
  18. package/dist/cli/convoy/read-model.test.js.map +1 -1
  19. package/dist/cli/convoy/spec-builder.d.ts +2 -2
  20. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  21. package/dist/cli/convoy/spec-builder.js +1 -1
  22. package/dist/cli/dashboard.js +1 -1
  23. package/dist/cli/dashboard.test.js +10 -2
  24. package/dist/cli/dashboard.test.js.map +1 -1
  25. package/dist/cli/dispatcher.test.js +5 -2
  26. package/dist/cli/dispatcher.test.js.map +1 -1
  27. package/dist/cli/docs-accuracy.test.js +5 -1
  28. package/dist/cli/docs-accuracy.test.js.map +1 -1
  29. package/dist/cli/doctor.d.ts.map +1 -1
  30. package/dist/cli/doctor.js +0 -25
  31. package/dist/cli/doctor.js.map +1 -1
  32. package/dist/cli/pipeline.d.ts +1 -1
  33. package/dist/cli/pipeline.flow.test.js +77 -77
  34. package/dist/cli/pipeline.flow.test.js.map +1 -1
  35. package/dist/cli/pipeline.js +24 -24
  36. package/dist/cli/pipeline.js.map +1 -1
  37. package/dist/cli/plan.d.ts +8 -2
  38. package/dist/cli/plan.d.ts.map +1 -1
  39. package/dist/cli/plan.js +18 -12
  40. package/dist/cli/plan.js.map +1 -1
  41. package/dist/cli/plan.test.js +17 -19
  42. package/dist/cli/plan.test.js.map +1 -1
  43. package/dist/cli/update.d.ts.map +1 -1
  44. package/dist/cli/update.js +1 -58
  45. package/dist/cli/update.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/cli/adapters/adapter-contract.test.ts +1 -1
  48. package/src/cli/adapters/single-file-base.ts +2 -11
  49. package/src/cli/bootstrap.ts +1 -1
  50. package/src/cli/command-namespace.test.ts +5 -22
  51. package/src/cli/convoy/engine.ts +2 -2
  52. package/src/{orchestrator/prompts/assess-complexity.prompt.md → cli/convoy/prompts/convoy-assess.prompt.md} +0 -3
  53. package/src/{orchestrator/prompts/fix-convoy.prompt.md → cli/convoy/prompts/convoy-plan-fix.prompt.md} +0 -3
  54. package/src/{orchestrator/prompts/validate-convoy.prompt.md → cli/convoy/prompts/convoy-plan-review.prompt.md} +0 -3
  55. package/src/{orchestrator/prompts/generate-convoy.prompt.md → cli/convoy/prompts/convoy-plan.prompt.md} +0 -2
  56. package/src/{orchestrator/prompts/fix-prd.prompt.md → cli/convoy/prompts/convoy-prd-fix.prompt.md} +0 -3
  57. package/src/{orchestrator/prompts/validate-prd.prompt.md → cli/convoy/prompts/convoy-prd-review.prompt.md} +0 -3
  58. package/src/{orchestrator/prompts/generate-prd.prompt.md → cli/convoy/prompts/convoy-prd.prompt.md} +0 -3
  59. package/src/cli/convoy/read-model.test.ts +5 -29
  60. package/src/cli/convoy/read-model.ts +11 -71
  61. package/src/cli/convoy/spec-builder.ts +2 -2
  62. package/src/cli/dashboard/dashboard.js +2 -4
  63. package/src/cli/dashboard.test.ts +10 -2
  64. package/src/cli/dashboard.ts +1 -1
  65. package/src/cli/dispatcher.test.ts +6 -2
  66. package/src/cli/docs-accuracy.test.ts +5 -1
  67. package/src/cli/doctor.ts +0 -26
  68. package/src/cli/pipeline.flow.test.ts +78 -78
  69. package/src/cli/pipeline.ts +25 -25
  70. package/src/cli/plan.test.ts +18 -20
  71. package/src/cli/plan.ts +18 -12
  72. package/src/cli/update.ts +1 -66
  73. package/src/orchestrator/agent-workflows/README.md +10 -18
  74. package/src/orchestrator/agent-workflows/data-pipeline.md +7 -140
  75. package/src/orchestrator/agent-workflows/database-migration.md +7 -153
  76. package/src/orchestrator/agent-workflows/performance-optimization.md +6 -119
  77. package/src/orchestrator/agent-workflows/refactoring.md +8 -137
  78. package/src/orchestrator/agent-workflows/schema-changes.md +8 -159
  79. package/src/orchestrator/agent-workflows/security-audit.md +7 -142
  80. package/src/orchestrator/agent-workflows/shared-delivery-phase.md +8 -25
  81. package/src/orchestrator/agents/architect.agent.md +2 -14
  82. package/src/orchestrator/agents/content-engineer.agent.md +8 -10
  83. package/src/orchestrator/agents/data-engineer.agent.md +8 -8
  84. package/src/orchestrator/agents/developer.agent.md +3 -10
  85. package/src/orchestrator/agents/devops-expert.agent.md +0 -3
  86. package/src/orchestrator/agents/performance-expert.agent.md +2 -3
  87. package/src/orchestrator/agents/security-expert.agent.md +10 -12
  88. package/src/orchestrator/agents/team-lead.agent.md +31 -75
  89. package/src/orchestrator/agents/testing-expert.agent.md +3 -6
  90. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -4
  91. package/src/orchestrator/agents/writer.agent.md +0 -3
  92. package/src/orchestrator/customizations/README.md +3 -4
  93. package/src/orchestrator/customizations/agents/agent-registry.md +3 -3
  94. package/src/orchestrator/customizations/agents/skill-matrix.json +6 -42
  95. package/src/orchestrator/instructions/general.instructions.md +10 -37
  96. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -6
  97. package/src/orchestrator/prompts/brainstorm.prompt.md +7 -12
  98. package/src/orchestrator/prompts/bug-fix.prompt.md +19 -100
  99. package/src/orchestrator/prompts/convoy.prompt.md +20 -0
  100. package/src/orchestrator/prompts/create-skill.prompt.md +1 -5
  101. package/src/orchestrator/prompts/implement-feature.prompt.md +22 -93
  102. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +1 -5
  103. package/src/orchestrator/skills/api-patterns/SKILL.md +21 -18
  104. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
  105. package/src/orchestrator/skills/fast-review/SKILL.md +28 -65
  106. package/src/orchestrator/skills/frontend-design/REFERENCE.md +0 -1
  107. package/src/orchestrator/skills/frontend-design/SKILL.md +3 -1
  108. package/src/orchestrator/skills/git-workflow/SKILL.md +18 -34
  109. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +16 -46
  110. package/src/orchestrator/skills/security-hardening/SKILL.md +20 -19
  111. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +2 -2
  112. package/src/orchestrator/skills/self-improvement/SKILL.md +21 -46
  113. package/src/orchestrator/skills/technical-writing/SKILL.md +3 -1
  114. package/src/orchestrator/skills/technical-writing/TEMPLATES.md +23 -0
  115. package/src/orchestrator/skills/testing-workflow/SKILL.md +21 -23
  116. package/src/orchestrator/skills/validation-gates/REFERENCE.md +2 -14
  117. package/src/orchestrator/skills/validation-gates/SKILL.md +10 -88
  118. package/dist/cli/log.d.ts +0 -44
  119. package/dist/cli/log.d.ts.map +0 -1
  120. package/dist/cli/log.js +0 -336
  121. package/dist/cli/log.js.map +0 -1
  122. package/dist/cli/log.test.d.ts +0 -2
  123. package/dist/cli/log.test.d.ts.map +0 -1
  124. package/dist/cli/log.test.js +0 -208
  125. package/dist/cli/log.test.js.map +0 -1
  126. package/src/cli/log.test.ts +0 -228
  127. package/src/cli/log.ts +0 -374
  128. package/src/orchestrator/agent-workflows/bug-fix.md +0 -130
  129. package/src/orchestrator/agent-workflows/feature-implementation.md +0 -232
  130. package/src/orchestrator/instructions/ai-optimization.instructions.md +0 -17
  131. package/src/orchestrator/prompts/quick-refinement.prompt.md +0 -110
  132. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +0 -44
  133. package/src/orchestrator/skills/agent-hooks/SKILL.md +0 -80
  134. package/src/orchestrator/skills/agent-memory/KNOWLEDGE-GRAPH.md +0 -49
  135. package/src/orchestrator/skills/agent-memory/SKILL.md +0 -50
  136. package/src/orchestrator/skills/code-commenting/SKILL.md +0 -18
  137. package/src/orchestrator/skills/context-map/REFERENCE.md +0 -67
  138. package/src/orchestrator/skills/context-map/SKILL.md +0 -71
  139. package/src/orchestrator/skills/decomposition/SKILL.md +0 -103
  140. package/src/orchestrator/skills/documentation-standards/SKILL.md +0 -33
  141. package/src/orchestrator/skills/fast-review/REFERENCE.md +0 -28
  142. package/src/orchestrator/skills/memory-merger/SKILL.md +0 -77
  143. package/src/orchestrator/skills/observability-logging/LOG-SCHEMA.md +0 -238
  144. package/src/orchestrator/skills/observability-logging/SKILL.md +0 -73
  145. package/src/orchestrator/skills/orchestration-protocols/REFERENCE.md +0 -38
  146. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +0 -120
  147. package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +0 -49
  148. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +0 -38
  149. package/src/orchestrator/skills/performance-optimization/SKILL.md +0 -23
  150. package/src/orchestrator/skills/project-consistency/SKILL.md +0 -80
  151. package/src/orchestrator/skills/project-consistency/TEMPLATES.md +0 -35
  152. package/src/orchestrator/skills/react-development/SKILL.md +0 -24
  153. package/src/orchestrator/skills/session-checkpoints/CHECKPOINT-TEMPLATE.md +0 -56
  154. package/src/orchestrator/skills/session-checkpoints/SKILL.md +0 -40
  155. package/src/orchestrator/skills/team-lead-reference/SKILL.md +0 -126
@@ -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.
@@ -1,166 +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: Schema / CMS Changes
3
+ # Workflow: CMS Schema Changes
4
4
 
5
- Structured workflow for CMS schema modifications, query updates, and content model changes.
5
+ For a change to the content model: new types or fields, renames, and the queries and pages that use them. The CMS's own syntax and tools are in its skill and in `.opencastle/stack/<cms>-config.md`.
6
6
 
7
- > **Project config:** For CMS-specific paths, schema locations, and query library details, see the relevant CMS customization file in `.opencastle/stack/`.
7
+ 1. **Analyse** (Content Engineer). Read the current schema and the queries the change affects, and check the content already in the CMS: what does a new required field mean for existing documents? Write down the field mapping, new against existing.
8
+ 2. **Change the schema** (Content Engineer). Add the types and fields with their validation rules, register them, and run the CMS's own schema check. A rename or a removal ships with a migration — or keeps serving the old field under the new name until one does.
9
+ 3. **Update the queries** (Content Engineer or Developer). Every query that reads the changed fields, and the types of their results; test them against real content.
10
+ 4. **Integrate** (Developer). Update the pages and components, handling content that lacks the new field; run the tests, lint and build; check the pages in a browser.
11
+ 5. **Verify** (Team Lead). The content model behaves in the CMS's editor, old content still renders, and the pages show the new fields.
8
12
 
9
- ## Phases
10
-
11
- ```
12
- Phase 1: Schema Analysis (sub-agent, inline)
13
- Phase 2: Schema Implementation (sub-agent or background)
14
- Phase 3: Query Updates (sub-agent, sequential)
15
- Phase 4: Page Integration (sub-agent, sequential)
16
- Phase 5: Verification (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 `chore/<ticket-id>-<short-description>`.
25
-
26
- ---
27
-
28
- ## Phase 1: Schema Analysis
29
-
30
- **Agent:** Content Engineer (via sub-agent)
31
- **Type:** Sub-agent (inline)
32
-
33
- ### Steps
34
-
35
- 1. Read current CMS schema to understand existing types
36
- 2. Check the data model documentation (Key Documentation in `.opencastle/project.instructions.md`) for field documentation
37
- 3. Check the query library (see CMS customization) for queries that will be affected
38
- 4. Verify schema changes don't conflict with existing content in the CMS
39
- 5. Document field mapping (new vs existing fields)
40
- 6. Create tracker issue with schema change details
41
-
42
- ### Exit Criteria
43
-
44
- - [ ] Existing schema understood
45
- - [ ] Impact on data queries assessed
46
- - [ ] Impact on existing content assessed
47
- - [ ] Tracker issue created
48
- - [ ] Approach decided (new type vs modify existing)
49
-
50
- ---
51
-
52
- ## Phase 2: Schema Implementation
53
-
54
- **Agent:** Content Engineer
55
- **Type:** Sub-agent (simple changes) or Background (complex schema additions)
56
-
57
- ### File Partition
58
-
59
- > See the CMS customization file for project-specific paths.
60
-
61
- - CMS schema directory — schema type files
62
- - CMS config file — schema registry
63
-
64
- ### Steps
65
-
66
- 1. Create or modify schema type files using `defineType` / `defineField`
67
- 2. Add validation rules where appropriate
68
- 3. Update the schema index to register new types
69
- 4. Deploy schema (see CMS customization for deploy command)
70
- 5. Verify in CMS studio that the schema renders correctly
71
- 6. Create any necessary content for new types
72
-
73
- ### Exit Criteria
74
-
75
- - [ ] Schema files created/modified
76
- - [ ] Schema deployed successfully
77
- - [ ] Schema renders correctly in CMS Studio
78
- - [ ] Existing content not broken by changes
79
- - [ ] Output contract returned
80
-
81
- ---
82
-
83
- ## Phase 3: Query Updates
84
-
85
- **Agent:** Content Engineer or Developer (via sub-agent)
86
- **Type:** Sub-agent (sequential — depends on Phase 2)
87
-
88
- ### File Partition
89
-
90
- > See the CMS customization file for project-specific query library paths.
91
-
92
- - Query library — data query files
93
-
94
- ### Steps
95
-
96
- 1. Update data queries to include new/modified fields
97
- 2. Update TypeScript types for query results
98
- 3. Test queries in the CMS query tool
99
- 4. Run query library tests
100
-
101
- ### Exit Criteria
102
-
103
- - [ ] Data queries updated
104
- - [ ] TypeScript types match schema
105
- - [ ] Queries tested in CMS query tool
106
- - [ ] Query tests pass
107
- - [ ] Output contract returned
108
-
109
- ---
110
-
111
- ## Phase 4: Page Integration
112
-
113
- **Agent:** Developer (via sub-agent)
114
- **Type:** Sub-agent (sequential — depends on Phase 3)
115
-
116
- ### File Partition
117
-
118
- - Varies by feature — typically app page routes and shared UI components
119
-
120
- ### Steps
121
-
122
- 1. Update components to use new/modified fields
123
- 2. Handle missing data gracefully (backwards compatibility)
124
- 3. Run lint + test + build for affected projects
125
- 4. Start dev server and verify in browser
126
-
127
- ### Exit Criteria
128
-
129
- - [ ] Components updated
130
- - [ ] Missing data handled gracefully
131
- - [ ] Lint + test + build pass
132
- - [ ] Visual verification in browser
133
- - [ ] Output contract returned
134
-
135
- ---
136
-
137
- ## Phase 5: Verification
138
-
139
- **Agent:** Team Lead (self)
140
- **Type:** Direct verification
141
-
142
- ### Steps
143
-
144
- 1. Review all output contracts
145
- 2. Verify in CMS that content can be created/edited
146
- 3. Start dev server and verify pages render correctly
147
- 4. Check both apps if shared schema/queries changed
148
- 5. Verify data model documentation is updated
149
- 6. Move tracker issue to Done
150
-
151
- ### Exit Criteria
152
-
153
- - [ ] Schema works in CMS
154
- - [ ] Pages render correctly in browser
155
- - [ ] Both apps verified (if shared code changed)
156
- - [ ] Data model documentation updated (if applicable)
157
- - [ ] Tracker issue moved to Done
158
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
159
-
160
- ---
161
-
162
- ### Phase 6: Delivery
13
+ ## Delivery
163
14
 
164
15
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
165
- >
166
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.
@@ -2,149 +2,14 @@
2
2
 
3
3
  # Workflow: Security Audit
4
4
 
5
- Comprehensive security review workflow for auth, RLS, headers, and API security.
5
+ For a security review of the whole application or one area of it, and fixing what it finds. The rules it checks against: **security-hardening**, and the skills of the stack's database and framework.
6
6
 
7
- ## Phases
7
+ 1. **Scope** (Team Lead). The whole application or one area; the known issues; the auth flow; every endpoint and server action.
8
+ 2. **Automated checks** (Security Expert). Lint with security rules, a secret scan (**validation-gates**), the dependency audit, the security headers and CSP of a running build, access control enabled on every table, and every place that renders raw HTML.
9
+ 3. **Manual review** (Security Expert). Authentication and sessions; authorization and route protection; access policies; input validation on every endpoint; CSRF; rate limiting; error responses; OAuth callbacks, state and PKCE; headers; cookie flags. Each finding rated Critical, High, Medium or Low.
10
+ 4. **Panel** — **panel-majority-vote** on the findings and the files they name, asking "Are there unmitigated vulnerabilities in this code?"
11
+ 5. **Fix** (Security Expert, or the Developer for application code). Critical and High first; an issue in the tracker for each Medium or Low left for later; the panel again if it blocked. A risk accepted on purpose goes in `.opencastle/KNOWN-ISSUES.md`.
8
12
 
9
- ```
10
- Phase 1: Scope & Context (sub-agent, inline)
11
- Phase 2: Automated Checks (sub-agent, inline)
12
- Phase 3: Manual Review (background agent)
13
- Phase 4: Panel Review (sub-agent, inline)
14
- Phase 5: Remediation (sub-agent or background)
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: `fix/<ticket-id>-<short-description>` for remediations.
23
-
24
- ---
25
-
26
- ## Phase 1: Scope & Context
27
-
28
- **Agent:** Team Lead (self)
29
- **Type:** Direct research
30
-
31
- ### Steps
32
-
33
- 1. Define audit scope (full audit vs. targeted area)
34
- 2. Read `.opencastle/project.instructions.md` security sections
35
- 3. Read `.opencastle/KNOWN-ISSUES.md` for existing security items
36
- 4. Check current CSP configuration in `next.config.js`
37
- 5. Review auth flow (see database/auth customization for library paths)
38
- 6. Map all API routes and Server Actions
39
- 7. Create tracker issue for the audit
40
-
41
- ### Exit Criteria
42
-
43
- - [ ] Scope defined (which apps, libs, routes)
44
- - [ ] Existing security docs reviewed
45
- - [ ] Attack surface mapped
46
- - [ ] Tracker issue created
47
-
48
- ---
49
-
50
- ## Phase 2: Automated Checks
51
-
52
- **Agent:** Security Expert (via sub-agent)
53
- **Type:** Sub-agent (inline)
54
-
55
- ### Steps
56
-
57
- 1. Run lint with security rules
58
- 2. Check for hardcoded secrets (`grep -r "password\|secret\|api_key"`)
59
- 3. Validate CSP headers
60
- 4. Check dependency vulnerabilities (`yarn audit`)
61
- 5. Verify RLS is enabled on all database tables
62
- 6. Check for `dangerouslySetInnerHTML` usage
63
-
64
- ### Exit Criteria
65
-
66
- - [ ] No hardcoded secrets found
67
- - [ ] CSP headers valid
68
- - [ ] Dependency audit clean (or known issues documented)
69
- - [ ] RLS enabled on all tables
70
- - [ ] No unsafe HTML injection points
71
- - [ ] Findings documented
72
-
73
- ---
74
-
75
- ## Phase 3: Manual Review
76
-
77
- **Agent:** Security Expert
78
- **Type:** Background agent
79
-
80
- ### Checklist
81
-
82
- - [ ] **Authentication:** Session handling, token refresh, logout flow
83
- - [ ] **Authorization:** Role checks, route protection, middleware
84
- - [ ] **RLS Policies:** Default-deny, explicit-allow, policy correctness
85
- - [ ] **Input Validation:** Zod schemas on all API routes and Server Actions
86
- - [ ] **CSRF Protection:** Server Actions use form tokens
87
- - [ ] **Rate Limiting:** Proxy layer, per-IP limits, fingerprinting
88
- - [ ] **Error Handling:** No sensitive data in error responses
89
- - [ ] **OAuth:** Callback URLs, state parameter, PKCE
90
- - [ ] **Headers:** HSTS, X-Content-Type-Options, X-Frame-Options
91
- - [ ] **Cookies:** HttpOnly, Secure, SameSite flags
92
-
93
- ### Exit Criteria
94
-
95
- - [ ] All checklist items reviewed
96
- - [ ] Findings categorized by severity
97
- - [ ] Output contract returned with findings list
98
-
99
- ---
100
-
101
- ## Phase 4: Panel Review
102
-
103
- **Agent:** Team Lead (orchestrates panel)
104
- **Type:** Sub-agent (inline)
105
-
106
- ### Steps
107
-
108
- 1. Load **panel-majority-vote** skill
109
- 2. Provide Phase 3 findings and affected files as in-scope artifacts
110
- 3. Panel question: "Are there any unmitigated security vulnerabilities in the reviewed code?"
111
- 4. Run 3 reviewer sub-agents
112
- 5. Consolidate results
113
-
114
- ### Exit Criteria
115
-
116
- - [ ] Panel completed (PASS or BLOCK)
117
- - [ ] Panel report linked to tracker issue
118
- - [ ] If BLOCK: MUST-FIX items extracted
119
-
120
- ---
121
-
122
- ## Phase 5: Remediation
123
-
124
- **Agent:** Security Expert or Developer (depends on finding)
125
- **Type:** Sub-agent (critical fixes) or Background (non-critical)
126
-
127
- ### Steps
128
-
129
- 1. Fix Critical and High severity findings first
130
- 2. Create separate tracker issues for Medium/Low findings if not fixing now
131
- 3. Run verification after each fix
132
- 4. Re-run panel review if initial panel BLOCKed
133
- 5. Update `.opencastle/KNOWN-ISSUES.md` for any accepted risks
134
-
135
- ### Exit Criteria
136
-
137
- - [ ] Critical/High findings remediated
138
- - [ ] Medium/Low findings tracked in tracker
139
- - [ ] Panel review passed (if applicable)
140
- - [ ] Known issues updated for accepted risks
141
- - [ ] All tracker issues updated
142
- - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
143
-
144
- ---
145
-
146
- ### Phase 6: Delivery
13
+ ## Delivery
147
14
 
148
15
  > **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**
149
- >
150
- > Commit → Push → PR → tracker linkage. Team Lead owns delivery.
@@ -2,34 +2,17 @@
2
2
 
3
3
  # Shared Delivery Phase
4
4
 
5
- This phase is referenced by all workflow templates. It covers the final delivery steps after all implementation and verification is complete.
5
+ The last phase of every workflow template, once the work is implemented and verified.
6
6
 
7
7
  ## Steps
8
8
 
9
- 1. **Commit all changes** to the feature branch with tracker issue IDs in commit messages
10
- 2. **Push the branch** to origin: `git push -u origin <branch-name>`
11
- 3. **Open a PR** using `gh` CLI (always use `GH_PAGER=cat` to prevent pager issues):
9
+ 1. **Commit** to the feature branch, with the tracker issue ID in the messages when there is one.
10
+ 2. **Push** it: `git push -u origin <branch>`.
11
+ 3. **Open a pull request**, with the body written to a file first so the shell cannot mangle it:
12
12
  ```bash
13
- GH_PAGER=cat gh pr create --base main --title "TAS-XX: Short description" --body "Resolves TAS-XX"
13
+ GH_PAGER=cat gh pr create --base main --title "<title>" --body-file /tmp/pr-body.md
14
14
  ```
15
- 4. **Do NOT merge** — PRs are opened for human review only
16
- 5. **Update tracker issues** with the PR URL for traceability
17
- 6. **Clean up session checkpoint** if one exists
15
+ 4. **Do NOT merge** — a person reviews and merges it.
16
+ 5. **Link it** from the tracker issue, when there is one.
18
17
 
19
- ## Branch & Delivery Strategy
20
-
21
- The **Team Lead owns delivery**, not individual specialist agents:
22
-
23
- - **Team Lead creates the branch** in Phase 1 before any delegation
24
- - **Sub-agents** work directly on the Team Lead's branch (shared working tree)
25
- - **Background agents** work in isolated worktrees branched from the feature branch
26
- - **Team Lead merges worktrees back** during verification
27
- - **Only the Team Lead pushes** to the branch and opens the PR
28
-
29
- ## Exit Criteria
30
-
31
- - [ ] All changes committed with tracker issue IDs in messages
32
- - [ ] Branch pushed to origin
33
- - [ ] PR opened on GitHub (NOT merged)
34
- - [ ] Tracker issues updated with PR URL
35
- - [ ] All project issues marked Done or Cancelled
18
+ Whoever coordinates the work owns delivery: the Team Lead creates the branch before delegating, sub-agents work on that branch, and only the Team Lead pushes and opens the pull request.
@@ -9,8 +9,7 @@ user-invocable: false
9
9
  # Software Architect
10
10
 
11
11
  Strategic decisions, system design, ADRs, technology evaluation, roadmap. Advises;
12
- never implements. Project focus: multi-app scalability, search architecture, data
13
- architecture, performance at scale, i18n, monetization.
12
+ never implements.
14
13
 
15
14
  ## Skills
16
15
 
@@ -19,7 +18,7 @@ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
19
18
  ## Rules
20
19
 
21
20
  1. **Never propose a big-bang rewrite** — find the incremental path, or defer the decision
22
- 2. **Every architectural decision gets an ADR** in `.opencastle/`
21
+ 2. **Every architectural decision gets an ADR**, where the project keeps them — or `.opencastle/project/decisions.md`, created with the first one (the ADR template is in **technical-writing**)
23
22
  3. **Check shared vs. app-specific boundaries** before recommending anything multi-app; map the dependency graph first
24
23
  4. **No clear winner → document the trade-offs and let the team decide.** Do not force a call
25
24
 
@@ -27,14 +26,6 @@ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
27
26
 
28
27
  Apps → libs (never reverse) · UI never fetches data · no barrel files · co-locate code changing together
29
28
 
30
- ## ADR Template
31
-
32
- ```markdown
33
- ## ADR-XXX: [Title]
34
- **Date:** YYYY-MM-DD **Status:** Proposed | Accepted | Deprecated | Superseded
35
- **Context:** … **Decision:** … **Consequences:** … **Alternatives Considered:** …
36
- ```
37
-
38
29
  ## Agent-Native Review
39
30
 
40
31
  For new features and APIs, assess whether an AI agent can consume them:
@@ -56,6 +47,3 @@ Implementing changes · writing tests · DB/schema changes · deploying infrastr
56
47
 
57
48
  1. **Assessment** — APPROVE / CONCERNS / RETHINK + rationale
58
49
  2. **Strengths** · **Risks** (likelihood + impact) · **Alternatives** · **Action Items**
59
-
60
- End with the standard closing items from the project instructions: observability
61
- logged, discovered issues, lessons applied.
@@ -16,14 +16,15 @@ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
16
16
 
17
17
  ## Rules
18
18
 
19
- 1. **Run `get_schema` before writing any query.** Trust local schema files over the remote schema.
20
- 2. **Check whether a field is an array** before projecting it.
19
+ The CMS's own syntax, tools and gotchas are in the skill bound to the **cms** slot.
20
+
21
+ 1. **Read the schema before writing a query** — the schema files in the repository, or the CMS's schema tool; trust the local files over the remote.
22
+ 2. **Check whether a field is a list** before projecting it.
21
23
  3. **Queries live in the shared query library**, never inline in components. Document non-obvious filters inline.
22
- 4. **Exclude drafts** with `!(_id in path("drafts.**"))`. A query returning `null` for content you know exists is almost always this filter missing. Drafts carry a `drafts.` ID prefix — never mix draft and published content in one result.
23
- 5. **Validate queries in the Vision tool before deploying**, and run `sanity schema validate` for schema changes — a failed deploy is usually a circular reference or a missing `type` field.
24
- 6. **Renaming or removing a field breaks backward compat** unless a migration ships with it. During a rename, project the old field: `| { "newName": oldName }`.
25
- 7. **New API endpoints belong to Developer** — hand off rather than adding routes.
26
- 8. `defineType` / `defineField` for schema; `references()` for relational fields.
24
+ 4. **Never mix draft and published content** in one result. A query that returns nothing for content you know exists is usually missing the draft filter.
25
+ 5. **Validate a query against real content, and a schema change with the CMS's own check, before deploying.**
26
+ 6. **Renaming or removing a field breaks backward compatibility** unless a migration ships with it. During a rename, serve the old field under the new name.
27
+ 7. **New API endpoints belong to the Developer** — hand off rather than adding routes.
27
28
 
28
29
  ## Verification
29
30
 
@@ -39,6 +40,3 @@ UI components · DB migrations mirroring CMS data · E2E tests for CMS pages ·
39
40
  2. **Queries** — new/modified queries with purpose
40
41
  3. **Verification** — schema deploy result, query test results
41
42
  4. **Migration Notes** — any data migration needed
42
-
43
- End with the standard closing items from the project instructions: observability
44
- logged, discovered issues, lessons applied.
@@ -18,13 +18,16 @@ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
18
18
  ## Rules — schema and migrations
19
19
 
20
20
  1. **Always write a migration.** Never modify a schema directly.
21
- 2. **Every table gets a security policy.** No exceptions. Derive identity from
22
- `auth.uid()`, never from a client-supplied user id.
21
+ 2. **Guard every table** with the access control the database offers —
22
+ row-level security, rules, or checks in the one data layer every query goes
23
+ through. Derive identity from the verified session, never from a
24
+ client-supplied user id. The database's own syntax is in its skill.
23
25
  3. **Test policies from every relevant role** — anonymous, authenticated, and any
24
26
  custom role. A policy that was never exercised from an anonymous session is
25
27
  untested.
26
- 4. **Migrations must be re-runnable** — guard with `IF NOT EXISTS` and `IF EXISTS`.
27
- 5. **Document the rollback** as reverse SQL, in the same change.
28
+ 4. **Migrations must be re-runnable** — guard with `IF NOT EXISTS` and `IF EXISTS`,
29
+ or the migration tool's own checks.
30
+ 5. **Document the rollback** — the reverse migration — in the same change.
28
31
  6. **Index what you query.** `EXPLAIN ANALYZE` a slow query; a sequential scan on
29
32
  a large table is a missing index.
30
33
 
@@ -57,9 +60,6 @@ production deployment
57
60
 
58
61
  1. **Migrations** — files and what each changes
59
62
  2. **Policies** — the access intent, and which roles were tested
60
- 3. **Rollback** — the reverse SQL
63
+ 3. **Rollback** — the reverse migration
61
64
  4. **Data impact** — rows affected, records skipped and why
62
65
  5. **Verification** — apply results, test queries, pipeline counts
63
-
64
- End with the standard closing items from the project instructions: observability
65
- logged, discovered issues, lessons applied.
@@ -23,19 +23,15 @@ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
23
23
  4. **Co-locate** component, styles, and tests in one directory. Shared components → UI library; queries → data layer.
24
24
  5. **Never invent a design value.** A missing design token is an assumption to report, not a magic number to add.
25
25
  6. **Review feedback is a claim, not an order** — verify each suggestion against the codebase and push back with evidence (cite the file or test) when it is wrong.
26
- 7. Multi-agent convoy work → load **project-consistency**.
26
+ 7. Several agents building UI at once: the foundation comes first (**frontend-design**).
27
27
 
28
28
  ## File Size Limits
29
29
 
30
30
  Target ≤ 500 lines/file. 500–800: use line-range reads. **>800 → propose a split before editing.**
31
31
 
32
- ## API Routes
32
+ ## API work
33
33
 
34
- 1. **Define the contract before the handler** — request and response shapes, status codes, error cases. Writing the handler first is how inconsistent APIs happen.
35
- 2. **Validate every input with a schema.** Client input is never trusted.
36
- 3. **Return typed error codes**, not a generic 500: 422 for validation failures, 409 for conflicts.
37
- 4. **Keep conventions uniform** across endpoints — naming, error shape, pagination. If existing routes already disagree, document the variance and propose one way forward rather than adding a third.
38
- 5. **Version from the start.** Removing a version later is easier than adding one retroactively.
34
+ Endpoints, server actions and external APIs follow **api-patterns**: the contract before the handler, a schema on every input.
39
35
 
40
36
  ## Verification
41
37
 
@@ -51,6 +47,3 @@ Database migrations · security policy changes · CMS schema changes · E2E/brow
51
47
  2. **Verification Results** — lint/test/build pass/fail + error count
52
48
  3. **Acceptance Criteria Status** — checklist, each item ✅ or ❌
53
49
  4. **Assumptions Made** — decisions not explicitly specified
54
-
55
- End with the standard closing items from the project instructions: observability
56
- logged, discovered issues, lessons applied.
@@ -49,6 +49,3 @@ Application code · business logic · DB migrations · RLS policies · CMS schem
49
49
  3. **Verification** — build result, deployment status, health check
50
50
  4. **Rollback Plan** — how to revert if the deployment causes issues
51
51
  5. **Monitoring** — what to watch after deployment
52
-
53
- End with the standard closing items from the project instructions: observability
54
- logged, discovered issues, lessons applied.