@fenglimg/fabric-cli 1.5.1 → 1.5.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/dist/{chunk-N7EZORJZ.js → chunk-2YW5CJ32.js} +17 -8
- package/dist/{chunk-Q4LOVXML.js → chunk-KOAEIH72.js} +40 -5
- package/dist/{doctor-QTSG2RWF.js → doctor-4BPYHV7V.js} +11 -2
- package/dist/index.js +6 -6
- package/dist/{init-QPKI2QOW.js → init-FDTUWEZX.js} +1 -1
- package/dist/{ledger-append-DULKJ6Q2.js → ledger-append-3MDNR3GU.js} +1 -1
- package/dist/{pre-commit-IK6SJOPT.js → pre-commit-53ENJDRZ.js} +4 -3
- package/dist/{sync-meta-LKVSO6TS.js → sync-meta-IZR2WLIL.js} +1 -1
- package/package.json +3 -3
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/commands/ledger-append.ts
|
|
7
7
|
import { execSync } from "child_process";
|
|
8
|
-
import { appendFileSync, existsSync, readFileSync, statSync } from "fs";
|
|
9
|
-
import { basename, isAbsolute,
|
|
8
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync } from "fs";
|
|
9
|
+
import { basename, isAbsolute, resolve } from "path";
|
|
10
|
+
import { getLedgerPath, getLegacyLedgerPath, LEGACY_LEDGER_PATH, LEDGER_PATH } from "@fenglimg/fabric-server";
|
|
10
11
|
import { defineCommand } from "citty";
|
|
11
|
-
var LEDGER_FILE = ".intent-ledger.jsonl";
|
|
12
12
|
var INITIAL_PARENT_SHA = "root";
|
|
13
13
|
var ledgerAppendCommand = defineCommand({
|
|
14
14
|
meta: {
|
|
@@ -35,7 +35,7 @@ var ledgerAppendCommand = defineCommand({
|
|
|
35
35
|
process.exitCode = 1;
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
const stagedFiles = getStagedFiles(target).filter((file) => file !==
|
|
38
|
+
const stagedFiles = getStagedFiles(target).filter((file) => file !== LEGACY_LEDGER_PATH && file !== LEDGER_PATH);
|
|
39
39
|
if (stagedFiles.length === 0) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -52,9 +52,11 @@ var ledgerAppendCommand = defineCommand({
|
|
|
52
52
|
if (hasMatchingTailEntry(target, entry)) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
const ledgerPath = getLedgerPath(target);
|
|
56
|
+
mkdirSync(resolve(target, ".fabric"), { recursive: true });
|
|
57
|
+
appendFileSync(ledgerPath, `${JSON.stringify(entry)}
|
|
56
58
|
`, "utf8");
|
|
57
|
-
execGit(target, `git add ${
|
|
59
|
+
execGit(target, `git add ${LEDGER_PATH}`);
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
62
|
var ledger_append_default = ledgerAppendCommand;
|
|
@@ -91,7 +93,7 @@ function deriveIntent(stagedFiles) {
|
|
|
91
93
|
return t("cli.ledger-append.intent.auto", { head, suffix });
|
|
92
94
|
}
|
|
93
95
|
function hasMatchingTailEntry(target, entry) {
|
|
94
|
-
const ledgerPath =
|
|
96
|
+
const ledgerPath = resolveTailLedgerPath(target);
|
|
95
97
|
if (!existsSync(ledgerPath)) {
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
@@ -106,6 +108,13 @@ function hasMatchingTailEntry(target, entry) {
|
|
|
106
108
|
return false;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
111
|
+
function resolveTailLedgerPath(target) {
|
|
112
|
+
const canonicalPath = getLedgerPath(target);
|
|
113
|
+
if (existsSync(canonicalPath)) {
|
|
114
|
+
return canonicalPath;
|
|
115
|
+
}
|
|
116
|
+
return getLegacyLedgerPath(target);
|
|
117
|
+
}
|
|
109
118
|
function isLedgerEntryLine(line) {
|
|
110
119
|
try {
|
|
111
120
|
const parsed = JSON.parse(line);
|
|
@@ -118,7 +127,7 @@ function normalizeDiffStat(diffStat) {
|
|
|
118
127
|
if (typeof diffStat !== "string") {
|
|
119
128
|
return "";
|
|
120
129
|
}
|
|
121
|
-
return diffStat.split(/\r?\n/).map((line) => line.trim()).map((line) => line.replace(/\s+\|\s+/g, " | ")).map((line) => line.replace(/\s+/g, " ")).filter((line) => line.length > 0).filter((line) => !line.includes(
|
|
130
|
+
return diffStat.split(/\r?\n/).map((line) => line.trim()).map((line) => line.replace(/\s+\|\s+/g, " | ")).map((line) => line.replace(/\s+/g, " ")).filter((line) => line.length > 0).filter((line) => !line.includes(LEGACY_LEDGER_PATH)).filter((line) => !line.includes(LEDGER_PATH)).filter((line) => !/\d+ files? changed(?:, \d+ insertions?\(\+\))?(?:, \d+ deletions?\(-\))?$/.test(line.trim())).join("\n");
|
|
122
131
|
}
|
|
123
132
|
function execGit(target, command) {
|
|
124
133
|
return execSync(command, {
|
|
@@ -10,6 +10,7 @@ import { isAbsolute, join, relative, resolve, sep } from "path";
|
|
|
10
10
|
import {
|
|
11
11
|
agentsMetaSchema,
|
|
12
12
|
deriveAgentsMetaLayer,
|
|
13
|
+
deriveAgentsMetaStableId,
|
|
13
14
|
deriveAgentsMetaTopologyType
|
|
14
15
|
} from "@fenglimg/fabric-shared";
|
|
15
16
|
import { defineCommand } from "citty";
|
|
@@ -68,14 +69,18 @@ function computeAgentsMeta(target) {
|
|
|
68
69
|
}
|
|
69
70
|
for (const file of agentsFiles) {
|
|
70
71
|
const existing = existingByFile.get(file);
|
|
72
|
+
const source = readFileSync(join(target, file), "utf8");
|
|
71
73
|
const id = deriveNodeId(file);
|
|
72
|
-
const hash = sha256(
|
|
74
|
+
const hash = sha256(source);
|
|
73
75
|
const defaults = createDefaultNodeMeta(file);
|
|
76
|
+
const identity = deriveRuleIdentity(file, source, existing?.node);
|
|
74
77
|
nodes[id] = {
|
|
75
78
|
...defaults,
|
|
76
79
|
...existing?.node,
|
|
77
80
|
file,
|
|
78
|
-
hash
|
|
81
|
+
hash,
|
|
82
|
+
stable_id: identity.stableId,
|
|
83
|
+
identity_source: identity.identitySource
|
|
79
84
|
};
|
|
80
85
|
}
|
|
81
86
|
return {
|
|
@@ -168,11 +173,17 @@ function createBootstrapNode(target, existing) {
|
|
|
168
173
|
return void 0;
|
|
169
174
|
}
|
|
170
175
|
const hash = sha256(readFileSync(sourcePath, "utf8"));
|
|
176
|
+
const identity = {
|
|
177
|
+
stableId: existing?.stable_id ?? deriveAgentsMetaStableId(".fabric/bootstrap/README.md"),
|
|
178
|
+
identitySource: existing?.identity_source ?? "derived"
|
|
179
|
+
};
|
|
171
180
|
return {
|
|
172
181
|
...createDefaultNodeMeta(".fabric/bootstrap/README.md"),
|
|
173
182
|
...existing,
|
|
174
183
|
file: ".fabric/bootstrap/README.md",
|
|
175
|
-
hash
|
|
184
|
+
hash,
|
|
185
|
+
stable_id: identity.stableId,
|
|
186
|
+
identity_source: identity.identitySource
|
|
176
187
|
};
|
|
177
188
|
}
|
|
178
189
|
function deriveScopeGlob(file) {
|
|
@@ -200,8 +211,8 @@ function sortNodes(nodes) {
|
|
|
200
211
|
return Object.fromEntries(Object.entries(nodes).sort(([left], [right]) => left.localeCompare(right)));
|
|
201
212
|
}
|
|
202
213
|
function computeRevision(nodes) {
|
|
203
|
-
const
|
|
204
|
-
return sha256(
|
|
214
|
+
const revisionSource = Object.entries(sortNodes(nodes)).map(([id, node]) => [id, node.hash, node.stable_id ?? "", node.identity_source ?? ""].join("|")).join("\n");
|
|
215
|
+
return sha256(revisionSource);
|
|
205
216
|
}
|
|
206
217
|
function writeStderr(message) {
|
|
207
218
|
process.stderr.write(`${message}
|
|
@@ -225,6 +236,30 @@ function toPosixPath(path) {
|
|
|
225
236
|
function sha256(content) {
|
|
226
237
|
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
227
238
|
}
|
|
239
|
+
function deriveRuleIdentity(file, source, existing) {
|
|
240
|
+
const declaredStableId = extractDeclaredStableId(source);
|
|
241
|
+
const derivedStableId = deriveAgentsMetaStableId(file);
|
|
242
|
+
if (declaredStableId !== void 0) {
|
|
243
|
+
return {
|
|
244
|
+
stableId: declaredStableId,
|
|
245
|
+
identitySource: "declared"
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (existing?.identity_source === "declared" && existing.stable_id !== void 0 && existing.stable_id !== derivedStableId) {
|
|
249
|
+
return {
|
|
250
|
+
stableId: existing.stable_id,
|
|
251
|
+
identitySource: "declared"
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
stableId: derivedStableId,
|
|
256
|
+
identitySource: "derived"
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function extractDeclaredStableId(source) {
|
|
260
|
+
const match = /^(?:\uFEFF)?<!--\s*fab:rule-id\s+([A-Za-z0-9][A-Za-z0-9/_-]*)\s*-->\s*(?:\r?\n|$)/u.exec(source);
|
|
261
|
+
return match?.[1];
|
|
262
|
+
}
|
|
228
263
|
|
|
229
264
|
export {
|
|
230
265
|
syncMetaCommand,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
// src/commands/doctor.ts
|
|
15
15
|
import { defineCommand } from "citty";
|
|
16
|
-
import { runDoctorAuditReport, runDoctorReport } from "@fenglimg/fabric-server";
|
|
16
|
+
import { runDoctorAuditReport, runDoctorFix, runDoctorReport } from "@fenglimg/fabric-server";
|
|
17
17
|
var DEFAULT_AUDIT_WINDOW_MINUTES = 5;
|
|
18
18
|
var doctorCommand = defineCommand({
|
|
19
19
|
meta: {
|
|
@@ -30,6 +30,11 @@ var doctorCommand = defineCommand({
|
|
|
30
30
|
description: t("cli.doctor.args.audit.description"),
|
|
31
31
|
default: false
|
|
32
32
|
},
|
|
33
|
+
fix: {
|
|
34
|
+
type: "boolean",
|
|
35
|
+
description: t("cli.doctor.args.fix.description"),
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
33
38
|
"window-minutes": {
|
|
34
39
|
type: "string",
|
|
35
40
|
description: t("cli.doctor.args.window-minutes.description"),
|
|
@@ -39,7 +44,11 @@ var doctorCommand = defineCommand({
|
|
|
39
44
|
async run({ args }) {
|
|
40
45
|
const workspaceRoot = process.cwd();
|
|
41
46
|
const resolution = resolveDevMode(args.target, workspaceRoot);
|
|
42
|
-
const
|
|
47
|
+
const fixReport = args.fix ? await runDoctorFix(resolution.target) : null;
|
|
48
|
+
const report = fixReport?.report ?? await runDoctorReport(resolution.target);
|
|
49
|
+
if (fixReport !== null) {
|
|
50
|
+
writeStdout(fixReport.message);
|
|
51
|
+
}
|
|
43
52
|
writeStdout(`${renderStatus(report.status)} ${paint.ai("fab doctor")} ${paint.human(resolution.target)}`);
|
|
44
53
|
for (const check of report.checks) {
|
|
45
54
|
writeStdout(`${renderStatus(check.status)} ${check.name}: ${check.message}`);
|
package/dist/index.js
CHANGED
|
@@ -9,15 +9,15 @@ import { defineCommand, runMain } from "citty";
|
|
|
9
9
|
// src/commands/index.ts
|
|
10
10
|
var allCommands = {
|
|
11
11
|
approve: () => import("./approve-YT4DEABS.js").then((module) => module.default),
|
|
12
|
-
init: () => import("./init-
|
|
12
|
+
init: () => import("./init-FDTUWEZX.js").then((module) => module.default),
|
|
13
13
|
update: () => import("./update-M5M5PYKE.js").then((module) => module.default),
|
|
14
14
|
scan: () => import("./scan-QH76LC7Z.js").then((module) => module.default),
|
|
15
15
|
serve: () => import("./serve-4J2CQY25.js").then((module) => module.default),
|
|
16
|
-
doctor: () => import("./doctor-
|
|
17
|
-
"sync-meta": () => import("./sync-meta-
|
|
16
|
+
doctor: () => import("./doctor-4BPYHV7V.js").then((module) => module.default),
|
|
17
|
+
"sync-meta": () => import("./sync-meta-IZR2WLIL.js").then((module) => module.default),
|
|
18
18
|
"human-lint": () => import("./human-lint-YSFOZHZ7.js").then((module) => module.default),
|
|
19
|
-
"ledger-append": () => import("./ledger-append-
|
|
20
|
-
"pre-commit": () => import("./pre-commit-
|
|
19
|
+
"ledger-append": () => import("./ledger-append-3MDNR3GU.js").then((module) => module.default),
|
|
20
|
+
"pre-commit": () => import("./pre-commit-53ENJDRZ.js").then((module) => module.default),
|
|
21
21
|
bootstrap: () => import("./bootstrap-VGL3AR26.js").then((module) => module.default),
|
|
22
22
|
config: () => import("./config-EC5L2QNI.js").then((module) => module.configCmd),
|
|
23
23
|
hooks: () => import("./hooks-ZSWVH2JD.js").then((module) => ({
|
|
@@ -33,7 +33,7 @@ var allCommands = {
|
|
|
33
33
|
var main = defineCommand({
|
|
34
34
|
meta: {
|
|
35
35
|
name: "fabric",
|
|
36
|
-
version: "1.5.
|
|
36
|
+
version: "1.5.2",
|
|
37
37
|
description: 'Initialize and manage Fabric projects. Use "fabric init" for one-shot setup.'
|
|
38
38
|
},
|
|
39
39
|
subCommands: allCommands
|
|
@@ -1147,7 +1147,7 @@ function readProjectName(target) {
|
|
|
1147
1147
|
return basename(target);
|
|
1148
1148
|
}
|
|
1149
1149
|
function getCliVersion() {
|
|
1150
|
-
return true ? "1.5.
|
|
1150
|
+
return true ? "1.5.2" : "unknown";
|
|
1151
1151
|
}
|
|
1152
1152
|
function sortRecord(record) {
|
|
1153
1153
|
return Object.fromEntries(Object.entries(record).sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
sync_meta_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KOAEIH72.js";
|
|
5
5
|
import {
|
|
6
6
|
human_lint_default
|
|
7
7
|
} from "./chunk-L43IGJ6X.js";
|
|
8
8
|
import {
|
|
9
9
|
ledger_append_default
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2YW5CJ32.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveDevModeTarget
|
|
13
13
|
} from "./chunk-AEOYCVBG.js";
|
|
@@ -24,6 +24,7 @@ import process from "process";
|
|
|
24
24
|
import { agentsMetaSchema } from "@fenglimg/fabric-shared";
|
|
25
25
|
import { defineCommand } from "citty";
|
|
26
26
|
import { minimatch } from "minimatch";
|
|
27
|
+
import { LEGACY_LEDGER_PATH, LEDGER_PATH } from "@fenglimg/fabric-server";
|
|
27
28
|
async function runOrFail(name, cmd, args) {
|
|
28
29
|
try {
|
|
29
30
|
await cmd.run?.({ args });
|
|
@@ -59,7 +60,7 @@ function tryReadAgentsMeta(target) {
|
|
|
59
60
|
function matchesFabricScope(stagedFiles, meta) {
|
|
60
61
|
const scopeGlobs = Object.values(meta.nodes).filter((node) => node.file !== ".fabric/bootstrap/README.md" && node.file !== "AGENTS.md").map((node) => node.scope_glob);
|
|
61
62
|
return stagedFiles.some(
|
|
62
|
-
(file) => file === ".fabric/bootstrap/README.md" || file === "AGENTS.md" || file === ".fabric/agents.meta.json" || file === ".fabric/human-lock.json" || file ===
|
|
63
|
+
(file) => file === ".fabric/bootstrap/README.md" || file === "AGENTS.md" || file === ".fabric/agents.meta.json" || file === ".fabric/human-lock.json" || file === LEDGER_PATH || file === LEGACY_LEDGER_PATH || scopeGlobs.some((pattern) => minimatch(file, pattern, { dot: true }))
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
66
|
var pre_commit_default = defineCommand({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fab": "dist/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"tree-sitter-javascript": "^0.25.0",
|
|
23
23
|
"tree-sitter-typescript": "^0.23.2",
|
|
24
24
|
"web-tree-sitter": "^0.26.8",
|
|
25
|
-
"@fenglimg/fabric-server": "1.5.
|
|
26
|
-
"@fenglimg/fabric-shared": "1.5.
|
|
25
|
+
"@fenglimg/fabric-server": "1.5.2",
|
|
26
|
+
"@fenglimg/fabric-shared": "1.5.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/iarna__toml": "^2.0.5",
|