@litfamily/litgrok 1.0.0
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/.grok/agents/litgrok-executor.md +33 -0
- package/.grok/agents/litgrok-korean-prose-editor.md +32 -0
- package/.grok/agents/litgrok-korean-style-analyzer.md +30 -0
- package/.grok/agents/litgrok-librarian-researcher.md +31 -0
- package/.grok/agents/litgrok-meaning-preservation-auditor.md +30 -0
- package/.grok/agents/litgrok-native-flow-reviewer.md +30 -0
- package/.grok/agents/litgrok-planner.md +31 -0
- package/.grok/agents/litgrok-polish-orchestrator.md +30 -0
- package/.grok/agents/litgrok-qa-runner.md +33 -0
- package/.grok/agents/litgrok-quality-reviewer.md +33 -0
- package/.grok/agents/litgrok-verifier.md +32 -0
- package/.grok/hooks/deliverable-hedge-guard.json +16 -0
- package/.grok/hooks/deliverable-hedge-guard.mjs +148 -0
- package/.grok/hooks/lit-mark.mjs +142 -0
- package/.grok/hooks/plan-gate.mjs +81 -0
- package/.grok/hooks/post-compact.json +15 -0
- package/.grok/hooks/post-compact.mjs +6 -0
- package/.grok/hooks/post-tool-use-failure.json +15 -0
- package/.grok/hooks/post-tool-use-failure.mjs +6 -0
- package/.grok/hooks/post-tool-use.json +16 -0
- package/.grok/hooks/post-tool-use.mjs +7 -0
- package/.grok/hooks/pre-compact.json +15 -0
- package/.grok/hooks/pre-compact.mjs +6 -0
- package/.grok/hooks/record-passive-event.mjs +198 -0
- package/.grok/hooks/session-start.json +15 -0
- package/.grok/hooks/session-start.mjs +37 -0
- package/.grok/hooks/stop-failure.json +15 -0
- package/.grok/hooks/stop-failure.mjs +6 -0
- package/.grok/hooks/stop.json +15 -0
- package/.grok/hooks/stop.mjs +36 -0
- package/.grok/hooks/subagent-start.json +15 -0
- package/.grok/hooks/subagent-start.mjs +6 -0
- package/.grok/hooks/subagent-stop.json +15 -0
- package/.grok/hooks/subagent-stop.mjs +6 -0
- package/.grok/hooks/user-prompt-submit.json +15 -0
- package/.grok/hooks/user-prompt-submit.mjs +7 -0
- package/.grok/rules/00-litgrok.md +152 -0
- package/.grok/skills/autoconference/LICENSE +21 -0
- package/.grok/skills/autoconference/PROVENANCE.md +23 -0
- package/.grok/skills/autoconference/SKILL.md +140 -0
- package/.grok/skills/autoconference/assets/conference_template.md +76 -0
- package/.grok/skills/autoconference/assets/report_template.md +56 -0
- package/.grok/skills/autoconference/assets/synthesis_template.md +40 -0
- package/.grok/skills/autoconference/references/_canonical-corpus/manifest.json +138 -0
- package/.grok/skills/autoconference/references/agent-prompts.md +30 -0
- package/.grok/skills/autoconference/references/conference-protocol.md +21 -0
- package/.grok/skills/autoconference/references/core-principles.md +13 -0
- package/.grok/skills/autoconference/references/family-contract.md +26 -0
- package/.grok/skills/autoconference/references/modes/analyze.md +11 -0
- package/.grok/skills/autoconference/references/modes/core/convergence-guide.md +41 -0
- package/.grok/skills/autoconference/references/modes/core/crash-recovery.md +11 -0
- package/.grok/skills/autoconference/references/modes/core.md +26 -0
- package/.grok/skills/autoconference/references/modes/debate.md +11 -0
- package/.grok/skills/autoconference/references/modes/plan.md +12 -0
- package/.grok/skills/autoconference/references/modes/resume.md +11 -0
- package/.grok/skills/autoconference/references/modes/ship.md +11 -0
- package/.grok/skills/autoconference/references/modes/survey.md +11 -0
- package/.grok/skills/autoconference/references/results-logging.md +12 -0
- package/.grok/skills/autoconference/references/visualization-guide.md +10 -0
- package/.grok/skills/autoconference/scripts/init_conference.py +646 -0
- package/.grok/skills/autoconference/scripts/verify-canonical-corpus.mjs +177 -0
- package/.grok/skills/autoconference/templates/code-performance.md +59 -0
- package/.grok/skills/autoconference/templates/debate-mode.md +50 -0
- package/.grok/skills/autoconference/templates/prompt-optimization.md +58 -0
- package/.grok/skills/autoconference/templates/quick-conference.md +48 -0
- package/.grok/skills/autoconference/templates/research-synthesis.md +56 -0
- package/.grok/skills/autoconference/templates/survey-mode.md +63 -0
- package/.grok/skills/autoresearch/LICENSE +21 -0
- package/.grok/skills/autoresearch/PROVENANCE.md +22 -0
- package/.grok/skills/autoresearch/SKILL.md +149 -0
- package/.grok/skills/autoresearch/assets/report_template.md +52 -0
- package/.grok/skills/autoresearch/assets/research_template.md +38 -0
- package/.grok/skills/autoresearch/assets/results_template.tsv +2 -0
- package/.grok/skills/autoresearch/references/_canonical-corpus/manifest.json +148 -0
- package/.grok/skills/autoresearch/references/core-principles.md +16 -0
- package/.grok/skills/autoresearch/references/family-contract.md +36 -0
- package/.grok/skills/autoresearch/references/modes/core/evaluator-contract.md +12 -0
- package/.grok/skills/autoresearch/references/modes/core/stuck-detection.md +11 -0
- package/.grok/skills/autoresearch/references/modes/core.md +21 -0
- package/.grok/skills/autoresearch/references/modes/debug/investigation-techniques.md +11 -0
- package/.grok/skills/autoresearch/references/modes/debug.md +11 -0
- package/.grok/skills/autoresearch/references/modes/fix.md +11 -0
- package/.grok/skills/autoresearch/references/modes/learn.md +11 -0
- package/.grok/skills/autoresearch/references/modes/plan.md +14 -0
- package/.grok/skills/autoresearch/references/modes/predict/persona-templates.md +11 -0
- package/.grok/skills/autoresearch/references/modes/predict.md +11 -0
- package/.grok/skills/autoresearch/references/modes/reason.md +11 -0
- package/.grok/skills/autoresearch/references/modes/scenario/dimensions.md +11 -0
- package/.grok/skills/autoresearch/references/modes/scenario.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security/owasp-checklist.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security/stride-model.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security.md +12 -0
- package/.grok/skills/autoresearch/references/modes/ship/type-checklists.md +12 -0
- package/.grok/skills/autoresearch/references/modes/ship.md +11 -0
- package/.grok/skills/autoresearch/references/results-logging.md +12 -0
- package/.grok/skills/autoresearch/references/visualization-guide.md +24 -0
- package/.grok/skills/autoresearch/scripts/init_research.py +391 -0
- package/.grok/skills/autoresearch/scripts/style_presets.py +123 -0
- package/.grok/skills/autoresearch/scripts/verify-canonical-corpus.mjs +179 -0
- package/.grok/skills/browser-drive/SKILL.md +194 -0
- package/.grok/skills/browser-drive/references/snapshot-act-loop.md +61 -0
- package/.grok/skills/comment-checker/SKILL.md +194 -0
- package/.grok/skills/debugging/SKILL.md +82 -0
- package/.grok/skills/debugging/references/methodology/00-setup.md +108 -0
- package/.grok/skills/debugging/references/methodology/02-investigate.md +126 -0
- package/.grok/skills/debugging/references/methodology/04-oracle-triple.md +106 -0
- package/.grok/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/.grok/skills/debugging/references/methodology/06-fix.md +116 -0
- package/.grok/skills/debugging/references/methodology/08-qa.md +94 -0
- package/.grok/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/.grok/skills/debugging/references/methodology/partial-runtime-evidence.md +228 -0
- package/.grok/skills/debugging/references/post-tool-use-failure-taxonomy.md +55 -0
- package/.grok/skills/debugging/references/reproduction-recipes.md +182 -0
- package/.grok/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/.grok/skills/debugging/references/runtimes/go.md +252 -0
- package/.grok/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/.grok/skills/debugging/references/runtimes/node.md +260 -0
- package/.grok/skills/debugging/references/runtimes/python.md +248 -0
- package/.grok/skills/debugging/references/runtimes/rust.md +234 -0
- package/.grok/skills/debugging/references/tools/ghidra.md +212 -0
- package/.grok/skills/debugging/references/tools/playwright-cli.md +194 -0
- package/.grok/skills/debugging/references/tools/pwndbg.md +263 -0
- package/.grok/skills/debugging/references/tools/pwntools.md +265 -0
- package/.grok/skills/deep-interview/SKILL.md +216 -0
- package/.grok/skills/frontend-ui-ux/LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/PROVENANCE.json +38 -0
- package/.grok/skills/frontend-ui-ux/SKILL.md +58 -0
- package/.grok/skills/frontend-ui-ux/SOURCE-MANIFEST.json +1060 -0
- package/.grok/skills/frontend-ui-ux/THIRD-PARTY-NOTICE.txt +14 -0
- package/.grok/skills/frontend-ui-ux/data/design-intelligence.json +1 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-ATTRIBUTION.md +217 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-LICENSE-Apache-2.0.txt +201 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/root-LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/manifest.json +873 -0
- package/.grok/skills/frontend-ui-ux/references/adaptive-layout.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/brand-and-imagery.md +93 -0
- package/.grok/skills/frontend-ui-ux/references/complete-contract.md +557 -0
- package/.grok/skills/frontend-ui-ux/references/composition.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/creative-directions.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/design/README.md +248 -0
- package/.grok/skills/frontend-ui-ux/references/design/_INDEX.md +191 -0
- package/.grok/skills/frontend-ui-ux/references/design/airbnb.md +393 -0
- package/.grok/skills/frontend-ui-ux/references/design/airtable.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/design/apple.md +250 -0
- package/.grok/skills/frontend-ui-ux/references/design/aside.md +209 -0
- package/.grok/skills/frontend-ui-ux/references/design/binance.md +348 -0
- package/.grok/skills/frontend-ui-ux/references/design/bmw.md +183 -0
- package/.grok/skills/frontend-ui-ux/references/design/brutalist-skill.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/design/bugatti.md +271 -0
- package/.grok/skills/frontend-ui-ux/references/design/cal.md +262 -0
- package/.grok/skills/frontend-ui-ux/references/design/claude.md +315 -0
- package/.grok/skills/frontend-ui-ux/references/design/clay.md +307 -0
- package/.grok/skills/frontend-ui-ux/references/design/clickhouse.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/clone-from-url.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/design/cohere.md +269 -0
- package/.grok/skills/frontend-ui-ux/references/design/coinbase.md +132 -0
- package/.grok/skills/frontend-ui-ux/references/design/composio.md +310 -0
- package/.grok/skills/frontend-ui-ux/references/design/cursor.md +312 -0
- package/.grok/skills/frontend-ui-ux/references/design/design-system-architecture.md +244 -0
- package/.grok/skills/frontend-ui-ux/references/design/elevenlabs.md +268 -0
- package/.grok/skills/frontend-ui-ux/references/design/expo.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/ferrari.md +317 -0
- package/.grok/skills/frontend-ui-ux/references/design/figma.md +223 -0
- package/.grok/skills/frontend-ui-ux/references/design/framer.md +249 -0
- package/.grok/skills/frontend-ui-ux/references/design/gpt-tasteskill.md +74 -0
- package/.grok/skills/frontend-ui-ux/references/design/hashicorp.md +281 -0
- package/.grok/skills/frontend-ui-ux/references/design/ibm.md +335 -0
- package/.grok/skills/frontend-ui-ux/references/design/image-to-code-skill.md +1228 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-brandkit.md +798 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-frontend-mobile.md +1465 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-frontend-web.md +987 -0
- package/.grok/skills/frontend-ui-ux/references/design/intercom.md +149 -0
- package/.grok/skills/frontend-ui-ux/references/design/kraken.md +128 -0
- package/.grok/skills/frontend-ui-ux/references/design/lamborghini.md +291 -0
- package/.grok/skills/frontend-ui-ux/references/design/layout-skill.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/design/lazyweb.md +77 -0
- package/.grok/skills/frontend-ui-ux/references/design/linear.app.md +370 -0
- package/.grok/skills/frontend-ui-ux/references/design/lovable.md +301 -0
- package/.grok/skills/frontend-ui-ux/references/design/mastercard.md +368 -0
- package/.grok/skills/frontend-ui-ux/references/design/meta.md +369 -0
- package/.grok/skills/frontend-ui-ux/references/design/minimalist-skill.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/design/minimax.md +260 -0
- package/.grok/skills/frontend-ui-ux/references/design/mintlify.md +329 -0
- package/.grok/skills/frontend-ui-ux/references/design/miro.md +111 -0
- package/.grok/skills/frontend-ui-ux/references/design/mistral.ai.md +264 -0
- package/.grok/skills/frontend-ui-ux/references/design/mongodb.md +269 -0
- package/.grok/skills/frontend-ui-ux/references/design/nike.md +366 -0
- package/.grok/skills/frontend-ui-ux/references/design/notion.md +312 -0
- package/.grok/skills/frontend-ui-ux/references/design/nvidia.md +296 -0
- package/.grok/skills/frontend-ui-ux/references/design/ollama.md +270 -0
- package/.grok/skills/frontend-ui-ux/references/design/opencode.ai.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/output-skill.md +49 -0
- package/.grok/skills/frontend-ui-ux/references/design/pinterest.md +233 -0
- package/.grok/skills/frontend-ui-ux/references/design/playstation.md +367 -0
- package/.grok/skills/frontend-ui-ux/references/design/posthog.md +259 -0
- package/.grok/skills/frontend-ui-ux/references/design/raycast.md +271 -0
- package/.grok/skills/frontend-ui-ux/references/design/react-dev-tooling-skill.md +230 -0
- package/.grok/skills/frontend-ui-ux/references/design/redesign-skill.md +178 -0
- package/.grok/skills/frontend-ui-ux/references/design/renault.md +314 -0
- package/.grok/skills/frontend-ui-ux/references/design/replicate.md +264 -0
- package/.grok/skills/frontend-ui-ux/references/design/resend.md +306 -0
- package/.grok/skills/frontend-ui-ux/references/design/revolut.md +188 -0
- package/.grok/skills/frontend-ui-ux/references/design/runwayml.md +247 -0
- package/.grok/skills/frontend-ui-ux/references/design/sanity.md +360 -0
- package/.grok/skills/frontend-ui-ux/references/design/sentry.md +265 -0
- package/.grok/skills/frontend-ui-ux/references/design/shopify.md +353 -0
- package/.grok/skills/frontend-ui-ux/references/design/soft-skill.md +98 -0
- package/.grok/skills/frontend-ui-ux/references/design/spacex.md +197 -0
- package/.grok/skills/frontend-ui-ux/references/design/spotify.md +249 -0
- package/.grok/skills/frontend-ui-ux/references/design/starbucks.md +583 -0
- package/.grok/skills/frontend-ui-ux/references/design/stitch-design-example.md +121 -0
- package/.grok/skills/frontend-ui-ux/references/design/stitch-skill.md +184 -0
- package/.grok/skills/frontend-ui-ux/references/design/stripe.md +325 -0
- package/.grok/skills/frontend-ui-ux/references/design/supabase.md +258 -0
- package/.grok/skills/frontend-ui-ux/references/design/superhuman.md +255 -0
- package/.grok/skills/frontend-ui-ux/references/design/taste-skill.md +1206 -0
- package/.grok/skills/frontend-ui-ux/references/design/tesla.md +289 -0
- package/.grok/skills/frontend-ui-ux/references/design/theverge.md +342 -0
- package/.grok/skills/frontend-ui-ux/references/design/together.ai.md +266 -0
- package/.grok/skills/frontend-ui-ux/references/design/uber.md +298 -0
- package/.grok/skills/frontend-ui-ux/references/design/vercel.md +313 -0
- package/.grok/skills/frontend-ui-ux/references/design/vodafone.md +426 -0
- package/.grok/skills/frontend-ui-ux/references/design/voltagent.md +326 -0
- package/.grok/skills/frontend-ui-ux/references/design/warp.md +256 -0
- package/.grok/skills/frontend-ui-ux/references/design/webflow.md +95 -0
- package/.grok/skills/frontend-ui-ux/references/design/wired.md +281 -0
- package/.grok/skills/frontend-ui-ux/references/design/wise.md +176 -0
- package/.grok/skills/frontend-ui-ux/references/design/x.ai.md +260 -0
- package/.grok/skills/frontend-ui-ux/references/design/zapier.md +331 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/EVIDENCE.md +97 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/README.md +48 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/UPSTREAM.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-a-direction.md +64 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-b-execution.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-c-review.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-d-memory.md +83 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/orchestration.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/routing.md +79 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/accessibility-reviewer.md +83 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/content-writer.md +132 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-builder.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-critic.md +89 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-lead.md +113 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-scout.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-strategist.md +121 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/heuristic-evaluator.md +268 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/inspiration-scout.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/motion-designer.md +120 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/accessible-content/reference.md +101 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/adaptive-interfaces/reference.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/cognitive-accessibility/reference.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debate/reference.md +199 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debt-tracker/reference.md +174 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-handoff/reference.md +125 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-md/reference.md +106 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-retrospective/reference.md +266 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-review/reference.md +123 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-system-alignment/reference.md +120 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/designpowers-critique/reference.md +164 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/heuristic-evaluation/reference.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/inclusive-personas/reference.md +98 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/inspiration-scouting/reference.md +165 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/interaction-design/reference.md +122 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/motion-choreography/reference.md +81 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/research-planning/reference.md +96 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/responsive-patterns/reference.md +77 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/synthetic-user-testing/reference.md +192 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-feedback/reference.md +165 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-report/reference.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/token-architecture/reference.md +75 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/ui-composition/reference.md +117 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/usability-testing/reference.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/verification-before-shipping/reference.md +125 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/voice-and-tone/reference.md +79 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/writing-design-plans/reference.md +119 -0
- package/.grok/skills/frontend-ui-ux/references/evidence-review.md +126 -0
- package/.grok/skills/frontend-ui-ux/references/implementation-platforms.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/inclusive-interface.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/interaction-motion.md +101 -0
- package/.grok/skills/frontend-ui-ux/references/operating-lanes.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/perfection/README.md +160 -0
- package/.grok/skills/frontend-ui-ux/references/perfection/react-perf-tooling.md +127 -0
- package/.grok/skills/frontend-ui-ux/references/performance-delivery.md +93 -0
- package/.grok/skills/frontend-ui-ux/references/product-direction.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/redesign-playbook.md +97 -0
- package/.grok/skills/frontend-ui-ux/references/system-foundations.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/taste-direction.md +86 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/README.md +659 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/charts.csv +26 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/colors.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/icons.csv +106 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/landing.csv +35 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/products.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/react-performance.csv +45 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/styles.csv +85 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/typography.csv +74 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/web-interface.csv +31 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/core.py +262 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/search.py +114 -0
- package/.grok/skills/frontend-ui-ux/references/visual-language.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/visual-reconstruction.md +97 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1alpha1.schema.json +306 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1beta1.schema.json +291 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1beta2.schema.json +311 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-format.mjs +286 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-inventory-rules.mjs +354 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-rules.mjs +361 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-surface-rules.mjs +313 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-data.mjs +68 -0
- package/.grok/skills/frontend-ui-ux/scripts/errors.mjs +12 -0
- package/.grok/skills/frontend-ui-ux/scripts/import-design-intelligence.mjs +124 -0
- package/.grok/skills/frontend-ui-ux/scripts/json-boundary.mjs +63 -0
- package/.grok/skills/frontend-ui-ux/scripts/query-design-intelligence.mjs +106 -0
- package/.grok/skills/frontend-ui-ux/scripts/search.mjs +43 -0
- package/.grok/skills/frontend-ui-ux/scripts/source-replay.mjs +153 -0
- package/.grok/skills/frontend-ui-ux/scripts/strict-json.mjs +143 -0
- package/.grok/skills/frontend-ui-ux/scripts/validate-design-contract.mjs +52 -0
- package/.grok/skills/frontend-ui-ux/scripts/verify-canonical-corpus.mjs +214 -0
- package/.grok/skills/lit-burnoff/SKILL.md +175 -0
- package/.grok/skills/lit-burnoff-file/SKILL.md +67 -0
- package/.grok/skills/lit-code/SKILL.md +531 -0
- package/.grok/skills/lit-code/references/go/README.md +90 -0
- package/.grok/skills/lit-code/references/go/backend-stack.md +641 -0
- package/.grok/skills/lit-code/references/go/bootstrap.md +328 -0
- package/.grok/skills/lit-code/references/go/bubbletea-v2.md +360 -0
- package/.grok/skills/lit-code/references/go/cobra-stack.md +468 -0
- package/.grok/skills/lit-code/references/go/concurrency.md +362 -0
- package/.grok/skills/lit-code/references/go/data-modeling.md +329 -0
- package/.grok/skills/lit-code/references/go/error-handling.md +359 -0
- package/.grok/skills/lit-code/references/go/golangci-strict.md +236 -0
- package/.grok/skills/lit-code/references/go/grpc-connect.md +375 -0
- package/.grok/skills/lit-code/references/go/libraries.md +337 -0
- package/.grok/skills/lit-code/references/go/one-liners.md +202 -0
- package/.grok/skills/lit-code/references/go/sqlc-pgx.md +471 -0
- package/.grok/skills/lit-code/references/go/testing.md +467 -0
- package/.grok/skills/lit-code/references/go/type-patterns.md +298 -0
- package/.grok/skills/lit-code/references/permission-sandbox-matrix.md +70 -0
- package/.grok/skills/lit-code/references/python/README.md +314 -0
- package/.grok/skills/lit-code/references/python/async-anyio.md +442 -0
- package/.grok/skills/lit-code/references/python/data-modeling.md +233 -0
- package/.grok/skills/lit-code/references/python/data-processing.md +133 -0
- package/.grok/skills/lit-code/references/python/error-handling.md +218 -0
- package/.grok/skills/lit-code/references/python/fastapi-stack.md +316 -0
- package/.grok/skills/lit-code/references/python/httpx2-optimization.md +360 -0
- package/.grok/skills/lit-code/references/python/libraries.md +307 -0
- package/.grok/skills/lit-code/references/python/one-liners.md +268 -0
- package/.grok/skills/lit-code/references/python/orjson-stack.md +378 -0
- package/.grok/skills/lit-code/references/python/pydantic-ai.md +285 -0
- package/.grok/skills/lit-code/references/python/pyproject-strict.md +232 -0
- package/.grok/skills/lit-code/references/python/textual-tui.md +201 -0
- package/.grok/skills/lit-code/references/python/type-patterns.md +176 -0
- package/.grok/skills/lit-code/references/rust/README.md +317 -0
- package/.grok/skills/lit-code/references/rust/async-tokio.md +299 -0
- package/.grok/skills/lit-code/references/rust/axum-stack.md +467 -0
- package/.grok/skills/lit-code/references/rust/cargo-strict.md +317 -0
- package/.grok/skills/lit-code/references/rust/clap-stack.md +409 -0
- package/.grok/skills/lit-code/references/rust/concurrency.md +375 -0
- package/.grok/skills/lit-code/references/rust/libraries.md +439 -0
- package/.grok/skills/lit-code/references/rust/one-liners.md +291 -0
- package/.grok/skills/lit-code/references/rust/proptest-insta.md +429 -0
- package/.grok/skills/lit-code/references/rust/type-state.md +354 -0
- package/.grok/skills/lit-code/references/rust/unsafe-discipline.md +250 -0
- package/.grok/skills/lit-code/references/rust/zero-cost-safety.md +527 -0
- package/.grok/skills/lit-code/references/rust-ub/README.md +289 -0
- package/.grok/skills/lit-code/references/rust-ub/miri-sanitizers-loom.md +411 -0
- package/.grok/skills/lit-code/references/rust-ub/ub-taxonomy.md +269 -0
- package/.grok/skills/lit-code/references/tool-boundaries.md +66 -0
- package/.grok/skills/lit-code/references/typescript/README.md +195 -0
- package/.grok/skills/lit-code/references/typescript/backend-hono.md +672 -0
- package/.grok/skills/lit-code/references/typescript/bootstrap.md +199 -0
- package/.grok/skills/lit-code/references/typescript/data-modeling.md +202 -0
- package/.grok/skills/lit-code/references/typescript/error-handling.md +169 -0
- package/.grok/skills/lit-code/references/typescript/tsconfig-strict.md +152 -0
- package/.grok/skills/lit-code/references/typescript/type-patterns.md +196 -0
- package/.grok/skills/lit-code/references/worked-cases.md +190 -0
- package/.grok/skills/lit-commit/SKILL.md +218 -0
- package/.grok/skills/lit-comprehend/SKILL.md +63 -0
- package/.grok/skills/lit-comprehend/references/artifact-format.md +58 -0
- package/.grok/skills/lit-comprehend/references/artifact-template.md +219 -0
- package/.grok/skills/lit-comprehend/references/honesty-ledger-contract.md +51 -0
- package/.grok/skills/lit-comprehend/references/micro-worlds.md +195 -0
- package/.grok/skills/lit-comprehend/references/worked-explainer.md +51 -0
- package/.grok/skills/lit-crucible/SKILL.md +231 -0
- package/.grok/skills/lit-handoff/SKILL.md +159 -0
- package/.grok/skills/lit-handoff/evals/evals.json +154 -0
- package/.grok/skills/lit-handoff/examples/HANDOFF-example-generic-auth-refactor.md +97 -0
- package/.grok/skills/lit-handoff/references/_canonical-corpus/manifest.json +17 -0
- package/.grok/skills/lit-handoff/references/source-pointer.md +31 -0
- package/.grok/skills/lit-handoff/scripts/verify-canonical-corpus.mjs +137 -0
- package/.grok/skills/lit-handoff/templates/HANDOFF.md +121 -0
- package/.grok/skills/lit-init/SKILL.md +244 -0
- package/.grok/skills/lit-korean/SKILL.md +176 -0
- package/.grok/skills/lit-plan/SKILL.md +71 -0
- package/.grok/skills/lit-plan/references/plan-schema.md +87 -0
- package/.grok/skills/lit-plan/references/start-work-handoff-contract.md +59 -0
- package/.grok/skills/lit-plan/scripts/scaffold-plan.mjs +259 -0
- package/.grok/skills/lit-plan/scripts/validate-plan.mjs +89 -0
- package/.grok/skills/lit-recap/SKILL.md +57 -0
- package/.grok/skills/lit-scientific-visualization/SKILL.md +213 -0
- package/.grok/skills/lit-scientific-visualization/scripts/verify-canonical-corpus.mjs +181 -0
- package/.grok/skills/lit-team/SKILL.md +73 -0
- package/.grok/skills/lit-team/references/explore-packet.md +70 -0
- package/.grok/skills/lit-team/references/general-purpose-packet.md +75 -0
- package/.grok/skills/lit-team/references/plan-packet.md +73 -0
- package/.grok/skills/litgoal/SKILL.md +98 -0
- package/.grok/skills/litgrok/SKILL.md +77 -0
- package/.grok/skills/litresearch/SKILL.md +60 -0
- package/.grok/skills/litresearch/references/mcp-tool-use-patterns.md +83 -0
- package/.grok/skills/litresearch/references/source-verdict-taxonomy.md +40 -0
- package/.grok/skills/litwork/SKILL.md +109 -0
- package/.grok/skills/lsp/SKILL.md +56 -0
- package/.grok/skills/lsp/references/built-in-lsp-contract.md +71 -0
- package/.grok/skills/lsp-setup/SKILL.md +82 -0
- package/.grok/skills/lsp-setup/references/bash/README.md +54 -0
- package/.grok/skills/lsp-setup/references/c-cpp/README.md +58 -0
- package/.grok/skills/lsp-setup/references/csharp/README.md +64 -0
- package/.grok/skills/lsp-setup/references/dart/README.md +48 -0
- package/.grok/skills/lsp-setup/references/elixir/README.md +51 -0
- package/.grok/skills/lsp-setup/references/go/README.md +53 -0
- package/.grok/skills/lsp-setup/references/haskell/README.md +57 -0
- package/.grok/skills/lsp-setup/references/java/README.md +55 -0
- package/.grok/skills/lsp-setup/references/julia/README.md +56 -0
- package/.grok/skills/lsp-setup/references/kotlin/README.md +58 -0
- package/.grok/skills/lsp-setup/references/lua/README.md +48 -0
- package/.grok/skills/lsp-setup/references/php/README.md +49 -0
- package/.grok/skills/lsp-setup/references/python/README.md +60 -0
- package/.grok/skills/lsp-setup/references/ruby/README.md +53 -0
- package/.grok/skills/lsp-setup/references/rust/README.md +55 -0
- package/.grok/skills/lsp-setup/references/swift/README.md +52 -0
- package/.grok/skills/lsp-setup/references/terraform/README.md +50 -0
- package/.grok/skills/lsp-setup/references/typescript/README.md +63 -0
- package/.grok/skills/lsp-setup/references/yaml/README.md +47 -0
- package/.grok/skills/lsp-setup/references/zig/README.md +49 -0
- package/.grok/skills/lsp-setup/scripts/detect-lsp.mjs +40 -0
- package/.grok/skills/lsp-setup/scripts/lsp-server-table.mjs +309 -0
- package/.grok/skills/lsp-setup/scripts/verify-lsp.mjs +54 -0
- package/.grok/skills/refactor/SKILL.md +210 -0
- package/.grok/skills/review-work/SKILL.md +515 -0
- package/.grok/skills/review-work/references/behavior-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/documentation-lane-contract.md +49 -0
- package/.grok/skills/review-work/references/integration-lane-contract.md +51 -0
- package/.grok/skills/review-work/references/regression-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/safety-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/test-lane-contract.md +48 -0
- package/.grok/skills/review-work/scripts/check-lanes.mjs +63 -0
- package/.grok/skills/rules/SKILL.md +51 -0
- package/.grok/skills/rules/references/loading-order-contract.md +66 -0
- package/.grok/skills/rules/scripts/resolve-guidance.mjs +180 -0
- package/.grok/skills/skill-observer/SKILL.md +78 -0
- package/.grok/skills/skill-observer/references/review-contract.md +77 -0
- package/.grok/skills/skill-observer/scripts/curator.mjs +121 -0
- package/.grok/skills/skill-observer/scripts/review.mjs +347 -0
- package/.grok/skills/skill-observer/scripts/skill-loop.mjs +2087 -0
- package/.grok/skills/skill-observer/scripts/validate-skills.mjs +83 -0
- package/.grok/skills/start-work/SKILL.md +396 -0
- package/.grok/skills/structural-search/SKILL.md +195 -0
- package/.grok/skills/visual-qa/SKILL.md +50 -0
- package/.grok/skills/visual-qa/references/capture-playbook.md +47 -0
- package/.grok/skills/visual-qa/references/complete-contract.md +721 -0
- package/.grok/skills/visual-qa/references/verdict-taxonomy.md +34 -0
- package/.grok/skills/visual-qa/scripts/verify-evidence-manifest.mjs +91 -0
- package/.grok/skills/wikify/SKILL.md +65 -0
- package/.grok/skills/wikify/references/page-format.md +81 -0
- package/.grok/skills/wikify/references/provenance-contract.md +52 -0
- package/.grok/vendor/NOTICE.md +16 -0
- package/.grok/vendor/licenses/045_scientific-visualization-MIT.txt +21 -0
- package/.grok/vendor/provenance/045_scientific-visualization.md +37 -0
- package/.grok/vendor/scientific-visualization/assets/color_palettes.py +197 -0
- package/.grok/vendor/scientific-visualization/assets/nature.mplstyle +75 -0
- package/.grok/vendor/scientific-visualization/assets/presentation.mplstyle +74 -0
- package/.grok/vendor/scientific-visualization/assets/publication.mplstyle +78 -0
- package/.grok/vendor/scientific-visualization/evals/evals.json +158 -0
- package/.grok/vendor/scientific-visualization/references/_canonical-corpus/manifest.json +38 -0
- package/.grok/vendor/scientific-visualization/references/color_palettes.md +380 -0
- package/.grok/vendor/scientific-visualization/references/journal_requirements.md +359 -0
- package/.grok/vendor/scientific-visualization/references/matplotlib_examples.md +608 -0
- package/.grok/vendor/scientific-visualization/references/mdanalysis_martini_visualization.md +85 -0
- package/.grok/vendor/scientific-visualization/references/publication_guidelines.md +217 -0
- package/.grok/vendor/scientific-visualization/references/seaborn_for_publications.md +293 -0
- package/.grok/vendor/scientific-visualization/scripts/figure_export.py +238 -0
- package/.grok/vendor/scientific-visualization/scripts/style_presets.py +467 -0
- package/.grok/vendor/scientific-visualization/tests/test_figure_export.py +51 -0
- package/.grok/vendor/scientific-visualization/tests/test_style_presets.py +114 -0
- package/CHANGELOG.md +131 -0
- package/CODE_OF_CONDUCT.md +9 -0
- package/CONTRIBUTING.md +22 -0
- package/LICENSE +21 -0
- package/README.md +228 -0
- package/README_ko-KR.md +228 -0
- package/SECURITY.md +11 -0
- package/SUPPORT.md +9 -0
- package/bin/litgrok.mjs +860 -0
- package/docs/assets/cover.webp +0 -0
- package/docs/assets/litgrok-clay-icon.png +0 -0
- package/docs/assets/litgrok-continuity-1600.webp +0 -0
- package/docs/assets/litgrok-ignition-1600.webp +0 -0
- package/docs/assets/litgrok-wordmark.svg +5 -0
- package/docs/assets/readme/README.md +31 -0
- package/docs/assets/readme/badge-license.svg +1 -0
- package/docs/assets/readme/badge-version.svg +1 -0
- package/docs/privacy.md +13 -0
- package/docs/reference.md +271 -0
- package/docs/reference_ko-KR.md +267 -0
- package/package.json +50 -0
- package/plugin.json +27 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
import { UiuxContractError } from "./errors.mjs";
|
|
5
|
+
import { readBoundedJson, requireFields } from "./json-boundary.mjs";
|
|
6
|
+
|
|
7
|
+
export const DATASET_MAX_BYTES = 4 * 1024 * 1024;
|
|
8
|
+
export const DATASET_SCHEMA = "litfamily.design-intelligence/v1";
|
|
9
|
+
export const DATASET_RECORDS = 2277;
|
|
10
|
+
export const DATASET_SHA256 = "a89011236a6ff14e12ec55fccbfab1bbd40ae34614cea5710c022121aa841bb8";
|
|
11
|
+
|
|
12
|
+
export const defaultDataPath = fileURLToPath(new URL("../data/design-intelligence.json", import.meta.url));
|
|
13
|
+
export const defaultProvenancePath = fileURLToPath(new URL("../PROVENANCE.json", import.meta.url));
|
|
14
|
+
|
|
15
|
+
export function sha256(bytes) {
|
|
16
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseProvenance(path) {
|
|
20
|
+
const parsed = readBoundedJson(path, {
|
|
21
|
+
maxBytes: 256 * 1024,
|
|
22
|
+
invalidCode: "PROVENANCE_INVALID_JSON",
|
|
23
|
+
});
|
|
24
|
+
requireFields(parsed.value, ["canonical_dataset"], "PROVENANCE_SCHEMA_INVALID", "PROVENANCE.json");
|
|
25
|
+
const canonical = parsed.value.canonical_dataset;
|
|
26
|
+
requireFields(
|
|
27
|
+
canonical,
|
|
28
|
+
["byte_count", "record_count", "schema_version", "sha256"],
|
|
29
|
+
"PROVENANCE_SCHEMA_INVALID",
|
|
30
|
+
"canonical_dataset",
|
|
31
|
+
);
|
|
32
|
+
return canonical;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function loadDesignData({
|
|
36
|
+
dataPath = defaultDataPath,
|
|
37
|
+
provenancePath = defaultProvenancePath,
|
|
38
|
+
} = {}) {
|
|
39
|
+
const parsed = readBoundedJson(dataPath, {
|
|
40
|
+
maxBytes: DATASET_MAX_BYTES,
|
|
41
|
+
invalidCode: "DATASET_INVALID_JSON",
|
|
42
|
+
});
|
|
43
|
+
const provenance = parseProvenance(provenancePath);
|
|
44
|
+
const actualHash = sha256(parsed.bytes);
|
|
45
|
+
if (actualHash !== provenance.sha256) {
|
|
46
|
+
throw new UiuxContractError(
|
|
47
|
+
"DATASET_HASH_MISMATCH",
|
|
48
|
+
`dataset SHA-256 ${actualHash} does not match provenance ${provenance.sha256}`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
requireFields(parsed.value, ["records", "schema_version", "source_commit"], "DATASET_SCHEMA_INVALID", "dataset");
|
|
52
|
+
if (parsed.value.schema_version !== DATASET_SCHEMA || !Array.isArray(parsed.value.records)) {
|
|
53
|
+
throw new UiuxContractError("DATASET_SCHEMA_INVALID", `expected ${DATASET_SCHEMA} records`);
|
|
54
|
+
}
|
|
55
|
+
if (parsed.value.records.length !== provenance.record_count) {
|
|
56
|
+
throw new UiuxContractError(
|
|
57
|
+
"DATASET_RECORD_COUNT_MISMATCH",
|
|
58
|
+
`dataset has ${parsed.value.records.length} records; provenance requires ${provenance.record_count}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
bytes: parsed.bytes.length,
|
|
63
|
+
records: parsed.value.records,
|
|
64
|
+
schema: parsed.value.schema_version,
|
|
65
|
+
sha256: actualHash,
|
|
66
|
+
sourceCommit: parsed.value.source_commit,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class UiuxContractError extends Error {
|
|
2
|
+
constructor(code, message, details = {}) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "UiuxContractError";
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.details = Object.freeze({ ...details });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function errorMessage(error) {
|
|
11
|
+
return error instanceof Error ? error.message : String(error);
|
|
12
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
DATASET_MAX_BYTES,
|
|
10
|
+
DATASET_RECORDS,
|
|
11
|
+
DATASET_SHA256,
|
|
12
|
+
loadDesignData,
|
|
13
|
+
} from "./design-data.mjs";
|
|
14
|
+
import { errorMessage, UiuxContractError } from "./errors.mjs";
|
|
15
|
+
import { readBoundedJson } from "./json-boundary.mjs";
|
|
16
|
+
import { replayPinnedSources, validateSourceManifest } from "./source-replay.mjs";
|
|
17
|
+
|
|
18
|
+
const DEFAULT_SKILL_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
|
19
|
+
const COMPANIONS = Object.freeze([
|
|
20
|
+
["LICENSE", "738f69dfa83db5c347c678fb9d90e560877059f0de93a327c39001bff92dc014"],
|
|
21
|
+
["PROVENANCE.json", "a00be969523fe376a07d310b7418be0c41824f01241294bdf00e82eb4d736e87"],
|
|
22
|
+
["SOURCE-MANIFEST.json", "9adf471d95aaf17e7866e1c7674cb1a101daae9abdab87c71c96a60f2a58e6fa"],
|
|
23
|
+
["THIRD-PARTY-NOTICE.txt", "ca1e7d88104177450ff848296cf9340f5f69aa421c4f215673a72a33c03c927e"],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
function hash(bytes) {
|
|
27
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseArgs(argv) {
|
|
31
|
+
const options = {};
|
|
32
|
+
const allowed = new Set(["--skill-root", "--source-root", "--expect-records", "--max-bytes"]);
|
|
33
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
34
|
+
const flag = argv[index];
|
|
35
|
+
if (flag === "--check") {
|
|
36
|
+
if (options.check) throw new UiuxContractError("INVALID_ARGUMENT", "duplicate --check");
|
|
37
|
+
options.check = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const value = argv[++index];
|
|
41
|
+
if (!allowed.has(flag) || value === undefined || value.length === 0) {
|
|
42
|
+
throw new UiuxContractError("INVALID_ARGUMENT", `invalid importer argument: ${flag ?? ""}`);
|
|
43
|
+
}
|
|
44
|
+
const key = flag.slice(2).replace(/-([a-z])/gu, (_, letter) => letter.toUpperCase());
|
|
45
|
+
if (options[key] !== undefined) throw new UiuxContractError("INVALID_ARGUMENT", `duplicate ${flag}`);
|
|
46
|
+
options[key] = value;
|
|
47
|
+
}
|
|
48
|
+
if (!options.check) throw new UiuxContractError("CHECK_MODE_REQUIRED", "--check is required");
|
|
49
|
+
if (options.sourceRoot
|
|
50
|
+
&& (options.expectRecords !== String(DATASET_RECORDS)
|
|
51
|
+
|| options.maxBytes !== String(DATASET_MAX_BYTES))) {
|
|
52
|
+
throw new UiuxContractError(
|
|
53
|
+
"INVALID_ARGUMENT",
|
|
54
|
+
`source replay requires --expect-records ${DATASET_RECORDS} --max-bytes ${DATASET_MAX_BYTES}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return options;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function verifyCompanions(skillRoot) {
|
|
61
|
+
return COMPANIONS.map(([path, expected]) => {
|
|
62
|
+
const absolutePath = join(skillRoot, path);
|
|
63
|
+
if (!existsSync(absolutePath)) throw new UiuxContractError("COMPANION_MISSING", path);
|
|
64
|
+
const actual = hash(readFileSync(absolutePath));
|
|
65
|
+
if (actual !== expected) {
|
|
66
|
+
throw new UiuxContractError("COMPANION_HASH_MISMATCH", `${path}: ${actual}`);
|
|
67
|
+
}
|
|
68
|
+
return { path, sha256: actual };
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function loadManifest(manifestPath) {
|
|
73
|
+
const manifest = readBoundedJson(manifestPath, {
|
|
74
|
+
maxBytes: DATASET_MAX_BYTES,
|
|
75
|
+
invalidCode: "SOURCE_MANIFEST_INVALID",
|
|
76
|
+
}).value;
|
|
77
|
+
validateSourceManifest(manifest);
|
|
78
|
+
return manifest;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function runImportCheck(argv) {
|
|
82
|
+
const options = parseArgs(argv);
|
|
83
|
+
const skillRoot = resolve(options.skillRoot ?? DEFAULT_SKILL_ROOT);
|
|
84
|
+
const companions = verifyCompanions(skillRoot);
|
|
85
|
+
const manifestPath = join(skillRoot, "SOURCE-MANIFEST.json");
|
|
86
|
+
const manifest = loadManifest(manifestPath);
|
|
87
|
+
const data = loadDesignData({
|
|
88
|
+
dataPath: join(skillRoot, "data/design-intelligence.json"),
|
|
89
|
+
provenancePath: join(skillRoot, "PROVENANCE.json"),
|
|
90
|
+
});
|
|
91
|
+
if (data.records.length !== DATASET_RECORDS
|
|
92
|
+
|| data.bytes > DATASET_MAX_BYTES
|
|
93
|
+
|| data.sha256 !== DATASET_SHA256) {
|
|
94
|
+
throw new UiuxContractError("SOURCE_CONTRACT_MISMATCH", "packaged corpus is outside contract");
|
|
95
|
+
}
|
|
96
|
+
const replay = options.sourceRoot
|
|
97
|
+
? replayPinnedSources(realpathSync(resolve(options.sourceRoot)), manifest, join(skillRoot, "data/design-intelligence.json"))
|
|
98
|
+
: null;
|
|
99
|
+
return {
|
|
100
|
+
schema_id: "litfamily.design-intelligence-import-check/v1",
|
|
101
|
+
status: "PASS",
|
|
102
|
+
dataset: {
|
|
103
|
+
schema_version: data.schema,
|
|
104
|
+
record_count: data.records.length,
|
|
105
|
+
byte_count: data.bytes,
|
|
106
|
+
sha256: data.sha256,
|
|
107
|
+
source_commit: data.sourceCommit,
|
|
108
|
+
},
|
|
109
|
+
companions,
|
|
110
|
+
replay,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function main() {
|
|
115
|
+
try {
|
|
116
|
+
process.stdout.write(`${JSON.stringify(runImportCheck(process.argv.slice(2)), null, 2)}\n`);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const code = error instanceof UiuxContractError ? error.code : "SOURCE_CONTRACT_FAILED";
|
|
119
|
+
process.stderr.write(`${code}: ${errorMessage(error)}\n`);
|
|
120
|
+
process.exitCode = 2;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) main();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { UiuxContractError } from "./errors.mjs";
|
|
5
|
+
import {
|
|
6
|
+
decodeStrictUtf8,
|
|
7
|
+
parseStrictJson,
|
|
8
|
+
StrictJsonError,
|
|
9
|
+
} from "./strict-json.mjs";
|
|
10
|
+
|
|
11
|
+
export function readBoundedJson(path, { maxBytes, invalidCode, allowSymlink = false }) {
|
|
12
|
+
const absolutePath = resolve(path);
|
|
13
|
+
const stat = lstatSync(absolutePath);
|
|
14
|
+
if (!stat.isFile() && !stat.isSymbolicLink()) {
|
|
15
|
+
throw new UiuxContractError(invalidCode, `expected a regular JSON file: ${absolutePath}`);
|
|
16
|
+
}
|
|
17
|
+
if (stat.isSymbolicLink() && !allowSymlink) {
|
|
18
|
+
throw new UiuxContractError(invalidCode, `symlink input requires explicit opt-in: ${absolutePath}`);
|
|
19
|
+
}
|
|
20
|
+
const resolvedPath = realpathSync(absolutePath);
|
|
21
|
+
const bytes = readFileSync(resolvedPath);
|
|
22
|
+
if (bytes.length > maxBytes) {
|
|
23
|
+
throw new UiuxContractError(invalidCode, `JSON input exceeds ${maxBytes} bytes`, {
|
|
24
|
+
actual_bytes: bytes.length,
|
|
25
|
+
max_bytes: maxBytes,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
let text;
|
|
29
|
+
let value;
|
|
30
|
+
try {
|
|
31
|
+
text = decodeStrictUtf8(bytes);
|
|
32
|
+
value = parseStrictJson(text);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error instanceof StrictJsonError) {
|
|
35
|
+
const code = error.code === "JSON_SYNTAX_INVALID" ? invalidCode : error.code;
|
|
36
|
+
throw new UiuxContractError(code, error.message, error.details);
|
|
37
|
+
}
|
|
38
|
+
throw new UiuxContractError(invalidCode, `invalid JSON: ${error.message}`);
|
|
39
|
+
}
|
|
40
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
41
|
+
throw new UiuxContractError(invalidCode, "top-level JSON value must be an object");
|
|
42
|
+
}
|
|
43
|
+
return { absolutePath, bytes, text, value };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function requireFields(value, fields, code, label) {
|
|
47
|
+
const missing = fields.filter((field) => !Object.hasOwn(value, field));
|
|
48
|
+
if (missing.length > 0) {
|
|
49
|
+
throw new UiuxContractError(code, `${label} is missing required fields: ${missing.join(", ")}`, {
|
|
50
|
+
missing,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function rejectUnknownFields(value, allowed, code, label) {
|
|
56
|
+
const allowedSet = new Set(allowed);
|
|
57
|
+
const unknown = Object.keys(value).filter((field) => !allowedSet.has(field));
|
|
58
|
+
if (unknown.length > 0) {
|
|
59
|
+
throw new UiuxContractError(code, `${label} contains unknown fields: ${unknown.join(", ")}`, {
|
|
60
|
+
unknown,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import { loadDesignData } from "./design-data.mjs";
|
|
7
|
+
import { errorMessage, UiuxContractError } from "./errors.mjs";
|
|
8
|
+
import { normalizeQuery, searchRecords } from "./search.mjs";
|
|
9
|
+
|
|
10
|
+
const QUERY_MAX_BYTES = 4096;
|
|
11
|
+
const OUTPUT_MAX_BYTES = 256 * 1024;
|
|
12
|
+
const RESULT_MAX = 20;
|
|
13
|
+
|
|
14
|
+
function parseArgs(argv) {
|
|
15
|
+
const options = { limit: 5, minScore: 0.000001, json: false };
|
|
16
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
17
|
+
const flag = argv[index];
|
|
18
|
+
if (flag === "--json") {
|
|
19
|
+
options.json = true;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (!["--query", "--domain", "--limit", "--min-score", "--data", "--provenance"].includes(flag)) {
|
|
23
|
+
throw new UiuxContractError("INVALID_ARGUMENT", `unknown argument ${flag}`);
|
|
24
|
+
}
|
|
25
|
+
const value = argv[index + 1];
|
|
26
|
+
if (value === undefined) throw new UiuxContractError("INVALID_ARGUMENT", `${flag} requires a value`);
|
|
27
|
+
options[flag.slice(2).replace("-", "")] = value;
|
|
28
|
+
index += 1;
|
|
29
|
+
}
|
|
30
|
+
return options;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function positiveNumber(value, fallback, maximum, label, { integer = false } = {}) {
|
|
34
|
+
if (value !== undefined && typeof value !== "number" && (value.trim() !== value
|
|
35
|
+
|| !/^(?:0|[1-9]\d*)(?:\.\d+)?$/u.test(value)
|
|
36
|
+
|| (integer && !/^[1-9]\d*$/u.test(value)))) {
|
|
37
|
+
throw new UiuxContractError("INVALID_ARGUMENT", `${label} has invalid numeric syntax`);
|
|
38
|
+
}
|
|
39
|
+
const parsed = value === undefined ? fallback : Number(value);
|
|
40
|
+
if (!Number.isFinite(parsed) || parsed <= 0 || parsed > maximum) {
|
|
41
|
+
throw new UiuxContractError("INVALID_ARGUMENT", `${label} must be greater than 0 and at most ${maximum}`);
|
|
42
|
+
}
|
|
43
|
+
if (integer && !Number.isInteger(parsed)) {
|
|
44
|
+
throw new UiuxContractError("INVALID_ARGUMENT", `${label} must be an integer`);
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function runQuery(argv) {
|
|
50
|
+
const options = parseArgs(argv);
|
|
51
|
+
if (typeof options.query !== "string" || typeof options.domain !== "string") {
|
|
52
|
+
throw new UiuxContractError("INVALID_ARGUMENT", "--query and --domain are required");
|
|
53
|
+
}
|
|
54
|
+
const queryBytes = Buffer.byteLength(options.query, "utf8");
|
|
55
|
+
if (queryBytes > QUERY_MAX_BYTES) {
|
|
56
|
+
throw new UiuxContractError(
|
|
57
|
+
"QUERY_TOO_LARGE",
|
|
58
|
+
`query is ${queryBytes} bytes; maximum is 4096 bytes`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const query = normalizeQuery(options.query);
|
|
62
|
+
if (query.length === 0) throw new UiuxContractError("QUERY_EMPTY", "--query must contain searchable text");
|
|
63
|
+
const limit = positiveNumber(options.limit, 5, RESULT_MAX, "--limit", { integer: true });
|
|
64
|
+
const minScore = positiveNumber(options.minscore, 0.000001, 1_000_000, "--min-score");
|
|
65
|
+
const data = loadDesignData({
|
|
66
|
+
dataPath: options.data,
|
|
67
|
+
provenancePath: options.provenance,
|
|
68
|
+
});
|
|
69
|
+
const domains = new Set(data.records.map((record) => record.domain));
|
|
70
|
+
if (!domains.has(options.domain)) {
|
|
71
|
+
throw new UiuxContractError("UNKNOWN_DOMAIN", `unknown design-intelligence domain: ${options.domain}`);
|
|
72
|
+
}
|
|
73
|
+
const results = searchRecords(data.records, {
|
|
74
|
+
query,
|
|
75
|
+
domain: options.domain,
|
|
76
|
+
limit,
|
|
77
|
+
minScore,
|
|
78
|
+
}).map((record) => ({ ...record, dataset_sha256: data.sha256 }));
|
|
79
|
+
const report = {
|
|
80
|
+
schema_id: "litfamily.design-intelligence-query/v1alpha1",
|
|
81
|
+
status: results.length === 0 ? "NO_RESULTS" : "RESULTS",
|
|
82
|
+
query: options.query,
|
|
83
|
+
normalized_query: query,
|
|
84
|
+
domain: options.domain,
|
|
85
|
+
dataset_sha256: data.sha256,
|
|
86
|
+
fallback: false,
|
|
87
|
+
results,
|
|
88
|
+
};
|
|
89
|
+
const output = `${JSON.stringify(report, null, 2)}\n`;
|
|
90
|
+
if (Buffer.byteLength(output) > OUTPUT_MAX_BYTES) {
|
|
91
|
+
throw new UiuxContractError("OUTPUT_TOO_LARGE", `query output exceeds ${OUTPUT_MAX_BYTES} bytes`);
|
|
92
|
+
}
|
|
93
|
+
return output;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function main() {
|
|
97
|
+
try {
|
|
98
|
+
process.stdout.write(runQuery(process.argv.slice(2)));
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const code = error instanceof UiuxContractError ? error.code : "QUERY_FAILED";
|
|
101
|
+
process.stderr.write(`${code}: ${errorMessage(error)}\n`);
|
|
102
|
+
process.exitCode = 2;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) main();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const TOKEN_PATTERN = /[\p{L}\p{N}]+/gu;
|
|
2
|
+
|
|
3
|
+
export function normalizeQuery(input) {
|
|
4
|
+
return input.normalize("NFKC").toLocaleLowerCase("en-US").trim();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function tokens(input) {
|
|
8
|
+
return normalizeQuery(String(input)).match(TOKEN_PATTERN) ?? [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function recordText(record) {
|
|
12
|
+
return Object.entries(record)
|
|
13
|
+
.filter(([key, value]) => key !== "No" && typeof value === "string")
|
|
14
|
+
.map(([, value]) => value)
|
|
15
|
+
.join(" ");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function scoreRecord(record, queryTokens) {
|
|
19
|
+
const haystack = tokens(recordText(record));
|
|
20
|
+
if (haystack.length === 0) return 0;
|
|
21
|
+
const frequencies = new Map();
|
|
22
|
+
for (const token of haystack) frequencies.set(token, (frequencies.get(token) ?? 0) + 1);
|
|
23
|
+
let matches = 0;
|
|
24
|
+
for (const token of queryTokens) {
|
|
25
|
+
matches += frequencies.get(token) ?? 0;
|
|
26
|
+
}
|
|
27
|
+
return matches / Math.sqrt(haystack.length);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function searchRecords(records, { query, domain, limit, minScore }) {
|
|
31
|
+
const queryTokens = tokens(query);
|
|
32
|
+
if (queryTokens.length === 0) return [];
|
|
33
|
+
return records
|
|
34
|
+
.filter((record) => record.domain === domain)
|
|
35
|
+
.map((record) => ({ record, score: scoreRecord(record, queryTokens) }))
|
|
36
|
+
.filter(({ score }) => score >= minScore && score > 0)
|
|
37
|
+
.sort((left, right) => right.score - left.score || left.record.record_id.localeCompare(right.record.record_id))
|
|
38
|
+
.slice(0, limit)
|
|
39
|
+
.map(({ record, score }) => ({
|
|
40
|
+
...record,
|
|
41
|
+
score: Number(score.toFixed(8)),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
3
|
+
import { basename, relative, resolve, sep } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { stableJson } from "./strict-json.mjs";
|
|
6
|
+
import { DATASET_MAX_BYTES, DATASET_RECORDS, DATASET_SHA256 } from "./design-data.mjs";
|
|
7
|
+
import { UiuxContractError } from "./errors.mjs";
|
|
8
|
+
|
|
9
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
10
|
+
|
|
11
|
+
function parseCsv(text, label) {
|
|
12
|
+
const rows = [];
|
|
13
|
+
let row = [];
|
|
14
|
+
let field = "";
|
|
15
|
+
let quoted = false;
|
|
16
|
+
let closed = false;
|
|
17
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
18
|
+
const char = text[index];
|
|
19
|
+
if (quoted) {
|
|
20
|
+
if (char === "\"" && text[index + 1] === "\"") {
|
|
21
|
+
field += "\""; index += 1;
|
|
22
|
+
} else if (char === "\"") {
|
|
23
|
+
quoted = false; closed = true;
|
|
24
|
+
} else field += char;
|
|
25
|
+
} else if (closed) {
|
|
26
|
+
if (char === ",") {
|
|
27
|
+
row.push(field); field = ""; closed = false;
|
|
28
|
+
} else if (char === "\n") {
|
|
29
|
+
row.push(field); rows.push(row); row = []; field = ""; closed = false;
|
|
30
|
+
} else throw new UiuxContractError("SOURCE_CSV_INVALID", `${label}: data after quote`);
|
|
31
|
+
} else if (char === "\"" && field.length === 0) quoted = true;
|
|
32
|
+
else if (char === ",") {
|
|
33
|
+
row.push(field); field = "";
|
|
34
|
+
} else if (char === "\n") {
|
|
35
|
+
row.push(field); rows.push(row); row = []; field = "";
|
|
36
|
+
} else field += char;
|
|
37
|
+
}
|
|
38
|
+
if (quoted) throw new UiuxContractError("SOURCE_CSV_INVALID", `${label}: unterminated quote`);
|
|
39
|
+
if (closed || field.length > 0 || row.length > 0) {
|
|
40
|
+
row.push(field);
|
|
41
|
+
rows.push(row);
|
|
42
|
+
}
|
|
43
|
+
if (rows.length < 2 || rows.some((candidate) => candidate.length !== rows[0].length)) {
|
|
44
|
+
throw new UiuxContractError("SOURCE_CSV_INVALID", `${label}: inconsistent row width`);
|
|
45
|
+
}
|
|
46
|
+
return rows;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function validateSourceManifest(manifest) {
|
|
50
|
+
if (manifest.schema_version !== "litfamily.source-import-manifest/v1"
|
|
51
|
+
|| manifest.source?.commit !== "1307d97a72e6c1cda572cb65471ae5ce82995218"
|
|
52
|
+
|| !Array.isArray(manifest.sources) || manifest.sources.length !== 34
|
|
53
|
+
|| new Set(manifest.sources.map(({ path }) => path)).size !== 34
|
|
54
|
+
|| manifest.sources.reduce((sum, entry) => sum + entry.normalized_record_count, 0) !== 2277
|
|
55
|
+
|| manifest.sources.some((entry) =>
|
|
56
|
+
typeof entry.path !== "string" || !/^[a-f0-9]{64}$/u.test(entry.raw_sha256)
|
|
57
|
+
|| !Array.isArray(entry.header) || !Array.isArray(entry.selected_columns)
|
|
58
|
+
|| !Number.isInteger(entry.data_row_count)
|
|
59
|
+
|| entry.normalized_record_count !== entry.data_row_count)) {
|
|
60
|
+
throw new UiuxContractError("SOURCE_MANIFEST_INVALID", "exact 34-source allowlist is required");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function sourceBytes(sourceRoot, entry) {
|
|
65
|
+
const path = resolve(sourceRoot, entry.path);
|
|
66
|
+
const rel = relative(sourceRoot, path);
|
|
67
|
+
if (rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
68
|
+
throw new UiuxContractError("SOURCE_PATH_INVALID", entry.path);
|
|
69
|
+
}
|
|
70
|
+
const stat = lstatSync(path);
|
|
71
|
+
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
72
|
+
throw new UiuxContractError("SOURCE_PATH_INVALID", entry.path);
|
|
73
|
+
}
|
|
74
|
+
return readFileSync(path);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function normalizeSource(bytes, entry) {
|
|
78
|
+
if (bytes.includes(0)) throw new UiuxContractError("SOURCE_CSV_INVALID", `${entry.path}: NUL`);
|
|
79
|
+
let text;
|
|
80
|
+
try {
|
|
81
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
82
|
+
} catch {
|
|
83
|
+
throw new UiuxContractError("SOURCE_CSV_INVALID", `${entry.path}: invalid UTF-8`);
|
|
84
|
+
}
|
|
85
|
+
text = text.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
|
|
86
|
+
if (entry.repair) {
|
|
87
|
+
const approved = entry.path === "src/ui-ux-pro-max/data/stacks/javafx.csv"
|
|
88
|
+
&& entry.repair.rule === "backslash_quote_to_rfc4180_double_quote"
|
|
89
|
+
&& entry.repair.occurrences === 18 && text.split("\\\"").length - 1 === 18;
|
|
90
|
+
if (!approved) throw new UiuxContractError("SOURCE_REPAIR_INVALID", entry.path);
|
|
91
|
+
text = text.replaceAll("\\\"", "\"\"");
|
|
92
|
+
if (hash(Buffer.from(text)) !== entry.repair.repaired_sha256) {
|
|
93
|
+
throw new UiuxContractError("SOURCE_REPAIR_INVALID", `${entry.path}: repaired hash`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return text;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function recordsFor(rows, entry) {
|
|
100
|
+
const header = rows[0];
|
|
101
|
+
if (JSON.stringify(header) !== JSON.stringify(entry.header)
|
|
102
|
+
|| rows.length - 1 !== entry.data_row_count) {
|
|
103
|
+
throw new UiuxContractError("SOURCE_SHAPE_MISMATCH", entry.path);
|
|
104
|
+
}
|
|
105
|
+
const indexes = entry.selected_columns.map((column) => header.indexOf(column));
|
|
106
|
+
if (indexes.some((index) => index < 0)) {
|
|
107
|
+
throw new UiuxContractError("SOURCE_SHAPE_MISMATCH", `${entry.path}: selected columns`);
|
|
108
|
+
}
|
|
109
|
+
const stack = entry.path.includes("/stacks/") ? basename(entry.path, ".csv") : undefined;
|
|
110
|
+
const domain = stack ? `stack/${stack}` : basename(entry.path, ".csv");
|
|
111
|
+
return rows.slice(1).map((row, offset) => {
|
|
112
|
+
const record = Object.fromEntries(entry.selected_columns.map(
|
|
113
|
+
(column, index) => [column, row[indexes[index]].trim()],
|
|
114
|
+
));
|
|
115
|
+
const number = Number(record.No);
|
|
116
|
+
if (!Number.isSafeInteger(number) || number < 1 || String(number) !== record.No) {
|
|
117
|
+
throw new UiuxContractError("SOURCE_SHAPE_MISMATCH", `${entry.path}:${offset + 2}`);
|
|
118
|
+
}
|
|
119
|
+
record.No = number;
|
|
120
|
+
record.domain = domain;
|
|
121
|
+
record.record_id = `${domain}/${number}`;
|
|
122
|
+
if (stack) record.stack = stack;
|
|
123
|
+
return record;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function replayPinnedSources(sourceRoot, manifest, packagedPath) {
|
|
128
|
+
const records = [];
|
|
129
|
+
const ids = new Set();
|
|
130
|
+
for (const entry of manifest.sources) {
|
|
131
|
+
const raw = sourceBytes(sourceRoot, entry);
|
|
132
|
+
if (hash(raw) !== entry.raw_sha256) {
|
|
133
|
+
throw new UiuxContractError("SOURCE_HASH_MISMATCH", `${entry.path} hash mismatch`);
|
|
134
|
+
}
|
|
135
|
+
for (const record of recordsFor(parseCsv(normalizeSource(raw, entry), entry.path), entry)) {
|
|
136
|
+
if (ids.has(record.record_id)) {
|
|
137
|
+
throw new UiuxContractError("SOURCE_SHAPE_MISMATCH", `duplicate ${record.record_id}`);
|
|
138
|
+
}
|
|
139
|
+
ids.add(record.record_id);
|
|
140
|
+
records.push(record);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const bytes = Buffer.from(`${stableJson({
|
|
144
|
+
records,
|
|
145
|
+
schema_version: "litfamily.design-intelligence/v1",
|
|
146
|
+
source_commit: manifest.source.commit,
|
|
147
|
+
})}\n`);
|
|
148
|
+
if (records.length !== DATASET_RECORDS || bytes.length > DATASET_MAX_BYTES
|
|
149
|
+
|| hash(bytes) !== DATASET_SHA256 || !readFileSync(packagedPath).equals(bytes)) {
|
|
150
|
+
throw new UiuxContractError("SOURCE_CONTRACT_MISMATCH", "replayed canonical bytes differ");
|
|
151
|
+
}
|
|
152
|
+
return { records: records.length, bytes: bytes.length, sha256: hash(bytes) };
|
|
153
|
+
}
|