agjan 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/guide.md +2 -2
- package/package.json +1 -1
- package/schemas/config.schema.json +5 -1
- package/src/adapters/claude-code.mjs +6 -4
- package/src/adapters/copilot.mjs +5 -4
- package/src/commands/setup.mjs +35 -5
- package/src/config.mjs +14 -0
package/docs/guide.md
CHANGED
|
@@ -150,7 +150,7 @@ lists replace. The schema is `node_modules/agjan/schemas/config.schema.json`.
|
|
|
150
150
|
"verify": { "cap": { "test": "npm test", "results": "reports/junit.xml" } },
|
|
151
151
|
"fix": { "max_total": 80, "max_per_file": 50 },
|
|
152
152
|
"review": { "build": "area" },
|
|
153
|
-
"models": { "claude-code": { "balanced": "
|
|
153
|
+
"models": { "claude-code": { "balanced": "session", "deep": "opus" }, "copilot": { "balanced": "session", "deep": "session" } },
|
|
154
154
|
"mcp": { "servers": { "ui5": { "enabled": false } } },
|
|
155
155
|
"ci": { "policy_changes": "warn", "untracked_changes": "fail" }
|
|
156
156
|
}
|
|
@@ -173,7 +173,7 @@ lists replace. The schema is `node_modules/agjan/schemas/config.schema.json`.
|
|
|
173
173
|
| `build.fix_attempts` | attempts for failing deterministic checks before the agent stops (default 3) |
|
|
174
174
|
| `language` | language of the documents' text (default `en`); headings, ids and keywords stay English |
|
|
175
175
|
| `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`) |
|
|
176
|
-
| `models.<host>.<tier>` | model of the reviewer agents per tier (`balanced`, `deep`) |
|
|
176
|
+
| `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. Model names differ per host (Claude Code: `sonnet`, `opus`; Copilot: for example `claude-opus-5.5`). `doctor` shows what each reviewer runs on |
|
|
177
177
|
| `mcp.servers.<name>` | documentation MCP servers: `command`, `args`, `env`, `areas`, `enabled` |
|
|
178
178
|
| `ci.policy_changes`, `ci.untracked_changes` | `warn` or `fail` in `check --ci` |
|
|
179
179
|
|
package/package.json
CHANGED
|
@@ -67,7 +67,11 @@
|
|
|
67
67
|
},
|
|
68
68
|
"additionalProperties": false
|
|
69
69
|
},
|
|
70
|
-
"models": {
|
|
70
|
+
"models": {
|
|
71
|
+
"description": "Reviewer agent models per host and tier (balanced, deep). 'session' runs the reviewer on the model of the session that starts it.",
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
74
|
+
},
|
|
71
75
|
"mcp": {
|
|
72
76
|
"type": "object",
|
|
73
77
|
"properties": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringify as toYaml } from 'yaml';
|
|
2
2
|
import { skillBody } from '../managed.mjs';
|
|
3
|
+
import { agentModel } from '../config.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Claude Code adapter (design 13): the generated reviewer agents and the deny rules for
|
|
@@ -8,7 +9,8 @@ import { skillBody } from '../managed.mjs';
|
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
export const HOST = 'claude-code';
|
|
11
|
-
|
|
12
|
+
/** The models earlier versions used when none were configured; `sync` writes them for such projects. */
|
|
13
|
+
export const LEGACY_MODELS = { balanced: 'sonnet', deep: 'opus' };
|
|
12
14
|
|
|
13
15
|
/** One agent per reviewer tier; workflow skills pick the tier per step (design 7.3). */
|
|
14
16
|
const REVIEWERS = [
|
|
@@ -65,7 +67,7 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
65
67
|
`agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
|
|
66
68
|
'review of a step; it records its result itself.',
|
|
67
69
|
tools: 'Read, Grep, Glob, mcp__agjan__review_context, mcp__agjan__review_record',
|
|
68
|
-
model,
|
|
70
|
+
...(model ? { model } : {}),
|
|
69
71
|
// Scoped to this agent only: the writer session must not have review_record.
|
|
70
72
|
mcpServers: [
|
|
71
73
|
{
|
|
@@ -89,12 +91,12 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
89
91
|
|
|
90
92
|
/** The plan items this adapter contributes. */
|
|
91
93
|
export function plan(config, skills) {
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
const skill = skills['solution-reviewer/SKILL.md'];
|
|
94
96
|
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
95
97
|
kind: 'file',
|
|
96
98
|
path: `.claude/agents/${name}.md`,
|
|
97
|
-
content: reviewerAgent(name, tier,
|
|
99
|
+
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
98
100
|
}));
|
|
99
101
|
items.push({
|
|
100
102
|
kind: 'json',
|
package/src/adapters/copilot.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringify as toYaml } from 'yaml';
|
|
2
2
|
import { skillBody } from '../managed.mjs';
|
|
3
|
+
import { agentModel } from '../config.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* GitHub Copilot adapter (design 13), verified with the Copilot CLI
|
|
@@ -16,8 +17,8 @@ export const HOST = 'copilot';
|
|
|
16
17
|
export const HOOK_FILE = '.github/hooks/agjan-guard.json';
|
|
17
18
|
export const GUARD = 'node_modules/agjan/kit/hooks/guard.mjs';
|
|
18
19
|
|
|
19
|
-
/**
|
|
20
|
-
export const
|
|
20
|
+
/** The models earlier versions used when none were configured: the session's model. */
|
|
21
|
+
export const LEGACY_MODELS = {};
|
|
21
22
|
|
|
22
23
|
const REVIEWERS = [
|
|
23
24
|
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
@@ -76,12 +77,12 @@ export function hookConfig() {
|
|
|
76
77
|
|
|
77
78
|
/** The plan items this adapter contributes. */
|
|
78
79
|
export function plan(config, skills) {
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
const skill = skills['solution-reviewer/SKILL.md'];
|
|
81
82
|
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
82
83
|
kind: 'file',
|
|
83
84
|
path: `.github/agents/${name}.agent.md`,
|
|
84
|
-
content: reviewerAgent(name, tier,
|
|
85
|
+
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
85
86
|
}));
|
|
86
87
|
items.push({ kind: 'file', path: HOOK_FILE, content: hookConfig() });
|
|
87
88
|
return items;
|
package/src/commands/setup.mjs
CHANGED
|
@@ -4,7 +4,9 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
|
-
import { CONFIG_FILE, RECOMMENDED_ALLOW, loadConfig, loadDomain } from '../config.mjs';
|
|
7
|
+
import { CONFIG_FILE, MODEL_TIERS, RECOMMENDED_ALLOW, SESSION_MODEL, agentModel, loadConfig, loadDomain } from '../config.mjs';
|
|
8
|
+
import { LEGACY_MODELS as CLAUDE_LEGACY } from '../adapters/claude-code.mjs';
|
|
9
|
+
import { LEGACY_MODELS as COPILOT_LEGACY } from '../adapters/copilot.mjs';
|
|
8
10
|
import { readJson, writeJson } from '../json-file.mjs';
|
|
9
11
|
import { applyPlan, planStatus } from '../managed.mjs';
|
|
10
12
|
import { ADAPTERS, buildPlan, unsupportedHosts } from '../plan.mjs';
|
|
@@ -44,16 +46,42 @@ function printResults(ctx, results) {
|
|
|
44
46
|
if (unchanged) ctx.out(s.gray(` ${unchanged} file(s) unchanged`));
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
const ADAPTER_LEGACY_MODELS = { 'claude-code': CLAUDE_LEGACY, copilot: COPILOT_LEGACY };
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Missing `models.<host>` entries for the configured hosts, so the reviewer models are
|
|
53
|
+
* visible in agjan.config.json. New projects get "session"; a project from an earlier
|
|
54
|
+
* version gets what it used implicitly (Claude Code: sonnet and opus), so nothing changes.
|
|
55
|
+
*/
|
|
56
|
+
function missingModels(raw, hosts, { existing }) {
|
|
57
|
+
const added = {};
|
|
58
|
+
for (const host of hosts) {
|
|
59
|
+
if (raw.models?.[host]) continue;
|
|
60
|
+
const legacy = existing ? ADAPTER_LEGACY_MODELS[host] ?? {} : {};
|
|
61
|
+
added[host] = Object.fromEntries(MODEL_TIERS.map((tier) => [tier, legacy[tier] ?? SESSION_MODEL]));
|
|
62
|
+
}
|
|
63
|
+
return added;
|
|
64
|
+
}
|
|
65
|
+
|
|
47
66
|
/** Writes the managed files for the current configuration and updates the recorded kit version. */
|
|
48
67
|
function doSync(ctx, { force }) {
|
|
49
68
|
const config = loadConfig(ctx.root);
|
|
50
69
|
for (const host of unsupportedHosts(config)) ctx.err(`agjan: host '${host}' has no adapter in this version; skipped`);
|
|
51
|
-
const results = applyPlan(ctx.root, buildPlan(config), { kit: ctx.kit, force });
|
|
52
70
|
const file = join(ctx.root, CONFIG_FILE);
|
|
53
71
|
const raw = readJson(file) ?? {};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const added = missingModels(raw, config.hosts, { existing: Boolean(raw.models) || raw.kit !== ctx.kit });
|
|
73
|
+
if (Object.keys(added).length) {
|
|
74
|
+
writeJson(file, { ...raw, models: { ...(raw.models ?? {}), ...added } });
|
|
75
|
+
config.models = { ...(config.models ?? {}), ...added };
|
|
76
|
+
}
|
|
77
|
+
const results = applyPlan(ctx.root, buildPlan(config), { kit: ctx.kit, force });
|
|
78
|
+
for (const [host, tiers] of Object.entries(added)) {
|
|
79
|
+
results.push({ path: CONFIG_FILE, action: `models.${host}: ${MODEL_TIERS.map((t) => `${t}=${tiers[t]}`).join(', ')}` });
|
|
80
|
+
}
|
|
81
|
+
const current = readJson(file) ?? {};
|
|
82
|
+
if (current.kit !== ctx.kit) {
|
|
83
|
+
writeJson(file, { ...current, kit: ctx.kit });
|
|
84
|
+
results.push({ path: CONFIG_FILE, action: current.kit ? `kit ${current.kit} -> ${ctx.kit}` : `kit ${ctx.kit}` });
|
|
57
85
|
}
|
|
58
86
|
return results;
|
|
59
87
|
}
|
|
@@ -90,6 +118,7 @@ export async function init(ctx, argv) {
|
|
|
90
118
|
domains,
|
|
91
119
|
hosts,
|
|
92
120
|
language: values.language ?? 'en',
|
|
121
|
+
models: missingModels({}, hosts, { existing: false }),
|
|
93
122
|
};
|
|
94
123
|
if (values.base) config.git = { base: values.base };
|
|
95
124
|
// Opt-in (design decision 61): asked once; without a terminal, nothing is allowed.
|
|
@@ -267,6 +296,7 @@ export function doctor(ctx) {
|
|
|
267
296
|
}
|
|
268
297
|
const allow = config.agent?.allow ?? [];
|
|
269
298
|
ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
|
|
299
|
+
ok('reviewer models', config.hosts.map((h) => `${h}: ${MODEL_TIERS.map((t) => `${t} ${agentModel(config, h, t) ?? 'session model'}`).join(', ')}`).join('; '));
|
|
270
300
|
ok('script edits', config.agent?.script_edits === 'allow' ? 'allowed (agent.script_edits)' : 'denied by the guard: agents edit files with their edit tool');
|
|
271
301
|
const ignored = git(root, ['check-ignore', '-q', '.agjan/x'], { allowFail: true }) !== null;
|
|
272
302
|
if (!ignored) warn('.gitignore', '.agjan/ is not ignored; run: npx agjan sync');
|
package/src/config.mjs
CHANGED
|
@@ -12,6 +12,20 @@ const KIT_DIR = new URL('../kit/', import.meta.url);
|
|
|
12
12
|
*/
|
|
13
13
|
export const RECOMMENDED_ALLOW = ['npx agjan', 'npm test', 'git status', 'git diff', 'git log', 'git add', 'git commit'];
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Reviewer models (`models.<host>.<tier>`). "session" means the reviewer agent runs on the
|
|
17
|
+
* model of the session that starts it: no model is written into the agent file. `init`
|
|
18
|
+
* writes this default visibly for every host, so users notice it and can change it.
|
|
19
|
+
*/
|
|
20
|
+
export const SESSION_MODEL = 'session';
|
|
21
|
+
export const MODEL_TIERS = ['balanced', 'deep'];
|
|
22
|
+
|
|
23
|
+
/** The model to write into an agent file, or undefined for the session's model. */
|
|
24
|
+
export function agentModel(config, host, tier) {
|
|
25
|
+
const value = config.models?.[host]?.[tier] ?? config.models?.[host]?.balanced;
|
|
26
|
+
return value && value !== SESSION_MODEL ? value : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
|
16
30
|
const DEFAULTS = {
|
|
17
31
|
domains: ['btp'],
|