know-thy-build 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "know-thy-build",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Multi-agent project definition & QA framework for Claude Code — Socratic dialogue, behavioral testing axes, design intent, orchestrated review",
5
5
  "bin": {
6
6
  "know-thy-build": "./bin/cli.js"
@@ -40,6 +40,15 @@ FEATURE_FILE="docs/features/$(printf '%03d' $FEATURE_NUM).md"
40
40
 
41
41
  Read the feature spec and extract the gate section from frontmatter.
42
42
 
43
+ ### 3. Read project operations
44
+
45
+ ```bash
46
+ # Check for project-specific merge/deploy requirements
47
+ grep -A 20 '## Operations' docs/PROJECT.md 2>/dev/null
48
+ ```
49
+
50
+ If an Operations section exists, note the project's merge strategy and additional gates. These are checked alongside know-thy-build gates below.
51
+
43
52
  ---
44
53
 
45
54
  ## Gate Check
@@ -70,6 +79,15 @@ Present a clear gate status report:
70
79
 
71
80
  → Stop here. Do NOT proceed with merge.
72
81
 
82
+ ### Project-specific gates (if defined)
83
+
84
+ If `docs/PROJECT.md` has an Operations → Additional Gates section, check those too:
85
+ - **Code review required?** → Verify PR was reviewed (or inform the user to do so)
86
+ - **CI must pass?** → Check CI status or inform the user to verify
87
+ - **Other gates?** → Report status of each
88
+
89
+ > These gates are informational — know-thy-build reports them but cannot enforce external systems. The user is responsible for ensuring project-specific gates pass before proceeding.
90
+
73
91
  ---
74
92
 
75
93
  ## Pre-merge Verification
@@ -131,14 +149,24 @@ Report what will be merged to main:
131
149
 
132
150
  ## Merge
133
151
 
134
- ### 1. Switch to main and merge
152
+ ### 1. Determine merge strategy
153
+
154
+ Check `docs/PROJECT.md` → Operations → Merge Strategy. Default to squash if not defined.
155
+
156
+ | Strategy | Command |
157
+ |----------|---------|
158
+ | squash (default) | `git merge --squash` |
159
+ | rebase | `git rebase main` then fast-forward merge |
160
+ | merge commit | `git merge --no-ff` |
161
+
162
+ ### 2. Switch to main and merge
135
163
 
136
164
  ```bash
137
165
  # Ensure main is up to date
138
166
  git checkout main
139
167
  git pull --ff-only origin main 2>/dev/null || true
140
168
 
141
- # Squash merge
169
+ # Execute the merge strategy determined above (default: squash)
142
170
  git merge --squash "feature/{{NNN}}-{{title_kebab}}"
143
171
  ```
144
172
 
@@ -551,6 +551,40 @@ Accumulate as:
551
551
 
552
552
  **Done when:** Frontier is empty. 2-7 principles captured, or user decides none are needed.
553
553
 
554
+ ### Operations — How does code ship?
555
+
556
+ > What to discover: The project's merge, deploy, and CI workflow. know-thy-build enforces quality gates (architect/designer/qa) BEFORE merge. This area defines what happens AT and AFTER merge — which is project-specific.
557
+
558
+ **Prerequisites:** Vision and Output areas settled.
559
+
560
+ Before asking, **find facts** — scan existing infrastructure:
561
+ ```bash
562
+ cat package.json 2>/dev/null | grep -E '"scripts"|"test"|"lint"|"build"|"deploy"' | head -10
563
+ ls .github/workflows/ .gitlab-ci.yml Jenkinsfile Makefile Dockerfile 2>/dev/null
564
+ cat .github/workflows/*.yml 2>/dev/null | head -40
565
+ ```
566
+
567
+ Present what you found as facts, then ask about decisions:
568
+
569
+ Frontier questions:
570
+
571
+ | Question | Depends on | Type |
572
+ |----------|-----------|------|
573
+ | How do feature branches merge to main? (squash, rebase, merge commit) | — | Decision |
574
+ | How does code reach users? (npm publish, docker, manual deploy, CI/CD trigger) | — | Decision |
575
+ | What automated checks run before merge? (lint, type check, tests) | merge-strategy | Fact (scan CI config) + Decision |
576
+ | Are there review requirements beyond know-thy-build gates? (code review, security scan) | — | Decision |
577
+
578
+ Slots to fill:
579
+ - `{{merge_strategy}}` — squash / rebase / merge commit
580
+ - `{{deploy_method}}` — how releases reach users
581
+ - `{{ci_checks}}` — automated quality checks
582
+ - `{{additional_gates}}` — extra review requirements
583
+
584
+ **Done when:** Frontier is empty. At minimum, merge strategy and deploy method are defined. CI/CD and additional gates can be "none yet" if the project is early.
585
+
586
+ > **Why this matters:** Without explicit operations definitions, sub-agents and hooks cannot enforce project-specific workflows. The merge gate hook only covers know-thy-build's built-in gates — project-specific gates (code review, CI checks) must be defined here so agents know to respect them.
587
+
554
588
  ---
555
589
 
556
590
  ## Checkpoints & State Tracking
@@ -781,6 +815,53 @@ Remove `areasRemaining`, `lastCheckpoint`, and `open` counts.
781
815
 
782
816
  **Technical Foundation:** [TECHNICAL.md](TECHNICAL.md)
783
817
 
818
+ ## Operations
819
+
820
+ <!-- How this project ships code. Each project defines its own workflow.
821
+ know-thy-build gates (architect/designer/qa) enforce quality BEFORE merge.
822
+ Everything below defines what happens AT and AFTER merge. -->
823
+
824
+ ### Merge Strategy
825
+
826
+ <!-- How feature branches become main. know-thy-build defaults to squash merge,
827
+ but your project may differ. -->
828
+
829
+ | Setting | Value |
830
+ |---------|-------|
831
+ | **Strategy** | {{squash / rebase / merge commit}} |
832
+ | **Branch naming** | `feature/NNN-slug` (know-thy-build default) |
833
+ | **Commit format** | `feat(NNN): title` |
834
+
835
+ ### Deploy
836
+
837
+ <!-- How main reaches users. Leave blank if not yet decided. -->
838
+
839
+ | Setting | Value |
840
+ |---------|-------|
841
+ | **Method** | {{npm publish / docker push / manual / CI-triggered / N/A}} |
842
+ | **Target** | {{registry, server, CDN, etc.}} |
843
+ | **Trigger** | {{on tag / on merge to main / manual}} |
844
+
845
+ ### CI/CD
846
+
847
+ <!-- Automated checks that run on push or PR. -->
848
+
849
+ | Check | Tool | Blocks merge? |
850
+ |-------|------|---------------|
851
+ | {{lint}} | {{eslint, ruff, etc.}} | {{yes/no}} |
852
+ | {{type check}} | {{tsc, mypy, etc.}} | {{yes/no}} |
853
+ | {{tests}} | {{jest, pytest, etc.}} | {{yes/no}} |
854
+
855
+ ### Additional Gates
856
+
857
+ <!-- Review requirements beyond know-thy-build's built-in gates.
858
+ Only include gates that actually exist or are planned. Omit if none. -->
859
+
860
+ | Gate | Required? | Who |
861
+ |------|-----------|-----|
862
+ | {{code review}} | {{yes/no}} | {{team lead, any reviewer, etc.}} |
863
+ | {{security scan}} | {{yes/no}} | {{tool name}} |
864
+
784
865
  ---
785
866
 
786
867
  *Generated by know-thy-build | {{date}}*
@@ -961,12 +1042,25 @@ Before any work, the sub-agent MUST read:
961
1042
  - Loop continues until ALL reviewers' criteria are `[x]`
962
1043
  - Only when all three gates pass does `/know-thy-build:finish` proceed
963
1044
 
1045
+ ### Project-Specific Operations
1046
+ The merge gate hook enforces know-thy-build's built-in gates (architect/designer/qa).
1047
+ Your project may have additional requirements defined in `docs/PROJECT.md` → Operations section:
1048
+ - **Merge strategy** — the hook assumes squash merge; adjust if your project uses rebase or merge commits
1049
+ - **CI/CD checks** — if your project requires CI to pass before merge, enforce that separately
1050
+ - **Additional gates** — code review, security scan, etc. are project-level concerns, not managed by know-thy-build
1051
+ - **Deploy** — what happens after merge is entirely project-defined
1052
+
1053
+ When `/know-thy-build:finish` runs, it checks know-thy-build gates. For project-specific gates, the project should either:
1054
+ 1. Add its own hooks to `.claude/settings.json`
1055
+ 2. Or rely on CI/CD and branch protection rules
1056
+
964
1057
  ### Document References
965
1058
  - Project definition: `docs/PROJECT.md`
966
1059
  - Technical foundation: `docs/TECHNICAL.md`
967
1060
  - Feature specs: `docs/features/NNN.md`
968
1061
  - QA test cases: `docs/QA.md`
969
1062
  - Feature registry: `docs/PROJECT.md` → Feature Registry section
1063
+ - Operations: `docs/PROJECT.md` → Operations section
970
1064
  ```
971
1065
 
972
1066
  ## Setup Merge Gate Hook
@@ -981,22 +1075,27 @@ After generating CLAUDE.md, set up the merge gate hook in `.claude/settings.json
981
1075
  #!/usr/bin/env bash
982
1076
  # know-thy-build merge gate — blocks git merge when feature gate is not fully passed
983
1077
 
984
- # Only check if the command contains git merge
985
- if ! echo "$TOOL_INPUT" | grep -qE 'git\s+merge'; then
986
- exit 0
987
- fi
1078
+ # Fast exit: only check commands that contain "git merge"
1079
+ echo "${TOOL_INPUT:-}" | grep -qE 'git\s+merge' || exit 0
988
1080
 
989
- # Find the active feature spec with gate
990
- FEATURE_FILE=$(ls -t docs/features/*.md 2>/dev/null | head -1)
991
- if [ -z "$FEATURE_FILE" ]; then
992
- exit 0
993
- fi
1081
+ # Identify current feature from branch name (feature/NNN-slug)
1082
+ BRANCH=$(git branch --show-current 2>/dev/null || echo "")
1083
+ echo "$BRANCH" | grep -qE '^feature/' || exit 0
1084
+
1085
+ FEATURE_NUM=$(echo "$BRANCH" | grep -oE '[0-9]+' | head -1)
1086
+ [ -z "$FEATURE_NUM" ] && exit 0
1087
+
1088
+ FEATURE_FILE="docs/features/$(printf '%03d' "$FEATURE_NUM").md"
1089
+ [ -f "$FEATURE_FILE" ] || exit 0
1090
+
1091
+ # Skip completed features — their gate is historical, not active
1092
+ grep -qE '^status:\s*complete' "$FEATURE_FILE" 2>/dev/null && exit 0
994
1093
 
995
1094
  # Check gate statuses
996
1095
  PENDING=$(grep -cE '^\s+(architect|designer|qa):\s*pending' "$FEATURE_FILE" 2>/dev/null || echo "0")
997
1096
 
998
1097
  if [ "$PENDING" -gt 0 ]; then
999
- echo "❌ Merge gate blocked — pending reviews exist:"
1098
+ echo "❌ Merge gate blocked — Feature $(printf '%03d' "$FEATURE_NUM") has pending reviews:"
1000
1099
  grep -E '^\s+(architect|designer|qa):' "$FEATURE_FILE" 2>/dev/null
1001
1100
  echo ""
1002
1101
  echo "Run /know-thy-build:finish to check gate status."
@@ -1028,6 +1127,8 @@ exit 0
1028
1127
 
1029
1128
  Make the hook script executable: `chmod +x .claude/hooks/check-merge-gate.sh`
1030
1129
 
1130
+ > **Note for projects**: The `"matcher": "Bash"` fires on every Bash tool call but exits in < 1ms for non-merge commands (first `grep` short-circuits). Claude Code does not support content-based matchers, so this is the lightest possible approach.
1131
+
1031
1132
  ## Closing
1032
1133
 
1033
1134
  **After CREATE:**