agjan 0.0.10 → 0.0.11

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 (31) hide show
  1. package/docs/guide.md +39 -2
  2. package/kit/domains/btp/domain.json +4 -4
  3. package/kit/skills/agjan-build/SKILL.md +10 -6
  4. package/kit/skills/agjan-design/SKILL.md +36 -4
  5. package/kit/skills/agjan-fix/SKILL.md +11 -4
  6. package/kit/skills/agjan-map/SKILL.md +11 -4
  7. package/kit/skills/agjan-spec/SKILL.md +11 -4
  8. package/kit/skills/agjan-verify/SKILL.md +26 -6
  9. package/kit/skills/cap-developer/SKILL.md +10 -2
  10. package/kit/skills/cap-developer/references/handlers.md +11 -9
  11. package/kit/skills/cap-developer/references/project-setup.md +21 -8
  12. package/kit/skills/cap-developer/references/testing.md +38 -14
  13. package/kit/skills/cap-developer/references/typescript.md +143 -0
  14. package/kit/skills/cap-developer/references/validation-security.md +26 -8
  15. package/kit/skills/fiori-developer/SKILL.md +20 -5
  16. package/kit/skills/fiori-developer/references/app-setup.md +91 -16
  17. package/kit/skills/fiori-developer/references/elements.md +19 -5
  18. package/kit/skills/fiori-developer/references/freestyle-ts.md +5 -1
  19. package/kit/skills/fiori-developer/references/testing.md +109 -15
  20. package/kit/templates/agents-block.md +4 -0
  21. package/package.json +1 -1
  22. package/src/browser.mjs +49 -0
  23. package/src/cli.mjs +14 -4
  24. package/src/commands/branch.mjs +50 -15
  25. package/src/commands/check.mjs +17 -6
  26. package/src/commands/gates.mjs +12 -9
  27. package/src/commands/review.mjs +69 -4
  28. package/src/commands/setup.mjs +12 -2
  29. package/src/commands/status.mjs +13 -11
  30. package/src/commands/ui-test.mjs +38 -0
  31. package/src/review.mjs +9 -6
package/docs/guide.md CHANGED
@@ -64,7 +64,9 @@ Then:
64
64
 
65
65
  Each feature on a branch of its own. When one is needed, the agent asks you: create the
66
66
  name it proposes, use a branch that already exists (it lists them), or provide a new
67
- name (it confirms the name before creating the branch).
67
+ name: type it in the chat (it confirms the name before creating the branch), or run
68
+ `npx agjan branch --edit "<proposal>"` in a terminal, which shows the proposed name
69
+ ready to edit and creates the branch when you press Enter.
68
70
 
69
71
  **Spec**: in Claude Code or Copilot:
70
72
 
@@ -79,9 +81,14 @@ your terminal:
79
81
  ```sh
80
82
  npx agjan status # what is ready and what blocks it
81
83
  npx agjan review show # the reviews and findings
84
+ npx agjan review report # the latest round, short: verdict, findings, what happens next
82
85
  npx agjan approve spec design # light mode; full mode: approve spec, later approve design
83
86
  ```
84
87
 
88
+ After every review the agent shows you that short report in its message: the verdict, the
89
+ findings by severity (🔴 blocker, 🟠 major, 🟡 minor), what the round resolved, the rounds
90
+ of the loop so far (`LVR-R1 ⛔ → LVR-R2 ✅`) and what the agent does next.
91
+
85
92
  `approve` shows a summary and asks you to type the feature key. It refuses when the
86
93
  latest review did not see the current files or has open blockers. After recording the
87
94
  approval it offers to commit the feature folder, with the message the agent proposed
@@ -95,15 +102,41 @@ pre-commit hook still runs. `accept` and `reject` do the same. To send a gate ba
95
102
  `design.md` and `tasks.md`; the deep reviewer checks them; you approve with
96
103
  `npx agjan approve design`.
97
104
 
105
+ New CAP services, tests and Fiori apps are written in **TypeScript** unless you or the
106
+ spec ask for JavaScript, or the application being changed is already JavaScript (then it
107
+ stays JavaScript; converting it is a design decision you make, not the agent).
108
+
98
109
  **Build**: `/agjan-build`. One commit per task, subject `ORDF-T1: …`; tests named with
99
110
  the AC ids; reviews when `agjan status` lists them as due. A file outside the approved
100
111
  task paths fails `agjan check`; the agent then proposes an amendment, which you approve
101
112
  with `npx agjan approve amendment ORDF-A1`.
102
113
 
114
+ If the approved design turns out wrong (an AC cannot be met as designed), the agent stops
115
+ and asks you. With your yes it revises `design.md` and `tasks.md` (done tasks stay done,
116
+ new tasks are added), the deep reviewer checks the revision, and you approve the design
117
+ again; then Build continues. Until then `agjan check` reports one error, that the changed
118
+ files wait for the revised design, and the pre-commit hook lets only the documents be
119
+ committed.
120
+
103
121
  **Verify**: `/agjan-verify`. Full build, tests and lint, the baseline update, the final
104
122
  deep review, `agjan check --ci`, `report.md`, and the PR description
105
123
  (`npx agjan pr-summary`). The agent opens a PR only when you ask; you review and merge.
106
124
 
125
+ **UI tests (optional)**: for what a user does on a page of a Fiori app (create a record,
126
+ choose an action), the agents also write Playwright tests (`test/ui/`, the script
127
+ `test:ui`), and `npx agjan ui-test` runs them in Chromium as each test user. Where Chromium
128
+ cannot start, it says why and skips them, and the agent tells you which ACs to try by
129
+ hand. agjan never installs anything with admin rights:
130
+
131
+ - macOS and Windows: `npx playwright install chromium` is all it needs.
132
+ - Linux, dev containers: Chromium also needs system libraries. Whoever maintains the
133
+ machine or the container image adds them once, for example
134
+ `RUN npx playwright install-deps chromium` in the Dockerfile (as root), or uses
135
+ Playwright's image `mcr.microsoft.com/playwright`. `npx agjan doctor` (row `ui tests`)
136
+ says what is missing.
137
+ - CI: on GitHub-hosted runners, add a job with `npx playwright install --with-deps
138
+ chromium` and `npx agjan ui-test --require`.
139
+
107
140
  At any time, `npx agjan status` says where a feature stands and what comes next. When a
108
141
  feature is verified, it ends with a completion block ("✔ ORDF is verified …") that lists
109
142
  what was met, what is open, and what you do next.
@@ -153,12 +186,15 @@ Run `npx agjan --help` for the full list.
153
186
  | Command | Who | Purpose |
154
187
  |---|---|---|
155
188
  | `init`, `sync [--force]` | you | set up; regenerate managed files after an upgrade |
156
- | `doctor` | anyone | check Node, git, versions, managed files, hook, CI, the MCP server, guards, folder trust (Claude Code, Copilot CLI) |
189
+ | `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 |
157
190
  | `status [--feature <id> \| --all]` | anyone | state, blockers, tasks, due reviews, next step |
158
191
  | `progress [--open]` | anyone | regenerate the progress pages, print the overview, open the HTML page |
159
192
  | `branch <name>` · `--list` · `--use <name>` | agent, after asking you | create the branch of a unit, list the existing branches, or switch to one |
160
193
  | `check [--staged \| --ci] [--base <ref>]` | anyone, hook, CI | enforce the rules |
194
+ | `lint [--all]` | anyone | the area linters (UI5 linter for Fiori apps) on the changed files |
195
+ | `ui-test [--require]` | anyone | the Playwright UI tests where Chromium can start; otherwise the reason, and a skip |
161
196
  | `review show [--step <step>]` | anyone | review records, or the material a reviewer gets |
197
+ | `review report [--step <step>]` | anyone | the latest review round as a short report (agents show it after each review) |
162
198
  | `pr-summary`, `report` | anyone | PR description; `report.md` with time and tokens |
163
199
  | `new`, `scaffold design`, `amend`, `log` | agent | used by the workflow skills |
164
200
  | `fix start \| check \| record`, `map start`, `baseline refresh` | agent | fast path and baseline |
@@ -346,5 +382,6 @@ Commit the result in a pull request of its own: CI reports it as a policy change
346
382
  | `approve` refuses: the review did not see the current files | Something changed after the last review; let the agent ask for the review again. |
347
383
  | `check` says a file is outside the approved task paths | Revert it, or let the agent propose `agjan amend` and approve the amendment. |
348
384
  | `check --ci` says the final verify review is stale | Files changed after it; run `/agjan-verify` again. |
385
+ | `ui-test` skips: Chromium cannot start, the system lacks its libraries | Linux only. The UI tests stay optional; to run them, add the libraries once to the machine or image (see "UI tests" above). Do not let an agent install them. |
349
386
  | Warnings about managed files | `npx agjan sync`; `--force` replaces files you edited. |
350
387
  | `agjan check --staged` blocks a commit | The pre-commit hook found a rule violation in the staged change; read its message. |
@@ -5,15 +5,15 @@
5
5
  "cap": {
6
6
  "role": "cap-developer",
7
7
  "tests": ["test/**"],
8
- "implicit": ["package.json", "package-lock.json", "test/fixtures/**", "_i18n/**"],
8
+ "implicit": ["package.json", "package-lock.json", "tsconfig.json", "tsconfig.cdsbuild.json", "test/fixtures/**", "_i18n/**"],
9
9
  "verify": { "test": "npm test" }
10
10
  },
11
11
  "fiori": {
12
12
  "role": "fiori-developer",
13
- "tests": ["app/*/webapp/test/**", "app/*/test/**"],
14
- "implicit": ["app/*/package.json", "app/*/package-lock.json", "app/*/webapp/i18n/**"],
13
+ "tests": ["app/*/webapp/test/**", "app/*/test/**", "test/ui/**"],
14
+ "implicit": ["app/*/package.json", "app/*/package-lock.json", "app/*/tsconfig.json", "app/*/webapp/i18n/**", "playwright.config.ts"],
15
15
  "verify": {},
16
- "lint": { "command": "npx --yes @ui5/linter", "in": "app/*", "files": "webapp/**" }
16
+ "lint": { "command": "npx --yes @ui5/linter", "in": "app/*", "files": "webapp/**/*.{js,ts,xml,json,html}" }
17
17
  },
18
18
  "btp": {
19
19
  "role": "btp-architect",
@@ -28,13 +28,15 @@ Repeat until `npx agjan status` says `next: all tasks done and reviewed`:
28
28
  - Write tests for the task's ACs. Each test name contains the AC id, for example
29
29
  `it('ORDF-AC2: an approved order cannot be edited', ...)`. Manual ACs need no test.
30
30
  - Run the task's `verify` command (default: the area's commands in
31
- `agjan.config.json`, else `npm test`) 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.
31
+ `agjan.config.json`, else `npm test`), for a `fiori` task also `npx agjan ui-test`
32
+ (the Playwright UI tests; it skips them where no browser can start: say so, never
33
+ 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.
32
34
  - Commit the task with the subject `<KEY>-<id>: <title>`, for example
33
35
  `ORDF-T1: Add the status filter`. Include the feature's `docs/agjan/` files if they
34
36
  changed.
35
37
  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`):
36
38
  `Review step build:<area or task> of feature <slug>.` The work must be committed
37
- first. Read the result with `npx agjan review show`; fix
39
+ 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
38
40
  blockers in a new commit with the same task subject prefix, then ask for the review
39
41
  again, up to the round limit that `npx agjan status` shows (default 3).
40
42
  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`.)
@@ -46,8 +48,10 @@ Do not change it silently; `agjan check` fails on it.
46
48
  - If the change is small and necessary: revert it, then propose an amendment:
47
49
  `npx agjan amend --task <id> --paths <path,...> --reason "<why>"`, and ask the user
48
50
  to approve it in a terminal: `npx agjan approve amendment <KEY>-A<n>`. Wait.
49
- - If the design itself is wrong (a new task, a different decision): stop and tell the
50
- user; the design must be changed and approved again.
51
+ - If the design itself is wrong (an AC cannot be met as designed, a new task, a
52
+ different decision): stop and tell the user what is wrong. With their yes, revise it
53
+ as `/agjan-design` describes ("Revising an approved design"): the design is reviewed
54
+ and approved again, then you continue with the open tasks. Done tasks stay done.
51
55
 
52
56
  ## 4. Done
53
57
 
@@ -57,6 +61,6 @@ When `npx agjan status` says all tasks are done and reviewed, tell the user to r
57
61
  ## Never
58
62
 
59
63
  - Run `agjan approve`, `agjan accept` or `agjan reject` yourself, in any form.
60
- - Edit `spec.md`, `design.md` or `tasks.md` to make the build fit; that is a design
61
- change for the human.
64
+ - Edit `spec.md`, `design.md` or `tasks.md` to make the build fit; a design change goes
65
+ through the revision in `/agjan-design`, with the user's yes and a new approval.
62
66
  - Skip or weaken a test to make a check pass.
@@ -35,6 +35,13 @@ Every decision states what, why, and the alternative considered. For every new F
35
35
  application, record `app_type: elements` or `app_type: freestyle` with reason and
36
36
  alternative. Existing applications keep their type (read it from `manifest.json`).
37
37
 
38
+ Before you go on, check the decisions against the ACs, one by one: can the chosen UI do
39
+ what each AC describes with this service shape (create, edit, delete, each action and
40
+ its input)? In a Fiori elements app, creating or editing records needs a draft-enabled
41
+ entity; "no draft" is only for read-only apps or apps that change data through actions
42
+ (fiori-developer). An AC the design cannot meet in the UI is a design error, not a
43
+ build problem.
44
+
38
45
  Then fill `## Answers to open technical questions` (one answer per question in the
39
46
  spec) and `## Risks and trade-offs`.
40
47
 
@@ -51,16 +58,22 @@ tasks:
51
58
  area: cap
52
59
  covers: [<KEY>-AC1, <KEY>-AC2]
53
60
  title: Add the status filter to the orders service
54
- paths: [srv/orders-service.cds, srv/orders-service.js, test/orders.test.js]
61
+ paths: [srv/orders-service.cds, srv/orders-service.ts, test/orders.test.ts]
55
62
  verify: npm test
56
63
  ```
57
64
 
58
65
  - Order: backend (`cap`) first, then UI (`fiori`) against the finished service, then
59
66
  deployment (`btp`).
60
- - Every AC is covered by at least one task.
67
+ - Every AC is covered by at least one task. A task covers an AC only if its `paths`
68
+ include every file needed to implement and test it (for a handler rule: the service
69
+ `.cds`, the handler file and the test file).
61
70
  - `paths` are the exact files, or a folder ending in `/`, that the task changes,
62
71
  including **the tests of the ACs it covers**. Tests of UI annotations usually live in
63
- the CAP tests (`test/`): a `fiori` task that adds annotations lists that test file too. Keep them tight; broad globs like `srv/**` defeat the scope
72
+ the CAP tests (`test/`): a `fiori` task that adds annotations lists that test file too.
73
+ An AC that a user does on a page (create a record, choose an action) also gets a UI
74
+ test, `test/ui/<app>.spec.ts` (Playwright, fiori-developer `references/testing.md`);
75
+ the first such task also lists `.gitignore` (`playwright.config.ts` is allowed
76
+ implicitly). Keep them tight; broad globs like `srv/**` defeat the scope
64
77
  check. Do not list `package.json`, lockfiles, i18n files or test fixtures: they are
65
78
  allowed implicitly.
66
79
  - `verify` is optional; it defaults to the area's commands in `agjan.config.json`.
@@ -72,7 +85,7 @@ Run `npx agjan check` and fix every error.
72
85
  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`):
73
86
  `Review step design of feature <slug>.`
74
87
 
75
- Read the result with `npx agjan review show`. 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
88
+ 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
76
89
  yourself. Any change after a review needs a new review; make no edits after the last
77
90
  passing one.
78
91
 
@@ -89,6 +102,25 @@ passing one.
89
102
  If the spec must change, say so: changing it needs a new spec approval, and the design
90
103
  is approved again after that.
91
104
 
105
+ ## Revising an approved design
106
+
107
+ When the approved design turns out wrong during Build or Verify (an AC cannot be met as
108
+ designed), the design is revised here, never quietly in Build:
109
+
110
+ 1. Stop building and tell the user what is wrong and what you would change. Revise only
111
+ after their yes.
112
+ 2. `npx agjan log --stage design --skill agjan-design`. Edit `design.md` (the decision,
113
+ its reason, the alternative, and why the first decision failed) and `tasks.md`. Tasks
114
+ that are done (committed) keep their id, title and paths; add new tasks (`T<n+1>`)
115
+ for the change, or extend the paths of an open task. Approved amendments lapse with
116
+ the new design: put their paths into the tasks.
117
+ 3. From the first edit on, the design is stale. `npx agjan check` then reports that the
118
+ design waits for its gate, and the pre-commit hook lets you commit the revised
119
+ documents (it warns, CI does not pass) but not code. Do not touch code until the
120
+ design is approved again.
121
+ 4. Review (step `design`, section 5) and Gate 2 (section 6) as before. After
122
+ `npx agjan approve design`, continue with `/agjan-build`: it picks up the open tasks.
123
+
92
124
  ## Never
93
125
 
94
126
  - Run `agjan approve`, `agjan accept` or `agjan reject` yourself, in any form.
@@ -30,9 +30,16 @@ choices, with these labels; do not merge them into one free-text question:
30
30
  AGENTS.md names one). Run `npx agjan branch <name>`.
31
31
  2. `Use an existing branch`: run `npx agjan branch --list`, ask which one (offer the
32
32
  names as choices), then run `npx agjan branch --use <picked>`.
33
- 3. `Provide new branch name`: ask for the name, then confirm it in a second question,
34
- `Create branch "<their name>"?` with the choices `Yes, create it` and
35
- `No, change the name`. Run `npx agjan branch <their name>` only after yes.
33
+ 3. `Provide new branch name`: ask a second question, `Type the branch name (proposal:
34
+ <name>), or edit the proposal in a terminal`, with free text allowed and the
35
+ choice `Edit it in a terminal`.
36
+ - A typed name: confirm it in a third question, `Create branch "<their name>"?`
37
+ with the choices `Yes, create it` and `No, change the name`. Run
38
+ `npx agjan branch <their name>` only after yes.
39
+ - `Edit it in a terminal`: ask the user to run `npx agjan branch --edit "<name>"`
40
+ in a terminal (it shows your proposal ready to edit and creates the branch; you
41
+ cannot run it, you have no terminal). Wait until they say it is done, then check
42
+ with `npx agjan branch --list` that the current branch (marked `*`) is theirs.
36
43
  If `agjan branch` refuses a name (invalid, already exists), say why and ask again.
37
44
  Never create or switch branches with git directly.
38
45
 
@@ -52,7 +59,7 @@ Pick a slug and a key of 2 to 6 capitals:
52
59
 
53
60
  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`):
54
61
  `Review step fix of feature fixes/<id>.` (the id is the folder name under
55
- `docs/agjan/fixes/`). Read the result with `npx agjan review show`. Fix blockers in a
62
+ `docs/agjan/fixes/`). 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 blockers in a
56
63
  new commit and review again, 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 fix` and continue; on `Stop here`, stop and tell the user. Make no
57
64
  change after the last passing review.
58
65
 
@@ -20,9 +20,16 @@ choices, with these labels; do not merge them into one free-text question:
20
20
  AGENTS.md names one). Run `npx agjan branch <name>`.
21
21
  2. `Use an existing branch`: run `npx agjan branch --list`, ask which one (offer the
22
22
  names as choices), then run `npx agjan branch --use <picked>`.
23
- 3. `Provide new branch name`: ask for the name, then confirm it in a second question,
24
- `Create branch "<their name>"?` with the choices `Yes, create it` and
25
- `No, change the name`. Run `npx agjan branch <their name>` only after yes.
23
+ 3. `Provide new branch name`: ask a second question, `Type the branch name (proposal:
24
+ <name>), or edit the proposal in a terminal`, with free text allowed and the
25
+ choice `Edit it in a terminal`.
26
+ - A typed name: confirm it in a third question, `Create branch "<their name>"?`
27
+ with the choices `Yes, create it` and `No, change the name`. Run
28
+ `npx agjan branch <their name>` only after yes.
29
+ - `Edit it in a terminal`: ask the user to run `npx agjan branch --edit "<name>"`
30
+ in a terminal (it shows your proposal ready to edit and creates the branch; you
31
+ cannot run it, you have no terminal). Wait until they say it is done, then check
32
+ with `npx agjan branch --list` that the current branch (marked `*`) is theirs.
26
33
  If `agjan branch` refuses a name (invalid, already exists), say why and ask again.
27
34
  Never create or switch branches with git directly.
28
35
 
@@ -56,7 +63,7 @@ user if unsure. These paths are protected for `/agjan-fix`.
56
63
 
57
64
  1. `npx agjan baseline refresh`
58
65
  2. 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`):
59
- `Review step map of feature maps/<id>.` Read the result with `npx agjan review show`;
66
+ `Review step map of feature maps/<id>.` 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);
60
67
  fix blockers and review again, up to the round limit that `npx agjan status` shows (default 3).
61
68
  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 map` and continue; on `Stop here`, stop and tell the user.
62
69
  3. Commit `docs/agjan/`. `npx agjan check --ci` must pass.
@@ -22,9 +22,16 @@ it instead of starting a new one. Otherwise:
22
22
  AGENTS.md names one). Run `npx agjan branch <name>`.
23
23
  2. `Use an existing branch`: run `npx agjan branch --list`, ask which one (offer the
24
24
  names as choices), then run `npx agjan branch --use <picked>`.
25
- 3. `Provide new branch name`: ask for the name, then confirm it in a second question,
26
- `Create branch "<their name>"?` with the choices `Yes, create it` and
27
- `No, change the name`. Run `npx agjan branch <their name>` only after yes.
25
+ 3. `Provide new branch name`: ask a second question, `Type the branch name (proposal:
26
+ <name>), or edit the proposal in a terminal`, with free text allowed and the
27
+ choice `Edit it in a terminal`.
28
+ - A typed name: confirm it in a third question, `Create branch "<their name>"?`
29
+ with the choices `Yes, create it` and `No, change the name`. Run
30
+ `npx agjan branch <their name>` only after yes.
31
+ - `Edit it in a terminal`: ask the user to run `npx agjan branch --edit "<name>"`
32
+ in a terminal (it shows your proposal ready to edit and creates the branch; you
33
+ cannot run it, you have no terminal). Wait until they say it is done, then check
34
+ with `npx agjan branch --list` that the current branch (marked `*`) is theirs.
28
35
  If `agjan branch` refuses a name (invalid, already exists), say why and ask again.
29
36
  Never create or switch branches with git directly.
30
37
  After switching, run `npx agjan status` again: an existing branch may already carry a
@@ -69,7 +76,7 @@ When all your edits are saved, delegate, on its own (not in parallel with other
69
76
  to the prompt. If no such agent is available, stop and tell the user: the review
70
77
  cannot be skipped (`npx agjan doctor` shows why).
71
78
 
72
- Then run `npx agjan review show`:
79
+ Then run `npx agjan review show` (and show the user the round: put the output of `npx agjan review report` into your message unchanged):
73
80
 
74
81
  - `blocked`: fix every blocker in `spec.md` (and majors where you agree), then ask for
75
82
  the review again, up to the round limit that `npx agjan status` shows (default 3).
@@ -16,13 +16,33 @@ tell the user what is open. Then `npx agjan log --stage verify --skill agjan-ver
16
16
  ## 2. Full checks
17
17
 
18
18
  Run every area's build, test and lint commands from `agjan.config.json` (else
19
- `npm test`), and `npx agjan lint` (the UI5 linter for Fiori apps). Where an area configures `results`, its test command writes that file;
19
+ `npm test`), `npx agjan lint` (the UI5 linter for Fiori apps) and `npx agjan ui-test` (the
20
+ Playwright UI tests, where Chromium can start; otherwise it says why and skips them). Where an area configures `results`, its test command writes that file;
20
21
  `agjan check` then requires a passing test for every automated AC, so run the tests
21
22
  again after the last change. Fix failures within the approved task paths and commit them with the
22
23
  subject of the task they belong to (`<KEY>-<id>: …`). A fix makes that area's build
23
24
  review due again: `npx agjan status` lists it; do it before the final review.
24
25
 
25
- ## 3. Baseline
26
+ ## 3. Start the application
27
+
28
+ Tests do not show that the app starts and serves its pages. Start `npx cds watch` in the
29
+ background (your host's way to run a long-running command), then request, with each
30
+ development user (`curl -u <user>:<user>`):
31
+
32
+ - the service's `$metadata` and each entity set the spec names: the status codes match the
33
+ spec's authorization (200, 403, 401 without a user);
34
+ - each Fiori app's `index.html`, `Component.js` (served from `Component.ts` in a TypeScript
35
+ app) and `manifest.json`: 200.
36
+
37
+ Stop the server afterwards. This is not a UI test. In your final message, name the
38
+ manual ACs, and if `npx agjan ui-test` skipped the UI tests (or the project has none), say
39
+ plainly that the UI was not tried in a browser and pass on its reason and how to enable
40
+ them, so the user tries those ACs by hand (`docs/agjan/project.md`, "Run locally"). Never
41
+ install system libraries or use `sudo` to make the UI tests run. If the project records no test results
42
+ (`verify.<area>.results` in `agjan.config.json`, a setting only the user can change), say
43
+ that ACs were matched by test names.
44
+
45
+ ## 4. Baseline
26
46
 
27
47
  If the feature added a CDS service, a Fiori application or a BTP service, update
28
48
  `docs/agjan/project.md` (short, with pointers to the real files). Keep its section
@@ -31,17 +51,17 @@ their roles, so the user can try the result. Then run
31
51
  `npx agjan baseline refresh` whenever `npx agjan check` warns that watched files changed
32
52
  since the baseline, and commit both.
33
53
 
34
- ## 4. Final review (step `verify`, deep)
54
+ ## 5. Final review (step `verify`, deep)
35
55
 
36
56
  Everything must be committed. 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`):
37
57
  `Review step verify of feature <slug>.`
38
58
 
39
- Read the result with `npx agjan review show`. If it is blocked, fix the blockers in new
59
+ 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). If it is blocked, fix the blockers in new
40
60
  commits and ask for the review again, up to the round limit that `npx agjan status` shows (default 3).
41
61
  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 verify` and continue; on `Stop here`, stop and tell the user.
42
62
  Any change after the final review makes it stale; review again after the last change.
43
63
 
44
- ## 5. Check and summary
64
+ ## 6. Check and summary
45
65
 
46
66
  - `npx agjan check --ci` must pass. Fix what it reports, then review again if files
47
67
  changed.
@@ -54,7 +74,7 @@ Any change after the final review makes it stale; review again after the last ch
54
74
  pull request is one of the optional next steps, done only when the user asks (its
55
75
  description is the output of `npx agjan pr-summary`).
56
76
 
57
- ## 6. Pull request, only when the user asks
77
+ ## 7. Pull request, only when the user asks
58
78
 
59
79
  Push the branch and create the PR with the summary as its body, for example
60
80
  `gh pr create --fill-first --body "<pr-summary output>"`. Never merge; the human
@@ -24,6 +24,7 @@ Rules for designing and building CAP Node.js backends in agjan. Project conventi
24
24
  | The task touches | Read |
25
25
  |---|---|
26
26
  | a new project, the layout, configuration, development users, sample data, running it | `references/project-setup.md` |
27
+ | TypeScript: setup, generated types, typed handlers, tests, build (the default language) | `references/typescript.md` |
27
28
  | entities, types, associations, compositions, localized texts | `references/modeling.md` |
28
29
  | services, projections, actions, functions, drafts, remote services | `references/services.md` |
29
30
  | input validation, `@mandatory`, `@assert…`, authorization, error messages | `references/validation-security.md` |
@@ -33,7 +34,11 @@ Rules for designing and building CAP Node.js backends in agjan. Project conventi
33
34
  ## Decide in this order
34
35
 
35
36
  0. **A new project** starts as `references/project-setup.md` says (`cds init <name>
36
- --nodejs`, never `cds add sample`).
37
+ --nodejs`, then `cds add typescript`; never `cds add sample`).
38
+ 0. **TypeScript by default.** Write handlers and tests in TypeScript unless the user or
39
+ the spec asks for JavaScript explicitly, or the application you change is JavaScript
40
+ (handlers in `srv/*.js`, no `tsconfig.json`): then stay in JavaScript, and never
41
+ convert it on your own (`references/typescript.md`).
37
42
 
38
43
  1. **Declarative before code.** What an annotation can express (validation, read-only,
39
44
  authorization, defaults) is never written as handler code.
@@ -48,6 +53,9 @@ Rules for designing and building CAP Node.js backends in agjan. Project conventi
48
53
 
49
54
  ## Building
50
55
 
51
- - Follow the project's style (ESM or CommonJS, file names `<name>-service.cds/.js`).
56
+ - Follow the project's style (ESM or CommonJS, file names `<name>-service.cds/.ts`, or
57
+ `.js` in a JavaScript project).
58
+ - In TypeScript, `npm run typecheck` (cds-typer, then `tsc --noEmit`) must pass with the
59
+ tests.
52
60
  - Write a test for each AC of the task, named with the AC id, through the service API.
53
61
  - Run the area's test command, then `npx agjan check`, before you commit the task.
@@ -8,8 +8,8 @@ with `search_docs`.
8
8
 
9
9
  ## Where handlers go
10
10
 
11
- - One class per service, extending `cds.ApplicationService`, in the `.js` file next to
12
- the service's `.cds` file. Register handlers in `init()` and call `super.init()`
11
+ - One class per service, extending `cds.ApplicationService`, in the `.ts` file next to
12
+ the service's `.cds` file (`.js` in a JavaScript project; typescript.md). Register handlers in `init()` and call `super.init()`
13
13
  (after your registrations, so yours run first). Take entities from `this.entities`.
14
14
  - `before` validates and enriches input, `on` replaces the default implementation (call
15
15
  `next()` to delegate), `after` post-processes results. Prefer `before`/`after`; an `on`
@@ -53,14 +53,14 @@ with `search_docs`.
53
53
  `cds.features.legacy_db_results: false` get `{ affected }` instead); 0 means the state
54
54
  had changed. `.where()` and `.with()` may come in either order.
55
55
 
56
- ## A handler file (ESM, checked with @sap/cds 10.1)
56
+ ## A handler file (TypeScript, checked with @sap/cds 10.1)
57
57
 
58
- <!-- checked: srv/leave-service.js -->
59
- ```js
58
+ <!-- checked: srv/leave-service.ts -->
59
+ ```ts
60
60
  import cds from '@sap/cds'
61
+ import { LeaveRequest, LeaveRequests } from '#cds-models/LeaveService'
61
62
 
62
- export class LeaveService extends cds.ApplicationService { init() {
63
- const { LeaveRequests } = this.entities
63
+ export class LeaveService extends cds.ApplicationService { override init() {
64
64
 
65
65
  // Fill what the client must not set; check a rule across rows.
66
66
  this.before('CREATE', LeaveRequests, async req => {
@@ -74,8 +74,8 @@ export class LeaveService extends cds.ApplicationService { init() {
74
74
  })
75
75
 
76
76
  // A status transition: one conditional UPDATE, no SELECT before it.
77
- this.on('approve', LeaveRequests, async req => {
78
- const [{ ID }] = req.params
77
+ this.on(LeaveRequest.actions.approve, async req => {
78
+ const [{ ID }] = req.params as { ID: string }[]
79
79
  const n = await UPDATE(LeaveRequests, ID).where({ status_code: 'N' }).with({ status_code: 'A' })
80
80
  if (!n) return req.reject(409, 'ONLY_NEW_REQUESTS') // key in _i18n/messages.properties
81
81
  })
@@ -91,6 +91,8 @@ export class LeaveService extends cds.ApplicationService { init() {
91
91
  }}
92
92
  ```
93
93
 
94
+ - In a JavaScript project the same file is `.js`: `const { LeaveRequests } = this.entities`
95
+ instead of the import, and `this.on('approve', LeaveRequests, …)`.
94
96
  - An after-`READ` handler sees only the columns the client selected (Fiori selects what
95
97
  the page shows). Compute from columns that are on the page, or read the missing ones.
96
98
  - `req.reject(status, code)` ends the request; `req.error(…)` collects several errors.
@@ -9,6 +9,7 @@ Distilled from the CAP documentation (capire), the CAP team's agent skills
9
9
  ```sh
10
10
  cds init <name> --nodejs # ESM ("type": "module"), db/, srv/, app/
11
11
  cd <name>
12
+ cds add typescript # TypeScript is the default; then fix tsconfig.json (typescript.md)
12
13
  npm add -D @cap-js/cds-test # tests with cds.test
13
14
  cds watch # dev loop; reloads on every save
14
15
  ```
@@ -30,13 +31,15 @@ cds watch # dev loop; reloads on every save
30
31
  | `db/schema.cds` | the domain model, with a `namespace` |
31
32
  | `db/data/<namespace>-<Entity>.csv` | seed and test data |
32
33
  | `srv/<name>-service.cds` | one service per file: projections and actions |
33
- | `srv/<name>-service.js` | its handlers; same base name, so CAP finds it (no `@impl`) |
34
+ | `srv/<name>-service.ts` | its handlers; same base name, so CAP finds it (no `@impl`); `.js` in a JavaScript project |
34
35
  | `srv/<name>-constraints.cds` | input validation (`@mandatory`, `@assert…`) and helper `extend`s for it |
35
36
  | `app/<app>/annotations.cds` | the Fiori annotations of one app (never in `srv/`) |
36
37
  | `app/services.cds` | `using from './<app>/annotations';` for every app |
37
38
  | `_i18n/i18n.properties` | labels used as `{i18n>Key}` in annotations |
38
39
  | `_i18n/messages.properties` | error messages, by the codes in `@assert` and `req.reject` |
39
- | `test/<topic>.test.js` | tests with `cds.test` and `node --test` |
40
+ | `test/<topic>.test.ts` | tests with `cds.test` and `node --test` (`.test.js` in a JavaScript project) |
41
+ | `tsconfig.json`, `tsconfig.cdsbuild.json` | TypeScript settings for the service and its build (typescript.md) |
42
+ | `@cds-models/` | types generated by cds-typer; ignored by git, never edited |
40
43
 
41
44
  ## Configuration
42
45
 
@@ -44,7 +47,8 @@ cds watch # dev loop; reloads on every save
44
47
  and `cds add` put it. Use `.cdsrc.json` only if the project already uses it.
45
48
  Personal, local settings belong in `.cdsrc-private.json` (not committed).
46
49
  - Development users go into the `[development]` profile, named after their role with the
47
- name as password, plus one without a role. `cds.test` and `cds watch` use them; in
50
+ name as password, plus one without a role, and for each `where` condition one user who
51
+ has the role but whom the condition excludes (`manager2`, a manager of another team). `cds.test` and `cds watch` use them; in
48
52
  production (`NODE_ENV=production`) the real authentication applies:
49
53
 
50
54
  <!-- checked: package.json -->
@@ -58,6 +62,7 @@ cds watch # dev loop; reloads on every save
58
62
  "employee": { "password": "employee", "roles": ["employee"] },
59
63
  "employee2": { "password": "employee2", "roles": ["employee"] },
60
64
  "manager": { "password": "manager", "roles": ["manager"] },
65
+ "manager2": { "password": "manager2", "roles": ["manager"] },
61
66
  "nobody": { "password": "nobody", "roles": [] }
62
67
  }
63
68
  }
@@ -67,8 +72,9 @@ cds watch # dev loop; reloads on every save
67
72
  ```
68
73
 
69
74
  - Check: `NODE_ENV=production npx cds env get requires.auth.kind` must not print `mocked`.
70
- - Scripts: `"watch": "cds watch"`, `"test": "node --test"` (add the JUnit reporter when
71
- `verify.<area>.results` in `agjan.config.json` names a results file).
75
+ - Scripts: `"watch": "cds watch"`, and the test and type-check scripts of typescript.md
76
+ (`"test": "node --test"` in a JavaScript project). Add the JUnit reporter when
77
+ `verify.<area>.results` in `agjan.config.json` names a results file.
72
78
 
73
79
  ## Sample data
74
80
 
@@ -82,6 +88,13 @@ cds watch # dev loop; reloads on every save
82
88
  ## Run locally
83
89
 
84
90
  Keep the section "Run locally" of `docs/agjan/project.md` current: the start command
85
- (`npx cds watch`), the URLs of the apps (`http://localhost:4004/<app>/webapp/index.html`),
86
- and the development users with their roles. A browser keeps a login: another user needs a
87
- private window.
91
+ (`npx cds watch`), the URLs of the apps (`http://localhost:4004/<app id>/index.html` for a
92
+ TypeScript app served through `cds-plugin-ui5`, `http://localhost:4004/<app>/webapp/index.html`
93
+ for a JavaScript app without it),
94
+ and the development users with their roles.
95
+
96
+ A browser keeps a basic-auth login, even after clearing cookies. To switch users, use a
97
+ private window, or a second host name for the same server (`http://127.0.0.1:4004/…` next
98
+ to `http://localhost:4004/…`). Never put credentials into the app's URL
99
+ (`http://user:pass@localhost…`): UI5 then fails to load, because the browser refuses
100
+ requests from such a page.