agjan 0.0.22 → 0.0.25

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 (66) hide show
  1. package/README.md +6 -4
  2. package/dist/adapters/claude-code.js +3 -3
  3. package/dist/baseline.js +2 -2
  4. package/dist/browser.js +25 -8
  5. package/dist/cli.js +22 -4
  6. package/dist/commands/check.js +91 -7
  7. package/dist/commands/discover.js +54 -0
  8. package/dist/commands/fix.js +8 -3
  9. package/dist/commands/gates.js +48 -28
  10. package/dist/commands/import.js +73 -0
  11. package/dist/commands/log.js +3 -2
  12. package/dist/commands/map.js +6 -1
  13. package/dist/commands/new.js +7 -3
  14. package/dist/commands/pr-summary.js +20 -5
  15. package/dist/commands/progress.js +1 -1
  16. package/dist/commands/report.js +1 -1
  17. package/dist/commands/review.js +21 -9
  18. package/dist/commands/setup.js +51 -1
  19. package/dist/commands/status.js +118 -20
  20. package/dist/commands/summary.js +2 -1
  21. package/dist/commands/team.js +45 -0
  22. package/dist/commands/test.js +37 -0
  23. package/dist/config.js +9 -1
  24. package/dist/defaults-file.js +33 -0
  25. package/dist/discovery.js +42 -0
  26. package/dist/feature.js +14 -7
  27. package/dist/imports.js +197 -0
  28. package/dist/plan.js +1 -1
  29. package/dist/progress-view.js +46 -11
  30. package/dist/qa.js +27 -3
  31. package/dist/readiness.js +33 -0
  32. package/dist/review-policy.js +2 -1
  33. package/dist/review.js +68 -17
  34. package/dist/schema.js +4 -0
  35. package/dist/story.js +15 -8
  36. package/dist/teams.js +127 -0
  37. package/dist/test-run.js +101 -0
  38. package/dist/types.js +0 -4
  39. package/dist/workflow.js +83 -0
  40. package/docs/guide.md +166 -24
  41. package/kit/domains/btp/domain.json +1 -0
  42. package/kit/hooks/guard.mjs +134 -6
  43. package/kit/skills/agjan-ask/SKILL.md +20 -9
  44. package/kit/skills/agjan-build/SKILL.md +6 -5
  45. package/kit/skills/agjan-design/SKILL.md +2 -2
  46. package/kit/skills/agjan-discover/SKILL.md +87 -0
  47. package/kit/skills/agjan-fix/SKILL.md +10 -6
  48. package/kit/skills/agjan-map/SKILL.md +12 -8
  49. package/kit/skills/agjan-spec/SKILL.md +14 -7
  50. package/kit/skills/agjan-verify/SKILL.md +27 -17
  51. package/kit/skills/btp-architect/SKILL.md +1 -1
  52. package/kit/skills/btp-architect/references/security.md +1 -1
  53. package/kit/skills/cap-developer/SKILL.md +1 -1
  54. package/kit/skills/cap-developer/references/project-setup.md +1 -1
  55. package/kit/skills/cap-developer/references/validation-security.md +1 -1
  56. package/kit/skills/fiori-developer/SKILL.md +1 -1
  57. package/kit/skills/qa-tester/SKILL.md +4 -2
  58. package/kit/templates/agents-block.md +13 -6
  59. package/kit/templates/progress.html +2 -2
  60. package/kit/templates/proposal.md +22 -0
  61. package/package.json +1 -1
  62. package/schemas/approvals.schema.json +9 -1
  63. package/schemas/config.defaults.json +66 -0
  64. package/schemas/config.schema.json +33 -1
  65. package/schemas/log.schema.json +1 -1
  66. package/schemas/reviews.schema.json +2 -2
@@ -0,0 +1,83 @@
1
+ export const MANDATORY_CONTROLS = ['independent-review', 'stamped-approvals', 'scope-check', 'human-decision'];
2
+ export const WORKFLOWS = {
3
+ feature: {
4
+ kind: 'feature',
5
+ name: 'feature',
6
+ container: null,
7
+ skill: 'agjan-spec',
8
+ stages: ['Spec', 'Design', 'Build', 'Verify'],
9
+ logStages: ['spec', 'design', 'build', 'verify'],
10
+ reviewSteps: ['spec', 'design', 'design:light', 'build:', 'qa', 'verify'],
11
+ gates: ['spec', 'design', 'spec design', 'verify'],
12
+ end: 'acceptance',
13
+ endGate: 'verify',
14
+ writes: 'tasks',
15
+ controls: ['independent-review', 'stamped-approvals', 'scope-check', 'human-decision'],
16
+ },
17
+ fix: {
18
+ kind: 'fix',
19
+ name: 'fix',
20
+ container: 'fixes',
21
+ skill: 'agjan-fix',
22
+ stages: ['Fix', 'Review'],
23
+ logStages: ['fix'],
24
+ reviewSteps: ['fix'],
25
+ gates: [],
26
+ end: 'merge',
27
+ writes: 'fix-rules',
28
+ controls: ['independent-review', 'stamped-approvals', 'scope-check', 'human-decision'],
29
+ },
30
+ map: {
31
+ kind: 'map',
32
+ name: 'map run',
33
+ container: 'maps',
34
+ skill: 'agjan-map',
35
+ stages: ['Map', 'Review'],
36
+ logStages: ['map'],
37
+ reviewSteps: ['map'],
38
+ gates: [],
39
+ end: 'merge',
40
+ writes: 'project-map',
41
+ controls: ['independent-review', 'stamped-approvals', 'scope-check', 'human-decision'],
42
+ },
43
+ discovery: {
44
+ kind: 'discovery',
45
+ name: 'discovery',
46
+ container: 'discoveries',
47
+ skill: 'agjan-discover',
48
+ stages: ['Proposal', 'Review', 'Approval'],
49
+ logStages: ['discover'],
50
+ reviewSteps: ['proposal'],
51
+ gates: ['proposal'],
52
+ end: 'acceptance',
53
+ endGate: 'proposal',
54
+ writes: 'own-folder',
55
+ controls: ['independent-review', 'stamped-approvals', 'scope-check', 'human-decision'],
56
+ },
57
+ };
58
+ export function workflowOf(kind) {
59
+ return WORKFLOWS[kind];
60
+ }
61
+ /** The unit kind whose units live in `container` (agjan-docs/<container>/), or undefined. */
62
+ export function kindOfContainer(container) {
63
+ return Object.values(WORKFLOWS).find((w) => w.container === container)?.kind;
64
+ }
65
+ /** The containers under agjan-docs: their names are not feature slugs. */
66
+ export const CONTAINERS = Object.fromEntries(Object.values(WORKFLOWS).filter((w) => w.container).map((w) => [w.container, w.kind]));
67
+ /** Every stage `agjan log --stage` accepts. */
68
+ export const LOG_STAGES = [...new Set(Object.values(WORKFLOWS).flatMap((w) => w.logStages))];
69
+ /** Whether `step` is one of the workflow's review steps. */
70
+ export function hasReviewStep(workflow, step) {
71
+ return workflow.reviewSteps.some((s) => (s.endsWith(':') ? step.startsWith(s) && step.length > s.length : s === step));
72
+ }
73
+ /** What a workflow definition lacks: missing mandatory controls, a gate-less acceptance, an empty track. */
74
+ export function workflowProblems(workflow) {
75
+ const problems = MANDATORY_CONTROLS.filter((c) => !workflow.controls.includes(c)).map((c) => `${workflow.kind}: the control '${c}' is missing`);
76
+ if (!workflow.reviewSteps.length)
77
+ problems.push(`${workflow.kind}: no review step, so no independent review`);
78
+ if (workflow.end === 'acceptance' && !(workflow.endGate && workflow.gates.includes(workflow.endGate)))
79
+ problems.push(`${workflow.kind}: ends with an acceptance but names no gate of its own for it`);
80
+ if (!workflow.stages.length)
81
+ problems.push(`${workflow.kind}: no stages`);
82
+ return problems;
83
+ }
package/docs/guide.md CHANGED
@@ -12,6 +12,8 @@ structure around the agents you already use (Claude Code, GitHub Copilot).
12
12
  - [Set up a project](#set-up-a-project)
13
13
  - [The workflow](#the-workflow)
14
14
  - [Small changes and existing applications](#small-changes-and-existing-applications)
15
+ - [Exploring a decision first](#exploring-a-decision-first)
16
+ - [Teams](#teams)
15
17
  - [Asking questions](#asking-questions)
16
18
  - [Commands](#commands)
17
19
  - [Configuration](#configuration)
@@ -22,7 +24,7 @@ structure around the agents you already use (Claude Code, GitHub Copilot).
22
24
 
23
25
  ## Concepts
24
26
 
25
- - **Feature**: one unit of work in `docs/agjan/<slug>/`, with a short key such as
27
+ - **Feature**: one unit of work in `agjan-docs/<slug>/`, with a short key such as
26
28
  `ORDF`. Its acceptance criteria are `ORDF-AC1`, `ORDF-AC2`, ...; tests carry these ids
27
29
  in their names.
28
30
  - **Stages**: Spec (what and why), Design (how, as tasks with file paths), Build (one
@@ -110,9 +112,10 @@ Then:
110
112
 
111
113
  ## The workflow
112
114
 
113
- Each feature on a branch of its own. When one is needed, the agent asks you in the chat:
114
- create a new branch or use one that already exists (it lists them). For a new branch it
115
- proposes a name; choose it, or type another one, and the agent creates the branch.
115
+ Each feature on a branch of its own. When you start work on the base branch, the agent
116
+ creates one with a name it proposes (`feature/<slug>`, or your team's rule from AGENTS.md)
117
+ and tells you its name. To be asked instead (a new branch with a name you choose, or an
118
+ existing one), set `"git": { "branches": "ask" }`.
116
119
 
117
120
  **Spec**: in Claude Code or Copilot:
118
121
 
@@ -129,7 +132,8 @@ npx agjan status # what is ready and what blocks it
129
132
  npx agjan review show # the reviews and findings
130
133
  npx agjan findings # only the open findings, by severity
131
134
  npx agjan summary # what has been done so far, in plain words
132
- npx agjan review report # the latest round, short: verdict, findings, what happens next
135
+ npx agjan review report # the latest round, short: verdict, blockers and majors, what happens next
136
+ npx agjan review report --full # the same with every minor finding and the reviewer
133
137
  npx agjan approve spec design # light mode; full mode: approve spec, later approve design
134
138
  ```
135
139
 
@@ -178,14 +182,28 @@ files wait for the revised design, and the pre-commit hook lets only the documen
178
182
  committed.
179
183
 
180
184
  **Verify**: `/agjan-verify`. Full build, tests and lint, the baseline update, QA, the
181
- final deep review, `agjan check --ci` and `report.md`. It ends with a completion block that
182
- gives you the last gate.
185
+ test run, the final deep review, `agjan check --ci` and `report.md`. It ends with a
186
+ completion block that gives you the last gate.
187
+
188
+ **The test run**: after QA, `npx agjan test` runs the feature's tests (its areas'
189
+ `verify.<area>.test` commands, else `npm test`, the QA tests included) and the UI tests where
190
+ a browser can start, and records the run in `agjan-docs/<feature>/tests.json` with the change
191
+ it ran on. The final review waits for a passing run, and `check --ci` and your acceptance
192
+ need one that matches the change: any change afterwards means running it again. CI does not
193
+ run your application's tests; it checks that the recorded run describes the change. To count
194
+ ACs by test names only, set `"test_evidence": "names"`.
183
195
 
184
196
  **QA** (full-mode features; `review.qa: "off"` turns it off): before the final review, a
185
197
  tester agent, `agjan-qa`, checks the feature from the spec alone. It gets the spec, how
186
198
  to run the application and its users, but not the design, the code or the main agent's
187
199
  tests, and writes tests aimed at what main agents tend to miss: invalid input, users a rule
188
200
  excludes, anonymous requests, boundaries, doing something twice, the flows in the browser.
201
+ In Claude Code, agjan's guard enforces this: the QA agent's reads of the design, the tasks,
202
+ the review records, the application code (`application`: `srv/`, `db/`, `app/`) and the other
203
+ tests are denied, also through shell commands such as `cat` or `git diff`; running the
204
+ application and the tests stays allowed. It is a guardrail, not a sandbox. The GitHub Copilot
205
+ CLI does not tell the guard which agent calls a tool, so there the rule is the QA agent's
206
+ instruction only.
189
207
  It runs them and records the result like a review. A failing test is a blocker: the
190
208
  agent fixes the code, never the QA tests, and QA runs again. Something the spec does not
191
209
  decide comes to you as a "Spec question". The tests stay in `test/qa/<feature>/` (UI tests
@@ -219,7 +237,11 @@ ask (its description is `npx agjan pr-summary`); you review and merge.
219
237
  choose an action), the agents also write Playwright tests (`test/ui/`, the script
220
238
  `test:ui`), and `npx agjan ui-test` runs them in Chromium as each test user. Where Chromium
221
239
  cannot start, it says why and skips them, and the agent tells you which ACs to try by
222
- hand. agjan never installs anything with admin rights:
240
+ hand. `npx agjan init` and `npx agjan doctor` check this for a project with a `test:ui`
241
+ script and, in your terminal, offer to fix it: the Chromium download (no admin rights) and,
242
+ on Linux, the system libraries (`sudo npx playwright install-deps chromium`, only with
243
+ passwordless sudo or as root, and only after your explicit yes; `--yes` does not cover it).
244
+ Agents and CI never install anything with admin rights:
223
245
 
224
246
  - macOS and Windows: `npx playwright install chromium` is all it needs.
225
247
  - Linux, dev containers: Chromium also needs system libraries. Whoever maintains the
@@ -284,27 +306,30 @@ team-leave-requests (TLR)
284
306
 
285
307
  ✔ Requirement received
286
308
  ✔ Draft spec prepared
287
- ✔ Spec reviewed: 3 findings (1 important, 2 minor)
309
+ ● Spec reviewed: 3 findings (1 important, 2 minor)
288
310
  ✔ Spec revised
289
311
  ✔ Spec reviewed again: no findings; 3 earlier findings fixed
290
312
  ✔ Spec approved automatically (auto mode)
291
313
  ✔ Design prepared (5 tasks)
292
314
  …
293
315
  ✔ Built: Fiori elements app for managers
294
- ✔ Independent tests written from the spec: all passed
295
- ✔ Final check: everything checks out
316
+ ✔ Independent tests written from the spec (4 test files): no findings
317
+ ✔ Final check: no findings
296
318
  ⏳ Now waiting for you: check TLR-AC11 by hand, then accept it
297
319
  Your next step: npx agjan approve verify
298
320
  ```
299
321
 
300
322
  The agent shows it in its message when the build is done (manual mode) and with its final
301
323
  message after the verification. Anyone can run it at any time (`--feature <slug>` for another
302
- feature). The technical timeline, with rounds and commits, is below.
324
+ feature). A review that found something keeps its mark (✖ a blocker, ● other findings), so
325
+ past problems stay visible; what holds now is the last line. "Revised" appears only when the
326
+ reviewed document or code changed between two rounds. The technical timeline, with rounds and
327
+ commits, is below.
303
328
 
304
329
  agjan keeps a progress page for every unit and regenerates it after every event it
305
330
  records (step, review, approval, amendment, fix record):
306
331
 
307
- - `docs/agjan/<unit>/progress.md`: stage track, whose turn it is, time spent, review
332
+ - `agjan-docs/<unit>/progress.md`: stage track, whose turn it is, time spent, review
308
333
  loops round by round, tasks with their commits and reviews, the timeline of every
309
334
  event, and the findings. Committed with the unit, so the pull request shows it.
310
335
  - `.agjan/progress.html`: the whole project in one self-contained page (no extension, no
@@ -319,7 +344,11 @@ approve, an amendment, the next skill to start (`/agjan-design`, `/agjan-build`,
319
344
  `/agjan-verify`; a skill counts as running once it logged its start), or the agent
320
345
  stopped and needs you (it logs the reason with `npx agjan log --waiting`). A verified feature
321
346
  is **done**: trying it locally, manual checks and the pull request are optional next
322
- steps. `npx agjan status --done` prints just that block. Units already on the base branch appear in the overview but
347
+ steps. `npx agjan status --done` prints just that block. A feature counts as verified only
348
+ when the acceptance would be allowed: QA passed, the final review is current and
349
+ `check --ci` has no error but the missing acceptance. While anything else fails, status,
350
+ the progress pages and `status --done` say **not verified yet** and list it (`status --done`
351
+ then exits with 1). Units already on the base branch appear in the overview but
323
352
  get no new page on another branch.
324
353
 
325
354
  ## Small changes and existing applications
@@ -346,15 +375,112 @@ is a new feature or a fix on a new branch.
346
375
  within the line limits (default 80 changed lines in total, 50 per file), and no
347
376
  protected or risk path (deployment and security descriptors, CDS service definitions,
348
377
  authorization, the "Do-not-touch list" of `project.md`). It runs on a branch of its own,
349
- is reviewed, and is recorded in `docs/agjan/fixes/<date>-<slug>/`. Anything bigger goes
378
+ is reviewed, and is recorded in `agjan-docs/fixes/<date>-<slug>/`. Anything bigger goes
350
379
  to `/agjan-spec`.
351
380
 
352
- **`/agjan-map`** describes an existing application in `docs/agjan/project.md` (one to
381
+ **`/agjan-map`** describes an existing application in `agjan-docs/project.md` (one to
353
382
  two pages, with pointers to real files) and records the watched files (models,
354
- services, app manifests, `mta.yaml`) in `docs/agjan/baseline.json`. Specs and designs
383
+ services, app manifests, `mta.yaml`) in `agjan-docs/baseline.json`. Specs and designs
355
384
  read it. When watched files change later, `agjan check` warns until `project.md` is
356
385
  updated and `npx agjan baseline refresh` has run (Verify does this).
357
386
 
387
+ ## Exploring a decision first
388
+
389
+ Some requirements need a decision before anyone writes a spec: which BTP service, how to
390
+ integrate with another system, whether something is feasible. **`/agjan-discover`** prepares
391
+ it like a workshop would, and changes no code:
392
+
393
+ 1. On a branch of its own, `npx agjan discover start <slug> --key <KEY> --question "…"`
394
+ creates `agjan-docs/discoveries/<slug>/proposal.md`.
395
+ 2. The agent reads the application (read-only), agjan's role skills and sources, and fills
396
+ the proposal: context, two to four options with effort and risks, a recommendation, open
397
+ questions and sources.
398
+ 3. An independent reviewer (the deep tier) checks the proposal: does it answer the question,
399
+ are the options real and correctly described, does the recommendation follow.
400
+ 4. You decide: read `proposal.md`, then `npx agjan approve proposal` in a terminal, or ask
401
+ for changes. The approval is stamped with the proposal's hash; a later change makes it
402
+ stale.
403
+
404
+ `agjan check` fails a discovery branch that changes anything outside the discovery's folder,
405
+ and CI waits for your approval. To build the recommendation, start a feature with
406
+ `/agjan-spec`: it reads the approved proposal.
407
+
408
+ ## Teams
409
+
410
+ A team decides what knowledge the agents bring to a unit of work; the workflow decides the
411
+ steps, reviews and gates, and a team cannot remove any of them. Three are built in:
412
+
413
+ | Team | Workflows | Implementer or analyst | Reviewer | Tester |
414
+ |---|---|---|---|---|
415
+ | `sap-delivery` | feature | cap-developer, fiori-developer, btp-architect | solution-reviewer and the three role skills | qa-tester |
416
+ | `sap-maintenance` | fix, map | cap-developer, fiori-developer (fix); the three role skills (map) | solution-reviewer, cap-developer, fiori-developer | - |
417
+ | `sap-discovery` | discovery | btp-architect, cap-developer, fiori-developer | solution-reviewer, btp-architect | - |
418
+
419
+ Define your own in `agjan.config.json`, reusing any skill in `.claude/skills/` (your own
420
+ included), and make it the default for a workflow:
421
+
422
+ ```json
423
+ {
424
+ "teams": {
425
+ "company-delivery": {
426
+ "description": "Delivery with our security standard",
427
+ "workflows": ["feature"],
428
+ "personas": {
429
+ "implementer": { "skills": ["cap-developer", "fiori-developer"] },
430
+ "reviewer": { "skills": ["solution-reviewer", "company-security"], "instructions": "Name the rule of the standard in every finding." },
431
+ "tester": { "skills": ["qa-tester"] }
432
+ }
433
+ }
434
+ },
435
+ "team": { "feature": "company-delivery" }
436
+ }
437
+ ```
438
+
439
+ A unit starts with the workflow's default team, or the one you name (`--team` on `new`,
440
+ `fix start`, `discover start`), and records it with a hash of its definition. A persona
441
+ starts no agent of its own: the implementer's skills reach the main agent through `status`,
442
+ the reviewer's and the tester's through their review and QA contexts. If the team's
443
+ definition changes while a unit is under way, `status` and `check` say so.
444
+ `npx agjan team list` lists the teams, `npx agjan team show <name>` their personas.
445
+
446
+ ### Importing skills and teams
447
+
448
+ Another team's skills and teams can come from a git repository that declares them in
449
+ `agjan-package.json`:
450
+
451
+ ```json
452
+ {
453
+ "name": "acme",
454
+ "version": "1.0.0",
455
+ "license": "Apache-2.0",
456
+ "skills": ["skills/security-review"],
457
+ "teams": {
458
+ "delivery": {
459
+ "description": "Delivery with the ACME security review",
460
+ "workflows": ["feature"],
461
+ "personas": { "reviewer": { "skills": ["solution-reviewer", "security-review"] } }
462
+ }
463
+ }
464
+ }
465
+ ```
466
+
467
+ A package offers skills and teams only: no hooks, agents, MCP servers or settings, so it
468
+ cannot change what your agents may do. Import it at an exact commit, in your terminal:
469
+
470
+ ```bash
471
+ npx agjan import https://github.com/acme/agjan-skills.git --commit <full commit id> --dry-run
472
+ npx agjan import https://github.com/acme/agjan-skills.git --commit <full commit id>
473
+ ```
474
+
475
+ agjan shows what the import adds or changes and asks you to type the package's name: the
476
+ skills become instructions to your agents, so read them first. Nothing in the repository
477
+ runs. The skills land in `.claude/skills/acme-<skill>/`, the teams as `acme/<team>`, and
478
+ `agjan.imports.json` records the source, commit, license and a hash of every file: `check`
479
+ fails when an imported file was changed by hand, and CI reports `agjan.imports.json` and
480
+ `.claude/` changes as policy changes. Importing a newer commit shows what changes;
481
+ `npx agjan import remove acme` takes everything out, `npx agjan import list` shows what is
482
+ imported. Agents cannot run `import`.
483
+
358
484
  ## Asking questions
359
485
 
360
486
  **`/agjan-ask`** answers a general question about SAP CAP, Fiori and UI5, SAP BTP,
@@ -370,9 +496,17 @@ when your host has web access and you allow it, it reads documentation pages and
370
496
  repositories. It says where an answer comes from (a skill's reference file, a page, or
371
497
  general knowledge) and when it is not sure.
372
498
 
373
- It is independent of your project: it reads none of the project's files, changes nothing,
374
- and leaves no record in `docs/agjan/`. Code or an error you paste into the question is
375
- part of the question. For work on the project itself it points you to `/agjan-spec` or
499
+ It reads your project only when you ask it to and name what to look at:
500
+
501
+ ```text
502
+ /agjan-ask Can a $filter in srv/ reach fields the services do not expose? Check srv/ and db/schema.cds.
503
+ ```
504
+
505
+ Then it reads those files or folders and nothing else (files with credentials, such as
506
+ `.env`, only when you name them). Without names, it answers in general terms and asks
507
+ which files to look at. It never changes anything, runs no commands and leaves no record
508
+ in `agjan-docs/`. Code or an error you paste into the question is part of the question.
509
+ What it finds is advice, not a review: for a change it points you to `/agjan-spec` or
376
510
  `/agjan-fix`.
377
511
 
378
512
  ## Commands
@@ -384,15 +518,20 @@ Run `npx agjan --help` for the full list.
384
518
  | `init`, `sync [--force]` | you | set up; regenerate managed files after an upgrade |
385
519
  | `doctor` | anyone | check Node, git, versions, managed files, hook, CI, the MCP server, guards, folder trust (Claude Code, Copilot CLI), whether the UI tests can run |
386
520
  | `status [--feature <id> \| --all]` | anyone | state, blockers, tasks, due reviews, next step |
521
+ | `discover start <slug> --key <KEY> --question "<text>"` | agent | start a discovery: its folder and `proposal.md` from the template |
522
+ | `approve proposal` | you, in a terminal | decide on a discovery's recommendation |
523
+ | `import <git url> --commit <id> [--dry-run]` · `import list` · `import remove <name>` | you, in a terminal | skills and teams from another repository at an exact commit, shown before they are written |
524
+ | `team list` · `team show <name>` | anyone | the teams, the default per workflow, and what a team's personas work with |
525
+ | `status --json` | tools | per unit: its workflow, stage, whose turn, what is next and the command or skill for it, and for a feature in Build whether it is verified and what blocks it |
387
526
  | `progress [--open]` | anyone | regenerate the progress pages, print the overview, open the HTML page |
388
- | `branch <name>` · `--list` · `--use <name>` | agent, after asking you | create the branch of a unit, list the existing branches, or switch to one |
527
+ | `branch <name>` · `--list` · `--use <name>` | agent (after asking you with `git.branches: "ask"`) | create the branch of a unit, list the existing branches, or switch to one |
389
528
  | `check [--staged \| --ci] [--base <ref>]` | anyone, hook, CI | enforce the rules |
390
529
  | `lint [--all]` | anyone | the area linters (UI5 linter for Fiori apps) on the changed files |
391
530
  | `ui-test [--require]` | anyone | the Playwright UI tests where Chromium can start; otherwise the reason, and a skip |
392
531
  | `findings [--all] [--feature <slug>]` | anyone | the open findings by severity, each with file and issue |
393
532
  | `summary [--feature <slug>]` | anyone | what has been done so far in plain words, and what the work waits for |
394
533
  | `review show [--step <step>]` | anyone | review records, or the material a reviewer gets |
395
- | `review report [--step <step>]` | anyone | the latest review round as a short report (agents show it after each review) |
534
+ | `review report [--step <step>] [--full]` | anyone | the latest review round as a short report (agents show it after each review): blockers and majors one per line, minors in one line with a link to `review.md`; `--full` lists every finding |
396
535
  | `pr-summary`, `report` | anyone | PR description; `report.md` with time and tokens |
397
536
  | `new`, `scaffold design`, `amend`, `log` | agent | used by the workflow skills |
398
537
  | `fix start \| check \| record`, `map start`, `baseline refresh` | agent | fast path and baseline |
@@ -433,14 +572,17 @@ is wrong, so a typo is never a silent default.
433
572
  | `domains` | enabled domains; phase 1 has `btp` (areas `cap`, `fiori`, `btp`) |
434
573
  | `hosts` | `claude-code`, `copilot`; decides which files `sync` generates |
435
574
  | `git.base` | the branch features merge into; default: the remote's default branch |
575
+ | `git.branches` | `new` (default): on the base branch the agent creates a branch with its proposed name; `ask`: it asks you first |
436
576
  | `verify.<area>` | `build`, `test`, `lint` commands for the skills; `results`: a JUnit XML, Jest or Mocha JSON file that `check` reads to require a passing test per AC |
437
577
  | `lint.<area>` | the linter `npx agjan lint` runs in each folder `in` (for example `app/*`) on the changed files matching `files`; the btp domain sets the UI5 linter for `fiori`; `null` turns it off |
438
578
  | `tests.<area>`, `scope.implicit.<area>` | test file globs; files every task of the area may change (i18n, lockfiles, fixtures) |
439
579
  | `risk_paths` | paths whose change needs a review per task and are never a fix |
580
+ | `application` | the application's code, which the QA agent may not read (the btp domain: `srv/**`, `db/**`, `app/**`) |
440
581
  | `fix` | `max_total`, `max_per_file`, `protected`, `ignored`, `new_file_paths` |
441
582
  | `review.build` | `area` (default: one build review per completed area) or `task` |
442
583
  | `review.rounds` | correction rounds per review step (default 3); if blockers remain, the agent asks you whether to run another round (one more per yes, recorded with `npx agjan review extend <step>`) or to stop |
443
584
  | `review.qa` | `on` (default) or `off`: the QA step in Verify for full-mode features |
585
+ | `test_evidence` | `run` (default): CI and the acceptance need a passing `agjan test` run on the change; `names`: a test whose name contains the AC id is enough |
444
586
  | `review.tiers.<step>` | `balanced` or `deep` per step kind (`spec`, `design:light`, `design`, `build`, `verify`, `fix`, `map`); decides which reviewer agent runs it. Defaults: `deep` for `design` and `verify`, else `balanced`; `fast` uses the balanced agent |
445
587
  | `build.fix_attempts` | attempts for failing deterministic checks before the agent stops (default 3) |
446
588
  | `language` | language of the documents' text (default `en`); headings, ids and keywords stay English |
@@ -527,8 +669,8 @@ your review. Create `.github/CODEOWNERS` (replace `@<owner>` with your GitHub us
527
669
  # agjan: changes to the rules need an owner's review
528
670
  /agjan.config.json @<owner>
529
671
  /agjan.lock.json @<owner>
530
- /docs/agjan/**/approvals.json @<owner>
531
- /docs/agjan/**/reviews.json @<owner>
672
+ /agjan-docs/**/approvals.json @<owner>
673
+ /agjan-docs/**/reviews.json @<owner>
532
674
  /AGENTS.md @<owner>
533
675
  /CLAUDE.md @<owner>
534
676
  /.claude/ @<owner>
@@ -22,6 +22,7 @@
22
22
  "verify": {}
23
23
  }
24
24
  },
25
+ "application": ["srv/**", "db/**", "app/**"],
25
26
  "risk_paths": ["xs-security.json", "ams/**", "mta.yaml", "srv/**/*auth*", "srv/**/*-access.cds"],
26
27
  "protected": ["mta.yaml", "xs-security.json", "ams/**", "srv/**/*.cds"],
27
28
  "watched": ["db/*.cds", "srv/*.cds", "app/*/webapp/manifest.json", "mta.yaml"]
@@ -2,7 +2,7 @@
2
2
  // @ts-check
3
3
  /**
4
4
  * agjan guard: a pre-tool-use hook that denies shell commands running the human-only
5
- * agjan commands (approve, accept, reject, auto, models set), however they are wrapped (`npx`, `sh -c`,
5
+ * agjan commands (approve, accept, reject, auto, import, models set), however they are wrapped (`npx`, `sh -c`,
6
6
  * `cd … &&`, `node …/agjan.mjs`). It is a guardrail in front of the terminal
7
7
  * confirmation, not a proof (design 9.4).
8
8
  *
@@ -17,6 +17,12 @@
17
17
  * edits of agjan's records (approvals.json, reviews.json, review.md, log.jsonl, the review
18
18
  * contexts in .agjan/, …) are always denied.
19
19
  *
20
+ * The QA agent (`agjan-qa`, decision 87) tests from the spec alone: its reads of agjan's
21
+ * records, the application code and the other tests are denied, by file tool and by the
22
+ * shell commands that read files, after the paths `qa_context` wrote to .agjan/qa-guard.json.
23
+ * Only where the host names the calling agent (Claude Code's `agent_type`); a guardrail,
24
+ * not a sandbox: running the application or its tests is allowed.
25
+ *
20
26
  * The guard only denies. Everything else is left to the host, which asks the user as it
21
27
  * is configured to (design decision 76).
22
28
  *
@@ -34,12 +40,13 @@ import { fileURLToPath } from 'node:url';
34
40
 
35
41
  /**
36
42
  * A host's tool call as the hook receives it: Copilot's or Claude Code's form.
37
- * @typedef {{ toolName?: string, toolArgs?: Record<string, any>, tool_name?: string, tool_input?: Record<string, any> }} Payload
43
+ * @typedef {{ toolName?: string, toolArgs?: Record<string, any>, tool_name?: string, tool_input?: Record<string, any>, agent_type?: string }} Payload
44
+ * @typedef {{ hidden: string[], visible: string[] }} QaGuard
38
45
  * @typedef {{ agent?: { script_edits?: string } }} GuardConfig
39
46
  */
40
47
 
41
48
  const REASON =
42
- 'agjan approve, accept, reject, auto and models set are for the human, in a terminal. Do not run them in any form; ask the user to run the command.';
49
+ 'agjan approve, accept, reject, auto, import and models set are for the human, in a terminal. Do not run them in any form; ask the user to run the command.';
43
50
 
44
51
  /**
45
52
  * agjan started as a command, up to its subcommand: the bin (`agjan`, `agjan.mjs`, the Windows
@@ -49,7 +56,7 @@ const REASON =
49
56
  const AGJAN = String.raw`\bagjan(?:\.(?:mjs|cmd|ps1))?(?:@[\w.^~*-]+)?["']?(?:\s+(?:--|-y|--yes)(?=\s))*\s+["']?`;
50
57
 
51
58
  /** agjan followed by a human-only command. */
52
- const HUMAN_ONLY = new RegExp(`${AGJAN}(approve|accept|reject|auto|models\\s+set)\\b`);
59
+ const HUMAN_ONLY = new RegExp(`${AGJAN}(approve|accept|reject|auto|import|models\\s+set)\\b`);
53
60
 
54
61
  /**
55
62
  * A human-only command named only as text, not run: quoted, as the pattern of a search
@@ -132,11 +139,11 @@ const RECORD_REASON =
132
139
  'agjan writes this file itself (approvals, reviews, logs, progress, fix records, baseline). Never edit it by hand; use the agjan commands.';
133
140
 
134
141
  /**
135
- * agjan's records inside docs/agjan/, and what it keeps for them in .agjan/ (the auto mode
142
+ * agjan's records inside agjan-docs/, and what it keeps for them in .agjan/ (the auto mode
136
143
  * default, the review contexts that review_record checks a result against): never edited by
137
144
  * an agent's edit tool.
138
145
  */
139
- const RECORD = /^docs\/agjan\/(?:.+\/)?(?:approvals\.json|reviews\.json|review\.md|log\.jsonl|progress\.md|report\.md|fix\.json|fix\.md)$|^docs\/agjan\/baseline\.json$|^\.agjan\/auto\.json$|^\.agjan\/review-contexts\//;
146
+ const RECORD = /^agjan-docs\/(?:.+\/)?(?:approvals\.json|reviews\.json|review\.md|log\.jsonl|progress\.md|report\.md|fix\.json|fix\.md|tests\.json)$|^agjan-docs\/baseline\.json$|^\.agjan\/auto\.json$|^\.agjan\/qa-guard\.json$|^\.agjan\/review-contexts\//;
140
147
 
141
148
  const AUTO_REASON =
142
149
  'The auto mode default (.agjan/auto.json) is the user\'s, set with npx agjan auto on --default in their terminal. Do not read, write, copy or remove it.';
@@ -144,6 +151,121 @@ const AUTO_REASON =
144
151
  /** Any shell command that names the auto mode default: agents have no business with it. */
145
152
  const AUTO_FILE = /\.agjan[\\/]+auto\.json/;
146
153
 
154
+ const QA_REASON =
155
+ 'You are the QA agent: you test from the spec alone. Do not read the design, the tasks, the review records, the application code or the existing tests; qa_context gives you what you need. Read only the spec, agjan-docs/project.md, your QA folders, the skills and the installed packages.';
156
+
157
+ const QA_START_REASON = 'Call qa_context first: it names what you may read.';
158
+
159
+ /** The QA guard file: what the QA agent may not read (decision 87). */
160
+ const QA_GUARD = /\.agjan[\\/]+qa-guard\.json/;
161
+
162
+ /** The files of a glob, as a regular expression: `**` any depth, `*` and `?` within a name. */
163
+ function globRegex(/** @type {string} */ glob) {
164
+ let out = '';
165
+ for (let i = 0; i < glob.length; i++) {
166
+ const c = glob[i];
167
+ if (c === '*' && glob[i + 1] === '*') {
168
+ i++;
169
+ if (glob[i + 1] === '/') {
170
+ i++;
171
+ out += '(?:.*/)?';
172
+ } else out += '.*';
173
+ } else if (c === '*') out += '[^/]*';
174
+ else if (c === '?') out += '[^/]';
175
+ else out += c.replace(/[.+^${}()|[\]\\]/g, '\\$&');
176
+ }
177
+ return new RegExp(`^${out}$`);
178
+ }
179
+
180
+ /** The folder a glob starts in: its part before the first wildcard, up to the last slash. */
181
+ const globBase = (/** @type {string} */ glob) => glob.slice(0, glob.search(/[*?]|$/)).replace(/[^/]*$/, '');
182
+
183
+ /**
184
+ * The QA agent's view of a repository path: `hidden`, `visible`, or `holds-hidden` for a
185
+ * folder that contains hidden paths (searching it would read them).
186
+ * @param {QaGuard} guard
187
+ * @param {string} rel
188
+ */
189
+ function qaView(guard, rel) {
190
+ const matches = (/** @type {string[]} */ globs, /** @type {string} */ path) => globs.some((g) => globRegex(g).test(path));
191
+ const dir = rel === '' ? '' : `${rel.replace(/\/$/, '')}/`;
192
+ // A visible folder (or a file in one) is visible, also when a hidden glob covers it.
193
+ if (matches(guard.visible, rel) || (dir && matches(guard.visible, `${dir}x`))) return 'visible';
194
+ if (matches(guard.hidden, rel) || (dir && matches(guard.hidden, `${dir}x`))) return 'hidden';
195
+ if (guard.hidden.some((g) => globBase(g).startsWith(dir))) return 'holds-hidden';
196
+ return 'visible';
197
+ }
198
+
199
+ /** The QA guard file; null before qa_context wrote it. @returns {QaGuard | null} */
200
+ function readQaGuard(/** @type {string} */ root) {
201
+ try {
202
+ const guard = JSON.parse(readFileSync(join(root, '.agjan', 'qa-guard.json'), 'utf8'));
203
+ return Array.isArray(guard?.hidden) && Array.isArray(guard?.visible) ? guard : null;
204
+ } catch {
205
+ return null;
206
+ }
207
+ }
208
+
209
+ /** A path as the repository names it, or null when it is outside the repository. */
210
+ function repoPath(/** @type {string} */ root, /** @type {string} */ target) {
211
+ const rel = relative(root, resolve(root, target)).split('\\').join('/');
212
+ return rel.startsWith('../') || rel === '..' || isAbsolute(rel) ? null : rel;
213
+ }
214
+
215
+ /** Shell commands whose arguments are files they read; the searchers also read folders. */
216
+ const READERS = /^(?:cat|head|tail|less|more|sed|awk|nl|strings|xxd|od|bat|cp|diff|grep|egrep|fgrep|rg|ack|ag)$/;
217
+ const SEARCHERS = /^(?:grep|egrep|fgrep|rg|ack|ag)$/;
218
+ /** git commands that show file contents or changes. */
219
+ const GIT_READS = /\bgit(?:\s+-[cC]\s+\S+)*\s+(?:diff|show|blame|grep|log\s+(?:\S+\s+)*?(?:-p|--patch|-L)\b|cat-file|archive)\b/;
220
+
221
+ /**
222
+ * The guard's answer for a tool call of the QA agent, or null. Paths outside the
223
+ * repository (the skills of another checkout, the system) are not its business.
224
+ * @param {Payload} payload
225
+ * @param {string} root
226
+ */
227
+ function decideQa(payload, root) {
228
+ const tool = payload.tool_name ?? payload.toolName ?? '';
229
+ const args = payload.tool_input ?? payload.toolArgs ?? {};
230
+ const guard = readQaGuard(root);
231
+ // A relative path is also read from the repository root: the command may `cd` first.
232
+ const denied = (/** @type {string} */ target, /** @type {boolean} */ searches) =>
233
+ [target, target.replace(/^(?:\.\.?\/)+/, '')].some((path) => deniedPath(path, searches));
234
+ const deniedPath = (/** @type {string} */ target, /** @type {boolean} */ searches) => {
235
+ const rel = repoPath(root, target);
236
+ if (rel === null || rel.startsWith('.claude/') || rel.startsWith('node_modules/')) return false;
237
+ if (!guard) return true;
238
+ const view = qaView(guard, rel);
239
+ return view === 'hidden' || (searches && view === 'holds-hidden');
240
+ };
241
+ const deny = () => answer(payload, 'deny', guard ? QA_REASON : QA_START_REASON);
242
+ if (tool === 'Read' || tool === 'NotebookRead') return typeof args.file_path === 'string' && denied(args.file_path, false) ? deny() : null;
243
+ if (tool === 'Grep') return denied(typeof args.path === 'string' ? args.path : '.', true) ? deny() : null;
244
+ if (tool === 'Glob') return typeof args.path === 'string' && denied(args.path, false) ? deny() : null;
245
+ const command = args.command;
246
+ if (typeof command !== 'string') return null;
247
+ if (GIT_READS.test(command)) return answer(payload, 'deny', QA_REASON);
248
+ if (!guard) return null;
249
+ for (const part of command.split(/\|\||&&|[|;&\n]/)) {
250
+ const words = part.match(/"[^"]*"|'[^']*'|\S+/g) ?? [];
251
+ const name = (words[0] ?? '').replace(/^.*\//, '');
252
+ const reader = READERS.test(name);
253
+ for (const word of words.slice(1)) {
254
+ const arg = word.replace(/^["']|["']$/g, '');
255
+ if (arg.startsWith('-')) continue;
256
+ // Any argument that names a path in a folder (a script's file, a URL is outside); every
257
+ // argument of a command that reads its files.
258
+ for (const path of reader ? [arg] : arg.match(/[\w.@~-]*\/[\w.@~/*-]*/g) ?? []) {
259
+ if (/^[a-z]+:\/\//i.test(path)) continue;
260
+ if (denied(path, reader && SEARCHERS.test(name))) return answer(payload, 'deny', QA_REASON);
261
+ }
262
+ }
263
+ }
264
+ return null;
265
+ }
266
+
267
+ const READ_TOOLS = new Set(['Read', 'NotebookRead', 'Grep', 'Glob']);
268
+
147
269
  const EDIT_TOOLS = new Set(['edit', 'create', 'Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
148
270
 
149
271
  /**
@@ -181,6 +303,11 @@ function answer(payload, decision, reason) {
181
303
  * @param {string} [root]
182
304
  */
183
305
  export function decide(payload, config = {}, root = process.env.CLAUDE_PROJECT_DIR || process.cwd()) {
306
+ if (payload?.agent_type === 'agjan-qa') {
307
+ const qa = decideQa(payload, root);
308
+ if (qa) return qa;
309
+ }
310
+ if (READ_TOOLS.has(payload?.tool_name ?? payload?.toolName ?? '')) return null;
184
311
  if (EDIT_TOOLS.has(payload?.toolName ?? payload?.tool_name ?? '')) return decideEdit(payload, root);
185
312
  const command = payload?.toolArgs?.command ?? payload?.tool_input?.command;
186
313
  if (typeof command !== 'string') return null;
@@ -188,6 +315,7 @@ export function decide(payload, config = {}, root = process.env.CLAUDE_PROJECT_D
188
315
  if (REVIEW_SERVER.test(command) || RECORD_TOOLS.test(command) || CONTEXT_FILES.test(command)) return answer(payload, 'deny', REVIEW_REASON);
189
316
  if (BRANCH_CREATE.test(command)) return answer(payload, 'deny', BRANCH_REASON);
190
317
  if (AUTO_FILE.test(command)) return answer(payload, 'deny', AUTO_REASON);
318
+ if (QA_GUARD.test(command)) return answer(payload, 'deny', RECORD_REASON);
191
319
  if (config?.agent?.script_edits !== 'allow' && SCRIPT_EDITS.some((matches) => matches(command))) return answer(payload, 'deny', EDIT_REASON);
192
320
  return null;
193
321
  }