opencastle 0.10.7 → 0.12.0

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 (132) hide show
  1. package/README.md +4 -0
  2. package/bin/cli.mjs +4 -0
  3. package/dist/cli/convoy/events.d.ts +10 -0
  4. package/dist/cli/convoy/events.d.ts.map +1 -0
  5. package/dist/cli/convoy/events.js +27 -0
  6. package/dist/cli/convoy/events.js.map +1 -0
  7. package/dist/cli/convoy/events.test.d.ts +2 -0
  8. package/dist/cli/convoy/events.test.d.ts.map +1 -0
  9. package/dist/cli/convoy/events.test.js +94 -0
  10. package/dist/cli/convoy/events.test.js.map +1 -0
  11. package/dist/cli/convoy/store.d.ts +23 -0
  12. package/dist/cli/convoy/store.d.ts.map +1 -0
  13. package/dist/cli/convoy/store.js +210 -0
  14. package/dist/cli/convoy/store.js.map +1 -0
  15. package/dist/cli/convoy/store.test.d.ts +2 -0
  16. package/dist/cli/convoy/store.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/store.test.js +387 -0
  18. package/dist/cli/convoy/store.test.js.map +1 -0
  19. package/dist/cli/convoy/types.d.ts +56 -0
  20. package/dist/cli/convoy/types.d.ts.map +1 -0
  21. package/dist/cli/convoy/types.js +2 -0
  22. package/dist/cli/convoy/types.js.map +1 -0
  23. package/dist/cli/dashboard.d.ts.map +1 -1
  24. package/dist/cli/dashboard.js +5 -1
  25. package/dist/cli/dashboard.js.map +1 -1
  26. package/dist/cli/init.test.js +1 -1
  27. package/dist/cli/init.test.js.map +1 -1
  28. package/dist/cli/lesson.d.ts +17 -0
  29. package/dist/cli/lesson.d.ts.map +1 -0
  30. package/dist/cli/lesson.js +294 -0
  31. package/dist/cli/lesson.js.map +1 -0
  32. package/dist/cli/log.d.ts +7 -0
  33. package/dist/cli/log.d.ts.map +1 -0
  34. package/dist/cli/log.js +131 -0
  35. package/dist/cli/log.js.map +1 -0
  36. package/dist/cli/run/executor.js.map +1 -1
  37. package/dist/cli/run/executor.test.js +1 -0
  38. package/dist/cli/run/executor.test.js.map +1 -1
  39. package/dist/cli/run/loop-executor.d.ts +3 -0
  40. package/dist/cli/run/loop-executor.d.ts.map +1 -0
  41. package/dist/cli/run/loop-executor.js +155 -0
  42. package/dist/cli/run/loop-executor.js.map +1 -0
  43. package/dist/cli/run/loop-reporter.d.ts +6 -0
  44. package/dist/cli/run/loop-reporter.d.ts.map +1 -0
  45. package/dist/cli/run/loop-reporter.js +112 -0
  46. package/dist/cli/run/loop-reporter.js.map +1 -0
  47. package/dist/cli/run/reporter.d.ts.map +1 -1
  48. package/dist/cli/run/reporter.js +28 -1
  49. package/dist/cli/run/reporter.js.map +1 -1
  50. package/dist/cli/run/schema.d.ts +4 -0
  51. package/dist/cli/run/schema.d.ts.map +1 -1
  52. package/dist/cli/run/schema.js +178 -50
  53. package/dist/cli/run/schema.js.map +1 -1
  54. package/dist/cli/run/schema.test.js +598 -1
  55. package/dist/cli/run/schema.test.js.map +1 -1
  56. package/dist/cli/run.d.ts.map +1 -1
  57. package/dist/cli/run.js +84 -3
  58. package/dist/cli/run.js.map +1 -1
  59. package/dist/cli/types.d.ts +78 -1
  60. package/dist/cli/types.d.ts.map +1 -1
  61. package/dist/cli/update.d.ts.map +1 -1
  62. package/dist/cli/update.js +54 -1
  63. package/dist/cli/update.js.map +1 -1
  64. package/package.json +3 -2
  65. package/src/cli/convoy/events.test.ts +118 -0
  66. package/src/cli/convoy/events.ts +41 -0
  67. package/src/cli/convoy/store.test.ts +446 -0
  68. package/src/cli/convoy/store.ts +308 -0
  69. package/src/cli/convoy/types.ts +68 -0
  70. package/src/cli/dashboard.ts +5 -1
  71. package/src/cli/init.test.ts +1 -1
  72. package/src/cli/lesson.ts +312 -0
  73. package/src/cli/log.ts +133 -0
  74. package/src/cli/run/executor.test.ts +1 -0
  75. package/src/cli/run/executor.ts +8 -8
  76. package/src/cli/run/loop-executor.ts +199 -0
  77. package/src/cli/run/loop-reporter.ts +125 -0
  78. package/src/cli/run/reporter.ts +30 -1
  79. package/src/cli/run/schema.test.ts +704 -3
  80. package/src/cli/run/schema.ts +206 -56
  81. package/src/cli/run.ts +82 -5
  82. package/src/cli/types.ts +87 -1
  83. package/src/cli/update.ts +62 -1
  84. package/src/dashboard/dist/index.html +14 -15
  85. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  86. package/src/dashboard/scripts/generate-seed-data.ts +23 -43
  87. package/src/dashboard/seed-data/events.ndjson +104 -0
  88. package/src/dashboard/src/pages/index.astro +14 -15
  89. package/src/orchestrator/agents/api-designer.agent.md +1 -1
  90. package/src/orchestrator/agents/architect.agent.md +1 -1
  91. package/src/orchestrator/agents/content-engineer.agent.md +1 -1
  92. package/src/orchestrator/agents/copywriter.agent.md +1 -1
  93. package/src/orchestrator/agents/data-expert.agent.md +1 -1
  94. package/src/orchestrator/agents/database-engineer.agent.md +1 -1
  95. package/src/orchestrator/agents/developer.agent.md +1 -1
  96. package/src/orchestrator/agents/devops-expert.agent.md +1 -1
  97. package/src/orchestrator/agents/documentation-writer.agent.md +1 -1
  98. package/src/orchestrator/agents/performance-expert.agent.md +1 -1
  99. package/src/orchestrator/agents/release-manager.agent.md +1 -1
  100. package/src/orchestrator/agents/security-expert.agent.md +1 -1
  101. package/src/orchestrator/agents/seo-specialist.agent.md +1 -1
  102. package/src/orchestrator/agents/session-guard.agent.md +9 -21
  103. package/src/orchestrator/agents/team-lead.agent.md +8 -34
  104. package/src/orchestrator/agents/testing-expert.agent.md +1 -1
  105. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -1
  106. package/src/orchestrator/customizations/AGENT-PERFORMANCE.md +11 -12
  107. package/src/orchestrator/customizations/DISPUTES.md +2 -2
  108. package/src/orchestrator/customizations/README.md +1 -3
  109. package/src/orchestrator/customizations/logs/README.md +66 -14
  110. package/src/orchestrator/instructions/ai-optimization.instructions.md +21 -132
  111. package/src/orchestrator/instructions/general.instructions.md +35 -181
  112. package/src/orchestrator/plugins/nx/SKILL.md +1 -1
  113. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -8
  114. package/src/orchestrator/prompts/bug-fix.prompt.md +4 -4
  115. package/src/orchestrator/prompts/implement-feature.prompt.md +3 -3
  116. package/src/orchestrator/prompts/quick-refinement.prompt.md +3 -3
  117. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +1 -1
  118. package/src/orchestrator/skills/agent-hooks/SKILL.md +11 -11
  119. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  120. package/src/orchestrator/skills/fast-review/SKILL.md +4 -19
  121. package/src/orchestrator/skills/git-workflow/SKILL.md +72 -0
  122. package/src/orchestrator/skills/memory-merger/SKILL.md +1 -1
  123. package/src/orchestrator/skills/observability-logging/SKILL.md +129 -0
  124. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +2 -2
  125. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +4 -7
  126. package/src/orchestrator/skills/self-improvement/SKILL.md +13 -26
  127. package/src/orchestrator/skills/team-lead-reference/SKILL.md +2 -2
  128. package/src/orchestrator/customizations/logs/delegations.ndjson +0 -1
  129. package/src/orchestrator/customizations/logs/panels.ndjson +0 -1
  130. package/src/orchestrator/customizations/logs/reviews.ndjson +0 -0
  131. package/src/orchestrator/customizations/logs/sessions.ndjson +0 -1
  132. /package/src/orchestrator/customizations/logs/{disputes.ndjson → events.ndjson} +0 -0
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: observability-logging
3
+ description: "Session logging, delegation records, review/panel/dispute NDJSON logging, pre-response checklists. Load before responding to verify all logs are written."
4
+ ---
5
+
6
+ # Observability Logging
7
+
8
+ ## Observability Logging (Mandatory)
9
+
10
+ > **⛔ HARD GATE — This is a blocking requirement, not a suggestion.**
11
+ > Do NOT respond to the user until you have appended the required log records.
12
+ > A session without log records is a failed session — regardless of code quality.
13
+
14
+ **Every agent MUST log every session to the observability NDJSON files.** No exceptions. No threshold. No "too small to log." The dashboard depends on this data.
15
+
16
+ ### What to log
17
+
18
+ | File | Event types | Who appends | When |
19
+ |------|------------|------------|------|
20
+ | `events.ndjson` | `session`, `delegation`, `review`, `panel`, `dispute` | All agents / Team Lead / Panel runner | After every applicable event — use `--type` to discriminate |
21
+
22
+ See `.github/customizations/logs/README.md` for the full schema of each record type.
23
+
24
+ ### How to log
25
+
26
+ Use the `opencastle log` CLI to append events to `.github/customizations/logs/events.ndjson`. When the Team Lead works directly, use the agent role that best describes the work (e.g., `--agent Developer`, `--agent "UI-UX Expert"`). If a single conversation involves multiple distinct tasks, log one record per task.
27
+
28
+ **Session record** (ALL agents, EVERY session):
29
+ ```sh
30
+ opencastle log --type session --agent Developer --model claude-opus-4-6 \
31
+ --task "Fix login redirect bug" --outcome success --duration_min 15 \
32
+ --files_changed 3 --retries 0
33
+ ```
34
+
35
+ **Delegation record** (Team Lead only, **immediately after each delegation — not at session end**):
36
+ ```sh
37
+ opencastle log --type delegation --session_id feat/prj-57 --agent Developer \
38
+ --model claude-sonnet-4-6 --tier quality --mechanism sub-agent \
39
+ --tracker_issue PRJ-57 --outcome success --retries 0 --phase 2 \
40
+ --file_partition "src/components/"
41
+ ```
42
+ Verify: `tail -1 .github/customizations/logs/events.ndjson`
43
+
44
+ > **`model` and `tier` must reflect the delegated agent's assignment from the agent registry** — not the Team Lead's own model.
45
+
46
+ **Fast review record** (Team Lead, **immediately after each fast review**):
47
+ ```sh
48
+ opencastle log --type review --tracker_issue PRJ-42 --agent Developer \
49
+ --reviewer_model gpt-5-mini --verdict pass --attempt 1 \
50
+ --issues_critical 0 --issues_major 0 --issues_minor 2 \
51
+ --confidence high --escalated false --duration_sec 45
52
+ ```
53
+ Verify: `tail -1 .github/customizations/logs/events.ndjson`
54
+
55
+ **Panel record** (Panel runner, **immediately after each panel majority vote**):
56
+ ```sh
57
+ opencastle log --type panel --panel_key auth-review --verdict pass \
58
+ --pass_count 3 --block_count 0 --must_fix 0 --should_fix 3 \
59
+ --reviewer_model claude-opus-4-6 --weighted false --attempt 1 \
60
+ --tracker_issue PRJ-42 --artifacts_count 5
61
+ ```
62
+ Verify: `tail -1 .github/customizations/logs/events.ndjson`
63
+
64
+ **Dispute record** (Team Lead, **immediately after each dispute**):
65
+ ```sh
66
+ opencastle log --type dispute --dispute_id DSP-001 --tracker_issue PRJ-42 \
67
+ --priority high --trigger panel-3x-block --implementing_agent Developer \
68
+ --reviewing_agents "Reviewer,Panel (3x)" --total_attempts 6 --status pending
69
+ ```
70
+ Verify: `tail -1 .github/customizations/logs/events.ndjson`
71
+
72
+ ### Pre-Response Logging Checklist
73
+
74
+ **STOP before responding to the user.** Verify each applicable item:
75
+
76
+ - [ ] **Session logged** — `events.ndjson` has a new `session` record for this session (ALWAYS required)
77
+ - [ ] **Delegations logged** — `events.ndjson` has a `delegation` record for **each** delegation (Team Lead only). Count delegations → count records → must match
78
+ - [ ] **Reviews logged** — `events.ndjson` has a `review` record for **each** fast review performed. Count reviews → count records → must match
79
+ - [ ] **Panels logged** — `events.ndjson` has a `panel` record for **each** panel review performed. Count panels → count records → must match
80
+ - [ ] **Disputes logged** — `events.ndjson` has a `dispute` record for **each** dispute created. Count disputes → count records → must match
81
+
82
+ If ANY required log is missing, run `opencastle log --type <type> ...` NOW before responding.
83
+
84
+ ### Rules
85
+
86
+ - **Log before yielding to the user** — logging is the LAST action before responding. This is Constitution rule #6.
87
+ - **Log per task**, not per conversation. Multiple tasks = multiple records.
88
+ - **Never batch-log retrospectively** across sessions.
89
+ - **Verify the append succeeded** — if unsure, `tail -1` the file to confirm.
90
+
91
+ ## Universal Agent Rules
92
+
93
+ These rules apply to ALL specialist agents automatically. **Do not duplicate them in individual agent files.**
94
+
95
+ 1. **Never delegate** — Specialist agents complete their own work and return results. Never invoke the Team Lead or spawn sub-agents. If work requires another domain, document the need in your output contract.
96
+ 2. **Follow the Discovered Issues Policy** — Track any pre-existing bugs found during your work (see the **git-workflow** skill).
97
+ 3. **Read and update lessons** — Read `.github/customizations/LESSONS-LEARNED.md` before starting. If you retry anything with a different approach that works, use the **self-improvement** skill to add a lesson immediately.
98
+ 4. **Log every session** — Append to `.github/customizations/logs/events.ndjson` after every session using `opencastle log --type session ...`. No exceptions. This is Constitution rule #6 — a blocking gate, not optional.
99
+
100
+ ## Base Output Contract
101
+
102
+ Every specialist agent's Output Contract MUST end with these standard items (in addition to domain-specific items above them):
103
+
104
+ - **Observability Logged** — Confirm ALL applicable log records were appended to `events.ndjson` (Constitution rule #6):
105
+ - `--type session` — ALWAYS (every agent, every session)
106
+ - `--type delegation` — if delegations occurred (Team Lead only)
107
+ - `--type review` — if fast reviews occurred
108
+ - `--type panel` — if panel reviews occurred
109
+ - `--type dispute` — if disputes were created
110
+ - **Discovered Issues** — Pre-existing bugs or anomalies found during work, with tracking action taken per the Discovered Issues Policy
111
+ - **Lessons Applied** — Lessons from `.github/customizations/LESSONS-LEARNED.md` that influenced this work, and any new lessons added
112
+
113
+ Agents reference this contract with: `See **Base Output Contract** in the observability-logging skill for the standard closing items.`
114
+
115
+ ## Pre-Response Quality Gate
116
+
117
+ > **⛔ STOP before responding to the user.** Run through this checklist. If ANY required item is missing, fix it NOW.
118
+
119
+ This is the single exit gate for every session. All items are mandatory unless marked conditional.
120
+
121
+ - [ ] **Lessons read** — `.github/customizations/LESSONS-LEARNED.md` was read at session start (Self-Improvement Protocol)
122
+ - [ ] **Lessons captured** — If any retry occurred, a new lesson was added via the **self-improvement** skill
123
+ - [ ] **Discovered issues tracked** — Any pre-existing bugs found were added to `KNOWN-ISSUES.md` or a tracker ticket was created (Discovered Issues Policy)
124
+ - [ ] **Lint/type/test pass** — No new errors introduced; verification ran after code changes (Constitution rule #5)
125
+ - [ ] **Session logged** — `events.ndjson` has a new `session` record for this session (Constitution rule #6 — ALWAYS required)
126
+ - [ ] **Delegations logged** — `events.ndjson` has a `delegation` record for each delegation (Team Lead only)
127
+ - [ ] **Reviews logged** — `events.ndjson` has a `review` record for each fast review performed (if any)
128
+ - [ ] **Panels logged** — `events.ndjson` has a `panel` record for each panel review performed (if any)
129
+ - [ ] **Disputes logged** — `events.ndjson` has a `dispute` record for each dispute created (if any)
@@ -122,7 +122,7 @@ Common failure modes and how to recover:
122
122
  ### Agent Stuck in Retry Loop
123
123
 
124
124
  **Symptom:** Agent retries the same failing command 3+ times without changing approach.
125
- **Recovery:** Intervene immediately. Read the error output, identify the root cause, and re-delegate with explicit fix instructions. Add a lesson to lessons learned.
125
+ **Recovery:** Intervene immediately. Read the error output, identify the root cause, and re-delegate with explicit fix instructions. Use the **self-improvement** skill to add a lesson.
126
126
 
127
127
  ### MCP Tool Unavailable
128
128
 
@@ -137,7 +137,7 @@ Common failure modes and how to recover:
137
137
  ### Merge Conflict from Parallel Agents
138
138
 
139
139
  **Symptom:** Two background agents modified overlapping files.
140
- **Recovery:** (1) This should never happen if file partitioning was followed. (2) Accept one agent's changes first (the one with more complex work). (3) Re-delegate the simpler changes to adapt to the new state. (4) Add the conflict to your lessons learned.
140
+ **Recovery:** (1) This should never happen if file partitioning was followed. (2) Accept one agent's changes first (the one with more complex work). (3) Re-delegate the simpler changes to adapt to the new state. (4) Use the **self-improvement** skill to add a lesson about the conflict.
141
141
 
142
142
  ### Context Window Exhausted
143
143
 
@@ -82,13 +82,10 @@ The isolated runner subagent must:
82
82
  6. Print a concise summary to chat
83
83
  - Overall verdict + vote tally + path to `<panelDir>/<panelKey>.md`.
84
84
 
85
- 7. Log the panel result
86
- - Append a JSON line to `.github/customizations/logs/panels.ndjson` with the panel record schema (see `.github/customizations/logs/README.md`).
87
- - Include: `timestamp`, `panel_key`, `verdict`, `pass_count`, `block_count`, `must_fix`, `should_fix`, `reviewer_model`, `weighted`, `attempt`, `tracker_issue`, `artifacts_count`, `report_path`.
88
- - Example:
89
- ```bash
90
- echo '{"timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","panel_key":"instruction-refactoring","verdict":"pass","pass_count":3,"block_count":0,"must_fix":0,"should_fix":5,"reviewer_model":"claude-opus-4-6","weighted":false,"attempt":1,"artifacts_count":14,"report_path":".github/customizations/logs/panel/instruction-refactoring.md"}' >> .github/customizations/logs/panels.ndjson
91
- ```
85
+ 7. Log the panel result **(⛔ hard gate — do NOT return the verdict or proceed until logged)**
86
+ - Log the panel result using the **observability-logging** skill's panel record command. An unlogged panel is a failed panel.
87
+ - Include: `panel_key`, `verdict`, `pass_count`, `block_count`, `must_fix`, `should_fix`, `reviewer_model`, `weighted`, `attempt`, `tracker_issue`, `artifacts_count`, `report_path`.
88
+ - The skill's panel record command includes a verify step.
92
89
 
93
90
  Finally: ensure whatever produced the claim being verified links the consolidated panel report as verification evidence.
94
91
 
@@ -21,41 +21,28 @@ This is the team's collective memory — a structured log of tool/command pitfal
21
21
 
22
22
  ## Protocol for All Agents
23
23
 
24
- The core protocol (read lessons → write on retry → log session) is defined in `general.instructions.md` § Self-Improvement Protocol. This skill provides the detailed reference material for writing lessons.
24
+ The core protocol (read lessons → write on retry → log session) is referenced from `general.instructions.md` via the **Workflow & Governance** table. This skill provides the detailed reference material for writing lessons.
25
25
 
26
26
  ## How to Write a Lesson
27
27
 
28
- ### Step 1: Determine the next lesson ID
28
+ > **⛔ HARD GATE — Use the CLI to write lessons. Do NOT edit LESSONS-LEARNED.md directly.**
29
29
 
30
- Look at the last `LES-XXX` entry in `.github/customizations/LESSONS-LEARNED.md` and increment by 1.
30
+ Use the `opencastle lesson` CLI command. It auto-increments the lesson ID, formats the entry, and updates the category index.
31
31
 
32
- ### Step 2: Write the entry
33
-
34
- Add it **before** the `## Index by Category` section, following this template:
35
-
36
- ```markdown
37
- ### LES-XXX: Short descriptive title
38
-
39
- | Field | Value |
40
- |-------|-------|
41
- | **Category** | `category-name` |
42
- | **Added** | YYYY-MM-DD |
43
- | **Severity** | `high` / `medium` / `low` |
44
-
45
- **Problem:** What went wrong and what error/behavior was observed.
46
-
47
- **Wrong approach:** The obvious/intuitive approach that fails (with code block).
48
-
49
- **Correct approach:** The working solution (with code block).
50
-
51
- **Why:** Root cause explanation (if known).
32
+ ```sh
33
+ opencastle lesson --title "Short descriptive title" --category general --severity high \
34
+ --problem "What went wrong and what error/behavior was observed" \
35
+ --wrong "The obvious/intuitive approach that fails" \
36
+ --correct "The working solution" \
37
+ --why "Root cause explanation"
52
38
  ```
53
39
 
54
- ### Step 3: Update the index
40
+ Required flags: `--title`, `--category`, `--severity`, `--problem`
41
+ Optional flags: `--wrong`, `--correct`, `--why`
55
42
 
56
- Add the lesson ID to the appropriate category row in the `## Index by Category` table.
43
+ Run `opencastle lesson --help` for full usage and valid category/severity values.
57
44
 
58
- ### Step 4: Update related instruction files (if applicable)
45
+ ### After writing the lesson
59
46
 
60
47
  If the lesson reveals a gap in existing instruction/skill files, **also update those files** to include the correct approach. This prevents the pitfall at the source level, not just as a retroactive note.
61
48
 
@@ -234,7 +234,7 @@ When automated resolution is exhausted (panel 3x BLOCK, approach conflicts, or c
234
234
  5. **Present resolution options** — At least 2 concrete options with rationale and risk for each
235
235
  6. **Recommend an action** — Which option the Team Lead thinks is best, with specific next steps
236
236
  7. **Link artifacts** — Panel reports, review logs, changed files, DLQ entries
237
- 8. **Log to disputes.ndjson** — Append a machine-readable record (see logs README)
237
+ 8. **Log to events.ndjson** — Use the **observability-logging** skill's dispute record command
238
238
  9. **Update the tracker issue** — Add the dispute ID and link to the dispute record
239
239
  10. **Update the Index table** — Add the new dispute to the bottom of the Index
240
240
 
@@ -245,7 +245,7 @@ When a human resolves a dispute:
245
245
  2. Record which option was chosen and any additional instructions
246
246
  3. If `resolved` → re-delegate the task with the human's decision as an explicit constraint
247
247
  4. If `deferred` → create a follow-up tracker issue and continue with other work
248
- 5. Log the resolution in `disputes.ndjson` (update the existing record or append a resolution event)
248
+ 5. Log the resolution in `events.ndjson` using the **observability-logging** skill's dispute record command (update or append a resolution event)
249
249
 
250
250
  ### Session Start: Check Disputes
251
251