agjan 0.0.30 → 0.0.31
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/README.md +3 -2
- package/dist/adapters/claude-code.js +39 -1
- package/dist/adapters/copilot.js +34 -1
- package/dist/baseline.js +3 -4
- package/dist/cli.js +5 -1
- package/dist/commands/areas.js +47 -0
- package/dist/commands/lint.js +2 -2
- package/dist/commands/map.js +6 -1
- package/dist/commands/review.js +3 -3
- package/dist/commands/setup.js +19 -16
- package/dist/commands/status.js +18 -2
- package/dist/commands/team.js +9 -3
- package/dist/commands/workflow.js +2 -1
- package/dist/config.js +55 -49
- package/dist/defaults-file.js +5 -3
- package/dist/mcp-config.js +1 -1
- package/dist/mcp.js +31 -3
- package/dist/review.js +7 -2
- package/dist/schema.js +4 -0
- package/dist/teams.js +117 -6
- package/dist/terminal.js +3 -0
- package/dist/validate.js +3 -3
- package/dist/worker.js +120 -0
- package/dist/workflow-view.js +15 -3
- package/docs/guide.md +58 -12
- package/docs/workflows-and-teams.md +43 -9
- package/kit/hooks/guard.mjs +55 -2
- package/kit/presets/generic.json +26 -0
- package/kit/presets/sap-btp.json +34 -0
- package/kit/skills/agjan-build/SKILL.md +9 -3
- package/kit/skills/agjan-design/SKILL.md +14 -11
- package/kit/skills/agjan-discover/SKILL.md +6 -0
- package/kit/skills/agjan-fix/SKILL.md +6 -0
- package/kit/skills/agjan-map/SKILL.md +14 -5
- package/kit/skills/agjan-spec/SKILL.md +6 -0
- package/kit/skills/agjan-worker/SKILL.md +36 -0
- package/kit/skills/agjan-worker/references/hand-off.md +32 -0
- package/kit/skills/backend-developer/SKILL.md +50 -0
- package/kit/skills/solution-architect/SKILL.md +54 -0
- package/kit/skills/technical-architect/SKILL.md +50 -0
- package/kit/skills/ui-developer/SKILL.md +48 -0
- package/kit/templates/project.md +3 -14
- package/package.json +1 -1
- package/schemas/config.defaults.json +8 -10
- package/schemas/config.schema.json +46 -35
- package/kit/domains/btp/domain.json +0 -29
package/dist/workflow-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BUILT_IN_TEAMS, allTeams, defaultTeam, mainRole, rolesFor, teamProblems } from './teams.js';
|
|
1
|
+
import { BUILT_IN_TEAMS, allTeams, defaultTeam, mainRole, roleDefinition, rolesFor, stageOwner, teamProblems } from './teams.js';
|
|
2
2
|
import { resolveBuild, resolveQa, resolveRounds, resolveTier, reviewerFor } from './review-policy.js';
|
|
3
3
|
import { baseOf, extrasOf } from './customization.js';
|
|
4
4
|
import { AgjanError } from './errors.js';
|
|
@@ -19,7 +19,7 @@ function trackStage(kind, stage, gate) {
|
|
|
19
19
|
function roleEntries(config, roles) {
|
|
20
20
|
return roles.map(({ role, skills, instructions }) => ({
|
|
21
21
|
role,
|
|
22
|
-
...(config
|
|
22
|
+
...(roleDefinition(config, role)?.description ? { description: roleDefinition(config, role).description } : {}),
|
|
23
23
|
skills,
|
|
24
24
|
...(instructions ? { instructions } : {}),
|
|
25
25
|
}));
|
|
@@ -47,7 +47,19 @@ export function resolveWorkflow(root, config, workflowName, options = {}) {
|
|
|
47
47
|
name: stage.name,
|
|
48
48
|
steps: stage.steps
|
|
49
49
|
.filter((step) => !step.mode || step.mode === mode)
|
|
50
|
-
.map((step) => {
|
|
50
|
+
.map((step, index, steps) => {
|
|
51
|
+
// The stage's writing step, when the team gives the stage to a role (decision 100).
|
|
52
|
+
const owner = step.actor === 'main' && steps.findIndex((x) => x.actor === 'main') === index ? stageOwner(config, team, stage.name) : null;
|
|
53
|
+
if (owner) {
|
|
54
|
+
return {
|
|
55
|
+
actor: step.actor,
|
|
56
|
+
agent: owner.worker ?? 'main agent',
|
|
57
|
+
does: step.does,
|
|
58
|
+
role: owner.role,
|
|
59
|
+
roles: roleEntries(config, [{ role: owner.role, skills: owner.skills, ...(owner.instructions ? { instructions: owner.instructions } : {}) }]),
|
|
60
|
+
...(owner.worker ? { handoff: true } : {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
51
63
|
const roles = team && step.actor !== 'human' ? rolesFor(config, team, kind, step.actor) : [];
|
|
52
64
|
const builtIn = step.actor === 'main' ? mainRole(kind) : step.actor === 'reviewer' ? 'reviewer' : step.actor === 'qa' ? 'tester' : null;
|
|
53
65
|
const resolved = {
|
package/docs/guide.md
CHANGED
|
@@ -43,7 +43,7 @@ Requirements: Node.js 22 or later, git, and Claude Code and/or GitHub Copilot.
|
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
45
|
npm install --global agjan
|
|
46
|
-
agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), whether to choose the reviewer models, then to commit the setup
|
|
46
|
+
agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), the preset (or: --preset generic|sap-btp), whether to choose the reviewer models, then to commit the setup
|
|
47
47
|
cd my-project # a command cannot move your shell: init prints this as its first next step
|
|
48
48
|
npx agjan doctor # from here on, npx runs the project's pinned agjan
|
|
49
49
|
```
|
|
@@ -410,10 +410,15 @@ and CI waits for your approval. To build the recommendation, start a feature wit
|
|
|
410
410
|
|
|
411
411
|
A team decides what knowledge the agents bring to a unit of work; the workflow decides the
|
|
412
412
|
steps, reviews and gates, and a team cannot remove any of them. [Workflows, teams, roles and
|
|
413
|
-
skills](workflows-and-teams.md) defines the terms.
|
|
413
|
+
skills](workflows-and-teams.md) defines the terms. Six teams are built in: three for any
|
|
414
|
+
stack, the defaults of a project without a `team` setting, and three for SAP BTP, the
|
|
415
|
+
defaults the `sap-btp` preset writes:
|
|
414
416
|
|
|
415
417
|
| Team | Workflows | Implementer or analyst | Reviewer | Tester |
|
|
416
418
|
|---|---|---|---|---|
|
|
419
|
+
| `delivery` | feature | technical-architect, backend-developer, ui-developer | solution-reviewer, technical-architect, backend-developer, ui-developer | qa-tester |
|
|
420
|
+
| `maintenance` | fix, map | backend-developer, ui-developer (fix); technical-architect and both developers (map) | solution-reviewer, backend-developer, ui-developer | - |
|
|
421
|
+
| `advisory` | discovery | solution-architect, technical-architect | solution-reviewer, solution-architect | - |
|
|
417
422
|
| `sap-delivery` | feature | cap-developer, fiori-developer, btp-architect | solution-reviewer and the three role skills | qa-tester |
|
|
418
423
|
| `sap-maintenance` | fix, map | cap-developer, fiori-developer (fix); the three role skills (map) | solution-reviewer, cap-developer, fiori-developer | - |
|
|
419
424
|
| `sap-discovery` | discovery | btp-architect, cap-developer, fiori-developer | solution-reviewer, btp-architect | - |
|
|
@@ -465,7 +470,43 @@ then works with the skills a team gives that role as well:
|
|
|
465
470
|
|
|
466
471
|
Here every review of a company-delivery unit works with both the reviewer's and the security
|
|
467
472
|
reviewer's skills, and the design review gets up to 5 rounds. A role adds knowledge to an agent's
|
|
468
|
-
existing steps; it
|
|
473
|
+
existing steps; it adds no step. Imported packages use the built-in roles.
|
|
474
|
+
|
|
475
|
+
**Roles that write a stage, and worker agents.** `stages` gives a stage (spec, design, build,
|
|
476
|
+
fix, map, proposal) to a role. A role of the main agent makes the main agent work as that role
|
|
477
|
+
there. A worker role runs as an agent of its own, with its own context and model: the built-in
|
|
478
|
+
`architect` (agent `agjan-worker-deep`) and `developer` (`agjan-worker`), or your own with
|
|
479
|
+
`"agent": "worker"` and a `tier`:
|
|
480
|
+
|
|
481
|
+
```json
|
|
482
|
+
{
|
|
483
|
+
"roles": { "data-engineer": { "agent": "worker", "tier": "deep", "description": "builds the data model and migrations" } },
|
|
484
|
+
"teams": {
|
|
485
|
+
"company-delivery": {
|
|
486
|
+
"description": "Architect and developer agents",
|
|
487
|
+
"workflows": ["feature"],
|
|
488
|
+
"stages": { "design": "architect", "build": "developer" },
|
|
489
|
+
"roles": {
|
|
490
|
+
"implementer": { "skills": ["solution-architect"] },
|
|
491
|
+
"architect": { "skills": ["technical-architect", "company-architecture"] },
|
|
492
|
+
"developer": { "skills": ["backend-developer", "ui-developer"] },
|
|
493
|
+
"reviewer": { "skills": ["solution-reviewer"] },
|
|
494
|
+
"tester": { "skills": ["qa-tester"] }
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
"models": { "claude-code": { "worker-deep": "opus" } }
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
`npx agjan status` then shows `hand off design → architect (agent agjan-worker-deep)`, and the
|
|
503
|
+
main agent starts that agent instead of writing the design itself (for build, one request per
|
|
504
|
+
task). The worker reads its role, skills, job and the paths it may write from its own agjan tool
|
|
505
|
+
(`role_context`), writes, and hands back a summary or questions, which the main agent asks you.
|
|
506
|
+
The main agent keeps talking to you, runs the checks and reviews, asks for your approvals and
|
|
507
|
+
commits. On Claude Code the guard keeps a worker to its paths and away from recording,
|
|
508
|
+
committing and branches. Worker models are `models.<host>.worker` and `worker-deep` (set them in
|
|
509
|
+
`agjan.config.json`; default: the session's model). The built-in `delivery` team works this way.
|
|
469
510
|
|
|
470
511
|
**Knowledge several teams share** is a skill: write it once as a skill of your own
|
|
471
512
|
(`.claude/skills/company-review/SKILL.md`, with the instructions and references your reviewers
|
|
@@ -663,18 +704,23 @@ it is plain text. `NO_COLOR=1` turns colors off, `FORCE_COLOR=1` turns them on.
|
|
|
663
704
|
|
|
664
705
|
## Configuration
|
|
665
706
|
|
|
666
|
-
`agjan.config.json` is layered over
|
|
667
|
-
|
|
707
|
+
`agjan.config.json` is layered over agjan's defaults: objects merge, lists replace.
|
|
708
|
+
`agjan init --preset <id>` writes a preset into it (`generic` for any stack, `sap-btp` for
|
|
709
|
+
CAP, Fiori and BTP; asked for on a terminal): the areas and paths below, which the project
|
|
710
|
+
owns from then on. The schema is `node_modules/agjan/schemas/config.schema.json`; every command
|
|
668
711
|
checks the file against it and stops with the reasons when a setting is unknown or a value
|
|
669
712
|
is wrong, so a typo is never a silent default.
|
|
670
713
|
|
|
671
714
|
```json
|
|
672
715
|
{
|
|
673
716
|
"kit": "0.1.0",
|
|
674
|
-
"domains": ["btp"],
|
|
675
717
|
"hosts": ["claude-code", "copilot"],
|
|
676
718
|
"git": { "base": "origin/main" },
|
|
677
|
-
"
|
|
719
|
+
"areas": {
|
|
720
|
+
"cap": { "title": "CAP", "skills": ["cap-developer"], "tests": ["test/**"],
|
|
721
|
+
"verify": { "test": "npm test", "results": "reports/junit.xml" } },
|
|
722
|
+
"fiori": { "title": "Fiori", "skills": ["fiori-developer"], "lint": null }
|
|
723
|
+
},
|
|
678
724
|
"fix": { "max_total": 80, "max_per_file": 50 },
|
|
679
725
|
"review": { "build": "area" },
|
|
680
726
|
"models": { "claude-code": { "balanced": "session", "deep": "opus" }, "copilot": { "balanced": "session", "deep": "session" } },
|
|
@@ -685,15 +731,15 @@ is wrong, so a typo is never a silent default.
|
|
|
685
731
|
|
|
686
732
|
| Key | Effect |
|
|
687
733
|
|---|---|
|
|
688
|
-
| `
|
|
734
|
+
| `areas.<area>` | the project's technical areas; every task belongs to one. `title` and `description`: its heading in `project.md`; `skills`: the skills in `.claude/skills/` that know it; `tests`: its test file globs; `implicit`: files every task of the area may change (i18n, lockfiles, fixtures). Without areas the project has one, `app`. `npx agjan areas` lists them |
|
|
689
735
|
| `hosts` | `claude-code`, `copilot`; decides which files `sync` generates |
|
|
690
736
|
| `git.base` | the branch features merge into; default: the remote's default branch |
|
|
691
737
|
| `git.branches` | `new` (default): on the base branch the agent creates a branch with its proposed name; `ask`: it asks you first |
|
|
692
|
-
| `
|
|
693
|
-
| `
|
|
694
|
-
| `
|
|
738
|
+
| `areas.<area>.verify` | `build`, `test`, `lint` commands for the skills; `results`: a JUnit XML, Jest or Mocha JSON file that `check` reads to require a passing test per AC |
|
|
739
|
+
| `areas.<area>.lint` | the linter `npx agjan lint` runs in each folder `in` (for example `app/*`) on the changed files matching `files`; the sap-btp preset sets the UI5 linter for `fiori`; `null` turns it off |
|
|
740
|
+
| `watched` | files whose change makes `project.md` stale (`agjan baseline refresh` records their hashes) |
|
|
695
741
|
| `risk_paths` | paths whose change needs a review per task and are never a fix |
|
|
696
|
-
| `application` | the application's code, which the QA agent may not read (the btp
|
|
742
|
+
| `application` | the application's code, which the QA agent may not read (the sap-btp preset: `srv/**`, `db/**`, `app/**`) |
|
|
697
743
|
| `fix` | `max_total`, `max_per_file`, `protected`, `ignored`, `new_file_paths` |
|
|
698
744
|
| `review.build` | `area` (default: one build review per completed area) or `task` |
|
|
699
745
|
| `review.rounds` | correction rounds per review step (default 3); if blockers remain, the agent asks you whether to run another round (one more per yes, recorded with `npx agjan review extend <step>`) or to stop |
|
|
@@ -16,8 +16,8 @@ shows how to use them.
|
|
|
16
16
|
| Term | What it is | Examples | Where it is defined |
|
|
17
17
|
|---|---|---|---|
|
|
18
18
|
| **Workflow** | A kind of work and its steps: stages, independent reviews, the approvals you give, and what it may change. | feature, fix, map, discovery; your own, such as a hotfix | Built into agjan; a project adds review steps and gates under `workflows`, and workflows of its own based on a built-in one. |
|
|
19
|
-
| **Team** | Serves one or more workflows and gives each role its skills (and optional instructions). It decides the knowledge, never the steps. | sap-delivery, sap-maintenance, sap-discovery | Built into agjan, imported from a package, or in the project's `agjan.config.json`. |
|
|
20
|
-
| **Skill** | A folder of instructions and references an agent reads for a specialty. | cap-developer, solution-reviewer, qa-tester | `.claude/skills/<name>/SKILL.md`: agjan's own, the project's own, or imported. |
|
|
19
|
+
| **Team** | Serves one or more workflows and gives each role its skills (and optional instructions). It decides the knowledge, never the steps. | delivery, maintenance, advisory; sap-delivery, sap-maintenance, sap-discovery | Built into agjan, imported from a package, or in the project's `agjan.config.json`. |
|
|
20
|
+
| **Skill** | A folder of instructions and references an agent reads for a specialty. | technical-architect, backend-developer, cap-developer, solution-reviewer, qa-tester | `.claude/skills/<name>/SKILL.md`: agjan's own, the project's own, or imported. |
|
|
21
21
|
|
|
22
22
|
A **role** is the part an agent plays in a workflow. There are four built-in roles; a team says
|
|
23
23
|
which skills each works with:
|
|
@@ -29,9 +29,17 @@ which skills each works with:
|
|
|
29
29
|
| reviewer | Reviews every step independently, read-only (the reviewer agents). |
|
|
30
30
|
| tester | Tests the built feature against its acceptance criteria (the QA agent). |
|
|
31
31
|
|
|
32
|
+
Two built-in **worker roles** run as agents of their own (design decision 100): `architect`
|
|
33
|
+
(the `agjan-worker-deep` agent) and `developer` (`agjan-worker`). A team gives them a stage under
|
|
34
|
+
`stages`, for example `"stages": { "design": "architect", "build": "developer" }`: the main agent
|
|
35
|
+
then hands that stage's writing to the worker agent (for build, one task per request) and keeps
|
|
36
|
+
the user, the checks, the reviews, the gates and the commits.
|
|
37
|
+
|
|
32
38
|
A project can add its own roles under `roles`, such as a `security-reviewer`. Each one reaches an
|
|
33
39
|
agent that already runs (the main agent, the reviewer or the QA agent), which then works with that
|
|
34
|
-
role's skills in the team as well
|
|
40
|
+
role's skills in the team as well, or is a worker of its own (`"agent": "worker"`, with a `tier`)
|
|
41
|
+
for the stage a team gives it. A role never adds a step: a worker writes a stage the workflow
|
|
42
|
+
already has.
|
|
35
43
|
|
|
36
44
|
A **unit** is one piece of work that runs a workflow: one feature, one fix, one map run or
|
|
37
45
|
one discovery.
|
|
@@ -45,7 +53,7 @@ WORKFLOW feature · fix · map · discovery
|
|
|
45
53
|
│ many-to-many: a team serves one or more workflows, a workflow has one or more teams
|
|
46
54
|
│ one default team per workflow; exactly one team per unit
|
|
47
55
|
▼
|
|
48
|
-
TEAM
|
|
56
|
+
TEAM delivery · maintenance · advisory · sap-delivery · … · your own
|
|
49
57
|
│
|
|
50
58
|
│ per role the workflow needs: the skills (and instructions) it works with in this team
|
|
51
59
|
▼
|
|
@@ -53,7 +61,7 @@ ROLE implementer · analyst · reviewer · tester · your own
|
|
|
53
61
|
│
|
|
54
62
|
│ many-to-many: a role lists its skills in each team; a skill is reused by many teams and roles
|
|
55
63
|
▼
|
|
56
|
-
SKILL
|
|
64
|
+
SKILL technical-architect · backend-developer · ui-developer · cap-developer · solution-reviewer · ...
|
|
57
65
|
```
|
|
58
66
|
|
|
59
67
|
The rules behind the arrows:
|
|
@@ -67,8 +75,12 @@ The rules behind the arrows:
|
|
|
67
75
|
change to the team is reported.
|
|
68
76
|
- A team lists skills per role, and must give every built-in role its workflows need at least
|
|
69
77
|
one skill. Its own roles are optional extras for the same agents.
|
|
70
|
-
- A role
|
|
71
|
-
|
|
78
|
+
- A role of the main agent, the reviewer or the QA agent starts no agent of its own: its
|
|
79
|
+
skills and instructions go to the agent that already does that job. A worker role is an
|
|
80
|
+
agent of its own, but only for the stage a team gives it under `stages`; the main agent
|
|
81
|
+
starts it and gets its result.
|
|
82
|
+
- `stages` can give spec, design, build (feature), fix, map and proposal to a role. Without an
|
|
83
|
+
entry, the workflow's own role does the stage.
|
|
72
84
|
- Knowledge several teams share is a skill of the project's own, listed in each team.
|
|
73
85
|
- How many rounds each review gets is a setting: `review.rounds` for all, and
|
|
74
86
|
`review.step_rounds` for one kind of step (for example 5 for the design review). A workflow
|
|
@@ -99,8 +111,30 @@ The rules behind the arrows:
|
|
|
99
111
|
|
|
100
112
|
## Example: the built-in teams
|
|
101
113
|
|
|
102
|
-
agjan ships three teams for
|
|
103
|
-
|
|
114
|
+
agjan ships three teams for any stack, the defaults of a project without a `team` setting:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
feature ────► delivery stages: design → architect, build → developer
|
|
118
|
+
implementer: solution-architect, technical-architect, backend-developer, ui-developer
|
|
119
|
+
architect: technical-architect (agent agjan-worker-deep)
|
|
120
|
+
developer: backend-developer, ui-developer (agent agjan-worker, one per task)
|
|
121
|
+
reviewer: solution-reviewer, technical-architect, backend-developer, ui-developer
|
|
122
|
+
tester: qa-tester
|
|
123
|
+
|
|
124
|
+
fix ──┐
|
|
125
|
+
map ──┴─────► maintenance
|
|
126
|
+
implementer: backend-developer, ui-developer (fix)
|
|
127
|
+
analyst: technical-architect, backend-developer, ui-developer (map)
|
|
128
|
+
reviewer: solution-reviewer, backend-developer, ui-developer
|
|
129
|
+
|
|
130
|
+
discovery ──► advisory
|
|
131
|
+
analyst: solution-architect, technical-architect
|
|
132
|
+
reviewer: solution-reviewer, solution-architect
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
And three for SAP CAP, Fiori and BTP projects, which the `sap-btp` preset makes the defaults.
|
|
136
|
+
The same skills appear in several teams and roles: that is the many-to-many link between roles
|
|
137
|
+
and skills.
|
|
104
138
|
|
|
105
139
|
```text
|
|
106
140
|
feature ────► sap-delivery
|
package/kit/hooks/guard.mjs
CHANGED
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
* Only where the host names the calling agent (Claude Code's `agent_type`); a guardrail,
|
|
24
24
|
* not a sandbox: running the application or its tests is allowed.
|
|
25
25
|
*
|
|
26
|
+
* A worker agent (`agjan-worker`, `agjan-worker-deep`, decision 100) does one stage for a role:
|
|
27
|
+
* its file edits are denied outside the paths `role_context` wrote to .agjan/worker-guard.json,
|
|
28
|
+
* and so are commands that record, commit or switch branches. Only where the host names the
|
|
29
|
+
* calling agent (Claude Code's `agent_type`); elsewhere it stays an instruction.
|
|
30
|
+
*
|
|
26
31
|
* The guard only denies. Everything else is left to the host, which asks the user as it
|
|
27
32
|
* is configured to (design decision 76).
|
|
28
33
|
*
|
|
@@ -42,6 +47,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
42
47
|
* A host's tool call as the hook receives it: Copilot's or Claude Code's form.
|
|
43
48
|
* @typedef {{ toolName?: string, toolArgs?: Record<string, any>, tool_name?: string, tool_input?: Record<string, any>, agent_type?: string }} Payload
|
|
44
49
|
* @typedef {{ hidden: string[], visible: string[] }} QaGuard
|
|
50
|
+
* @typedef {{ allow: string[], deny: string[] }} WorkerGuard
|
|
45
51
|
* @typedef {{ agent?: { script_edits?: string } }} GuardConfig
|
|
46
52
|
*/
|
|
47
53
|
|
|
@@ -143,7 +149,7 @@ const RECORD_REASON =
|
|
|
143
149
|
* default, the review contexts that review_record checks a result against): never edited by
|
|
144
150
|
* an agent's edit tool.
|
|
145
151
|
*/
|
|
146
|
-
const RECORD = /^agjan-docs\/(?:.+\/)?(?:approvals\.json|reviews\.json|review\.md|log\.jsonl|progress\.md|report\.md|fix\.json|fix\.md|tests\.json)$|^agjan-docs\/baseline\.json$|^\.agjan\/auto\.json$|^\.agjan\/qa-guard\.json$|^\.agjan\/review-contexts\//;
|
|
152
|
+
const RECORD = /^agjan-docs\/(?:.+\/)?(?:approvals\.json|reviews\.json|review\.md|log\.jsonl|progress\.md|report\.md|fix\.json|fix\.md|tests\.json)$|^agjan-docs\/baseline\.json$|^\.agjan\/auto\.json$|^\.agjan\/qa-guard\.json$|^\.agjan\/worker-guard\.json$|^\.agjan\/review-contexts\//;
|
|
147
153
|
|
|
148
154
|
const AUTO_REASON =
|
|
149
155
|
'The auto mode default (.agjan/auto.json) is the user\'s, set with npx agjan auto on --default in their terminal. Do not read, write, copy or remove it.';
|
|
@@ -157,7 +163,7 @@ const QA_REASON =
|
|
|
157
163
|
const QA_START_REASON = 'Call qa_context first: it names what you may read.';
|
|
158
164
|
|
|
159
165
|
/** The QA guard file: what the QA agent may not read (decision 87). */
|
|
160
|
-
const QA_GUARD = /\.agjan[\\/]+qa-guard\.json/;
|
|
166
|
+
const QA_GUARD = /\.agjan[\\/]+(?:qa|worker)-guard\.json/;
|
|
161
167
|
|
|
162
168
|
/** The files of a glob, as a regular expression: `**` any depth, `*` and `?` within a name. */
|
|
163
169
|
function globRegex(/** @type {string} */ glob) {
|
|
@@ -264,6 +270,49 @@ function decideQa(payload, root) {
|
|
|
264
270
|
return null;
|
|
265
271
|
}
|
|
266
272
|
|
|
273
|
+
const WORKER_REASON =
|
|
274
|
+
'You are an agjan worker: write only the paths role_context gave you, and leave recording, committing and branches to the main agent. If the work needs another file, stop and say which and why.';
|
|
275
|
+
const WORKER_START_REASON = 'You are an agjan worker: call role_context first; it tells you which paths you may write.';
|
|
276
|
+
|
|
277
|
+
/** agjan commands a worker may run: those that only read or check. */
|
|
278
|
+
const WORKER_AGJAN = new RegExp(`${AGJAN}(?!(?:status|check|areas|lint|ui-test|team|workflow|summary|report)\\b)[a-z]`);
|
|
279
|
+
/** git commands that change history, the index or branches. */
|
|
280
|
+
const WORKER_GIT = /\bgit(?:\s+-[cC]\s+\S+|\s+--[\w-]+(?:=\S+)?)*\s+(?:commit|push|reset|rebase|merge|cherry-pick|revert|switch|checkout|stash|tag|branch\s+-[dDmM]|add|rm|mv|restore\s+--staged)\b/;
|
|
281
|
+
|
|
282
|
+
/** The worker guard file; null before role_context wrote it. @returns {WorkerGuard | null} */
|
|
283
|
+
function readWorkerGuard(/** @type {string} */ root) {
|
|
284
|
+
try {
|
|
285
|
+
const guard = JSON.parse(readFileSync(join(root, '.agjan', 'worker-guard.json'), 'utf8'));
|
|
286
|
+
return Array.isArray(guard?.allow) && Array.isArray(guard?.deny) ? guard : null;
|
|
287
|
+
} catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The guard's answer for a tool call of a worker agent, or null (the general rules apply).
|
|
294
|
+
* @param {Payload} payload
|
|
295
|
+
* @param {string} root
|
|
296
|
+
*/
|
|
297
|
+
function decideWorker(payload, root) {
|
|
298
|
+
const tool = payload.tool_name ?? payload.toolName ?? '';
|
|
299
|
+
const args = payload.tool_input ?? payload.toolArgs ?? {};
|
|
300
|
+
if (EDIT_TOOLS.has(tool)) {
|
|
301
|
+
const target = args.path ?? args.file_path ?? args.notebook_path;
|
|
302
|
+
if (typeof target !== 'string' || target === '') return null;
|
|
303
|
+
const rel = repoPath(root, target);
|
|
304
|
+
if (rel === null) return answer(payload, 'deny', WORKER_REASON);
|
|
305
|
+
const guard = readWorkerGuard(root);
|
|
306
|
+
if (!guard) return answer(payload, 'deny', WORKER_START_REASON);
|
|
307
|
+
const matches = (/** @type {string[]} */ globs) => globs.some((g) => globRegex(g).test(rel));
|
|
308
|
+
return matches(guard.allow) && !matches(guard.deny) ? null : answer(payload, 'deny', WORKER_REASON);
|
|
309
|
+
}
|
|
310
|
+
const command = args.command;
|
|
311
|
+
if (typeof command !== 'string') return null;
|
|
312
|
+
if (WORKER_AGJAN.test(command) || WORKER_GIT.test(command)) return answer(payload, 'deny', WORKER_REASON);
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
|
|
267
316
|
const READ_TOOLS = new Set(['Read', 'NotebookRead', 'Grep', 'Glob']);
|
|
268
317
|
|
|
269
318
|
const EDIT_TOOLS = new Set(['edit', 'create', 'Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
|
|
@@ -307,6 +356,10 @@ export function decide(payload, config = {}, root = process.env.CLAUDE_PROJECT_D
|
|
|
307
356
|
const qa = decideQa(payload, root);
|
|
308
357
|
if (qa) return qa;
|
|
309
358
|
}
|
|
359
|
+
if (payload?.agent_type === 'agjan-worker' || payload?.agent_type === 'agjan-worker-deep') {
|
|
360
|
+
const worker = decideWorker(payload, root);
|
|
361
|
+
if (worker) return worker;
|
|
362
|
+
}
|
|
310
363
|
if (READ_TOOLS.has(payload?.tool_name ?? payload?.toolName ?? '')) return null;
|
|
311
364
|
if (EDIT_TOOLS.has(payload?.toolName ?? payload?.tool_name ?? '')) return decideEdit(payload, root);
|
|
312
365
|
const command = payload?.toolArgs?.command ?? payload?.tool_input?.command;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "generic",
|
|
3
|
+
"title": "Any stack: backend, user interface and platform areas",
|
|
4
|
+
"config": {
|
|
5
|
+
"areas": {
|
|
6
|
+
"backend": {
|
|
7
|
+
"title": "Backend",
|
|
8
|
+
"description": "Services and APIs, the data model, authentication, external dependencies.",
|
|
9
|
+
"skills": ["backend-developer"],
|
|
10
|
+
"tests": ["test/**", "tests/**", "**/*.test.*", "**/*.spec.*"],
|
|
11
|
+
"implicit": ["package.json", "package-lock.json"]
|
|
12
|
+
},
|
|
13
|
+
"ui": {
|
|
14
|
+
"title": "User interface",
|
|
15
|
+
"description": "Each application or page: its folder, its framework, the APIs it uses.",
|
|
16
|
+
"skills": ["ui-developer"],
|
|
17
|
+
"tests": ["e2e/**", "test/ui/**"]
|
|
18
|
+
},
|
|
19
|
+
"platform": {
|
|
20
|
+
"title": "Platform",
|
|
21
|
+
"description": "Runtime, infrastructure, configuration and deployment targets.",
|
|
22
|
+
"skills": ["technical-architect"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "sap-btp",
|
|
3
|
+
"title": "SAP BTP: CAP Node.js, Fiori elements and UI5, BTP services",
|
|
4
|
+
"config": {
|
|
5
|
+
"areas": {
|
|
6
|
+
"cap": {
|
|
7
|
+
"title": "CAP",
|
|
8
|
+
"description": "Services, key entities, authentication, external dependencies.",
|
|
9
|
+
"skills": ["cap-developer"],
|
|
10
|
+
"tests": ["test/**"],
|
|
11
|
+
"implicit": ["package.json", "package-lock.json", "tsconfig.json", "tsconfig.cdsbuild.json", "test/fixtures/**", "_i18n/**"],
|
|
12
|
+
"verify": { "test": "npm test" }
|
|
13
|
+
},
|
|
14
|
+
"fiori": {
|
|
15
|
+
"title": "Fiori",
|
|
16
|
+
"description": "Each application: its folder, `app_type` (elements or freestyle), the service it uses.",
|
|
17
|
+
"skills": ["fiori-developer"],
|
|
18
|
+
"tests": ["app/*/webapp/test/**", "app/*/test/**", "test/ui/**"],
|
|
19
|
+
"implicit": ["app/*/package.json", "app/*/package-lock.json", "app/*/tsconfig.json", "app/*/webapp/i18n/**", "playwright.config.ts"],
|
|
20
|
+
"lint": { "command": "npx --yes @ui5/linter", "in": "app/*", "files": "webapp/**/*.{js,ts,xml,json,html}" }
|
|
21
|
+
},
|
|
22
|
+
"btp": {
|
|
23
|
+
"title": "BTP",
|
|
24
|
+
"description": "Runtime, BTP services, deployment targets.",
|
|
25
|
+
"skills": ["btp-architect"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"application": ["srv/**", "db/**", "app/**"],
|
|
29
|
+
"risk_paths": ["xs-security.json", "ams/**", "mta.yaml", "srv/**/*auth*", "srv/**/*-access.cds"],
|
|
30
|
+
"fix": { "protected": ["mta.yaml", "xs-security.json", "ams/**", "srv/**/*.cds"] },
|
|
31
|
+
"watched": ["db/*.cds", "srv/*.cds", "app/*/webapp/manifest.json", "mta.yaml"],
|
|
32
|
+
"team": { "feature": "sap-delivery", "fix": "sap-maintenance", "map": "sap-maintenance", "discovery": "sap-discovery" }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -15,6 +15,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
15
15
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
16
16
|
skill or with the user, this skill and the user win.
|
|
17
17
|
|
|
18
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
19
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
20
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
21
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
22
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
23
|
+
|
|
18
24
|
## Your workflow's extras
|
|
19
25
|
|
|
20
26
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -43,14 +49,14 @@ Repeat until `npx agjan status` says `next: all tasks done and reviewed`:
|
|
|
43
49
|
2. **A task:**
|
|
44
50
|
- `npx agjan log --stage build --task <id> --role <role> --skill agjan-build`
|
|
45
51
|
- Read the task in `tasks.md`, its ACs in `spec.md`, the decisions in
|
|
46
|
-
`design.md`, and the
|
|
47
|
-
`
|
|
52
|
+
`design.md`, and the skills of its area (`npx agjan areas` lists them; for
|
|
53
|
+
example `cap-developer` for `cap`).
|
|
48
54
|
- Change only files matching the task's `paths` (plus implicitly allowed files:
|
|
49
55
|
`package.json`, lockfiles, i18n files, test fixtures).
|
|
50
56
|
- Write tests for the task's ACs. Each test name contains the AC id, for example
|
|
51
57
|
`it('ORDF-AC2: an approved order cannot be edited', ...)`. Manual ACs need no test.
|
|
52
58
|
- Run the task's `verify` command (default: the area's commands in
|
|
53
|
-
`agjan.config.json`, else `npm test`), for a
|
|
59
|
+
`agjan.config.json`, else `npm test`), for a task with UI tests also `npx agjan ui-test`
|
|
54
60
|
(the Playwright UI tests; it skips them where no browser can start: say so, never
|
|
55
61
|
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.
|
|
56
62
|
- Commit the task with the subject `<KEY>-<id>: <title>`, for example
|
|
@@ -15,6 +15,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
15
15
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
16
16
|
skill or with the user, this skill and the user win.
|
|
17
17
|
|
|
18
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
19
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
20
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
21
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
22
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
23
|
+
|
|
18
24
|
## Your workflow's extras
|
|
19
25
|
|
|
20
26
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -38,21 +44,17 @@ user. Then `npx agjan log --stage design --skill agjan-design`.
|
|
|
38
44
|
## 2. Impact analysis
|
|
39
45
|
|
|
40
46
|
Read `spec.md`, `agjan-docs/project.md` if it exists, and the real files involved.
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
Run `npx agjan areas`: it lists this project's areas and the skills of each. Decide the
|
|
48
|
+
`areas` (a subset of them) with a reason each. Do not load the area skills before you know
|
|
49
|
+
the areas.
|
|
43
50
|
|
|
44
51
|
`npx agjan scaffold design`, then set `mode: full` and `areas` in `design.md`.
|
|
45
52
|
|
|
46
53
|
## 3. Role steps, in this order, only for the chosen areas
|
|
47
54
|
|
|
48
|
-
For each area, read
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|---|---|
|
|
52
|
-
| `btp` | `.claude/skills/btp-architect/SKILL.md` |
|
|
53
|
-
| `cap` | `.claude/skills/cap-developer/SKILL.md` |
|
|
54
|
-
| `fiori` | `.claude/skills/fiori-developer/SKILL.md` |
|
|
55
|
-
|
|
55
|
+
For each area, read the skills `npx agjan areas` lists for it and write its part of
|
|
56
|
+
`## Decisions`. An area without skills is decided from the project's own conventions
|
|
57
|
+
(`agjan-docs/project.md`, the code).
|
|
56
58
|
Every decision states what, why, and the alternative considered. For every new Fiori
|
|
57
59
|
application, record `app_type: elements` or `app_type: freestyle` with reason and
|
|
58
60
|
alternative. Existing applications keep their type (read it from `manifest.json`).
|
|
@@ -64,7 +66,8 @@ entity; "no draft" is only for read-only apps or apps that change data through a
|
|
|
64
66
|
(fiori-developer). An AC the design cannot meet in the UI is a design error, not a
|
|
65
67
|
build problem.
|
|
66
68
|
|
|
67
|
-
Then check the decisions for production, with the rules of the
|
|
69
|
+
Then check the decisions for production, with the rules of the area skills you read. For
|
|
70
|
+
the areas of the sap-btp preset:
|
|
68
71
|
|
|
69
72
|
| Area | Decide for the feature |
|
|
70
73
|
|---|---|
|
|
@@ -18,6 +18,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
18
18
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
19
19
|
skill or with the user, this skill and the user win.
|
|
20
20
|
|
|
21
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
22
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
23
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
24
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
25
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
26
|
+
|
|
21
27
|
## Your workflow's extras
|
|
22
28
|
|
|
23
29
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -15,6 +15,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
15
15
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
16
16
|
skill or with the user, this skill and the user win.
|
|
17
17
|
|
|
18
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
19
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
20
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
21
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
22
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
23
|
+
|
|
18
24
|
## Your workflow's extras
|
|
19
25
|
|
|
20
26
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -15,6 +15,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
15
15
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
16
16
|
skill or with the user, this skill and the user win.
|
|
17
17
|
|
|
18
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
19
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
20
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
21
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
22
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
23
|
+
|
|
18
24
|
## Your workflow's extras
|
|
19
25
|
|
|
20
26
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -53,13 +59,16 @@ It creates the map run folder and, if absent, `agjan-docs/project.md` from the t
|
|
|
53
59
|
|
|
54
60
|
## 2. Read the application
|
|
55
61
|
|
|
56
|
-
Use the project files and the documentation tools configured for
|
|
62
|
+
Use the project files, the skills of each area and the documentation tools configured for
|
|
63
|
+
it (MCP). `npx agjan areas` lists the areas; `project.md` has a heading for each, with what
|
|
64
|
+
to describe under it. For the areas of the sap-btp preset:
|
|
57
65
|
|
|
58
|
-
- `db/` and `srv
|
|
59
|
-
- `app
|
|
66
|
+
- `db/` and `srv/` (CAP): services, key entities, authentication, external dependencies;
|
|
67
|
+
- `app/` (Fiori): each Fiori application, its `app_type` (`sap.fe.templates` in its
|
|
60
68
|
`manifest.json` means elements, else freestyle) and the service it uses;
|
|
61
|
-
- `mta.yaml`, `xs-security.json`, `package.json
|
|
62
|
-
|
|
69
|
+
- `mta.yaml`, `xs-security.json`, `package.json` (BTP): runtime, BTP services, deployment.
|
|
70
|
+
|
|
71
|
+
In every project: tests, lint and naming patterns are the conventions.
|
|
63
72
|
|
|
64
73
|
## 3. Write `agjan-docs/project.md`
|
|
65
74
|
|
|
@@ -16,6 +16,12 @@ your role works with (read them next to the ones this skill names), and each `fo
|
|
|
16
16
|
an instruction of your team for you. Follow those instructions; where one conflicts with this
|
|
17
17
|
skill or with the user, this skill and the user win.
|
|
18
18
|
|
|
19
|
+
A team can also give this skill's writing to a role (design decision 100). A `role` row in
|
|
20
|
+
`npx agjan status` names the role you work as for the current stage and its skills. A
|
|
21
|
+
`hand off` row means a worker agent of your team writes the stage: at the step where you
|
|
22
|
+
would write it, follow `.claude/skills/agjan-worker/references/hand-off.md`; everything else
|
|
23
|
+
in this skill (the user, the checks, the reviews, the gates, the commits) stays yours.
|
|
24
|
+
|
|
19
25
|
## Your workflow's extras
|
|
20
26
|
|
|
21
27
|
The project can add review steps and gates to this workflow (`npx agjan workflow show
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agjan-worker
|
|
3
|
+
description: Knowledge of agjan's worker agents, which do one stage of a unit for a role of the team (design, a build task, ...). Used by the generated agjan-worker agents; do not invoke it directly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# agjan worker
|
|
7
|
+
|
|
8
|
+
You are an agjan worker. The main agent handed you one stage of a unit of work (a feature's
|
|
9
|
+
design, one build task, a fix, a project map, a proposal) for a role of its team. You do the
|
|
10
|
+
writing for that stage and hand back; the main agent keeps the conversation with the user,
|
|
11
|
+
the reviews, the gates and the commits.
|
|
12
|
+
|
|
13
|
+
## How you work
|
|
14
|
+
|
|
15
|
+
1. **Call `role_context` first**, with the stage (and for `build` the task id, and the unit
|
|
16
|
+
when the main agent names one) from the main agent's request. It returns your role, your
|
|
17
|
+
skills, your job, what to read, the paths you may write and how to hand back. Work only
|
|
18
|
+
from that material and the files it points to.
|
|
19
|
+
2. **Read your skills** before you decide anything: each `SKILL.md` it lists, and the
|
|
20
|
+
references its table names for your topic. The project's own conventions
|
|
21
|
+
(`agjan-docs/project.md`, the existing code) win over a skill's defaults.
|
|
22
|
+
3. **Write only the paths you may write.** Use your file edit tool. If the work needs another
|
|
23
|
+
file, stop and say which file and why: the main agent asks the user for an amendment.
|
|
24
|
+
4. **Check your work** where the stage has checks: for a build task, run its tests (the area's
|
|
25
|
+
test command) until they pass, and `npx agjan check`; fix failures in the code, never by
|
|
26
|
+
weakening a test.
|
|
27
|
+
5. **Hand back** as `role_context` says: a short summary of what you changed and ran, or a
|
|
28
|
+
`QUESTIONS:` section when you need a decision. You cannot ask the user yourself.
|
|
29
|
+
|
|
30
|
+
## Never
|
|
31
|
+
|
|
32
|
+
- Run commands that record or decide: `agjan approve`, `accept`, `reject`, `review`, `log`,
|
|
33
|
+
`amend`, `new`, `branch`, `sync`; never commit, push, rebase or switch branches.
|
|
34
|
+
- Start a reviewer or another agent, or review your own work.
|
|
35
|
+
- Change agjan's records (`approvals.json`, `reviews.json`, `log.jsonl`, `.agjan/`).
|
|
36
|
+
- Decide a question the material leaves open: ask it in `QUESTIONS:` instead.
|