@citemap/cli 0.4.0 → 0.4.1

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 CHANGED
@@ -104,6 +104,10 @@ If a citemap claims a level via `citemapLevel` that doesn't match actual content
104
104
  MIT
105
105
 
106
106
 
107
+ ## 0.4.1
108
+
109
+ - The `citemap` command runs the current build (0.4.0's bin still loaded an old 0.3.x file, so URLs read as "File not found").
110
+
107
111
  ## 0.4.0
108
112
 
109
113
  - `citemap validate <url>` reads a citemap over https.
package/bin/citemap.js CHANGED
@@ -1,2 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import('../dist/index.js');
2
+ // tsup writes ESM as dist/index.mjs (no "type": "module" here); 0.4.0 still
3
+ // pointed at a stale dist/index.js from 0.3.x.
4
+ import('../dist/index.mjs');
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  import { readFileSync } from "fs";
5
5
  import { resolve } from "path";
6
6
  import { validate, validateAndDiagnose, validateContentFile, checkAcrossFiles } from "@citemap/validator";
7
- var VERSION = "0.4.0";
7
+ var VERSION = "0.4.1";
8
8
  var colors = {
9
9
  reset: "\x1B[0m",
10
10
  bright: "\x1B[1m",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citemap/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Command-line tool for validating citemap.json files",
5
5
  "bin": {
6
6
  "citemap": "bin/citemap.js"
@@ -10,7 +10,7 @@
10
10
  "bin"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsup src/index.ts --format esm --no-dts --out-dir dist",
13
+ "build": "tsup src/index.ts --format esm --no-dts --out-dir dist --clean",
14
14
  "dev": "node --loader ts-node/esm src/index.ts",
15
15
  "prepublishOnly": "npm run build"
16
16
  },
@@ -24,7 +24,7 @@
24
24
  "license": "MIT",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/citemaps/citemap"
27
+ "url": "git+https://github.com/citemaps/citemap.git"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=18.0.0"
package/dist/index.js DELETED
@@ -1,213 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/index.ts
4
- import { readFileSync } from "fs";
5
- import { resolve } from "path";
6
- import { validate, validateAndDiagnose } from "@citemap/validator";
7
- var VERSION = "0.3.3";
8
- var colors = {
9
- reset: "\x1B[0m",
10
- bright: "\x1B[1m",
11
- dim: "\x1B[2m",
12
- red: "\x1B[31m",
13
- green: "\x1B[32m",
14
- yellow: "\x1B[33m",
15
- blue: "\x1B[34m",
16
- magenta: "\x1B[35m",
17
- cyan: "\x1B[36m"
18
- };
19
- function printUsage() {
20
- console.log(`
21
- ${colors.bright}citemap${colors.reset} \u2014 Validate citemap.json files for AI accuracy
22
-
23
- ${colors.bright}Usage:${colors.reset}
24
- citemap validate <path> Validate a citemap.json file
25
- citemap diagnose <path> Run detailed analysis with scores and level assessment
26
- citemap --help Show this help message
27
- citemap --version Show version number
28
-
29
- ${colors.bright}Examples:${colors.reset}
30
- citemap validate ./citemap.json
31
- citemap diagnose .well-known/citemap.json
32
-
33
- ${colors.bright}Learn more:${colors.reset}
34
- https://github.com/citemaps/citemap
35
- `);
36
- }
37
- function printVersion() {
38
- console.log(`citemap v${VERSION}`);
39
- }
40
- function loadJSON(filePath) {
41
- try {
42
- const absolutePath = resolve(filePath);
43
- const content = readFileSync(absolutePath, "utf-8");
44
- return JSON.parse(content);
45
- } catch (error) {
46
- if (error instanceof SyntaxError) {
47
- console.error(`${colors.red}\u2717 Invalid JSON${colors.reset}: ${error.message}`);
48
- process.exit(1);
49
- }
50
- if (error instanceof Error && "code" in error && error.code === "ENOENT") {
51
- console.error(`${colors.red}\u2717 File not found${colors.reset}: ${filePath}`);
52
- process.exit(1);
53
- }
54
- console.error(`${colors.red}\u2717 Error reading file${colors.reset}: ${error instanceof Error ? error.message : String(error)}`);
55
- process.exit(1);
56
- }
57
- }
58
- function getProgressBar(percentage, width = 20) {
59
- const filled = Math.round(percentage / 100 * width);
60
- const empty = width - filled;
61
- return `[${colors.green}${"\u2588".repeat(filled)}${colors.reset}${colors.dim}${"\u2591".repeat(empty)}${colors.reset}]`;
62
- }
63
- function scoreColor(score) {
64
- if (score >= 80) return colors.green;
65
- if (score >= 60) return colors.yellow;
66
- return colors.red;
67
- }
68
- function formatValidationOutput(result) {
69
- const statusIcon = result.valid ? `${colors.green}\u2713${colors.reset}` : `${colors.red}\u2717${colors.reset}`;
70
- const statusText = result.valid ? `${colors.green}Valid${colors.reset}` : `${colors.red}Invalid${colors.reset}`;
71
- console.log(`
72
- ${statusIcon} ${statusText} citemap.json ${colors.dim}v${result.version}${colors.reset}`);
73
- const lvl = result.level;
74
- const levelColor = lvl.current === 3 ? colors.green : lvl.current === 2 ? colors.cyan : colors.yellow;
75
- console.log(` ${levelColor}${colors.bright}${lvl.badge}${colors.reset}`);
76
- if (!lvl.claimAccurate && lvl.claimed != null) {
77
- console.log(` ${colors.yellow}\u26A0 Claimed Level ${lvl.claimed}, actual Level ${lvl.current}${colors.reset}`);
78
- }
79
- console.log();
80
- if (result.errors.length > 0) {
81
- console.log(`${colors.red}${colors.bright}Errors (${result.errors.length}):${colors.reset}`);
82
- result.errors.forEach((error) => {
83
- console.log(` ${colors.red}\u2022${colors.reset} ${error.path}: ${error.message}`);
84
- });
85
- console.log();
86
- }
87
- if (result.warnings.length > 0) {
88
- console.log(`${colors.yellow}${colors.bright}Warnings (${result.warnings.length}):${colors.reset}`);
89
- result.warnings.forEach((warning) => {
90
- console.log(` ${colors.yellow}\u2022${colors.reset} ${warning.path}: ${warning.message}`);
91
- console.log(` ${colors.dim}\u2192 ${warning.suggestion}${colors.reset}`);
92
- });
93
- console.log();
94
- }
95
- const s = result.score;
96
- console.log(`${colors.bright}Quality Score: ${scoreColor(s.overall)}${s.overall}%${colors.reset}`);
97
- console.log(` Completeness ${scoreColor(s.completeness)}${s.completeness.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.completeness)}`);
98
- console.log(` Modules ${scoreColor(s.modules)}${s.modules.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.modules)}`);
99
- console.log(` Trust ${scoreColor(s.trust)}${s.trust.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.trust)}`);
100
- console.log();
101
- if (result.valid) {
102
- console.log(`${colors.green}All validations passed.${colors.reset}
103
- `);
104
- }
105
- process.exit(result.valid ? 0 : 1);
106
- }
107
- function formatDiagnosticOutput(data) {
108
- const result = validateAndDiagnose(data);
109
- const diag = result.diagnosis;
110
- const statusIcon = result.valid ? `${colors.green}\u2713${colors.reset}` : `${colors.red}\u2717${colors.reset}`;
111
- const statusText = result.valid ? `${colors.green}Valid${colors.reset}` : `${colors.red}Invalid${colors.reset}`;
112
- console.log(`
113
- ${statusIcon} ${statusText} citemap.json ${colors.dim}v${result.version}${colors.reset}`);
114
- const lvl = result.level;
115
- const levelColor = lvl.current === 3 ? colors.green : lvl.current === 2 ? colors.cyan : colors.yellow;
116
- console.log(` ${levelColor}${colors.bright}${lvl.badge}${colors.reset}`);
117
- if (!lvl.claimAccurate && lvl.claimed != null) {
118
- console.log(` ${colors.yellow}\u26A0 Claimed Level ${lvl.claimed}, actual Level ${lvl.current}${colors.reset}`);
119
- }
120
- console.log();
121
- if (result.errors.length > 0) {
122
- console.log(`${colors.red}${colors.bright}Errors (${result.errors.length}):${colors.reset}`);
123
- result.errors.forEach((error) => {
124
- console.log(` ${colors.red}\u2022${colors.reset} ${error.path}: ${error.message}`);
125
- });
126
- console.log();
127
- }
128
- if (result.warnings.length > 0) {
129
- console.log(`${colors.yellow}${colors.bright}Warnings (${result.warnings.length}):${colors.reset}`);
130
- result.warnings.forEach((warning) => {
131
- console.log(` ${colors.yellow}\u2022${colors.reset} ${warning.path}: ${warning.message}`);
132
- console.log(` ${colors.dim}\u2192 ${warning.suggestion}${colors.reset}`);
133
- });
134
- console.log();
135
- }
136
- const s = result.score;
137
- console.log(`${colors.bright}Quality Scores:${colors.reset}`);
138
- console.log(` Overall ${scoreColor(s.overall)}${s.overall.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.overall)}`);
139
- console.log(` Completeness ${scoreColor(s.completeness)}${s.completeness.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.completeness)}`);
140
- console.log(` Modules ${scoreColor(s.modules)}${s.modules.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.modules)}`);
141
- console.log(` Trust ${scoreColor(s.trust)}${s.trust.toString().padStart(3)}%${colors.reset} ${getProgressBar(s.trust)}`);
142
- console.log();
143
- console.log(`${colors.bright}Diagnosis:${colors.reset}`);
144
- console.log(` Site type: ${colors.cyan}${diag.siteType}${colors.reset}`);
145
- console.log(` Field coverage: ${scoreColor(diag.fieldCoverage.percentage)}${diag.fieldCoverage.filled}/${diag.fieldCoverage.total} (${diag.fieldCoverage.percentage}%)${colors.reset}`);
146
- if (diag.presentModules.length > 0) {
147
- console.log(` Modules present: ${colors.green}${diag.presentModules.join(", ")}${colors.reset}`);
148
- }
149
- if (diag.missingModules.length > 0) {
150
- console.log(` Modules missing: ${colors.yellow}${diag.missingModules.join(", ")}${colors.reset}`);
151
- }
152
- console.log();
153
- if (lvl.nextLevelHints.length > 0) {
154
- const nextLevel = lvl.current + 1;
155
- console.log(`${colors.bright}To reach Level ${nextLevel}:${colors.reset}`);
156
- lvl.nextLevelHints.forEach((hint) => {
157
- console.log(` ${colors.magenta}\u2192${colors.reset} ${hint}`);
158
- });
159
- console.log();
160
- }
161
- if (diag.recommendations.length > 0) {
162
- console.log(`${colors.bright}Recommendations:${colors.reset}`);
163
- diag.recommendations.forEach((rec) => {
164
- console.log(` ${colors.blue}\u2022${colors.reset} ${rec}`);
165
- });
166
- console.log();
167
- }
168
- if (result.valid) {
169
- console.log(`${colors.green}\u2713 All validations passed.${colors.reset}
170
- `);
171
- } else {
172
- console.log(`${colors.red}\u2717 Validation failed. See errors above.${colors.reset}
173
- `);
174
- }
175
- process.exit(result.valid ? 0 : 1);
176
- }
177
- async function main() {
178
- const args = process.argv.slice(2);
179
- if (args.length === 0 || args[0] === "--help") {
180
- printUsage();
181
- process.exit(0);
182
- }
183
- if (args[0] === "--version") {
184
- printVersion();
185
- process.exit(0);
186
- }
187
- const command = args[0];
188
- const filePath = args[1];
189
- if (!filePath) {
190
- console.error(`${colors.red}Error: File path required${colors.reset}
191
- `);
192
- printUsage();
193
- process.exit(1);
194
- }
195
- if (command !== "validate" && command !== "diagnose") {
196
- console.error(`${colors.red}Error: Unknown command '${command}'${colors.reset}
197
- `);
198
- console.error(`Supported commands: ${colors.cyan}validate${colors.reset}, ${colors.cyan}diagnose${colors.reset}
199
- `);
200
- process.exit(1);
201
- }
202
- const data = loadJSON(filePath);
203
- if (command === "validate") {
204
- const result = validate(data);
205
- formatValidationOutput(result);
206
- } else if (command === "diagnose") {
207
- formatDiagnosticOutput(data);
208
- }
209
- }
210
- main().catch((error) => {
211
- console.error(`${colors.red}Fatal error:${colors.reset}`, error instanceof Error ? error.message : String(error));
212
- process.exit(1);
213
- });