@metasession.co/devaudit-cli 0.1.58 → 0.1.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metasession.co/devaudit-cli",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "description": "DevAudit CLI — installs, syncs, and operates the Metasession SDLC across consumer projects.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@clack/prompts": "^0.8.2",
36
- "@metasession.co/devaudit-plugin-sdk": "^0.1.58",
36
+ "@metasession.co/devaudit-plugin-sdk": "^0.1.59",
37
37
  "ajv": "^8.20.0",
38
38
  "commander": "^12.1.0",
39
39
  "consola": "^3.2.3",
@@ -231,6 +231,8 @@ TOTAL_SIZE=0
231
231
  UPLOAD_URL="${DEVAUDIT_BASE_URL}/api/evidence/upload"
232
232
  MAX_ATTEMPTS=${UPLOAD_MAX_ATTEMPTS:-5}
233
233
  INITIAL_BACKOFF_SECONDS=${UPLOAD_INITIAL_BACKOFF_SECONDS:-1}
234
+ UPLOAD_CONNECT_TIMEOUT_SECONDS=${UPLOAD_CONNECT_TIMEOUT_SECONDS:-10}
235
+ UPLOAD_MAX_TIME_SECONDS=${UPLOAD_MAX_TIME_SECONDS:-120}
234
236
 
235
237
  is_unedited_starter_stub() {
236
238
  # Match BOTH banner phrasings the SDLC has shipped (v0.1.36 changed
@@ -254,7 +256,10 @@ for FILE in "${FILES[@]}"; do
254
256
  # every consumer's CI silently fails on a stale base URL. `--max-redirs 3`
255
257
  # bounds the follow so a misconfigured redirect loop can't hang CI.
256
258
  CURL_ARGS=(
257
- -X POST -L --max-redirs 3 "$UPLOAD_URL"
259
+ -X POST -L --max-redirs 3
260
+ --connect-timeout "$UPLOAD_CONNECT_TIMEOUT_SECONDS"
261
+ --max-time "$UPLOAD_MAX_TIME_SECONDS"
262
+ "$UPLOAD_URL"
258
263
  -H "Authorization: Bearer ${DEVAUDIT_API_KEY}"
259
264
  -F "file=@${FILE}"
260
265
  -F "projectSlug=${PROJECT_SLUG}"
@@ -277,11 +282,31 @@ for FILE in "${FILES[@]}"; do
277
282
  BACKOFF=$INITIAL_BACKOFF_SECONDS
278
283
  HTTP_CODE=0
279
284
  RESP_BODY_FILE=""
285
+ RESP_HEADERS_FILE=""
286
+ LAST_CURL_ERROR=""
280
287
  while [ "$ATTEMPT" -le "$MAX_ATTEMPTS" ]; do
281
288
  [ -n "$RESP_BODY_FILE" ] && rm -f "$RESP_BODY_FILE"
282
289
  RESP_BODY_FILE=$(mktemp)
283
290
  RESP_HEADERS_FILE=$(mktemp)
284
- HTTP_CODE=$(curl -s -o "$RESP_BODY_FILE" -D "$RESP_HEADERS_FILE" -w "%{http_code}" "${CURL_ARGS[@]}")
291
+ CURL_EXIT=0
292
+ HTTP_CODE=$(curl -s -o "$RESP_BODY_FILE" -D "$RESP_HEADERS_FILE" -w "%{http_code}" "${CURL_ARGS[@]}") || CURL_EXIT=$?
293
+ if [ "$CURL_EXIT" -ne 0 ]; then
294
+ LAST_CURL_ERROR="curl exit ${CURL_EXIT}"
295
+ if [ "$CURL_EXIT" -eq 28 ]; then
296
+ LAST_CURL_ERROR="${LAST_CURL_ERROR} (timed out after ${UPLOAD_MAX_TIME_SECONDS}s)"
297
+ fi
298
+ if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
299
+ WAIT_SECONDS=$BACKOFF
300
+ echo -n "(${LAST_CURL_ERROR}, retry in ${WAIT_SECONDS}s) "
301
+ rm -f "$RESP_HEADERS_FILE"
302
+ sleep "$WAIT_SECONDS"
303
+ ATTEMPT=$((ATTEMPT + 1))
304
+ BACKOFF=$((BACKOFF * 2))
305
+ continue
306
+ fi
307
+ rm -f "$RESP_HEADERS_FILE"
308
+ break
309
+ fi
285
310
  if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
286
311
  rm -f "$RESP_HEADERS_FILE"
287
312
  break
@@ -317,8 +342,14 @@ for FILE in "${FILES[@]}"; do
317
342
  SUCCEEDED=$((SUCCEEDED + 1))
318
343
  TOTAL_SIZE=$((TOTAL_SIZE + FILE_SIZE))
319
344
  else
320
- echo "FAILED (HTTP ${HTTP_CODE} after ${ATTEMPT} attempt(s))"
321
- echo " Response: $(head -c 500 "$RESP_BODY_FILE")"
345
+ if [ -n "$LAST_CURL_ERROR" ]; then
346
+ echo "FAILED (${LAST_CURL_ERROR} after ${ATTEMPT} attempt(s))"
347
+ else
348
+ echo "FAILED (HTTP ${HTTP_CODE} after ${ATTEMPT} attempt(s))"
349
+ fi
350
+ if [ -s "$RESP_BODY_FILE" ]; then
351
+ echo " Response: $(head -c 500 "$RESP_BODY_FILE")"
352
+ fi
322
353
  rm -f "$RESP_BODY_FILE"
323
354
  FAILED=$((FAILED + 1))
324
355
  fi
@@ -34,7 +34,7 @@ The default way to implement a tracked change is the **`sdlc-implementer`** skil
34
34
  Even if a change doesn't need a REQ entry:
35
35
  1. Review existing tests that cover the changed code
36
36
  2. Update or add tests BEFORE committing
37
- 3. Run all gates locally — do not push without verifying no regressions
37
+ 3. Run the applicable local checks from the approved scope/test plan — do not push without verifying the change-relevant commands pass
38
38
  4. If the change affects financial calculations, user-facing data, or access control — it needs a REQ entry regardless of size
39
39
 
40
40
  What needs a REQ entry: New features → always. Bug fixes affecting financial data, user-facing behaviour, access control → always. Internal logic → only if MEDIUM/HIGH risk. Typos, formatting, dependency bumps → never.
@@ -47,7 +47,7 @@ When creating an issue via `gh issue create`, ALWAYS append this to the body:
47
47
  - [ ] Requirement: RTM entry created (or confirmed trivial)
48
48
  - [ ] Planning: test-scope.md and test-plan.md created (or confirmed trivial)
49
49
  - [ ] Tests: existing tests reviewed, tests updated/added
50
- - [ ] Gates: all pass locally (tsc, semgrep, audit, playwright)
50
+ - [ ] Gates: applicable local checks pass; CI/UAT full gates pass where required
51
51
  - [ ] Evidence: compiled and uploaded (if tracked requirement)
52
52
 
53
53
  ### Requirement Planning (do this BEFORE coding)
@@ -73,22 +73,24 @@ Read `SDLC/2-implement-and-test.md` for full details. Summary:
73
73
  - **Before coding:** Verify ALL exist: `ls compliance/evidence/REQ-XXX/test-scope.md` AND `ls compliance/evidence/REQ-XXX/test-plan.md`. If either is missing, STOP and run planning workflow first. For MEDIUM/HIGH also verify `implementation-plan.md` exists.
74
74
  - **Phase 1 — Unit tests (TDD):** Write unit tests before implementation. Tests should initially fail. **CHECKPOINT:** Unit test coverage matches test plan.
75
75
  - **Phase 2 — Implementation:** Write the code. Unit tests should now pass. **CHECKPOINT:** All unit tests green.
76
- - **Phase 3 — E2E tests:** Write E2E tests against the working implementation. **CHECKPOINT:** All E2E tests green.
77
- - **Phase 4 — All gates:** Run full gate suite (TypeScript, SAST, dep audit, all tests, build). **CHECKPOINT:** All gates green, push to develop.
76
+ - **Phase 3 — E2E tests:** Write E2E tests against the working implementation when the test plan calls for E2E coverage. Before starting a full local E2E suite, confirm local prerequisites (services, database, secrets, seeded auth/test data, browsers). If prerequisites are missing, run the targeted local checks from the test plan and let CI/UAT provide the authoritative full E2E gate.
77
+ - **Phase 4 — All gates:** Run the applicable local gate suite for the change (TypeScript/SAST/dep audit/unit or targeted tests/build as specified). **CHECKPOINT:** Local scoped checks are green, then push to develop for authoritative CI gates.
78
78
  - Every commit: conventional format with `Ref: REQ-XXX` and `Co-Authored-By` for AI.
79
79
  - Add `@requirement REQ-XXX` JSDoc headers to modified files.
80
80
  - Log AI prompts in `compliance/evidence/REQ-XXX/ai-prompts.md` for MEDIUM/HIGH risk.
81
81
 
82
82
  ### Before Pushing
83
83
 
84
- Run ALL gates every one must pass:
84
+ Run the local checks required by the approved test plan/scope. For a typical code change this includes:
85
85
  ```
86
86
  npx tsc --noEmit # 0 errors
87
87
  semgrep scan --config auto src/ # 0 high/critical
88
88
  npm audit --audit-level=high # 0 vulnerabilities
89
- npx playwright test # all pass
89
+ npm test # unit/integration tests pass
90
90
  ```
91
91
 
92
+ **Full local E2E boundary:** Do NOT start `npx playwright test` locally unless you have confirmed the local environment has every required service, database, secret, seeded fixture, authenticated test setup, and browser dependency. For LOW-risk docs/tooling/script-only changes, run the targeted commands in the approved test plan and rely on CI/UAT for the full E2E gate unless the operator explicitly requests a local full-suite run.
93
+
92
94
  **Verify test plan tests are written:** For tracked requirements, check that every test file referenced in `compliance/evidence/REQ-XXX/test-plan.md` exists and passes. If `test-plan.md` lists tests that haven't been written yet, STOP — write and run the tests before pushing.
93
95
 
94
96
  ### After Pushing: WAIT — Confirm CI Green
@@ -97,7 +99,7 @@ npx playwright test # all pass
97
99
  gh run list --branch develop --limit 1
98
100
  ```
99
101
 
100
- Do NOT proceed to evidence compilation or PR creation until CI is green. If CI fails, fix locally and re-push.
102
+ Do NOT proceed to evidence compilation or PR creation until CI is green. If CI fails, fix locally and re-push. CI/UAT is the authoritative full E2E verification environment when local prerequisites are unavailable.
101
103
 
102
104
  ### Evidence Storage Rule
103
105
 
@@ -22,6 +22,7 @@ devaudit update v1.5.0 ../your-project
22
22
  ```
23
23
 
24
24
  This generates:
25
+ - `AGENTS.md` → pointer to `INSTRUCTIONS.md` and relevant `SDLC/` workflows
25
26
  - `.cursorrules` → pointer to `INSTRUCTIONS.md`
26
27
  - `.windsurfrules` → pointer to `INSTRUCTIONS.md`
27
28
  - `CLAUDE.md` → preserves project header, adds pointer to `INSTRUCTIONS.md`
@@ -95,7 +96,7 @@ Only `wawagardenbar-app` is an active consumer as of 2026-05-19; META-AGENT / ME
95
96
  This:
96
97
  1. Tags DevAudit as `sdlc-v1.1.0` and pushes the tag
97
98
  2. Copies SDLC files, hooks, scripts, and CI templates to each project
98
- 3. Generates AI agent pointer files (.cursorrules, .windsurfrules, CLAUDE.md, GEMINI.md) referencing `INSTRUCTIONS.md`
99
+ 3. Generates AI agent pointer files (AGENTS.md, .cursorrules, .windsurfrules, CLAUDE.md, GEMINI.md) referencing `INSTRUCTIONS.md`
99
100
  4. Appends/replaces the SDLC section in `INSTRUCTIONS.md` from `INSTRUCTIONS-SDLC.md`
100
101
  5. Updates tag references in consuming project CI workflows
101
102
  6. Reports what was synced — review the diff before committing
@@ -390,7 +390,7 @@ If any step fails, fix the configuration before starting real work.
390
390
  | Local tooling installed (Semgrep, Playwright) | [ ] |
391
391
  | Git hooks configured (Husky, Commitlint, lint-staged) | [ ] |
392
392
  | Hook verification passed (commitlint, pre-push tsc) | [ ] |
393
- | AI assistant SDLC rules configured (CLAUDE.md / .windsurfrules / .cursorrules) | [ ] |
393
+ | AI assistant SDLC rules configured (AGENTS.md / CLAUDE.md / GEMINI.md / .windsurfrules / .cursorrules) | [ ] |
394
394
  | DevAudit evidence upload configured in CI | [ ] |
395
395
  | Project Test Plan created | [ ] |
396
396
  | End-to-end pipeline verified with test change | [ ] |
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Implement changes on develop, run all local gates (tests + security scans), commit with compliance-aware conventions
2
+ description: Implement changes on develop, run scoped local gates, and let CI/UAT provide authoritative full E2E verification when local prerequisites are unavailable
3
3
  ---
4
4
 
5
5
  # Implement & Test
@@ -14,11 +14,9 @@ description: Implement changes on develop, run all local gates (tests + security
14
14
  ## Prerequisites
15
15
 
16
16
  - On the `develop` branch
17
- - Dev server starts
18
- - Database running locally
19
- - Playwright browsers installed
20
- - Test data seeded
17
+ - Dev server starts when the local test scope requires it
21
18
  - Semgrep installed
19
+ - For a full local E2E suite only: database/services running locally, required secrets available, Playwright browsers installed, test data seeded, and auth/session setup configured
22
20
 
23
21
  ## Steps
24
22
 
@@ -124,7 +122,7 @@ npm test
124
122
 
125
123
  Write or update E2E tests **after** implementation. E2E tests need working UI/API to test against — writing Playwright tests against routes and selectors that don't exist is impractical.
126
124
 
127
- > **Skill available:** invoke the **`e2e-test-engineer`** skill for this step (at `.claude/skills/e2e-test-engineer/SKILL.md`). It derives scenarios from the requirement's acceptance criteria, reconciles with the existing test pack (flags obsoletes — but never deletes without confirmation), runs the suite, and files defects for failures or missed ACs. Framework-agnostic (Playwright, Cypress, pytest-playwright, etc.) and tracker-agnostic (GitHub, Linear, Jira, etc.). For projects with no e2e suite yet, the skill also covers bootstrapping one. See [`sdlc/SKILLS.md`](../sdlc/SKILLS.md) for the full list of available skills.
125
+ > **Skill available:** invoke the **`e2e-test-engineer`** skill for this step (at `.claude/skills/e2e-test-engineer/SKILL.md`). It derives scenarios from the requirement's acceptance criteria, reconciles with the existing test pack (flags obsoletes — but never deletes without confirmation), checks local full-suite prerequisites before running broad E2E locally, and files defects for failures or missed ACs. Framework-agnostic (Playwright, Cypress, pytest-playwright, etc.) and tracker-agnostic (GitHub, Linear, Jira, etc.). For projects with no e2e suite yet, the skill also covers bootstrapping one. See [`sdlc/SKILLS.md`](../sdlc/SKILLS.md) for the full list of available skills.
128
126
 
129
127
  > **Run authenticated flows in CI.** Tests that need a logged-in session (admin forms, role-gated flows) belong in their own Playwright project that depends on `auth-setup`. Register that project name in `sdlc-config.json` `e2e_projects` and set `e2e_seed_command` / `e2e_env` so CI seeds fixtures and runs it as a **report-only** gate (continue-on-error — it surfaces failures as evidence without blocking the merge until proven stable). Prove each UI-driven AC with an `evidenceShot(page, 'REQ-XXX', acN, 'slug')` so the PNG lands in `compliance/evidence/REQ-XXX/screenshots/`. This is what lets Stage 3 Step 10 reduce manual UAT to a light smoke instead of a full re-click.
130
128
 
@@ -146,14 +144,23 @@ cat compliance/evidence/REQ-XXX/test-plan.md
146
144
 
147
145
  **4d. Remove obsolete E2E tests** listed in the "Tests to Remove" section (if any).
148
146
 
149
- ### WAIT CHECKPOINT: E2E Tests Green
147
+ ### WAIT CHECKPOINT: E2E Scope Complete
150
148
 
151
- All E2E tests must pass:
149
+ Run the E2E checks required by the approved test plan. Before running the full local suite, confirm the local prerequisites are present:
150
+
151
+ - Required services/databases are running locally
152
+ - Required secrets/env vars point to disposable local or test resources
153
+ - Test data and authenticated fixtures are seeded
154
+ - Playwright browsers and project dependencies are installed
155
+
156
+ If those prerequisites are confirmed, run:
152
157
  ```bash
153
158
  npx playwright test
154
159
  ```
155
160
 
156
- **Do NOT proceed** until all E2E tests are green.
161
+ If prerequisites are missing, do **not** start the full local suite. Run the targeted local checks listed in the test plan and record that full E2E verification is delegated to CI/UAT. For LOW-risk docs/tooling/script-only changes, targeted local verification is expected unless the operator explicitly requests a full local E2E run.
162
+
163
+ **Do NOT proceed** until the scoped E2E/test-plan checks are complete and any local limitations are called out.
157
164
 
158
165
  ### Step 5: Stage Selectively
159
166
 
@@ -184,7 +191,7 @@ EOF
184
191
 
185
192
  Types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`, `compliance`, `security`
186
193
 
187
- ### Step 7: Run All Local Gates (Mandatory)
194
+ ### Step 7: Run Applicable Local Gates (Mandatory)
188
195
 
189
196
  #### Gate 1: TypeScript
190
197
  ```bash
@@ -205,10 +212,13 @@ npm audit
205
212
  ```
206
213
 
207
214
  #### Gate 3: E2E Tests
215
+ Run the E2E scope from the approved test plan. Use full local Playwright only after confirming local services, secrets, seeded data, auth fixtures, and browser dependencies are ready:
208
216
  ```bash
209
217
  npx playwright test
210
218
  ```
211
219
 
220
+ For LOW-risk docs/tooling/script-only changes or environments without the required local prerequisites, do not run the full local suite by default. Run the targeted commands in the test plan and rely on CI/UAT for the authoritative full E2E gate.
221
+
212
222
  #### Exit Criteria
213
223
 
214
224
  | Gate | Threshold |
@@ -216,7 +226,7 @@ npx playwright test
216
226
  | TypeScript | 0 errors |
217
227
  | SAST (high/critical) | 0 findings |
218
228
  | Dependencies (high/critical) | 0 vulnerabilities |
219
- | E2E tests | All pass |
229
+ | E2E tests | Scoped local E2E checks pass; full CI/UAT E2E passes before PR/release |
220
230
  | Severity-1 defects | 0 open |
221
231
 
222
232
  For Medium/High risk, also verify access control and audit log tests pass (see Test Plan and test-scope.md).
@@ -235,7 +245,7 @@ git push origin develop
235
245
  If rejected:
236
246
  ```bash
237
247
  git pull --rebase origin develop
238
- # Re-run ALL local gates after rebase
248
+ # Re-run applicable local gates after rebase
239
249
  git push origin develop
240
250
  ```
241
251
 
@@ -251,7 +261,7 @@ gh run list --branch develop --limit 1
251
261
  gh run watch
252
262
  ```
253
263
 
254
- **Do NOT proceed** until CI is green. If CI fails, diagnose the failure, fix locally, re-run all local gates, and push again. Do not push repeatedly hoping CI will pass — fix the root cause.
264
+ **Do NOT proceed** until CI is green. If CI fails, diagnose the failure, fix locally, re-run the applicable local gates, and push again. Do not push repeatedly hoping CI will pass — fix the root cause. CI/UAT is the authoritative full E2E environment when local services/secrets/seeded auth state are not available.
255
265
 
256
266
  ### Step 9: Update Evidence
257
267
 
@@ -264,7 +274,7 @@ git push origin develop
264
274
 
265
275
  ## Iteration
266
276
 
267
- Repeat Steps 3-9. Every commit must leave all local gates green. Step 2 (implementation plan) is done once per requirement. Each push triggers full CI and auto-deploys to UAT.
277
+ Repeat Steps 3-9. Every commit must leave the applicable local gates green. Step 2 (implementation plan) is done once per requirement. Each push triggers full CI and auto-deploys to UAT.
268
278
 
269
279
  ## Output
270
280
 
@@ -209,7 +209,7 @@ If production smoke fails:
209
209
 
210
210
  ## Sample prompts
211
211
 
212
- Copy-paste these into Claude Code, Cursor, or any agent with shell access to kick off each stage. The agent should already have `AGENT.md` (portal) or the consumer's `INSTRUCTIONS.md` loaded as the canonical rules file.
212
+ Copy-paste these into Claude Code, Cursor, or any agent with shell access to kick off each stage. The agent should already have `AGENTS.md` (consumer), `AGENT.md` (portal), or the consumer's `INSTRUCTIONS.md` loaded as the canonical rules file.
213
213
 
214
214
  > **Replace placeholders.** `{ISSUE_NUMBER}`, `{REQ_ID}`, `{PROJECT_SLUG}`, `{VERSION}` etc. are placeholders — substitute the real values before invoking.
215
215
 
@@ -231,7 +231,7 @@ stage 1 (plan-requirement) for it:
231
231
 
232
232
  STOP after the plan is posted. Do NOT begin implementation.
233
233
 
234
- Reference: AGENT.md (or INSTRUCTIONS.md for consumer repos), and the canonical
234
+ Reference: AGENTS.md / INSTRUCTIONS.md for consumer repos (or AGENT.md for the portal), and the canonical
235
235
  sdlc/_common/1-plan-requirement.md from DevAudit-Installer.
236
236
  ```
237
237
 
@@ -33,7 +33,7 @@ When you `git clone`, you've already got everything the framework synced into th
33
33
  | `compliance/RTM.md`, `compliance/risk-register.md`, … | Compliance artefacts | Team — appended by tracked work |
34
34
  | `scripts/*.sh` | Helpers (`upload-evidence.sh`, `close-out-release.sh`, `validate-commits.sh`, …) | Team — synced from DevAudit-Installer |
35
35
  | `.husky/`, `.github/workflows/*.yml` | Git hooks + CI gates | Team — generated by the operator's onboarding install |
36
- | `.cursorrules`, `.windsurfrules`, `GEMINI.md`, `INSTRUCTIONS.md`, `CLAUDE.md` | AI rule files | Team — synced |
36
+ | `AGENTS.md`, `.cursorrules`, `.windsurfrules`, `GEMINI.md`, `INSTRUCTIONS.md`, `CLAUDE.md` | AI rule files | Team — synced |
37
37
  | `.claude/skills/` | The `sdlc-implementer` + `e2e-test-engineer` Claude Code skills | Team — synced |
38
38
 
39
39
  Your job is to wire up the **local** half (the bits per-developer):
@@ -101,7 +101,7 @@ devaudit status .
101
101
  # Stack: node / python
102
102
  # Host: railway
103
103
  # …
104
- # ✓ INSTRUCTIONS.md, CLAUDE.md, .cursorrules, …
104
+ # ✓ INSTRUCTIONS.md, AGENTS.md, CLAUDE.md, .cursorrules, …
105
105
  ```
106
106
 
107
107
  If any of the framework files are missing, the operator hasn't completed onboarding yet (or your clone is behind `main` — `git pull`). Ask them to run `devaudit update`.