mandrel 2.78.0 → 2.80.0

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.
Files changed (57) hide show
  1. package/.agents/README.md +6 -1
  2. package/.agents/agents/auditor.md +8 -3
  3. package/.agents/audit-checklists/architecture.md +1 -0
  4. package/.agents/audit-checklists/clean-code.md +1 -0
  5. package/.agents/audit-checklists/data-model.md +9 -1
  6. package/.agents/audit-checklists/devops.md +4 -1
  7. package/.agents/audit-checklists/security.md +1 -1
  8. package/.agents/docs/agentrc-reference.json +3 -0
  9. package/.agents/docs/configuration.md +2 -2
  10. package/.agents/docs/workflows.md +1 -1
  11. package/.agents/schemas/agentrc.schema.json +20 -2
  12. package/.agents/schemas/audit-rules.json +5 -1
  13. package/.agents/scripts/bootstrap.js +87 -16
  14. package/.agents/scripts/lib/audit-to-stories/seed-from-findings.js +37 -2
  15. package/.agents/scripts/lib/bootstrap/commit-push.js +3 -2
  16. package/.agents/scripts/lib/bootstrap/manifest.js +2 -2
  17. package/.agents/scripts/lib/bootstrap/project-bootstrap.js +51 -15
  18. package/.agents/scripts/lib/bootstrap/prompt.js +30 -1
  19. package/.agents/scripts/lib/close-validation/commands.js +33 -0
  20. package/.agents/scripts/lib/close-validation/gates.js +11 -4
  21. package/.agents/scripts/lib/config/explain.js +3 -2
  22. package/.agents/scripts/lib/config-settings-schema.js +20 -2
  23. package/.agents/scripts/lib/findings/audit-finding-record.js +95 -0
  24. package/.agents/scripts/lib/findings/route-finding.js +4 -3
  25. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  26. package/.agents/scripts/lib/orchestration/plan-persist/audit-attribution.js +182 -0
  27. package/.agents/scripts/lib/orchestration/plan-persist/audit-provenance.js +11 -10
  28. package/.agents/scripts/lib/orchestration/plan-persist/collision-message.js +52 -0
  29. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +5 -3
  30. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +28 -14
  31. package/.agents/scripts/lib/orchestration/plan-persist/wave-collision-gate.js +8 -4
  32. package/.agents/scripts/lib/orchestration/plan-persist/wave-serialisation.js +3 -2
  33. package/.agents/scripts/lib/orchestration/story-handoff.js +15 -3
  34. package/.agents/scripts/lib/orchestration/verify-credit.js +9 -4
  35. package/.agents/scripts/lib/qa/resolve-qa-contract.js +28 -9
  36. package/.agents/scripts/lib/templates/decomposer-prompts.js +2 -2
  37. package/.agents/scripts/lib/test-run-credit.js +46 -17
  38. package/.agents/scripts/lib/wave-runner/footprint.js +114 -17
  39. package/.agents/scripts/lib/wave-runner/ready-set.js +16 -5
  40. package/.agents/workflows/audit-architecture.md +20 -4
  41. package/.agents/workflows/audit-clean-code.md +17 -1
  42. package/.agents/workflows/audit-data-model.md +94 -10
  43. package/.agents/workflows/audit-devops.md +58 -14
  44. package/.agents/workflows/audit-performance.md +22 -0
  45. package/.agents/workflows/audit-quality.md +30 -0
  46. package/.agents/workflows/audit-security.md +23 -8
  47. package/.agents/workflows/audit-to-stories.md +22 -7
  48. package/.agents/workflows/helpers/audit-lens-core.md +56 -7
  49. package/.agents/workflows/helpers/plan-reference.md +11 -3
  50. package/README.md +13 -1
  51. package/docs/CHANGELOG.md +24 -0
  52. package/lib/cli/registry.js +85 -12
  53. package/lib/cli/uninstall.js +34 -18
  54. package/lib/cli/update.js +37 -6
  55. package/lib/migrations/index.js +2 -0
  56. package/lib/migrations/steps/2.79.0-container-safe-projections.js +91 -0
  57. package/package.json +1 -1
@@ -20,6 +20,8 @@ import {
20
20
  import {
21
21
  BOOTSTRAP_COMMAND,
22
22
  GITIGNORE_BLOCKS,
23
+ LEGACY_PREPARE_COMMAND,
24
+ PREPARE_COMMAND,
23
25
  SYNC_COMMAND,
24
26
  SYSTEM_PROMPT_AGENTS_MD,
25
27
  SYSTEM_PROMPT_BLOCK,
@@ -297,6 +299,33 @@ function revertGitignore(projectRoot, fsImpl) {
297
299
  return { kind: 'reverted', target: rel, detail };
298
300
  }
299
301
 
302
+ /** Every `prepare` value bootstrap writes whole: guarded, legacy pair, bare sync. */
303
+ const BOOTSTRAP_PREPARE_FORMS = new Set([
304
+ PREPARE_COMMAND,
305
+ LEGACY_PREPARE_COMMAND,
306
+ SYNC_COMMAND,
307
+ ]);
308
+
309
+ /**
310
+ * Strip the framework part of a `prepare`: a whole bootstrap-written form
311
+ * goes entirely; an operator command with the sync appended via ` && ` loses
312
+ * just that fragment. `next === ''` means delete the key, never write `""`.
313
+ *
314
+ * @param {unknown} prepare
315
+ * @returns {{ changed: boolean, next: string }}
316
+ */
317
+ function stripPrepare(prepare) {
318
+ if (typeof prepare !== 'string' || !prepare.includes(SYNC_COMMAND)) {
319
+ return { changed: false, next: '' };
320
+ }
321
+ if (BOOTSTRAP_PREPARE_FORMS.has(prepare)) return { changed: true, next: '' };
322
+ const next = prepare
323
+ .replace(` && ${SYNC_COMMAND}`, '')
324
+ .replace(`${SYNC_COMMAND} && `, '')
325
+ .trim();
326
+ return { changed: next !== prepare, next };
327
+ }
328
+
300
329
  /**
301
330
  * @param {string} projectRoot
302
331
  * @param {typeof fs} fsImpl
@@ -319,27 +348,14 @@ function revertPackageJson(projectRoot, fsImpl) {
319
348
  removed.push(name);
320
349
  }
321
350
  }
322
- // `prepare` is either the bare sync command or an operator command with it
323
- // appended via ` && `; strip just the fragment, never write `""`.
324
- const prepare = pkg.scripts.prepare;
325
- if (typeof prepare === 'string' && prepare.includes(SYNC_COMMAND)) {
326
- if (prepare === SYNC_COMMAND) {
351
+ const prepare = stripPrepare(pkg.scripts.prepare);
352
+ if (prepare.changed) {
353
+ if (prepare.next === '') {
327
354
  delete pkg.scripts.prepare;
328
- removed.push('prepare');
329
355
  } else {
330
- const stripped = prepare
331
- .replace(` && ${SYNC_COMMAND}`, '')
332
- .replace(`${SYNC_COMMAND} && `, '')
333
- .trim();
334
- if (stripped !== prepare) {
335
- if (stripped === '') {
336
- delete pkg.scripts.prepare;
337
- } else {
338
- pkg.scripts.prepare = stripped;
339
- }
340
- removed.push('prepare');
341
- }
356
+ pkg.scripts.prepare = prepare.next;
342
357
  }
358
+ removed.push('prepare');
343
359
  }
344
360
  if (removed.length === 0) {
345
361
  return { kind: 'skipped', target: rel, detail: 'no framework scripts' };
package/lib/cli/update.js CHANGED
@@ -22,6 +22,7 @@ import { defaultResolvePackageRoot } from './sync.js';
22
22
  import { isStale } from './version-check.js';
23
23
  import {
24
24
  compareVersions,
25
+ resolveConsumerPinSpec,
25
26
  resolveConsumerPinVersion,
26
27
  } from './version-helpers.js';
27
28
 
@@ -196,22 +197,43 @@ function probePackageManager(cwd, fs = nodeFs) {
196
197
  return detectPackageManagerWithWorkspace(cwd, exists);
197
198
  }
198
199
 
200
+ /**
201
+ * The save flag and spec that keep the consumer's pin style: an exact pin
202
+ * gains the manager's save-exact flag, a tilde rides in the spec (which all
203
+ * three managers record as-is), and caret or unknown keeps the bare spec.
204
+ *
205
+ * @param {string} target
206
+ * @param {'pnpm' | 'yarn' | 'npm'} packageManager
207
+ * @param {'^' | '~' | '' | null} pinOperator
208
+ * @returns {{ exact: string, spec: string }}
209
+ */
210
+ function pinPreservingSpec(target, packageManager, pinOperator) {
211
+ const exactFlag = packageManager === 'yarn' ? '--exact' : '--save-exact';
212
+ return {
213
+ exact: pinOperator === '' ? ` ${exactFlag}` : '',
214
+ spec: `${PACKAGE_NAME}@${pinOperator === '~' ? '~' : ''}${target}`,
215
+ };
216
+ }
217
+
199
218
  /**
200
219
  * The install command. An `--install-cmd` override is used verbatim except
201
- * that `{target}` is replaced with the resolved semver.
220
+ * that `{target}` is replaced with the resolved semver. Otherwise the
221
+ * consumer's current pin operator decides the save style: exact keeps an
222
+ * exact pin, tilde keeps a tilde, and caret or unknown keeps today's form.
202
223
  *
203
224
  * @param {string} target
204
225
  * @param {string} [override]
205
226
  * @param {{
206
227
  * packageManager?: 'pnpm' | 'yarn' | 'npm',
207
228
  * workspaceRoot?: boolean,
229
+ * pinOperator?: '^' | '~' | '' | null,
208
230
  * }} [detected]
209
231
  * @returns {string}
210
232
  */
211
233
  export function resolveInstallCmd(
212
234
  target,
213
235
  override,
214
- { packageManager = 'npm', workspaceRoot = false } = {},
236
+ { packageManager = 'npm', workspaceRoot = false, pinOperator = null } = {},
215
237
  ) {
216
238
  const trimmed = String(override ?? '').trim();
217
239
  if (trimmed.length > 0) {
@@ -219,13 +241,18 @@ export function resolveInstallCmd(
219
241
  ? trimmed.replaceAll('{target}', target)
220
242
  : trimmed;
221
243
  }
244
+ const { exact, spec } = pinPreservingSpec(
245
+ target,
246
+ packageManager,
247
+ pinOperator,
248
+ );
222
249
  if (packageManager === 'pnpm') {
223
- return `pnpm add -D ${PACKAGE_NAME}@${target}${workspaceRoot ? ' -w' : ''}`;
250
+ return `pnpm add -D${exact} ${spec}${workspaceRoot ? ' -w' : ''}`;
224
251
  }
225
252
  if (packageManager === 'yarn') {
226
- return `yarn add -D ${PACKAGE_NAME}@${target}`;
253
+ return `yarn add -D${exact} ${spec}`;
227
254
  }
228
- return `npm install ${PACKAGE_NAME}@${target}`;
255
+ return `npm install${exact} ${spec}`;
229
256
  }
230
257
 
231
258
  const LOCKFILE_BY_PACKAGE_MANAGER = {
@@ -461,7 +488,11 @@ export function defaultNpmUpdate(
461
488
  } = {},
462
489
  ) {
463
490
  const detected = detectPackageManager(cwd, fs);
464
- const cmd = resolveInstallCmd(target, installCmd, detected);
491
+ const pinOperator = resolveConsumerPinSpec(cwd, fs)?.operator ?? null;
492
+ const cmd = resolveInstallCmd(target, installCmd, {
493
+ ...detected,
494
+ pinOperator,
495
+ });
465
496
  const repairHint =
466
497
  `\n → If node_modules looks wrong, run \`${repairInstallCommand(detected.packageManager)}\`` +
467
498
  ' to restore it to a consistent state.';
@@ -18,6 +18,7 @@ import { retireAuditResultsAutoFile } from './steps/2.60.0-retire-audit-results-
18
18
  import { baselineMergeQueueShape } from './steps/2.63.0-baseline-merge-queue-shape.js';
19
19
  import { foldClaudeMdIntoAgentsMdStep } from './steps/2.65.0-fold-claude-md-into-agents-md.js';
20
20
  import { retireAuditLedger } from './steps/2.70.0-retire-audit-ledger.js';
21
+ import { containerSafeProjections } from './steps/2.79.0-container-safe-projections.js';
21
22
  import { stripRemovedAgentrcKeys } from './steps/strip-removed-agentrc-keys.js';
22
23
 
23
24
  /**
@@ -44,6 +45,7 @@ export const migrations = [
44
45
  baselineMergeQueueShape,
45
46
  foldClaudeMdIntoAgentsMdStep,
46
47
  retireAuditLedger,
48
+ containerSafeProjections,
47
49
  ];
48
50
 
49
51
  export { compareVersions };
@@ -0,0 +1,91 @@
1
+ // lib/migrations/steps/2.79.0-container-safe-projections.js
2
+ /**
3
+ * Bring an existing consumer's bootstrap footprint to the container-safe
4
+ * shape: upgrade the legacy unguarded `prepare` to the guarded
5
+ * form, and add the `.claude/agents/` ignore entry. Reuses the bootstrap's own
6
+ * helpers so a migrated tree matches a fresh bootstrap byte for byte. An
7
+ * operator-customised `prepare` is never touched.
8
+ */
9
+
10
+ import nodeFs from 'node:fs';
11
+ import path from 'node:path';
12
+
13
+ import {
14
+ ensureGitignore,
15
+ ensurePrepareScript,
16
+ GITIGNORE_BLOCKS,
17
+ LEGACY_PREPARE_COMMAND,
18
+ } from '../../../.agents/scripts/lib/bootstrap/project-bootstrap.js';
19
+
20
+ /**
21
+ * @param {string} root
22
+ * @param {typeof nodeFs} fsImpl
23
+ * @returns {{ pkgPath: string, pkg: object | null }}
24
+ */
25
+ function readPackageJson(root, fsImpl) {
26
+ const pkgPath = path.join(root, 'package.json');
27
+ if (!fsImpl.existsSync(pkgPath)) return { pkgPath, pkg: null };
28
+ try {
29
+ return { pkgPath, pkg: JSON.parse(fsImpl.readFileSync(pkgPath, 'utf8')) };
30
+ } catch {
31
+ return { pkgPath, pkg: null };
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @param {string} root
37
+ * @param {typeof nodeFs} fsImpl
38
+ * @returns {boolean}
39
+ */
40
+ function hasLegacyPrepare(root, fsImpl) {
41
+ const { pkg } = readPackageJson(root, fsImpl);
42
+ return pkg?.scripts?.prepare === LEGACY_PREPARE_COMMAND;
43
+ }
44
+
45
+ /**
46
+ * @param {string} root
47
+ * @param {typeof nodeFs} fsImpl
48
+ * @returns {boolean}
49
+ */
50
+ function lacksAgentsIgnore(root, fsImpl) {
51
+ const target = path.join(root, '.gitignore');
52
+ const body = fsImpl.existsSync(target)
53
+ ? fsImpl.readFileSync(target, 'utf8')
54
+ : '';
55
+ return !GITIGNORE_BLOCKS.agents.pattern.test(body);
56
+ }
57
+
58
+ export const containerSafeProjections = {
59
+ version: '2.79.0',
60
+ description:
61
+ 'guard the bootstrap `prepare` so a manifest-only container `npm ci` ' +
62
+ 'skips the projections, and gitignore the generated .claude/agents/ ' +
63
+ '(Story #5581)',
64
+ /**
65
+ * @param {{ projectRoot?: string, fs?: typeof nodeFs }} [ctx]
66
+ * @param {typeof nodeFs} [fsImpl]
67
+ * @returns {boolean}
68
+ */
69
+ detect(ctx, fsImpl = ctx?.fs ?? nodeFs) {
70
+ const root = ctx?.projectRoot ?? process.cwd();
71
+ return hasLegacyPrepare(root, fsImpl) || lacksAgentsIgnore(root, fsImpl);
72
+ },
73
+ /**
74
+ * @param {{ projectRoot?: string, fs?: typeof nodeFs }} [ctx]
75
+ * @param {typeof nodeFs} [fsImpl]
76
+ * @returns {void}
77
+ */
78
+ apply(ctx, fsImpl = ctx?.fs ?? nodeFs) {
79
+ const root = ctx?.projectRoot ?? process.cwd();
80
+ if (hasLegacyPrepare(root, fsImpl)) {
81
+ const { pkgPath, pkg } = readPackageJson(root, fsImpl);
82
+ ensurePrepareScript(pkg.scripts);
83
+ fsImpl.writeFileSync(
84
+ pkgPath,
85
+ `${JSON.stringify(pkg, null, 2)}\n`,
86
+ 'utf8',
87
+ );
88
+ }
89
+ ensureGitignore({ projectRoot: root, fsImpl }, ['agents']);
90
+ },
91
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mandrel",
3
- "version": "2.78.0",
3
+ "version": "2.80.0",
4
4
  "description": "Claude Code-first opinionated workflow framework: instructions, skills, rules, and SDLC workflows that govern AI coding assistants.",
5
5
  "files": [
6
6
  ".agents/",