@fenglimg/fabric-cli 2.0.0 → 2.1.0-rc.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.
- package/LICENSE +21 -0
- package/README.md +6 -5
- package/dist/chunk-BATF4PEJ.js +361 -0
- package/dist/{chunk-OBQU6NHO.js → chunk-COI5VDFU.js} +0 -18
- package/dist/chunk-F46ORPOA.js +903 -0
- package/dist/chunk-HFQVXY6P.js +86 -0
- package/dist/chunk-L4Q55UC4.js +52 -0
- package/dist/chunk-LFIKMVY7.js +27 -0
- package/dist/chunk-MF3OTILQ.js +544 -0
- package/dist/chunk-PWLW3B57.js +18 -0
- package/dist/chunk-RYAFBNES.js +33 -0
- package/dist/chunk-T5RPGCCM.js +40 -0
- package/dist/chunk-WU6GAPKH.js +36 -0
- package/dist/config-XJIPZNUP.js +13 -0
- package/dist/doctor-QVNPHLJK.js +920 -0
- package/dist/index.js +23 -8
- package/dist/{init-BIRSIOXO.js → install-2HDO5FTQ.js} +807 -705
- package/dist/metrics-ACEQFPDU.js +122 -0
- package/dist/onboard-coverage-MFCAEBDO.js +220 -0
- package/dist/{plan-context-hint-QMUPAXIB.js → plan-context-hint-FC6P3WFE.js} +34 -28
- package/dist/scope-explain-2F2R5URO.js +33 -0
- package/dist/status-GLQWLWH6.js +23 -0
- package/dist/store-XTSE5TY6.js +105 -0
- package/dist/sync-BJCWDPNC.js +245 -0
- package/dist/uninstall-TAXSUSKH.js +1073 -0
- package/dist/whoami-B6AEMSEV.js +31 -0
- package/package.json +30 -5
- package/templates/hooks/cite-policy-evict.cjs +231 -0
- package/templates/hooks/configs/README.md +29 -6
- package/templates/hooks/configs/claude-code.json +14 -3
- package/templates/hooks/configs/codex-hooks.json +6 -3
- package/templates/hooks/configs/cursor-hooks.json +8 -10
- package/templates/hooks/fabric-hint.cjs +873 -105
- package/templates/hooks/knowledge-hint-broad.cjs +549 -135
- package/templates/hooks/knowledge-hint-narrow.cjs +830 -26
- package/templates/hooks/lib/banner-i18n.cjs +309 -0
- package/templates/hooks/lib/bindings-snapshot-reader.cjs +81 -0
- package/templates/hooks/lib/cite-contract-reminder.cjs +179 -0
- package/templates/hooks/lib/cite-line-parser.cjs +180 -0
- package/templates/hooks/lib/client-adapter.cjs +106 -0
- package/templates/hooks/lib/config-cache.cjs +107 -0
- package/templates/hooks/lib/state-store.cjs +84 -0
- package/templates/hooks/lib/summary-fallback.cjs +210 -0
- package/templates/skills/fabric-archive/SKILL.md +97 -419
- package/templates/skills/fabric-archive/ref/dry-run-scope.md +16 -0
- package/templates/skills/fabric-archive/ref/e5-cron-recap.md +58 -0
- package/templates/skills/fabric-archive/ref/i18n-policy.md +86 -0
- package/templates/skills/fabric-archive/ref/phase-0-range-resolution.md +156 -0
- package/templates/skills/fabric-archive/ref/phase-1-5-onboard.md +218 -0
- package/templates/skills/fabric-archive/ref/phase-1-cross-session.md +62 -0
- package/templates/skills/fabric-archive/ref/phase-2-5-viability.md +68 -0
- package/templates/skills/fabric-archive/ref/phase-3-5-scope.md +108 -0
- package/templates/skills/fabric-archive/ref/phase-3-classify.md +63 -0
- package/templates/skills/fabric-archive/ref/phase-4-5-emit.md +78 -0
- package/templates/skills/fabric-archive/ref/phase-4-mcp-persist.md +89 -0
- package/templates/skills/fabric-archive/ref/rc-history.md +38 -0
- package/templates/skills/fabric-archive/ref/worked-examples.md +78 -0
- package/templates/skills/fabric-import/SKILL.md +77 -514
- package/templates/skills/fabric-import/ref/checkpoint-state.md +85 -0
- package/templates/skills/fabric-import/ref/i18n-policy.md +79 -0
- package/templates/skills/fabric-import/ref/output-contract.md +61 -0
- package/templates/skills/fabric-import/ref/phase-2-mining.md +213 -0
- package/templates/skills/fabric-import/ref/phase-3-dedup.md +75 -0
- package/templates/skills/fabric-import/ref/state-recovery.md +57 -0
- package/templates/skills/fabric-import/ref/worked-examples.md +127 -0
- package/templates/skills/fabric-review/SKILL.md +90 -284
- package/templates/skills/fabric-review/ref/askuserquestion-policy.md +66 -0
- package/templates/skills/fabric-review/ref/i18n-policy.md +111 -0
- package/templates/skills/fabric-review/ref/modify-flow.md +103 -0
- package/templates/skills/fabric-review/ref/output-contract.md +58 -0
- package/templates/skills/fabric-review/ref/per-mode-flows.md +155 -0
- package/templates/skills/fabric-review/ref/semantic-check.md +26 -0
- package/templates/skills/fabric-review/ref/worked-examples.md +95 -0
- package/templates/skills/fabric-sync/SKILL.md +46 -0
- package/templates/skills/lib/shared-policy.md +69 -0
- package/dist/chunk-6ICJICVU.js +0 -10
- package/dist/chunk-74SZWYPH.js +0 -658
- package/dist/chunk-EYIDD2YS.js +0 -1000
- package/dist/doctor-T7JWODKG.js +0 -282
- package/dist/hooks-Y74Y5LQS.js +0 -12
- package/dist/scan-LMK3UCWL.js +0 -22
- package/dist/serve-H554BHLG.js +0 -124
- package/templates/agents-md/AGENTS.md.template +0 -59
- package/templates/bootstrap/CLAUDE.md +0 -8
- package/templates/bootstrap/codex-AGENTS-header.md +0 -6
- package/templates/bootstrap/cursor-fabric-bootstrap.mdc +0 -10
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fabric-sync
|
|
3
|
+
description: 多 store git 同步辅助 — 遍历挂载的知识 store, pull --rebase + push, AI 辅助解冲突。Triggers 同步知识库/sync stores/fabric-sync/解决 store 冲突/rebase 冲突.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# fabric-sync
|
|
7
|
+
|
|
8
|
+
跨多个挂载知识 store 的 git 同步辅助 (v2.1, S46)。CLI `fabric sync` 是事务/状态机引擎;本 skill 是它的 AI 辅助外层:遍历 store、解释每个 store 的同步结果、在 rebase 冲突时辅助用户决断 continue/abort。
|
|
9
|
+
|
|
10
|
+
## Precondition
|
|
11
|
+
|
|
12
|
+
- 已 `fabric install --global` (存在 `~/.fabric` + 全局 store registry)。无全局配置 → 提示先装,停止。
|
|
13
|
+
- 本 skill 不直接读 `~/.fabric` store 树;所有 store 状态经 `fabric sync` / `fabric store list` / `fabric scope-explain` 的 JSON 输出获取 (hook/skill 不自解析 store)。
|
|
14
|
+
|
|
15
|
+
## Phase 0 — Enumerate stores
|
|
16
|
+
|
|
17
|
+
`fabric store list` 拿到挂载的 store (alias / uuid / remote)。仅 remote-backed store 参与同步;local-only store 跳过 (无可推/拉),但提示「local-only — 加 remote 备份」(R5#5)。
|
|
18
|
+
|
|
19
|
+
## Phase 1 — Run sync
|
|
20
|
+
|
|
21
|
+
执行 `fabric sync`。逐 store 渲染结果 (NOT 聚合成一坨):
|
|
22
|
+
- `synced` — 干净 rebase + push 完成。
|
|
23
|
+
- `offline` — 网络不可达;本地已提交,push 已 defer (S17 offline-first),下次 online 重试。**不报错**。
|
|
24
|
+
- `conflict` — rebase 冲突,sync 暂停并持久化 session。进入 Phase 2。
|
|
25
|
+
|
|
26
|
+
## Phase 2 — AI-assisted conflict resolution (仅冲突时)
|
|
27
|
+
|
|
28
|
+
冲突 store 的工作区停在 rebase 中途。辅助用户:
|
|
29
|
+
1. 展示冲突文件 (store 知识树 `.fabric/knowledge/<type>/*.md` 中的 `<<<<<<<`/`=======`/`>>>>>>>` 段)。
|
|
30
|
+
2. 对每个冲突,MUST 解释两侧 (ours = 本地草稿/晋升, theirs = 远端协作者) 并给出**合并建议**(知识条目通常可并存或取更成熟 maturity)。NEVER 擅自丢弃任一侧未经用户确认。
|
|
31
|
+
3. 用户解决后 → `fabric sync --continue` (git rebase --continue + 恢复遍历剩余 store)。
|
|
32
|
+
4. 用户选择放弃该 store → `fabric sync --abort` (git rebase --abort,该 store 留未同步,继续遍历其余)。
|
|
33
|
+
|
|
34
|
+
## Phase 3 — Settle
|
|
35
|
+
|
|
36
|
+
所有 store settled (无 pending/conflict) 后:CLI 自动清 session 并重生 `~/.fabric/state/bindings/<id>_resolved.json` 快照 (P3→P4 链)。汇报:已同步 store 数、deferred (offline) store 数、aborted store 数。
|
|
37
|
+
|
|
38
|
+
## UX i18n Policy
|
|
39
|
+
|
|
40
|
+
按 `.fabric/fabric-config.json` 的 `fabric_language` 渲染用户可见文案。Protected tokens (`fabric sync`, `--continue`, `--abort`, `git rebase`, store alias, enum) NEVER translate。
|
|
41
|
+
|
|
42
|
+
## Constraints
|
|
43
|
+
|
|
44
|
+
- Hook/skill **绝不**直接解析 store 或执行 store 内任何文件 (S65 RCE 防线:store 是数据-only)。
|
|
45
|
+
- 冲突合并建议是辅助,最终由用户拍板;不静默丢弃知识。
|
|
46
|
+
- promotion/CR 经普通 git commit,不跨 store 搬运条目。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Shared skill policy — cross-skill canonical core (rc.37 NEW-13)
|
|
2
|
+
|
|
3
|
+
> **Single source of truth** for the policy invariants that fabric-archive,
|
|
4
|
+
> fabric-review, and fabric-import all depend on. Each skill's `ref/` keeps
|
|
5
|
+
> only its skill-specific examples and points here (`../../lib/shared-policy.md`)
|
|
6
|
+
> for the common rules. Edit invariants HERE — never fork them per skill.
|
|
7
|
+
|
|
8
|
+
## 1. Protected tokens — NEVER translated
|
|
9
|
+
|
|
10
|
+
When rendering bilingual (zh-CN ↔ en) output, prose is translated but the
|
|
11
|
+
following classes of token appear **verbatim in both variants**:
|
|
12
|
+
|
|
13
|
+
- **MCP tool + field names**: `fab_extract_knowledge`, `fab_review`,
|
|
14
|
+
`fab_recall`, `fab_plan_context`, `fab_get_knowledge_sections`,
|
|
15
|
+
`relevance_scope`, `relevance_paths`, `source_sessions`, `proposed_reason`,
|
|
16
|
+
`session_context`, `intent_clues`, `tech_stack`, `impact`, `must_read_if`,
|
|
17
|
+
`evidence_paths`, `tags`, `pending_path`, `layer`.
|
|
18
|
+
- **Enum / routing values**: `narrow`, `broad`, `team`, `personal`, `draft`,
|
|
19
|
+
`verified`, `proven`, `knowledge_scope_degraded`.
|
|
20
|
+
- **Imperatives + paths**: `MUST`, `NEVER`, `.fabric/knowledge/`, file paths.
|
|
21
|
+
|
|
22
|
+
The authoritative machine-checked list is `PROTECTED_TOKENS` in
|
|
23
|
+
`@fenglimg/fabric-shared` (enforced by `scripts/lint-protected-tokens.ts`).
|
|
24
|
+
Bilingualization scope is **prose ONLY**.
|
|
25
|
+
|
|
26
|
+
## 2. AskUserQuestion routing-key invariant
|
|
27
|
+
|
|
28
|
+
When any skill issues an `AskUserQuestion`:
|
|
29
|
+
|
|
30
|
+
- `header` + `question` → user-facing prose → **translated** per
|
|
31
|
+
`.fabric/fabric-config.json` → `fabric_language`.
|
|
32
|
+
- `options[]` entries → **routing keys** consumed by the skill's `switch`
|
|
33
|
+
over the returned choice → stay **English** in BOTH variants.
|
|
34
|
+
|
|
35
|
+
Canonical option arrays (English in every locale):
|
|
36
|
+
|
|
37
|
+
- Per-item review action: `["approve", "reject", "modify", "defer", "skip"]`
|
|
38
|
+
- Stale-item action (review health mode): `["defer", "demote", "skip"]`
|
|
39
|
+
- Layer-flip target: `["team", "personal"]`
|
|
40
|
+
|
|
41
|
+
A skill that translates `options[]` MUST then dual-string-match
|
|
42
|
+
(`choice === "approve" || choice === "通过"`); avoid this — keep options
|
|
43
|
+
English so the state machine stays single-string.
|
|
44
|
+
|
|
45
|
+
## 3. Layer heuristic (team vs personal)
|
|
46
|
+
|
|
47
|
+
Default classification when archiving / proposing knowledge:
|
|
48
|
+
|
|
49
|
+
- **强 team** — cross-cutting decisions, architecture, shared pitfalls,
|
|
50
|
+
conventions the whole repo depends on.
|
|
51
|
+
- **强 personal** — individual workflow preferences, local environment quirks,
|
|
52
|
+
notes scoped to one contributor (`KP-*` ids, in-repo `~/.fabric` root).
|
|
53
|
+
- **默认 team** — when ambiguous, default to `team` (shared visibility is the
|
|
54
|
+
safer default; a mis-scoped personal entry hides knowledge from the team).
|
|
55
|
+
|
|
56
|
+
This block is itself a protected token sequence — render `强 team` /
|
|
57
|
+
`强 personal` / `默认 team` verbatim.
|
|
58
|
+
|
|
59
|
+
## 4. Events emit convention
|
|
60
|
+
|
|
61
|
+
Skills persist lifecycle via MCP tools (which emit the canonical events) —
|
|
62
|
+
they do NOT hand-write `.fabric/events.jsonl`:
|
|
63
|
+
|
|
64
|
+
- `fab_extract_knowledge` → `knowledge_proposed` (+ archive-attempt events).
|
|
65
|
+
- `fab_review` approve → `knowledge_promote_started` → `knowledge_promoted`.
|
|
66
|
+
- `fab_review` modify-layer → `knowledge_layer_changed` (+ id-redirect).
|
|
67
|
+
|
|
68
|
+
Never instruct the user to delete or hand-edit the event ledger; it is the
|
|
69
|
+
append-only audit trail. Counter rollups live in `.fabric/metrics.jsonl`.
|