claude-code-jsonl-validator 0.1.4-beta.24 → 0.1.4-beta.26

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
@@ -1,41 +1,46 @@
1
1
  # claude-code-jsonl-validator
2
2
 
3
- 実際の Claude Code JSONL コーパスを、`claude-code-jsonl-parser` が持つ既知スキーマに対して回帰検証する CLI / ライブラリ。
3
+ A CLI and library that regression-checks real Claude Code JSONL corpora against the known schemas (the zod schemas exported by `claude-code-jsonl-generator`).
4
4
 
5
5
  ## ✨ Features
6
6
 
7
- - **リグレッション検出専用** — 既知スキーマから外れた行を検出し、集計付きで報告する
8
- - **CLI 1 本で完結** — コーパスのディレクトリを指定するだけ
9
- - **CI との統合を想定** — 検出時は非 0 の終了コードを返すため、そのまま CI のゲートに使える
10
- - **プログラムからの利用も可能** — 1 行分の検証・集計処理を個別に import できる
7
+ - **Regression detection only**: finds lines that deviate from the known schemas and reports them with counts
8
+ - **One CLI**: just pass the corpus directory
9
+ - **Made for CI**: exits with a non-zero code when a regression is found, so it can gate CI as is
10
+ - **Programmatic use**: validate one line and aggregate findings with separate imports
11
11
 
12
- ## 📦 インストール
12
+ ## 📦 Installation
13
13
 
14
14
  ```bash
15
15
  npm install --save-dev claude-code-jsonl-validator
16
16
  ```
17
17
 
18
- ## 🚀 CLI の使い方
18
+ ## 🚀 CLI usage
19
19
 
20
20
  ```bash
21
21
  npx claude-code-jsonl-validator /path/to/jsonl-corpus
22
22
  ```
23
23
 
24
- 指定したディレクトリ以下の `.jsonl` ファイルを再帰的に読み込み、各行を検証する。
25
- JSON 構文エラーの行はパーサー側の責務のため無視される。
24
+ Reads every `.jsonl` file under the given directory recursively and validates each line.
25
+ Lines with a JSON syntax error are ignored, because they are the parser's concern.
26
+ Running it without a directory prints a usage message and exits with code 2.
26
27
 
27
- - リグレッションが無い場合: `No regressions. All lines match known schemas.` を表示し、終了コード `0`
28
- - リグレッションがある場合: `type` ごとに検出件数・種別・代表例を表示し、終了コード `1`
28
+ - No regressions: prints `No regressions. All lines match known schemas.` and exits with `0`
29
+ - Regressions found: prints the number of findings, the kinds and up to 5 sample messages per `type`, then exits with `1`
30
+
31
+ A finding has one of four kinds: `no-type` (not an object, or no string `type`), `unknown-type` (no schema for the type), `schema-mismatch` (a required field is missing or has the wrong type), and `unknown-field` (a top-level key the schema does not list).
29
32
 
30
33
  ```
31
- [assistant] 3 finding(s)
32
- schema-mismatch: 3
33
- - uuid: Required
34
+ [mode] 2 finding(s)
35
+ schema-mismatch: 1
36
+ unknown-field: 1
37
+ - mode: Invalid input: expected string, received undefined
38
+ - unknown field "brandNewField" on type "mode"
34
39
 
35
40
  Regression detected. See findings above.
36
41
  ```
37
42
 
38
- ## 📖 プログラムからの利用 (上級者向け)
43
+ ## 📖 Programmatic use (advanced)
39
44
 
40
45
  ```ts
41
46
  import { validateLine, aggregateReport, hasFindings } from 'claude-code-jsonl-validator'
@@ -43,16 +48,16 @@ import { validateLine, aggregateReport, hasFindings } from 'claude-code-jsonl-va
43
48
  const findings = validateLine(JSON.parse(rawLine))
44
49
  const report = aggregateReport(findings)
45
50
  if (hasFindings(report)) {
46
- // type ごとの Finding[] が report に集約されている
51
+ // report groups the Finding[] by type
47
52
  }
48
53
  ```
49
54
 
50
- | エクスポート | 用途 |
55
+ | Export | Purpose |
51
56
  | --- | --- |
52
- | `validateLine(obj)` | パース済み 1 行分のオブジェクトを検証し `Finding[]` を返す |
53
- | `aggregateReport(findings)` | `Finding[]` を `type` ごとに集約する |
54
- | `hasFindings(report)` | 集約結果に 1 件でも `Finding` があるかを判定する |
57
+ | `validateLine(obj)` | Validates one parsed object and returns a `Finding[]` |
58
+ | `aggregateReport(findings)` | Groups a `Finding[]` by `type` into a `Map` |
59
+ | `hasFindings(report)` | Tells whether the aggregated report contains at least one `Finding` |
55
60
 
56
- ## 📑 ライセンス
61
+ ## 📑 License
57
62
 
58
- このプロジェクトは [MIT License](./LICENSE) の下で公開されている。
63
+ This project is released under the [MIT License](./LICENSE).
package/dist/cli.cjs CHANGED
@@ -20,14 +20,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- const require_validate = require("./validate-CpJSBIyD.cjs");
23
+ const require_validate = require("./validate-ssJkhCcu.cjs");
24
24
  let node_fs = require("node:fs");
25
25
  let node_fs_promises = require("node:fs/promises");
26
26
  let node_readline = require("node:readline");
27
27
  let node_path = require("node:path");
28
28
  node_path = __toESM(node_path, 1);
29
29
  // src/cli.ts
30
- /** `.jsonl` を再帰収集する。 */
30
+ /** Recursively collects `.jsonl` files. */
31
31
  async function collectJsonl(dir) {
32
32
  const out = [];
33
33
  const entries = await (0, node_fs_promises.readdir)(dir);
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-PqQ452Uy.js";
2
+ import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-B4LNzB8k.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
- /** `.jsonl` を再帰収集する。 */
8
+ /** Recursively collects `.jsonl` files. */
9
9
  async function collectJsonl(dir) {
10
10
  const out = [];
11
11
  const entries = await readdir(dir);
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 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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UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
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/** Recursively collects `.jsonl` files. */\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 // Syntax errors are the parser's concern; ignore them here\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 // Show a few representative messages\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: un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,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-CpJSBIyD.cjs");
2
+ const require_validate = require("./validate-ssJkhCcu.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,30 +1,30 @@
1
- /** 検出種別。 */
1
+ /** Kind of finding. */
2
2
  type FindingKind = 'no-type' | 'unknown-type' | 'schema-mismatch' | 'unknown-field';
3
- /** 1 件の検出。 */
3
+ /** One finding. */
4
4
  interface Finding {
5
- /** 対象 type (type 無しの場合は '<no-type>')。 */
5
+ /** Target type (`'<no-type>'` if the line has none). */
6
6
  type: string;
7
7
  kind: FindingKind;
8
- /** unknown-field のときのフィールド名。 */
8
+ /** Field name for `unknown-field` (and the issue path for `schema-mismatch`). */
9
9
  field?: string;
10
10
  message: string;
11
11
  }
12
12
  /**
13
- * 1 行 (パース済み JSON) を検証して findings を返す。
13
+ * Validates one line (parsed JSON) and returns its findings.
14
14
  *
15
- * @param obj - パース済みの生 JSON
15
+ * @param obj - Parsed raw JSON
16
16
  */
17
17
  export declare function validateLine(obj: unknown): Finding[];
18
18
  /**
19
- * findings を type ごとに集計する。
19
+ * Groups findings by type.
20
20
  *
21
- * @param findings - 全 findings
21
+ * @param findings - All findings
22
22
  */
23
23
  export declare function aggregateReport(findings: Finding[]): Map<string, Finding[]>;
24
24
  /**
25
- * レポートに 1 件でも finding があれば true。
25
+ * Returns true if the report contains at least one finding.
26
26
  *
27
- * @param report - 集計済みレポート
27
+ * @param report - Aggregated report
28
28
  */
29
29
  export declare function hasFindings(report: Map<string, Finding[]>): boolean;
30
30
  export type { Finding, FindingKind };
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAkD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAgBlD,YAAY,QAAQ,YAAY"}
package/dist/index.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- /** 検出種別。 */
1
+ /** Kind of finding. */
2
2
  type FindingKind = 'no-type' | 'unknown-type' | 'schema-mismatch' | 'unknown-field';
3
- /** 1 件の検出。 */
3
+ /** One finding. */
4
4
  interface Finding {
5
- /** 対象 type (type 無しの場合は '<no-type>')。 */
5
+ /** Target type (`'<no-type>'` if the line has none). */
6
6
  type: string;
7
7
  kind: FindingKind;
8
- /** unknown-field のときのフィールド名。 */
8
+ /** Field name for `unknown-field` (and the issue path for `schema-mismatch`). */
9
9
  field?: string;
10
10
  message: string;
11
11
  }
12
12
  /**
13
- * 1 行 (パース済み JSON) を検証して findings を返す。
13
+ * Validates one line (parsed JSON) and returns its findings.
14
14
  *
15
- * @param obj - パース済みの生 JSON
15
+ * @param obj - Parsed raw JSON
16
16
  */
17
17
  export declare function validateLine(obj: unknown): Finding[];
18
18
  /**
19
- * findings を type ごとに集計する。
19
+ * Groups findings by type.
20
20
  *
21
- * @param findings - 全 findings
21
+ * @param findings - All findings
22
22
  */
23
23
  export declare function aggregateReport(findings: Finding[]): Map<string, Finding[]>;
24
24
  /**
25
- * レポートに 1 件でも finding があれば true。
25
+ * Returns true if the report contains at least one finding.
26
26
  *
27
- * @param report - 集計済みレポート
27
+ * @param report - Aggregated report
28
28
  */
29
29
  export declare function hasFindings(report: Map<string, Finding[]>): boolean;
30
30
  export type { Finding, FindingKind };
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAkD5B,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-PqQ452Uy.js";
1
+ export { t as aggregateReport, n as hasFindings, r as validateLine } from "./validate-B4LNzB8k.js";
@@ -1,14 +1,14 @@
1
1
  import { entrySchemas, knownTypeSchema } from "claude-code-jsonl-generator";
2
2
  // src/validate.ts
3
- /** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
3
+ /** Returns the top-level keys declared by the schema of a known type. */
4
4
  function knownKeysOf(type) {
5
5
  const schema = entrySchemas[type];
6
6
  return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
7
7
  }
8
8
  /**
9
- * 1 行 (パース済み JSON) を検証して findings を返す。
9
+ * Validates one line (parsed JSON) and returns its findings.
10
10
  *
11
- * @param obj - パース済みの生 JSON
11
+ * @param obj - Parsed raw JSON
12
12
  */
13
13
  function validateLine(obj) {
14
14
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
@@ -49,9 +49,9 @@ function validateLine(obj) {
49
49
  return findings;
50
50
  }
51
51
  /**
52
- * findings を type ごとに集計する。
52
+ * Groups findings by type.
53
53
  *
54
- * @param findings - 全 findings
54
+ * @param findings - All findings
55
55
  */
56
56
  function aggregateReport(findings) {
57
57
  const report = /* @__PURE__ */ new Map();
@@ -63,9 +63,9 @@ function aggregateReport(findings) {
63
63
  return report;
64
64
  }
65
65
  /**
66
- * レポートに 1 件でも finding があれば true。
66
+ * Returns true if the report contains at least one finding.
67
67
  *
68
- * @param report - 集計済みレポート
68
+ * @param report - Aggregated report
69
69
  */
70
70
  function hasFindings(report) {
71
71
  for (const bucket of report.values()) if (bucket.length > 0) return true;
@@ -73,4 +73,4 @@ function hasFindings(report) {
73
73
  }
74
74
  export { hasFindings as n, validateLine as r, aggregateReport as t };
75
75
 
76
- //# sourceMappingURL=validate-PqQ452Uy.js.map
76
+ //# sourceMappingURL=validate-B4LNzB8k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-B4LNzB8k.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { entrySchemas, knownTypeSchema } from 'claude-code-jsonl-generator'\n\n/** Kind of finding. */\nexport type FindingKind =\n | 'no-type'\n | 'unknown-type'\n | 'schema-mismatch'\n | 'unknown-field'\n\n/** One finding. */\nexport interface Finding {\n /** Target type (`'<no-type>'` if the line has none). */\n type: string\n kind: FindingKind\n /** Field name for `unknown-field` (and the issue path for `schema-mismatch`). */\n field?: string\n message: string\n}\n\n/** Returns the top-level keys declared by the schema of a known 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 * Validates one line (parsed JSON) and returns its findings.\n *\n * @param obj - Parsed raw 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 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 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 * Groups findings by type.\n *\n * @param findings - All 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 is ES2024; avoid changing the lib target (ES2023) of the published package\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 * Returns true if the report contains at least one finding.\n *\n * @param report - Aggregated 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,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M,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAyC;CACnE,KAAK,MAAM,UAAU,OAAO,OAAO,GACjC,IAAI,OAAO,SAAS,GAAG,OAAO;CAEhC,OAAO;AACT"}
@@ -1,14 +1,14 @@
1
1
  let claude_code_jsonl_generator = require("claude-code-jsonl-generator");
2
2
  // src/validate.ts
3
- /** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
3
+ /** Returns the top-level keys declared by the schema of a known type. */
4
4
  function knownKeysOf(type) {
5
5
  const schema = claude_code_jsonl_generator.entrySchemas[type];
6
6
  return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
7
7
  }
8
8
  /**
9
- * 1 行 (パース済み JSON) を検証して findings を返す。
9
+ * Validates one line (parsed JSON) and returns its findings.
10
10
  *
11
- * @param obj - パース済みの生 JSON
11
+ * @param obj - Parsed raw JSON
12
12
  */
13
13
  function validateLine(obj) {
14
14
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
@@ -49,9 +49,9 @@ function validateLine(obj) {
49
49
  return findings;
50
50
  }
51
51
  /**
52
- * findings を type ごとに集計する。
52
+ * Groups findings by type.
53
53
  *
54
- * @param findings - 全 findings
54
+ * @param findings - All findings
55
55
  */
56
56
  function aggregateReport(findings) {
57
57
  const report = /* @__PURE__ */ new Map();
@@ -63,9 +63,9 @@ function aggregateReport(findings) {
63
63
  return report;
64
64
  }
65
65
  /**
66
- * レポートに 1 件でも finding があれば true。
66
+ * Returns true if the report contains at least one finding.
67
67
  *
68
- * @param report - 集計済みレポート
68
+ * @param report - Aggregated report
69
69
  */
70
70
  function hasFindings(report) {
71
71
  for (const bucket of report.values()) if (bucket.length > 0) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-jsonl-validator",
3
- "version": "0.1.4-beta.24",
3
+ "version": "0.1.4-beta.26",
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.4-beta.24",
41
+ "claude-code-jsonl-generator": "0.1.4-beta.26",
42
42
  "zod": "4.6.7"
43
43
  },
44
44
  "scripts": {
@@ -1 +0,0 @@
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;CAA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