@davidorex/pi-workflows 0.14.6 → 0.28.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 (102) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +12 -9
  3. package/agents/handoff-writer.agent.yaml +1 -1
  4. package/agents/requirements-gatherer.agent.yaml +1 -1
  5. package/dist/agent-spec.d.ts.map +1 -1
  6. package/dist/agent-spec.js +4 -3
  7. package/dist/agent-spec.js.map +1 -1
  8. package/dist/auth-required.d.ts +10 -0
  9. package/dist/auth-required.d.ts.map +1 -0
  10. package/dist/auth-required.js +10 -0
  11. package/dist/auth-required.js.map +1 -0
  12. package/dist/bundled-dirs.d.ts +2 -0
  13. package/dist/bundled-dirs.d.ts.map +1 -0
  14. package/dist/bundled-dirs.js +26 -0
  15. package/dist/bundled-dirs.js.map +1 -0
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +146 -14
  19. package/dist/index.js.map +1 -1
  20. package/dist/render-by-id.d.ts +62 -0
  21. package/dist/render-by-id.d.ts.map +1 -0
  22. package/dist/render-by-id.js +105 -0
  23. package/dist/render-by-id.js.map +1 -0
  24. package/dist/step-agent.js +1 -1
  25. package/dist/step-block.d.ts +5 -1
  26. package/dist/step-block.d.ts.map +1 -1
  27. package/dist/step-block.js +88 -40
  28. package/dist/step-block.js.map +1 -1
  29. package/dist/step-monitor.d.ts +1 -1
  30. package/dist/step-monitor.d.ts.map +1 -1
  31. package/dist/step-monitor.js +1 -1
  32. package/dist/step-monitor.js.map +1 -1
  33. package/dist/step-shared.d.ts +1 -1
  34. package/dist/step-shared.d.ts.map +1 -1
  35. package/dist/step-shared.js +16 -10
  36. package/dist/step-shared.js.map +1 -1
  37. package/dist/template-validation.d.ts.map +1 -1
  38. package/dist/template-validation.js +6 -6
  39. package/dist/template-validation.js.map +1 -1
  40. package/dist/template.d.ts.map +1 -1
  41. package/dist/template.js +2 -1
  42. package/dist/template.js.map +1 -1
  43. package/dist/test-helpers.d.ts +91 -0
  44. package/dist/test-helpers.d.ts.map +1 -1
  45. package/dist/test-helpers.js +185 -1
  46. package/dist/test-helpers.js.map +1 -1
  47. package/dist/tui.d.ts +3 -3
  48. package/dist/tui.d.ts.map +1 -1
  49. package/dist/tui.js +1 -1
  50. package/dist/types.d.ts +36 -1
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/workflow-discovery.d.ts.map +1 -1
  53. package/dist/workflow-discovery.js +2 -1
  54. package/dist/workflow-discovery.js.map +1 -1
  55. package/dist/workflow-executor.d.ts.map +1 -1
  56. package/dist/workflow-executor.js +23 -9
  57. package/dist/workflow-executor.js.map +1 -1
  58. package/dist/workflow-sdk.d.ts.map +1 -1
  59. package/dist/workflow-sdk.js +18 -11
  60. package/dist/workflow-sdk.js.map +1 -1
  61. package/dist/workflow-spec.js +99 -2
  62. package/dist/workflow-spec.js.map +1 -1
  63. package/package.json +17 -7
  64. package/skill-narrative.md +5 -3
  65. package/skills/pi-workflows/SKILL.md +46 -9
  66. package/skills/pi-workflows/references/bundled-resources.md +0 -36
  67. package/workflows/analyze-existing-project.workflow.yaml +1 -1
  68. package/workflows/init-new-project.workflow.yaml +1 -1
  69. package/workflows/plan-from-requirements.workflow.yaml +2 -2
  70. package/templates/analyzers/base-analyzer.md +0 -9
  71. package/templates/analyzers/patterns-task.md +0 -11
  72. package/templates/analyzers/patterns.md +0 -15
  73. package/templates/analyzers/quality-task.md +0 -11
  74. package/templates/analyzers/quality.md +0 -15
  75. package/templates/analyzers/structure-task.md +0 -17
  76. package/templates/analyzers/structure.md +0 -15
  77. package/templates/architecture-designer/task.md +0 -117
  78. package/templates/architecture-inferrer/task.md +0 -61
  79. package/templates/audit-finding-verifier/task.md +0 -59
  80. package/templates/audit-fixer/task.md +0 -67
  81. package/templates/audit-results-router/task.md +0 -37
  82. package/templates/decomposer/task.md +0 -56
  83. package/templates/explorer/system.md +0 -3
  84. package/templates/explorer/task.md +0 -9
  85. package/templates/gap-identifier/task.md +0 -103
  86. package/templates/gap-resolution-assessor/task.md +0 -48
  87. package/templates/handoff-writer/task.md +0 -101
  88. package/templates/investigator/task.md +0 -30
  89. package/templates/phase-author/task.md +0 -82
  90. package/templates/plan-creator/task.md +0 -143
  91. package/templates/plan-decomposer/task.md +0 -46
  92. package/templates/project-definer/task.md +0 -67
  93. package/templates/project-inferrer/task.md +0 -56
  94. package/templates/requirements-gatherer/task.md +0 -90
  95. package/templates/researcher/task.md +0 -26
  96. package/templates/shared/macros.md +0 -152
  97. package/templates/spec-implementer/task.md +0 -53
  98. package/templates/synthesizer/system.md +0 -3
  99. package/templates/synthesizer/task.md +0 -38
  100. package/templates/task-verifier/task.md +0 -44
  101. package/templates/task-worker/task.md +0 -52
  102. package/templates/verifier/task.md +0 -57
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@davidorex/pi-workflows",
3
- "version": "0.14.6",
3
+ "version": "0.28.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Workflow orchestration extension for Pi",
5
8
  "license": "MIT",
6
9
  "author": "David Ryan",
@@ -36,6 +39,10 @@
36
39
  "./types": {
37
40
  "types": "./dist/types.d.ts",
38
41
  "default": "./dist/types.js"
42
+ },
43
+ "./auth-required": {
44
+ "types": "./dist/auth-required.d.ts",
45
+ "default": "./dist/auth-required.js"
39
46
  }
40
47
  },
41
48
  "pi": {
@@ -52,24 +59,27 @@
52
59
  "agents/",
53
60
  "schemas/",
54
61
  "workflows/",
55
- "templates/",
56
62
  "*.md"
57
63
  ],
58
64
  "scripts": {
59
65
  "clean": "rm -rf dist",
60
- "build": "tsc -p tsconfig.build.json",
66
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
61
67
  "prepublishOnly": "npm run clean && npm run build",
62
68
  "test": "tsx --test src/*.test.ts"
63
69
  },
64
70
  "dependencies": {
65
71
  "nunjucks": "^3.2.4",
66
72
  "yaml": "^2.7.1",
67
- "@davidorex/pi-project": "^0.14.6",
68
- "@mariozechner/pi-ai": "^0.70.2",
69
- "@mariozechner/pi-coding-agent": "^0.70.2",
70
- "@mariozechner/pi-tui": "^0.70.2"
73
+ "@davidorex/pi-jit-agents": "^0.28.0",
74
+ "@davidorex/pi-context": "^0.28.0",
75
+ "@earendil-works/pi-ai": "^0.75.4",
76
+ "@earendil-works/pi-coding-agent": "^0.75.4",
77
+ "@earendil-works/pi-tui": "^0.75.4"
71
78
  },
72
79
  "devDependencies": {
73
80
  "@types/nunjucks": "^3.2.6"
81
+ },
82
+ "engines": {
83
+ "node": ">=22.19.0"
74
84
  }
75
85
  }
@@ -28,7 +28,9 @@ Workflows are discovered from three locations (first match wins):
28
28
  | loop | `loop: { maxAttempts, steps }` | Repeat sub-steps until gate breaks or max reached |
29
29
  | parallel | `parallel: { a: ..., b: ... }` | Run named sub-steps concurrently |
30
30
  | pause | `pause: true` or `pause: "message"` | Pause execution, resumable later |
31
- | forEach | `forEach: "${{ expr }}"` | Iterate over an array, executing the step per element |
31
+ | block | `block: { op: read\|write\|append\|update\|remove\|… }` | Validated in-process substrate block I/O via the block API no LLM, no subprocess |
32
+
33
+ `forEach: "${{ expr }}"` (iterate the step per array element) and `as:` are step MODIFIERS, not step types — they combine with any type above.
32
34
  </step_types>
33
35
 
34
36
  <expression_syntax>
@@ -64,7 +66,7 @@ Incomplete runs (failed or paused) are detected on next invocation. If the workf
64
66
  <output_validation>
65
67
  Steps with `output.schema` validate the agent's JSON output against a JSON Schema file. Validation failure marks the step as failed.
66
68
 
67
- Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `.project/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
69
+ Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `<substrate-dir>/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
68
70
  </output_validation>
69
71
 
70
72
  <retry>
@@ -79,7 +81,7 @@ After execution, the workflow result is injected into the main LLM conversation.
79
81
  </completion_messages>
80
82
 
81
83
  <artifacts>
82
- Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `.project/*.json` are routed through `writeBlock()` for schema validation.
84
+ Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `<substrate-dir>/*.json` are routed through `writeBlock()` for schema validation.
83
85
 
84
86
  Block artifact write failures are fatal — if the data doesn't conform to the block's schema, the workflow fails. Non-block artifact failures remain non-fatal (warning). On resume, all steps are preserved; only artifact processing re-runs, so fixing the schema issue or agent output and resuming avoids re-running expensive LLM steps.
85
87
  </artifacts>
@@ -8,10 +8,10 @@ description: >
8
8
  ---
9
9
 
10
10
  <tools_reference>
11
- <tool name="workflow">
12
- Run a named workflow with typed input. Discovers workflows from .workflows/ and ~/.pi/agent/workflows/.
11
+ <tool name="workflow-execute">
12
+ Execute a named workflow with typed input. Discovers workflows from .workflows/ and ~/.pi/agent/workflows/. Auto-resumes the most recent compatible incomplete run unless fresh='true'. Use workflow-resume for explicit-only resume by runId.
13
13
 
14
- *Run a multi-step workflow with typed data flow between agents*
14
+ *Execute a multi-step workflow with typed data flow (auto-resumes compatible incomplete runs)*
15
15
 
16
16
  | Parameter | Type | Required | Description |
17
17
  |-----------|------|----------|-------------|
@@ -20,6 +20,18 @@ Run a named workflow with typed input. Discovers workflows from .workflows/ and
20
20
  | `fresh` | string | no | Set to 'true' to start a fresh run, ignoring any incomplete prior runs |
21
21
  </tool>
22
22
 
23
+ <tool name="workflow-resume">
24
+ Explicitly resume an incomplete workflow run by name + runId. Rejects when no incomplete run exists for the workflow OR when runId does not match the most recent incomplete run. Use workflow-execute for default auto-resume; this surface is for explicit-only scenarios where the caller wants to fail loudly if the run is gone or has been superseded.
25
+
26
+ *Explicitly resume an incomplete workflow run by name + runId (rejects on no-match)*
27
+
28
+ | Parameter | Type | Required | Description |
29
+ |-----------|------|----------|-------------|
30
+ | `workflow` | string | yes | Workflow name |
31
+ | `runId` | string | yes | Incomplete run ID — required, no auto-detect |
32
+ | `input` | unknown | no | Optional input override; defaults to the original run's input |
33
+ </tool>
34
+
23
35
  <tool name="workflow-list">
24
36
  List available workflows with names, descriptions, and sources.
25
37
 
@@ -61,6 +73,29 @@ Initialize .workflows/ directory for workflow run state.
61
73
 
62
74
  </tool>
63
75
 
76
+ <tool name="render-item-by-id">
77
+ Render a project block item by ID through its registered per-item macro. Resolves the item via the cross-block resolver, looks up the macro via the renderer registry, and renders with the supplied depth and depth-aware cross-reference recursion. Returns `[not-found: <id>]` on resolver miss and `[unrendered: <kind>/<id>]` on registry miss — same fallback markers `render_recursive` emits inside agent prompts.
78
+
79
+ *Render a project block item as prompt text via its per-item macro (with depth-controlled cross-ref recursion)*
80
+
81
+ | Parameter | Type | Required | Description |
82
+ |-----------|------|----------|-------------|
83
+ | `id` | string | yes | Kind-prefixed ID, e.g., DEC-NNNN / FEAT-NNN |
84
+ | `depth` | number | no | 0 = bare-ID refs (default), 1 = inline direct cross-references, 2+ = recurse further |
85
+ </tool>
86
+
87
+ <tool name="enforce-budget">
88
+ Check rendered text against an `x-prompt-budget` annotation on a schema field. Returns `{ output, warning }` — `output` is the original text passed through when under budget, or tail-truncated text with `[…truncated to budget]` marker when over; `warning` is null when no truncation occurred or a structured BudgetWarning record otherwise. Annotation absence is pass-through (no error). Mirrors the behaviour of the `enforceBudget` Nunjucks global registered by compileAgent.
89
+
90
+ *Validate rendered text against a schema field's prompt budget — returns truncated output and warning*
91
+
92
+ | Parameter | Type | Required | Description |
93
+ |-----------|------|----------|-------------|
94
+ | `rendered` | string | yes | Rendered text to check against the field's prompt budget |
95
+ | `blockName` | string | yes | Block schema name (without .schema.json suffix), e.g. 'decisions' or 'features' |
96
+ | `fieldPath` | string | yes | JSON-pointer-style path to the field, e.g. '/properties/decisions/items/properties/context' |
97
+ </tool>
98
+
64
99
  </tools_reference>
65
100
 
66
101
  <commands_reference>
@@ -78,7 +113,7 @@ Subcommands: `init`, `list`, `run`, `resume`, `validate`, `status`, `help`
78
113
  </keyboard_shortcuts>
79
114
 
80
115
  <bundled_resources>
81
- 26 agents, 15 schemas, 15 workflows, 33 templates bundled.
116
+ 26 agents, 15 schemas, 15 workflows bundled.
82
117
  See references/bundled-resources.md for full inventory.
83
118
  </bundled_resources>
84
119
 
@@ -127,7 +162,7 @@ See references/bundled-resources.md for full inventory.
127
162
  </agent_input>
128
163
 
129
164
  <agent_input name="handoff-writer">
130
- - `project_state` [required] — Current project state (from projectState() or /project status — includes phases, blocks, gaps, decisions, recent commits)
165
+ - `project_state` [required] — Current project state (from contextState() or /context status — includes phases, blocks, gaps, decisions, recent commits)
131
166
  - `path` string [required] — Root path of the project
132
167
  </agent_input>
133
168
 
@@ -212,7 +247,7 @@ See references/bundled-resources.md for full inventory.
212
247
  | `filter-names` | warning | Expression filters are recognized |
213
248
  | `steptype-metadata` | error | retry/input/output declarations match step type capabilities |
214
249
  | `inputschema-required` | error | Agent required input keys are provided by step |
215
- | `contextblocks-existence` | warning | Declared context blocks exist in .project/ |
250
+ | `contextblocks-existence` | warning | Declared context blocks exist in the substrate dir |
216
251
  | `template-alignment` | error | Template variables match step inputs and source schemas |
217
252
 
218
253
  </validation_vocabulary>
@@ -239,7 +274,9 @@ Workflows are discovered from three locations (first match wins):
239
274
  | loop | `loop: { maxAttempts, steps }` | Repeat sub-steps until gate breaks or max reached |
240
275
  | parallel | `parallel: { a: ..., b: ... }` | Run named sub-steps concurrently |
241
276
  | pause | `pause: true` or `pause: "message"` | Pause execution, resumable later |
242
- | forEach | `forEach: "${{ expr }}"` | Iterate over an array, executing the step per element |
277
+ | block | `block: { op: read\|write\|append\|update\|remove\|… }` | Validated in-process substrate block I/O via the block API no LLM, no subprocess |
278
+
279
+ `forEach: "${{ expr }}"` (iterate the step per array element) and `as:` are step MODIFIERS, not step types — they combine with any type above.
243
280
  </step_types>
244
281
 
245
282
  <expression_syntax>
@@ -275,7 +312,7 @@ Incomplete runs (failed or paused) are detected on next invocation. If the workf
275
312
  <output_validation>
276
313
  Steps with `output.schema` validate the agent's JSON output against a JSON Schema file. Validation failure marks the step as failed.
277
314
 
278
- Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `.project/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
315
+ Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `<substrate-dir>/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
279
316
  </output_validation>
280
317
 
281
318
  <retry>
@@ -290,7 +327,7 @@ After execution, the workflow result is injected into the main LLM conversation.
290
327
  </completion_messages>
291
328
 
292
329
  <artifacts>
293
- Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `.project/*.json` are routed through `writeBlock()` for schema validation.
330
+ Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `<substrate-dir>/*.json` are routed through `writeBlock()` for schema validation.
294
331
 
295
332
  Block artifact write failures are fatal — if the data doesn't conform to the block's schema, the workflow fails. Non-block artifact failures remain non-fatal (warning). On resume, all steps are preserved; only artifact processing re-runs, so fixing the schema issue or agent output and resuming avoids re-running expensive LLM steps.
296
333
  </artifacts>
@@ -64,39 +64,3 @@
64
64
  - `workflows/resumable-analysis.workflow.yaml`
65
65
  - `workflows/self-implement.workflow.yaml`
66
66
  - `workflows/typed-analysis.workflow.yaml`
67
-
68
- ## templates/ (33 files)
69
-
70
- - `templates/analyzers/base-analyzer.md`
71
- - `templates/analyzers/patterns-task.md`
72
- - `templates/analyzers/patterns.md`
73
- - `templates/analyzers/quality-task.md`
74
- - `templates/analyzers/quality.md`
75
- - `templates/analyzers/structure-task.md`
76
- - `templates/analyzers/structure.md`
77
- - `templates/architecture-designer/task.md`
78
- - `templates/architecture-inferrer/task.md`
79
- - `templates/audit-finding-verifier/task.md`
80
- - `templates/audit-fixer/task.md`
81
- - `templates/audit-results-router/task.md`
82
- - `templates/decomposer/task.md`
83
- - `templates/explorer/system.md`
84
- - `templates/explorer/task.md`
85
- - `templates/gap-identifier/task.md`
86
- - `templates/gap-resolution-assessor/task.md`
87
- - `templates/handoff-writer/task.md`
88
- - `templates/investigator/task.md`
89
- - `templates/phase-author/task.md`
90
- - `templates/plan-creator/task.md`
91
- - `templates/plan-decomposer/task.md`
92
- - `templates/project-definer/task.md`
93
- - `templates/project-inferrer/task.md`
94
- - `templates/requirements-gatherer/task.md`
95
- - `templates/researcher/task.md`
96
- - `templates/shared/macros.md`
97
- - `templates/spec-implementer/task.md`
98
- - `templates/synthesizer/system.md`
99
- - `templates/synthesizer/task.md`
100
- - `templates/task-verifier/task.md`
101
- - `templates/task-worker/task.md`
102
- - `templates/verifier/task.md`
@@ -85,4 +85,4 @@ completion:
85
85
  **Architecture:** ${{ steps.infer-architecture.output.modules | length }} modules, ${{ steps.infer-architecture.output.patterns | length }} patterns
86
86
  **Gaps:** ${{ steps.identify-issues.output.issues | length }} identified
87
87
 
88
- Use `/project status` to see the full state. Use `/project validate` to check cross-block references.
88
+ Use `/context status` to see the full state. Use `/context validate` to check cross-block references.
@@ -78,4 +78,4 @@ completion:
78
78
  **Architecture:** ${{ steps.design-architecture.output.modules | length }} modules
79
79
  **Plan:** phases and tasks created
80
80
 
81
- Use `/project status` to see the full state. Use `/project validate` to check cross-block references.
81
+ Use `/context status` to see the full state. Use `/context validate` to check cross-block references.
@@ -44,5 +44,5 @@ completion:
44
44
  template: |
45
45
  Plan created from requirements. Tasks written to .project/tasks.json.
46
46
 
47
- Use `/project status` to see the phase and task breakdown.
48
- Use `/project validate` to check cross-block references.
47
+ Use `/context status` to see the phase and task breakdown.
48
+ Use `/context validate` to check cross-block references.
@@ -1,9 +0,0 @@
1
- {% block identity %}You are a code analyst.{% endblock %} Given an exploration summary and a code path to analyze:
2
-
3
- {% block checklist %}
4
- 1. Analyze the code thoroughly
5
- {% endblock %}
6
-
7
- {% block constraints %}
8
- Be specific — cite files and line ranges where applicable.
9
- {% endblock %}
@@ -1,11 +0,0 @@
1
- Analyze design patterns at `{{ path }}`.
2
-
3
- {% if exploration.files is defined %}
4
- ## Codebase
5
- {% for file in exploration.files %}
6
- - `{{ file.path }}` ({{ file.lines }} lines)
7
- {% endfor %}
8
- {% endif %}
9
-
10
- Identify patterns, conventions, and anti-patterns. Provide recommendations.
11
- Write your analysis as JSON conforming to the output schema.
@@ -1,15 +0,0 @@
1
- {% extends "analyzers/base-analyzer.md" %}
2
-
3
- {% block identity %}You are a design pattern analyst.{% endblock %}
4
-
5
- {% block checklist %}
6
- 1. **Design patterns**: What patterns are used? Are they applied correctly?
7
- 2. **Idioms**: What language/framework idioms are followed or violated?
8
- 3. **Conventions**: Naming, file organization, import style — are they consistent?
9
- 4. **Anti-patterns**: Are there patterns that work against the codebase?
10
- 5. **Recommendations**: What patterns would improve the codebase?
11
- {% endblock %}
12
-
13
- {% block constraints %}
14
- Focus on patterns and conventions, not raw quality or architecture. Be specific — cite examples.
15
- {% endblock %}
@@ -1,11 +0,0 @@
1
- Analyze code quality at `{{ path }}`.
2
-
3
- {% if exploration.files is defined %}
4
- ## Codebase
5
- {% for file in exploration.files %}
6
- - `{{ file.path }}` ({{ file.lines }} lines)
7
- {% endfor %}
8
- {% endif %}
9
-
10
- Assess test coverage, error handling, code smells, and maintainability.
11
- Write your analysis as JSON conforming to the output schema.
@@ -1,15 +0,0 @@
1
- {% extends "analyzers/base-analyzer.md" %}
2
-
3
- {% block identity %}You are a code quality analyst.{% endblock %}
4
-
5
- {% block checklist %}
6
- 1. **Test coverage**: What is tested? What isn't? Are tests meaningful?
7
- 2. **Error handling**: How are errors handled? Are there gaps?
8
- 3. **Code smells**: Duplicated logic, overly complex functions, magic numbers?
9
- 4. **Documentation**: Is the code documented? Are the docs accurate?
10
- 5. **Maintainability**: How easy would it be to modify this code?
11
- {% endblock %}
12
-
13
- {% block constraints %}
14
- Focus on quality concerns, not architecture or design patterns. Be specific — cite files and line ranges.
15
- {% endblock %}
@@ -1,17 +0,0 @@
1
- Analyze the code at `{{ path }}`.
2
-
3
- {% if exploration.files is defined %}
4
- ## Prior Exploration
5
- {% for file in exploration.files %}
6
- - `{{ file.path }}` ({{ file.lines }} lines){% if file.exports %}: {{ file.exports | length }} exports{% endif %}
7
- {% endfor %}
8
- {% endif %}
9
-
10
- {% if exploration.types is defined %}
11
- ## Known Types
12
- {% for t in exploration.types %}
13
- - `{{ t.name }}` ({{ t.kind }}) in `{{ t.file }}`
14
- {% endfor %}
15
- {% endif %}
16
-
17
- Write your analysis as JSON conforming to the output schema.
@@ -1,15 +0,0 @@
1
- {% extends "analyzers/base-analyzer.md" %}
2
-
3
- {% block identity %}You are a code structure analyst.{% endblock %}
4
-
5
- {% block checklist %}
6
- 1. **Architecture**: How is the code organized? What patterns are used?
7
- 2. **Module boundaries**: Are responsibilities clearly separated?
8
- 3. **Dependencies**: What are the key dependency relationships?
9
- 4. **Entry points**: How does execution flow through the code?
10
- 5. **Configuration**: How is the system configured?
11
- {% endblock %}
12
-
13
- {% block constraints %}
14
- Focus on structural concerns, not code quality or patterns. Be specific — cite files and directories.
15
- {% endblock %}
@@ -1,117 +0,0 @@
1
- ## Project Identity
2
-
3
- **Name:** {{ project.name }}
4
- **Description:** {{ project.description }}
5
- **Core Value:** {{ project.core_value }}
6
- {% if project.stack %}
7
-
8
- ### Stack
9
- {% for item in project.stack %}
10
- - {{ item }}
11
- {% endfor %}
12
- {% endif %}
13
-
14
- ### Constraints
15
- {% for constraint in project.constraints %}
16
- - [{{ constraint.type }}] {{ constraint.description }}
17
- {% endfor %}
18
-
19
- ### Scope Boundaries
20
-
21
- **In scope:**
22
- {% for item in project.scope_boundaries.in %}
23
- - {{ item }}
24
- {% endfor %}
25
-
26
- **Out of scope:**
27
- {% for item in project.scope_boundaries.out %}
28
- - {{ item }}
29
- {% endfor %}
30
-
31
- ## Requirements
32
-
33
- ### Must
34
- {% for req in requirements.requirements %}
35
- {% if req.priority == "must" %}
36
- - **{{ req.id }}** [{{ req.type }}]: {{ req.description }}
37
- {% endif %}
38
- {% endfor %}
39
-
40
- ### Should
41
- {% for req in requirements.requirements %}
42
- {% if req.priority == "should" %}
43
- - **{{ req.id }}** [{{ req.type }}]: {{ req.description }}
44
- {% endif %}
45
- {% endfor %}
46
-
47
- ### Could
48
- {% for req in requirements.requirements %}
49
- {% if req.priority == "could" %}
50
- - **{{ req.id }}** [{{ req.type }}]: {{ req.description }}
51
- {% endif %}
52
- {% endfor %}
53
-
54
- ## Instructions
55
-
56
- Design the initial architecture for this project. Produce modules, patterns, and boundaries that satisfy the requirements above — starting with "must" requirements and ensuring "should" requirements have a clear home.
57
-
58
- ### For each module, provide:
59
-
60
- 1. **name** — short identifier (e.g., "api", "auth", "storage", "cli")
61
- 2. **file** — primary file path relative to project root (e.g., "src/api.ts")
62
- 3. **responsibility** — one sentence: what this module owns and what it does not
63
- 4. **dependencies** — array of other module names this depends on (empty if none)
64
- 5. **lines** — estimated lines of code (rough order of magnitude)
65
-
66
- ### For each pattern, provide:
67
-
68
- 1. **name** — recognized pattern name (e.g., "Repository Pattern", "Event Sourcing", "Middleware Pipeline")
69
- 2. **description** — why this pattern is appropriate for this project's specific needs
70
- 3. **used_in** — array of module names that implement this pattern
71
-
72
- ### For boundaries, provide:
73
-
74
- An array of strings — each describing a hard architectural constraint. These should be specific to this project, not generic ("All database access goes through the storage module", not "separate concerns").
75
-
76
- ### Design principles
77
-
78
- - Module count should be proportional to requirements — a 5-requirement project needs 3-5 modules, not 15
79
- - Every "must" functional requirement should map to at least one module's responsibility
80
- - Every "must" non-functional requirement should be addressed by a pattern or boundary
81
- - Dependencies should flow in one direction — avoid circular module dependencies
82
- - If the project has a stated stack, modules should use file extensions and conventions matching that stack
83
- - Prefer explicit boundaries over implicit conventions
84
-
85
- ### Overview
86
-
87
- Write an `overview` paragraph (required) summarizing:
88
- - The architectural style (layered, modular, pipeline, etc.)
89
- - The key structural decisions and why they fit this project
90
- - How the architecture supports the core_value
91
-
92
- ### Output format
93
-
94
- Produce a single JSON object:
95
-
96
- ```json
97
- {
98
- "overview": "string (required)",
99
- "modules": [
100
- {
101
- "name": "string (required)",
102
- "file": "string (required)",
103
- "responsibility": "string (required)",
104
- "dependencies": ["string"],
105
- "lines": 100
106
- }
107
- ],
108
- "patterns": [
109
- {
110
- "name": "string (required)",
111
- "description": "string (required)",
112
- "used_in": ["module-name"]
113
- }
114
- ],
115
- "boundaries": ["string"]
116
- }
117
- ```
@@ -1,61 +0,0 @@
1
- Infer the architecture of the project at `{{ path }}`.
2
-
3
- ## Codebase Analysis
4
-
5
- {% if exploration.files is defined %}
6
- ### Files
7
- {% for file in exploration.files %}
8
- - `{{ file.path }}` ({{ file.language | default("unknown") }}, {{ file.lines | default("?") }} lines){% if file.exports %} — {{ file.exports | length }} exports{% endif %}
9
- {% endfor %}
10
- {% endif %}
11
-
12
- {% if exploration.types is defined %}
13
- ### Types
14
- {% for t in exploration.types %}
15
- - `{{ t.name }}` ({{ t.kind }}) in `{{ t.file }}`
16
- {% endfor %}
17
- {% endif %}
18
-
19
- {% if exploration.dependencies is defined %}
20
- ### Dependencies
21
- {% for d in exploration.dependencies %}
22
- - `{{ d.from }}` → `{{ d.to }}` ({{ d.type | default("import") }})
23
- {% endfor %}
24
- {% endif %}
25
-
26
- {% if exploration.entryPoints is defined %}
27
- ### Entry Points
28
- {% for ep in exploration.entryPoints %}
29
- - `{{ ep }}`
30
- {% endfor %}
31
- {% endif %}
32
-
33
- ## Instructions
34
-
35
- From the analysis above and targeted code reads, produce an architecture block:
36
-
37
- 1. **Modules** — each cohesive unit with a clear responsibility. For each:
38
- - `name`: concise identifier (e.g., "block-api", "expression-engine")
39
- - `file`: primary file path relative to project root
40
- - `responsibility`: one-sentence description of what this module does
41
- - `dependencies`: array of other module names this module depends on
42
- - `lines`: approximate line count
43
-
44
- 2. **Patterns** — design patterns evidenced in the code. For each:
45
- - `name`: pattern name (e.g., "registry", "factory", "middleware")
46
- - `description`: how this pattern is applied in this codebase
47
- - `used_in`: array of module names that use this pattern
48
-
49
- 3. **Boundaries** — architectural seams where modules interact through defined interfaces (e.g., "block-api validates all writes before persistence", "dispatch spawns subprocesses through a single entry point")
50
-
51
- 4. **Overview** — one paragraph summarizing the architecture: what the system does, how it's organized, and what the key design decisions are
52
-
53
- Read entry points, config files, and module interfaces to confirm the exploration. Do not read every file.
54
-
55
- ## Required Output Schema
56
-
57
- You MUST produce JSON conforming exactly to this schema. Every required field must be present.
58
-
59
- ```json
60
- {{ output_schema }}
61
- ```
@@ -1,59 +0,0 @@
1
- Verify whether the following audit findings have been resolved.
2
-
3
- ## Audit Findings
4
-
5
- {% for finding in audit.findings %}
6
- ### Finding: {{ finding.id }}
7
-
8
- **Description**: {{ finding.description }}
9
- **Severity**: {{ finding.severity | default("unspecified") }}
10
- **Category**: {{ finding.category | default("unspecified") }}
11
- **Principle**: {{ finding.principle | default("unspecified") }}
12
-
13
- **Locations**:
14
- {% for loc in finding.locations %}
15
- - `{{ loc.file }}` {% if loc.line %}line {{ loc.line }}{% endif %} {% if loc.description %} — {{ loc.description }}{% endif %}
16
- {% endfor %}
17
-
18
- {% if finding.fix %}
19
- **Fix suggestion**: {{ finding.fix.suggestion | default("none") }}
20
- {% endif %}
21
-
22
- {% if finding.resolution and finding.resolution.status == 'passed' %}
23
- *Previously marked as resolved — re-verify.*
24
- {% endif %}
25
- ---
26
- {% endfor %}
27
-
28
- ## Implementation Results
29
-
30
- {% if implementation_results is iterable and implementation_results is not string %}
31
- {% for result in implementation_results %}
32
- - {{ result.spec_name | default(result.name | default("task")) }}: {{ result.status | default("unknown") }}
33
- {% endfor %}
34
- {% else %}
35
- ```json
36
- {{ implementation_results | dump(2) }}
37
- ```
38
- {% endif %}
39
-
40
- {% if conformance_reference %}
41
- ## Conformance Reference
42
-
43
- ```json
44
- {{ conformance_reference | dump(2) }}
45
- ```
46
- {% endif %}
47
-
48
- ## Instructions
49
-
50
- For EACH finding above:
51
-
52
- 1. Read the code at the referenced location(s)
53
- 2. Determine if the finding's described issue is addressed
54
- 3. Record your verdict: `passed`, `failed`, or `needs_inspect`
55
- 4. Provide specific evidence (code snippet, file:line reference)
56
-
57
- Do NOT use grep exit codes as evidence. Read the code and assess whether the issue described in the finding is genuinely resolved.
58
-
59
- Produce JSON output with a `findings` array containing one entry per finding, plus summary statistics.