@event4u/agent-config 14.7.0 → 14.8.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 (138) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +245 -388
  3. package/README.md +1 -1
  4. package/dist/agent-src/commands/evals/git-pr-merge.json +13 -0
  5. package/dist/agent-src/commands/evals/roadmap.json +17 -1
  6. package/dist/agent-src/commands/pr/create.md +14 -2
  7. package/dist/agent-src/commands/pr/merge.md +379 -0
  8. package/dist/agent-src/commands/roadmap/process-full.md +157 -3
  9. package/dist/agent-src/commands/roadmap.md +1 -1
  10. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +46 -36
  11. package/dist/agent-src/contexts/execution/autonomy-mechanics.md +37 -2
  12. package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +64 -2
  13. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +154 -2
  14. package/dist/agent-src/rules/artifact-drafting-protocol.md +5 -1
  15. package/dist/agent-src/rules/decision-revisit-gate.md +65 -33
  16. package/dist/agent-src/rules/recurring-criticism.md +1 -1
  17. package/dist/agent-src/rules/roadmap-progress-sync.md +19 -0
  18. package/dist/agent-src/rules/source-confidentiality.md +1 -1
  19. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +7 -4
  20. package/dist/agent-src/scripts/dashboard_mode.ts +212 -0
  21. package/dist/agent-src/scripts/update_roadmap_progress.ts +47 -48
  22. package/dist/agent-src/skills/adr-create/SKILL.md +124 -5
  23. package/dist/agent-src/skills/decision-record/SKILL.md +61 -3
  24. package/dist/agent-src/skills/decision-review/SKILL.md +65 -0
  25. package/dist/agent-src/skills/merge-conflicts/SKILL.md +26 -0
  26. package/dist/agent-src/skills/security/SKILL.md +8 -0
  27. package/dist/agent-src/skills/security-audit/SKILL.md +12 -1
  28. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  29. package/dist/agent-src/templates/roadmaps.md +20 -2
  30. package/dist/cli/registry.js +1 -0
  31. package/dist/cli/registry.js.map +1 -1
  32. package/dist/cli-delegate/{chunk-JZ4NR2TW.js → chunk-7PRE6ZV2.js} +1 -1
  33. package/dist/cli-delegate/{chunk-7F3VYSM2.js → chunk-EEJUMCDZ.js} +14 -14
  34. package/dist/cli-delegate/{chunk-74E3TKWV.js → chunk-H4VIVD4C.js} +5 -5
  35. package/dist/cli-delegate/chunk-I3EIN2YG.js +36 -0
  36. package/dist/cli-delegate/{chunk-4VR4ORQ6.js → chunk-LPPWO5CE.js} +4 -3
  37. package/dist/cli-delegate/{chunk-UEZ7D35A.js → chunk-N7CDDGI3.js} +4 -23
  38. package/dist/cli-delegate/cmd_adr_effective.js +1162 -0
  39. package/dist/cli-delegate/cmd_conformance.js +14 -14
  40. package/dist/cli-delegate/cmd_converge.js +3 -3
  41. package/dist/cli-delegate/cmd_doctor.js +7 -7
  42. package/dist/cli-delegate/cmd_export.js +6 -6
  43. package/dist/cli-delegate/cmd_handoff.js +7 -6
  44. package/dist/cli-delegate/cmd_memory_get.js +2 -1
  45. package/dist/cli-delegate/cmd_migrate.js +2 -2
  46. package/dist/cli-delegate/cmd_preflight.js +5 -5
  47. package/dist/cli-delegate/cmd_prune.js +6 -6
  48. package/dist/cli-delegate/cmd_route_audit.js +6 -5
  49. package/dist/cli-delegate/cmd_route_explain.js +3 -3
  50. package/dist/cli-delegate/cmd_session_recycle.js +3 -3
  51. package/dist/cli-delegate/cmd_settings_get.js +3 -3
  52. package/dist/cli-delegate/cmd_settings_migrate.js +6 -6
  53. package/dist/cli-delegate/cmd_sync.js +6 -6
  54. package/dist/cli-delegate/cmd_uninstall.js +6 -6
  55. package/dist/cli-delegate/cmd_update.js +3 -3
  56. package/dist/cli-delegate/cmd_upgrade.js +3 -3
  57. package/dist/cli-delegate/cmd_validate.js +6 -6
  58. package/dist/cli-delegate/cmd_versions.js +3 -3
  59. package/dist/discovery/deprecation-report.md +1 -1
  60. package/dist/discovery/discovery-manifest.json +53 -22
  61. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  62. package/dist/discovery/discovery-manifest.summary.md +3 -3
  63. package/dist/discovery/dormancy-report.md +1 -1
  64. package/dist/discovery/orphan-report.md +1 -1
  65. package/dist/discovery/packs.json +7 -6
  66. package/dist/discovery/trust-report.md +2 -2
  67. package/dist/discovery/workspaces.json +6 -5
  68. package/dist/hooks/dispatch.js +806 -681
  69. package/dist/install/globalRuleLayers.js +169 -0
  70. package/dist/install/globalRuleLayers.js.map +1 -0
  71. package/dist/install/partitionEligibility.js +156 -0
  72. package/dist/install/partitionEligibility.js.map +1 -1
  73. package/dist/install/ruleLayerPartition.js +157 -0
  74. package/dist/install/ruleLayerPartition.js.map +1 -0
  75. package/dist/mcp/registry-manifest.json +3 -3
  76. package/dist/mcp/server.json +2 -2
  77. package/dist/mcp/server.mjs +654 -578
  78. package/dist/scripts/_lib/prune_empty_dirs.js +85 -0
  79. package/dist/scripts/_lib/prune_empty_dirs.js.map +1 -0
  80. package/dist/scripts/condense.js +52 -89
  81. package/dist/scripts/condense.js.map +1 -1
  82. package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +45 -1
  83. package/docs/guidelines/agent-infra/false-green.md +47 -1
  84. package/package.json +1 -1
  85. package/src/agent-src/scripts/archive_completed_roadmaps.ts +7 -4
  86. package/src/agent-src/scripts/dashboard_mode.ts +212 -0
  87. package/src/agent-src/scripts/update_roadmap_progress.ts +47 -48
  88. package/src/config/ci-local-parity.yml +21 -0
  89. package/src/config/estate-count-budget.json +275 -2
  90. package/src/config/evaluator-budgets.json +3 -3
  91. package/src/config/gate-coverage.yml +220 -12
  92. package/src/config/gate-violation-baselines.json +73 -63
  93. package/src/config/gitignore-block.txt +15 -2
  94. package/src/config/hook-latency-budget.json +5 -0
  95. package/src/config/rule-stub-ceilings.json +17 -3
  96. package/src/install/globalRuleLayers.ts +197 -0
  97. package/src/install/partitionEligibility.ts +177 -0
  98. package/src/install/ruleLayerPartition.ts +212 -0
  99. package/src/scripts/_cli/cmd_adr_effective.ts +484 -0
  100. package/src/scripts/_dispatch.bash +11 -0
  101. package/src/scripts/_lib/adr_frontmatter.test.ts +365 -0
  102. package/src/scripts/_lib/adr_frontmatter.ts +459 -0
  103. package/src/scripts/_lib/envelope_grounding.ts +11 -1
  104. package/src/scripts/_lib/layer_overlap_notice.ts +11 -2
  105. package/src/scripts/_lib/prune_empty_dirs.ts +80 -0
  106. package/src/scripts/adr/evidence_census.ts +899 -0
  107. package/src/scripts/adr/regenerate_index.ts +12 -32
  108. package/src/scripts/adr_cite_check.ts +540 -39
  109. package/src/scripts/audit_adr_coverage.ts +103 -17
  110. package/src/scripts/bench_hook_latency.ts +204 -0
  111. package/src/scripts/build_archive_index.ts +34 -0
  112. package/src/scripts/check_adr_frontmatter.ts +574 -39
  113. package/src/scripts/check_hook_bundle_content.ts +219 -0
  114. package/src/scripts/check_new_adr_evidence.ts +529 -0
  115. package/src/scripts/check_references.ts +18 -0
  116. package/src/scripts/check_rule_layer_partition.ts +531 -0
  117. package/src/scripts/check_single_delivery.ts +137 -4
  118. package/src/scripts/check_standing_rule_delivery.ts +8 -2
  119. package/src/scripts/condense.ts +61 -91
  120. package/src/scripts/external_sources_denylist.json +4 -1
  121. package/src/scripts/hooks/block_unauthorized_git.ts +22 -2
  122. package/src/scripts/hooks/dispatch_hook.ts +154 -187
  123. package/src/scripts/hooks/dispatch_issues.ts +38 -19
  124. package/src/scripts/hooks/fallback_yaml.ts +66 -0
  125. package/src/scripts/hooks/host_semantics.ts +21 -0
  126. package/src/scripts/hooks/injection_budget.ts +13 -3
  127. package/src/scripts/hooks/py_json_dumps.ts +103 -0
  128. package/src/scripts/hooks/state_io.ts +88 -1
  129. package/src/scripts/hooks/stdin_failure_policy.ts +96 -0
  130. package/src/scripts/injection_scan_hook.ts +137 -5
  131. package/src/scripts/lint_hook_manifest.ts +49 -0
  132. package/src/scripts/lint_provenance_vocabulary.ts +472 -4
  133. package/src/scripts/routing_doctor.ts +5 -1
  134. package/src/scripts/sync_pr_branch.ts +163 -20
  135. package/dist/cli-delegate/{chunk-PPQO4NGR.js → chunk-6RJA2F5A.js} +3 -3
  136. package/dist/cli-delegate/{chunk-6EOCNQAM.js → chunk-E4XIZDIB.js} +0 -0
  137. package/dist/cli-delegate/{chunk-FBKL6JWT.js → chunk-MMSGVZKV.js} +3 -3
  138. package/dist/cli-delegate/{chunk-GJ5BVHXM.js → chunk-PMEKGDED.js} +3 -3
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Where each host's GLOBAL rule layer lives on disk, and whether it carries a
3
+ * given set of rules.
4
+ *
5
+ * ## Why this module exists
6
+ *
7
+ * ADR-236 partitions rules between the global and the project layer: an artefact
8
+ * scoped to this package alone stays project-local, everything else is delivered
9
+ * globally and withheld from the project tree. `partitionEligibility.ts` decides
10
+ * WHETHER the partition is on, by verifying the claude host layer against
11
+ * `installed.lock`. Its own docstring then draws the only conclusion that
12
+ * evidence supports — it "says nothing about `~/.cursor`", so withholding a
13
+ * cursor artefact on the strength of a claude fingerprint "would deliver it
14
+ * nowhere".
15
+ *
16
+ * That reasoning is right and its scope was too narrow for rules. The rule
17
+ * filter sits in `condense.ts::_scoped_rule_basenames()`, which is per-RUN and
18
+ * not per-DIRECTORY, so it already withholds from `.clinerules` on a claude
19
+ * fingerprint — the exact extrapolation the docstring refuses. Measured
20
+ * 2026-08-22 in a freshly generated worktree with the partition active:
21
+ *
22
+ * ```
23
+ * .claude/rules 13 files, 13 package-only, 0 global-only
24
+ * .clinerules 14 files, 13 package-only, 0 global-only
25
+ * .cursor/rules 126 files, 26 package-only, 100 global-only
26
+ * .windsurf/rules 113 files, 13 package-only, 100 global-only
27
+ * .augment/rules 118 files, 15 package-only, 103 global-only
28
+ * ```
29
+ *
30
+ * Two hosts partition on borrowed evidence; three do not partition at all. This
31
+ * module supplies the evidence per host so neither case has to be guessed:
32
+ * {@link globalRuleLayerNames} reads the host's own global directory, and
33
+ * {@link hostLayerCarries} answers the one question a withhold depends on.
34
+ *
35
+ * ## Why the paths are written out rather than imported
36
+ *
37
+ * `USER_SCOPE_PATHS` in `src/scripts/install.ts` is the authority for a host's
38
+ * global scope ROOT, and it is the right authority. It is not imported here for
39
+ * two reasons: `install.ts` is a multi-thousand-line CLI entry point that pulls
40
+ * in the whole installer graph, and a scope root is not a rules path — cline's
41
+ * root already IS its rules directory (`~/Documents/Cline/Rules/`) while every
42
+ * other host appends a subdirectory. So the mapping is stated once here and
43
+ * PINNED against `USER_SCOPE_PATHS` by `tests/install/global_rule_layers.test.ts`,
44
+ * which fails if a root moves. A pinned restatement drifts loudly; an import
45
+ * would have cost the bundle.
46
+ */
47
+ import * as fs from 'node:fs';
48
+ import * as os from 'node:os';
49
+ import * as path from 'node:path';
50
+ /**
51
+ * Tool id → its global rule directory, relative to the user's home.
52
+ *
53
+ * Keys are the ids `USER_SCOPE_PATHS` and `TOOL_SIGNALS` use, so a row here is
54
+ * traceable to the installer's own scope table rather than invented.
55
+ *
56
+ * The five hosts below are the ones that receive a projected rule TREE. A host
57
+ * whose rules arrive as a single concatenated file (`.windsurfrules`,
58
+ * `GEMINI.md`, copilot instructions) has no directory to compare and is
59
+ * deliberately absent: {@link globalRuleLayerPath} returns null for it, which
60
+ * reads as "no evidence" and keeps the full projection.
61
+ */
62
+ export const GLOBAL_RULE_DIRS = {
63
+ 'claude-code': '.claude/rules',
64
+ cursor: '.cursor/rules',
65
+ augment: '.augment/rules',
66
+ // Windsurf's scope root is `~/.codeium/windsurf/`, not `~/.windsurf/`.
67
+ windsurf: '.codeium/windsurf/rules',
68
+ // Cline's scope root IS the rules directory — no `rules/` suffix.
69
+ cline: 'Documents/Cline/Rules',
70
+ };
71
+ /**
72
+ * Project rule directory → the tool id whose global layer covers it.
73
+ *
74
+ * Five entries, because five directories receive a projected rule TREE. Two are
75
+ * symlink trees (`condense.ts::TOOL_DIRS`); three are written by their own
76
+ * emitters — `generate_cursor_mdc_rules`, `generate_windsurf_modern_rules`, and
77
+ * `project_to_augment`. The `.cursor/rules` row covers both the `.mdc` files and
78
+ * the legacy `.md` symlinks that share that directory.
79
+ *
80
+ * It lives here rather than in either consumer so the gate that reports a
81
+ * duplicate and the emitters that must stop creating one read the same list. A
82
+ * sixth host directory added to one and not the other is exactly how a gate goes
83
+ * green over a tree nobody checks.
84
+ */
85
+ export const PROJECT_RULE_DIRS = {
86
+ '.claude/rules': 'claude-code',
87
+ '.cursor/rules': 'cursor',
88
+ '.clinerules': 'cline',
89
+ '.windsurf/rules': 'windsurf',
90
+ '.augment/rules': 'augment',
91
+ };
92
+ /** The tool id whose global layer covers a project rule directory, or null. */
93
+ export function toolIdForProjectRuleDir(dir) {
94
+ return PROJECT_RULE_DIRS[dir] ?? null;
95
+ }
96
+ /** Every tool id that has a global rule directory this module can read. */
97
+ export function hostsWithGlobalRuleLayer() {
98
+ return Object.keys(GLOBAL_RULE_DIRS).sort();
99
+ }
100
+ /**
101
+ * Absolute path to a host's global rule directory, or null when the host has no
102
+ * directory-shaped global layer.
103
+ *
104
+ * Null is a real answer and not an error: it means this module cannot supply
105
+ * evidence for that host, and every caller must read that as "do not withhold".
106
+ */
107
+ export function globalRuleLayerPath(toolId, home = process.env['HOME'] ?? os.homedir()) {
108
+ const rel = GLOBAL_RULE_DIRS[toolId];
109
+ return rel === undefined ? null : path.join(home, rel);
110
+ }
111
+ /**
112
+ * The rule basenames a host's global layer actually holds, normalised to `.md`.
113
+ *
114
+ * Returns null when the directory does not exist or cannot be read — the
115
+ * absent-tolerant contract Phase 1.1 requires. Normalisation matters because
116
+ * Cursor's tree is `.mdc`: comparing raw filenames would report every rule as
117
+ * missing there and turn the partition off for the one host whose duplication is
118
+ * largest.
119
+ */
120
+ export function globalRuleLayerNames(toolId, home = process.env['HOME'] ?? os.homedir()) {
121
+ const dir = globalRuleLayerPath(toolId, home);
122
+ if (dir === null) {
123
+ return null;
124
+ }
125
+ let entries;
126
+ try {
127
+ entries = fs.readdirSync(dir);
128
+ }
129
+ catch {
130
+ return null;
131
+ }
132
+ return entries
133
+ .filter((f) => f.endsWith('.md') || f.endsWith('.mdc'))
134
+ .map((f) => (f.endsWith('.mdc') ? `${f.slice(0, -4)}.md` : f))
135
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
136
+ }
137
+ /**
138
+ * Does this host's global layer carry every rule that would be withheld from its
139
+ * project directory?
140
+ *
141
+ * This is the property `personaPartition`'s docstring states as the precondition
142
+ * for any withhold — "withholding is only safe once the surviving layer is known
143
+ * to carry what is withheld" — asked per host instead of inferred from claude.
144
+ *
145
+ * Fails safe in all three negative directions: a host with no directory layer, a
146
+ * directory that is absent, and a directory missing even one name all return
147
+ * `carries: false`, so the caller keeps the full projection. An empty
148
+ * `ruleNames` is vacuously carried, which is correct — withholding nothing needs
149
+ * no evidence.
150
+ */
151
+ export function hostLayerCarries(toolId, ruleNames, home = process.env['HOME'] ?? os.homedir()) {
152
+ const layerPath = globalRuleLayerPath(toolId, home);
153
+ if (layerPath === null) {
154
+ return { carries: false, layerPath: null, missing: [...ruleNames], reason: 'no-layer-for-host' };
155
+ }
156
+ const have = globalRuleLayerNames(toolId, home);
157
+ if (have === null) {
158
+ return { carries: false, layerPath, missing: [...ruleNames], reason: 'layer-absent' };
159
+ }
160
+ const present = new Set(have);
161
+ const missing = ruleNames.filter((n) => !present.has(n));
162
+ return {
163
+ carries: missing.length === 0,
164
+ layerPath,
165
+ missing,
166
+ reason: missing.length === 0 ? 'carries' : 'missing-names',
167
+ };
168
+ }
169
+ //# sourceMappingURL=globalRuleLayers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalRuleLayers.js","sourceRoot":"","sources":["../../src/install/globalRuleLayers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAA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EAAE,mBAAmB,EAAE,CAAC;IACrG,CAAC;IACD,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IAC1F,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO;QACH,OAAO,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC;QAC7B,SAAS;QACT,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe;KAC7D,CAAC;AACN,CAAC"}
@@ -128,6 +128,31 @@ export function partitionVerdict(inputs) {
128
128
  * artefact is NOT package-only, so it is delivered globally and withheld from
129
129
  * the project layer. Both defaults resolve toward "the artefact is generally
130
130
  * useful"; only one of them is about withholding.
131
+ *
132
+ * ## The state space, MEASURED rather than enumerated defensively (2026-08-21)
133
+ *
134
+ * Three of this function's branches — unreadable file, absent `workspaces:`,
135
+ * empty list — all resolve to `false`, and the closure review asked whether one
136
+ * of them was resolving by accident. Counted over all 119 files in `src/rules/`:
137
+ *
138
+ * absent=0 · empty=0 · maintainer-only=16 · mixed=103 · scalar-or-other=0
139
+ *
140
+ * So exactly TWO states occur today, both deliberate, and the 16 is the figure
141
+ * ADR-236 partitions on.
142
+ *
143
+ * **The other three branches are CURRENTLY ABSENT from the generated tree, not
144
+ * unreachable** — an earlier revision of this note said "the state space is
145
+ * closed by that count", and a neutral review was right to refuse it. A file can
146
+ * become unreadable at runtime (permissions, a partial write, a truncated
147
+ * checkout) and a rule can acquire a malformed `workspaces:` on any commit. The
148
+ * count is a current inventory, never a proof of impossibility.
149
+ *
150
+ * What the count DOES buy is a bound on the defensive work worth doing now:
151
+ * fixtures for the absent and malformed cases would pin behaviour on inputs no
152
+ * committed rule produces, so they were not written. All three branches already
153
+ * resolve to `false` — deliver globally, withhold from the project layer — which
154
+ * is the over-delivery direction rather than the losing one, so the untested
155
+ * branches fail safe. Should that count move, this note is the thing that dates.
131
156
  */
132
157
  export function isExclusivelyPackageOnly(source_path) {
133
158
  let meta;
@@ -273,4 +298,135 @@ skip, report) {
273
298
  return null;
274
299
  }
275
300
  }
301
+ /**
302
+ * Per-tool-directory persona list under the partition — ADR-236's closure for the
303
+ * one family it never reached.
304
+ *
305
+ * The partition shipped for rules and skills and stopped there, so
306
+ * `<repo>/.claude/personas` kept being written while `~/.claude/personas` was
307
+ * installed from `_CLAUDE_SKILL_BUNDLE` (`install.ts:1916-1921`). Measured
308
+ * 2026-08-21 on a freshly regenerated tree with the partition ACTIVE: **29 shared
309
+ * names**, and neither `check_single_delivery` nor `_lib/layer_overlap_notice`
310
+ * looked, because `personas` was in neither's `TYPES`.
311
+ *
312
+ * ## Two properties the caller depends on
313
+ *
314
+ * **Scoped to `.claude/` only.** {@link partitionActive} verifies the CLAUDE host
315
+ * layer against `installed.lock`. It says nothing about `~/.cursor`, so
316
+ * withholding a cursor persona on the strength of a claude fingerprint would
317
+ * deliver it nowhere — the one failure the fail-safe design exists to prevent.
318
+ * Every other tool directory keeps the full projection.
319
+ *
320
+ * **Reconciliation is the empty list, not a second code path.** The caller's
321
+ * stale-symlink sweep removes any link whose name is absent from the list it was
322
+ * given for that directory, so returning `[]` empties a directory an earlier
323
+ * version populated. A gate that only declined to WRITE would leave the existing
324
+ * duplicate standing — a partition that stops new duplication and keeps the old
325
+ * is not a partition.
326
+ *
327
+ * Verified before shipping: every one of the 29 project personas is present in
328
+ * the global layer (32 there, a strict superset). The partition is a removal and
329
+ * has no repair path, so withholding is only safe once the surviving layer is
330
+ * known to carry what is withheld.
331
+ */
332
+ export function personaPartition(projectRoot, all) {
333
+ const active = partitionActive(projectRoot);
334
+ return {
335
+ all,
336
+ listFor: (toolDir) => (personaWithheldFor(toolDir, active) ? [] : all),
337
+ note: active ? ' — .claude/ withheld: ADR-236 partition, personas arrive from ~/.claude' : '',
338
+ countFor: (toolDir) => (personaWithheldFor(toolDir, active) ? 0 : all.length),
339
+ };
340
+ }
341
+ /**
342
+ * The pure half of {@link personaPartition}: withhold iff the partition is active
343
+ * AND this is a Claude tool directory.
344
+ *
345
+ * Split out so the decision is testable in BOTH directions. `personaPartition`
346
+ * reads `installed.lock` through a memoized `partitionActive`, so a test over it
347
+ * can only assert whatever this machine happens to be — which is a test that
348
+ * passes either way and therefore proves nothing. The two properties worth
349
+ * pinning are exactly the two this signature exposes: `.claude/` is withheld when
350
+ * active, and NOTHING else ever is.
351
+ */
352
+ export function personaWithheldFor(toolDir, active) {
353
+ return active && toolDir.startsWith('.claude/');
354
+ }
355
+ /**
356
+ * Does the project layer withhold the colon-form `/cluster:sub` commands?
357
+ *
358
+ * ## The claim this replaces, and the measurement that revised it
359
+ *
360
+ * `generate_claude_project_commands` was written on the reasoning that "Claude
361
+ * Code dedupes project and user scope by name, so the two copies of
362
+ * `/cluster:sub` collapse" — a host-behaviour claim with no first-party
363
+ * observation behind it. Its sibling claim about skills WAS probed under
364
+ * ADR-236's roadmap (Phase 5.2, `claudeMdExcludes`) and came back negative, so
365
+ * an unprobed host assumption in the same area was not a safe default.
366
+ *
367
+ * **MEASURED 2026-08-21, Claude Code 2.1.238.** Fixture: `/analyze:inbox`
368
+ * present in BOTH `~/.claude/commands/analyze/` and a temp project's
369
+ * `.claude/commands/analyze/`. The session reports `COUNT=1`. A control second
370
+ * entry (`/analyze:inboxctl`, project-only) makes the same probe report
371
+ * `COUNT=2` — so the 1 is an observation, not a probe that can only say one.
372
+ *
373
+ * **The half nobody had checked: the surviving copy is the GLOBAL one.** Asked
374
+ * for the command's description, the session returned the global body, not the
375
+ * project fixture's. So the dedup claim holds and its unstated corollary
376
+ * inverts the value of the project-layer copy: where a verified global layer
377
+ * exists, those 40 symlinks are written, deduped away, and LOSE. They are dead
378
+ * weight there — not a second listing, and not a reachability guarantee either.
379
+ *
380
+ * ## Why `partitionActive` is the right predicate rather than a new one
381
+ *
382
+ * It is true exactly when a global layer is present and verified against
383
+ * `installed.lock`, which is exactly the case where the project copy loses; and
384
+ * false on a fresh checkout, an unverified install, or a version mismatch —
385
+ * every case where the project copy is the only reachable one. So the
386
+ * fail-safe direction the whole module is built around already matches the
387
+ * measurement, and withholding needs no separate switch.
388
+ *
389
+ * ## Honest limits
390
+ *
391
+ * Self-report, n=1 per condition, one host version, one machine. What is NOT
392
+ * claimed: that older or newer hosts dedupe the same way, or that precedence is
393
+ * stable across them.
394
+ *
395
+ * **And a claim that WAS made here has been withdrawn as false** (neutral review,
396
+ * 2026-08-21). It read: *"A host that stopped deduping would show up as a
397
+ * double-listing, and `check_single_delivery` reports the overlap either way."*
398
+ * It cannot. When this predicate returns true the project copy is never written,
399
+ * so there is no second copy for the host to double-list or for the gate to
400
+ * count — it would report zero overlap while the assumption underneath had
401
+ * failed. Worse, `partitionActive` verifies the INSTALL (version + content
402
+ * fingerprint), never the HOST version whose behaviour was measured, so a host
403
+ * upgrade changes the premise and moves nothing this code reads.
404
+ *
405
+ * What actually holds: reachability survives a dedup change either way, because
406
+ * the global copy is delivered regardless. What is lost is only the project
407
+ * copy's redundancy, and nothing detects that. A real detector would have to
408
+ * pin the host version this measurement was taken against and re-probe when it
409
+ * moves — not built here, and named as absent rather than implied away.
410
+ */
411
+ export function commandsWithheld(projectRoot) {
412
+ return partitionActive(projectRoot);
413
+ }
414
+ /**
415
+ * ## The caller's early return, flagged by review and kept
416
+ *
417
+ * `generate_claude_project_commands` applies this predicate and then returns
418
+ * early when `src/domains/` is absent — BEFORE its stale-link sweep. So a tree
419
+ * with no `src/domains` keeps whatever `.claude/commands` it already had, even
420
+ * when the commands are now withheld.
421
+ *
422
+ * Invariant rather than oversight: this package always ships `src/domains/`, the
423
+ * generator only runs from a checkout that has it, and a consumer never reaches
424
+ * this path. Documented rather than reordered, because hoisting the sweep above
425
+ * the guard would make a non-package tree lose a directory this code did not
426
+ * write — a worse failure than the one being avoided, and on a tree we do not own.
427
+ *
428
+ * The transition that DOES occur is covered: `partition_delivery_topology.test.ts`
429
+ * runs inactive→active over a fixture that has `src/domains`, and asserts both
430
+ * the links and the empty cluster directories are gone after one run.
431
+ */
276
432
  //# sourceMappingURL=partitionEligibility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"partitionEligibility.js","sourceRoot":"","sources":["../../src/install/partitionEligibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACH,uBAAuB,EACvB,aAAa,EACb,cAAc,GACjB,MAAM,mCAAmC,CAAC;AAE3C,iFAAiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAgC9D;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACpD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC3B,OAAO;YACH,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE,sCAAsC;SACjD,CAAC;IACN,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO;YACH,IAAI,EAAE,iBAAiB;Y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AC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAAC,CAAC;QACjG,OAAO,WAAW,CAAC;IACvB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CACF,wCAAwC,MAAM,CAAC,CAAC,CAAC,kDAAkD,CACtG,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"partitionEligibility.js","sourceRoot":"","sources":["../../src/install/partitionEligibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACH,uBAAuB,EACvB,aAAa,EACb,cAAc,GACjB,MAAM,mCAAmC,CAAC;AAE3C,iFAAiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAgC9D;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACpD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC3B,OAAO;YACH,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE,sCAAsC;SACjD,CAAC;IACN,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO;YACH,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE,kEAAkE;SAC7E,CAAC;IACN,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC;IAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO;YACH,IAAI,EAAE,i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CACF,wCAAwC,MAAM,CAAC,CAAC,CAAC,kDAAkD,CACtG,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,gBAAgB,CAC5B,WAAmB,EACnB,GAAsB;IAgBtB,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC5C,OAAO;QACH,GAAG;QACH,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACtE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,yEAAyE,CAAC,CAAC,CAAC,EAAE;QAC7F,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;KAChF,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,MAAe;IAC/D,OAAO,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAChD,OAAO,eAAe,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * The ADR-236 rule partition, decided per HOST directory on that host's own
3
+ * evidence.
4
+ *
5
+ * ## Why the decision moved from per-run to per-directory
6
+ *
7
+ * The filter used to sit in `condense.ts::_scoped_rule_basenames()`, which runs
8
+ * once per generation, so `partitionActive` — a claude-only fingerprint against
9
+ * `installed.lock` — decided for every host at once. That contradicted
10
+ * `partitionEligibility.ts`'s own fail-safe reasoning, which refuses to withhold a
11
+ * cursor artefact on claude's evidence because it "would deliver it nowhere", and
12
+ * it was measurably wrong in both directions on 2026-08-22 (partition ACTIVE,
13
+ * freshly generated worktree):
14
+ *
15
+ * ```
16
+ * .claude/rules 13 files, 13 package-only, 0 global-only
17
+ * .clinerules 14 files, 13 package-only, 0 global-only ← narrowed on
18
+ * borrowed evidence
19
+ * .cursor/rules 126 files, 26 package-only, 100 global-only ← never narrowed
20
+ * .windsurf/rules 113 files, 13 package-only, 100 global-only ← never narrowed
21
+ * .augment/rules 118 files, 15 package-only, 103 global-only ← never narrowed
22
+ * ```
23
+ *
24
+ * So the narrowing is per directory and gated on real evidence:
25
+ * {@link hostLayerCarries} reads that host's global directory and answers whether
26
+ * every name about to be withheld is actually there. No layer, an unreadable layer,
27
+ * or one missing a single name → the full projection is returned. A withhold now
28
+ * costs a directory read; the alternative cost a rule.
29
+ *
30
+ * ## Why it lives here rather than in condense.ts
31
+ *
32
+ * Four call sites consume it — the symlink emit plan, the cursor `.mdc` emitter,
33
+ * the windsurf emitter, the augment projector — and four sites deciding this
34
+ * separately is exactly how three of them came to disagree. It is in `src/install/`
35
+ * beside {@link partitionActive} and {@link hostLayerCarries}, the two predicates
36
+ * it composes, rather than in the 2,700-line generator that calls it.
37
+ *
38
+ * ## The classification source is the PROJECTION, not the authored tree
39
+ *
40
+ * `rulesSource` is `dist/agent-src/rules` at every call site, deliberately. A rule
41
+ * absent from `dist/` is compile-disabled and never projected, so it can be neither
42
+ * withheld nor duplicated — classifying from `src/rules` would count
43
+ * `telegraph-speak.md` (compile-disabled: 119 rules / 16 package-only in `src/`,
44
+ * 118 / 15 in `dist/`) and disagree with the emitter by exactly one file.
45
+ */
46
+ import * as fs from 'node:fs';
47
+ import * as os from 'node:os';
48
+ import * as path from 'node:path';
49
+ import { isExclusivelyPackageOnly, partitionActive } from './partitionEligibility.js';
50
+ import { hostLayerCarries, toolIdForProjectRuleDir } from './globalRuleLayers.js';
51
+ /**
52
+ * Narrow one directory's rule list to the package-only set — but only when THIS
53
+ * host's global layer is verified to carry what would be withheld.
54
+ *
55
+ * Returns a copy of `rules` unchanged in every uncertain case. That direction is
56
+ * the whole design: an unnecessary duplicate costs context, a wrong withhold costs
57
+ * the rule.
58
+ */
59
+ export function partitionRulesForDir(opts) {
60
+ const { toolDir, rules, projectRoot, rulesSource } = opts;
61
+ const active = opts.active ?? partitionActive(projectRoot);
62
+ if (!active) {
63
+ return [...rules];
64
+ }
65
+ const toolId = toolIdForProjectRuleDir(toolDir);
66
+ if (toolId === null) {
67
+ // An unmapped directory has no global layer this code can point at, so
68
+ // there is no evidence to withhold on.
69
+ return [...rules];
70
+ }
71
+ const packageOnly = rules.filter((r) => isExclusivelyPackageOnly(path.join(rulesSource, r)));
72
+ const keep = new Set(packageOnly);
73
+ const withheld = rules.filter((r) => !keep.has(r));
74
+ const home = opts.userHome ?? process.env['HOME'] ?? os.homedir();
75
+ const verdict = hostLayerCarries(toolId, withheld, home);
76
+ if (!verdict.carries) {
77
+ opts.announce?.(` ⚠️ ${toolDir}: full projection kept — ${toolId}'s global layer ${verdict.reason}` +
78
+ (verdict.missing.length > 0
79
+ ? ` (${String(verdict.missing.length)} rule(s) not there, e.g. ` +
80
+ `${verdict.missing.slice(0, 3).join(', ')})`
81
+ : ''));
82
+ return [...rules];
83
+ }
84
+ return packageOnly;
85
+ }
86
+ // ── The older, weaker duplicate-avoidance mechanism ──────────────────────────
87
+ //
88
+ // `projection.scope_dedup` (default OFF) predates the partition and solves the
89
+ // same problem with a narrower method: skip a project copy only when its
90
+ // user-scope twin is BYTE-IDENTICAL. It moved here from condense.ts alongside the
91
+ // partition because the two are one subject — a reader deciding how a duplicate is
92
+ // avoided should find both in one file rather than one here and one in a
93
+ // 2,700-line generator. Behaviour is unchanged; only `MODULE_STATE` reads became
94
+ // parameters.
95
+ /** `fs.statSync(p).isFile()`, false on any error — condense.ts's `_isFile`. */
96
+ function isFile(p) {
97
+ try {
98
+ return fs.statSync(p).isFile();
99
+ }
100
+ catch {
101
+ return false;
102
+ }
103
+ }
104
+ /**
105
+ * Per-tool user-scope rule directory, for the scope-dedup below. Only tools
106
+ * whose host reads a user-scope rules directory can have a redundant twin;
107
+ * everything else has nothing to de-duplicate against.
108
+ */
109
+ const USER_SCOPE_RULE_DIRS = {
110
+ '.claude/rules': path.join('.claude', 'rules'),
111
+ };
112
+ export function dedupableRules(opts) {
113
+ const { toolDir: tool_dir, rules, userHome, rulesSource } = opts;
114
+ const relative = USER_SCOPE_RULE_DIRS[tool_dir];
115
+ if (relative === undefined) {
116
+ return new Set();
117
+ }
118
+ // A hostile or simply absent $HOME must make the dedup inert, not
119
+ // adventurous. In a container `$HOME` is often unset (so `homedir()` can
120
+ // resolve to `/`) or world-writable, and this function decides which rules
121
+ // to STOP emitting — reading an unexpected tree there is how a projection
122
+ // silently loses a rule. Council review of PR #1055 raised exactly this.
123
+ let userDirStat;
124
+ const userDir = path.join(userHome, relative);
125
+ try {
126
+ userDirStat = fs.statSync(userDir);
127
+ }
128
+ catch {
129
+ return new Set();
130
+ }
131
+ if (!userDirStat.isDirectory()) {
132
+ return new Set();
133
+ }
134
+ // World-writable user scope: anyone on the box could plant a byte-identical
135
+ // twin and thereby delete a rule from the project projection. Refuse.
136
+ if ((userDirStat.mode & 0o002) !== 0) {
137
+ opts.announce?.(` ⚠️ ${tool_dir}: user-scope rules dir is world-writable — scope-dedup skipped`);
138
+ return new Set();
139
+ }
140
+ const skip = new Set();
141
+ for (const rule of rules) {
142
+ const twin = path.join(userDir, rule);
143
+ const source = path.join(rulesSource, rule);
144
+ try {
145
+ if (!isFile(twin) || !isFile(source))
146
+ continue;
147
+ if (fs.readFileSync(twin).equals(fs.readFileSync(source))) {
148
+ skip.add(rule);
149
+ }
150
+ }
151
+ catch {
152
+ // An unreadable twin is simply not de-duplicable — emit the project copy.
153
+ }
154
+ }
155
+ return skip;
156
+ }
157
+ //# sourceMappingURL=ruleLayerPartition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleLayerPartition.js","sourceRoot":"","sources":["../../src/install/ruleLayerPartition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AA+BlF;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAA2B;IAC5D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,uEAAuE;QACvE,uCAAuC;QACvC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC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AE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBAAE,SAAS;YAC/C,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,0EAA0E;QAC9E,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "discovery": {
3
- "artefact_count": 611,
3
+ "artefact_count": 612,
4
4
  "scanner_version": "de0a22b4ac4c"
5
5
  },
6
- "generated_at": "2026-08-21",
6
+ "generated_at": "2026-08-22",
7
7
  "package": {
8
8
  "description": "Governed skills, rules and commands for AI coding tools (Claude Code, Cursor, Windsurf, Copilot) \u2014 every claim machine-checked, including \"zero runtime daemon\".",
9
9
  "homepage": "https://event4u-app.github.io/agent-config",
10
10
  "name": "@event4u/agent-config",
11
11
  "repository": "https://github.com/event4u-app/agent-config",
12
- "version": "14.7.0"
12
+ "version": "14.8.0"
13
13
  },
14
14
  "registries": [
15
15
  {
@@ -9,12 +9,12 @@
9
9
  "transport": {
10
10
  "type": "stdio"
11
11
  },
12
- "version": "14.7.0"
12
+ "version": "14.8.0"
13
13
  }
14
14
  ],
15
15
  "repository": {
16
16
  "source": "github",
17
17
  "url": "https://github.com/event4u-app/agent-config"
18
18
  },
19
- "version": "14.7.0"
19
+ "version": "14.8.0"
20
20
  }