@drafthq/draft 3.0.0 → 3.1.5
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/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/bin/README.md +4 -7
- package/core/shared/condensation.md +8 -8
- package/core/shared/draft-context-loading.md +5 -9
- package/core/shared/graph-query.md +36 -30
- package/core/shared/graph-usage-report.md +1 -1
- package/core/shared/pattern-learning.md +2 -2
- package/core/shared/red-flags.md +3 -3
- package/core/templates/ai-context.md +1 -1
- package/core/templates/architecture.md +3 -3
- package/integrations/agents/AGENTS.md +165 -142
- package/integrations/copilot/.github/copilot-instructions.md +165 -142
- package/package.json +1 -1
- package/scripts/lib.sh +1 -3
- package/scripts/tools/adr-index.sh +2 -2
- package/scripts/tools/check-scope-conflicts.sh +2 -2
- package/scripts/tools/check-skill-line-caps.sh +2 -2
- package/scripts/tools/cycle-detect.sh +5 -1
- package/scripts/tools/diff-templates-vs-tracks.sh +2 -2
- package/scripts/tools/fix-whitespace.sh +15 -9
- package/scripts/tools/graph-arch.sh +72 -0
- package/scripts/tools/graph-impact.sh +1 -0
- package/scripts/tools/graph-init.sh +3 -3
- package/scripts/tools/graph-snapshot.sh +52 -51
- package/scripts/tools/hotspot-rank.sh +2 -0
- package/scripts/tools/manage-symlinks.sh +1 -1
- package/scripts/tools/parse-reports.sh +1 -1
- package/scripts/tools/verify-doc-anchors.sh +2 -2
- package/scripts/tools/verify-graph-binary.sh +1 -1
- package/skills/GRAPH.md +2 -2
- package/skills/bughunt/SKILL.md +1 -1
- package/skills/debug/SKILL.md +3 -3
- package/skills/decompose/SKILL.md +5 -5
- package/skills/deep-review/SKILL.md +2 -2
- package/skills/deploy-checklist/SKILL.md +2 -2
- package/skills/graph/SKILL.md +1 -1
- package/skills/implement/SKILL.md +1 -1
- package/skills/init/SKILL.md +62 -42
- package/skills/init/references/architecture-spec.md +12 -11
- package/skills/learn/SKILL.md +5 -5
- package/skills/quick-review/SKILL.md +3 -3
- package/skills/review/SKILL.md +7 -7
- package/skills/tech-debt/SKILL.md +2 -2
- package/scripts/tools/okf-bundle.sh +0 -141
- package/scripts/tools/okf-check.sh +0 -137
- package/scripts/tools/okf-emit.sh +0 -161
package/skills/init/SKILL.md
CHANGED
|
@@ -52,7 +52,7 @@ Initialize a Draft project for Context-Driven Development.
|
|
|
52
52
|
|
|
53
53
|
## Graph Fidelity & Diagram-First Priority (MANDATORY)
|
|
54
54
|
|
|
55
|
-
The knowledge graph
|
|
55
|
+
The knowledge graph — served live by the local `codebase-memory-mcp` engine (packages, languages, routes, fan-in/out, hotspots) and queried via the `graph-*.sh` wrappers — is the **deterministic structural ground truth** for the system's actual architecture. Draft is engine-only: `draft/graph/` holds only the `schema.yaml` gate marker; all graph data comes from live queries.
|
|
56
56
|
|
|
57
57
|
**You are running inside a powerful agentic coding environment** (Cursor, Claude Code, Copilot, Windsurf, etc.) that maintains its own rich, continuously updated index of the entire codebase. **Use that indexed knowledge aggressively** in addition to the explicit graph data and direct source reads. Your environment's index often captures higher-level intent, naming patterns, cross-file workflows, and architectural signals that the static graph may not fully express yet. Combine both sources:
|
|
58
58
|
- Graph = authoritative modules, edges, public surfaces, hotspots, call relationships.
|
|
@@ -499,9 +499,9 @@ else
|
|
|
499
499
|
fi
|
|
500
500
|
```
|
|
501
501
|
|
|
502
|
-
- **Root init** writes `<root>/draft/graph
|
|
502
|
+
- **Root init** writes `<root>/draft/graph/schema.yaml` — the committed gate marker. Draft is engine-only: graph data is served live by the engine, never committed.
|
|
503
503
|
- **Module init** also writes `draft/graph/root-link.json` (module→root); follow `root_graph` for cross-module understanding. The root spine is rebuilt first so the link is live.
|
|
504
|
-
- Only `
|
|
504
|
+
- Only `schema.yaml` (and `root-link.json` in a module) is committed. The engine's `~/.cache` index is the live structural store — never commit it; it rebuilds deterministically from source.
|
|
505
505
|
|
|
506
506
|
Optionally record which engine was selected (usage-report contract):
|
|
507
507
|
|
|
@@ -511,15 +511,20 @@ scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null || true
|
|
|
511
511
|
|
|
512
512
|
See `core/shared/graph-query.md` and `bin/README.md` for the query contract and engine resolution.
|
|
513
513
|
|
|
514
|
-
If
|
|
514
|
+
If indexing succeeds, `draft/graph/schema.yaml` is written and later steps query the engine live for structure + populate the injection slots.
|
|
515
515
|
|
|
516
|
-
### 2. If
|
|
516
|
+
### 2. If indexing succeeds, query the engine for structural context
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
518
|
+
Pull the architecture view once and reuse it across phases:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
ARCH=$(scripts/tools/graph-arch.sh --repo .)
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
- `$ARCH | jq '.packages'` — module list with fan-in/out
|
|
525
|
+
- `$ARCH | jq '.routes'` — detected service endpoints
|
|
526
|
+
- `$ARCH | jq '.languages, .node_labels, .layers, .boundaries'` — language mix, node shape, layering
|
|
527
|
+
- `scripts/tools/hotspot-rank.sh --repo . --top 20` — complexity/fan-in hotspots (live)
|
|
523
528
|
|
|
524
529
|
### 3. Use graph data to accelerate Step 1.5
|
|
525
530
|
|
|
@@ -533,10 +538,10 @@ Read these files to get structural context for all subsequent phases:
|
|
|
533
538
|
### 4. Compute codebase tier and module priority
|
|
534
539
|
|
|
535
540
|
**Step 1.4.5 — Compute Codebase Tier:**
|
|
536
|
-
|
|
537
|
-
- `M =
|
|
538
|
-
- `F =
|
|
539
|
-
- `P =
|
|
541
|
+
From the live `$ARCH` (above), extract:
|
|
542
|
+
- `M = $ARCH | jq '.packages | length'` (modules)
|
|
543
|
+
- `F = $ARCH | jq '[.node_labels[] | select(.label=="Function" or .label=="Method") | .count] | add // 0'` (functions+methods)
|
|
544
|
+
- `P = $ARCH | jq '.routes | length'` (routes / RPCs)
|
|
540
545
|
|
|
541
546
|
Apply tier table:
|
|
542
547
|
|
|
@@ -551,8 +556,8 @@ Apply tier table:
|
|
|
551
556
|
Hold tier in memory. This governs: architecture.md length minimum, .ai-context.md budget, and module deep-dive depth.
|
|
552
557
|
|
|
553
558
|
**Step 1.4.6 — Build Module Priority List:**
|
|
554
|
-
From `
|
|
555
|
-
From
|
|
559
|
+
From `scripts/tools/hotspot-rank.sh --repo .`: count hotspot symbols per module.
|
|
560
|
+
From `$ARCH | jq '.packages[]'`: read `fan_in` per module.
|
|
556
561
|
Rank modules by: `(hotspot_count × 2) + fan_in_count`.
|
|
557
562
|
Top-ranked modules drive Section 6 deep-dive ordering and depth. Modules ranked zero on both: summary treatment only.
|
|
558
563
|
Hold ranked list in memory — it replaces directory scanning for module discovery.
|
|
@@ -572,7 +577,7 @@ The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on e
|
|
|
572
577
|
```
|
|
573
578
|
|
|
574
579
|
For Section 20 (hotspots slot):
|
|
575
|
-
|
|
580
|
+
Run `scripts/tools/hotspot-rank.sh --repo . --top 10`, take the top 10 by fanIn, build a markdown table:
|
|
576
581
|
```
|
|
577
582
|
<!-- GRAPH:hotspots:START -->
|
|
578
583
|
| Symbol | fanIn |
|
|
@@ -631,7 +636,7 @@ Perform a **one-time, exhaustive analysis** of the existing codebase. This is NO
|
|
|
631
636
|
|
|
632
637
|
If the codebase is large (200+ files), focus on the module boundaries but still enumerate exhaustively within each module.
|
|
633
638
|
|
|
634
|
-
> **Large codebase guardrail:** If the codebase exceeds 500 source files, limit Section 7 deep dives to the top 20 most-imported modules and summarize others in a table. Rank modules by the number of unique files that import/reference them (descending) — use
|
|
639
|
+
> **Large codebase guardrail:** If the codebase exceeds 500 source files, limit Section 7 deep dives to the top 20 most-imported modules and summarize others in a table. Rank modules by the number of unique files that import/reference them (descending) — use the engine's `.packages[].fan_in` (`get_architecture`, captured as `$ARCH` in Step 1.4.2) if the engine is available. For dynamic languages where static import counting is impractical, rank by file count within each module directory (larger modules first). **Even for summarized modules, enumerate immediate sub-directories with file counts** (one-line per sub-dir) — this is cheap with graph data and provides essential navigation context.
|
|
635
640
|
|
|
636
641
|
### Parallel Analysis Protocol (Tiers 3–5)
|
|
637
642
|
|
|
@@ -658,16 +663,16 @@ For tier 3+, readers run simultaneously; wall clock = slowest reader, not the su
|
|
|
658
663
|
|
|
659
664
|
#### Phase 0: Graph Data (already done in Step 1.4)
|
|
660
665
|
|
|
661
|
-
The
|
|
662
|
-
-
|
|
663
|
-
-
|
|
664
|
-
- `
|
|
666
|
+
The engine is already indexed. Query it live throughout this protocol (reuse `$ARCH` from Step 1.4.2):
|
|
667
|
+
- `$ARCH | jq '.packages'` — module list with `.fan_in`/`.fan_out` (for grouping)
|
|
668
|
+
- `$ARCH | jq '.languages, .node_labels'` — file/symbol counts, tier metrics
|
|
669
|
+
- `scripts/tools/hotspot-rank.sh --repo .` — top hotspot symbols per module (feed to readers)
|
|
665
670
|
|
|
666
671
|
#### Phase 1: Spawn Parallel Module Readers
|
|
667
672
|
|
|
668
673
|
**Step 1: Group modules.**
|
|
669
674
|
|
|
670
|
-
From
|
|
675
|
+
From `$ARCH | jq '.packages[]'`, extract all module names and their `fan_in` counts.
|
|
671
676
|
Apply dependency-aware grouping (see `core/shared/parallel-analysis.md`).
|
|
672
677
|
Use the modules-per-agent count from the tier table above (4 for tier 4/5; all modules in one agent for tier 1):
|
|
673
678
|
- Assign highest fan-in modules to separate readers (tier 3+)
|
|
@@ -683,7 +688,7 @@ Hotspot files:
|
|
|
683
688
|
execution/engine.go (847 lines, fanIn=12)
|
|
684
689
|
execution/router.go (412 lines, fanIn=8)
|
|
685
690
|
fill_processor/handler.go (623 lines, fanIn=5)
|
|
686
|
-
Module edges (from
|
|
691
|
+
Module edges (from $ARCH .packages fan-in/out):
|
|
687
692
|
execution → [risk, data, services]
|
|
688
693
|
fill_processor → [execution, persistence]
|
|
689
694
|
```
|
|
@@ -788,7 +793,7 @@ If any reader agent fails to produce valid JSON after one retry:
|
|
|
788
793
|
When the Agent tool is unavailable or reader agents fail after retry, write `draft/architecture.md` using the **10-section graph-primary structure** (checklist above + `core/templates/architecture.md`). Do not use legacy 28-section or Pass 1/2/3 volume protocols.
|
|
789
794
|
|
|
790
795
|
1. Use the ranked module list from Step 1.4.6 (graph-first — do not re-scan by directory if Phase 0 succeeded).
|
|
791
|
-
2. For each top module (up to 20 by fan-in),
|
|
796
|
+
2. For each top module (up to 20 by fan-in), query the engine for its symbols/callers (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, or `$ARCH | jq '.packages[] | select(.name=="<m>")'`), read the hotspot files and 3–5 key sources; embed graph blocks and at least one workflow/state diagram per significant module inside §4–§8 as appropriate.
|
|
792
797
|
3. Always include §9 Graph Coverage Gaps and §10 Relationship when the Context Audit requires them.
|
|
793
798
|
4. Run Completion Verification (defined later in this skill) before condensation. Fidelity, provenance, and gap honesty block completion — not line counts.
|
|
794
799
|
|
|
@@ -911,11 +916,11 @@ Follow these steps in order. The specific files to look for depend on the langua
|
|
|
911
916
|
|
|
912
917
|
#### Phase 1: Discovery (Broad Scan)
|
|
913
918
|
|
|
914
|
-
1. **Map the directory tree**: Recursively list the project to understand the file layout. Note subdirectory groupings. (If Step 1.4 graph analysis succeeded, use
|
|
919
|
+
1. **Map the directory tree**: Recursively list the project to understand the file layout. Note subdirectory groupings. (If Step 1.4 graph analysis succeeded, use the engine's `$ARCH | jq '.packages, .file_tree'` instead — it is exhaustive and includes file counts.)
|
|
915
920
|
|
|
916
921
|
2. **Read build / dependency files**: These reveal the module structure, dependencies, and targets. (See language guide above for which files.)
|
|
917
922
|
|
|
918
|
-
3. **Read API definition files**: These define the module's data model and service interfaces. (See language guide above for which files. If Step 1.4 succeeded,
|
|
923
|
+
3. **Read API definition files**: These define the module's data model and service interfaces. (See language guide above for which files. If Step 1.4 succeeded, the engine's `$ARCH | jq '.routes'` already has all detected service endpoints.)
|
|
919
924
|
|
|
920
925
|
4. **Read interface / type definition files**: Class declarations, interface definitions, and type annotations reveal the public API and design intent.
|
|
921
926
|
|
|
@@ -1653,22 +1658,37 @@ For **brownfield** projects, run `/draft:learn` (no arguments — full codebase
|
|
|
1653
1658
|
|
|
1654
1659
|
## Completion
|
|
1655
1660
|
|
|
1656
|
-
**Finalize
|
|
1657
|
-
|
|
1658
|
-
|
|
1661
|
+
**Finalize the context index:** After all `draft/` files are written, author (or refresh)
|
|
1662
|
+
`draft/index.md` — a plain, navigable index over the context bundle. No OKF framing, no
|
|
1663
|
+
special frontmatter; it is a human- and agent-readable table of contents.
|
|
1659
1664
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1665
|
+
Write `draft/index.md` with this structure (omit rows whose files were not generated):
|
|
1666
|
+
|
|
1667
|
+
```md
|
|
1668
|
+
# <project> — Draft Context
|
|
1669
|
+
|
|
1670
|
+
Start here. This indexes the Draft context for this repo.
|
|
1671
|
+
|
|
1672
|
+
## Context
|
|
1673
|
+
- [Architecture](architecture.md) — module map, dependencies, hotspots (graph-grounded)
|
|
1674
|
+
- [Product](product.md) — what this system does and for whom
|
|
1675
|
+
- [Tech Stack](tech-stack.md) — languages, frameworks, infra
|
|
1676
|
+
- [Workflow](workflow.md) — how work flows through the repo
|
|
1677
|
+
- [Guardrails](guardrails.md) — learned conventions and anti-patterns
|
|
1678
|
+
- [AI Context Map](.ai-context.md) — condensed orientation for agents
|
|
1679
|
+
- [AI Profile](.ai-profile.md) — repo profile + tiering
|
|
1680
|
+
|
|
1681
|
+
## Tracks
|
|
1682
|
+
- [Track Index](tracks.md) — active, completed, and archived tracks
|
|
1683
|
+
|
|
1684
|
+
## Knowledge graph
|
|
1685
|
+
- Engine-only (`codebase-memory-mcp`). Structural data is queried live via the
|
|
1686
|
+
`graph-*.sh` wrappers; `draft/graph/schema.yaml` is the gate marker. There is no
|
|
1687
|
+
committed graph mirror to browse.
|
|
1663
1688
|
```
|
|
1664
1689
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes from
|
|
1668
|
-
the templates; `okf-check.sh` validates §9 conformance (frontmatter + `type` on every
|
|
1669
|
-
concept; reserved `index.md`/`log.md` structure). It is advisory — report the result,
|
|
1670
|
-
do not fail init. Note: operational reports later written into `draft/` (e.g.
|
|
1671
|
-
`deep-review-report.md`) are not OKF concepts and will be flagged.
|
|
1690
|
+
Keep one-line descriptions accurate to what each file actually contains. This index is
|
|
1691
|
+
the single committed entry point to the `draft/` bundle.
|
|
1672
1692
|
|
|
1673
1693
|
**Finalize run memory:** Update `draft/.state/run-memory.json`:
|
|
1674
1694
|
- `status`: `"completed"`
|
|
@@ -1679,7 +1699,7 @@ For **Brownfield** projects, announce:
|
|
|
1679
1699
|
"Draft initialized successfully with comprehensive analysis!
|
|
1680
1700
|
|
|
1681
1701
|
Created:
|
|
1682
|
-
- draft/index.md (
|
|
1702
|
+
- draft/index.md (plain docs index — navigable table of contents for the draft/ bundle)
|
|
1683
1703
|
- draft/.ai-profile.md (20-50 lines — ultra-compact always-injected profile, Tier 0)
|
|
1684
1704
|
- draft/.ai-context.md (200-400 lines — token-optimized AI context, self-contained, Tier 1)
|
|
1685
1705
|
- draft/architecture.md (comprehensive human-readable engineering reference, Tier 2)
|
|
@@ -1714,7 +1734,7 @@ For **Greenfield** projects, announce:
|
|
|
1714
1734
|
"Draft initialized successfully!
|
|
1715
1735
|
|
|
1716
1736
|
Created:
|
|
1717
|
-
- draft/index.md (
|
|
1737
|
+
- draft/index.md (plain docs index — navigable table of contents for the draft/ bundle)
|
|
1718
1738
|
- draft/product.md
|
|
1719
1739
|
- draft/tech-stack.md
|
|
1720
1740
|
- draft/workflow.md
|
|
@@ -275,13 +275,13 @@ Only when material: authentication/authorization checkpoints, distributed transa
|
|
|
275
275
|
|
|
276
276
|
**Core rule:** The graph is the source of truth for structure. LLM synthesis exists only to interpret the graph into actionable design understanding — primarily via one accurate workflow or state diagram per module — plus tiny supporting notes. The previous volume-oriented deep-dive expectations are superseded.
|
|
277
277
|
|
|
278
|
-
For each module
|
|
278
|
+
For each module returned by `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'`, produce a subsection whose **primary content** is the deterministic graph block followed by one synthesized behavioral diagram. Every module gets a slot; do not sample. The block's fan-in/out and node counts come from `.packages[]`; public API and key call edges come from live per-package queries (`scripts/tools/graph-callers.sh`, `graph-impact.sh`) and `scripts/tools/hotspot-rank.sh --repo .`.
|
|
279
279
|
|
|
280
280
|
#### 7.{N} {module-name}
|
|
281
281
|
|
|
282
282
|
<!-- GRAPH:module-deep/{module-name}:START -->
|
|
283
283
|
<!-- Rendered deterministic block: package name, node count, public API list, fan-in/fan-out (from
|
|
284
|
-
|
|
284
|
+
get_architecture .packages), hotspot fan-in (from hotspot-rank.sh), key call edges (from
|
|
285
285
|
graph-callers.sh/graph-impact.sh), entry points if known. No LLM prose inside fence. -->
|
|
286
286
|
<!-- GRAPH:module-deep/{module-name}:END -->
|
|
287
287
|
|
|
@@ -300,7 +300,7 @@ Synthesize a single, accurate Mermaid diagram (`stateDiagram-v2`, `sequenceDiagr
|
|
|
300
300
|
|
|
301
301
|
#### Sub-Module Guidance (when graph justifies recursion)
|
|
302
302
|
|
|
303
|
-
When a module has clear internal structure visible in `
|
|
303
|
+
When a module has clear internal structure visible in live engine query `get_architecture .packages` (fan-in/out) or live per-package queries:
|
|
304
304
|
- Create `##### 7.X.Y {Parent}/{Child}` subsections only for children that have their own meaningful public surface or high internal fan-in.
|
|
305
305
|
- Each sub-module subsection follows the same compact pattern: graph facts + **one mandatory workflow/state diagram** + ≤60 words Design Notes.
|
|
306
306
|
- Do not descend further unless the child itself shows additional clear boundaries in the graph data.
|
|
@@ -362,7 +362,7 @@ Regardless of tier, any directory whose name contains `ops`, `handlers`, `execut
|
|
|
362
362
|
| ... | (enumerate ALL — no sampling, no "and others") | | | |
|
|
363
363
|
```
|
|
364
364
|
|
|
365
|
-
Use `
|
|
365
|
+
Use `scripts/tools/graph-callers.sh --symbol <module>` or `scripts/tools/graph-arch.sh --repo .` to get the complete file list. Use `scripts/tools/hotspot-rank.sh --repo .` to flag high-complexity operations.
|
|
366
366
|
|
|
367
367
|
#### Example: Full Sub-Module Treatment for `icebox/` (917 files)
|
|
368
368
|
|
|
@@ -409,7 +409,7 @@ stateDiagram-v2
|
|
|
409
409
|
After writing Section 7, run these checks before proceeding. **If any check fails, STOP and fix.**
|
|
410
410
|
|
|
411
411
|
**Check 1 — Graph block present and faithful for every module:**
|
|
412
|
-
Every top-level module from `
|
|
412
|
+
Every top-level module from the live engine (`get_architecture .packages`) has its `<!-- GRAPH:module-deep/...:START --> ... <!-- GRAPH:module-deep/...:END -->` fence rendered verbatim. No LLM prose inside the fence. No modules missing.
|
|
413
413
|
|
|
414
414
|
**Check 2 — One mandatory workflow/state diagram per module:**
|
|
415
415
|
Every `#### 7.X` (and every `##### 7.X.Y` that the graph justified) contains exactly one high-signal `Primary Workflow / State` Mermaid diagram (`stateDiagram-v2`, `sequenceDiagram`, or clear `flowchart`). The diagram must reflect facts from the module's graph record (entry points, public symbols, call targets). Generic placeholder diagrams fail this check.
|
|
@@ -513,12 +513,13 @@ Include architecturally significant implementations (high fan-in, core extension
|
|
|
513
513
|
|---|-----------|-------------|-------|-------------|
|
|
514
514
|
| 1 | ArchiveFilesOp | `icebox/master/ops/archive_files_op.cc` | 2100 | Archives files to cloud vault |
|
|
515
515
|
| 2 | CancelJobOp | `icebox/master/ops/cancel_job_op.cc` | 450 | Cancels running archive job |
|
|
516
|
-
| (enumerate ALL — use
|
|
516
|
+
| (enumerate ALL — use hotspot-rank.sh and graph-callers.sh / get_architecture for file list and line counts) |
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
> **MANDATORY (graph data)**:
|
|
520
|
-
>
|
|
521
|
-
>
|
|
519
|
+
> **MANDATORY (graph data)**: Query `scripts/tools/graph-arch.sh --repo .` or
|
|
520
|
+
> `scripts/tools/graph-callers.sh --symbol <module>` to get the complete file list with line counts.
|
|
521
|
+
> Filter for files in operation sub-directories (paths containing `/ops/`,
|
|
522
|
+
> `/handlers/`, `/executors/`, `/workers/`). Use `scripts/tools/hotspot-rank.sh --repo .` to flag
|
|
522
523
|
> high-complexity operations (high line count or fanIn). Do NOT skip this step — incomplete
|
|
523
524
|
> catalogs cause AI agents to reinvent existing functionality.
|
|
524
525
|
|
|
@@ -1209,11 +1210,11 @@ Fix: Add actual payload descriptions on arrows, `alt`/`opt` blocks for condition
|
|
|
1209
1210
|
|
|
1210
1211
|
**FAILURE 3 — Empty Appendices:**
|
|
1211
1212
|
Detection: Appendix B, C, or D tables have fewer than 10 data rows.
|
|
1212
|
-
Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (Appendix C), and add 2-3 detailed sequence diagrams to Appendix D. Use
|
|
1213
|
+
Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (Appendix C), and add 2-3 detailed sequence diagrams to Appendix D. Use live engine queries (`get_architecture .packages`/`.routes`) to enumerate exhaustively.
|
|
1213
1214
|
|
|
1214
1215
|
**FAILURE 4 — Missing Sub-Modules:**
|
|
1215
1216
|
Detection: A module with 100+ source files (check graph data) has no Sub-Module Structure table.
|
|
1216
|
-
Fix:
|
|
1217
|
+
Fix: Query `scripts/tools/graph-arch.sh --repo .` or `scripts/tools/graph-callers.sh --symbol <name>`, group results by immediate sub-directory, and generate the table with file counts and one-line role descriptions per sub-directory.
|
|
1217
1218
|
|
|
1218
1219
|
**FAILURE 4b — Shallow Sub-Module Treatment:**
|
|
1219
1220
|
Detection: Large sub-modules (50+ files) listed only as table rows with no dedicated deep-dive subsection. Or ops/handler directories have no operation catalog.
|
package/skills/learn/SKILL.md
CHANGED
|
@@ -11,8 +11,8 @@ Scan the codebase to discover recurring coding patterns and update `draft/guardr
|
|
|
11
11
|
|
|
12
12
|
When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Use the graph to:
|
|
13
13
|
|
|
14
|
-
1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `
|
|
15
|
-
2. Prioritize hotspots
|
|
14
|
+
1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `scripts/tools/graph-arch.sh --repo .` (preferred over `find`).
|
|
15
|
+
2. Prioritize hotspots via `scripts/tools/hotspot-rank.sh --repo .` — patterns in high-fanIn files are more impactful when learned.
|
|
16
16
|
3. For TS/Python/Go/C/C++, use `*-index.jsonl` to identify class/function definitions rather than re-discovering them via regex.
|
|
17
17
|
|
|
18
18
|
Filesystem `find` for source discovery (Step 2.1) is permitted **as a complement** to the graph for languages not covered by indexes (e.g. Ruby, Java without ctags). Record the rationale in the Graph Usage Report.
|
|
@@ -246,15 +246,15 @@ git log --follow --oneline -1 -- {file_containing_pattern}
|
|
|
246
246
|
|
|
247
247
|
### 2.7: Graph-Aware Severity Enrichment
|
|
248
248
|
|
|
249
|
-
If `draft/graph/
|
|
249
|
+
If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `scripts/tools/hotspot-rank.sh --repo .`.
|
|
250
250
|
|
|
251
251
|
For each anti-pattern candidate from Step 2.2:
|
|
252
|
-
1. Check if any evidence files appear in `
|
|
252
|
+
1. Check if any evidence files appear in the hotspot output from `scripts/tools/hotspot-rank.sh --repo .`
|
|
253
253
|
2. Take the highest fanIn value across all evidence files:
|
|
254
254
|
- fanIn ≥ 10 → `graph_severity: critical` (breakage propagates to many callers)
|
|
255
255
|
- fanIn 5–9 → `graph_severity: high`
|
|
256
256
|
- fanIn 1–4 → `graph_severity: medium`
|
|
257
|
-
- fanIn 0 or file not in
|
|
257
|
+
- fanIn 0 or file not in hotspot output → `graph_severity: low`
|
|
258
258
|
3. If no graph data exists → `graph_severity: unresolved`
|
|
259
259
|
|
|
260
260
|
Collect all evidence files with fanIn ≥ 5 for the `high_fanin_files` field.
|
|
@@ -11,7 +11,7 @@ You are performing a lightweight, ad-hoc code review. This is the fast alternati
|
|
|
11
11
|
|
|
12
12
|
When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Quick-review keeps the graph load light:
|
|
13
13
|
|
|
14
|
-
1. Always
|
|
14
|
+
1. Always run `scripts/tools/hotspot-rank.sh --repo .` for every changed file (Step 2 blast-radius pre-check below).
|
|
15
15
|
2. If a finding spans more than one file, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
|
|
16
16
|
|
|
17
17
|
Filesystem `grep` is reserved for source-text scans (literal strings, regex patterns). Symbol and caller discovery go through the graph.
|
|
@@ -68,9 +68,9 @@ Determine the diff to review:
|
|
|
68
68
|
3. If commit range: `git diff <range>`
|
|
69
69
|
4. Default: `git diff HEAD~1..HEAD` (last commit)
|
|
70
70
|
|
|
71
|
-
## Step 2: Blast Radius Pre-check (if `draft/graph/
|
|
71
|
+
## Step 2: Blast Radius Pre-check (if `draft/graph/schema.yaml` exists)
|
|
72
72
|
|
|
73
|
-
Before the four-dimension review, check if any files in scope appear in
|
|
73
|
+
Before the four-dimension review, run `scripts/tools/hotspot-rank.sh --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
|
|
74
74
|
|
|
75
75
|
```
|
|
76
76
|
⚠ HIGH IMPACT: {file} is a high-fanIn hotspot (fanIn={N}). Changes here propagate to many callers — review with extra care.
|
package/skills/review/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ You are conducting a code review using Draft's Context-Driven Development method
|
|
|
11
11
|
|
|
12
12
|
When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Stage 1 (Automated Validation) **starts from the graph**:
|
|
13
13
|
|
|
14
|
-
1. Run blast-radius assessment
|
|
14
|
+
1. Run blast-radius assessment via `scripts/tools/hotspot-rank.sh --repo .` and `scripts/tools/graph-impact.sh` (see Stage 1).
|
|
15
15
|
2. For each changed file with non-trivial diff size, run `scripts/tools/graph-impact.sh --repo . --file <path>` to obtain the affected module set deterministically.
|
|
16
16
|
3. For each public symbol modified, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
|
|
17
17
|
|
|
@@ -370,18 +370,18 @@ For the files changed in the diff, perform static checks using `grep` or similar
|
|
|
370
370
|
|
|
371
371
|
- **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
|
|
372
372
|
- List all changed files from the diff
|
|
373
|
-
- For each changed file, check if it appears in `
|
|
374
|
-
- Classify: files with fanIn in the top 20% of the
|
|
375
|
-
- For any file in a HIGH or MEDIUM module,
|
|
373
|
+
- For each changed file, check if it appears in `scripts/tools/hotspot-rank.sh --repo .` output — if yes, record its `fanIn` value
|
|
374
|
+
- Classify: files with fanIn in the top 20% of the hotspot output = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in output = **STANDARD**
|
|
375
|
+
- For any file in a HIGH or MEDIUM module, query `scripts/tools/graph-arch.sh --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
|
|
376
376
|
- Include a `Blast Radius` line in the Stage 1 report summary: `Blast Radius: HIGH | MEDIUM | STANDARD — <N> changed files affect high-fanIn modules: [file list]`
|
|
377
377
|
- If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
|
|
378
378
|
- **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
|
|
379
379
|
- **Dead Code:** Check for newly exported functions/classes in the diff that have 0 references across the codebase.
|
|
380
380
|
- **Dependency Cycles:** Trace the import chains for new imports to ensure no circular dependencies (e.g., A → B → C → A) are introduced.
|
|
381
|
-
- **Graph Boundary Check** (if `draft/graph/
|
|
381
|
+
- **Graph Boundary Check** (if `draft/graph/schema.yaml` exists) `[RC-013]`:
|
|
382
382
|
- For each changed file, identify its module from the graph
|
|
383
383
|
- Check if any new cross-module includes were added in the diff
|
|
384
|
-
- Verify they follow the established dependency direction from `
|
|
384
|
+
- Verify they follow the established dependency direction from `scripts/tools/graph-arch.sh --repo .` package fan-in/out
|
|
385
385
|
- Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
|
|
386
386
|
- Check if changes introduce files in modules listed in graph cycles — flag as higher risk
|
|
387
387
|
- **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
|
|
@@ -1075,7 +1075,7 @@ If Jira ticket linked, sync via `core/shared/jira-sync.md`:
|
|
|
1075
1075
|
|
|
1076
1076
|
Before printing the final verdict, internally verify and report:
|
|
1077
1077
|
|
|
1078
|
-
1. **Graph
|
|
1078
|
+
1. **Graph data queried** — which live-engine tools were invoked (e.g. `get_architecture`, `hotspot-rank.sh`, `graph-impact.sh`, `graph-callers.sh`, `cycle-detect.sh`).
|
|
1079
1079
|
2. **Layer 1 files deliberately skipped** — list any context sections skipped as irrelevant to the diff under review.
|
|
1080
1080
|
3. **Filesystem grep fallback justification** — for every `grep`/`find` run, state the concept it searched for. Source-text scans (string literals, regex matches in code) are exempt — they are not symbol/file discovery.
|
|
1081
1081
|
|
|
@@ -11,8 +11,8 @@ You are conducting a technical debt analysis to catalog, prioritize, and plan re
|
|
|
11
11
|
|
|
12
12
|
When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Tech-debt prioritization is fundamentally driven by graph data:
|
|
13
13
|
|
|
14
|
-
1.
|
|
15
|
-
2.
|
|
14
|
+
1. Run `scripts/tools/hotspot-rank.sh --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
|
|
15
|
+
2. Query `scripts/tools/graph-arch.sh --repo .` and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
|
|
16
16
|
3. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
|
|
17
17
|
4. For each catalogued finding, run `scripts/tools/graph-impact.sh --repo . --file <path>` so the remediation plan includes blast-radius.
|
|
18
18
|
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# okf-bundle.sh — make a draft/ context directory an Open Knowledge Format bundle.
|
|
3
|
-
#
|
|
4
|
-
# OKF (Google Cloud, open spec) treats a directory of markdown files with YAML
|
|
5
|
-
# frontmatter as a knowledge bundle: one file per concept, the file path is the
|
|
6
|
-
# concept's identity, concepts cross-link with markdown links, and index.md is
|
|
7
|
-
# the navigable root. Draft's project-doc files already carry the required
|
|
8
|
-
# `type` frontmatter (architecture.md, .ai-context.md, product.md, ...); this
|
|
9
|
-
# tool writes the bundle's root index.md so the whole draft/ tree is a portable,
|
|
10
|
-
# vendor-neutral OKF bundle.
|
|
11
|
-
# https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing
|
|
12
|
-
#
|
|
13
|
-
# Writes <dir>/index.md (the OKF bundle-root index, §6/§11) linking every concept
|
|
14
|
-
# file present, the tracks, and the graph sub-bundle (graph/okf/). Validate the
|
|
15
|
-
# result with okf-check.sh (the OKF v0.1 conformance checker).
|
|
16
|
-
#
|
|
17
|
-
# Usage: scripts/tools/okf-bundle.sh [--dir DIR]
|
|
18
|
-
# Exit codes: 0 OK, 1 invocation error, 2 dir missing.
|
|
19
|
-
set -euo pipefail
|
|
20
|
-
|
|
21
|
-
DIR="draft"
|
|
22
|
-
|
|
23
|
-
usage() {
|
|
24
|
-
cat <<'EOF'
|
|
25
|
-
okf-bundle.sh — write the OKF bundle-root index.md for a draft/ context bundle.
|
|
26
|
-
|
|
27
|
-
Usage:
|
|
28
|
-
scripts/tools/okf-bundle.sh [--dir DIR]
|
|
29
|
-
|
|
30
|
-
Flags:
|
|
31
|
-
--dir DIR Bundle root (default: draft).
|
|
32
|
-
--help Show this help.
|
|
33
|
-
|
|
34
|
-
Writes <dir>/index.md cross-linking every concept present, the tracks, and the
|
|
35
|
-
graph sub-bundle. Validate conformance with `okf-check.sh --dir <dir>`.
|
|
36
|
-
Exit 0 OK, 1 invocation error, 2 when <dir> is absent.
|
|
37
|
-
EOF
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
while [[ $# -gt 0 ]]; do
|
|
41
|
-
case "$1" in
|
|
42
|
-
--dir) DIR="$2"; shift 2;;
|
|
43
|
-
--help|-h) usage; exit 0;;
|
|
44
|
-
-*) echo "Unknown flag: $1" >&2; usage >&2; exit 1;;
|
|
45
|
-
*) echo "Unexpected arg: $1" >&2; usage >&2; exit 1;;
|
|
46
|
-
esac
|
|
47
|
-
done
|
|
48
|
-
|
|
49
|
-
[[ -d "$DIR" ]] || { echo "ERROR: --dir '$DIR' is not a directory" >&2; exit 2; }
|
|
50
|
-
|
|
51
|
-
# Canonical Draft concepts, ordered: "filename|label|expected-type".
|
|
52
|
-
# Each present file is linked from index.md and checked for `type:` under --check.
|
|
53
|
-
CONCEPTS=(
|
|
54
|
-
".ai-profile.md|AI Profile|Profile"
|
|
55
|
-
".ai-context.md|AI Context Map|ContextMap"
|
|
56
|
-
"architecture.md|Architecture|Architecture"
|
|
57
|
-
"product.md|Product|Product"
|
|
58
|
-
"tech-stack.md|Tech Stack|TechStack"
|
|
59
|
-
"workflow.md|Workflow|Workflow"
|
|
60
|
-
"guardrails.md|Guardrails|Guardrails"
|
|
61
|
-
"service-index.md|Service Index|ServiceIndex"
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
# read_fm_field FILE FIELD — print a top-level frontmatter scalar (quotes stripped).
|
|
65
|
-
read_fm_field() {
|
|
66
|
-
awk -v field="$2" '
|
|
67
|
-
NR==1 { if ($0 != "---") exit; next }
|
|
68
|
-
/^---[[:space:]]*$/ { exit }
|
|
69
|
-
{
|
|
70
|
-
if (index($0, field ":") == 1) {
|
|
71
|
-
sub("^" field ":[[:space:]]*", "")
|
|
72
|
-
gsub(/^"|"$/, "")
|
|
73
|
-
print
|
|
74
|
-
exit
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
' "$1"
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# --- write the bundle root index.md ---
|
|
81
|
-
PROJECT=""
|
|
82
|
-
for probe in architecture.md .ai-context.md product.md .ai-profile.md; do
|
|
83
|
-
if [[ -f "$DIR/$probe" ]]; then
|
|
84
|
-
PROJECT="$(read_fm_field "$DIR/$probe" project)"
|
|
85
|
-
[[ -n "$PROJECT" ]] && break
|
|
86
|
-
fi
|
|
87
|
-
done
|
|
88
|
-
[[ -n "$PROJECT" && "$PROJECT" != "{PROJECT_NAME}" ]] || PROJECT="$(basename "$(cd "$DIR/.." && pwd)")"
|
|
89
|
-
|
|
90
|
-
INDEX="$DIR/index.md"
|
|
91
|
-
{
|
|
92
|
-
# Bundle-root index.md: frontmatter is permitted only to declare okf_version (§11).
|
|
93
|
-
printf -- '---\n'
|
|
94
|
-
printf 'okf_version: "0.1"\n'
|
|
95
|
-
printf -- '---\n\n'
|
|
96
|
-
printf '# %s — Draft Context Bundle\n\n' "$PROJECT"
|
|
97
|
-
printf 'Open Knowledge Format (OKF) bundle root. Each concept below is a markdown file with a `type` frontmatter field; the links form the navigable knowledge graph.\n'
|
|
98
|
-
|
|
99
|
-
# Context concepts (only if at least one is present)
|
|
100
|
-
context=""
|
|
101
|
-
for entry in "${CONCEPTS[@]}"; do
|
|
102
|
-
IFS='|' read -r fname label expected <<< "$entry"
|
|
103
|
-
[[ -f "$DIR/$fname" ]] || continue
|
|
104
|
-
t="$(read_fm_field "$DIR/$fname" type)"
|
|
105
|
-
[[ -n "$t" ]] || t="$expected"
|
|
106
|
-
d="$(read_fm_field "$DIR/$fname" description)"
|
|
107
|
-
desc="${d:-$t concept}"
|
|
108
|
-
context+="$(printf -- '* [%s](%s) - %s' "$label" "$fname" "$desc")"$'\n'
|
|
109
|
-
done
|
|
110
|
-
if [[ -n "$context" ]]; then
|
|
111
|
-
printf '\n# Context\n\n%s' "$context"
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
# Tracks
|
|
115
|
-
if [[ -f "$DIR/tracks.md" || -d "$DIR/tracks" ]]; then
|
|
116
|
-
printf '\n# Tracks\n\n'
|
|
117
|
-
[[ -f "$DIR/tracks.md" ]] && printf -- '* [Track Index](tracks.md) - active, completed, and archived tracks\n'
|
|
118
|
-
if [[ -d "$DIR/tracks" ]]; then
|
|
119
|
-
for td in "$DIR"/tracks/*/; do
|
|
120
|
-
[[ -d "$td" ]] || continue
|
|
121
|
-
id="$(basename "$td")"
|
|
122
|
-
[[ -f "$td/spec.md" ]] || continue
|
|
123
|
-
title="$id"
|
|
124
|
-
if command -v jq >/dev/null 2>&1 && [[ -f "$td/metadata.json" ]]; then
|
|
125
|
-
mt="$(jq -r '.title // empty' "$td/metadata.json" 2>/dev/null || true)"
|
|
126
|
-
[[ -n "$mt" ]] && title="$mt"
|
|
127
|
-
fi
|
|
128
|
-
printf -- '* [%s](tracks/%s/spec.md) - track %s\n' "$title" "$id" "$id"
|
|
129
|
-
done
|
|
130
|
-
fi
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
# Knowledge graph sub-bundle
|
|
134
|
-
if [[ -f "$DIR/graph/okf/index.md" ]]; then
|
|
135
|
-
printf '\n# Knowledge graph\n\n'
|
|
136
|
-
printf -- '* [Graph bundle](graph/okf/index.md) - structural knowledge graph (modules, dependencies, hotspots)\n'
|
|
137
|
-
fi
|
|
138
|
-
} > "$INDEX"
|
|
139
|
-
|
|
140
|
-
echo "OKF bundle root written to $INDEX"
|
|
141
|
-
exit 0
|