@fenglimg/fabric-shared 1.8.0-rc.3 → 2.0.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/{chunk-FEEWLYO3.js → chunk-U2SR2M4L.js} +26 -21
- package/dist/chunk-VQDCDCJA.js +555 -0
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +3398 -1031
- package/dist/index.js +381 -82
- package/dist/node.js +172 -3
- package/dist/schemas/api-contracts.d.ts +822 -114
- package/dist/schemas/api-contracts.js +51 -13
- package/dist/types/index.d.ts +37 -6
- package/package.json +3 -7
- package/dist/chunk-GI6L6VTT.js +0 -176
- package/dist/chunk-KV27CZH3.js +0 -223
- package/dist/node/bootstrap-guide.d.ts +0 -12
- package/dist/node/bootstrap-guide.js +0 -52
|
@@ -1,36 +1,74 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FabExtractKnowledgeInputSchema,
|
|
3
|
+
FabExtractKnowledgeInputShape,
|
|
4
|
+
FabExtractKnowledgeOutputSchema,
|
|
5
|
+
FabReviewInputSchema,
|
|
6
|
+
FabReviewOutputSchema,
|
|
7
|
+
KNOWLEDGE_TYPE_CODES,
|
|
8
|
+
KnowledgeEntryFrontmatterSchema,
|
|
9
|
+
KnowledgeTypeSchema,
|
|
10
|
+
LayerSchema,
|
|
11
|
+
MaturitySchema,
|
|
12
|
+
PROPOSED_REASON_DESCRIPTIONS,
|
|
13
|
+
ProposedReasonSchema,
|
|
14
|
+
StableIdSchema,
|
|
2
15
|
annotateIntentRequestSchema,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
16
|
+
fabExtractKnowledgeAnnotations,
|
|
17
|
+
fabReviewAnnotations,
|
|
18
|
+
formatKnowledgeId,
|
|
19
|
+
getKnowledgeAnnotations,
|
|
20
|
+
getKnowledgeInputSchema,
|
|
21
|
+
getKnowledgeOutputSchema,
|
|
6
22
|
historyStateQuerySchema,
|
|
7
23
|
humanLockApproveRequestSchema,
|
|
8
24
|
humanLockFileParamsSchema,
|
|
25
|
+
knowledgeSectionsAnnotations,
|
|
26
|
+
knowledgeSectionsInputSchema,
|
|
27
|
+
knowledgeSectionsOutputSchema,
|
|
9
28
|
ledgerQuerySchema,
|
|
10
29
|
ledgerSourceSchema,
|
|
30
|
+
parseKnowledgeId,
|
|
11
31
|
planContextAnnotations,
|
|
32
|
+
planContextHintNarrowEntrySchema,
|
|
33
|
+
planContextHintOutputSchema,
|
|
12
34
|
planContextInputSchema,
|
|
13
35
|
planContextOutputSchema,
|
|
14
|
-
ruleSectionsAnnotations,
|
|
15
|
-
ruleSectionsInputSchema,
|
|
16
|
-
ruleSectionsOutputSchema,
|
|
17
36
|
structuredWarningSchema
|
|
18
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-VQDCDCJA.js";
|
|
19
38
|
export {
|
|
39
|
+
FabExtractKnowledgeInputSchema,
|
|
40
|
+
FabExtractKnowledgeInputShape,
|
|
41
|
+
FabExtractKnowledgeOutputSchema,
|
|
42
|
+
FabReviewInputSchema,
|
|
43
|
+
FabReviewOutputSchema,
|
|
44
|
+
KNOWLEDGE_TYPE_CODES,
|
|
45
|
+
KnowledgeEntryFrontmatterSchema,
|
|
46
|
+
KnowledgeTypeSchema,
|
|
47
|
+
LayerSchema,
|
|
48
|
+
MaturitySchema,
|
|
49
|
+
PROPOSED_REASON_DESCRIPTIONS,
|
|
50
|
+
ProposedReasonSchema,
|
|
51
|
+
StableIdSchema,
|
|
20
52
|
annotateIntentRequestSchema,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
fabExtractKnowledgeAnnotations,
|
|
54
|
+
fabReviewAnnotations,
|
|
55
|
+
formatKnowledgeId,
|
|
56
|
+
getKnowledgeAnnotations,
|
|
57
|
+
getKnowledgeInputSchema,
|
|
58
|
+
getKnowledgeOutputSchema,
|
|
24
59
|
historyStateQuerySchema,
|
|
25
60
|
humanLockApproveRequestSchema,
|
|
26
61
|
humanLockFileParamsSchema,
|
|
62
|
+
knowledgeSectionsAnnotations,
|
|
63
|
+
knowledgeSectionsInputSchema,
|
|
64
|
+
knowledgeSectionsOutputSchema,
|
|
27
65
|
ledgerQuerySchema,
|
|
28
66
|
ledgerSourceSchema,
|
|
67
|
+
parseKnowledgeId,
|
|
29
68
|
planContextAnnotations,
|
|
69
|
+
planContextHintNarrowEntrySchema,
|
|
70
|
+
planContextHintOutputSchema,
|
|
30
71
|
planContextInputSchema,
|
|
31
72
|
planContextOutputSchema,
|
|
32
|
-
ruleSectionsAnnotations,
|
|
33
|
-
ruleSectionsInputSchema,
|
|
34
|
-
ruleSectionsOutputSchema,
|
|
35
73
|
structuredWarningSchema
|
|
36
74
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ interface RuleDescription {
|
|
|
9
9
|
impact: string[];
|
|
10
10
|
must_read_if: string;
|
|
11
11
|
entities?: string[];
|
|
12
|
+
id?: string;
|
|
13
|
+
knowledge_type?: "model" | "decision" | "guideline" | "pitfall" | "process";
|
|
14
|
+
maturity?: "draft" | "verified" | "proven";
|
|
15
|
+
knowledge_layer?: "personal" | "team";
|
|
16
|
+
layer_reason?: string;
|
|
17
|
+
created_at?: string;
|
|
18
|
+
tags?: string[];
|
|
19
|
+
relevance_scope?: "narrow" | "broad";
|
|
20
|
+
relevance_paths?: string[];
|
|
12
21
|
}
|
|
13
22
|
interface RuleDescriptionIndexItem {
|
|
14
23
|
stable_id: string;
|
|
@@ -16,6 +25,12 @@ interface RuleDescriptionIndexItem {
|
|
|
16
25
|
required: boolean;
|
|
17
26
|
selectable: boolean;
|
|
18
27
|
description: RuleDescription;
|
|
28
|
+
type?: "model" | "decision" | "guideline" | "pitfall" | "process";
|
|
29
|
+
maturity?: "draft" | "verified" | "proven";
|
|
30
|
+
layer?: "personal" | "team";
|
|
31
|
+
layer_reason?: string;
|
|
32
|
+
relevance_scope?: "narrow" | "broad";
|
|
33
|
+
relevance_paths?: string[];
|
|
19
34
|
}
|
|
20
35
|
interface AgentsMetaNodeActivation {
|
|
21
36
|
tier: AgentsActivationTier;
|
|
@@ -25,21 +40,33 @@ interface AgentsMetaNode {
|
|
|
25
40
|
file: string;
|
|
26
41
|
content_ref?: string;
|
|
27
42
|
scope_glob: string;
|
|
28
|
-
deps: string[];
|
|
29
|
-
priority: "high" | "medium" | "low";
|
|
30
|
-
level?: AgentsLayer;
|
|
31
|
-
layer: AgentsLayer;
|
|
32
|
-
topology_type: AgentsTopologyType;
|
|
33
43
|
hash: string;
|
|
34
44
|
stable_id?: string;
|
|
35
45
|
identity_source?: AgentsIdentitySource;
|
|
36
46
|
activation?: AgentsMetaNodeActivation;
|
|
37
47
|
description?: RuleDescription;
|
|
38
48
|
sections?: string[];
|
|
49
|
+
deps?: string[];
|
|
50
|
+
priority?: "high" | "medium" | "low";
|
|
51
|
+
level?: AgentsLayer;
|
|
52
|
+
layer?: AgentsLayer;
|
|
53
|
+
topology_type?: AgentsTopologyType;
|
|
54
|
+
}
|
|
55
|
+
interface AgentsMetaKnowledgeTypeCounters {
|
|
56
|
+
MOD: number;
|
|
57
|
+
DEC: number;
|
|
58
|
+
GLD: number;
|
|
59
|
+
PIT: number;
|
|
60
|
+
PRO: number;
|
|
61
|
+
}
|
|
62
|
+
interface AgentsMetaCountersEnvelope {
|
|
63
|
+
KP: AgentsMetaKnowledgeTypeCounters;
|
|
64
|
+
KT: AgentsMetaKnowledgeTypeCounters;
|
|
39
65
|
}
|
|
40
66
|
interface AgentsMeta {
|
|
41
67
|
revision: string;
|
|
42
68
|
nodes: Record<string, AgentsMetaNode>;
|
|
69
|
+
counters?: AgentsMetaCountersEnvelope;
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
interface AiLedgerEntry {
|
|
@@ -80,6 +107,8 @@ interface McpPayloadLimits {
|
|
|
80
107
|
warnBytes?: number;
|
|
81
108
|
hardBytes?: number;
|
|
82
109
|
}
|
|
110
|
+
type KnowledgeLanguage = "match-existing" | "zh-CN" | "en";
|
|
111
|
+
type DefaultLayerFilter = "team" | "personal" | "both";
|
|
83
112
|
interface FabricConfig {
|
|
84
113
|
clientPaths?: ClientPaths;
|
|
85
114
|
externalFixturePath?: string;
|
|
@@ -87,6 +116,8 @@ interface FabricConfig {
|
|
|
87
116
|
auditMode?: AuditMode;
|
|
88
117
|
audit_mode?: AuditMode;
|
|
89
118
|
mcpPayloadLimits?: McpPayloadLimits;
|
|
119
|
+
knowledge_language?: KnowledgeLanguage;
|
|
120
|
+
default_layer_filter?: DefaultLayerFilter;
|
|
90
121
|
}
|
|
91
122
|
|
|
92
|
-
export type { AgentsActivationTier, AgentsIdentitySource, AgentsLayer, AgentsMeta, AgentsMetaNode, AgentsMetaNodeActivation, AgentsTopologyType, AiLedgerEntry, AuditMode, ClientPaths, FabricConfig, HumanLedgerEntry, HumanLockEntry, LedgerEntry, McpPayloadLimits, RuleDescription, RuleDescriptionIndexItem };
|
|
123
|
+
export type { AgentsActivationTier, AgentsIdentitySource, AgentsLayer, AgentsMeta, AgentsMetaCountersEnvelope, AgentsMetaKnowledgeTypeCounters, AgentsMetaNode, AgentsMetaNodeActivation, AgentsTopologyType, AiLedgerEntry, AuditMode, ClientPaths, DefaultLayerFilter, FabricConfig, HumanLedgerEntry, HumanLockEntry, KnowledgeLanguage, LedgerEntry, McpPayloadLimits, RuleDescription, RuleDescriptionIndexItem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -29,10 +29,6 @@
|
|
|
29
29
|
"types": "./dist/node/mcp-payload-guard.d.ts",
|
|
30
30
|
"import": "./dist/node/mcp-payload-guard.js"
|
|
31
31
|
},
|
|
32
|
-
"./node/bootstrap-guide": {
|
|
33
|
-
"types": "./dist/node/bootstrap-guide.d.ts",
|
|
34
|
-
"import": "./dist/node/bootstrap-guide.js"
|
|
35
|
-
},
|
|
36
32
|
"./errors": {
|
|
37
33
|
"types": "./dist/errors/index.d.ts",
|
|
38
34
|
"import": "./dist/errors/index.js"
|
|
@@ -56,8 +52,8 @@
|
|
|
56
52
|
"vitest": "^3.2.4"
|
|
57
53
|
},
|
|
58
54
|
"scripts": {
|
|
59
|
-
"build": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/
|
|
60
|
-
"dev": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/
|
|
55
|
+
"build": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts --format esm --dts --clean",
|
|
56
|
+
"dev": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts --format esm --dts --watch",
|
|
61
57
|
"test": "vitest run",
|
|
62
58
|
"test:coverage": "vitest run --coverage"
|
|
63
59
|
}
|
package/dist/chunk-GI6L6VTT.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
// src/detector.ts
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
function detectFramework(root) {
|
|
5
|
-
const evidence = [];
|
|
6
|
-
const creatorConfigPath = join(root, "project.config.json");
|
|
7
|
-
if (existsSync(creatorConfigPath)) {
|
|
8
|
-
const version = readCreatorVersion(creatorConfigPath);
|
|
9
|
-
return {
|
|
10
|
-
kind: "cocos-creator",
|
|
11
|
-
version,
|
|
12
|
-
subkind: inferCocosSubkind(root, version),
|
|
13
|
-
evidence: version === "unknown" ? ["project.config.json"] : [`project.config.json: creator.version=${version}`],
|
|
14
|
-
framework: "cocos-creator",
|
|
15
|
-
confidence: "HIGH",
|
|
16
|
-
ast_evidence: [],
|
|
17
|
-
co_packages: collectProjectFileEvidence(root, ["package.json", "tsconfig.json"])
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const packageJsonPath = join(root, "package.json");
|
|
21
|
-
if (existsSync(packageJsonPath)) {
|
|
22
|
-
const packageJson = readPackageJson(packageJsonPath);
|
|
23
|
-
const creatorVersion = packageJson.creator?.version;
|
|
24
|
-
if (typeof creatorVersion === "string" && creatorVersion.trim().length > 0) {
|
|
25
|
-
const deps2 = collectDependencyVersions(packageJson);
|
|
26
|
-
return {
|
|
27
|
-
kind: "cocos-creator",
|
|
28
|
-
version: creatorVersion,
|
|
29
|
-
subkind: inferCocosSubkind(root, creatorVersion),
|
|
30
|
-
evidence: [`package.json: creator.version=${creatorVersion}`],
|
|
31
|
-
framework: "cocos-creator",
|
|
32
|
-
confidence: "HIGH",
|
|
33
|
-
ast_evidence: [],
|
|
34
|
-
co_packages: collectCoPackages(deps2, "cocos-creator", root)
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const deps = collectDependencyVersions(packageJson);
|
|
38
|
-
for (const [dependencyName, kind] of [
|
|
39
|
-
["next", "next"],
|
|
40
|
-
["vite", "vite"],
|
|
41
|
-
["react", "react"],
|
|
42
|
-
["vue", "vue"]
|
|
43
|
-
]) {
|
|
44
|
-
if (deps.has(dependencyName)) {
|
|
45
|
-
const version = deps.get(dependencyName) ?? "unknown";
|
|
46
|
-
evidence.push(`package.json dependency: ${dependencyName}@${version}`);
|
|
47
|
-
return {
|
|
48
|
-
kind,
|
|
49
|
-
version,
|
|
50
|
-
subkind: inferPackageSubkind(kind),
|
|
51
|
-
evidence,
|
|
52
|
-
framework: kind,
|
|
53
|
-
confidence: determinePackageConfidence(kind, deps, root),
|
|
54
|
-
ast_evidence: [],
|
|
55
|
-
co_packages: collectCoPackages(deps, kind, root)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
evidence.push("package.json");
|
|
60
|
-
}
|
|
61
|
-
if (existsSync(join(root, "Cargo.toml"))) {
|
|
62
|
-
return {
|
|
63
|
-
kind: "rust",
|
|
64
|
-
version: "unknown",
|
|
65
|
-
subkind: "cargo-project",
|
|
66
|
-
evidence: ["Cargo.toml"],
|
|
67
|
-
framework: "rust",
|
|
68
|
-
confidence: "HIGH",
|
|
69
|
-
ast_evidence: [],
|
|
70
|
-
co_packages: collectProjectFileEvidence(root, ["Cargo.lock"])
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
74
|
-
return {
|
|
75
|
-
kind: "python",
|
|
76
|
-
version: "unknown",
|
|
77
|
-
subkind: "pyproject",
|
|
78
|
-
evidence: ["pyproject.toml"],
|
|
79
|
-
framework: "python",
|
|
80
|
-
confidence: "HIGH",
|
|
81
|
-
ast_evidence: [],
|
|
82
|
-
co_packages: collectProjectFileEvidence(root, ["uv.lock", "poetry.lock", "requirements.txt"])
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
kind: "unknown",
|
|
87
|
-
version: "unknown",
|
|
88
|
-
subkind: "unknown",
|
|
89
|
-
evidence,
|
|
90
|
-
framework: "unknown",
|
|
91
|
-
confidence: "LOW",
|
|
92
|
-
ast_evidence: [],
|
|
93
|
-
co_packages: []
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function readPackageJson(packageJsonPath) {
|
|
97
|
-
try {
|
|
98
|
-
return JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
99
|
-
} catch {
|
|
100
|
-
return {};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function readCreatorVersion(creatorConfigPath) {
|
|
104
|
-
try {
|
|
105
|
-
const creatorConfig = JSON.parse(readFileSync(creatorConfigPath, "utf8"));
|
|
106
|
-
return creatorConfig.creator?.version ?? "unknown";
|
|
107
|
-
} catch {
|
|
108
|
-
return "unknown";
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function collectDependencyVersions(packageJson) {
|
|
112
|
-
return new Map([
|
|
113
|
-
...Object.entries(packageJson.dependencies ?? {}),
|
|
114
|
-
...Object.entries(packageJson.devDependencies ?? {}),
|
|
115
|
-
...Object.entries(packageJson.peerDependencies ?? {}),
|
|
116
|
-
...Object.entries(packageJson.optionalDependencies ?? {})
|
|
117
|
-
]);
|
|
118
|
-
}
|
|
119
|
-
function inferCocosSubkind(root, version) {
|
|
120
|
-
const majorVersion = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
121
|
-
if (majorVersion === 2) {
|
|
122
|
-
return "javascript-traditional";
|
|
123
|
-
}
|
|
124
|
-
if (majorVersion >= 3) {
|
|
125
|
-
return "typescript-component";
|
|
126
|
-
}
|
|
127
|
-
return existsSync(join(root, "tsconfig.json")) ? "typescript-component" : "javascript-traditional";
|
|
128
|
-
}
|
|
129
|
-
function inferPackageSubkind(kind) {
|
|
130
|
-
switch (kind) {
|
|
131
|
-
case "next":
|
|
132
|
-
return "next-application";
|
|
133
|
-
case "vite":
|
|
134
|
-
return "vite-application";
|
|
135
|
-
case "react":
|
|
136
|
-
return "react-application";
|
|
137
|
-
case "vue":
|
|
138
|
-
return "vue-application";
|
|
139
|
-
default:
|
|
140
|
-
return "unknown";
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function determinePackageConfidence(kind, deps, root) {
|
|
144
|
-
const coPackages = collectCoPackages(deps, kind, root);
|
|
145
|
-
return coPackages.length > 0 ? "HIGH" : "MEDIUM";
|
|
146
|
-
}
|
|
147
|
-
function collectCoPackages(deps, kind, root) {
|
|
148
|
-
const expectedPackagesByFramework = {
|
|
149
|
-
next: ["react", "react-dom", "typescript"],
|
|
150
|
-
vite: ["@vitejs/plugin-react", "@vitejs/plugin-vue", "typescript", "react", "vue"],
|
|
151
|
-
react: ["react-dom", "@types/react", "@types/react-dom"],
|
|
152
|
-
vue: ["@vitejs/plugin-vue", "typescript"],
|
|
153
|
-
"cocos-creator": ["typescript"]
|
|
154
|
-
};
|
|
155
|
-
const expectedProjectFilesByFramework = {
|
|
156
|
-
next: ["next.config.js", "next.config.mjs", "next.config.ts", "tsconfig.json"],
|
|
157
|
-
vite: ["vite.config.js", "vite.config.mjs", "vite.config.ts", "tsconfig.json"],
|
|
158
|
-
react: ["tsconfig.json"],
|
|
159
|
-
vue: ["vue.config.js", "vite.config.ts", "tsconfig.json"],
|
|
160
|
-
"cocos-creator": ["project.config.json", "tsconfig.json"]
|
|
161
|
-
};
|
|
162
|
-
return [
|
|
163
|
-
...compactStrings((expectedPackagesByFramework[kind] ?? []).map((packageName) => deps.has(packageName) ? packageName : null)),
|
|
164
|
-
...collectProjectFileEvidence(root, expectedProjectFilesByFramework[kind] ?? [])
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
function collectProjectFileEvidence(root, relativePaths) {
|
|
168
|
-
return relativePaths.filter((relativePath) => existsSync(join(root, relativePath)));
|
|
169
|
-
}
|
|
170
|
-
function compactStrings(values) {
|
|
171
|
-
return [...new Set(values.filter((value) => value !== null && value !== void 0 && value.length > 0))];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export {
|
|
175
|
-
detectFramework
|
|
176
|
-
};
|
package/dist/chunk-KV27CZH3.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
// src/schemas/api-contracts.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var structuredWarningSchema = z.object({
|
|
4
|
-
code: z.string(),
|
|
5
|
-
file: z.string(),
|
|
6
|
-
line: z.number().optional(),
|
|
7
|
-
action_hint: z.string()
|
|
8
|
-
});
|
|
9
|
-
var _ruleDescriptionSchema = z.object({
|
|
10
|
-
summary: z.string(),
|
|
11
|
-
intent_clues: z.array(z.string()),
|
|
12
|
-
tech_stack: z.array(z.string()),
|
|
13
|
-
impact: z.array(z.string()),
|
|
14
|
-
must_read_if: z.string(),
|
|
15
|
-
entities: z.array(z.string()).optional()
|
|
16
|
-
});
|
|
17
|
-
var _descriptionIndexItemSchema = z.object({
|
|
18
|
-
stable_id: z.string(),
|
|
19
|
-
level: z.enum(["L0", "L1", "L2"]),
|
|
20
|
-
required: z.boolean(),
|
|
21
|
-
selectable: z.boolean(),
|
|
22
|
-
description: _ruleDescriptionSchema
|
|
23
|
-
});
|
|
24
|
-
var _requirementProfileSchema = z.object({
|
|
25
|
-
target_path: z.string(),
|
|
26
|
-
path_segments: z.array(z.string()),
|
|
27
|
-
extension: z.string(),
|
|
28
|
-
inferred_domain: z.array(z.string()),
|
|
29
|
-
known_tech: z.array(z.string()),
|
|
30
|
-
user_intent: z.string(),
|
|
31
|
-
intent_tokens: z.array(z.string()),
|
|
32
|
-
impact_hints: z.array(z.string()),
|
|
33
|
-
detected_entities: z.array(z.string())
|
|
34
|
-
});
|
|
35
|
-
var _selectionPolicySchema = z.object({
|
|
36
|
-
required_levels: z.tuple([z.literal("L0"), z.literal("L2")]),
|
|
37
|
-
ai_selectable_levels: z.tuple([z.literal("L1")]),
|
|
38
|
-
final_fetch_rule: z.literal("required_stable_ids + ai_selected_l1_stable_ids")
|
|
39
|
-
});
|
|
40
|
-
var planContextInputSchema = z.object({
|
|
41
|
-
paths: z.array(z.string()).min(1).describe("Candidate file paths to build neutral rule selection context for"),
|
|
42
|
-
intent: z.string().optional().describe("User-stated requirement or implementation intent; used only to build a neutral requirement profile"),
|
|
43
|
-
known_tech: z.array(z.string()).optional().describe("Known technologies involved in the requirement profile"),
|
|
44
|
-
detected_entities: z.record(z.array(z.string())).optional().describe("Optional path-keyed detected entities for the requirement profile"),
|
|
45
|
-
client_hash: z.string().optional().describe("Revision hash from a prior fab_plan_context response; enables stale detection"),
|
|
46
|
-
correlation_id: z.string().optional().describe("Optional caller-provided correlation id for Event Ledger records"),
|
|
47
|
-
session_id: z.string().optional().describe("Optional caller-provided session id for Event Ledger records")
|
|
48
|
-
});
|
|
49
|
-
var planContextOutputSchema = z.object({
|
|
50
|
-
revision_hash: z.string(),
|
|
51
|
-
stale: z.boolean(),
|
|
52
|
-
selection_token: z.string(),
|
|
53
|
-
entries: z.array(
|
|
54
|
-
z.object({
|
|
55
|
-
path: z.string(),
|
|
56
|
-
requirement_profile: _requirementProfileSchema,
|
|
57
|
-
description_index: z.array(_descriptionIndexItemSchema),
|
|
58
|
-
required_stable_ids: z.array(z.string()),
|
|
59
|
-
ai_selectable_stable_ids: z.array(z.string()),
|
|
60
|
-
initial_selected_stable_ids: z.array(z.string()),
|
|
61
|
-
selection_policy: _selectionPolicySchema
|
|
62
|
-
})
|
|
63
|
-
),
|
|
64
|
-
shared: z.object({
|
|
65
|
-
required_stable_ids: z.array(z.string()),
|
|
66
|
-
ai_selectable_stable_ids: z.array(z.string()),
|
|
67
|
-
description_index: z.array(_descriptionIndexItemSchema),
|
|
68
|
-
preflight_diagnostics: z.array(
|
|
69
|
-
z.object({
|
|
70
|
-
code: z.literal("missing_description"),
|
|
71
|
-
severity: z.literal("warn"),
|
|
72
|
-
message: z.string(),
|
|
73
|
-
stable_ids: z.array(z.string()).optional(),
|
|
74
|
-
path: z.string().optional()
|
|
75
|
-
})
|
|
76
|
-
)
|
|
77
|
-
}),
|
|
78
|
-
warnings: z.array(structuredWarningSchema).optional()
|
|
79
|
-
});
|
|
80
|
-
var planContextAnnotations = {
|
|
81
|
-
readOnlyHint: true,
|
|
82
|
-
idempotentHint: true,
|
|
83
|
-
destructiveHint: false,
|
|
84
|
-
openWorldHint: false,
|
|
85
|
-
title: "Plan rule context"
|
|
86
|
-
};
|
|
87
|
-
var _rulesEntrySchema = z.object({ path: z.string(), content: z.string() });
|
|
88
|
-
var _humanLockedSchema = z.object({ file: z.string(), excerpt: z.string() });
|
|
89
|
-
var _descriptionStubSchema = z.object({ path: z.string(), description: z.string() });
|
|
90
|
-
var getRulesInputSchema = z.object({
|
|
91
|
-
path: z.string().describe("Target file path to query rules for"),
|
|
92
|
-
client_hash: z.string().optional().describe("Revision hash from prior fab_get_rules response; enables stale detection"),
|
|
93
|
-
correlation_id: z.string().optional().describe("Optional caller-provided correlation id for Event Ledger records"),
|
|
94
|
-
session_id: z.string().optional().describe("Optional caller-provided session id for Event Ledger records")
|
|
95
|
-
});
|
|
96
|
-
var getRulesOutputSchema = z.object({
|
|
97
|
-
revision_hash: z.string(),
|
|
98
|
-
stale: z.boolean(),
|
|
99
|
-
rules: z.object({
|
|
100
|
-
L0: z.string(),
|
|
101
|
-
L1: z.array(_rulesEntrySchema),
|
|
102
|
-
L2: z.array(_rulesEntrySchema),
|
|
103
|
-
human_locked_nearby: z.array(_humanLockedSchema),
|
|
104
|
-
description_stubs: z.array(_descriptionStubSchema).optional()
|
|
105
|
-
}),
|
|
106
|
-
warnings: z.array(structuredWarningSchema).optional()
|
|
107
|
-
});
|
|
108
|
-
var getRulesAnnotations = {
|
|
109
|
-
readOnlyHint: true,
|
|
110
|
-
idempotentHint: true,
|
|
111
|
-
destructiveHint: false,
|
|
112
|
-
openWorldHint: false,
|
|
113
|
-
title: "Get rule content"
|
|
114
|
-
};
|
|
115
|
-
var RULE_SECTION_NAMES_TUPLE = ["MISSION_STATEMENT", "MANDATORY_INJECTION", "BUSINESS_LOGIC_CHUNKS", "CONTEXT_INFO"];
|
|
116
|
-
var ruleSectionsInputSchema = z.object({
|
|
117
|
-
selection_token: z.string().min(1).describe("Selection token returned by fab_plan_context"),
|
|
118
|
-
sections: z.array(z.enum(RULE_SECTION_NAMES_TUPLE)).min(1).describe("Structured rule sections to fetch"),
|
|
119
|
-
ai_selected_stable_ids: z.array(z.string()).describe("AI-selected L1 stable_ids chosen from fab_plan_context ai_selectable_stable_ids"),
|
|
120
|
-
ai_selection_reasons: z.record(z.string().min(1)).describe("Reason for each AI-selected L1 stable_id"),
|
|
121
|
-
correlation_id: z.string().optional().describe("Optional caller-provided correlation id for Event Ledger records"),
|
|
122
|
-
session_id: z.string().optional().describe("Optional caller-provided session id for Event Ledger records")
|
|
123
|
-
});
|
|
124
|
-
var ruleSectionsOutputSchema = z.object({
|
|
125
|
-
revision_hash: z.string(),
|
|
126
|
-
precedence: z.tuple([z.literal("L2"), z.literal("L1"), z.literal("L0")]),
|
|
127
|
-
selected_stable_ids: z.array(z.string()),
|
|
128
|
-
rules: z.array(
|
|
129
|
-
z.object({
|
|
130
|
-
stable_id: z.string(),
|
|
131
|
-
level: z.enum(["L0", "L1", "L2"]),
|
|
132
|
-
path: z.string(),
|
|
133
|
-
sections: z.record(z.string())
|
|
134
|
-
})
|
|
135
|
-
),
|
|
136
|
-
diagnostics: z.array(
|
|
137
|
-
z.object({
|
|
138
|
-
code: z.literal("missing_section"),
|
|
139
|
-
severity: z.literal("warn"),
|
|
140
|
-
stable_id: z.string(),
|
|
141
|
-
section: z.enum(RULE_SECTION_NAMES_TUPLE),
|
|
142
|
-
message: z.string()
|
|
143
|
-
})
|
|
144
|
-
),
|
|
145
|
-
warnings: z.array(structuredWarningSchema).optional()
|
|
146
|
-
});
|
|
147
|
-
var ruleSectionsAnnotations = {
|
|
148
|
-
readOnlyHint: true,
|
|
149
|
-
idempotentHint: true,
|
|
150
|
-
destructiveHint: false,
|
|
151
|
-
openWorldHint: false,
|
|
152
|
-
title: "Filter rule sections"
|
|
153
|
-
};
|
|
154
|
-
var ledgerSourceSchema = z.enum(["ai", "human"]);
|
|
155
|
-
var timestampFilterSchema = z.preprocess((value) => {
|
|
156
|
-
if (value === void 0 || value === null || value === "") {
|
|
157
|
-
return void 0;
|
|
158
|
-
}
|
|
159
|
-
if (typeof value === "number") {
|
|
160
|
-
return value;
|
|
161
|
-
}
|
|
162
|
-
if (typeof value === "string") {
|
|
163
|
-
const trimmed = value.trim();
|
|
164
|
-
if (trimmed.length === 0) {
|
|
165
|
-
return void 0;
|
|
166
|
-
}
|
|
167
|
-
if (/^\d+$/.test(trimmed)) {
|
|
168
|
-
return Number.parseInt(trimmed, 10);
|
|
169
|
-
}
|
|
170
|
-
const parsed = Date.parse(trimmed);
|
|
171
|
-
return Number.isNaN(parsed) ? value : parsed;
|
|
172
|
-
}
|
|
173
|
-
return value;
|
|
174
|
-
}, z.number().int().nonnegative());
|
|
175
|
-
var ledgerQuerySchema = z.object({
|
|
176
|
-
source: ledgerSourceSchema.optional(),
|
|
177
|
-
since: timestampFilterSchema.optional()
|
|
178
|
-
});
|
|
179
|
-
var historyStateQuerySchema = z.object({
|
|
180
|
-
ledger_id: z.string().trim().min(1).optional(),
|
|
181
|
-
ts: timestampFilterSchema.optional()
|
|
182
|
-
}).superRefine((value, ctx) => {
|
|
183
|
-
const provided = [value.ledger_id, value.ts].filter((entry) => entry !== void 0);
|
|
184
|
-
if (provided.length !== 1) {
|
|
185
|
-
ctx.addIssue({
|
|
186
|
-
code: z.ZodIssueCode.custom,
|
|
187
|
-
message: "Provide exactly one of ledger_id or ts.",
|
|
188
|
-
path: ["ledger_id"]
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
var humanLockApproveRequestSchema = z.object({
|
|
193
|
-
file: z.string().min(1),
|
|
194
|
-
start_line: z.number().int().positive(),
|
|
195
|
-
end_line: z.number().int().positive(),
|
|
196
|
-
new_hash: z.string().min(1)
|
|
197
|
-
});
|
|
198
|
-
var humanLockFileParamsSchema = z.object({
|
|
199
|
-
file: z.string().min(1)
|
|
200
|
-
});
|
|
201
|
-
var annotateIntentRequestSchema = z.object({
|
|
202
|
-
ledger_entry_id: z.string().min(1),
|
|
203
|
-
annotation: z.string().trim().min(1)
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
export {
|
|
207
|
-
structuredWarningSchema,
|
|
208
|
-
planContextInputSchema,
|
|
209
|
-
planContextOutputSchema,
|
|
210
|
-
planContextAnnotations,
|
|
211
|
-
getRulesInputSchema,
|
|
212
|
-
getRulesOutputSchema,
|
|
213
|
-
getRulesAnnotations,
|
|
214
|
-
ruleSectionsInputSchema,
|
|
215
|
-
ruleSectionsOutputSchema,
|
|
216
|
-
ruleSectionsAnnotations,
|
|
217
|
-
ledgerSourceSchema,
|
|
218
|
-
ledgerQuerySchema,
|
|
219
|
-
historyStateQuerySchema,
|
|
220
|
-
humanLockApproveRequestSchema,
|
|
221
|
-
humanLockFileParamsSchema,
|
|
222
|
-
annotateIntentRequestSchema
|
|
223
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const FABRIC_BOOTSTRAP_PATH = ".fabric/bootstrap/README.md";
|
|
2
|
-
/**
|
|
3
|
-
* Build the content for .fabric/bootstrap/README.md.
|
|
4
|
-
*
|
|
5
|
-
* Produces the same structured bootstrap guide that `fab init` writes, using
|
|
6
|
-
* the detected framework kind and the project name from package.json. This
|
|
7
|
-
* lives in shared so both the CLI and the server doctor --fix path can use the
|
|
8
|
-
* identical builder.
|
|
9
|
-
*/
|
|
10
|
-
declare function buildBootstrapContent(projectRoot: string): string;
|
|
11
|
-
|
|
12
|
-
export { FABRIC_BOOTSTRAP_PATH, buildBootstrapContent };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
detectFramework
|
|
3
|
-
} from "../chunk-GI6L6VTT.js";
|
|
4
|
-
|
|
5
|
-
// src/node/bootstrap-guide.ts
|
|
6
|
-
import { existsSync, readFileSync } from "fs";
|
|
7
|
-
import { join, parse } from "path";
|
|
8
|
-
var FABRIC_BOOTSTRAP_PATH = ".fabric/bootstrap/README.md";
|
|
9
|
-
function buildBootstrapContent(projectRoot) {
|
|
10
|
-
const framework = detectFramework(projectRoot);
|
|
11
|
-
const projectName = readProjectName(projectRoot) ?? parse(projectRoot).base;
|
|
12
|
-
const frameworkKind = framework.kind;
|
|
13
|
-
const content = `# ${projectName} \u2014 Fabric Bootstrap Protocol
|
|
14
|
-
|
|
15
|
-
## CORE RULES (DO NOT TRANSLATE)
|
|
16
|
-
|
|
17
|
-
MUST: Treat this file as the Fabric Protocol bootstrap for this repository.
|
|
18
|
-
MUST: Treat \`.fabric/rules/\` as the source of truth for all Fabric rule bodies.
|
|
19
|
-
MUST: Before ANY code reading, architecture planning, or logic modification, call \`fab_plan_context(paths=[<target file>])\`, then call \`fab_get_rule_sections\`.
|
|
20
|
-
MUST: When creating or changing an L1/L2 rule node, keep \`.fabric/agents.meta.json\` synchronized through Fabric tooling.
|
|
21
|
-
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\`.
|
|
22
|
-
NEVER: Add import-style directive lines to this bootstrap file.
|
|
23
|
-
NEVER: Put framework, domain, repository rule bodies, or submodule rules in this file.
|
|
24
|
-
NEVER: Create colocated \`AGENTS.md\` rule files under source directories.
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
- This file bootstraps the Fabric Protocol; it does not carry project-specific rules.
|
|
29
|
-
- Detailed bootstrap notes are in \`.fabric/bootstrap/README.md\`.
|
|
30
|
-
- Detected framework kind: \`${frameworkKind}\`.
|
|
31
|
-
- This repository uses \`rule source mirroring\`: source directories contain ZERO rule files, while \`.fabric/rules/\` mirrors source paths for AI constraints.
|
|
32
|
-
- Root-level rules belong in \`.fabric/rules/root.md\`; cross-domain rules in \`.fabric/rules/_cross/\`.
|
|
33
|
-
- If \`.fabric/rules/root.md\` is missing, complete the Fabric initialization flow before normal coding.
|
|
34
|
-
`;
|
|
35
|
-
return content;
|
|
36
|
-
}
|
|
37
|
-
function readProjectName(projectRoot) {
|
|
38
|
-
const packageJsonPath = join(projectRoot, "package.json");
|
|
39
|
-
if (!existsSync(packageJsonPath)) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const raw = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
44
|
-
return typeof raw.name === "string" && raw.name.length > 0 ? raw.name : void 0;
|
|
45
|
-
} catch {
|
|
46
|
-
return void 0;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export {
|
|
50
|
-
FABRIC_BOOTSTRAP_PATH,
|
|
51
|
-
buildBootstrapContent
|
|
52
|
-
};
|