@fenglimg/fabric-cli 0.1.4 → 1.1.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/dist/{bootstrap-HUDJ2E3Q.js → bootstrap-PMIA4W6G.js} +16 -12
- package/dist/chunk-6ICJICVU.js +10 -0
- package/dist/{chunk-T3WQUWW4.js → chunk-6UUPKSDE.js} +78 -36
- package/dist/chunk-AEOYCVBG.js +0 -0
- package/dist/{chunk-U376IPKT.js → chunk-F2BXHPM5.js} +11 -7
- package/dist/chunk-JWUO6TIS.js +220 -0
- package/dist/{chunk-CZ7U6ULM.js → chunk-L43IGJ6X.js} +17 -7
- package/dist/{chunk-N7TTCGJA.js → chunk-VMYPJPKV.js} +1 -0
- package/dist/chunk-WWNXR34K.js +49 -0
- package/dist/{config-YKDWIRCT.js → config-PXEEXWLM.js} +14 -11
- package/dist/doctor-QTSG2RWF.js +125 -0
- package/dist/{hooks-VXXO4VZP.js → hooks-5S5IRVQE.js} +15 -12
- package/dist/human-lint-YSFOZHZ7.js +13 -0
- package/dist/index.js +16 -11
- package/dist/init-R73E5YTG.js +1164 -0
- package/dist/{ledger-append-EGIKSMU5.js → ledger-append-XZ5SX4O5.js} +2 -1
- package/dist/{pre-commit-CXPH7BZH.js → pre-commit-BLSUMT3P.js} +14 -9
- package/dist/{scan-UASZQLQP.js → scan-JBGFRB7P.js} +3 -2
- package/dist/serve-4J2CQY25.js +112 -0
- package/dist/{sync-meta-YTG5V3Y6.js → sync-meta-THZSEM7Y.js} +6 -2
- package/package.json +12 -8
- package/templates/agents-md/AGENTS.md.template +20 -29
- package/templates/agents-md/variants/cocos.md +20 -0
- package/templates/agents-md/variants/next.md +20 -0
- package/templates/agents-md/variants/vite.md +20 -0
- package/templates/claude-hooks/agents-md-init-reminder.cjs +18 -0
- package/templates/claude-skills/agents-md-init/SKILL.md +86 -0
- package/dist/chunk-BWZHNZG6.js +0 -236
- package/dist/chunk-P4KVFB2T.js +0 -22
- package/dist/human-lint-II6TBGP4.js +0 -9
- package/dist/init-IBS7KO7A.js +0 -149
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ledger_append_default
|
|
4
|
+
} from "./chunk-F2BXHPM5.js";
|
|
2
5
|
import {
|
|
3
6
|
resolveDevModeTarget
|
|
4
7
|
} from "./chunk-AEOYCVBG.js";
|
|
5
8
|
import {
|
|
6
9
|
sync_meta_default
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-P4KVFB2T.js";
|
|
10
|
+
} from "./chunk-6UUPKSDE.js";
|
|
9
11
|
import {
|
|
10
12
|
human_lint_default
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-L43IGJ6X.js";
|
|
14
|
+
import "./chunk-WWNXR34K.js";
|
|
12
15
|
import {
|
|
13
|
-
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
t
|
|
17
|
+
} from "./chunk-6ICJICVU.js";
|
|
15
18
|
|
|
16
19
|
// src/commands/pre-commit.ts
|
|
17
20
|
import { defineCommand } from "citty";
|
|
@@ -20,20 +23,22 @@ async function runOrFail(name, cmd, args) {
|
|
|
20
23
|
try {
|
|
21
24
|
await cmd.run?.({ args });
|
|
22
25
|
} catch (err) {
|
|
23
|
-
process.stderr.write(
|
|
24
|
-
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
`${t("cli.pre-commit.run-failed", { name, message: err.message })}
|
|
28
|
+
`
|
|
29
|
+
);
|
|
25
30
|
process.exit(1);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
var pre_commit_default = defineCommand({
|
|
29
34
|
meta: {
|
|
30
35
|
name: "pre-commit",
|
|
31
|
-
description: "
|
|
36
|
+
description: t("cli.pre-commit.description")
|
|
32
37
|
},
|
|
33
38
|
args: {
|
|
34
39
|
target: {
|
|
35
40
|
type: "string",
|
|
36
|
-
description: "
|
|
41
|
+
description: t("cli.pre-commit.args.target.description")
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
async run({ args }) {
|
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
createScanReport,
|
|
4
4
|
scanCommand,
|
|
5
5
|
scan_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JWUO6TIS.js";
|
|
7
7
|
import "./chunk-AEOYCVBG.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WWNXR34K.js";
|
|
9
|
+
import "./chunk-6ICJICVU.js";
|
|
9
10
|
export {
|
|
10
11
|
createScanReport,
|
|
11
12
|
scan_default as default,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createDebugLogger,
|
|
4
|
+
resolveDevMode
|
|
5
|
+
} from "./chunk-AEOYCVBG.js";
|
|
6
|
+
import {
|
|
7
|
+
paint,
|
|
8
|
+
symbol
|
|
9
|
+
} from "./chunk-WWNXR34K.js";
|
|
10
|
+
import {
|
|
11
|
+
t
|
|
12
|
+
} from "./chunk-6ICJICVU.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/serve.ts
|
|
15
|
+
import { defineCommand } from "citty";
|
|
16
|
+
import { startHttpServer } from "@fenglimg/fabric-server";
|
|
17
|
+
var DEFAULT_PORT = 7373;
|
|
18
|
+
var serveCommand = defineCommand({
|
|
19
|
+
meta: {
|
|
20
|
+
name: "serve",
|
|
21
|
+
description: t("cli.serve.description")
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
port: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: t("cli.serve.args.port.description"),
|
|
27
|
+
default: String(DEFAULT_PORT)
|
|
28
|
+
},
|
|
29
|
+
host: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: t("cli.serve.args.host.description"),
|
|
32
|
+
default: "127.0.0.1"
|
|
33
|
+
},
|
|
34
|
+
target: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: t("cli.serve.args.target.description")
|
|
37
|
+
},
|
|
38
|
+
debug: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
description: t("cli.serve.args.debug.description"),
|
|
41
|
+
default: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async run({ args }) {
|
|
45
|
+
const workspaceRoot = process.cwd();
|
|
46
|
+
const logger = createDebugLogger(args.debug);
|
|
47
|
+
const resolution = resolveDevMode(args.target, workspaceRoot);
|
|
48
|
+
const port = parsePort(args.port);
|
|
49
|
+
const requestedHost = parseHost(args.host);
|
|
50
|
+
const authToken = readAuthTokenFromEnv();
|
|
51
|
+
const host = validateHost(requestedHost, authToken);
|
|
52
|
+
logger(`serve target source: ${resolution.source}`);
|
|
53
|
+
for (const step of resolution.chain) {
|
|
54
|
+
logger(step);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await startHttpServer({
|
|
58
|
+
port,
|
|
59
|
+
projectRoot: resolution.target,
|
|
60
|
+
host,
|
|
61
|
+
authToken
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (isNodeError(error) && error.code === "EADDRINUSE") {
|
|
65
|
+
throw new Error(t("cli.serve.error.port-in-use", { port: String(port), nextPort: String(port + 1) }));
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
console.log(`${symbol.ok} ${paint.ai(t("cli.serve.ready.title"))} ${paint.human(`http://${host}:${port}`)}`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var serve_default = serveCommand;
|
|
73
|
+
function parsePort(value) {
|
|
74
|
+
const port = Number.parseInt(value ?? String(DEFAULT_PORT), 10);
|
|
75
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
76
|
+
throw new Error(t("cli.shared.invalid-port", { value: value ?? "<unset>" }));
|
|
77
|
+
}
|
|
78
|
+
return port;
|
|
79
|
+
}
|
|
80
|
+
function parseHost(value) {
|
|
81
|
+
const host = value?.trim() ?? "127.0.0.1";
|
|
82
|
+
if (host.length === 0) {
|
|
83
|
+
throw new Error(t("cli.shared.invalid-host-empty"));
|
|
84
|
+
}
|
|
85
|
+
return host;
|
|
86
|
+
}
|
|
87
|
+
function readAuthTokenFromEnv() {
|
|
88
|
+
const token = process.env.FABRIC_AUTH_TOKEN;
|
|
89
|
+
return token === void 0 || token.length === 0 ? void 0 : token;
|
|
90
|
+
}
|
|
91
|
+
function validateHost(host, authToken) {
|
|
92
|
+
if (authToken !== void 0) {
|
|
93
|
+
return host;
|
|
94
|
+
}
|
|
95
|
+
if (!isLoopbackHost(host)) {
|
|
96
|
+
console.error(
|
|
97
|
+
`${symbol.warn} ${paint.warn(t("cli.serve.warning.host-fallback", { host }))}`
|
|
98
|
+
);
|
|
99
|
+
return "127.0.0.1";
|
|
100
|
+
}
|
|
101
|
+
return host;
|
|
102
|
+
}
|
|
103
|
+
function isLoopbackHost(host) {
|
|
104
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1";
|
|
105
|
+
}
|
|
106
|
+
function isNodeError(error) {
|
|
107
|
+
return error instanceof Error;
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
serve_default as default,
|
|
111
|
+
serveCommand
|
|
112
|
+
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
computeAgentsMeta,
|
|
4
|
+
deriveLayer,
|
|
5
|
+
deriveTopologyType,
|
|
4
6
|
syncMetaCommand,
|
|
5
7
|
sync_meta_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-6UUPKSDE.js";
|
|
9
|
+
import "./chunk-6ICJICVU.js";
|
|
8
10
|
export {
|
|
9
11
|
computeAgentsMeta,
|
|
10
12
|
sync_meta_default as default,
|
|
13
|
+
deriveLayer,
|
|
14
|
+
deriveTopologyType,
|
|
11
15
|
syncMetaCommand
|
|
12
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fab": "dist/index.js"
|
|
@@ -11,19 +11,23 @@
|
|
|
11
11
|
"dist",
|
|
12
12
|
"templates"
|
|
13
13
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"dev": "tsup --watch"
|
|
17
|
-
},
|
|
18
14
|
"dependencies": {
|
|
19
|
-
"@fenglimg/fabric-server": "^0.1.0",
|
|
20
15
|
"@iarna/toml": "^2.2.5",
|
|
21
|
-
"citty": "^0.2.2"
|
|
16
|
+
"citty": "^0.2.2",
|
|
17
|
+
"picocolors": "^1.1.1",
|
|
18
|
+
"string-width": "^7.2.0",
|
|
19
|
+
"@fenglimg/fabric-shared": "1.1.0",
|
|
20
|
+
"@fenglimg/fabric-server": "1.1.0"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
24
23
|
"@types/iarna__toml": "^2.0.5",
|
|
25
24
|
"@types/node": "^22.15.0",
|
|
26
25
|
"tsup": "^8.5.0",
|
|
27
26
|
"typescript": "^5.8.3"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"dev": "tsup --watch",
|
|
31
|
+
"test": "vitest run"
|
|
28
32
|
}
|
|
29
|
-
}
|
|
33
|
+
}
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
# { projectName } —
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## @HUMAN
|
|
22
|
-
|
|
23
|
-
// TODO: human-owned decisions live here. AI must not rewrite locked sentences.
|
|
24
|
-
// TODO: placeholder locked sentence 1.
|
|
25
|
-
// TODO: placeholder locked sentence 2.
|
|
26
|
-
|
|
27
|
-
## L1 Candidate Notes
|
|
28
|
-
|
|
29
|
-
// TODO: identify domain folders that may need scoped AGENTS.md files.
|
|
1
|
+
# { projectName } — Fabric Bootstrap Protocol
|
|
2
|
+
|
|
3
|
+
## CORE RULES (DO NOT TRANSLATE)
|
|
4
|
+
|
|
5
|
+
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
+
MUST: Treat `.fabric/agents/` as the authoritative home for all AI shadow constraints.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_get_rules(path=<target file>)`.
|
|
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/agents/`, `.fabric/agents.meta.json`, `fab_get_rules`, `shadow constraints`, `Shadow Mirroring`, `MUST`, `NEVER`.
|
|
10
|
+
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
|
+
NEVER: Put framework, domain, repository rule bodies, or submodule rules in this file.
|
|
12
|
+
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
13
|
+
|
|
14
|
+
## 使用说明 / Explanation
|
|
15
|
+
|
|
16
|
+
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载项目业务规则。
|
|
17
|
+
- Detected framework kind: `{ frameworkKind }`.
|
|
18
|
+
- This repository uses `Shadow Mirroring`: source directories contain ZERO rule files, while `.fabric/agents/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/agents/root.md`;跨领域规则应放在 `.fabric/agents/_cross/`。
|
|
20
|
+
- If `.fabric/agents/root.md` is missing, stop normal coding and run the initialization flow that creates shadow constraints.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# { projectName } — Fabric Bootstrap Protocol
|
|
2
|
+
|
|
3
|
+
## CORE RULES (DO NOT TRANSLATE)
|
|
4
|
+
|
|
5
|
+
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
+
MUST: Treat `.fabric/agents/` as the authoritative home for all AI shadow constraints.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_get_rules(path=<target file>)`.
|
|
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/agents/`, `.fabric/agents.meta.json`, `fab_get_rules`, `shadow constraints`, `Shadow Mirroring`, `MUST`, `NEVER`.
|
|
10
|
+
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
|
+
NEVER: Put Cocos, asset, prefab, scene, repository rule bodies, or submodule rules in this file.
|
|
12
|
+
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
13
|
+
|
|
14
|
+
## 使用说明 / Explanation
|
|
15
|
+
|
|
16
|
+
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Cocos 业务或编辑器规则。
|
|
17
|
+
- Detected framework kind: `cocos-creator`.
|
|
18
|
+
- This repository uses `Shadow Mirroring`: source directories contain ZERO rule files, while `.fabric/agents/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/agents/root.md`;跨领域规则应放在 `.fabric/agents/_cross/`。
|
|
20
|
+
- If `.fabric/agents/root.md` is missing, stop normal coding and run the initialization flow that creates shadow constraints.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# { projectName } — Fabric Bootstrap Protocol
|
|
2
|
+
|
|
3
|
+
## CORE RULES (DO NOT TRANSLATE)
|
|
4
|
+
|
|
5
|
+
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
+
MUST: Treat `.fabric/agents/` as the authoritative home for all AI shadow constraints.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_get_rules(path=<target file>)`.
|
|
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/agents/`, `.fabric/agents.meta.json`, `fab_get_rules`, `shadow constraints`, `Shadow Mirroring`, `MUST`, `NEVER`.
|
|
10
|
+
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
|
+
NEVER: Put Next.js, route, repository rule bodies, or submodule rules in this file.
|
|
12
|
+
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
13
|
+
|
|
14
|
+
## 使用说明 / Explanation
|
|
15
|
+
|
|
16
|
+
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Next.js 业务或路由规则。
|
|
17
|
+
- Detected framework kind: `next`.
|
|
18
|
+
- This repository uses `Shadow Mirroring`: source directories contain ZERO rule files, while `.fabric/agents/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/agents/root.md`;跨领域规则应放在 `.fabric/agents/_cross/`。
|
|
20
|
+
- If `.fabric/agents/root.md` is missing, stop normal coding and run the initialization flow that creates shadow constraints.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# { projectName } — Fabric Bootstrap Protocol
|
|
2
|
+
|
|
3
|
+
## CORE RULES (DO NOT TRANSLATE)
|
|
4
|
+
|
|
5
|
+
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
6
|
+
MUST: Treat `.fabric/agents/` as the authoritative home for all AI shadow constraints.
|
|
7
|
+
MUST: Before ANY code reading, architecture planning, or logic modification, call `fab_get_rules(path=<target file>)`.
|
|
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/agents/`, `.fabric/agents.meta.json`, `fab_get_rules`, `shadow constraints`, `Shadow Mirroring`, `MUST`, `NEVER`.
|
|
10
|
+
NEVER: Add import-style directive lines to this bootstrap file.
|
|
11
|
+
NEVER: Put Vite, browser, repository rule bodies, or submodule rules in this file.
|
|
12
|
+
NEVER: Create colocated `AGENTS.md` rule files under source directories.
|
|
13
|
+
|
|
14
|
+
## 使用说明 / Explanation
|
|
15
|
+
|
|
16
|
+
- 本文件只负责启动 Fabric Bootstrap Protocol,不承载 Vite 业务或浏览器规则。
|
|
17
|
+
- Detected framework kind: `vite`.
|
|
18
|
+
- This repository uses `Shadow Mirroring`: source directories contain ZERO rule files, while `.fabric/agents/` mirrors source paths for AI constraints.
|
|
19
|
+
- 根级规则应放在 `.fabric/agents/root.md`;跨领域规则应放在 `.fabric/agents/_cross/`。
|
|
20
|
+
- If `.fabric/agents/root.md` is missing, stop normal coding and run the initialization flow that creates shadow constraints.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { existsSync } = require("node:fs");
|
|
3
|
+
const { join } = require("node:path");
|
|
4
|
+
|
|
5
|
+
const forensicPath = join(process.cwd(), ".fabric", "forensic.json");
|
|
6
|
+
const initContextPath = join(process.cwd(), ".fabric", "init-context.json");
|
|
7
|
+
|
|
8
|
+
if (!existsSync(forensicPath) || existsSync(initContextPath)) {
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
process.stdout.write(
|
|
13
|
+
JSON.stringify({
|
|
14
|
+
decision: "block",
|
|
15
|
+
reason:
|
|
16
|
+
"fab init 已完成证据收集,但项目 AGENTS.md 初始化尚未完成。调用 agents-md-init skill (通过 Skill 工具) 完成 3 阶段初始化访谈。参考: .claude/skills/agents-md-init/SKILL.md + .fabric/forensic.json",
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agents-md-init
|
|
3
|
+
description: Use this skill when fab init just completed, when forensic.json 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
|
+
## Precondition
|
|
8
|
+
|
|
9
|
+
必须先 Read `.fabric/forensic.json`。若该文件不存在,终止 skill 并告知用户:`请先运行 fab init 生成证据包`。
|
|
10
|
+
|
|
11
|
+
把以下状态视为 initialization pending:
|
|
12
|
+
|
|
13
|
+
- `.fabric/forensic.json` 存在
|
|
14
|
+
- `.fabric/init-context.json` 不存在
|
|
15
|
+
|
|
16
|
+
## 执行流程 (3 Phase / 3 Round)
|
|
17
|
+
|
|
18
|
+
### Phase 1 — 框架确认(1 轮,高效)
|
|
19
|
+
|
|
20
|
+
展示 `.fabric/forensic.json` 的 `framework`、`topology.by_ext`、`entry_points` 摘要,向用户提 1-2 个框架架构澄清问题。
|
|
21
|
+
|
|
22
|
+
示例(Cocos Creator 3.x):
|
|
23
|
+
|
|
24
|
+
> 我检测到 Cocos Creator 3.8 项目,主要脚本在 `assets/scripts`,采用 `@ccclass + extends Component` 模式。请确认:(1) 这是 TypeScript 项目(非 JavaScript)对吗?(2) 节点引用主要通过 `@property(Node)` 注入,还是 `find/getChildByName`?
|
|
25
|
+
|
|
26
|
+
将用户确认结果暂存为已验证 framework assumptions。
|
|
27
|
+
|
|
28
|
+
### Phase 2 — 不变式提取(1 轮,关键)
|
|
29
|
+
|
|
30
|
+
基于 `.fabric/forensic.json` 的 `recommendations_for_skill` 列表,向用户提 3-5 个 invariants 问题,覆盖三类:
|
|
31
|
+
|
|
32
|
+
- `ban`:禁止 any、禁止 update() 中 async、禁止 find-by-name 等
|
|
33
|
+
- `require`:必须 strict TypeScript、必须 `@ccclass` decorator、必须 import from `cc` only 等
|
|
34
|
+
- `protect`:哪些目录或文件 AI 不能修改,一般是 `assets/prefabs/**`、`assets/scenes/**`、`**/*.meta`
|
|
35
|
+
|
|
36
|
+
原则:
|
|
37
|
+
|
|
38
|
+
- 只问 invariants,不问 preferences
|
|
39
|
+
- 每个问题只接受 yes/no/具体规则,不接受模糊回答
|
|
40
|
+
- 不要自动推测用户未确认的硬约束
|
|
41
|
+
|
|
42
|
+
### Phase 3 — 构造与落地(1 轮,自动)
|
|
43
|
+
|
|
44
|
+
1. 写入 `.fabric/init-context.json`,包含:
|
|
45
|
+
|
|
46
|
+
- `framework`
|
|
47
|
+
- `architecture_patterns`
|
|
48
|
+
- `invariants`
|
|
49
|
+
- `domain_groups`
|
|
50
|
+
- `interview_trail`
|
|
51
|
+
- `forensic_ref`
|
|
52
|
+
|
|
53
|
+
写入规则:
|
|
54
|
+
|
|
55
|
+
- `invariants[].type` 必须是 `ban`、`require`、`protect`
|
|
56
|
+
- `domain_groups` 由 `entry_points` 和访谈结果推断
|
|
57
|
+
- `interview_trail[]` 必须记录 Phase 1 和 Phase 2 的原始问答
|
|
58
|
+
- `forensic_ref` 必须为 `.fabric/forensic.json`
|
|
59
|
+
|
|
60
|
+
2. 生成分层 `AGENTS.md`:
|
|
61
|
+
|
|
62
|
+
- 根 `AGENTS.md` 必须在 300 行以内,结构包含:
|
|
63
|
+
- `# {projectName} — L0 AGENTS.md`
|
|
64
|
+
- `<!-- fab:index -->`:填充 `domain_groups` 索引
|
|
65
|
+
- `## L0 AI Constraints`:从 invariants 派生,按 `ban`、`require`、`protect` 分段
|
|
66
|
+
- `## @HUMAN`:protect 路径和用户声明的人类保护规则
|
|
67
|
+
- `## L1 Candidate Notes`:domain_groups 对应的候选子模块说明
|
|
68
|
+
|
|
69
|
+
如果 `domain_groups.length >= 2`,为每个 group 生成 `{group_path}/AGENTS.md`。最多到 L3,总嵌套不超过 4 层。
|
|
70
|
+
|
|
71
|
+
3. 更新 `.fabric/agents.meta.json` 的 nodes 树,保持 revision hash 链一致:
|
|
72
|
+
|
|
73
|
+
- nodes 结构与生成后的 AGENTS 层级一致
|
|
74
|
+
- 更新所有变更 AGENTS 文件的 hash
|
|
75
|
+
- 保持 revision hash 链内部一致
|
|
76
|
+
|
|
77
|
+
4. 最终输出:向用户列出生成文件清单,并建议后续维护时运行 `fab sync-meta`。
|
|
78
|
+
|
|
79
|
+
## Hard Rules
|
|
80
|
+
|
|
81
|
+
- Zero TODO: 不生成任何 `TODO`、`TBD`、placeholder、stub
|
|
82
|
+
- No YAML frontmatter in outputs: 除本 skill 自身外,生成的 `AGENTS.md` 不得包含 YAML frontmatter
|
|
83
|
+
- Root AGENTS.md <= 300 lines
|
|
84
|
+
- AGENTS 嵌套总层级 <= 4
|
|
85
|
+
- 不得自动推测用户未确认的 invariants
|
|
86
|
+
- 有不确定内容时删除,不要留占位符
|