@fenglimg/fabric-cli 1.2.0 → 1.3.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-MDI7523D.js → chunk-TO5RUB4R.js} +4 -0
- package/dist/{config-3JBB77TX.js → config-MKWKDE32.js} +2 -1
- package/dist/index.js +6 -17
- package/dist/{init-3FPLOABB.js → init-BZ73IUHH.js} +6 -6
- package/dist/pre-commit-AK55G73F.js +97 -0
- package/dist/update-JZPUJ36D.js +116 -0
- package/package.json +4 -3
- package/dist/pre-commit-CJ7EDKJK.js +0 -59
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
resolveClients
|
|
4
4
|
} from "./chunk-VMYPJPKV.js";
|
|
5
|
+
import {
|
|
6
|
+
hooksCommand
|
|
7
|
+
} from "./chunk-YDZJRLHL.js";
|
|
5
8
|
import {
|
|
6
9
|
t
|
|
7
10
|
} from "./chunk-6ICJICVU.js";
|
|
@@ -73,6 +76,7 @@ var configCmd = defineCommand({
|
|
|
73
76
|
description: t("cli.config.description")
|
|
74
77
|
},
|
|
75
78
|
subCommands: {
|
|
79
|
+
hooks: hooksCommand,
|
|
76
80
|
install: defineCommand({
|
|
77
81
|
meta: {
|
|
78
82
|
name: "install",
|
package/dist/index.js
CHANGED
|
@@ -8,28 +8,17 @@ import { defineCommand, runMain } from "citty";
|
|
|
8
8
|
|
|
9
9
|
// src/commands/index.ts
|
|
10
10
|
var allCommands = {
|
|
11
|
-
init: () => import("./init-
|
|
11
|
+
init: () => import("./init-BZ73IUHH.js").then((module) => module.default),
|
|
12
|
+
update: () => import("./update-JZPUJ36D.js").then((module) => module.default),
|
|
12
13
|
scan: () => import("./scan-WKDSKEBB.js").then((module) => module.default),
|
|
13
14
|
serve: () => import("./serve-MMN4GYLM.js").then((module) => module.default),
|
|
14
15
|
doctor: () => import("./doctor-5KJGOV2P.js").then((module) => module.default),
|
|
15
16
|
"sync-meta": () => import("./sync-meta-THZSEM7Y.js").then((module) => module.default),
|
|
16
17
|
"human-lint": () => import("./human-lint-YSFOZHZ7.js").then((module) => module.default),
|
|
17
18
|
"ledger-append": () => import("./ledger-append-XZ5SX4O5.js").then((module) => module.default),
|
|
18
|
-
"pre-commit": () => import("./pre-commit-
|
|
19
|
-
bootstrap: () => import("./bootstrap-IUL4SAAK.js").then((module) =>
|
|
20
|
-
|
|
21
|
-
meta: {
|
|
22
|
-
...module.default.meta,
|
|
23
|
-
hidden: true
|
|
24
|
-
}
|
|
25
|
-
})),
|
|
26
|
-
config: () => import("./config-3JBB77TX.js").then((module) => ({
|
|
27
|
-
...module.configCmd,
|
|
28
|
-
meta: {
|
|
29
|
-
...module.configCmd.meta,
|
|
30
|
-
hidden: true
|
|
31
|
-
}
|
|
32
|
-
})),
|
|
19
|
+
"pre-commit": () => import("./pre-commit-AK55G73F.js").then((module) => module.default),
|
|
20
|
+
bootstrap: () => import("./bootstrap-IUL4SAAK.js").then((module) => module.default),
|
|
21
|
+
config: () => import("./config-MKWKDE32.js").then((module) => module.configCmd),
|
|
33
22
|
hooks: () => import("./hooks-ZSWVH2JD.js").then((module) => ({
|
|
34
23
|
...module.default,
|
|
35
24
|
meta: {
|
|
@@ -43,7 +32,7 @@ var allCommands = {
|
|
|
43
32
|
var main = defineCommand({
|
|
44
33
|
meta: {
|
|
45
34
|
name: "fabric",
|
|
46
|
-
version: "1.
|
|
35
|
+
version: "1.3.0",
|
|
47
36
|
description: 'Initialize and manage Fabric projects. Use "fabric init" for one-shot setup.'
|
|
48
37
|
},
|
|
49
38
|
subCommands: allCommands
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
installBootstrap
|
|
4
4
|
} from "./chunk-RUQCZA2Q.js";
|
|
5
|
+
import {
|
|
6
|
+
createScanReport,
|
|
7
|
+
detectFramework
|
|
8
|
+
} from "./chunk-N4DCTOXW.js";
|
|
5
9
|
import {
|
|
6
10
|
installMcpClients
|
|
7
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TO5RUB4R.js";
|
|
8
12
|
import "./chunk-VMYPJPKV.js";
|
|
9
13
|
import {
|
|
10
14
|
installHooks
|
|
11
15
|
} from "./chunk-YDZJRLHL.js";
|
|
12
|
-
import {
|
|
13
|
-
createScanReport,
|
|
14
|
-
detectFramework
|
|
15
|
-
} from "./chunk-N4DCTOXW.js";
|
|
16
16
|
import {
|
|
17
17
|
paint
|
|
18
18
|
} from "./chunk-WWNXR34K.js";
|
|
@@ -852,7 +852,7 @@ function readProjectName(target) {
|
|
|
852
852
|
return basename(target);
|
|
853
853
|
}
|
|
854
854
|
function getCliVersion() {
|
|
855
|
-
return true ? "1.
|
|
855
|
+
return true ? "1.3.0" : "unknown";
|
|
856
856
|
}
|
|
857
857
|
function sortRecord(record) {
|
|
858
858
|
return Object.fromEntries(Object.entries(record).sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
sync_meta_default
|
|
4
|
+
} from "./chunk-6UUPKSDE.js";
|
|
5
|
+
import {
|
|
6
|
+
human_lint_default
|
|
7
|
+
} from "./chunk-L43IGJ6X.js";
|
|
8
|
+
import {
|
|
9
|
+
ledger_append_default
|
|
10
|
+
} from "./chunk-F2BXHPM5.js";
|
|
11
|
+
import "./chunk-WWNXR34K.js";
|
|
12
|
+
import {
|
|
13
|
+
resolveDevModeTarget
|
|
14
|
+
} from "./chunk-AEOYCVBG.js";
|
|
15
|
+
import {
|
|
16
|
+
t
|
|
17
|
+
} from "./chunk-6ICJICVU.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/pre-commit.ts
|
|
20
|
+
import { execSync } from "child_process";
|
|
21
|
+
import { readFileSync } from "fs";
|
|
22
|
+
import { join } from "path";
|
|
23
|
+
import process from "process";
|
|
24
|
+
import { agentsMetaSchema } from "@fenglimg/fabric-shared";
|
|
25
|
+
import { defineCommand } from "citty";
|
|
26
|
+
import { minimatch } from "minimatch";
|
|
27
|
+
async function runOrFail(name, cmd, args) {
|
|
28
|
+
try {
|
|
29
|
+
await cmd.run?.({ args });
|
|
30
|
+
} catch (err) {
|
|
31
|
+
process.stderr.write(
|
|
32
|
+
`${t("cli.pre-commit.run-failed", { name, message: err.message })}
|
|
33
|
+
`
|
|
34
|
+
);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getStagedFiles(target) {
|
|
39
|
+
try {
|
|
40
|
+
const output = execSync("git diff --cached --name-only --no-renames", {
|
|
41
|
+
cwd: target,
|
|
42
|
+
encoding: "utf8",
|
|
43
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
44
|
+
});
|
|
45
|
+
return output.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
46
|
+
} catch {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function tryReadAgentsMeta(target) {
|
|
51
|
+
const metaPath = join(target, ".fabric", "agents.meta.json");
|
|
52
|
+
try {
|
|
53
|
+
const raw = readFileSync(metaPath, "utf8");
|
|
54
|
+
return agentsMetaSchema.parse(JSON.parse(raw));
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function matchesFabricScope(stagedFiles, meta) {
|
|
60
|
+
const scopeGlobs = Object.values(meta.nodes).filter((node) => node.file !== "AGENTS.md").map((node) => node.scope_glob);
|
|
61
|
+
return stagedFiles.some(
|
|
62
|
+
(file) => file === "AGENTS.md" || file === ".fabric/agents.meta.json" || file === ".fabric/human-lock.json" || file === ".intent-ledger.jsonl" || scopeGlobs.some((pattern) => minimatch(file, pattern, { dot: true }))
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
var pre_commit_default = defineCommand({
|
|
66
|
+
meta: {
|
|
67
|
+
name: "pre-commit",
|
|
68
|
+
description: t("cli.pre-commit.description")
|
|
69
|
+
},
|
|
70
|
+
args: {
|
|
71
|
+
target: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: t("cli.pre-commit.args.target.description")
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
async run({ args }) {
|
|
77
|
+
const target = resolveDevModeTarget(args.target);
|
|
78
|
+
const stagedFiles = getStagedFiles(target);
|
|
79
|
+
const meta = tryReadAgentsMeta(target);
|
|
80
|
+
if (stagedFiles.length > 0 && meta !== null && !matchesFabricScope(stagedFiles, meta)) {
|
|
81
|
+
process.stderr.write("No fabric-managed files staged, skipping checks\n");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await runOrFail("sync-meta --check-only", sync_meta_default, {
|
|
85
|
+
target,
|
|
86
|
+
"check-only": true
|
|
87
|
+
});
|
|
88
|
+
await runOrFail("human-lint", human_lint_default, { target });
|
|
89
|
+
await runOrFail("ledger-append --staged", ledger_append_default, {
|
|
90
|
+
target,
|
|
91
|
+
staged: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
export {
|
|
96
|
+
pre_commit_default as default
|
|
97
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
installMcpClients
|
|
4
|
+
} from "./chunk-TO5RUB4R.js";
|
|
5
|
+
import "./chunk-VMYPJPKV.js";
|
|
6
|
+
import {
|
|
7
|
+
installHooks
|
|
8
|
+
} from "./chunk-YDZJRLHL.js";
|
|
9
|
+
import {
|
|
10
|
+
paint
|
|
11
|
+
} from "./chunk-WWNXR34K.js";
|
|
12
|
+
import {
|
|
13
|
+
resolveDevModeTarget
|
|
14
|
+
} from "./chunk-AEOYCVBG.js";
|
|
15
|
+
import {
|
|
16
|
+
t
|
|
17
|
+
} from "./chunk-6ICJICVU.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/update.ts
|
|
20
|
+
import { defineCommand } from "citty";
|
|
21
|
+
function writeStderr(message) {
|
|
22
|
+
process.stderr.write(`${message}
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
function completedLabel() {
|
|
26
|
+
return paint.success(t("cli.init.stages.completed"));
|
|
27
|
+
}
|
|
28
|
+
function skippedLabel() {
|
|
29
|
+
return paint.muted(t("cli.init.stages.skipped"));
|
|
30
|
+
}
|
|
31
|
+
function failedLabel() {
|
|
32
|
+
return paint.error(t("cli.init.stages.failed"));
|
|
33
|
+
}
|
|
34
|
+
function formatStageResult(stage, status, installedCount, skippedCount, note) {
|
|
35
|
+
const label = status === "completed" ? completedLabel() : skippedLabel();
|
|
36
|
+
const counts = `installed=${installedCount} skipped=${skippedCount}`;
|
|
37
|
+
const suffix = note ? ` ${paint.muted(`(${note})`)}` : "";
|
|
38
|
+
return `${label} ${stage}: ${counts}${suffix}`;
|
|
39
|
+
}
|
|
40
|
+
function formatStageFailure(stage, error) {
|
|
41
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
42
|
+
return `${failedLabel()} ${stage}: ${message}`;
|
|
43
|
+
}
|
|
44
|
+
function printStageSummary(stageResults) {
|
|
45
|
+
const ran = stageResults.filter((s) => s.disposition === "ran").map((s) => s.name);
|
|
46
|
+
const skipped = stageResults.filter((s) => s.disposition === "skipped").map((s) => s.name);
|
|
47
|
+
const failed = stageResults.filter((s) => s.disposition === "failed").map((s) => s.name);
|
|
48
|
+
console.log(`${paint.success(t("cli.init.stages.summary.ran"))}: ${ran.length > 0 ? ran.join(", ") : t("cli.shared.none")}`);
|
|
49
|
+
console.log(`${paint.muted(t("cli.init.stages.summary.skipped"))}: ${skipped.length > 0 ? skipped.join(", ") : t("cli.shared.none")}`);
|
|
50
|
+
console.log(`${paint.error(t("cli.init.stages.summary.failed"))}: ${failed.length > 0 ? failed.join(", ") : t("cli.shared.none")}`);
|
|
51
|
+
}
|
|
52
|
+
var updateCommand = defineCommand({
|
|
53
|
+
meta: {
|
|
54
|
+
name: "update",
|
|
55
|
+
description: t("cli.update.description")
|
|
56
|
+
},
|
|
57
|
+
args: {
|
|
58
|
+
target: {
|
|
59
|
+
type: "string",
|
|
60
|
+
description: t("cli.update.args.target.description")
|
|
61
|
+
},
|
|
62
|
+
mcp: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
default: true,
|
|
65
|
+
negativeDescription: t("cli.update.args.no-mcp.description")
|
|
66
|
+
},
|
|
67
|
+
hooks: {
|
|
68
|
+
type: "boolean",
|
|
69
|
+
default: true,
|
|
70
|
+
negativeDescription: t("cli.update.args.no-hooks.description")
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
async run({ args }) {
|
|
74
|
+
const target = resolveDevModeTarget(args.target);
|
|
75
|
+
const skipMcp = args.mcp === false;
|
|
76
|
+
const skipHooks = args.hooks === false;
|
|
77
|
+
const stageResults = [];
|
|
78
|
+
if (skipMcp) {
|
|
79
|
+
stageResults.push({ name: "mcp", disposition: "skipped" });
|
|
80
|
+
} else {
|
|
81
|
+
console.log(`${paint.ai(t("cli.shared.next"))} ${paint.muted(t("cli.init.stages.mcp"))}`);
|
|
82
|
+
try {
|
|
83
|
+
const result = await installMcpClients(target);
|
|
84
|
+
if (result.details.length === 0) {
|
|
85
|
+
console.log(formatStageResult("mcp", "skipped", 0, 0, t("cli.config.install.no-configs")));
|
|
86
|
+
stageResults.push({ name: "mcp", disposition: "skipped" });
|
|
87
|
+
} else {
|
|
88
|
+
console.log(formatStageResult("mcp", "completed", result.installed.length, result.skipped.length));
|
|
89
|
+
stageResults.push({ name: "mcp", disposition: "ran" });
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
writeStderr(formatStageFailure("mcp", error));
|
|
93
|
+
stageResults.push({ name: "mcp", disposition: "failed" });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (skipHooks) {
|
|
97
|
+
stageResults.push({ name: "hooks", disposition: "skipped" });
|
|
98
|
+
} else {
|
|
99
|
+
console.log(`${paint.ai(t("cli.shared.next"))} ${paint.muted(t("cli.init.stages.hooks"))}`);
|
|
100
|
+
try {
|
|
101
|
+
const result = await installHooks(target);
|
|
102
|
+
console.log(formatStageResult("hooks", "completed", result.installed.length, result.skipped.length));
|
|
103
|
+
stageResults.push({ name: "hooks", disposition: "ran" });
|
|
104
|
+
} catch (error) {
|
|
105
|
+
writeStderr(formatStageFailure("hooks", error));
|
|
106
|
+
stageResults.push({ name: "hooks", disposition: "failed" });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
printStageSummary(stageResults);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
var update_default = updateCommand;
|
|
113
|
+
export {
|
|
114
|
+
update_default as default,
|
|
115
|
+
updateCommand
|
|
116
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fab": "dist/index.js",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@iarna/toml": "^2.2.5",
|
|
17
17
|
"citty": "^0.2.2",
|
|
18
|
+
"minimatch": "^10.0.1",
|
|
18
19
|
"picocolors": "^1.1.1",
|
|
19
20
|
"string-width": "^7.2.0",
|
|
20
|
-
"@fenglimg/fabric-
|
|
21
|
-
"@fenglimg/fabric-
|
|
21
|
+
"@fenglimg/fabric-server": "1.3.0",
|
|
22
|
+
"@fenglimg/fabric-shared": "1.3.0"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/iarna__toml": "^2.0.5",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
sync_meta_default
|
|
4
|
-
} from "./chunk-6UUPKSDE.js";
|
|
5
|
-
import {
|
|
6
|
-
human_lint_default
|
|
7
|
-
} from "./chunk-L43IGJ6X.js";
|
|
8
|
-
import {
|
|
9
|
-
ledger_append_default
|
|
10
|
-
} from "./chunk-F2BXHPM5.js";
|
|
11
|
-
import "./chunk-WWNXR34K.js";
|
|
12
|
-
import {
|
|
13
|
-
resolveDevModeTarget
|
|
14
|
-
} from "./chunk-AEOYCVBG.js";
|
|
15
|
-
import {
|
|
16
|
-
t
|
|
17
|
-
} from "./chunk-6ICJICVU.js";
|
|
18
|
-
|
|
19
|
-
// src/commands/pre-commit.ts
|
|
20
|
-
import { defineCommand } from "citty";
|
|
21
|
-
import process from "process";
|
|
22
|
-
async function runOrFail(name, cmd, args) {
|
|
23
|
-
try {
|
|
24
|
-
await cmd.run?.({ args });
|
|
25
|
-
} catch (err) {
|
|
26
|
-
process.stderr.write(
|
|
27
|
-
`${t("cli.pre-commit.run-failed", { name, message: err.message })}
|
|
28
|
-
`
|
|
29
|
-
);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
var pre_commit_default = defineCommand({
|
|
34
|
-
meta: {
|
|
35
|
-
name: "pre-commit",
|
|
36
|
-
description: t("cli.pre-commit.description")
|
|
37
|
-
},
|
|
38
|
-
args: {
|
|
39
|
-
target: {
|
|
40
|
-
type: "string",
|
|
41
|
-
description: t("cli.pre-commit.args.target.description")
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
async run({ args }) {
|
|
45
|
-
const target = resolveDevModeTarget(args.target);
|
|
46
|
-
await runOrFail("sync-meta --check-only", sync_meta_default, {
|
|
47
|
-
target,
|
|
48
|
-
"check-only": true
|
|
49
|
-
});
|
|
50
|
-
await runOrFail("human-lint", human_lint_default, { target });
|
|
51
|
-
await runOrFail("ledger-append --staged", ledger_append_default, {
|
|
52
|
-
target,
|
|
53
|
-
staged: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
export {
|
|
58
|
-
pre_commit_default as default
|
|
59
|
-
};
|