Repository navigation
fix: harden AI-friendly validation and game07 fallback for tables - #26
Merged
Merged
Conversation
… quick music/SFX toggles under settings; switch settings icon to sliders\n\n- Gate App auto-play by user-enabled flag from useBackgroundMusic\n- Expose in useBackgroundMusic and persist it\n- Only start BGM on AI start when enabled\n- Add two floating toggles (BGM/SFX) below settings button\n- Replace settings gear icon with sliders for clarity
…s (no hand-drawn SVG)
…t tasks; correct visual cleanup timing for counters (东山再起等)\n\n- add visualsActive to AI effect deps; cancel timers immediately\n- guard async decision/fallback against canceled tasks\n- defer processed marking for local auto stone until executed\n- tune useVisualEffects cleanup by role/effectId (counter-restore-board/instant-win/etc)
…user gesture; ensure SFX plays for skills via resumed context\n\n- useSoundEffects: context resume + user-gesture unlock; new 'draw-card' effect\n- App: play draw SFX when hand count increases
… SFX pitch; richer skill-specific sequences (mini-melodies)\n\n- App: detect pendingAction creation -> play 'play-card' sfx; per-side draw-card using role\n- SFX: add tone scheduling (seq/chord), enrich mappings (summon, restore, reverse, instant-win, etc.)
- Carry card tags/subtype into VisualEffectEvent for per-card SFX mapping
- Add variation pool for repeating skills; rotate sequences
- Spatialize SFX with StereoPanner based on board cell column
- Enrich playEffect to accept {tags, subtype, pan}; playForEvent wires them
… on tablets (touch devices with width >= 768)\n\n- Add MobileBlocker overlay\n- Add allowTapPlay path: CardView/HandPanel/PlayerHUD support hand click\n- App: device detection (pointer: coarse + width); pass onCardClick and allowTapPlay to PlayerHUD
…() for MobileBlocker to prevent invalid hook call; use static import
…rom in-game stage
…usively on Pad\n\n- HandPanel: when allowTapPlay, omit onDragStart/onDragEnd so CardView isn't draggable\n- PlayerHUD: show '轻点发动技能卡' hint when allowTapPlay
…CardPanel.CountdownCancel now tracks absolute end time and schedules timeout; no off-by-one (previously fired at ~6s)
… and blur; prevent background scroll; show on loading/error/Setup
- Show stand_kara.png on welcome (RulesIntroPanel) and mobile blocker - Use stand_kara (top-cropped) as player avatar; switch to skill5.png when 张兴朝在场; revert automatically on离场 - Skill visuals show card quote and skill5 image when casting '技能五' - Carry cardTid/quote in visual events
…or 技能五/See You Again effects\n\n- SkillEffectLayer: h-16~h-20 size, extraNote text per cardTid/effectId ('下一个回合开始合体技可以生效了' / '合体技失效了')
…/md:h-36 with stronger shadow)
…o BLACK's instant skill; wait full countdown (7s)\n\n- fallbacks.ts: in counter_window, if pending is BLACK && uiInstant, skip resolveCard(false,null) and let useAutoResolvePending fire
…hadow offset; no inline row layout
…n- Victory: warm border/halos, show stand_kara image\n- Defeat: cool border/halos, show AI stand.png\n- Keep draw neutral
…ffect layout/position of skill text
…n; ensure quote/text z-index above image
…or owner; set winner immediately if five-in-a-row formed
…- Clamp board-stage paddings by vh; enlarge board max-w to min(80vh,80vw)\n- Slightly shrink HUD/hand heights and widths on compact layouts\n- Tighten right column width range and grid gaps/paddings
…ft panel to bottom-right via clamp(right,bottom) and responsive width
…age; keep responsive paddings\n\n- Outer wrapper back to h-screen/overflow-hidden\n- Stage back to absolute inset-0; HUD absolute top/bottom\n- Keep clamp paddings for small heights
…hand panels further right, fix MusicToggle import; scaffold GameStageLayout component (not yet wired).
… description; add card list (source-of-truth from cards.csv); note merged Shichahai under Game Log; clarify Feisha effects.
…ve all cost mentions; clarify merged Shichahai location under Game Log.
…/图鉴/音乐开关/音效开关); wire Card Collection panel via trigger; enhance AI Settings panel with standing portraits, larger prompt with examples, and compact inputs.
…hesitation); targeting/counter/mulligan modest delays; ensure local auto-suggestion stone also delayed.
…overflow-visible) so edges aren’t clipped.
…endingCardPanel messaging\n\n- useAutoResolvePending: apply to any pending action in counter_window; resolve immediately if window already expired (handles background tab/clock jumps)\n- PendingCardPanel: show reaction UI only in counter_window; in card_targeting show '请选择技能目标' and hide cancel to avoid unsupported engine path; pass current phase from App
…line\n\n- SkillEffectLayer: show '对受的合体技被封印了, 哈哈哈嘻哈哈哈' when See You Again triggers
…flag\n\n- GameOverPanel: only render share block when localStorage['__DEBUG__'] is 'true' or '1'
… stones remain prominent\n\n- App: when targetRequest.type==='cell', raise board container z-index to sit between overlay (120) and confirm panel (130)
…ck AI actions during card_targeting\n\n- Board: in target mode, raise z-index only for occupied cells (stones), clear their cell background, and add an inner dim overlay over the board\n- App: previously raised board container above global overlay, now combined with inner dim, visually only stones stand out\n- AI: add strong state re-validation in decisions and fallbacks to prevent WHITE from acting during card_targeting/counter_window transitions
… show target highlights for AI (view-only); raise only stones above dim overlay; add pulsing ring on selected target for clarity in counter/confirm\n- App: disable interactive targeting when acting player is WHITE (AI)
…lobal fixed overlay ring + cloned stone above dim (z-128) when a target is selected (outside targeting phase); in targeting, selected cell uses higher z and strong ring\n- Board: compute target highlights for AI (view-only) and elevate only stones; keep grid dimmed
…bal overlay\n\n- App: remove conditional z-raise on board container during targeting\n- Board: portal-clone target candidates (and selected) as simplified stones above dim (z=128); inside board keep inner dim for mood only
…s use local fallback\n\n- openAiClient.hasValidSettings now requires endpoint+model+apiKey\n- requestAiDecision bails fast if navigator.offline or missing apiKey, so useAIActions falls back immediately\n- avoids long hangs/timeouts when network is unavailable
## Context - Before: CLI context loading and table failures lacked a stable machine-readable surface for agents and CI. - Change: The CLI now loads context consistently, exposes inspect and validate JSON flows, and serializers share stable payload construction. - Result: Single-file diagnostics and validation return parseable JSON with focused errors while existing export behavior remains covered. ## Key Facts - P0 Single-file `--inspect` and `--validate` emit JSON diagnostics and validation results, with context loading and preflight failures handled in machine-readable form. Key refs: src/exec.ts:30, src/exec.ts:149 - P1 `inspectTableFile` and `validateTableFile` expose reusable API diagnostics with sheet names, structured validation messages, and TID collision classification. Key refs: src/serializer/core/index.ts:14, src/serializer/core/index.ts:93 - P1 Serializer formats share stable convert payload construction while preserving TS omission rules for empty aliases and indexes. Key refs: src/serializer/core/convertPayload.ts:17, src/serializer/formats/ts.ts:23 - P2 CLI and API docs plus Jest coverage describe and exercise context loading, inspect JSON, validate JSON, and failure contracts. Key refs: docs-site/reference/cli.md:33, test/e2e/cli.e2e.test.ts:47 ## Validation - `npm run typecheck` passed. - `npm run build` passed. - `npm run test` passed with all suites and snapshots. ## Follow-ups - Add row, column, and field-path extraction for parser-originated validation messages. - Consider moving single-file context loading into a shared context path helper. [[BAGAKIT]] - GitMessageCraft: Protocol=bagakit.git-message-craft/v1
## Context - Before: the validation JSON path still had gaps for inaccessible input, incidental warnings, schema parser failures, and direct editor-friendly error context. - Change: machine-readable CLI mode now sanitizes preflight errors, captures warn output, classifies schema parser failures, and enriches validate errors with structured location and details. - Result: agents and CI can parse validation output across common failure modes without scraping logs or exposing local machine paths. ## Key Facts - P0 Machine-readable inspect and validate preflight now returns JSON for missing inputs and suppresses console warn noise under `--json`. Key refs: src/exec.ts:113, src/exec.ts:158 - P0 Schema parser failures are retained as `schema_error` diagnostics instead of collapsing into generic inspect failures. Key refs: src/serializer/core/index.ts:184, test/e2e/cli.e2e.test.ts:324 - P1 Validation errors now parse known convert messages into row, column, fieldPath, tableName, tid, policy, numeric, BigInt, and alias details. Key refs: src/serializer/core/validationErrorContext.ts:39, test/unit/serializer.core.test.ts:332 - P2 CLI/API docs describe the structured `location` and `details` contract for AI-friendly validation. Key refs: docs-site/reference/cli.md:67, docs-site/reference/api.md:48 ## Validation - `npm run typecheck` passed. - `npm run build -- --quiet && npx jest test/e2e/cli.e2e.test.ts --runInBand --coverage=false` passed. - `npx jest test/unit/serializer.core.test.ts --runInBand --coverage=false` passed. - `npm run test` passed with all suites and snapshots. - `bash skills/harness/bagakit-feature-tracker/scripts/feature-tracker.sh validate-tracker --root .` passed. ## Follow-ups - Consider introducing typed validation errors in convert internals so future parsing no longer depends on message text. - Consolidate CLI context file loading into a reusable helper if API callers need single-file context parity. [[BAGAKIT]] - GitMessageCraft: Protocol=bagakit.git-message-craft/v1
## Context - Before: the validation diagnostics hardening still had edge cases around context path sanitization, dotted TIDs, row targeting, and a misleading docs example. - Change: The CLI sanitizes parent directories from machine-mode errors, TID parsing preserves dotted IDs, missing-TID row numbers now match sheet rows, and docs show a valid failure JSON shape. - Result: validation JSON is safer to expose to agents and more reliable for editor jumps. ## Key Facts - P0 Machine-mode preflight sanitization now replaces input and context parent directories, covering context resolver errors that include base directories. Key refs: src/exec.ts:113, test/e2e/cli.e2e.test.ts:275 - P1 TID collision parsing keeps dotted IDs intact and is covered by a focused parser test. Key refs: src/serializer/core/validationErrorContext.ts:30, test/unit/serializer.core.test.ts:331 - P1 Missing TID errors now report the actual sheet row instead of the next row. Key refs: src/plugin/convert.ts:76, test/unit/serializer.core.test.ts:319 - P2 CLI docs now show a valid validation failure JSON example with details under the error entry. Key refs: docs-site/reference/cli.md:73 ## Validation - `npm run typecheck` passed. - `npx jest test/unit/serializer.core.test.ts test/unit/convert.fullCoverage.test.ts test/unit/convert.policy.test.ts --runInBand --coverage=false` passed. - `npm run build -- --quiet && npx jest test/e2e/cli.e2e.test.ts --runInBand --coverage=false` passed. - `npm run test` passed with all suites and snapshots. - `bash skills/harness/bagakit-feature-tracker/scripts/feature-tracker.sh validate-tracker --root .` passed. ## Follow-ups - Replace message parsing with typed validation errors when convert internals can expose structured failures directly. [[BAGAKIT]] - GitMessageCraft: Protocol=bagakit.git-message-craft/v1
## Context - Before: single context file loading lived only in the CLI, while API callers only had directory-oriented `loadContext`. - Change: Serializer core now exposes `loadContextPath` for directories, `context.<blob>.json` files, and full context JSON files, and the CLI delegates `--context` loading to it. - Result: future validation APIs can reuse one context-loading contract instead of duplicating CLI parsing rules. ## Key Facts - P0 `loadContextPath` centralizes context path loading and preserves `loadContext(dir)` behavior for existing callers. Key refs: src/serializer/core/index.ts:284, test/unit/serializer.core.test.ts:74 - P1 CLI `--context` now delegates to the shared serializer core helper. Key refs: src/exec.ts:13, src/exec.ts:76 - P2 README and API docs describe `loadContextPath` as the unified context entry point. Key refs: README.md:323, docs-site/reference/api.md:68 ## Validation - `npm run typecheck` passed. - `npx jest test/unit/serializer.core.test.ts --runInBand --coverage=false` passed. - `npm run build -- --quiet && npx jest test/e2e/cli.e2e.test.ts --runInBand --coverage=false` passed. - `npm run test` passed with all suites and snapshots. - `bash skills/harness/bagakit-feature-tracker/scripts/feature-tracker.sh validate-tracker --root .` passed. ## Follow-ups - Build typed validation failure metadata on top of the shared context-loading surface. - Keep phase-2 cross-table validation bounded before exposing broader project checks. [[BAGAKIT]] - GitMessageCraft: Protocol=bagakit.git-message-craft/v1
## Context - Follow-up from review of the shared context path loading change. - The CLI already accepts context directories, context blob files, and full context JSON files through the shared loader. ## Changes - Align CLI help text with the supported context input forms. - Clarify README guidance for directory auto-loading and explicit single-file context usage. ## Validation - npm run typecheck - git diff --check on targeted files - targeted leak scan for usernames, absolute paths, and timestamp-like strings ## Guardrails - Kept this as a documentation/help-only follow-up. - Did not touch unrelated staged example files.
## Context - Validation currently preserves convert failures mostly as message strings, then reconstructs row and details with parser fallbacks. - This change starts the phase-2 validation architecture by attaching structured metadata to convert-owned errors while preserving existing Error messages. ## Changes - Add shared validation location/detail types and a convert error metadata helper that attaches metadata to normal Error objects. - Attach metadata to missing TID, TID collision, numeric overflow, BigInt preservation, and alias validation failures. - Make inspect/validate preserve metadata and prefer it before falling back to message parsing. - Document structured convert metadata in the AI-friendly validation API notes. ## Validation - npm run typecheck - focused Jest coverage for convert internals, table convert edge cases, and serializer core validation - npm run test - tracker validation, diff whitespace check, and targeted leak scan ## Guardrails - Kept public thrown messages compatible. - Kept public validation codes stable except existing TID collision mapping. - Did not touch unrelated staged example files.
## Context - Review found typed convert metadata was attached as an enumerable Error property. - That preserved messages but could expose metadata through generic JSON logging. ## Changes - Attach convertErrorMeta with Object.defineProperty as a non-enumerable property. - Add focused coverage proving metadata remains accessible through the helper but absent from Object.keys and JSON output. ## Validation - npm run typecheck - npx jest test/unit/convertInternals.test.ts --runInBand --coverage=false - diff whitespace check and targeted leak scan ## Guardrails - Kept the typed metadata accessor behavior unchanged. - Did not touch unrelated staged example files.
## Context - Follow-up review found non-enumerable convertErrorMeta became non-writable by default. - That was stricter than the prior assignment-based property behavior. ## Changes - Mark convertErrorMeta as writable while keeping it non-enumerable. - Extend focused coverage to verify metadata can still be reassigned by consumers. ## Validation - npm run typecheck - npx jest test/unit/convertInternals.test.ts --runInBand --coverage=false - diff whitespace check and targeted leak scan ## Guardrails - Kept metadata hidden from enumeration and JSON output. - Did not touch unrelated staged example files.
## Context - Context enum refs can point at other tables, but validation reported many failures as generic preflight errors. - Phase-2 validation needs a bounded cross-table foundation without expanding into whole-project validation. ## Changes - Add context enum reference collection and structured validation for missing target tables and non-alias target fields. - Add validateContextReferences API and loadContextPath resolve options so refs can be checked before enum resolution mutates context. - Make CLI validate emit context_ref_error messages for supported context ref failures. - Document the new API and JSON error behavior for AI-friendly consumers. ## Validation - npm run typecheck - focused Jest coverage for context resolver and serializer core - CLI e2e validation after build - npm run test - tracker validation, diff whitespace check, and targeted leak scan ## Guardrails - Kept the scope to context.enums table refs. - Did not change table convert payloads or serializer outputs. - Did not touch unrelated staged example files.
## Context - Review found three context reference validation edge cases after the initial foundation commit. - Inspect mode should remain diagnostic-only, and machine-readable validation must avoid leaking user-supplied absolute refs. ## Changes - Keep context ref validation scoped to validate mode, so inspect can still return workbook diagnostics with unresolved context refs. - Sanitize string details in CLI validation errors, including user-supplied absolute table refs. - Return structured context_ref_error results when validateContextReferences(path) cannot load the context file. - Add focused unit and CLI e2e coverage for those review cases. ## Validation - npm run typecheck - npx jest test/unit/serializer.core.test.ts --runInBand --coverage=false - npm run build -- --quiet && npx jest test/e2e/cli.e2e.test.ts --runInBand --coverage=false - npm run test - tracker validation, diff whitespace check, and targeted leak scan ## Guardrails - Kept inspect behavior compatible. - Did not touch unrelated staged example files.
## Context - Review found context_ref_error details were sanitized, but messages could still include arbitrary absolute table refs supplied in context. ## Changes - Sanitize quoted and bare absolute path fragments in CLI validation messages down to basenames. - Keep structured details sanitized through the same basename helper. - Add CLI e2e coverage for absolute refs outside the context directory. ## Validation - npm run typecheck - npm run build -- --quiet && npx jest test/e2e/cli.e2e.test.ts --runInBand --coverage=false - npm run test - tracker validation, diff whitespace check, and targeted leak scan ## Guardrails - Kept machine-readable error shape unchanged. - Did not touch unrelated staged example files.
## Context Game07 AI fallback and UI helper paths needed a final merge gate pass before opening the master PR. The cloud client had its offline/api-key guard stranded outside the request path, and the example UI had several type drifts that kept its dedicated TypeScript check from passing. ## Key Facts - P0: Moved the offline/api-key guard into the cloud request path so callers can reliably fall back before network work starts (example/game_07_skill_gomoku/ui/src/ai/openAiClient.ts:117). - P1: Added a public game-rules action to the AI settings trigger and removed the private workspace link from the committed surface (example/game_07_skill_gomoku/ui/src/app/components/AiSettingsTrigger.tsx:20). - P1: Reconciled game07 UI type drift around replay payloads, router state, sound sequences, visual effect payloads, and card display variants (example/game_07_skill_gomoku/ui/src/app/utils/replay.ts:12). - P2: Kept the change scoped to the game07 UI example and avoided generated artifact churn. ## Validation - git diff --cached --check - staged leak scan for private links, absolute local paths, and secret-like tokens - npm run typecheck - npx tsc -p example/game_07_skill_gomoku/ui/tsconfig.json --noEmit - npm run test - npx vite --config example/game_07_skill_gomoku/vite.config.ts build --mode production --outDir <temp> [[BAGAKIT]] - GitMessageCraft: Protocol=bagakit.git-message-craft/v1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR moves the tables toolchain toward the next AI-friendly stage: richer validation diagnostics for table conversion/serialization, clearer CLI/context docs, and a hardened game07 example with reliable AI fallback and typed UI surfaces.
What Changed
Validation
git diff --cached --checknpm run typechecknpx tsc -p example/game_07_skill_gomoku/ui/tsconfig.json --noEmitnpm run testnpx vite --config example/game_07_skill_gomoku/vite.config.ts build --mode production --outDir <temp>Notes
origin/masterhas one newer commit than this branch; merge-base file-overlap check found no overlapping changed files.