agjan 0.0.6 → 0.0.7
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/docs/guide.md +20 -7
- package/kit/hooks/guard.mjs +124 -15
- package/kit/skills/agjan-verify/SKILL.md +9 -6
- package/kit/skills/cap-developer/SKILL.md +4 -0
- package/kit/skills/cap-developer/references/handlers.md +61 -4
- package/kit/skills/cap-developer/references/modeling.md +33 -1
- package/kit/skills/cap-developer/references/project-setup.md +87 -0
- package/kit/skills/cap-developer/references/services.md +32 -1
- package/kit/skills/cap-developer/references/testing.md +46 -14
- package/kit/skills/cap-developer/references/validation-security.md +66 -2
- package/kit/skills/fiori-developer/SKILL.md +1 -0
- package/kit/skills/fiori-developer/references/app-setup.md +127 -0
- package/kit/skills/fiori-developer/references/elements.md +109 -11
- package/kit/skills/fiori-developer/references/ui5-basics.md +3 -2
- package/kit/templates/progress.html +14 -9
- package/kit/templates/project.md +5 -0
- package/package.json +1 -1
- package/src/adapters/claude-code.mjs +16 -12
- package/src/commands/setup.mjs +116 -23
- package/src/commands/status.mjs +36 -10
- package/src/plan.mjs +8 -4
- package/src/progress-view.mjs +32 -11
- package/src/review.mjs +1 -1
- package/src/terminal.mjs +5 -3
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Input validation and authorization
|
|
2
2
|
|
|
3
3
|
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
-
MCP server on 2026-10-17
|
|
4
|
+
MCP server on 2026-10-17, with patterns from the CAP team's agent skills (`capire/skills`)
|
|
5
|
+
and the reference apps `capire/bookshop` and `capire/incidents-app` (Apache-2.0); the
|
|
6
|
+
examples were checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated; check details
|
|
7
|
+
with `search_docs`.
|
|
5
8
|
|
|
6
9
|
## Validation with annotations
|
|
7
10
|
|
|
@@ -22,6 +25,48 @@ handlers.
|
|
|
22
25
|
`@assert.integrity`. A target created in the same deep insert is not found.
|
|
23
26
|
- `@readonly` on an element: the client cannot set it (and Fiori shows it read-only).
|
|
24
27
|
|
|
28
|
+
## Rules across fields: `@assert` with an expression
|
|
29
|
+
|
|
30
|
+
`@assert: (case when <violation> then '<MESSAGE_KEY>' end)` is evaluated per row; a
|
|
31
|
+
non-null result rejects the request with 400, the message from
|
|
32
|
+
`_i18n/messages.properties` under that key, and the element as `target` (Fiori shows it at
|
|
33
|
+
the field). It replaces most "I need a handler" validations. Put constraints into a file
|
|
34
|
+
of their own next to the service (`srv/<name>-constraints.cds`). Checked with
|
|
35
|
+
`@sap/cds` 10.1:
|
|
36
|
+
|
|
37
|
+
<!-- checked: srv/leave-constraints.cds -->
|
|
38
|
+
```cds
|
|
39
|
+
using { LeaveService } from './leave-service';
|
|
40
|
+
|
|
41
|
+
annotate LeaveService.LeaveRequests with {
|
|
42
|
+
endDate @assert: (case when endDate < startDate then 'ASSERT_END_BEFORE_START' end);
|
|
43
|
+
type @assert: (case when not exists type then 'ASSERT_TYPE_UNKNOWN' end);
|
|
44
|
+
status @readonly;
|
|
45
|
+
reason @readonly;
|
|
46
|
+
employee @readonly;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<!-- checked: _i18n/messages.properties -->
|
|
51
|
+
```properties
|
|
52
|
+
# _i18n/messages.properties
|
|
53
|
+
ASSERT_END_BEFORE_START=The end date must not be before the start date.
|
|
54
|
+
ASSERT_TYPE_UNKNOWN=This leave type does not exist.
|
|
55
|
+
ASSERT_OVERLAP=You already have a request in this period.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- Prefer `@assert: (case when not exists <assoc> …)` to `@assert.target`: it gives a
|
|
59
|
+
specific message.
|
|
60
|
+
- Rules across rows (no overlapping requests, one open order per customer) go into a
|
|
61
|
+
`before` handler that queries the other rows (handlers.md), with a message key from the
|
|
62
|
+
same file. Never add a helper association to an exposed entity to reach other rows in
|
|
63
|
+
an `@assert`: clients can `$expand` it past `@restrict`.
|
|
64
|
+
- In an `@assert` on a service entity, address foreign keys through the association
|
|
65
|
+
(`employee.userId`), not as `employee_userId`.
|
|
66
|
+
- The rule is checked after `before` handlers: a field a handler fills (for example the
|
|
67
|
+
current user) is already set.
|
|
68
|
+
- Messages from annotations take no arguments; a `{0}` in the text stays literal.
|
|
69
|
+
|
|
25
70
|
Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`,
|
|
26
71
|
`ASSERT_FORMAT`, `ASSERT_TARGET`. Project-specific texts go into
|
|
27
72
|
`_i18n/messages_<locale>.properties` under the same keys.
|
|
@@ -48,9 +93,28 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
|
|
|
48
93
|
collections, only simple comparisons of user attributes with literals
|
|
49
94
|
(`$user.level >= 2`) can be checked.
|
|
50
95
|
- `$metadata` does not apply `@restrict`; do not rely on hiding entities there.
|
|
96
|
+
- Responses: no or wrong login 401; logged in without a matching role 403; a `where`
|
|
97
|
+
condition that excludes a row makes it invisible (404 for a single read).
|
|
98
|
+
- Example with two roles, checked with `@sap/cds` 10.1 (an employee sees and creates own
|
|
99
|
+
requests; a manager reads and decides the team's):
|
|
100
|
+
|
|
101
|
+
<!-- checked: srv/leave-service.cds -->
|
|
102
|
+
```cds
|
|
103
|
+
@restrict: [
|
|
104
|
+
{ grant: ['READ', 'CREATE'], to: 'employee', where: 'employee_userId = $user' },
|
|
105
|
+
{ grant: ['READ', 'approve', 'reject'], to: 'manager', where: 'employee.team.manager = $user' }
|
|
106
|
+
]
|
|
107
|
+
entity LeaveRequests as projection on my.LeaveRequests { … };
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Project configuration goes into the `cds` section of `package.json`, where `cds init`
|
|
111
|
+
and `cds add` put it; use `.cdsrc.json` only if the project already uses it. Personal,
|
|
112
|
+
local settings belong in `.cdsrc-private.json`, which is not committed.
|
|
51
113
|
- Users for tests and local runs (`auth` of kind `mocked` with `users`) belong in a
|
|
52
114
|
profile: `cds.requires["[development]"].auth` in `package.json` (`cds.test` runs in it
|
|
53
|
-
too).
|
|
115
|
+
too). Name them after their role, with the name as password (`employee`, `manager`, a
|
|
116
|
+
role-less `nobody`; `employee2` for a second one), so anyone can guess how to log in,
|
|
117
|
+
and list them under "Run locally" in `docs/agjan/project.md`. Without the profile they also apply in production, where anyone could log in
|
|
54
118
|
with those passwords. Check: `NODE_ENV=production npx cds env get requires.auth.kind`
|
|
55
119
|
must not print `mocked` or `dummy`.
|
|
56
120
|
- Name roles after the spec's business roles; the same roles go into
|
|
@@ -49,6 +49,7 @@ then building blocks or custom sections and columns, and controller extensions l
|
|
|
49
49
|
| The task touches | Read |
|
|
50
50
|
|---|---|
|
|
51
51
|
| any UI5 code, views, i18n, `index.html`, CAP integration | `references/ui5-basics.md` |
|
|
52
|
+
| a new elements app: its files, `manifest.json`, `index.html`, serving and checking it | `references/app-setup.md` |
|
|
52
53
|
| an elements app (annotations, pages, value help, actions, side effects) | `references/elements.md` |
|
|
53
54
|
| a freestyle TypeScript app | `references/freestyle-ts.md` |
|
|
54
55
|
| UI tests | `references/testing.md` |
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# A Fiori elements app inside a CAP project
|
|
2
|
+
|
|
3
|
+
Distilled from the reference apps `capire/incidents-app` and `capire/bookshop` (Apache-2.0)
|
|
4
|
+
and the UI5 MCP server's guidelines (Apache-2.0). The files below were checked on
|
|
5
|
+
2026-10-18: `run_manifest_validation` valid, `run_ui5_linter` without findings, and the app
|
|
6
|
+
served by `cds watch` and used in a browser. Rules restated.
|
|
7
|
+
|
|
8
|
+
To create an app, the Fiori MCP server's generator (or SAP Fiori tools) can produce it;
|
|
9
|
+
these are the files it must end up with, and the minimum to write by hand.
|
|
10
|
+
|
|
11
|
+
## Files
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
app/
|
|
15
|
+
services.cds using from './requests/annotations';
|
|
16
|
+
requests/
|
|
17
|
+
annotations.cds UI annotations (references/elements.md)
|
|
18
|
+
ui5.yaml specVersion "4.0", name leaves.requests, type application
|
|
19
|
+
webapp/
|
|
20
|
+
manifest.json
|
|
21
|
+
Component.js
|
|
22
|
+
index.html
|
|
23
|
+
i18n/i18n.properties appTitle=Leave requests
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`cds watch` serves it at `http://localhost:4004/requests/webapp/index.html` (the folder
|
|
27
|
+
name under `app/`, then `webapp/index.html`; there is no default file).
|
|
28
|
+
|
|
29
|
+
## manifest.json (Manifest Version 2)
|
|
30
|
+
|
|
31
|
+
<!-- checked: app/requests/webapp/manifest.json -->
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"_version": "2.0.0",
|
|
35
|
+
"sap.app": {
|
|
36
|
+
"id": "leaves.requests",
|
|
37
|
+
"type": "application",
|
|
38
|
+
"i18n": "i18n/i18n.properties",
|
|
39
|
+
"applicationVersion": { "version": "1.0.0" },
|
|
40
|
+
"title": "{{appTitle}}",
|
|
41
|
+
"dataSources": {
|
|
42
|
+
"mainService": { "uri": "/odata/v4/leave/", "type": "OData", "settings": { "odataVersion": "4.0" } }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"sap.ui": { "technology": "UI5", "deviceTypes": { "desktop": true, "tablet": true, "phone": true } },
|
|
46
|
+
"sap.ui5": {
|
|
47
|
+
"flexEnabled": true,
|
|
48
|
+
"dependencies": { "minUI5Version": "1.136.0", "libs": { "sap.m": {}, "sap.ui.core": {}, "sap.fe.templates": {} } },
|
|
49
|
+
"contentDensities": { "compact": true, "cozy": true },
|
|
50
|
+
"models": {
|
|
51
|
+
"i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "leaves.requests.i18n.i18n" } },
|
|
52
|
+
"": { "dataSource": "mainService", "preload": true, "settings": { "operationMode": "Server", "autoExpandSelect": true, "earlyRequests": true } }
|
|
53
|
+
},
|
|
54
|
+
"routing": {
|
|
55
|
+
"routes": [
|
|
56
|
+
{ "pattern": ":?query:", "name": "LeaveRequestsList", "target": "LeaveRequestsList" },
|
|
57
|
+
{ "pattern": "LeaveRequests({key}):?query:", "name": "LeaveRequestsObjectPage", "target": "LeaveRequestsObjectPage" }
|
|
58
|
+
],
|
|
59
|
+
"targets": {
|
|
60
|
+
"LeaveRequestsList": {
|
|
61
|
+
"type": "Component", "id": "LeaveRequestsList", "name": "sap.fe.templates.ListReport",
|
|
62
|
+
"options": { "settings": { "contextPath": "/LeaveRequests", "variantManagement": "Page", "initialLoad": "Enabled",
|
|
63
|
+
"navigation": { "LeaveRequests": { "detail": { "route": "LeaveRequestsObjectPage" } } } } }
|
|
64
|
+
},
|
|
65
|
+
"LeaveRequestsObjectPage": {
|
|
66
|
+
"type": "Component", "id": "LeaveRequestsObjectPage", "name": "sap.fe.templates.ObjectPage",
|
|
67
|
+
"options": { "settings": { "contextPath": "/LeaveRequests", "editableHeaderContent": false } }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `_version` 2.0.0 with `minUI5Version` 1.136.0 or later: the linter rejects older
|
|
76
|
+
manifests. Do not use the deprecated `synchronizationMode` model setting.
|
|
77
|
+
- `dataSources.mainService.uri` is the service's path (`/odata/v4/<service path>/`).
|
|
78
|
+
- `contextPath` names the entity set; the object page route's pattern uses its name.
|
|
79
|
+
|
|
80
|
+
## Component.js
|
|
81
|
+
|
|
82
|
+
<!-- checked: app/requests/webapp/Component.js -->
|
|
83
|
+
```js
|
|
84
|
+
sap.ui.define(['sap/fe/core/AppComponent'], (AppComponent) => AppComponent.extend('leaves.requests.Component', {
|
|
85
|
+
metadata: { manifest: 'json' }
|
|
86
|
+
}));
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## index.html
|
|
90
|
+
|
|
91
|
+
<!-- checked: app/requests/webapp/index.html -->
|
|
92
|
+
```html
|
|
93
|
+
<!DOCTYPE html>
|
|
94
|
+
<html lang="en">
|
|
95
|
+
<head>
|
|
96
|
+
<meta charset="UTF-8">
|
|
97
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
98
|
+
<title>Leave requests</title>
|
|
99
|
+
<style>
|
|
100
|
+
html, body, body > div, #container, #container-uiarea { height: 100%; }
|
|
101
|
+
</style>
|
|
102
|
+
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
|
|
103
|
+
data-sap-ui-theme="sap_horizon"
|
|
104
|
+
data-sap-ui-resource-roots='{ "leaves.requests": "./" }'
|
|
105
|
+
data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"
|
|
106
|
+
data-sap-ui-compat-version="edge"
|
|
107
|
+
data-sap-ui-async="true"
|
|
108
|
+
data-sap-ui-frame-options="trusted"></script>
|
|
109
|
+
</head>
|
|
110
|
+
<body class="sapUiBody sapUiSizeCompact" id="content">
|
|
111
|
+
<div data-sap-ui-component data-name="leaves.requests" data-id="container" data-settings='{"id": "leaves.requests"}'></div>
|
|
112
|
+
</body>
|
|
113
|
+
</html>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- The full-height style is required: a Fiori elements app fills its parent and stays
|
|
117
|
+
invisible in a container of height 0.
|
|
118
|
+
- The linter requires `data-sap-ui-compat-version`.
|
|
119
|
+
- The CDN URL without a version loads the latest SAPUI5; pin a version
|
|
120
|
+
(`https://ui5.sap.com/1.136.7/resources/…`) when the project needs a fixed one.
|
|
121
|
+
|
|
122
|
+
## Check
|
|
123
|
+
|
|
124
|
+
1. `run_manifest_validation` on `webapp/manifest.json` and `run_ui5_linter` on the app
|
|
125
|
+
folder (UI5 MCP server): no findings.
|
|
126
|
+
2. `npx cds watch`, open the app as each role of the spec (a private window per user),
|
|
127
|
+
and try what the ACs describe, including buttons and messages.
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Distilled from the SAPUI5 and SAP Fiori tools documentation (`SAP-docs/sapui5`,
|
|
4
4
|
`SAP-docs/btp-fiori-tools`, CC-BY-4.0), retrieved through the Fiori MCP server
|
|
5
|
-
(`@sap-ux/fiori-mcp-server` 1.15.13) on 2026-10-17
|
|
6
|
-
|
|
5
|
+
(`@sap-ux/fiori-mcp-server` 1.15.13) on 2026-10-17, with patterns from the reference apps
|
|
6
|
+
`capire/incidents-app` and `capire/bookshop` and the SAP Fiori elements feature showcase
|
|
7
|
+
(Apache-2.0). The complete example below was compiled, linted and clicked through in a
|
|
8
|
+
browser with `@sap/cds` 10.1 and SAPUI5 1.14x on 2026-10-18. Rules restated; check details
|
|
9
|
+
and current syntax with `search_docs`.
|
|
7
10
|
|
|
8
11
|
## Where things go
|
|
9
12
|
|
|
@@ -39,8 +42,9 @@ current syntax with `search_docs`.
|
|
|
39
42
|
|
|
40
43
|
- An ID with a readable text, on the ID element:
|
|
41
44
|
`@Common.Text: customer.name` and `@Common.Text.@UI.TextArrangement: #TextOnly` (or
|
|
42
|
-
`#TextFirst`, `#TextLast`, `#TextSeparate`).
|
|
43
|
-
|
|
45
|
+
`#TextFirst`, `#TextLast`, `#TextSeparate`). CAP also accepts the shorthand
|
|
46
|
+
`@Common.TextArrangement: #TextOnly` and compiles it to the same nested annotation. The
|
|
47
|
+
older form with `$value` is deprecated in CAP.
|
|
44
48
|
- Value help: `@Common.ValueList` on the property, with `CollectionPath` (the value help
|
|
45
49
|
entity of the same service) and `Parameters` (`Common.ValueListParameterInOut` for the
|
|
46
50
|
key, `…DisplayOnly` for extra columns). For a short fixed list (dropdown), add
|
|
@@ -58,13 +62,8 @@ current syntax with `search_docs`.
|
|
|
58
62
|
page header). The action's authorization is the service's `@restrict`.
|
|
59
63
|
- Do not use determining actions (`Determining: true`) for new designs; they are
|
|
60
64
|
deprecated.
|
|
61
|
-
- Paths in annotations of a bound action start with its
|
|
62
|
-
|
|
63
|
-
`@Core.OperationAvailable: { $edmJson: { $Path: 'in/canApprove' } }`. Refresh after the
|
|
64
|
-
action: `@Common.SideEffects: { TargetProperties: ['in/status'] }` on the action (no
|
|
65
|
-
draft needed). Without the side effect, the page may keep showing the old values.
|
|
66
|
-
Paths without the prefix (`'status'`) are wrong here. (SAP Fiori elements feature
|
|
67
|
-
showcase, `cds.odata.bindingparameter.name: '_it'` with `TargetProperties: ['_it/*']`.)
|
|
65
|
+
- Paths in annotations of a bound action start with its binding parameter (`in/…`): see
|
|
66
|
+
"Paths in action annotations" below.
|
|
68
67
|
|
|
69
68
|
## Side effects of field changes (draft apps)
|
|
70
69
|
|
|
@@ -82,3 +81,102 @@ current syntax with `search_docs`.
|
|
|
82
81
|
- Do not override the framework's keyboard shortcuts.
|
|
83
82
|
- Prefer an annotation over a custom column wherever an annotation can show the value (for
|
|
84
83
|
performance and for personalization).
|
|
84
|
+
|
|
85
|
+
## Paths in action annotations: the binding parameter
|
|
86
|
+
|
|
87
|
+
Annotations of a bound action address the entity through its **binding parameter**, which
|
|
88
|
+
CAP names `in` (`@cds.odata.bindingparameter.name: '_it'` renames it). Paths without the
|
|
89
|
+
prefix are wrong here.
|
|
90
|
+
|
|
91
|
+
- `@Core.OperationAvailable: { $edmJson: { $Path: 'in/canDecide' } }` enables the button
|
|
92
|
+
per row (a Boolean element, for example a virtual one set in an after-READ handler).
|
|
93
|
+
- `@Common.SideEffects: { TargetProperties: ['in/status_code', 'in/canDecide'] }` refreshes
|
|
94
|
+
those fields after the action (no draft needed).
|
|
95
|
+
- **Checked in a browser:** with the side effect, the status shows the new value right
|
|
96
|
+
after the click and the button disables itself; **without it, the page keeps the old
|
|
97
|
+
status and the enabled button** until a reload. An action that changes data shown on the
|
|
98
|
+
page always gets a side effect.
|
|
99
|
+
|
|
100
|
+
## Hiding what the service forbids
|
|
101
|
+
|
|
102
|
+
The service decides (`@restrict`); the UI should not offer what fails anyway:
|
|
103
|
+
`@UI.DeleteHidden: true` and `@UI.CreateHidden: true` on the entity when no user of the
|
|
104
|
+
app may delete or create (Fiori shows Delete otherwise), path-based
|
|
105
|
+
(`@UI.DeleteHidden: { $edmJson: { $Path: 'isLocked' } }`) when it depends on the row.
|
|
106
|
+
|
|
107
|
+
## A complete example (checked)
|
|
108
|
+
|
|
109
|
+
`app/requests/annotations.cds` for the leave requests of `cap-developer`'s examples: list
|
|
110
|
+
report with filters and a colored status, object page with two sections, value helps as
|
|
111
|
+
dropdowns, Approve and Reject buttons enabled per row and refreshing the page.
|
|
112
|
+
|
|
113
|
+
<!-- checked: app/requests/annotations.cds -->
|
|
114
|
+
```cds
|
|
115
|
+
using { LeaveService as service } from '../../srv/leave-service';
|
|
116
|
+
|
|
117
|
+
annotate service.LeaveRequests with @(
|
|
118
|
+
UI.HeaderInfo : {
|
|
119
|
+
TypeName : '{i18n>LeaveRequest}',
|
|
120
|
+
TypeNamePlural : '{i18n>LeaveRequests}',
|
|
121
|
+
Title : { Value : employeeName },
|
|
122
|
+
Description : { Value : type.name },
|
|
123
|
+
},
|
|
124
|
+
UI.SelectionFields : [ status_code, type_code ],
|
|
125
|
+
UI.LineItem : [
|
|
126
|
+
{ Value : employeeName },
|
|
127
|
+
{ Value : type_code },
|
|
128
|
+
{ Value : startDate },
|
|
129
|
+
{ Value : endDate },
|
|
130
|
+
{ Value : days },
|
|
131
|
+
{ Value : status_code, Criticality : status.criticality },
|
|
132
|
+
],
|
|
133
|
+
UI.Identification : [
|
|
134
|
+
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.approve', Label : '{i18n>Approve}' },
|
|
135
|
+
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.reject', Label : '{i18n>Reject}' },
|
|
136
|
+
],
|
|
137
|
+
UI.Facets : [
|
|
138
|
+
{ $Type : 'UI.ReferenceFacet', ID : 'request', Label : '{i18n>Request}', Target : '@UI.FieldGroup#Request' },
|
|
139
|
+
{ $Type : 'UI.ReferenceFacet', ID : 'decision', Label : '{i18n>Decision}', Target : '@UI.FieldGroup#Decision' },
|
|
140
|
+
],
|
|
141
|
+
UI.FieldGroup #Request : { Data : [ { Value : type_code }, { Value : startDate }, { Value : endDate }, { Value : days }, { Value : comment } ] },
|
|
142
|
+
UI.FieldGroup #Decision : { Data : [ { Value : status_code, Criticality : status.criticality }, { Value : reason } ] },
|
|
143
|
+
UI.DeleteHidden : true,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
annotate service.LeaveRequests with {
|
|
147
|
+
employeeName @title : '{i18n>Employee}';
|
|
148
|
+
startDate @title : '{i18n>StartDate}';
|
|
149
|
+
endDate @title : '{i18n>EndDate}';
|
|
150
|
+
days @title : '{i18n>Days}';
|
|
151
|
+
comment @title : '{i18n>Comment}' @UI.MultiLineText;
|
|
152
|
+
reason @title : '{i18n>Reason}';
|
|
153
|
+
type @title : '{i18n>Type}' @Common.Text : type.name @Common.TextArrangement : #TextOnly
|
|
154
|
+
@Common.ValueListWithFixedValues
|
|
155
|
+
@Common.ValueList : { CollectionPath : 'LeaveTypes', Parameters : [
|
|
156
|
+
{ $Type : 'Common.ValueListParameterInOut', LocalDataProperty : type_code, ValueListProperty : 'code' },
|
|
157
|
+
{ $Type : 'Common.ValueListParameterDisplayOnly', ValueListProperty : 'name' },
|
|
158
|
+
]};
|
|
159
|
+
status @title : '{i18n>Status}' @Common.Text : status.name @Common.TextArrangement : #TextOnly
|
|
160
|
+
@Common.ValueListWithFixedValues
|
|
161
|
+
@Common.ValueList : { CollectionPath : 'Status', Parameters : [
|
|
162
|
+
{ $Type : 'Common.ValueListParameterInOut', LocalDataProperty : status_code, ValueListProperty : 'code' },
|
|
163
|
+
{ $Type : 'Common.ValueListParameterDisplayOnly', ValueListProperty : 'name' },
|
|
164
|
+
]};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
annotate service.LeaveRequests actions {
|
|
168
|
+
approve @Core.OperationAvailable : { $edmJson : { $Path : 'in/canDecide' } }
|
|
169
|
+
@Common.SideEffects : { TargetProperties : [ 'in/status_code', 'in/canDecide' ] };
|
|
170
|
+
reject @Core.OperationAvailable : { $edmJson : { $Path : 'in/canDecide' } }
|
|
171
|
+
@Common.SideEffects : { TargetProperties : [ 'in/status_code', 'in/reason', 'in/canDecide' ] };
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The labels (`{i18n>…}`) are in the project's `_i18n/i18n.properties`, not in the app's
|
|
176
|
+
`webapp/i18n`, which holds only the app's own texts (its title).
|
|
177
|
+
|
|
178
|
+
## Drafts
|
|
179
|
+
|
|
180
|
+
For apps that create and edit data, `annotate service.Incidents with @odata.draft.enabled;`
|
|
181
|
+
in the app's annotations file (the incidents app does so). Keys then include
|
|
182
|
+
`IsActiveEntity`; tests use the draft choreography (`cap-developer`, testing).
|
|
@@ -10,8 +10,9 @@ Distilled from the UI5 MCP server's development guidelines (`get_guidelines`,
|
|
|
10
10
|
`sap.ui.define` / `sap.ui.require` in JavaScript.
|
|
11
11
|
- In XML views, controls load from their tags; formatters and types used in bindings are
|
|
12
12
|
imported with `core:require="{ Currency: 'sap/ui/model/type/Currency' }"`.
|
|
13
|
-
- Start an app from `index.html` with `data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"
|
|
14
|
-
|
|
13
|
+
- Start an app from `index.html` with `data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"`,
|
|
14
|
+
`data-sap-ui-async="true"` and `data-sap-ui-compat-version="edge"` (the linter requires
|
|
15
|
+
it; a complete file is in `app-setup.md`). No inline `<script>` code: it breaks the content
|
|
15
16
|
security policy.
|
|
16
17
|
- Give the component container full height in `index.html`
|
|
17
18
|
(`html, body, body > div, #container, #container-uiarea { height: 100%; }`): a Fiori
|
|
@@ -70,9 +70,11 @@ section.detail { display: grid; gap: 22px; }
|
|
|
70
70
|
.headline h1 .key { font-family: var(--mono); font-weight: 500; font-size: 21px; color: var(--accent); }
|
|
71
71
|
.now-box { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
|
|
72
72
|
.now-box.you { background: var(--human-bg); border-color: color-mix(in srgb, var(--human) 35%, transparent); }
|
|
73
|
-
.now-box.merged { background: var(--pass-bg); }
|
|
73
|
+
.now-box.merged, .now-box.done { background: var(--pass-bg); }
|
|
74
|
+
.now-box ul { margin: 6px 0 0; padding-left: 18px; }
|
|
75
|
+
.now-box .opt { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
|
|
74
76
|
.now-box .ico { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--surface); display: grid; place-items: center; font-weight: 700; }
|
|
75
|
-
.now-box.you .ico { background: var(--human); } .now-box.merged .ico { background: var(--pass); }
|
|
77
|
+
.now-box.you .ico { background: var(--human); } .now-box.merged .ico, .now-box.done .ico { background: var(--pass); }
|
|
76
78
|
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
|
|
77
79
|
.stat { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; }
|
|
78
80
|
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
@@ -141,7 +143,7 @@ footer { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--lin
|
|
|
141
143
|
<div class="gen"><span id="generated"></span><span>refresh: <code>npx agjan progress --open</code></span></div>
|
|
142
144
|
</header>
|
|
143
145
|
<section aria-labelledby="ov">
|
|
144
|
-
<div class="panel-head" style="margin-bottom:10px"><h2 id="ov">Project</h2><span class="legend"><span><i style="background:var(--human)"></i>your turn</span><span><i style="background:var(--accent)"></i>agent working</span><span><i style="background:var(--pass)"></i>done</span></span></div>
|
|
146
|
+
<div class="panel-head" style="margin-bottom:10px"><h2 id="ov">Project</h2><span class="legend"><span><i style="background:var(--human)"></i>your turn</span><span><i style="background:var(--accent)"></i>agent working</span><span><i style="background:var(--pass)"></i>done or merged</span></span></div>
|
|
145
147
|
<div class="units" id="units"></div>
|
|
146
148
|
</section>
|
|
147
149
|
<section class="detail" id="detail" aria-live="polite"></section>
|
|
@@ -170,12 +172,14 @@ function severities(ids, f) {
|
|
|
170
172
|
function turnPill(u) {
|
|
171
173
|
if (u.turn === 'you') return `<span class="pill you"><span class="pulse">●</span> Your turn</span>`;
|
|
172
174
|
if (u.turn === 'merged') return `<span class="pill merged">✓ Merged</span>`;
|
|
175
|
+
if (u.turn === 'done') return `<span class="pill merged">✓ Done</span>`;
|
|
173
176
|
return `<span class="pill agent">Agent working</span>`;
|
|
174
177
|
}
|
|
175
178
|
function trackHtml(u) {
|
|
176
179
|
return u.stages.map((s, i) => {
|
|
177
|
-
const
|
|
178
|
-
const
|
|
180
|
+
const finished = u.turn === 'done' || u.turn === 'merged';
|
|
181
|
+
const cls = i < u.at || finished ? 'done' : i === u.at ? `now ${u.turn === 'you' ? 'you' : ''}` : '';
|
|
182
|
+
const markc = i < u.at || finished ? '✓' : i === u.at ? (u.turn === 'you' ? '!' : '…') : '';
|
|
179
183
|
return `<span class="st ${cls}"><span class="dot">${markc}</span>${esc(s)}</span>`;
|
|
180
184
|
}).join('<span class="bar"></span>');
|
|
181
185
|
}
|
|
@@ -192,7 +196,7 @@ function renderUnits() {
|
|
|
192
196
|
const kind = `${KIND[u.kind] || u.kind}${u.mode ? ` · ${u.mode} mode` : ''}${u.host ? ` · ${u.host}` : ''}`;
|
|
193
197
|
b.innerHTML = `<span class="name"><span class="key">${esc(u.key)}</span><span class="slug">${esc(u.slug)}</span><span class="kind">${esc(kind)}</span></span>
|
|
194
198
|
<span class="track">${trackHtml(u)}</span>
|
|
195
|
-
<span class="turn">${turnPill(u)}<span class="muted">${esc(u.turn === 'merged' ? `${u.stats.reviews} review${u.stats.reviews === 1 ? '' : 's'} · last ${dhm(u.last)}` : u.now)}</span></span>`;
|
|
199
|
+
<span class="turn">${turnPill(u)}<span class="muted">${esc(u.turn === 'merged' || u.turn === 'done' ? `${u.stats.reviews} review${u.stats.reviews === 1 ? '' : 's'} · last ${dhm(u.last)}` : u.now)}</span></span>`;
|
|
196
200
|
b.addEventListener('click', () => { selected = u.slug; filter = 'open'; focusReview = null; renderUnits(); renderDetail(); });
|
|
197
201
|
box.append(b);
|
|
198
202
|
}
|
|
@@ -282,8 +286,9 @@ function renderDetail() {
|
|
|
282
286
|
if (!u) { d.innerHTML = ''; return; }
|
|
283
287
|
const s = u.stats;
|
|
284
288
|
const count = (st) => Object.values(u.findings).filter((f) => st === 'all' || f.status === st).length;
|
|
285
|
-
const icon = u.turn === 'you' ? '!' : u.turn === 'merged' ? '✓' : '…';
|
|
286
|
-
const who = u.turn === 'you' ? 'Your turn' : u.turn === 'merged' ? 'Merged' : 'The agent is working';
|
|
289
|
+
const icon = u.turn === 'you' ? '!' : u.turn === 'merged' || u.turn === 'done' ? '✓' : '…';
|
|
290
|
+
const who = u.turn === 'you' ? 'Your turn' : u.turn === 'merged' ? 'Merged' : u.turn === 'done' ? 'Done' : 'The agent is working';
|
|
291
|
+
const optional = (u.optional || []).length ? `<span class="opt">Optional next steps</span><ul>${u.optional.map((o) => `<li>${esc(o)}</li>`).join('')}</ul>` : '';
|
|
287
292
|
const acs = u.acs ? `<div class="stat"><span class="v">${u.acs.passing ?? u.acs.withTests}/${u.acs.automated}</span><span class="l">ACs with ${u.acs.passing === null ? '' : 'passing '}tests${u.acs.manual.length ? ` · ${u.acs.manual.length} manual` : ''}</span></div>` : '';
|
|
288
293
|
const tasks = u.tasks.length ? `<div class="stat"><span class="v">${u.tasks.filter((t) => t.done).length}/${u.tasks.length}</span><span class="l">tasks committed</span></div>` : '';
|
|
289
294
|
const taskRows = u.tasks.map((t) => `<tr><td><span class="mono">${esc(t.id)}</span> <span class="muted">${esc(t.area)}</span><br>${esc(t.title)}<br><span class="muted">covers ${esc(t.covers.join(', '))}</span></td><td class="mono">${t.commits.map(esc).join('<br>') || '–'}</td><td class="mono">${t.reviews.map(esc).join(', ') || '–'}</td></tr>`).join('');
|
|
@@ -295,7 +300,7 @@ function renderDetail() {
|
|
|
295
300
|
d.innerHTML = `
|
|
296
301
|
<div class="headline"><h2>${esc(KIND[u.kind] || u.kind)}</h2><h1><span class="key">${esc(u.key)}</span>${esc(u.title)}</h1>
|
|
297
302
|
<span class="muted"><span class="mono">docs/agjan/${esc(u.slug)}/</span>${u.mode ? ` · ${esc(u.mode)} mode` : ''}${u.areas.length ? ` · areas ${esc(u.areas.join(', '))}` : ''} · started ${dhm(u.start)}</span></div>
|
|
298
|
-
<div class="now-box ${esc(u.turn)}" role="status"><span class="ico" aria-hidden="true">${icon}</span><span><b>${who}:</b> ${esc(u.now)}${u.acs && u.acs.manual.length ? ` · check by hand: ${esc(u.acs.manual.join(', '))}` : ''}</span></div>
|
|
303
|
+
<div class="now-box ${esc(u.turn)}" role="status"><span class="ico" aria-hidden="true">${icon}</span><span><b>${who}:</b> ${esc(u.now)}${u.turn !== 'done' && u.acs && u.acs.manual.length ? ` · check by hand: ${esc(u.acs.manual.join(', '))}` : ''}${optional}</span></div>
|
|
299
304
|
<div class="stats">
|
|
300
305
|
<div class="stat"><span class="v">${dur(s.activeMs)}</span><span class="l">agent work</span></div>
|
|
301
306
|
<div class="stat"><span class="v">${dur(s.waitingMs)}</span><span class="l">waiting for a human</span></div>
|
package/kit/templates/project.md
CHANGED
|
@@ -17,6 +17,11 @@ Each application: its folder, `app_type` (elements or freestyle), the service it
|
|
|
17
17
|
|
|
18
18
|
Runtime, BTP services, deployment targets.
|
|
19
19
|
|
|
20
|
+
## Run locally
|
|
21
|
+
|
|
22
|
+
How to start the application and try it: the command (for example `npx cds watch`),
|
|
23
|
+
the URLs of the apps, and the test users with their roles and passwords.
|
|
24
|
+
|
|
20
25
|
## Conventions
|
|
21
26
|
|
|
22
27
|
Naming, tests, lint.
|
package/package.json
CHANGED
|
@@ -43,20 +43,26 @@ export const GUARD_HOOK = {
|
|
|
43
43
|
const GUARD_PATH = 'node_modules/agjan/kit/hooks/guard.mjs';
|
|
44
44
|
|
|
45
45
|
/** A guard entry written by an earlier agjan version (for example the exec form). */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
/** The tools the guard sees: the shell, and the file edit tools (records, allow_edits). */
|
|
47
|
+
export const GUARD_MATCHER = 'Bash|Edit|Write|MultiEdit|NotebookEdit';
|
|
48
|
+
|
|
49
|
+
const isGuard = (hook) => JSON.stringify(hook).includes(GUARD_PATH);
|
|
50
|
+
const isCurrent = (hook) => JSON.stringify(hook) === JSON.stringify(GUARD_HOOK);
|
|
50
51
|
|
|
52
|
+
/** The current guard, in a group with the current matcher, and no other guard entry. */
|
|
51
53
|
function hasGuard(data) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
+
const groups = data.hooks?.PreToolUse ?? [];
|
|
55
|
+
const guards = groups.flatMap((group) => (group.hooks ?? []).filter(isGuard).map((hook) => ({ group, hook })));
|
|
56
|
+
return guards.length === 1 && isCurrent(guards[0].hook) && guards[0].group.matcher === GUARD_MATCHER;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
59
|
+
/**
|
|
60
|
+
* PreToolUse without any guard entry (earlier forms, or the current one under an older
|
|
61
|
+
* matcher such as 'Bash'); a group left empty is dropped. The caller adds the current one.
|
|
62
|
+
*/
|
|
63
|
+
function withoutGuards(groups) {
|
|
58
64
|
return groups
|
|
59
|
-
.map((group) => (group.hooks?.some(
|
|
65
|
+
.map((group) => (group.hooks?.some(isGuard) ? { ...group, hooks: group.hooks.filter((h) => !isGuard(h)) } : group))
|
|
60
66
|
.filter((group) => !Array.isArray(group.hooks) || group.hooks.length > 0);
|
|
61
67
|
}
|
|
62
68
|
|
|
@@ -106,9 +112,7 @@ export function plan(config, skills) {
|
|
|
106
112
|
const deny = [...new Set([...(data.permissions?.deny ?? []), ...DENY_RULES])];
|
|
107
113
|
let hooks = data.hooks ?? {};
|
|
108
114
|
if (!hasGuard(data)) {
|
|
109
|
-
|
|
110
|
-
const current = groups.some((g) => (g.hooks ?? []).some((h) => JSON.stringify(h) === JSON.stringify(GUARD_HOOK)));
|
|
111
|
-
hooks = { ...hooks, PreToolUse: current ? groups : [...groups, { matcher: 'Bash', hooks: [GUARD_HOOK] }] };
|
|
115
|
+
hooks = { ...hooks, PreToolUse: [...withoutGuards(hooks.PreToolUse ?? []), { matcher: GUARD_MATCHER, hooks: [GUARD_HOOK] }] };
|
|
112
116
|
}
|
|
113
117
|
return { ...data, permissions: { ...(data.permissions ?? {}), deny }, hooks };
|
|
114
118
|
},
|