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
package/src/cli/plan.ts CHANGED
@@ -98,15 +98,21 @@ export function parseFrontmatter(text: string): Record<string, string> {
98
98
  return result
99
99
  }
100
100
 
101
+ /**
102
+ * A planning step's template. They live with the engine, not among the
103
+ * prompts every assistant is given: only the planner runs them, with their
104
+ * input filled in, and as `/oc:` commands they were seven menu entries nobody
105
+ * should pick.
106
+ */
101
107
  export function templatePath(pkgRoot: string, name: string): string {
102
- return join(pkgRoot, 'src', 'orchestrator', 'prompts', `${name}.prompt.md`)
108
+ return join(pkgRoot, 'src', 'cli', 'convoy', 'prompts', `${name}.prompt.md`)
103
109
  }
104
110
 
105
111
  /**
106
112
  * Put the inputs into a template.
107
113
  *
108
114
  * A placeholder is filled only where it stands on a line of its own. The
109
- * instructions in generate-convoy mentioned `{{goal}}` and `{{context}}` in
115
+ * instructions in convoy-plan mentioned `{{goal}}` and `{{context}}` in
110
116
  * passing, and a global replace pasted the whole PRD into those sentences as
111
117
  * well, so every plan carried its PRD twice.
112
118
  *
@@ -154,7 +160,7 @@ function extractMarkdownBody(output: string): string {
154
160
  /**
155
161
  * The JSON in an answer: the last ```json fence if there is one, else the whole
156
162
  * answer. A missing fence used to abort the plan outright, before the one
157
- * retry generate-convoy is allowed; now the parser downstream sees the text and
163
+ * retry convoy-plan is allowed; now the parser downstream sees the text and
158
164
  * reports why it is not a plan.
159
165
  */
160
166
  export function extractJson(output: string): string {
@@ -223,13 +229,13 @@ function prdStem(content: string): string {
223
229
  const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
224
230
 
225
231
  const TEMPLATE_MESSAGES: Record<string, string> = {
226
- 'generate-prd': 'Writing the PRD',
227
- 'validate-prd': 'Checking the PRD',
228
- 'fix-prd': 'Fixing the PRD',
229
- 'assess-complexity': 'Sizing the work',
230
- 'generate-convoy': 'Breaking it into tasks',
231
- 'validate-convoy': 'Reviewing the plan',
232
- 'fix-convoy': 'Fixing the plan',
232
+ 'convoy-prd': 'Writing the PRD',
233
+ 'convoy-prd-review': 'Checking the PRD',
234
+ 'convoy-prd-fix': 'Fixing the PRD',
235
+ 'convoy-assess': 'Sizing the work',
236
+ 'convoy-plan': 'Breaking it into tasks',
237
+ 'convoy-plan-review': 'Reviewing the plan',
238
+ 'convoy-plan-fix': 'Fixing the plan',
233
239
  }
234
240
 
235
241
  /**
@@ -277,7 +283,7 @@ function startProgress(templateName: string): () => void {
277
283
  * standard tier; checking and sizing them is a short read, so it gets economy.
278
284
  */
279
285
  function modelFor(adapter: AgentAdapter, template: string): string | undefined {
280
- const tier = /^(validate-|assess-)/.test(template) ? 'economy' : 'standard'
286
+ const tier = /-review$|^convoy-assess$/.test(template) ? 'economy' : 'standard'
281
287
  return adapter.tierModels?.[tier]
282
288
  }
283
289
 
@@ -291,7 +297,7 @@ function modelFor(adapter: AgentAdapter, template: string): string | undefined {
291
297
  * sizing, the PRD, the checks and the fixes get `low`.
292
298
  */
293
299
  export function effortFor(template: string): 'low' | 'medium' {
294
- return template === 'generate-convoy' ? 'medium' : 'low'
300
+ return template === 'convoy-plan' ? 'medium' : 'low'
295
301
  }
296
302
 
297
303
  /**
package/src/cli/update.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, resolve, relative, join, dirname } from 'node:path'
2
2
  import { existsSync } from 'node:fs'
3
- import { readFile, appendFile, rename, mkdir, writeFile, unlink, copyFile, readdir, rm } from 'node:fs/promises'
3
+ import { readFile, mkdir, writeFile, unlink, copyFile, readdir, rm } from 'node:fs/promises'
4
4
  import { readManifest, writeManifest } from './manifest.js'
5
5
  import { multiselect, confirm, closePrompts, stdinIsExhausted, c } from './prompt.js'
6
6
  import { isLegacyStack, migrateStackConfig, IDE_LABELS } from './types.js'
@@ -720,9 +720,6 @@ export default async function update({
720
720
  // cannot fix it. The population that most needs the new block is the one that
721
721
  // never runs `init` again.
722
722
 
723
- // ── Migrate legacy log files ────────────────────────────────────
724
- await migrateLegacyLogs(projectRoot)
725
-
726
723
  // ── Lessons: one file each, and the index agents read compiled from them ──
727
724
  // Not compiled output of any target — agents read `.opencastle/` directly —
728
725
  // but compiled all the same, and `sync --check` holds it to its sources.
@@ -1045,68 +1042,6 @@ async function migrateCustomizationsDir(projectRoot: string): Promise<void> {
1045
1042
  }
1046
1043
  }
1047
1044
 
1048
- async function migrateLegacyLogs(projectRoot: string): Promise<void> {
1049
- const candidateLogsDirs = [
1050
- resolve(projectRoot, '.github', 'customizations', 'logs'),
1051
- resolve(projectRoot, '.opencastle', 'logs'),
1052
- ]
1053
-
1054
- const typeMap: Record<string, string> = {
1055
- 'sessions.ndjson': 'session',
1056
- 'delegations.ndjson': 'delegation',
1057
- 'reviews.ndjson': 'review',
1058
- 'panels.ndjson': 'panel',
1059
- 'disputes.ndjson': 'dispute',
1060
- }
1061
-
1062
- for (const logsDir of candidateLogsDirs) {
1063
- if (!existsSync(logsDir)) continue
1064
-
1065
- const eventsFile = resolve(logsDir, 'events.ndjson')
1066
- let totalMigrated = 0
1067
-
1068
- for (const [filename, type] of Object.entries(typeMap)) {
1069
- const filePath = resolve(logsDir, filename)
1070
- if (!existsSync(filePath)) continue
1071
-
1072
- let content: string
1073
- try {
1074
- content = await readFile(filePath, 'utf8')
1075
- } catch {
1076
- continue
1077
- }
1078
-
1079
- const lines = content.split('\n').filter((line) => line.trim() !== '')
1080
- if (lines.length === 0) continue
1081
-
1082
- const migratedLines: string[] = []
1083
- for (const line of lines) {
1084
- try {
1085
- const record = JSON.parse(line) as Record<string, unknown>
1086
- if (!record['type']) {
1087
- record['type'] = type
1088
- }
1089
- migratedLines.push(JSON.stringify(record))
1090
- } catch {
1091
- console.warn(` ${c.yellow('⚠')} Skipping malformed JSON line in ${filename}`)
1092
- }
1093
- }
1094
-
1095
- if (migratedLines.length > 0) {
1096
- await appendFile(eventsFile, migratedLines.join('\n') + '\n', 'utf8')
1097
- totalMigrated += migratedLines.length
1098
- }
1099
-
1100
- await rename(filePath, filePath + '.migrated')
1101
- }
1102
-
1103
- if (totalMigrated > 0) {
1104
- console.log(
1105
- ` ${c.green('✓')} Migrated ${c.bold(String(totalMigrated))} records from legacy log files to events.ndjson`
1106
- )
1107
- }
1108
- }
1109
- }
1110
1045
 
1111
1046
  function sameSet(a: Set<string>, b: Set<string>): boolean {
1112
1047
  if (a.size !== b.size) return false
@@ -2,25 +2,17 @@
2
2
 
3
3
  # Workflow Templates
4
4
 
5
- Declarative workflow templates for common orchestration patterns. Inspired by Sandcastle's YAML workflow engine, these templates provide reproducible execution plans that the Team Lead and prompts can reference.
5
+ Templates for recurring kinds of work that need more than the prompts give them: the steps, who does each, and what to check. The Team Lead follows one when a task matches it; in Claude Code each is also a `/oc:workflow-<name>` command.
6
6
 
7
- ## How to Use
7
+ | Template | For |
8
+ |----------|-----|
9
+ | [Database Migration](database-migration.md) | Schema, access-policy and data migrations |
10
+ | [CMS Schema Changes](schema-changes.md) | Content-model changes, and the queries and pages that use them |
11
+ | [Data Pipeline](data-pipeline.md) | Crawl → process → validate → import |
12
+ | [Performance Optimization](performance-optimization.md) | Measure → find the bottleneck → optimize → measure again |
13
+ | [Refactoring](refactoring.md) | Changing code without changing behaviour |
14
+ | [Security Audit](security-audit.md) | A security review, and fixing what it finds |
8
15
 
9
- 1. **Reference in prompts** — When delegating, cite the relevant template and phase
10
- 2. **Customize per task** — Templates define the structure; fill in specific files, agents, and criteria
11
- 3. **Track progress** — Use the phase structure to update session checkpoints
12
-
13
- ## Available Templates
14
-
15
- | Template | Use Case |
16
- |----------|----------|
17
- | [Feature Implementation](feature-implementation.md) | Multi-layer features spanning DB → Query → UI → Tests |
18
- | [Bug Fix](bug-fix.md) | Triage → RCA → Fix → Verify workflow |
19
- | [Data Pipeline](data-pipeline.md) | Scrape → Convert → Enrich → Validate → Import |
20
- | [Security Audit](security-audit.md) | Comprehensive security review workflow |
21
- | [Performance Optimization](performance-optimization.md) | Measure → Analyze → Optimize → Verify |
22
- | [Schema Changes](schema-changes.md) | CMS schema modifications, query updates, content model changes |
23
- | [Database Migration](database-migration.md) | Database migrations, RLS policies, type generation, rollback |
24
- | [Refactoring](refactoring.md) | Safe code refactoring with baseline metrics and behavior preservation |
16
+ Feature work and bug fixes have prompts of their own: `implement-feature` and `bug-fix`.
25
17
 
26
18
  Every template ends by pointing at [the shared delivery phase](shared-delivery-phase.md). The compiler replaces that pointer with the phase itself, so each installed template is complete and the phase is not installed on its own.
@@ -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.