@fenglimg/fabric-cli 0.1.4 → 1.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.
Files changed (30) hide show
  1. package/dist/{bootstrap-HUDJ2E3Q.js → bootstrap-PMIA4W6G.js} +16 -12
  2. package/dist/{chunk-T3WQUWW4.js → chunk-5BSTO745.js} +9 -6
  3. package/dist/chunk-6ICJICVU.js +10 -0
  4. package/dist/chunk-AEOYCVBG.js +0 -0
  5. package/dist/chunk-DKQ3HOTK.js +206 -0
  6. package/dist/{chunk-U376IPKT.js → chunk-F2BXHPM5.js} +11 -7
  7. package/dist/{chunk-CZ7U6ULM.js → chunk-L43IGJ6X.js} +17 -7
  8. package/dist/chunk-P4KVFB2T.js +0 -0
  9. package/dist/{chunk-N7TTCGJA.js → chunk-VMYPJPKV.js} +1 -0
  10. package/dist/chunk-WWNXR34K.js +49 -0
  11. package/dist/{config-YKDWIRCT.js → config-PXEEXWLM.js} +14 -11
  12. package/dist/{hooks-VXXO4VZP.js → hooks-5S5IRVQE.js} +15 -12
  13. package/dist/human-lint-YSFOZHZ7.js +13 -0
  14. package/dist/index.js +15 -11
  15. package/dist/init-G6Q3OOMC.js +601 -0
  16. package/dist/{ledger-append-EGIKSMU5.js → ledger-append-XZ5SX4O5.js} +2 -1
  17. package/dist/{pre-commit-CXPH7BZH.js → pre-commit-IEIXHKOD.js} +13 -7
  18. package/dist/{scan-UASZQLQP.js → scan-6CURGC3D.js} +3 -1
  19. package/dist/serve-4J2CQY25.js +112 -0
  20. package/dist/{sync-meta-YTG5V3Y6.js → sync-meta-L6M4AEUT.js} +2 -1
  21. package/package.json +12 -8
  22. package/templates/agents-md/AGENTS.md.template +17 -11
  23. package/templates/agents-md/variants/cocos.md +37 -0
  24. package/templates/agents-md/variants/next.md +37 -0
  25. package/templates/agents-md/variants/vite.md +37 -0
  26. package/templates/claude-hooks/agents-md-init-reminder.cjs +18 -0
  27. package/templates/claude-skills/agents-md-init/SKILL.md +86 -0
  28. package/dist/chunk-BWZHNZG6.js +0 -236
  29. package/dist/human-lint-II6TBGP4.js +0 -9
  30. package/dist/init-IBS7KO7A.js +0 -149
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- createScanReport
4
- } from "./chunk-BWZHNZG6.js";
5
- import {
6
- createDebugLogger,
7
- resolveDevMode
8
- } from "./chunk-AEOYCVBG.js";
9
- import "./chunk-P4KVFB2T.js";
10
-
11
- // src/commands/init.ts
12
- import { createHash } from "crypto";
13
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
14
- import { dirname, isAbsolute, join, parse, resolve } from "path";
15
- import { fileURLToPath } from "url";
16
- import { defineCommand } from "citty";
17
- var initCommand = defineCommand({
18
- meta: {
19
- name: "init",
20
- description: "\u5728\u76EE\u6807\u9879\u76EE\u4E2D\u521D\u59CB\u5316 Fabric\u3002"
21
- },
22
- args: {
23
- target: {
24
- type: "string",
25
- description: "\u76EE\u6807\u9879\u76EE\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u4F9D\u6B21\u4F7F\u7528 CLI \u53C2\u6570\u3001EXTERNAL_FIXTURE_PATH\u3001fabric.config.json \u6216\u5F53\u524D\u76EE\u5F55\u3002"
26
- },
27
- debug: {
28
- type: "boolean",
29
- description: "\u5C06\u76EE\u6807\u89E3\u6790\u8BE6\u60C5\u8F93\u51FA\u5230 stderr\u3002",
30
- default: false
31
- }
32
- },
33
- async run({ args }) {
34
- const logger = createDebugLogger(args.debug);
35
- const resolution = resolveDevMode(args.target, process.cwd());
36
- const target = normalizeTarget(resolution.target);
37
- logger(`init target source: ${resolution.source}`);
38
- for (const step of resolution.chain) {
39
- logger(step);
40
- }
41
- const created = initFabric(target);
42
- console.log(`Created ${created.agentsPath}`);
43
- console.log(`Created ${created.metaPath}`);
44
- console.log(`Created ${created.humanLockPath}`);
45
- console.log("Next: run fab hooks install to add the Day 4 pre-commit pipeline.");
46
- }
47
- });
48
- var init_default = initCommand;
49
- function initFabric(target) {
50
- assertExistingDirectory(target);
51
- const agentsPath = join(target, "AGENTS.md");
52
- const fabricDir = join(target, ".fabric");
53
- if (existsSync(agentsPath)) {
54
- throw new Error(`ABORT: ${agentsPath} already exists. fab init is non-destructive.`);
55
- }
56
- if (existsSync(fabricDir)) {
57
- throw new Error(`ABORT: ${fabricDir} already exists. fab init is non-destructive.`);
58
- }
59
- const scanReport = createScanReport(target);
60
- const template = readFileSync(findTemplatePath("templates/agents-md/AGENTS.md.template"), "utf8");
61
- const humanLockTemplate = readFileSync(findTemplatePath("templates/fabric/human-lock.json"), "utf8");
62
- const packageName = readPackageName(target) ?? "// TODO: project name";
63
- const agentsContent = template.replaceAll("{ projectName }", packageName).replaceAll("{ frameworkKind }", scanReport.framework.kind);
64
- const agentsHash = sha256(agentsContent);
65
- const meta = createInitialMeta(agentsHash);
66
- const metaPath = join(fabricDir, "agents.meta.json");
67
- const humanLockPath = join(fabricDir, "human-lock.json");
68
- mkdirSync(fabricDir, { recursive: false });
69
- writeNewFile(agentsPath, agentsContent);
70
- writeNewFile(metaPath, `${JSON.stringify(meta, null, 2)}
71
- `);
72
- writeNewFile(humanLockPath, humanLockTemplate.endsWith("\n") ? humanLockTemplate : `${humanLockTemplate}
73
- `);
74
- return { agentsPath, metaPath, humanLockPath };
75
- }
76
- function normalizeTarget(targetInput) {
77
- return isAbsolute(targetInput) ? targetInput : resolve(process.cwd(), targetInput);
78
- }
79
- function assertExistingDirectory(target) {
80
- if (!existsSync(target) || !statSync(target).isDirectory()) {
81
- throw new Error(`Target must be an existing directory: ${target}`);
82
- }
83
- }
84
- function createInitialMeta(agentsHash) {
85
- return {
86
- revision: sha256(agentsHash),
87
- nodes: {
88
- L0: {
89
- file: "AGENTS.md",
90
- scope_glob: "**",
91
- deps: [],
92
- priority: "high",
93
- hash: agentsHash
94
- }
95
- }
96
- };
97
- }
98
- function readPackageName(target) {
99
- const packageJsonPath = join(target, "package.json");
100
- if (!existsSync(packageJsonPath)) {
101
- return void 0;
102
- }
103
- try {
104
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
105
- return packageJson.name;
106
- } catch {
107
- return void 0;
108
- }
109
- }
110
- function findTemplatePath(relativePath) {
111
- const currentModuleDir = dirname(fileURLToPath(import.meta.url));
112
- const candidates = [
113
- ...templateCandidatesFrom(process.cwd(), relativePath),
114
- ...templateCandidatesFrom(currentModuleDir, relativePath)
115
- ];
116
- for (const candidate of candidates) {
117
- if (existsSync(candidate)) {
118
- return candidate;
119
- }
120
- }
121
- throw new Error(`Template not found: ${relativePath}`);
122
- }
123
- function templateCandidatesFrom(start, relativePath) {
124
- const candidates = [];
125
- let current = resolve(start);
126
- while (true) {
127
- candidates.push(join(current, ...relativePath.split("/")));
128
- const parent = dirname(current);
129
- if (parent === current || parse(current).root === current) {
130
- break;
131
- }
132
- current = parent;
133
- }
134
- return candidates;
135
- }
136
- function writeNewFile(path, content) {
137
- if (existsSync(path)) {
138
- throw new Error(`ABORT: ${path} already exists. fab init is non-destructive.`);
139
- }
140
- writeFileSync(path, content, "utf8");
141
- }
142
- function sha256(content) {
143
- return `sha256:${createHash("sha256").update(content).digest("hex")}`;
144
- }
145
- export {
146
- init_default as default,
147
- initCommand,
148
- initFabric
149
- };