agjan 0.0.2 → 0.0.4
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 +34 -0
- package/kit/hooks/guard.mjs +99 -7
- package/kit/skills/agjan-build/SKILL.md +1 -1
- package/kit/skills/agjan-design/SKILL.md +1 -1
- package/kit/skills/agjan-fix/SKILL.md +5 -3
- package/kit/skills/agjan-map/SKILL.md +4 -2
- package/kit/skills/agjan-spec/SKILL.md +6 -1
- package/kit/skills/agjan-verify/SKILL.md +1 -1
- package/kit/skills/cap-developer/references/handlers.md +3 -0
- package/kit/skills/cap-developer/references/validation-security.md +9 -0
- package/kit/templates/agents-block.md +7 -0
- package/package.json +1 -1
- package/schemas/config.schema.json +36 -1
- package/src/cli.mjs +5 -1
- package/src/commands/branch.mjs +50 -0
- package/src/commands/check.mjs +17 -1
- package/src/commands/setup.mjs +16 -3
- package/src/commands/status.mjs +7 -5
- package/src/config.mjs +7 -1
- package/src/context.mjs +4 -1
- package/src/feature.mjs +12 -1
- package/src/fix.mjs +2 -2
- package/src/git.mjs +9 -0
- package/src/progress.mjs +3 -3
- package/src/review-policy.mjs +29 -1
- package/src/review.mjs +73 -9
- package/src/terminal.mjs +16 -0
package/docs/guide.md
CHANGED
|
@@ -161,6 +161,8 @@ lists replace. The schema is `node_modules/agjan/schemas/config.schema.json`.
|
|
|
161
161
|
| `domains` | enabled domains; phase 1 has `btp` (areas `cap`, `fiori`, `btp`) |
|
|
162
162
|
| `hosts` | `claude-code`, `copilot`; decides which files `sync` generates |
|
|
163
163
|
| `git.base` | the branch features merge into; default: the remote's default branch |
|
|
164
|
+
| `git.branch.create` | who creates the branch of a feature, fix or map run: `agent` (default; the agent runs `npx agjan branch <name>`) or `confirm` (the agent proposes a name; a human runs `npx agjan branch <name>` in a terminal, may edit the name, and the guard hook blocks `git switch -c` and similar for agents) |
|
|
165
|
+
| `git.branch.pattern` | a regular expression for branch names, for teams with naming rules: `agjan branch` refuses other names, `check` warns about them (an error with `--ci`) |
|
|
164
166
|
| `verify.<area>` | `build`, `test`, `lint` commands for the skills; `results`: a JUnit XML, Jest or Mocha JSON file that `check` reads to require a passing test per AC |
|
|
165
167
|
| `tests.<area>`, `scope.implicit.<area>` | test file globs; files every task of the area may change (i18n, lockfiles, fixtures) |
|
|
166
168
|
| `risk_paths` | paths whose change needs a review per task and are never a fix |
|
|
@@ -190,6 +192,38 @@ line; the skills take these values, and the reviewer agent per step, from `statu
|
|
|
190
192
|
On every host, `approve` needs a human at a real terminal: the confirmation is read
|
|
191
193
|
from the terminal, not from input an agent can pipe in.
|
|
192
194
|
|
|
195
|
+
### Fewer permission prompts
|
|
196
|
+
|
|
197
|
+
The hosts ask before every shell command and, in Copilot, before every file change. Two
|
|
198
|
+
settings remove the routine prompts without giving up control:
|
|
199
|
+
|
|
200
|
+
- **Commands: `agent.allow`** in `agjan.config.json`. `init` asks once whether to add the
|
|
201
|
+
recommended list (`--agent-allow` / `--no-agent-allow` decide without asking):
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
"agent": { "allow": ["npx agjan", "npm test", "git status", "git diff", "git log", "git add", "git commit"] }
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
agjan's guard hook approves a command without a prompt when it is a **single simple
|
|
208
|
+
command** starting with a listed entry: `npm test` and `git commit -m "…"` run, but
|
|
209
|
+
`npm test && git push`, pipes, redirections and `$(…)` still ask. `agjan approve`,
|
|
210
|
+
`accept` and `reject` are always denied, listed or not. Works in Claude Code and the
|
|
211
|
+
Copilot CLI (both run the hook). Edit the list like any configuration: a change is a
|
|
212
|
+
policy change that `check` reports and the PR shows.
|
|
213
|
+
- **File changes (Copilot):** start with `copilot --allow-tool write`, or answer the first
|
|
214
|
+
edit prompt with "don't ask again for file operations in this repo". agjan's scope
|
|
215
|
+
check, the pre-commit hook and the reviewer cover what the agent changes.
|
|
216
|
+
|
|
217
|
+
**Script edits are denied.** Agents sometimes edit files with small scripts
|
|
218
|
+
(`python3 - <<EOF … open(p, 'w')`, `sed -i`, `cat > file <<EOF`) instead of their edit
|
|
219
|
+
tool. Such an edit fails silently when the text it replaces does not match, and you do
|
|
220
|
+
not see the change. agjan's guard denies these commands and tells the agent to use its
|
|
221
|
+
edit tool; reading (`cat`, `sed -n`, `grep`) and running project scripts stay allowed.
|
|
222
|
+
Set `agent.script_edits` to `"allow"` in `agjan.config.json` to turn this off.
|
|
223
|
+
|
|
224
|
+
Copilot keeps your own "don't ask again" answers per folder in
|
|
225
|
+
`~/.copilot/permissions-config.json`; that file is personal and not part of the project.
|
|
226
|
+
|
|
193
227
|
## CI and repository settings
|
|
194
228
|
|
|
195
229
|
`init` creates `.github/workflows/agjan.yml`. On every pull request it runs
|
package/kit/hooks/guard.mjs
CHANGED
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
* `cd … &&`, `node …/agjan.mjs`). It is a guardrail in front of the terminal
|
|
6
6
|
* confirmation, not a proof (design 9.4).
|
|
7
7
|
*
|
|
8
|
+
* It denies file edits by shell or script commands (python/node scripts that write files,
|
|
9
|
+
* sed -i, cat > file, …) so that agents use their file edit tool, unless the project sets
|
|
10
|
+
* `agent.script_edits` to "allow" (design decision 63).
|
|
11
|
+
*
|
|
12
|
+
* It also approves, without a prompt, shell commands the project lists in `agent.allow`
|
|
13
|
+
* of agjan.config.json (opt-in, design decision 61): a single simple command that starts
|
|
14
|
+
* with a listed command. Anything with `;`, `&&`, `|`, `$(…)`, backticks or redirections is
|
|
15
|
+
* left to the host's own prompt. Denying always comes first.
|
|
16
|
+
*
|
|
8
17
|
* Reads the host's payload on stdin and answers in the host's format:
|
|
9
18
|
* - GitHub Copilot: { toolName, toolArgs: { command } } -> { permissionDecision, permissionDecisionReason }
|
|
10
19
|
* - Claude Code: { tool_name, tool_input: { command } } -> { hookSpecificOutput: { … } }
|
|
@@ -13,7 +22,8 @@
|
|
|
13
22
|
* Deliberately self-contained and dependency-free: it runs before every tool call.
|
|
14
23
|
*/
|
|
15
24
|
|
|
16
|
-
import { realpathSync } from 'node:fs';
|
|
25
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
26
|
+
import { join } from 'node:path';
|
|
17
27
|
import { fileURLToPath } from 'node:url';
|
|
18
28
|
|
|
19
29
|
const REASON =
|
|
@@ -22,13 +32,95 @@ const REASON =
|
|
|
22
32
|
/** `agjan` (or `agjan.mjs`) followed directly by a human-only command; an optional `--` (npm exec) between. */
|
|
23
33
|
const HUMAN_ONLY = /\bagjan(?:\.mjs)?["']?\s+(?:--\s+)?["']?(approve|accept|reject)\b/;
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
const BRANCH_REASON =
|
|
36
|
+
'In this project a human creates branches (git.branch.create: confirm in agjan.config.json). Propose a branch name and ask the user to run in a terminal: npx agjan branch <name>';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Commands that create or rename a branch: git switch -c/-C, git checkout -b/-B/--orphan,
|
|
40
|
+
* git branch <name> (also -m/-c), git worktree add -b. Denied when git.branch.create is
|
|
41
|
+
* "confirm" (design decision 62); git options such as `-C <dir>` may come before.
|
|
42
|
+
*/
|
|
43
|
+
const BRANCH_CREATE = new RegExp(
|
|
44
|
+
String.raw`\bgit(?:\s+-[cC]\s+\S+|\s+--[\w-]+(?:=\S+)?)*\s+` +
|
|
45
|
+
String.raw`(?:switch\s+(?:\S+\s+)*?(?:-c|-C|--create|--force-create)\b` +
|
|
46
|
+
String.raw`|checkout\s+(?:\S+\s+)*?(?:-b|-B|--orphan)\b` +
|
|
47
|
+
String.raw`|branch\s+(?:(?:-[mMcCf]|--move|--copy|--force)\s+)*[^-\s]` +
|
|
48
|
+
String.raw`|worktree\s+add\s+(?:\S+\s+)*?-[bB]\b)`,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const EDIT_REASON =
|
|
52
|
+
'Edit files with your file edit tool, not with shell or script commands: the edit tool shows the change to the user and fails visibly when the text to replace does not match. If you have no edit tool, ask the user.';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Shell commands that write files as a script (design decision 63): interpreter scripts
|
|
56
|
+
* that open files for writing, in-place stream edits, and cat/echo/printf/tee into a file.
|
|
57
|
+
* Reading (cat file, sed -n, grep, running a project script) is not matched.
|
|
58
|
+
*/
|
|
59
|
+
const SCRIPT_EDITS = [
|
|
60
|
+
// python3 - <<EOF … / python -c "…" that writes a file (the script is inside quotes or a heredoc)
|
|
61
|
+
(c) => /\bpython[0-9.]*\b/.test(c) && /(<<|\s-c\s)/.test(c) && /open\([^,)]*,\s*(?:mode\s*=\s*)?['"][wax]b?\+?['"]|\.write_(text|bytes)\(/.test(c),
|
|
62
|
+
// node -e / node <<EOF that writes a file
|
|
63
|
+
(c) => /\bnode\b/.test(c) && /(<<|\s(-e|--eval|-p|--print)\s)/.test(c) && /\b(writeFileSync|appendFileSync|writeFile|appendFile|createWriteStream)\b/.test(c),
|
|
64
|
+
// The rest looks at the command line itself, with quoted text (messages, patterns) masked.
|
|
65
|
+
(c) => /\bsed\s+(?:[^|;&]*\s)?(?:-[a-zA-Z]*i\b|--in-place)/.test(unquoted(c)),
|
|
66
|
+
(c) => /\bperl\s+(?:[^|;&]*\s)?-[a-zA-Z]*i/.test(unquoted(c)),
|
|
67
|
+
// cat / echo / printf redirected into a file (not /dev/null, not 2>&1)
|
|
68
|
+
(c) => /\b(cat|echo|printf)\b[^|;&]*?(?<![0-9&])>>?\s*(?!&|\/dev\/null\b)[\w./~-]/.test(unquoted(c)),
|
|
69
|
+
// tee into a file
|
|
70
|
+
(c) => /\btee\s+(?:-a\s+)?(?!\/dev\/)[\w./~]/.test(unquoted(c)),
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
/** The command with every quoted string replaced by Q, so quoted text is not read as syntax. */
|
|
74
|
+
function unquoted(command) {
|
|
75
|
+
return command.replace(/'[^']*'|"(?:[^"\\]|\\.)*"/g, 'Q');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Characters that chain, substitute or redirect: such commands are never auto-approved. */
|
|
79
|
+
const COMPOUND = /[;&|`$<>(){}\n\r]/;
|
|
80
|
+
|
|
81
|
+
/** Whether `command` is one simple command starting with an entry of the allow list. */
|
|
82
|
+
export function allowed(command, allow) {
|
|
83
|
+
if (!Array.isArray(allow) || COMPOUND.test(command)) return false;
|
|
84
|
+
const normalized = command.trim().replace(/\s+/g, ' ');
|
|
85
|
+
return allow.some((entry) => {
|
|
86
|
+
if (typeof entry !== 'string' || entry.trim() === '') return false;
|
|
87
|
+
const prefix = entry.trim().replace(/\s+/g, ' ');
|
|
88
|
+
return normalized === prefix || normalized.startsWith(`${prefix} `);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function answer(payload, decision, reason) {
|
|
28
93
|
if (payload.tool_input !== undefined) {
|
|
29
|
-
return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision:
|
|
94
|
+
return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: decision, permissionDecisionReason: reason } };
|
|
95
|
+
}
|
|
96
|
+
return { permissionDecision: decision, permissionDecisionReason: reason };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The guard's answer for a payload: deny, allow (listed in `config.agent.allow`), or null
|
|
101
|
+
* (the host decides). `config` is the project's agjan.config.json.
|
|
102
|
+
*/
|
|
103
|
+
export function decide(payload, config = {}) {
|
|
104
|
+
const command = payload?.toolArgs?.command ?? payload?.tool_input?.command;
|
|
105
|
+
if (typeof command !== 'string') return null;
|
|
106
|
+
if (HUMAN_ONLY.test(command)) return answer(payload, 'deny', REASON);
|
|
107
|
+
if (config?.git?.branch?.create === 'confirm' && BRANCH_CREATE.test(command)) return answer(payload, 'deny', BRANCH_REASON);
|
|
108
|
+
if (config?.agent?.script_edits !== 'allow' && SCRIPT_EDITS.some((matches) => matches(command))) return answer(payload, 'deny', EDIT_REASON);
|
|
109
|
+
const allow = config?.agent?.allow ?? [];
|
|
110
|
+
const shell = /^(bash|powershell|shell)$/i.test(payload.toolName ?? payload.tool_name ?? '');
|
|
111
|
+
if (shell && allowed(command, allow)) return answer(payload, 'allow', 'listed in agent.allow of agjan.config.json');
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The project's agjan.config.json; empty when it cannot be read. */
|
|
116
|
+
function projectConfig() {
|
|
117
|
+
try {
|
|
118
|
+
const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
119
|
+
const config = JSON.parse(readFileSync(join(root, 'agjan.config.json'), 'utf8'));
|
|
120
|
+
return config !== null && typeof config === 'object' ? config : {};
|
|
121
|
+
} catch {
|
|
122
|
+
return {};
|
|
30
123
|
}
|
|
31
|
-
return { permissionDecision: 'deny', permissionDecisionReason: REASON };
|
|
32
124
|
}
|
|
33
125
|
|
|
34
126
|
function main() {
|
|
@@ -44,7 +136,7 @@ function main() {
|
|
|
44
136
|
} catch {
|
|
45
137
|
return; // not a payload we understand: default behavior
|
|
46
138
|
}
|
|
47
|
-
const decision = decide(payload);
|
|
139
|
+
const decision = decide(payload, projectConfig());
|
|
48
140
|
if (decision) process.stdout.write(JSON.stringify(decision));
|
|
49
141
|
});
|
|
50
142
|
}
|
|
@@ -32,7 +32,7 @@ Repeat until `npx agjan status` says `next: all tasks done and reviewed`:
|
|
|
32
32
|
- Commit the task with the subject `<KEY>-<id>: <title>`, for example
|
|
33
33
|
`ORDF-T1: Add the status filter`. Include the feature's `docs/agjan/` files if they
|
|
34
34
|
changed.
|
|
35
|
-
3. **A due review** (`due review build:<area>` or `build:<task>`): delegate to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
35
|
+
3. **A due review** (`due review build:<area>` or `build:<task>`): when all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
36
36
|
`Review step build:<area or task> of feature <slug>.` The work must be committed
|
|
37
37
|
first. Read the result with `npx agjan review show`; fix
|
|
38
38
|
blockers in a new commit with the same task subject prefix, then ask for the review
|
|
@@ -68,7 +68,7 @@ Run `npx agjan check` and fix every error.
|
|
|
68
68
|
|
|
69
69
|
## 5. Review (step `design`, deep)
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer-deep`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
72
72
|
`Review step design of feature <slug>.`
|
|
73
73
|
|
|
74
74
|
Read the result with `npx agjan review show`. Fix blockers and re-review, up to the round limit that `npx agjan status` shows (default 3); if blockers remain, stop and tell the user. Never edit review files or review
|
|
@@ -20,8 +20,10 @@ change, or a business decision: stop and recommend `/agjan-spec`.
|
|
|
20
20
|
|
|
21
21
|
## 2. Start
|
|
22
22
|
|
|
23
|
-
Work on a branch of its own, without features.
|
|
24
|
-
|
|
23
|
+
Work on a branch of its own, without features. If you are on the base branch, create
|
|
24
|
+
it with `npx agjan branch <name>`, or, when `npx agjan status` says a human creates
|
|
25
|
+
branches, propose the name and ask the user to run that command; never with git directly.
|
|
26
|
+
Pick a slug and a key of 2 to 6 capitals:
|
|
25
27
|
|
|
26
28
|
`npx agjan fix start <slug> --key <KEY> --what "<one sentence: what the fix changes>"`
|
|
27
29
|
|
|
@@ -35,7 +37,7 @@ capitals:
|
|
|
35
37
|
|
|
36
38
|
## 4. Review (step `fix`)
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
39
41
|
`Review step fix of feature fixes/<id>.` (the id is the folder name under
|
|
40
42
|
`docs/agjan/fixes/`). Read the result with `npx agjan review show`. Fix blockers in a
|
|
41
43
|
new commit and review again, up to the round limit that `npx agjan status` shows (default 3); then stop and tell the user. Make no
|
|
@@ -10,7 +10,9 @@ The merge of this branch is its approval.
|
|
|
10
10
|
|
|
11
11
|
## 1. Start
|
|
12
12
|
|
|
13
|
-
On a branch of its own, without features or fixes
|
|
13
|
+
On a branch of its own, without features or fixes (create it with
|
|
14
|
+
`npx agjan branch <name>`, or ask the user to when `npx agjan status` says a human
|
|
15
|
+
creates branches; never with git directly):
|
|
14
16
|
|
|
15
17
|
`npx agjan map start`
|
|
16
18
|
|
|
@@ -39,7 +41,7 @@ user if unsure. These paths are protected for `/agjan-fix`.
|
|
|
39
41
|
## 4. Baseline and review (step `map`)
|
|
40
42
|
|
|
41
43
|
1. `npx agjan baseline refresh`
|
|
42
|
-
2.
|
|
44
|
+
2. When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
43
45
|
`Review step map of feature maps/<id>.` Read the result with `npx agjan review show`;
|
|
44
46
|
fix blockers and review again, up to the round limit that `npx agjan status` shows (default 3).
|
|
45
47
|
3. Commit `docs/agjan/`. `npx agjan check --ci` must pass.
|
|
@@ -14,6 +14,11 @@ design. You write; the agjan reviewer checks; the human approves.
|
|
|
14
14
|
Run `npx agjan status`. If a feature is already in progress on this branch, continue
|
|
15
15
|
it instead of starting a new one. Otherwise:
|
|
16
16
|
|
|
17
|
+
- If you are on the base branch, the work needs a branch of its own. The settings line
|
|
18
|
+
of `npx agjan status` says who creates it. Propose a name (and follow the branch
|
|
19
|
+
pattern if it names one): if the agent creates branches, run `npx agjan branch <name>`;
|
|
20
|
+
if a human does, ask the user to run `npx agjan branch <name>` in their terminal (they
|
|
21
|
+
may edit the name) and stop until they did. Never create branches with git directly.
|
|
17
22
|
- Pick a slug (lowercase, `-`, short: `order-status-filter`) and a key of 2 to 6
|
|
18
23
|
capitals (`OSF`).
|
|
19
24
|
- `npx agjan new <slug> --key <KEY>`
|
|
@@ -49,7 +54,7 @@ Run `npx agjan check` and fix every error in `spec.md`.
|
|
|
49
54
|
|
|
50
55
|
## 4. Review (step `spec`)
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
53
58
|
`Review step spec of feature <slug>.` Do not add your reasoning, summaries or opinions
|
|
54
59
|
to the prompt. If no such agent is available, stop and tell the user: the review
|
|
55
60
|
cannot be skipped (`npx agjan doctor` shows why).
|
|
@@ -31,7 +31,7 @@ since the baseline, and commit both.
|
|
|
31
31
|
|
|
32
32
|
## 4. Final review (step `verify`, deep)
|
|
33
33
|
|
|
34
|
-
Everything must be committed.
|
|
34
|
+
Everything must be committed. When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer-deep`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent):
|
|
35
35
|
`Review step verify of feature <slug>.`
|
|
36
36
|
|
|
37
37
|
Read the result with `npx agjan review show`. If it is blocked, fix the blockers in new
|
|
@@ -45,3 +45,6 @@ MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
|
45
45
|
you, and nested calls to other services do not join it.
|
|
46
46
|
- Lock what you read before changing it in the same transaction:
|
|
47
47
|
`SELECT(1).from(Orders, id).forUpdate()`.
|
|
48
|
+
- For a status transition, make the update itself conditional on the expected state:
|
|
49
|
+
`UPDATE(Orders).set({ status: 'Shipped' }).where({ ID: id, status: 'Approved' })`
|
|
50
|
+
returns the number of changed rows; 0 means the state changed in between.
|
|
@@ -28,6 +28,10 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
|
|
|
28
28
|
|
|
29
29
|
## Authorization
|
|
30
30
|
|
|
31
|
+
- A service, entity or operation without `@requires` or `@restrict` is open to every
|
|
32
|
+
user, anonymous requests included (CAP does not restrict services by default). Every
|
|
33
|
+
entity and operation the spec's roles cover needs one, and tests for a user without
|
|
34
|
+
the role (403) and an anonymous request (401).
|
|
31
35
|
- `@requires: 'Role'` (or a list, meaning any of them) on a service, entity or
|
|
32
36
|
operation. Pseudo roles: `authenticated-user`, `system-user`, `any`. A service with
|
|
33
37
|
`@requires` also protects its `$metadata` and service root.
|
|
@@ -44,6 +48,11 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
|
|
|
44
48
|
collections, only simple comparisons of user attributes with literals
|
|
45
49
|
(`$user.level >= 2`) can be checked.
|
|
46
50
|
- `$metadata` does not apply `@restrict`; do not rely on hiding entities there.
|
|
51
|
+
- Users for tests and local runs (`auth` of kind `mocked` with `users`) belong in a
|
|
52
|
+
profile: `cds.requires["[development]"].auth` in `package.json` (`cds.test` runs in it
|
|
53
|
+
too). Without the profile they also apply in production, where anyone could log in
|
|
54
|
+
with those passwords. Check: `NODE_ENV=production npx cds env get requires.auth.kind`
|
|
55
|
+
must not print `mocked` or `dummy`.
|
|
47
56
|
- Name roles after the spec's business roles; the same roles go into
|
|
48
57
|
`xs-security.json` (btp area). Every authorization change is a risk in the design and
|
|
49
58
|
gets its own review.
|
|
@@ -17,4 +17,11 @@ Rules for agents:
|
|
|
17
17
|
results.
|
|
18
18
|
- During Build, change only files within the approved task paths; otherwise revert, or
|
|
19
19
|
propose `npx agjan amend`.
|
|
20
|
+
- Create branches only with `npx agjan branch <name>`, never with git directly. When
|
|
21
|
+
`npx agjan status` says a human creates branches, propose the name and ask the user.
|
|
22
|
+
- Run commands from the project root; do not `cd` into folders. Edit files with your
|
|
23
|
+
editor tool, not with scripts. Check behavior with the project's tests (add one if
|
|
24
|
+
needed), not with throwaway scripts.
|
|
25
|
+
- Start a review only when all your edits are saved, and on its own: never in parallel
|
|
26
|
+
with other tool calls. The reviewer must see the finished change.
|
|
20
27
|
- Run `npx agjan check` before you report a step as done.
|
package/package.json
CHANGED
|
@@ -10,7 +10,27 @@
|
|
|
10
10
|
"domains": { "type": "array", "items": { "type": "string" } },
|
|
11
11
|
"language": { "type": "string" },
|
|
12
12
|
"hosts": { "type": "array", "items": { "enum": ["claude-code", "copilot"] } },
|
|
13
|
-
"git": {
|
|
13
|
+
"git": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"base": { "type": ["string", "null"] },
|
|
17
|
+
"branch": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"create": {
|
|
21
|
+
"description": "Who creates branches: 'agent' (default; with npx agjan branch) or 'confirm' (the agent proposes a name, a human runs npx agjan branch in a terminal and may edit it).",
|
|
22
|
+
"enum": ["agent", "confirm"]
|
|
23
|
+
},
|
|
24
|
+
"pattern": {
|
|
25
|
+
"description": "Regular expression every branch name must match (npx agjan branch refuses others; check reports them).",
|
|
26
|
+
"type": ["string", "null"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"additionalProperties": false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
},
|
|
14
34
|
"scope": {
|
|
15
35
|
"type": "object",
|
|
16
36
|
"properties": { "implicit": { "type": "object", "additionalProperties": { "type": "array", "items": { "type": "string" } } } },
|
|
@@ -69,6 +89,21 @@
|
|
|
69
89
|
"additionalProperties": false
|
|
70
90
|
},
|
|
71
91
|
"limits": { "type": "object", "additionalProperties": { "type": "number" } },
|
|
92
|
+
"agent": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"properties": {
|
|
95
|
+
"allow": {
|
|
96
|
+
"description": "Shell commands agents may run without a prompt (the agjan guard hook approves a single simple command starting with an entry). agjan approve, accept and reject are always denied.",
|
|
97
|
+
"type": "array",
|
|
98
|
+
"items": { "type": "string", "minLength": 1 }
|
|
99
|
+
},
|
|
100
|
+
"script_edits": {
|
|
101
|
+
"description": "Whether agents may edit files with shell or script commands (python/node scripts that write files, sed -i, cat > file, tee). Default 'deny': the agjan guard hook sends them to their file edit tool.",
|
|
102
|
+
"enum": ["deny", "allow"]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"additionalProperties": false
|
|
106
|
+
},
|
|
72
107
|
"ci": {
|
|
73
108
|
"type": "object",
|
|
74
109
|
"properties": { "policy_changes": { "enum": ["warn", "fail"] }, "untracked_changes": { "enum": ["warn", "fail"] } },
|
package/src/cli.mjs
CHANGED
|
@@ -12,12 +12,14 @@ import * as setup from './commands/setup.mjs';
|
|
|
12
12
|
import * as report from './commands/report.mjs';
|
|
13
13
|
import * as fix from './commands/fix.mjs';
|
|
14
14
|
import * as mapCommand from './commands/map.mjs';
|
|
15
|
+
import * as branch from './commands/branch.mjs';
|
|
15
16
|
|
|
16
17
|
const COMMANDS = {
|
|
17
18
|
init: setup.init,
|
|
18
19
|
sync: setup.sync,
|
|
19
20
|
doctor: setup.doctor,
|
|
20
21
|
hook: setup.hook,
|
|
22
|
+
branch: branch.run,
|
|
21
23
|
new: newCommand.run,
|
|
22
24
|
scaffold: newCommand.scaffold,
|
|
23
25
|
status: status.run,
|
|
@@ -45,13 +47,15 @@ Usage: agjan <command> [options]
|
|
|
45
47
|
|
|
46
48
|
Setup (human):
|
|
47
49
|
init [--domains btp] [--hosts claude-code,copilot] [--base <ref>]
|
|
48
|
-
[--no-hook] [--no-ci] [--prepare]
|
|
50
|
+
[--no-hook] [--no-ci] [--prepare] [--agent-allow | --no-agent-allow]
|
|
49
51
|
set up agjan in this repository
|
|
50
52
|
sync [--force] regenerate managed files (skills, agents, blocks, settings)
|
|
51
53
|
hook install install the pre-commit hook
|
|
52
54
|
doctor check the environment and the project setup
|
|
53
55
|
|
|
54
56
|
Agent and human:
|
|
57
|
+
branch <name> create the branch for a feature, fix or map run (with
|
|
58
|
+
git.branch.create "confirm": a human, who may edit the name)
|
|
55
59
|
new <slug> --key <KEY> create a feature folder with approvals.json and spec.md
|
|
56
60
|
scaffold design create design.md and tasks.md from the templates
|
|
57
61
|
status [--feature <s> | --all]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { git, currentBranch, resolveBase } from '../git.mjs';
|
|
3
|
+
import { AgjanError, UsageError } from '../errors.mjs';
|
|
4
|
+
|
|
5
|
+
/** Problems with a proposed branch name: git's rules, the project's pattern, existence. */
|
|
6
|
+
export function branchProblems(root, config, name) {
|
|
7
|
+
const problems = [];
|
|
8
|
+
if (git(root, ['check-ref-format', '--branch', name], { allowFail: true }) === null) problems.push(`'${name}' is not a valid branch name`);
|
|
9
|
+
const pattern = config.git?.branch?.pattern;
|
|
10
|
+
if (pattern && !new RegExp(pattern).test(name)) problems.push(`'${name}' does not match the branch pattern ${pattern} (git.branch.pattern)`);
|
|
11
|
+
if (git(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}`], { allowFail: true }) !== null) problems.push(`branch '${name}' already exists`);
|
|
12
|
+
return problems;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* agjan branch <name>: creates the branch for a feature, fix or map run and switches to it.
|
|
17
|
+
* With git.branch.create "confirm" a human runs it in a terminal and may edit the proposed
|
|
18
|
+
* name first (design decision 62); with "agent" (the default) the agent runs it.
|
|
19
|
+
*/
|
|
20
|
+
export async function run(ctx, argv) {
|
|
21
|
+
const { positionals } = parseArgs({ args: argv, allowPositionals: true });
|
|
22
|
+
if (positionals.length !== 1) throw new UsageError('usage: agjan branch <name>');
|
|
23
|
+
const s = ctx.style;
|
|
24
|
+
const policy = ctx.config.git?.branch ?? {};
|
|
25
|
+
let name = positionals[0];
|
|
26
|
+
if (policy.create === 'confirm') {
|
|
27
|
+
let edited;
|
|
28
|
+
try {
|
|
29
|
+
edited = await ctx.edit(`${s.bold('Branch name')} (Enter to create, empty to cancel): `, name);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (!(error instanceof AgjanError)) throw error;
|
|
32
|
+
throw new AgjanError(
|
|
33
|
+
`in this project a human creates branches (git.branch.create: confirm).\nAsk the user to run in a terminal: npx agjan branch ${name}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
name = String(edited ?? '').trim();
|
|
37
|
+
if (!name) {
|
|
38
|
+
ctx.out(s.yellow('cancelled, no branch created'));
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const problems = branchProblems(ctx.root, ctx.config, name);
|
|
43
|
+
if (problems.length) throw new AgjanError(`cannot create the branch:\n${problems.map((p) => ` - ${p}`).join('\n')}`);
|
|
44
|
+
const from = currentBranch(ctx.root);
|
|
45
|
+
git(ctx.root, ['switch', '-q', '-c', name]);
|
|
46
|
+
ctx.out(`${s.green('created branch')} ${s.bold(name)}${from ? s.gray(` (from ${from})`) : ''}`);
|
|
47
|
+
const base = resolveBase(ctx.root, ctx.config.git?.base);
|
|
48
|
+
if (from && base && from !== base.replace(/^origin\//, '')) ctx.out(s.yellow(`note: created from ${from}, not from the base branch ${base}`));
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
package/src/commands/check.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, statSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
|
-
import { git, changedFiles, mergeBase, resolveBase } from '../git.mjs';
|
|
4
|
+
import { git, changedFiles, currentBranch, mergeBase, resolveBase } from '../git.mjs';
|
|
5
5
|
import { CONFIG_FILE, resolveArea } from '../config.mjs';
|
|
6
6
|
import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature } from '../feature.mjs';
|
|
7
7
|
import { documentProblems, designProblems } from '../validate.mjs';
|
|
@@ -333,6 +333,7 @@ export function runChecks(ctx, level, explicitFeature) {
|
|
|
333
333
|
checkScope(report, features, config, files, level);
|
|
334
334
|
const policy = level === 'ci' ? checkPolicy(report, root, config, files, base) : [];
|
|
335
335
|
if (level !== 'staged') {
|
|
336
|
+
checkBranchName(report, root, config, base, level);
|
|
336
337
|
checkManaged(report, ctx);
|
|
337
338
|
// The baseline describes the application; changes to watched files make it stale.
|
|
338
339
|
const drift = features.some((f) => f.kind === 'map') ? null : baselineDrift(root, config);
|
|
@@ -343,6 +344,21 @@ export function runChecks(ctx, level, explicitFeature) {
|
|
|
343
344
|
return { report, slugs, features, files, policy };
|
|
344
345
|
}
|
|
345
346
|
|
|
347
|
+
/**
|
|
348
|
+
* git.branch.pattern (design decision 62): a branch with work on it must match. A warning
|
|
349
|
+
* locally, an error in CI. The base branch itself and a detached HEAD are not judged.
|
|
350
|
+
*/
|
|
351
|
+
function checkBranchName(report, root, config, base, level) {
|
|
352
|
+
const pattern = config.git?.branch?.pattern;
|
|
353
|
+
if (!pattern) return;
|
|
354
|
+
const branch = currentBranch(root);
|
|
355
|
+
if (!branch || branch === base?.replace(/^origin\//, '')) return;
|
|
356
|
+
if (new RegExp(pattern).test(branch)) return;
|
|
357
|
+
const message = `branch '${branch}' does not match the branch pattern ${pattern} (git.branch.pattern)`;
|
|
358
|
+
if (level === 'ci') report.error('git', message);
|
|
359
|
+
else report.warn('git', message);
|
|
360
|
+
}
|
|
361
|
+
|
|
346
362
|
/** `--base <ref>` overrides git.base for this run, for CI where the base ref is known. */
|
|
347
363
|
export function overrideBase(ctx, base) {
|
|
348
364
|
if (base) ctx.config.git = { ...ctx.config.git, base };
|
package/src/commands/setup.mjs
CHANGED
|
@@ -4,7 +4,7 @@ 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, loadConfig, loadDomain } from '../config.mjs';
|
|
7
|
+
import { CONFIG_FILE, RECOMMENDED_ALLOW, loadConfig, loadDomain } from '../config.mjs';
|
|
8
8
|
import { readJson, writeJson } from '../json-file.mjs';
|
|
9
9
|
import { applyPlan, planStatus } from '../managed.mjs';
|
|
10
10
|
import { ADAPTERS, buildPlan, unsupportedHosts } from '../plan.mjs';
|
|
@@ -58,8 +58,11 @@ function doSync(ctx, { force }) {
|
|
|
58
58
|
return results;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/**
|
|
62
|
+
* agjan init [--domains btp] [--hosts claude-code] [--language en] [--base <ref>] [--no-hook] [--no-ci]
|
|
63
|
+
* [--prepare] [--agent-allow | --no-agent-allow]
|
|
64
|
+
*/
|
|
65
|
+
export async function init(ctx, argv) {
|
|
63
66
|
const { values } = parseArgs({
|
|
64
67
|
args: argv,
|
|
65
68
|
options: {
|
|
@@ -70,6 +73,8 @@ export function init(ctx, argv) {
|
|
|
70
73
|
'no-hook': { type: 'boolean' },
|
|
71
74
|
'no-ci': { type: 'boolean' },
|
|
72
75
|
prepare: { type: 'boolean' },
|
|
76
|
+
'agent-allow': { type: 'boolean' },
|
|
77
|
+
'no-agent-allow': { type: 'boolean' },
|
|
73
78
|
},
|
|
74
79
|
});
|
|
75
80
|
const root = ctx.root;
|
|
@@ -87,12 +92,17 @@ export function init(ctx, argv) {
|
|
|
87
92
|
language: values.language ?? 'en',
|
|
88
93
|
};
|
|
89
94
|
if (values.base) config.git = { base: values.base };
|
|
95
|
+
// Opt-in (design decision 61): asked once; without a terminal, nothing is allowed.
|
|
96
|
+
let agentAllow = values['agent-allow'] ? true : values['no-agent-allow'] ? false : null;
|
|
97
|
+
agentAllow ??= ctx.ask(`Let agents run these commands without a prompt: ${RECOMMENDED_ALLOW.join(', ')}?\n(agjan approve, accept and reject stay blocked; edit agent.allow in ${CONFIG_FILE} later.)`) ?? false;
|
|
98
|
+
if (agentAllow) config.agent = { allow: RECOMMENDED_ALLOW };
|
|
90
99
|
writeJson(join(root, CONFIG_FILE), config);
|
|
91
100
|
const s = ctx.style;
|
|
92
101
|
for (const line of banner(s, ctx.kit)) ctx.out(line);
|
|
93
102
|
ctx.out(`${s.bold('agjan init')}: ${CONFIG_FILE} (domains ${domains.join(', ')}; hosts ${hosts.join(', ')})`);
|
|
94
103
|
|
|
95
104
|
printResults(ctx, doSync(ctx, { force: false }));
|
|
105
|
+
ctx.out(` ${pad(agentAllow ? tone(s, 'created') : s.gray('none'), agentAllow ? 'created' : 'none', 14)} agent.allow${agentAllow ? ` (${RECOMMENDED_ALLOW.length} commands)` : ''}`);
|
|
96
106
|
|
|
97
107
|
if (!values['no-hook']) {
|
|
98
108
|
const hook = installHook(root);
|
|
@@ -255,6 +265,9 @@ export function doctor(ctx) {
|
|
|
255
265
|
if (trust === 'trusted') ok('claude code trust', 'project folder trusted');
|
|
256
266
|
else warn('claude code trust', `${trust}; open the folder in Claude Code once and trust it, or the reviewer has no agjan tools`);
|
|
257
267
|
}
|
|
268
|
+
const allow = config.agent?.allow ?? [];
|
|
269
|
+
ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
|
|
270
|
+
ok('script edits', config.agent?.script_edits === 'allow' ? 'allowed (agent.script_edits)' : 'denied by the guard: agents edit files with their edit tool');
|
|
258
271
|
const ignored = git(root, ['check-ignore', '-q', '.agjan/x'], { allowFail: true }) !== null;
|
|
259
272
|
if (!ignored) warn('.gitignore', '.agjan/ is not ignored; run: npx agjan sync');
|
|
260
273
|
}
|
package/src/commands/status.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
|
-
import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature } from '../feature.mjs';
|
|
2
|
+
import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature, stillBlocked } from '../feature.mjs';
|
|
3
3
|
import { UsageError } from '../errors.mjs';
|
|
4
4
|
import { buildProgress, verifyState } from '../progress.mjs';
|
|
5
5
|
import { gateReadiness, pendingGate } from './gates.mjs';
|
|
@@ -28,7 +28,7 @@ function reviewNext(ctx, feature, step) {
|
|
|
28
28
|
if (state.exhausted) {
|
|
29
29
|
return `the ${step} review is still blocked after ${state.round} of ${state.limit} rounds: stop and hand over to the human (fix with them, accept findings, or change the documents)`;
|
|
30
30
|
}
|
|
31
|
-
const round = state.round ? `, round ${state.
|
|
31
|
+
const round = state.round ? `, round ${state.next} of ${state.limit}` : '';
|
|
32
32
|
return `review step ${step} with ${reviewerFor(ctx.config, step)}${round}`;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -83,7 +83,7 @@ function describeOnBase(ctx, feature) {
|
|
|
83
83
|
const s = ctx.style;
|
|
84
84
|
const progress = buildProgress(ctx.root, ctx.config, feature, { history: true });
|
|
85
85
|
const verify = feature.reviews.records.filter((r) => r.step === 'verify').at(-1);
|
|
86
|
-
const merged = progress.complete && verify && verify
|
|
86
|
+
const merged = progress.complete && verify && !stillBlocked(feature, verify);
|
|
87
87
|
heading(ctx, feature, merged ? `stage: ${s.green('merged')}` : `stage: ${s.magenta(feature.stage)} (on the base branch)`);
|
|
88
88
|
row(ctx, 'spec', tone(s, feature.state.spec));
|
|
89
89
|
row(ctx, 'design', `${tone(s, feature.state.design)}${feature.design?.parsed.mode ? ` (${feature.design.parsed.mode})` : ''}`);
|
|
@@ -99,7 +99,7 @@ function describeOnBase(ctx, feature) {
|
|
|
99
99
|
function describeRecordOnBase(ctx, unit) {
|
|
100
100
|
const s = ctx.style;
|
|
101
101
|
const last = unit.reviews.records.at(-1);
|
|
102
|
-
const merged = last && last
|
|
102
|
+
const merged = last && !stillBlocked(unit, last);
|
|
103
103
|
heading(ctx, unit, `${s.magenta(unit.kind)} ${merged ? `stage: ${s.green('merged')}` : '(on the base branch)'}`);
|
|
104
104
|
row(ctx, 'review', last ? `${last.id} ${tone(s, last.verdict)}` : 'none');
|
|
105
105
|
const open = unit.findings.filter((f) => f.status === 'open');
|
|
@@ -162,7 +162,9 @@ export function run(ctx, argv) {
|
|
|
162
162
|
slugs = values.all ? listFeatures(root) : changedFeatures(root, ctx.config);
|
|
163
163
|
}
|
|
164
164
|
const c = ctx.config;
|
|
165
|
-
|
|
165
|
+
const branches = c.git?.branch?.create === 'confirm' ? 'a human creates branches (npx agjan branch, name proposed by the agent)' : 'the agent creates branches with npx agjan branch';
|
|
166
|
+
const pattern = c.git?.branch?.pattern ? `, names matching ${c.git.branch.pattern}` : '';
|
|
167
|
+
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}${pattern}`));
|
|
166
168
|
if (slugs.length === 0) {
|
|
167
169
|
ctx.out(values.all ? `no features in ${FEATURES_DIR}` : 'no changed feature on this branch (agjan status --all lists every feature)');
|
|
168
170
|
return 0;
|
package/src/config.mjs
CHANGED
|
@@ -6,12 +6,18 @@ export const CONFIG_FILE = 'agjan.config.json';
|
|
|
6
6
|
|
|
7
7
|
const KIT_DIR = new URL('../kit/', import.meta.url);
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The commands `agjan init` offers for `agent.allow`: agjan itself (approve, accept and
|
|
11
|
+
* reject stay denied by the guard), the tests, and the git commands of the workflow.
|
|
12
|
+
*/
|
|
13
|
+
export const RECOMMENDED_ALLOW = ['npx agjan', 'npm test', 'git status', 'git diff', 'git log', 'git add', 'git commit'];
|
|
14
|
+
|
|
9
15
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
|
10
16
|
const DEFAULTS = {
|
|
11
17
|
domains: ['btp'],
|
|
12
18
|
hosts: ['claude-code'],
|
|
13
19
|
language: 'en',
|
|
14
|
-
git: { base: null },
|
|
20
|
+
git: { base: null, branch: { create: 'agent', pattern: null } },
|
|
15
21
|
scope: { implicit: {} },
|
|
16
22
|
risk_paths: [],
|
|
17
23
|
tests: {},
|
package/src/context.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { repoRoot, userEmail } from './git.mjs';
|
|
3
3
|
import { loadConfig } from './config.mjs';
|
|
4
|
-
import { confirmOnTerminal, editOnTerminal } from './terminal.mjs';
|
|
4
|
+
import { askOnTerminal, confirmOnTerminal, editOnTerminal } from './terminal.mjs';
|
|
5
5
|
import { createStyle } from './ui.mjs';
|
|
6
6
|
|
|
7
7
|
export const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
@@ -24,6 +24,7 @@ export function createContext({
|
|
|
24
24
|
now = utcNow,
|
|
25
25
|
confirm = confirmOnTerminal,
|
|
26
26
|
edit = editOnTerminal,
|
|
27
|
+
ask = askOnTerminal,
|
|
27
28
|
} = {}) {
|
|
28
29
|
let root;
|
|
29
30
|
let config;
|
|
@@ -35,6 +36,8 @@ export function createContext({
|
|
|
35
36
|
confirm,
|
|
36
37
|
/** Asks the human for one line, prefilled with `initial` (async). */
|
|
37
38
|
edit,
|
|
39
|
+
/** Asks the human a yes/no question; null without a terminal. */
|
|
40
|
+
ask,
|
|
38
41
|
kit: pkg.version,
|
|
39
42
|
get root() {
|
|
40
43
|
root ??= repoRoot(cwd);
|
package/src/feature.mjs
CHANGED
|
@@ -111,6 +111,17 @@ function validateApprovals(data, slug) {
|
|
|
111
111
|
return data;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Whether a review still blocks: its verdict is blocked and the human has not accepted
|
|
116
|
+
* every blocker it raised (design 7.4: no open blocker, unless accepted). An accepted
|
|
117
|
+
* blocker leaves the correction loop, so the step needs no further round for it.
|
|
118
|
+
*/
|
|
119
|
+
export function stillBlocked(feature, record) {
|
|
120
|
+
if (record?.verdict !== 'blocked') return false;
|
|
121
|
+
const status = new Map(feature.findings.map((f) => [f.id, f.status]));
|
|
122
|
+
return (record.findings ?? []).some((f) => f.severity === 'blocker' && status.get(f.id) !== 'accepted');
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
/**
|
|
115
126
|
* Findings with their current status. A finding is resolved when a later record lists
|
|
116
127
|
* it in `resolves`, accepted when the human accepted it, and open otherwise.
|
|
@@ -206,7 +217,7 @@ export function gateReview(feature, gate) {
|
|
|
206
217
|
if (gate === 'design' && docs.design !== feature.designHash) {
|
|
207
218
|
problems.push(`the latest ${record.step} review (${record.id}) did not review the current design.md and tasks.md`);
|
|
208
219
|
}
|
|
209
|
-
if (record
|
|
220
|
+
if (stillBlocked(feature, record)) problems.push(`the latest ${record.step} review (${record.id}) is blocked`);
|
|
210
221
|
}
|
|
211
222
|
const blockers = feature.findings.filter((f) => f.status === 'open' && f.severity === 'blocker' && steps.includes(f.step));
|
|
212
223
|
for (const f of blockers) problems.push(`open blocker ${f.id}: ${f.issue}`);
|
package/src/fix.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { git, mergeBase, resolveBase } from './git.mjs';
|
|
4
|
-
import { FEATURES_DIR, latestReview } from './feature.mjs';
|
|
4
|
+
import { FEATURES_DIR, latestReview, stillBlocked } from './feature.mjs';
|
|
5
5
|
import { treeHash } from './review.mjs';
|
|
6
6
|
import { matcher } from './scope.mjs';
|
|
7
7
|
|
|
@@ -100,7 +100,7 @@ export function fixRules(root, config) {
|
|
|
100
100
|
export function freshReview(root, config, unit, step) {
|
|
101
101
|
const record = latestReview(unit.reviews, [step]);
|
|
102
102
|
if (!record) return { problem: `no ${step} review recorded` };
|
|
103
|
-
if (record
|
|
103
|
+
if (stillBlocked(unit, record)) return { record, problem: `the latest ${step} review ${record.id} is blocked` };
|
|
104
104
|
if (record.tree_hash !== treeHash(root, config, unit.slug)) {
|
|
105
105
|
return { record, problem: `the latest ${step} review ${record.id} is stale: files changed after it` };
|
|
106
106
|
}
|
package/src/git.mjs
CHANGED
|
@@ -36,6 +36,15 @@ export function resolveBase(root, configured) {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* The checked-out branch: the local branch name, or in a pull request job (detached HEAD)
|
|
41
|
+
* the PR's head branch from the CI environment. Null when there is none.
|
|
42
|
+
*/
|
|
43
|
+
export function currentBranch(root, env = process.env) {
|
|
44
|
+
const name = git(root, ['symbolic-ref', '--quiet', '--short', 'HEAD'], { allowFail: true })?.trim();
|
|
45
|
+
return name || env.GITHUB_HEAD_REF || env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME || null;
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
/** The merge-base commit with the base branch, or null when there is none yet. */
|
|
40
49
|
export function mergeBase(root, base) {
|
|
41
50
|
if (!base) return null;
|
package/src/progress.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { git, mergeBase, resolveBase } from './git.mjs';
|
|
2
2
|
import { resolveArea } from './config.mjs';
|
|
3
3
|
import { matcher } from './scope.mjs';
|
|
4
|
-
import { latestReview } from './feature.mjs';
|
|
4
|
+
import { latestReview, stillBlocked } from './feature.mjs';
|
|
5
5
|
import { treeHash } from './review.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -35,7 +35,7 @@ function isAncestor(root, ancestor, descendant) {
|
|
|
35
35
|
|
|
36
36
|
/** A passing review of `step` that saw the given commit (its head contains the commit). */
|
|
37
37
|
function reviewedSince(root, feature, step, sha) {
|
|
38
|
-
return feature.reviews.records.some((r) => r.step === step && r
|
|
38
|
+
return feature.reviews.records.some((r) => r.step === step && !stillBlocked(feature, r) && isAncestor(root, sha, r.head_commit));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -79,7 +79,7 @@ export function buildProgress(root, config, feature, options = {}) {
|
|
|
79
79
|
export function verifyState(root, config, feature) {
|
|
80
80
|
const record = latestReview(feature.reviews, ['verify']);
|
|
81
81
|
if (!record) return { state: 'none', record: null };
|
|
82
|
-
if (record
|
|
82
|
+
if (stillBlocked(feature, record)) return { state: 'blocked', record };
|
|
83
83
|
if (record.tree_hash !== treeHash(root, config, feature.slug)) return { state: 'stale', record };
|
|
84
84
|
return { state: 'current', record };
|
|
85
85
|
}
|
package/src/review-policy.mjs
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* (`build.fix_attempts`). `agjan status` shows them; the skills follow `status`.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { stillBlocked } from './feature.mjs';
|
|
9
|
+
|
|
8
10
|
/** Default tier per kind of review step. */
|
|
9
11
|
export const DEFAULT_TIERS = {
|
|
10
12
|
spec: 'balanced',
|
|
@@ -36,6 +38,32 @@ export function fixAttempts(config) {
|
|
|
36
38
|
return config.build?.fix_attempts ?? 3;
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
/** The gate approvals that close a correction loop of a review step. */
|
|
42
|
+
const CLOSING_APPROVALS = { spec: ['spec'], design: ['design'], 'design:light': ['spec', 'design'] };
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The round the next review of `step` gets (design 7.4). Rounds count within one
|
|
46
|
+
* correction loop: a loop ends with a review without findings (`pass`), with the gate's
|
|
47
|
+
* approval after its last review, or, for build steps, with a passing verify review after
|
|
48
|
+
* it. A later change, for example after the human's Gate 3 review, starts a new loop at
|
|
49
|
+
* round 1.
|
|
50
|
+
*/
|
|
51
|
+
export function nextRound(feature, step) {
|
|
52
|
+
const records = feature.reviews.records.filter((r) => r.step === step);
|
|
53
|
+
const approvals = (CLOSING_APPROVALS[step] ?? []).map((gate) => feature.approvals.approvals[gate]?.at_utc).filter(Boolean);
|
|
54
|
+
if (step.startsWith('build:')) {
|
|
55
|
+
const verified = feature.reviews.records.filter((r) => r.step === 'verify' && !stillBlocked(feature, r));
|
|
56
|
+
approvals.push(...verified.map((r) => r.at_utc));
|
|
57
|
+
}
|
|
58
|
+
let round = 1;
|
|
59
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
60
|
+
const r = records[i];
|
|
61
|
+
if (r.verdict === 'pass' || approvals.some((at) => at >= r.at_utc)) break;
|
|
62
|
+
round += 1;
|
|
63
|
+
}
|
|
64
|
+
return round;
|
|
65
|
+
}
|
|
66
|
+
|
|
39
67
|
/**
|
|
40
68
|
* The state of one review step: its latest round and verdict, and whether the round limit
|
|
41
69
|
* is reached with the step still blocked (design 7.4: stop and hand over to the human).
|
|
@@ -45,5 +73,5 @@ export function roundState(feature, config, step) {
|
|
|
45
73
|
const last = records.at(-1) ?? null;
|
|
46
74
|
const limit = roundLimit(config);
|
|
47
75
|
const round = last?.round ?? 0;
|
|
48
|
-
return { last, round, limit, exhausted: last
|
|
76
|
+
return { last, round, next: nextRound(feature, step), limit, exhausted: stillBlocked(feature, last) && round >= limit };
|
|
49
77
|
}
|
package/src/review.mjs
CHANGED
|
@@ -13,6 +13,8 @@ import { watchedHashes } from './baseline.mjs';
|
|
|
13
13
|
import { acResults, loadResults, resultLabel } from './test-results.mjs';
|
|
14
14
|
import { LOG_FILE, appendLog } from './log.mjs';
|
|
15
15
|
import { AgjanError } from './errors.mjs';
|
|
16
|
+
import { nextRound } from './review-policy.mjs';
|
|
17
|
+
import { designProblems, documentProblems } from './validate.mjs';
|
|
16
18
|
|
|
17
19
|
export const REVIEW_MD = 'review.md';
|
|
18
20
|
const CONTEXT_DIR = '.agjan/review-contexts';
|
|
@@ -137,13 +139,36 @@ function openFindings(feature, steps) {
|
|
|
137
139
|
const CHECKLISTS = {
|
|
138
140
|
spec: 'No unrequested technical decisions. Technical questions listed under Open technical questions are expected and are not decisions: never ask to remove that section; Design answers them. Every AC testable and complete; an AC without a Verification line is automated, which is the default and not a finding; flag only ACs that cannot be tested automatically but are not marked manual. Non-functional and authorization requirements considered. Scope consistent.',
|
|
139
141
|
'design:light': 'The spec checks, plus: light mode is justified (nothing new: no new service, application, BTP service, authorization or deployment change). Tasks: paths plausible, every AC covered.',
|
|
140
|
-
design: 'Every AC covered by tasks. Areas and app types justified with alternatives. Open technical questions answered. Nothing beyond the spec.',
|
|
141
|
-
build: 'Each covered AC is met by the diff. Tests exist and carry the AC id in their names. Project conventions. Security basics (authorization, input validation, no secrets).',
|
|
142
|
+
design: 'Every AC covered by tasks. Areas and app types justified with alternatives. Open technical questions answered. Every rule of the spec\'s Authorization section has a decision on how it is enforced. Nothing beyond the spec.',
|
|
143
|
+
build: 'Each covered AC is met by the diff. Tests exist and carry the AC id in their names. Project conventions. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request. Security basics (authorization, input validation, no secrets; test or mocked users and other development settings only in a development profile, never active in production). Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope.',
|
|
142
144
|
fix: 'The change does exactly what the fix description says and nothing else. It is correct and complete. A test covers it where practical. No hidden scope: anything that changes behaviour beyond the description, or needs a business decision, is a blocker (it belongs in /agjan-spec).',
|
|
143
145
|
map: 'Every claim in project.md is traceable to the files it points to. Services, applications and BTP services are complete. The do-not-touch list is plausible and uses real paths. Short: one to two pages, pointers instead of copies.',
|
|
144
|
-
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. The baseline (project.md) updated if a service, application or BTP service was added. Do not re-review each task.',
|
|
146
|
+
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request. Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope. The baseline (project.md) updated if a service, application or BTP service was added. Do not re-review each task.',
|
|
145
147
|
};
|
|
146
148
|
|
|
149
|
+
/**
|
|
150
|
+
* What the given tasks may change (design 6.5), as `agjan check` judges it: the task paths,
|
|
151
|
+
* the implicit paths of their areas (lockfiles, i18n, fixtures, package.json), and approved
|
|
152
|
+
* amendments. The reviewer sees the same scope as the script.
|
|
153
|
+
*/
|
|
154
|
+
function scopeOf(config, feature, tasks) {
|
|
155
|
+
const taskIds = new Set(tasks.map((t) => t.id));
|
|
156
|
+
const own = tasks.flatMap((t) => t.paths);
|
|
157
|
+
const areas = [...new Set(tasks.map((t) => resolveArea(config, t.area ?? '')?.name).filter(Boolean))];
|
|
158
|
+
const implicit = [...new Set(areas.flatMap((a) => config.scope.implicit[a] ?? []))];
|
|
159
|
+
const amended = feature.amendments.filter((a) => a.status === 'approved' && taskIds.has(a.task)).flatMap((a) => a.paths);
|
|
160
|
+
return { own, implicit, amended, all: [...new Set([...own, ...implicit, ...amended])] };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function scopeText(scope) {
|
|
164
|
+
const list = (items) => (items.length ? items.map((p) => `\`${p}\``).join(', ') : '(none)');
|
|
165
|
+
return [
|
|
166
|
+
`- Task paths: ${list(scope.own)}`,
|
|
167
|
+
`- Implicit for the tasks' areas: ${list(scope.implicit)}`,
|
|
168
|
+
`- Approved amendments: ${list(scope.amended)}`,
|
|
169
|
+
].join('\n');
|
|
170
|
+
}
|
|
171
|
+
|
|
147
172
|
/** Builds the reviewer's input for a step: the only material the reviewer should read. */
|
|
148
173
|
export function buildContextText(root, config, feature, parsed) {
|
|
149
174
|
const base = resolveBase(root, config.git?.base);
|
|
@@ -177,12 +202,11 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
177
202
|
parts.push(section('tasks.md', fence(feature.tasks.text, 'md')));
|
|
178
203
|
} else if (parsed.kind === 'build') {
|
|
179
204
|
const ids = new Set(parsed.tasks.flatMap((t) => t.covers));
|
|
180
|
-
const
|
|
181
|
-
const taskIds = new Set(parsed.tasks.map((t) => t.id));
|
|
182
|
-
for (const a of feature.amendments) if (a.status === 'approved' && taskIds.has(a.task)) paths.push(...a.paths);
|
|
205
|
+
const scope = scopeOf(config, feature, parsed.tasks);
|
|
183
206
|
parts.push(section('Tasks', fence(toYaml(parsed.tasks.map(({ verify, ...t }) => (verify ? { ...t, verify } : t))), 'yaml')));
|
|
207
|
+
parts.push(section('Allowed paths (scope, enforced by agjan check)', scopeText(scope)));
|
|
184
208
|
parts.push(section('Acceptance criteria covered', acsText(feature, ids)));
|
|
185
|
-
parts.push(section('Diff of the
|
|
209
|
+
parts.push(section('Diff of the allowed paths', fence(diffOf(root, base, scope.all), 'diff')));
|
|
186
210
|
} else if (parsed.kind === 'verify') {
|
|
187
211
|
if (!feature.design || !feature.tasks) throw new AgjanError('design.md and tasks.md must exist for the verify review');
|
|
188
212
|
const areaNames = [...new Set(feature.tasks.parsed.tasks.map((t) => resolveArea(config, t.area)?.name).filter(Boolean))];
|
|
@@ -197,6 +221,7 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
197
221
|
parts.push(section('AC coverage (test files mentioning the AC id, and test results)', `| AC | verification | test files | result |\n|---|---|---|---|\n${coverage}`));
|
|
198
222
|
parts.push(section('design.md', fence(feature.design.text, 'md')));
|
|
199
223
|
parts.push(section('tasks.md', fence(feature.tasks.text, 'md')));
|
|
224
|
+
parts.push(section('Allowed paths (scope, enforced by agjan check)', scopeText(scopeOf(config, feature, feature.tasks.parsed.tasks))));
|
|
200
225
|
parts.push(section('Changed files', changed.map((f) => `- ${f}`).join('\n') || '(none)'));
|
|
201
226
|
parts.push(section('Full diff', fence(diffOf(root, base, changed), 'diff')));
|
|
202
227
|
}
|
|
@@ -215,9 +240,48 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
215
240
|
}
|
|
216
241
|
|
|
217
242
|
/** review_context: builds the context, stores its metadata, returns id and text. */
|
|
243
|
+
/**
|
|
244
|
+
* A new round of a step is pointless when nothing changed since its last round raised
|
|
245
|
+
* findings: the reviewer would see the same files. It happens when a writer starts the
|
|
246
|
+
* review before (or in parallel with) its edits, and it costs one of the step's rounds.
|
|
247
|
+
*/
|
|
248
|
+
function unchangedSinceFindings(feature, step, tree) {
|
|
249
|
+
const last = feature.reviews.records.filter((r) => r.step === step).at(-1);
|
|
250
|
+
if (!last || last.verdict === 'pass' || last.tree_hash !== tree) return;
|
|
251
|
+
throw new AgjanError(
|
|
252
|
+
`nothing changed since ${last.id} (${last.verdict}); address its findings and save the changes before the next round. ` +
|
|
253
|
+
'A finding that needs no change is accepted by the human (agjan accept), not reviewed again.',
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Spec and design reviews need complete documents: the same structural checks the gate
|
|
259
|
+
* runs (sections, areas, every AC covered by a task with a title and paths). A review of
|
|
260
|
+
* an unfinished template only reports that and costs one of the step's rounds.
|
|
261
|
+
*/
|
|
262
|
+
function unfinishedDocuments(feature, config, step) {
|
|
263
|
+
if (!['spec', 'design', 'design:light'].includes(step)) return;
|
|
264
|
+
const problems = [];
|
|
265
|
+
if (!feature.spec) problems.push('spec.md does not exist');
|
|
266
|
+
if (step !== 'spec') {
|
|
267
|
+
if (!feature.design) problems.push('design.md does not exist');
|
|
268
|
+
if (!feature.tasks) problems.push('tasks.md does not exist');
|
|
269
|
+
}
|
|
270
|
+
const names = step === 'spec' ? ['spec.md'] : ['spec.md', 'design.md', 'tasks.md'];
|
|
271
|
+
problems.push(...documentProblems(feature).filter((p) => names.some((n) => p.startsWith(n))));
|
|
272
|
+
if (step !== 'spec') problems.push(...designProblems(feature, config));
|
|
273
|
+
if (problems.length === 0) return;
|
|
274
|
+
throw new AgjanError(
|
|
275
|
+
`the documents are not ready for the ${step} review; complete them first:\n${problems.map((p) => ` - ${p}`).join('\n')}`,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
218
279
|
export function createReviewContext(root, config, { feature: slug, step }) {
|
|
219
280
|
const feature = loadFeature(root, slug);
|
|
220
281
|
const parsed = parseStep(step, feature, config);
|
|
282
|
+
unfinishedDocuments(feature, config, parsed.step);
|
|
283
|
+
const tree = treeHash(root, config, feature.slug);
|
|
284
|
+
unchangedSinceFindings(feature, parsed.step, tree);
|
|
221
285
|
const text = buildContextText(root, config, feature, parsed);
|
|
222
286
|
const id = `${feature.key}-C${randomBytes(4).toString('hex')}`;
|
|
223
287
|
const base = resolveBase(root, config.git?.base);
|
|
@@ -227,7 +291,7 @@ export function createReviewContext(root, config, { feature: slug, step }) {
|
|
|
227
291
|
step: parsed.step,
|
|
228
292
|
documents: { spec: feature.spec?.hash, design: feature.designHash ?? undefined },
|
|
229
293
|
inputs_hash: sha256(text),
|
|
230
|
-
tree_hash:
|
|
294
|
+
tree_hash: tree,
|
|
231
295
|
base_commit: mergeBase(root, base),
|
|
232
296
|
head_commit: git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true })?.trim() ?? null,
|
|
233
297
|
};
|
|
@@ -287,7 +351,7 @@ export function recordReview(root, config, { context_id: contextId, verdict, fin
|
|
|
287
351
|
const record = {
|
|
288
352
|
id: `${feature.key}-R${records.length + 1}`,
|
|
289
353
|
step: meta.step,
|
|
290
|
-
round:
|
|
354
|
+
round: nextRound(feature, meta.step),
|
|
291
355
|
at_utc: now(),
|
|
292
356
|
reviewer: { host, model: null, isolation },
|
|
293
357
|
context: contextId,
|
package/src/terminal.mjs
CHANGED
|
@@ -58,6 +58,22 @@ export function confirmOnTerminal(summary, expected) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Asks a yes/no question on the controlling terminal. Returns true or false, or null when
|
|
63
|
+
* there is no terminal (a script, CI or an agent): the caller then keeps its default.
|
|
64
|
+
*/
|
|
65
|
+
export function askOnTerminal(question) {
|
|
66
|
+
const tty = openTerminal();
|
|
67
|
+
if (!tty) return null;
|
|
68
|
+
try {
|
|
69
|
+
writeSync(tty.output, `${question} [y/N] `);
|
|
70
|
+
return /^y(es)?$/i.test(readLine(tty.input).trim());
|
|
71
|
+
} finally {
|
|
72
|
+
closeSync(tty.input);
|
|
73
|
+
if (tty.output !== tty.input) closeSync(tty.output);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* Asks for one line on the controlling terminal with `initial` already typed, so the human
|
|
63
79
|
* can edit it in place (cursor keys, backspace) or press Enter to keep it. Without line
|