agjan 0.0.29 → 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 +4 -3
- 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 +7 -3
- 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 +26 -10
- package/dist/commands/team.js +16 -12
- package/dist/commands/workflow.js +10 -9
- package/dist/config.js +55 -49
- package/dist/defaults-file.js +5 -3
- package/dist/imports.js +4 -6
- package/dist/mcp-config.js +1 -1
- package/dist/mcp.js +31 -3
- package/dist/review.js +12 -7
- package/dist/schema.js +4 -0
- package/dist/teams.js +141 -37
- package/dist/terminal.js +3 -0
- package/dist/validate.js +3 -3
- package/dist/worker.js +120 -0
- package/dist/workflow-view.js +25 -15
- package/docs/guide.md +76 -30
- package/docs/workflows-and-teams.md +53 -18
- 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 +53 -53
- package/kit/domains/btp/domain.json +0 -29
package/dist/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readdirSync } from 'node:fs';
|
|
1
2
|
import { join } from 'node:path';
|
|
2
3
|
import { readJson } from './json-file.js';
|
|
3
4
|
import { importedTeams } from './imports.js';
|
|
@@ -15,6 +16,15 @@ export const SESSION_MODEL = 'session';
|
|
|
15
16
|
export const MODEL_TIERS = ['balanced', 'deep'];
|
|
16
17
|
/** Every agent tier `agjan models` sets: the reviewers' and the QA agent's (decision 81). */
|
|
17
18
|
export const AGENT_TIERS = [...MODEL_TIERS, 'qa'];
|
|
19
|
+
/**
|
|
20
|
+
* The model of a worker agent (decision 100): `models.<host>.worker` for agjan-worker,
|
|
21
|
+
* `models.<host>.worker-deep` for agjan-worker-deep; without one, the session's model (never
|
|
22
|
+
* a reviewer's, so the reviewers stay on models of their own).
|
|
23
|
+
*/
|
|
24
|
+
export function workerModel(config, host, tier) {
|
|
25
|
+
const value = config.models?.[host]?.[tier === 'deep' ? 'worker-deep' : 'worker'];
|
|
26
|
+
return value && value !== SESSION_MODEL ? value : undefined;
|
|
27
|
+
}
|
|
18
28
|
/** The model to write into an agent file, or undefined for the session's model. */
|
|
19
29
|
export function agentModel(config, host, tier) {
|
|
20
30
|
const models = config.models?.[host];
|
|
@@ -22,9 +32,8 @@ export function agentModel(config, host, tier) {
|
|
|
22
32
|
const value = models?.[tier] ?? (tier === 'qa' ? models?.deep : undefined) ?? models?.balanced;
|
|
23
33
|
return value && value !== SESSION_MODEL ? value : undefined;
|
|
24
34
|
}
|
|
25
|
-
/** Package defaults
|
|
35
|
+
/** Package defaults; the project's agjan.config.json is layered on top. */
|
|
26
36
|
export const DEFAULTS = {
|
|
27
|
-
domains: ['btp'],
|
|
28
37
|
hosts: ['claude-code'],
|
|
29
38
|
language: 'en',
|
|
30
39
|
git: { base: null },
|
|
@@ -32,6 +41,7 @@ export const DEFAULTS = {
|
|
|
32
41
|
risk_paths: [],
|
|
33
42
|
application: [],
|
|
34
43
|
tests: {},
|
|
44
|
+
watched: [],
|
|
35
45
|
fix: {
|
|
36
46
|
max_total: 80,
|
|
37
47
|
max_per_file: 50,
|
|
@@ -58,11 +68,43 @@ export function merge(base, override) {
|
|
|
58
68
|
out[key] = merge(base[key], value);
|
|
59
69
|
return out;
|
|
60
70
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
/** Area names: lowercase, as task ids and review steps (`build:<area>`) use them. */
|
|
72
|
+
export const AREA_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
73
|
+
/** The one area of a project that defines none: the whole application. */
|
|
74
|
+
export const DEFAULT_AREAS = {
|
|
75
|
+
app: { title: 'Application', description: 'What the application does, its main parts and how they fit together.' },
|
|
76
|
+
};
|
|
77
|
+
/** The areas of a project, resolved from its `areas` (decision 98): the default one when it defines none. */
|
|
78
|
+
export function resolveAreas(defined) {
|
|
79
|
+
const source = defined && Object.keys(defined).length ? defined : DEFAULT_AREAS;
|
|
80
|
+
return Object.fromEntries(Object.entries(source).map(([name, a]) => [name, {
|
|
81
|
+
id: name,
|
|
82
|
+
name,
|
|
83
|
+
title: a.title ?? name,
|
|
84
|
+
description: a.description ?? '',
|
|
85
|
+
skills: a.skills ?? [],
|
|
86
|
+
}]));
|
|
87
|
+
}
|
|
88
|
+
/** The per-area settings the rest of agjan reads, derived from `areas`. */
|
|
89
|
+
function areaSettings(defined) {
|
|
90
|
+
const entries = Object.entries(defined);
|
|
91
|
+
return {
|
|
92
|
+
scope: { implicit: Object.fromEntries(entries.map(([n, a]) => [n, a.implicit ?? []])) },
|
|
93
|
+
tests: Object.fromEntries(entries.map(([n, a]) => [n, a.tests ?? []])),
|
|
94
|
+
verify: Object.fromEntries(entries.map(([n, a]) => [n, a.verify ?? {}])),
|
|
95
|
+
lint: Object.fromEntries(entries.filter(([, a]) => a.lint !== undefined).map(([n, a]) => [n, a.lint ?? null])),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const PRESETS_DIR = new URL('presets/', KIT_DIR);
|
|
99
|
+
/** The presets `init` offers, generic first. */
|
|
100
|
+
export function presetIds() {
|
|
101
|
+
return readdirSync(PRESETS_DIR).filter((f) => f.endsWith('.json')).map((f) => f.slice(0, -5)).sort((a, b) => (a === 'generic' ? -1 : b === 'generic' ? 1 : a.localeCompare(b)));
|
|
102
|
+
}
|
|
103
|
+
export function loadPreset(id) {
|
|
104
|
+
const preset = /^[a-z][a-z0-9-]*$/.test(id) ? readJson(new URL(`${id}.json`, PRESETS_DIR)) : null;
|
|
105
|
+
if (!preset)
|
|
106
|
+
throw new AgjanError(`unknown preset '${id}' (presets: ${presetIds().join(', ')})`);
|
|
107
|
+
return preset;
|
|
66
108
|
}
|
|
67
109
|
/** The project's own `review` settings (agjan.config.json as written), by the configuration loadConfig made of it. */
|
|
68
110
|
const writtenReview = new WeakMap();
|
|
@@ -76,8 +118,8 @@ export function projectSetsReview(config, key) {
|
|
|
76
118
|
}
|
|
77
119
|
/**
|
|
78
120
|
* Loads the effective configuration of the project at `root`: package defaults, then
|
|
79
|
-
*
|
|
80
|
-
*
|
|
121
|
+
* agjan.config.json. Resolves the project's areas (decision 98) and derives the per-area
|
|
122
|
+
* settings (implicit paths, tests, verify commands, linters) from them.
|
|
81
123
|
*/
|
|
82
124
|
export function loadConfig(root) {
|
|
83
125
|
const project = readJson(join(root, CONFIG_FILE)) ?? {};
|
|
@@ -88,49 +130,13 @@ export function loadConfig(root) {
|
|
|
88
130
|
if (problems.length) {
|
|
89
131
|
throw new AgjanError(`${CONFIG_FILE} does not match its schema (node_modules/agjan/schemas/config.schema.json):\n${problems.map((p) => ` - ${p}`).join('\n')}`);
|
|
90
132
|
}
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
const shortCount = {};
|
|
95
|
-
for (const id of domainIds) {
|
|
96
|
-
const domain = loadDomain(id);
|
|
97
|
-
const implicit = {};
|
|
98
|
-
const tests = {};
|
|
99
|
-
const verify = {};
|
|
100
|
-
const lint = {};
|
|
101
|
-
for (const [name, area] of Object.entries(domain.areas)) {
|
|
102
|
-
const canonical = `${id}:${name}`;
|
|
103
|
-
areas[canonical] = { id: canonical, domain: id, name, role: area.role };
|
|
104
|
-
shortCount[name] = (shortCount[name] ?? 0) + 1;
|
|
105
|
-
implicit[name] = area.implicit ?? [];
|
|
106
|
-
tests[name] = area.tests ?? [];
|
|
107
|
-
verify[name] = area.verify ?? {};
|
|
108
|
-
if (area.lint)
|
|
109
|
-
lint[name] = area.lint;
|
|
110
|
-
}
|
|
111
|
-
config = merge(config, {
|
|
112
|
-
scope: { implicit },
|
|
113
|
-
tests,
|
|
114
|
-
verify,
|
|
115
|
-
lint,
|
|
116
|
-
risk_paths: [...config.risk_paths, ...(domain.risk_paths ?? [])],
|
|
117
|
-
application: [...config.application, ...(domain.application ?? [])],
|
|
118
|
-
fix: { protected: [...config.fix.protected, ...(domain.protected ?? [])] },
|
|
119
|
-
watched: [...(config.watched ?? []), ...(domain.watched ?? [])],
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
// Short ids resolve only when they are unique among the enabled domains (design 3).
|
|
123
|
-
for (const area of Object.values(areas)) {
|
|
124
|
-
if (shortCount[area.name] === 1)
|
|
125
|
-
areas[area.name] = area;
|
|
126
|
-
}
|
|
127
|
-
config = merge(config, project);
|
|
133
|
+
const { areas: defined, ...rest } = project;
|
|
134
|
+
const used = defined && Object.keys(defined).length ? defined : DEFAULT_AREAS;
|
|
135
|
+
const config = { ...merge(merge(DEFAULTS, rest), areaSettings(used)), areas: resolveAreas(used) };
|
|
128
136
|
// Imported teams (decision 93) sit under the project's own: a project team of the same name wins.
|
|
129
137
|
const imported = importedTeams(root);
|
|
130
138
|
if (Object.keys(imported).length)
|
|
131
139
|
config.teams = { ...imported, ...(config.teams ?? {}) };
|
|
132
|
-
config.domains = domainIds;
|
|
133
|
-
config.areas = areas;
|
|
134
140
|
writtenReview.set(config, isObject(project.review) ? project.review : {});
|
|
135
141
|
return config;
|
|
136
142
|
}
|
|
@@ -151,7 +157,7 @@ export function ciSettingsAt(root, commit) {
|
|
|
151
157
|
return null;
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
|
-
/**
|
|
160
|
+
/** The area of that name, or null. */
|
|
155
161
|
export function resolveArea(config, id) {
|
|
156
162
|
return config.areas[id] ?? null;
|
|
157
163
|
}
|
package/dist/defaults-file.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULTS, merge } from './config.js';
|
|
1
|
+
import { DEFAULTS, DEFAULT_AREAS, merge } from './config.js';
|
|
2
2
|
import { DEFAULT_TIERS } from './review-policy.js';
|
|
3
3
|
/**
|
|
4
4
|
* agjan's default settings as data: schemas/config.defaults.json, shipped in the package next
|
|
@@ -22,10 +22,12 @@ function reviewTiers() {
|
|
|
22
22
|
return Object.fromEntries(Object.entries(DEFAULT_TIERS).filter(([, tier]) => ['fast', 'balanced', 'deep'].includes(tier)));
|
|
23
23
|
}
|
|
24
24
|
export function defaultsDocument() {
|
|
25
|
+
// The per-area settings are derived from `areas`; a project does not set them itself.
|
|
26
|
+
const { scope: _scope, tests: _tests, verify: _verify, lint: _lint, ...settable } = DEFAULTS;
|
|
25
27
|
return {
|
|
26
|
-
description: "agjan's defaults for agjan.config.json
|
|
28
|
+
description: "agjan's defaults for agjan.config.json; the project's file overrides them (agjan init --preset writes a preset's areas and paths into it). Objects merge, arrays replace. A project without areas has the one area shown here. Review steps without a tier use balanced.",
|
|
27
29
|
format: 1,
|
|
28
|
-
defaults: merge(merge(
|
|
30
|
+
defaults: merge(merge(settable, IMPLICIT_DEFAULTS), { areas: DEFAULT_AREAS, review: { tiers: reviewTiers() } }),
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
export function defaultsFileText() {
|
package/dist/imports.js
CHANGED
|
@@ -51,13 +51,11 @@ function manifestProblems(data) {
|
|
|
51
51
|
if (data.teams !== undefined) {
|
|
52
52
|
for (const p of validate(loadSchema('config'), { teams: data.teams }))
|
|
53
53
|
problems.push(`${MANIFEST}: ${p}`);
|
|
54
|
-
// A package brings no roles
|
|
54
|
+
// A package brings no roles of its own: its teams use the built-in roles.
|
|
55
55
|
for (const [name, team] of Object.entries(data.teams ?? {})) {
|
|
56
|
-
for (const
|
|
56
|
+
for (const role of Object.keys(team?.roles ?? {})) {
|
|
57
57
|
if (!ROLES.includes(role))
|
|
58
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
59
|
}
|
|
62
60
|
}
|
|
63
61
|
}
|
|
@@ -130,8 +128,8 @@ export function planImport(source, commit) {
|
|
|
130
128
|
throw new AgjanError('the package is larger than 5 MiB');
|
|
131
129
|
const teams = {};
|
|
132
130
|
for (const [name, team] of Object.entries(manifest.teams ?? {})) {
|
|
133
|
-
const
|
|
134
|
-
teams[`${manifest.name}/${name}`] = { ...team,
|
|
131
|
+
const roles = Object.fromEntries(Object.entries(team.roles).map(([role, r]) => [role, { ...r, skills: r.skills.map((s) => skillNames.get(s) ?? s) }]));
|
|
132
|
+
teams[`${manifest.name}/${name}`] = { ...team, roles };
|
|
135
133
|
}
|
|
136
134
|
return { manifest, source, commit, files, teams };
|
|
137
135
|
}
|
package/dist/mcp-config.js
CHANGED
|
@@ -13,7 +13,7 @@ export const PINNED = JSON.parse(readFileSync(new URL('../kit/mcp/servers.json',
|
|
|
13
13
|
export const DEFAULT_SERVERS = Object.fromEntries(Object.entries(PINNED).map(([name, s]) => [name, { command: 'npx', args: ['-y', `${s.package}@${s.version}`], areas: s.areas }]));
|
|
14
14
|
/**
|
|
15
15
|
* The servers to write, and the names to remove (configured with `enabled: false`).
|
|
16
|
-
* A server is written only when one of its areas
|
|
16
|
+
* A server is written only when the project has one of its areas (kit servers: cap, fiori).
|
|
17
17
|
*/
|
|
18
18
|
export function mcpServers(config) {
|
|
19
19
|
const configured = { ...DEFAULT_SERVERS, ...(config.mcp?.servers ?? {}) };
|
package/dist/mcp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
2
|
import { createQaContext, createReviewContext, recordQa, recordReview } from './review.js';
|
|
3
|
-
import { selectFeature } from './feature.js';
|
|
3
|
+
import { loadFeature, selectFeature } from './feature.js';
|
|
4
|
+
import { createWorkerContext } from './worker.js';
|
|
4
5
|
import { AgjanError } from './errors.js';
|
|
5
6
|
/**
|
|
6
7
|
* The agjan MCP server (design 7.2): a minimal MCP implementation over stdio,
|
|
@@ -56,6 +57,27 @@ export const QA_TOOLS = [
|
|
|
56
57
|
},
|
|
57
58
|
},
|
|
58
59
|
];
|
|
60
|
+
/** The worker agents' tool (decision 100): their own server, so neither the main agent nor the reviewer sees it. */
|
|
61
|
+
export const WORKER_TOOLS = [
|
|
62
|
+
{
|
|
63
|
+
name: 'role_context',
|
|
64
|
+
title: 'agjan: get role context',
|
|
65
|
+
description: 'Returns your input as an agjan worker for one stage of a unit: your role and skills, what to do, what to ' +
|
|
66
|
+
'read, the paths you may write and how to hand back. Call it first; the main agent names the stage (and for ' +
|
|
67
|
+
'build the task) in its request.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
stage: { type: 'string', enum: ['spec', 'design', 'build', 'fix', 'map', 'proposal'] },
|
|
72
|
+
task: { type: 'string', description: 'The task id (build only), for example T1' },
|
|
73
|
+
feature: { type: 'string', description: 'The unit (feature slug, fixes/<id>, maps/<id>, discoveries/<slug>); optional when exactly one changed on the branch' },
|
|
74
|
+
},
|
|
75
|
+
required: ['stage'],
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
},
|
|
78
|
+
annotations: { readOnlyHint: false },
|
|
79
|
+
},
|
|
80
|
+
];
|
|
59
81
|
export const TOOLS = [
|
|
60
82
|
{
|
|
61
83
|
name: 'review_context',
|
|
@@ -98,6 +120,12 @@ function text(content, isError = false) {
|
|
|
98
120
|
/** Handles one tools/call; tool failures are results with isError, not protocol errors. */
|
|
99
121
|
function callTool(ctx, server, name, args = {}) {
|
|
100
122
|
try {
|
|
123
|
+
if (server.role === 'worker') {
|
|
124
|
+
if (name !== 'role_context')
|
|
125
|
+
return null;
|
|
126
|
+
const unit = loadFeature(ctx.root, selectFeature(ctx.root, ctx.config, args.feature));
|
|
127
|
+
return text(createWorkerContext(ctx.root, ctx.config, unit, { stage: args.stage, task: args.task }).text);
|
|
128
|
+
}
|
|
101
129
|
if (server.role === 'qa') {
|
|
102
130
|
if (name === 'qa_context') {
|
|
103
131
|
const feature = selectFeature(ctx.root, ctx.config, args.feature);
|
|
@@ -146,13 +174,13 @@ export function handleMessage(ctx, server, message) {
|
|
|
146
174
|
protocolVersion: SUPPORTED_VERSIONS.includes(requested) ? requested : SUPPORTED_VERSIONS[0],
|
|
147
175
|
capabilities: { tools: { listChanged: false } },
|
|
148
176
|
serverInfo: { name: 'agjan', version: ctx.kit },
|
|
149
|
-
instructions: 'agjan review tools. Only the agjan reviewer agent uses them.',
|
|
177
|
+
instructions: server.role === 'worker' ? 'agjan worker tools. Only the agjan worker agents use them.' : 'agjan review tools. Only the agjan reviewer agent uses them.',
|
|
150
178
|
});
|
|
151
179
|
}
|
|
152
180
|
case 'ping':
|
|
153
181
|
return reply({});
|
|
154
182
|
case 'tools/list':
|
|
155
|
-
return reply({ tools: server.role === 'qa' ? QA_TOOLS : TOOLS });
|
|
183
|
+
return reply({ tools: server.role === 'qa' ? QA_TOOLS : server.role === 'worker' ? WORKER_TOOLS : TOOLS });
|
|
156
184
|
case 'tools/call': {
|
|
157
185
|
const result = callTool(ctx, server, params?.name, params?.arguments);
|
|
158
186
|
return result ? reply(result) : fail(-32602, `unknown tool '${params?.name}'`);
|
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 {
|
|
18
|
+
import { roleText, rolesFor, unitTeam } from './teams.js';
|
|
19
19
|
import { LOG_FILE, appendLog } from './log.js';
|
|
20
20
|
import { AgjanError } from './errors.js';
|
|
21
21
|
import { nextRound, resolveQa, roundState } from './review-policy.js';
|
|
@@ -238,11 +238,11 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
238
238
|
parts.push(section(`This review: ${parsed.extra.id}`, `An extra review step of this project's ${unitWorkflow(feature)} workflow, on what its ${parsed.extra.stage} stage produced. Focus: ${parsed.extra.description}\n\nThe checklist of the stage's own review below still applies where it bears on this focus.`));
|
|
239
239
|
parts.push(section('Checklist', CHECKLISTS[parsed.kind]));
|
|
240
240
|
// The unit's team adds what the reviewer works with; it never removes a check (decision 92).
|
|
241
|
-
// An extra review names its role: the reviewer then works with that role's
|
|
241
|
+
// An extra review names its role: the reviewer then works with that role's skills in the team.
|
|
242
242
|
const team = unitTeam(config, feature.approvals.feature.team);
|
|
243
243
|
const role = parsed.extra?.role;
|
|
244
|
-
const
|
|
245
|
-
const reviewer = team?.team ?
|
|
244
|
+
const roles = !team?.team ? [] : role && role !== 'reviewer' ? (team.team.roles[role] ? [{ role, ...team.team.roles[role] }] : []) : rolesFor(config, team.team, feature.kind, 'reviewer');
|
|
245
|
+
const reviewer = team?.team ? roleText(config, team.name, roles) : null;
|
|
246
246
|
if (reviewer)
|
|
247
247
|
parts.push(section('Your team', reviewer));
|
|
248
248
|
const baseline = join(root, FEATURES_DIR, 'project.md');
|
|
@@ -262,7 +262,8 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
262
262
|
parts.push(section(docPath(feature, 'proposal.md'), fence(feature.proposal.text, 'md')));
|
|
263
263
|
if (baselineText)
|
|
264
264
|
parts.push(section(`${FEATURES_DIR}/project.md (the application)`, fence(baselineText, 'md')));
|
|
265
|
-
|
|
265
|
+
const skills = [...new Set(Object.values(config.areas).flatMap((a) => a.skills))];
|
|
266
|
+
parts.push(section('Sources to check claims against', `${skills.length ? `The skills of the project's areas in \`.claude/skills/\` (${skills.join(', ')}), the` : 'The'} skills of your team and \`.claude/skills/agjan-ask/references/sources.md\`.`));
|
|
266
267
|
}
|
|
267
268
|
else if (parsed.kind === 'map') {
|
|
268
269
|
if (!baselineText)
|
|
@@ -555,6 +556,10 @@ export function createQaContext(root, config, { feature: slug }) {
|
|
|
555
556
|
const runLocally = existsSync(baseline) ? (/^## Run locally\s*$([\s\S]*?)(?=^## |\s*$(?![\s\S]))/m.exec(readFileSync(baseline, 'utf8'))?.[1] ?? '').trim() : '';
|
|
556
557
|
const areaNames = [...new Set(feature.tasks.parsed.tasks.map((t) => resolveArea(config, t.area)?.name).filter((name) => Boolean(name)))];
|
|
557
558
|
const commands = areaNames.map((a) => `- ${a}: ${config.verify?.[a]?.test ?? 'npm test'} (tests: ${(config.tests[a] ?? []).join(', ') || '-'})`).join('\n');
|
|
559
|
+
// The testing references of the feature's areas' skills (decision 98).
|
|
560
|
+
const testingRefs = [...new Set(areaNames.flatMap((a) => config.areas[a]?.skills ?? []))]
|
|
561
|
+
.map((skill) => `.claude/skills/${skill}/references/testing.md`)
|
|
562
|
+
.filter((f) => existsSync(join(root, f)));
|
|
558
563
|
const ui = Boolean(readJson(join(root, 'package.json'))?.scripts?.['test:ui']);
|
|
559
564
|
const existing = qaTestFiles(root, feature.slug);
|
|
560
565
|
const parts = [
|
|
@@ -567,10 +572,10 @@ export function createQaContext(root, config, { feature: slug }) {
|
|
|
567
572
|
section('Run locally (from agjan-docs/project.md)', runLocally || '(not described: start the application as the project README or package.json says)'),
|
|
568
573
|
...((() => {
|
|
569
574
|
const team = unitTeam(config, feature.approvals.feature.team);
|
|
570
|
-
const tester = team?.team ?
|
|
575
|
+
const tester = team?.team ? roleText(config, team.name, rolesFor(config, team.team, feature.kind, 'qa')) : null;
|
|
571
576
|
return tester ? [section('Your team', tester)] : [];
|
|
572
577
|
})()),
|
|
573
|
-
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'}
|
|
578
|
+
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'}${testingRefs.length ? `\n- How tests are written in this stack: ${testingRefs.map((f) => `\`${f}\``).join(' and ')}. Read those for the test mechanics only.` : ''}`),
|
|
574
579
|
section('Your tests from earlier QA rounds', existing.length ? existing.map((f) => `- ${f}`).join('\n') : '(none: this is the first QA round)'),
|
|
575
580
|
section('Earlier rounds', reviewHistory(feature)),
|
|
576
581
|
section('Open findings', openFindings(feature, [QA_STEP])),
|
package/dist/schema.js
CHANGED
|
@@ -77,6 +77,10 @@ export function validate(schema, value, root = schema, path = '') {
|
|
|
77
77
|
errors.push(`${where}: unknown name; one of ${schema.propertyNames.enum.join(', ')}`);
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
|
+
if (schema.propertyNames?.pattern && !new RegExp(schema.propertyNames.pattern).test(key)) {
|
|
81
|
+
errors.push(`${where}: '${key}' is not a valid name (${schema.propertyNames.pattern})`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
80
84
|
if (schema.properties?.[key])
|
|
81
85
|
errors.push(...validate(schema.properties[key], item, root, where));
|
|
82
86
|
else if (schema.additionalProperties === false)
|
package/dist/teams.js
CHANGED
|
@@ -5,7 +5,26 @@ import { AgjanError } from './errors.js';
|
|
|
5
5
|
import { WORKFLOWS } from './workflow.js';
|
|
6
6
|
import { baseOf } from './customization.js';
|
|
7
7
|
export const ROLES = ['implementer', 'reviewer', 'tester', 'analyst'];
|
|
8
|
-
export const ROLE_AGENTS = ['main', 'reviewer', 'qa'];
|
|
8
|
+
export const ROLE_AGENTS = ['main', 'reviewer', 'qa', 'worker'];
|
|
9
|
+
/**
|
|
10
|
+
* The built-in worker roles (decision 100): a team gives them a stage under `stages` and
|
|
11
|
+
* skills under `roles`, like a role of the project's own.
|
|
12
|
+
*/
|
|
13
|
+
export const WORKER_ROLES = {
|
|
14
|
+
architect: { agent: 'worker', tier: 'deep', description: 'designs how the approved spec is built and splits it into tasks' },
|
|
15
|
+
developer: { agent: 'worker', tier: 'balanced', description: 'builds one task of the design, with its tests' },
|
|
16
|
+
};
|
|
17
|
+
/** The stages a team may give to a role, per built-in workflow: those where the main agent writes. */
|
|
18
|
+
export const STAGE_KEYS = {
|
|
19
|
+
feature: ['spec', 'design', 'build'],
|
|
20
|
+
fix: ['fix'],
|
|
21
|
+
map: ['map'],
|
|
22
|
+
discovery: ['proposal'],
|
|
23
|
+
};
|
|
24
|
+
/** The worker agent of a tier. */
|
|
25
|
+
export function workerAgentName(tier) {
|
|
26
|
+
return tier === 'deep' ? 'agjan-worker-deep' : 'agjan-worker';
|
|
27
|
+
}
|
|
9
28
|
/** The agent each built-in role reaches; implementer and analyst are the main agent in different workflows. */
|
|
10
29
|
const BUILT_IN_AGENT = { implementer: 'main', analyst: 'main', reviewer: 'reviewer', tester: 'qa' };
|
|
11
30
|
/** The built-in roles a workflow needs. */
|
|
@@ -16,11 +35,46 @@ const ROLES_OF = {
|
|
|
16
35
|
discovery: ['analyst', 'reviewer'],
|
|
17
36
|
};
|
|
18
37
|
const ROLE_SKILLS = ['cap-developer', 'fiori-developer', 'btp-architect'];
|
|
38
|
+
const DEVELOPERS = ['backend-developer', 'ui-developer'];
|
|
39
|
+
/**
|
|
40
|
+
* The built-in teams (decision 99): stack-neutral ones first, so a project without a
|
|
41
|
+
* `team` setting starts with them; the SAP BTP ones, which the sap-btp preset makes the
|
|
42
|
+
* defaults.
|
|
43
|
+
*/
|
|
19
44
|
export const BUILT_IN_TEAMS = {
|
|
45
|
+
delivery: {
|
|
46
|
+
description: 'Implements a feature on any stack: an architect agent designs it, developer agents build each task.',
|
|
47
|
+
workflows: ['feature'],
|
|
48
|
+
stages: { design: 'architect', build: 'developer' },
|
|
49
|
+
roles: {
|
|
50
|
+
implementer: { skills: ['solution-architect', 'technical-architect', ...DEVELOPERS] },
|
|
51
|
+
architect: { skills: ['technical-architect'] },
|
|
52
|
+
developer: { skills: DEVELOPERS },
|
|
53
|
+
reviewer: { skills: ['solution-reviewer', 'technical-architect', ...DEVELOPERS] },
|
|
54
|
+
tester: { skills: ['qa-tester'] },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
maintenance: {
|
|
58
|
+
description: 'Fixes a bounded defect, and maps an existing application, on any stack.',
|
|
59
|
+
workflows: ['fix', 'map'],
|
|
60
|
+
roles: {
|
|
61
|
+
implementer: { skills: DEVELOPERS },
|
|
62
|
+
analyst: { skills: ['technical-architect', ...DEVELOPERS] },
|
|
63
|
+
reviewer: { skills: ['solution-reviewer', ...DEVELOPERS] },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
advisory: {
|
|
67
|
+
description: 'Explores a question and recommends an option: build or reuse, integration, feasibility.',
|
|
68
|
+
workflows: ['discovery'],
|
|
69
|
+
roles: {
|
|
70
|
+
analyst: { skills: ['solution-architect', 'technical-architect'] },
|
|
71
|
+
reviewer: { skills: ['solution-reviewer', 'solution-architect'] },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
20
74
|
'sap-delivery': {
|
|
21
75
|
description: 'Implements a business feature on SAP BTP: CAP, Fiori elements and UI5, BTP services.',
|
|
22
76
|
workflows: ['feature'],
|
|
23
|
-
|
|
77
|
+
roles: {
|
|
24
78
|
implementer: { skills: ROLE_SKILLS },
|
|
25
79
|
reviewer: { skills: ['solution-reviewer', ...ROLE_SKILLS] },
|
|
26
80
|
tester: { skills: ['qa-tester'] },
|
|
@@ -29,7 +83,7 @@ export const BUILT_IN_TEAMS = {
|
|
|
29
83
|
'sap-maintenance': {
|
|
30
84
|
description: 'Fixes a bounded defect, and maps an existing application.',
|
|
31
85
|
workflows: ['fix', 'map'],
|
|
32
|
-
|
|
86
|
+
roles: {
|
|
33
87
|
implementer: { skills: ['cap-developer', 'fiori-developer'] },
|
|
34
88
|
analyst: { skills: ROLE_SKILLS },
|
|
35
89
|
reviewer: { skills: ['solution-reviewer', 'cap-developer', 'fiori-developer'] },
|
|
@@ -38,38 +92,70 @@ export const BUILT_IN_TEAMS = {
|
|
|
38
92
|
'sap-discovery': {
|
|
39
93
|
description: 'Explores a question and recommends an option: integration, BTP services, feasibility.',
|
|
40
94
|
workflows: ['discovery'],
|
|
41
|
-
|
|
95
|
+
roles: {
|
|
42
96
|
analyst: { skills: ['btp-architect', 'cap-developer', 'fiori-developer'] },
|
|
43
97
|
reviewer: { skills: ['solution-reviewer', 'btp-architect'] },
|
|
44
98
|
},
|
|
45
99
|
},
|
|
46
100
|
};
|
|
47
|
-
/**
|
|
48
|
-
function resolveTeam(config, team) {
|
|
49
|
-
const personas = Object.fromEntries(Object.entries(team.personas ?? {}).map(([role, p]) => [role, typeof p === 'string' ? (config.personas?.[p] ?? { skills: [] }) : p]));
|
|
50
|
-
return { description: team.description, workflows: team.workflows, personas };
|
|
51
|
-
}
|
|
52
|
-
/** The built-in teams with the imported ones (loadConfig puts them in) and the project's own on top, resolved. */
|
|
101
|
+
/** The built-in teams with the imported ones (loadConfig puts them in) and the project's own on top. */
|
|
53
102
|
export function allTeams(config) {
|
|
54
103
|
const defined = { ...BUILT_IN_TEAMS, ...(config.teams ?? {}) };
|
|
55
|
-
return Object.fromEntries(Object.entries(defined).map(([name, team]) => [name,
|
|
104
|
+
return Object.fromEntries(Object.entries(defined).map(([name, team]) => [name, {
|
|
105
|
+
description: team.description,
|
|
106
|
+
workflows: team.workflows,
|
|
107
|
+
roles: team.roles ?? {},
|
|
108
|
+
...(team.stages && Object.keys(team.stages).length ? { stages: team.stages } : {}),
|
|
109
|
+
}]));
|
|
56
110
|
}
|
|
57
|
-
/**
|
|
111
|
+
/** A role's definition: a built-in one's, else the project's under `roles`. */
|
|
112
|
+
export function roleDefinition(config, role) {
|
|
113
|
+
const builtIn = BUILT_IN_AGENT[role];
|
|
114
|
+
if (builtIn)
|
|
115
|
+
return { agent: builtIn };
|
|
116
|
+
return WORKER_ROLES[role] ?? config.roles?.[role] ?? null;
|
|
117
|
+
}
|
|
118
|
+
/** The agent a role reaches: a built-in role's, or the one its definition under `roles` names. */
|
|
58
119
|
export function roleAgent(config, role) {
|
|
59
|
-
return
|
|
120
|
+
return roleDefinition(config, role)?.agent ?? null;
|
|
121
|
+
}
|
|
122
|
+
/** The stage key a unit's stage or log stage maps to: Proposal is `proposal`, discover's `proposal`. */
|
|
123
|
+
export function stageKey(stage) {
|
|
124
|
+
const key = stage.toLowerCase();
|
|
125
|
+
return key === 'discover' ? 'proposal' : key;
|
|
126
|
+
}
|
|
127
|
+
/** The role a team gives a stage, with its agent, or null when the workflow's own role does it. */
|
|
128
|
+
export function stageOwner(config, team, stage) {
|
|
129
|
+
const key = stageKey(stage);
|
|
130
|
+
const role = team?.stages?.[key];
|
|
131
|
+
if (!team || !role)
|
|
132
|
+
return null;
|
|
133
|
+
const def = roleDefinition(config, role);
|
|
134
|
+
if (!def || (def.agent !== 'main' && def.agent !== 'worker'))
|
|
135
|
+
return null;
|
|
136
|
+
const what = team.roles[role] ?? { skills: [] };
|
|
137
|
+
return {
|
|
138
|
+
stage: key,
|
|
139
|
+
role,
|
|
140
|
+
agent: def.agent,
|
|
141
|
+
...(def.agent === 'worker' ? { worker: workerAgentName(def.tier) } : {}),
|
|
142
|
+
skills: what.skills ?? [],
|
|
143
|
+
...(what.instructions?.trim() ? { instructions: what.instructions.trim() } : {}),
|
|
144
|
+
};
|
|
60
145
|
}
|
|
61
146
|
/**
|
|
62
|
-
* The
|
|
63
|
-
* analyst for the main agent, the reviewer, the tester), then the team's own
|
|
147
|
+
* The roles an agent works as in a workflow, with their skills: the built-in role first (the
|
|
148
|
+
* implementer or analyst for the main agent, the reviewer, the tester), then the team's own
|
|
149
|
+
* roles for that agent.
|
|
64
150
|
*/
|
|
65
|
-
export function
|
|
151
|
+
export function rolesFor(config, team, kind, agent) {
|
|
66
152
|
const builtIn = agent === 'main' ? mainRole(kind) : agent === 'reviewer' ? 'reviewer' : 'tester';
|
|
67
153
|
const out = [];
|
|
68
|
-
if (team.
|
|
69
|
-
out.push({ role: builtIn,
|
|
70
|
-
for (const [role,
|
|
154
|
+
if (team.roles[builtIn])
|
|
155
|
+
out.push({ role: builtIn, ...team.roles[builtIn] });
|
|
156
|
+
for (const [role, what] of Object.entries(team.roles)) {
|
|
71
157
|
if (!ROLES.includes(role) && roleAgent(config, role) === agent)
|
|
72
|
-
out.push({ role,
|
|
158
|
+
out.push({ role, ...what });
|
|
73
159
|
}
|
|
74
160
|
return out;
|
|
75
161
|
}
|
|
@@ -109,9 +195,8 @@ export function teamHash(team) {
|
|
|
109
195
|
}
|
|
110
196
|
/** What is wrong with a team, for the workflow it would run (or all it serves). */
|
|
111
197
|
export function teamProblems(root, config, name, kind) {
|
|
112
|
-
const definition = config.teams?.[name] ?? BUILT_IN_TEAMS[name];
|
|
113
198
|
const team = allTeams(config)[name];
|
|
114
|
-
if (!
|
|
199
|
+
if (!team)
|
|
115
200
|
return [`no team '${name}' (built in: ${Object.keys(BUILT_IN_TEAMS).join(', ')}; or define it under "teams" in agjan.config.json)`];
|
|
116
201
|
const problems = [];
|
|
117
202
|
if (!team.workflows?.length)
|
|
@@ -122,41 +207,60 @@ export function teamProblems(root, config, name, kind) {
|
|
|
122
207
|
if (kind && !serves(config, team, kind))
|
|
123
208
|
problems.push(`team '${name}' does not serve the ${WORKFLOWS[kind]?.name ?? kind} workflow (it serves: ${team.workflows.join(', ')})`);
|
|
124
209
|
const custom = Object.keys(config.roles ?? {});
|
|
125
|
-
|
|
210
|
+
const known = [...ROLES, ...Object.keys(WORKER_ROLES), ...custom];
|
|
211
|
+
for (const [role, what] of Object.entries(team.roles)) {
|
|
126
212
|
const agent = roleAgent(config, role);
|
|
127
213
|
if (!agent)
|
|
128
|
-
problems.push(`team '${name}': unknown role '${role}' (roles: ${
|
|
129
|
-
|
|
130
|
-
problems.push(`team '${name}', ${role}: no persona '${ref}' under "personas"`);
|
|
131
|
-
for (const skill of team.personas[role]?.skills ?? []) {
|
|
214
|
+
problems.push(`team '${name}': unknown role '${role}' (roles: ${known.join(', ')}; or define it under "roles")`);
|
|
215
|
+
for (const skill of what.skills ?? []) {
|
|
132
216
|
if (!existsSync(join(root, '.claude', 'skills', skill, 'SKILL.md')))
|
|
133
217
|
problems.push(`team '${name}', ${role}: no skill '${skill}' in .claude/skills/`);
|
|
134
218
|
}
|
|
219
|
+
// A worker role works only through a stage the team gives it.
|
|
220
|
+
if (agent === 'worker' && !Object.values(team.stages ?? {}).includes(role))
|
|
221
|
+
problems.push(`team '${name}', ${role}: a worker role needs a stage under "stages" (one of ${stageKeys(config, team).join(', ')})`);
|
|
135
222
|
// A role whose agent has no step in any of the team's workflows would never be used.
|
|
136
|
-
if (agent && !ROLES.includes(role) && !(team.workflows ?? []).some((w) => WORKFLOWS[baseOf(config, w) ?? '']?.track.some((t) => t.steps.some((s) => s.actor === agent)))) {
|
|
223
|
+
if (agent && agent !== 'worker' && !ROLES.includes(role) && !(team.workflows ?? []).some((w) => WORKFLOWS[baseOf(config, w) ?? '']?.track.some((t) => t.steps.some((s) => s.actor === agent)))) {
|
|
137
224
|
problems.push(`team '${name}', ${role}: its agent (${agent}) has no step in ${team.workflows.join(', ')}`);
|
|
138
225
|
}
|
|
139
226
|
}
|
|
140
227
|
for (const role of custom)
|
|
141
|
-
if (ROLES.includes(role))
|
|
228
|
+
if (ROLES.includes(role) || WORKER_ROLES[role])
|
|
142
229
|
problems.push(`roles: '${role}' is a built-in role`);
|
|
230
|
+
// The stages: one the team's workflows have, given to a role of the main agent or a worker with skills in the team.
|
|
231
|
+
const stages = stageKeys(config, team);
|
|
232
|
+
for (const [stage, role] of Object.entries(team.stages ?? {})) {
|
|
233
|
+
if (!stages.includes(stage))
|
|
234
|
+
problems.push(`team '${name}': stages.${stage} is not a stage its workflows give a role (${stages.join(', ') || 'none'})`);
|
|
235
|
+
const agent = roleAgent(config, role);
|
|
236
|
+
if (!agent)
|
|
237
|
+
problems.push(`team '${name}': stages.${stage}: unknown role '${role}'`);
|
|
238
|
+
else if (agent !== 'main' && agent !== 'worker')
|
|
239
|
+
problems.push(`team '${name}': stages.${stage}: role '${role}' reaches the ${agent} agent; a stage needs the main agent or a worker`);
|
|
240
|
+
else if (!team.roles[role]?.skills?.length)
|
|
241
|
+
problems.push(`team '${name}': stages.${stage}: role '${role}' has no skills in the team`);
|
|
242
|
+
}
|
|
143
243
|
for (const w of team.workflows ?? []) {
|
|
144
244
|
for (const role of ROLES_OF[baseOf(config, w) ?? ''] ?? []) {
|
|
145
|
-
if (!team.
|
|
245
|
+
if (!team.roles[role]?.skills?.length)
|
|
146
246
|
problems.push(`team '${name}' serves ${w} but has no ${role} with skills`);
|
|
147
247
|
}
|
|
148
248
|
}
|
|
149
249
|
return problems;
|
|
150
250
|
}
|
|
151
|
-
/** The
|
|
152
|
-
|
|
153
|
-
|
|
251
|
+
/** The stages a team's workflows give a role. */
|
|
252
|
+
function stageKeys(config, team) {
|
|
253
|
+
return [...new Set((team.workflows ?? []).flatMap((w) => STAGE_KEYS[baseOf(config, w) ?? ''] ?? []))];
|
|
254
|
+
}
|
|
255
|
+
/** The roles an agent works as, as it reads them: per role, the skill files, then the instructions. */
|
|
256
|
+
export function roleText(config, team, roles) {
|
|
257
|
+
if (!roles.length)
|
|
154
258
|
return null;
|
|
155
|
-
return
|
|
156
|
-
.map(({ role,
|
|
259
|
+
return roles
|
|
260
|
+
.map(({ role, skills, instructions }) => {
|
|
157
261
|
const what = config.roles?.[role]?.description;
|
|
158
|
-
const
|
|
159
|
-
return [`Team ${team}, ${role}${what ? ` (${what})` : ''}. Work with these skills:`,
|
|
262
|
+
const files = skills.map((s) => `- \`.claude/skills/${s}/SKILL.md\` (and the references its table names for your topic)`).join('\n');
|
|
263
|
+
return [`Team ${team}, ${role}${what ? ` (${what})` : ''}. Work with these skills:`, files, instructions?.trim() ? `\n${instructions.trim()}` : ''].join('\n').trim();
|
|
160
264
|
})
|
|
161
265
|
.join('\n\n');
|
|
162
266
|
}
|
package/dist/terminal.js
CHANGED
|
@@ -142,6 +142,9 @@ async function pickOnTerminal(question, picker) {
|
|
|
142
142
|
}
|
|
143
143
|
finally {
|
|
144
144
|
write('\x1b[?25h');
|
|
145
|
+
// Back to line mode: a question after the picker reads Enter as the end of its line.
|
|
146
|
+
if (input.isRaw)
|
|
147
|
+
input.setRawMode(false);
|
|
145
148
|
input.destroy();
|
|
146
149
|
if (tty.output !== tty.input)
|
|
147
150
|
closeSync(tty.output);
|