lazycodex-ai 5.1.44 → 5.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +0 -5
- package/README.es.md +0 -5
- package/README.fr.md +0 -5
- package/README.it.md +0 -5
- package/README.ja.md +0 -5
- package/README.ko.md +0 -5
- package/README.md +4 -5
- package/README.pt-br.md +0 -5
- package/README.ru.md +0 -6
- package/README.zh-cn.md +0 -5
- package/dist/cli/index.js +865 -413
- package/dist/cli/service-auth/keystore.d.ts +4 -2
- package/dist/cli-node/index.js +865 -413
- package/docs/reference/web-terminal-visual-qa.md +8 -0
- package/package.json +1 -1
- package/packages/lsp-daemon/dist/cli.js +7 -7
- package/packages/lsp-daemon/dist/client.js +7 -7
- package/packages/lsp-daemon/dist/index.js +7 -7
- package/packages/lsp-daemon/package.json +3 -3
- package/packages/lsp-tools-mcp/dist/cli.js +7 -7
- package/packages/lsp-tools-mcp/dist/mcp.js +7 -7
- package/packages/lsp-tools-mcp/dist/tools.js +4 -4
- package/packages/lsp-tools-mcp/package.json +3 -3
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +77 -26
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/biome.json +1 -21
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +4 -4
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +1 -21
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +4 -4
- package/packages/omo-codex/plugin/components/lsp/biome.json +1 -21
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +4 -4
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +4 -4
- package/packages/omo-codex/plugin/components/lsp/scripts/build-runtime.mjs +0 -1
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-not-installed.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/biome.json +1 -21
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +4 -4
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/biome.json +1 -21
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +90 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +91 -1
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +4 -4
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/biome.json +1 -21
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/biome.json +1 -21
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/directive.md +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/biome.json +1 -21
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +7 -7
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-mutations.mjs +2 -0
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +14 -9
- package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +1 -1
- package/packages/omo-codex/plugin/skills/browser/SKILL.md +21 -22
- package/packages/omo-codex/plugin/skills/browser/references/commands.md +2 -9
- package/packages/omo-codex/plugin/skills/browser/references/install.md +1 -2
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-doctor.mjs +2 -2
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-engine-guard.mjs +63 -487
- package/packages/omo-codex/plugin/skills/browser/scripts/browser-install.mjs +1 -1
- package/packages/omo-codex/plugin/skills/browser/scripts/omowright.mjs +1 -10
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +2 -2
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +79 -118
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +75 -224
- package/packages/omo-codex/plugin/skills/frontend/references/design/stylegallery.md +32 -27
- package/packages/omo-codex/plugin/skills/frontend/references/perfection/README.md +2 -2
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/check-accent-stripes.ts +8 -24
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/check-draft-guard.ts +40 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/collect-files.ts +53 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/findings.ts +16 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/lint.ts +38 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/rules.ts +69 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +121 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/attr-lookalikes.tsx +10 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/bound-values.tsx +12 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/const-generics.tsx +3 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/generics.tsx +7 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/measured-stats.html +6 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/plain-copy.html +9 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/state-copy.html +11 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/attribute-edges.html +7 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/components.tsx +16 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/decorative-badge.vue +7 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/emoji-icons.tsx +9 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/jsx-edges.tsx +1 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.html +6 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.tsx +8 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/vanity-stats.html +5 -0
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +10 -7
- package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +10 -7
- package/packages/omo-codex/plugin/skills/programming/references/typescript/bootstrap.md +9 -23
- package/packages/omo-codex/plugin/skills/programming/references/typescript/oxc-lint.md +130 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/tsconfig-strict.md +6 -62
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +12 -12
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/new-project.ts +20 -81
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/.oxfmtrc.json +9 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/.oxlintrc.json +46 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/LICENSE +21 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/index.js +10 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.js +28 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.js +62 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/tsconfig.json +29 -0
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +14 -14
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/AGENTS.md +21 -3
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +37 -12
- package/packages/omo-codex/plugin/skills/ulw-research/references/deliverable-phase.md +77 -16
- package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger-grammar.md +134 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger.md +95 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/fidelity-claim-kinds.md +19 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/report-gates.md +68 -3
- package/packages/omo-codex/plugin/skills/ulw-research/references/report-visualization.md +2 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/unit-rules.md +157 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/claim-kinds.mjs +116 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/claims-index.mjs +125 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/cli-support.mjs +19 -5
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/contracts.mjs +89 -3
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +191 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands.mjs +239 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-derive.mjs +66 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-expr.mjs +108 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-fill.mjs +194 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger-kinds.mjs +250 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger-schema.mjs +221 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger.mjs +123 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-locate.mjs +231 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-pairs.mjs +187 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-recompute.mjs +89 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-binding.mjs +130 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-brief.mjs +150 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-claims.mjs +89 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-lexicon.mjs +145 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-records.mjs +163 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-state.mjs +64 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-trace.mjs +85 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-values.mjs +229 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-fidelity.mjs +113 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-static.mjs +29 -9
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-structure.mjs +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-text.mjs +1 -27
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-lite.mjs +2 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-markup.mjs +182 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/lexicon.mjs +47 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/md-lite.mjs +193 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/meaning-check.mjs +196 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/numerals.mjs +226 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/outcome.mjs +8 -8
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/particles-ko.mjs +108 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/placeholder.mjs +184 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-apply.mjs +115 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-diff.mjs +31 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-project.mjs +125 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-rules.mjs +170 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/rational.mjs +139 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools-commands.mjs +21 -10
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools.mjs +15 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/sentence-split.mjs +77 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-commands.mjs +140 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-snapshot.mjs +176 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/text-normalize.mjs +82 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/text-similarity.mjs +28 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-algebra.mjs +101 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-errors.mjs +23 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-metadata.mjs +31 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-pairs.mjs +72 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-precision.mjs +44 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-rules-shapes.mjs +64 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-rules.mjs +173 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/units.mjs +105 -0
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +71 -64
- package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +4 -1
- package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +19 -0
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +12 -8
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +169 -30
- package/packages/shared-skills/skills/ast-grep/AGENTS.md +1 -1
- package/packages/shared-skills/skills/browser/SKILL.md +21 -22
- package/packages/shared-skills/skills/browser/references/commands.md +2 -9
- package/packages/shared-skills/skills/browser/references/install.md +1 -2
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/shared-skills/skills/browser/scripts/browser-doctor.mjs +2 -2
- package/packages/shared-skills/skills/browser/scripts/browser-engine-guard.mjs +63 -487
- package/packages/shared-skills/skills/browser/scripts/browser-install.mjs +1 -1
- package/packages/shared-skills/skills/browser/scripts/omowright.mjs +1 -10
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +2 -2
- package/packages/shared-skills/skills/frontend/SKILL.md +79 -118
- package/packages/shared-skills/skills/frontend/references/design/README.md +75 -224
- package/packages/shared-skills/skills/frontend/references/design/stylegallery.md +32 -27
- package/packages/shared-skills/skills/frontend/references/perfection/README.md +2 -2
- package/packages/shared-skills/skills/frontend/scripts/perfection/check-accent-stripes.ts +8 -24
- package/packages/shared-skills/skills/frontend/scripts/perfection/check-draft-guard.test.ts +101 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/check-draft-guard.ts +40 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/collect-files.test.ts +50 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/collect-files.ts +53 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/findings.ts +16 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/lint.ts +38 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/rules.ts +69 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +121 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/attr-lookalikes.tsx +10 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/bound-values.tsx +12 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/const-generics.tsx +3 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/generics.tsx +7 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/measured-stats.html +6 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/plain-copy.html +9 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/state-copy.html +11 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/attribute-edges.html +7 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/components.tsx +16 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/decorative-badge.vue +7 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/emoji-icons.tsx +9 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/jsx-edges.tsx +1 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.html +6 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.tsx +8 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/vanity-stats.html +5 -0
- package/packages/shared-skills/skills/programming/SKILL.md +10 -7
- package/packages/shared-skills/skills/programming/references/typescript/README.md +10 -7
- package/packages/shared-skills/skills/programming/references/typescript/bootstrap.md +9 -23
- package/packages/shared-skills/skills/programming/references/typescript/oxc-lint.md +130 -0
- package/packages/shared-skills/skills/programming/references/typescript/tsconfig-strict.md +6 -62
- package/packages/shared-skills/skills/programming/scripts/typescript/check-no-excuse-rules.ts +12 -12
- package/packages/shared-skills/skills/programming/scripts/typescript/new-project.test.ts +162 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/new-project.ts +20 -81
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/.oxfmtrc.json +9 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/.oxlintrc.json +46 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/LICENSE +21 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/index.js +10 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.js +28 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.js +62 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/oxc/tsconfig.json +29 -0
- package/packages/shared-skills/skills/refactor/SKILL.md +13 -13
- package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +1 -1
- package/packages/shared-skills/skills/ulw-execute/SKILL.md +1 -1
- package/packages/shared-skills/skills/ulw-research/AGENTS.md +21 -3
- package/packages/shared-skills/skills/ulw-research/SKILL.md +37 -12
- package/packages/shared-skills/skills/ulw-research/references/deliverable-phase.md +77 -16
- package/packages/shared-skills/skills/ulw-research/references/fact-ledger-grammar.md +134 -0
- package/packages/shared-skills/skills/ulw-research/references/fact-ledger.md +95 -0
- package/packages/shared-skills/skills/ulw-research/references/fidelity-claim-kinds.md +19 -0
- package/packages/shared-skills/skills/ulw-research/references/report-gates.md +68 -3
- package/packages/shared-skills/skills/ulw-research/references/report-visualization.md +2 -0
- package/packages/shared-skills/skills/ulw-research/references/unit-rules.md +157 -0
- package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.mjs +116 -0
- package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.test.ts +193 -0
- package/packages/shared-skills/skills/ulw-research/scripts/claims-index.mjs +125 -0
- package/packages/shared-skills/skills/ulw-research/scripts/claims-index.test.ts +149 -0
- package/packages/shared-skills/skills/ulw-research/scripts/cli-support.mjs +19 -5
- package/packages/shared-skills/skills/ulw-research/scripts/cli-support.test.ts +13 -2
- package/packages/shared-skills/skills/ulw-research/scripts/contracts.mjs +89 -3
- package/packages/shared-skills/skills/ulw-research/scripts/contracts.test.ts +100 -12
- package/packages/shared-skills/skills/ulw-research/scripts/copy-returns.test.ts +183 -0
- package/packages/shared-skills/skills/ulw-research/scripts/delivery-barrier.test.ts +245 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-meaning.mjs +191 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands.mjs +239 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.mjs +66 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.test.ts +375 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-expr.mjs +108 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-fill.mjs +194 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-fill.test.ts +221 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-grammar.test.ts +197 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.mjs +250 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.test.ts +156 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-legacy.test.ts +160 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-schema.mjs +221 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-schema.test.ts +43 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger.mjs +123 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger.test.ts +254 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-locate.mjs +231 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-locate.test.ts +118 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-pairs.mjs +187 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-pairs.test.ts +167 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-recompute.mjs +89 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-dimensions.test.ts +409 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-rules.test.ts +388 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-binding.mjs +130 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-binding.test.ts +81 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-brief.mjs +150 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-brief.test.ts +179 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-claims.mjs +89 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-lexicon.mjs +145 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-lexicon.test.ts +117 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-records.mjs +163 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-state.mjs +64 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-state.test.ts +46 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-trace.mjs +85 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-trace.test.ts +58 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.mjs +229 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.test.ts +270 -0
- package/packages/shared-skills/skills/ulw-research/scripts/gates-context.test.ts +64 -0
- package/packages/shared-skills/skills/ulw-research/scripts/gates-fidelity.mjs +113 -0
- package/packages/shared-skills/skills/ulw-research/scripts/gates-fidelity.test.ts +73 -0
- package/packages/shared-skills/skills/ulw-research/scripts/gates-static.mjs +29 -9
- package/packages/shared-skills/skills/ulw-research/scripts/gates-structure.mjs +1 -1
- package/packages/shared-skills/skills/ulw-research/scripts/gates-text.mjs +1 -27
- package/packages/shared-skills/skills/ulw-research/scripts/html-lite.mjs +2 -2
- package/packages/shared-skills/skills/ulw-research/scripts/html-markup.mjs +182 -0
- package/packages/shared-skills/skills/ulw-research/scripts/lexicon.mjs +47 -0
- package/packages/shared-skills/skills/ulw-research/scripts/lexicon.test.ts +57 -0
- package/packages/shared-skills/skills/ulw-research/scripts/md-lite.mjs +193 -0
- package/packages/shared-skills/skills/ulw-research/scripts/md-lite.test.ts +271 -0
- package/packages/shared-skills/skills/ulw-research/scripts/meaning-check.mjs +196 -0
- package/packages/shared-skills/skills/ulw-research/scripts/meaning-check.test.ts +228 -0
- package/packages/shared-skills/skills/ulw-research/scripts/numerals.mjs +226 -0
- package/packages/shared-skills/skills/ulw-research/scripts/numerals.test.ts +120 -0
- package/packages/shared-skills/skills/ulw-research/scripts/outcome.mjs +8 -8
- package/packages/shared-skills/skills/ulw-research/scripts/outcome.test.ts +29 -0
- package/packages/shared-skills/skills/ulw-research/scripts/particles-ko.mjs +108 -0
- package/packages/shared-skills/skills/ulw-research/scripts/particles-ko.test.ts +86 -0
- package/packages/shared-skills/skills/ulw-research/scripts/placeholder.mjs +184 -0
- package/packages/shared-skills/skills/ulw-research/scripts/placeholder.test.ts +77 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-apply.mjs +115 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-apply.test.ts +363 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-diff.mjs +31 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-diff.test.ts +168 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-markup.test.ts +187 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-project.mjs +125 -0
- package/packages/shared-skills/skills/ulw-research/scripts/polish-rules.mjs +170 -0
- package/packages/shared-skills/skills/ulw-research/scripts/rational.mjs +139 -0
- package/packages/shared-skills/skills/ulw-research/scripts/rational.test.ts +46 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-commands.mjs +21 -10
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools.mjs +15 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools.test.ts +458 -2
- package/packages/shared-skills/skills/ulw-research/scripts/sentence-split.mjs +77 -0
- package/packages/shared-skills/skills/ulw-research/scripts/sentence-split.test.ts +109 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-commands.mjs +140 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.mjs +176 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.test.ts +113 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/assets/share.csv +3 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/claim-graph.md +13 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/gen-legacy-dev.mjs +89 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-basic.json +223 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-legacy-dev.json +859 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-verify.json +420 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/report-bad.html +19 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/report-good.html +39 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/acronyms.json +3 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/meta.json +9 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/sentences.jsonl +7 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/text.txt +7 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4.html +19 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/acronyms.json +1 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/meta.json +9 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/sentences.jsonl +1 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/text.txt +1 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S9.txt +1 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-locked.md +17 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-pending.md +17 -0
- package/packages/shared-skills/skills/ulw-research/scripts/text-normalize.mjs +82 -0
- package/packages/shared-skills/skills/ulw-research/scripts/text-normalize.test.ts +73 -0
- package/packages/shared-skills/skills/ulw-research/scripts/text-similarity.mjs +28 -0
- package/packages/shared-skills/skills/ulw-research/scripts/text-similarity.test.ts +38 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-algebra.mjs +101 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-errors.mjs +23 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-metadata.mjs +31 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-pairs.mjs +72 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-precision.mjs +44 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-rules-shapes.mjs +64 -0
- package/packages/shared-skills/skills/ulw-research/scripts/unit-rules.mjs +173 -0
- package/packages/shared-skills/skills/ulw-research/scripts/units.mjs +105 -0
- package/packages/shared-skills/skills/ulw-research/scripts/units.test.ts +83 -0
- package/packages/shared-skills/skills/visual-qa/SKILL.md +70 -63
- package/packages/shared-skills/skills/visual-qa/scripts/skill-doc-fields.test.ts +34 -0
- package/script/qa/web-terminal-visual-qa.mjs +6 -2
- package/script/qa/xterm-live-terminal.mjs +26 -3
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
// outcome.mjs - the per-run outcome manifest (`outcome.json`) and the closing briefing.
|
|
2
|
-
//
|
|
3
|
-
// manifest, the sources-ledger text, and an injected `now`. node: builtins only.
|
|
1
|
+
// outcome.mjs - the per-run outcome manifest (`outcome.json`) and the closing briefing. Manifest functions are pure (they return a new manifest).
|
|
2
|
+
// The briefing reads only the manifest, the sources-ledger text, and an injected `now`. node: builtins only.
|
|
4
3
|
|
|
5
4
|
import * as nodeFs from "node:fs"
|
|
6
5
|
import { basename, dirname, join } from "node:path"
|
|
7
6
|
|
|
8
|
-
import { DELIVERABLE_FORMATS, DELIVERABLE_STATUSES, GATE_NAMES, GATE_STATUSES, LANES } from "./contracts.mjs"
|
|
9
|
-
import { MANIFEST_CODES, SCHEMA_VERSION, validateOutcomeManifest } from "./contracts.mjs"
|
|
7
|
+
import { DELIVERABLE_FORMATS, DELIVERABLE_STATUSES, GATE_NAMES, GATE_STATUSES, LANES, MANIFEST_CODES, normalizeManifest, SCHEMA_VERSION, validateOutcomeManifest } from "./contracts.mjs"
|
|
10
8
|
|
|
11
9
|
export const MANIFEST_FILENAME = "outcome.json"
|
|
12
10
|
const MISSING = MANIFEST_CODES[0]
|
|
@@ -87,7 +85,7 @@ export function setDeliverable(manifest, format, status, detail = {}) {
|
|
|
87
85
|
const next = clone(manifest)
|
|
88
86
|
const index = next.deliverables.findIndex((row) => row.format === format)
|
|
89
87
|
const row = { format, status, promised: index >= 0 ? next.deliverables[index].promised : false, updatedAt: stamp(detail.now) }
|
|
90
|
-
for (const key of ["path", "reason", "pages", "bytes"]) {
|
|
88
|
+
for (const key of ["path", "reason", "pages", "bytes", "verifiedBy", "renderedFrom"]) {
|
|
91
89
|
if (detail[key] !== undefined) row[key] = detail[key]
|
|
92
90
|
}
|
|
93
91
|
if (index >= 0) next.deliverables[index] = row
|
|
@@ -95,11 +93,13 @@ export function setDeliverable(manifest, format, status, detail = {}) {
|
|
|
95
93
|
return next
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
export function setGate(manifest, gate, status) {
|
|
96
|
+
export function setGate(manifest, gate, status, detail = {}) {
|
|
99
97
|
assertOneOf("unknown_gate", "gate", gate, GATE_NAMES)
|
|
100
98
|
assertOneOf("unknown_gate_status", "gate status", status, GATE_STATUSES)
|
|
99
|
+
if (gate === "fidelity" && status === "not_run" && (typeof detail.reason !== "string" || !detail.reason.trim())) throw new OutcomeError("gate_reason_required", "fidelity not_run requires a non-empty --reason")
|
|
101
100
|
const next = clone(manifest)
|
|
102
101
|
next.gates[gate] = status
|
|
102
|
+
next.gateHistory = [...(next.gateHistory ?? []), { gate, status, ...(detail.reason !== undefined ? { reason: detail.reason.trim() } : {}), at: stamp(detail.now) }]
|
|
103
103
|
return next
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -226,7 +226,7 @@ function assertValid(manifest, where) {
|
|
|
226
226
|
export function readManifest(file) {
|
|
227
227
|
let manifest
|
|
228
228
|
try {
|
|
229
|
-
manifest = JSON.parse(nodeFs.readFileSync(file, "utf8"))
|
|
229
|
+
manifest = normalizeManifest(JSON.parse(nodeFs.readFileSync(file, "utf8")))
|
|
230
230
|
} catch (error) {
|
|
231
231
|
if (error instanceof SyntaxError) throw new OutcomeError("invalid_manifest", `${file}: not valid JSON (${error.message})`)
|
|
232
232
|
throw error
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Korean particle normalization after a filled value: read the value's final sound, then pick the
|
|
2
|
+
// particle form. Hangul and the particle table are \u escapes (this directory ships no Hangul).
|
|
3
|
+
|
|
4
|
+
// Unit token -> reading of its Korean name. Duplicated from the planned units.koreanReadingOf so this
|
|
5
|
+
// module has no dependency on a sibling not yet landed; the units module reconciles the two tables.
|
|
6
|
+
// Hangul unit words (won, dalleo, jo, eok, ...) need no row: they are read by code point.
|
|
7
|
+
const UNIT_READINGS = new Map([
|
|
8
|
+
["%", "open"], // peosenteu
|
|
9
|
+
["%p", "open"], // peosenteu pointeu
|
|
10
|
+
["pp", "open"], // peosenteu pointeu
|
|
11
|
+
["m", "open"], // miteo
|
|
12
|
+
["mm", "open"], // millimiteo
|
|
13
|
+
["cm", "open"], // sentimiteo
|
|
14
|
+
["km", "open"], // killomiteo
|
|
15
|
+
["kg", "closed"], // killogeuraem
|
|
16
|
+
["g", "closed"], // geuraem
|
|
17
|
+
["t", "closed"], // ton
|
|
18
|
+
["s", "open"], // cho
|
|
19
|
+
["ms", "open"], // millicho
|
|
20
|
+
["min", "closed"], // bun
|
|
21
|
+
["h", "closed"], // sigan
|
|
22
|
+
["B", "open"], // baiteu
|
|
23
|
+
["KB", "open"], // killobaiteu
|
|
24
|
+
["MB", "open"], // megabaiteu
|
|
25
|
+
["GB", "open"], // gigabaiteu
|
|
26
|
+
["TB", "open"], // terabaiteu
|
|
27
|
+
["C", "open"], // do
|
|
28
|
+
["\u00B0C", "open"], // do
|
|
29
|
+
["F", "open"], // do
|
|
30
|
+
["\u00B0F", "open"], // do
|
|
31
|
+
["USD", "open"], // dalleo
|
|
32
|
+
["$", "open"], // dalleo
|
|
33
|
+
["KRW", "closed"], // won
|
|
34
|
+
["EUR", "open"], // yuro
|
|
35
|
+
["JPY", "closed"], // en
|
|
36
|
+
["x", "open"], // bae
|
|
37
|
+
["\u00D7", "open"], // bae
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
// Sino-Korean digit readings: yeong il i sam sa o yuk chil pal gu.
|
|
41
|
+
const DIGIT_READINGS = Object.freeze(["closed", "l", "open", "closed", "open", "open", "closed", "l", "l", "open"])
|
|
42
|
+
|
|
43
|
+
// Spoken ending of a power of ten beyond the units digit: sip baek cheon, then the 10^4 group markers
|
|
44
|
+
// man eok jo gyeong. Only jo (10^12) is open.
|
|
45
|
+
const TEN_POWER_READINGS = Object.freeze(["closed", "closed", "closed"])
|
|
46
|
+
const GROUP_READINGS = Object.freeze({ 4: "closed", 8: "closed", 12: "open", 16: "closed" })
|
|
47
|
+
|
|
48
|
+
// [particle, form after an open vowel, form after final l, form after another final consonant]
|
|
49
|
+
const PARTICLES = Object.freeze([
|
|
50
|
+
Object.freeze(["\uC73C\uB85C", "\uB85C", "\uB85C", "\uC73C\uB85C"]),
|
|
51
|
+
Object.freeze(["\uB85C", "\uB85C", "\uB85C", "\uC73C\uB85C"]),
|
|
52
|
+
Object.freeze(["\uC740", "\uB294", "\uC740", "\uC740"]),
|
|
53
|
+
Object.freeze(["\uB294", "\uB294", "\uC740", "\uC740"]),
|
|
54
|
+
Object.freeze(["\uC774", "\uAC00", "\uC774", "\uC774"]),
|
|
55
|
+
Object.freeze(["\uAC00", "\uAC00", "\uC774", "\uC774"]),
|
|
56
|
+
Object.freeze(["\uC744", "\uB97C", "\uC744", "\uC744"]),
|
|
57
|
+
Object.freeze(["\uB97C", "\uB97C", "\uC744", "\uC744"]),
|
|
58
|
+
Object.freeze(["\uC640", "\uC640", "\uACFC", "\uACFC"]),
|
|
59
|
+
Object.freeze(["\uACFC", "\uC640", "\uACFC", "\uACFC"]),
|
|
60
|
+
])
|
|
61
|
+
const FORM_INDEX = Object.freeze({ open: 1, l: 2, closed: 3 })
|
|
62
|
+
|
|
63
|
+
const HANGUL_FIRST = 0xac00
|
|
64
|
+
const HANGUL_LAST = 0xd7a3
|
|
65
|
+
const BOUNDARY = /^[\s\p{P}]/u
|
|
66
|
+
const TRAILING_DIGITS = /([0-9][0-9,]*)(?:\.([0-9]+))?$/
|
|
67
|
+
|
|
68
|
+
function hangulReading(char) {
|
|
69
|
+
const code = char.codePointAt(0)
|
|
70
|
+
if (code === undefined || code < HANGUL_FIRST || code > HANGUL_LAST) return null
|
|
71
|
+
const finalConsonant = (code - HANGUL_FIRST) % 28
|
|
72
|
+
if (finalConsonant === 0) return "open"
|
|
73
|
+
return finalConsonant === 8 ? "l" : "closed"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function numberReading(text) {
|
|
77
|
+
const match = TRAILING_DIGITS.exec(text)
|
|
78
|
+
if (!match) return null
|
|
79
|
+
// Decimals read digit by digit: 6.50 ends on yeong, so a trailing 0 after the point is closed.
|
|
80
|
+
if (match[2] !== undefined) return DIGIT_READINGS[Number(match[2].at(-1))]
|
|
81
|
+
const digits = match[1].replaceAll(",", "")
|
|
82
|
+
const trailingZeros = digits.length - digits.replace(/0+$/, "").length
|
|
83
|
+
if (trailingZeros === 0 || trailingZeros === digits.length) return DIGIT_READINGS[Number(digits.at(-1))]
|
|
84
|
+
// From 10^4 up the spoken end is the last non-zero group word (sipjo ends on jo), not sip/baek/cheon.
|
|
85
|
+
if (trailingZeros >= 4) return GROUP_READINGS[trailingZeros - (trailingZeros % 4)] ?? null
|
|
86
|
+
return TEN_POWER_READINGS[trailingZeros - 1]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function finalReading(valueText, unitToken) {
|
|
90
|
+
if (unitToken !== null && unitToken !== undefined) return UNIT_READINGS.get(unitToken) ?? hangulReading(unitToken.at(-1) ?? "")
|
|
91
|
+
const text = valueText.trimEnd()
|
|
92
|
+
const last = text.at(-1)
|
|
93
|
+
if (last === undefined) return null
|
|
94
|
+
const hangul = hangulReading(last)
|
|
95
|
+
if (hangul !== null) return hangul
|
|
96
|
+
if (last >= "0" && last <= "9") return numberReading(text)
|
|
97
|
+
const token = /[^\s0-9.,]+$/u.exec(text)?.[0] ?? ""
|
|
98
|
+
return UNIT_READINGS.get(token) ?? null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function rewriteParticle(following, reading) {
|
|
102
|
+
const entry = PARTICLES.find(([particle]) => following.startsWith(particle))
|
|
103
|
+
if (entry === undefined) return { text: following, applied: false, candidate: false }
|
|
104
|
+
const rest = following.slice(entry[0].length)
|
|
105
|
+
const index = FORM_INDEX[reading]
|
|
106
|
+
if ((rest !== "" && !BOUNDARY.test(rest)) || index === undefined) return { text: following, applied: false, candidate: true }
|
|
107
|
+
return { text: entry[index] + rest, applied: true, candidate: true }
|
|
108
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// placeholder.mjs - the fact pointer grammar of the fill step and its render helpers.
|
|
2
|
+
// Value pointers: {{F12:label}}, {{F12:label:value}}, {{F12:label:unit}}, {{F12:label:q}}.
|
|
3
|
+
// Quote pointers: {{Q7:label}}, {{Q7:label:lead=18}}, {{Q7:label:from="x":to="y"}} (anchors are
|
|
4
|
+
// JSON strings, so they may hold a colon or an escaped quote). Labels are compared exactly by the
|
|
5
|
+
// caller; this module never guesses an id. Pure functions; node: builtins only.
|
|
6
|
+
|
|
7
|
+
import { parseNumeral } from "./numerals.mjs"
|
|
8
|
+
|
|
9
|
+
export const ELLIPSIS = "\u2026"
|
|
10
|
+
|
|
11
|
+
const ID = /^([FQ])\d+$/
|
|
12
|
+
const LABEL = /^[^\s:{}"]+$/
|
|
13
|
+
const VALUE_MODES = new Set(["value", "unit", "q"])
|
|
14
|
+
const LEAD = /^lead=([1-9]\d*)$/
|
|
15
|
+
const LINEAGE = Object.freeze({ measured: "MEASURED", assumed: "ASSUMED", derived: "DERIVED", converted: "DERIVED" })
|
|
16
|
+
|
|
17
|
+
/** End index (exclusive) of a JSON string starting at `at`, or -1 when it is not closed on its line. */
|
|
18
|
+
function jsonStringEnd(text, at) {
|
|
19
|
+
let i = at + 1
|
|
20
|
+
while (i < text.length && text[i] !== '"' && text[i] !== "\n") i += text[i] === "\\" ? 2 : 1
|
|
21
|
+
return text[i] === '"' ? i + 1 : -1
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readJsonString(text, at) {
|
|
25
|
+
if (text[at] !== '"') return null
|
|
26
|
+
const end = jsonStringEnd(text, at)
|
|
27
|
+
if (end === -1) return null
|
|
28
|
+
try {
|
|
29
|
+
return { value: JSON.parse(text.slice(at, end)), end }
|
|
30
|
+
} catch {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseAnchors(tail) {
|
|
36
|
+
if (!tail.startsWith("from=")) return null
|
|
37
|
+
const from = readJsonString(tail, 5)
|
|
38
|
+
if (from === null || !tail.startsWith(":to=", from.end)) return null
|
|
39
|
+
const to = readJsonString(tail, from.end + 4)
|
|
40
|
+
if (to === null || to.end !== tail.length || from.value === "" || to.value === "") return null
|
|
41
|
+
return { from: from.value, to: to.value }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @returns the parsed pointer, or { error } for a malformed one. */
|
|
45
|
+
export function parsePlaceholder(token) {
|
|
46
|
+
if (!token.startsWith("{{") || !token.endsWith("}}")) return { error: "a placeholder is {{ID:label...}}" }
|
|
47
|
+
const body = token.slice(2, -2)
|
|
48
|
+
const colon = body.indexOf(":")
|
|
49
|
+
const id = colon === -1 ? body : body.slice(0, colon)
|
|
50
|
+
const idMatch = ID.exec(id)
|
|
51
|
+
if (idMatch === null) return { error: `"${id}" is not an F<n> or Q<n> id` }
|
|
52
|
+
if (colon === -1) return { error: `${id} has no label; write {{${id}:label}}` }
|
|
53
|
+
const rest = body.slice(colon + 1)
|
|
54
|
+
const second = rest.indexOf(":")
|
|
55
|
+
const label = second === -1 ? rest : rest.slice(0, second)
|
|
56
|
+
if (!LABEL.test(label)) return { error: `"${label}" is not a label` }
|
|
57
|
+
const tail = second === -1 ? null : rest.slice(second + 1)
|
|
58
|
+
const base = { id, kind: idMatch[1], label }
|
|
59
|
+
if (idMatch[1] === "F") {
|
|
60
|
+
if (tail === null) return { ...base, mode: "full" }
|
|
61
|
+
return VALUE_MODES.has(tail) ? { ...base, mode: tail } : { error: `"${tail}" is not a value mode (value, unit, q)` }
|
|
62
|
+
}
|
|
63
|
+
if (tail === null) return { ...base, mode: "full", selector: "full" }
|
|
64
|
+
const lead = LEAD.exec(tail)
|
|
65
|
+
if (lead !== null) return { ...base, mode: "lead", lead: Number(lead[1]), selector: `lead=${lead[1]}` }
|
|
66
|
+
const anchors = parseAnchors(tail)
|
|
67
|
+
if (anchors === null) return { error: `"${tail}" is not a quote selector (lead=N or from="..":to="..")` }
|
|
68
|
+
return { ...base, mode: "span", ...anchors, selector: `from=${anchors.from};to=${anchors.to}` }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** End index (exclusive) of the pointer opened at `at`, or -1 when it is not closed on its line. */
|
|
72
|
+
function placeholderEnd(text, at) {
|
|
73
|
+
let i = at + 2
|
|
74
|
+
while (i < text.length && text[i] !== "\n") {
|
|
75
|
+
if (text[i] === '"') {
|
|
76
|
+
const end = jsonStringEnd(text, i)
|
|
77
|
+
if (end === -1) return -1
|
|
78
|
+
i = end
|
|
79
|
+
} else if (text.startsWith("}}", i)) return i + 2
|
|
80
|
+
else i++
|
|
81
|
+
}
|
|
82
|
+
return -1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Every `{{...}}` pointer in source order: [{ token, start, end, parsed }]. */
|
|
86
|
+
export function findPlaceholders(text) {
|
|
87
|
+
const found = []
|
|
88
|
+
let at = text.indexOf("{{")
|
|
89
|
+
while (at !== -1) {
|
|
90
|
+
const end = placeholderEnd(text, at)
|
|
91
|
+
if (end === -1) {
|
|
92
|
+
found.push({ token: text.slice(at, text.indexOf("\n", at) === -1 ? text.length : text.indexOf("\n", at)), start: at, end: at + 2, parsed: { error: "the placeholder is not closed on its line" } })
|
|
93
|
+
at = text.indexOf("{{", at + 2)
|
|
94
|
+
continue
|
|
95
|
+
}
|
|
96
|
+
const token = text.slice(at, end)
|
|
97
|
+
found.push({ token, start: at, end, parsed: parsePlaceholder(token) })
|
|
98
|
+
at = text.indexOf("{{", end)
|
|
99
|
+
}
|
|
100
|
+
return found
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function occurrences(text, needle) {
|
|
104
|
+
let count = 0
|
|
105
|
+
for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + 1)) count++
|
|
106
|
+
return count
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function cut(quote, start, end) {
|
|
110
|
+
return { text: `${start > 0 ? ELLIPSIS : ""}${quote.slice(start, end)}${end < quote.length ? ELLIPSIS : ""}`, start, end }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The contiguous span from `from` through `to`; each anchor must occur exactly once, in order. */
|
|
114
|
+
export function subSpan(quote, from, to) {
|
|
115
|
+
if (occurrences(quote, from) !== 1 || occurrences(quote, to) !== 1) return null
|
|
116
|
+
const start = quote.indexOf(from)
|
|
117
|
+
const toAt = quote.indexOf(to)
|
|
118
|
+
if (toAt < start || toAt + to.length < start + from.length) return null
|
|
119
|
+
return cut(quote, start, toAt + to.length)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The first `n` whitespace-delimited words, with an ellipsis when words were cut. */
|
|
123
|
+
export function lead(quote, n) {
|
|
124
|
+
const words = [...quote.matchAll(/\S+/g)]
|
|
125
|
+
if (words.length <= n) return { text: quote, start: 0, end: quote.length }
|
|
126
|
+
const last = words[n - 1]
|
|
127
|
+
return cut(quote, 0, last.index + last[0].length)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The value and unit parts of a row's raw text ("4.2 eok won" -> value "4.2 eok", unit "won"). */
|
|
131
|
+
export function valueParts(row) {
|
|
132
|
+
const unitText = parseNumeral(row.raw)?.unitRaw ?? row.unit
|
|
133
|
+
const valueText = unitText && row.raw.endsWith(unitText) ? row.raw.slice(0, -unitText.length).trimEnd() : (row.value ?? row.raw)
|
|
134
|
+
return { valueText, unitText: unitText ?? "" }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The quote interval holding the row's qualifier and its raw quantity, or null if absent. */
|
|
138
|
+
export function qualifiedText(row) {
|
|
139
|
+
if (row.qualifier === null) return row.raw
|
|
140
|
+
for (let numeral = parseNumeral(row.quote); numeral !== null; numeral = parseNumeral(row.quote, numeral.span[1])) {
|
|
141
|
+
if (numeral.raw !== row.raw || numeral.qualifierRaw === null) continue
|
|
142
|
+
const [start, end] = numeral.span
|
|
143
|
+
const before = row.quote.lastIndexOf(numeral.qualifierRaw, start)
|
|
144
|
+
const between = before === -1 ? [] : row.quote.slice(before + numeral.qualifierRaw.length, start).split(/\s+/u).filter(Boolean)
|
|
145
|
+
if (before !== -1 && between.length <= 1) return row.quote.slice(before, end)
|
|
146
|
+
const after = row.quote.indexOf(numeral.qualifierRaw, end)
|
|
147
|
+
if (after !== -1) return row.quote.slice(start, after + numeral.qualifierRaw.length)
|
|
148
|
+
}
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function escapeHtml(text) {
|
|
153
|
+
return String(text).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The elements the renderers below emit as fact spans; recognizers build their patterns from this. */
|
|
157
|
+
export const FACT_ELEMENT_TAGS = Object.freeze(["data", "q", "blockquote"])
|
|
158
|
+
|
|
159
|
+
export function renderValueHtml(row, text) {
|
|
160
|
+
const unit = row.unit === null ? "" : ` data-unit="${escapeHtml(row.unit)}"`
|
|
161
|
+
return `<data class="fact" value="${escapeHtml(row.value)}" data-fact="${row.fact_id}"${unit} data-lineage="${LINEAGE[row.kind]}">${escapeHtml(text)}</data>`
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function renderQuote(row, selector, text, format) {
|
|
165
|
+
const marker = `[${row.source_id}]`
|
|
166
|
+
if (format === "md") return `"${text}" ${marker}`
|
|
167
|
+
return `<q data-fact="${row.fact_id}" data-quote-sel="${escapeHtml(selector)}">${escapeHtml(text)}</q> ${marker}`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const RENDERED_MD_QUOTE = /^"([\s\S]*)" (\[S\d+\])$/u
|
|
171
|
+
|
|
172
|
+
/** The quote text and source marker of bytes renderQuote wrote for md, or null for any other layout. */
|
|
173
|
+
export function parseRenderedQuote(body) {
|
|
174
|
+
const match = RENDERED_MD_QUOTE.exec(body)
|
|
175
|
+
return match ? { text: match[1], marker: match[2] } : null
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The attributed block that replaces a twice-failed sentence; entity and valid_at stay outside the quote. */
|
|
179
|
+
export function renderBlockquote(row, key, format) {
|
|
180
|
+
const attribution = row.entity === null ? "" : `, on ${row.entity}${row.valid_at === null ? "" : ` (${row.valid_at})`}`
|
|
181
|
+
const footer = `[${row.source_id}]${attribution}`
|
|
182
|
+
if (format === "md") return `> "${row.quote}"\n> ${footer}`
|
|
183
|
+
return `<blockquote data-fact="${row.fact_id}" data-replaced="${escapeHtml(key)}">"${escapeHtml(row.quote)}" <footer>${escapeHtml(footer)}</footer></blockquote>`
|
|
184
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// polish-apply.mjs - checked, per-edit application of a proofread lane's polish edits.
|
|
2
|
+
//
|
|
3
|
+
// An edit whose before or after holds <, > or & is polish_edit_rejected (POLISH_MARKUP_REASON)
|
|
4
|
+
// before anything else, so no edit can create, alter, close or escape a tag, comment,
|
|
5
|
+
// bogus comment, CDATA section, entity or script, whatever the tokenizer models; a located region
|
|
6
|
+
// that overlaps a character reference or opens one (it starts inside `&name`) is rejected with
|
|
7
|
+
// POLISH_REFERENCE_REASON, so an edit can neither change nor complete an existing reference.
|
|
8
|
+
// Those two guards are the early, actionable refusals; the guarantee itself is the whole-document
|
|
9
|
+
// skeleton comparison (html-markup.skeletonChange) that polish-rules runs in both gates: every
|
|
10
|
+
// markup token and every character reference stays byte-identical, and an accepted edit's span
|
|
11
|
+
// holds no skeleton token, so any difference refuses the edit and reports polish_diff_fail.
|
|
12
|
+
// applyEdits(html, edits, ledger) applies each {before, after, reason} edit in edits-file order,
|
|
13
|
+
// against the output of the edits accepted before it. `before` must occur exactly once (runs of
|
|
14
|
+
// whitespace match any whitespace run) and must not cut through a fact span; otherwise the edit is
|
|
15
|
+
// polish_edit_unlocated. A located edit is applied whole or not at all: it is polish_edit_rejected
|
|
16
|
+
// when polish-rules.polishDefects(..., {ordered: true}) finds any defect between the current
|
|
17
|
+
// document and the document with the edit (per edit), or between the ORIGINAL input and the
|
|
18
|
+
// document with the edit (whole document: the baseline polish-diff uses). Ordered is stricter than
|
|
19
|
+
// polish-diff's multiset comparison and the last accepted candidate is the output, so a clean run
|
|
20
|
+
// is always polish-diff clean: no cross-edit case is left to the backstop. The rules see the
|
|
21
|
+
// text-node projection and freeze every markup byte, including script/style/template content.
|
|
22
|
+
// validatePolishEdits and POLISH_EDIT_FIELDS are the edit
|
|
23
|
+
// contract every caller (the CLI included) uses. No IO, no model. Plain Node ESM.
|
|
24
|
+
|
|
25
|
+
import { CHARACTER_REFERENCE } from "./html-markup.mjs"
|
|
26
|
+
import { factSpans } from "./polish-project.mjs"
|
|
27
|
+
import { polishDefects } from "./polish-rules.mjs"
|
|
28
|
+
|
|
29
|
+
export { numeralKeys, project, SLOT, termCounts, textOf } from "./polish-project.mjs"
|
|
30
|
+
|
|
31
|
+
/** The fields of one polish edit: before and after are required strings, reason an optional string. */
|
|
32
|
+
export const POLISH_EDIT_FIELDS = Object.freeze({ before: "required", after: "required", reason: "optional" })
|
|
33
|
+
|
|
34
|
+
/** Throws a TypeError naming the first edit that breaks POLISH_EDIT_FIELDS; returns the edits. */
|
|
35
|
+
export function validatePolishEdits(edits) {
|
|
36
|
+
if (!Array.isArray(edits)) throw new TypeError("edits must be an array")
|
|
37
|
+
edits.forEach((edit, index) => {
|
|
38
|
+
if (edit === null || typeof edit !== "object" || Array.isArray(edit)) throw new TypeError(`edit ${index} must be an object`)
|
|
39
|
+
for (const [field, need] of Object.entries(POLISH_EDIT_FIELDS)) {
|
|
40
|
+
if (need === "optional" && edit[field] === undefined) continue
|
|
41
|
+
if (typeof edit[field] !== "string") throw new TypeError(`edit ${index} needs ${need === "optional" ? "a string" : "string"} ${field}`)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
return edits
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Characters an edit's before and after may never contain. */
|
|
48
|
+
export const POLISH_MARKUP_CHARACTERS = /[<>&]/
|
|
49
|
+
/** The actionable rejection reason for an edit holding a markup character. */
|
|
50
|
+
export const POLISH_MARKUP_REASON = "edit contains markup characters (<, >, &): route this section through the full fidelity gates"
|
|
51
|
+
/** The actionable rejection reason for a located region touching a character reference. */
|
|
52
|
+
export const POLISH_REFERENCE_REASON = "edit touches a character reference: route this section through the full fidelity gates"
|
|
53
|
+
|
|
54
|
+
/** True when [start, end) overlaps a character reference of html or starts inside one. */
|
|
55
|
+
export function touchesReference(html, start, end) {
|
|
56
|
+
for (const match of String(html).matchAll(CHARACTER_REFERENCE)) {
|
|
57
|
+
if (match.index < end && match.index + match[0].length > start) return true
|
|
58
|
+
}
|
|
59
|
+
return /&[#\w]*$/.test(html.slice(Math.max(0, start - 16), start))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
63
|
+
|
|
64
|
+
/** The single whitespace-normalized match of `before` in html as {start, end}, or {count} otherwise. */
|
|
65
|
+
function locate(html, before) {
|
|
66
|
+
if (before.trim() === "") return { count: 0 }
|
|
67
|
+
const pattern = new RegExp(before.split(/\s+/).map(escape).join("\\s+"), "g")
|
|
68
|
+
const hits = [...html.matchAll(pattern)]
|
|
69
|
+
return hits.length === 1 ? { count: 1, start: hits[0].index, end: hits[0].index + hits[0][0].length } : { count: hits.length }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The id of a fact span the region [start, end) cuts through (overlaps without containing), or null. */
|
|
73
|
+
export function cutSpan(html, start, end) {
|
|
74
|
+
return factSpans(html).find((span) => span.start < end && span.end > start && !(start <= span.start && span.end <= end))?.id ?? null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} html the filled report
|
|
79
|
+
* @param {{ before: string, after: string, reason?: string }[]} edits in edits-file order
|
|
80
|
+
* @param {{ rows: object[] }} ledger
|
|
81
|
+
* @returns {{ out: string, applied: number[], rejected: { index: number, code: string, reason: string }[],
|
|
82
|
+
* unlocated: { index: number, code: string, reason: string }[] }}
|
|
83
|
+
*/
|
|
84
|
+
export function applyEdits(html, edits, ledger) {
|
|
85
|
+
validatePolishEdits(edits)
|
|
86
|
+
const original = String(html)
|
|
87
|
+
const result = { out: original, applied: [], rejected: [], unlocated: [] }
|
|
88
|
+
const defects = (candidate) => {
|
|
89
|
+
const messages = [result.out, original].flatMap((base) => polishDefects(base, candidate, ledger, { ordered: true }).map((d) => d.message))
|
|
90
|
+
return [...new Set(messages)]
|
|
91
|
+
}
|
|
92
|
+
edits.forEach((edit, index) => {
|
|
93
|
+
const touches = POLISH_MARKUP_CHARACTERS.test(edit.before) || POLISH_MARKUP_CHARACTERS.test(edit.after)
|
|
94
|
+
const where = locate(result.out, edit.before)
|
|
95
|
+
if (where.count !== 1 && !touches) {
|
|
96
|
+
result.unlocated.push({ index, code: "polish_edit_unlocated", reason: `before matches ${where.count} times; it must match exactly once` })
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
const reasons = touches ? [POLISH_MARKUP_REASON] : []
|
|
100
|
+
const candidate = where.count === 1 ? result.out.slice(0, where.start) + edit.after + result.out.slice(where.end) : result.out
|
|
101
|
+
if (where.count === 1) {
|
|
102
|
+
const cut = cutSpan(result.out, where.start, where.end)
|
|
103
|
+
if (touchesReference(result.out, where.start, where.end)) reasons.push(POLISH_REFERENCE_REASON)
|
|
104
|
+
reasons.push(...defects(candidate))
|
|
105
|
+
if (cut !== null) reasons.push(`the edit cuts through fact span ${cut}`)
|
|
106
|
+
}
|
|
107
|
+
if (reasons.length > 0) {
|
|
108
|
+
result.rejected.push({ index, code: "polish_edit_rejected", reason: reasons.join("; ") })
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
result.out = candidate
|
|
112
|
+
result.applied.push(index)
|
|
113
|
+
})
|
|
114
|
+
return result
|
|
115
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// polish-diff.mjs - whole-document backstop between a pre-polish artifact and its polished result.
|
|
2
|
+
//
|
|
3
|
+
// diffPolish(beforeHtml, afterHtml, ledger) runs the polish-rules.mjs rule set (the same rules
|
|
4
|
+
// polish-apply runs per edit) over the whole document, as multisets, and returns at most one defect
|
|
5
|
+
// per code. Severity is looked up in contracts.DEFECT_CODES for every emitted code; a code missing
|
|
6
|
+
// there throws. polish-apply checks every edit against this same whole-document baseline (ordered,
|
|
7
|
+
// so stricter), so a clean polish-apply run is clean here; this catches hand edits. No IO, no model.
|
|
8
|
+
// Plain Node ESM.
|
|
9
|
+
|
|
10
|
+
import { DEFECT_CODES } from "./contracts.mjs"
|
|
11
|
+
import { POLISH_CODES, polishDefects } from "./polish-rules.mjs"
|
|
12
|
+
|
|
13
|
+
export { churnRatio, TICKER } from "./polish-rules.mjs"
|
|
14
|
+
|
|
15
|
+
/** The DEFECT_CODES entry of a polish code; refuses a code the registry does not define. */
|
|
16
|
+
function registryEntry(code) {
|
|
17
|
+
if (!Object.hasOwn(DEFECT_CODES, code)) throw new Error(`polish code ${code} is not in DEFECT_CODES`)
|
|
18
|
+
return DEFECT_CODES[code]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} beforeHtml the pre-polish artifact
|
|
23
|
+
* @param {string} afterHtml the polished artifact
|
|
24
|
+
* @param {{ rows: object[] }} ledger
|
|
25
|
+
* @returns {{ code: string, severity: string, message: string }[]} at most one defect per code
|
|
26
|
+
*/
|
|
27
|
+
export function diffPolish(beforeHtml, afterHtml, ledger) {
|
|
28
|
+
const found = new Map()
|
|
29
|
+
for (const { code, message } of polishDefects(beforeHtml, afterHtml, ledger)) found.set(code, [...(found.get(code) ?? []), message])
|
|
30
|
+
return POLISH_CODES.filter((code) => found.has(code)).map((code) => ({ code, severity: registryEntry(code).severity, message: found.get(code).join("; ") }))
|
|
31
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// polish-project.mjs - the protected projection of report markup that every polish check compares.
|
|
2
|
+
//
|
|
3
|
+
// project(markup) yields the ordered fact spans {id, html}, the visible text, the masked text (each
|
|
4
|
+
// fact span replaced by SLOT) and the ordered href values. Callers pass markup already reduced by
|
|
5
|
+
// html-markup.markupParts().source, with frozen script/style/template content omitted. Fact spans are the
|
|
6
|
+
// placeholder.mjs FACT_ELEMENT_TAGS elements carrying data-fact (any quoting), found by
|
|
7
|
+
// html-markup.elementSpans (a same-name nested element and a quoted ">" stay inside). Hedge and
|
|
8
|
+
// qualifier terms come from fidelity-lexicon (guardedTerms, lexicalPattern "guard" mode).
|
|
9
|
+
// No IO, no model. Plain Node ESM.
|
|
10
|
+
|
|
11
|
+
import { decodeEntities } from "./entities.mjs"
|
|
12
|
+
import { guardedTerms, lexicalPattern, QUALIFIER_FORMS } from "./fidelity-lexicon.mjs"
|
|
13
|
+
import { elementSpans, markupParts, tagAttributes } from "./html-markup.mjs"
|
|
14
|
+
import { HEDGES } from "./lexicon.mjs"
|
|
15
|
+
import { parseNumeral } from "./numerals.mjs"
|
|
16
|
+
import { FACT_ELEMENT_TAGS } from "./placeholder.mjs"
|
|
17
|
+
import { splitSentences } from "./sentence-split.mjs"
|
|
18
|
+
import { normalizeUnit } from "./units.mjs"
|
|
19
|
+
|
|
20
|
+
/** The link attributes polish_link_changed owns; a data-claim id change is a markup (fact-binding) change. */
|
|
21
|
+
export const POLISH_LINK_ATTRIBUTES = Object.freeze(["href"])
|
|
22
|
+
/** The bare digit runs compared outside fact spans when no quantity parses around them. */
|
|
23
|
+
export const POLISH_DIGITS = /\d+(?:[.,]\d+)*/g
|
|
24
|
+
/** Stands in for one fact span in masked text; a private-use char, so no numeral or word matches it. */
|
|
25
|
+
export const SLOT = "\uE000"
|
|
26
|
+
const FACT_TAGS = new Set(FACT_ELEMENT_TAGS)
|
|
27
|
+
const isFactElement = (name, attrs) => FACT_TAGS.has(name) && (attrs["data-fact"] ?? "") !== ""
|
|
28
|
+
|
|
29
|
+
/** Each fact span of the markup as {id, start, end, html}, in order; an unclosed one runs to the end. */
|
|
30
|
+
export function factSpans(markup) {
|
|
31
|
+
const src = String(markup)
|
|
32
|
+
return elementSpans(src, isFactElement).map(({ start, end, tag }) => ({ id: tag.attrs["data-fact"], start, end, html: src.slice(start, end) }))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Visible text of an HTML fragment: the scanner's text slots joined by a space (so a quoted ">"
|
|
37
|
+
* inside a tag stays markup), entities decoded, whitespace collapsed. One tokenization is shared
|
|
38
|
+
* with the markup rules; no second tag-stripping regex.
|
|
39
|
+
*/
|
|
40
|
+
export function textOf(html) {
|
|
41
|
+
return decodeEntities(markupParts(html).text.join(" ")).replace(/\s+/g, " ")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The protected projection of (already visible) markup; see the header. */
|
|
45
|
+
export function project(markup) {
|
|
46
|
+
const facts = []
|
|
47
|
+
let visible = ""
|
|
48
|
+
let masked = ""
|
|
49
|
+
let at = 0
|
|
50
|
+
for (const span of factSpans(markup)) {
|
|
51
|
+
const outside = textOf(markup.slice(at, span.start))
|
|
52
|
+
facts.push({ id: span.id, html: span.html.replace(/\s+/g, " ") })
|
|
53
|
+
visible += `${outside}${textOf(span.html)}`
|
|
54
|
+
masked += `${outside} ${SLOT} `
|
|
55
|
+
at = span.end
|
|
56
|
+
}
|
|
57
|
+
const rest = textOf(markup.slice(at))
|
|
58
|
+
const links = tagAttributes(markup).flatMap(({ attrs }) =>
|
|
59
|
+
POLISH_LINK_ATTRIBUTES.filter((name) => Object.hasOwn(attrs, name)).map((name) => `${name}=${attrs[name]}`),
|
|
60
|
+
)
|
|
61
|
+
return { facts, visible: (visible + rest).replace(/\s+/g, " ").trim(), masked: (masked + rest).replace(/\s+/g, " ").trim(), links }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const unitKey = (raw) => (raw === null ? "" : (normalizeUnit(raw) ?? raw.toLowerCase()))
|
|
65
|
+
|
|
66
|
+
/** Ordered numeral keys: a parsed quantity as "value unit" (once), any other digit run as written. */
|
|
67
|
+
export function numeralKeys(text) {
|
|
68
|
+
const quantities = []
|
|
69
|
+
for (let found = parseNumeral(text); found !== null; found = parseNumeral(text, found.span[1])) quantities.push(found)
|
|
70
|
+
const keys = []
|
|
71
|
+
let k = 0
|
|
72
|
+
for (const match of text.matchAll(POLISH_DIGITS)) {
|
|
73
|
+
while (k < quantities.length && quantities[k].span[1] <= match.index) k++
|
|
74
|
+
const quantity = quantities[k]
|
|
75
|
+
if (!quantity || quantity.span[0] > match.index) keys.push(match[0])
|
|
76
|
+
else if (!quantity.counted) {
|
|
77
|
+
quantity.counted = true
|
|
78
|
+
keys.push(`${quantity.value}${quantity.range ? `~${quantity.valueEnd}` : ""} ${unitKey(quantity.unitRaw)}`.trim())
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return keys
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** term -> occurrence count of each listed term in the text (guard mode of the lexical engine). */
|
|
85
|
+
export function termCounts(text, terms = guardedTerms()) {
|
|
86
|
+
const counts = new Map()
|
|
87
|
+
for (const term of terms) {
|
|
88
|
+
const n = [...text.matchAll(lexicalPattern(term, "guard"))].length
|
|
89
|
+
if (n > 0) counts.set(term, n)
|
|
90
|
+
}
|
|
91
|
+
return counts
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const add = (into, term, n) => into.set(term, (into.get(term) ?? 0) + n)
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The hedge and qualifier tokens the text before a polish holds and must keep (term -> count), per
|
|
98
|
+
* sentence of the masked text: a sentence without fact spans keeps all its guarded tokens; a
|
|
99
|
+
* sentence with fact spans keeps those of its tokens that the referenced rows' quote hedges or
|
|
100
|
+
* qualifier forms name. A ledger term the sentence never held is never required.
|
|
101
|
+
*/
|
|
102
|
+
export function requiredTerms(projection, rows) {
|
|
103
|
+
const required = new Map()
|
|
104
|
+
let cursor = 0
|
|
105
|
+
for (const { text } of splitSentences(projection.masked)) {
|
|
106
|
+
const slots = text.split(SLOT).length - 1
|
|
107
|
+
const facts = projection.facts.slice(cursor, cursor + slots)
|
|
108
|
+
cursor += slots
|
|
109
|
+
const present = termCounts(text)
|
|
110
|
+
const sourced = new Set()
|
|
111
|
+
for (const { id } of facts) {
|
|
112
|
+
const row = rows.get(id)
|
|
113
|
+
for (const term of termCounts(row?.quote ?? "", HEDGES).keys()) sourced.add(term)
|
|
114
|
+
for (const form of QUALIFIER_FORMS[row?.qualifier] ?? []) sourced.add(form)
|
|
115
|
+
}
|
|
116
|
+
for (const [term, n] of present) if (slots === 0 || sourced.has(term)) add(required, term, n)
|
|
117
|
+
}
|
|
118
|
+
return required
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Required terms the text no longer holds as many times, as "term" names. */
|
|
122
|
+
export function missingTerms(required, text) {
|
|
123
|
+
const have = termCounts(text, [...required.keys()])
|
|
124
|
+
return [...required].filter(([term, n]) => (have.get(term) ?? 0) < n).map(([term]) => term)
|
|
125
|
+
}
|