agjan 0.0.23 → 0.0.25
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/dist/browser.js +25 -8
- package/dist/commands/setup.js +51 -1
- package/dist/config.js +1 -1
- package/dist/defaults-file.js +33 -0
- package/docs/guide.md +5 -1
- package/package.json +1 -1
- package/schemas/config.defaults.json +66 -0
package/dist/browser.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { platform } from 'node:os';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { readJson } from './json-file.js';
|
|
4
5
|
/**
|
|
5
6
|
* UI tests are optional (design decision 75): they run in Playwright's Chromium where it
|
|
6
7
|
* can start, and are skipped with the reason where it cannot. On macOS and Windows,
|
|
7
8
|
* `npx playwright install chromium` is all it needs; on Linux, Chromium also needs system
|
|
8
|
-
* libraries, which only an administrator adds. agjan
|
|
9
|
+
* libraries, which only an administrator adds. agjan installs nothing on its own: `init` and
|
|
10
|
+
* `doctor` offer the steps on a terminal and run one only when the user says yes.
|
|
9
11
|
*/
|
|
10
12
|
/** The npm script that runs a project's UI tests. */
|
|
11
13
|
export const UI_SCRIPT = 'test:ui';
|
|
@@ -18,20 +20,16 @@ await browser.close();`;
|
|
|
18
20
|
export function hasUiTests(root) {
|
|
19
21
|
return Boolean(readJson(join(root, 'package.json'))?.scripts?.[UI_SCRIPT]);
|
|
20
22
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Starts and closes Chromium from the project. Returns { ready: true } or { ready: false,
|
|
23
|
-
* reason, enable }. AGJAN_BROWSER_PROBE names a Node script that replaces the probe (tests).
|
|
24
|
-
*/
|
|
25
23
|
export function probeBrowser(root) {
|
|
26
24
|
const fake = process.env.AGJAN_BROWSER_PROBE;
|
|
27
25
|
const run = spawnSync(process.execPath, fake ? [fake] : ['--input-type=module', '-e', PROBE], { cwd: root, encoding: 'utf8', timeout: 120_000 });
|
|
28
26
|
if (run.status === 0)
|
|
29
27
|
return { ready: true };
|
|
30
28
|
if (run.status === 3)
|
|
31
|
-
return { ready: false, reason: '@playwright/test is not installed', enable: 'npm install' };
|
|
29
|
+
return { ready: false, reason: '@playwright/test is not installed', enable: 'npm install', missing: 'package' };
|
|
32
30
|
const output = `${run.stderr ?? ''}${run.stdout ?? ''}`;
|
|
33
31
|
if (/Executable doesn't exist|playwright install/i.test(output) && !/install-deps|missing dependencies/i.test(output)) {
|
|
34
|
-
return { ready: false, reason: 'Chromium is not downloaded', enable: 'npx playwright install chromium (no admin rights needed)' };
|
|
32
|
+
return { ready: false, reason: 'Chromium is not downloaded', enable: 'npx playwright install chromium (no admin rights needed)', missing: 'download' };
|
|
35
33
|
}
|
|
36
34
|
const library = /error while loading shared libraries: (\S+?):/.exec(output)?.[1];
|
|
37
35
|
if (library || /missing dependencies|install-deps/i.test(output)) {
|
|
@@ -39,8 +37,27 @@ export function probeBrowser(root) {
|
|
|
39
37
|
ready: false,
|
|
40
38
|
reason: `Chromium cannot start: this Linux system lacks its libraries${library ? ` (${library})` : ''}`,
|
|
41
39
|
enable: 'whoever maintains the machine or container image adds them once, for example with `npx playwright install-deps chromium` run as root in its Dockerfile',
|
|
40
|
+
missing: 'libraries',
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
const first = output.split('\n').map((l) => l.trim()).find((l) => l && !l.startsWith('at ')) ?? (run.error ? run.error.message : `exit code ${run.status}`);
|
|
45
|
-
return { ready: false, reason: `Chromium cannot start: ${first.replace(/^\w*Error: /, '')}`, enable: 'npx playwright install chromium, then npx agjan doctor' };
|
|
44
|
+
return { ready: false, reason: `Chromium cannot start: ${first.replace(/^\w*Error: /, '')}`, enable: 'npx playwright install chromium, then npx agjan doctor', missing: 'other' };
|
|
45
|
+
}
|
|
46
|
+
/** The Dockerfile line that keeps the system libraries across container rebuilds. */
|
|
47
|
+
export const DEPS_DOCKERFILE_LINE = 'RUN npx playwright install-deps chromium';
|
|
48
|
+
/** The command that adds the system libraries, or null when this user cannot run it unattended. */
|
|
49
|
+
export function depsCommand() {
|
|
50
|
+
if (platform() !== 'linux')
|
|
51
|
+
return null;
|
|
52
|
+
const install = ['npx', 'playwright', 'install-deps', 'chromium'];
|
|
53
|
+
if (process.getuid?.() === 0)
|
|
54
|
+
return { command: install[0], args: install.slice(1), shown: install.join(' ') };
|
|
55
|
+
// sudo -n never asks for a password: it fails at once where one would be needed.
|
|
56
|
+
if (spawnSync('sudo', ['-n', 'true'], { stdio: 'ignore' }).status !== 0)
|
|
57
|
+
return null;
|
|
58
|
+
return { command: 'sudo', args: ['-n', 'env', `PATH=${process.env.PATH ?? ''}`, ...install], shown: `sudo ${install.join(' ')}` };
|
|
59
|
+
}
|
|
60
|
+
/** Runs a setup command from the project with its output shown; true when it succeeded. */
|
|
61
|
+
export function runVisible(root, command, args) {
|
|
62
|
+
return spawnSync(command, args, { cwd: root, stdio: 'inherit' }).status === 0;
|
|
46
63
|
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -19,7 +19,7 @@ import { blink, mark, pad, tone, verdictColor } from '../ui.js';
|
|
|
19
19
|
import { PINNED, mcpServers } from '../mcp-config.js';
|
|
20
20
|
import { addCommand, addCopilotServers, copilotServers } from '../copilot-mcp.js';
|
|
21
21
|
import { AGENTS, FOLLOW, OTHER, copilotModels, hostModels, modelChoices } from '../model-choices.js';
|
|
22
|
-
import { UI_SCRIPT, hasUiTests, probeBrowser } from '../browser.js';
|
|
22
|
+
import { DEPS_DOCKERFILE_LINE, UI_SCRIPT, depsCommand, hasUiTests, probeBrowser, runVisible } from '../browser.js';
|
|
23
23
|
import { readAutoDefault } from '../auto.js';
|
|
24
24
|
const CI_FILE = '.github/workflows/agjan.yml';
|
|
25
25
|
const CI_TEMPLATE = new URL('../../kit/templates/agjan-ci.yml', import.meta.url);
|
|
@@ -429,6 +429,7 @@ export async function init(ctx, argv) {
|
|
|
429
429
|
ctx.out(` ${pad(tone(s, 'created'), 'created', 14)} ${CI_FILE}`);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
+
offerBrowser(ctx, root);
|
|
432
433
|
let committed = null;
|
|
433
434
|
if (wantCommit) {
|
|
434
435
|
const result = commitSetup(root, { firstCommit });
|
|
@@ -449,6 +450,53 @@ export async function init(ctx, argv) {
|
|
|
449
450
|
}));
|
|
450
451
|
return 0;
|
|
451
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Offers to make Chromium start, for a project that has UI tests: the download (no admin rights)
|
|
455
|
+
* and, on Linux, the system libraries (sudo). Asks first and only on a terminal; with no terminal
|
|
456
|
+
* or an answer of no, nothing is installed. `--yes` never covers it.
|
|
457
|
+
*/
|
|
458
|
+
function offerBrowser(ctx, root) {
|
|
459
|
+
if (!hasUiTests(root))
|
|
460
|
+
return;
|
|
461
|
+
const s = ctx.style;
|
|
462
|
+
let changed = false;
|
|
463
|
+
let previous = '';
|
|
464
|
+
for (let step = 0; step < 2; step++) {
|
|
465
|
+
const browser = probeBrowser(root);
|
|
466
|
+
if (browser.ready || browser.missing === previous)
|
|
467
|
+
break; // what was just done did not help: do not ask again
|
|
468
|
+
previous = browser.missing;
|
|
469
|
+
if (browser.missing === 'download') {
|
|
470
|
+
if (!ask(ctx, `UI tests: ${browser.reason}. Download it now (npx playwright install chromium, no admin rights)?`, { defaultYes: true }))
|
|
471
|
+
return;
|
|
472
|
+
if (!runVisible(root, 'npx', ['playwright', 'install', 'chromium']))
|
|
473
|
+
return void ctx.out('', s.yellow('The download failed; the UI tests stay skipped.'));
|
|
474
|
+
}
|
|
475
|
+
else if (browser.missing === 'libraries') {
|
|
476
|
+
const deps = depsCommand();
|
|
477
|
+
if (!deps) {
|
|
478
|
+
if (ctx.isTTY)
|
|
479
|
+
ctx.out('', `${s.bold('ui tests')}: ${browser.reason}.`, ` Installing them needs root: run \`npx playwright install-deps chromium\` as root, and add \`${DEPS_DOCKERFILE_LINE}\``, ' to the Dockerfile so a rebuilt container keeps them.');
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (!ask(ctx, `UI tests: ${browser.reason}. Install them now (${deps.shown})? It changes this machine.`, { defaultYes: false })) {
|
|
483
|
+
if (ctx.isTTY)
|
|
484
|
+
ctx.out('', ` To keep them across container rebuilds, add \`${DEPS_DOCKERFILE_LINE}\` to the Dockerfile.`);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (!runVisible(root, deps.command, deps.args))
|
|
488
|
+
return void ctx.out('', s.yellow('The installation failed; the UI tests stay skipped.'));
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
changed = true;
|
|
494
|
+
}
|
|
495
|
+
if (!changed)
|
|
496
|
+
return;
|
|
497
|
+
const last = probeBrowser(root);
|
|
498
|
+
ctx.out('', last.ready ? `${s.bold('ui tests')}: Chromium starts now` : s.yellow(`ui tests: still skipped: ${last.reason}`));
|
|
499
|
+
}
|
|
452
500
|
function addPrepare(root) {
|
|
453
501
|
const file = join(root, 'package.json');
|
|
454
502
|
const pkg = readJson(file);
|
|
@@ -666,5 +714,7 @@ export async function doctor(ctx) {
|
|
|
666
714
|
const failed = rows.filter((r) => r[0] === 'fail').length;
|
|
667
715
|
const warned = rows.filter((r) => r[0] === 'warn').length;
|
|
668
716
|
ctx.out(`${s.bold('agjan doctor')}: ${verdictColor(s, failed, warned)(`${failed} failure(s), ${warned} warning(s)`)}`);
|
|
717
|
+
if (root)
|
|
718
|
+
offerBrowser(ctx, root);
|
|
669
719
|
return failed ? 1 : 0;
|
|
670
720
|
}
|
package/dist/config.js
CHANGED
|
@@ -23,7 +23,7 @@ export function agentModel(config, host, tier) {
|
|
|
23
23
|
return value && value !== SESSION_MODEL ? value : undefined;
|
|
24
24
|
}
|
|
25
25
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
|
26
|
-
const DEFAULTS = {
|
|
26
|
+
export const DEFAULTS = {
|
|
27
27
|
domains: ['btp'],
|
|
28
28
|
hosts: ['claude-code'],
|
|
29
29
|
language: 'en',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DEFAULTS, merge } from './config.js';
|
|
2
|
+
import { DEFAULT_TIERS } from './review-policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* agjan's default settings as data: schemas/config.defaults.json, shipped in the package next
|
|
5
|
+
* to config.schema.json, so tools that do not run agjan (agjan Studio) can show what a setting
|
|
6
|
+
* is when agjan.config.json leaves it out. test/unit/defaults-file.test.ts keeps the file in
|
|
7
|
+
* step with the code; scripts/defaults.ts writes it.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULTS_FILE = 'schemas/config.defaults.json';
|
|
10
|
+
/**
|
|
11
|
+
* Defaults that are not in DEFAULTS because the code reads them where they apply:
|
|
12
|
+
* git.branches (status, branch), review.qa (qa.ts: on unless "off"), agent.script_edits
|
|
13
|
+
* (the guard hook: deny unless "allow").
|
|
14
|
+
*/
|
|
15
|
+
export const IMPLICIT_DEFAULTS = {
|
|
16
|
+
git: { branches: 'new' },
|
|
17
|
+
review: { qa: 'on' },
|
|
18
|
+
agent: { script_edits: 'deny' },
|
|
19
|
+
};
|
|
20
|
+
/** The tier of each review step; `qa` is the QA agent's own tier, not a review.tiers value. */
|
|
21
|
+
function reviewTiers() {
|
|
22
|
+
return Object.fromEntries(Object.entries(DEFAULT_TIERS).filter(([, tier]) => ['fast', 'balanced', 'deep'].includes(tier)));
|
|
23
|
+
}
|
|
24
|
+
export function defaultsDocument() {
|
|
25
|
+
return {
|
|
26
|
+
description: "agjan's defaults for agjan.config.json. Domains add their own on top (kit/domains/<id>/domain.json: per area implicit, tests, verify, lint; application, risk_paths and protected are appended), and the project's file overrides both. Objects merge, arrays replace. Review steps without a tier use balanced.",
|
|
27
|
+
format: 1,
|
|
28
|
+
defaults: merge(merge(DEFAULTS, IMPLICIT_DEFAULTS), { review: { tiers: reviewTiers() } }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function defaultsFileText() {
|
|
32
|
+
return `${JSON.stringify(defaultsDocument(), null, 2)}\n`;
|
|
33
|
+
}
|
package/docs/guide.md
CHANGED
|
@@ -237,7 +237,11 @@ ask (its description is `npx agjan pr-summary`); you review and merge.
|
|
|
237
237
|
choose an action), the agents also write Playwright tests (`test/ui/`, the script
|
|
238
238
|
`test:ui`), and `npx agjan ui-test` runs them in Chromium as each test user. Where Chromium
|
|
239
239
|
cannot start, it says why and skips them, and the agent tells you which ACs to try by
|
|
240
|
-
hand. agjan
|
|
240
|
+
hand. `npx agjan init` and `npx agjan doctor` check this for a project with a `test:ui`
|
|
241
|
+
script and, in your terminal, offer to fix it: the Chromium download (no admin rights) and,
|
|
242
|
+
on Linux, the system libraries (`sudo npx playwright install-deps chromium`, only with
|
|
243
|
+
passwordless sudo or as root, and only after your explicit yes; `--yes` does not cover it).
|
|
244
|
+
Agents and CI never install anything with admin rights:
|
|
241
245
|
|
|
242
246
|
- macOS and Windows: `npx playwright install chromium` is all it needs.
|
|
243
247
|
- Linux, dev containers: Chromium also needs system libraries. Whoever maintains the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agjan",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
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",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "agjan's defaults for agjan.config.json. Domains add their own on top (kit/domains/<id>/domain.json: per area implicit, tests, verify, lint; application, risk_paths and protected are appended), and the project's file overrides both. Objects merge, arrays replace. Review steps without a tier use balanced.",
|
|
3
|
+
"format": 1,
|
|
4
|
+
"defaults": {
|
|
5
|
+
"domains": [
|
|
6
|
+
"btp"
|
|
7
|
+
],
|
|
8
|
+
"hosts": [
|
|
9
|
+
"claude-code"
|
|
10
|
+
],
|
|
11
|
+
"language": "en",
|
|
12
|
+
"git": {
|
|
13
|
+
"base": null,
|
|
14
|
+
"branches": "new"
|
|
15
|
+
},
|
|
16
|
+
"scope": {
|
|
17
|
+
"implicit": {}
|
|
18
|
+
},
|
|
19
|
+
"risk_paths": [],
|
|
20
|
+
"application": [],
|
|
21
|
+
"tests": {},
|
|
22
|
+
"fix": {
|
|
23
|
+
"max_total": 80,
|
|
24
|
+
"max_per_file": 50,
|
|
25
|
+
"protected": [],
|
|
26
|
+
"ignored": [
|
|
27
|
+
"package-lock.json",
|
|
28
|
+
"**/package-lock.json",
|
|
29
|
+
"gen/**",
|
|
30
|
+
"dist/**"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"verify": {},
|
|
34
|
+
"lint": {},
|
|
35
|
+
"build": {
|
|
36
|
+
"fix_attempts": 3
|
|
37
|
+
},
|
|
38
|
+
"review": {
|
|
39
|
+
"build": "area",
|
|
40
|
+
"rounds": 3,
|
|
41
|
+
"qa": "on",
|
|
42
|
+
"tiers": {
|
|
43
|
+
"spec": "balanced",
|
|
44
|
+
"design:light": "balanced",
|
|
45
|
+
"design": "deep",
|
|
46
|
+
"build": "balanced",
|
|
47
|
+
"verify": "deep",
|
|
48
|
+
"fix": "balanced",
|
|
49
|
+
"map": "balanced",
|
|
50
|
+
"proposal": "deep"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"test_evidence": "run",
|
|
54
|
+
"ci": {
|
|
55
|
+
"policy_changes": "warn",
|
|
56
|
+
"untracked_changes": "fail"
|
|
57
|
+
},
|
|
58
|
+
"limits": {
|
|
59
|
+
"spec_kb": 12,
|
|
60
|
+
"design_kb": 20
|
|
61
|
+
},
|
|
62
|
+
"agent": {
|
|
63
|
+
"script_edits": "deny"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|