omo-ai 5.1.69 → 5.1.71
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/bin/darwin/omo-keychain +0 -0
- package/bin/lib/agent-dir.js +8 -1
- package/bin/lib/auth-store.js +11 -1
- package/bin/lib/bun-bin-shim.js +12 -2
- package/bin/lib/category-coverage.js +56 -18
- package/bin/lib/child-process.js +2 -1
- package/bin/lib/compile-safe-engine.js +14 -2
- package/bin/lib/daemon-adopt.js +41 -10
- package/bin/lib/daemon-config.js +9 -3
- package/bin/lib/daemon-operations.js +11 -3
- package/bin/lib/daemon-rollback.js +28 -23
- package/bin/lib/daemon-status.js +9 -3
- package/bin/lib/daemon.js +18 -3
- package/bin/lib/doctor-memory-runtime.js +46 -12
- package/bin/lib/doctor-migration.js +65 -38
- package/bin/lib/doctor-pi-config.js +8 -3
- package/bin/lib/doctor-reflection-lock.js +35 -12
- package/bin/lib/doctor.js +64 -49
- package/bin/lib/engine-boot.js +3 -1
- package/bin/lib/engine-commands.js +11 -1
- package/bin/lib/engine-environment.js +8 -1
- package/bin/lib/engine-models.js +2 -1
- package/bin/lib/engine-prepare.js +18 -3
- package/bin/lib/host-status.js +5 -1
- package/bin/lib/jsonc-edit.js +10 -6
- package/bin/lib/keychain-helper-doctor.js +13 -3
- package/bin/lib/launch-spec-mode.js +6 -2
- package/bin/lib/launcher.js +31 -19
- package/bin/lib/model-chains.js +12 -5
- package/bin/lib/npm-dist-tags.js +2 -1
- package/bin/lib/package-paths.js +18 -10
- package/bin/lib/private-fd-table.js +19 -10
- package/bin/lib/process-list.js +26 -0
- package/bin/lib/provider-map.json +1 -1
- package/bin/lib/rpc-stream-errors.js +6 -2
- package/bin/lib/same-version.js +6 -1
- package/bin/lib/self-update.js +41 -10
- package/bin/lib/service-auth.generated.js +57 -43
- package/bin/lib/setup-assets-import.js +25 -5
- package/bin/lib/setup-commandcode.js +5 -2
- package/bin/lib/setup-credentials.js +12 -2
- package/bin/lib/setup-detect-refresh.js +9 -6
- package/bin/lib/setup-detect.js +4 -5
- package/bin/lib/setup-guidance.js +1 -1
- package/bin/lib/setup-import.js +35 -7
- package/bin/lib/setup-model-choices-import.js +61 -10
- package/bin/lib/setup-models.js +9 -5
- package/bin/lib/setup-opencode-assets.js +26 -9
- package/bin/lib/setup-opencode-models.d.ts +4 -1
- package/bin/lib/setup-opencode-models.js +76 -30
- package/bin/lib/setup-opencode-providers.js +58 -17
- package/bin/lib/setup-providers-import.js +38 -6
- package/bin/lib/setup-report.js +9 -7
- package/bin/lib/setup-stream-items.js +29 -5
- package/bin/lib/setup-stream.d.ts +13 -3
- package/bin/lib/setup-stream.js +92 -15
- package/bin/lib/setup-summary.js +61 -18
- package/bin/lib/sqlite-rows.js +3 -1
- package/bin/lib/thread-output.js +14 -4
- package/bin/lib/thread.js +224 -38
- package/bin/lib/update-args.js +5 -1
- package/bin/lib/update-lock.js +13 -2
- package/bin/omo.js +1 -1
- package/package.json +2 -2
- package/plugin/CHANGELOG.md +148 -0
- package/plugin/README.md +9 -1
- package/plugin/extensions/gateway-store-worker.mjs +2 -2
- package/plugin/extensions/memory-run-supervisor.mjs +1 -1
- package/plugin/extensions/omo-claim-receipt.js +1 -1
- package/plugin/extensions/omo-computer-run-worker.mjs +1 -1
- package/plugin/extensions/omo-computer-use.js +2 -2
- package/plugin/extensions/omo-desktop-toolkit.js +1 -1
- package/plugin/extensions/omo-device-account.js +4 -4
- package/plugin/extensions/omo-device-service.js +5 -5
- package/plugin/extensions/omo-feedback.js +2 -2
- package/plugin/extensions/omo-init-deep-advisor.js +2 -2
- package/plugin/extensions/omo-member.js +2 -2
- package/plugin/extensions/omo-memory-commands.js +2 -2
- package/plugin/extensions/omo-memory-doctor.js +3 -3
- package/plugin/extensions/omo-memory-memfs.js +1 -1
- package/plugin/extensions/omo-memory-palace.js +3 -3
- package/plugin/extensions/omo-memory-sync.js +2 -2
- package/plugin/extensions/omo-onboarding-scan.js +2 -2
- package/plugin/extensions/omo-recall-store.js +1 -1
- package/plugin/extensions/omo-session-history.js +1 -1
- package/plugin/extensions/omo-side-panel.js +3 -3
- package/plugin/extensions/omo-task.js +2 -2
- package/plugin/extensions/omo-telemetry-otlp.js +2 -2
- package/plugin/extensions/omo-telemetry-posthog.js +1 -1
- package/plugin/extensions/omo-telemetry-recovery.js +1 -1
- package/plugin/extensions/omo-thread-client.js +5 -5
- package/plugin/extensions/omo.js +3 -3
- package/plugin/package.json +1 -1
- package/plugin/runtime/agent-toolkit-sdk/sdk.js +2 -2
- package/plugin/runtime/ast-grep-mcp/cli.js +26 -5
- package/plugin/runtime/ast-grep-mcp/manifest.json +2 -2
- package/plugin/runtime/bunshin-ts/sdk.js +4 -4
- package/plugin/runtime/category-coverage/index.js +6 -6
- package/plugin/runtime/lsp-daemon/dist/.omo-runtime-manifest.json +4 -4
- package/plugin/runtime/lsp-daemon/dist/cli.js +8 -2
- package/plugin/runtime/lsp-daemon/dist/client.js +8 -2
- package/plugin/runtime/lsp-daemon/dist/index.js +8 -2
- package/plugin/runtime/rollback-migrate.js +2 -2
- package/plugin/runtime/task-config/index.js +3 -3
- package/plugin/runtime/thread-sdk/sdk.js +5 -5
- package/plugin/scripts/install.mjs +20 -15
- package/plugin/skills/ast-grep/references/recipes.md +1 -1
- package/plugin/skills/ast-grep/tests/smoke.ps1 +1 -1
- package/plugin/skills/ast-grep/tests/smoke.sh +1 -1
- package/plugin/skills/browser/runtime/omowright/index.js +16 -16
- package/plugin/skills/browser/runtime/omowright/manifest.json +5 -5
- package/plugin/skills/browser/runtime/omowright/page-bundle.js +14 -4
- package/plugin/skills/browser/scripts/browser-doctor-report.mjs +36 -9
- package/plugin/skills/browser/scripts/browser-doctor.mjs +24 -7
- package/plugin/skills/browser/scripts/browser-engine-guard.mjs +2 -1
- package/plugin/skills/browser/scripts/browser-install.mjs +40 -8
- package/plugin/skills/debugging/references/scripts/dap.mjs +280 -170
- package/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +104 -42
- package/plugin/skills/frontend/scripts/detect/cli.ts +67 -50
- package/plugin/skills/frontend/scripts/detect/config.ts +41 -38
- package/plugin/skills/frontend/scripts/detect/core/color.ts +109 -94
- package/plugin/skills/frontend/scripts/detect/core/page.ts +43 -42
- package/plugin/skills/frontend/scripts/detect/core/shadow.ts +38 -29
- package/plugin/skills/frontend/scripts/detect/core/source.ts +25 -20
- package/plugin/skills/frontend/scripts/detect/detect.ts +63 -45
- package/plugin/skills/frontend/scripts/detect/lint.ts +78 -69
- package/plugin/skills/frontend/scripts/detect/render/probe-placement.ts +36 -32
- package/plugin/skills/frontend/scripts/detect/render/renderer.ts +14 -13
- package/plugin/skills/frontend/scripts/detect/render/webview.ts +53 -50
- package/plugin/skills/frontend/scripts/detect/report.ts +20 -18
- package/plugin/skills/frontend/scripts/detect/rule.ts +21 -21
- package/plugin/skills/frontend/scripts/detect/rules/color/ai-color-palette.ts +144 -63
- package/plugin/skills/frontend/scripts/detect/rules/color/cream-palette.ts +41 -27
- package/plugin/skills/frontend/scripts/detect/rules/color/dark-glow.ts +59 -34
- package/plugin/skills/frontend/scripts/detect/rules/color/design-system-color.ts +37 -28
- package/plugin/skills/frontend/scripts/detect/rules/color/gradient-text.ts +68 -45
- package/plugin/skills/frontend/scripts/detect/rules/color/gray-on-color.ts +34 -25
- package/plugin/skills/frontend/scripts/detect/rules/color/index.ts +9 -2
- package/plugin/skills/frontend/scripts/detect/rules/color/low-contrast.ts +106 -43
- package/plugin/skills/frontend/scripts/detect/rules/color/radial-halo.ts +48 -23
- package/plugin/skills/frontend/scripts/detect/rules/color/radial-spotlight-glow.ts +49 -26
- package/plugin/skills/frontend/scripts/detect/rules/color/support/animation-opacity.ts +90 -66
- package/plugin/skills/frontend/scripts/detect/rules/color/support/color-path.ts +43 -6
- package/plugin/skills/frontend/scripts/detect/rules/color/support/contrast-pairs.ts +75 -38
- package/plugin/skills/frontend/scripts/detect/rules/color/support/contrast-role.ts +142 -59
- package/plugin/skills/frontend/scripts/detect/rules/color/support/glow-forms.ts +93 -44
- package/plugin/skills/frontend/scripts/detect/rules/color/support/gradient-samples.ts +115 -114
- package/plugin/skills/frontend/scripts/detect/rules/color/support/gradients.ts +77 -66
- package/plugin/skills/frontend/scripts/detect/rules/color/support/mockup-roots.ts +178 -48
- package/plugin/skills/frontend/scripts/detect/rules/color/support/page-ignore.ts +6 -2
- package/plugin/skills/frontend/scripts/detect/rules/color/support/painted-text.ts +171 -108
- package/plugin/skills/frontend/scripts/detect/rules/color/support/palette-roles.ts +60 -39
- package/plugin/skills/frontend/scripts/detect/rules/color/support/placeholder-contrast.ts +36 -16
- package/plugin/skills/frontend/scripts/detect/rules/color/support/stock-accent.ts +48 -18
- package/plugin/skills/frontend/scripts/detect/rules/color/support/text-colors.ts +88 -62
- package/plugin/skills/frontend/scripts/detect/rules/copy/aphoristic-cadence.ts +25 -15
- package/plugin/skills/frontend/scripts/detect/rules/copy/broken-image.ts +20 -12
- package/plugin/skills/frontend/scripts/detect/rules/copy/em-dash-overuse.ts +63 -39
- package/plugin/skills/frontend/scripts/detect/rules/copy/index.ts +9 -2
- package/plugin/skills/frontend/scripts/detect/rules/copy/marketing-buzzword.ts +53 -25
- package/plugin/skills/frontend/scripts/detect/rules/copy/numbered-section-labels.ts +49 -28
- package/plugin/skills/frontend/scripts/detect/rules/copy/repeated-container-text.ts +80 -47
- package/plugin/skills/frontend/scripts/detect/rules/copy/script-error.ts +42 -34
- package/plugin/skills/frontend/scripts/detect/rules/copy/skipped-heading.ts +199 -75
- package/plugin/skills/frontend/scripts/detect/rules/copy/support/numbered-label.ts +122 -71
- package/plugin/skills/frontend/scripts/detect/rules/copy/support/page-text.ts +32 -24
- package/plugin/skills/frontend/scripts/detect/rules/copy/theater-slop-phrase.ts +42 -13
- package/plugin/skills/frontend/scripts/detect/rules/decoration/blinking-cursor.ts +49 -41
- package/plugin/skills/frontend/scripts/detect/rules/decoration/border-accent-on-rounded.ts +10 -10
- package/plugin/skills/frontend/scripts/detect/rules/decoration/bounce-easing.ts +87 -68
- package/plugin/skills/frontend/scripts/detect/rules/decoration/buried-raster.ts +83 -64
- package/plugin/skills/frontend/scripts/detect/rules/decoration/codex-grid-background.ts +29 -29
- package/plugin/skills/frontend/scripts/detect/rules/decoration/design-system-radius.ts +33 -26
- package/plugin/skills/frontend/scripts/detect/rules/decoration/gpt-thin-border-wide-shadow.ts +61 -58
- package/plugin/skills/frontend/scripts/detect/rules/decoration/hard-offset-shadow.ts +25 -23
- package/plugin/skills/frontend/scripts/detect/rules/decoration/hero-eyebrow-chip.ts +16 -14
- package/plugin/skills/frontend/scripts/detect/rules/decoration/icon-tile-stack.ts +85 -84
- package/plugin/skills/frontend/scripts/detect/rules/decoration/index.ts +17 -17
- package/plugin/skills/frontend/scripts/detect/rules/decoration/kicker-above-heading.ts +79 -64
- package/plugin/skills/frontend/scripts/detect/rules/decoration/marquee.ts +57 -40
- package/plugin/skills/frontend/scripts/detect/rules/decoration/organic-clip-path.ts +34 -34
- package/plugin/skills/frontend/scripts/detect/rules/decoration/pulsing-dot.ts +92 -58
- package/plugin/skills/frontend/scripts/detect/rules/decoration/repeating-stripes-gradient.ts +19 -19
- package/plugin/skills/frontend/scripts/detect/rules/decoration/shape-assembled-illustration.ts +59 -53
- package/plugin/skills/frontend/scripts/detect/rules/decoration/side-tab.ts +15 -12
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/appearance.ts +89 -85
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/assert-cases.ts +17 -15
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/borders.ts +178 -136
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/clip-geometry.ts +155 -145
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/css-candidates.ts +60 -54
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/curve-samples.ts +51 -48
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/gradient-pattern.ts +43 -34
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/keyframes.ts +118 -113
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/labels.ts +74 -67
- package/plugin/skills/frontend/scripts/detect/rules/decoration/support/raster-state.ts +80 -42
- package/plugin/skills/frontend/scripts/detect/rules/index.ts +6 -6
- package/plugin/skills/frontend/scripts/detect/rules/layout/body-text-viewport-edge.ts +116 -55
- package/plugin/skills/frontend/scripts/detect/rules/layout/clipped-overflow-container.ts +22 -9
- package/plugin/skills/frontend/scripts/detect/rules/layout/content-hidden-at-rest.ts +113 -52
- package/plugin/skills/frontend/scripts/detect/rules/layout/cramped-padding.ts +167 -90
- package/plugin/skills/frontend/scripts/detect/rules/layout/edge-flush-cards.ts +82 -41
- package/plugin/skills/frontend/scripts/detect/rules/layout/first-viewport-column-overflow.ts +74 -37
- package/plugin/skills/frontend/scripts/detect/rules/layout/heading-rhythm.ts +49 -24
- package/plugin/skills/frontend/scripts/detect/rules/layout/index.ts +14 -3
- package/plugin/skills/frontend/scripts/detect/rules/layout/monotonous-spacing.ts +47 -28
- package/plugin/skills/frontend/scripts/detect/rules/layout/nested-cards.ts +66 -31
- package/plugin/skills/frontend/scripts/detect/rules/layout/straggler.ts +46 -22
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/cards.ts +157 -82
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/clipping.ts +98 -50
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/declared-mockups.ts +100 -36
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/geometry.ts +66 -43
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/hidden-interface.ts +56 -24
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/layout-cases.ts +23 -8
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/line-breaks.ts +28 -16
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/motion.ts +88 -56
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/padding.ts +106 -68
- package/plugin/skills/frontend/scripts/detect/rules/layout/support/rhythm.ts +204 -128
- package/plugin/skills/frontend/scripts/detect/rules/layout/text-occlusion.ts +125 -70
- package/plugin/skills/frontend/scripts/detect/rules/layout/text-overflow.ts +111 -59
- package/plugin/skills/frontend/scripts/detect/rules/layout/unbalanced-heading.ts +27 -16
- package/plugin/skills/frontend/scripts/detect/rules/layout/viewport-reflow.ts +38 -23
- package/plugin/skills/frontend/scripts/detect/rules/source/ai-color-palette.ts +17 -6
- package/plugin/skills/frontend/scripts/detect/rules/source/aphoristic-cadence.ts +19 -9
- package/plugin/skills/frontend/scripts/detect/rules/source/border-accent-on-rounded.ts +31 -13
- package/plugin/skills/frontend/scripts/detect/rules/source/bounce-easing.ts +41 -16
- package/plugin/skills/frontend/scripts/detect/rules/source/broken-image.ts +19 -9
- package/plugin/skills/frontend/scripts/detect/rules/source/codex-grid-background.ts +36 -12
- package/plugin/skills/frontend/scripts/detect/rules/source/dark-glow.ts +28 -14
- package/plugin/skills/frontend/scripts/detect/rules/source/em-dash-overuse.ts +17 -9
- package/plugin/skills/frontend/scripts/detect/rules/source/gradient-text.ts +14 -6
- package/plugin/skills/frontend/scripts/detect/rules/source/gray-on-color.ts +18 -7
- package/plugin/skills/frontend/scripts/detect/rules/source/index.ts +18 -1
- package/plugin/skills/frontend/scripts/detect/rules/source/marketing-buzzword.ts +49 -11
- package/plugin/skills/frontend/scripts/detect/rules/source/marquee.ts +16 -6
- package/plugin/skills/frontend/scripts/detect/rules/source/monotonous-spacing.ts +35 -17
- package/plugin/skills/frontend/scripts/detect/rules/source/overused-font.ts +51 -10
- package/plugin/skills/frontend/scripts/detect/rules/source/radial-halo.ts +16 -8
- package/plugin/skills/frontend/scripts/detect/rules/source/side-tab.ts +88 -47
- package/plugin/skills/frontend/scripts/detect/rules/source/support/accent-scans.ts +103 -62
- package/plugin/skills/frontend/scripts/detect/rules/source/support/check-source.ts +6 -2
- package/plugin/skills/frontend/scripts/detect/rules/source/support/corners.ts +148 -80
- package/plugin/skills/frontend/scripts/detect/rules/source/support/css-effects.ts +86 -66
- package/plugin/skills/frontend/scripts/detect/rules/source/support/css-scopes.ts +148 -113
- package/plugin/skills/frontend/scripts/detect/rules/source/support/image-tags.ts +113 -105
- package/plugin/skills/frontend/scripts/detect/rules/source/support/js-punctuation.ts +47 -30
- package/plugin/skills/frontend/scripts/detect/rules/source/support/markup-scope.ts +45 -34
- package/plugin/skills/frontend/scripts/detect/rules/source/support/source-color.ts +64 -29
- package/plugin/skills/frontend/scripts/detect/rules/source/support/source-shadow.ts +17 -10
- package/plugin/skills/frontend/scripts/detect/rules/source/support/source-text.ts +128 -86
- package/plugin/skills/frontend/scripts/detect/rules/typography/all-caps-body.ts +23 -9
- package/plugin/skills/frontend/scripts/detect/rules/typography/design-system-font-size.ts +27 -17
- package/plugin/skills/frontend/scripts/detect/rules/typography/design-system-font.ts +27 -17
- package/plugin/skills/frontend/scripts/detect/rules/typography/extreme-negative-tracking.ts +26 -12
- package/plugin/skills/frontend/scripts/detect/rules/typography/flat-type-hierarchy.ts +41 -19
- package/plugin/skills/frontend/scripts/detect/rules/typography/index.ts +14 -3
- package/plugin/skills/frontend/scripts/detect/rules/typography/italic-serif-display.ts +67 -16
- package/plugin/skills/frontend/scripts/detect/rules/typography/justified-text.ts +47 -25
- package/plugin/skills/frontend/scripts/detect/rules/typography/line-length.ts +37 -21
- package/plugin/skills/frontend/scripts/detect/rules/typography/oversized-h1.ts +35 -14
- package/plugin/skills/frontend/scripts/detect/rules/typography/overused-font.ts +83 -38
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/drawn-enlargement.ts +68 -40
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/fading-text.ts +59 -39
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/flex-runs.ts +13 -8
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/font-family.ts +68 -17
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/painted-text.ts +173 -67
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/svg-size.ts +56 -49
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/text-context.ts +155 -78
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/text-lines.ts +38 -28
- package/plugin/skills/frontend/scripts/detect/rules/typography/support/type-hierarchy.ts +43 -38
- package/plugin/skills/frontend/scripts/detect/rules/typography/tight-leading.ts +67 -39
- package/plugin/skills/frontend/scripts/detect/rules/typography/tiny-text.ts +34 -15
- package/plugin/skills/frontend/scripts/detect/rules/typography/undersized-ui-text.ts +52 -22
- package/plugin/skills/frontend/scripts/detect/rules/typography/wide-tracking.ts +37 -19
- package/plugin/skills/frontend/scripts/detect/snapshot/collect.ts +154 -145
- package/plugin/skills/frontend/scripts/detect/snapshot/style-props.ts +121 -21
- package/plugin/skills/frontend/scripts/detect/testing/build-snapshot.ts +140 -65
- package/plugin/skills/frontend/scripts/detect/types.ts +81 -76
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/color.ts +205 -85
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/css-parse.ts +97 -80
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/declarations.ts +129 -101
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/findings.ts +23 -23
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/gradient.ts +43 -42
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/lint.ts +75 -60
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/markup.ts +131 -106
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/selector.ts +28 -25
- package/plugin/skills/frontend/scripts/perfection/accent-stripes/tailwind.ts +93 -78
- package/plugin/skills/frontend/scripts/perfection/check-accent-stripes.ts +22 -22
- package/plugin/skills/frontend/scripts/perfection/check-draft-guard.ts +24 -24
- package/plugin/skills/frontend/scripts/perfection/collect-files.ts +49 -36
- package/plugin/skills/frontend/scripts/perfection/draft-guard/findings.ts +10 -9
- package/plugin/skills/frontend/scripts/perfection/draft-guard/lint.ts +27 -24
- package/plugin/skills/frontend/scripts/perfection/draft-guard/rules.ts +46 -42
- package/plugin/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +98 -75
- package/plugin/skills/lsp-setup/scripts/detect-lsp.ts +162 -152
- package/plugin/skills/lsp-setup/scripts/lsp-server-table.ts +164 -164
- package/plugin/skills/lsp-setup/scripts/verify-lsp.ts +94 -91
- package/plugin/skills/programming/SKILL.md +2 -2
- package/plugin/skills/programming/scripts/go/new-project.ts +68 -68
- package/plugin/skills/programming/scripts/python/new-project.ts +64 -64
- package/plugin/skills/programming/scripts/python/new-script.ts +39 -39
- package/plugin/skills/programming/scripts/rust/new-project.ts +60 -57
- package/plugin/skills/programming/scripts/shared/run-tool.ts +7 -7
- package/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +96 -36
- package/plugin/skills/programming/scripts/typescript/check-test-junk-rules.ts +38 -17
- package/plugin/skills/programming/scripts/typescript/check-test-junk.ts +13 -2
- package/plugin/skills/programming/scripts/typescript/mutation-proof.ts +16 -4
- package/plugin/skills/programming/scripts/typescript/new-project.ts +21 -21
- package/plugin/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +65 -62
- package/plugin/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +73 -70
- package/plugin/skills/ulw-plan/scripts/plan-templates.mjs +30 -30
- package/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +131 -123
- package/plugin/skills/ulw-research/scripts/claim-kinds.mjs +178 -67
- package/plugin/skills/ulw-research/scripts/claims-index.mjs +117 -93
- package/plugin/skills/ulw-research/scripts/cli-support.mjs +73 -73
- package/plugin/skills/ulw-research/scripts/contracts.mjs +604 -174
- package/plugin/skills/ulw-research/scripts/conversion-probe.mjs +161 -113
- package/plugin/skills/ulw-research/scripts/css-hiding.mjs +126 -92
- package/plugin/skills/ulw-research/scripts/css-lite.mjs +143 -137
- package/plugin/skills/ulw-research/scripts/design-spec.mjs +123 -107
- package/plugin/skills/ulw-research/scripts/entities.mjs +66 -30
- package/plugin/skills/ulw-research/scripts/entry-guard.mjs +8 -8
- package/plugin/skills/ulw-research/scripts/fact-commands-fill.mjs +104 -51
- package/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +207 -105
- package/plugin/skills/ulw-research/scripts/fact-commands-polish.mjs +143 -76
- package/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -120
- package/plugin/skills/ulw-research/scripts/fact-commands.mjs +264 -151
- package/plugin/skills/ulw-research/scripts/fact-derive.mjs +92 -48
- package/plugin/skills/ulw-research/scripts/fact-expr.mjs +90 -78
- package/plugin/skills/ulw-research/scripts/fact-fill.mjs +215 -127
- package/plugin/skills/ulw-research/scripts/fact-ledger-kinds.mjs +305 -131
- package/plugin/skills/ulw-research/scripts/fact-ledger-schema.mjs +264 -158
- package/plugin/skills/ulw-research/scripts/fact-ledger.mjs +93 -57
- package/plugin/skills/ulw-research/scripts/fact-locate.mjs +204 -147
- package/plugin/skills/ulw-research/scripts/fact-pairs.mjs +126 -108
- package/plugin/skills/ulw-research/scripts/fact-recompute.mjs +89 -66
- package/plugin/skills/ulw-research/scripts/fidelity-binding.mjs +101 -70
- package/plugin/skills/ulw-research/scripts/fidelity-brief.mjs +95 -89
- package/plugin/skills/ulw-research/scripts/fidelity-claims.mjs +76 -48
- package/plugin/skills/ulw-research/scripts/fidelity-csv.mjs +27 -27
- package/plugin/skills/ulw-research/scripts/fidelity-lexicon.mjs +101 -78
- package/plugin/skills/ulw-research/scripts/fidelity-originals.mjs +124 -77
- package/plugin/skills/ulw-research/scripts/fidelity-policy.mjs +132 -83
- package/plugin/skills/ulw-research/scripts/fidelity-records.mjs +179 -117
- package/plugin/skills/ulw-research/scripts/fidelity-snapshot-readability.mjs +38 -33
- package/plugin/skills/ulw-research/scripts/fidelity-sources.mjs +92 -54
- package/plugin/skills/ulw-research/scripts/fidelity-state.mjs +27 -27
- package/plugin/skills/ulw-research/scripts/fidelity-trace.mjs +81 -48
- package/plugin/skills/ulw-research/scripts/fidelity-value-unit.mjs +207 -104
- package/plugin/skills/ulw-research/scripts/fidelity-values.mjs +255 -154
- package/plugin/skills/ulw-research/scripts/format-extract-css.mjs +74 -74
- package/plugin/skills/ulw-research/scripts/format-extract.mjs +161 -134
- package/plugin/skills/ulw-research/scripts/gates-fidelity.mjs +118 -59
- package/plugin/skills/ulw-research/scripts/gates-figures.mjs +192 -141
- package/plugin/skills/ulw-research/scripts/gates-layout.mjs +119 -85
- package/plugin/skills/ulw-research/scripts/gates-static.mjs +109 -102
- package/plugin/skills/ulw-research/scripts/gates-structure.mjs +105 -86
- package/plugin/skills/ulw-research/scripts/gates-text.mjs +169 -113
- package/plugin/skills/ulw-research/scripts/html-foreign-object.mjs +39 -34
- package/plugin/skills/ulw-research/scripts/html-lite.mjs +230 -176
- package/plugin/skills/ulw-research/scripts/html-markup.mjs +150 -128
- package/plugin/skills/ulw-research/scripts/html-text-map.mjs +125 -96
- package/plugin/skills/ulw-research/scripts/layout-probe.mjs +10 -8
- package/plugin/skills/ulw-research/scripts/lexicon.mjs +36 -19
- package/plugin/skills/ulw-research/scripts/markdown-closers.mjs +85 -85
- package/plugin/skills/ulw-research/scripts/md-lite.mjs +133 -125
- package/plugin/skills/ulw-research/scripts/meaning-check.mjs +154 -123
- package/plugin/skills/ulw-research/scripts/number-grammar.mjs +10 -8
- package/plugin/skills/ulw-research/scripts/numerals.mjs +181 -137
- package/plugin/skills/ulw-research/scripts/outcome-start.mjs +50 -36
- package/plugin/skills/ulw-research/scripts/outcome.mjs +194 -153
- package/plugin/skills/ulw-research/scripts/particles-ko.mjs +72 -70
- package/plugin/skills/ulw-research/scripts/placeholder.mjs +130 -112
- package/plugin/skills/ulw-research/scripts/polish-apply.mjs +67 -51
- package/plugin/skills/ulw-research/scripts/polish-diff.mjs +10 -5
- package/plugin/skills/ulw-research/scripts/polish-project.mjs +67 -57
- package/plugin/skills/ulw-research/scripts/polish-rules.mjs +120 -100
- package/plugin/skills/ulw-research/scripts/rational.mjs +74 -73
- package/plugin/skills/ulw-research/scripts/raw-decode.mjs +74 -74
- package/plugin/skills/ulw-research/scripts/raw-locator.mjs +32 -24
- package/plugin/skills/ulw-research/scripts/repair-tracker.mjs +98 -93
- package/plugin/skills/ulw-research/scripts/report-tools-commands.mjs +265 -176
- package/plugin/skills/ulw-research/scripts/report-tools.mjs +65 -62
- package/plugin/skills/ulw-research/scripts/sentence-split.mjs +63 -43
- package/plugin/skills/ulw-research/scripts/source-commands.mjs +199 -125
- package/plugin/skills/ulw-research/scripts/source-refresh.mjs +91 -54
- package/plugin/skills/ulw-research/scripts/source-snapshot.mjs +143 -102
- package/plugin/skills/ulw-research/scripts/source-view.mjs +82 -46
- package/plugin/skills/ulw-research/scripts/sources-citation.mjs +135 -96
- package/plugin/skills/ulw-research/scripts/text-normalize.mjs +63 -48
- package/plugin/skills/ulw-research/scripts/text-similarity.mjs +15 -15
- package/plugin/skills/ulw-research/scripts/unit-algebra.mjs +98 -66
- package/plugin/skills/ulw-research/scripts/unit-errors.mjs +14 -14
- package/plugin/skills/ulw-research/scripts/unit-metadata.mjs +30 -14
- package/plugin/skills/ulw-research/scripts/unit-pairs.mjs +57 -45
- package/plugin/skills/ulw-research/scripts/unit-precision.mjs +39 -25
- package/plugin/skills/ulw-research/scripts/unit-rules-shapes.mjs +79 -44
- package/plugin/skills/ulw-research/scripts/unit-rules.mjs +262 -135
- package/plugin/skills/ulw-research/scripts/units.mjs +96 -65
- package/plugin/skills/visual-qa/scripts/ansi.ts +3 -6
- package/plugin/skills/visual-qa/scripts/cli.ts +52 -52
- package/plugin/skills/visual-qa/scripts/east-asian-width.ts +53 -53
- package/plugin/skills/visual-qa/scripts/image-diff.ts +86 -86
- package/plugin/skills/visual-qa/scripts/png-crc.ts +16 -16
- package/plugin/skills/visual-qa/scripts/png-decode.ts +167 -167
- package/plugin/skills/visual-qa/scripts/png-synth.ts +36 -40
- package/plugin/skills/visual-qa/scripts/tui-grid.ts +63 -63
- package/plugin/skills/visual-qa/scripts/types.ts +37 -37
- package/plugin/skills/visual-qa/scripts/visual-qa.mjs +268 -289
|
@@ -28,8 +28,13 @@ const isFactElement = (name, attrs) => FACT_TAGS.has(name) && (attrs["data-fact"
|
|
|
28
28
|
|
|
29
29
|
/** Each fact span of the markup as {id, start, end, html}, in order; an unclosed one runs to the end. */
|
|
30
30
|
export function factSpans(markup) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const src = String(markup)
|
|
32
|
+
return elementSpans(src, isFactElement).map(({ start, end, tag }) => ({
|
|
33
|
+
id: tag.attrs["data-fact"],
|
|
34
|
+
start,
|
|
35
|
+
end,
|
|
36
|
+
html: src.slice(start, end),
|
|
37
|
+
}))
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -38,57 +43,62 @@ export function factSpans(markup) {
|
|
|
38
43
|
* with the markup rules; no second tag-stripping regex.
|
|
39
44
|
*/
|
|
40
45
|
export function textOf(html) {
|
|
41
|
-
|
|
46
|
+
return decodeEntities(markupParts(html).text.join(" ")).replace(/\s+/g, " ")
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
/** The protected projection of (already visible) markup; see the header. */
|
|
45
50
|
export function project(markup) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
const facts = []
|
|
52
|
+
let visible = ""
|
|
53
|
+
let masked = ""
|
|
54
|
+
let at = 0
|
|
55
|
+
for (const span of factSpans(markup)) {
|
|
56
|
+
const outside = textOf(markup.slice(at, span.start))
|
|
57
|
+
facts.push({ id: span.id, html: span.html.replace(/\s+/g, " ") })
|
|
58
|
+
visible += `${outside}${textOf(span.html)}`
|
|
59
|
+
masked += `${outside} ${SLOT} `
|
|
60
|
+
at = span.end
|
|
61
|
+
}
|
|
62
|
+
const rest = textOf(markup.slice(at))
|
|
63
|
+
const links = tagAttributes(markup).flatMap(({ attrs }) =>
|
|
64
|
+
POLISH_LINK_ATTRIBUTES.filter((name) => Object.hasOwn(attrs, name)).map((name) => `${name}=${attrs[name]}`),
|
|
65
|
+
)
|
|
66
|
+
return {
|
|
67
|
+
facts,
|
|
68
|
+
visible: (visible + rest).replace(/\s+/g, " ").trim(),
|
|
69
|
+
masked: (masked + rest).replace(/\s+/g, " ").trim(),
|
|
70
|
+
links,
|
|
71
|
+
}
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
const unitKey = (raw) => (raw === null ? "" : (normalizeUnit(raw) ?? raw.toLowerCase()))
|
|
65
75
|
|
|
66
76
|
/** Ordered numeral keys: a parsed quantity as "value unit" (once), any other digit run as written. */
|
|
67
77
|
export function numeralKeys(text) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const quantities = []
|
|
79
|
+
for (let found = parseNumeral(text); found !== null; found = parseNumeral(text, found.span[1])) quantities.push(found)
|
|
80
|
+
const keys = []
|
|
81
|
+
let k = 0
|
|
82
|
+
for (const match of text.matchAll(POLISH_DIGITS)) {
|
|
83
|
+
while (k < quantities.length && quantities[k].span[1] <= match.index) k++
|
|
84
|
+
const quantity = quantities[k]
|
|
85
|
+
if (!quantity || quantity.span[0] > match.index) keys.push(match[0])
|
|
86
|
+
else if (!quantity.counted) {
|
|
87
|
+
quantity.counted = true
|
|
88
|
+
keys.push(`${quantity.value}${quantity.range ? `~${quantity.valueEnd}` : ""} ${unitKey(quantity.unitRaw)}`.trim())
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return keys
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
/** term -> occurrence count of each listed term in the text (guard mode of the lexical engine). */
|
|
85
95
|
export function termCounts(text, terms = guardedTerms()) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
const counts = new Map()
|
|
97
|
+
for (const term of terms) {
|
|
98
|
+
const n = [...text.matchAll(lexicalPattern(term, "guard"))].length
|
|
99
|
+
if (n > 0) counts.set(term, n)
|
|
100
|
+
}
|
|
101
|
+
return counts
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
const add = (into, term, n) => into.set(term, (into.get(term) ?? 0) + n)
|
|
@@ -100,26 +110,26 @@ const add = (into, term, n) => into.set(term, (into.get(term) ?? 0) + n)
|
|
|
100
110
|
* qualifier forms name. A ledger term the sentence never held is never required.
|
|
101
111
|
*/
|
|
102
112
|
export function requiredTerms(projection, rows) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
const required = new Map()
|
|
114
|
+
let cursor = 0
|
|
115
|
+
for (const { text } of splitSentences(projection.masked)) {
|
|
116
|
+
const slots = text.split(SLOT).length - 1
|
|
117
|
+
const facts = projection.facts.slice(cursor, cursor + slots)
|
|
118
|
+
cursor += slots
|
|
119
|
+
const present = termCounts(text)
|
|
120
|
+
const sourced = new Set()
|
|
121
|
+
for (const { id } of facts) {
|
|
122
|
+
const row = rows.get(id)
|
|
123
|
+
for (const term of termCounts(row?.quote ?? "", HEDGES).keys()) sourced.add(term)
|
|
124
|
+
for (const form of QUALIFIER_FORMS[row?.qualifier] ?? []) sourced.add(form)
|
|
125
|
+
}
|
|
126
|
+
for (const [term, n] of present) if (slots === 0 || sourced.has(term)) add(required, term, n)
|
|
127
|
+
}
|
|
128
|
+
return required
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
/** Required terms the text no longer holds as many times, as "term" names. */
|
|
122
132
|
export function missingTerms(required, text) {
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
const have = termCounts(text, [...required.keys()])
|
|
134
|
+
return [...required].filter(([term, n]) => (have.get(term) ?? 0) < n).map(([term]) => term)
|
|
125
135
|
}
|
|
@@ -28,7 +28,13 @@ import { splitSentences } from "./sentence-split.mjs"
|
|
|
28
28
|
import { normalizeText } from "./text-normalize.mjs"
|
|
29
29
|
|
|
30
30
|
/** The codes polishDefects can emit, in report order. */
|
|
31
|
-
export const POLISH_CODES = Object.freeze([
|
|
31
|
+
export const POLISH_CODES = Object.freeze([
|
|
32
|
+
"polish_diff_fail",
|
|
33
|
+
"polish_hedging_decreased",
|
|
34
|
+
"polish_text_churn",
|
|
35
|
+
"polish_link_changed",
|
|
36
|
+
"polish_name_changed",
|
|
37
|
+
])
|
|
32
38
|
export const TICKER = /(?<![\p{L}\p{N}])(?:[A-Z]{1,5}(?:\.[A-Z]{1,2})?|\d{6})(?![\p{L}\p{N}])/gu
|
|
33
39
|
/** The capitalized-token heuristic for proper nouns in ledger quotes. */
|
|
34
40
|
export const POLISH_NAME = /\p{Lu}[\p{L}\p{N}&'-]+/gu
|
|
@@ -42,86 +48,94 @@ const same = (a, b) => a.length === b.length && a.every((item, k) => item === b[
|
|
|
42
48
|
|
|
43
49
|
/** null when unchanged; a reorder counts only when ordered. */
|
|
44
50
|
function listChange(label, before, after, ordered) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (same(before, after)) return null
|
|
52
|
+
const remaining = sorted(before)
|
|
53
|
+
const added = []
|
|
54
|
+
for (const item of after) {
|
|
55
|
+
const at = remaining.indexOf(item)
|
|
56
|
+
if (at === -1) added.push(item)
|
|
57
|
+
else remaining.splice(at, 1)
|
|
58
|
+
}
|
|
59
|
+
if (remaining.length > 0 || added.length > 0)
|
|
60
|
+
return `${label} changed: removed [${remaining.join(", ")}], added [${added.join(", ")}]`
|
|
61
|
+
return ordered ? `${label} reordered: [${before.join(", ")}] became [${after.join(", ")}]` : null
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
const tableRows = (html) =>
|
|
64
|
+
const tableRows = (html) =>
|
|
65
|
+
html
|
|
66
|
+
.split(/<table\b/i)
|
|
67
|
+
.slice(1)
|
|
68
|
+
.map((part) => (part.split(/<\/table\s*>/i)[0].match(/<tr\b/gi) ?? []).length)
|
|
58
69
|
|
|
59
70
|
function levenshtein(a, b) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
if (a === b) return 0
|
|
72
|
+
if (a.length * b.length > DISTANCE_CELLS) return Math.max(a.length, b.length)
|
|
73
|
+
let previous = Array.from({ length: b.length + 1 }, (_, k) => k)
|
|
74
|
+
for (let i = 1; i <= a.length; i++) {
|
|
75
|
+
const current = [i]
|
|
76
|
+
for (let j = 1; j <= b.length; j++) {
|
|
77
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1))
|
|
78
|
+
}
|
|
79
|
+
previous = current
|
|
80
|
+
}
|
|
81
|
+
return previous[b.length]
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
/** Changed share of normalized prose: edit distance over unmatched sentence runs / longer length. */
|
|
74
85
|
export function churnRatio(beforeText, afterText) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
const [a, b] = [normalizeText(beforeText), normalizeText(afterText)]
|
|
87
|
+
const longest = Math.max(a.length, b.length)
|
|
88
|
+
if (longest === 0) return 0
|
|
89
|
+
const [sa, sb] = [splitSentences(a).map((s) => s.text), splitSentences(b).map((s) => s.text)]
|
|
90
|
+
const lcs = Array.from({ length: sa.length + 1 }, () => new Array(sb.length + 1).fill(0))
|
|
91
|
+
for (let i = sa.length - 1; i >= 0; i--) {
|
|
92
|
+
for (let j = sb.length - 1; j >= 0; j--)
|
|
93
|
+
lcs[i][j] = sa[i] === sb[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1])
|
|
94
|
+
}
|
|
95
|
+
let distance = 0
|
|
96
|
+
let gap = [[], []]
|
|
97
|
+
const flush = () => {
|
|
98
|
+
distance += levenshtein(gap[0].join(" "), gap[1].join(" "))
|
|
99
|
+
gap = [[], []]
|
|
100
|
+
}
|
|
101
|
+
let [i, j] = [0, 0]
|
|
102
|
+
while (i < sa.length || j < sb.length) {
|
|
103
|
+
if (i < sa.length && j < sb.length && sa[i] === sb[j]) {
|
|
104
|
+
flush()
|
|
105
|
+
i++
|
|
106
|
+
j++
|
|
107
|
+
} else if (j >= sb.length || (i < sa.length && lcs[i + 1][j] >= lcs[i][j + 1])) gap[0].push(sa[i++])
|
|
108
|
+
else gap[1].push(sb[j++])
|
|
109
|
+
}
|
|
110
|
+
flush()
|
|
111
|
+
return distance / longest
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
function linkChange(from, to, before, after, ordered) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
const change = listChange("href and data-claim values", from.links, to.links, ordered)
|
|
116
|
+
if (change) return change
|
|
117
|
+
const ids = (html) =>
|
|
118
|
+
new Set(tagAttributes(html).flatMap(({ attrs }) => (Object.hasOwn(attrs, "id") ? [attrs.id] : [])))
|
|
119
|
+
const [idsBefore, idsAfter] = [ids(before), ids(after)]
|
|
120
|
+
const targets = to.links.filter((link) => link.startsWith("href=#")).map((link) => link.slice(5))
|
|
121
|
+
const broken = targets.filter((href) => idsBefore.has(href.slice(1)) && !idsAfter.has(href.slice(1)))
|
|
122
|
+
return broken.length > 0 ? `internal link targets stopped resolving: [${[...new Set(broken)].join(", ")}]` : null
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
/** Capitalized tokens of the ledger quotes, minus each sentence's first word. */
|
|
113
126
|
function ledgerNames(rows) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
const names = new Set()
|
|
128
|
+
for (const row of rows) {
|
|
129
|
+
for (const { text } of splitSentences(row.quote ?? "")) {
|
|
130
|
+
const first = text.match(/^\P{L}*\p{L}+/u)?.[0].length ?? 0
|
|
131
|
+
for (const match of text.matchAll(POLISH_NAME)) if (match.index >= first) names.add(match[0])
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return names
|
|
122
135
|
}
|
|
123
136
|
|
|
124
|
-
const hasWord = (text, word) =>
|
|
137
|
+
const hasWord = (text, word) =>
|
|
138
|
+
new RegExp(`(?<![\\p{L}\\p{N}])${word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}])`, "u").test(text)
|
|
125
139
|
|
|
126
140
|
/**
|
|
127
141
|
* @param {string} beforeHtml
|
|
@@ -131,40 +145,46 @@ const hasWord = (text, word) => new RegExp(`(?<![\\p{L}\\p{N}])${word.replace(/[
|
|
|
131
145
|
* @returns {{ code: string, message: string }[]} in POLISH_CODES order
|
|
132
146
|
*/
|
|
133
147
|
export function polishDefects(beforeHtml, afterHtml, ledger, { ordered = false } = {}) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
148
|
+
const ambiguous = [...new Set([...ambiguousMarkup(beforeHtml), ...ambiguousMarkup(afterHtml)])]
|
|
149
|
+
if (ambiguous.length > 0) return [{ code: "polish_diff_fail", message: `ambiguous markup: ${ambiguous.join(", ")}` }]
|
|
150
|
+
const [beforeParts, afterParts] = [markupParts(beforeHtml), markupParts(afterHtml)]
|
|
151
|
+
const [before, after] = [beforeParts.source, afterParts.source]
|
|
152
|
+
const [from, to] = [project(before), project(after)]
|
|
153
|
+
const rows = ledger?.rows ?? []
|
|
154
|
+
const defects = []
|
|
155
|
+
const note = (code, message) => message && defects.push({ code, message })
|
|
156
|
+
const factKey = (fact) => `${fact.id} ${fact.html}`
|
|
157
|
+
const tickers = (text) => text.match(TICKER) ?? []
|
|
158
|
+
const markupEqual = same(beforeParts.markup, afterParts.markup)
|
|
159
|
+
note("polish_diff_fail", markupEqual ? null : "markup changed")
|
|
160
|
+
note("polish_diff_fail", skeletonChange(beforeHtml, afterHtml))
|
|
161
|
+
note("polish_diff_fail", listChange("fact spans", from.facts.map(factKey), to.facts.map(factKey), ordered))
|
|
162
|
+
note(
|
|
163
|
+
"polish_diff_fail",
|
|
164
|
+
listChange("numerals outside fact spans", numeralKeys(from.masked), numeralKeys(to.masked), ordered),
|
|
165
|
+
)
|
|
166
|
+
note("polish_diff_fail", listChange("tickers", tickers(from.masked), tickers(to.masked), ordered))
|
|
167
|
+
const [rowsBefore, rowsAfter] = [tableRows(before), tableRows(after)]
|
|
168
|
+
if (!same(rowsBefore, rowsAfter))
|
|
169
|
+
note("polish_diff_fail", `table row counts changed: [${rowsBefore}] became [${rowsAfter}]`)
|
|
170
|
+
const required = requiredTerms(from, new Map(rows.map((row) => [row.fact_id, row])))
|
|
171
|
+
if (markupEqual) {
|
|
172
|
+
for (const [index, raw] of beforeParts.text.entries()) {
|
|
173
|
+
const [a, b] = [raw, afterParts.text[index]].map(textOf)
|
|
174
|
+
note("polish_diff_fail", listChange("text-node numerals", numeralKeys(a), numeralKeys(b), ordered))
|
|
175
|
+
note("polish_diff_fail", listChange("text-node tickers", tickers(a), tickers(b), ordered))
|
|
176
|
+
const lost = missingTerms(termCounts(a, [...required.keys()]), b)
|
|
177
|
+
if (lost.length) note("polish_hedging_decreased", `text-node hedges removed: ${lost.join(", ")}`)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const missing = missingTerms(required, to.visible)
|
|
181
|
+
if (missing.length > 0)
|
|
182
|
+
note("polish_hedging_decreased", `hedges or qualifiers removed: ${missing.map((term) => `"${term}"`).join(", ")}`)
|
|
183
|
+
const ratio = churnRatio(from.visible, to.visible)
|
|
184
|
+
if (ratio > POLISH_CHURN_LIMIT)
|
|
185
|
+
note("polish_text_churn", `${(ratio * 100).toFixed(1)} percent of the normalized prose changed`)
|
|
186
|
+
note("polish_link_changed", linkChange(from, to, before, after, ordered))
|
|
187
|
+
const lost = [...ledgerNames(rows)].filter((name) => hasWord(from.visible, name) && !hasWord(to.visible, name))
|
|
188
|
+
if (lost.length > 0) note("polish_name_changed", `ledger-quote names missing after polish: ${lost.join(", ")}`)
|
|
189
|
+
return defects.sort((a, b) => POLISH_CODES.indexOf(a.code) - POLISH_CODES.indexOf(b.code))
|
|
170
190
|
}
|
|
@@ -9,99 +9,100 @@ const DECIMAL = /^([+-]?)(\d+)(?:\.(\d+))?$/
|
|
|
9
9
|
const abs = (n) => (n < 0n ? -n : n)
|
|
10
10
|
|
|
11
11
|
function gcd(a, b) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let x = abs(a)
|
|
13
|
+
let y = abs(b)
|
|
14
|
+
while (y !== 0n) [x, y] = [y, x % y]
|
|
15
|
+
return x
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function make(num, den) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
if (den === 0n) throw new RangeError("rational: zero denominator")
|
|
20
|
+
const sign = den < 0n ? -1n : 1n
|
|
21
|
+
const g = gcd(num, den) || 1n
|
|
22
|
+
return Object.freeze({ num: (sign * num) / g, den: (sign * den) / g })
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Accepts a rational, a bigint, a safe integer, or a decimal string. */
|
|
26
26
|
function coerce(value) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (typeof value === "bigint") return make(value, 1n)
|
|
28
|
+
if (typeof value === "number") {
|
|
29
|
+
if (!Number.isSafeInteger(value))
|
|
30
|
+
throw new TypeError(`rational: ${value} is not a safe integer; pass a decimal string`)
|
|
31
|
+
return make(BigInt(value), 1n)
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "string") return fromDecimal(value)
|
|
34
|
+
if (value && typeof value.num === "bigint" && typeof value.den === "bigint") return make(value.num, value.den)
|
|
35
|
+
throw new TypeError("rational: expected a rational, bigint, integer, or decimal string")
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/** "12.50" -> 25/2. Accepts an optional sign, digits, and an optional fraction; nothing else. */
|
|
38
39
|
export function fromDecimal(str) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const match = DECIMAL.exec(String(str).trim())
|
|
41
|
+
if (!match) throw new SyntaxError(`rational: "${str}" is not a plain decimal`)
|
|
42
|
+
const [, sign, whole, frac = ""] = match
|
|
43
|
+
const num = BigInt(whole + frac) * (sign === "-" ? -1n : 1n)
|
|
44
|
+
return make(num, 10n ** BigInt(frac.length))
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export function add(a, b) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const x = coerce(a)
|
|
49
|
+
const y = coerce(b)
|
|
50
|
+
return make(x.num * y.den + y.num * x.den, x.den * y.den)
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export function sub(a, b) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const x = coerce(a)
|
|
55
|
+
const y = coerce(b)
|
|
56
|
+
return make(x.num * y.den - y.num * x.den, x.den * y.den)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export function mul(a, b) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const x = coerce(a)
|
|
61
|
+
const y = coerce(b)
|
|
62
|
+
return make(x.num * y.num, x.den * y.den)
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export function div(a, b) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const x = coerce(a)
|
|
67
|
+
const y = coerce(b)
|
|
68
|
+
if (y.num === 0n) throw new RangeError("rational: division by zero")
|
|
69
|
+
return make(x.num * y.den, x.den * y.num)
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
export function eq(a, b) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const x = coerce(a)
|
|
74
|
+
const y = coerce(b)
|
|
75
|
+
return x.num === y.num && x.den === y.den
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/** Digits of a non-negative integer scaled by 10^-scale, as a decimal string. */
|
|
78
79
|
function placeDecimal(digits, scale) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (scale <= 0) return digits + "0".repeat(-scale)
|
|
81
|
+
const padded = digits.padStart(scale + 1, "0")
|
|
82
|
+
return `${padded.slice(0, padded.length - scale)}.${padded.slice(padded.length - scale)}`
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/** Exact decimal; throws RangeError when the expansion does not terminate. */
|
|
85
86
|
function exactDecimal(r) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
let den = r.den
|
|
88
|
+
let twos = 0
|
|
89
|
+
let fives = 0
|
|
90
|
+
while (den % 2n === 0n) [den, twos] = [den / 2n, twos + 1]
|
|
91
|
+
while (den % 5n === 0n) [den, fives] = [den / 5n, fives + 1]
|
|
92
|
+
if (den !== 1n) throw new RangeError(`rational: ${r.num}/${r.den} has no finite decimal; pass sigFigs`)
|
|
93
|
+
const scale = Math.max(twos, fives)
|
|
94
|
+
const digits = (abs(r.num) * 10n ** BigInt(scale)) / r.den
|
|
95
|
+
return (r.num < 0n ? "-" : "") + placeDecimal(digits.toString(), scale)
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
/** Number of decimal digits in the integer part of |num/den| (0 when below 1). */
|
|
98
99
|
function integerDigits(num, den) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
const whole = num / den
|
|
101
|
+
if (whole > 0n) return whole.toString().length
|
|
102
|
+
let exp = 0
|
|
103
|
+
let scaled = num
|
|
104
|
+
while (scaled < den) [scaled, exp] = [scaled * 10n, exp - 1]
|
|
105
|
+
return exp + 1
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/**
|
|
@@ -110,19 +111,19 @@ function integerDigits(num, den) {
|
|
|
110
111
|
* with an exponent, so 319999 at 2 figures renders "320000".
|
|
111
112
|
*/
|
|
112
113
|
export function toDecimal(value, sigFigs) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
const r = coerce(value)
|
|
115
|
+
if (sigFigs === undefined) return exactDecimal(r)
|
|
116
|
+
if (!Number.isInteger(sigFigs) || sigFigs < 1) throw new RangeError("rational: sigFigs must be a positive integer")
|
|
117
|
+
if (r.num === 0n) return sigFigs > 1 ? `0.${"0".repeat(sigFigs - 1)}` : "0"
|
|
118
|
+
const num = abs(r.num)
|
|
119
|
+
const scale = sigFigs - integerDigits(num, r.den)
|
|
120
|
+
const numer = scale >= 0 ? num * 10n ** BigInt(scale) : num
|
|
121
|
+
const denom = scale >= 0 ? r.den : r.den * 10n ** BigInt(-scale)
|
|
122
|
+
let digits = numer / denom
|
|
123
|
+
let places = scale
|
|
124
|
+
if ((numer % denom) * 2n >= denom) digits += 1n
|
|
125
|
+
if (digits.toString().length > sigFigs) [digits, places] = [digits / 10n, places - 1]
|
|
126
|
+
return (r.num < 0n ? "-" : "") + placeDecimal(digits.toString(), places)
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
/**
|
|
@@ -131,9 +132,9 @@ export function toDecimal(value, sigFigs) {
|
|
|
131
132
|
* after leading zeros counts ("320" -> 3, "100" -> 3, "20" -> 2).
|
|
132
133
|
*/
|
|
133
134
|
export function sigFigsOf(decimalStr) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
const match = DECIMAL.exec(String(decimalStr).trim())
|
|
136
|
+
if (!match) throw new SyntaxError(`rational: "${decimalStr}" is not a plain decimal`)
|
|
137
|
+
const [, , whole, frac] = match
|
|
138
|
+
const digits = (whole + (frac ?? "")).replace(/^0+/, "")
|
|
139
|
+
return Math.max(digits.length, 1)
|
|
139
140
|
}
|