@akjamie/agentic-sdlc 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # agentic-sdlc
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@akjamie/agentic-sdlc?color=6366f1&label=npm)](https://www.npmjs.com/package/@akjamie/agentic-sdlc)
4
- [![version: v1.9.1](https://img.shields.io/badge/version-v1.9.1-6366f1.svg)](package.json)
4
+ [![version: v1.9.2](https://img.shields.io/badge/version-v1.9.2-6366f1.svg)](package.json)
5
5
  [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-10b981.svg)](LICENSE)
6
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D20.19.0-38bdf8.svg)](https://nodejs.org/)
7
- [![tests](https://img.shields.io/badge/tests-212%20passing-10b981.svg)](#development--verification)
7
+ [![tests](https://img.shields.io/badge/tests-213%20passing-10b981.svg)](#development--verification)
8
8
  [![architecture](https://img.shields.io/badge/governance-L0--L3%20Adaptive%20Dual--Track-f59e0b.svg)](#adaptive-risk-tiered-governance-l0l3)
9
9
 
10
10
  > **The Intelligent Governance Engine for Autonomous AI Coding.**
@@ -371,7 +371,7 @@ git clone https://github.com/akjamie/agentic-sdlc.git
371
371
  cd agentic-sdlc
372
372
  npm install
373
373
 
374
- # Run complete test suite (212 tests passing, 100% pass rate)
374
+ # Run complete test suite (213 tests passing, 100% pass rate)
375
375
  npm test
376
376
 
377
377
  # Run end-to-end multi-language simulation tests
@@ -28,6 +28,10 @@ Drawing from Anthropic's engineering practices for scaling AI code reviews, this
28
28
  > **Scope**: Reviews *implementation conformance and code quality* — spec adherence, test rigor, architecture, and production safety.
29
29
  > Requires `asdlc test <CHANGE_ID>` and `asdlc verify <CHANGE_ID>` to have passed before this review can issue an APPROVE verdict.
30
30
  > Does NOT review spec intent — that is `asdlc-spec-review`.
31
+ >
32
+ > **Output Routing Contract (PR vs. Local)**:
33
+ > - **PR Mode** (invoked with a PR URL, PR number, or via CI PR trigger): **Post the review comment directly to the PR** via `gh pr comment` — **NEVER pause to ask the user whether to post comments**.
34
+ > - **Local Mode** (invoked with `<CHANGE_ID>` only, no PR context): **Print the formatted review report directly** in your response; do NOT run `gh pr comment`.
31
35
 
32
36
  ---
33
37
 
@@ -214,9 +218,11 @@ Every finding must follow a structured schema with explicit defect attribution s
214
218
 
215
219
  ---
216
220
 
217
- ### Step 5: Post PR Comment
221
+ ### Step 5: Deliver Review (Post PR Comment or Print Locally)
218
222
 
219
- Compose the review markdown and post it as a PR comment using the GitHub API:
223
+ Compose the review using the markdown format below, then deliver it according to the invocation mode:
224
+
225
+ - **If reviewing a PR** (PR URL, PR number, or CI PR trigger): **Post the comment directly** without asking the user for confirmation:
220
226
 
221
227
  ```bash
222
228
  gh pr comment $PR_NUMBER --repo $REPO --body "$(cat <<'EOF'
@@ -225,6 +231,8 @@ EOF
225
231
  )"
226
232
  ```
227
233
 
234
+ - **If reviewing locally** (`<CHANGE_ID>` only, no PR): **Print the formatted review markdown directly** in your response and skip `gh pr comment` and Step 6.
235
+
228
236
  Format the comment body strictly as:
229
237
 
230
238
  ~~~markdown
@@ -53,7 +53,10 @@ If `pass` is false:
53
53
 
54
54
  ### Step 3: Lint Complete (Self-Review Passed)
55
55
  When `pass` is true (`0 blockers`):
56
- Report to the author that the spec is structurally valid, fully traceable, and passes all BDD/acceptance criteria checks:
56
+ Report to the author that the spec is structurally valid, fully traceable, and passes all BDD/acceptance criteria checks, then guide them based on the change's governance track (`asdlc status <CHANGE_ID>`):
57
57
 
58
- > "Spec lint passed with 0 blocking issues. The spec is ready for PR. When you are ready to submit it for review, use `asdlc pr <CHANGE_ID> <targetBranch>`."
58
+ - **Track A (Dual-PR — L2 / L3 or `spec-first`)**:
59
+ > "Spec lint passed with 0 blocking issues. Open the Spec PR with `asdlc pr <CHANGE_ID> [targetBranch]`."
60
+ - **Track B (Single-PR — L0 / L1 under `supervised` or `auto`)**:
61
+ > "Spec lint passed with 0 blocking issues. In Single-PR mode, no separate Spec PR or `asdlc approve` is needed — draft `tasks.md` and run `asdlc apply <CHANGE_ID>` to start TDD."
59
62
 
@@ -12,20 +12,20 @@ This skill opens a **Spec PR** (Stage 3) or an **Implementation PR** (Stage 6.5)
12
12
  ## Command
13
13
 
14
14
  ```powershell
15
- asdlc pr <CHANGE_ID> <targetBranch>
15
+ asdlc pr <CHANGE_ID> [targetBranch]
16
16
  ```
17
17
 
18
- - `<targetBranch>`: Target branch to merge into (e.g. `main`, `develop`, `release/*`). Required.
19
- - Zero manual flags: `asdlc pr` automatically detects whether to open a Spec PR or an Implementation PR.
18
+ - `[targetBranch]`: Target branch to merge into (e.g. `main`, `master`, `develop`). Optional — defaults to `.openspec.yaml`'s `targetBranch` or the repository's default branch (`resolveDefaultBranch`).
19
+ - Zero manual flags: `asdlc pr` automatically detects whether to open a Spec PR (Track A) or an Implementation / Single PR (Track A/B).
20
20
 
21
21
  ---
22
22
 
23
- ## Dual-PR Lifecycle & Pre-flight Gates
23
+ ## Two-Track Lifecycle & Pre-flight Gates
24
24
 
25
- | PR Type | Phase & Moment | Pre-Flight Guard | Auto Labels | Review Automation Trigger |
25
+ | PR Type | Track & Moment | Pre-Flight Guard | Auto Labels | Review Automation Trigger |
26
26
  | :--- | :--- | :--- | :--- | :--- |
27
- | **Spec PR** | Stage 3 (After drafting proposal & specs) | **`asdlc lint <ID>`**<br>(0 blocking BDD/AC issues) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` + routes to **Independent Spec AI Review** (`asdlc-spec-review`) |
28
- | **Impl PR** | Stage 6.5 (After TDD apply & tasks complete) | **`asdlc verify <ID>`**<br>(12 deterministic gates pass) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` + routes to **Independent Impl AI Review** (`asdlc-impl-review`) |
27
+ | **Spec PR** | **Track A** Stage 3 (L2/L3/`spec-first` after drafting proposal & specs) | **`asdlc lint <ID>`**<br>(0 blocking BDD/AC issues) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` + routes to **Independent Spec AI Review** (`asdlc-spec-review`) |
28
+ | **Impl / Single PR** | **Track A** Stage 6.5 or **Track B** (L0/L1 Single-PR after TDD & tasks complete) | **`asdlc verify <ID>`**<br>(12 deterministic gates pass) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` + routes to **Independent Impl AI Review** (`asdlc-impl-review`) |
29
29
 
30
30
  ---
31
31
 
@@ -37,6 +37,7 @@ asdlc pr <CHANGE_ID> <targetBranch>
37
37
  - `.openspec.yaml` has `status: ready_for_impl` or a locked `specSha`.
38
38
  - Spec intent commit is already merged on `<targetBranch>`.
39
39
  - Branch name starts with `impl/`.
40
+ - Single-PR change (`L0`/`L1` under `supervised`/`auto`) with source code changes outside `openspec/changes/<slug>/`.
40
41
  - Source code changes exist outside `openspec/changes/<slug>/` and tasks in `tasks.md` are marked complete.
41
42
  - **Detected as Spec PR (`spec`) otherwise**:
42
43
  - Spec artifacts (`proposal.md`, `specs/**`) are in drafting/review stage before approval.
@@ -16,7 +16,10 @@ It applies the **Player ≠ Referee** principle: the reviewing agent MUST NOT be
16
16
  > **Scope**: Reviews *intent* — BDD quality, logical consistency, architectural soundness, AC testability.
17
17
  > Does NOT re-run `asdlc lint` (deterministic structural checks are already gated by `asdlc pr`).
18
18
  > Does NOT review implementation code — that is `asdlc-impl-review`.
19
- > Output can be posted as a PR comment or reported locally.
19
+ >
20
+ > **Output Routing Contract (PR vs. Local)**:
21
+ > - **PR Mode** (invoked with a PR URL, PR number, or via CI PR trigger): **Post the review comment directly to the PR** via `gh pr comment` — **NEVER pause to ask the user whether to post comments**.
22
+ > - **Local Mode** (invoked with `<CHANGE_ID>` only, no PR context): **Print the formatted review report directly** in your response; do NOT run `gh pr comment`.
20
23
 
21
24
  ---
22
25
 
@@ -121,9 +124,11 @@ Classify each finding:
121
124
 
122
125
  ---
123
126
 
124
- ### Step 5: Post PR Comment
127
+ ### Step 5: Deliver Review (Post PR Comment or Print Locally)
125
128
 
126
- Compose the review as markdown and post it as a PR comment using the GitHub API:
129
+ Compose the review using the markdown format below, then deliver it according to the invocation mode:
130
+
131
+ - **If reviewing a PR** (PR URL, PR number, or CI PR trigger): **Post the comment directly** without asking the user for confirmation:
127
132
 
128
133
  ```bash
129
134
  gh pr comment $PR_NUMBER --repo $REPO --body "$(cat <<'EOF'
@@ -132,6 +137,8 @@ EOF
132
137
  )"
133
138
  ```
134
139
 
140
+ - **If reviewing locally** (`<CHANGE_ID>` only, no PR): **Print the formatted review markdown directly** in your response and skip `gh pr comment` and Step 6.
141
+
135
142
  Format the comment body strictly as:
136
143
 
137
144
  ~~~markdown
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akjamie/agentic-sdlc",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Enterprise Agentic SDLC governance CLI: a 7-stage spec-driven flow on top of OpenSpec + Graphify, enforced by CI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,15 +4,14 @@ import { execFileSync } from 'node:child_process';
4
4
  import { exists, readText, writeText } from '../lib/fs.js';
5
5
  import { changeDir } from '../lib/paths.js';
6
6
  import { requireRepo, toChangeSlug } from '../lib/cliutil.js';
7
- import { git, isGitRepo, changeOnRef, lastCommitTouching, safeCommit } from '../lib/git.js';
7
+ import { git, isGitRepo, changeOnRef, lastCommitTouching, safeCommit, resolveDefaultBranch } from '../lib/git.js';
8
8
  import { loadPolicy, matchesAny } from '../lib/policy.js';
9
9
  import { runLint } from './lint.js';
10
10
  import { runVerify } from './verify.js';
11
11
  import { fail } from '../lib/errors.js';
12
12
  import { log } from '../lib/log.js';
13
13
  import { assess, renderLabels, renderPRComment } from '../assess/index.js';
14
- import { readEffectiveLevel } from '../lib/level.js';
15
- import { resolveWorkflowMode } from '../lib/config.js';
14
+ import { readEffectiveLevel, resolveTopology } from '../lib/level.js';
16
15
 
17
16
  const SAFE_ENV_TEMPLATE_RE = /(^|\/)\.env\.(example|sample|template|defaults|schema)$/i;
18
17
  const SENSITIVE_OR_DUMP_PATTERNS = [
@@ -129,13 +128,6 @@ export async function createPR(changeId, targetBranch, opts = {}) {
129
128
  const repoRoot = requireRepo(opts);
130
129
  if (!isGitRepo(repoRoot)) fail('not a git repository');
131
130
 
132
- if (!targetBranch) {
133
- fail('target branch is required (e.g. `asdlc pr <changeId> main` or `asdlc pr <changeId> develop`)', {
134
- code: 'MISSING_TARGET_BRANCH',
135
- hint: 'specify the base branch to merge into: asdlc pr <changeId> <targetBranch>',
136
- });
137
- }
138
-
139
131
  const slug = toChangeSlug(changeId);
140
132
  const cdir = changeDir(repoRoot, slug);
141
133
  if (!exists(cdir)) fail(`change '${slug}' not found`);
@@ -143,6 +135,11 @@ export async function createPR(changeId, targetBranch, opts = {}) {
143
135
  // Detect PR type 100% automatically (Spec PR vs Impl PR)
144
136
  const metaPath = path.join(cdir, '.openspec.yaml');
145
137
  const metaText = exists(metaPath) ? readText(metaPath) : '';
138
+ const tbMatch = metaText.match(/^\s*targetBranch:\s*['"]?([^\s'"]+)['"]?\s*$/m);
139
+ const metaTargetBranch = tbMatch ? tbMatch[1] : null;
140
+ if (!targetBranch) {
141
+ targetBranch = metaTargetBranch || resolveDefaultBranch(repoRoot).replace(/^origin\//, '');
142
+ }
146
143
  const statusMatch = metaText.match(/^\s*status:\s*['"]?([^\s'"]+)['"]?\s*$/m);
147
144
  const changeStatus = statusMatch ? statusMatch[1].toLowerCase() : '';
148
145
  const shaMatch = metaText.match(/^\s*specSha:\s*['"]?([^\s'"]+)['"]?\s*$/m);
@@ -172,10 +169,9 @@ export async function createPR(changeId, targetBranch, opts = {}) {
172
169
  const allPotentialFiles = [...diffFilesPre, ...uncommittedFiles];
173
170
  const hasSourceChanges = allPotentialFiles.some((f) => !f.startsWith(`openspec/changes/${slug}/`));
174
171
 
175
- const lvlMatch = metaText.match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
176
- const changeLevel = lvlMatch ? lvlMatch[1].toUpperCase() : null;
177
- const resolvedMode = resolveWorkflowMode({ cliMode: opts.mode, repoRoot, baseRef: targetBranch });
178
- const isSinglePr = (changeLevel === 'L0' || changeLevel === 'L1') && resolvedMode !== 'spec-first' && !metaText.match(/^\s*workflowMode:\s*['"]?spec-first['"]?/m);
172
+ const topology = resolveTopology({ repoRoot, slug, baseRef: targetBranch, cliMode: opts.mode });
173
+ const resolvedMode = topology.mode;
174
+ const isSinglePr = topology.isSinglePr;
179
175
 
180
176
  let prType;
181
177
  if (opts.type) {
@@ -598,7 +594,7 @@ export function parseRemoteUrl(url, opts = {}) {
598
594
 
599
595
  export function register(program) {
600
596
  program
601
- .command('pr <changeId> <targetBranch>')
597
+ .command('pr <changeId> [targetBranch]')
602
598
  .description('automatically open a Spec or Implementation PR: auto-detects stage, pre-flight checks, pushes branch, and attaches labels for CI AI review')
603
599
  .option('--mode <mode>', 'workflow mode: supervised (default) | spec-first | auto')
604
600
  .option('--repo-root <path>')
@@ -6,7 +6,7 @@ import { openspecDir, changeDir } from '../lib/paths.js';
6
6
  import { requireRepo, toChangeSlug, readLintConfig, jsonOut } from '../lib/cliutil.js';
7
7
  import { validateChange } from '../lib/openspec.js';
8
8
  import { runShell } from '../lib/exec.js';
9
- import { lastCommitTouching, changeOnRef, git } from '../lib/git.js';
9
+ import { lastCommitTouching, changeOnRef, git, resolveDefaultBranch } from '../lib/git.js';
10
10
  import { lintSpecText, countBlockers } from '../lib/speclint.js';
11
11
  import { checkSchema } from '../lib/schema.js';
12
12
  import { loadPolicy, isAdvisory, DEFAULT_POLICY, matchesAny } from '../lib/policy.js';
@@ -195,7 +195,6 @@ export function extractJson(text) {
195
195
  export function runVerify(changeId, opts = {}) {
196
196
  const results = [];
197
197
  const add = (name, status, detail) => results.push({ name, status, detail });
198
- const branch = opts.protectedBranch ?? 'origin/main';
199
198
 
200
199
  let repoRoot;
201
200
  try {
@@ -206,6 +205,8 @@ export function runVerify(changeId, opts = {}) {
206
205
  return finish(results, DEFAULT_POLICY);
207
206
  }
208
207
 
208
+ const branch = opts.protectedBranch ?? resolveDefaultBranch(repoRoot);
209
+
209
210
  const slug = toChangeSlug(changeId);
210
211
  const base = opts.base ?? branch;
211
212
  const head = opts.head ?? 'HEAD';
@@ -266,7 +267,7 @@ export function runVerify(changeId, opts = {}) {
266
267
  } else if (isSinglePr) {
267
268
  add('approved-spec', 'pass', `${changeLevel || 'single-pr'} single-PR mode (spec approval co-located in implementation PR)`);
268
269
  } else if (!approvedSha) {
269
- add('approved-spec', 'fail', `no commit on locked paths is merged into ${branch} (not approved)`);
270
+ add('approved-spec', 'fail', `no commit on locked paths is merged into ${branch} (not approved; ensure target branch is fetched, e.g. git fetch)`);
270
271
  } else if (specSha && specSha !== approvedSha) {
271
272
  add('approved-spec', 'fail', `declared specSha ${specSha.slice(0, 8)} != approved commit ${approvedSha.slice(0, 8)}`);
272
273
  } else {
@@ -285,7 +286,7 @@ export function runVerify(changeId, opts = {}) {
285
286
  add('flow-state', 'pass', `${changeLevel || 'single-pr'} single-PR mode (direct implementation)`);
286
287
  } else {
287
288
  add('flow-state', status === 'ready_for_impl' ? 'pass' : 'fail',
288
- status === 'ready_for_impl' ? 'READY_FOR_IMPL' : `status is ${status ?? 'unset'} (run: asdlc approve ${changeId})`);
289
+ status === 'ready_for_impl' ? 'READY_FOR_IMPL' : `status is ${status ?? 'unset'} (ensure target branch is fetched, then run: asdlc approve ${changeId})`);
289
290
  }
290
291
 
291
292
  const isCI = opts.ci !== undefined