agjan 0.0.22 → 0.0.23

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 (62) 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/cli.js +22 -4
  5. package/dist/commands/check.js +91 -7
  6. package/dist/commands/discover.js +54 -0
  7. package/dist/commands/fix.js +8 -3
  8. package/dist/commands/gates.js +48 -28
  9. package/dist/commands/import.js +73 -0
  10. package/dist/commands/log.js +3 -2
  11. package/dist/commands/map.js +6 -1
  12. package/dist/commands/new.js +7 -3
  13. package/dist/commands/pr-summary.js +20 -5
  14. package/dist/commands/progress.js +1 -1
  15. package/dist/commands/report.js +1 -1
  16. package/dist/commands/review.js +21 -9
  17. package/dist/commands/status.js +118 -20
  18. package/dist/commands/summary.js +2 -1
  19. package/dist/commands/team.js +45 -0
  20. package/dist/commands/test.js +37 -0
  21. package/dist/config.js +8 -0
  22. package/dist/discovery.js +42 -0
  23. package/dist/feature.js +14 -7
  24. package/dist/imports.js +197 -0
  25. package/dist/plan.js +1 -1
  26. package/dist/progress-view.js +46 -11
  27. package/dist/qa.js +27 -3
  28. package/dist/readiness.js +33 -0
  29. package/dist/review-policy.js +2 -1
  30. package/dist/review.js +68 -17
  31. package/dist/schema.js +4 -0
  32. package/dist/story.js +15 -8
  33. package/dist/teams.js +127 -0
  34. package/dist/test-run.js +101 -0
  35. package/dist/types.js +0 -4
  36. package/dist/workflow.js +83 -0
  37. package/docs/guide.md +161 -23
  38. package/kit/domains/btp/domain.json +1 -0
  39. package/kit/hooks/guard.mjs +134 -6
  40. package/kit/skills/agjan-ask/SKILL.md +20 -9
  41. package/kit/skills/agjan-build/SKILL.md +6 -5
  42. package/kit/skills/agjan-design/SKILL.md +2 -2
  43. package/kit/skills/agjan-discover/SKILL.md +87 -0
  44. package/kit/skills/agjan-fix/SKILL.md +10 -6
  45. package/kit/skills/agjan-map/SKILL.md +12 -8
  46. package/kit/skills/agjan-spec/SKILL.md +14 -7
  47. package/kit/skills/agjan-verify/SKILL.md +27 -17
  48. package/kit/skills/btp-architect/SKILL.md +1 -1
  49. package/kit/skills/btp-architect/references/security.md +1 -1
  50. package/kit/skills/cap-developer/SKILL.md +1 -1
  51. package/kit/skills/cap-developer/references/project-setup.md +1 -1
  52. package/kit/skills/cap-developer/references/validation-security.md +1 -1
  53. package/kit/skills/fiori-developer/SKILL.md +1 -1
  54. package/kit/skills/qa-tester/SKILL.md +4 -2
  55. package/kit/templates/agents-block.md +13 -6
  56. package/kit/templates/progress.html +2 -2
  57. package/kit/templates/proposal.md +22 -0
  58. package/package.json +1 -1
  59. package/schemas/approvals.schema.json +9 -1
  60. package/schemas/config.schema.json +33 -1
  61. package/schemas/log.schema.json +1 -1
  62. package/schemas/reviews.schema.json +2 -2
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
@@ -284,27 +302,30 @@ team-leave-requests (TLR)
284
302
 
285
303
  ✔ Requirement received
286
304
  ✔ Draft spec prepared
287
- ✔ Spec reviewed: 3 findings (1 important, 2 minor)
305
+ ● Spec reviewed: 3 findings (1 important, 2 minor)
288
306
  ✔ Spec revised
289
307
  ✔ Spec reviewed again: no findings; 3 earlier findings fixed
290
308
  ✔ Spec approved automatically (auto mode)
291
309
  ✔ Design prepared (5 tasks)
292
310
  …
293
311
  ✔ Built: Fiori elements app for managers
294
- ✔ Independent tests written from the spec: all passed
295
- ✔ Final check: everything checks out
312
+ ✔ Independent tests written from the spec (4 test files): no findings
313
+ ✔ Final check: no findings
296
314
  ⏳ Now waiting for you: check TLR-AC11 by hand, then accept it
297
315
  Your next step: npx agjan approve verify
298
316
  ```
299
317
 
300
318
  The agent shows it in its message when the build is done (manual mode) and with its final
301
319
  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.
320
+ feature). A review that found something keeps its mark (✖ a blocker, ● other findings), so
321
+ past problems stay visible; what holds now is the last line. "Revised" appears only when the
322
+ reviewed document or code changed between two rounds. The technical timeline, with rounds and
323
+ commits, is below.
303
324
 
304
325
  agjan keeps a progress page for every unit and regenerates it after every event it
305
326
  records (step, review, approval, amendment, fix record):
306
327
 
307
- - `docs/agjan/<unit>/progress.md`: stage track, whose turn it is, time spent, review
328
+ - `agjan-docs/<unit>/progress.md`: stage track, whose turn it is, time spent, review
308
329
  loops round by round, tasks with their commits and reviews, the timeline of every
309
330
  event, and the findings. Committed with the unit, so the pull request shows it.
310
331
  - `.agjan/progress.html`: the whole project in one self-contained page (no extension, no
@@ -319,7 +340,11 @@ approve, an amendment, the next skill to start (`/agjan-design`, `/agjan-build`,
319
340
  `/agjan-verify`; a skill counts as running once it logged its start), or the agent
320
341
  stopped and needs you (it logs the reason with `npx agjan log --waiting`). A verified feature
321
342
  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
343
+ steps. `npx agjan status --done` prints just that block. A feature counts as verified only
344
+ when the acceptance would be allowed: QA passed, the final review is current and
345
+ `check --ci` has no error but the missing acceptance. While anything else fails, status,
346
+ the progress pages and `status --done` say **not verified yet** and list it (`status --done`
347
+ then exits with 1). Units already on the base branch appear in the overview but
323
348
  get no new page on another branch.
324
349
 
325
350
  ## Small changes and existing applications
@@ -346,15 +371,112 @@ is a new feature or a fix on a new branch.
346
371
  within the line limits (default 80 changed lines in total, 50 per file), and no
347
372
  protected or risk path (deployment and security descriptors, CDS service definitions,
348
373
  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
374
+ is reviewed, and is recorded in `agjan-docs/fixes/<date>-<slug>/`. Anything bigger goes
350
375
  to `/agjan-spec`.
351
376
 
352
- **`/agjan-map`** describes an existing application in `docs/agjan/project.md` (one to
377
+ **`/agjan-map`** describes an existing application in `agjan-docs/project.md` (one to
353
378
  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
379
+ services, app manifests, `mta.yaml`) in `agjan-docs/baseline.json`. Specs and designs
355
380
  read it. When watched files change later, `agjan check` warns until `project.md` is
356
381
  updated and `npx agjan baseline refresh` has run (Verify does this).
357
382
 
383
+ ## Exploring a decision first
384
+
385
+ Some requirements need a decision before anyone writes a spec: which BTP service, how to
386
+ integrate with another system, whether something is feasible. **`/agjan-discover`** prepares
387
+ it like a workshop would, and changes no code:
388
+
389
+ 1. On a branch of its own, `npx agjan discover start <slug> --key <KEY> --question "…"`
390
+ creates `agjan-docs/discoveries/<slug>/proposal.md`.
391
+ 2. The agent reads the application (read-only), agjan's role skills and sources, and fills
392
+ the proposal: context, two to four options with effort and risks, a recommendation, open
393
+ questions and sources.
394
+ 3. An independent reviewer (the deep tier) checks the proposal: does it answer the question,
395
+ are the options real and correctly described, does the recommendation follow.
396
+ 4. You decide: read `proposal.md`, then `npx agjan approve proposal` in a terminal, or ask
397
+ for changes. The approval is stamped with the proposal's hash; a later change makes it
398
+ stale.
399
+
400
+ `agjan check` fails a discovery branch that changes anything outside the discovery's folder,
401
+ and CI waits for your approval. To build the recommendation, start a feature with
402
+ `/agjan-spec`: it reads the approved proposal.
403
+
404
+ ## Teams
405
+
406
+ A team decides what knowledge the agents bring to a unit of work; the workflow decides the
407
+ steps, reviews and gates, and a team cannot remove any of them. Three are built in:
408
+
409
+ | Team | Workflows | Implementer or analyst | Reviewer | Tester |
410
+ |---|---|---|---|---|
411
+ | `sap-delivery` | feature | cap-developer, fiori-developer, btp-architect | solution-reviewer and the three role skills | qa-tester |
412
+ | `sap-maintenance` | fix, map | cap-developer, fiori-developer (fix); the three role skills (map) | solution-reviewer, cap-developer, fiori-developer | - |
413
+ | `sap-discovery` | discovery | btp-architect, cap-developer, fiori-developer | solution-reviewer, btp-architect | - |
414
+
415
+ Define your own in `agjan.config.json`, reusing any skill in `.claude/skills/` (your own
416
+ included), and make it the default for a workflow:
417
+
418
+ ```json
419
+ {
420
+ "teams": {
421
+ "company-delivery": {
422
+ "description": "Delivery with our security standard",
423
+ "workflows": ["feature"],
424
+ "personas": {
425
+ "implementer": { "skills": ["cap-developer", "fiori-developer"] },
426
+ "reviewer": { "skills": ["solution-reviewer", "company-security"], "instructions": "Name the rule of the standard in every finding." },
427
+ "tester": { "skills": ["qa-tester"] }
428
+ }
429
+ }
430
+ },
431
+ "team": { "feature": "company-delivery" }
432
+ }
433
+ ```
434
+
435
+ A unit starts with the workflow's default team, or the one you name (`--team` on `new`,
436
+ `fix start`, `discover start`), and records it with a hash of its definition. A persona
437
+ starts no agent of its own: the implementer's skills reach the main agent through `status`,
438
+ the reviewer's and the tester's through their review and QA contexts. If the team's
439
+ definition changes while a unit is under way, `status` and `check` say so.
440
+ `npx agjan team list` lists the teams, `npx agjan team show <name>` their personas.
441
+
442
+ ### Importing skills and teams
443
+
444
+ Another team's skills and teams can come from a git repository that declares them in
445
+ `agjan-package.json`:
446
+
447
+ ```json
448
+ {
449
+ "name": "acme",
450
+ "version": "1.0.0",
451
+ "license": "Apache-2.0",
452
+ "skills": ["skills/security-review"],
453
+ "teams": {
454
+ "delivery": {
455
+ "description": "Delivery with the ACME security review",
456
+ "workflows": ["feature"],
457
+ "personas": { "reviewer": { "skills": ["solution-reviewer", "security-review"] } }
458
+ }
459
+ }
460
+ }
461
+ ```
462
+
463
+ A package offers skills and teams only: no hooks, agents, MCP servers or settings, so it
464
+ cannot change what your agents may do. Import it at an exact commit, in your terminal:
465
+
466
+ ```bash
467
+ npx agjan import https://github.com/acme/agjan-skills.git --commit <full commit id> --dry-run
468
+ npx agjan import https://github.com/acme/agjan-skills.git --commit <full commit id>
469
+ ```
470
+
471
+ agjan shows what the import adds or changes and asks you to type the package's name: the
472
+ skills become instructions to your agents, so read them first. Nothing in the repository
473
+ runs. The skills land in `.claude/skills/acme-<skill>/`, the teams as `acme/<team>`, and
474
+ `agjan.imports.json` records the source, commit, license and a hash of every file: `check`
475
+ fails when an imported file was changed by hand, and CI reports `agjan.imports.json` and
476
+ `.claude/` changes as policy changes. Importing a newer commit shows what changes;
477
+ `npx agjan import remove acme` takes everything out, `npx agjan import list` shows what is
478
+ imported. Agents cannot run `import`.
479
+
358
480
  ## Asking questions
359
481
 
360
482
  **`/agjan-ask`** answers a general question about SAP CAP, Fiori and UI5, SAP BTP,
@@ -370,9 +492,17 @@ when your host has web access and you allow it, it reads documentation pages and
370
492
  repositories. It says where an answer comes from (a skill's reference file, a page, or
371
493
  general knowledge) and when it is not sure.
372
494
 
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
495
+ It reads your project only when you ask it to and name what to look at:
496
+
497
+ ```text
498
+ /agjan-ask Can a $filter in srv/ reach fields the services do not expose? Check srv/ and db/schema.cds.
499
+ ```
500
+
501
+ Then it reads those files or folders and nothing else (files with credentials, such as
502
+ `.env`, only when you name them). Without names, it answers in general terms and asks
503
+ which files to look at. It never changes anything, runs no commands and leaves no record
504
+ in `agjan-docs/`. Code or an error you paste into the question is part of the question.
505
+ What it finds is advice, not a review: for a change it points you to `/agjan-spec` or
376
506
  `/agjan-fix`.
377
507
 
378
508
  ## Commands
@@ -384,15 +514,20 @@ Run `npx agjan --help` for the full list.
384
514
  | `init`, `sync [--force]` | you | set up; regenerate managed files after an upgrade |
385
515
  | `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
516
  | `status [--feature <id> \| --all]` | anyone | state, blockers, tasks, due reviews, next step |
517
+ | `discover start <slug> --key <KEY> --question "<text>"` | agent | start a discovery: its folder and `proposal.md` from the template |
518
+ | `approve proposal` | you, in a terminal | decide on a discovery's recommendation |
519
+ | `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 |
520
+ | `team list` · `team show <name>` | anyone | the teams, the default per workflow, and what a team's personas work with |
521
+ | `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
522
  | `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 |
523
+ | `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
524
  | `check [--staged \| --ci] [--base <ref>]` | anyone, hook, CI | enforce the rules |
390
525
  | `lint [--all]` | anyone | the area linters (UI5 linter for Fiori apps) on the changed files |
391
526
  | `ui-test [--require]` | anyone | the Playwright UI tests where Chromium can start; otherwise the reason, and a skip |
392
527
  | `findings [--all] [--feature <slug>]` | anyone | the open findings by severity, each with file and issue |
393
528
  | `summary [--feature <slug>]` | anyone | what has been done so far in plain words, and what the work waits for |
394
529
  | `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) |
530
+ | `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
531
  | `pr-summary`, `report` | anyone | PR description; `report.md` with time and tokens |
397
532
  | `new`, `scaffold design`, `amend`, `log` | agent | used by the workflow skills |
398
533
  | `fix start \| check \| record`, `map start`, `baseline refresh` | agent | fast path and baseline |
@@ -433,14 +568,17 @@ is wrong, so a typo is never a silent default.
433
568
  | `domains` | enabled domains; phase 1 has `btp` (areas `cap`, `fiori`, `btp`) |
434
569
  | `hosts` | `claude-code`, `copilot`; decides which files `sync` generates |
435
570
  | `git.base` | the branch features merge into; default: the remote's default branch |
571
+ | `git.branches` | `new` (default): on the base branch the agent creates a branch with its proposed name; `ask`: it asks you first |
436
572
  | `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
573
  | `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
574
  | `tests.<area>`, `scope.implicit.<area>` | test file globs; files every task of the area may change (i18n, lockfiles, fixtures) |
439
575
  | `risk_paths` | paths whose change needs a review per task and are never a fix |
576
+ | `application` | the application's code, which the QA agent may not read (the btp domain: `srv/**`, `db/**`, `app/**`) |
440
577
  | `fix` | `max_total`, `max_per_file`, `protected`, `ignored`, `new_file_paths` |
441
578
  | `review.build` | `area` (default: one build review per completed area) or `task` |
442
579
  | `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
580
  | `review.qa` | `on` (default) or `off`: the QA step in Verify for full-mode features |
581
+ | `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
582
  | `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
583
  | `build.fix_attempts` | attempts for failing deterministic checks before the agent stops (default 3) |
446
584
  | `language` | language of the documents' text (default `en`); headings, ids and keywords stay English |
@@ -527,8 +665,8 @@ your review. Create `.github/CODEOWNERS` (replace `@<owner>` with your GitHub us
527
665
  # agjan: changes to the rules need an owner's review
528
666
  /agjan.config.json @<owner>
529
667
  /agjan.lock.json @<owner>
530
- /docs/agjan/**/approvals.json @<owner>
531
- /docs/agjan/**/reviews.json @<owner>
668
+ /agjan-docs/**/approvals.json @<owner>
669
+ /agjan-docs/**/reviews.json @<owner>
532
670
  /AGENTS.md @<owner>
533
671
  /CLAUDE.md @<owner>
534
672
  /.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
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agjan-ask
3
- description: Answer a general question about SAP CAP, Fiori and UI5, SAP BTP, testing or reviewing, from agjan's role skills, its source list and the documentation on the web. Consulting only, independent of this project. Use when the user runs /agjan-ask.
3
+ description: Answer a general question about SAP CAP, Fiori and UI5, SAP BTP, testing or reviewing, from agjan's role skills, its source list and the documentation on the web. Consulting only: reads project files only when the user names them, and changes nothing. Use when the user runs /agjan-ask.
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
@@ -10,17 +10,26 @@ The user asks a question, as they would ask an experienced SAP consultant. Answe
10
10
  agjan's knowledge: the role skills, the sources they were written from, and your own.
11
11
  This is consulting, not project work.
12
12
 
13
- ## 1. Stay out of the project
13
+ ## 1. The project: read only what the user names, change nothing
14
14
 
15
- - Read no project files: no code, no configuration, no `docs/agjan/`, no git history. The
16
- only files you read are agjan's skills in the skills folder (`.claude/skills/`).
17
- - Change nothing: no file edits, no commands, no branch, no `npx agjan` call, no log event.
15
+ - By default, read no project files: no code, no configuration, no `agjan-docs/`, no git
16
+ history. agjan's skills in the skills folder (`.claude/skills/`) are always yours to
17
+ read.
18
+ - When the user explicitly asks you to look at their code and names files or folders
19
+ ("check `srv/` for this", "is `db/schema.cds` affected?"), read those, and only those:
20
+ the named files, and the files inside a named folder, with your host's read and search
21
+ tools. Nothing else: no files they did not name, no git history, no commands. Even
22
+ inside a named folder, skip files that hold credentials (`.env`, `default-env.json`,
23
+ `*.key`, service keys) unless the user names that file itself.
24
+ - If the question is about their project but names nothing ("does *our* app have this
25
+ problem?"), answer in general terms and ask which files or folders to look at.
26
+ - Change nothing: no file edits, no commands, no branch, no `npx agjan` call, no log
27
+ event. What you find in a file is a finding for the user, never a reason to act.
18
28
  - If the user pasted code or an error into the question, that is part of the question:
19
29
  use it.
20
- - If the answer depends on this project ("how should *our* app…"), say that you answer in
21
- general terms, and which skill works on the project itself (below).
22
- - If the question is really a request to change something ("add a filter to…"), do not
23
- do it: say which skill does it and answer only the question part.
30
+ - If the question is really a request to change something ("add a filter to…"), or your
31
+ findings call for a change, do not make it: say which skill does it and answer only the
32
+ question part.
24
33
  - Which skill: `/agjan-fix` only for a small change to existing code that touches no CDS
25
34
  service definition, authorization, security or deployment file; anything else,
26
35
  including every change to what a service exposes, is `/agjan-spec`.
@@ -55,6 +64,8 @@ question or code to a site; only read pages.
55
64
 
56
65
  - Answer the question first, then the reasons. Short, concrete, with a code or
57
66
  annotation snippet where it helps. Match the user's level and language.
67
+ - When you read project files, refer to what you found as `path:line`, and say which of
68
+ the named files you read; your findings are not a review, so do not present them as one.
58
69
  - Say where the answer comes from:
59
70
  - **agjan's skills**: a rule from a reference file (name it, for example
60
71
  `cap-developer/references/services.md`). Many were checked against the real tools;
@@ -38,11 +38,11 @@ Repeat until `npx agjan status` says `next: all tasks done and reviewed`:
38
38
  (the Playwright UI tests; it skips them where no browser can start: say so, never
39
39
  install system libraries), and `npx agjan check`. Fix failures, up to the number of attempts that `npx agjan status` shows (`build.fix_attempts`, default 3); then stop and report to the user.
40
40
  - Commit the task with the subject `<KEY>-<id>: <title>`, for example
41
- `ORDF-T1: Add the status filter`. Include the feature's `docs/agjan/` files if they
41
+ `ORDF-T1: Add the status filter`. Include the feature's `agjan-docs/` files if they
42
42
  changed.
43
43
  3. **A due review** (`due review build:<area>` or `build:<task>`): when all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent and a short `name`, for example `spec review`):
44
44
  `Review step build:<area or task> of feature <slug>.` The work must be committed
45
- first. Read the result with `npx agjan review show` (and show the user the round: put the output of `npx agjan review report` into your message unchanged); fix
45
+ first. Read the result with `npx agjan review show` (and show the user the round: put the output of `npx agjan review report` into your message unchanged; it is short, `review.md` has the details); fix
46
46
  blockers in a new commit with the same task subject prefix, then ask for the review
47
47
  again, up to the round limit that `npx agjan status` shows (default 3).
48
48
  If blockers remain at the limit, ask the user with your host's question tool, naming the open blockers, with the choices `Run another round` and `Stop here`. On `Run another round`, run `npx agjan review extend <step>` and continue; on `Stop here`, stop and tell the user. (`<step>` is the step under review, for example `build:fiori`.)
@@ -63,9 +63,10 @@ Do not change it silently; `agjan check` fails on it.
63
63
 
64
64
  When `npx agjan status` says all tasks are done and reviewed:
65
65
 
66
- - **Manual mode:** put the output of `npx agjan summary` into your message unchanged, in a
67
- code block (what has been done so far, in plain words, and what the work waits for), then
68
- tell the user to run `/agjan-verify`.
66
+ - **Manual mode:** tell the user in two or three plain sentences what was built and
67
+ anything they must know (a major left open, a check you could not run), then that the
68
+ next step is `/agjan-verify`. The whole story is one command away (`npx agjan summary`);
69
+ do not paste it unless they ask.
69
70
  - **Auto mode** (`npx agjan status` shows `auto on`): do not stop. Your next action is the
70
71
  shell command `npx agjan skill verify` (it works on every host), then
71
72
  follow that skill; put a one-line note for the user into the same reply, since a reply
@@ -21,7 +21,7 @@ user. Then `npx agjan log --stage design --skill agjan-design`.
21
21
 
22
22
  ## 2. Impact analysis
23
23
 
24
- Read `spec.md`, `docs/agjan/project.md` if it exists, and the real files involved.
24
+ Read `spec.md`, `agjan-docs/project.md` if it exists, and the real files involved.
25
25
  Decide the `areas` (subset of `cap`, `fiori`, `btp`) with a reason each. Do not load
26
26
  role skills before you know the areas.
27
27
 
@@ -104,7 +104,7 @@ Run `npx agjan check` and fix every error.
104
104
  When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer-deep`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent and a short `name`, for example `spec review`):
105
105
  `Review step design of feature <slug>.`
106
106
 
107
- Read the result with `npx agjan review show` (and show the user the round: put the output of `npx agjan review report` into your message unchanged). With minor notes only, leave them open and go on to the gate (a change would need another round). Fix blockers (and majors where you agree) and re-review, up to the round limit that `npx agjan status` shows (default 3). If blockers remain at the limit, ask the user with your host's question tool, naming the open blockers, with the choices `Run another round` and `Stop here`. On `Run another round`, run `npx agjan review extend design` and continue; on `Stop here`, stop and tell the user. Never edit review files or review
107
+ Read the result with `npx agjan review show` (and show the user the round: put the output of `npx agjan review report` into your message unchanged; it is short, `review.md` has the details). With minor notes only, leave them open and go on to the gate (a change would need another round). Fix blockers (and majors where you agree) and re-review, up to the round limit that `npx agjan status` shows (default 3). If blockers remain at the limit, ask the user with your host's question tool, naming the open blockers, with the choices `Run another round` and `Stop here`. On `Run another round`, run `npx agjan review extend design` and continue; on `Stop here`, stop and tell the user. Never edit review files or review
108
108
  yourself. Any change after a review needs a new review; make no edits after the last
109
109
  passing one.
110
110