@cratis/pi 7.152.1 → 7.153.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/package/corpus/skills/cratis-screenplay-reverse-engineering/scripts/score-fidelity.mjs
CHANGED
|
@@ -150,6 +150,19 @@ function parseArguments(args) {
|
|
|
150
150
|
return options;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function readCatalog(path) {
|
|
154
|
+
try {
|
|
155
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new CatalogError(`cannot read ${path}: ${error.message}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function writeScore(options) {
|
|
162
|
+
const result = score(readCatalog(options.catalog), options.naming ? readCatalog(options.naming) : undefined);
|
|
163
|
+
console.log(options.json ? JSON.stringify(roundDeep(result)) : format(result));
|
|
164
|
+
}
|
|
165
|
+
|
|
153
166
|
async function main() {
|
|
154
167
|
try {
|
|
155
168
|
const options = parseArguments(process.argv.slice(2));
|
|
@@ -159,15 +172,7 @@ async function main() {
|
|
|
159
172
|
return;
|
|
160
173
|
}
|
|
161
174
|
if (!options.catalog) throw new CatalogError('Usage: node score-fidelity.mjs <catalog.json> [--naming <naming.json>] [--json] | --self-test');
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
165
|
-
} catch (error) {
|
|
166
|
-
throw new CatalogError(`cannot read ${path}: ${error.message}`);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const result = score(read(options.catalog), options.naming ? read(options.naming) : undefined);
|
|
170
|
-
console.log(options.json ? JSON.stringify(roundDeep(result)) : format(result));
|
|
175
|
+
writeScore(options);
|
|
171
176
|
} catch (error) {
|
|
172
177
|
console.error(`score-fidelity: ${error.message}`);
|
|
173
178
|
process.exitCode = error instanceof CatalogError ? 2 : 1;
|