@whitehatd/crag 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +94 -120
  2. package/package.json +6 -2
package/README.md CHANGED
@@ -72,31 +72,28 @@ The same universal skills — written once, never modified per project — disco
72
72
 
73
73
  ## The Architecture
74
74
 
75
- ```mermaid
76
- flowchart TB
77
- subgraph SHIPPED["Ships with crag (universal)"]
78
- direction LR
79
- PRE["pre-start skill\ndiscovers ANY project"]
80
- POST["post-start skill\nvalidates using YOUR gates"]
81
- end
82
-
83
- subgraph GENERATED["Generated from interview or analyze (project-specific)"]
84
- GOV["governance.md\n20-30 lines of YOUR rules"]
85
- end
86
-
87
- subgraph ALSO["Also generated"]
88
- HOOKS["hooks/"]
89
- AGENTS["agents/"]
90
- SETTINGS["settings"]
91
- end
92
-
93
- PRE -->|"reads at runtime"| GOV
94
- POST -->|"reads at runtime"| GOV
95
-
96
- style SHIPPED fill:#1a3a1a,stroke:#00ff88,color:#eee
97
- style GENERATED fill:#3a2a1a,stroke:#ffbb33,color:#eee
98
- style GOV fill:#3a2a1a,stroke:#ffbb33,color:#eee
99
- style ALSO fill:#0f3460,stroke:#00d2ff,color:#eee
75
+ ```
76
+ ┌──────────────────────────────────────────────────────────────┐
77
+ Ships with crag (universal — same for every project)
78
+ │ │
79
+ │ ┌──────────────────────┐ ┌──────────────────────┐ │
80
+ │ │ pre-start skill │ post-start skill │ │
81
+ │ │ discovers ANY │ │ validates using │ │
82
+ │ │ project │ │ YOUR gates │ │
83
+ │ └──────────┬───────────┘ └──────────┬───────────┘ │
84
+ └─────────────┼───────────────────────────────┼───────────────┘
85
+ │ │
86
+ │ reads at runtime │ reads at runtime
87
+ ▼ ▼
88
+ ┌──────────────────────────────────────────────────────────────┐
89
+ │ Generated from interview or analyze (project-specific) │
90
+ │ │
91
+ │ ┌────────────────────────────────────────────┐ │
92
+ │ │ governance.md — 20-30 lines of YOUR rules │ │
93
+ │ └────────────────────────────────────────────┘ │
94
+ │ │
95
+ │ Also generated: hooks/ agents/ settings │
96
+ └──────────────────────────────────────────────────────────────┘
100
97
  ```
101
98
 
102
99
  The skills ship once and work forever. They don't know your stack — they discover it. They don't know your gates — they read them from governance.md. Add a service, change your CI, switch frameworks — the skills adapt. Nothing to update.
@@ -565,41 +562,31 @@ crag compile # Or list targets interactively
565
562
 
566
563
  The compiler parses your gates, auto-detects runtimes from the commands (Node, Rust, Python, Java, Go, Docker), and generates the right setup steps with proper version inference from your project files (not hardcoded defaults). Human-readable `Verify X contains Y` gates are compiled to `grep` commands automatically (with shell-injection-safe escaping). All 12 targets write atomically (temp file + rename) so partial failures leave the old state intact.
567
564
 
568
- ```mermaid
569
- flowchart LR
570
- GOV["governance.md\n(one file)"]
571
-
572
- subgraph CI["CI / git hooks"]
573
- GH["gates.yml"]
574
- HK["husky"]
575
- PC["pre-commit"]
576
- end
577
-
578
- subgraph NATIVE["AI native"]
579
- AM["AGENTS.md"]
580
- CR["Cursor MDC"]
581
- GM["GEMINI.md"]
582
- end
583
-
584
- subgraph EXTRAS["AI extras"]
585
- CO["Copilot"]
586
- CL["Cline"]
587
- CN["Continue"]
588
- WS["Windsurf"]
589
- ZE["Zed"]
590
- CY["Cody"]
591
- end
592
-
593
- GOV --> CI
594
- GOV --> NATIVE
595
- GOV --> EXTRAS
596
- GOV -->|"read at runtime"| SKILL["Universal skills"]
597
-
598
- style GOV fill:#3a2a1a,stroke:#ffbb33,color:#eee
599
- style CI fill:#0f3460,stroke:#00d2ff,color:#eee
600
- style NATIVE fill:#1a3a1a,stroke:#00ff88,color:#eee
601
- style EXTRAS fill:#2a1a3a,stroke:#bb86fc,color:#eee
602
- style SKILL fill:#1a3a1a,stroke:#00ff88,color:#eee
565
+ ```
566
+ ┌────────────────────┐
567
+ governance.md
568
+ │ (one file) │
569
+ └──────────┬─────────┘
570
+
571
+ crag compile --target all
572
+
573
+ ┌─────────────────────────┼─────────────────────────┐
574
+ │ │ │
575
+ ▼ ▼ ▼
576
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
577
+ CI / hooks │ │ AI native │ │ AI extras │
578
+ ├─────────────┤ ├─────────────┤ ├─────────────┤
579
+ │ gates.yml │ │ AGENTS.md │ │ Copilot │
580
+ │ husky │ │ Cursor MDC │ │ Cline │
581
+ pre-commit │ │ GEMINI.md │ │ Continue │
582
+ └─────────────┘ └─────────────┘ │ Windsurf │
583
+ │ Zed │
584
+ │ Cody
585
+ └─────────────┘
586
+
587
+ + read at runtime by
588
+ universal skills
589
+ (pre-start / post-start)
603
590
  ```
604
591
 
605
592
  Governance-as-config that compiles to agent behavior, CI/CD pipelines, and **9 different AI coding tool configs** from a single 20-line file.
@@ -674,71 +661,58 @@ The update checker queries the npm registry (cached for 24 hours, 3s timeout, gr
674
661
 
675
662
  ## Why Everything Else Is Static
676
663
 
677
- ```mermaid
678
- flowchart LR
679
- subgraph STATIC["Current ecosystem"]
680
- T["CLAUDE.md / AGENTS.md\nStatic config files\nHardcode project facts\nRot when project changes"]
681
- C["Skill collections\n1,234+ skills\nPick per project\nManual assembly"]
682
- I["Templates\nOne stack per template\nCopy and modify\nNo runtime discovery"]
683
- end
684
-
685
- subgraph RUNTIME["crag"]
686
- U["Universal skills\nDiscover at runtime\nWork for any stack\nNever go stale"]
687
- G["governance.md\n20-30 lines\nYour rules only\nHuman-controlled"]
688
- end
689
-
690
- T -->|"manual updates required"| STALE["Stale instructions"]
691
- C -->|"wrong skill for new stack"| MISMATCH["Stack mismatch"]
692
- I -->|"facts change"| ROT["Template rot"]
693
- U -->|"reads filesystem every session"| FRESH["Always current"]
694
- G -->|"changes only when you decide"| STABLE["Your standards"]
695
-
696
- style STATIC fill:#3a1a1a,stroke:#ff6b6b,color:#eee
697
- style RUNTIME fill:#1a3a1a,stroke:#00ff88,color:#eee
698
- style STALE fill:#3a1a1a,stroke:#ff6b6b,color:#eee
699
- style MISMATCH fill:#3a1a1a,stroke:#ff6b6b,color:#eee
700
- style ROT fill:#3a1a1a,stroke:#ff6b6b,color:#eee
701
- style FRESH fill:#1a3a1a,stroke:#00ff88,color:#eee
702
- style STABLE fill:#3a2a1a,stroke:#ffbb33,color:#eee
703
- ```
664
+ | Current ecosystem | Why it rots | crag's approach |
665
+ |-------------------------------------------|--------------------------------------|------------------------------------------------|
666
+ | **CLAUDE.md / AGENTS.md** static files | Hardcode project facts; manual edits | **Universal skills** read filesystem every session — always current |
667
+ | **Skill collections** (1,234+ skills) | Pick-per-project; stack mismatch | **One engine** that works for any stack |
668
+ | **Per-framework templates** | One stack per template; rot on change | **`governance.md`** — 20–30 lines of YOUR rules only, human-controlled |
669
+
670
+ **The difference:** everything else tries to pack facts INTO config files. crag reads facts FROM the filesystem at runtime. The skills don't know your stack — they discover it. The governance doesn't know your paths — it holds your rules.
704
671
 
705
672
  ---
706
673
 
707
674
  ## The Session Loop
708
675
 
709
- ```mermaid
710
- flowchart LR
711
- subgraph PRE["Pre-start (universal)"]
712
- direction TB
713
- W["Warm start?\n.session-state.json"]
714
- IC["Classify intent\nscope discovery"]
715
- CC["Cache valid?\n.discovery-cache.json"]
716
- W --> IC --> CC
717
- CC -->|"hit"| FAST["Fast path\nskip 80% of discovery"]
718
- CC -->|"miss"| FULL["Full discovery\ndetect stack · load memory"]
719
- FAST --> GOV["Read governance"]
720
- FULL --> GOV
721
- end
722
-
723
- TASK["Your task"]
724
-
725
- subgraph POST["Post-start (universal)"]
726
- direction TB
727
- V1["Detect changes"]
728
- V2["Run governance gates"]
729
- V2 -->|"fail"| FIX["Auto-fix\n(bounded retry)"]
730
- FIX --> V2
731
- V2 -->|"pass"| V3["Security review"]
732
- V3 --> V4["Capture knowledge"]
733
- V4 --> V5["Write session state\nCommit · Deploy"]
734
- end
735
-
736
- PRE --> TASK --> POST
737
- POST -.->|"cache + state + knowledge"| PRE
738
-
739
- style PRE fill:#1a2a3a,stroke:#03dac6,color:#eee
740
- style TASK fill:#2a1a3a,stroke:#bb86fc,color:#eee
741
- style POST fill:#1a3a2a,stroke:#00ff88,color:#eee
676
+ ```
677
+ ┌────────────────────────────────────────────────────────────────┐
678
+ PRE-START (universal skill — runs before every task)
679
+ │ │
680
+ Warm start? Intent? Cache valid? │
681
+ │ .session-state.json classify → .discovery-cache.json │
682
+ │ │ │ │ │
683
+ │ │ │ ┌───────┴───────┐ │
684
+ │ │ │ ▼ ▼ │
685
+ │ │ │ Fast path Full discovery
686
+ │ │ │ (skip 80%) (detect stack, │
687
+ │ │ │ │ load memory) │
688
+ │ └────────────────┴──────────┴───────────────┘ │
689
+ │ │ │
690
+ │ ▼ │
691
+ │ Read governance.md │
692
+ └───────────────────────────────┬────────────────────────────────┘
693
+
694
+
695
+ ┌──────────────────┐
696
+ │ YOUR TASK │
697
+ │ (code changes)
698
+ └────────┬─────────┘
699
+
700
+
701
+ ┌────────────────────────────────────────────────────────────────┐
702
+ │ POST-START (universal skill — runs after every task) │
703
+ │ │
704
+ │ Detect changes Run gates (fail?) → Auto-fix → retry │
705
+ │ │ │
706
+ │ pass │
707
+ │ ▼ │
708
+ │ Security review → Capture knowledge │
709
+ │ │ │
710
+ │ ▼ │
711
+ │ Write session state · Commit │
712
+ └────────────────────────────────┬───────────────────────────────┘
713
+
714
+ │ cache + state + knowledge
715
+ └─────► feeds next session
742
716
  ```
743
717
 
744
718
  ### What makes this loop tight
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@whitehatd/crag",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "The bedrock layer for AI coding agents. One governance.md. Any project. Never stale.",
5
5
  "bin": {
6
6
  "crag": "bin/crag.js"
7
7
  },
8
8
  "scripts": {
9
- "test": "node test/all.js"
9
+ "test": "node test/all.js",
10
+ "sync-hashes": "node scripts/sync-skill-hashes.js",
11
+ "release:patch": "node scripts/bump-version.js patch",
12
+ "release:minor": "node scripts/bump-version.js minor",
13
+ "release:major": "node scripts/bump-version.js major"
10
14
  },
11
15
  "keywords": [
12
16
  "claude-code",