agjan 0.0.26 → 0.0.27

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.
@@ -13,22 +13,44 @@ import { acResults, loadResults } from '../test-results.js';
13
13
  import { testRunState } from '../test-run.js';
14
14
  import { workflowOf } from '../workflow.js';
15
15
  import { proposalProblems, proposalReview } from '../discovery.js';
16
- import { mainRole, unitTeam } from '../teams.js';
16
+ import { mainRole, personasFor, unitTeam } from '../teams.js';
17
17
  import { finalSteps, unitModel } from '../progress-view.js';
18
18
  import { splitNow } from '../story.js';
19
19
  import { verification } from '../readiness.js';
20
20
  import { readLog } from '../log.js';
21
21
  import { readAutoDefault } from '../auto.js';
22
22
  import { QA_STEP, qaState, qaTestFiles } from '../qa.js';
23
- /** The unit's team and the skills of the main agent's role in it (decision 92). */
23
+ /**
24
+ * The unit's team and what the main agent works with in it (decision 92): the skills of its
25
+ * role and the team's own roles for it, then each persona's instructions, which the workflow
26
+ * skills tell the main agent to follow (the reviewer and QA agent get theirs in their contexts).
27
+ */
24
28
  function teamRow(ctx, unit) {
25
29
  const team = unitTeam(ctx.config, unit.approvals.feature.team);
26
30
  if (!team)
27
31
  return;
28
32
  const role = mainRole(unit.kind);
29
- const skills = team.team?.personas[role]?.skills ?? [];
33
+ const skills = mainSkills(ctx, team.team, unit.kind);
30
34
  const changed = team.changed ? ctx.style.yellow(' (its definition changed since this unit started)') : '';
31
35
  row(ctx, 'team', `${team.name}${skills.length ? ctx.style.gray(` · ${role}: ${skills.join(', ')}`) : ''}${changed}`);
36
+ for (const p of mainPersonas(ctx, team.team, unit.kind)) {
37
+ if (p.instructions)
38
+ row(ctx, 'follow', `${p.role}: ${p.instructions}`);
39
+ }
40
+ }
41
+ /** The main agent's personas: role, skills and instructions (one line). */
42
+ function mainPersonas(ctx, team, kind) {
43
+ if (!team)
44
+ return [];
45
+ return personasFor(ctx.config, team, kind, 'main').map(({ role, persona }) => ({
46
+ role,
47
+ skills: persona.skills,
48
+ ...(persona.instructions?.trim() ? { instructions: persona.instructions.trim().replace(/\s+/g, ' ') } : {}),
49
+ }));
50
+ }
51
+ /** The skills the main agent works with: its role's, then those of the team's own roles for it. */
52
+ function mainSkills(ctx, team, kind) {
53
+ return team ? [...new Set(personasFor(ctx.config, team, kind, 'main').flatMap((p) => p.persona.skills))] : [];
32
54
  }
33
55
  /** One indented row: a label column, then the value. `next` and `blocks` stand out. */
34
56
  function row(ctx, label, value) {
@@ -392,7 +414,7 @@ function json(ctx, slugs) {
392
414
  ...((() => {
393
415
  const team = unitTeam(ctx.config, unit.approvals.feature.team);
394
416
  const role = mainRole(unit.kind);
395
- return team ? { team: { name: team.name, changed: team.changed, role, skills: team.team?.personas[role]?.skills ?? [] } } : {};
417
+ return team ? { team: { name: team.name, changed: team.changed, role, skills: mainSkills(ctx, team.team, unit.kind), personas: mainPersonas(ctx, team.team, unit.kind) } } : {};
396
418
  })()),
397
419
  ...(verified ? { verified: verified.problems.length === 0, accepted: verified.accepted, problems: verified.problems } : {}),
398
420
  };
@@ -422,7 +444,7 @@ export async function run(ctx, argv) {
422
444
  for (const line of markLine(ctx.style, ctx.kit, 'status'))
423
445
  ctx.out(line);
424
446
  const autoDefault = readAutoDefault(root) ? '; auto mode: on for new features (your default)' : '';
425
- ctx.out(ctx.style.gray(`settings: documents in '${c.language ?? 'en'}' (headings in English); reviews up to ${roundLimit(c)} rounds; ${fixAttempts(c)} attempts for failing checks; ${branches}${autoDefault}`));
447
+ ctx.out(ctx.style.gray(`settings: documents in '${c.language ?? 'en'}' (headings in English); reviews up to ${roundLimit(c)} rounds${Object.keys(c.review?.step_rounds ?? {}).length ? ` (${Object.entries(c.review.step_rounds).map(([k, n]) => `${k}: ${n}`).join(', ')})` : ''}; ${fixAttempts(c)} attempts for failing checks; ${branches}${autoDefault}`));
426
448
  if (slugs.length === 0) {
427
449
  ctx.out(values.all ? `no features in ${FEATURES_DIR}` : 'no changed feature on this branch (agjan status --all lists every feature)');
428
450
  return 0;
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from 'node:util';
2
2
  import { UsageError } from '../errors.js';
3
- import { BUILT_IN_TEAMS, ROLES, allTeams, defaultTeam, teamProblems } from '../teams.js';
3
+ import { BUILT_IN_TEAMS, ROLES, allTeams, defaultTeam, roleAgent, teamProblems } from '../teams.js';
4
4
  import { WORKFLOWS } from '../workflow.js';
5
5
  const USAGE = 'usage: agjan team list | agjan team show <name>';
6
6
  /**
@@ -27,14 +27,19 @@ export function run(ctx, argv) {
27
27
  const problems = teamProblems(ctx.root, ctx.config, name);
28
28
  if (!team)
29
29
  throw new UsageError(problems[0]);
30
- ctx.out(`${s.bold(name)}: ${team.description}`, ` workflows ${team.workflows.join(', ')}`);
31
- for (const role of ROLES) {
30
+ ctx.out(`${s.bold(name)}: ${team.description}`);
31
+ // The built-in roles first, then the team's own; a named persona says so.
32
+ const definition = ctx.config.teams?.[name] ?? BUILT_IN_TEAMS[name];
33
+ const roles = [...ROLES.filter((r) => team.personas[r]), ...Object.keys(team.personas).filter((r) => !ROLES.includes(r))];
34
+ const width = Math.max(12, ...roles.filter((r) => !ROLES.includes(r)).map((r) => r.length + 2));
35
+ ctx.out(` ${'workflows'.padEnd(width)}${team.workflows.join(', ')}`);
36
+ for (const role of roles) {
32
37
  const persona = team.personas[role];
33
- if (!persona)
34
- continue;
35
- ctx.out(` ${role.padEnd(12)}${persona.skills.join(', ')}`);
38
+ const ref = definition?.personas[role];
39
+ const notes = [typeof ref === 'string' ? `persona ${ref}` : '', ROLES.includes(role) ? '' : `reaches the ${roleAgent(ctx.config, role) ?? 'unknown'} agent`].filter(Boolean);
40
+ ctx.out(` ${role.padEnd(width)}${persona.skills.join(', ')}${notes.length ? s.gray(` (${notes.join('; ')})`) : ''}`);
36
41
  if (persona.instructions?.trim())
37
- ctx.out(` ${''.padEnd(12)}${s.gray(persona.instructions.trim().replace(/\s+/g, ' '))}`);
42
+ ctx.out(` ${''.padEnd(width)}${s.gray(persona.instructions.trim().replace(/\s+/g, ' '))}`);
38
43
  }
39
44
  ctx.out(s.gray(' The workflow decides the steps, reviews and gates; a team adds what its agents work with.'));
40
45
  for (const p of problems)
@@ -56,13 +56,17 @@ export function run(ctx, argv) {
56
56
  ctx.out(` ${step.agent.padEnd(21)} ${does}${details.length ? s.gray(` (${details.join('; ')})`) : ''}`);
57
57
  }
58
58
  }
59
- const roles = [...new Set(view.stages.flatMap((st) => st.steps).filter((st) => st.role).map((st) => st.role))];
60
- if (view.team && roles.length) {
59
+ // Each role once, with the agent it reaches: the built-in roles first, then the team's own.
60
+ const seen = new Map();
61
+ for (const step of view.stages.flatMap((st) => st.steps))
62
+ for (const p of step.personas)
63
+ if (!seen.has(p.role))
64
+ seen.set(p.role, { agent: step.actor === 'main' ? 'main agent' : step.actor === 'qa' ? 'QA agent' : 'reviewer', persona: p });
65
+ if (view.team && seen.size) {
61
66
  ctx.out('', s.bold(`What the agents work with (team ${view.team.name})`));
62
- for (const role of roles) {
63
- const persona = view.stages.flatMap((st) => st.steps).find((st) => st.role === role)?.persona;
64
- ctx.out(` ${role.padEnd(21)} ${persona?.skills.length ? persona.skills.join(', ') : s.gray('no persona')}`);
65
- if (persona?.instructions?.trim())
67
+ for (const [role, { agent, persona }] of seen) {
68
+ ctx.out(` ${role.padEnd(21)} ${persona.skills.length ? persona.skills.join(', ') : s.gray('no skills')}${s.gray(` (${agent}${persona.description ? `: ${persona.description}` : ''})`)}`);
69
+ if (persona.instructions?.trim())
66
70
  ctx.out(` ${''.padEnd(21)} ${s.gray(persona.instructions.trim().replace(/\s+/g, ' '))}`);
67
71
  }
68
72
  }
package/dist/imports.js CHANGED
@@ -6,6 +6,7 @@ import { dirname, join, relative } from 'node:path';
6
6
  import { readJson, writeJson } from './json-file.js';
7
7
  import { AgjanError } from './errors.js';
8
8
  import { loadSchema, validate } from './schema.js';
9
+ import { ROLES } from './teams.js';
9
10
  /**
10
11
  * Imports (decision 93): skills and teams from another repository, at an exact commit.
11
12
  *
@@ -50,6 +51,15 @@ function manifestProblems(data) {
50
51
  if (data.teams !== undefined) {
51
52
  for (const p of validate(loadSchema('config'), { teams: data.teams }))
52
53
  problems.push(`${MANIFEST}: ${p}`);
54
+ // A package brings no roles or named personas: its teams use the built-in roles, with their personas inline.
55
+ for (const [name, team] of Object.entries(data.teams ?? {})) {
56
+ for (const [role, persona] of Object.entries(team?.personas ?? {})) {
57
+ if (!ROLES.includes(role))
58
+ problems.push(`${MANIFEST}: teams.${name}: role '${role}' is not a built-in role (${ROLES.join(', ')})`);
59
+ if (typeof persona === 'string')
60
+ problems.push(`${MANIFEST}: teams.${name}.personas.${role}: a package's personas are written out, not named`);
61
+ }
62
+ }
53
63
  }
54
64
  return problems;
55
65
  }
@@ -320,7 +320,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now(), memo =
320
320
  decisions: shown,
321
321
  reviewers,
322
322
  humans,
323
- roundLimit: roundLimit(config),
323
+ roundLimits: Object.fromEntries([...new Set(reviews.map((r) => r.step))].map((step) => [step, roundLimit(config, step)])),
324
324
  stats: {
325
325
  activeMs: steps.reduce((t, s) => t + (s.to - s.from), 0),
326
326
  waitingMs: gates.reduce((t, s) => t + (s.to - s.from), 0),
@@ -441,7 +441,7 @@ export function unitMarkdown(model, { generatedAt }) {
441
441
  const course = rs
442
442
  .map((r, i) => `${i && r.round === 1 ? '↺ ' : i ? '→ ' : ''}${r.id} ${VERDICT_MD[r.verdict]}${r.findings.length ? ` (${severities(r.findings, model.findings)})` : ''}`)
443
443
  .join(' ');
444
- out.push(`| ${step} | ${rs.length} (limit ${model.roundLimit} per loop) | ${course} |`);
444
+ out.push(`| ${step} | ${rs.length} (limit ${model.roundLimits[step]} per loop) | ${course} |`);
445
445
  }
446
446
  out.push('');
447
447
  }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Review settings from agjan.config.json (design 7.3, 7.4): which reviewer agent runs a
3
- * step (`review.tiers`), how many correction rounds a step gets (`review.rounds`), and
3
+ * step (`review.tiers`), how many correction rounds a step gets (`review.rounds`, or its
4
+ * kind's own under `review.step_rounds`), and
4
5
  * how many attempts the main agent has for failing deterministic checks
5
6
  * (`build.fix_attempts`). `agjan status` shows them; the skills follow `status`.
6
7
  */
@@ -28,8 +29,10 @@ export function reviewerFor(config, step) {
28
29
  const tier = config.review?.tiers?.[kind] ?? DEFAULT_TIERS[kind] ?? 'balanced';
29
30
  return tier === 'qa' ? 'agjan-qa' : tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer';
30
31
  }
31
- export function roundLimit(config) {
32
- return config.review?.rounds ?? 3;
32
+ /** The round limit of a review step: its kind's under `review.step_rounds`, else `review.rounds` (default 3). */
33
+ export function roundLimit(config, step) {
34
+ const own = step ? config.review?.step_rounds?.[stepKind(step)] : undefined;
35
+ return own ?? config.review?.rounds ?? 3;
33
36
  }
34
37
  export function fixAttempts(config) {
35
38
  return config.build?.fix_attempts ?? 3;
@@ -73,7 +76,7 @@ export function roundState(feature, config, step) {
73
76
  const records = feature.reviews.records.filter((r) => r.step === step);
74
77
  const last = records.at(-1) ?? null;
75
78
  const extra = extraRounds(feature, step);
76
- const limit = roundLimit(config) + extra;
79
+ const limit = roundLimit(config, step) + extra;
77
80
  const round = last?.round ?? 0;
78
81
  // Exhausted: still blocked, and the next round would pass the limit; a loop that an approval
79
82
  // or a passing verify review closed starts again at round 1 (nextRound).
package/dist/review.js CHANGED
@@ -15,7 +15,7 @@ import { acResults, loadResults, resultLabel } from './test-results.js';
15
15
  import { readTestRun, testRunProblem } from './test-run.js';
16
16
  import { WORKFLOWS, hasReviewStep, workflowOf } from './workflow.js';
17
17
  import { proposalProblems } from './discovery.js';
18
- import { personaText, unitTeam } from './teams.js';
18
+ import { personaText, personasFor, unitTeam } from './teams.js';
19
19
  import { LOG_FILE, appendLog } from './log.js';
20
20
  import { AgjanError } from './errors.js';
21
21
  import { nextRound, roundState } from './review-policy.js';
@@ -230,7 +230,7 @@ export function buildContextText(root, config, feature, parsed) {
230
230
  parts.push(section('Checklist', CHECKLISTS[parsed.kind]));
231
231
  // The unit's team adds what the reviewer works with; it never removes a check (decision 92).
232
232
  const team = unitTeam(config, feature.approvals.feature.team);
233
- const reviewer = team?.team ? personaText(team.name, 'reviewer', team.team.personas.reviewer) : null;
233
+ const reviewer = team?.team ? personaText(config, team.name, personasFor(config, team.team, feature.kind, 'reviewer')) : null;
234
234
  if (reviewer)
235
235
  parts.push(section('Your team', reviewer));
236
236
  const baseline = join(root, FEATURES_DIR, 'project.md');
@@ -554,7 +554,7 @@ export function createQaContext(root, config, { feature: slug }) {
554
554
  section('Run locally (from agjan-docs/project.md)', runLocally || '(not described: start the application as the project README or package.json says)'),
555
555
  ...((() => {
556
556
  const team = unitTeam(config, feature.approvals.feature.team);
557
- const tester = team?.team ? personaText(team.name, 'tester', team.team.personas.tester) : null;
557
+ const tester = team?.team ? personaText(config, team.name, personasFor(config, team.team, feature.kind, 'qa')) : null;
558
558
  return tester ? [section('Your team', tester)] : [];
559
559
  })()),
560
560
  section('Test conventions', `${commands}\n- UI tests: ${ui ? '`npx agjan ui-test` runs the Playwright tests (it skips them, with the reason, where no browser can start)' : 'the project has no Playwright setup (no `test:ui` script): write service tests only'}\n- How tests are written in this stack: \`.claude/skills/cap-developer/references/testing.md\` (cds.test) and \`.claude/skills/fiori-developer/references/testing.md\` (Playwright). Read those for the test mechanics only.`),
package/dist/teams.js CHANGED
@@ -4,7 +4,10 @@ import { hashText } from './hash.js';
4
4
  import { AgjanError } from './errors.js';
5
5
  import { WORKFLOWS } from './workflow.js';
6
6
  export const ROLES = ['implementer', 'reviewer', 'tester', 'analyst'];
7
- /** The roles a workflow uses, besides the reviewer every workflow has. */
7
+ export const ROLE_AGENTS = ['main', 'reviewer', 'qa'];
8
+ /** The agent each built-in role reaches; implementer and analyst are the main agent in different workflows. */
9
+ const BUILT_IN_AGENT = { implementer: 'main', analyst: 'main', reviewer: 'reviewer', tester: 'qa' };
10
+ /** The built-in roles a workflow needs. */
8
11
  const ROLES_OF = {
9
12
  feature: ['implementer', 'reviewer', 'tester'],
10
13
  fix: ['implementer', 'reviewer'],
@@ -40,9 +43,34 @@ export const BUILT_IN_TEAMS = {
40
43
  },
41
44
  },
42
45
  };
43
- /** The built-in teams with the imported ones (loadConfig puts them in) and the project's own on top. */
46
+ /** A team definition with every persona resolved; a name with no persona under `personas` gives no skills (`teamProblems` reports it). */
47
+ function resolveTeam(config, team) {
48
+ const personas = Object.fromEntries(Object.entries(team.personas ?? {}).map(([role, p]) => [role, typeof p === 'string' ? (config.personas?.[p] ?? { skills: [] }) : p]));
49
+ return { description: team.description, workflows: team.workflows, personas };
50
+ }
51
+ /** The built-in teams with the imported ones (loadConfig puts them in) and the project's own on top, resolved. */
44
52
  export function allTeams(config) {
45
- return { ...BUILT_IN_TEAMS, ...(config.teams ?? {}) };
53
+ const defined = { ...BUILT_IN_TEAMS, ...(config.teams ?? {}) };
54
+ return Object.fromEntries(Object.entries(defined).map(([name, team]) => [name, resolveTeam(config, team)]));
55
+ }
56
+ /** The agent a role's persona reaches: a built-in role's, or the one its definition under `roles` names. */
57
+ export function roleAgent(config, role) {
58
+ return BUILT_IN_AGENT[role] ?? config.roles?.[role]?.agent ?? null;
59
+ }
60
+ /**
61
+ * The personas an agent works with in a workflow: the built-in role's first (the implementer or
62
+ * analyst for the main agent, the reviewer, the tester), then the team's own roles for that agent.
63
+ */
64
+ export function personasFor(config, team, kind, agent) {
65
+ const builtIn = agent === 'main' ? mainRole(kind) : agent === 'reviewer' ? 'reviewer' : 'tester';
66
+ const out = [];
67
+ if (team.personas[builtIn])
68
+ out.push({ role: builtIn, persona: team.personas[builtIn] });
69
+ for (const [role, persona] of Object.entries(team.personas)) {
70
+ if (!ROLES.includes(role) && roleAgent(config, role) === agent)
71
+ out.push({ role, persona });
72
+ }
73
+ return out;
46
74
  }
47
75
  /** The default team of a workflow: the project's choice (`team.<kind>`), else the first that serves it. */
48
76
  export function defaultTeam(config, kind) {
@@ -66,8 +94,9 @@ export function teamHash(team) {
66
94
  }
67
95
  /** What is wrong with a team, for the workflow it would run (or all it serves). */
68
96
  export function teamProblems(root, config, name, kind) {
97
+ const definition = config.teams?.[name] ?? BUILT_IN_TEAMS[name];
69
98
  const team = allTeams(config)[name];
70
- if (!team)
99
+ if (!definition || !team)
71
100
  return [`no team '${name}' (built in: ${Object.keys(BUILT_IN_TEAMS).join(', ')}; or define it under "teams" in agjan.config.json)`];
72
101
  const problems = [];
73
102
  if (!team.workflows?.length)
@@ -77,14 +106,25 @@ export function teamProblems(root, config, name, kind) {
77
106
  problems.push(`team '${name}': unknown workflow '${w}'`);
78
107
  if (kind && !team.workflows?.includes(kind))
79
108
  problems.push(`team '${name}' does not serve the ${WORKFLOWS[kind].name} workflow (it serves: ${team.workflows.join(', ')})`);
80
- for (const [role, persona] of Object.entries(team.personas ?? {})) {
81
- if (!ROLES.includes(role))
82
- problems.push(`team '${name}': unknown role '${role}' (roles: ${ROLES.join(', ')})`);
83
- for (const skill of persona?.skills ?? []) {
109
+ const custom = Object.keys(config.roles ?? {});
110
+ for (const [role, ref] of Object.entries(definition.personas ?? {})) {
111
+ const agent = roleAgent(config, role);
112
+ if (!agent)
113
+ problems.push(`team '${name}': unknown role '${role}' (roles: ${[...ROLES, ...custom].join(', ')}; or define it under "roles")`);
114
+ if (typeof ref === 'string' && !config.personas?.[ref])
115
+ problems.push(`team '${name}', ${role}: no persona '${ref}' under "personas"`);
116
+ for (const skill of team.personas[role]?.skills ?? []) {
84
117
  if (!existsSync(join(root, '.claude', 'skills', skill, 'SKILL.md')))
85
118
  problems.push(`team '${name}', ${role}: no skill '${skill}' in .claude/skills/`);
86
119
  }
120
+ // A role whose agent has no step in any of the team's workflows would never be used.
121
+ if (agent && !ROLES.includes(role) && !(team.workflows ?? []).some((w) => WORKFLOWS[w]?.track.some((t) => t.steps.some((s) => s.actor === agent)))) {
122
+ problems.push(`team '${name}', ${role}: its agent (${agent}) has no step in ${team.workflows.join(', ')}`);
123
+ }
87
124
  }
125
+ for (const role of custom)
126
+ if (ROLES.includes(role))
127
+ problems.push(`roles: '${role}' is a built-in role`);
88
128
  for (const w of team.workflows ?? []) {
89
129
  for (const role of ROLES_OF[w] ?? []) {
90
130
  if (!team.personas?.[role]?.skills?.length)
@@ -93,12 +133,17 @@ export function teamProblems(root, config, name, kind) {
93
133
  }
94
134
  return problems;
95
135
  }
96
- /** A persona as the agent in its role reads it: the skill files, then the instructions. */
97
- export function personaText(team, role, persona) {
98
- if (!persona)
136
+ /** The personas an agent works with, as it reads them: per role, the skill files, then the instructions. */
137
+ export function personaText(config, team, personas) {
138
+ if (!personas.length)
99
139
  return null;
100
- const skills = persona.skills.map((s) => `- \`.claude/skills/${s}/SKILL.md\` (and the references its table names for your topic)`).join('\n');
101
- return [`Team ${team}, ${role}. Work with these skills:`, skills, persona.instructions?.trim() ? `\n${persona.instructions.trim()}` : ''].join('\n').trim();
140
+ return personas
141
+ .map(({ role, persona }) => {
142
+ const what = config.roles?.[role]?.description;
143
+ const skills = persona.skills.map((s) => `- \`.claude/skills/${s}/SKILL.md\` (and the references its table names for your topic)`).join('\n');
144
+ return [`Team ${team}, ${role}${what ? ` (${what})` : ''}. Work with these skills:`, skills, persona.instructions?.trim() ? `\n${persona.instructions.trim()}` : ''].join('\n').trim();
145
+ })
146
+ .join('\n\n');
102
147
  }
103
148
  /** The role of the main agent in a workflow: it implements, or (map run, discovery) it analyses. */
104
149
  export function mainRole(kind) {
@@ -1,4 +1,4 @@
1
- import { BUILT_IN_TEAMS, allTeams, defaultTeam, mainRole, teamProblems } from './teams.js';
1
+ import { BUILT_IN_TEAMS, allTeams, defaultTeam, mainRole, personasFor, teamProblems } from './teams.js';
2
2
  import { DEFAULT_TIERS, reviewerFor, roundLimit, stepKind } from './review-policy.js';
3
3
  import { WORKFLOWS } from './workflow.js';
4
4
  /** Where a team comes from: agjan, an imported package (`<package>/<team>`), or the project's configuration. */
@@ -17,20 +17,26 @@ export function resolveWorkflow(root, config, kind, options = {}) {
17
17
  const fallback = defaultTeam(config, kind);
18
18
  const name = options.team ?? fallback;
19
19
  const team = name ? (allTeams(config)[name] ?? null) : null;
20
- const roleOf = { main: mainRole(kind), reviewer: 'reviewer', qa: 'tester', human: null };
21
20
  const qaOff = config.review?.qa === 'off';
22
21
  const stages = workflow.track.map((stage) => ({
23
22
  name: stage.name,
24
23
  steps: stage.steps
25
24
  .filter((step) => !step.mode || step.mode === mode)
26
25
  .map((step) => {
27
- const role = roleOf[step.actor];
26
+ const personas = team && step.actor !== 'human' ? personasFor(config, team, kind, step.actor) : [];
27
+ const builtIn = step.actor === 'main' ? mainRole(kind) : step.actor === 'reviewer' ? 'reviewer' : step.actor === 'qa' ? 'tester' : null;
28
28
  const resolved = {
29
29
  actor: step.actor,
30
30
  agent: step.actor === 'main' ? 'main agent' : 'you',
31
31
  does: step.does,
32
- role,
33
- persona: role ? (team?.personas[role] ?? null) : null,
32
+ role: builtIn,
33
+ persona: builtIn ? (team?.personas[builtIn] ?? null) : null,
34
+ personas: personas.map(({ role, persona }) => ({
35
+ role,
36
+ ...(config.roles?.[role]?.description ? { description: config.roles[role].description } : {}),
37
+ skills: persona.skills,
38
+ ...(persona.instructions ? { instructions: persona.instructions } : {}),
39
+ })),
34
40
  };
35
41
  if (step.review) {
36
42
  const kindOfStep = stepKind(step.review);
@@ -38,7 +44,7 @@ export function resolveWorkflow(root, config, kind, options = {}) {
38
44
  resolved.review = {
39
45
  step: step.review,
40
46
  tier: step.review === 'qa' ? 'qa' : (config.review?.tiers?.[kindOfStep] ?? DEFAULT_TIERS[kindOfStep] ?? 'balanced'),
41
- rounds: roundLimit(config),
47
+ rounds: roundLimit(config, step.review),
42
48
  ...(step.review === 'build:' ? { per: config.review?.build === 'task' ? 'task' : 'area' } : {}),
43
49
  };
44
50
  if (step.review === 'qa' && qaOff)
package/docs/guide.md CHANGED
@@ -437,9 +437,43 @@ included), and make it the default for a workflow:
437
437
  }
438
438
  ```
439
439
 
440
+ **Your own roles and shared personas.** Next to implementer, reviewer, tester and analyst you can
441
+ define roles under `roles`; each reaches one of the agents that already run (`main`, `reviewer`,
442
+ `qa`), which then works with that role's persona as well. A persona used by several teams can be
443
+ defined once under `personas` and named in each team:
444
+
445
+ ```json
446
+ {
447
+ "roles": {
448
+ "security-reviewer": { "agent": "reviewer", "description": "checks our security standard" }
449
+ },
450
+ "personas": {
451
+ "company-reviewer": { "skills": ["solution-reviewer"], "instructions": "Cite file and line." }
452
+ },
453
+ "teams": {
454
+ "company-delivery": {
455
+ "description": "Delivery with our security standard",
456
+ "workflows": ["feature"],
457
+ "personas": {
458
+ "implementer": { "skills": ["cap-developer", "fiori-developer"] },
459
+ "reviewer": "company-reviewer",
460
+ "security-reviewer": { "skills": ["company-security"] },
461
+ "tester": { "skills": ["qa-tester"] }
462
+ }
463
+ }
464
+ },
465
+ "review": { "step_rounds": { "design": 5 } }
466
+ }
467
+ ```
468
+
469
+ Here every review of a company-delivery unit works with both the reviewer's and the security
470
+ reviewer's skills, and the design review gets up to 5 rounds. A role adds knowledge to an agent's
471
+ existing steps; it starts no agent and adds no step. Imported packages use the built-in roles,
472
+ with their personas written out.
473
+
440
474
  A unit starts with the workflow's default team, or the one you name (`--team` on `new`,
441
475
  `fix start`, `discover start`), and records it with a hash of its definition. A persona
442
- starts no agent of its own: the implementer's skills reach the main agent through `status`,
476
+ starts no agent of its own: the implementer's or analyst's skills and instructions reach the main agent through `status` (its `team` and `follow` rows),
443
477
  the reviewer's and the tester's through their review and QA contexts. If the team's
444
478
  definition changes while a unit is under way, `status` and `check` say so.
445
479
  `npx agjan team list` lists the teams, `npx agjan team show <name>` their personas.
@@ -587,6 +621,7 @@ is wrong, so a typo is never a silent default.
587
621
  | `fix` | `max_total`, `max_per_file`, `protected`, `ignored`, `new_file_paths` |
588
622
  | `review.build` | `area` (default: one build review per completed area) or `task` |
589
623
  | `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 |
624
+ | `review.step_rounds.<step>` | the round limit of one kind of review step (`spec`, `design:light`, `design`, `build`, `qa`, `verify`, `fix`, `map`, `proposal`) over `review.rounds`, for example `{ "design": 5 }` |
590
625
  | `review.qa` | `on` (default) or `off`: the QA step in Verify for full-mode features |
591
626
  | `test_evidence` | `run` (default): CI and the acceptance need a passing `agjan test` run on the change; `names`: a test whose name contains the AC id is enough |
592
627
  | `review.tiers.<step>` | `balanced` or `deep` per step kind (`spec`, `design:light`, `design`, `build`, `verify`, `fix`, `map`); decides which reviewer agent runs it. Defaults: `deep` for `design` and `verify`, else `balanced`; `fast` uses the balanced agent |
@@ -595,6 +630,8 @@ is wrong, so a typo is never a silent default.
595
630
  | `limits.spec_kb`, `limits.design_kb` | soft size limits; `check` warns above them (defaults 12 and 20 KB; design covers `design.md` and `tasks.md`) |
596
631
  | `models.<host>.<tier>` | model of the reviewer agents per tier (`balanced`, `deep`); `"session"` (the default, written by `init` so you see it) runs the reviewer on the model of the session that starts it. Set it with `npx agjan models set deep <model>` in your terminal (`npx agjan models` lists the settings and, for Copilot, the models it offers). A deep reviewer on another model family than the main agent (for example `gpt-6-sol` while the main agent runs on Claude) misses other things than the main agent. Model names differ per host (Claude Code: `sonnet`, `opus` or a full id; Copilot: for example `claude-opus-5.5`). Copilot uses the agent file's model unless the session was started with `--model`, which overrides it. `doctor` shows what each reviewer runs on |
597
632
  | `mcp.servers.<name>` | documentation MCP servers: `command`, `args`, `env`, `areas`, `enabled` |
633
+ | `teams`, `team` | your own teams, and the default team per workflow ([Teams](#teams)) |
634
+ | `roles`, `personas` | your own roles, each reaching the main agent, the reviewer or the QA agent, and named personas teams refer to ([Teams](#teams)) |
598
635
  | `ci.policy_changes`, `ci.untracked_changes` | `warn` or `fail` in `check --ci`; CI reads them from the base branch, so a pull request cannot lower them for itself |
599
636
 
600
637
  `npx agjan status` prints the language, the round limit and the attempts in its first
@@ -17,10 +17,10 @@ shows how to use them.
17
17
  |---|---|---|---|
18
18
  | **Workflow** | A kind of work and its fixed steps: stages, independent reviews, the approvals you give, and what it may change. | feature, fix, map, discovery | Built into agjan; a project cannot change it. |
19
19
  | **Team** | A named group of personas for one or more workflows. 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
- | **Persona** | A role inside a team, with the skills (and optional instructions) that role works with. | the reviewer of sap-delivery | Inside its team; a persona does not exist on its own. |
20
+ | **Persona** | A role inside a team, with the skills (and optional instructions) that role works with. | the reviewer of sap-delivery | Inside its team, or defined once under `personas` in `agjan.config.json` and named by several teams. |
21
21
  | **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. |
22
22
 
23
- There are four **roles**, and a persona fills one of them:
23
+ There are four built-in **roles**, and a persona fills one of them:
24
24
 
25
25
  | Role | What it does |
26
26
  |---|---|
@@ -29,6 +29,10 @@ There are four **roles**, and a persona fills one of them:
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
+ A project can add its own roles under `roles`, such as a `security-reviewer`. Each one reaches an
33
+ agent that already runs (the main agent, the reviewer or the QA agent), which then works with that
34
+ role's persona as well. A role adds knowledge; it never adds an agent or a step.
35
+
32
36
  A **unit** is one piece of work that runs a workflow: one feature, one fix, one map run or
33
37
  one discovery.
34
38
 
@@ -61,10 +65,12 @@ The rules behind the arrows:
61
65
  - Each unit runs with **exactly one** team: the default, or the one named with `--team`
62
66
  when the unit starts. The unit records the team and a hash of its definition, so a later
63
67
  change to the team is reported.
64
- - A team has one persona per role, and must fill every role its workflows need with at
65
- least one skill.
68
+ - A team has one persona per role, and must fill every built-in role its workflows need with
69
+ at least one skill. Its own roles are optional extras for the same agents.
66
70
  - A persona starts no agent of its own. Its skills and instructions go to the agent that
67
71
  already does that job: the main agent, the reviewer or the QA agent.
72
+ - How many rounds each review gets is a setting: `review.rounds` for all, and
73
+ `review.step_rounds` for one kind of step (for example 5 for the design review).
68
74
  - A team cannot remove a step. Every workflow keeps an independent review, approvals
69
75
  stamped by a script, scope checks, and a person who decides at the end.
70
76
 
@@ -8,6 +8,13 @@ description: Build an approved agjan design task by task, within the approved pa
8
8
  Implement `tasks.md` in order. The approved design is the contract: build what it says,
9
9
  where it says.
10
10
 
11
+ ## Your team
12
+
13
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
14
+ your role works with (read them next to the ones this skill names), and each `follow` row is
15
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
16
+ skill or with the user, this skill and the user win.
17
+
11
18
  ## Arriving in auto mode
12
19
 
13
20
  In auto mode you reach this skill from the previous one within one run, through `npx agjan skill build`.
@@ -8,6 +8,13 @@ description: Full-mode agjan design. After the spec is approved, the role skills
8
8
  Answer the approved spec technically: areas, decisions, tasks. Light changes are
9
9
  designed by `/agjan-spec`; this skill is for full mode.
10
10
 
11
+ ## Your team
12
+
13
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
14
+ your role works with (read them next to the ones this skill names), and each `follow` row is
15
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
16
+ skill or with the user, this skill and the user win.
17
+
11
18
  ## Arriving in auto mode
12
19
 
13
20
  In auto mode you reach this skill from the previous one within one run, through `npx agjan skill design`.
@@ -11,6 +11,13 @@ You answer it like an SAP consultant preparing a workshop: options, trade-offs a
11
11
  recommendation the user can approve. You change no code; building the recommendation is a
12
12
  feature afterwards (`/agjan-spec`).
13
13
 
14
+ ## Your team
15
+
16
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
17
+ your role works with (read them next to the ones this skill names), and each `follow` row is
18
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
19
+ skill or with the user, this skill and the user win.
20
+
14
21
  ## 1. Start
15
22
 
16
23
  - If you are on the base branch, the work needs a branch of its own. `npx agjan status`
@@ -34,7 +41,7 @@ Otherwise do not ask: state your assumptions in the Context.
34
41
  - The application: `agjan-docs/project.md`, then the files that matter for the question
35
42
  (models, services, `mta.yaml`, `xs-security.json`, app manifests). Read; never change.
36
43
  - agjan's knowledge: the skills of your role in the discovery's team (`npx agjan status`,
37
- `team` row; by default btp-architect, cap-developer, fiori-developer; read their tables and
44
+ `team` row, see Your team; by default btp-architect, cap-developer, fiori-developer; read their tables and
38
45
  only the matching references) and the source list
39
46
  `.claude/skills/agjan-ask/references/sources.md`.
40
47
  - The documentation servers configured for the project and, where your host can and the
@@ -8,6 +8,13 @@ description: Fast path for a small agjan change (a bug fix, a label, a small cor
8
8
  A small change to existing files, checked by script and reviewed, without Spec and
9
9
  Design. A human still reviews and merges the pull request.
10
10
 
11
+ ## Your team
12
+
13
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
14
+ your role works with (read them next to the ones this skill names), and each `follow` row is
15
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
16
+ skill or with the user, this skill and the user win.
17
+
11
18
  ## 1. Is it a fix?
12
19
 
13
20
  A fix changes existing files only (new files only for tests), stays within the
@@ -8,6 +8,13 @@ description: Map an existing application for agjan. Writes the short architectur
8
8
  Give later specs and designs the picture of the application: what exists and where.
9
9
  The merge of this branch is its approval.
10
10
 
11
+ ## Your team
12
+
13
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
14
+ your role works with (read them next to the ones this skill names), and each `follow` row is
15
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
16
+ skill or with the user, this skill and the user win.
17
+
11
18
  ## 1. Start
12
19
 
13
20
  On a branch of its own, without features or fixes. If you are on the base branch:
@@ -9,6 +9,13 @@ argument-hint: <what the user wants>
9
9
  Turn the user's request into an approved-ready `spec.md`, then decide light or full
10
10
  design. You write; the agjan reviewer checks; the human approves.
11
11
 
12
+ ## Your team
13
+
14
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
15
+ your role works with (read them next to the ones this skill names), and each `follow` row is
16
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
17
+ skill or with the user, this skill and the user win.
18
+
12
19
  ## 1. Start, continue or revise
13
20
 
14
21
  Run `npx agjan status`. It shows the features this branch carries:
@@ -8,6 +8,13 @@ description: Verify a built agjan feature. Full build, tests and lint, the basel
8
8
  Prove that the feature is complete and consistent, and hand it to the human, who
9
9
  accepts it (Gate 3, `npx agjan approve verify`).
10
10
 
11
+ ## Your team
12
+
13
+ Once the unit exists, `npx agjan status` shows its team: the `team` row lists the skills
14
+ your role works with (read them next to the ones this skill names), and each `follow` row is
15
+ an instruction of your team for you. Follow those instructions; where one conflicts with this
16
+ skill or with the user, this skill and the user win.
17
+
11
18
  ## Arriving in auto mode
12
19
 
13
20
  In auto mode you reach this skill from the previous one within one run, through `npx agjan skill verify`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agjan",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
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",
@@ -36,19 +36,37 @@
36
36
  "description": { "type": "string" },
37
37
  "workflows": { "type": "array", "items": { "enum": ["feature", "fix", "map", "discovery"] }, "minItems": 1 },
38
38
  "personas": {
39
+ "description": "A persona per role (implementer, reviewer, tester, analyst, or one under \"roles\"): inline, or the name of one under \"personas\".",
39
40
  "type": "object",
40
- "propertyNames": { "enum": ["implementer", "reviewer", "tester", "analyst"] },
41
41
  "additionalProperties": {
42
- "type": "object",
43
- "required": ["skills"],
44
- "properties": { "skills": { "type": "array", "items": { "type": "string" } }, "instructions": { "type": "string" } },
45
- "additionalProperties": false
42
+ "oneOf": [
43
+ { "$ref": "#/definitions/persona" },
44
+ { "type": "string", "minLength": 1 }
45
+ ]
46
46
  }
47
47
  }
48
48
  },
49
49
  "additionalProperties": false
50
50
  }
51
51
  },
52
+ "roles": {
53
+ "description": "The project's own roles next to implementer, reviewer, tester and analyst (decision 94): each reaches one agent, which works with its persona too.",
54
+ "type": "object",
55
+ "additionalProperties": {
56
+ "type": "object",
57
+ "required": ["agent"],
58
+ "properties": {
59
+ "agent": { "enum": ["main", "reviewer", "qa"], "description": "main: the main agent; reviewer: the reviewer agents; qa: the QA agent." },
60
+ "description": { "type": "string" }
61
+ },
62
+ "additionalProperties": false
63
+ }
64
+ },
65
+ "personas": {
66
+ "description": "Named personas teams refer to by name (decision 94).",
67
+ "type": "object",
68
+ "additionalProperties": { "$ref": "#/definitions/persona" }
69
+ },
52
70
  "team": {
53
71
  "description": "The default team per workflow.",
54
72
  "type": "object",
@@ -96,6 +114,12 @@
96
114
  "properties": {
97
115
  "build": { "enum": ["area", "task"] },
98
116
  "rounds": { "type": "integer", "minimum": 1 },
117
+ "step_rounds": {
118
+ "description": "The round limit of a kind of review step, over rounds.",
119
+ "type": "object",
120
+ "propertyNames": { "enum": ["spec", "design:light", "design", "build", "qa", "verify", "fix", "map", "proposal"] },
121
+ "additionalProperties": { "type": "integer", "minimum": 1 }
122
+ },
99
123
  "tiers": { "type": "object", "additionalProperties": { "enum": ["fast", "balanced", "deep"] } },
100
124
  "qa": { "enum": ["on", "off"], "description": "The QA step in Verify for full-mode features (default on): the agjan-qa agent writes and runs tests from the spec alone." }
101
125
  },
@@ -143,5 +167,17 @@
143
167
  "additionalProperties": false
144
168
  }
145
169
  },
170
+ "definitions": {
171
+ "persona": {
172
+ "type": "object",
173
+ "required": ["skills"],
174
+ "properties": {
175
+ "skills": { "type": "array", "items": { "type": "string" } },
176
+ "instructions": { "type": "string" },
177
+ "description": { "type": "string" }
178
+ },
179
+ "additionalProperties": false
180
+ }
181
+ },
146
182
  "additionalProperties": false
147
183
  }