agjan 0.0.18 → 0.0.19

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.
package/dist/cli.js CHANGED
@@ -17,6 +17,7 @@ import * as progress from './commands/progress.js';
17
17
  import * as lint from './commands/lint.js';
18
18
  import * as uiTest from './commands/ui-test.js';
19
19
  import * as models from './commands/models.js';
20
+ import * as findings from './commands/findings.js';
20
21
  import { onEvent } from './log.js';
21
22
  import { refreshAfterEvent } from './progress-view.js';
22
23
  const COMMANDS = {
@@ -39,6 +40,7 @@ const COMMANDS = {
39
40
  reject: gates.reject,
40
41
  auto: gates.auto,
41
42
  review: review.run,
43
+ findings: findings.run,
42
44
  log: log.run,
43
45
  'pr-summary': prSummary.run,
44
46
  report: report.run,
@@ -96,6 +98,9 @@ Agent and human:
96
98
  fast path for small changes (record folder under fixes/)
97
99
  map start start mapping an existing application (project.md)
98
100
  baseline refresh record the watched files in baseline.json
101
+ findings [--all] [--feature <s>]
102
+ the open findings by severity (--all: with resolved and
103
+ accepted ones), and how to decide each
99
104
  review show [--step <step>] list review records, or print a step's review context
100
105
  review report [--step <step>] the latest review round for the user: verdict, findings,
101
106
  rounds, what happens next (agents show it after each review)
@@ -0,0 +1,67 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { changedFeatures, listFeatures, loadFeature } from '../feature.js';
3
+ import { UsageError } from '../errors.js';
4
+ import { markLine, pad } from '../ui.js';
5
+ const SEVERITIES = ['blocker', 'major', 'minor'];
6
+ const WIDTH = 100;
7
+ /** Words joined into lines of at most `width` characters. */
8
+ function wrap(text, width) {
9
+ const lines = [];
10
+ let line = '';
11
+ for (const word of text.replace(/\s+/g, ' ').trim().split(' ')) {
12
+ if (line && line.length + 1 + word.length > width) {
13
+ lines.push(line);
14
+ line = word;
15
+ }
16
+ else
17
+ line = line ? `${line} ${word}` : word;
18
+ }
19
+ if (line)
20
+ lines.push(line);
21
+ return lines;
22
+ }
23
+ /** The number in a finding id (`TLR-F12` -> 12), to list findings in the order they were raised. */
24
+ function order(f) {
25
+ return Number(/(\d+)$/.exec(f.id)?.[1] ?? 0);
26
+ }
27
+ function describe(ctx, feature, all) {
28
+ const s = ctx.style;
29
+ const shown = feature.findings.filter((f) => all || f.status === 'open');
30
+ const open = feature.findings.filter((f) => f.status === 'open');
31
+ ctx.out('', `${s.bold(feature.slug)} ${s.gray(`(${feature.key})`)} ${open.length ? s.yellow(`${open.length} open`) : s.green('no open findings')}${all ? s.gray(`, ${feature.findings.length} in all`) : ''}`);
32
+ const color = { blocker: s.red, major: s.yellow, minor: s.gray };
33
+ for (const severity of SEVERITIES) {
34
+ const group = shown.filter((f) => f.severity === severity).sort((a, b) => order(a) - order(b));
35
+ if (!group.length)
36
+ continue;
37
+ ctx.out('', ` ${color[severity](s.bold(severity))} ${s.gray(`(${group.length})`)}`);
38
+ for (const f of group) {
39
+ const status = f.status === 'open' ? '' : ` ${s.gray(`[${f.status}${f.status === 'accepted' ? `: ${feature.approvals.accepted.find((a) => a.finding === f.id)?.reason ?? ''}` : ''}]`)}`;
40
+ ctx.out(` ${pad(s.bold(f.id), f.id, 10)}${s.gray(f.step)}${f.file ? s.gray(` ${f.file}${f.line ? `:${f.line}` : ''}`) : ''}${status}`);
41
+ for (const line of wrap(f.issue, WIDTH))
42
+ ctx.out(` ${' '.repeat(10)}${line}`);
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * agjan findings [--all] [--feature <slug>]: the findings still open, by severity (every
48
+ * finding with its status with --all), for the feature(s) this branch changed.
49
+ */
50
+ export function run(ctx, argv) {
51
+ const { values } = parseArgs({ args: argv, options: { all: { type: 'boolean' }, feature: { type: 'string' } } });
52
+ const root = ctx.root;
53
+ if (values.feature && !listFeatures(root).includes(values.feature))
54
+ throw new UsageError(`no feature '${values.feature}'`);
55
+ const slugs = values.feature ? [values.feature] : changedFeatures(root, ctx.config);
56
+ for (const line of markLine(ctx.style, ctx.kit, 'findings'))
57
+ ctx.out(line);
58
+ if (slugs.length === 0) {
59
+ ctx.out('no changed feature on this branch (pass --feature <slug>; agjan status --all lists every feature)');
60
+ return 0;
61
+ }
62
+ for (const slug of slugs)
63
+ describe(ctx, loadFeature(root, slug), Boolean(values.all));
64
+ const s = ctx.style;
65
+ ctx.out('', s.gray('Only an open blocker stops a gate. For each finding: ask the agent for a fix, accept it with'), s.gray('npx agjan accept <id> --reason "<why>" (in your terminal), or leave it open as a follow-up.'));
66
+ return 0;
67
+ }
@@ -92,7 +92,9 @@ async function commitRecord(ctx, feature, values, proposal) {
92
92
  return ctx.out(`${s.green('committed')} ${s.gray(sha)} ${message}`);
93
93
  }
94
94
  function reviewLine(ctx, review) {
95
- const notes = review.findings?.length ? `, ${review.findings.length} finding(s)` : '';
95
+ // The findings raised in this one round, not the ones open in all: the next line counts those.
96
+ const n = review.findings?.length ?? 0;
97
+ const notes = n ? `, raised ${n} finding${n === 1 ? '' : 's'}` : '';
96
98
  return `review ${review.id} ${review.step} round ${review.round}: ${tone(ctx.style, review.verdict)}${notes}`;
97
99
  }
98
100
  function specGateProblems(feature) {
@@ -263,6 +265,17 @@ async function approveCombined(ctx, feature, values) {
263
265
  await commitRecord(ctx, feature, values, proposedMessage(feature, 'spec design') || `${feature.key}: approve spec and design`);
264
266
  return 0;
265
267
  }
268
+ /** What accepting leaves open, so it is not accepted blind: counts by severity and where the list is. */
269
+ export function openFindingsLine(feature) {
270
+ const open = feature.findings.filter((f) => f.status === 'open');
271
+ if (!open.length)
272
+ return 'findings none open';
273
+ const counts = ['blocker', 'major', 'minor'].flatMap((s) => {
274
+ const n = open.filter((f) => f.severity === s).length;
275
+ return n ? [`${n} ${s}`] : [];
276
+ });
277
+ return `findings ${open.length} open (${counts.join(', ')}): npx agjan findings lists them`;
278
+ }
266
279
  async function approveVerify(ctx, feature, values) {
267
280
  const record = ready('accept the feature', gateReadiness(ctx, feature, 'verify'));
268
281
  const manual = feature.spec.parsed.acs.filter((ac) => ac.verification === 'manual').map((ac) => ac.id);
@@ -271,6 +284,7 @@ async function approveVerify(ctx, feature, values) {
271
284
  `change ${short(record.tree_hash)} (the files the verify review saw)`,
272
285
  reviewLine(ctx, record),
273
286
  manual.length ? `manual ${manual.join(', ')}: confirm that you tried them` : 'manual none (every AC has an automated test)',
287
+ openFindingsLine(feature),
274
288
  ];
275
289
  if (!(await confirmGate(ctx, feature, `accept the feature${previous}: implemented and verified`, lines)))
276
290
  return 1;
@@ -189,13 +189,19 @@ function nextSteps(ctx, hosts, left) {
189
189
  ? `Commit the setup: ${s.cyan(`git add -A && git commit -m "${SETUP_COMMIT}"`)}`
190
190
  : `Commit the setup on a branch of its own and merge it with a PR: ${s.cyan(`git switch -c ${SETUP_BRANCH} && git add -A && git commit -m "${SETUP_COMMIT}"`)}`);
191
191
  }
192
- if (hosts.includes('claude-code')) {
192
+ // The doctor checks the setup, so it runs before the host is started. With Claude Code it
193
+ // also checks that the folder is trusted there, which only the host can do: it runs last.
194
+ const claude = hosts.includes('claude-code');
195
+ if (!claude)
196
+ steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
197
+ if (claude) {
193
198
  steps.push("Open this folder once in Claude Code and trust it: the reviewer's agjan tools load only in trusted folders.");
194
199
  }
195
200
  if (hosts.includes('copilot')) {
196
201
  steps.push(`Start ${s.cyan('copilot')} in this folder and trust it.`);
197
202
  }
198
- steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
203
+ if (claude)
204
+ steps.push(`Run: ${s.cyan('npx agjan doctor')} ${s.gray('(it also checks that Claude Code trusts the folder)')}`);
199
205
  return ['', s.bold('Next steps:'), ...steps.map((text, i) => ` ${i + 1}. ${text}`)];
200
206
  }
201
207
  /**
@@ -103,7 +103,7 @@ function nextInBuild(ctx, feature, progress) {
103
103
  function findingCount(ctx, open) {
104
104
  const blockers = open.filter((f) => f.severity === 'blocker').length;
105
105
  const text = `${open.length} open, ${blockers} blocker(s)`;
106
- return blockers ? ctx.style.red(text) : ctx.style.yellow(text);
106
+ return `${blockers ? ctx.style.red(text) : ctx.style.yellow(text)} ${ctx.style.gray('(npx agjan findings lists them)')}`;
107
107
  }
108
108
  /** A fix or a map run: its checks, its review, and the next step. */
109
109
  function describeRecord(ctx, unit, onBase = false) {
package/dist/review.js CHANGED
@@ -132,7 +132,7 @@ function reviewHistory(feature) {
132
132
  if (feature.reviews.records.length === 0)
133
133
  return '(none)';
134
134
  return feature.reviews.records
135
- .map((r) => `- ${r.id} ${r.step} round ${r.round}: ${r.verdict}, ${r.findings?.length ?? 0} finding(s)`)
135
+ .map((r) => `- ${r.id} ${r.step} round ${r.round}: ${r.verdict}, raised ${r.findings?.length ?? 0} finding(s)`)
136
136
  .join('\n');
137
137
  }
138
138
  function openFindings(feature, steps) {
package/docs/guide.md CHANGED
@@ -124,6 +124,7 @@ your terminal:
124
124
  ```sh
125
125
  npx agjan status # what is ready and what blocks it
126
126
  npx agjan review show # the reviews and findings
127
+ npx agjan findings # only the open findings, by severity
127
128
  npx agjan review report # the latest round, short: verdict, findings, what happens next
128
129
  npx agjan approve spec design # light mode; full mode: approve spec, later approve design
129
130
  ```
@@ -132,6 +133,17 @@ After every review the agent shows you that short report in its message: the ver
132
133
  findings by severity (🔴 blocker, 🟠 major, 🟡 minor), what the round resolved, the rounds
133
134
  of the loop so far (`LVR-R1 ⛔ → LVR-R2 ✅`) and what the agent does next.
134
135
 
136
+ **Which findings stay open.** `npx agjan findings` lists the open ones by severity (and `approve verify` shows how many are open before you type the key), with the
137
+ file and what is wrong (`--all` adds resolved and accepted ones). Only an open blocker stops a
138
+ gate; majors and minors do not.
139
+ Minors are left open on purpose (fixing them would need another review round, which can
140
+ raise more). To keep the list honest: a reviewer does not file a finding that an open one
141
+ already covers; severity follows the harm (a contradiction of an AC, or a requirement no AC
142
+ covers, is never minor); and before the final review `/agjan-verify` fixes the majors it
143
+ agrees with, settles each "Unverified" finding with one command or test, and leaves the
144
+ other minors for the PR summary. A major it did not fix, and the reason, is in its final
145
+ message.
146
+
135
147
  `approve` shows a summary and asks you to type the feature key. It refuses when the
136
148
  latest review did not see the current files or has open blockers. After recording the
137
149
  approval it offers to commit the feature folder, with the message the agent proposed
@@ -328,6 +340,7 @@ Run `npx agjan --help` for the full list.
328
340
  | `check [--staged \| --ci] [--base <ref>]` | anyone, hook, CI | enforce the rules |
329
341
  | `lint [--all]` | anyone | the area linters (UI5 linter for Fiori apps) on the changed files |
330
342
  | `ui-test [--require]` | anyone | the Playwright UI tests where Chromium can start; otherwise the reason, and a skip |
343
+ | `findings [--all] [--feature <slug>]` | anyone | the open findings by severity, each with file and issue |
331
344
  | `review show [--step <step>]` | anyone | review records, or the material a reviewer gets |
332
345
  | `review report [--step <step>]` | anyone | the latest review round as a short report (agents show it after each review) |
333
346
  | `pr-summary`, `report` | anyone | PR description; `report.md` with time and tokens |
@@ -78,6 +78,26 @@ them and records the result. Its tests stay in the project as regression tests.
78
78
  The final review (next section) waits until QA has passed, and so do `check --ci` and
79
79
  the acceptance.
80
80
 
81
+ ## 5b. Settle what is open
82
+
83
+ Before the final review, read the open findings of all steps (`npx agjan status`, `npx agjan
84
+ review show`) and clear what you can within the approved task paths, so the user gets a short
85
+ list:
86
+
87
+ 1. **Majors:** fix those you agree with, in new commits with the subject of the task they
88
+ belong to (`<KEY>-<id>: …`); a fix makes that area's build review due again, so do it before
89
+ the final review. For one you disagree with, keep your reason for the final message.
90
+ 2. **"Unverified:" findings** about the app's behavior: settle each with one command or test,
91
+ for example a request with `curl`, a test that does what the finding doubts (a `PATCH` of a
92
+ draft, a call as the user the rule excludes), or the UI test run. Add a test to the area's
93
+ tests when it is worth keeping. The final review then lists the finding in `resolves` when
94
+ it is fixed or disproved. Do not remove working code on the strength of an unverified claim.
95
+ 3. **Findings about the spec or the design** are not fixed here. Mention the ones that matter
96
+ in the final message; a change to the spec is a revision (`/agjan-spec`, section 7).
97
+ 4. **Other minors** stay open: they go to the user in the PR summary. Do not chase style.
98
+
99
+ Do not start extra review rounds for minors.
100
+
81
101
  ## 6. Final review (step `verify`, deep)
82
102
 
83
103
  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`):
@@ -102,7 +122,8 @@ Any change after the final review makes it stale; review again after the last ch
102
122
  **verbatim, in a code block**: it says that the feature is verified, what was met, and
103
123
  the user's turn: try it, check the manual ACs by hand, and accept it in their terminal
104
124
  with `npx agjan approve verify`. After it, add only what the user must know that it does
105
- not say (for example what you could not check yourself). Then stop: never run
125
+ not say (for example what you could not check yourself, a major you left open and why, or
126
+ an "Unverified" finding you could not settle). Then stop: never run
106
127
  `agjan approve` yourself, also in auto mode: the acceptance is always the user's.
107
128
  Opening a pull request is optional, done only when the user
108
129
  asks (its description is the output of `npx agjan pr-summary`).
@@ -70,6 +70,13 @@ service LeaveService {
70
70
  the project's `@sap/cds` version with `search_docs`). Validation that must hold for
71
71
  saved data therefore belongs in `before CREATE/UPDATE` handlers of the active entity, or
72
72
  better in annotations; `SAVE` on `Entity.drafts` runs before the activation.
73
+ - **Draft authorization is derived; grant nothing for draft events.** The grants of the
74
+ active entity decide: `CREATE` lets a user create a new draft and then edit (`PATCH`),
75
+ discard and activate it; `UPDATE` lets a user open an active row for editing (`EDIT`) and
76
+ then edit, discard and activate that draft. Only the user who created a draft can edit
77
+ it. So an entity that users only create through the app needs `READ` and `CREATE`, and
78
+ `PATCH` on the draft is allowed by them: do not add `UPDATE` "for the draft", and do not
79
+ treat a `403` on a draft `PATCH` as likely.
73
80
  - `SELECT.from(Entity)` reads active data, `SELECT.from(Entity.drafts)` draft data. Do
74
81
  not filter on draft properties by hand.
75
82
  - Introducing drafts changes how handlers run; it is a design decision.
@@ -62,7 +62,9 @@ describe('LeaveService', () => {
62
62
  saves it, and that is where `@assert`, `@mandatory` and `before CREATE` handlers answer
63
63
  400. Test the activation, not only the first `POST`. Active rows have the key
64
64
  `(ID=…,IsActiveEntity=true)`; a list read returns drafts too unless you filter
65
- `IsActiveEntity eq true`.
65
+ `IsActiveEntity eq true`. Between the two, `PATCH` a field of the draft as the same user:
66
+ that is the call the Fiori form makes while editing, and it shows the authorization and
67
+ the draft-time checks the user will meet.
66
68
  - Every `where` of an `@restrict` gets a test with a user of the role whom the condition
67
69
  excludes (here `manager2`, a manager of another team), for every operation it guards,
68
70
  including bound actions.
@@ -125,6 +125,10 @@ service LeaveService {
125
125
  }
126
126
  ```
127
127
 
128
+ - In the example, `employee` can create a request and then edit it as a draft with only
129
+ `READ` and `CREATE`: draft events are authorized from the grants of the active entity
130
+ (`CREATE` covers creating, editing, discarding and activating the user's own new draft;
131
+ `UPDATE` would cover editing existing active rows). See `services.md`, Drafts.
128
132
  - Project configuration goes into the `cds` section of `package.json`, where `cds init`
129
133
  and `cds add` put it; use `.cdsrc.json` only if the project already uses it. Personal,
130
134
  local settings belong in `.cdsrc-private.json`, which is not committed.
@@ -189,6 +189,9 @@ actions (approve, reject).
189
189
  (`@odata.draft.enabled` on `LeaveRequests` in `srv/leave-service.cds`), or in the app's
190
190
  annotations file (`annotate service.Incidents with @odata.draft.enabled;`, as the
191
191
  incidents app does).
192
+ - Authorization needs nothing extra for the draft: the user who may `CREATE` the entity may
193
+ edit their new draft, and `UPDATE` covers editing existing rows (cap-developer
194
+ `services.md`, Drafts).
192
195
  - What changes: keys include `IsActiveEntity`; `POST` creates a draft and
193
196
  `draftActivate` saves it, which is when `@assert`, `@mandatory` and `before CREATE`
194
197
  handlers run. `@restrict` grants (`CREATE`, `UPDATE`) apply to the draft events too.
@@ -35,11 +35,30 @@ Severity:
35
35
  - `major`: a real problem that should be fixed, but does not make the result wrong.
36
36
  - `minor`: style, wording, small improvements.
37
37
 
38
+ Severity follows the harm, not the wish for a pass. These are never `minor`:
39
+
40
+ - The document or the code contradicts an AC or a rule the spec states (for example another
41
+ status code, text or rule than the AC says): at least `major`, and `blocker` when the AC
42
+ cannot be met as written.
43
+ - A requirement the spec states (an authorization rule, a validation, a limit) that no AC
44
+ covers, or an AC that no test exercises: `major`.
45
+
46
+ Do not lower a real defect to `minor` to let the step pass.
47
+
38
48
  Each finding states the file and line where possible (with the repository paths the
39
49
  review context uses), the issue in one or two sentences, and a concrete suggestion. In
40
50
  `resolves`, list the ids of earlier open findings that the current material has fixed;
41
51
  only those.
42
52
 
53
+ ## Open findings are not filed again
54
+
55
+ The review context lists the findings that are still open under "Open findings". Read it
56
+ before you write yours. If an open finding already covers an issue (the same cause, or the
57
+ same place), do not file it again, not even when a later step shows it from another side:
58
+ it stays open until the material fixes it, and then you list its id in `resolves`. File a
59
+ new finding only for what no open finding covers. Repeating one only makes the list longer
60
+ and hides what is new.
61
+
43
62
  ## Technical claims need evidence
44
63
 
45
64
  A finding that says an API, annotation, configuration or syntax is wrong must name its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agjan",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Agentic engineering harness for AI coding agents: role agents, human approval gates, independent review and CI-enforced checks. SAP BTP first.",
5
5
  "keywords": [
6
6
  "agentic-engineering",