Claude/update jsonic library gj8 zb#5
Conversation
- Replace @hapi/code's expect with a tiny node:assert-based shim supporting the .equal/.exist/.throws fluent methods used in tests. Normalize null-prototype objects (jsonic returns these) to plain objects before deepStrictEqual to match hapi/code's looser semantics. - Remove @jsonic/doc and its 'doc' script; drop 'doc' from the repo-publish-quick pipeline. - All 9 tests pass.
- Add test/spec/ with TSV spec files per directive configuration: happy, subobj, close-foo, close-foo-bar, inject, adder, multiplier, annotate. Format: <input>\t<expected-json> or <input>\t!error <regex>. Blank and #-prefixed lines ignored. - Rewrite test/directive.test.ts to load & run specs; retain TS-only cases (implicit-list property access, xlog meta, NaN, specific error regex). - Rewrite go/directive_test.go to load & run the same specs and add TestInject, TestAnnotate, TestSubobj which now share the TS spec tables. - Include extra edge cases in the specs (nested containers, mixed bool/null/negative values, complex bodies, cross-directive nesting).
- README.md: landing page with a 4-quadrant index and quickstart snippets for TS and Go. - docs/tutorial.md: step-by-step walkthrough (install → first directive → add a close token) for both languages. - docs/how-to.md: task-oriented recipes (close tokens, shared close, scoped rules, conditions, option paths, custom callbacks, spec files, disabling defaults). - docs/reference.md: exhaustive API listing for TS and Go — options, types, defaults, token naming, group tags, counters, errors, spec format. - docs/explanation.md: conceptual discussion of the rule model, dr_<NAME> counter, implicit container guards, grammar-spec tagging, shared-close-token reuse, design principles.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfeead9944
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| scanner := bufio.NewScanner(f) | ||
| scanner.Buffer(make([]byte, 1024*1024), 1024*1024) | ||
| for scanner.Scan() { | ||
| line := scanner.Text() |
There was a problem hiding this comment.
Strip CR before parsing TSV rows
Normalize each scanned line before splitting so Windows/autocrlf checkouts don't leave a trailing \r in Expected. Right now scanner.Text() is used as-is, so cases like !error unexpected become !error unexpected\r, which can cause regex mismatch, and JSON expectations can fail to unmarshal; the TS loader in the same commit already handles this with replace(/\r$/, ''), so the Go loader is currently inconsistent and can produce platform-specific false test failures.
Useful? React with 👍 / 👎.
bufio.Scanner's Text() returns lines with the \r preserved on CRLF-terminated files, which happens when Windows / autocrlf checkouts re-encode the TSVs. That left expected columns like "!error unexpected\r", which then either failed to regex-match or failed JSON unmarshal, depending on the row. The TS loader already strips the trailing \r; mirror that in Go.
No description provided.