@exaudeus/workrail 0.2.4 → 0.2.5-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "0.2.4",
3
+ "version": "0.2.5-beta.0",
4
4
  "description": "MCP server for structured workflow orchestration and step-by-step task guidance",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -19,6 +19,88 @@
19
19
  "Maintain the persona of a helpful, collaborative senior engineer.",
20
20
  "If at any point you determine that a crucial piece of information is missing, you must pause and ask the user to provide it."
21
21
  ],
22
+ "functionDefinitions": [
23
+ {
24
+ "name": "collectNits",
25
+ "definition": "From the current analysis pass, extract items labeled 'Nit:' or clearly Minor suggestions. Append them to a running array `nitFindings` with entries: { title, details, filePath, line, analysisDepth }. Maintain `nitsCount`.",
26
+ "scope": "workflow"
27
+ },
28
+ {
29
+ "name": "prepareNitAppendix",
30
+ "definition": "Aggregate `nitFindings` into a concise appendix grouped by file. Format each bullet as: `filePath:line - short description`. Produce markdown in `nitAppendix` and set `nitAppendixReady = true`.",
31
+ "scope": "workflow"
32
+ },
33
+ {
34
+ "name": "discoverModulePatterns",
35
+ "definition": "Determine `moduleRoot` as the nearest common ancestor of changed files (clamped to the package or src subtree). Scan only within `moduleRoot` to build `patternCatalog` and `patternExamples` (naming, dependency injection, error handling, logging, test style, file layout).",
36
+ "scope": "workflow"
37
+ },
38
+ {
39
+ "name": "consolidatePatternFindings",
40
+ "definition": "Compare MR changes against `patternCatalog` scoped to `moduleRoot`. Produce `patternFindings` and a grouped `patternAppendix` (by directory/file), and set `patternAppendixReady = true`.",
41
+ "scope": "workflow"
42
+ },
43
+ {
44
+ "name": "initReviewDoc",
45
+ "definition": "Create a live Markdown report at project root. Determine filename as `<YYYY-MM-DD>--<ticket-or-branch>--mr-review.md` (ticket preferred, else branch, else `mr-unknown`). Initialize sections with stable markers and write header metadata. Set `reviewDocPath`.",
46
+ "scope": "workflow"
47
+ },
48
+ {
49
+ "name": "upsertSection",
50
+ "definition": "Upsert content under a known section marker in the Markdown doc without duplicating sections. Maintain concise, scannable formatting.",
51
+ "scope": "workflow"
52
+ },
53
+ {
54
+ "name": "appendChangedFileRow",
55
+ "definition": "Append or update a row in the Changed Files table with columns: File | +/- | Summary | Risk.",
56
+ "scope": "workflow"
57
+ },
58
+ {
59
+ "name": "appendFinding",
60
+ "definition": "Append a finding grouped by severity (Critical/Major/Minor). Each entry includes path:line, 1–2 lines rationale, optional tiny diff.",
61
+ "scope": "workflow"
62
+ },
63
+ {
64
+ "name": "appendPatternResult",
65
+ "definition": "Append a Pattern Adherence row (Check | Result | Note) and brief per-file deviations.",
66
+ "scope": "workflow"
67
+ },
68
+ {
69
+ "name": "appendNit",
70
+ "definition": "Append a Nit entry grouped by file: `path:line — nit text`.",
71
+ "scope": "workflow"
72
+ },
73
+ {
74
+ "name": "appendMRComment",
75
+ "definition": "Append a copy-ready MR comment block with file:line, short title, rationale, and optional tiny diff snippet.",
76
+ "scope": "workflow"
77
+ },
78
+ {
79
+ "name": "logRevision",
80
+ "definition": "Append a timestamped line to the Revision Log describing the update (e.g., 'Added Depth 1 results').",
81
+ "scope": "workflow"
82
+ },
83
+ {
84
+ "name": "discoverHygieneSignals",
85
+ "definition": "Within `moduleRoot`, scan changed files and immediate neighbors for generic hygiene signals: disabled/skipped/focused tests; tests with no assertions; commented-out code; stale/misleading comments; TODO/FIXME/HACK/BUG without ticket/reference or clearly stale; high-density TODOs; naming/DI/logging/error handling inconsistencies vs local `patternCatalog`; ad-hoc debug prints; obvious unused identifiers/unreachable code.",
86
+ "scope": "workflow"
87
+ },
88
+ {
89
+ "name": "consolidateHygieneFindings",
90
+ "definition": "Consolidate hygiene signals with caps: total ≤10, per-category ≤3; dedupe similar items; group by file; elevate severity to Major only for clearly risky cases (e.g., focused tests, tests with no assertions). Produce category counts and a capped item list.",
91
+ "scope": "workflow"
92
+ },
93
+ {
94
+ "name": "appendHygieneFinding",
95
+ "definition": "Append a hygiene bullet to the live doc grouped by file: `path:line — short note (≤ 2 lines)`. Avoid duplication with Nit items; reference '(linked in Nits)' instead of repeating if needed.",
96
+ "scope": "workflow"
97
+ },
98
+ {
99
+ "name": "finalizeReviewDocument",
100
+ "definition": "Finalize the live review document. If `complexity == 'Trivial'`: write a brief executive summary (approve), do light hygiene (≤2) and quick nit sweep, set status=Final, log revision. Otherwise: write full executive summary (3 positives, 3 risks, recommendation), dedupe/sort findings, ensure sections (patterns, deviations, tests/docs, ideas, nits, MR comments), ensure Critical/Major coverage with curated MR comments, set status=Final, log revision.",
101
+ "scope": "workflow"
102
+ }
103
+ ],
22
104
  "steps": [
23
105
  {
24
106
  "id": "phase-0-triage",
@@ -29,18 +111,20 @@
29
111
  "**[Trivial]:** For minor fixes (typos, docs). This will run a condensed, single-phase review.",
30
112
  "**[Standard]:** For typical features or bug fixes. This uses the full, multi-phase review process.",
31
113
  "**[High-Risk]:** For major architectural changes or features touching sensitive code. This follows the full process with maximum diligence."
32
- ]
114
+ ],
115
+ "functionReferences": ["initReviewDoc()", "logRevision()"]
33
116
  },
34
117
  {
35
118
  "id": "phase-1-context",
36
119
  "title": "Phase 1: Contextual Understanding & Confirmation",
37
- "prompt": "My goal is to ensure I fully understand the MR before the deep analysis. Based on the context you provided, I will perform the following tasks:\n\n1. **Summarize Goal:** Briefly summarize what I understand to be the primary goal and scope of this MR.\n2. **File Overview:** List all changed files (added, modified, deleted) and provide a one-sentence summary of the changes for each.\n3. **Initial Questions:** Formulate any immediate questions I have about the MR's purpose or requirements.\n4. **Confirmation Gate:** Does my summary accurately reflect the MR's goal? Please confirm before I proceed.",
120
+ "prompt": "My goal is to ensure I fully understand the MR before the deep analysis. Based on the context you provided, I will perform the following tasks:\n\n1. **Summarize Goal:** Briefly summarize what I understand to be the primary goal and scope of this MR.\n2. **File Overview:** List all changed files (added, modified, deleted) and provide a one-sentence summary of the changes for each.\n3. **Initial Questions:** Formulate any immediate questions I have about the MR's purpose or requirements.\n4. **Confirmation Gate:** Does my summary accurately reflect the MR's goal? Please confirm before I proceed.\n\nI will also update the live review document with the Changed Files table and the Context summary.",
38
121
  "agentRole": "You are a thorough code review analyst specializing in requirement comprehension and change impact assessment. Your strength is quickly understanding the intent and scope of code changes while identifying potential gaps in understanding early in the review process.",
39
122
  "guidance": [
40
123
  "This is a critical sanity check. If the agent's summary is incorrect, correct it now to prevent a flawed review. This step is skipped for 'Trivial' reviews."
41
124
  ],
42
125
  "runCondition": { "var": "complexity", "not_equals": "Trivial" },
43
- "requireConfirmation": true
126
+ "requireConfirmation": true,
127
+ "functionReferences": ["upsertSection()", "appendChangedFileRow()", "logRevision()"]
44
128
  },
45
129
  {
46
130
  "id": "phase-1-context-setup",
@@ -48,12 +132,12 @@
48
132
  "prompt": "Initializing state for progressive depth analysis. Setting analysisDepth = 1, analysisComplete = false, and majorIssuesFound = false.",
49
133
  "agentRole": "You are a state manager preparing the workflow for an iterative review process.",
50
134
  "guidance": ["This is an automated step to prepare for the analysis loop."],
51
- "runCondition": { "var": "complexity", "not_equals": "Trivial" }
135
+ "runCondition": { "and": [ { "var": "complexity", "not_equals": "Trivial" }, { "or": [ { "var": "contextGatheringComplete", "equals": true }, { "var": "skipContextGathering", "equals": true } ] } ] }
52
136
  },
53
137
  {
54
138
  "id": "phase-1a-llm-context-gathering",
55
139
  "title": "Phase 1a: Comprehensive Context Gathering",
56
- "prompt": "To perform a thorough review, I need more than just the code diff. Please provide the following:\n\n1. **Business Context:** Paste the full text of the associated Jira/GitHub ticket, including the requirements and acceptance criteria. This helps me validate the 'why' behind the change.\n2. **Technical Context:** If this change relies on other parts of the codebase, please provide the relevant code snippets or file contents. Also, include any relevant architectural diagrams or coding standards documents.\n\nI will synthesize this information to build a comprehensive context for my review.",
140
+ "prompt": "To perform a thorough review, I need more than just the code diff. Please provide the following:\n\n1. **Business Context:** Paste the full text of the associated Jira/GitHub ticket, including the requirements and acceptance criteria. This helps me validate the 'why' behind the change.\n2. **Technical Context:** If this change relies on other parts of the codebase, please provide the relevant code snippets or file contents. Also, include any relevant architectural diagrams or coding standards documents.\n\nI will synthesize this information to build a comprehensive context for my review.\n\n**Confirmation & Gating:**\n- After you confirm that I have the right context (or explicitly instruct me to skip), I will set `contextGatheringComplete = true` or `skipContextGathering = true` accordingly.\n- I will not proceed to deeper analysis until one of these is set.",
57
141
  "agentRole": "You are a context-aware analyst ensuring you have all necessary information before starting a deep review.",
58
142
  "guidance": ["A high-quality review depends on high-quality context. The more information provided here, the more accurate the review will be."],
59
143
  "runCondition": { "var": "complexity", "not_equals": "Trivial" },
@@ -63,7 +147,7 @@
63
147
  "id": "phase-2-depth-analysis-loop",
64
148
  "type": "loop",
65
149
  "title": "Phase 2: Progressive Depth Analysis",
66
- "runCondition": { "var": "complexity", "not_equals": "Trivial" },
150
+ "runCondition": { "and": [ { "var": "complexity", "not_equals": "Trivial" }, { "or": [ { "var": "contextGatheringComplete", "equals": true }, { "var": "skipContextGathering", "equals": true } ] } ] },
67
151
  "loop": {
68
152
  "type": "until",
69
153
  "condition": { "var": "analysisComplete", "equals": true },
@@ -71,6 +155,18 @@
71
155
  "iterationVar": "analysisDepth"
72
156
  },
73
157
  "body": [
158
+ {
159
+ "id": "discover-module-patterns",
160
+ "title": "Discover Module Patterns (Depth 1)",
161
+ "prompt": "Compute `moduleRoot` as the nearest common ancestor of changed files, clamped to the package or `src/` subtree. Scan only within `moduleRoot` to gather exemplars (naming, DI, error handling, logging, test style, file layout). Produce `patternCatalog` and `patternExamples` in context. Do not block or require confirmation.",
162
+ "agentRole": "You are a codebase pattern scout building a concise pattern catalog for the current module.",
163
+ "guidance": [
164
+ "Scope strictly to `moduleRoot` discovered from changed files.",
165
+ "Cap exemplars (e.g., 3–5 per concern) for speed."
166
+ ],
167
+ "runCondition": { "var": "analysisDepth", "equals": 1 },
168
+ "functionReferences": ["discoverModulePatterns()"]
169
+ },
74
170
  {
75
171
  "id": "perform-analysis-pass",
76
172
  "title": "Analysis Pass {{analysisDepth}} of 3",
@@ -79,7 +175,8 @@
79
175
  "guidance": [
80
176
  "At each depth, focus only on the items in that checklist.",
81
177
  "Use Chain-of-Thought reasoning to explain your findings."
82
- ]
178
+ ],
179
+ "functionReferences": ["collectNits()", "appendFinding()", "appendMRComment()", "logRevision()"]
83
180
  },
84
181
  {
85
182
  "id": "check-analysis-completion",
@@ -90,6 +187,18 @@
90
187
  }
91
188
  ]
92
189
  },
190
+ {
191
+ "id": "consolidate-patterns",
192
+ "title": "Consolidate Pattern Findings",
193
+ "prompt": "Using `moduleRoot` and `patternCatalog`, compare the MR changes to local conventions. Summarize adherence and deviations, and generate a grouped `patternAppendix` (by directory/file). Set `patternAppendixReady = true`.",
194
+ "agentRole": "You are a senior engineer consolidating pattern adherence findings for clear reporting.",
195
+ "guidance": [
196
+ "Restrict to the module of the MR (`moduleRoot`).",
197
+ "Avoid re-scanning if `patternCatalog` already exists; reuse it."
198
+ ],
199
+ "runCondition": { "var": "complexity", "not_equals": "Trivial" },
200
+ "functionReferences": ["consolidatePatternFindings()", "appendPatternResult()", "upsertSection()", "logRevision()"]
201
+ },
93
202
  {
94
203
  "id": "phase-3-impact-analysis",
95
204
  "title": "Phase 3: Testing, Documentation & Impact Analysis",
@@ -98,38 +207,41 @@
98
207
  "guidance": [
99
208
  "Assessing test coverage is critical. A lack of tests for new logic is often a 'Major' or 'Critical' concern."
100
209
  ],
101
- "runCondition": { "var": "complexity", "not_equals": "Trivial" }
210
+ "runCondition": { "and": [ { "var": "complexity", "not_equals": "Trivial" }, { "or": [ { "var": "contextGatheringComplete", "equals": true }, { "var": "skipContextGathering", "equals": true } ] } ] }
102
211
  },
103
212
  {
104
- "id": "phase-4-refinement-loop",
105
- "type": "loop",
106
- "title": "Phase 4: Iterative Summary & Refinement",
213
+ "id": "hygiene-and-inconsistencies",
214
+ "title": "Hygiene & Inconsistencies Sweep",
215
+ "prompt": "Perform a platform-agnostic hygiene sweep scoped to the current module and changed files. Surface concise, actionable findings across categories:\n\n- Tests: disabled/skipped/focused tests; tests with no assertions; mismatched or overly generic names\n- Comments: commented-out code blocks; stale/misleading comments; suppression directives without justification\n- TODO/FIXME/HACK/BUG: missing ticket/reference or clearly stale; high density in an area\n- Inconsistencies: naming/DI/logging/error handling divergences from local patterns; ad-hoc debug prints; obvious unused identifiers/unreachable code\n\nConstraints:\n- Total ≤10 items; ≤3 per category; dedupe similar items; group by file; keep each note ≤2 lines\n- Elevate to Major only when clearly risky (e.g., focused tests, tests with no assertions)\n\nWrite results to the live doc under 'Hygiene & Inconsistencies' with category counts and bullets grouped by file. For the top 2–3 actionable items, add Ready-to-Copy MR comments. Log the revision.",
216
+ "agentRole": "You are a pragmatic reviewer catching small but valuable quality issues without adding noise.",
217
+ "guidance": [
218
+ "Scope strictly to moduleRoot and changed files plus immediate neighbors.",
219
+ "Write full details to the live doc; in chat, report counts and the doc path."
220
+ ],
107
221
  "runCondition": { "var": "complexity", "not_equals": "Trivial" },
108
- "loop": {
109
- "type": "until",
110
- "condition": { "var": "critiqueComplete", "equals": true },
111
- "maxIterations": 2,
112
- "iterationVar": "critiquePass"
113
- },
114
- "body": [
115
- {
116
- "id": "generate-summary-and-critique",
117
- "title": "Generate Summary & Self-Critique (Pass {{critiquePass}})",
118
- "prompt": "Consolidate all findings into a final, actionable report.\n\n**1. Devil's Advocate Self-Critique:**\nReview your own findings. Are any of your 'Major' concerns actually minor preferences? Is there a pattern among 'Minor' suggestions that points to a larger problem? Does this critique reveal a fundamental flaw in your analysis that requires another pass?\n\n**2. Final Report:**\n* **Overall Assessment:** A 2-3 sentence summary.\n* **Key Positive Aspects:** Highlights of what was done well.\n* **Concerns (Categorized):** Critical, Major, and Minor/Nit.\n* **Questions for Author:** Clarifying questions.\n* **Actionable Recommendations:** Concrete suggestions.\n\n**3. Set Flag:** Based on your self-critique, set `critiqueComplete = true` if the summary is robust, or `critiqueComplete = false` if you need one more pass to refine it.",
119
- "agentRole": "You are a facilitator synthesizing feedback and performing a self-critique to ensure the final report is balanced and high-quality.",
120
- "guidance": ["Use 'Nit:' for minor issues. Balance criticism with praise. The goal is a collaborative and constructive report."]
121
- }
122
- ]
222
+ "functionReferences": ["discoverHygieneSignals()", "consolidateHygieneFindings()", "appendHygieneFinding()", "appendMRComment()", "upsertSection()", "logRevision()"]
223
+ },
224
+ {
225
+ "id": "prepare-nit-appendix",
226
+ "title": "Prepare Nit Appendix",
227
+ "prompt": "Consolidate all non-blocking 'Nit:' items found so far into a clean appendix.\n\nTasks:\n1. Aggregate `nitFindings` by file.\n2. Format each entry as: `filePath:line - short description` with one-line context if helpful.\n3. Produce markdown in `nitAppendix`.\n4. Set `nitAppendixReady = true` and `nitsCount` accordingly.",
228
+ "agentRole": "You are a meticulous note-taker consolidating non-blocking suggestions for clarity and follow-through.",
229
+ "guidance": [
230
+ "This step is non-blocking and purely for documentation quality.",
231
+ "Keep items concise; avoid repeating Major concerns."
232
+ ],
233
+ "runCondition": { "and": [ { "var": "complexity", "not_equals": "Trivial" }, { "or": [ { "var": "contextGatheringComplete", "equals": true }, { "var": "skipContextGathering", "equals": true } ] } ] },
234
+ "functionReferences": ["prepareNitAppendix()", "appendNit()", "upsertSection()", "logRevision()"]
123
235
  },
124
236
  {
125
- "id": "phase-5-trivial-review-summary",
126
- "title": "Phase 5: Trivial Review Summary",
127
- "prompt": "Based on the trivial nature of this MR, I have performed a quick check for obvious errors. The change appears to correctly address the stated purpose without any clear side effects. I recommend approval.",
128
- "agentRole": "You are an efficient code reviewer specializing in rapid assessment of low-risk changes. Your role is to quickly validate that trivial changes are safe and appropriate while avoiding over-analysis of simple modifications.",
237
+ "id": "finalize-review-document",
238
+ "title": "Finalize Review Document",
239
+ "prompt": "Finalize the live review document (no new analysis).\n\nBranching:\n- If `complexity == 'Trivial'`:\n 1) Upsert a brief Executive Summary (1–2 lines) with 'Recommendation: Approve'.\n 2) Perform light hygiene (≤2 items) on changed files; write concise bullets under 'Hygiene & Inconsistencies'.\n 3) Quick Nit sweep; write bullets under 'Nit Appendix'.\n 4) Update Header: set status=Final; include final counts.\n 5) Append 'Finalized trivial review' to the Revision Log.\n\n- Otherwise (non-trivial):\n 1) Upsert Executive Summary (3 positives, 3 risks, final recommendation).\n 2) Dedupe and sort Findings (Severity → File → Line).\n 3) Ensure sections exist: Patterns, Pattern Deviations, Tests & Docs, Ideas & Alternatives, Nits, MR Comments.\n 4) Ensure every Critical/Major finding has a curated MR comment; add minimal ones if missing.\n 5) Update Header: set status=Final; include final counts and decision.\n 6) Append 'Finalized document' to the Revision Log.\n\nChat: Provide a concise recap (Trivial: 2–3 lines; Non-trivial: ≤10 lines) with decision and the doc path.",
240
+ "agentRole": "You are a facilitator ensuring the final document is complete, accurate, and consumable.",
129
241
  "guidance": [
130
- "This is the condensed summary for 'Trivial' reviews. The agent skips all other analytical steps and provides a simple confirmation for straightforward changes."
242
+ "Write full details to the live doc; keep chat to a concise recap with the doc path."
131
243
  ],
132
- "runCondition": { "var": "complexity", "equals": "Trivial" }
244
+ "functionReferences": ["finalizeReviewDocument()", "ensureSectionMarkers()", "upsertSection()", "curateMRComments()", "discoverHygieneSignals()", "consolidateHygieneFindings()", "appendHygieneFinding()", "logRevision()"]
133
245
  }
134
246
  ]
135
247
  }