pirl-framework-cli 0.0.0-stage → 1.0.1

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 (92) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/LICENSE +21 -0
  3. package/README.md +88 -2
  4. package/bundled-framework/files/.agents/evals/layer_record.py +438 -0
  5. package/bundled-framework/files/.agents/evals/tests/test_layer_record.py +264 -0
  6. package/bundled-framework/files/.agents/evals/tests/test_skills.py +210 -0
  7. package/bundled-framework/files/.agents/evals/tests/test_validate_layer_artifact.py +214 -0
  8. package/bundled-framework/files/.agents/evals/validate_layer_artifact.py +415 -0
  9. package/bundled-framework/files/.agents/instructions/implement.instructions.md +343 -0
  10. package/bundled-framework/files/.agents/instructions/layered-task-execution.instructions.md +370 -0
  11. package/bundled-framework/files/.agents/instructions/layout-verification.instructions.md +107 -0
  12. package/bundled-framework/files/.agents/instructions/plan.instructions.md +292 -0
  13. package/bundled-framework/files/.agents/instructions/review.instructions.md +236 -0
  14. package/bundled-framework/files/.agents/instructions/self-evaluation.instructions.md +146 -0
  15. package/bundled-framework/files/.agents/instructions/standalone-and-maintenance.instructions.md +230 -0
  16. package/bundled-framework/files/.agents/roles/backend-developer.role.md +45 -0
  17. package/bundled-framework/files/.agents/roles/business-analyst.role.md +55 -0
  18. package/bundled-framework/files/.agents/roles/code-analyst.role.md +63 -0
  19. package/bundled-framework/files/.agents/roles/code-reviewer.role.md +46 -0
  20. package/bundled-framework/files/.agents/roles/frontend-developer.role.md +51 -0
  21. package/bundled-framework/files/.agents/roles/process-auditor.role.md +62 -0
  22. package/bundled-framework/files/.agents/roles/solution-architect.role.md +53 -0
  23. package/bundled-framework/files/.agents/roles/technical-writer.role.md +68 -0
  24. package/bundled-framework/files/.agents/roles/ux-designer.role.md +46 -0
  25. package/bundled-framework/files/.skills/pirl-implement/SKILL.md +115 -0
  26. package/bundled-framework/files/.skills/pirl-implement/assets/implementation-record-template.md +22 -0
  27. package/bundled-framework/files/.skills/pirl-implement/references/implementation-record-format.md +41 -0
  28. package/bundled-framework/files/.skills/pirl-implement/scripts/add_implementation_record.py +58 -0
  29. package/bundled-framework/files/.skills/pirl-implement/scripts/new_layout_run.py +51 -0
  30. package/bundled-framework/files/.skills/pirl-plan/SKILL.md +100 -0
  31. package/bundled-framework/files/.skills/pirl-plan/assets/plan-template.md +48 -0
  32. package/bundled-framework/files/.skills/pirl-plan/references/plan-format.md +65 -0
  33. package/bundled-framework/files/.skills/pirl-plan/scripts/new_plan.py +93 -0
  34. package/bundled-framework/files/.skills/pirl-review/SKILL.md +106 -0
  35. package/bundled-framework/files/.skills/pirl-review/assets/review-template.md +92 -0
  36. package/bundled-framework/files/.skills/pirl-review/references/review-format.md +70 -0
  37. package/bundled-framework/files/.skills/pirl-review/scripts/new_review.py +83 -0
  38. package/bundled-framework/files/AGENTS.md +303 -0
  39. package/bundled-framework/files/CONTEXT.md +187 -0
  40. package/bundled-framework/files/LICENSE +21 -0
  41. package/bundled-framework/files/README.md +170 -0
  42. package/bundled-framework/files/gitignore.pirl-bundled +12 -0
  43. package/bundled-framework/manifest.json +45 -0
  44. package/dist/bin/main.js +128 -0
  45. package/dist/bin/pirl.js +6 -0
  46. package/dist/commands/dispatch.js +57 -0
  47. package/dist/commands/registry.js +39 -0
  48. package/dist/core/clipboard.js +70 -0
  49. package/dist/core/config.js +73 -0
  50. package/dist/core/exec.js +32 -0
  51. package/dist/core/paths.js +34 -0
  52. package/dist/core/targetRepo.js +22 -0
  53. package/dist/doctor/doctor.js +95 -0
  54. package/dist/engine/agentMerge.js +71 -0
  55. package/dist/engine/agents.js +67 -0
  56. package/dist/engine/attachments.js +251 -0
  57. package/dist/engine/claudeQuota.js +62 -0
  58. package/dist/engine/claudeRunner.js +118 -0
  59. package/dist/engine/claudeStream.js +205 -0
  60. package/dist/engine/hubData.js +176 -0
  61. package/dist/engine/permissions.js +67 -0
  62. package/dist/engine/pricing.js +24 -0
  63. package/dist/engine/protocol.js +98 -0
  64. package/dist/engine/run.js +527 -0
  65. package/dist/engine/runStore.js +67 -0
  66. package/dist/engine/types.js +3 -0
  67. package/dist/hub/framework.js +13 -0
  68. package/dist/hub/hub.js +125 -0
  69. package/dist/hub/services.js +38 -0
  70. package/dist/hub/update.js +261 -0
  71. package/dist/providers/claude.js +62 -0
  72. package/dist/providers/index.js +17 -0
  73. package/dist/providers/types.js +1 -0
  74. package/dist/ui/App.js +849 -0
  75. package/dist/ui/browse.js +144 -0
  76. package/dist/ui/components/Header.js +54 -0
  77. package/dist/ui/components/Input.js +76 -0
  78. package/dist/ui/components/Lines.js +50 -0
  79. package/dist/ui/components/Panels.js +73 -0
  80. package/dist/ui/content.js +225 -0
  81. package/dist/ui/frameworkConsole.js +541 -0
  82. package/dist/ui/inputEditor.js +86 -0
  83. package/dist/ui/layout.js +36 -0
  84. package/dist/ui/lines.js +15 -0
  85. package/dist/ui/listOverlay.js +97 -0
  86. package/dist/ui/runView.js +305 -0
  87. package/dist/ui/session.js +1 -0
  88. package/dist/ui/terminalInput.js +45 -0
  89. package/dist/ui/text.js +58 -0
  90. package/dist/ui/theme.js +139 -0
  91. package/dist/ui/ticker.js +48 -0
  92. package/package.json +67 -4
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: "Self-evaluation Instructions"
3
+ description: "How process-auditor classifies the issues of a layer run, applies improvements and writes the run's record. Read in full by process-auditor; read by the coordinator only when it self-evaluates in mode: self."
4
+ applyTo: ".agents/instructions/**/*,.skills/**/*,.agents/roles/process-auditor.role.md"
5
+ metadata:
6
+ id: ".agents/instructions/self-evaluation"
7
+ kind: "instruction"
8
+ version: "1.0.0"
9
+ status: "active"
10
+ ---
11
+
12
+ # Self-evaluation Instructions
13
+
14
+ This file holds the procedure of the
15
+ [router's Self-evaluation and improvement section](layered-task-execution.instructions.md#self-evaluation-and-improvement),
16
+ which owns when a Plan, Implement or Review run self-evaluates, who evaluates
17
+ and how the result is reported. `process-auditor` reads this whole file in
18
+ every layer run; the coordinator reads it only when it self-evaluates in
19
+ `mode: self`. Standalone tasks and framework maintenance do not apply it.
20
+
21
+ ## Issues and causes
22
+
23
+ An issue is a decision or output that is wrong against the request, the
24
+ source, a contract or a rule, with evidence. Each issue records the role (or
25
+ `coordinator`), the wrong decision, the related rule as `file#section`, the
26
+ evidence and an `issue_key`: a kebab-case key describing the issue; an issue
27
+ already present in an earlier record keeps its existing key.
28
+
29
+ Before classifying, look up earlier records with `layer_record.py query --issue-key <key>`
30
+ and `layer_record.py query --rule <file#section>`. Classify by evidence, not
31
+ by how many times it repeated:
32
+
33
+ | Cause | When | Required improvement |
34
+ | --- | --- | --- |
35
+ | `instruction` | Reading the rules at exactly `framework_ref`: no rule covers this case, a rule leads to the wrong decision, two rules conflict, or a rule is ambiguous | Fix the rule |
36
+ | `ineffective_fix` | An earlier record fixed an issue with the same key or the same rule, and the issue still happens | Determine why that fix failed (wrong cause, does not cover this case, the role does not load the rule), then replace or revert that fix itself, without stacking another. Record `prior_fix` |
37
+ | `input` | The rule is right but the input is missing or wrong: the Plan lacks a decision, the target repository's context documentation is incomplete or wrong | Fix where the input is produced: the rule of the layer or skill that produces it. A gap in the target repository's context documentation lies outside the framework: record that improvement `pending_user` with reason `repository` and propose it to the user as a standalone task in that repository |
38
+ | `execution` | The rule is clear, was loaded and leads to the right decision, but the role did not follow it | Increase enforcement: put that point in the role's "Done when" column in the layer file's table, or assign a verification role to check exactly that point |
39
+
40
+ ## Thorough improvement
41
+
42
+ Applies in `mode: agent`, and in `mode: self` per the
43
+ [Self-evaluation when `mode: self`](#self-evaluation-when-mode-self) section.
44
+ Every issue must have an improvement applied within the run. There are no
45
+ off-limits areas and no waiting for proposals:
46
+
47
+ 1. Before editing any framework file, read the
48
+ [standalone and maintenance instructions](standalone-and-maintenance.instructions.md). Fix every place that owns
49
+ the cause: layer files, skills, role files,
50
+ `AGENTS.md`, the router, framework tools with their tests. The only
51
+ improvement not applied this way is one in a target repository's context
52
+ documentation, handled per the `input` row above.
53
+ 2. Sweep the whole framework for places still describing the old behavior and
54
+ fix them in the same run.
55
+ 3. Replace the wrong passage with concrete conditions and actions; do not pile
56
+ on reminders, and write it in the general form described in the
57
+ [Framework maintenance section](standalone-and-maintenance.instructions.md#framework-maintenance).
58
+ 4. Bump the `version` of files that have one.
59
+ 5. Re-read the edited part against the three scenarios of the
60
+ [Framework maintenance section](standalone-and-maintenance.instructions.md#framework-maintenance).
61
+ 6. Run the commands in [Framework checks](standalone-and-maintenance.instructions.md#framework-checks)
62
+ that match what was edited.
63
+
64
+ Mandatory exception: never loosen the
65
+ [safety rules](../../AGENTS.md#safety-rules-and-self-improvement).
66
+ An improvement that would loosen a safety rule is not applied: record
67
+ `pending_user` with reason `safety` and ask the user.
68
+
69
+ ## Self-evaluation when `mode: self`
70
+
71
+ The self-evaluation itself does not edit framework files: every improvement in
72
+ its record is recorded as `pending_user` with reason `mode_self`, and the tool
73
+ rejects `applied` in `mode: self`. Improvements that touch no safety rule do not
74
+ need the user's confirmation ([AGENTS.md](../../AGENTS.md#workflow)), so within
75
+ the same run the coordinator applies each improvement that touches no safety
76
+ rule as user-directed framework maintenance, following the six steps of the
77
+ [Thorough improvement](#thorough-improvement) section. It then writes a new
78
+ record whose `supersedes` points to the self-evaluation record, with empty
79
+ `issues` and `fixes`, and a `summary` stating each `issue_key`, the file and
80
+ section edited, old → new version, the check commands run and a reference to
81
+ the authorization in `AGENTS.md`. The final response reports this in the
82
+ "Self-improvement" section, without asking.
83
+
84
+ An improvement that touches a safety rule (loosening, narrowing, removing or
85
+ working around it) is not applied: the record states `pending_user` with reason
86
+ `safety`; the final response states the issue, cause, rule, the concrete change
87
+ and the evidence of that improvement in the "Self-improvement" section, and the
88
+ user's decision (apply, skip, or re-evaluate with a separate agent) is one point
89
+ in "Needs confirmation"
90
+ ([CONTEXT.md](../../CONTEXT.md#5-closing-block-needs-confirmation-and-proposals));
91
+ no other separate section is opened for that decision. The run that carries out
92
+ that choice writes a new record whose `supersedes` points to the old record.
93
+
94
+ ## Record
95
+
96
+ Each run writes exactly one record with
97
+ `python -B .agents/evals/layer_record.py append --input <JSON file>`
98
+ (or by passing JSON on stdin). On Windows, use `--input` with a UTF-8 file so
99
+ non-ASCII text is not corrupted. The tool adds `schema`, `record_id`,
100
+ `recorded_at` and rejects malformed records; if the record is rejected, the run
101
+ is not complete. Do not edit the JSONL files by hand; correct a record with a
102
+ new record that has `supersedes`. Records are handoff output, stored at
103
+ `.agents/evals/records/<layer>/<YYYY-MM-DD>.jsonl`. That directory is ignored
104
+ by Git because records describe the user's projects: they stay on the local
105
+ machine and are never committed, and the tool still reads them for `query` and
106
+ `check`.
107
+
108
+ | Field | Content |
109
+ | --- | --- |
110
+ | `layer` | `plan`, `implement` or `review` |
111
+ | `framework_ref` | The value `start` returned at the start of the run |
112
+ | `task` | `plan_set`, `task_ids`; Review adds `report_file` |
113
+ | `target_repo` | As in the Plan |
114
+ | `outcome` | `status` (Plan: `ready`, `draft`, `blocked`; Implement: the Implementation Record status; Review: `completed`, `blocked`) and `summary`; Review adds `verdict` |
115
+ | `roles` | Each participating role: `role`, `mode`, `assignment`, `result` (`PASS`, `FAIL`, `BLOCKED`) |
116
+ | `audit` | `role: process-auditor`, `mode`, `result` (`clean` or `issues`) |
117
+ | `issues` | Each issue: `id` (`ISSUE-NN`), `issue_key`, `role`, `record` (null; or the record in `evaluates` when the issue belongs to the re-evaluated run), `cause`, `decision`, `rule`, `evidence`, `prior_fix` (`<record_id>#FIX-NN`, only for `ineffective_fix`) |
118
+ | `fixes` | Each improvement: `id` (`FIX-NN`), the `issues` it addresses, `status` (`applied` or `pending_user`), `reason` when pending (`mode_self`, `safety` or `repository`), `files` (`path`, `section`), `summary`, `checks` (check commands that were run, required when `applied`) |
119
+ | `evaluates` | Review: the record of the reviewed Implement run; other layers write null |
120
+ | `supersedes` | The record being corrected, or null |
121
+
122
+ A complete record for a Plan run, as the input of `append`. Values in `<...>`
123
+ are placeholders; `framework_ref` is the object `start` returned, copied as is.
124
+ A run with no issues writes `issues: []`, `fixes: []` and
125
+ `audit.result: "clean"`; a Review record also has `task.report_file` and
126
+ `outcome.verdict`.
127
+
128
+ ```json
129
+ {
130
+ "layer": "plan",
131
+ "framework_ref": {"commit": "<commit>", "files": {"<path>": "<hash>"}},
132
+ "task": {"plan_set": "<plan-set>", "task_ids": ["T01"]},
133
+ "target_repo": "<as in the Plan>",
134
+ "outcome": {"status": "ready", "summary": "<summary>"},
135
+ "roles": [{"role": "code-analyst", "mode": "agent", "assignment": "<assignment>", "result": "PASS"}],
136
+ "audit": {"role": "process-auditor", "mode": "agent", "result": "issues"},
137
+ "issues": [{"id": "ISSUE-01", "issue_key": "<kebab-case-key>", "role": "coordinator", "record": null,
138
+ "cause": "instruction", "decision": "<wrong decision>", "rule": "<file#section>", "evidence": "<evidence>"}],
139
+ "fixes": [{"id": "FIX-01", "issues": ["ISSUE-01"], "status": "applied",
140
+ "files": [{"path": "<framework file>", "section": "<section>"}], "summary": "<change>", "checks": ["<command>"]}],
141
+ "evaluates": null,
142
+ "supersedes": null
143
+ }
144
+ ```
145
+
146
+ Every issue must belong to at least one improvement.
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: "Standalone Tasks and Framework Maintenance Instructions"
3
+ description: "Standalone tasks and how the framework itself is maintained: its structure and owners, the role catalog, the constraints on roles and the checks; read only in the cases listed at the top."
4
+ applyTo: ".agents/**/*,.skills/**/*,AGENTS.md,CONTEXT.md"
5
+ metadata:
6
+ id: ".agents/instructions/standalone-and-maintenance"
7
+ kind: "instruction"
8
+ version: "1.0.3"
9
+ status: "active"
10
+ ---
11
+
12
+ # Standalone tasks and framework maintenance
13
+
14
+ Read this file only in these cases:
15
+
16
+ - a standalone task: the [Standalone tasks](#standalone-tasks) section;
17
+ - framework maintenance the user assigns: the whole file;
18
+ - inside a Plan, Implement or Review run, only when a framework improvement is
19
+ applied (`process-auditor`, or the coordinator in `mode: self`), per the
20
+ [Thorough improvement](self-evaluation.instructions.md#thorough-improvement)
21
+ section of the self-evaluation instructions.
22
+
23
+ Plan, Implement and Review runs do not read it otherwise; a question that only
24
+ needs an explanation reads it only when the question is about the framework's
25
+ structure or maintenance.
26
+
27
+ ## Standalone tasks
28
+
29
+ A standalone task is work the user assigns directly that closes within that
30
+ same run, outside the Plan → Implement → Review chain: writing or updating
31
+ documentation on request, an investigation with durable output, a small fix
32
+ the user specifies. Carrying out a Plan task is still Implement, even with a
33
+ single role. A question that only needs an explanation and creates no durable
34
+ output is answered directly (step 3 of
35
+ [Choosing a layer](../../AGENTS.md#choosing-a-layer)).
36
+
37
+ No Review is scheduled, so the person doing the work closes the loop within the session:
38
+
39
+ 1. Complete the delivery within exactly the scope the user assigned, under the
40
+ core rules.
41
+ 2. Self-verify: check the output against the request and the authoritative
42
+ sources, and pick a counterexample that could refute the most important
43
+ claim; fix wrong output before reporting. Record it as self-verification,
44
+ not an independent review.
45
+ 3. Report separately the delivery result, how it was verified and what remains
46
+ unknown. Do not create a Plan or report unless the user asks. Standalone
47
+ tasks write no self-evaluation record; only the three layers write one, per
48
+ the [Self-evaluation and improvement section](layered-task-execution.instructions.md#self-evaluation-and-improvement).
49
+ 4. Clean up temporary resources per the [cleanup section](layered-task-execution.instructions.md#cleaning-up-temporary-resources-before-handoff).
50
+
51
+ If the user later asks for a Review, the Review evaluates as usual;
52
+ self-verification does not replace the Review's conclusions.
53
+
54
+ ### Verifying standalone work
55
+
56
+ Applies to standalone tasks and to work done directly without a layer; the
57
+ three layers verify per the
58
+ [Verification by reasoning section](layered-task-execution.instructions.md#verification-by-reasoning).
59
+
60
+ - Choose the narrowest verification that answers the open question: static
61
+ (types, lint, syntax, metadata), unit (pure functions, services, domain
62
+ rules), component (UI behavior and accessibility), integration (API,
63
+ authentication, storage, multi-tier flows) or manual (visual layout, real
64
+ browser, multi-step flows per viewport). Widen only when an affected contract
65
+ or a concrete failure mechanism requires it; a file name or the existence of
66
+ a test does not create that need. Tests written or run follow the
67
+ [FUT rule](layered-task-execution.instructions.md#functional-tests-fut-rule).
68
+ - A passing command only proves the cases that ran, not invariant coverage,
69
+ adjacent integration paths, edge behavior or the reliability of the skipped
70
+ part. A case skipped because of the platform only proves that case does not
71
+ run in this environment; it does not prove the product needs another
72
+ platform. Infer environment requirements from the user's task and the
73
+ repository's actually supported behavior.
74
+ - Report each verification with the command, its purpose, the working
75
+ directory, pass/fail/blocker, a summary of the key output and the remaining
76
+ risk.
77
+
78
+ ## Framework maintenance
79
+
80
+ A request to edit `AGENTS.md`, `CONTEXT.md`, instructions, roles, skills or
81
+ the tools in `.agents/evals/` directly is framework maintenance within the scope
82
+ the user assigns. Do not force a product Plan or
83
+ report before editing. Improvements that `process-auditor` applies during a
84
+ layer run under the
85
+ [Self-evaluation and improvement section](layered-task-execution.instructions.md#self-evaluation-and-improvement) are
86
+ also framework maintenance, allowed by that section without a separate request.
87
+
88
+ - Start from the wrong or missing decision, then identify the owning file:
89
+ `AGENTS.md` for the core rules, structure, roles and the target repository;
90
+ `CONTEXT.md` for how responses to the user are presented; the router for
91
+ layer boundaries and shared contracts; the layer contract for the roles'
92
+ responsibilities, decisions and exit conditions; the layer's skill for the
93
+ run procedure, the output format and the helper scripts. Read the files that
94
+ reference the rule before changing it, so that other files do not restore the
95
+ old behavior.
96
+ - Write rules in the framework's general form, reusable for every repository,
97
+ host and situation of the same kind: conditions are stated by kind of
98
+ situation, actions by role and output, not by one event that happened. The
99
+ content of `AGENTS.md`, `CONTEXT.md`, instructions, role files, rules and tools
100
+ contains no details specific to one run or one project as a condition or
101
+ basis: repository or product names, paths inside a product repository,
102
+ specific tokens or values, task or record IDs, dates, quotes from the user,
103
+ names of a specific host or tool. Illustrative examples, when needed, are
104
+ marked as examples and do not become conditions. Knowledge specific to one
105
+ repository lives in that repository's own context documentation; the
106
+ decisions and evidence of a run live in Plans, Implementation Records,
107
+ reports and records.
108
+ - Fix with conditions and actions that are concrete enough; replace the wrong
109
+ passage instead of piling on reminders. Re-read against three scenarios: the
110
+ scenario that caused the problem, a similar scenario where the rule must not
111
+ apply, and a scenario of the same kind in another repository or host; the
112
+ rule must apply to the third scenario without changes. Do not add tests,
113
+ validators or schemas in place of improving the content, and do not create
114
+ tests or validators that grade wording by headings, keywords, counts or
115
+ format.
116
+ - After editing, run the matching commands in the
117
+ [Framework checks](#framework-checks) section below.
118
+ The checks only confirm structure; they do not prove the quality of the wording.
119
+
120
+ ### Framework structure
121
+
122
+ ```text
123
+ AGENTS.md root: core rules, flow, choosing the kind of work, delegation, target repository
124
+ CONTEXT.md how responses to the user are presented
125
+ .agents/
126
+ instructions/
127
+ layered-task-execution.instructions.md router: layer boundaries, assignment, shared contracts
128
+ plan.instructions.md Plan layer contract
129
+ implement.instructions.md Implement layer contract
130
+ review.instructions.md Review layer contract
131
+ layout-verification.instructions.md layout verification with mocks, read when a diff changes the UI
132
+ self-evaluation.instructions.md issue causes, improvements and the record of a layer run, read by process-auditor
133
+ standalone-and-maintenance.instructions.md standalone tasks, framework maintenance, structure, role catalog
134
+ roles/ expertise of each role: <role-id>.role.md
135
+ evals/
136
+ validate_layer_artifact.py Plan/Review validator
137
+ layer_record.py self-evaluation record tool
138
+ tests/ tests of the tools, the role catalog and the skills
139
+ records/ self-evaluation records: <layer>/<YYYY-MM-DD>.jsonl (local, ignored by Git)
140
+ .skills/
141
+ pirl-plan/ Plan skill: SKILL.md, assets/, references/, scripts/
142
+ pirl-implement/ Implement skill: same layout
143
+ pirl-review/ Review skill: same layout
144
+ .tmp/ temporary output, ignored by Git (layout snapshots, tool logs)
145
+ <plan-set>/ Plan package and its Review reports, created at the Hub root unless the user names another directory (ignored by Git)
146
+ ```
147
+
148
+ | Source | Owns |
149
+ | --- | --- |
150
+ | `AGENTS.md` | Core rules, flow, choosing the kind of work, delegation, target repository, Git |
151
+ | `CONTEXT.md` | How answers, summaries, reports, proposals and syntheses sent to the user are presented |
152
+ | Router | Boundaries between kinds of work, assignment principles, shared contracts (verification by reasoning, functional tests, shared snapshots and older records, when a run self-evaluates and how it reports, cleanup) |
153
+ | Self-evaluation instructions | How issues are classified by cause, how improvements are applied, the record and its fields |
154
+ | Standalone and maintenance instructions | Standalone tasks, framework maintenance and its check commands, this structure, the role catalog, the constraints that keep roles separate from skills |
155
+ | Layer instruction | Each role's responsibilities at the layer, the decisions the layer settles, the content its output must hold and its exit conditions; the Implement contract also holds when layout verification with mocks applies |
156
+ | Layout verification instructions | How layout is captured and checked with mocks, and how Review reads the result |
157
+ | Skill | How one layer run is carried out: when the skill applies, the ordered procedure linking each step to the contract that owns it, the output format and template, helper scripts |
158
+ | Role file | Shared expertise of one role, identical in every layer |
159
+ | Evals | Checking handoff artifacts, writing and checking records, the tests of the framework tools and skills |
160
+ | Record | History of self-evaluation and improvement for each layer run; appended only through the tool and kept on the local machine |
161
+
162
+ Each rule lives in exactly one owner; other files point to it instead of
163
+ copying it.
164
+
165
+ ### Role catalog
166
+
167
+ Each layer assigns work to AI Agents by role, matching the expertise the work
168
+ needs. This table is the only catalog of role IDs. A role's expertise lives in
169
+ `.agents/roles/<ID>.role.md`; its concrete responsibilities at each layer (what
170
+ it is assigned, its inputs, when it is done) live in the role table of the
171
+ corresponding layer file. The `Used in` column says where a role can be
172
+ selected: `plan`, `implement`, `verify` (QG verification at Implement),
173
+ `review`, or `audit` (self-evaluation at the end of each layer).
174
+
175
+ | ID | Expertise | Used in |
176
+ | --- | --- | --- |
177
+ | `business-analyst` | Business logic, REQs, QGs, missing product decisions | plan, review |
178
+ | `solution-architect` | API/data contracts, ownership, permission model, boundaries and dependencies between tasks | plan, review |
179
+ | `code-analyst` | Tracing data/control flow, callers/consumers, impact on documentation, scenario tables for multi-branch flows | plan, verify, review |
180
+ | `ux-designer` | Screens, display states, interaction flows, UI strings per language, layout per viewport | plan, verify, review |
181
+ | `backend-developer` | Non-UI code: API, domain, data, jobs, CLI, scripts, tools; accompanying docs and tests under FUT | implement |
182
+ | `frontend-developer` | UI code, i18n strings, layout snapshots with mocks; accompanying docs and tests under FUT | implement |
183
+ | `technical-writer` | Documentation that must match the source: context docs, contracts, indexes, status tables | implement |
184
+ | `code-reviewer` | Challenging the diff: bugs, regressions, permissions and security, data/state consistency, guards/validators/error handling | verify, review |
185
+ | `process-auditor` | Self-evaluating a layer run, finding root causes, improving the framework, writing records | audit |
186
+
187
+ ### Constraints that keep roles separate from skills
188
+
189
+ Constraints that keep roles separate from skills:
190
+
191
+ - Closed catalog: only the IDs in this table. Adding, merging or removing a role
192
+ means editing this table together with the role file, the layer file tables
193
+ and the framework checks, in one change.
194
+ - Layers pick roles themselves following the layer file's guidance: Plan and
195
+ Review by the "Select when" column; the Implement team for implementation and
196
+ verification is chosen by the Plan. The user does not need to name roles, but
197
+ when they do, keep exactly that list.
198
+ - A role file contains only shared expertise: the questions the role answers,
199
+ how it works, warning signs, boundaries with other roles. It does not contain
200
+ a layer's sequence, output templates, commands or completion conditions; those
201
+ belong to the layer contract and the layer's skill.
202
+ - Roles have no artifacts, tools, skills or evaluation mechanism of their own;
203
+ a role is evaluated through the layer's record.
204
+ - Knowledge specific to one repository lives in that repository's context
205
+ documentation, not in role files or skills. Roles do not rely on a host's
206
+ skill mechanism or custom agent configuration: the layer skills are plain
207
+ files the coordinator reads and passes on.
208
+
209
+ ### Framework checks
210
+
211
+ Pick the checks that match the change. They only validate handoff inputs and
212
+ outputs and do not grade the wording; instruction content is re-read against
213
+ the scenario that caused the problem.
214
+
215
+ ```powershell
216
+ python -B .agents/evals/validate_layer_artifact.py --kind <plan|review> --path <file or directory>
217
+ python -B .agents/evals/layer_record.py <start|append|check|query> ...
218
+ python -B -m unittest discover -s .agents/evals/tests -p "test_*.py"
219
+ ```
220
+
221
+ The first command checks Plan/Review files (schema, required fields, roles,
222
+ dependencies, time zone) and runs when they are handed off. The second writes
223
+ and checks self-evaluation records as the router describes; `check` runs after
224
+ each write or when the tool itself is edited. The last command runs the tests
225
+ of the two tools above, of the role catalog, of the skills (structure, helper
226
+ scripts), of the links between framework files, that private outputs stay out
227
+ of Git and that every tracked file is either framework content or listed as not
228
+ framework; run it when editing the tools, the role catalog, a layer's role
229
+ table, a role file, a skill, `.gitignore`, the headings that other framework
230
+ files link to, or when adding a top-level path.
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: .agents/roles/backend-developer
3
+ kind: role
4
+ version: 1.2.0
5
+ status: active
6
+ ---
7
+
8
+ # backend-developer
9
+
10
+ Writes and edits all non-UI code: API, domain, data and migrations, server-side
11
+ authorization, jobs, CLI, scripts and tools; together with the accompanying
12
+ documentation and functional tests for that part.
13
+
14
+ ## Questions the role answers
15
+
16
+ - Which invariant must hold, and where is it owned?
17
+ - At which boundary is untrusted input validated?
18
+ - How are errors returned; does anything swallow errors or report false success?
19
+ - Does a write keep the data consistent when an error happens midway?
20
+
21
+ ## How it works
22
+
23
+ - Trace the execution path from input to result before editing.
24
+ - Keep each invariant where it is owned and update every affected writer/reader.
25
+ - Follow the repository's existing patterns; add an abstraction only when there
26
+ is evidence it is needed.
27
+ - Validate input at the trust boundary, return clear errors, and do not report
28
+ success when the operation has not finished.
29
+ - Functional tests trace back to a REQ, assert behavior at the functionality's
30
+ contract and do not lock in implementation details.
31
+ - Accompanying documentation is written following the way of working of
32
+ [`technical-writer`](technical-writer.role.md#how-it-works).
33
+ - Self-challenge with counterexamples and edge branches before handing over.
34
+
35
+ ## Common warning signs
36
+
37
+ - Fixing the symptom in the caller instead of where the invariant is owned.
38
+ - Catching an error and ignoring it.
39
+ - Tests that assert the code just written instead of the specification.
40
+ - Forgetting documentation that still describes the old behavior.
41
+
42
+ ## Boundaries with other roles
43
+
44
+ The UI belongs to `frontend-developer`; documentation-only tasks belong to
45
+ `technical-writer`.
@@ -0,0 +1,55 @@
1
+ ---
2
+ id: .agents/roles/business-analyst
3
+ kind: role
4
+ version: 1.2.0
5
+ status: active
6
+ ---
7
+
8
+ # business-analyst
9
+
10
+ Turns requests into verifiable business behavior, finds missing product
11
+ decisions, and checks the source's behavior against the settled business rules.
12
+
13
+ ## Questions the role answers
14
+
15
+ - What outcome does the user need, in which situation?
16
+ - When is something allowed, when is it refused; which state must hold after
17
+ each branch?
18
+ - Which decision has nobody settled, where different choices would give
19
+ different results?
20
+
21
+ ## How it works
22
+
23
+ - Break the request into situation → expected outcome, including refusal and
24
+ failure branches. Each situation records its source: the user's words, a
25
+ specification, or a file/symbol.
26
+ - Distinguish three kinds: what the user has decided; what the agent decided
27
+ with a basis; what nobody has decided. Only the third kind needs a question.
28
+ The user decided only what is in their words or in the verbatim text of the
29
+ choices and choice descriptions they saw when choosing. What is inferred from
30
+ the source and the repository's conventions, what interprets or extends a
31
+ choice, and what the agent chose itself in work the user explicitly delegated
32
+ to the agent are decided by the agent; record them with their basis so the
33
+ user can see and change them.
34
+ - Write criteria as logic observable at the functionality's contract:
35
+ situation → where it is handled → outcome/state. Do not write them as test
36
+ results, builds or measurements.
37
+ - When checking against the source: take the criteria verbatim, consider
38
+ whether each branch can really occur, and do not add criteria by preference.
39
+
40
+ ## Common warning signs
41
+
42
+ - Adding requirements the user did not state: platforms, coverage, performance.
43
+ - Vague criteria such as "works correctly" or "handles errors reasonably".
44
+ - Hiding an unsettled decision behind generic words such as "integrate" or
45
+ "support".
46
+ - Recording what the agent added to a user's choice (for example treating a
47
+ "many" level as also including the items of a lower level) as the user's
48
+ decision.
49
+ - Asking again about something already in the request or findable in the source.
50
+
51
+ ## Boundaries with other roles
52
+
53
+ Technical contracts and ownership belong to `solution-architect`; display states
54
+ and layout belong to `ux-designer`; tracing execution paths in code belongs to
55
+ `code-analyst`.
@@ -0,0 +1,63 @@
1
+ ---
2
+ id: .agents/roles/code-analyst
3
+ kind: role
4
+ version: 1.5.0
5
+ status: active
6
+ ---
7
+
8
+ # code-analyst
9
+
10
+ Traces data and control flow in the source, identifies callers/consumers and the
11
+ impact of a change, and builds scenario tables when a flow has many branches,
12
+ states or orderings.
13
+
14
+ ## Questions the role answers
15
+
16
+ - From the entrypoint, which guards, data transformations and write/read
17
+ operations does the execution path pass through to reach the final state?
18
+ - Who writes and who reads this data; which callers, consumers, configuration
19
+ and documentation does the change touch?
20
+ - For each combination of branch, prior state and event order, what is the
21
+ result?
22
+ - Which elements, consumers or configuration beyond the intended target does
23
+ this change spread to, and what is its effect on each?
24
+
25
+ ## How it works
26
+
27
+ - Start from a real entrypoint: route, handler, job, CLI command, listener.
28
+ - Find callers by symbol, not by file name. Include indirect calls through
29
+ events, configuration, dependency injection or reflection.
30
+ - For multi-branch flows: build the scenario table from the contract (input,
31
+ prior state, order) before reading the code, then trace each row of the table
32
+ through the source.
33
+ - For changes with a spreading scope (inherited or cascading properties,
34
+ properties that create a containing block or stacking context, shared
35
+ configuration or default values, middleware, global parameters): before
36
+ choosing where to put the change, list the child elements or consumers it
37
+ reaches and its effect on each; put it where its spread matches exactly the
38
+ scope needed, or state the acceptable side effects.
39
+ - Check documentation (indexes, API/error/configuration/permission catalogs)
40
+ against the source. Read the sentences that state rules, limits or
41
+ quantities too, not just tables of values, and read in full any sentence the
42
+ diff changes only in part, including clauses outside the diff. For tables or
43
+ lists, read the lead-in sentence, heading and column labels as well, then
44
+ check them against each row or item. Check those sentences following the way
45
+ of working of [`technical-writer`](technical-writer.role.md#how-it-works).
46
+ - Record the file/symbol source for each step traced.
47
+
48
+ ## Common warning signs
49
+
50
+ - Drawing a conclusion about the whole system from one internal function.
51
+ - Stopping at the first calling layer and missing indirect consumers.
52
+ - Building the scenario table from the existing code instead of the contract,
53
+ thereby repeating the code's own defects.
54
+ - Choosing where to put a change by intent ("the navigation bar's background",
55
+ "the module's configuration") without listing what that change spreads to.
56
+ - Concluding that documentation matches the source because the table of values
57
+ matches, while a rule sentence in another section, or the table's own lead-in
58
+ sentence, contradicts a row of that table.
59
+
60
+ ## Boundaries with other roles
61
+
62
+ Challenging a diff to find bugs belongs to `code-reviewer`; contract decisions
63
+ belong to `solution-architect`.
@@ -0,0 +1,46 @@
1
+ ---
2
+ id: .agents/roles/code-reviewer
3
+ kind: role
4
+ version: 1.1.0
5
+ status: active
6
+ ---
7
+
8
+ # code-reviewer
9
+
10
+ Challenges a diff to find real defects: bugs, regressions, permission and
11
+ security holes, data or state inconsistency, guards/validators/error handling
12
+ that cannot tell right from wrong, contract violations, and tests that violate
13
+ the FUT rule.
14
+
15
+ ## Questions the role answers
16
+
17
+ - Which input makes this change produce a wrong result?
18
+ - When an error happens midway, is the state still consistent?
19
+ - Who can perform this operation without having the permission?
20
+ - Does the guard or validator really reject bad values, or does it always
21
+ report success?
22
+ - Do the tests trace back to a REQ; do they lock in implementation details?
23
+
24
+ ## How it works
25
+
26
+ - Read the diff together with the surrounding source and callers, not just the
27
+ diff.
28
+ - For each suspicion, connect trigger → mechanism → consequence, then look for
29
+ a guard or competing explanation that could refute it before concluding.
30
+ - Consider untrusted input, permissions, secrets, injection and every error path.
31
+ - For guards and validators: try boundary values and clearly wrong values on
32
+ paper.
33
+ - Rate severity by impact and by how likely it is to happen on a real failure
34
+ path.
35
+
36
+ ## Common warning signs
37
+
38
+ - Concluding from a function name, a regex or a single code fragment.
39
+ - Raising severity before showing the failure path.
40
+ - Treating a green test as evidence of correct behavior.
41
+ - Keeping a refuted suspicion alive by turning it into a risk.
42
+
43
+ ## Boundaries with other roles
44
+
45
+ Tracing flows across the whole system belongs to `code-analyst`; checking
46
+ business behavior belongs to `business-analyst`.
@@ -0,0 +1,51 @@
1
+ ---
2
+ id: .agents/roles/frontend-developer
3
+ kind: role
4
+ version: 1.3.0
5
+ status: active
6
+ ---
7
+
8
+ # frontend-developer
9
+
10
+ Writes and edits the UI: components, display states, styles, UI strings for each
11
+ language, client-side API calls; together with the accompanying documentation,
12
+ functional tests, and mocks for capturing layout.
13
+
14
+ ## Questions the role answers
15
+
16
+ - Has every display state named by the contract been built?
17
+ - How is API data handled when it is empty, failing or slow?
18
+ - Are the UI strings available for every language?
19
+ - Does the layout hold at every viewport?
20
+
21
+ ## How it works
22
+
23
+ - Follow the repository's existing component, state and style patterns.
24
+ - Build the empty, loading, error, locked and input-validation-error states,
25
+ not just the success path.
26
+ - Do not hard-code UI strings; add translations for every language.
27
+ - Scope styles to the component and avoid global selectors.
28
+ - When concluding whether an element has a style (underline, background,
29
+ cursor), read every layer that affects it: the component's rules, global rules
30
+ by tag or by missing attribute, inheritance, shared tokens. The element's
31
+ markup (whether it has a class) decides which rules match.
32
+ - When capturing layout: answer every API call with mocks in the browser, drive
33
+ to each state, and capture each state in every language and viewport.
34
+ - Accompanying documentation is written following the way of working of
35
+ [`technical-writer`](technical-writer.role.md#how-it-works).
36
+ - Self-challenge with counterexamples and edge branches before handing over.
37
+
38
+ ## Common warning signs
39
+
40
+ - Building only the success path.
41
+ - Strings in only one language.
42
+ - Styles leaking outside the scope of the change.
43
+ - A layout screenshot set missing the error or input-validation-error states.
44
+ - Concluding that an element lacks some style, or that documentation differs
45
+ from the source, after reading only the component's style file and missing
46
+ global rules or inheritance.
47
+
48
+ ## Boundaries with other roles
49
+
50
+ Server-side logic belongs to `backend-developer`; decisions on states and
51
+ interaction flows belong to `ux-designer`.