@chrono-meta/fh-gate 1.4.16 → 1.4.18

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.
@@ -0,0 +1,432 @@
1
+ ---
2
+ name: install-wizard-detail
3
+ description: Detail reference for install-wizard — Mode D companion setup, detection bash, report/proposal formats, execution blocks, baseline bash. Load when executing a specific step.
4
+ load: on-demand
5
+ ---
6
+
7
+ # install-wizard — Detail Reference
8
+
9
+ > Load when executing a specific step. SKILL.md contains key terms, execution modes, core principles, the step overview, behavioral rules per step, environment adaptation, cluster loading, and Done When.
10
+
11
+ ---
12
+
13
+ ## §Mode-D-Companion-Setup
14
+
15
+ Guide companion-store setup before Step 1 when Mode D (FH developer/researcher) is detected:
16
+
17
+ ```
18
+ You're developing FH itself — you need a private companion store
19
+ alongside the public mirror.
20
+
21
+ Recommended layout:
22
+ public: {org}/{hub} (methodology, skills, rules)
23
+ private: {org}/{hub}-be (paper drafts, experiment logs,
24
+ raw signals, handoff files)
25
+
26
+ Quick setup (remote-backed):
27
+ gh repo create {org}/{hub}-be --private
28
+ git clone https://github.com/{org}/{hub}-be ~/path/to/{hub}-be
29
+ mkdir -p {hub}-be/{paper-drafts,paper-signals,digests,handoff}
30
+
31
+ Local-only variant (no GitHub — your data never leaves the machine):
32
+ git init ~/path/to/{hub}-be # no remote needed
33
+ mkdir -p ~/path/to/{hub}-be/{paper-drafts,paper-signals,digests,handoff}
34
+ → the sync script detects the missing upstream and skips push
35
+ automatically; local git history carries durability. Any store
36
+ name works — set BE_DIR (and HUB_DIR) env vars to your paths.
37
+
38
+ Key rule: knowledge/shared/ drafts stay local via .gitignore glob.
39
+ Push snapshots to the companion store explicitly — never auto-push.
40
+ handoff/ files bridge cloud session → local without exposing content.
41
+ ```
42
+
43
+ ---
44
+
45
+ ## §Token-Injection
46
+
47
+ **Method A — One-time injection per session (recommended):**
48
+ ```bash
49
+ # In terminal before starting CC
50
+ export GH_TOKEN=ghp_xxxx # GitHub Personal Access Token
51
+ export GITHUB_TOKEN=$GH_TOKEN # Some CLIs read GITHUB_TOKEN
52
+ claude # gh / git commands will automatically use token afterward
53
+ ```
54
+
55
+ **Method B — Permanent local secret file:**
56
+ ```bash
57
+ mkdir -p ~/.cc_secrets
58
+ echo 'export GH_TOKEN=ghp_xxxx' >> ~/.cc_secrets/tokens.env
59
+ chmod 600 ~/.cc_secrets/tokens.env
60
+ echo 'source ~/.cc_secrets/tokens.env' >> ~/.zshrc
61
+ ```
62
+
63
+ > `~/.cc_secrets/` is a local-only path outside git management — not a commit target for team repos.
64
+
65
+ ---
66
+
67
+ ## §Step0-Detection-Bash
68
+
69
+ Environment detection procedures that CC executes automatically. No need for users to run manually.
70
+
71
+ ```bash
72
+ # Prompt injection pre-flight: scan config AND the project's AI-instruction surfaces — CLAUDE.md,
73
+ # AGENTS.md, .claude/rules/* — which are the higher-risk vectors in an unknown repo (not just shell/settings).
74
+ # Injection-SPECIFIC patterns only (override/exfil), since instruction files legitimately carry directives;
75
+ # advisory (recommend manual review), never an auto-block.
76
+ if grep -rIE "ignore (all )?previous|disregard (the )?above|exfiltrat|^# CLAUDE:|^# AI:|<instructions>" \
77
+ ~/.zshrc .claude/settings.json CLAUDE.md AGENTS.md .claude/rules/ 2>/dev/null | grep -q .; then
78
+ echo "⚠️ AI-instruction / override pattern detected in config or instruction files — injection risk in an unknown repo. Review the listed files manually before proceeding."; fi
79
+
80
+ # FH location
81
+ echo "FH_DIR=${FH_DIR:-not set}"
82
+ echo "CC_HUB_DIR=${CC_HUB_DIR:-not set}"
83
+
84
+ # cwd project info
85
+ basename "$(pwd)"
86
+ ls .claude/ 2>/dev/null
87
+
88
+ # CC settings (handle both dict and list for plugins)
89
+ cat .claude/settings.json 2>/dev/null | python3 -c "
90
+ import json,sys
91
+ d=json.load(sys.stdin)
92
+ p=d.get('plugins',{})
93
+ print('plugins:', list(p.keys()) if isinstance(p,dict) else p)
94
+ " 2>/dev/null || echo "settings.json not found"
95
+
96
+ # MCP plugin connection status
97
+ python3 -c "import json,os; d=json.load(open(os.path.expanduser('~/.claude.json'))); print('MCP:', list(d.get('mcpServers',{}).keys()))" 2>/dev/null || echo "MCP config not found"
98
+
99
+ # zshrc hook status
100
+ grep -q "fh_audit_check.zsh" ~/.zshrc 2>/dev/null && echo "zshrc hook: present" || echo "zshrc hook: absent"
101
+
102
+ # Framework detection (optional) — only used to look for a matching OPTIONAL domain pattern pack.
103
+ # Generic: capture the framework name; the pattern-pack path is derived as {framework}_patterns.md.
104
+ # No pattern pack ships by default — this is a user-supplied extension point, absence is the normal state.
105
+ FRAMEWORK=""
106
+ for fw in streamlit django fastapi flask; do
107
+ if grep -qi "$fw" requirements.txt pyproject.toml 2>/dev/null; then FRAMEWORK="$fw"; echo "Framework: $fw detected"; break; fi
108
+ done
109
+ ```
110
+
111
+ **Bootstrap guidance when FH_DIR is not set (stop immediately in Step 0):**
112
+ ```
113
+ ⚠️ FH_DIR not set — install FH first then rerun.
114
+
115
+ 1. Clone FH repo:
116
+ git clone https://github.com/chrono-meta/forge-harness ~/forge-harness
117
+
118
+ 2. Set environment variables:
119
+ export FH_DIR=~/forge-harness
120
+ export CC_HUB_DIR=$FH_DIR # FH hub dir (holds tracks/_audit for the weekly-audit mtime check);
121
+ # equals FH_DIR unless you run a separate hub clone
122
+
123
+ 3. Install FH plugin in CC:
124
+ Settings → Plugins → Add → {FH_DIR}/plugins/fh-meta
125
+
126
+ 4. Rerun /install-wizard after completion
127
+ ```
128
+
129
+ ---
130
+
131
+ ## §Env-Card-Format
132
+
133
+ Output detection results as **environment card**. If a framework was detected AND you maintain a matching
134
+ optional domain pattern pack, reference it (none ship by default — absence is normal, never a gap):
135
+ ```
136
+ 📌 {FRAMEWORK} project detected → optional domain pattern pack check
137
+ {CC_HUB_DIR}/knowledge/shared/{FRAMEWORK}_patterns.md loaded (only if you supplied it; not shipped by default)
138
+ If absent: skip silently — no pack is the expected default state.
139
+ ```
140
+
141
+ ```
142
+ install-wizard — Environment Detection
143
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+ Project: {cwd name}
145
+ FH_DIR: {path or not set}
146
+ CC Hub: {CC_HUB_DIR or not set}
147
+ Plugins: {installed plugin list}
148
+ zshrc hook: {present/absent}
149
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
150
+ ```
151
+
152
+ ---
153
+
154
+ ## §Step0C-Integration
155
+
156
+ **Illustrative single-run measurements** (n=1 per project, `--dry-run` verified — not benchmarks; your numbers will differ):
157
+
158
+ | Project type | Example | Total volume | Reduction | Main cause |
159
+ |---|---|---|---|---|
160
+ | QA strategy platform (domain-specialized complete) | Project A | 324 lines | **14%** (46 lines) | Duplicate meta operation rules |
161
+ | Mobile QA automation framework | Project B | 2,448 lines (constant) | **32%** (~790 lines) | 2 unremoved duplicate files post-install |
162
+
163
+ Token savings: Project A ~0.5K/session, Project B ~15~20K/session
164
+
165
+ * QA strategy platform level = CLAUDE.md 200~400 lines, 5~10 rules files. Mobile QA automation level = 7+ rule files, 2,000+ lines of constant context.
166
+ * Check your own project numbers directly with `/install-wizard --dry-run`. (These numbers are from actual single measurements and may vary by environment.)
167
+
168
+ **How to read**: FH does not touch domain-specific rules (code guides, domain knowledge).
169
+ Reduction targets are only meta operation rules (PR procedures, commit guides, FH path duplicates, etc.).
170
+
171
+ **Detection bash:**
172
+
173
+ ```bash
174
+ # Detect existing harness scale
175
+ CLAUDE_MD_LINES=$(wc -l < CLAUDE.md 2>/dev/null || echo 0)
176
+ RULES_COUNT=$(ls .claude/rules/*.md 2>/dev/null | wc -l || echo 0)
177
+
178
+ echo "CLAUDE.md: ${CLAUDE_MD_LINES} lines"
179
+ echo ".claude/rules/: ${RULES_COUNT} files"
180
+
181
+ # Existing harness detected: CLAUDE.md > 50 lines OR 3+ rules
182
+ if [ "$CLAUDE_MD_LINES" -gt 50 ] || [ "$RULES_COUNT" -ge 3 ]; then
183
+ echo "STATUS: Existing harness detected → proceeding with integration analysis"
184
+ else
185
+ echo "STATUS: New install → move to Step 1"
186
+ fi
187
+ ```
188
+
189
+ **Integration analysis output format:**
190
+
191
+ ```
192
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
193
+ Existing Harness Integration Analysis
194
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
195
+ CLAUDE.md current: {X} lines
196
+ .claude/rules/: {N} files
197
+
198
+ Duplicates (FH-covered): {A} items → can be removed
199
+ FH-delegatable: {B} items → replaceable with skills
200
+ Project-specific: {C} items → keep
201
+
202
+ Expected after integration: CLAUDE.md {X} → {Y} lines ({Z}% reduction)
203
+ Token savings estimate: ~{W}K tokens/session saved
204
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
205
+
206
+ Show integration plan?
207
+ Y — Per-item removal/delegation detailed proposal (applied in subsequent Step 1)
208
+ N — Continue with add-only approach (keep existing rules)
209
+ S — Skip for now, move directly to Step 1. Can reanalyze later with /install-wizard --dry-run
210
+ ```
211
+
212
+ ---
213
+
214
+ ## §Step1-Checks
215
+
216
+ Auto-check the following items based on detected environment. Each item classified as PASS / MISS / FAIL.
217
+
218
+ | Check item | Criteria | Verification method |
219
+ |---|---|---|
220
+ | `.claudeignore` | Existence | `ls .claudeignore` |
221
+ | `local_fh_context.md` | Existence in `.claude/rules/` | `ls .claude/rules/local_fh_context.md` |
222
+ | `zshrc hook` | Contains `fh_audit_check.zsh` source line | `grep fh_audit_check.zsh ~/.zshrc` |
223
+ | `weekly_audit` latest | Within 7 days | CC_HUB_DIR/tracks/_audit/ mtime |
224
+ | `sentinel` setup | `~/.cc_sentinels/` exists | `ls ~/.cc_sentinels/` |
225
+ | FH plugin install | `installed_plugins.json` has `fh-meta` entry | `python3 -c "import json,os; d=json.load(open(os.path.expanduser('~/.claude/plugins/installed_plugins.json'))); print([k for k in d.get('plugins',{}) if 'fh-meta' in k])"` |
226
+ | `.git/info/exclude` | Personal files excluded | grep local_fh_context .git/info/exclude |
227
+ | MCP plugin | ~/.claude.json mcpServers contains entry | `python3 -c "import json,os; d=json.load(open(os.path.expanduser('~/.claude.json'))); print(list(d.get('mcpServers',{}).keys()))"` |
228
+ | `deep-insight plugin` | settings.json plugins contains deep-insight | `grep -r "deep-insight" .claude/settings.json 2>/dev/null` |
229
+ | `fh_env_context.jsonc` | `.claude/rules/fh_env_context.jsonc` exists | `ls .claude/rules/fh_env_context.jsonc` |
230
+ | `phantom-gate` | **(Python + AI-output projects only)** `phantom-gate` present in `requirements.txt` / `pyproject.toml` | `grep "phantom.gate" requirements.txt pyproject.toml 2>/dev/null` |
231
+ | `Domain pattern pack applied` | (optional — only when a `{framework}_patterns.md` pack is present; none ship by default) framework-specific pattern checks | `knowledge/shared/{framework}_patterns.md` check (skip if file absent — the normal default) |
232
+
233
+ ---
234
+
235
+ ## §Step2-Formats
236
+
237
+ **Diagnosis report + proposal list:**
238
+
239
+ ```
240
+ install-wizard — Diagnosis Results ({score}/100)
241
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
242
+ ✅ PASS .claudeignore exists
243
+ ⚠️ MISS local_fh_context.md absent
244
+ ⚠️ MISS zshrc hook absent
245
+ ❌ FAIL weekly_audit 12 days elapsed
246
+ ✅ PASS FH plugin installed
247
+ ⚠️ MISS MCP plugin absent
248
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
249
+
250
+ 📋 Proposal list (per-item approval required before execution):
251
+
252
+ [1] Install local_fh_context.md — FH skill auto-recognition
253
+ [2] Add zshrc hook — periodic audit notification on terminal start
254
+ [3] Run weekly_audit immediately — call /harvest-loop (lightweight mode)
255
+ [4] Initialize ~/.cc_sentinels/ — project audit tracking
256
+ [5] Install fh-meta plugin — activate all FH skills (if FH plugin MISS)
257
+ AI executes automatically via Bash — no manual terminal input needed:
258
+ claude plugin marketplace add https://github.com/chrono-meta/forge-harness.git
259
+ claude plugin install -s user fh-meta@forge-harness
260
+ CC restart required after completion for skills to appear in /skills list
261
+ [6] Add MCP plugin — activate integrations (if MCP plugin MISS)
262
+ Run: claude mcp add <your-mcp-plugin> -- npx -y <your-mcp-plugin>
263
+ CC restart required after completion
264
+ [7] (Optional — field plugin, NOT required) Install deep-insight — adds the field's domain personas to sim-conductor
265
+ deep-insight is a private/field marketplace plugin. sim-conductor already ships the built-in
266
+ user-mastery spectrum (beginner · main-player · expert · challenger), so multi-persona simulation
267
+ works WITHOUT it. If you have access: Settings → Plugins → Add → <your deep-insight path>.
268
+ If not: skip — sim-conductor falls back to the built-in spectrum agents (no capability lost).
269
+ [8] Create fh_env_context.jsonc — org/network/Git environment context file (if fh_env_context.jsonc MISS)
270
+ Copy: {FH_DIR}/templates/fh_env_context.jsonc → .claude/rules/fh_env_context.jsonc
271
+ Then manually update with actual values for org name, Jira URL, environment status, etc.
272
+ Effect: Each skill references common environment context → eliminate individual setting duplication
273
+ [9] Install phantom-gate — AI output hallucination detection (Python + AI-output projects only, if MISS)
274
+ Run: pip install git+https://github.com/chrono-meta/phantom-gate.git
275
+ Usage: phantom-gate scan output.txt / phantom-gate scan . --project
276
+ Detectors: M1 (phantom claims) · M2 (self-reference loops) · M3 (unvalidated external-dep claims) · M4 (temporal) · M5 (cross-file version mismatch)
277
+ Skip condition: non-Python project OR no AI-generated output in pipeline
278
+
279
+
280
+ Each item: Y (approve) / N (skip) / L (later) / A (approve all)
281
+ ```
282
+
283
+ **cross-install detection output format:**
284
+ ```
285
+ 🔍 cross-install detected: {skill name} ({trigger keywords})
286
+ → agent-composer mapping gap confirmed
287
+ → auto-update proposal included in Step 3
288
+ ```
289
+
290
+ **`--dry-run` exit message:**
291
+ ```
292
+ install-wizard [dry-run] — Analysis complete ({score}/100)
293
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
294
+ MISS/FAIL items: {N} — rerun /install-wizard to execute
295
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
296
+ ```
297
+
298
+ ---
299
+
300
+ ## §Step3-Execution
301
+
302
+ **Action preview example (local_fh_context.md install):**
303
+ ```
304
+ ▶ [1] Install local_fh_context.md
305
+ Copy: {FH_DIR}/templates/local_fh_context.md
306
+ → .claude/rules/local_fh_context.md
307
+ Exclude: add pattern to .git/info/exclude
308
+ Execute? (Y/N):
309
+ ```
310
+
311
+ **FH plugin auto-install execution block** — when FH plugin is MISS, execute via Bash (no manual input required):
312
+
313
+ ```bash
314
+ # Step A: register marketplace (idempotent — "already on disk" is OK)
315
+ claude plugin marketplace add https://github.com/chrono-meta/forge-harness.git 2>&1
316
+
317
+ # Step B: install plugin
318
+ claude plugin install -s user fh-meta@forge-harness 2>&1
319
+ ```
320
+
321
+ **Error handling:**
322
+
323
+ | Output | Meaning | Action |
324
+ |---|---|---|
325
+ | `✔ Marketplace ... already on disk` | Already registered | Continue to Step B |
326
+ | `✔ Successfully installed` | Done | Report success, remind CC restart |
327
+ | `Plugin "fh-meta" not found` | Marketplace cache stale | Run `claude plugin marketplace update forge-harness` then retry Step B |
328
+ | Any other error | Unknown failure | Report error verbatim, ask user to retry manually |
329
+
330
+ **Output format on success:**
331
+ ```
332
+ ▶ [5] Install fh-meta plugin
333
+ ✅ Marketplace: forge-harness registered
334
+ ✅ Plugin: fh-meta@forge-harness installed (scope: user)
335
+ ⚠️ CC restart needed — skills will appear in /skills after restart
336
+ ```
337
+
338
+ **agent-composer mapping update** (when skills were added via cross-install):
339
+
340
+ For skills with confirmed agent-composer mapping gaps from Step 2 cross-install detection,
341
+ propose adding rows to `agent-composer/SKILL.md` Step 1 mapping table in this format:
342
+
343
+ ```
344
+ | {skill name} related task | {skill name} (S) | — |
345
+ ```
346
+
347
+ Output preview before execution:
348
+ ```
349
+ ▶ agent-composer mapping update
350
+ Add to: agent-composer/SKILL.md Step 1 table
351
+ | {skill name} related task | {skill name} (S) | — |
352
+ Execute? (Y/N):
353
+ ```
354
+
355
+ ---
356
+
357
+ ## §Step4-Baseline-Bash
358
+
359
+ ```bash
360
+ # zshrc hook (if not installed — preview then confirm, idempotent)
361
+ if ! grep -q "fh_audit_check.zsh" ~/.zshrc 2>/dev/null; then
362
+ cat >> ~/.zshrc << 'EOF'
363
+ export FH_DIR="{FH_DIR}"
364
+ export CC_HUB_DIR="{CC_HUB_DIR}"
365
+ export CC_SENTINELS_DIR="$HOME/.cc_sentinels"
366
+ source "$FH_DIR/templates/fh_audit_check.zsh"
367
+ EOF
368
+ fi
369
+
370
+ # 4-axis verification gate (Mode D / FH-self-development only — OPT-IN, double-confirm required)
371
+ # SCOPE (state this before asking): this gates commits IN YOUR FH CLONE ($FH_DIR) — git commit there is
372
+ # blocked until the 4-axis markers pass. It is FH-internal infra (hardcodes hub paths/markers) and is
373
+ # NEVER installed into field projects (see auto_project_mapping.md §6). Skip unless you develop FH itself.
374
+ # Per Core Principles (Per-item approval + Double-confirm irreversible changes): this is NOT auto-run —
375
+ # it is a separate explicit Y/N, not folded into the baseline-setup batch.
376
+ if [ -d "$FH_DIR/templates/.git-hooks" ]; then
377
+ echo "Enable the 4-axis pre-commit gate on your FH clone ($FH_DIR)? It will block commits there until"
378
+ echo "markers pass (Mode D / FH-development only). Skip if you are not developing FH itself. (Y/N)"
379
+ # → On explicit Y only:
380
+ git -C "$FH_DIR" config core.hooksPath templates/.git-hooks
381
+ chmod +x "$FH_DIR/templates/.git-hooks/pre-commit" 2>/dev/null
382
+ echo "4-axis pre-commit gate: installed (core.hooksPath -> templates/.git-hooks)"
383
+ fi
384
+
385
+ # sentinel initialization (per-project independent — prevent conflicts with other projects on same machine)
386
+ mkdir -p ~/.cc_sentinels
387
+ touch ~/.cc_sentinels/$(basename "$(pwd)")_wizard_done
388
+
389
+ # Weekly audit cadence — NO cron needed (a session-scoped scheduler cannot fire on a later day).
390
+ # Durable mechanism = the zshrc hook above (fh_audit_check.zsh warns on terminal start when 7+ days
391
+ # since last weekly_audit) + FH session-start detection (proposes /harvest-loop lightweight when overdue).
392
+ ```
393
+
394
+ ---
395
+
396
+ ## §Step5-Completion-Report
397
+
398
+ ```
399
+ install-wizard — Complete
400
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
401
+ ✅ Executed: {N} ⏭ Skipped: {N} ⏳ Later: {N}
402
+
403
+ From now on:
404
+ · Periodic audit auto-check on terminal start
405
+ · Yellow warning output when weekly_audit exceeds 7 days
406
+ · /harvest-loop (lightweight) proposed at session start when 7+ days since last weekly_audit
407
+
408
+ Next step skills:
409
+ · Not sure which plugin you need → /plugin-recommender
410
+ · Need complex task automation → /agent-composer
411
+ · Quality audit before publishing external assets → hub-persona-auditor auto-run
412
+ (select "external user entry point audit" task type when composing in agent-composer)
413
+
414
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
415
+ 💡 If this setup helped, consider contributing to FH.
416
+ Pattern discovered → return with /field-harvest
417
+ New skill proposal → PR:
418
+ https://github.com/chrono-meta/forge-harness
419
+
420
+ 🔬 Developing FH itself? Set up a private companion store:
421
+ gh repo create {org}/{hub}-be --private # paper drafts, experiment logs, handoffs
422
+ (or local-only: git init ~/path/{hub}-be — no remote; push is auto-skipped)
423
+ → public mirror holds methodology · private store holds research artifacts
424
+ → field projects (internal harness) can use the same dual-repo pattern
425
+
426
+ 🔀 Don't want to lose your accumulated assets — fork as your own hub:
427
+ Personal skills/rules/notes added directly to FH may be lost on FH updates.
428
+ git clone <FH_URL> ~/my-forge # name is up to you (my-forge, team-forge, etc.)
429
+ → Build freely in your fork and preserve permanently with git
430
+ → When you discover valuable patterns, /field-harvest to reverse-contribute to FH anytime
431
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
432
+ ```