324 Commits

Author SHA1 Message Date
xingyue 0d09e3cb80 Merge pull request 'feat: P3 JSON Schema support — not, contains, propertyNames, metadata (#82)' (#88) from feat/82-schema-p3 into main 2026-06-01 02:34:07 +00:00
xiaoju ca4fe8c3ac feat: P3 JSON Schema support — not, contains, propertyNames, metadata (#82)
Add 8 new schema keywords:

Combinators (with collectRefs support):
- not: negation schema
- contains: array must contain matching item

Constraints:
- propertyNames: constrain object key names

Metadata (no collectRefs impact):
- examples, readOnly, writeOnly, deprecated, $comment

Total supported keywords: 40 (of ~45 commonly used).
Only $ref/$defs/$id/$schema remain unsupported (P4, deferred).

516 tests, 0 fail.

Closes #82
2026-06-01 02:31:59 +00:00
xingyue 58f57b0dd8 Merge pull request 'feat: P2 JSON Schema support — allOf, if/then/else, patternProperties, prefixItems (#82)' (#87) from feat/82-schema-p2 into main 2026-06-01 02:15:35 +00:00
xiaoju edff831e87 feat: P2 JSON Schema support — allOf, if/then/else, patternProperties, prefixItems (#82)
Add 10 new schema keywords:

Combinators/conditionals (with collectRefs support):
- allOf: array of sub-schemas, all must match
- if/then/else: conditional validation
- patternProperties: regex-keyed property schemas
- prefixItems: tuple validation (per-position schemas)

Leaf constraints:
- multipleOf, minProperties, maxProperties, default

Updated: ALLOWED_SCHEMA_KEYS, isValidSchema(), collectRefs(),
meta-schema (bootstrap.ts), and schema-validation tests.

13 new tests: schema acceptance, validation, rejection,
and collectRefs traversal for allOf/patternProperties/prefixItems.

510 tests, 0 fail.

Refs #82
2026-06-01 02:10:37 +00:00
xingyue 054b5d9308 Merge pull request 'feat: put/hash support --pipe/-p to read JSON from stdin (#83)' (#85) from fix/83-put-hash-pipe into main 2026-06-01 01:54:28 +00:00
xingyue bdb77fd1e3 feat: put/hash support --pipe/-p to read JSON from stdin (#83) 2026-06-01 09:50:03 +08:00
xingyue b7fc03fa16 Merge pull request 'fix: CLI put @schema uses putSchema() for recursive validation (#82)' (#86) from fix/82-meta-schema-nested-validation into main 2026-06-01 01:39:49 +00:00
xiaoju 9367a4141a fix: CLI put @schema uses putSchema() for recursive validation (#82)
CLI 'ucas put @schema' now detects meta-schema target and routes
through putSchema() which uses isValidSchema() — a proper recursive
validator — instead of ajv against the meta-schema (which cannot
express recursive constraints for nested property sub-schemas).

This fixes the core issue where schemas with typed properties like
{"type":"string","minLength":1} were rejected by the CLI path.

Added CLI E2E test: put @schema with nested constraints (minLength,
maximum, uniqueItems).

494 tests, 0 fail.

Refs #82
2026-06-01 01:35:40 +00:00
xingyue bfec74fe8e Merge pull request 'feat: support P1 leaf JSON Schema constraints (#82)' (#84) from feat/82-schema-p1-leaf-constraints into main 2026-06-01 01:26:50 +00:00
xiaoju 70af05adf5 feat: support P1 leaf JSON Schema constraints (#82)
Add 10 new schema keywords to whitelist + meta-schema:
- numeric: minimum, maximum, exclusiveMinimum, exclusiveMaximum
- string: minLength, maxLength, pattern
- array: minItems, maxItems, uniqueItems

These are pure leaf constraints with no collectRefs() impact.
5 new tests covering validation, rejection, and nested usage.

Refs #82
2026-06-01 01:14:02 +00:00
xiaoju ceba0b5d43 chore: add prepublishOnly workspace:* guard
Checks for unresolved workspace:* dependencies before publish.
Changesets resolves these automatically, so normal release flow
passes through. Direct npm publish with workspace deps is blocked.
2026-05-31 23:43:51 +00:00
xiaoju a050160bee chore: remove prepublishOnly guards
Changesets already handles workspace:* → real version resolution
during publish. The guard scripts are unnecessary and block the
release flow.
2026-05-31 23:33:58 +00:00
xiaoju 515f4d32f9 chore: version 0.6.0 — unified envelope output (RFC #67) 2026-05-31 23:24:59 +00:00
xiaoju c03180e66c Merge pull request 'feat: wrap template commands with envelope, update docs (Phase 4)' (#81) from fix/72-template-envelope into main 2026-05-31 16:00:32 +00:00
xiaoju 9090456ed2 feat: wrap template commands with envelope, update docs (Phase 4)
Fixes #72
2026-05-31 16:00:21 +00:00
xiaoju 15ffff1fd4 Merge pull request 'feat: wrap refs/walk/gc/var with envelope (Phase 3)' (#80) from fix/71-refs-walk-var-envelope into main 2026-05-31 15:41:08 +00:00
xiaoju d2b9dee4b9 feat: wrap refs/walk/gc/var with {type,value} envelope (Phase 3)
Fixes #71
2026-05-31 15:41:02 +00:00
xiaoju 547c45829f Merge pull request 'feat: wrap simple commands with envelope (Phase 2)' (#79) from fix/70-simple-envelope into main 2026-05-31 15:29:54 +00:00
xiaoju d328fbe6e4 feat: wrap put/get/has/hash/verify/list with {type,value} envelope (Phase 2)
Fixes #70
2026-05-31 15:29:49 +00:00
xiaoju 11bb6b3e32 Merge pull request 'feat: register 18 @output/* schemas, default templates, wrapEnvelope (Phase 1c)' (#78) from fix/75-output-schemas into main 2026-05-31 15:14:49 +00:00
xiaoju 0dca8a5521 feat: register 18 @output/* schemas, default templates, wrapEnvelope (Phase 1c)
Fixes #75
2026-05-31 15:14:28 +00:00
xiaoju 5aad956c83 Merge pull request 'feat: remove cat/schema commands, add list --type, enhance verify (Phase 1b)' (#77) from fix/74-remove-cat-schema into main 2026-05-31 14:52:36 +00:00
xiaoju 038c901f4b feat: remove cat/schema commands, add list --type, enhance verify (Phase 1b)
Fixes #74
2026-05-31 14:41:38 +00:00
xiaoju f4cf92e128 Merge pull request 'feat: auto-bootstrap CAS store on open (Phase 1a)' (#76) from fix/73-auto-bootstrap into main
feat: auto-bootstrap CAS store on open (Phase 1a)

Fixes #73
2026-05-31 13:40:43 +00:00
xiaoju c8bf38cb81 feat: auto-bootstrap CAS store on open (Phase 1a)
Changes:
1. openStore() now async, auto-creates directory and bootstraps
2. Removed shouldCreate parameter and validateStoreExists()
3. All openStore() calls now awaited
4. Deleted init and bootstrap commands
5. Removed Issue #55 store validation tests (superseded by auto-bootstrap)
6. Enhanced error handling in openStore() for permission/path issues
7. Updated e2e snapshots after fixing missed await in cmdRender

Bootstrap is idempotent. Core tests using createMemoryStore() unaffected.

Fixes #73

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 13:34:43 +00:00
xingyue b93d7b229a Merge pull request 'feat(cli): convert e2e-check scenarios to snapshot fixture tests' (#68) from fix/66-e2e-snapshot-tests into main 2026-05-31 11:43:32 +00:00
xingyue 9912013b0a fix(cli): use dot notation for GC result assertions (Biome lint)
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-05-31 19:30:31 +08:00
xingyue 2ed097e207 fix(cli): make e2e snapshots stable across machines and runs
- Strip volatile fields (timestamp, created, updated) from JSON before
  snapshotting using a stripVolatile helper
- Remove toMatchSnapshot() from test 2.1 to avoid embedding machine-
  specific tmp paths in the snapshot; use toContain assertions instead
- Replace GC count snapshot with structural shape assertions so counts
  don't need to match exact phase-history state

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-05-31 19:29:25 +08:00
xingyue b0d5b05457 feat(cli): add e2e snapshot fixture tests for all CLI scenarios
Convert 46 e2e-check workflow scenarios to fast bun test snapshot tests.
7 describe phases share a single mkdtempSync store; hashes are deterministic
so cross-phase data dependencies work without re-creating data.

Closes #66

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-05-31 19:24:17 +08:00
xiaomo de20cfde53 Merge pull request 'refactor: e2e-check workflow 拆分为 4 角色' (#64) from fix/e2e-check-role-split into main 2026-05-31 10:58:50 +00:00
xingyue 9948db77ea refactor: split e2e-check workflow into 4 roles
- preparer: Docker setup, install, build, lint, unit test, init store
- tester: pure CLI scenario testing (receives container + store path)
- reporter: file Gitea issues (triggered by bugs or setup failures)
- cleanup: stop and remove Docker container

Also fixes template variable prefix (payload.name vs name).
2026-05-31 18:23:34 +08:00
xiaomo c60f05f650 Merge pull request 'fix: validate store directory exists before CLI operations' (#63) from fix/55-store-path-validation-rebase into main 2026-05-31 09:20:41 +00:00
xiaoju 314b076c05 fix: validate store path before read operations (Fixes #55)
- Add validateStoreExists() helper to check store directory existence
- Modify openStore() to accept shouldCreate parameter (default: false)
- Update read commands to validate store exists first
- Update write commands (init, put, schema put, hash) to allow creation
- Add 10 E2E tests covering all affected commands
- Improve error message: "Store not found at <path>" vs "Node not found"

Commands that now validate:
- get, has, verify, refs, walk, cat
- schema get, schema list

Commands that still create:
- init, put, schema put, hash
- var commands (use openVarStore)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 09:19:23 +00:00
xiaomo 664409b94a Merge pull request 'fix: workflow frontmatter schema 加 type: object' (#56) from fix/workflow-frontmatter-schema into main 2026-05-31 09:16:53 +00:00
xingyue f3f13e6f35 fix: add type: object to all oneOf variants in workflow frontmatter schemas
ajv strict mode requires explicit type: object when properties/required
are used. All three workflow YAMLs had this missing, causing frontmatter
validation to fail with:
  strict mode: missing type "object" for keyword "required"

Also added frontmatter output example in e2e-check.yaml procedure to
prevent agents from outputting bugs as plain strings instead of objects.
2026-05-31 17:15:43 +08:00
xiaomo 10c5c8f98e Merge pull request 'fix: clean error message for invalid schema in schema put command' (#61) from fix/54-schema-put-invalid-error into main 2026-05-31 09:15:37 +00:00
xiaomo d28003779e Merge pull request 'fix: detect missing root hash in render command' (#60) from fix/53-render-missing-hash-error into main 2026-05-31 09:15:35 +00:00
xiaomo 885a8e1147 Merge pull request 'test: add E2E template variable rendering tests' (#59) from fix/52-template-variable-rendering into main 2026-05-31 09:15:33 +00:00
xiaomo f0ffe6b234 Merge pull request 'fix: validate payload against schema in put command' (#57) from fix/50-schema-validation into main 2026-05-31 09:15:28 +00:00
xiaoju fc869cfc99 fix: resolve test failures for issue #53
Applied tester feedback to fix 5 test failures:

1. Updated error message format from "Node not found" to "CAS node not found"
   for consistency with existing tests in variable-store.test.ts and var.test.ts

2. Fixed CLI tests R9 and R10 to use bootstrap() directly instead of
   non-existent "types" command. Added imports for bootstrap and createFsStore.

3. Fixed render test 6.5 to pass actual schema Hash instead of entire
   bootstrap object (Record<string, Hash>)

4. Updated test expectations in render.test.ts (tests 1.5, 10.1, 10.2) to
   match new error message format

All 390 tests now pass. Core functionality verified:
- Missing root hash detection working correctly
- CLI exits with code 1 on missing hash
- Error message includes hash: "CAS node not found: <hash>"
- Nested nodes still render as cas: references (preserved behavior)
- Resolution decay behavior preserved

Fixes #53

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:36:19 +00:00
xiaoju 7fd2013ef2 fix: validate payload against schema in put command
Add schema validation to the `json-cas put` command to ensure data
integrity. The CLI now validates the payload against the specified
schema before storing, and exits with a non-zero code and descriptive
error message if validation fails.

Changes:
- Add schema existence check in cmdPut()
- Add payload validation before storing
- Exit with error code 1 on validation failure
- Provide helpful error messages indicating the file and schema
- Add comprehensive test suite with 16 test scenarios covering:
  - Valid data (regression tests)
  - Type mismatches (new validation)
  - Schema errors (edge cases)
  - Integration with existing features
  - Error message quality

The hash command continues to work without validation (dry-run
consistency), and schema put continues to use its own validation.

Fixes #50

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:24:13 +00:00
xiaoju 0b72c9400f style: apply biome formatting fixes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:21:10 +00:00
xiaoju eb36c16420 fix: detect missing root hash in render command and exit with error
When rendering a non-existent hash, the CLI now exits with code 1 and
displays an error message instead of silently outputting "cas:<hash>"
with exit code 0.

Changes:
- Updated CasNodeNotFoundError constructor signature to store hash
- Added root hash existence check in render() and renderAsync()
- Updated CLI error handling to catch CasNodeNotFoundError
- Added comprehensive test suite for missing hash error handling
- Updated existing incorrect tests (R2 and test 1.5)

The fix distinguishes between:
- Root hash (user-requested): Must exist or throw error
- Nested hash (during traversal): Renders as cas: reference (existing behavior)
- Resolution below epsilon: Renders as cas: reference (existing behavior)

Fixes #53

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:18:15 +00:00
xiaoju 3c8b16d7b1 fix: clean error message for invalid schema in schema put command
Fixes #54

The `json-cas schema put` command now catches SchemaValidationError
and displays a clean error message instead of showing a raw stack trace.

Changes:
- Import SchemaValidationError from @uncaged/json-cas
- Wrap putSchema() call in try-catch in cmdSchemaPut
- Catch SchemaValidationError specifically and call die(e.message)
- Add 5 comprehensive tests for invalid schema error handling

Test cases:
1. Invalid JSON Schema type value
2. Unknown schema keys
3. Invalid nested schema
4. Non-object root schema
5. Valid schema regression test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:14:23 +00:00
xiaoju 51e81c7b99 test: add E2E template variable rendering tests for issue #52
Add comprehensive test suite (Suite 9 and 10) covering template variable rendering:
- Suite 9: E2E Template Variable Rendering (12 tests)
  - Tests correct {{ payload.* }} syntax vs incorrect direct property access
  - Tests primitive payloads (string, number)
  - Tests nested objects, arrays, null values, booleans
  - Tests edge cases: empty strings, zero values, special characters
  - Validates CLI integration flow
- Suite 10: Context Variable Completeness (2 tests)
  - Verifies context propagation through recursive renders
  - Tests context isolation between parent and child nodes

All tests pass. Confirms the renderNode function correctly passes
node.payload to template context. Issue #52 was user error - templates
require {{ payload.name }} syntax, not {{ name }}.

Fixes #52

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-31 08:13:36 +00:00
xiaomo 2932aa5980 Merge pull request 'feat: ucas render --pipe/-p for stdin { type, value } input' (#49) from feat/48-render-pipe into main 2026-05-31 07:47:01 +00:00
xiaoju a0d7b67923 fix: address PR #49 review feedback
- Convention: renderDirect uses Store | null, options | null (no ?:)
- Validation: hash format check (13-char Crockford Base32) on stdin input
- DRY: remove collectRefsFromSchema, import collectRefs from schema.ts
- DRY: extract validateAndExtractOptions shared by render/renderAsync/renderDirect
- stdin: use process.stdin async iteration instead of /dev/stdin
- UX: error on --pipe + hash conflict instead of silent ignore
- Tests: add 9.10 (store present, schema missing)
2026-05-31 07:43:25 +00:00
xiaoju 7b29fe777c chore: remove stale temp files 2026-05-31 07:34:16 +00:00
xiaoju 64b8a88bdc feat: add renderDirect() and ucas render --pipe/-p
In-memory rendering of { type, value } envelopes without store writes.
Store is optional and read-only (for expanding nested cas_ref references).

CLI: ucas render --pipe/-p reads JSON from stdin.
Core: renderDirect(typeHash, value, store?, options?) for programmatic use.

Fixes #48
2026-05-31 07:34:07 +00:00
xiaoju 4717024e9b Merge pull request 'chore: Phase 4 cleanup — dedupe types, remove unused params, fix tests' (#47) from fix/46-phase4-cleanup into main 2026-05-31 07:19:42 +00:00