agentic-sdlc-kit 0.3.1 → 0.4.1
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/CHANGELOG.md +43 -1
- package/INSTALL.md +8 -8
- package/README.md +32 -15
- package/dist/commands/approve.js +174 -15
- package/dist/commands/board.js +13 -2
- package/dist/commands/githook.js +12 -2
- package/dist/commands/hook.js +163 -17
- package/dist/commands/task.js +1 -0
- package/dist/commands/upgrade.js +7 -1
- package/dist/core/approvals.js +15 -5
- package/dist/core/ownerCommand.js +35 -5
- package/dist/core/pendingDecision.js +45 -0
- package/dist/core/promptProof.js +109 -0
- package/dist/core/stateMachine.js +1 -1
- package/dist/engine/reconcile.js +4 -2
- package/dist/hooks/session.js +64 -1
- package/dist/install/apply.js +9 -1
- package/dist/install/detect.js +106 -17
- package/dist/outbox/outbox.js +9 -5
- package/dist/render/instructions.js +65 -3
- package/package.json +2 -2
- package/templates/instructions/block.md +7 -2
- package/templates/owner-commands/command.md +11 -0
- package/templates/owner-commands/command.toml +2 -0
- package/templates/skills/sdlc-delivery/SKILL.md +2 -2
- package/templates/skills/sdlc-task-tracking/SKILL.md +43 -11
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,46 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.1] - 2026-11-29
|
|
10
|
+
|
|
11
|
+
Merged work waits for its release: release targets from the install on, `board ensure` adds missing labels, and the release workflow creates the GitHub release.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- The `release` workflow creates the GitHub release `v<version>` after it publishes to npm (#19). The notes are the version's `CHANGELOG.md` section, so that section must exist before the tag is pushed: the `test` job checks it first, so a tag without it fails before anything reaches npm. A hyphenated version is marked as a prerelease, and any other version is left for GitHub to rank as Latest by date and version, so a release of an older line does not take Latest. A release that already exists is left alone, so running a tag again is harmless. The new `github-release` job is the only one with write access to the repository, and it runs no repository code; it refuses a `CHANGELOG.md` that is a symlink.
|
|
16
|
+
- `config suggest` proposes a target with `deploy.via: release` for a workflow that publishes on a tag push or a release (`npm`, `pypi` or `crates` after the registry, else `release`), and keeps `feature` and `bugfix` on (#15). Its note says that tasks wait until a published GitHub Release contains the merge. A publish in a comment or with `--dry-run` does not count.
|
|
17
|
+
- The instruction block says which type ships when a type that ends on a deploy is enabled: work that reaches users is such a type and waits as Awaiting deployment after the merge; `tooling` is for changes that never ship (#15).
|
|
18
|
+
- `sdlc board ensure` also creates the missing `type:<id>` labels, so a task type enabled after the install gets its board options and its label in one step. `sdlc upgrade`, which never touches GitHub, says to run it when it changed files (#15).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- INSTALL.md always asks about deploy and release targets (question 5), also when none was detected, and says that a release target needs a published GitHub Release, not a tag. The no-target note of `config suggest` says that every merged task then goes straight to Done (#15).
|
|
23
|
+
- The kit's own configuration pins `kit_ref: v0.4.0`.
|
|
24
|
+
|
|
25
|
+
## [0.4.0] - 2026-11-29
|
|
26
|
+
|
|
27
|
+
Free-form owner approvals: decide in your own words, in any language, or with registered `/approve` commands; plus a developer guide.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- A developer guide under `docs/guide` (installation, configuration, task lifecycle, control and safety, CLI reference, FAQ) with screenshots, and a short README (#8).
|
|
32
|
+
- Free-form owner approvals (#11). The owner approves, accepts, confirms a run or cancels in words, in any language. When a decision waits, the prompt hook reminds the agent of each task that waits for the owner (on a task branch only that branch's task, on any other branch the board; it words the decision as the approve of a phase, "the owner's acceptance of the result" or "the owner's confirmation that they ran it") and the agent records a plain yes with `sdlc approve <issue> <action> --from-prompt <key>`, the owner's prompt text on stdin. `--from-prompt` records only the decision the task waits for (`cancel` aside) and names it when it refuses. The kit proves that the text is the owner's latest prompt and later than what it decides; the agent judges the intent, and when it is not sure it asks again with the exact phrase in quotes. The approval has the new source `prompt-judged` (it counts in `observe` and `enforce`), and the issue quotes the first 280 characters of the normalised text.
|
|
33
|
+
- Typed owner commands can name a task (`/approve 11`, `/accept 11`, `/ran 11`, also in an issue or PR comment). A named task is never swapped for another: the hook records on the task the command names, a comment that names another task does not count, and a number that cannot be read (`/approve 11a`) records nothing. Off a task branch the hook takes the one task that waits for a decision; with several waiting it records nothing and the agent asks which one. `/cancel <reason>` never takes a task from the board.
|
|
34
|
+
- `init` and `upgrade` register `/approve`, `/accept`, `/ran` and `/cancel` as Claude Code skills and Gemini CLI commands, so the harness delivers the typed line to the hook instead of answering "Unknown command". In both harnesses the expanded command starts with its command line (`/approve <arguments>`), so the hook reads it as typed.
|
|
35
|
+
- Approval entries in the guide's FAQ (`docs/guide/faq.md`) and a section on how a decision is recorded in `docs/guide/control-and-safety.md`; threat-model items 21 (an agent that misjudges or lies about intent can record `prompt-judged`, and a prompt sent by an SDK or orchestrator such as `claude -p` counts as the owner's) and 22 (one prompt can record decisions on several tasks); the old items 21 to 30 are now 23 to 32.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- The prompt hook's deadline is 20 s (it was 6 s), for writing an approval; finding the waiting task (the task of the branch, or the board) still has 6 s of it. When that read does not answer in time, the reminder is left out, and a typed command that names no task records nothing and asks for the task to be named. A deadline that passes while an approval is being written says that the outcome is unknown instead of "not recorded".
|
|
40
|
+
- The outbox never queues a command with `--from-prompt`: its prompt text is on stdin, and a replay has none.
|
|
41
|
+
- The prompt log keeps a normalised hash of each prompt, which `--from-prompt` checks the text against; forging the log is now part of threat-model item 18.
|
|
42
|
+
- The instruction block and the `sdlc-task-tracking` skill describe the three ways the owner decides, the certainty rule and the comment route for when no session is open; their example phrase names `#<issue>`.
|
|
43
|
+
- The package author in `package.json` carries the SobSoft s.r.o. website, and the package is managed by the `sobsoft` organization on npm.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Owner approval leftovers (#12). A typed command reads the task number even with sentence punctuation stuck to it (`/approve 11.`, `/approve #11,`, `/accept 7!` name the task); `11a`, `11.5` and `#11x` still cannot be read and record nothing. `sdlc reconcile` no longer drops a comment command that names another task (`/approve 12` on #11) or a number it cannot read: it lists the comment as `ignored_approval` with its reason, and records nothing. The README says the owner approves in the agent's session (in words or with `/approve`) or with a comment, not only with a comment.
|
|
48
|
+
|
|
9
49
|
## [0.3.1] - 2026-11-28
|
|
10
50
|
|
|
11
51
|
The first release published by the workflow through trusted publishing, so it carries npm provenance.
|
|
@@ -76,7 +116,9 @@ First release. It installs an agentic SDLC into any repository: the task lifecyc
|
|
|
76
116
|
- Secret guard: the pre-commit and pre-push hooks run 76 content rules and 10 file-name rules. Output is masked and the guard fails closed; gitleaks is optional.
|
|
77
117
|
- `sdlc doctor`: preflight and install checks.
|
|
78
118
|
|
|
79
|
-
[Unreleased]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.
|
|
119
|
+
[Unreleased]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.4.1...HEAD
|
|
120
|
+
[0.4.1]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.4.0...v0.4.1
|
|
121
|
+
[0.4.0]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.3.1...v0.4.0
|
|
80
122
|
[0.3.1]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.3.0...v0.3.1
|
|
81
123
|
[0.3.0]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.2.0...v0.3.0
|
|
82
124
|
[0.2.0]: https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/compare/v0.1.0...v0.2.0
|
package/INSTALL.md
CHANGED
|
@@ -54,16 +54,16 @@ Key `mode`: `observe` (default) records gaps and warns; `enforce` blocks. In `en
|
|
|
54
54
|
|
|
55
55
|
#### 4. Task types
|
|
56
56
|
|
|
57
|
-
Key `task_types.enabled`; built-in ids are `feature`, `bugfix`, `tooling`, `analysis`, `production-data`, `artifact`, `spike`. Keep `tooling`: the install PR is a `tooling` task. `feature` and `bugfix` end on a deploy and need at least one target, so
|
|
57
|
+
Key `task_types.enabled`; built-in ids are `feature`, `bugfix`, `tooling`, `analysis`, `production-data`, `artifact`, `spike`. Keep `tooling`: the install PR is a `tooling` task. `feature` and `bugfix` end on a deploy and need at least one target, so `config suggest` turns them off when it found no target; question 5 decides. A type enabled later, after the install, also needs `sdlc upgrade` (the instruction blocks) and `sdlc board ensure` (its board options and its `type:<id>` label). Custom types go under `task_types.custom`; see [the design, Task types](https://github.com/SobSoft-s-r-o/agentic-sdlc-kit/blob/main/docs/superpowers/specs/2026-11-27-agentic-sdlc-design.md#7-task-types).
|
|
58
58
|
|
|
59
59
|
#### 5. Deploy targets
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Always ask, even when nothing was detected: does merged work reach users only after a deploy or a release (a package, a GitHub Release, an app build)? If it does, add a target and enable `feature` and `bugfix`; without one, every merged task goes straight to Done. Key `targets`, for each: `name` (kebab-case), `environment` (the GitHub environment; default `production` for one target, `production-<name>` for several; each must be unique), `deploy.via` and optionally `paths` (globs that suggest which targets a PR touches).
|
|
62
62
|
|
|
63
63
|
- `deploy.via: script` with `command`;
|
|
64
64
|
- `deploy.via: actions` with `workflow` (detected from workflows that name an `environment:`);
|
|
65
65
|
- `deploy.via: manual`;
|
|
66
|
-
- `deploy.via: release` (a GitHub Release).
|
|
66
|
+
- `deploy.via: release`: a published GitHub Release whose commit contains the merge; a tag alone does not count. `config suggest` proposes one for a workflow that publishes on a tag or release (npm, PyPI, crates.io, a GitHub Release).
|
|
67
67
|
|
|
68
68
|
#### 6. Quality gate
|
|
69
69
|
|
|
@@ -247,7 +247,7 @@ Give the owner this list; do not do these yourself and do not ask for any value.
|
|
|
247
247
|
5. Turn on secret scanning push protection if `doctor` warns that it is off (repository settings, Code security).
|
|
248
248
|
6. Install the Superpowers plugin for each harness if `stack.superpowers` is on, and graphify if `stack.graphify` is on (commands under question 11, including Codex's `/plugins` route).
|
|
249
249
|
7. Trust the project in each harness so that it runs the hooks: Claude Code's workspace trust dialog, Codex's project trust and the `/hooks` review, Gemini CLI's folder trust (see "Harness hooks and trust"). Make sure `.sdlc/hooks/run.sh` is committed and merged.
|
|
250
|
-
8. When the owner works through an agent session under the account the agents use, approve
|
|
250
|
+
8. When the owner works through an agent session under the account the agents use, approve in the session: write the decision in your own words, or type the command as the first line of a prompt (see "Owner, agents and tokens").
|
|
251
251
|
9. When the rules should block instead of warn, switch the mode: `npx --no-install sdlc config set mode enforce` (an owner login only: an agent login is refused, and the hooks refuse an agent that tries), then `npx --no-install sdlc upgrade` so the instruction blocks and hooks match. Commit the result through a task PR. Run `config set` in the main checkout: the harness hooks read the worktree's `sdlc.config.yaml` and then take `mode`, and only `mode`, from the main checkout's file, so the change reaches every existing task worktree at once, committed or not. When the main checkout has no config or its config does not load, the hooks use the worktree's own mode. `--config <file>` wins over both. The rest of the config, and the git hooks and `sdlc` commands, read each checkout's own copy, so they follow the commit. Run the check at the end of Step 6.
|
|
252
252
|
|
|
253
253
|
## Secrets
|
|
@@ -319,7 +319,7 @@ Limits you must tell the owner:
|
|
|
319
319
|
`sdlc` has to tell what the owner decided from what an agent wrote. It does that by GitHub login.
|
|
320
320
|
|
|
321
321
|
- **Agents should write under a separate account**, listed under `agents` in the config (a bot or machine account, or a GitHub App's `<app>[bot]` login). The state comments of the logins in `agents` are trusted like the owners', but their comments never count as an owner approval. A login cannot be both an owner and an agent (config error).
|
|
322
|
-
- **If they do not**, because the agents run `gh` with the owner's own account, an owner's `/approve` comment is written by the same login `sdlc` acts as, and the tool cannot tell it from the agent approving its own work. In `enforce` mode it is refused ("authored by the agent's own login"); in `observe` mode it is recorded as `unverified`. The way out for an owner who uses one login is the **prompt approval
|
|
322
|
+
- **If they do not**, because the agents run `gh` with the owner's own account, an owner's `/approve` comment is written by the same login `sdlc` acts as, and the tool cannot tell it from the agent approving its own work. In `enforce` mode it is refused ("authored by the agent's own login"); in `observe` mode it is recorded as `unverified`. The way out for an owner who uses one login is the **prompt approval**, in either of two forms. (1) Type the command as the first non-empty line of a prompt in the agent session (`/approve [issue]`, `/accept [issue]`, `/ran [issue]` or `/cancel <reason>`; `init` registers the four as Claude Code skills and Gemini CLI commands so the line reaches the hook). The prompt hook sees what the human typed, not what the agent did, and records it as an approval from the prompt, for the task the command names (`/approve 11`), else the task of the current branch, else the one task on the board that waits for a decision; with several waiting it records nothing and the agent asks which one. `/cancel <reason>` never takes a task from the board: it needs the task of the branch. (2) Write the decision in your own words, in any language ("schvaľujem", "ok, go ahead"). On such a prompt the hook reminds the agent of each task that waits for you and names `sdlc approve <issue> <action> --from-prompt <key>`; the agent runs it with your text on stdin only when your message is an unconditional yes and it is 100 % sure, and otherwise records nothing and asks again with the exact phrase in quotes. The kit proves that the text is your latest prompt, recorded by the hook for a human; it cannot read intent, so the agent's judgment is part of the trust. The approval is recorded as `prompt-judged` and the issue quotes what you wrote (the first 280 characters, normalised), so you can see what was taken for your yes. With a single owner it is recorded for that owner whichever login `gh` runs as; with several owners, the login `gh` runs as must be one of them. `/approve` covers the current phase; the other commands apply to the task. The prompt text is never stored locally, only hashes; the quote on the issue is the one place it is written. A subagent's prompt is ignored, a quoted or later line is not a command, and `/approve type <id>` still needs a comment. A prompt approval is only as good as the hook: see "Harness hooks and trust" and the threat model for what an agent with a shell can still forge. The same happens in `enforce` when the tool's login cannot be read (an Actions `GITHUB_TOKEN` or an App token) and `agents` is empty: owner comments are refused as indistinguishable. `doctor` warns about that case (`approvals.trust`, in `enforce` mode with `stack.actions` on and `agents` empty).
|
|
323
323
|
- **Owner commands on a pull request.** A `/approve`, `/accept`, `/ran` or `/cancel` in a comment on a PR counts only while the PR body links that task alone (`Related to #<n>`) and has not been edited since the comment. If the body is edited after the owner commented, the comment is ignored (`reconcile` reports it as an ignored approval (`--json` gives the reason), `sdlc approve --comment-url` refuses it), so write the command again once the body is final. The same command on the task issue is never affected. Owner commands (`/approve`, `/accept`, `/ran`, `/cancel`) go in a plain comment, not in a review. A command typed into a review body or an inline review comment is never read: no approval is recorded and `reconcile` does not report it.
|
|
324
324
|
- **The workflow token.** The reconcile workflow reads the secret `SDLC_TOKEN` (set with `gh secret set SDLC_TOKEN`) and fails with a message when it is missing. Use a token with the scopes `repo` and `project` for an account that can write to the repository and the board. The Actions-provided `GITHUB_TOKEN` is not enough for the board. Make that account the one listed under `agents`, not the owner's: with the owner's token the workflow runs as the owner, and in `enforce` mode the owner's own `/approve` comments are then refused as the tool's login. The workflow installs the kit in a step without the token, pins its actions by commit SHA and skips Dependabot runs.
|
|
325
325
|
- **Actions minutes.** The workflow also runs every hour. On a private repository each run counts against the account's Actions minutes (on a public repository it is free): roughly 720 short runs a month, each billed as at least one minute. Tell the owner; to save minutes, lower the frequency in the `cron:` line, keeping at least one run per `reconcile.closed_lookback_days`.
|
|
@@ -331,7 +331,7 @@ In short: owner decides under the owner login; agents and the workflow act under
|
|
|
331
331
|
`init` and `upgrade` write the harness hooks for each configured harness: Claude Code (`.claude/settings.json`), Codex (`.codex/hooks.json`) and Gemini CLI (`.gemini/settings.json`); `agents-md` has none. Each runs the launcher `.sdlc/hooks/run.sh <harness> <event>` on session start, on every prompt and before every tool call. The launcher runs `sdlc hook <harness> <event>` (the `sdlc` on the PATH, or `npx --no-install sdlc`), prints its answer and always exits 0. What the hooks do:
|
|
332
332
|
|
|
333
333
|
- Session start tells the agent which task its branch has, and starts `sdlc sync` in the background when something is queued.
|
|
334
|
-
- Every prompt is read for the owner's first-line command (see "Owner, agents and tokens").
|
|
334
|
+
- Every prompt is read for the owner's first-line command (see "Owner, agents and tokens"). On any other human prompt the hook reminds the agent of each task that waits for the owner's decision, so that it can record a decision written in words (`--from-prompt`).
|
|
335
335
|
- Before a tool call, `enforce` blocks and `observe` only warns, and both record a gap on the task, for: a file edit before the plan is approved (docs, `*.md`, debugging repro and task types without a planning phase are excepted; in `enforce` the agent may not edit `sdlc.config.yaml`, `.git`, `.sdlc/` apart from `.sdlc/agents/custom/`, or the harness settings: `.claude/settings.json`, `.claude/settings.local.json`, `.codex/hooks.json`, `.codex/config.toml` and `.gemini/settings.json` at any depth, `.mcp.json` at the root, and the same files plus `.claude.json` in the home directory), a subagent without a role and model tier, `gh pr merge --admin`, a merge through `gh api` (`.../pulls/<n>/merge`, or a GraphQL `mergePullRequest` or `enablePullRequestAutoMerge` in the command; `api-merge`), another AI CLI (`claude`, `codex`, `gemini`, `aider`, and the like; `--version` and `mcp`, `plugin` or `extensions` `list` are allowed), `--no-verify`, turning the git hooks off through git config (`core.hooksPath`, `include.path`), force pushes, `git worktree prune` and forced `git worktree remove`, `rm -rf`, `sdlc config set`, `sdlc uninstall` and `sdlc init --overwrite-modified` (`kit-removal`; `--dry-run` of uninstall and `sdlc upgrade` are allowed) and running the hooks by hand. The `sdlc` rules also read `node .../dist/cli.js ...` and `node_modules/.bin/sdlc`. Running `sdlc hook` or the launcher by hand, and `kit-removal`, block in both modes.
|
|
336
336
|
- **The hooks fail open.** Any error of their own (no `sdlc` found, GitHub unreachable, a malformed payload, a timeout) lets the action through, with one line `sdlc: hook skipped: <reason>` on stderr. The task lookup before a tool call has a 3 second deadline: when it times out the edit is allowed with a warning, so a slow network weakens `enforce`. A hook is a guardrail for an agent that follows the rules, not a wall against one that does not: the threat model (`docs/threat-model.md`) lists what it does not stop.
|
|
337
337
|
|
|
@@ -349,7 +349,7 @@ In short: owner decides under the owner login; agents and the workflow act under
|
|
|
349
349
|
|
|
350
350
|
**Worktrees.** One worktree per task keeps edits out of the main checkout: `npx --no-install sdlc worktree start <issue>` creates `.worktrees/<issue>-<slug>` on the branch `task/<issue>-<slug>` from the freshly fetched default branch (`--dry-run` shows the plan). After the merge, run `npx --no-install sdlc worktree finish <issue>` from the main checkout, never from inside the worktree. It refuses while the worktree has uncommitted or untracked changes or an ignored `.env` or `.env.*` file, or when no pull request of the task has merged. Other ignored files, such as `node_modules` and build output, are deleted with the worktree. It fast-forwards the default branch when the main checkout is clean and on it, then runs `git worktree remove` and `git branch -d`, never forced. `sdlc status` lists orphan worktrees and `doctor` (`worktrees.orphans`) warns about them.
|
|
351
351
|
|
|
352
|
-
**Offline.** When GitHub cannot be reached (a `gh` call that runs longer than 60 seconds is killed and counts as unreachable), the commands an agent needs to keep working are queued instead of failing: `stage start`, `stage publish`, `evidence add`, `review handoff`, `approve` and `task checkpoint`. A queued command prints ``queued for `sdlc sync` (GitHub unreachable): sdlc ...`` and exits 0. The queue is `.sdlc/cache/outbox.jsonl` in the main checkout (git ignores it), shared by all worktrees. The gaps recorded by the hooks wait in `.sdlc/cache/gaps.jsonl` and go into the task's state comment on the next sync (the newest 20 are kept). A gap belongs to a task: one logged where no task exists is dropped by the sync. Run `npx --no-install sdlc sync` when GitHub is back: it replays the queue in order (`--dry-run` only lists it) and exits 0 when it is done, 75 when GitHub is still unreachable (what is left stays queued), and 1 when a command failed for good (it moves to `.sdlc/cache/outbox-failed.jsonl` for the owner to look at). Session start runs a sync in the background, and `sdlc status` shows `Queued for sync: <n> write(s), <m> gap(s)`; `doctor` (`outbox.pending`) warns when writes are queued or failed. `task new` and `deploy record` are never queued: run them again once GitHub is back. With `SDLC_NO_QUEUE=1` a command that cannot reach GitHub exits 75 and queues nothing. A command that half-succeeded before the connection dropped can post its comment twice when it is replayed.
|
|
352
|
+
**Offline.** When GitHub cannot be reached (a `gh` call that runs longer than 60 seconds is killed and counts as unreachable), the commands an agent needs to keep working are queued instead of failing: `stage start`, `stage publish`, `evidence add`, `review handoff`, `approve` and `task checkpoint`. A queued command prints ``queued for `sdlc sync` (GitHub unreachable): sdlc ...`` and exits 0. The queue is `.sdlc/cache/outbox.jsonl` in the main checkout (git ignores it), shared by all worktrees. The gaps recorded by the hooks wait in `.sdlc/cache/gaps.jsonl` and go into the task's state comment on the next sync (the newest 20 are kept). A gap belongs to a task: one logged where no task exists is dropped by the sync. Run `npx --no-install sdlc sync` when GitHub is back: it replays the queue in order (`--dry-run` only lists it) and exits 0 when it is done, 75 when GitHub is still unreachable (what is left stays queued), and 1 when a command failed for good (it moves to `.sdlc/cache/outbox-failed.jsonl` for the owner to look at). Session start runs a sync in the background, and `sdlc status` shows `Queued for sync: <n> write(s), <m> gap(s)`; `doctor` (`outbox.pending`) warns when writes are queued or failed. `task new` and `deploy record` are never queued: run them again once GitHub is back. `approve --from-prompt` is never queued either: its prompt text is on stdin, a replay has none, and a prompt counts only while it is the owner's latest. With `SDLC_NO_QUEUE=1` a command that cannot reach GitHub exits 75 and queues nothing. A command that half-succeeded before the connection dropped can post its comment twice when it is replayed.
|
|
353
353
|
|
|
354
354
|
## MCP servers
|
|
355
355
|
|
|
@@ -382,7 +382,7 @@ Role files are templates: `{{...}}` is filled in when the file is rendered. To w
|
|
|
382
382
|
| `git.legacyHooks` | the repository's own hooks in `.git/hooks` that the kit's hooks run after their own step; a warning names one that is not executable and is skipped: `chmod +x` it |
|
|
383
383
|
| `sdlc.onPath` (warning), `secrets.guard` (failure) | the hooks cannot find `sdlc` (they look on the PATH, then run `npx --no-install sdlc`), so the secret guard is not active: install the dev dependency or a global install (Step 4). Under `npx -y` doctor leaves out the PATH entries npx added for its own run, as a hook does not see them |
|
|
384
384
|
| `kit.ref` | failure: a release `kit_ref` from `v0.3.0` on is not published on npm, so the generated `npx -y agentic-sdlc-kit@<version>` commands fail: set `kit_ref` to a published version or `main`. Warning: a branch (or a tag below `v0.3.0`) `kit_ref` does not exist in the kit's repository, so the generated `npx -y github:...#<kit_ref>` commands fail: set it to `main` or the ref you installed from. `v0.1.0` and `v0.2.0` (never on npm) are looked up in git, pass, and say to move to `v0.3.0` or later. "cannot verify" means `npm view` (release) or `git ls-remote` (branch, old tag) could not reach the registry or GitHub |
|
|
385
|
-
| `board.fields`, `labels` | no board number in the config, or fields, options or
|
|
385
|
+
| `board.fields`, `labels` | no board number in the config, or fields, options, views or labels missing: `sdlc board ensure`. A view the API cannot create is a warning and a manual step |
|
|
386
386
|
| `actions.workflow`, `actions.secret` | the workflow file is missing (`sdlc init`) or `SDLC_TOKEN` is not set (`gh secret set SDLC_TOKEN`); without admin rights the secret cannot be checked and `doctor` only warns |
|
|
387
387
|
| `mcp.token`, `mcp.<harness>` | export `GITHUB_PERSONAL_ACCESS_TOKEN` from the OS keystore in the shell profile ("Secrets"); `mcp.claude`, `mcp.codex` and `mcp.gemini` warn when `<harness> mcp list` does not show the configured servers: approve or add the server, and trust the project in Codex and Gemini |
|
|
388
388
|
| `git.version` | git is older than 2.31, which the hooks and worktrees need: upgrade git |
|
package/README.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
# agentic-sdlc-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Agentic software development, under control.** Your coding agent tracks its own work as a task on a GitHub Projects board and follows a proven lifecycle: intake, brainstorming, planning, implementation, verification, review, delivery and deployment. It pauses for your approval at the decisions that matter. Merging, deploying and touching production data stay with you.
|
|
4
|
+
|
|
5
|
+
Works with Claude Code, OpenAI Codex, Gemini CLI and any `AGENTS.md`-aware agent. On npm as [`agentic-sdlc-kit`](https://www.npmjs.com/package/agentic-sdlc-kit); the binary is `sdlc`.
|
|
4
6
|
|
|
5
7
|
> Status: core CLI, installer and harness hooks available; on npm as `agentic-sdlc-kit` from version 0.3.0
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## What you get
|
|
12
|
+
|
|
13
|
+
- **Every request becomes a task.** Before touching anything, the agent opens a GitHub issue with a hidden state comment and a card on your board.
|
|
14
|
+
- **A route, not improvisation.** The design and the plan are published on the issue, and the task pauses until you approve. You decide in the agent's session, in your own words or with `/approve`, or with an `/approve` comment on the issue. Only then does the agent write code, in its own worktree and branch.
|
|
15
|
+
- **A board that is always current.** Status, phase, who it waits on, the current and next step, pending deploy targets. `sdlc status` gives the same view in the terminal.
|
|
16
|
+
- **You hold the gates.** Only you merge and deploy. Hooks refuse `gh pr merge --admin`, merges through the API, other AI CLIs and changes to the kit's own settings. In `observe` mode they warn; in `enforce` mode they block.
|
|
17
|
+
- **Secrets stay out.** A commit and push guard blocks credentials in every mode, and push protection backs it up on GitHub.
|
|
18
|
+
- **Survives restarts.** A new session is told its task, phase and next step.
|
|
8
19
|
|
|
9
20
|
## Install
|
|
10
21
|
|
|
@@ -14,7 +25,7 @@ Ask your coding agent to install it. In the repository you want to set up, give
|
|
|
14
25
|
Install agentic-sdlc-kit from https://github.com/SobSoft-s-r-o/agentic-sdlc-kit into this repository. Follow its INSTALL.md.
|
|
15
26
|
```
|
|
16
27
|
|
|
17
|
-
The agent runs the preflight, detects your setup, asks you the install questions one at a time (agents, board, mode, task types, deploy targets, quality gate, merge policy, MCP servers, where secrets live, models, stack, owners, language), shows you `sdlc.config.yaml` and the plan, installs, and opens a pull request for you to review. The steps only you can do (tokens, MCP approvals) are listed at the end. The full procedure is in [INSTALL.md](INSTALL.md).
|
|
28
|
+
The agent runs the preflight, detects your setup, asks you the install questions one at a time (agents, board, mode, task types, deploy targets, quality gate, merge policy, MCP servers, where secrets live, models, stack, owners, language), shows you `sdlc.config.yaml` and the plan, installs, and opens a pull request for you to review. The steps only you can do (tokens, MCP approvals) are listed at the end. The full procedure is in [INSTALL.md](INSTALL.md); what it looks like for you, with screenshots, is in [the installation guide](docs/guide/installation.md).
|
|
18
29
|
|
|
19
30
|
## Requirements
|
|
20
31
|
|
|
@@ -24,6 +35,22 @@ The agent runs the preflight, detects your setup, asks you the install questions
|
|
|
24
35
|
|
|
25
36
|
The package is [`agentic-sdlc-kit` on npm](https://www.npmjs.com/package/agentic-sdlc-kit) and its binary is `sdlc`. Add it to a project with `npm install --save-dev agentic-sdlc-kit`, or run a release once with `npx -y agentic-sdlc-kit@<version> <command>`; the walkthrough below uses both.
|
|
26
37
|
|
|
38
|
+
## Guide
|
|
39
|
+
|
|
40
|
+
| | |
|
|
41
|
+
|---|---|
|
|
42
|
+
| [Overview](docs/guide/index.md) | What the kit is and the problem it solves |
|
|
43
|
+
| [How it works](docs/guide/how-it-works.md) | CLI, state comment, board, git and harness hooks, reconcile |
|
|
44
|
+
| [Installation](docs/guide/installation.md) | The install run step by step, and what changes |
|
|
45
|
+
| [Task lifecycle](docs/guide/task-lifecycle.md) | One real task from request to deployment |
|
|
46
|
+
| [The board](docs/guide/board.md) | Fields, views, how commands move cards |
|
|
47
|
+
| [Control and safety](docs/guide/control-and-safety.md) | Owner gates, `observe` and `enforce`, what is blocked, secrets |
|
|
48
|
+
| [Configuration](docs/guide/configuration.md) | `sdlc.config.yaml`, key by key |
|
|
49
|
+
| [CLI reference](docs/guide/cli-reference.md) | Every `sdlc` command |
|
|
50
|
+
| [FAQ](docs/guide/faq.md) | Troubleshooting, limits, upgrading |
|
|
51
|
+
|
|
52
|
+
What the layers guarantee, and what an agent with a shell can still do, is in [the threat model](docs/threat-model.md). The design behind it all is in [docs/superpowers/specs](docs/superpowers/specs/2026-11-27-agentic-sdlc-design.md).
|
|
53
|
+
|
|
27
54
|
## Two-minute walkthrough
|
|
28
55
|
|
|
29
56
|
Run these yourself instead, from the root of a git repository with `gh` logged in. `<version>` is a release on npm, from `0.3.0` on (for example `0.3.0`; `v0.1.0` and `v0.2.0` were never published). To try `main` or a commit instead, write `github:SobSoft-s-r-o/agentic-sdlc-kit#<ref>` where the commands say `agentic-sdlc-kit@<version>`.
|
|
@@ -53,11 +80,11 @@ Tasks and the board:
|
|
|
53
80
|
- `sdlc stage start | publish` - start a phase, or post its result as an issue comment.
|
|
54
81
|
- `sdlc evidence add` - record the evidence (a backup, a dry run) a task type requires before review.
|
|
55
82
|
- `sdlc review handoff` - hand a task over for review with a linked pull request.
|
|
56
|
-
- `sdlc approve` - record an owner decision: approve a stage, accept a result, confirm a run, or cancel.
|
|
83
|
+
- `sdlc approve` - record an owner decision: approve a stage, accept a result, confirm a run, or cancel. The source is the owner's comment (`--comment-url`) or, for an agent, the owner's latest prompt (`--from-prompt <key>`, the prompt text on stdin; the issue then quotes what the owner wrote).
|
|
57
84
|
- `sdlc deploy record` - record that a commit is deployed to a target.
|
|
58
85
|
- `sdlc reconcile` - bring tasks, the board and issues in line with merges, approvals and deployments (`--dry-run` only reports). It reads open tasks and those closed within `reconcile.closed_lookback_days` (default 30); `--all` reads every task. It also adds the `sdlc:partial` label to a task's PR whose body says `Scope: partial` and removes it from any other, and prints owner commands that did not count as one summary line (`--json` lists every action).
|
|
59
86
|
- `sdlc status` - show tasks by status, what waits on the owner, what is stale (`--stale-days`, default 7), untracked issues, what reconcile would change, what waits for `sdlc sync` (`Queued for sync:`) and the orphan worktrees (`--all` also lists tasks closed before the lookback).
|
|
60
|
-
- `sdlc sync` - replay the commands that were queued while GitHub was unreachable and record the gaps the harness hooks logged (`--dry-run` only lists them). The queue is `.sdlc/cache/outbox.jsonl` in the main checkout; only `stage start`, `stage publish`, `evidence add`, `review handoff`, `approve` and `task checkpoint` are ever replayed.
|
|
87
|
+
- `sdlc sync` - replay the commands that were queued while GitHub was unreachable and record the gaps the harness hooks logged (`--dry-run` only lists them). The queue is `.sdlc/cache/outbox.jsonl` in the main checkout; only `stage start`, `stage publish`, `evidence add`, `review handoff`, `approve` and `task checkpoint` are ever replayed, and never one with `--from-prompt` (its prompt text is on stdin and a replay has none).
|
|
61
88
|
- `sdlc worktree start | finish` - create the worktree `.worktrees/<issue>-<slug>` of a task from the fetched default branch, and after the merge remove it and its branch. Nothing is forced: `finish` refuses while the worktree has uncommitted or untracked changes or holds an ignored `.env*` file, when the task has no merged PR, and when run from inside the worktree (`--dry-run` shows the plan).
|
|
62
89
|
- `sdlc board ensure` - create the board or add its missing fields, options and views (add-only).
|
|
63
90
|
|
|
@@ -74,16 +101,6 @@ Installing and checking:
|
|
|
74
101
|
|
|
75
102
|
Run `sdlc <command> --help` for the options of each command.
|
|
76
103
|
|
|
77
|
-
## Harness hooks
|
|
78
|
-
|
|
79
|
-
With the hooks installed, `sdlc` is also the referee of the agent's session. At session start the agent is told its task. Every prompt is read for the owner's `/approve`, `/accept`, `/ran` or `/cancel <reason>` as its first line, which is recorded as an approval. Every edit made with the harness's edit tools, every shell command and every subagent dispatch is checked, and in `enforce` mode a violation is refused: edits before the plan is approved, subagents without a role and model tier, `gh pr merge --admin` and merges through `gh api`, other AI CLIs, `sdlc config set`. In `observe` mode the agent is only warned. Either way a gap is recorded on the task. Hooks fail open: any error of their own lets the action through. Commit `.sdlc/hooks/run.sh`, or new worktrees and clones run no hooks; Codex and Gemini also need the project trusted ([INSTALL.md](INSTALL.md), "Harness hooks and trust").
|
|
80
|
-
|
|
81
|
-
What the layers guarantee, and what an agent with a shell can still do, is in [the threat model](docs/threat-model.md).
|
|
82
|
-
|
|
83
|
-
## Secrets
|
|
84
|
-
|
|
85
|
-
The commit and push hooks block anything that looks like a secret, in `observe` and `enforce` mode alike, and print only a masked value. Secrets for local testing live in your OS keystore, production secrets in the store you name in the config; none belongs in a repository file. See "Secret guard" in [INSTALL.md](INSTALL.md).
|
|
86
|
-
|
|
87
104
|
## Contributing, security and changes
|
|
88
105
|
|
|
89
106
|
Setup, tests and commit style are in [CONTRIBUTING.md](CONTRIBUTING.md); everyone taking part follows the [Code of Conduct](CODE_OF_CONDUCT.md). Report a vulnerability privately, as [SECURITY.md](SECURITY.md) describes. What changed in each release is in [CHANGELOG.md](CHANGELOG.md).
|
package/dist/commands/approve.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { pendingDecision } from '../core/pendingDecision.js';
|
|
1
2
|
import { APPROVAL_ACTIONS, approvalEvent, ApprovalRefusedError, assertApprovalFits, finalMergeTime, normalizeCommentUrl, PR_BODY_EDITED_MESSAGE, prBodyEditedAfter, recordedRefs, validateCommentApproval, } from '../core/approvals.js';
|
|
2
3
|
import { parsePrBody } from '../core/prBody.js';
|
|
4
|
+
import { provePrompt, quoteForIssue } from '../core/promptProof.js';
|
|
3
5
|
import { renderCancelReport } from '../core/summary.js';
|
|
6
|
+
import { PROMPTS_FILE, readJsonLines } from '../hooks/localLog.js';
|
|
7
|
+
import { promptApprover, promptRefOfHash } from '../hooks/session.js';
|
|
8
|
+
import { HOOK_HARNESSES } from '../hooks/types.js';
|
|
4
9
|
import { commitLoaded, describeState, loadTask, parseChoice, parseIssueNumber, parsePhase, runCommand, trackerStep, } from './context.js';
|
|
10
|
+
import { readAllStdin } from './githook.js';
|
|
5
11
|
export { APPROVAL_ACTIONS };
|
|
6
12
|
/** The thread (issue or PR number) a comment URL points into, when the URL says. */
|
|
7
13
|
const threadOf = (url) => {
|
|
@@ -96,42 +102,180 @@ export function unverifiedAt(state, now) {
|
|
|
96
102
|
* comes from and that it is genuine; this only applies it. The task is read here unless the caller
|
|
97
103
|
* already has it (`loaded`, so a caller that looked at the state first does not read it twice).
|
|
98
104
|
* `phase` defaults to the task's current phase and only matters for `approve`; `cancel` needs a
|
|
99
|
-
* reason and posts the cancel report before the state is written.
|
|
105
|
+
* reason and posts the cancel report before the state is written. `input.comment`, when given, is
|
|
106
|
+
* posted on the issue first of all, also before the state is written: a refused or failed decision
|
|
107
|
+
* leaves no comment behind it, and a failed write leaves the comment and says so.
|
|
100
108
|
*/
|
|
101
109
|
export async function applyApproval(ctx, issue, input, approval, loaded) {
|
|
102
|
-
const { action } = input;
|
|
110
|
+
const { action, comment } = input;
|
|
103
111
|
const task = loaded ?? (await loadTask(ctx, issue));
|
|
104
112
|
const phase = input.phase ?? task.task.state.phase;
|
|
105
113
|
const reason = input.reason?.trim() ?? '';
|
|
106
114
|
if (action === 'cancel' && !reason)
|
|
107
115
|
throw new Error('cancel needs a reason (--reason <text>)');
|
|
116
|
+
const posts = [
|
|
117
|
+
...(comment === undefined ? [] : ['the comment']),
|
|
118
|
+
...(action === 'cancel' ? ['the cancel report'] : []),
|
|
119
|
+
];
|
|
120
|
+
const post = (body) => trackerStep('postComment', issue, () => ctx.tracker.postComment(issue, body), 'the state was not changed');
|
|
108
121
|
return commitLoaded(ctx, task, approvalEvent(action, phase, reason, approval), {
|
|
109
|
-
beforeWrite:
|
|
110
|
-
?
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
beforeWrite: posts.length === 0
|
|
123
|
+
? undefined
|
|
124
|
+
: async (next) => {
|
|
125
|
+
if (comment !== undefined)
|
|
126
|
+
await post(comment);
|
|
127
|
+
if (action === 'cancel')
|
|
128
|
+
await post(renderCancelReport(next));
|
|
129
|
+
},
|
|
130
|
+
writeHint: posts.length === 0
|
|
131
|
+
? undefined
|
|
132
|
+
: `${posts.join(' and ')} ${posts.length > 1 ? 'were' : 'was'} posted; the state was not changed`,
|
|
116
133
|
});
|
|
117
134
|
}
|
|
135
|
+
const PROMPT_IS_ALONE = '--from-prompt is a source of its own: do not combine it with --comment-url or --unverified';
|
|
136
|
+
/** Throws when `--from-prompt` is given together with another source of the approval. */
|
|
137
|
+
function assertPromptIsAlone(fromPrompt, otherSource) {
|
|
138
|
+
if (fromPrompt && otherSource)
|
|
139
|
+
throw new Error(PROMPT_IS_ALONE);
|
|
140
|
+
}
|
|
141
|
+
/** The dates among `times`, as given: a missing time or one that is not a date is left out. */
|
|
142
|
+
const dated = (times) => times.filter((time) => msOf(time) !== undefined);
|
|
143
|
+
/**
|
|
144
|
+
* The floor of a `cancel` by prompt. The owner can cancel at any time, so no publish speaks for it,
|
|
145
|
+
* yet a prompt written before the task existed must not be able to cancel it: a session the owner
|
|
146
|
+
* left days ago still has a newest prompt. The state has no creation stamp, so the task's start is
|
|
147
|
+
* the earliest time it records (a published stage, evidence, a type change, the result, the merge);
|
|
148
|
+
* a task reopened since is dated by the reopen if that is later. A stage published again keeps only
|
|
149
|
+
* its latest time, so the start can only come out late, which makes the floor stricter, never laxer.
|
|
150
|
+
* `undefined` when the state records no time at all (a task just created): there is nothing to show
|
|
151
|
+
* a prompt newer than.
|
|
152
|
+
*/
|
|
153
|
+
function cancelFloor(state) {
|
|
154
|
+
const [started] = dated([
|
|
155
|
+
...Object.values(state.stages).map(stage => stage?.publishedAt),
|
|
156
|
+
...state.evidence.map(item => item.at),
|
|
157
|
+
...(state.typeChanges ?? []).map(change => change.at),
|
|
158
|
+
state.resultPublishedAt,
|
|
159
|
+
state.finalMergedAt,
|
|
160
|
+
]).sort((a, b) => Date.parse(a) - Date.parse(b));
|
|
161
|
+
const [reopened] = dated([state.reopenedAt]);
|
|
162
|
+
if (reopened !== undefined && (started === undefined || msOf(reopened) >= msOf(started))) {
|
|
163
|
+
return { at: reopened, what: 'the reopen of the task' };
|
|
164
|
+
}
|
|
165
|
+
return started === undefined ? undefined : { at: started, what: 'the start of the task' };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* What a prompt must be later than to speak for `action`: the published stage (`approve`), the
|
|
169
|
+
* published result (`accept`), the merge of the final PR (`ran`), the start or the last reopen of
|
|
170
|
+
* the task (`cancel`). `undefined` means there is nothing to date the prompt against: the thing was
|
|
171
|
+
* never published or merged, or the task has no recorded time.
|
|
172
|
+
*/
|
|
173
|
+
function promptFloor(state, action, phase) {
|
|
174
|
+
const floor = (at, what) => at === undefined ? undefined : { at, what };
|
|
175
|
+
switch (action) {
|
|
176
|
+
case 'approve':
|
|
177
|
+
return floor(state.stages[phase]?.publishedAt, 'the published revision');
|
|
178
|
+
case 'accept':
|
|
179
|
+
return floor(state.resultPublishedAt, 'the published result');
|
|
180
|
+
case 'ran':
|
|
181
|
+
return floor(state.finalMergedAt, 'the merge of the final PR');
|
|
182
|
+
case 'cancel':
|
|
183
|
+
return cancelFloor(state);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** The first line of the issue comment that quotes the owner: which decision, on what. */
|
|
187
|
+
function promptCommentHeading(state, action, phase) {
|
|
188
|
+
switch (action) {
|
|
189
|
+
case 'approve': {
|
|
190
|
+
const revision = state.stages[phase]?.revision;
|
|
191
|
+
return `Owner's approve of ${phase}${revision === undefined ? '' : ` (revision ${revision})`}, from the prompt:`;
|
|
192
|
+
}
|
|
193
|
+
case 'accept':
|
|
194
|
+
return "Owner's accept of the result, from the prompt:";
|
|
195
|
+
case 'ran':
|
|
196
|
+
return "Owner's confirmation that the run was done (ran), from the prompt:";
|
|
197
|
+
case 'cancel':
|
|
198
|
+
return "Owner's cancel of the task, from the prompt:";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The owner's decision as the agent judged it from a free-form prompt (`--from-prompt`). The kit
|
|
203
|
+
* cannot read intent, so it proves provenance: the text is a prompt the prompt hook recorded for a
|
|
204
|
+
* human (`provePrompt`: fresh, the owner's latest of the session, later than what it decides on), and
|
|
205
|
+
* it is not already recorded as a decision (the reference is the hook's own for the same prompt, so
|
|
206
|
+
* either route counts a prompt once). The decision is recorded with source `prompt-judged`, at the
|
|
207
|
+
* time of the prompt, and the issue gets a comment quoting the owner (`quoteForIssue`), posted first.
|
|
208
|
+
* The prompt text goes nowhere else: not into the prompt log, not into the state.
|
|
209
|
+
*/
|
|
210
|
+
async function approveFromPrompt(ctx, loaded, input, prompt) {
|
|
211
|
+
const { action, phase, reason } = input;
|
|
212
|
+
const { issue, state } = loaded.task;
|
|
213
|
+
// Both are known before anything is read or posted: a refusal leaves no comment behind it.
|
|
214
|
+
if (action === 'cancel' && !reason)
|
|
215
|
+
throw new Error('cancel needs a reason (--reason <text>)');
|
|
216
|
+
// A free-form "yes" answers the decision the task waits for, never another one (`cancel` answers none).
|
|
217
|
+
if (action !== 'cancel') {
|
|
218
|
+
const pending = pendingDecision(state, loaded.type);
|
|
219
|
+
if (pending !== action) {
|
|
220
|
+
throw new ApprovalRefusedError(pending === undefined
|
|
221
|
+
? `#${issue} waits for no owner decision, so a prompt cannot ${action} it`
|
|
222
|
+
: `#${issue} waits for the owner's ${pending}, not ${action}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const floor = promptFloor(state, action, phase);
|
|
226
|
+
if (floor === undefined) {
|
|
227
|
+
throw new ApprovalRefusedError(action === 'cancel'
|
|
228
|
+
? `nothing is recorded for #${issue} yet that dates the task, so a prompt cannot be shown to be newer than it; record the cancel from the owner's comment (--comment-url) instead`
|
|
229
|
+
: `nothing is published or merged for #${issue} that a prompt could ${action}`);
|
|
230
|
+
}
|
|
231
|
+
if (ctx.repoRoot === undefined) {
|
|
232
|
+
throw new ApprovalRefusedError('cannot find the prompt log: run sdlc inside the repository whose prompts these are');
|
|
233
|
+
}
|
|
234
|
+
const records = await readJsonLines(ctx.repoRoot, PROMPTS_FILE);
|
|
235
|
+
const proof = provePrompt(records, prompt.key, prompt.text, floor.at, floor.what);
|
|
236
|
+
if ('refused' in proof)
|
|
237
|
+
throw new ApprovalRefusedError(proof.refused);
|
|
238
|
+
const { record } = proof;
|
|
239
|
+
const harness = HOOK_HARNESSES.find(known => known === record.harness);
|
|
240
|
+
if (harness === undefined)
|
|
241
|
+
throw new ApprovalRefusedError(`the record of the prompt ${prompt.key} is malformed`);
|
|
242
|
+
const ref = promptRefOfHash(harness, record.sessionId, record.promptId, action === 'approve' ? `approve-${phase}` : action, record.sha256);
|
|
243
|
+
if (recordedRefs(state).has(normalizeCommentUrl(ref))) {
|
|
244
|
+
throw new Error(`the prompt ${prompt.key} is already recorded as an approval of #${issue}`);
|
|
245
|
+
}
|
|
246
|
+
// As the hook does: with one owner the prompt is theirs, whatever login the tool runs as.
|
|
247
|
+
const login = ctx.cfg.owners.length === 1
|
|
248
|
+
? undefined
|
|
249
|
+
: await trackerStep('authenticatedLogin', undefined, () => ctx.tracker.authenticatedLogin());
|
|
250
|
+
const approver = promptApprover(ctx.cfg, login);
|
|
251
|
+
if ('refused' in approver)
|
|
252
|
+
throw new ApprovalRefusedError(approver.refused);
|
|
253
|
+
return applyApproval(ctx, issue, {
|
|
254
|
+
action,
|
|
255
|
+
phase,
|
|
256
|
+
reason,
|
|
257
|
+
comment: `${promptCommentHeading(state, action, phase)}\n\n${quoteForIssue(prompt.text)}`,
|
|
258
|
+
}, { source: 'prompt-judged', ref, by: approver.by, at: record.at }, loaded);
|
|
259
|
+
}
|
|
118
260
|
/**
|
|
119
261
|
* Records an owner decision on the task: `approve` a published stage, `accept` the published result,
|
|
120
262
|
* confirm the production-data run (`ran`) or `cancel`. The decision needs a source: an owner's
|
|
121
|
-
* `commentUrl`,
|
|
263
|
+
* `commentUrl`, `unverified` (observe mode only), or a `fromPrompt` the agent judged to be the
|
|
264
|
+
* owner's decision (`approveFromPrompt`; either mode). The comment must be that command (`/approve`,
|
|
122
265
|
* `/accept`, `/ran`, `/cancel <reason>`), never edited after posting, and newer than what it acts
|
|
123
266
|
* on. A comment by the tool's own login is the agent approving itself: refused in enforce mode,
|
|
124
267
|
* recorded as unverified in observe mode. `cancel` needs a reason, from `input.reason` or else the
|
|
125
268
|
* comment, and posts the cancel report before the state is written.
|
|
126
269
|
*/
|
|
127
270
|
export async function approve(ctx, issue, input) {
|
|
128
|
-
const { action, commentUrl, unverified = false } = input;
|
|
271
|
+
const { action, commentUrl, unverified = false, fromPrompt } = input;
|
|
272
|
+
assertPromptIsAlone(fromPrompt !== undefined, commentUrl !== undefined || unverified);
|
|
129
273
|
if (commentUrl !== undefined && unverified)
|
|
130
274
|
throw new Error('Use either --comment-url or --unverified, not both');
|
|
131
275
|
if (unverified && ctx.cfg.mode !== 'observe') {
|
|
132
276
|
throw new Error('unverified approvals are not allowed in enforce mode');
|
|
133
277
|
}
|
|
134
|
-
if (commentUrl === undefined && !unverified) {
|
|
278
|
+
if (commentUrl === undefined && !unverified && fromPrompt === undefined) {
|
|
135
279
|
throw new Error('An approval needs --comment-url <url>, or --unverified in observe mode');
|
|
136
280
|
}
|
|
137
281
|
const loaded = await loadTask(ctx, issue);
|
|
@@ -140,6 +284,8 @@ export async function approve(ctx, issue, input) {
|
|
|
140
284
|
let reason = input.reason?.trim() ?? '';
|
|
141
285
|
// Fail on anything but timing (not published, wrong task type, done) before looking up comments.
|
|
142
286
|
assertApprovalFits(state, loaded.type, action, phase, reason);
|
|
287
|
+
if (fromPrompt !== undefined)
|
|
288
|
+
return approveFromPrompt(ctx, loaded, { action, phase, reason }, fromPrompt);
|
|
143
289
|
let prsRead;
|
|
144
290
|
const listPrs = () => (prsRead ??= trackerStep('listTaskPrs', issue, () => ctx.tracker.listTaskPrs(issue)));
|
|
145
291
|
let approval;
|
|
@@ -156,6 +302,7 @@ export async function approve(ctx, issue, input) {
|
|
|
156
302
|
const checked = await validateCommentApproval({
|
|
157
303
|
comment,
|
|
158
304
|
action,
|
|
305
|
+
issue,
|
|
159
306
|
phase,
|
|
160
307
|
state,
|
|
161
308
|
cfg: ctx.cfg,
|
|
@@ -168,8 +315,16 @@ export async function approve(ctx, issue, input) {
|
|
|
168
315
|
}
|
|
169
316
|
return applyApproval(ctx, issue, { action, phase, reason }, approval, loaded);
|
|
170
317
|
}
|
|
171
|
-
/**
|
|
172
|
-
|
|
318
|
+
/**
|
|
319
|
+
* The prompt for `--from-prompt <key>`: the key and all of stdin, as UTF-8. The other sources are
|
|
320
|
+
* refused first, so a refused command never waits for stdin.
|
|
321
|
+
*/
|
|
322
|
+
async function promptFromStdin(key, options, readStdin) {
|
|
323
|
+
assertPromptIsAlone(true, options.commentUrl !== undefined || options.unverified === true);
|
|
324
|
+
return { key, text: await readStdin() };
|
|
325
|
+
}
|
|
326
|
+
/** Registers `sdlc approve <issue> <action>`. `readStdin` gives the prompt text for `--from-prompt`. */
|
|
327
|
+
export function registerApproveCommand(program, makeContext, readStdin = () => readAllStdin()) {
|
|
173
328
|
program
|
|
174
329
|
.command('approve')
|
|
175
330
|
.description('Record an owner decision: approve a stage, accept a result, confirm a run or cancel')
|
|
@@ -179,14 +334,18 @@ export function registerApproveCommand(program, makeContext) {
|
|
|
179
334
|
.option('--reason <text>', 'cancel: why the task is cancelled')
|
|
180
335
|
.option('--comment-url <url>', "URL of the owner's comment on the issue or one of its PRs")
|
|
181
336
|
.option('--unverified', 'record the approval without a source (observe mode only)')
|
|
337
|
+
.option('--from-prompt <key>', "record the decision from the owner's latest prompt: the key the prompt hook gave, the prompt text on stdin")
|
|
182
338
|
.option('--json', 'print machine-readable JSON')
|
|
183
339
|
.action(async (issue, action, options) => {
|
|
184
|
-
await runCommand(makeContext, options, ctx => approve(ctx, parseIssueNumber(issue), {
|
|
340
|
+
await runCommand(makeContext, options, async (ctx) => approve(ctx, parseIssueNumber(issue), {
|
|
185
341
|
action: parseChoice(action, APPROVAL_ACTIONS, 'action'),
|
|
186
342
|
phase: options.phase === undefined ? undefined : parsePhase(options.phase),
|
|
187
343
|
reason: options.reason,
|
|
188
344
|
commentUrl: options.commentUrl,
|
|
189
345
|
unverified: options.unverified === true,
|
|
346
|
+
...(options.fromPrompt === undefined
|
|
347
|
+
? {}
|
|
348
|
+
: { fromPrompt: await promptFromStdin(options.fromPrompt, options, readStdin) }),
|
|
190
349
|
}), describeState);
|
|
191
350
|
});
|
|
192
351
|
}
|
package/dist/commands/board.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ensureBoard } from '../github/board.js';
|
|
2
|
+
import { ensureLabels } from '../install/provision.js';
|
|
2
3
|
const list = (names) => names.join(', ');
|
|
4
|
+
/** The labels line of `board ensure`. */
|
|
5
|
+
export function formatLabels(created, dryRun) {
|
|
6
|
+
if (created.length === 0)
|
|
7
|
+
return 'Labels are up to date';
|
|
8
|
+
return `${dryRun ? 'Would create labels' : 'Created labels'}: ${list(created)}`;
|
|
9
|
+
}
|
|
3
10
|
/** Human-readable summary of an `ensureBoard` run. */
|
|
4
11
|
export function formatEnsureResult(result, dryRun) {
|
|
5
12
|
const lines = [];
|
|
@@ -43,7 +50,7 @@ export function registerBoardCommand(program, makeContext) {
|
|
|
43
50
|
const board = program.command('board').description('Manage the Projects v2 board');
|
|
44
51
|
board
|
|
45
52
|
.command('ensure')
|
|
46
|
-
.description('Create the board or add its missing fields, options and views (add-only)')
|
|
53
|
+
.description('Create the board or add its missing fields, options and views, and the missing labels (add-only)')
|
|
47
54
|
.option('--dry-run', 'only query GitHub and print what would change')
|
|
48
55
|
.option('--json', 'print machine-readable JSON')
|
|
49
56
|
.action(async (options) => {
|
|
@@ -55,7 +62,11 @@ export function registerBoardCommand(program, makeContext) {
|
|
|
55
62
|
onProjectCreated: project => err(`Created project #${project.number}${project.url ? ` (${project.url})` : ''}; ` +
|
|
56
63
|
`set github.project.number: ${project.number} in sdlc.config.yaml before running this again`),
|
|
57
64
|
});
|
|
58
|
-
|
|
65
|
+
// A task type enabled after the install needs its `type:<id>` label too.
|
|
66
|
+
const labels = await ensureLabels(run, config, { dryRun });
|
|
67
|
+
out(options.json
|
|
68
|
+
? JSON.stringify({ dryRun, ...result, labelsCreated: labels.created }, null, 2)
|
|
69
|
+
: `${formatEnsureResult(result, dryRun)}\n${formatLabels(labels.created, dryRun)}`);
|
|
59
70
|
// A view that failed to create is a failed GitHub write.
|
|
60
71
|
if (result.viewsFailed.length > 0)
|
|
61
72
|
process.exitCode = 1;
|
package/dist/commands/githook.js
CHANGED
|
@@ -182,13 +182,17 @@ export class DeadlineError extends Error {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
export function deadlineOf(totalMs) {
|
|
185
|
+
return boundedDeadline(totalMs, work => work(), () => undefined);
|
|
186
|
+
}
|
|
187
|
+
/** A deadline of `totalMs` whose calls go through `outer` (an enclosing deadline), telling it with `onAbandon` when one is abandoned. */
|
|
188
|
+
function boundedDeadline(totalMs, outer, onAbandon) {
|
|
185
189
|
let timer;
|
|
186
190
|
let expiry;
|
|
187
191
|
let passed = false;
|
|
188
192
|
let abandoned = false;
|
|
189
193
|
let pending = 0;
|
|
190
194
|
const timedOut = () => new DeadlineError(`timed out after ${totalMs / 1000}s`);
|
|
191
|
-
|
|
195
|
+
const deadline = {
|
|
192
196
|
get abandoned() {
|
|
193
197
|
return abandoned;
|
|
194
198
|
},
|
|
@@ -199,11 +203,13 @@ export function deadlineOf(totalMs) {
|
|
|
199
203
|
timer = setTimeout(() => {
|
|
200
204
|
passed = true;
|
|
201
205
|
abandoned = pending > 0;
|
|
206
|
+
if (abandoned)
|
|
207
|
+
onAbandon();
|
|
202
208
|
reject(timedOut());
|
|
203
209
|
}, totalMs);
|
|
204
210
|
});
|
|
205
211
|
// Started from a promise, so work that throws at once is a rejected call like any other.
|
|
206
|
-
const call = Promise.resolve().then(work);
|
|
212
|
+
const call = Promise.resolve().then(() => outer(work));
|
|
207
213
|
pending += 1;
|
|
208
214
|
const settled = () => {
|
|
209
215
|
pending -= 1;
|
|
@@ -212,7 +218,11 @@ export function deadlineOf(totalMs) {
|
|
|
212
218
|
return Promise.race([call, expiry]);
|
|
213
219
|
},
|
|
214
220
|
stop: () => clearTimeout(timer),
|
|
221
|
+
within: ms => boundedDeadline(ms, work => deadline.run(work), () => {
|
|
222
|
+
abandoned = true;
|
|
223
|
+
}),
|
|
215
224
|
};
|
|
225
|
+
return deadline;
|
|
216
226
|
}
|
|
217
227
|
/**
|
|
218
228
|
* The config, loaded on first use. A config that cannot be loaded gives `undefined` (after one
|