claude-code-jsonl-validator 0.1.3-beta.9 → 0.1.4-beta.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/dist/cli.cjs +9 -8
- package/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{validate-xB-c5Gv6.cjs → validate-CpJSBIyD.cjs} +3 -5
- package/dist/{validate-D3RwKa-F.js → validate-PqQ452Uy.js} +4 -6
- package/dist/validate-PqQ452Uy.js.map +1 -0
- package/package.json +2 -2
- package/dist/validate-D3RwKa-F.js.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,18 +20,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
|
|
24
|
-
const require_validate = require("./validate-xB-c5Gv6.cjs");
|
|
23
|
+
const require_validate = require("./validate-CpJSBIyD.cjs");
|
|
25
24
|
let node_fs = require("node:fs");
|
|
26
25
|
let node_fs_promises = require("node:fs/promises");
|
|
27
26
|
let node_readline = require("node:readline");
|
|
28
27
|
let node_path = require("node:path");
|
|
29
28
|
node_path = __toESM(node_path, 1);
|
|
30
|
-
|
|
29
|
+
// src/cli.ts
|
|
31
30
|
/** `.jsonl` を再帰収集する。 */
|
|
32
31
|
async function collectJsonl(dir) {
|
|
33
32
|
const out = [];
|
|
34
|
-
|
|
33
|
+
const entries = await (0, node_fs_promises.readdir)(dir);
|
|
34
|
+
for (const entry of entries) {
|
|
35
35
|
const full = node_path.default.join(dir, entry);
|
|
36
36
|
if ((await (0, node_fs_promises.stat)(full)).isDirectory()) out.push(...await collectJsonl(full));
|
|
37
37
|
else if (entry.endsWith(".jsonl")) out.push(full);
|
|
@@ -45,7 +45,8 @@ async function main() {
|
|
|
45
45
|
process.exit(2);
|
|
46
46
|
}
|
|
47
47
|
const findings = [];
|
|
48
|
-
|
|
48
|
+
const files = await collectJsonl(corpus);
|
|
49
|
+
for (const file of files) {
|
|
49
50
|
const rl = (0, node_readline.createInterface)({
|
|
50
51
|
input: (0, node_fs.createReadStream)(file, { encoding: "utf8" }),
|
|
51
52
|
crlfDelay: Infinity
|
|
@@ -62,7 +63,8 @@ async function main() {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
const report = require_validate.aggregateReport(findings);
|
|
65
|
-
|
|
66
|
+
const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b));
|
|
67
|
+
for (const [type, bucket] of sortedReport) {
|
|
66
68
|
console.log(`\n[${type}] ${bucket.length} finding(s)`);
|
|
67
69
|
const byKind = /* @__PURE__ */ new Map();
|
|
68
70
|
for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1);
|
|
@@ -79,4 +81,3 @@ main().catch((error) => {
|
|
|
79
81
|
console.error(error);
|
|
80
82
|
process.exit(1);
|
|
81
83
|
});
|
|
82
|
-
//#endregion
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-
|
|
2
|
+
import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-PqQ452Uy.js";
|
|
3
3
|
import { createReadStream } from "node:fs";
|
|
4
4
|
import { readdir, stat } from "node:fs/promises";
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
|
|
7
|
+
// src/cli.ts
|
|
8
8
|
/** `.jsonl` を再帰収集する。 */
|
|
9
9
|
async function collectJsonl(dir) {
|
|
10
10
|
const out = [];
|
|
11
|
-
|
|
11
|
+
const entries = await readdir(dir);
|
|
12
|
+
for (const entry of entries) {
|
|
12
13
|
const full = path.join(dir, entry);
|
|
13
14
|
if ((await stat(full)).isDirectory()) out.push(...await collectJsonl(full));
|
|
14
15
|
else if (entry.endsWith(".jsonl")) out.push(full);
|
|
@@ -22,7 +23,8 @@ async function main() {
|
|
|
22
23
|
process.exit(2);
|
|
23
24
|
}
|
|
24
25
|
const findings = [];
|
|
25
|
-
|
|
26
|
+
const files = await collectJsonl(corpus);
|
|
27
|
+
for (const file of files) {
|
|
26
28
|
const rl = createInterface({
|
|
27
29
|
input: createReadStream(file, { encoding: "utf8" }),
|
|
28
30
|
crlfDelay: Infinity
|
|
@@ -39,7 +41,8 @@ async function main() {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
const report = aggregateReport(findings);
|
|
42
|
-
|
|
44
|
+
const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b));
|
|
45
|
+
for (const [type, bucket] of sortedReport) {
|
|
43
46
|
console.log(`\n[${type}] ${bucket.length} finding(s)`);
|
|
44
47
|
const byKind = /* @__PURE__ */ new Map();
|
|
45
48
|
for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1);
|
|
@@ -56,7 +59,6 @@ main().catch((error) => {
|
|
|
56
59
|
console.error(error);
|
|
57
60
|
process.exit(1);
|
|
58
61
|
});
|
|
59
|
-
//#endregion
|
|
60
62
|
export {};
|
|
61
63
|
|
|
62
64
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createReadStream } from 'node:fs'\nimport { readdir, stat } from 'node:fs/promises'\nimport { createInterface } from 'node:readline'\nimport path from 'node:path'\nimport { validateLine, aggregateReport, hasFindings, type Finding } from './validate'\n\n/** `.jsonl` を再帰収集する。 */\nasync function collectJsonl(dir: string): Promise<string[]> {\n const out: string[] = []\n
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createReadStream } from 'node:fs'\nimport { readdir, stat } from 'node:fs/promises'\nimport { createInterface } from 'node:readline'\nimport path from 'node:path'\nimport { validateLine, aggregateReport, hasFindings, type Finding } from './validate'\n\n/** `.jsonl` を再帰収集する。 */\nasync function collectJsonl(dir: string): Promise<string[]> {\n const out: string[] = []\n const entries = await readdir(dir)\n for (const entry of entries) {\n const full = path.join(dir, entry)\n const st = await stat(full)\n if (st.isDirectory()) out.push(...(await collectJsonl(full)))\n else if (entry.endsWith('.jsonl')) out.push(full)\n }\n return out\n}\n\nasync function main(): Promise<void> {\n const corpus = process.argv[2]\n if (!corpus) {\n console.error('Usage: claude-code-jsonl-validator <corpus-dir>')\n process.exit(2)\n }\n\n const findings: Finding[] = []\n const files = await collectJsonl(corpus)\n for (const file of files) {\n const rl = createInterface({\n input: createReadStream(file, { encoding: 'utf8' }),\n crlfDelay: Infinity,\n })\n for await (const raw of rl) {\n if (raw.trim() === '') continue\n let obj: unknown\n try {\n obj = JSON.parse(raw)\n } catch {\n continue // 構文エラーは parser 側の責務。ここでは無視\n }\n findings.push(...validateLine(obj))\n }\n }\n\n const report = aggregateReport(findings)\n const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b))\n for (const [type, bucket] of sortedReport) {\n console.log(`\\n[${type}] ${bucket.length} finding(s)`)\n const byKind = new Map<string, number>()\n for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1)\n for (const [kind, n] of byKind) console.log(` ${kind}: ${n}`)\n // 代表例を数件表示\n for (const f of bucket.slice(0, 5)) console.log(` - ${f.message}`)\n }\n\n if (hasFindings(report)) {\n console.error('\\nRegression detected. See findings above.')\n process.exit(1)\n }\n console.log('\\nNo regressions. All lines match known schemas.')\n}\n\nmain().catch((error: unknown) => {\n console.error(error)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;AAQA,eAAe,aAAa,KAAgC;CAC1D,MAAM,MAAgB,CAAC;CACvB,MAAM,UAAU,MAAM,QAAQ,GAAG;CACjC,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,KAAK,KAAK,KAAK,KAAK;EAEjC,KAAI,MADa,KAAK,IAAI,EAAA,CACnB,YAAY,GAAG,IAAI,KAAK,GAAI,MAAM,aAAa,IAAI,CAAE;OACvD,IAAI,MAAM,SAAS,QAAQ,GAAG,IAAI,KAAK,IAAI;CAClD;CACA,OAAO;AACT;AAEA,eAAe,OAAsB;CACnC,MAAM,SAAS,QAAQ,KAAK;CAC5B,IAAI,CAAC,QAAQ;EACX,QAAQ,MAAM,iDAAiD;EAC/D,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,WAAsB,CAAC;CAC7B,MAAM,QAAQ,MAAM,aAAa,MAAM;CACvC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,KAAK,gBAAgB;GACzB,OAAO,iBAAiB,MAAM,EAAE,UAAU,OAAO,CAAC;GAClD,WAAW;EACb,CAAC;EACD,WAAW,MAAM,OAAO,IAAI;GAC1B,IAAI,IAAI,KAAK,MAAM,IAAI;GACvB,IAAI;GACJ,IAAI;IACF,MAAM,KAAK,MAAM,GAAG;GACtB,QAAQ;IACN;GACF;GACA,SAAS,KAAK,GAAG,aAAa,GAAG,CAAC;EACpC;CACF;CAEA,MAAM,SAAS,gBAAgB,QAAQ;CACvC,MAAM,eAAe,CAAC,GAAG,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAC1E,KAAK,MAAM,CAAC,MAAM,WAAW,cAAc;EACzC,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,OAAO,YAAY;EACrD,MAAM,yBAAS,IAAI,IAAoB;EACvC,KAAK,MAAM,KAAK,QAAQ,OAAO,IAAI,EAAE,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC;EACxE,KAAK,MAAM,CAAC,MAAM,MAAM,QAAQ,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;EAE7D,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,SAAS;CACtE;CAEA,IAAI,YAAY,MAAM,GAAG;EACvB,QAAQ,MAAM,4CAA4C;EAC1D,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,IAAI,kDAAkD;AAChE;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-CpJSBIyD.cjs");
|
|
3
3
|
exports.aggregateReport = require_validate.aggregateReport;
|
|
4
4
|
exports.hasFindings = require_validate.hasFindings;
|
|
5
5
|
exports.validateLine = require_validate.validateLine;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/validate.d.ts
|
|
2
1
|
/** 検出種別。 */
|
|
3
2
|
type FindingKind = 'no-type' | 'unknown-type' | 'schema-mismatch' | 'unknown-field';
|
|
4
3
|
/** 1 件の検出。 */
|
|
@@ -28,6 +27,5 @@ export declare function aggregateReport(findings: Finding[]): Map<string, Findin
|
|
|
28
27
|
* @param report - 集計済みレポート
|
|
29
28
|
*/
|
|
30
29
|
export declare function hasFindings(report: Map<string, Finding[]>): boolean;
|
|
31
|
-
//#endregion
|
|
32
30
|
export type { Finding, FindingKind };
|
|
33
31
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/validate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAgBlD,YAAY,QAAQ,YAAY"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/validate.d.ts
|
|
2
1
|
/** 検出種別。 */
|
|
3
2
|
type FindingKind = 'no-type' | 'unknown-type' | 'schema-mismatch' | 'unknown-field';
|
|
4
3
|
/** 1 件の検出。 */
|
|
@@ -28,6 +27,5 @@ export declare function aggregateReport(findings: Finding[]): Map<string, Findin
|
|
|
28
27
|
* @param report - 集計済みレポート
|
|
29
28
|
*/
|
|
30
29
|
export declare function hasFindings(report: Map<string, Finding[]>): boolean;
|
|
31
|
-
//#endregion
|
|
32
30
|
export type { Finding, FindingKind };
|
|
33
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/validate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAgBlD,YAAY,QAAQ,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as aggregateReport, n as hasFindings, r as validateLine } from "./validate-
|
|
1
|
+
export { t as aggregateReport, n as hasFindings, r as validateLine } from "./validate-PqQ452Uy.js";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
let claude_code_jsonl_generator = require("claude-code-jsonl-generator");
|
|
2
|
-
|
|
2
|
+
// src/validate.ts
|
|
3
3
|
/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
|
|
4
4
|
function knownKeysOf(type) {
|
|
5
5
|
const schema = claude_code_jsonl_generator.entrySchemas[type];
|
|
6
|
-
|
|
7
|
-
return new Set(Object.keys(schema.shape));
|
|
6
|
+
return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* 1 行 (パース済み JSON) を検証して findings を返す。
|
|
@@ -12,7 +11,6 @@ function knownKeysOf(type) {
|
|
|
12
11
|
* @param obj - パース済みの生 JSON
|
|
13
12
|
*/
|
|
14
13
|
function validateLine(obj) {
|
|
15
|
-
const findings = [];
|
|
16
14
|
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
|
|
17
15
|
type: "<no-type>",
|
|
18
16
|
kind: "no-type",
|
|
@@ -25,6 +23,7 @@ function validateLine(obj) {
|
|
|
25
23
|
kind: "no-type",
|
|
26
24
|
message: "missing string \"type\""
|
|
27
25
|
}];
|
|
26
|
+
const findings = [];
|
|
28
27
|
const schema = (0, claude_code_jsonl_generator.knownTypeSchema)(type);
|
|
29
28
|
if (schema === void 0) return [{
|
|
30
29
|
type,
|
|
@@ -72,7 +71,6 @@ function hasFindings(report) {
|
|
|
72
71
|
for (const bucket of report.values()) if (bucket.length > 0) return true;
|
|
73
72
|
return false;
|
|
74
73
|
}
|
|
75
|
-
//#endregion
|
|
76
74
|
Object.defineProperty(exports, "aggregateReport", {
|
|
77
75
|
enumerable: true,
|
|
78
76
|
get: function() {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { entrySchemas, knownTypeSchema } from "claude-code-jsonl-generator";
|
|
2
|
-
|
|
2
|
+
// src/validate.ts
|
|
3
3
|
/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
|
|
4
4
|
function knownKeysOf(type) {
|
|
5
5
|
const schema = entrySchemas[type];
|
|
6
|
-
|
|
7
|
-
return new Set(Object.keys(schema.shape));
|
|
6
|
+
return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* 1 行 (パース済み JSON) を検証して findings を返す。
|
|
@@ -12,7 +11,6 @@ function knownKeysOf(type) {
|
|
|
12
11
|
* @param obj - パース済みの生 JSON
|
|
13
12
|
*/
|
|
14
13
|
function validateLine(obj) {
|
|
15
|
-
const findings = [];
|
|
16
14
|
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
|
|
17
15
|
type: "<no-type>",
|
|
18
16
|
kind: "no-type",
|
|
@@ -25,6 +23,7 @@ function validateLine(obj) {
|
|
|
25
23
|
kind: "no-type",
|
|
26
24
|
message: "missing string \"type\""
|
|
27
25
|
}];
|
|
26
|
+
const findings = [];
|
|
28
27
|
const schema = knownTypeSchema(type);
|
|
29
28
|
if (schema === void 0) return [{
|
|
30
29
|
type,
|
|
@@ -72,7 +71,6 @@ function hasFindings(report) {
|
|
|
72
71
|
for (const bucket of report.values()) if (bucket.length > 0) return true;
|
|
73
72
|
return false;
|
|
74
73
|
}
|
|
75
|
-
//#endregion
|
|
76
74
|
export { hasFindings as n, validateLine as r, aggregateReport as t };
|
|
77
75
|
|
|
78
|
-
//# sourceMappingURL=validate-
|
|
76
|
+
//# sourceMappingURL=validate-PqQ452Uy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-PqQ452Uy.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { entrySchemas, knownTypeSchema } from 'claude-code-jsonl-generator'\n\n/** 検出種別。 */\nexport type FindingKind =\n | 'no-type'\n | 'unknown-type'\n | 'schema-mismatch'\n | 'unknown-field'\n\n/** 1 件の検出。 */\nexport interface Finding {\n /** 対象 type (type 無しの場合は '<no-type>')。 */\n type: string\n kind: FindingKind\n /** unknown-field のときのフィールド名。 */\n field?: string\n message: string\n}\n\n/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */\nfunction knownKeysOf(type: string): Set<string> | undefined {\n const schema = (\n entrySchemas as Record<string, { shape?: Record<string, unknown> } | undefined>\n )[type]\n return schema?.shape ? new Set(Object.keys(schema.shape)) : undefined\n}\n\n/**\n * 1 行 (パース済み JSON) を検証して findings を返す。\n *\n * @param obj - パース済みの生 JSON\n */\nexport function validateLine(obj: unknown): Finding[] {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [{ type: '<no-type>', kind: 'no-type', message: 'not a JSON object' }]\n }\n const record = obj as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string') {\n return [{ type: '<no-type>', kind: 'no-type', message: 'missing string \"type\"' }]\n }\n\n const findings: Finding[] = []\n const schema = knownTypeSchema(type)\n if (schema === undefined) {\n return [{ type, kind: 'unknown-type', message: `unknown type \"${type}\"` }]\n }\n\n // スキーマ検証 (必須欠落・型不一致)\n const parsed = schema.safeParse(record)\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n findings.push({\n type,\n kind: 'schema-mismatch',\n field: issue.path.join('.') || undefined,\n message: `${issue.path.join('.')}: ${issue.message}`,\n })\n }\n }\n\n // 未知フィールド検出 (スキーマが列挙するキー以外)\n const known = knownKeysOf(type)\n if (known) {\n for (const key of Object.keys(record)) {\n if (!known.has(key)) {\n findings.push({\n type,\n kind: 'unknown-field',\n field: key,\n message: `unknown field \"${key}\" on type \"${type}\"`,\n })\n }\n }\n }\n\n return findings\n}\n\n/**\n * findings を type ごとに集計する。\n *\n * @param findings - 全 findings\n */\nexport function aggregateReport(findings: Finding[]): Map<string, Finding[]> {\n const report = new Map<string, Finding[]>()\n // eslint-disable-next-line unicorn/prefer-group-by -- Map.groupBy は ES2024 であり、公開パッケージの lib ターゲット (ES2023) を変えないため\n for (const f of findings) {\n const bucket = report.get(f.type) ?? []\n bucket.push(f)\n report.set(f.type, bucket)\n }\n return report\n}\n\n/**\n * レポートに 1 件でも finding があれば true。\n *\n * @param report - 集計済みレポート\n */\nexport function hasFindings(report: Map<string, Finding[]>): boolean {\n for (const bucket of report.values()) {\n if (bucket.length > 0) return true\n }\n return false\n}\n"],"mappings":";;;AAoBA,SAAS,YAAY,MAAuC;CAC1D,MAAM,SACJ,aACA;CACF,OAAO,QAAQ,QAAQ,IAAI,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC,IAAI,KAAA;AAC9D;;;;;;AAOA,SAAgB,aAAa,KAAyB;CACpD,IAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,GAAG,GAC9D,OAAO,CAAC;EAAE,MAAM;EAAa,MAAM;EAAW,SAAS;CAAoB,CAAC;CAE9E,MAAM,SAAS;CACf,MAAM,OAAO,OAAO;CACpB,IAAI,OAAO,SAAS,UAClB,OAAO,CAAC;EAAE,MAAM;EAAa,MAAM;EAAW,SAAS;CAAwB,CAAC;CAGlF,MAAM,WAAsB,CAAC;CAC7B,MAAM,SAAS,gBAAgB,IAAI;CACnC,IAAI,WAAW,KAAA,GACb,OAAO,CAAC;EAAE;EAAM,MAAM;EAAgB,SAAS,iBAAiB,KAAK;CAAG,CAAC;CAI3E,MAAM,SAAS,OAAO,UAAU,MAAM;CACtC,IAAI,CAAC,OAAO,SACV,KAAK,MAAM,SAAS,OAAO,MAAM,QAC/B,SAAS,KAAK;EACZ;EACA,MAAM;EACN,OAAO,MAAM,KAAK,KAAK,GAAG,KAAK,KAAA;EAC/B,SAAS,GAAG,MAAM,KAAK,KAAK,GAAG,EAAE,IAAI,MAAM;CAC7C,CAAC;CAKL,MAAM,QAAQ,YAAY,IAAI;CAC9B,IAAI,OACG;OAAA,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IAAI,CAAC,MAAM,IAAI,GAAG,GAChB,SAAS,KAAK;GACZ;GACA,MAAM;GACN,OAAO;GACP,SAAS,kBAAkB,IAAI,aAAa,KAAK;EACnD,CAAC;CAAA;CAKP,OAAO;AACT;;;;;;AAOA,SAAgB,gBAAgB,UAA6C;CAC3E,MAAM,yBAAS,IAAI,IAAuB;CAE1C,KAAK,MAAM,KAAK,UAAU;EACxB,MAAM,SAAS,OAAO,IAAI,EAAE,IAAI,KAAK,CAAC;EACtC,OAAO,KAAK,CAAC;EACb,OAAO,IAAI,EAAE,MAAM,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAyC;CACnE,KAAK,MAAM,UAAU,OAAO,OAAO,GACjC,IAAI,OAAO,SAAS,GAAG,OAAO;CAEhC,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-jsonl-validator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-beta.1",
|
|
4
4
|
"description": "Regression-check real Claude Code JSONL corpora against known schemas",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"claude-code-jsonl-generator": "0.1.
|
|
41
|
+
"claude-code-jsonl-generator": "0.1.4-beta.1",
|
|
42
42
|
"zod": "4.6.7"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-D3RwKa-F.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { entrySchemas, knownTypeSchema } from 'claude-code-jsonl-generator'\n\n/** 検出種別。 */\nexport type FindingKind =\n | 'no-type'\n | 'unknown-type'\n | 'schema-mismatch'\n | 'unknown-field'\n\n/** 1 件の検出。 */\nexport interface Finding {\n /** 対象 type (type 無しの場合は '<no-type>')。 */\n type: string\n kind: FindingKind\n /** unknown-field のときのフィールド名。 */\n field?: string\n message: string\n}\n\n/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */\nfunction knownKeysOf(type: string): Set<string> | undefined {\n const schema = (\n entrySchemas as Record<string, { shape?: Record<string, unknown> } | undefined>\n )[type]\n if (!schema?.shape) return undefined\n return new Set(Object.keys(schema.shape))\n}\n\n/**\n * 1 行 (パース済み JSON) を検証して findings を返す。\n *\n * @param obj - パース済みの生 JSON\n */\nexport function validateLine(obj: unknown): Finding[] {\n const findings: Finding[] = []\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [{ type: '<no-type>', kind: 'no-type', message: 'not a JSON object' }]\n }\n const record = obj as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string') {\n return [{ type: '<no-type>', kind: 'no-type', message: 'missing string \"type\"' }]\n }\n\n const schema = knownTypeSchema(type)\n if (schema === undefined) {\n return [{ type, kind: 'unknown-type', message: `unknown type \"${type}\"` }]\n }\n\n // スキーマ検証 (必須欠落・型不一致)\n const parsed = schema.safeParse(record)\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n findings.push({\n type,\n kind: 'schema-mismatch',\n field: issue.path.join('.') || undefined,\n message: `${issue.path.join('.')}: ${issue.message}`,\n })\n }\n }\n\n // 未知フィールド検出 (スキーマが列挙するキー以外)\n const known = knownKeysOf(type)\n if (known) {\n for (const key of Object.keys(record)) {\n if (!known.has(key)) {\n findings.push({\n type,\n kind: 'unknown-field',\n field: key,\n message: `unknown field \"${key}\" on type \"${type}\"`,\n })\n }\n }\n }\n\n return findings\n}\n\n/**\n * findings を type ごとに集計する。\n *\n * @param findings - 全 findings\n */\nexport function aggregateReport(findings: Finding[]): Map<string, Finding[]> {\n const report = new Map<string, Finding[]>()\n for (const f of findings) {\n const bucket = report.get(f.type) ?? []\n bucket.push(f)\n report.set(f.type, bucket)\n }\n return report\n}\n\n/**\n * レポートに 1 件でも finding があれば true。\n *\n * @param report - 集計済みレポート\n */\nexport function hasFindings(report: Map<string, Finding[]>): boolean {\n for (const bucket of report.values()) {\n if (bucket.length > 0) return true\n }\n return false\n}\n"],"mappings":";;;AAoBA,SAAS,YAAY,MAAuC;CAC1D,MAAM,SACJ,aACA;CACF,IAAI,CAAC,QAAQ,OAAO,OAAO,KAAA;CAC3B,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;AAC1C;;;;;;AAOA,SAAgB,aAAa,KAAyB;CACpD,MAAM,WAAsB,CAAC;CAC7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,GAAG,GAC9D,OAAO,CAAC;EAAE,MAAM;EAAa,MAAM;EAAW,SAAS;CAAoB,CAAC;CAE9E,MAAM,SAAS;CACf,MAAM,OAAO,OAAO;CACpB,IAAI,OAAO,SAAS,UAClB,OAAO,CAAC;EAAE,MAAM;EAAa,MAAM;EAAW,SAAS;CAAwB,CAAC;CAGlF,MAAM,SAAS,gBAAgB,IAAI;CACnC,IAAI,WAAW,KAAA,GACb,OAAO,CAAC;EAAE;EAAM,MAAM;EAAgB,SAAS,iBAAiB,KAAK;CAAG,CAAC;CAI3E,MAAM,SAAS,OAAO,UAAU,MAAM;CACtC,IAAI,CAAC,OAAO,SACV,KAAK,MAAM,SAAS,OAAO,MAAM,QAC/B,SAAS,KAAK;EACZ;EACA,MAAM;EACN,OAAO,MAAM,KAAK,KAAK,GAAG,KAAK,KAAA;EAC/B,SAAS,GAAG,MAAM,KAAK,KAAK,GAAG,EAAE,IAAI,MAAM;CAC7C,CAAC;CAKL,MAAM,QAAQ,YAAY,IAAI;CAC9B,IAAI,OACG;OAAA,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IAAI,CAAC,MAAM,IAAI,GAAG,GAChB,SAAS,KAAK;GACZ;GACA,MAAM;GACN,OAAO;GACP,SAAS,kBAAkB,IAAI,aAAa,KAAK;EACnD,CAAC;CAAA;CAKP,OAAO;AACT;;;;;;AAOA,SAAgB,gBAAgB,UAA6C;CAC3E,MAAM,yBAAS,IAAI,IAAuB;CAC1C,KAAK,MAAM,KAAK,UAAU;EACxB,MAAM,SAAS,OAAO,IAAI,EAAE,IAAI,KAAK,CAAC;EACtC,OAAO,KAAK,CAAC;EACb,OAAO,IAAI,EAAE,MAAM,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAyC;CACnE,KAAK,MAAM,UAAU,OAAO,OAAO,GACjC,IAAI,OAAO,SAAS,GAAG,OAAO;CAEhC,OAAO;AACT"}
|