@fenglimg/fabric-cli 2.2.0 → 2.3.0-rc.1

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 (74) hide show
  1. package/README.md +2 -2
  2. package/dist/audit-PURSJJFH.js +734 -0
  3. package/dist/{chunk-QPAW6IYT.js → chunk-7V4XMLQ2.js} +3 -3
  4. package/dist/{chunk-7ZDXBOOU.js → chunk-ACSMNX3V.js} +44 -128
  5. package/dist/{chunk-PTGQAZEW.js → chunk-GGDVZCD6.js} +2 -4
  6. package/dist/{chunk-EOT63RDH.js → chunk-I5F5BHWI.js} +9 -0
  7. package/dist/chunk-PP7QVRXH.js +565 -0
  8. package/dist/chunk-SL77FXX7.js +54 -0
  9. package/dist/{chunk-3D7B2UAZ.js → chunk-VQKXTMWH.js} +44 -4
  10. package/dist/doctor-S6KPGS35.js +27 -0
  11. package/dist/index.js +90 -80
  12. package/dist/{info-7FKBTMVO.js → info-NJEY26H6.js} +91 -46
  13. package/dist/{context-UJCGYOT6.js → inspect-5YZMJPFM.js} +10 -10
  14. package/dist/{install-v2-3KJX3YRO.js → install-v2-KGIDII4H.js} +163 -364
  15. package/dist/{store-HOCORVL3.js → store-GF4SFBMJ.js} +155 -57
  16. package/dist/{sync-DT5UJMMR.js → sync-3XCIRDPK.js} +3 -4
  17. package/dist/{uninstall-IFN2KYBK.js → uninstall-BG4ML4FC.js} +39 -10
  18. package/package.json +3 -7
  19. package/templates/hooks/cite-policy-evict.cjs +1 -1
  20. package/templates/hooks/configs/claude-code.json +1 -5
  21. package/templates/hooks/configs/codex-hooks.json +1 -5
  22. package/templates/hooks/fabric-hint.cjs +67 -41
  23. package/templates/hooks/knowledge-hint-broad.cjs +82 -24
  24. package/templates/hooks/knowledge-hint-narrow.cjs +3 -3
  25. package/templates/hooks/knowledge-pretooluse.cjs +111 -0
  26. package/templates/hooks/lib/banner-i18n.cjs +12 -11
  27. package/templates/hooks/lib/bindings-snapshot-reader.cjs +1 -1
  28. package/templates/hooks/lib/event-writer.cjs +79 -0
  29. package/templates/hooks/lib/nudge-policy.cjs +11 -0
  30. package/templates/hooks/lib/theme.cjs +62 -0
  31. package/templates/hooks/post-tooluse-mutation.cjs +28 -39
  32. package/templates/skills/fabric-archive/SKILL.md +29 -12
  33. package/templates/skills/fabric-archive/ref/dry-run-scope.md +1 -1
  34. package/templates/skills/fabric-archive/ref/i18n-policy.md +1 -1
  35. package/templates/skills/fabric-archive/ref/phase-1-5-onboard.md +5 -5
  36. package/templates/skills/fabric-archive/ref/phase-1-cross-session.md +2 -2
  37. package/templates/skills/fabric-archive/ref/phase-2-5-viability.md +1 -1
  38. package/templates/skills/fabric-archive/ref/phase-3-5-scope.md +1 -1
  39. package/templates/skills/fabric-archive/ref/phase-3-6-related-edges.md +1 -1
  40. package/templates/skills/fabric-archive/ref/phase-3-classify.md +1 -1
  41. package/templates/skills/fabric-archive/ref/phase-4-5-emit.md +1 -1
  42. package/templates/skills/fabric-archive/ref/phase-4-mcp-persist.md +6 -5
  43. package/templates/skills/{fabric-import/ref/checkpoint-state.md → fabric-archive/ref/source-checkpoint.md} +3 -3
  44. package/templates/skills/{fabric-import/ref/phase-3-dedup.md → fabric-archive/ref/source-dedup.md} +4 -4
  45. package/templates/skills/{fabric-import/ref/phase-2-mining.md → fabric-archive/ref/source-mining.md} +20 -20
  46. package/templates/skills/{fabric-import/ref/output-contract.md → fabric-archive/ref/source-output-contract.md} +3 -3
  47. package/templates/skills/{fabric-import/ref/state-recovery.md → fabric-archive/ref/source-state-recovery.md} +2 -2
  48. package/templates/skills/{fabric-import/ref/worked-examples.md → fabric-archive/ref/source-worked-examples.md} +10 -10
  49. package/templates/skills/fabric-archive/ref/worked-examples.md +3 -3
  50. package/templates/skills/fabric-review/SKILL.md +19 -15
  51. package/templates/skills/fabric-review/ref/cite-contract.md +2 -2
  52. package/templates/skills/fabric-review/ref/modify-flow.md +13 -1
  53. package/templates/skills/fabric-review/ref/per-mode-flows.md +5 -5
  54. package/templates/skills/fabric-review/ref/relate-mode.md +33 -0
  55. package/templates/skills/fabric-review/ref/retire-mode.md +47 -0
  56. package/templates/skills/fabric-review/ref/semantic-check.md +1 -1
  57. package/templates/skills/fabric-review/ref/worked-examples.md +5 -5
  58. package/templates/skills/fabric-store/SKILL.md +12 -27
  59. package/templates/skills/fabric-sync/SKILL.md +16 -35
  60. package/templates/skills/lib/shared-policy.md +6 -4
  61. package/dist/chunk-27HK6H5Y.js +0 -69
  62. package/dist/chunk-E7HJUU34.js +0 -1096
  63. package/dist/chunk-NLNH64A3.js +0 -43
  64. package/dist/chunk-QFIVFZRH.js +0 -13
  65. package/dist/doctor-MDTZWKBK.js +0 -24
  66. package/dist/metrics-HMFH4YHK.js +0 -135
  67. package/dist/scope-explain-HLJZ2M33.js +0 -48
  68. package/dist/status-4R3TM4FJ.js +0 -37
  69. package/dist/whoami-ITGEFWH4.js +0 -49
  70. package/templates/skills/fabric/SKILL.md +0 -100
  71. package/templates/skills/fabric-audit/SKILL.md +0 -63
  72. package/templates/skills/fabric-connect/SKILL.md +0 -48
  73. package/templates/skills/fabric-import/SKILL.md +0 -151
  74. package/templates/skills/fabric-import/ref/i18n-policy.md +0 -78
@@ -1,151 +0,0 @@
1
- ---
2
- name: fabric-import
3
- description: 冷启动从 git log + docs/*.md 回灌 active write store pending knowledge (NOT code/data import). Triggers 导入历史/bootstrap fabric/mine changelog/挖掘 commit.
4
- allowed-tools: Read, Glob, Grep, Bash, mcp__fabric__fab_extract_knowledge, mcp__fabric__fab_review
5
- ---
6
-
7
- > **Surface**: Skill (LLM judgment over git + docs). See [`docs/surfaces.md`](https://github.com/fenglimg/fabric/blob/main/docs/surfaces.md).
8
-
9
- ## Purpose
10
-
11
- One-time per-project cold-start: lift git commits + `docs/*.md` into the active write store as `team`-layer pending entries. Bridges `fabric install`'s 4-7 baseline → accumulated corpus. Run once on adoption or after major refactor.
12
-
13
- ## Precondition
14
-
15
- Invoke only when ANY: user explicit ("import knowledge" / "bootstrap fabric" / "mine changelog"); user named skill; SessionStart hook fired `shouldRecommendImport()`.
16
-
17
- Else stop: `没有触发 import 信号;如需手动 import 请显式调用 fabric-import` / `No import signal detected; to manually import, explicitly invoke fabric-import` (per `fabric_language`).
18
-
19
- SKIP when: `.fabric/` missing (→ `fabric install`); canonical > `import_skip_canonical_threshold` (default 50); state file `phase=complete` + `last_checkpoint_at <24h`.
20
-
21
- Required: `.fabric/` exists, target store resolved, MCP `fab_extract_knowledge` + `fab_review` registered, working tree reasonably clean.
22
-
23
- ## Phase 0 — Init
24
-
25
- Read/init `.fabric/.import-state.json`. Scan stale `.tmp-import-*`. State-corruption recovery → `Read .../ref/state-recovery.md`.
26
-
27
- > 旧 `.fabric/.import-requested` sentinel 机制已下线 (rc.8+);推荐由 SessionStart hook 的 underseed 自检触发(`shouldRecommendImport()`)。本 skill 不再读写 sentinel。
28
-
29
- ## Phase 0.5 — Config Load
30
-
31
- Read `.fabric/fabric-config.json` for tunables (defaults if absent):
32
-
33
- | Field | Default |
34
- |---|---|
35
- | `import_window_first_run_months` | 60 |
36
- | `import_window_rerun_months` | 2 |
37
- | `import_max_pending_per_run` | 10 |
38
- | `import_max_commits_scan` | 500 |
39
- | `import_skip_canonical_threshold` | 50 |
40
-
41
- First-run vs re-run by state file (ENOENT or `phase != complete && proposed == 0` → first-run window).
42
-
43
- ### Store routing (v2.1 multi-store)
44
-
45
- Import requires an **explicit target store** (E7) — mined entries are NOT auto-routed. Resolve candidates via `fabric scope-explain team` (writable stores in the read-set); if more than one writable store exists, `AskUserQuestion` for the target store alias before persisting (header/question translate, the alias options stay English routing keys). Single writable store → use it. Persist through `fab_extract_knowledge` with the chosen store; echo the target alias. Never write to a store the project did not declare (read-set bound).
46
-
47
- ## UX i18n Policy
48
-
49
- Read `fabric_language` (`zh-CN` / `en` / `zh-CN-hybrid` / `match-existing`). Emit prose per variant. Protected tokens NEVER translate (`fab_extract_knowledge`, `fab_review`, `.fabric/.import-state.json`, all enum strings, `MUST`/`NEVER`). Full 5-class taxonomy → `Read .../ref/i18n-policy.md`.
50
-
51
- ## 3-Phase Pipeline
52
-
53
- Strict P1→P2→P3 order. State write after every sub-step. Infer-not-Ask.
54
-
55
- ### Phase 1 — Init-Scan Reference (NO RE-IMPLEMENT)
56
-
57
- `fabric install` produced baseline. Phase 1 REFERENCES, does NOT redo.
58
-
59
- 1. Run `fabric onboard-coverage --json` and `fab_review action="search"` as needed to understand existing canonical titles in the mounted store read-set.
60
- 2. If no write store is resolved: STOP. Tell user `请先绑定并选择写入 store` / `Please bind and select a write store first` and exit.
61
- 3. Use the returned canonical titles for the P2 negative filter.
62
- 4. State: `phase=P1-done`, `p1_baseline_titles=[...]`, `last_checkpoint_at=<ISO>`.
63
-
64
- No MCP calls.
65
-
66
- ### Phase 2 — LLM-Driven Mining
67
-
68
- Classify each candidate into 5 types (decisions/pitfalls/guidelines/models/processes), draft slug, propose via `fab_extract_knowledge`. Layer: `team`.
69
-
70
- #### Mandatory Scope Rule — broad + empty paths (NON-NEGOTIABLE)
71
-
72
- Every call MUST `relevance_scope="broad"` AND `relevance_paths=[]`. No exceptions. Why: import is LLM-driven (not session-driven); LLM-inferred narrow lies about applicability. Post-rc.37 A1 the server returns every selectable entry regardless of scope, so false-narrow no longer hides knowledge — but it still poisons doctor lint accounting + downstream consumers that read `relevance_paths` literally. Narrowing deferred to `fab_review.modify` post-import when the user has the real applicability surface. Full rationale + prohibitions + doctor lint #23 → `Read .../ref/phase-2-mining.md`.
73
-
74
- #### Step 2.1 — Git Mining
75
-
76
- `git log --since="<window> months ago" --pretty=format:"%H%n%s%n%b%n---ENDCOMMIT---" -n <cap>`. Conventional prefix → type signal (feat→decision/model, fix→pitfall, refactor→decision, docs→guideline; chore/test/ci skip). Extract observation → Skip Tree → `fab_extract_knowledge` (broad+[]). Cap: `import_max_pending_per_run`.
77
-
78
- #### Step 2.1.5 — Proposed Reason
79
-
80
- Infer one of: `decision-confirmation` | `new-dependency-or-pattern` | `wrong-turn-revert` | `diagnostic-then-fix` | `explicit-user-mark` | `dismissal-with-reason`. Fallback: `new-dependency-or-pattern`. 11-row table → ref.
81
-
82
- #### Step 2.2 — Docs Mining
83
-
84
- `find docs/ -maxdepth 3 -name '*.md'` + root `*.md`. Skip README / CHANGELOG / LICENSE / CODE_OF_CONDUCT / CONTRIBUTING / <300B files. Same call shape. Shared cap.
85
-
86
- #### Skip Decision Tree
87
-
88
- Skip if: cosmetic-only / metadata-only / in baseline / not classifiable / slug not derivable to 2-5 kebab words.
89
-
90
- #### Dry-Run
91
-
92
- Explicit token `--dry-run` in invocation → skip MCP, render bilingual preview table (every Scope row `broad+[]`). State NOT written. P3 skipped. v2.0.0-rc.37 NEW-10 dropped legacy substring fallback on bare `dry-run` / `预览` (false-positive on incidental mentions).
93
-
94
- Full MCP call shape, Step 2.1.5 table, dry-run templates, T5 idempotency → `Read .../ref/phase-2-mining.md`.
95
-
96
- ### Phase 3 — LLM-Driven Dedup
97
-
98
- For each P2 pending: check vs canonical. Semantic compare is LLM's job — `fab_review` does NOT compare meaning.
99
-
100
- 1. **3.1** — `fab_review action="search"` filter by `type`, top 5.
101
- 2. **3.2** — Classify each pair: `duplicate` (reject pending) | `subsumption` (reject pending) | `subsumption-with-novelty` (modify canonical + reject pending) | `contradiction` (leave + flag) | `genuinely-new` (keep).
102
- 3. **3.3** — Issue `fab_review` reject / modify.
103
- 4. **3.4** — `phase=complete` + `final_summary` + roll-up.
104
-
105
- Full call shapes + 5-way classification → `Read .../ref/phase-3-dedup.md`.
106
-
107
- ## Checkpoint Logic
108
-
109
- State file `.fabric/.import-state.json` is single resumability source. Atomic write: Step A `Write .tmp` → Step B `Bash mv` (POSIX `rename(2)`). `Write` alone NOT atomic.
110
-
111
- Resume contract: re-invoke MUST NOT dup-propose / re-dedup. By `phase`: `P1-done`→2.1, `P2-done`→3.1, `complete <24h`→skip, `≥24h`→confirm.
112
-
113
- Full rationale + 4KB POSIX constraint + state schema + 6-step Resume → `Read .../ref/checkpoint-state.md`.
114
-
115
- ## Default Knobs
116
-
117
- Layer `team` / scope `broad` / paths `[]` are contract-locked (no override). Max pending = config / dry-run via keyword / re-run <24h blocked. Full table → ref.
118
-
119
- ## Hard Rules
120
-
121
- ### DISPLAY (per entry)
122
-
123
- `[type=...]` `[layer=team]` `[scope=broad]` `slug=...` `src=<sha7-or-path>` + `pending_path`. zh-CN body + EN headings. Roll-up: proposed / kept / rejected_dup / merged / contradictions_flagged. Final `phase` on exit. Never hide source / show `idempotency_key` / auto-classify `personal`.
124
-
125
- ### WRITE
126
-
127
- NEVER write entry via `Edit`/`Write`/`Bash` — only `fab_extract_knowledge` (P2) + `fab_review` (P3).
128
-
129
- NEVER batch P2 candidates / skip P1 ref / call `fab_review.approve` / `git mv` directly / infer layer-flip / non-atomic state / exceed cap / `relevance_scope="narrow"` / non-empty `relevance_paths` / copy fabric-archive Phase 1.5 logic.
130
-
131
- Narrowing post-import = `fab_review.modify` (out-of-band).
132
-
133
- Protected tokens (verbatim, no translate): `stable_id`, `pending_path`, `layer`, `team`, `personal`, `knowledge_proposed`, `fab_extract_knowledge`, `fab_review`, `MUST`, `NEVER`, `phase`, `.import-state.json`, `relevance_scope`, `relevance_paths`, `broad`, `narrow`, `source_sessions`, `proposed_reason`, `session_context`, `intent_clues`, `tech_stack`, `impact`, `must_read_if`.
134
-
135
- ## Output Contract
136
-
137
- Roll-up sections (per `fabric_language`): `Phase 2 — Mining` | `Phase 3 — Dedup` | `State` | `Next Steps`. Include the target store alias for proposed entries. Bilingual templates → `Read .../ref/output-contract.md`.
138
-
139
- ## Worked Examples
140
-
141
- 4 end-to-end (A feat→pitfall + WRONG counter-ex; B docs→decision; C P3 dup→reject; D out-of-band narrow) → `Read .../ref/worked-examples.md`.
142
-
143
- ## Failure Recovery
144
-
145
- - P2 mid-fail: state has `p2_processed_commits[]`; rerun skips them.
146
- - P3 mid-fail: state has `p3_dedup_completed[]`; rerun resumes.
147
- - `errors.length > 5`: halt + ask `继续 (y) / 中止并保留 state (n)` / `Continue (y) / Abort and keep state (n)`.
148
- - State corruption: P0 detects → rename `.json.corrupt-<ISO>` → restart P1.
149
- - MCP unreachable: halt + `MCP 工具未注册;请检查 fabric server 是否运行` / `MCP tool not registered; please check that the fabric server is running` → exit without state write.
150
-
151
- Resume policy: inspect existing state and continue from the last completed phase — do not prompt the user mid-flow.
@@ -1,78 +0,0 @@
1
- # UX i18n Policy — fabric-import full reference
2
-
3
- > **Shared core (rc.37 NEW-13):** the cross-skill invariants — protected-token
4
- > NEVER-translate list, AskUserQuestion routing-key rule, layer heuristic, and
5
- > events-emit convention — live once in `../../lib/shared-policy.md`. This file
6
- > keeps only the fabric-import-specific 5-class examples. Read the shared lib
7
- > for the common rules; do not fork them here.
8
-
9
- > **Loaded on demand.** Only consult when you need to disambiguate which of the 5 classes a given string belongs to. SKILL.md gives the operative rule.
10
-
11
- ## UX i18n Policy (5-class bilingualization)
12
-
13
- The skill consults `fabric_language` from `.fabric/fabric-config.json`
14
- (固化于 install 时,via `scan.ts:detectExistingLanguage`; default `"en"` when no
15
- CJK signal is detected in README + docs/; may resolve to `"match-existing"`,
16
- `"zh-CN"`, `"en"`, or `"zh-CN-hybrid"`). All user-facing text in the
17
- following 5 categories MUST be rendered in the resolved language:
18
-
19
- 1. **Roll-up templates** — final summary blocks (`# Import Summary — phase=...`,
20
- `## Phase 2 — Mining`, `## Phase 3 — Dedup`, etc.). zh-CN ↔ en mirror.
21
- 2. **Errors / Preconditions warnings** — abort + gate-fail messages (e.g.
22
- "请先运行 fabric install 完成基线扫描…" / "Please run fabric install first…").
23
- zh-CN ↔ en mirror.
24
- 3. **Confirmation prompts** — re-run-within-24h prompt, reset prompts, etc.
25
- zh-CN ↔ en mirror.
26
- 4. **Dry-run table headers** — `# Import Dry Run — would propose N pending
27
- entries…` + the `| # | Source | Type | Slug | Scope | Summary |` header row.
28
- zh-CN ↔ en mirror.
29
- 5. **AskUserQuestion** — `header` + `question` fields (NOT `options[]`).
30
- zh-CN ↔ en mirror. fabric-import itself does not surface AskUserQuestion
31
- in the current contract (the rare re-run prompt is free-text), but if a
32
- future version adds one, this rule applies.
33
-
34
- Rendering rule:
35
-
36
- - `fabric_language === "zh-CN"` → emit the zh-CN variant; pure monolingual, no language mixing inside a single user-facing block.
37
- - `fabric_language === "en"` → emit the en variant; pure monolingual, no language mixing inside a single user-facing block.
38
- - `fabric_language === "zh-CN-hybrid"` → emit Chinese narrative prose with English technical terms preserved. Protected tokens (always EN): MCP tool names (e.g. `fab_recall`), CLI command names (e.g. `fabric install`), file paths, technical concepts (`Skill`, `SessionStart`, `hook`, `MCP`, `revision_hash`, `pending`, `proven`, `verified`, `draft`).
39
- - `fabric_language === "match-existing"` or any other value → emit the en variant; pure monolingual.
40
-
41
- Protected tokens (`fab_extract_knowledge`, `fab_review`, `relevance_scope`,
42
- `relevance_paths`, `broad`, `narrow`, `source_sessions`, `proposed_reason`,
43
- `session_context`, `intent_clues`, `tech_stack`, `impact`, `must_read_if`,
44
- `pending_path`, `layer`, `team`, `personal`,
45
- `knowledge_scope_degraded`, `MUST`, `NEVER`, `knowledge/pending`, etc.)
46
- are NEVER translated — they appear verbatim in both language variants.
47
- The bilingualization scope is prose ONLY.
48
-
49
- ### AskUserQuestion i18n Policy (value vs label)
50
-
51
- When a skill (this one or any sibling skill the user is composing with)
52
- issues an `AskUserQuestion`, the `header` and `question` strings are
53
- user-facing prose → translated per `fabric_language`. The `options[]`
54
- array entries (e.g. `["approve", "reject", "modify", "defer", "skip"]` in
55
- fabric-review) are **routing keys** consumed by the skill state machine —
56
- they MUST remain English regardless of `fabric_language`.
57
-
58
- ```ts
59
- // EN (fabric_language === "en")
60
- AskUserQuestion({
61
- header: "Review pending entry",
62
- question: "What action for '{title}'?",
63
- options: ["approve", "reject", "modify", "defer", "skip"]
64
- })
65
-
66
- // zh-CN (fabric_language === "zh-CN")
67
- AskUserQuestion({
68
- header: "审核 pending 条目",
69
- question: "对 '{title}' 执行什么操作?",
70
- options: ["approve", "reject", "modify", "defer", "skip"] // 不翻译 — routing key
71
- })
72
- ```
73
-
74
- Rationale: localizing routing keys would force every routing branch to
75
- dual-string match (e.g. `if (choice === "approve" || choice === "通过")`),
76
- which doubles the surface area for protected-token regressions and breaks
77
- the option-list invariants that downstream tooling depends on. Keeping
78
- `options[]` English-only is contract-locked across all three skills.