@fenglimg/fabric-cli 2.0.0-rc.13 → 2.0.0-rc.15
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 +4 -2
- package/dist/chunk-AIB54QRT.js +82 -0
- package/dist/{chunk-FDRLV5PL.js → chunk-AXIFEVAS.js} +5 -213
- package/dist/{chunk-WWNXR34K.js → chunk-G2CIOLD4.js} +16 -1
- package/dist/{chunk-OHWQNSLH.js → chunk-SKSYUHKK.js} +267 -40
- package/dist/{chunk-X7QPY5KH.js → chunk-UTF4YBDN.js} +34 -271
- package/dist/config-7YD365I3.js +13 -0
- package/dist/{doctor-RILCO5OG.js → doctor-6XHLQJXB.js} +67 -50
- package/dist/index.js +7 -8
- package/dist/{install-SLS5W27W.js → install-JLDCHAXV.js} +328 -341
- package/dist/{plan-context-hint-QMUPAXIB.js → plan-context-hint-73U4FGKO.js} +6 -1
- package/dist/{serve-NGLXHDYC.js → serve-L3X5UHG2.js} +15 -10
- package/dist/{uninstall-JHUSFENL.js → uninstall-DD6FIFCI.js} +56 -163
- package/package.json +3 -3
- package/templates/hooks/configs/README.md +9 -5
- package/templates/hooks/configs/cursor-hooks.json +7 -10
- package/dist/chunk-Q72D24BG.js +0 -186
- package/dist/hooks-HIWYI3VG.js +0 -13
- package/dist/scan-VHKZPT2W.js +0 -24
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
runInitScan
|
|
4
|
+
} from "./chunk-AXIFEVAS.js";
|
|
5
|
+
import {
|
|
6
|
+
hasActionHint,
|
|
3
7
|
paint,
|
|
8
|
+
renderFabricError,
|
|
4
9
|
symbol
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
resolveDevMode
|
|
8
|
-
} from "./chunk-OBQU6NHO.js";
|
|
10
|
+
} from "./chunk-G2CIOLD4.js";
|
|
9
11
|
import {
|
|
10
12
|
t
|
|
11
13
|
} from "./chunk-6ICJICVU.js";
|
|
14
|
+
import {
|
|
15
|
+
resolveDevMode
|
|
16
|
+
} from "./chunk-OBQU6NHO.js";
|
|
12
17
|
|
|
13
18
|
// src/commands/doctor.ts
|
|
14
19
|
import { confirm, isCancel } from "@clack/prompts";
|
|
@@ -16,11 +21,11 @@ import { defineCommand } from "citty";
|
|
|
16
21
|
import {
|
|
17
22
|
appendEventLedgerEvent,
|
|
18
23
|
checkLockOrThrow,
|
|
19
|
-
runDoctorApplyLint,
|
|
24
|
+
runDoctorApplyLint as runDoctorFixKnowledge,
|
|
20
25
|
runDoctorFix,
|
|
21
26
|
runDoctorReport
|
|
22
27
|
} from "@fenglimg/fabric-server";
|
|
23
|
-
var
|
|
28
|
+
var FIX_KNOWLEDGE_CODE_LABELS = {
|
|
24
29
|
knowledge_orphan_demote_required: "demote (maturity)",
|
|
25
30
|
knowledge_stale_archive_required: "archive (git mv)",
|
|
26
31
|
knowledge_pending_auto_archive: "archive (git mv, pending)",
|
|
@@ -43,28 +48,28 @@ var doctorCommand = defineCommand({
|
|
|
43
48
|
description: t("cli.doctor.args.fix.description"),
|
|
44
49
|
default: false
|
|
45
50
|
},
|
|
46
|
-
|
|
51
|
+
"fix-knowledge": {
|
|
47
52
|
type: "boolean",
|
|
48
|
-
description: t("cli.doctor.args.
|
|
53
|
+
description: t("cli.doctor.args.fix-knowledge.description"),
|
|
49
54
|
default: false
|
|
50
55
|
},
|
|
51
|
-
|
|
56
|
+
json: {
|
|
52
57
|
type: "boolean",
|
|
53
|
-
description: t("cli.doctor.args.
|
|
58
|
+
description: t("cli.doctor.args.json.description"),
|
|
54
59
|
default: false
|
|
55
60
|
},
|
|
56
|
-
|
|
61
|
+
rescan: {
|
|
57
62
|
type: "boolean",
|
|
58
|
-
description: t("cli.doctor.args.
|
|
63
|
+
description: t("cli.doctor.args.rescan.description"),
|
|
59
64
|
default: false
|
|
60
65
|
},
|
|
61
|
-
|
|
66
|
+
strict: {
|
|
62
67
|
type: "boolean",
|
|
63
|
-
description: t("cli.doctor.args.
|
|
68
|
+
description: t("cli.doctor.args.strict.description"),
|
|
64
69
|
default: false
|
|
65
70
|
},
|
|
66
71
|
// rc.7 T11: skip the safety confirm before mutations. Required for any
|
|
67
|
-
// non-tty invocation that wants to run --
|
|
72
|
+
// non-tty invocation that wants to run --fix-knowledge without setting
|
|
68
73
|
// FABRIC_NONINTERACTIVE=1 in the environment.
|
|
69
74
|
yes: {
|
|
70
75
|
type: "boolean",
|
|
@@ -75,26 +80,38 @@ var doctorCommand = defineCommand({
|
|
|
75
80
|
async run({ args }) {
|
|
76
81
|
const workspaceRoot = process.cwd();
|
|
77
82
|
const resolution = resolveDevMode(args.target, workspaceRoot);
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
try {
|
|
84
|
+
checkLockOrThrow(resolution.target);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
if (hasActionHint(err)) {
|
|
87
|
+
renderFabricError(err);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
const fixKnowledge = args["fix-knowledge"] === true;
|
|
80
93
|
const fix = args.fix === true;
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
const rescan = args.rescan === true;
|
|
95
|
+
if (fixKnowledge && fix) {
|
|
96
|
+
writeStderr(t("cli.doctor.errors.fix-knowledge-fix-mutually-exclusive"));
|
|
83
97
|
process.exitCode = 1;
|
|
84
98
|
return;
|
|
85
99
|
}
|
|
86
|
-
|
|
100
|
+
if (rescan) {
|
|
101
|
+
await runInitScan(resolution.target, { source: "doctor-rescan" });
|
|
102
|
+
}
|
|
103
|
+
let fixKnowledgeReport = null;
|
|
87
104
|
let fixReport = null;
|
|
88
105
|
let report;
|
|
89
|
-
if (
|
|
106
|
+
if (fixKnowledge) {
|
|
90
107
|
const preReport = await runDoctorReport(resolution.target);
|
|
91
|
-
const plan =
|
|
108
|
+
const plan = computeFixKnowledgePlan(preReport);
|
|
92
109
|
const yesFlag = args.yes === true;
|
|
93
110
|
const envBypass = process.env.FABRIC_NONINTERACTIVE === "1";
|
|
94
111
|
if (plan.totalCount === 0) {
|
|
95
112
|
} else {
|
|
96
|
-
|
|
97
|
-
const decision = await
|
|
113
|
+
renderFixKnowledgePlan(plan);
|
|
114
|
+
const decision = await resolveFixKnowledgeConsent({
|
|
98
115
|
yesFlag,
|
|
99
116
|
envBypass,
|
|
100
117
|
plan
|
|
@@ -104,8 +121,8 @@ var doctorCommand = defineCommand({
|
|
|
104
121
|
return;
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
|
-
|
|
108
|
-
report =
|
|
124
|
+
fixKnowledgeReport = await runDoctorFixKnowledge(resolution.target);
|
|
125
|
+
report = fixKnowledgeReport.report;
|
|
109
126
|
} else if (fix) {
|
|
110
127
|
fixReport = await runDoctorFix(resolution.target);
|
|
111
128
|
report = fixReport.report;
|
|
@@ -113,30 +130,30 @@ var doctorCommand = defineCommand({
|
|
|
113
130
|
report = await runDoctorReport(resolution.target);
|
|
114
131
|
}
|
|
115
132
|
if (args.json === true) {
|
|
116
|
-
writeStdout(JSON.stringify(
|
|
133
|
+
writeStdout(JSON.stringify(fixKnowledgeReport ?? fixReport ?? report, null, 2));
|
|
117
134
|
} else {
|
|
118
|
-
if (
|
|
119
|
-
writeStdout(
|
|
120
|
-
if (
|
|
121
|
-
writeStderr(
|
|
135
|
+
if (fixKnowledgeReport !== null) {
|
|
136
|
+
writeStdout(fixKnowledgeReport.message);
|
|
137
|
+
if (fixKnowledgeReport.aborted && fixKnowledgeReport.abort_reason !== void 0) {
|
|
138
|
+
writeStderr(fixKnowledgeReport.abort_reason);
|
|
122
139
|
}
|
|
123
|
-
|
|
140
|
+
renderFixKnowledgeMutations(fixKnowledgeReport);
|
|
124
141
|
} else if (fixReport !== null) {
|
|
125
142
|
writeStdout(fixReport.message);
|
|
126
143
|
}
|
|
127
144
|
renderHumanReport(report);
|
|
128
145
|
}
|
|
129
146
|
await emitDoctorRunEventBestEffort(resolution.target, {
|
|
130
|
-
mode:
|
|
147
|
+
mode: fixKnowledge ? "fix-knowledge" : "lint",
|
|
131
148
|
issues: report.fixable_errors.length + report.manual_errors.length + report.warnings.length,
|
|
132
|
-
mutations:
|
|
149
|
+
mutations: fixKnowledgeReport !== null ? fixKnowledgeReport.mutations.filter((m) => m.applied).length : void 0
|
|
133
150
|
});
|
|
134
|
-
if (
|
|
135
|
-
if (
|
|
151
|
+
if (fixKnowledgeReport !== null) {
|
|
152
|
+
if (fixKnowledgeReport.aborted) {
|
|
136
153
|
process.exitCode = 1;
|
|
137
154
|
return;
|
|
138
155
|
}
|
|
139
|
-
if (
|
|
156
|
+
if (fixKnowledgeReport.mutations.some((m) => !m.applied)) {
|
|
140
157
|
process.exitCode = 1;
|
|
141
158
|
return;
|
|
142
159
|
}
|
|
@@ -156,13 +173,13 @@ function renderHumanReport(report) {
|
|
|
156
173
|
writeIssueSection(t("doctor.section.manual"), report.manual_errors);
|
|
157
174
|
writeIssueSection(t("doctor.section.warnings"), report.warnings);
|
|
158
175
|
}
|
|
159
|
-
function
|
|
160
|
-
if (
|
|
176
|
+
function renderFixKnowledgeMutations(fixKnowledgeReport) {
|
|
177
|
+
if (fixKnowledgeReport.mutations.length === 0) {
|
|
161
178
|
return;
|
|
162
179
|
}
|
|
163
180
|
writeStdout("");
|
|
164
|
-
writeStdout(t("doctor.section.
|
|
165
|
-
for (const mutation of
|
|
181
|
+
writeStdout(t("doctor.section.fix-knowledge-mutations"));
|
|
182
|
+
for (const mutation of fixKnowledgeReport.mutations) {
|
|
166
183
|
const marker = mutation.applied ? symbol.ok : symbol.error;
|
|
167
184
|
const errSuffix = mutation.applied || mutation.error === void 0 ? "" : ` (${mutation.error})`;
|
|
168
185
|
writeStdout(`${marker} ${mutation.kind}: ${mutation.path} [${mutation.detail}]${errSuffix}`);
|
|
@@ -207,28 +224,28 @@ function writeStderr(message) {
|
|
|
207
224
|
process.stderr.write(`${message}
|
|
208
225
|
`);
|
|
209
226
|
}
|
|
210
|
-
function
|
|
227
|
+
function computeFixKnowledgePlan(report) {
|
|
211
228
|
const buckets = {};
|
|
212
229
|
const sources = [
|
|
213
230
|
...report.fixable_errors,
|
|
214
231
|
...report.warnings
|
|
215
232
|
];
|
|
216
233
|
for (const issue of sources) {
|
|
217
|
-
if (
|
|
234
|
+
if (FIX_KNOWLEDGE_CODE_LABELS[issue.code] === void 0) continue;
|
|
218
235
|
if (!Array.isArray(buckets[issue.code])) {
|
|
219
236
|
buckets[issue.code] = [];
|
|
220
237
|
}
|
|
221
238
|
buckets[issue.code].push(issue);
|
|
222
239
|
}
|
|
223
240
|
const codes = Object.keys(buckets).sort(
|
|
224
|
-
(a, b) =>
|
|
241
|
+
(a, b) => FIX_KNOWLEDGE_CODE_LABELS[a].localeCompare(FIX_KNOWLEDGE_CODE_LABELS[b])
|
|
225
242
|
);
|
|
226
243
|
const perCodeLines = [];
|
|
227
244
|
let totalCount = 0;
|
|
228
245
|
for (const code of codes) {
|
|
229
246
|
const items = buckets[code];
|
|
230
247
|
totalCount += items.length;
|
|
231
|
-
perCodeLines.push(` - ${
|
|
248
|
+
perCodeLines.push(` - ${FIX_KNOWLEDGE_CODE_LABELS[code]}: ${items.length}`);
|
|
232
249
|
}
|
|
233
250
|
const previewLines = [];
|
|
234
251
|
const flattened = codes.flatMap((c) => buckets[c]);
|
|
@@ -241,9 +258,9 @@ function computeApplyLintPlan(report) {
|
|
|
241
258
|
}
|
|
242
259
|
return { totalCount, perCodeLines, previewLines };
|
|
243
260
|
}
|
|
244
|
-
function
|
|
261
|
+
function renderFixKnowledgePlan(plan) {
|
|
245
262
|
writeStdout("");
|
|
246
|
-
writeStdout(`${paint.warn("
|
|
263
|
+
writeStdout(`${paint.warn("fix-knowledge mutation plan")} (${plan.totalCount} total)`);
|
|
247
264
|
for (const line of plan.perCodeLines) {
|
|
248
265
|
writeStdout(line);
|
|
249
266
|
}
|
|
@@ -255,13 +272,13 @@ function renderApplyLintPlan(plan) {
|
|
|
255
272
|
}
|
|
256
273
|
}
|
|
257
274
|
}
|
|
258
|
-
async function
|
|
275
|
+
async function resolveFixKnowledgeConsent(options) {
|
|
259
276
|
if (options.yesFlag || options.envBypass) {
|
|
260
277
|
return "proceed";
|
|
261
278
|
}
|
|
262
279
|
if (process.stdin.isTTY !== true) {
|
|
263
280
|
writeStderr(
|
|
264
|
-
"doctor --
|
|
281
|
+
"doctor --fix-knowledge: stdin is not a TTY and neither --yes nor FABRIC_NONINTERACTIVE=1 is set. Refusing to mutate."
|
|
265
282
|
);
|
|
266
283
|
return "abort";
|
|
267
284
|
}
|
|
@@ -271,7 +288,7 @@ async function resolveApplyLintConsent(options) {
|
|
|
271
288
|
initialValue: false
|
|
272
289
|
});
|
|
273
290
|
if (isCancel(answer) || answer !== true) {
|
|
274
|
-
writeStderr("doctor --
|
|
291
|
+
writeStderr("doctor --fix-knowledge: aborted by user.");
|
|
275
292
|
return "abort";
|
|
276
293
|
}
|
|
277
294
|
return "proceed";
|
package/dist/index.js
CHANGED
|
@@ -8,20 +8,19 @@ import { defineCommand, runMain } from "citty";
|
|
|
8
8
|
|
|
9
9
|
// src/commands/index.ts
|
|
10
10
|
var allCommands = {
|
|
11
|
-
install: () => import("./install-
|
|
12
|
-
|
|
13
|
-
serve: () => import("./serve-
|
|
14
|
-
uninstall: () => import("./uninstall-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"plan-context-hint": () => import("./plan-context-hint-QMUPAXIB.js").then((module) => module.default)
|
|
11
|
+
install: () => import("./install-JLDCHAXV.js").then((module) => module.default),
|
|
12
|
+
doctor: () => import("./doctor-6XHLQJXB.js").then((module) => module.default),
|
|
13
|
+
serve: () => import("./serve-L3X5UHG2.js").then((module) => module.default),
|
|
14
|
+
uninstall: () => import("./uninstall-DD6FIFCI.js").then((module) => module.default),
|
|
15
|
+
config: () => import("./config-7YD365I3.js").then((module) => module.default),
|
|
16
|
+
"plan-context-hint": () => import("./plan-context-hint-73U4FGKO.js").then((module) => module.default)
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
// src/index.ts
|
|
21
20
|
var main = defineCommand({
|
|
22
21
|
meta: {
|
|
23
22
|
name: "fabric",
|
|
24
|
-
version: "2.0.0-rc.
|
|
23
|
+
version: "2.0.0-rc.15",
|
|
25
24
|
description: 'Initialize and manage Fabric projects. Use "fabric install" for one-shot setup.'
|
|
26
25
|
},
|
|
27
26
|
subCommands: allCommands
|