bmad-module-skill-forge 4.0.0 → 5.0.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 (85) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +3 -3
  3. package/docs/_data/pinned.yaml +19 -13
  4. package/docs/architecture.md +2 -2
  5. package/docs/concepts.md +4 -4
  6. package/docs/examples.md +32 -25
  7. package/docs/getting-started.md +3 -3
  8. package/docs/how-it-works.md +2 -2
  9. package/docs/index.md +1 -1
  10. package/docs/skill-model.md +41 -39
  11. package/docs/verifying-a-skill.md +41 -20
  12. package/docs/why-skf.md +1 -1
  13. package/docs/workflows.md +2 -2
  14. package/package.json +1 -1
  15. package/src/shared/scripts/schemas/skf-update-result-envelope.v1.json +11 -3
  16. package/src/shared/scripts/schemas/skill-brief.v1.json +1 -1
  17. package/src/shared/scripts/skf-build-change-manifest.py +881 -168
  18. package/src/shared/scripts/skf-count-tokens.py +54 -10
  19. package/src/shared/scripts/skf-detect-workspaces.py +67 -0
  20. package/src/shared/scripts/skf-emit-result-envelope.py +6 -5
  21. package/src/shared/scripts/skf-extract-public-api.py +439 -107
  22. package/src/shared/scripts/skf-extraction-inventory.py +10 -6
  23. package/src/shared/scripts/skf-extraction-snapshot.py +6 -6
  24. package/src/shared/scripts/skf-parse-gaps.py +135 -26
  25. package/src/shared/scripts/skf-render-metadata-stats.py +1 -1
  26. package/src/shared/scripts/skf-resolve-customization.py +197 -0
  27. package/src/shared/scripts/skf-shard-body.py +239 -41
  28. package/src/shared/scripts/skf-validate-output.py +12 -3
  29. package/src/shared/scripts/skf-verify-provenance-completeness.py +470 -38
  30. package/src/shared/tool-requirements.yaml +8 -2
  31. package/src/skf-analyze-source/SKILL.md +2 -2
  32. package/src/skf-analyze-source/assets/skill-brief-schema.md +1 -1
  33. package/src/skf-audit-skill/SKILL.md +2 -2
  34. package/src/skf-audit-skill/references/re-index.md +2 -2
  35. package/src/skf-brief-skill/SKILL.md +2 -2
  36. package/src/skf-brief-skill/assets/skill-brief-schema.md +2 -2
  37. package/src/skf-brief-skill/references/scope-definition.md +4 -4
  38. package/src/skf-campaign/SKILL.md +2 -2
  39. package/src/skf-campaign/references/step-05-skill-loop.md +6 -1
  40. package/src/skf-create-skill/SKILL.md +2 -2
  41. package/src/skf-create-skill/assets/skill-sections.md +1 -1
  42. package/src/skf-create-skill/references/extract.md +2 -1
  43. package/src/skf-create-skill/references/extraction-patterns.md +3 -3
  44. package/src/skf-create-skill/references/report.md +6 -1
  45. package/src/skf-create-stack-skill/SKILL.md +2 -2
  46. package/src/skf-create-stack-skill/references/validate.md +1 -1
  47. package/src/skf-drop-skill/SKILL.md +2 -2
  48. package/src/skf-export-skill/SKILL.md +2 -2
  49. package/src/skf-export-skill/assets/snippet-format.md +5 -5
  50. package/src/skf-export-skill/references/generate-snippet.md +22 -15
  51. package/src/skf-export-skill/references/load-skill.md +1 -1
  52. package/src/skf-export-skill/references/token-report.md +29 -9
  53. package/src/skf-forger/SKILL.md +2 -2
  54. package/src/skf-quick-skill/SKILL.md +2 -2
  55. package/src/skf-refine-architecture/SKILL.md +6 -8
  56. package/src/skf-rename-skill/SKILL.md +2 -2
  57. package/src/skf-setup/SKILL.md +2 -2
  58. package/src/skf-test-skill/SKILL.md +2 -2
  59. package/src/skf-test-skill/assets/output-section-formats.md +6 -4
  60. package/src/skf-test-skill/references/coherence-check.md +4 -3
  61. package/src/skf-test-skill/references/coverage-check-branches.md +61 -0
  62. package/src/skf-test-skill/references/coverage-check-tiers.md +1 -1
  63. package/src/skf-test-skill/references/coverage-check.md +45 -69
  64. package/src/skf-test-skill/references/init.md +2 -1
  65. package/src/skf-test-skill/references/migration-section-rules.md +26 -14
  66. package/src/skf-test-skill/references/report.md +2 -2
  67. package/src/skf-test-skill/references/scoring-rules.md +5 -4
  68. package/src/skf-test-skill/references/source-access-protocol.md +6 -6
  69. package/src/skf-test-skill/scripts/gap-ledger.py +378 -163
  70. package/src/skf-test-skill/scripts/load-coverage-inputs.py +171 -70
  71. package/src/skf-test-skill/scripts/locate-export-segments.py +101 -20
  72. package/src/skf-test-skill/scripts/reconcile-coverage.py +192 -39
  73. package/src/skf-test-skill/scripts/score-signatures.py +329 -54
  74. package/src/skf-test-skill/scripts/stage-helper-payload.py +64 -13
  75. package/src/skf-test-skill/scripts/validate-inventory.py +108 -9
  76. package/src/skf-test-skill/templates/test-report-template.md +1 -0
  77. package/src/skf-update-skill/SKILL.md +2 -2
  78. package/src/skf-update-skill/references/detect-changes.md +1 -1
  79. package/src/skf-update-skill/references/gap-driven.md +36 -21
  80. package/src/skf-update-skill/references/merge.md +15 -10
  81. package/src/skf-update-skill/references/re-extract.md +3 -1
  82. package/src/skf-update-skill/references/report.md +5 -4
  83. package/src/skf-update-skill/references/write.md +39 -18
  84. package/src/skf-verify-stack/SKILL.md +2 -2
  85. package/tools/cli/lib/tool-check.js +158 -2
@@ -23,11 +23,24 @@ Measured artifacts (all relative to the positional skill-package dir):
23
23
  extracted from the first --target-file that contains one
24
24
  (shared across the batch; measured once)
25
25
 
26
+ The managed_section object also gives `skills`, the number of skill rows (each
27
+ `[name v...]` row header) in the measured block, and `target_files`, every --target-file
28
+ that holds a block, in the order passed and each once. A target file that cannot be read
29
+ as UTF-8 text is skipped.
30
+
26
31
  package_total sums context-snippet.md + SKILL.md + metadata.json + references_total and
27
32
  DELIBERATELY EXCLUDES the managed-section row — the managed section is a shared all-skills
28
33
  cost reported separately, and including it would double-count this skill's own snippet
29
34
  (see references/token-report.md §1).
30
35
 
36
+ context_budget gives the token report's Context Budget Impact values, in tokens:
37
+ - always_on: the managed section (loaded in every session); null when no
38
+ target file holds a block
39
+ - on_trigger: SKILL.md (loaded when the skill triggers)
40
+ - full_disclosure: SKILL.md + references_total (loaded when every reference is read too);
41
+ neither the snippet nor metadata.json, so it is not package_total
42
+ - snippet: context-snippet.md (this skill's share of the managed section)
43
+
31
44
  CLI:
32
45
  python3 skf-count-tokens.py <skill-package-dir>
33
46
  python3 skf-count-tokens.py <skill-package-dir> --target-file CLAUDE.md
@@ -52,6 +65,13 @@ MANAGED_SECTION_RE = re.compile(
52
65
  re.DOTALL,
53
66
  )
54
67
 
68
+ # A skill row header of the managed section: `[name v<version>]` at the start of a line,
69
+ # optionally after the format's leading `|`, with or without a `root:` field. The
70
+ # ` v<version>` keeps the section's own `[SKF Skills]|{n} skills|{m} stack` header out.
71
+ # This is skf-rebuild-managed-sections.py's ROW_HEADER_PATTERN, so both scripts count the
72
+ # rows parse_managed_rows returns (test-skf-count-tokens.py keeps them in step).
73
+ MANAGED_ROW_RE = re.compile(r"^\|?\[(?P<name>[^\]]+?) v(?P<version>[^\]\s]+)\]", re.MULTILINE)
74
+
55
75
  # Core per-skill artifacts, in report order. (references/ is handled separately.)
56
76
  CORE_ARTIFACTS = [
57
77
  ("context-snippet.md", "context-snippet"),
@@ -87,6 +107,11 @@ def extract_managed_section(text: str) -> str | None:
87
107
  return m.group(0) if m else None
88
108
 
89
109
 
110
+ def count_managed_skills(section: str) -> int:
111
+ """The number of skill rows (`[name v...]` row headers) in a managed section."""
112
+ return len(MANAGED_ROW_RE.findall(section))
113
+
114
+
90
115
  def measure_reference_files(references_dir: Path) -> tuple[list[dict], dict]:
91
116
  """Measure every file under references/ (recursively, sorted). Returns (per-file rows, total)."""
92
117
  rows: list[dict] = []
@@ -144,20 +169,38 @@ def count_package(skill_dir: Path, target_files: list[Path] | None = None) -> di
144
169
  "tokens": sum(core_by_role[r]["tokens"] for r in core_by_role) + references_total["tokens"],
145
170
  }
146
171
 
147
- # Managed section — first --target-file that actually contains a block wins.
148
- managed_section = {"present": False, "source_file": None, "words": 0, "tokens": 0}
172
+ # Managed section: the first --target-file that actually contains a block is measured;
173
+ # target_files lists every one that holds a block.
174
+ managed_section = {"present": False, "source_file": None, "target_files": [], "skills": 0,
175
+ "words": 0, "tokens": 0}
176
+ seen: set[Path] = set()
149
177
  for tf in target_files:
150
178
  tf = Path(tf)
151
- if not tf.is_file():
179
+ if tf.resolve() in seen or not tf.is_file():
152
180
  continue
153
- section = extract_managed_section(_read_text(tf))
154
- if section is not None:
155
- managed_section = {
156
- "present": True,
157
- "source_file": tf.as_posix(),
181
+ seen.add(tf.resolve())
182
+ try:
183
+ section = extract_managed_section(_read_text(tf))
184
+ except (OSError, UnicodeDecodeError):
185
+ continue # unreadable or not UTF-8: it holds no block this helper can measure
186
+ if section is None:
187
+ continue
188
+ managed_section["target_files"].append(tf.as_posix())
189
+ if not managed_section["present"]:
190
+ managed_section.update(
191
+ present=True,
192
+ source_file=tf.as_posix(),
193
+ skills=count_managed_skills(section),
158
194
  **measure(section),
159
- }
160
- break
195
+ )
196
+
197
+ # The Context Budget Impact values token-report.md §2 renders.
198
+ context_budget = {
199
+ "always_on": managed_section["tokens"] if managed_section["present"] else None,
200
+ "on_trigger": core_by_role["skill-md"]["tokens"],
201
+ "full_disclosure": core_by_role["skill-md"]["tokens"] + references_total["tokens"],
202
+ "snippet": core_by_role["context-snippet"]["tokens"],
203
+ }
161
204
 
162
205
  return {
163
206
  "status": "ok",
@@ -166,6 +209,7 @@ def count_package(skill_dir: Path, target_files: list[Path] | None = None) -> di
166
209
  "references_total": references_total,
167
210
  "managed_section": managed_section,
168
211
  "package_total": package_total,
212
+ "context_budget": context_budget,
169
213
  }
170
214
 
171
215
 
@@ -160,6 +160,26 @@ skf-recommend-scope-type.py reads (registry.ts, components.ts and their .tsx
160
160
  forms, at any depth), found by that script's own rule (the sibling in this
161
161
  folder, which must sit beside this script).
162
162
 
163
+ Brief scope (scoped_tree)
164
+ -------------------------
165
+
166
+ scoped_tree(tree, excludes, glob_match) is the tree a skill brief's
167
+ scope.exclude globs leave, as workspace detection reads it (#780): a
168
+ workspace member counts only through the files the brief keeps. It holds
169
+ each file no exclude glob matches, but a manifest (a MEMBER_MANIFESTS name);
170
+ each root manifest (a file at the root named in MEMBER_MANIFESTS,
171
+ CONTENT_MANIFESTS or nx.json), always; and each member manifest (a
172
+ MEMBER_MANIFESTS name below the root) whose folder still holds, at any
173
+ depth, a non-manifest file no exclude glob matches, whether or not a glob
174
+ matches the manifest itself. A member manifest whose folder holds no
175
+ non-manifest file at all stays unless a glob matches it. So `rust/**`,
176
+ `rust/**/*.rs` or `rust/*/src/**` drops the members under rust/,
177
+ `**/Cargo.toml` alone drops none, and a workspace with no member left is
178
+ no workspace, while one with a member left still is. With no exclude glob
179
+ the tree is returned as given. Callers (test-skill's stage-helper-payload.py
180
+ and skf-extract-public-api.py's monorepo arm) pass the glob rule of
181
+ skf-resolve-authoritative-files.py, which this script does not load.
182
+
163
183
  Exit codes:
164
184
 
165
185
  0 success (regardless of is_monorepo value)
@@ -181,6 +201,7 @@ import posixpath
181
201
  import re
182
202
  import sys
183
203
  import tomllib
204
+ from collections.abc import Callable
184
205
  from pathlib import Path
185
206
  from typing import Optional
186
207
 
@@ -200,6 +221,11 @@ RECOGNISED_MANIFESTS = (
200
221
  # in the tree alone): --manifest-files lists them, --manifest-dir reads them,
201
222
  # and a warning names each one the tree lists that was not supplied.
202
223
  CONTENT_MANIFESTS = ("package.json", "pnpm-workspace.yaml", "lerna.json", "rush.json", "Cargo.toml")
224
+ # The manifest a workspace member is found by: a recognised one, or an Nx
225
+ # project's project.json. scoped_tree keeps one while its folder keeps a file.
226
+ MEMBER_MANIFESTS = RECOGNISED_MANIFESTS + ("project.json",)
227
+ # The root files scoped_tree keeps whatever the brief excludes.
228
+ ROOT_MANIFESTS = frozenset(MEMBER_MANIFESTS + CONTENT_MANIFESTS + ("nx.json",))
203
229
  MAX_MANIFEST_BYTES = 1024 * 1024
204
230
  # Folders a snapshot's module root is never followed down through (names
205
231
  # matched in lower case): tests, test helpers and fixtures, docs and sites,
@@ -698,6 +724,47 @@ def detect(payload: dict) -> dict:
698
724
  }
699
725
 
700
726
 
727
+ # --------------------------------------------------------------------------
728
+ # Brief scope
729
+ # --------------------------------------------------------------------------
730
+
731
+
732
+ def scoped_tree(tree: list[str], excludes: list[str], glob_match: Callable[[str, str], bool]) -> list[str]:
733
+ """The paths of `tree` workspace detection reads under a brief whose
734
+ scope.exclude globs are `excludes`, in their order: see "Brief scope" in
735
+ the module docstring. `glob_match(path, glob)` is the brief's glob rule."""
736
+ if not excludes:
737
+ return list(tree)
738
+
739
+ def manifest(path: str) -> bool:
740
+ return posixpath.basename(path) in MEMBER_MANIFESTS
741
+
742
+ excluded = {path for path in tree if any(glob_match(path, glob) for glob in excludes)}
743
+ holding: set[str] = set() # folders holding a non-manifest file
744
+ kept_holding: set[str] = set() # folders holding one no exclude glob matches
745
+ for path in tree:
746
+ if manifest(path):
747
+ continue
748
+ parts = path.split("/")
749
+ for depth in range(1, len(parts)):
750
+ folder = "/".join(parts[:depth])
751
+ holding.add(folder)
752
+ if path not in excluded:
753
+ kept_holding.add(folder)
754
+ kept = []
755
+ for path in tree:
756
+ if "/" not in path and path in ROOT_MANIFESTS:
757
+ keep = True
758
+ elif not manifest(path):
759
+ keep = path not in excluded
760
+ else:
761
+ folder = posixpath.dirname(path)
762
+ keep = folder in kept_holding or (folder not in holding and path not in excluded)
763
+ if keep:
764
+ kept.append(path)
765
+ return kept
766
+
767
+
701
768
  # --------------------------------------------------------------------------
702
769
  # Tree snapshot
703
770
  # --------------------------------------------------------------------------
@@ -423,11 +423,12 @@ def _compute_tool_deltas(current: dict, previous) -> tuple[list[str], list[str]]
423
423
  def _resolver_warning(payload: dict) -> list[str]:
424
424
  """The customization_resolver_unavailable warning, when the payload reports one.
425
425
 
426
- Every workflow's On Activation runs resolve_customization.py. When that
427
- script is missing or fails, the run falls back to the skill's own
428
- customize.toml, so the team and user overrides under `_bmad/custom/`
429
- silently do nothing; the payload key carries the resolver's reason so
430
- the envelope says so.
426
+ Every workflow's On Activation runs skf-resolve-customization.py, which
427
+ runs BMAD core's resolve_customization.py. When either script is missing
428
+ or fails, or a core before 6.11.0 would read another folder's overrides,
429
+ the run falls back to the skill's own customize.toml, so the team and
430
+ user overrides under `_bmad/custom/` silently do nothing; the payload
431
+ key carries the reason, whatever its words, so the envelope says so.
431
432
  """
432
433
  reason = payload.get("customization_resolver_unavailable")
433
434
  if not reason: