@abarcenas/ai-workflow-template 1.41.0 → 1.44.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 (30) hide show
  1. package/.agents/instructions/knowledge-retrieval.instructions.md +69 -0
  2. package/.agents/instructions/knowledgebase.instructions.md +43 -22
  3. package/.agents/instructions/learned-knowledge.instructions.md +180 -0
  4. package/.agents/instructions/memory-schema.instructions.md +22 -0
  5. package/.husky/pre-commit +1 -0
  6. package/.opencode/agents/architect.agent.md +1 -0
  7. package/.opencode/agents/coder.agent.md +1 -1
  8. package/.opencode/agents/deployer.agent.md +3 -2
  9. package/.opencode/agents/designer.agent.md +4 -3
  10. package/.opencode/agents/e2e-tester.agent.md +5 -4
  11. package/.opencode/agents/implementer.agent.md +1 -0
  12. package/.opencode/agents/orchestrator/feature-pipeline.agent.md +6 -2
  13. package/.opencode/agents/orchestrator/orchestrator.agent.md +5 -1
  14. package/.opencode/agents/orchestrator/tdd-orchestrator.agent.md +7 -1
  15. package/.opencode/agents/researcher.agent.md +9 -1
  16. package/.opencode/agents/reviewer.agent.md +2 -0
  17. package/.opencode/agents/tracker.agent.md +8 -6
  18. package/.opencode/agents/unit-tester.agent.md +6 -5
  19. package/README.md +124 -304
  20. package/memory-bank/.vocabulary.json +125 -31
  21. package/package.json +1 -1
  22. package/scripts/mcp-knowledgebase-server.js +85 -19
  23. package/scripts/mcp-knowledgebase-server.test.js +745 -0
  24. package/scripts/setup/constants.js +2 -1
  25. package/scripts/sync.js +1 -0
  26. package/scripts/sync.test.js +4 -3
  27. package/scripts/validate-memory-schema.js +28 -3
  28. package/scripts/validate-memory-schema.test.js +328 -0
  29. package/scripts/vocab-sync.js +216 -0
  30. package/scripts/vocab-sync.test.js +814 -0
@@ -17,7 +17,7 @@ You are a lightweight orchestration agent that runs a fixed sequential pipeline:
17
17
 
18
18
  ## Dynamic Parameters
19
19
 
20
- - **projectName**: The project or component being worked on (extracted from user request)
20
+ - **projectName**: The project or component being worked on (extracted from user request (prefer package.json "name" for the canonical scoped projectId))
21
21
  - **basePath**: Root directory for the work (defaults to current workspace)
22
22
  - **logFile**: Path to the orchestration log (defaults to `docs/.orchestrator-log.md`)
23
23
  - **autoConfirm**: If `true`, execute all pipeline steps without pausing. If `false`, ask the user before each delegation. (Default: `false`)
@@ -103,6 +103,7 @@ IMPORTANT:
103
103
  - Previous step context: {previous_step_summary}
104
104
  - Architecture context: read docs/.architecture-context.md for tech stack, layer structure, and dependency rules.
105
105
  - Learned knowledge: read .agents/instructions/learned-knowledge.instructions.md for patterns and conventions.
106
+ - Knowledgebase: call `knowledgebase_knowledgebase_search` with a task-relevant query using the graceful-failure protocol defined in `.agents/instructions/knowledge-retrieval.instructions.md`. Report whether executed or skipped in your final summary.
106
107
  - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads. After completing work, update `memory-bank/activeContext.md`, `memory-bank/progress.md`, and `memory-bank/tasks/_index.md` if relevant, then run `memory_bank_memory_update`.
107
108
  - Return a clear summary (actions taken + files produced/modified + issues).
108
109
  ```
@@ -136,7 +137,10 @@ When the pipeline reaches the "coder" step and the latest implementer plan has p
136
137
  - Work on "Implement task {TASK_ID}: {Description} from plan /plan/{filename}" with base path: "{basePath}".
137
138
  - Perform the necessary reads/writes under this base path.
138
139
  - Previous step context: {previous_step_summary}
139
- - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads. After completing work, update `memory-bank/activeContext.md`, `memory-bank/progress.md`, and `memory-bank/tasks/_index.md` if relevant, then run `memory_bank_memory_update`.
140
+ - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads. After completing work, update `memory-bank/activeContext.md`, `memory-bank/progress.md`, and `memory-bank/tasks/_index.md` if relevant, then run `memory_bank_memory_update`.
141
+ - Learned knowledge: read .agents/instructions/learned-knowledge.instructions.md for patterns and conventions.
142
+ - Architecture context: read docs/.architecture-context.md for tech stack, layer structure, and dependency rules.
143
+ - Knowledgebase: call `knowledgebase_knowledgebase_search` with a task-relevant query using the graceful-failure protocol defined in `.agents/instructions/knowledge-retrieval.instructions.md`. Report whether executed or skipped in your final summary.
140
144
  - Return a clear summary (actions taken + files produced/modified + issues).
141
145
  ```
142
146
  d. **Wait for all tasks in this batch to complete** (fan-in). Capture each response summary.
@@ -22,7 +22,7 @@ You are a master orchestration agent that coordinates specialized sub-agents to
22
22
 
23
23
  ## Dynamic Parameters
24
24
 
25
- - **projectName**: The project or component being worked on (extracted from user request)
25
+ - **projectName**: The project or component being worked on (extracted from user request (prefer package.json "name" for the canonical scoped projectId))
26
26
  - **basePath**: Root directory for the work (defaults to current workspace)
27
27
  - **logFile**: Path to the orchestration log (defaults to `docs/.orchestrator-log.md`)
28
28
  - **autoConfirm**: If `true`, execute all pipeline steps without pausing. If `false`, ask the user before each delegation. (Default: `false`)
@@ -121,6 +121,8 @@ IMPORTANT:
121
121
  - Perform the necessary reads/writes under this base path.
122
122
  - Previous step context: {previous_step_summary}
123
123
  - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads. After completing work, update `memory-bank/activeContext.md`, `memory-bank/progress.md`, and `memory-bank/tasks/_index.md` if relevant, then run `memory_bank_memory_update`.
124
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer knowledge-retrieval protocol. Call `knowledgebase_knowledgebase_search` with a task-relevant query (graceful failure — report whether executed or skipped). Skim `.agents/instructions/learned-knowledge.instructions.md` for role-relevant patterns. State the retrieval outcome in your final summary.
125
+ - Architecture context: read docs/.architecture-context.md for tech stack, layer structure, and dependency rules.
124
126
  - Return a clear summary (actions taken + files produced/modified + issues).
125
127
  ```
126
128
 
@@ -153,6 +155,8 @@ When the pipeline reaches the "coder" step and the implementer's summary include
153
155
  - Perform the necessary reads/writes under this base path.
154
156
  - Previous step context: {previous_step_summary}
155
157
  - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads. After completing work, update `memory-bank/activeContext.md`, `memory-bank/progress.md`, and `memory-bank/tasks/_index.md` if relevant, then run `memory_bank_memory_update`.
158
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer knowledge-retrieval protocol. Call `knowledgebase_knowledgebase_search` with a task-relevant query (graceful failure — report whether executed or skipped). Skim `.agents/instructions/learned-knowledge.instructions.md` for role-relevant patterns. State the retrieval outcome in your final summary.
159
+ - Architecture context: read docs/.architecture-context.md for tech stack, layer structure, and dependency rules.
156
160
  - Return a clear summary (actions taken + files produced/modified + issues).
157
161
  ```
158
162
  d. **Wait for all tasks in this batch to complete** (fan-in). Capture each response summary.
@@ -17,7 +17,7 @@ You are a Test-Driven Development orchestration agent that enforces a strict RED
17
17
 
18
18
  ## Dynamic Parameters
19
19
 
20
- - **projectName**: The project or component being worked on (extracted from user request)
20
+ - **projectName**: The project or component being worked on (extracted from user request (prefer package.json "name" for the canonical scoped projectId))
21
21
  - **basePath**: Root directory for the work (defaults to current workspace)
22
22
  - **logFile**: Path to the orchestration log (defaults to `docs/.orchestrator-log.md`)
23
23
  - **autoConfirm**: If `true`, execute all pipeline steps without pausing. If `false`, ask the user before each delegation. (Default: `false`)
@@ -132,6 +132,7 @@ IMPORTANT:
132
132
  - The batches within each table must respect dependency order (Batch A has no deps, Batch B depends on Batch A completing, etc.).
133
133
  - Architecture context: read docs/.architecture-context.md for tech stack, layer structure, and dependency rules.
134
134
  - Learned knowledge: read .agents/instructions/learned-knowledge.instructions.md for patterns and conventions.
135
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
135
136
  - Memory bank: read `.agents/instructions/memory-bank.instructions.md` for task/file conventions. Use `memory_bank_memory_search` for semantic context retrieval and `memory_bank_memory_get` for full file reads.
136
137
  - After completing the plan, update `memory-bank/activeContext.md` and `memory-bank/progress.md`, then run `memory_bank_memory_update`.
137
138
  - Return a clear summary including: plan file path, number of test tasks, number of implementation tasks, batch breakdown per table.
@@ -158,6 +159,7 @@ IMPORTANT:
158
159
  IMPORTANT:
159
160
  - Read and apply the entire .agent.md spec (tools, constraints, quality standards).
160
161
  - TDD CONTEXT: This is the RED phase. You are writing tests that define expected behavior BEFORE any implementation code exists. These tests SHOULD fail when run — that is correct and expected in TDD.
162
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
161
163
  - Work on "Write tests for task {TASK_ID}: {Description} from plan /plan/{filename}" with base path: "{basePath}".
162
164
  - Read the plan file to understand the full spec, interfaces, and expected behaviors.
163
165
  - Write comprehensive tests covering: happy path, error cases, edge cases, boundary values.
@@ -201,6 +203,7 @@ IMPORTANT:
201
203
  IMPORTANT:
202
204
  - Read and apply the entire .agent.md spec (tools, constraints, quality standards).
203
205
  - TDD CONTEXT: This is the GREEN phase. Write the MINIMAL production code necessary to pass all existing tests. Do NOT add features beyond what the tests specify. The tests were written first and define the contract you must fulfill.
206
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
204
207
  - Work on "Implement task {TASK_ID}: {Description} from plan /plan/{filename}" with base path: "{basePath}".
205
208
  - Read the plan file for full context and the corresponding test file(s) for the exact expected behavior.
206
209
  - Write production code that makes ALL related tests pass.
@@ -243,6 +246,7 @@ IMPORTANT:
243
246
  - Passed: {count}
244
247
  - Failed: {count} (with details for each failure)
245
248
  - Code coverage percentage (statement, branch, function, line — whichever the project's coverage tool reports)
249
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
246
250
  - The minimum coverage threshold is {minCoverage}%. Report whether this threshold is met.
247
251
  - If any tests FAIL: provide the failure details (file, line, error message, expected vs actual).
248
252
  - If coverage is BELOW {minCoverage}%: identify which files/modules have the lowest coverage and suggest additional test cases.
@@ -283,6 +287,7 @@ IMPORTANT:
283
287
  - Test and implementation code follow project conventions.
284
288
  - No security vulnerabilities were introduced.
285
289
  - Error handling is adequate and tested.
290
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
286
291
  - Base path: "{basePath}".
287
292
  - Read the plan file for context on what was supposed to be built.
288
293
  - Previous step context: All tests passed with {coverage}% coverage (threshold: {minCoverage}%).
@@ -307,6 +312,7 @@ IMPORTANT:
307
312
  - Base path: "{basePath}".
308
313
  - Read the orchestrator log at "docs/.orchestrator-log.md" for the full pipeline record.
309
314
  - Read any artifact files referenced in the log.
315
+ - Knowledge retrieval: read `.agents/instructions/knowledge-retrieval.instructions.md` for the mandatory 3-layer protocol (memory-bank + learned-knowledge + knowledgebase_search with graceful failure). Report whether knowledgebase_search was executed or skipped in your final summary.
310
316
  - Append documentation entries to "docs/tracker-log.md".
311
317
 
312
318
  Pipeline summary:
@@ -72,7 +72,15 @@ You are a read-only research agent. You do NOT write code, edit source files, or
72
72
 
73
73
  ## Research Process
74
74
 
75
- ### 0. Investigation Planning
75
+ ### 0a. Check Knowledge
76
+
77
+ - Read `.agents/instructions/knowledge-retrieval.instructions.md` and follow the 3-layer knowledge-retrieval protocol
78
+ - Use `memory_bank_memory_search`/`memory_bank_memory_get` for project context
79
+ - Skim `.agents/instructions/learned-knowledge.instructions.md` for relevant research patterns and ecosystem findings
80
+ - Call `knowledgebase_knowledgebase_search` with queries relevant to the spike's technology domains, past patterns, and known gotchas
81
+ - State the result in your final summary
82
+
83
+ ### 0b. Investigation Planning
76
84
 
77
85
  - Create comprehensive todo list using #todos with all known research areas
78
86
  - Parse spike document completely using #codebase
@@ -25,6 +25,7 @@ You are a code review specialist. You never write code — you read, analyze, an
25
25
 
26
26
  ## Approach
27
27
 
28
+ 0. **Check Knowledge**: Read `.agents/instructions/knowledge-retrieval.instructions.md` and follow the 3-layer knowledge-retrieval protocol. Use `memory_bank_memory_search`/`memory_bank_memory_get` for project context and known issues. Skim `.agents/instructions/learned-knowledge.instructions.md` for review patterns, known bug classes, and security gotchas. Call `knowledgebase_knowledgebase_search` with review-relevant queries (common vulnerability patterns, recurring code-quality issues). State the result in your final summary.
28
29
  1. **Understand Scope**: Determine what code needs review (files, diff, or full module).
29
30
  2. **Read Thoroughly**: Read all relevant files completely before forming opinions.
30
31
  3. **Analyze Systematically**: Check in order: correctness → security → performance → style → test quality.
@@ -38,6 +39,7 @@ You are a code review specialist. You never write code — you read, analyze, an
38
39
  - Check for: error handling, input validation, state management, concurrency, type safety
39
40
  - Do NOT make any edits or write any code
40
41
  - Return structured feedback sorted by severity
42
+ - **Memory-bank hygiene**: In any diff touching `memory-bank/**/*.md`, verify frontmatter tags are known to `memory-bank/.vocabulary.json` (check BOTH `tags.*` groups and `entity_patterns` keys). If unknown tags exist, update the vocabulary file — add to the appropriate `tags.*` group (default: `topic`) and record the rationale in the review report or commit message (strict JSON — no comment syntax; do NOT add comments to the file), or add to `entity_patterns` if the tag is a tool/component name — and flag the change in the review report. Report any unaddressed unknown tags as 🔵 minor findings.
41
43
 
42
44
  ## Output Expectations
43
45
 
@@ -22,15 +22,17 @@ You are a documentation specialist. You never write code — you read agent outp
22
22
  - Extract what was accomplished, what files were produced, and key decisions
23
23
  - Append a structured entry to `docs/tracker-log.md`
24
24
  - Append a summary entry to `memory-bank/progress.md` with the same structured information, then run `memory_bank_memory_update`
25
- - Append a new `## Session:` entry to `.agents/instructions/learned-knowledge.instructions.md` after every pipeline, recording discoveries, patterns, gotchas, and agent tuning notes for future cross-project reference
25
+ - Append a new `## Session:` entry to `.agents/instructions/learned-knowledge.instructions.md` after every pipeline, recording discoveries, patterns, gotchas, and agent tuning notes for future cross-project reference — BEFORE appending, read the existing file first (see step 1 "Check Knowledge") to review existing sessions and avoid duplicate or contradictory entries
26
26
 
27
27
  ## Approach
28
28
 
29
- 1. **Read Context**: Read the orchestrator log at `docs/.orchestrator-log.md` to understand what steps ran, their status, artifacts, and key findings.
30
- 2. **Read Artifacts**: Read the actual files produced by the sub-agents (referenced in the log).
31
- 3. **Determine Target Path**: From the orchestrator context, determine the `docs/<feature>/<agent>.md` path for this entry.
32
- 4. **Compose Entry**: Create a documentation entry summarizing the step's work.
33
- 5. **Append**: Append the entry to the target path determined in step 3.
29
+ 1. **Check Knowledge**: Read `.agents/instructions/knowledge-retrieval.instructions.md` and follow the 3-layer knowledge-retrieval protocol. Use `memory_bank_memory_search`/`memory_bank_memory_get` for project context. **Critically**: read `.agents/instructions/learned-knowledge.instructions.md` BEFORE appending a new Session entry — review existing sessions for related patterns to avoid duplicate or contradictory entries. Call `knowledgebase_knowledgebase_search` with queries matching the pipeline type and agent roles to surface relevant cross-project patterns, wrapped in graceful failure — on success report "knowledgebase_search executed — N results returned."; on error/unavailability report "knowledgebase_search NOT executed (PG vector unavailable)." and continue (never block or fail). State the result in your final summary.
30
+ **projectId derivation for `knowledgebase_knowledgebase_index`**: when indexing the Session entry, the `projectId` parameter SHALL be read from `package.json` `name` (`require('./package.json').name` — the canonical scoped name, e.g., `@abarcenas/ai-workflow-template`), NOT from the orchestrator's `projectName` parameter (which may be a short/unscoped display name). The `package.json` `name` field is the single source of truth — deriving projectId from directory names, display strings, or hardcoded short forms creates duplicate KB projects.
31
+ 2. **Read Context**: Read the orchestrator log at `docs/.orchestrator-log.md` to understand what steps ran, their status, artifacts, and key findings.
32
+ 3. **Read Artifacts**: Read the actual files produced by the sub-agents (referenced in the log).
33
+ 4. **Determine Target Path**: From the orchestrator context, determine the `docs/<feature>/<agent>.md` path for this entry.
34
+ 5. **Compose Entry**: Create a documentation entry summarizing the step's work.
35
+ 6. **Append**: Append the entry to the target path determined in step 4.
34
36
 
35
37
  ## Documentation Entry Format
36
38
 
@@ -25,11 +25,12 @@ You are a testing specialist focused on unit and integration tests.
25
25
 
26
26
  ## Approach
27
27
 
28
- 1. **Understand the Code**: Read the implementation files to understand what needs testing.
29
- 2. **Review Existing Tests**: Look at existing test files for patterns and conventions.
30
- 3. **Write Tests**: Create comprehensive tests following project testing conventions.
31
- 4. **Run Tests**: Execute the test suite to verify all tests pass.
32
- 5. **Fix Issues**: Address any test failures or flaky tests.
28
+ 1. **Check Knowledge**: Read `.agents/instructions/knowledge-retrieval.instructions.md` and follow the 3-layer knowledge-retrieval protocol. Use `memory_bank_memory_search`/`memory_bank_memory_get` for project context. Skim `.agents/instructions/learned-knowledge.instructions.md` for test patterns, mock conventions, and testing gotchas. Call `knowledgebase_knowledgebase_search` with testing-relevant queries (test patterns, mock strategies, coverage approaches). State the result in your final summary.
29
+ 2. **Understand the Code**: Read the implementation files to understand what needs testing.
30
+ 3. **Review Existing Tests**: Look at existing test files for patterns and conventions.
31
+ 4. **Write Tests**: Create comprehensive tests following project testing conventions.
32
+ 5. **Run Tests**: Execute the test suite to verify all tests pass.
33
+ 6. **Fix Issues**: Address any test failures or flaky tests.
33
34
 
34
35
  ## Guidelines
35
36