@fenglimg/fabric-cli 1.6.0 → 1.8.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.
- package/README.md +8 -14
- package/dist/{chunk-QSAEGVKE.js → chunk-NMMUETVK.js} +4 -8
- package/dist/{chunk-AEOYCVBG.js → chunk-QPCRBQ5Y.js} +52 -5
- package/dist/doctor-F52XWWZC.js +98 -0
- package/dist/index.js +5 -20
- package/dist/{init-LBVOI2QI.js → init-AEO5JU7R.js} +1084 -167
- package/dist/{scan-QH76LC7Z.js → scan-NNBNGIZG.js} +2 -4
- package/dist/{serve-4J2CQY25.js → serve-466QXQ5Q.js} +17 -9
- package/package.json +5 -7
- package/templates/agents-md/AGENTS.md.template +7 -7
- package/templates/agents-md/variants/cocos.md +7 -7
- package/templates/agents-md/variants/next.md +7 -7
- package/templates/agents-md/variants/vite.md +7 -7
- package/templates/bootstrap/CLAUDE.md +3 -1
- package/templates/bootstrap/GEMINI.md +3 -1
- package/templates/bootstrap/codex-AGENTS-header.md +3 -1
- package/templates/bootstrap/cursor-fabric-bootstrap.mdc +5 -6
- package/templates/bootstrap/roo-fabric.md +5 -6
- package/templates/bootstrap/windsurf-fabric.md +5 -6
- package/templates/claude-skills/fabric-init/SKILL.md +163 -0
- package/templates/codex-skills/fabric-init/SKILL.md +153 -18
- package/templates/husky/pre-commit +9 -24
- package/templates/skill-source/fabric-init/SOURCE.md +157 -0
- package/templates/skill-source/fabric-init/clients.json +17 -0
- package/dist/approve-YT4DEABS.js +0 -138
- package/dist/bootstrap-VGL3AR26.js +0 -16
- package/dist/chunk-2YW5CJ32.js +0 -147
- package/dist/chunk-6ICJICVU.js +0 -10
- package/dist/chunk-BEKSXO5N.js +0 -442
- package/dist/chunk-BVTMVW5M.js +0 -159
- package/dist/chunk-KOAEIH72.js +0 -270
- package/dist/chunk-L43IGJ6X.js +0 -106
- package/dist/chunk-T2WJF5I3.js +0 -254
- package/dist/chunk-WWNXR34K.js +0 -49
- package/dist/chunk-YDZJRLHL.js +0 -155
- package/dist/config-EC5L2QNI.js +0 -16
- package/dist/doctor-4BPYHV7V.js +0 -134
- package/dist/hooks-ZSWVH2JD.js +0 -12
- package/dist/human-lint-YSFOZHZ7.js +0 -13
- package/dist/ledger-append-3MDNR3GU.js +0 -10
- package/dist/pre-commit-53ENJDRZ.js +0 -98
- package/dist/sync-meta-IZR2WLIL.js +0 -16
- package/dist/update-M5M5PYKE.js +0 -116
- package/templates/claude-skills/agents-md-init/SKILL.md +0 -86
- package/templates/fabric/human-lock.json +0 -12
|
@@ -3,10 +3,8 @@ import {
|
|
|
3
3
|
createScanReport,
|
|
4
4
|
scanCommand,
|
|
5
5
|
scan_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-WWNXR34K.js";
|
|
9
|
-
import "./chunk-6ICJICVU.js";
|
|
6
|
+
} from "./chunk-NMMUETVK.js";
|
|
7
|
+
import "./chunk-QPCRBQ5Y.js";
|
|
10
8
|
export {
|
|
11
9
|
createScanReport,
|
|
12
10
|
scan_default as default,
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createDebugLogger,
|
|
4
|
-
resolveDevMode
|
|
5
|
-
} from "./chunk-AEOYCVBG.js";
|
|
6
|
-
import {
|
|
7
4
|
paint,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
5
|
+
resolveDevMode,
|
|
6
|
+
symbol,
|
|
11
7
|
t
|
|
12
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QPCRBQ5Y.js";
|
|
13
9
|
|
|
14
10
|
// src/commands/serve.ts
|
|
15
11
|
import { defineCommand } from "citty";
|
|
16
|
-
import { startHttpServer } from "@fenglimg/fabric-server";
|
|
12
|
+
import { acquireLock, releaseLock, startHttpServer } from "@fenglimg/fabric-server";
|
|
17
13
|
var DEFAULT_PORT = 7373;
|
|
18
14
|
var serveCommand = defineCommand({
|
|
19
15
|
meta: {
|
|
@@ -39,6 +35,11 @@ var serveCommand = defineCommand({
|
|
|
39
35
|
type: "boolean",
|
|
40
36
|
description: t("cli.serve.args.debug.description"),
|
|
41
37
|
default: false
|
|
38
|
+
},
|
|
39
|
+
force: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
description: t("cli.serve.args.force.description"),
|
|
42
|
+
default: false
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
async run({ args }) {
|
|
@@ -49,6 +50,11 @@ var serveCommand = defineCommand({
|
|
|
49
50
|
const requestedHost = parseHost(args.host);
|
|
50
51
|
const authToken = readAuthTokenFromEnv();
|
|
51
52
|
const host = validateHost(requestedHost, authToken);
|
|
53
|
+
const projectRoot = resolution.target;
|
|
54
|
+
acquireLock(projectRoot, { force: args.force });
|
|
55
|
+
process.on("exit", () => {
|
|
56
|
+
releaseLock(projectRoot);
|
|
57
|
+
});
|
|
52
58
|
logger(`serve target source: ${resolution.source}`);
|
|
53
59
|
for (const step of resolution.chain) {
|
|
54
60
|
logger(step);
|
|
@@ -56,14 +62,16 @@ var serveCommand = defineCommand({
|
|
|
56
62
|
try {
|
|
57
63
|
await startHttpServer({
|
|
58
64
|
port,
|
|
59
|
-
projectRoot
|
|
65
|
+
projectRoot,
|
|
60
66
|
host,
|
|
61
67
|
authToken
|
|
62
68
|
});
|
|
63
69
|
} catch (error) {
|
|
64
70
|
if (isNodeError(error) && error.code === "EADDRINUSE") {
|
|
71
|
+
releaseLock(projectRoot);
|
|
65
72
|
throw new Error(t("cli.serve.error.port-in-use", { port: String(port), nextPort: String(port + 1) }));
|
|
66
73
|
}
|
|
74
|
+
releaseLock(projectRoot);
|
|
67
75
|
throw error;
|
|
68
76
|
}
|
|
69
77
|
console.log(`${symbol.ok} ${paint.ai(t("cli.serve.ready.title"))} ${paint.human(`http://${host}:${port}`)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fab": "dist/index.js",
|
|
@@ -14,19 +14,16 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@clack/prompts": "^1.2.0",
|
|
17
|
-
"@iarna/toml": "^2.2.5",
|
|
18
17
|
"citty": "^0.2.2",
|
|
19
|
-
"minimatch": "^10.0.1",
|
|
20
18
|
"picocolors": "^1.1.1",
|
|
21
19
|
"string-width": "^7.2.0",
|
|
22
20
|
"tree-sitter-javascript": "^0.25.0",
|
|
23
21
|
"tree-sitter-typescript": "^0.23.2",
|
|
24
22
|
"web-tree-sitter": "^0.26.8",
|
|
25
|
-
"@fenglimg/fabric-server": "1.
|
|
26
|
-
"@fenglimg/fabric-shared": "1.
|
|
23
|
+
"@fenglimg/fabric-server": "1.8.0-rc.1",
|
|
24
|
+
"@fenglimg/fabric-shared": "1.8.0-rc.1"
|
|
27
25
|
},
|
|
28
26
|
"devDependencies": {
|
|
29
|
-
"@types/iarna__toml": "^2.0.5",
|
|
30
27
|
"@types/node": "^22.15.0",
|
|
31
28
|
"tsup": "^8.5.0",
|
|
32
29
|
"typescript": "^5.8.3"
|
|
@@ -34,6 +31,7 @@
|
|
|
34
31
|
"scripts": {
|
|
35
32
|
"build": "tsup",
|
|
36
33
|
"dev": "tsup --watch",
|
|
37
|
-
"test": "vitest run"
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:coverage": "vitest run --coverage"
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
## CORE RULES (DO NOT TRANSLATE)
|
|
4
4
|
|
|
5
5
|
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
-
MUST: Treat `.fabric/
|
|
7
|
-
MUST: Before ANY code reading, architecture planning, or logic modification, call `
|
|
8
|
-
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
-
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/
|
|
6
|
+
MUST: Treat `.fabric/rules/` as the source of truth for all Fabric rule bodies.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_plan_context(paths=[<target file>])`, then call `fab_get_rule_sections`.
|
|
8
|
+
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
+
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/rules/`, `.fabric/agents.meta.json`, `fab_plan_context`, `fab_get_rule_sections`, `rule sources`, `rule source mirroring`, `MUST`, `NEVER`.
|
|
10
10
|
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
11
|
NEVER: Put framework, domain, repository rule bodies, or submodule rules in this file.
|
|
12
12
|
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
@@ -16,6 +16,6 @@ NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
|
16
16
|
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载项目业务规则。
|
|
17
17
|
- 详细 bootstrap 说明位于 `.fabric/bootstrap/README.md`。
|
|
18
18
|
- Detected framework kind: `{ frameworkKind }`.
|
|
19
|
-
- This repository uses `
|
|
20
|
-
- 根级规则应放在 `.fabric/
|
|
21
|
-
- If `.fabric/
|
|
19
|
+
- This repository uses `rule source mirroring`: source directories contain ZERO rule files, while `.fabric/rules/` mirrors source paths for AI constraints.
|
|
20
|
+
- 根级规则应放在 `.fabric/rules/root.md`;跨领域规则应放在 `.fabric/rules/_cross/`。
|
|
21
|
+
- If `.fabric/rules/root.md` is missing, continue with the Fabric initialization flow before normal coding.
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
## CORE RULES (DO NOT TRANSLATE)
|
|
4
4
|
|
|
5
5
|
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
-
MUST: Treat `.fabric/
|
|
7
|
-
MUST: Before ANY code reading, architecture planning, or logic modification, call `
|
|
8
|
-
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
-
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/
|
|
6
|
+
MUST: Treat `.fabric/rules/` as the source of truth for all Fabric rule bodies.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_plan_context(paths=[<target file>])`, then call `fab_get_rule_sections`.
|
|
8
|
+
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
+
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/rules/`, `.fabric/agents.meta.json`, `fab_plan_context`, `fab_get_rule_sections`, `rule sources`, `rule source mirroring`, `MUST`, `NEVER`.
|
|
10
10
|
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
11
|
NEVER: Put Cocos, asset, prefab, scene, repository rule bodies, or submodule rules in this file.
|
|
12
12
|
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
@@ -15,6 +15,6 @@ NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
|
15
15
|
|
|
16
16
|
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Cocos 业务或编辑器规则。
|
|
17
17
|
- Detected framework kind: `cocos-creator`.
|
|
18
|
-
- This repository uses `
|
|
19
|
-
- 根级规则应放在 `.fabric/
|
|
20
|
-
- If `.fabric/
|
|
18
|
+
- This repository uses `rule source mirroring`: source directories contain ZERO rule files, while `.fabric/rules/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/rules/root.md`;跨领域规则应放在 `.fabric/rules/_cross/`。
|
|
20
|
+
- If `.fabric/rules/root.md` is missing, continue with the Fabric initialization flow before normal coding.
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
## CORE RULES (DO NOT TRANSLATE)
|
|
4
4
|
|
|
5
5
|
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
-
MUST: Treat `.fabric/
|
|
7
|
-
MUST: Before ANY code reading, architecture planning, or logic modification, call `
|
|
8
|
-
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
-
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/
|
|
6
|
+
MUST: Treat `.fabric/rules/` as the source of truth for all Fabric rule bodies.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_plan_context(paths=[<target file>])`, then call `fab_get_rule_sections`.
|
|
8
|
+
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
+
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/rules/`, `.fabric/agents.meta.json`, `fab_plan_context`, `fab_get_rule_sections`, `rule sources`, `rule source mirroring`, `MUST`, `NEVER`.
|
|
10
10
|
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
11
|
NEVER: Put Next.js, route, repository rule bodies, or submodule rules in this file.
|
|
12
12
|
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
@@ -15,6 +15,6 @@ NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
|
15
15
|
|
|
16
16
|
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Next.js 业务或路由规则。
|
|
17
17
|
- Detected framework kind: `next`.
|
|
18
|
-
- This repository uses `
|
|
19
|
-
- 根级规则应放在 `.fabric/
|
|
20
|
-
- If `.fabric/
|
|
18
|
+
- This repository uses `rule source mirroring`: source directories contain ZERO rule files, while `.fabric/rules/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/rules/root.md`;跨领域规则应放在 `.fabric/rules/_cross/`。
|
|
20
|
+
- If `.fabric/rules/root.md` is missing, continue with the Fabric initialization flow before normal coding.
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
## CORE RULES (DO NOT TRANSLATE)
|
|
4
4
|
|
|
5
5
|
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
-
MUST: Treat `.fabric/
|
|
7
|
-
MUST: Before ANY code reading, architecture planning, or logic modification, call `
|
|
8
|
-
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
-
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/
|
|
6
|
+
MUST: Treat `.fabric/rules/` as the source of truth for all Fabric rule bodies.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_plan_context(paths=[<target file>])`, then call `fab_get_rule_sections`.
|
|
8
|
+
MUST: When creating or changing an L1/L2 rule node, keep `.fabric/agents.meta.json` synchronized through Fabric tooling.
|
|
9
|
+
MUST: Preserve protected tokens exactly: `AGENTS.md`, `.fabric/rules/`, `.fabric/agents.meta.json`, `fab_plan_context`, `fab_get_rule_sections`, `rule sources`, `rule source mirroring`, `MUST`, `NEVER`.
|
|
10
10
|
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
11
|
NEVER: Put Vite, browser, repository rule bodies, or submodule rules in this file.
|
|
12
12
|
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
@@ -15,6 +15,6 @@ NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
|
15
15
|
|
|
16
16
|
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Vite 业务或浏览器规则。
|
|
17
17
|
- Detected framework kind: `vite`.
|
|
18
|
-
- This repository uses `
|
|
19
|
-
- 根级规则应放在 `.fabric/
|
|
20
|
-
- If `.fabric/
|
|
18
|
+
- This repository uses `rule source mirroring`: source directories contain ZERO rule files, while `.fabric/rules/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/rules/root.md`;跨领域规则应放在 `.fabric/rules/_cross/`。
|
|
20
|
+
- If `.fabric/rules/root.md` is missing, continue with the Fabric initialization flow before normal coding.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Fabric Bootstrap
|
|
2
2
|
- 主说明文档已收敛到 `.fabric/bootstrap/README.md`。
|
|
3
3
|
- 项目级 bootstrap 入口仍然是 `AGENTS.md`。
|
|
4
|
-
- 修改任何文件前必须调用 `
|
|
4
|
+
- 修改任何文件前必须调用 `fab_plan_context(paths=[<被改文件>])`,再调用 `fab_get_rule_sections` 获取规则段落。
|
|
5
|
+
MCP 和 doctor 会写入 `.fabric/events.jsonl`。
|
|
6
|
+
- 规则 baseline 变更通过 `fabric doctor --fix` 接受。
|
|
5
7
|
|
|
6
8
|
@AGENTS.md
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Fabric Bootstrap
|
|
2
2
|
- 主说明文档已收敛到 `.fabric/bootstrap/README.md`。
|
|
3
3
|
- 项目级 bootstrap 入口仍然是 `AGENTS.md`。
|
|
4
|
-
- 修改任何文件前必须调用 `
|
|
4
|
+
- 修改任何文件前必须调用 `fab_plan_context(paths=[<被改文件>])`,再调用 `fab_get_rule_sections` 获取规则段落。
|
|
5
|
+
MCP 和 doctor 会写入 `.fabric/events.jsonl`。
|
|
6
|
+
- 规则 baseline 变更通过 `fabric doctor --fix` 接受。
|
|
5
7
|
|
|
6
8
|
@AGENTS.md
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# Fabric Bootstrap
|
|
2
2
|
- 主说明文档已收敛到 `.fabric/bootstrap/README.md`。
|
|
3
3
|
- 此 header 仅用于把 Codex 引导到 Fabric 项目级规则入口。
|
|
4
|
-
- 修改任何文件前必须调用 `
|
|
4
|
+
- 修改任何文件前必须调用 `fab_plan_context(paths=[<被改文件>])`,再调用 `fab_get_rule_sections` 获取规则段落。
|
|
5
|
+
MCP 和 doctor 会写入 `.fabric/events.jsonl`。
|
|
6
|
+
- 规则 baseline 变更通过 `fabric doctor --fix` 接受。
|
|
@@ -3,9 +3,8 @@ alwaysApply: true
|
|
|
3
3
|
description: Fabric Protocol bootstrap rules
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Fabric Bootstrap
|
|
7
|
-
- 本项目使用 Fabric Protocol 管理规则。
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
- 每次完整任务结束,调 `fab_append_intent` 写一条意图记录。
|
|
6
|
+
# Fabric Bootstrap
|
|
7
|
+
- 本项目使用 Fabric Protocol 管理规则。
|
|
8
|
+
- **任何文件修改前**,必须先调 MCP tool `fab_plan_context(paths=[<被改文件>])`,再调 `fab_get_rule_sections` 获取规则段落。
|
|
9
|
+
- 新建或调整 L1/L2 节点时,修改规则源文件后运行 `fabric doctor --fix` 接受 baseline,**严禁**直接编辑 `.fabric/agents.meta.json`。
|
|
10
|
+
Fabric 会把 MCP 和 doctor 行为写入 `.fabric/events.jsonl`。
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# Fabric Bootstrap
|
|
2
|
-
- 本项目使用 Fabric Protocol 管理规则。
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
|
|
6
|
-
- 每次完整任务结束,调 `fab_append_intent` 写一条意图记录。
|
|
1
|
+
# Fabric Bootstrap
|
|
2
|
+
- 本项目使用 Fabric Protocol 管理规则。
|
|
3
|
+
- **任何文件修改前**,必须先调 MCP tool `fab_plan_context(paths=[<被改文件>])`,再调 `fab_get_rule_sections` 获取规则段落。
|
|
4
|
+
- 新建或调整 L1/L2 节点时,修改规则源文件后运行 `fabric doctor --fix` 接受 baseline,**严禁**直接编辑 `.fabric/agents.meta.json`。
|
|
5
|
+
Fabric 会把 MCP 和 doctor 行为写入 `.fabric/events.jsonl`。
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# Fabric Bootstrap
|
|
2
|
-
- 本项目使用 Fabric Protocol 管理规则。
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
|
|
6
|
-
- 每次完整任务结束,调 `fab_append_intent` 写一条意图记录。
|
|
1
|
+
# Fabric Bootstrap
|
|
2
|
+
- 本项目使用 Fabric Protocol 管理规则。
|
|
3
|
+
- **任何文件修改前**,必须先调 MCP tool `fab_plan_context(paths=[<被改文件>])`,再调 `fab_get_rule_sections` 获取规则段落。
|
|
4
|
+
- 新建或调整 L1/L2 节点时,修改规则源文件后运行 `fabric doctor --fix` 接受 baseline,**严禁**直接编辑 `.fabric/agents.meta.json`。
|
|
5
|
+
Fabric 会把 MCP 和 doctor 行为写入 `.fabric/events.jsonl`。
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fabric-init
|
|
3
|
+
description: Use this skill when fab init just completed, when forensic.json was generated, or when the user is asking to initialize AGENTS.md. This skill runs a 3-phase initialization interview, writes .fabric/init-context.json, generates layered AGENTS.md, and updates .fabric/agents.meta.json.
|
|
4
|
+
allowed-tools: ["Read", "Write", "Glob", "Grep", "Bash"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# fabric-init — Canonical Skill Source
|
|
8
|
+
|
|
9
|
+
> This file is the single source of truth for the fabric-init skill.
|
|
10
|
+
> Do NOT edit the per-client SKILL.md files directly.
|
|
11
|
+
> Run `packages/cli/scripts/derive-skills.ts` to regenerate them from this source.
|
|
12
|
+
|
|
13
|
+
## Precondition
|
|
14
|
+
|
|
15
|
+
MUST: Read `.fabric/forensic.json` before taking any other action. If the file does not
|
|
16
|
+
exist, stop immediately and tell the user: run `fab init` first to generate the evidence
|
|
17
|
+
package.
|
|
18
|
+
|
|
19
|
+
MUST: Check `.fabric/init-context.json`. If it already exists, stop and report that this
|
|
20
|
+
repository appears to have completed initialization already.
|
|
21
|
+
|
|
22
|
+
MUST: Treat `.fabric/bootstrap/README.md` as the authoritative initialization guide for
|
|
23
|
+
the current repository.
|
|
24
|
+
|
|
25
|
+
MUST: Use `.fabric/forensic.json` and repository structure as evidence when deciding what
|
|
26
|
+
to do next.
|
|
27
|
+
|
|
28
|
+
MUST: Preserve protected tokens exactly as written — see the Protected Tokens section.
|
|
29
|
+
|
|
30
|
+
NEVER: Claim initialization is complete without having checked `.fabric/init-context.json`.
|
|
31
|
+
|
|
32
|
+
NEVER: Rewrite or translate protected tokens.
|
|
33
|
+
|
|
34
|
+
NEVER: Ignore `.fabric/bootstrap/README.md` when determining the next initialization step.
|
|
35
|
+
|
|
36
|
+
Treat the following state as initialization pending:
|
|
37
|
+
|
|
38
|
+
- `.fabric/forensic.json` exists
|
|
39
|
+
- `.fabric/init-context.json` does not exist
|
|
40
|
+
|
|
41
|
+
## Execution Flow — 3 Phases / 3 Rounds
|
|
42
|
+
|
|
43
|
+
### Phase 1 — Framework Confirmation (1 round, efficient)
|
|
44
|
+
|
|
45
|
+
Display a summary of `framework`, `topology.by_ext`, and `entry_points` from
|
|
46
|
+
`.fabric/forensic.json`. Ask the user 1–2 clarifying questions about the framework
|
|
47
|
+
architecture.
|
|
48
|
+
|
|
49
|
+
Example (Cocos Creator 3.x):
|
|
50
|
+
|
|
51
|
+
> I detected a Cocos Creator 3.8 project. Main scripts are in `assets/scripts` using the
|
|
52
|
+
> `@ccclass + extends Component` pattern. Please confirm: (1) Is this a TypeScript project
|
|
53
|
+
> (not JavaScript)? (2) Are node references injected mainly via `@property(Node)`, or via
|
|
54
|
+
> `find/getChildByName`?
|
|
55
|
+
|
|
56
|
+
Store the user's answers as verified framework assumptions before proceeding to Phase 2.
|
|
57
|
+
|
|
58
|
+
### Phase 2 — Invariant Extraction (1 round, critical)
|
|
59
|
+
|
|
60
|
+
Based on the `recommendations_for_skill` list in `.fabric/forensic.json`, ask the user
|
|
61
|
+
3–5 invariant questions covering three categories:
|
|
62
|
+
|
|
63
|
+
- `ban`: things that must never appear — e.g. `any`, `async` in `update()`, find-by-name
|
|
64
|
+
- `require`: things that must always be present — e.g. strict TypeScript, `@ccclass`
|
|
65
|
+
decorator, imports only from `cc`
|
|
66
|
+
- `protect`: directories or files that AI must not modify — typically
|
|
67
|
+
`assets/prefabs/**`, `assets/scenes/**`, `**/*.meta`
|
|
68
|
+
|
|
69
|
+
Principles:
|
|
70
|
+
|
|
71
|
+
- Ask only about invariants, not about preferences.
|
|
72
|
+
- Each question accepts only yes / no / a concrete rule — never accept vague answers.
|
|
73
|
+
- Do not auto-infer hard constraints the user has not confirmed.
|
|
74
|
+
|
|
75
|
+
### Phase 3 — Construction and Landing (1 round, automated)
|
|
76
|
+
|
|
77
|
+
#### 3.1 Write `.fabric/init-context.json`
|
|
78
|
+
|
|
79
|
+
Fields required:
|
|
80
|
+
|
|
81
|
+
- `framework`
|
|
82
|
+
- `architecture_patterns`
|
|
83
|
+
- `invariants`
|
|
84
|
+
- `domain_groups`
|
|
85
|
+
- `interview_trail`
|
|
86
|
+
- `forensic_ref`
|
|
87
|
+
|
|
88
|
+
Writing rules:
|
|
89
|
+
|
|
90
|
+
- `invariants[].type` MUST be one of `ban`, `require`, `protect`.
|
|
91
|
+
- `domain_groups` is inferred from `entry_points` and interview results.
|
|
92
|
+
- `interview_trail[]` MUST record the raw Q&A from Phase 1 and Phase 2.
|
|
93
|
+
- `forensic_ref` MUST be `.fabric/forensic.json`.
|
|
94
|
+
|
|
95
|
+
#### 3.2 Generate layered `AGENTS.md`
|
|
96
|
+
|
|
97
|
+
Root `AGENTS.md` requirements:
|
|
98
|
+
|
|
99
|
+
- MUST be within 300 lines.
|
|
100
|
+
- Structure:
|
|
101
|
+
- `# {projectName} — L0 AGENTS.md`
|
|
102
|
+
- `<!-- fab:index -->`: populated with the `domain_groups` index
|
|
103
|
+
- `## L0 AI Constraints`: derived from invariants, grouped by `ban`, `require`, `protect`
|
|
104
|
+
- `## @HUMAN`: protect paths and any human-declared protection rules
|
|
105
|
+
- `## L1 Candidate Notes`: candidate sub-module descriptions for each domain group
|
|
106
|
+
|
|
107
|
+
If `domain_groups.length >= 2`, generate a `{group_path}/AGENTS.md` for each group.
|
|
108
|
+
Maximum depth is L3; total nesting MUST NOT exceed 4 levels.
|
|
109
|
+
|
|
110
|
+
#### 3.3 Update `.fabric/agents.meta.json`
|
|
111
|
+
|
|
112
|
+
- The `nodes` tree MUST match the generated AGENTS hierarchy.
|
|
113
|
+
- Update the hash of every AGENTS.md file that was written.
|
|
114
|
+
- Maintain a consistent internal revision hash chain.
|
|
115
|
+
|
|
116
|
+
#### 3.4 Final output
|
|
117
|
+
|
|
118
|
+
List all generated files for the user and recommend running `fabric doctor --fix` for
|
|
119
|
+
ongoing maintenance.
|
|
120
|
+
|
|
121
|
+
## Hard Rules
|
|
122
|
+
|
|
123
|
+
- Zero TODO: never generate `TODO`, `TBD`, placeholders, or stubs in output files.
|
|
124
|
+
- No YAML frontmatter in outputs: generated `AGENTS.md` files MUST NOT contain YAML
|
|
125
|
+
frontmatter.
|
|
126
|
+
- Root `AGENTS.md` MUST be <= 300 lines.
|
|
127
|
+
- Total AGENTS nesting MUST be <= 4 levels.
|
|
128
|
+
- Do not auto-infer invariants the user has not confirmed.
|
|
129
|
+
- When content is uncertain, omit it — do not leave placeholders.
|
|
130
|
+
|
|
131
|
+
## Output Contract
|
|
132
|
+
|
|
133
|
+
On successful completion the following files exist or are updated:
|
|
134
|
+
|
|
135
|
+
| File | Action |
|
|
136
|
+
|------|--------|
|
|
137
|
+
| `.fabric/init-context.json` | Created with all required fields |
|
|
138
|
+
| `AGENTS.md` | Created (root L0) |
|
|
139
|
+
| `{group_path}/AGENTS.md` | Created for each domain group (when applicable) |
|
|
140
|
+
| `.fabric/agents.meta.json` | Updated nodes tree + hashes |
|
|
141
|
+
|
|
142
|
+
On failure or early termination the skill MUST leave no partial files. If a write fails
|
|
143
|
+
mid-sequence, report the failure and the exact file that was not written.
|
|
144
|
+
|
|
145
|
+
## Protected Tokens
|
|
146
|
+
|
|
147
|
+
The following tokens MUST be preserved exactly as shown — same casing, same punctuation,
|
|
148
|
+
never translated:
|
|
149
|
+
|
|
150
|
+
| Token | Type |
|
|
151
|
+
|-------|------|
|
|
152
|
+
| `AGENTS.md` | Filename |
|
|
153
|
+
| `FABRIC.md` | Filename |
|
|
154
|
+
| `.fabric/agents.meta.json` | Path |
|
|
155
|
+
| `.fabric/init-context.json` | Path |
|
|
156
|
+
| `.fabric/forensic.json` | Path |
|
|
157
|
+
| `.fabric/bootstrap/README.md` | Path |
|
|
158
|
+
| `MUST` | Keyword |
|
|
159
|
+
| `NEVER` | Keyword |
|
|
160
|
+
| `fab init` | CLI command |
|
|
161
|
+
| `fabric doctor --fix` | CLI command |
|
|
162
|
+
| `<!-- fab:index -->` | HTML comment marker |
|
|
163
|
+
| `@HUMAN` | Section marker |
|
|
@@ -1,27 +1,162 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fabric-init
|
|
3
|
-
description: Use this skill when
|
|
3
|
+
description: Use this skill when .fabric/forensic.json exists and this repository still needs the remaining Fabric initialization steps.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# fabric-init — Canonical Skill Source
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
MUST: 使用 `.fabric/forensic.json` 和仓库结构中的依据,判断接下来该做什么。
|
|
12
|
-
MUST: Preserve protected tokens exactly: `AGENTS.md`, `FABRIC.md`, `.fabric/agents.meta.json`, `.fabric/human-lock.json`, `.fabric/init-context.json`, `.fabric/forensic.json`, `MUST`, `NEVER`.
|
|
13
|
-
NEVER: 在没有检查 `.fabric/init-context.json` 的情况下声称初始化已经完成。
|
|
14
|
-
NEVER: 改写或翻译受保护 token。
|
|
15
|
-
NEVER: 在判断下一步初始化动作时忽略 `.fabric/bootstrap/README.md`。
|
|
8
|
+
> This file is the single source of truth for the fabric-init skill.
|
|
9
|
+
> Do NOT edit the per-client SKILL.md files directly.
|
|
10
|
+
> Run `packages/cli/scripts/derive-skills.ts` to regenerate them from this source.
|
|
16
11
|
|
|
17
|
-
##
|
|
12
|
+
## Precondition
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
MUST: Read `.fabric/forensic.json` before taking any other action. If the file does not
|
|
15
|
+
exist, stop immediately and tell the user: run `fab init` first to generate the evidence
|
|
16
|
+
package.
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
MUST: Check `.fabric/init-context.json`. If it already exists, stop and report that this
|
|
19
|
+
repository appears to have completed initialization already.
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
MUST: Treat `.fabric/bootstrap/README.md` as the authoritative initialization guide for
|
|
22
|
+
the current repository.
|
|
23
|
+
|
|
24
|
+
MUST: Use `.fabric/forensic.json` and repository structure as evidence when deciding what
|
|
25
|
+
to do next.
|
|
26
|
+
|
|
27
|
+
MUST: Preserve protected tokens exactly as written — see the Protected Tokens section.
|
|
28
|
+
|
|
29
|
+
NEVER: Claim initialization is complete without having checked `.fabric/init-context.json`.
|
|
30
|
+
|
|
31
|
+
NEVER: Rewrite or translate protected tokens.
|
|
32
|
+
|
|
33
|
+
NEVER: Ignore `.fabric/bootstrap/README.md` when determining the next initialization step.
|
|
34
|
+
|
|
35
|
+
Treat the following state as initialization pending:
|
|
36
|
+
|
|
37
|
+
- `.fabric/forensic.json` exists
|
|
38
|
+
- `.fabric/init-context.json` does not exist
|
|
39
|
+
|
|
40
|
+
## Execution Flow — 3 Phases / 3 Rounds
|
|
41
|
+
|
|
42
|
+
### Phase 1 — Framework Confirmation (1 round, efficient)
|
|
43
|
+
|
|
44
|
+
Display a summary of `framework`, `topology.by_ext`, and `entry_points` from
|
|
45
|
+
`.fabric/forensic.json`. Ask the user 1–2 clarifying questions about the framework
|
|
46
|
+
architecture.
|
|
47
|
+
|
|
48
|
+
Example (Cocos Creator 3.x):
|
|
49
|
+
|
|
50
|
+
> I detected a Cocos Creator 3.8 project. Main scripts are in `assets/scripts` using the
|
|
51
|
+
> `@ccclass + extends Component` pattern. Please confirm: (1) Is this a TypeScript project
|
|
52
|
+
> (not JavaScript)? (2) Are node references injected mainly via `@property(Node)`, or via
|
|
53
|
+
> `find/getChildByName`?
|
|
54
|
+
|
|
55
|
+
Store the user's answers as verified framework assumptions before proceeding to Phase 2.
|
|
56
|
+
|
|
57
|
+
### Phase 2 — Invariant Extraction (1 round, critical)
|
|
58
|
+
|
|
59
|
+
Based on the `recommendations_for_skill` list in `.fabric/forensic.json`, ask the user
|
|
60
|
+
3–5 invariant questions covering three categories:
|
|
61
|
+
|
|
62
|
+
- `ban`: things that must never appear — e.g. `any`, `async` in `update()`, find-by-name
|
|
63
|
+
- `require`: things that must always be present — e.g. strict TypeScript, `@ccclass`
|
|
64
|
+
decorator, imports only from `cc`
|
|
65
|
+
- `protect`: directories or files that AI must not modify — typically
|
|
66
|
+
`assets/prefabs/**`, `assets/scenes/**`, `**/*.meta`
|
|
67
|
+
|
|
68
|
+
Principles:
|
|
69
|
+
|
|
70
|
+
- Ask only about invariants, not about preferences.
|
|
71
|
+
- Each question accepts only yes / no / a concrete rule — never accept vague answers.
|
|
72
|
+
- Do not auto-infer hard constraints the user has not confirmed.
|
|
73
|
+
|
|
74
|
+
### Phase 3 — Construction and Landing (1 round, automated)
|
|
75
|
+
|
|
76
|
+
#### 3.1 Write `.fabric/init-context.json`
|
|
77
|
+
|
|
78
|
+
Fields required:
|
|
79
|
+
|
|
80
|
+
- `framework`
|
|
81
|
+
- `architecture_patterns`
|
|
82
|
+
- `invariants`
|
|
83
|
+
- `domain_groups`
|
|
84
|
+
- `interview_trail`
|
|
85
|
+
- `forensic_ref`
|
|
86
|
+
|
|
87
|
+
Writing rules:
|
|
88
|
+
|
|
89
|
+
- `invariants[].type` MUST be one of `ban`, `require`, `protect`.
|
|
90
|
+
- `domain_groups` is inferred from `entry_points` and interview results.
|
|
91
|
+
- `interview_trail[]` MUST record the raw Q&A from Phase 1 and Phase 2.
|
|
92
|
+
- `forensic_ref` MUST be `.fabric/forensic.json`.
|
|
93
|
+
|
|
94
|
+
#### 3.2 Generate layered `AGENTS.md`
|
|
95
|
+
|
|
96
|
+
Root `AGENTS.md` requirements:
|
|
97
|
+
|
|
98
|
+
- MUST be within 300 lines.
|
|
99
|
+
- Structure:
|
|
100
|
+
- `# {projectName} — L0 AGENTS.md`
|
|
101
|
+
- `<!-- fab:index -->`: populated with the `domain_groups` index
|
|
102
|
+
- `## L0 AI Constraints`: derived from invariants, grouped by `ban`, `require`, `protect`
|
|
103
|
+
- `## @HUMAN`: protect paths and any human-declared protection rules
|
|
104
|
+
- `## L1 Candidate Notes`: candidate sub-module descriptions for each domain group
|
|
105
|
+
|
|
106
|
+
If `domain_groups.length >= 2`, generate a `{group_path}/AGENTS.md` for each group.
|
|
107
|
+
Maximum depth is L3; total nesting MUST NOT exceed 4 levels.
|
|
108
|
+
|
|
109
|
+
#### 3.3 Update `.fabric/agents.meta.json`
|
|
110
|
+
|
|
111
|
+
- The `nodes` tree MUST match the generated AGENTS hierarchy.
|
|
112
|
+
- Update the hash of every AGENTS.md file that was written.
|
|
113
|
+
- Maintain a consistent internal revision hash chain.
|
|
114
|
+
|
|
115
|
+
#### 3.4 Final output
|
|
116
|
+
|
|
117
|
+
List all generated files for the user and recommend running `fabric doctor --fix` for
|
|
118
|
+
ongoing maintenance.
|
|
119
|
+
|
|
120
|
+
## Hard Rules
|
|
121
|
+
|
|
122
|
+
- Zero TODO: never generate `TODO`, `TBD`, placeholders, or stubs in output files.
|
|
123
|
+
- No YAML frontmatter in outputs: generated `AGENTS.md` files MUST NOT contain YAML
|
|
124
|
+
frontmatter.
|
|
125
|
+
- Root `AGENTS.md` MUST be <= 300 lines.
|
|
126
|
+
- Total AGENTS nesting MUST be <= 4 levels.
|
|
127
|
+
- Do not auto-infer invariants the user has not confirmed.
|
|
128
|
+
- When content is uncertain, omit it — do not leave placeholders.
|
|
129
|
+
|
|
130
|
+
## Output Contract
|
|
131
|
+
|
|
132
|
+
On successful completion the following files exist or are updated:
|
|
133
|
+
|
|
134
|
+
| File | Action |
|
|
135
|
+
|------|--------|
|
|
136
|
+
| `.fabric/init-context.json` | Created with all required fields |
|
|
137
|
+
| `AGENTS.md` | Created (root L0) |
|
|
138
|
+
| `{group_path}/AGENTS.md` | Created for each domain group (when applicable) |
|
|
139
|
+
| `.fabric/agents.meta.json` | Updated nodes tree + hashes |
|
|
140
|
+
|
|
141
|
+
On failure or early termination the skill MUST leave no partial files. If a write fails
|
|
142
|
+
mid-sequence, report the failure and the exact file that was not written.
|
|
143
|
+
|
|
144
|
+
## Protected Tokens
|
|
145
|
+
|
|
146
|
+
The following tokens MUST be preserved exactly as shown — same casing, same punctuation,
|
|
147
|
+
never translated:
|
|
148
|
+
|
|
149
|
+
| Token | Type |
|
|
150
|
+
|-------|------|
|
|
151
|
+
| `AGENTS.md` | Filename |
|
|
152
|
+
| `FABRIC.md` | Filename |
|
|
153
|
+
| `.fabric/agents.meta.json` | Path |
|
|
154
|
+
| `.fabric/init-context.json` | Path |
|
|
155
|
+
| `.fabric/forensic.json` | Path |
|
|
156
|
+
| `.fabric/bootstrap/README.md` | Path |
|
|
157
|
+
| `MUST` | Keyword |
|
|
158
|
+
| `NEVER` | Keyword |
|
|
159
|
+
| `fab init` | CLI command |
|
|
160
|
+
| `fabric doctor --fix` | CLI command |
|
|
161
|
+
| `<!-- fab:index -->` | HTML comment marker |
|
|
162
|
+
| `@HUMAN` | Section marker |
|