claude-code-ultimate-guide-mcp 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.
@@ -0,0 +1,254 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ // src/lib/content.ts
9
+ import { readFileSync as readFileSync2 } from "fs";
10
+ import { resolve as resolve2, join, sep } from "path";
11
+ import { parse as parseYaml } from "yaml";
12
+ import { fileURLToPath } from "url";
13
+
14
+ // src/lib/fetcher.ts
15
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from "fs";
16
+ import { resolve, dirname } from "path";
17
+ import { homedir } from "os";
18
+ import { createHash } from "crypto";
19
+ var PACKAGE_VERSION = "1.0.0";
20
+ var GITHUB_RAW_BASE = "https://raw.githubusercontent.com/FlorianBruniaux/claude-code-ultimate-guide/main";
21
+ var CACHE_DIR = resolve(homedir(), ".cache", "claude-code-guide", PACKAGE_VERSION);
22
+ var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
23
+ function getCachePath(filePath) {
24
+ const hash = createHash("md5").update(filePath).digest("hex").slice(0, 8);
25
+ const safe = filePath.replace(/[^a-zA-Z0-9._-]/g, "_");
26
+ return resolve(CACHE_DIR, `${hash}_${safe}`);
27
+ }
28
+ function isCacheValid(cachePath) {
29
+ if (!existsSync(cachePath)) return false;
30
+ const stat = statSync(cachePath);
31
+ return Date.now() - stat.mtimeMs < CACHE_TTL_MS;
32
+ }
33
+ async function fetchFile(filePath) {
34
+ const normalizedPath = filePath.replace(/\\/g, "/");
35
+ const cachePath = getCachePath(normalizedPath);
36
+ if (isCacheValid(cachePath)) {
37
+ return readFileSync(cachePath, "utf8");
38
+ }
39
+ const url = `${GITHUB_RAW_BASE}/${normalizedPath}`;
40
+ try {
41
+ const response = await fetch(url, {
42
+ headers: { "User-Agent": "claude-code-ultimate-guide-mcp/1.0.0" },
43
+ signal: AbortSignal.timeout(1e4)
44
+ });
45
+ if (!response.ok) {
46
+ if (existsSync(cachePath)) {
47
+ return readFileSync(cachePath, "utf8");
48
+ }
49
+ return null;
50
+ }
51
+ const content = await response.text();
52
+ mkdirSync(dirname(cachePath), { recursive: true });
53
+ writeFileSync(cachePath, content, "utf8");
54
+ return content;
55
+ } catch {
56
+ if (existsSync(cachePath)) {
57
+ return readFileSync(cachePath, "utf8");
58
+ }
59
+ return null;
60
+ }
61
+ }
62
+
63
+ // src/lib/content.ts
64
+ var __filename = fileURLToPath(import.meta.url);
65
+ var __dirname = resolve2(__filename, "..");
66
+ var GUIDE_ROOT = process.env.GUIDE_ROOT ? resolve2(process.env.GUIDE_ROOT) : null;
67
+ var CONTENT_DIR = GUIDE_ROOT ? resolve2(GUIDE_ROOT, "machine-readable") : resolve2(__dirname, "../../content");
68
+ var ALLOWED_EXTENSIONS = /* @__PURE__ */ new Set([
69
+ ".md",
70
+ ".yaml",
71
+ ".yml",
72
+ ".sh",
73
+ ".ts",
74
+ ".js",
75
+ ".json",
76
+ ".py",
77
+ ".txt"
78
+ ]);
79
+ function resolveContentPath(relativePath) {
80
+ const base = GUIDE_ROOT ?? resolve2(__dirname, "../../..");
81
+ const resolved = resolve2(base, relativePath);
82
+ if (!resolved.startsWith(base + sep)) return null;
83
+ const ext = relativePath.slice(relativePath.lastIndexOf("."));
84
+ if (!ALLOWED_EXTENSIONS.has(ext)) return null;
85
+ return resolved;
86
+ }
87
+ function isDevMode() {
88
+ return GUIDE_ROOT !== null;
89
+ }
90
+ function getGuideRoot() {
91
+ return GUIDE_ROOT ?? resolve2(__dirname, "../../..");
92
+ }
93
+ var referenceCache = null;
94
+ var releasesCache = null;
95
+ var threatDbCache = null;
96
+ function loadReference() {
97
+ if (referenceCache) return referenceCache;
98
+ const filePath = join(CONTENT_DIR, "reference.yaml");
99
+ const raw = parseYaml(readFileSync2(filePath, "utf8"));
100
+ const entries = [];
101
+ flattenReference(raw, "", entries);
102
+ referenceCache = {
103
+ version: raw.version ?? "unknown",
104
+ entries,
105
+ raw
106
+ };
107
+ return referenceCache;
108
+ }
109
+ function loadReleases() {
110
+ if (releasesCache) return releasesCache;
111
+ const filePath = join(CONTENT_DIR, "claude-code-releases.yaml");
112
+ const raw = parseYaml(readFileSync2(filePath, "utf8"));
113
+ releasesCache = {
114
+ latest: raw.latest ?? "unknown",
115
+ updated: raw.updated ?? "unknown",
116
+ releases: raw.releases ?? [],
117
+ raw
118
+ };
119
+ return releasesCache;
120
+ }
121
+ async function loadThreatDb() {
122
+ if (threatDbCache) return threatDbCache;
123
+ const THREAT_DB_PATH = "examples/commands/resources/threat-db.yaml";
124
+ let content;
125
+ if (GUIDE_ROOT) {
126
+ content = readFileSync2(join(GUIDE_ROOT, THREAT_DB_PATH), "utf8");
127
+ } else {
128
+ const fetched = await fetchFile(THREAT_DB_PATH);
129
+ if (!fetched) throw new Error("Failed to load threat-db.yaml");
130
+ content = fetched;
131
+ }
132
+ const raw = parseYaml(content);
133
+ threatDbCache = {
134
+ version: raw.version ?? "unknown",
135
+ updated: raw.updated ?? "unknown",
136
+ sources: raw.sources ?? [],
137
+ malicious_authors: raw.malicious_authors ?? [],
138
+ malicious_skills: raw.malicious_skills ?? [],
139
+ cve_database: raw.cve_database ?? [],
140
+ attack_techniques: raw.attack_techniques ?? [],
141
+ minimum_safe_versions: raw.minimum_safe_versions ?? {},
142
+ raw
143
+ };
144
+ return threatDbCache;
145
+ }
146
+ function loadLlmsTxt() {
147
+ const filePath = join(CONTENT_DIR, "llms.txt");
148
+ return readFileSync2(filePath, "utf8");
149
+ }
150
+ function getReferenceYamlRaw() {
151
+ const filePath = join(CONTENT_DIR, "reference.yaml");
152
+ return readFileSync2(filePath, "utf8");
153
+ }
154
+ function getReleasesYamlRaw() {
155
+ const filePath = join(CONTENT_DIR, "claude-code-releases.yaml");
156
+ return readFileSync2(filePath, "utf8");
157
+ }
158
+ function resolveDeepDive(value) {
159
+ if (value === null || value === void 0) return void 0;
160
+ if (typeof value === "number") {
161
+ return { type: "line", file: "guide/ultimate-guide.md", line: value };
162
+ }
163
+ if (typeof value === "string") {
164
+ if (value.startsWith("http://") || value.startsWith("https://")) {
165
+ return { type: "url", url: value };
166
+ }
167
+ const filePathMatch = value.match(/^(guide\/|examples\/|whitepapers\/|machine-readable\/)(.+?)(?::(\d+))?$/);
168
+ if (filePathMatch) {
169
+ return {
170
+ type: "file",
171
+ path: filePathMatch[1] + filePathMatch[2],
172
+ line: filePathMatch[3] ? parseInt(filePathMatch[3], 10) : void 0
173
+ };
174
+ }
175
+ return { type: "inline", text: value };
176
+ }
177
+ if (typeof value === "object") {
178
+ return { type: "structured", data: value };
179
+ }
180
+ return { type: "inline", text: String(value) };
181
+ }
182
+ function flattenReference(obj, prefix, entries) {
183
+ for (const [key, value] of Object.entries(obj)) {
184
+ const fullKey = prefix ? `${prefix}_${key}` : key;
185
+ if (key === "version" || key === "generated" || key === "description" || key === "note") {
186
+ continue;
187
+ }
188
+ if (value === null || value === void 0) continue;
189
+ if (typeof value === "object" && !Array.isArray(value)) {
190
+ const obj2 = value;
191
+ const hasDeepDive = "deep_dive" in obj2;
192
+ const hasNestedObjects = Object.values(obj2).some(
193
+ (v) => typeof v === "object" && v !== null && !Array.isArray(v) && !("deep_dive" in v)
194
+ );
195
+ if (hasDeepDive || !hasNestedObjects) {
196
+ const searchableText = buildSearchableText(fullKey, value);
197
+ const target = hasDeepDive ? resolveDeepDive(obj2.deep_dive) : resolveDeepDive(value);
198
+ entries.push({
199
+ key: fullKey,
200
+ section: prefix.split("_")[0] ?? fullKey,
201
+ value,
202
+ searchableText,
203
+ target
204
+ });
205
+ } else {
206
+ flattenReference(obj2, fullKey, entries);
207
+ }
208
+ } else {
209
+ const searchableText = buildSearchableText(fullKey, value);
210
+ const target = resolveDeepDive(value);
211
+ entries.push({
212
+ key: fullKey,
213
+ section: prefix.split("_")[0] ?? fullKey,
214
+ value,
215
+ searchableText,
216
+ target
217
+ });
218
+ }
219
+ }
220
+ }
221
+ function buildSearchableText(key, value) {
222
+ const parts = [key.replace(/_/g, " ")];
223
+ if (typeof value === "string") {
224
+ parts.push(value);
225
+ } else if (typeof value === "number") {
226
+ parts.push(String(value));
227
+ } else if (Array.isArray(value)) {
228
+ for (const item of value) {
229
+ if (typeof item === "string") parts.push(item);
230
+ else if (typeof item === "object" && item !== null) {
231
+ parts.push(JSON.stringify(item));
232
+ }
233
+ }
234
+ } else if (typeof value === "object" && value !== null) {
235
+ parts.push(JSON.stringify(value));
236
+ }
237
+ return parts.join(" ").toLowerCase();
238
+ }
239
+
240
+ export {
241
+ __export,
242
+ fetchFile,
243
+ resolveContentPath,
244
+ isDevMode,
245
+ getGuideRoot,
246
+ loadReference,
247
+ loadReleases,
248
+ loadThreatDb,
249
+ loadLlmsTxt,
250
+ getReferenceYamlRaw,
251
+ getReleasesYamlRaw,
252
+ resolveDeepDive
253
+ };
254
+ //# sourceMappingURL=chunk-2OLPHMWN.js.map
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getGuideRoot,
4
+ getReferenceYamlRaw,
5
+ getReleasesYamlRaw,
6
+ isDevMode,
7
+ loadLlmsTxt,
8
+ loadReference,
9
+ loadReleases,
10
+ loadThreatDb,
11
+ resolveContentPath,
12
+ resolveDeepDive
13
+ } from "./chunk-2OLPHMWN.js";
14
+ export {
15
+ getGuideRoot,
16
+ getReferenceYamlRaw,
17
+ getReleasesYamlRaw,
18
+ isDevMode,
19
+ loadLlmsTxt,
20
+ loadReference,
21
+ loadReleases,
22
+ loadThreatDb,
23
+ resolveContentPath,
24
+ resolveDeepDive
25
+ };
26
+ //# sourceMappingURL=content-LZDXNAPI.js.map
@@ -0,0 +1,2 @@
1
+
2
+ export { }