@codedrifters/configulator 0.0.274 → 0.0.276

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/lib/index.mjs CHANGED
@@ -936,7 +936,7 @@ var agendaBundle = {
936
936
  {
937
937
  name: "agenda:finalize",
938
938
  color: "BFDADC",
939
- description: "Phase 2: incorporate late-added items, register in the meetings index, cross-link related docs, and lock the agenda"
939
+ description: "Phase 2: register in meetings index, cross-link related docs, and lock the agenda before the meeting"
940
940
  }
941
941
  ]
942
942
  };
@@ -2783,442 +2783,6 @@ function assertValidProductContextPath(value) {
2783
2783
  }
2784
2784
  }
2785
2785
 
2786
- // src/agent/bundles/workflow-diagrams.ts
2787
- var DEFAULT_WORKFLOW_DIAGRAMS_ENABLED = true;
2788
- var DEFAULT_WORKFLOW_DIAGRAMS_PATH = "docs/src/content/docs/agents/workflows.md";
2789
- var DEFAULT_WORKFLOW_DIAGRAMS_BUNDLE_PATH_PATTERNS = [
2790
- "packages/@codedrifters/configulator/src/agent/bundles/**/*.ts",
2791
- ".claude/agents/**/*.md",
2792
- ".claude/skills/**/*.md"
2793
- ];
2794
- var DEFAULT_WORKFLOW_DIAGRAMS_EMIT_STARTER = false;
2795
- var DEFAULT_WORKFLOW_DIAGRAMS_EMIT_CHECKER = false;
2796
- var DEFAULT_WORKFLOW_DIAGRAMS_REQUIRE_UPDATE = true;
2797
- function resolveWorkflowDiagrams(config) {
2798
- const diagramsPath = config?.diagramsPath ?? DEFAULT_WORKFLOW_DIAGRAMS_PATH;
2799
- assertValidDiagramsPath(diagramsPath);
2800
- const bundlePathPatterns = config?.bundlePathPatterns ?? DEFAULT_WORKFLOW_DIAGRAMS_BUNDLE_PATH_PATTERNS;
2801
- assertValidBundlePathPatterns2(bundlePathPatterns);
2802
- return {
2803
- enabled: config?.enabled ?? DEFAULT_WORKFLOW_DIAGRAMS_ENABLED,
2804
- diagramsPath,
2805
- bundlePathPatterns,
2806
- emitStarterDiagram: config?.emitStarterDiagram ?? DEFAULT_WORKFLOW_DIAGRAMS_EMIT_STARTER,
2807
- emitChecker: config?.emitChecker ?? DEFAULT_WORKFLOW_DIAGRAMS_EMIT_CHECKER,
2808
- requireDiagramUpdate: config?.requireDiagramUpdate ?? DEFAULT_WORKFLOW_DIAGRAMS_REQUIRE_UPDATE
2809
- };
2810
- }
2811
- function validateWorkflowDiagramsConfig(config) {
2812
- return resolveWorkflowDiagrams(config);
2813
- }
2814
- function renderWorkflowDiagramsRuleContent(wd) {
2815
- if (!wd.enabled) {
2816
- return [
2817
- "# Workflow Diagrams",
2818
- "",
2819
- "**The workflow-diagrams convention is disabled in this project.**",
2820
- "Agents may change bundle or agent source files without updating",
2821
- "any diagrams page. When diagrams fall behind the prose, humans",
2822
- "must reconcile them manually.",
2823
- "",
2824
- "Enable the convention via",
2825
- "`AgentConfigOptions.workflowDiagrams.enabled = true`."
2826
- ].join("\n");
2827
- }
2828
- const requirementVerb = wd.requireDiagramUpdate ? "MUST" : "SHOULD";
2829
- const lines = [
2830
- "# Workflow Diagrams",
2831
- "",
2832
- "This project maintains a single hand-authored workflow-diagrams",
2833
- "page that visualises every agent's phases, its decision points,",
2834
- "and every cross-agent handoff. Prose scattered across rule files",
2835
- "and agent prompts describes each handoff in isolation; the",
2836
- "diagrams page is the single visual reference that shows the",
2837
- "whole pipeline at once.",
2838
- "",
2839
- "Diagrams are **hand-authored for readability**, not",
2840
- "auto-generated. A machine-generated graph of bundle dependencies",
2841
- "would technically stay in sync, but would not communicate the",
2842
- "intent behind each handoff \u2014 so the convention trades",
2843
- "auto-sync for editorial clarity and enforces sync via the rule",
2844
- "below.",
2845
- "",
2846
- "## Diagrams Page",
2847
- "",
2848
- `The workflow-diagrams page lives at \`${wd.diagramsPath}\`. It`,
2849
- "follows a stable structure so the sync rule can mechanically",
2850
- "identify which section matches which bundle:",
2851
- "",
2852
- "1. **Master cross-agent diagram** \u2014 one top-level Mermaid",
2853
- " flowchart showing every agent as a node and every",
2854
- " cross-agent issue-creation or file-consumption handoff as an",
2855
- " edge.",
2856
- "2. **One section per agent / bundle** \u2014 a `## N. <agent-name>`",
2857
- " heading followed by a single Mermaid `flowchart TD` diagram",
2858
- " that depicts the agent's phase graph (nodes = phases /",
2859
- " decisions, edges = transitions, styled end-nodes = commit /",
2860
- " PR / done terminals).",
2861
- "3. **Legend** \u2014 a short table mapping colours and arrow styles",
2862
- " to their meanings (dispatcher vs agent vs skill; solid vs",
2863
- " dashed arrows for issue-creation vs file-consumption).",
2864
- "",
2865
- "Each agent section is independent. Changing one agent's phase",
2866
- "graph touches only that section; cross-agent handoff changes",
2867
- "touch the master diagram plus any affected agent sections.",
2868
- "",
2869
- "## Diagram-Touched-When-Bundle-Touched Rule",
2870
- "",
2871
- `Every change that modifies a bundle's phase graph ${requirementVerb}`,
2872
- `also update \`${wd.diagramsPath}\` in the same change set. The`,
2873
- "rule applies when **any** staged file in a commit or PR matches",
2874
- "one of the bundle-path patterns below:",
2875
- "",
2876
- ...wd.bundlePathPatterns.map((p) => `- \`${p}\``),
2877
- "",
2878
- "Mechanically: when a change set includes a file matching one of",
2879
- `the patterns above, it ${requirementVerb} also include a`,
2880
- `modification to \`${wd.diagramsPath}\`.`,
2881
- "",
2882
- "### What counts as a phase-graph change",
2883
- "",
2884
- "The rule targets edits that change **what the agent does**, not",
2885
- "stylistic tweaks. Concretely:",
2886
- "",
2887
- "- Adding, removing, or renaming a phase label.",
2888
- "- Changing a phase's inputs, outputs, or decision branches.",
2889
- "- Adding or removing a cross-agent handoff (an issue-creation",
2890
- " or file-consumption edge between two bundles).",
2891
- "- Changing the sort order or priority logic that drives",
2892
- " dispatcher routing between tiers.",
2893
- "",
2894
- "Edits that do **not** require a diagram update:",
2895
- "",
2896
- "- Typo fixes, comment tweaks, wording polish in rule prose.",
2897
- "- Refactors that preserve the exact phase / handoff graph",
2898
- " (extracting a helper, renaming an internal variable,",
2899
- " reordering imports).",
2900
- "- Updates to supporting metadata (permissions lists, default",
2901
- " paths) that do not change the visible phase flow.",
2902
- "",
2903
- "When a change is borderline \u2014 the phase graph is unchanged but",
2904
- "the diagram's caption or annotation would be more accurate \u2014",
2905
- "err on the side of updating the diagram. The convention favours",
2906
- "over-updating over silent drift.",
2907
- "",
2908
- "## Authoring Checklist",
2909
- "",
2910
- "Authors and reviewers walk the following checklist before",
2911
- "merging any PR that touches a bundle path:",
2912
- "",
2913
- `1. **Did the phase graph change?** If yes, update \`${wd.diagramsPath}\``,
2914
- " in the same PR \u2014 both the affected agent section and, if the",
2915
- " change added or removed a cross-agent handoff, the master",
2916
- " diagram.",
2917
- "2. **Did the diagram render?** Preview the Mermaid block locally",
2918
- " (or via the docs site's dev server) and confirm it renders",
2919
- " without syntax errors.",
2920
- `3. **Is the section heading stable?** Each agent section uses a`,
2921
- " `## N. <agent-name>` heading where `<agent-name>` matches the",
2922
- " bundle name / agent prompt filename. Keep the headings stable",
2923
- " \u2014 downstream tooling may match on them.",
2924
- "4. **Does the legend still apply?** If a new arrow style or node",
2925
- " colour was introduced, document it in the legend.",
2926
- ""
2927
- ];
2928
- if (wd.emitChecker) {
2929
- lines.push(
2930
- "## Automated Check",
2931
- "",
2932
- `The bundled \`.claude/procedures/check-workflow-diagrams.sh\``,
2933
- "helper enforces the rule mechanically. Given a set of changed",
2934
- "files (as a newline-separated list on stdin, or positional",
2935
- `arguments), it fails non-zero when any file matches a`,
2936
- `bundle-path pattern and \`${wd.diagramsPath}\` is not also in`,
2937
- "the list. Wire it into a pre-commit hook or CI job as needed:",
2938
- "",
2939
- "```bash",
2940
- "# Pre-commit (staged files):",
2941
- "git diff --cached --name-only \\",
2942
- " | .claude/procedures/check-workflow-diagrams.sh",
2943
- "",
2944
- "# CI (branch-vs-base):",
2945
- "git diff --name-only origin/main...HEAD \\",
2946
- " | .claude/procedures/check-workflow-diagrams.sh",
2947
- "```",
2948
- "",
2949
- "The helper exits with a descriptive diagnostic on failure, so",
2950
- "it plugs directly into any hook framework without further",
2951
- "glue. It exits `0` when no bundle files were touched or when",
2952
- "the diagrams file is also present in the change set.",
2953
- ""
2954
- );
2955
- }
2956
- lines.push(
2957
- "## Out of Scope",
2958
- "",
2959
- "The convention intentionally does not:",
2960
- "",
2961
- "- Auto-generate the diagrams \u2014 readability is the point.",
2962
- "- Enforce a specific Mermaid sub-grammar beyond `flowchart TD`",
2963
- " for per-agent sections. Sequence diagrams, state diagrams, or",
2964
- " class diagrams are fine for bespoke sections as long as they",
2965
- " render.",
2966
- "- Gate every unrelated cleanup PR on a diagram touch. The rule",
2967
- " targets phase-graph-affecting edits; pure cleanups documented",
2968
- " as such are exempt."
2969
- );
2970
- return lines.join("\n");
2971
- }
2972
- function renderWorkflowDiagramsBundleHook(wd, bundleLabel) {
2973
- if (!wd.enabled) {
2974
- return "";
2975
- }
2976
- const verb = wd.requireDiagramUpdate ? "must" : "should";
2977
- return [
2978
- "## Workflow Diagram",
2979
- "",
2980
- `Every ${bundleLabel} change that modifies the phase graph,`,
2981
- "decision branches, or cross-agent handoffs documented by this",
2982
- `bundle ${verb} also update the matching section in`,
2983
- `\`${wd.diagramsPath}\` in the same PR. See the`,
2984
- "`workflow-diagrams-convention` rule for the full authoring",
2985
- "checklist, the path patterns the rule covers, and what counts",
2986
- "as a phase-graph change vs. a cosmetic edit."
2987
- ].join("\n");
2988
- }
2989
- function renderWorkflowDiagramsStarterPage(_wd) {
2990
- return [
2991
- "---",
2992
- "title: Agent Workflows",
2993
- "description: Hand-authored Mermaid diagrams for every agent pipeline and every cross-agent handoff.",
2994
- "---",
2995
- "",
2996
- "# Agent Workflows",
2997
- "",
2998
- "Each diagram shows every input, decision point, output path, and",
2999
- "downstream issue created by the agent. Solid arrows are issue-",
3000
- "creation handoffs; dashed arrows are file-consumption handoffs.",
3001
- "",
3002
- "Update this page in the same PR that changes a bundle's phase",
3003
- "graph \u2014 see the `workflow-diagrams-convention` rule for the full",
3004
- "contract.",
3005
- "",
3006
- "## Master Cross-Agent Diagram",
3007
- "",
3008
- "```mermaid",
3009
- "flowchart TB",
3010
- " %% Replace the placeholder below with the real agent ecosystem.",
3011
- " DISPATCHER[Dispatcher]",
3012
- " AGENT_A[Agent A]",
3013
- " AGENT_B[Agent B]",
3014
- " DISPATCHER --> AGENT_A",
3015
- " DISPATCHER --> AGENT_B",
3016
- " AGENT_A -->|issue-creation| AGENT_B",
3017
- " AGENT_B -.->|file-consumption| AGENT_A",
3018
- "```",
3019
- "",
3020
- "## 1. Example Agent",
3021
- "",
3022
- "```mermaid",
3023
- "flowchart TD",
3024
- " START([Session Start]) --> CLAIM[Claim issue]",
3025
- " CLAIM --> PHASE{Phase label?}",
3026
- " PHASE -->|phase:a| A1[Phase A work]",
3027
- " PHASE -->|phase:b| B1[Phase B work]",
3028
- " A1 --> COMMIT[Commit & PR]",
3029
- " B1 --> COMMIT",
3030
- " COMMIT --> STOP([Stop])",
3031
- " style STOP fill:#e8f5e9,stroke:#2e7d32",
3032
- "```",
3033
- "",
3034
- "## Legend",
3035
- "",
3036
- "| Style | Meaning |",
3037
- "|-------|---------|",
3038
- "| Solid arrow | Issue-creation handoff (agent A creates an issue for agent B) |",
3039
- "| Dashed arrow | File-consumption handoff (agent A reads files produced by agent B) |",
3040
- "| Green end-node | Terminal state (session complete) |"
3041
- ].join("\n");
3042
- }
3043
- function renderWorkflowDiagramsCheckerScript(wd) {
3044
- const patternsLiteral = wd.bundlePathPatterns.map((p) => ` ${JSON.stringify(p)}`).join("\n");
3045
- return [
3046
- "#!/usr/bin/env bash",
3047
- "# check-workflow-diagrams.sh \u2014 Enforce the diagram-touched-when-bundle-touched rule.",
3048
- "#",
3049
- "# Usage:",
3050
- "# .claude/procedures/check-workflow-diagrams.sh <file>...",
3051
- "# git diff --name-only HEAD | .claude/procedures/check-workflow-diagrams.sh",
3052
- "#",
3053
- "# Exits 0 when the workflow-diagrams page was touched alongside any",
3054
- "# bundle file in the change set, or when no bundle files were touched.",
3055
- "# Exits non-zero with a descriptive diagnostic on failure.",
3056
- "#",
3057
- "# The bundle-path patterns and diagrams path are rendered from the",
3058
- "# consumer's WorkflowDiagramsConfig at synth time \u2014 do not edit by",
3059
- "# hand; regenerate via `pnpm exec projen`.",
3060
- "#",
3061
- "# Patterns support the `**` recursive-segment wildcard even though",
3062
- "# bash's native `[[ $file == $glob ]]` pattern matching does not:",
3063
- "# each glob is converted to a POSIX-extended regex internally and",
3064
- "# matched with `=~`, so the script works uniformly on bash 3.2",
3065
- "# (macOS default) and bash 4+ (Linux / CI) without depending on",
3066
- "# `shopt -s globstar` (which only affects pathname expansion, not",
3067
- "# `[[ ]]` pattern matching).",
3068
- "",
3069
- "set -uo pipefail",
3070
- "",
3071
- "err() {",
3072
- ' printf "check-workflow-diagrams.sh: %s\\n" "$*" >&2',
3073
- "}",
3074
- "",
3075
- `diagrams_path=${JSON.stringify(wd.diagramsPath)}`,
3076
- "",
3077
- "# Bundle-path glob patterns. Translated to anchored POSIX-extended",
3078
- "# regexes at runtime by `glob_to_regex` below so `**` matches",
3079
- "# recursively across path segments.",
3080
- "bundle_patterns=(",
3081
- patternsLiteral,
3082
- ")",
3083
- "",
3084
- "# Convert a bash-style glob into an anchored POSIX-extended regex:",
3085
- "# **/ \u2192 (.+/)? (zero or more path segments plus trailing slash)",
3086
- "# ** \u2192 .* (anywhere, including `/`)",
3087
- "# * \u2192 [^/]* (single path segment)",
3088
- "# ? \u2192 [^/] (single non-slash char)",
3089
- "# Every other char is passed through, with regex metacharacters",
3090
- "# backslash-escaped so literal `.` / `+` / `(` etc. match themselves.",
3091
- "glob_to_regex() {",
3092
- ' local glob="$1"',
3093
- ' local regex=""',
3094
- " local i=0",
3095
- " local len=${#glob}",
3096
- " while (( i < len )); do",
3097
- ' local c="${glob:i:1}"',
3098
- ' if [[ "$c" == "*" ]]; then',
3099
- ' local next="${glob:i+1:1}"',
3100
- ' if [[ "$next" == "*" ]]; then',
3101
- " # `**` \u2014 recursive segment wildcard.",
3102
- ' local after="${glob:i+2:1}"',
3103
- ' if [[ "$after" == "/" ]]; then',
3104
- ' regex+="(.+/)?"',
3105
- " i=$(( i + 3 ))",
3106
- " else",
3107
- ' regex+=".*"',
3108
- " i=$(( i + 2 ))",
3109
- " fi",
3110
- " else",
3111
- ' regex+="[^/]*"',
3112
- " i=$(( i + 1 ))",
3113
- " fi",
3114
- ' elif [[ "$c" == "?" ]]; then',
3115
- ' regex+="[^/]"',
3116
- " i=$(( i + 1 ))",
3117
- " else",
3118
- ' case "$c" in',
3119
- " # Regex metacharacters \u2014 escape to match literally.",
3120
- " '.'|'+'|'^'|'$'|'('|')'|'{'|'}'|'|'|'['|']'|'\\\\')",
3121
- ' regex+="\\\\$c"',
3122
- " ;;",
3123
- " *)",
3124
- ' regex+="$c"',
3125
- " ;;",
3126
- " esac",
3127
- " i=$(( i + 1 ))",
3128
- " fi",
3129
- " done",
3130
- ' printf "^%s$" "$regex"',
3131
- "}",
3132
- "",
3133
- "# Collect the input file list: positional args override stdin.",
3134
- "if [[ $# -gt 0 ]]; then",
3135
- ' files=("$@")',
3136
- "else",
3137
- " files=()",
3138
- " while IFS= read -r line; do",
3139
- ' [[ -z "$line" ]] && continue',
3140
- ' files+=("$line")',
3141
- " done",
3142
- "fi",
3143
- "",
3144
- "if [[ ${#files[@]} -eq 0 ]]; then",
3145
- " # No input \u2014 nothing to check.",
3146
- " exit 0",
3147
- "fi",
3148
- "",
3149
- "# Precompile each bundle pattern to a regex once.",
3150
- "bundle_regexes=()",
3151
- 'for pattern in "${bundle_patterns[@]}"; do',
3152
- ' bundle_regexes+=("$(glob_to_regex "$pattern")")',
3153
- "done",
3154
- "",
3155
- "bundle_touched=0",
3156
- "matched_bundle=''",
3157
- "diagrams_touched=0",
3158
- "",
3159
- 'for file in "${files[@]}"; do',
3160
- ' if [[ "$file" == "$diagrams_path" ]]; then',
3161
- " diagrams_touched=1",
3162
- " continue",
3163
- " fi",
3164
- ' for regex in "${bundle_regexes[@]}"; do',
3165
- ' if [[ "$file" =~ $regex ]]; then',
3166
- " bundle_touched=1",
3167
- ' matched_bundle="$file"',
3168
- " break",
3169
- " fi",
3170
- " done",
3171
- "done",
3172
- "",
3173
- 'if [[ "$bundle_touched" -eq 1 && "$diagrams_touched" -eq 0 ]]; then',
3174
- ` err "bundle file '$matched_bundle' was modified but '$diagrams_path' was not"`,
3175
- ' err "update the workflow-diagrams page in the same change set (see workflow-diagrams-convention rule)"',
3176
- " exit 1",
3177
- "fi",
3178
- "",
3179
- "exit 0"
3180
- ].join("\n");
3181
- }
3182
- function assertValidDiagramsPath(value) {
3183
- if (typeof value !== "string" || value.trim().length === 0) {
3184
- throw new Error(
3185
- `WorkflowDiagramsConfig.diagramsPath must be a non-empty string; got ${JSON.stringify(
3186
- value
3187
- )}`
3188
- );
3189
- }
3190
- if (value.startsWith("/")) {
3191
- throw new Error(
3192
- `WorkflowDiagramsConfig.diagramsPath must be a repo-relative path (no leading '/'); got ${JSON.stringify(
3193
- value
3194
- )}`
3195
- );
3196
- }
3197
- }
3198
- function assertValidBundlePathPatterns2(value) {
3199
- if (!Array.isArray(value)) {
3200
- throw new Error(
3201
- `WorkflowDiagramsConfig.bundlePathPatterns must be an array; got ${JSON.stringify(
3202
- value
3203
- )}`
3204
- );
3205
- }
3206
- if (value.length === 0) {
3207
- throw new Error(
3208
- "WorkflowDiagramsConfig.bundlePathPatterns must not be empty \u2014 supply at least one pattern or omit the field to use the defaults"
3209
- );
3210
- }
3211
- for (const entry of value) {
3212
- if (typeof entry !== "string" || entry.trim().length === 0) {
3213
- throw new Error(
3214
- `WorkflowDiagramsConfig.bundlePathPatterns entries must be non-empty strings; got ${JSON.stringify(
3215
- entry
3216
- )}`
3217
- );
3218
- }
3219
- }
3220
- }
3221
-
3222
2786
  // src/agent/bundles/base.ts
3223
2787
  var createPackageSkill = {
3224
2788
  name: "create-package",
@@ -4296,16 +3860,6 @@ function buildBaseBundle(paths = DEFAULT_AGENT_PATHS) {
4296
3860
  },
4297
3861
  tags: ["workflow"]
4298
3862
  },
4299
- {
4300
- name: "workflow-diagrams-convention",
4301
- description: `Workflow-diagrams convention: hand-authored Mermaid page under \`${paths.docsRoot}/agents/workflows.md\` with one diagram per agent plus a master cross-agent diagram, and the diagram-touched-when-bundle-touched rule that keeps the page in sync with every phase-graph or cross-agent-handoff change.`,
4302
- scope: AGENT_RULE_SCOPE.ALWAYS,
4303
- content: renderWorkflowDiagramsRuleContent(resolveWorkflowDiagrams()),
4304
- platforms: {
4305
- cursor: { exclude: true }
4306
- },
4307
- tags: ["workflow"]
4308
- },
4309
3863
  {
4310
3864
  name: "issue-templates-convention",
4311
3865
  description: `Issue-templates convention: a single hand-authored reference page under \`${paths.docsRoot}/agents/issue-templates.md\` that carries one canonical \`gh issue create\` recipe per downstream phase label, and the reference-don't-inline rule that keeps bundle rules and agent prompts citing that page instead of duplicating full template invocations.`,
@@ -5045,12 +4599,12 @@ function buildBcmWriterBundle(paths = DEFAULT_AGENT_PATHS) {
5045
4599
  {
5046
4600
  name: "bcm:context",
5047
4601
  color: "D4C5F9",
5048
- description: "Phase 3: fill Project Relevance, Value Stream Mapping, Enabling Software Systems, Roles Involved, and Company Size Applicability"
4602
+ description: "Phase 3: fill Project Relevance, Value Stream Mapping, Software Systems, Roles, and Company Size"
5049
4603
  },
5050
4604
  {
5051
4605
  name: "bcm:connect",
5052
4606
  color: "FEF2C0",
5053
- description: "Phase 4: cross-link with parent/siblings, update registry and capability-map, open downstream research issues"
4607
+ description: "Phase 4: cross-link parent/siblings, update registry and capability-map, open downstream issues"
5054
4608
  }
5055
4609
  ]
5056
4610
  };
@@ -6045,7 +5599,7 @@ function buildBusinessModelsBundle(paths = DEFAULT_AGENT_PATHS) {
6045
5599
  {
6046
5600
  name: "type:business-model",
6047
5601
  color: "5319E7",
6048
- description: "Work that authors or updates a Business Model Canvas plus BIZBOK value streams for an industry segment"
5602
+ description: "Authors or updates a Business Model Canvas plus BIZBOK value streams for an industry segment"
6049
5603
  },
6050
5604
  {
6051
5605
  name: "business-models:scan",
@@ -8384,22 +7938,22 @@ function buildCustomerProfileBundle(paths = DEFAULT_AGENT_PATHS) {
8384
7938
  {
8385
7939
  name: "type:customer-profile",
8386
7940
  color: "5319E7",
8387
- description: "Work that researches a customer archetype: discovery across a scope, deep profile of one archetype, or feature-to-need competitor analysis for one archetype"
7941
+ description: "Researches a customer archetype: discovery, deep profile, or competitor analysis"
8388
7942
  },
8389
7943
  {
8390
7944
  name: "customer:discover",
8391
7945
  color: "C5DEF5",
8392
- description: "Phase 1: scan existing documentation for customer archetype candidates and write a discovery report; create downstream profile issues"
7946
+ description: "Phase 1: scan docs for archetype candidates, write discovery report, create profile issues"
8393
7947
  },
8394
7948
  {
8395
7949
  name: "customer:profile",
8396
7950
  color: "BFDADC",
8397
- description: "Phase 2: research one archetype in depth and populate the archetype page with segment, goals, jobs-to-be-done, constraints, buying process, and technology landscape"
7951
+ description: "Phase 2: deep-research one archetype: segment, goals, JTBD, constraints, buying process, tech"
8398
7952
  },
8399
7953
  {
8400
7954
  name: "customer:competitors",
8401
7955
  color: "D4C5F9",
8402
- description: "Phase 3: map shared feature-matrix rows to archetype needs, identify unmet needs, and hand off req:scan seeds to the requirements-analyst bundle"
7956
+ description: "Phase 3: map feature-matrix rows to archetype needs and hand off req:scan seeds"
8403
7957
  }
8404
7958
  ]
8405
7959
  };
@@ -8487,6 +8041,63 @@ function buildDocsSyncSubAgent(_paths) {
8487
8041
  "",
8488
8042
  "---",
8489
8043
  "",
8044
+ "## Phase 1: Scan",
8045
+ "",
8046
+ "Phase 1 walks the repo, runs every registered drift check, and",
8047
+ "writes a single combined **audit report** to disk. Phase 1 never",
8048
+ "edits documentation \u2014 only the persisted report changes between",
8049
+ "scan and fix.",
8050
+ "",
8051
+ "### Audit report",
8052
+ "",
8053
+ "The report shape is exported from `@codedrifters/configulator`",
8054
+ "as `AuditReport` (under `src/docs-sync/scan/`) so Phase 2 and",
8055
+ "any downstream consumers share one definition. Reports are",
8056
+ "persisted at:",
8057
+ "",
8058
+ "```",
8059
+ ".claude/state/docs-sync/<issue-number>-audit.json",
8060
+ "```",
8061
+ "",
8062
+ "Every report carries a `schemaVersion`, the `issueNumber`, the",
8063
+ "invocation `mode` (`pr` or `audit`), the `generatedAt` UTC",
8064
+ "timestamp, the `repoRoot`, and an optional `scope` label, plus",
8065
+ "two parallel views of the findings:",
8066
+ "",
8067
+ "- **`categories`** \u2014 findings grouped by drift-check category.",
8068
+ " Every category key is always present; empty arrays are",
8069
+ " persisted explicitly. The five categories are `apiDiff`,",
8070
+ " `tsdocCoverage`, `referenceMismatches`, `linkFailures`, and",
8071
+ " `sampleFailures`.",
8072
+ "- **`findings`** \u2014 the same records re-aggregated as a single",
8073
+ " flat array, sorted by severity (`blocking` first), then",
8074
+ " category, file, line, and subject. Provided so consumers",
8075
+ " that don't need the category grouping can iterate one array",
8076
+ " and see the merge-blocking findings at the top.",
8077
+ "",
8078
+ "Every finding carries a `category`, `severity`",
8079
+ "(`mechanical` / `advisory` / `blocking`), `location`, `subject`,",
8080
+ "`details`, and an optional `fixHint` for the Phase 2 fix agent.",
8081
+ "",
8082
+ "### Orchestrator",
8083
+ "",
8084
+ "The scan is driven by `runScan(...)` (also exported under",
8085
+ "`src/docs-sync/scan/`). The orchestrator accepts a list of",
8086
+ "`AuditCheckRunner` instances, invokes each one in registration",
8087
+ "order, merges the findings into the report, and (optionally)",
8088
+ "persists the report to disk. The default check list is empty \u2014",
8089
+ "this skeleton release runs cleanly with no checks registered",
8090
+ "and produces a schema-compliant report whose category arrays",
8091
+ "are all empty.",
8092
+ "",
8093
+ "Children of the parent docs-sync epic plug runners into the",
8094
+ "orchestrator: API/TSDoc/reference checks land first, link",
8095
+ "and fenced-sample checks land second, the fix phase reads the",
8096
+ "persisted report, and the audit-mode walker reuses the same",
8097
+ "report shape.",
8098
+ "",
8099
+ "---",
8100
+ "",
8490
8101
  "## Write Boundaries",
8491
8102
  "",
8492
8103
  "Even once the pipeline is wired, the following boundaries are",
@@ -9209,22 +8820,22 @@ function buildDocsSyncBundle(paths = DEFAULT_AGENT_PATHS) {
9209
8820
  {
9210
8821
  name: "docs-sync:scan",
9211
8822
  color: "C5DEF5",
9212
- description: "Phase 1: scan code and docs for drift (API diff, TSDoc coverage, reference integrity, link integrity, code-sample compilation)"
8823
+ description: "Phase 1: scan for drift (API diff, TSDoc coverage, references, links, sample compilation)"
9213
8824
  },
9214
8825
  {
9215
8826
  name: "docs-sync:fix",
9216
8827
  color: "BFDADC",
9217
- description: "Phase 2: apply mechanical idempotent fixes (TSDoc stubs, dead-link updates, registry sync, rename-follow) and file docs:write follow-ups for conceptual changes"
8828
+ description: "Phase 2: apply mechanical fixes and file docs:write follow-ups for conceptual changes"
9218
8829
  },
9219
8830
  {
9220
8831
  name: "docs-sync:advisory",
9221
8832
  color: "FBCA04",
9222
- description: "Drift detected by docs-sync but does not block the PR; surfaced as a non-blocking note on the sticky comment"
8833
+ description: "Drift detected by docs-sync but does not block the PR; surfaced as a sticky-comment note"
9223
8834
  },
9224
8835
  {
9225
8836
  name: "docs-sync:blocking",
9226
8837
  color: "B60205",
9227
- description: "Drift detected by docs-sync blocks the PR; applied together with review:human-required so pr-reviewer owns the merge gate"
8838
+ description: "Drift blocks the PR; applied with review:human-required so pr-reviewer owns the merge gate"
9228
8839
  }
9229
8840
  ]
9230
8841
  };
@@ -10819,7 +10430,7 @@ function buildMaintenanceAuditBundle(paths = DEFAULT_AGENT_PATHS) {
10819
10430
  {
10820
10431
  name: "maint:verify",
10821
10432
  color: "D4C5F9",
10822
- description: "Phase 3: re-run the scan checks scoped to the paths the fix phase touched, compare pre/post findings, and close or re-queue the parent scan"
10433
+ description: "Phase 3: re-run scan checks scoped to fix-phase paths, compare findings, close or re-queue scan"
10823
10434
  }
10824
10435
  ]
10825
10436
  };
@@ -15358,7 +14969,7 @@ function buildPeopleProfileBundle(paths = DEFAULT_AGENT_PATHS) {
15358
14969
  {
15359
14970
  name: "people:followup",
15360
14971
  color: "D4C5F9",
15361
- description: "Phase 3: cross-link the profile to existing companies, software, and meeting notes, and enqueue follow-up research issues for unprofiled companies and software products"
14972
+ description: "Phase 3: cross-link profile to companies/software/meetings; enqueue follow-up research issues"
15362
14973
  },
15363
14974
  {
15364
14975
  name: "people:refresh",
@@ -18158,22 +17769,22 @@ function buildRegulatoryResearchBundle(paths = DEFAULT_AGENT_PATHS) {
18158
17769
  {
18159
17770
  name: "type:regulatory-research",
18160
17771
  color: "5319E7",
18161
- description: "Work that researches a regulatory compliance obligation: scan of a jurisdictional landscape, deep-dive on one regulation, or impact analysis against the consuming project"
17772
+ description: "Researches a regulatory obligation: jurisdictional scan, deep-dive, or impact analysis"
18162
17773
  },
18163
17774
  {
18164
17775
  name: "regulatory:scan",
18165
17776
  color: "C5DEF5",
18166
- description: "Phase 1: enumerate regulations applicable to an industry, jurisdiction, or platform scope; write a scan report; create downstream research issues"
17777
+ description: "Phase 1: enumerate regulations for an industry/jurisdiction/scope; create research issues"
18167
17778
  },
18168
17779
  {
18169
17780
  name: "regulatory:research",
18170
17781
  color: "BFDADC",
18171
- description: "Phase 2: research one regulation in depth and populate the regulation page with scope, triggers, requirements, jurisdiction variations, enforcement, and penalties"
17782
+ description: "Phase 2: research one regulation in depth (scope, triggers, requirements, enforcement)"
18172
17783
  },
18173
17784
  {
18174
17785
  name: "regulatory:impact",
18175
17786
  color: "D4C5F9",
18176
- description: "Phase 3: assess product impact against one regulation and hand off actionable obligations as SEC req:scan seeds to the requirements-analyst bundle"
17787
+ description: "Phase 3: assess product impact and hand off SEC req:scan seeds to requirements-analyst"
18177
17788
  }
18178
17789
  ]
18179
17790
  };
@@ -21450,7 +21061,7 @@ function buildRequirementsWriterBundle(paths = DEFAULT_AGENT_PATHS) {
21450
21061
  {
21451
21062
  name: "tier:customer-workflow",
21452
21063
  color: "EDEDED",
21453
- description: "Architectural tier: customer-configured workflow (business logic tenants configure within the platform)"
21064
+ description: "Architectural tier: customer-configured workflow (business logic tenants configure)"
21454
21065
  },
21455
21066
  {
21456
21067
  name: "tier:consumer-app",
@@ -22850,7 +22461,7 @@ function buildRequirementsReviewerBundle(paths = DEFAULT_AGENT_PATHS) {
22850
22461
  {
22851
22462
  name: "req:deprecate",
22852
22463
  color: "D93F0B",
22853
- description: "Phase: transition existing requirement documents to Deprecated or Superseded using the requirements-reviewer skill"
22464
+ description: "Phase: transition requirement docs to Deprecated/Superseded via the requirements-reviewer"
22854
22465
  }
22855
22466
  ]
22856
22467
  };
@@ -24504,7 +24115,7 @@ function buildSoftwareProfileBundle(paths = DEFAULT_AGENT_PATHS) {
24504
24115
  {
24505
24116
  name: "type:software-profile",
24506
24117
  color: "0E8A16",
24507
- description: "Work that produces or maintains a software profile, research notes, feature-matrix rows, or capability mappings"
24118
+ description: "Produces a software profile, research notes, feature-matrix rows, or capability mappings"
24508
24119
  },
24509
24120
  {
24510
24121
  name: "software:research",
@@ -24524,12 +24135,12 @@ function buildSoftwareProfileBundle(paths = DEFAULT_AGENT_PATHS) {
24524
24135
  {
24525
24136
  name: "software:map",
24526
24137
  color: "A2EEEF",
24527
- description: "Phase 4: map each feature back to the BCM capability model, write the mapping onto the profile, and enqueue `bcm:outline` issues for unmapped features above the configured threshold"
24138
+ description: "Phase 4: map features to the BCM model and enqueue bcm:outline issues for unmapped features"
24528
24139
  },
24529
24140
  {
24530
24141
  name: "software:followup",
24531
24142
  color: "FBCA04",
24532
- description: "Phase 5: enqueue follow-up research issues for adjacent products, the vendor company, and primary-attribution people surfaced in the profile"
24143
+ description: "Phase 5: enqueue follow-up research for adjacent products, vendor company, and key people"
24533
24144
  }
24534
24145
  ]
24535
24146
  };
@@ -25856,32 +25467,32 @@ function buildStandardsResearchBundle(paths = DEFAULT_AGENT_PATHS) {
25856
25467
  {
25857
25468
  name: "type:standards-research",
25858
25469
  color: "5319E7",
25859
- description: "Work that researches an interoperability standard: version research, cross-version comparison, extension analysis, or standards-body organization profiling"
25470
+ description: "Researches an interoperability standard: versions, comparison, extension, or org profile"
25860
25471
  },
25861
25472
  {
25862
25473
  name: "standards:scope",
25863
25474
  color: "C5DEF5",
25864
- description: "Phase 1: plan the research campaign for one standard; write the query plan; create downstream research, compare, and organizations issues"
25475
+ description: "Phase 1: plan a standard's research campaign; write query plan; create downstream issues"
25865
25476
  },
25866
25477
  {
25867
25478
  name: "standards:research",
25868
25479
  color: "BFDADC",
25869
- description: "Phase 2: research one version of the standard and populate the version page with status, key changes, resources, adoption, and governance touch-points"
25480
+ description: "Phase 2: research one version (status, key changes, resources, adoption, governance)"
25870
25481
  },
25871
25482
  {
25872
25483
  name: "standards:compare",
25873
25484
  color: "D4C5F9",
25874
- description: "Phase 3: synthesize a cross-version comparison on the standard's overview page \u2014 version timeline, maturity progression, breaking changes, migration paths"
25485
+ description: "Phase 3: synthesize cross-version comparison: timeline, maturity, breaking changes, migration"
25875
25486
  },
25876
25487
  {
25877
25488
  name: "standards:extension",
25878
25489
  color: "FBCA04",
25879
- description: "Phase 4: analyze the extension mechanism needed for one domain entity whose base-spec mapping is Partial or Gap; hand off a Proposed ADR to the requirements pipeline"
25490
+ description: "Phase 4: analyze extension for one Partial/Gap entity; hand off Proposed ADR to requirements"
25880
25491
  },
25881
25492
  {
25882
25493
  name: "standards:organizations",
25883
25494
  color: "0E8A16",
25884
- description: "Phase 5: profile one standards-body organization's role in the standard; hand off canonical company and people profiles to the profile bundles"
25495
+ description: "Phase 5: profile one standards-body organization; hand off company/people profile issues"
25885
25496
  }
25886
25497
  ]
25887
25498
  };
@@ -26943,8 +26554,8 @@ var FALLBACKS = {
26943
26554
  monorepoLayoutSeedBlock: ""
26944
26555
  };
26945
26556
  var TEMPLATE_RE = /\{\{(\w+(?:\.\w+)*)\}\}/g;
26946
- function getNestedValue(obj, path6) {
26947
- const parts = path6.split(".");
26557
+ function getNestedValue(obj, path7) {
26558
+ const parts = path7.split(".");
26948
26559
  let current = obj;
26949
26560
  for (const part of parts) {
26950
26561
  if (current == null || typeof current !== "object") {
@@ -27170,20 +26781,20 @@ var ClaudeRenderer = class _ClaudeRenderer {
27170
26781
  obj.excludedCommands = [...sandbox.excludedCommands];
27171
26782
  }
27172
26783
  if (sandbox.filesystem) {
27173
- const fs3 = {};
26784
+ const fs4 = {};
27174
26785
  if (sandbox.filesystem.allowRead?.length) {
27175
- fs3.allowRead = [...sandbox.filesystem.allowRead];
26786
+ fs4.allowRead = [...sandbox.filesystem.allowRead];
27176
26787
  }
27177
26788
  if (sandbox.filesystem.denyRead?.length) {
27178
- fs3.denyRead = [...sandbox.filesystem.denyRead];
26789
+ fs4.denyRead = [...sandbox.filesystem.denyRead];
27179
26790
  }
27180
26791
  if (sandbox.filesystem.allowWrite?.length) {
27181
- fs3.allowWrite = [...sandbox.filesystem.allowWrite];
26792
+ fs4.allowWrite = [...sandbox.filesystem.allowWrite];
27182
26793
  }
27183
26794
  if (sandbox.filesystem.denyWrite?.length) {
27184
- fs3.denyWrite = [...sandbox.filesystem.denyWrite];
26795
+ fs4.denyWrite = [...sandbox.filesystem.denyWrite];
27185
26796
  }
27186
- if (Object.keys(fs3).length > 0) obj.filesystem = fs3;
26797
+ if (Object.keys(fs4).length > 0) obj.filesystem = fs4;
27187
26798
  }
27188
26799
  if (sandbox.network) {
27189
26800
  const net = {};
@@ -27639,26 +27250,6 @@ var SKILL_EVALS_BUNDLE_HOOKS = [
27639
27250
  ["requirements-analyst-workflow", "requirements-analyst"],
27640
27251
  ["requirements-writer-workflow", "write-requirement"]
27641
27252
  ];
27642
- var WORKFLOW_DIAGRAMS_BUNDLE_HOOKS = [
27643
- ["bcm-writer-workflow", "bcm-writer"],
27644
- ["business-models-workflow", "business-models"],
27645
- ["company-profile-workflow", "company-profile"],
27646
- ["customer-profile-workflow", "customer-profile"],
27647
- ["industry-discovery-workflow", "industry-discovery"],
27648
- ["maintenance-audit-workflow", "maintenance-audit"],
27649
- ["meeting-agenda-workflow", "agenda"],
27650
- ["meeting-processing-workflow", "meeting-analysis"],
27651
- ["orchestrator-conventions", "orchestrator"],
27652
- ["people-profile-workflow", "people-profile"],
27653
- ["pr-review-workflow", "pr-review"],
27654
- ["regulatory-research-workflow", "regulatory-research"],
27655
- ["requirements-analyst-workflow", "requirements-analyst"],
27656
- ["requirements-reviewer-workflow", "requirements-reviewer"],
27657
- ["requirements-writer-workflow", "requirements-writer"],
27658
- ["research-pipeline-workflow", "research-pipeline"],
27659
- ["software-profile-workflow", "software-profile"],
27660
- ["standards-research-workflow", "standards-research"]
27661
- ];
27662
27253
  var ISSUE_TEMPLATES_BUNDLE_HOOKS = [
27663
27254
  ["bcm-writer-workflow", "bcm-writer"],
27664
27255
  ["business-models-workflow", "business-models"],
@@ -27830,24 +27421,6 @@ var AgentConfig = class _AgentConfig extends Component8 {
27830
27421
  executable: true
27831
27422
  });
27832
27423
  }
27833
- const resolvedWorkflowDiagrams = validateWorkflowDiagramsConfig(
27834
- this.options.workflowDiagrams
27835
- );
27836
- if (resolvedWorkflowDiagrams.enabled) {
27837
- if (resolvedWorkflowDiagrams.emitChecker) {
27838
- new TextFile4(this, ".claude/procedures/check-workflow-diagrams.sh", {
27839
- lines: renderWorkflowDiagramsCheckerScript(
27840
- resolvedWorkflowDiagrams
27841
- ).split("\n"),
27842
- executable: true
27843
- });
27844
- }
27845
- if (resolvedWorkflowDiagrams.emitStarterDiagram) {
27846
- new SampleFile(this.project, resolvedWorkflowDiagrams.diagramsPath, {
27847
- contents: renderWorkflowDiagramsStarterPage(resolvedWorkflowDiagrams)
27848
- });
27849
- }
27850
- }
27851
27424
  const resolvedIssueTemplates = validateIssueTemplatesConfig(
27852
27425
  this.options.issueTemplates
27853
27426
  );
@@ -28160,46 +27733,6 @@ ${hook}`
28160
27733
 
28161
27734
  ---
28162
27735
 
28163
- ${hook}`
28164
- });
28165
- }
28166
- }
28167
- const resolvedWorkflowDiagramsForRules = resolveWorkflowDiagrams(
28168
- this.options.workflowDiagrams
28169
- );
28170
- if (this.options.workflowDiagrams) {
28171
- const workflowDiagramsRule = ruleMap.get("workflow-diagrams-convention");
28172
- if (workflowDiagramsRule) {
28173
- const workflowDiagramsContent = renderWorkflowDiagramsRuleContent(
28174
- resolvedWorkflowDiagramsForRules
28175
- );
28176
- if (workflowDiagramsContent !== workflowDiagramsRule.content) {
28177
- ruleMap.set("workflow-diagrams-convention", {
28178
- ...workflowDiagramsRule,
28179
- content: workflowDiagramsContent
28180
- });
28181
- }
28182
- }
28183
- }
28184
- if (resolvedWorkflowDiagramsForRules.enabled) {
28185
- for (const [ruleName, label] of WORKFLOW_DIAGRAMS_BUNDLE_HOOKS) {
28186
- const existing = ruleMap.get(ruleName);
28187
- if (!existing) {
28188
- continue;
28189
- }
28190
- const hook = renderWorkflowDiagramsBundleHook(
28191
- resolvedWorkflowDiagramsForRules,
28192
- label
28193
- );
28194
- if (hook.length === 0) {
28195
- continue;
28196
- }
28197
- ruleMap.set(ruleName, {
28198
- ...existing,
28199
- content: `${existing.content}
28200
-
28201
- ---
28202
-
28203
27736
  ${hook}`
28204
27737
  });
28205
27738
  }
@@ -29392,8 +28925,405 @@ function formatDiagnostic(d) {
29392
28925
  return `${code}${text}`.trim();
29393
28926
  }
29394
28927
 
29395
- // src/docs-sync/tsdoc-coverage/coverage.ts
28928
+ // src/docs-sync/scan/audit-report.ts
28929
+ var AuditCategory = {
28930
+ /**
28931
+ * Findings produced by the public-API diff check that surfaces
28932
+ * added, renamed, or removed exports between the current branch
28933
+ * and the recorded baseline. Wired in by child issue #519.
28934
+ */
28935
+ ApiDiff: "apiDiff",
28936
+ /**
28937
+ * Findings produced by the TSDoc-coverage check that flags public
28938
+ * exports without a one-sentence summary. Wired in by child issue
28939
+ * #519.
28940
+ */
28941
+ TsdocCoverage: "tsdocCoverage",
28942
+ /**
28943
+ * Findings produced by the doc-reference cross-index check that
28944
+ * flags inline-code symbol mentions whose target is missing or
28945
+ * has changed. Wired in by child issue #519.
28946
+ */
28947
+ ReferenceMismatches: "referenceMismatches",
28948
+ /**
28949
+ * Findings produced by the link-integrity check (internal via
28950
+ * `astro check`, external via `lychee`). Wired in by child issue
28951
+ * #520.
28952
+ */
28953
+ LinkFailures: "linkFailures",
28954
+ /**
28955
+ * Findings produced by the fenced-sample compilation check that
28956
+ * flags ` ```ts ` / ` ```typescript ` / ` ```tsx ` blocks in the
28957
+ * docs that fail `tsc`. Wired in by child issue #520.
28958
+ */
28959
+ SampleFailures: "sampleFailures"
28960
+ };
28961
+ var AuditSeverity = {
28962
+ /**
28963
+ * The finding has a deterministic mechanical fix that the Phase 2
28964
+ * (Fix) agent will auto-apply (TSDoc stubs, dead-link updates,
28965
+ * registry sync, etc.).
28966
+ */
28967
+ Mechanical: "mechanical",
28968
+ /**
28969
+ * The finding deserves human attention but does not block the PR.
28970
+ * Surfaced as a non-blocking note on the sticky `## Docs sync`
28971
+ * comment.
28972
+ */
28973
+ Advisory: "advisory",
28974
+ /**
28975
+ * The finding blocks the PR. Per the parent epic this is reserved
28976
+ * for the two narrow cases of confirmed broken external links and
28977
+ * fenced TS samples that fail to compile.
28978
+ */
28979
+ Blocking: "blocking"
28980
+ };
28981
+ var AuditMode = {
28982
+ Pr: "pr",
28983
+ Audit: "audit"
28984
+ };
28985
+ var DOCS_SYNC_AUDIT_SCHEMA_VERSION = 1;
28986
+ function auditReportJsonSchema() {
28987
+ const locationSchema = {
28988
+ type: "object",
28989
+ additionalProperties: false,
28990
+ required: ["file", "line"],
28991
+ properties: {
28992
+ file: { type: "string" },
28993
+ line: { type: "integer", minimum: 0 }
28994
+ }
28995
+ };
28996
+ const findingBaseProperties = {
28997
+ severity: { type: "string", enum: ["mechanical", "advisory", "blocking"] },
28998
+ location: locationSchema,
28999
+ subject: { type: "string" },
29000
+ details: { type: "string" },
29001
+ fixHint: { type: "string" }
29002
+ };
29003
+ const apiDiffFindingSchema = {
29004
+ type: "object",
29005
+ required: [
29006
+ "category",
29007
+ "severity",
29008
+ "location",
29009
+ "subject",
29010
+ "details",
29011
+ "change",
29012
+ "symbol"
29013
+ ],
29014
+ properties: {
29015
+ ...findingBaseProperties,
29016
+ category: { type: "string", const: "apiDiff" },
29017
+ change: { type: "string", enum: ["added", "removed", "changed"] },
29018
+ symbol: { type: "string" }
29019
+ }
29020
+ };
29021
+ const tsdocCoverageFindingSchema = {
29022
+ type: "object",
29023
+ required: [
29024
+ "category",
29025
+ "severity",
29026
+ "location",
29027
+ "subject",
29028
+ "details",
29029
+ "shortfall",
29030
+ "symbol"
29031
+ ],
29032
+ properties: {
29033
+ ...findingBaseProperties,
29034
+ category: { type: "string", const: "tsdocCoverage" },
29035
+ shortfall: {
29036
+ type: "string",
29037
+ enum: [
29038
+ "missing-summary",
29039
+ "thin-summary",
29040
+ "missing-params",
29041
+ "missing-returns"
29042
+ ]
29043
+ },
29044
+ symbol: { type: "string" }
29045
+ }
29046
+ };
29047
+ const referenceMismatchFindingSchema = {
29048
+ type: "object",
29049
+ required: [
29050
+ "category",
29051
+ "severity",
29052
+ "location",
29053
+ "subject",
29054
+ "details",
29055
+ "mismatch",
29056
+ "symbol"
29057
+ ],
29058
+ properties: {
29059
+ ...findingBaseProperties,
29060
+ category: { type: "string", const: "referenceMismatches" },
29061
+ mismatch: {
29062
+ type: "string",
29063
+ enum: ["unknown-symbol", "signature-changed"]
29064
+ },
29065
+ symbol: { type: "string" }
29066
+ }
29067
+ };
29068
+ const linkFailureFindingSchema = {
29069
+ type: "object",
29070
+ required: [
29071
+ "category",
29072
+ "severity",
29073
+ "location",
29074
+ "subject",
29075
+ "details",
29076
+ "url",
29077
+ "kind",
29078
+ "reason"
29079
+ ],
29080
+ properties: {
29081
+ ...findingBaseProperties,
29082
+ category: { type: "string", const: "linkFailures" },
29083
+ url: { type: "string" },
29084
+ kind: { type: "string", enum: ["internal", "external"] },
29085
+ reason: { type: "string" }
29086
+ }
29087
+ };
29088
+ const sampleFailureFindingSchema = {
29089
+ type: "object",
29090
+ required: [
29091
+ "category",
29092
+ "severity",
29093
+ "location",
29094
+ "subject",
29095
+ "details",
29096
+ "fenceIndex",
29097
+ "lang",
29098
+ "diagnostics"
29099
+ ],
29100
+ properties: {
29101
+ ...findingBaseProperties,
29102
+ category: { type: "string", const: "sampleFailures" },
29103
+ fenceIndex: { type: "integer", minimum: 0 },
29104
+ lang: { type: "string" },
29105
+ diagnostics: { type: "array", items: { type: "string" } }
29106
+ }
29107
+ };
29108
+ return {
29109
+ $schema: "http://json-schema.org/draft-07/schema#",
29110
+ title: "DocsSyncAuditReport",
29111
+ type: "object",
29112
+ additionalProperties: false,
29113
+ required: [
29114
+ "schemaVersion",
29115
+ "issueNumber",
29116
+ "mode",
29117
+ "generatedAt",
29118
+ "repoRoot",
29119
+ "scope",
29120
+ "categories",
29121
+ "findings"
29122
+ ],
29123
+ properties: {
29124
+ schemaVersion: { type: "integer", const: DOCS_SYNC_AUDIT_SCHEMA_VERSION },
29125
+ issueNumber: { type: "integer", minimum: 0 },
29126
+ mode: { type: "string", enum: ["pr", "audit"] },
29127
+ generatedAt: { type: "string", format: "date-time" },
29128
+ repoRoot: { type: "string" },
29129
+ scope: { type: "string" },
29130
+ categories: {
29131
+ type: "object",
29132
+ additionalProperties: false,
29133
+ required: [
29134
+ "apiDiff",
29135
+ "tsdocCoverage",
29136
+ "referenceMismatches",
29137
+ "linkFailures",
29138
+ "sampleFailures"
29139
+ ],
29140
+ properties: {
29141
+ apiDiff: { type: "array", items: apiDiffFindingSchema },
29142
+ tsdocCoverage: { type: "array", items: tsdocCoverageFindingSchema },
29143
+ referenceMismatches: {
29144
+ type: "array",
29145
+ items: referenceMismatchFindingSchema
29146
+ },
29147
+ linkFailures: { type: "array", items: linkFailureFindingSchema },
29148
+ sampleFailures: { type: "array", items: sampleFailureFindingSchema }
29149
+ }
29150
+ },
29151
+ findings: {
29152
+ type: "array",
29153
+ items: {
29154
+ oneOf: [
29155
+ apiDiffFindingSchema,
29156
+ tsdocCoverageFindingSchema,
29157
+ referenceMismatchFindingSchema,
29158
+ linkFailureFindingSchema,
29159
+ sampleFailureFindingSchema
29160
+ ]
29161
+ }
29162
+ }
29163
+ }
29164
+ };
29165
+ }
29166
+
29167
+ // src/docs-sync/scan/run-scan.ts
29168
+ import * as fs3 from "fs";
29396
29169
  import * as path5 from "path";
29170
+ var DEFAULT_AUDIT_REPORT_DIR = ".claude/state/docs-sync";
29171
+ var SEVERITY_RANK = {
29172
+ blocking: 0,
29173
+ advisory: 1,
29174
+ mechanical: 2
29175
+ };
29176
+ var AUDIT_CATEGORY_ORDER = [
29177
+ AuditCategory.ApiDiff,
29178
+ AuditCategory.TsdocCoverage,
29179
+ AuditCategory.ReferenceMismatches,
29180
+ AuditCategory.LinkFailures,
29181
+ AuditCategory.SampleFailures
29182
+ ];
29183
+ function runScan(options) {
29184
+ const repoRoot = path5.resolve(options.repoRoot);
29185
+ const mode = options.mode;
29186
+ const scope = options.scope ?? "";
29187
+ const issueNumber = options.issueNumber;
29188
+ const checks = options.checks ?? [];
29189
+ const now = options.now ?? /* @__PURE__ */ new Date();
29190
+ const persist = options.persist ?? false;
29191
+ const reportDir = options.reportDir ?? DEFAULT_AUDIT_REPORT_DIR;
29192
+ const context = {
29193
+ repoRoot,
29194
+ mode,
29195
+ scope,
29196
+ issueNumber
29197
+ };
29198
+ const collected = [];
29199
+ for (const check of checks) {
29200
+ const result = check.run(context);
29201
+ for (const finding of result) {
29202
+ collected.push(finding);
29203
+ }
29204
+ }
29205
+ const report = buildReport({
29206
+ issueNumber,
29207
+ mode,
29208
+ scope,
29209
+ repoRoot,
29210
+ generatedAt: now,
29211
+ findings: collected
29212
+ });
29213
+ let reportPath = "";
29214
+ if (persist) {
29215
+ reportPath = persistAuditReport({
29216
+ report,
29217
+ repoRoot,
29218
+ reportDir
29219
+ });
29220
+ }
29221
+ return { report, reportPath };
29222
+ }
29223
+ function buildReport(args) {
29224
+ const buckets = emptyCategoryBuckets();
29225
+ for (const finding of args.findings) {
29226
+ pushIntoBucket(buckets, finding);
29227
+ }
29228
+ buckets.apiDiff.sort(compareFindings);
29229
+ buckets.tsdocCoverage.sort(compareFindings);
29230
+ buckets.referenceMismatches.sort(compareFindings);
29231
+ buckets.linkFailures.sort(compareFindings);
29232
+ buckets.sampleFailures.sort(compareFindings);
29233
+ const flat = [];
29234
+ for (const key of AUDIT_CATEGORY_ORDER) {
29235
+ const bucket = buckets[key];
29236
+ for (const finding of bucket) {
29237
+ flat.push(finding);
29238
+ }
29239
+ }
29240
+ flat.sort(compareFindings);
29241
+ return {
29242
+ schemaVersion: DOCS_SYNC_AUDIT_SCHEMA_VERSION,
29243
+ issueNumber: args.issueNumber,
29244
+ mode: args.mode,
29245
+ generatedAt: args.generatedAt.toISOString(),
29246
+ repoRoot: args.repoRoot,
29247
+ scope: args.scope,
29248
+ categories: {
29249
+ apiDiff: buckets.apiDiff,
29250
+ tsdocCoverage: buckets.tsdocCoverage,
29251
+ referenceMismatches: buckets.referenceMismatches,
29252
+ linkFailures: buckets.linkFailures,
29253
+ sampleFailures: buckets.sampleFailures
29254
+ },
29255
+ findings: flat
29256
+ };
29257
+ }
29258
+ function persistAuditReport(args) {
29259
+ const repoRoot = path5.resolve(args.repoRoot);
29260
+ const reportDir = args.reportDir ?? DEFAULT_AUDIT_REPORT_DIR;
29261
+ const targetDir = path5.resolve(repoRoot, reportDir);
29262
+ fs3.mkdirSync(targetDir, { recursive: true });
29263
+ const targetFile = path5.join(
29264
+ targetDir,
29265
+ `${args.report.issueNumber}-audit.json`
29266
+ );
29267
+ const tempFile = `${targetFile}.tmp-${process.pid}-${Date.now()}`;
29268
+ const serialized = `${JSON.stringify(args.report, null, 2)}
29269
+ `;
29270
+ fs3.writeFileSync(tempFile, serialized, "utf-8");
29271
+ fs3.renameSync(tempFile, targetFile);
29272
+ return targetFile;
29273
+ }
29274
+ function emptyCategoryBuckets() {
29275
+ return {
29276
+ apiDiff: [],
29277
+ tsdocCoverage: [],
29278
+ referenceMismatches: [],
29279
+ linkFailures: [],
29280
+ sampleFailures: []
29281
+ };
29282
+ }
29283
+ function pushIntoBucket(buckets, finding) {
29284
+ switch (finding.category) {
29285
+ case AuditCategory.ApiDiff:
29286
+ buckets.apiDiff.push(finding);
29287
+ return;
29288
+ case AuditCategory.TsdocCoverage:
29289
+ buckets.tsdocCoverage.push(finding);
29290
+ return;
29291
+ case AuditCategory.ReferenceMismatches:
29292
+ buckets.referenceMismatches.push(finding);
29293
+ return;
29294
+ case AuditCategory.LinkFailures:
29295
+ buckets.linkFailures.push(finding);
29296
+ return;
29297
+ case AuditCategory.SampleFailures:
29298
+ buckets.sampleFailures.push(finding);
29299
+ return;
29300
+ default: {
29301
+ const exhaustive = finding;
29302
+ throw new Error(
29303
+ `runScan: unrecognized finding category: ${JSON.stringify(exhaustive)}`
29304
+ );
29305
+ }
29306
+ }
29307
+ }
29308
+ function compareFindings(a, b) {
29309
+ const sevDelta = SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
29310
+ if (sevDelta !== 0) {
29311
+ return sevDelta;
29312
+ }
29313
+ if (a.category !== b.category) {
29314
+ return a.category.localeCompare(b.category);
29315
+ }
29316
+ if (a.location.file !== b.location.file) {
29317
+ return a.location.file.localeCompare(b.location.file);
29318
+ }
29319
+ if (a.location.line !== b.location.line) {
29320
+ return a.location.line - b.location.line;
29321
+ }
29322
+ return a.subject.localeCompare(b.subject);
29323
+ }
29324
+
29325
+ // src/docs-sync/tsdoc-coverage/coverage.ts
29326
+ import * as path6 from "path";
29397
29327
  import { TSDocParser } from "@microsoft/tsdoc";
29398
29328
  import * as ts2 from "typescript";
29399
29329
  var TsDocCoverageKind = {
@@ -29411,8 +29341,8 @@ var DEFAULT_THIN_SUMMARY_WORD_THRESHOLD = 4;
29411
29341
  var DEFAULT_ENTRY_POINT = "src/index.ts";
29412
29342
  function analyzeTsDocCoverage(options) {
29413
29343
  const resolvedOptions = typeof options === "string" ? { packageRoot: options } : options;
29414
- const packageRoot = path5.resolve(resolvedOptions.packageRoot);
29415
- const entryPoint = path5.resolve(
29344
+ const packageRoot = path6.resolve(resolvedOptions.packageRoot);
29345
+ const entryPoint = path6.resolve(
29416
29346
  packageRoot,
29417
29347
  resolvedOptions.entryPoint ?? DEFAULT_ENTRY_POINT
29418
29348
  );
@@ -29475,7 +29405,7 @@ function analyzeTsDocCoverage(options) {
29475
29405
  }
29476
29406
  function resolveCompilerOptions(packageRoot, tsconfigPath) {
29477
29407
  if (tsconfigPath) {
29478
- const absoluteTsconfig = path5.resolve(packageRoot, tsconfigPath);
29408
+ const absoluteTsconfig = path6.resolve(packageRoot, tsconfigPath);
29479
29409
  const configFile = ts2.readConfigFile(absoluteTsconfig, ts2.sys.readFile);
29480
29410
  if (configFile.error) {
29481
29411
  throw new Error(
@@ -29485,7 +29415,7 @@ function resolveCompilerOptions(packageRoot, tsconfigPath) {
29485
29415
  const parsed = ts2.parseJsonConfigFileContent(
29486
29416
  configFile.config,
29487
29417
  ts2.sys,
29488
- path5.dirname(absoluteTsconfig)
29418
+ path6.dirname(absoluteTsconfig)
29489
29419
  );
29490
29420
  return { ...parsed.options, noEmit: true };
29491
29421
  }
@@ -29949,8 +29879,8 @@ var ResetTask = class _ResetTask extends Component14 {
29949
29879
  const resetTask = this.project.tasks.addTask(this.taskName, {
29950
29880
  description: "Delete build artifacts specified by pathsToRemove option, or artifactsDirectory if pathsToRemove is empty"
29951
29881
  });
29952
- this.pathsToRemove.forEach((path6) => {
29953
- resetTask.exec(`[ -e "${path6}" ] && rm -rf ${path6} || true`);
29882
+ this.pathsToRemove.forEach((path7) => {
29883
+ resetTask.exec(`[ -e "${path7}" ] && rm -rf ${path7} || true`);
29954
29884
  });
29955
29885
  const rootHasTurbo = TurboRepo.of(this.project.root) !== void 0;
29956
29886
  const isSubproject = this.project !== this.project.root;
@@ -30292,6 +30222,7 @@ var DEFAULT_TYPE_LABELS = [
30292
30222
  ];
30293
30223
  var DEFAULT_WORKFLOW_NAME2 = "sync-labels";
30294
30224
  var LABELS_CONFIG_PATH = ".github/labels.yml";
30225
+ var MAX_LABEL_DESCRIPTION_LENGTH = 100;
30295
30226
  function addSyncLabelsWorkflow(project, options) {
30296
30227
  const workflowName = options.workflowName ?? DEFAULT_WORKFLOW_NAME2;
30297
30228
  const deleteOtherLabels = options.deleteOtherLabels ?? true;
@@ -30314,6 +30245,18 @@ function addSyncLabelsWorkflow(project, options) {
30314
30245
  labelMap.set(label.name, label);
30315
30246
  }
30316
30247
  const allLabels = [...labelMap.values()];
30248
+ const overlength = allLabels.filter(
30249
+ (l) => (l.description ?? "").length > MAX_LABEL_DESCRIPTION_LENGTH
30250
+ );
30251
+ if (overlength.length > 0) {
30252
+ const offenders = overlength.map(
30253
+ (l) => ` - ${l.name} (${(l.description ?? "").length} chars): ${l.description}`
30254
+ ).join("\n");
30255
+ throw new Error(
30256
+ `The following label descriptions exceed GitHub's ${MAX_LABEL_DESCRIPTION_LENGTH}-char limit and would break the sync-labels workflow:
30257
+ ${offenders}`
30258
+ );
30259
+ }
30317
30260
  new LabelsFile(project, allLabels);
30318
30261
  const workflow = project.github?.addWorkflow(workflowName);
30319
30262
  if (!workflow) {
@@ -31892,11 +31835,15 @@ export {
31892
31835
  AGENT_RULE_SCOPE,
31893
31836
  AGENT_TIER_ROLES,
31894
31837
  AGENT_TIER_VALUES,
31838
+ AUDIT_CATEGORY_ORDER,
31895
31839
  AgentConfig,
31896
31840
  ApiExtractor,
31897
31841
  AstroConfig,
31898
31842
  AstroOutput,
31899
31843
  AstroProject,
31844
+ AuditCategory,
31845
+ AuditMode,
31846
+ AuditSeverity,
31900
31847
  AwsCdkProject,
31901
31848
  AwsDeployWorkflow,
31902
31849
  AwsDeploymentConfig,
@@ -31912,6 +31859,7 @@ export {
31912
31859
  DEFAULT_API_EXTRACTOR_ENTRY_POINT,
31913
31860
  DEFAULT_API_EXTRACTOR_REPORT_FILENAME,
31914
31861
  DEFAULT_API_EXTRACTOR_REPORT_FOLDER,
31862
+ DEFAULT_AUDIT_REPORT_DIR,
31915
31863
  DEFAULT_DECOMPOSITION_TEMPLATE,
31916
31864
  DEFAULT_DELEGATE_TO_PR_REVIEWER,
31917
31865
  DEFAULT_DISPATCH_MODEL,
@@ -31953,15 +31901,11 @@ export {
31953
31901
  DEFAULT_TYPE_LABELS,
31954
31902
  DEFAULT_UNBLOCK_COMMENT_TEMPLATE,
31955
31903
  DEFAULT_UNBLOCK_DEPENDENTS_ENABLED,
31956
- DEFAULT_WORKFLOW_DIAGRAMS_BUNDLE_PATH_PATTERNS,
31957
- DEFAULT_WORKFLOW_DIAGRAMS_EMIT_CHECKER,
31958
- DEFAULT_WORKFLOW_DIAGRAMS_EMIT_STARTER,
31959
- DEFAULT_WORKFLOW_DIAGRAMS_ENABLED,
31960
- DEFAULT_WORKFLOW_DIAGRAMS_PATH,
31961
- DEFAULT_WORKFLOW_DIAGRAMS_REQUIRE_UPDATE,
31904
+ DOCS_SYNC_AUDIT_SCHEMA_VERSION,
31962
31905
  JsiiFaker,
31963
31906
  LAYOUT_ENFORCEMENT,
31964
31907
  LAYOUT_ROOT_BY_PROJECT_TYPE,
31908
+ MAX_LABEL_DESCRIPTION_LENGTH,
31965
31909
  MCP_TRANSPORT,
31966
31910
  MERGE_METHODS,
31967
31911
  MIMIMUM_RELEASE_AGE,
@@ -32000,6 +31944,7 @@ export {
32000
31944
  addSyncLabelsWorkflow,
32001
31945
  agendaBundle,
32002
31946
  analyzeTsDocCoverage,
31947
+ auditReportJsonSchema,
32003
31948
  awsCdkBundle,
32004
31949
  baseBundle,
32005
31950
  bcmWriterBundle,
@@ -32016,6 +31961,7 @@ export {
32016
31961
  buildOrchestratorConventionsContent,
32017
31962
  buildPeopleProfileBundle,
32018
31963
  buildRegulatoryResearchBundle,
31964
+ buildReport,
32019
31965
  buildRequirementsAnalystBundle,
32020
31966
  buildRequirementsReviewerBundle,
32021
31967
  buildRequirementsWriterBundle,
@@ -32032,6 +31978,7 @@ export {
32032
31978
  compileFencedSamples,
32033
31979
  customerProfileBundle,
32034
31980
  docsSyncBundle,
31981
+ emptyCategoryBuckets,
32035
31982
  extractApiProcedure,
32036
31983
  extractDocReferences,
32037
31984
  extractFencedSamples,
@@ -32045,6 +31992,7 @@ export {
32045
31992
  meetingAnalysisBundle,
32046
31993
  orchestratorBundle,
32047
31994
  peopleProfileBundle,
31995
+ persistAuditReport,
32048
31996
  pnpmBundle,
32049
31997
  prReviewBundle,
32050
31998
  projenBundle,
@@ -32084,10 +32032,6 @@ export {
32084
32032
  renderSourceTierExamples,
32085
32033
  renderUnblockDependentsScript,
32086
32034
  renderUnblockDependentsSection,
32087
- renderWorkflowDiagramsBundleHook,
32088
- renderWorkflowDiagramsCheckerScript,
32089
- renderWorkflowDiagramsRuleContent,
32090
- renderWorkflowDiagramsStarterPage,
32091
32035
  requirementsAnalystBundle,
32092
32036
  requirementsReviewerBundle,
32093
32037
  requirementsWriterBundle,
@@ -32110,7 +32054,7 @@ export {
32110
32054
  resolveTemplateVariables,
32111
32055
  resolveTypeScriptProjectOutdir,
32112
32056
  resolveUnblockDependents,
32113
- resolveWorkflowDiagrams,
32057
+ runScan,
32114
32058
  slackBundle,
32115
32059
  softwareProfileBundle,
32116
32060
  standardsResearchBundle,
@@ -32128,7 +32072,6 @@ export {
32128
32072
  validateSkillEvalsConfig,
32129
32073
  validateStarlightSingleton,
32130
32074
  validateUnblockDependentsConfig,
32131
- validateWorkflowDiagramsConfig,
32132
32075
  vitestBundle
32133
32076
  };
32134
32077
  //# sourceMappingURL=index.mjs.map