oh-my-opencode 5.1.47 → 5.1.51
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/dist/agents/refusal-rule.d.ts +7 -0
- package/dist/cli/index.js +1194 -752
- package/dist/cli/service-auth/accounts-gate.d.ts +11 -0
- package/dist/cli/service-auth/commands.d.ts +2 -4
- package/dist/cli/service-auth/index.d.ts +1 -1
- package/dist/cli/service-auth/keystore.d.ts +26 -2
- package/dist/cli/service-auth/protocol.d.ts +7 -1
- package/dist/cli/service-auth/session.d.ts +6 -0
- package/dist/cli/service-auth/signed-out-marker.d.ts +11 -0
- package/dist/cli-node/index.js +1194 -752
- package/dist/config/schema/hooks.d.ts +1 -0
- package/dist/create-hooks.d.ts +1 -0
- package/dist/features/boulder-state/storage.d.ts +1 -1
- package/dist/features/boulder-state/types.d.ts +1 -1
- package/dist/hooks/atlas/idle-continuation.d.ts +2 -1
- package/dist/hooks/atlas/types.d.ts +9 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/momus-review-persistence/hook.d.ts +19 -0
- package/dist/hooks/momus-review-persistence/index.d.ts +1 -0
- package/dist/hooks/momus-review-persistence/review-resolution.d.ts +20 -0
- package/dist/hooks/prometheus-md-only/constants.d.ts +2 -0
- package/dist/hooks/prometheus-md-only/fixtures/denial-log.d.ts +1 -0
- package/dist/hooks/prometheus-md-only/fixtures/guarded-hashline.d.ts +1 -0
- package/dist/hooks/prometheus-md-only/fixtures/invoke-before.d.ts +7 -0
- package/dist/hooks/prometheus-md-only/fixtures/opencode-patch-parser.d.ts +2 -0
- package/dist/hooks/prometheus-md-only/hook.d.ts +5 -1
- package/dist/hooks/prometheus-md-only/path-policy.d.ts +2 -9
- package/dist/hooks/prometheus-md-only/vendor/opencode-patch-parser.d.ts +22 -0
- package/dist/index.js +2322 -1045
- package/dist/plugin/hooks/create-core-hooks.d.ts +1 -0
- package/dist/plugin/hooks/create-tool-guard-hooks.d.ts +2 -1
- package/dist/shared/posthog-activity-state.d.ts +1 -0
- package/dist/shared/posthog.d.ts +1 -2
- package/dist/shared/resolve-file-write-path.d.ts +6 -0
- package/dist/skills/ast-grep/README.md +1 -1
- package/dist/skills/ast-grep/install.ps1 +5 -3
- package/dist/skills/ast-grep/install.sh +4 -5
- package/dist/skills/ast-grep/references/install.md +2 -2
- package/dist/skills/ast-grep/scripts/ast_grep_helper.py +13 -3
- package/dist/skills/browser/runtime/omowright/manifest.json +1 -1
- package/dist/skills/coding-agent-sessions/AGENTS.md +5 -4
- package/dist/skills/coding-agent-sessions/SKILL.md +11 -11
- package/dist/skills/coding-agent-sessions/references/all-platforms.md +2 -2
- package/dist/skills/coding-agent-sessions/references/codex.md +4 -4
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +1 -1
- package/dist/skills/coding-agent-sessions/scripts/find-agent-sessions.py +6 -3
- package/dist/skills/frontend/ATTRIBUTION.md +1 -1
- package/dist/skills/frontend/SKILL.md +34 -12
- package/dist/skills/frontend/references/design/README.md +2 -2
- package/dist/skills/frontend/references/design/_INDEX.md +2 -1
- package/dist/skills/frontend/references/design/component-catalogs.md +14 -10
- package/dist/skills/frontend/references/design/design-system-architecture.md +19 -6
- package/dist/skills/frontend/references/design/grounding.md +29 -0
- package/dist/skills/frontend/references/ui-ux-db/scripts/design_system.py +2 -0
- package/dist/skills/frontend/references/ui-ux-db/scripts/search.py +2 -0
- package/dist/skills/ultimate-browsing/SKILL.md +5 -4
- package/dist/skills/ultimate-browsing/engine/AGENTS.md +2 -2
- package/dist/skills/ultimate-browsing/engine/__main__.py +9 -6
- package/dist/skills/ultimate-browsing/engine/summary.py +1 -1
- package/dist/skills/ultimate-browsing/references/insane-search/README.md +4 -4
- package/dist/skills/ultimate-browsing/scripts/extract_cookies.py +4 -2
- package/dist/skills/ulw-research/AGENTS.md +8 -4
- package/dist/skills/ulw-research/SKILL.md +7 -259
- package/dist/skills/ulw-research/references/deliverable-phase.md +68 -24
- package/dist/skills/ulw-research/references/fact-ledger-grammar.md +7 -3
- package/dist/skills/ulw-research/references/fact-ledger.md +42 -8
- package/dist/skills/ulw-research/references/fidelity-claim-kinds.md +1 -1
- package/dist/skills/ulw-research/references/markdown-blocks.md +12 -0
- package/dist/skills/ulw-research/references/report-gates.md +14 -6
- package/dist/skills/ulw-research/references/research-collection.md +195 -0
- package/dist/skills/ulw-research/references/research-delivery.md +123 -0
- package/dist/skills/ulw-research/scripts/claim-kinds.mjs +33 -5
- package/dist/skills/ulw-research/scripts/claim-kinds.test.ts +37 -2
- package/dist/skills/ulw-research/scripts/claim-prefix.test.ts +76 -0
- package/dist/skills/ulw-research/scripts/contracts-validation.test.ts +83 -0
- package/dist/skills/ulw-research/scripts/contracts.mjs +16 -15
- package/dist/skills/ulw-research/scripts/contracts.test.ts +6 -109
- package/dist/skills/ulw-research/scripts/conversion-altered.test.ts +154 -0
- package/dist/skills/ulw-research/scripts/conversion-originals.test.ts +297 -0
- package/dist/skills/ulw-research/scripts/conversion-probe-classes.test.ts +361 -0
- package/dist/skills/ulw-research/scripts/conversion-probe.mjs +229 -0
- package/dist/skills/ulw-research/scripts/conversion-probe.test.ts +218 -0
- package/dist/skills/ulw-research/scripts/copy-returns-fidelity-policy.test.ts +156 -0
- package/dist/skills/ulw-research/scripts/copy-returns-polish.test.ts +10 -9
- package/dist/skills/ulw-research/scripts/css-hiding.mjs +158 -0
- package/dist/skills/ulw-research/scripts/css-lite.mjs +4 -2
- package/dist/skills/ulw-research/scripts/delivery-barrier-meaning.test.ts +186 -0
- package/dist/skills/ulw-research/scripts/delivery-barrier.test.ts +40 -87
- package/dist/skills/ulw-research/scripts/entities.mjs +13 -4
- package/dist/skills/ulw-research/scripts/fact-commands-fill.mjs +96 -0
- package/dist/skills/ulw-research/scripts/fact-commands-meaning.mjs +26 -30
- package/dist/skills/ulw-research/scripts/fact-commands-polish.mjs +46 -19
- package/dist/skills/ulw-research/scripts/fact-commands-verify.mjs +37 -6
- package/dist/skills/ulw-research/scripts/fact-commands.mjs +40 -62
- package/dist/skills/ulw-research/scripts/fact-derive-2.test.ts +149 -0
- package/dist/skills/ulw-research/scripts/fact-derive.mjs +7 -2
- package/dist/skills/ulw-research/scripts/fact-derive.test.ts +7 -192
- package/dist/skills/ulw-research/scripts/fact-fill.mjs +9 -6
- package/dist/skills/ulw-research/scripts/fact-ledger-kinds.mjs +6 -7
- package/dist/skills/ulw-research/scripts/fact-ledger-kinds.test.ts +2 -1
- package/dist/skills/ulw-research/scripts/fact-ledger-legacy.test.ts +2 -1
- package/dist/skills/ulw-research/scripts/fact-locate.mjs +15 -9
- package/dist/skills/ulw-research/scripts/fact-unit-dimensions-2.test.ts +149 -0
- package/dist/skills/ulw-research/scripts/fact-unit-dimensions.test.ts +4 -168
- package/dist/skills/ulw-research/scripts/fact-unit-rules.test.ts +3 -229
- package/dist/skills/ulw-research/scripts/fidelity-claims.mjs +4 -3
- package/dist/skills/ulw-research/scripts/fidelity-csv.mjs +32 -0
- package/dist/skills/ulw-research/scripts/fidelity-lexicon.mjs +1 -1
- package/dist/skills/ulw-research/scripts/fidelity-originals.mjs +161 -0
- package/dist/skills/ulw-research/scripts/fidelity-policy.mjs +183 -0
- package/dist/skills/ulw-research/scripts/fidelity-records.mjs +81 -14
- package/dist/skills/ulw-research/scripts/fidelity-snapshot-readability.mjs +49 -0
- package/dist/skills/ulw-research/scripts/fidelity-sources.mjs +76 -0
- package/dist/skills/ulw-research/scripts/fidelity-trace.mjs +25 -11
- package/dist/skills/ulw-research/scripts/fidelity-value-unit.mjs +202 -0
- package/dist/skills/ulw-research/scripts/fidelity-values.mjs +40 -39
- package/dist/skills/ulw-research/scripts/fidelity-values.test.ts +8 -29
- package/dist/skills/ulw-research/scripts/gates-fidelity.mjs +8 -6
- package/dist/skills/ulw-research/scripts/gates-static-headings.test.ts +17 -0
- package/dist/skills/ulw-research/scripts/gates-static.mjs +10 -1
- package/dist/skills/ulw-research/scripts/html-lite.mjs +6 -2
- package/dist/skills/ulw-research/scripts/html-markup.mjs +2 -2
- package/dist/skills/ulw-research/scripts/html-text-map.mjs +140 -0
- package/dist/skills/ulw-research/scripts/html-text-map.test.ts +148 -0
- package/dist/skills/ulw-research/scripts/markdown-closers.mjs +126 -0
- package/dist/skills/ulw-research/scripts/md-lite-boundaries.test.ts +46 -0
- package/dist/skills/ulw-research/scripts/md-lite.mjs +1 -1
- package/dist/skills/ulw-research/scripts/number-grammar.mjs +33 -0
- package/dist/skills/ulw-research/scripts/number-grammar.test.ts +36 -0
- package/dist/skills/ulw-research/scripts/numerals.mjs +18 -7
- package/dist/skills/ulw-research/scripts/numerals.test.ts +3 -0
- package/dist/skills/ulw-research/scripts/outcome-start.mjs +66 -0
- package/dist/skills/ulw-research/scripts/outcome-start.test.ts +109 -0
- package/dist/skills/ulw-research/scripts/outcome.mjs +11 -22
- package/dist/skills/ulw-research/scripts/page-source-locator.test.ts +187 -0
- package/dist/skills/ulw-research/scripts/placeholder.mjs +18 -6
- package/dist/skills/ulw-research/scripts/polish-apply.mjs +3 -2
- package/dist/skills/ulw-research/scripts/polish-markup.test.ts +15 -1
- package/dist/skills/ulw-research/scripts/polish-partial.test.ts +42 -0
- package/dist/skills/ulw-research/scripts/raw-decode.mjs +110 -0
- package/dist/skills/ulw-research/scripts/raw-locator.mjs +47 -0
- package/dist/skills/ulw-research/scripts/raw-snapshot.test.ts +139 -0
- package/dist/skills/ulw-research/scripts/report-tools-2.test.ts +233 -0
- package/dist/skills/ulw-research/scripts/report-tools-3.test.ts +141 -0
- package/dist/skills/ulw-research/scripts/report-tools-4.test.ts +135 -0
- package/dist/skills/ulw-research/scripts/report-tools-5.test.ts +231 -0
- package/dist/skills/ulw-research/scripts/report-tools-commands.mjs +1 -1
- package/dist/skills/ulw-research/scripts/report-tools.mjs +7 -1
- package/dist/skills/ulw-research/scripts/report-tools.test.ts +6 -560
- package/dist/skills/ulw-research/scripts/snapshot-readability.test.ts +116 -0
- package/dist/skills/ulw-research/scripts/source-commands.mjs +87 -29
- package/dist/skills/ulw-research/scripts/source-integrity.test.ts +243 -0
- package/dist/skills/ulw-research/scripts/source-refresh.mjs +82 -0
- package/dist/skills/ulw-research/scripts/source-snapshot.mjs +73 -69
- package/dist/skills/ulw-research/scripts/source-snapshot.test.ts +7 -4
- package/dist/skills/ulw-research/scripts/source-view.mjs +89 -0
- package/dist/skills/ulw-research/scripts/sources-citation.mjs +203 -0
- package/dist/skills/ulw-research/scripts/sources-citation.test.ts +236 -0
- package/dist/skills/ulw-research/scripts/tests/contracts-support.ts +147 -0
- package/dist/skills/ulw-research/scripts/tests/delivery-barrier-session.ts +59 -0
- package/dist/skills/ulw-research/scripts/tests/derive-clock.ts +4 -0
- package/dist/skills/ulw-research/scripts/tests/fact-derive-support.ts +65 -0
- package/dist/skills/ulw-research/scripts/tests/fact-unit-dimensions-support.ts +41 -0
- package/dist/skills/ulw-research/scripts/tests/fact-unit-rules-support.ts +241 -0
- package/dist/skills/ulw-research/scripts/tests/fidelity-values-support.ts +30 -0
- package/dist/skills/ulw-research/scripts/tests/fixtures/conversion-probe.html +14 -0
- package/dist/skills/ulw-research/scripts/tests/fixtures/sources-shapes.html +20 -0
- package/dist/skills/ulw-research/scripts/tests/numeral-classes.ts +196 -0
- package/dist/skills/ulw-research/scripts/tests/report-tools-support.ts +182 -0
- package/dist/skills/ulw-research/scripts/tests/value-mode-support.ts +48 -0
- package/dist/skills/ulw-research/scripts/units.mjs +14 -3
- package/dist/skills/ulw-research/scripts/units.test.ts +10 -0
- package/dist/skills/ulw-research/scripts/value-mode-unit-classes.test.ts +255 -0
- package/dist/skills/ulw-research/scripts/value-mode-unit.test.ts +179 -0
- package/dist/skills/ulw-research/scripts/value-rules-cli.test.ts +157 -0
- package/dist/skills/ulw-research/scripts/value-rules-followups.test.ts +72 -0
- package/dist/skills/ulw-research/scripts/value-rules-priority.test.ts +80 -0
- package/dist/tools/delegate-task/executor-types.d.ts +1 -0
- package/dist/tools/delegate-task/sync-session-existence.d.ts +4 -0
- package/dist/tools/delegate-task/types.d.ts +1 -0
- package/dist/tools/skill/description-formatter.d.ts +2 -1
- package/dist/tools/skill/types.d.ts +6 -0
- package/dist/tui.js +131 -33
- package/package.json +18 -15
- package/packages/git-bash-mcp/package.json +1 -1
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/README.md +1 -1
- 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/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- 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/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lcx/skills/lcx-contribute-bug-fix/SKILL.md +51 -55
- package/packages/omo-codex/plugin/components/lcx/skills/lcx-contribute-bug-fix/agents/openai.yaml +1 -1
- package/packages/omo-codex/plugin/components/lcx/skills/lcx-report-bug/SKILL.md +7 -7
- package/packages/omo-codex/plugin/components/lcx/skills/lcx-report-bug/agents/openai.yaml +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +2 -2
- package/packages/omo-codex/plugin/components/telemetry/README.md +2 -2
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +52 -15
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +52 -19
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +2 -9
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +4 -13
- package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +0 -2
- package/packages/omo-codex/plugin/components/telemetry/test/codex-hook-diagnostics.test.ts +0 -3
- package/packages/omo-codex/plugin/components/telemetry/test/codex-hook.test.ts +3 -8
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +3 -0
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +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 +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- 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 +16 -16
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/shared/package.json +1 -1
- package/packages/omo-codex/plugin/skills/ast-grep/README.md +1 -1
- package/packages/omo-codex/plugin/skills/ast-grep/install.ps1 +5 -3
- package/packages/omo-codex/plugin/skills/ast-grep/install.sh +4 -5
- package/packages/omo-codex/plugin/skills/ast-grep/references/install.md +2 -2
- package/packages/omo-codex/plugin/skills/ast-grep/scripts/ast_grep_helper.py +13 -3
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/AGENTS.md +5 -4
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +11 -11
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/all-platforms.md +2 -2
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/codex.md +4 -4
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +1 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/find-agent-sessions.py +6 -3
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +34 -12
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +2 -2
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +2 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/component-catalogs.md +14 -10
- package/packages/omo-codex/plugin/skills/frontend/references/design/design-system-architecture.md +19 -6
- package/packages/omo-codex/plugin/skills/frontend/references/design/grounding.md +29 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/scripts/design_system.py +2 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/scripts/search.py +2 -0
- package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/SKILL.md +51 -55
- package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/agents/openai.yaml +1 -1
- package/packages/omo-codex/plugin/skills/lcx-report-bug/SKILL.md +7 -7
- package/packages/omo-codex/plugin/skills/lcx-report-bug/agents/openai.yaml +1 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +5 -4
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +2 -2
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/__main__.py +9 -6
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/summary.py +1 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/README.md +4 -4
- package/packages/omo-codex/plugin/skills/ultimate-browsing/scripts/extract_cookies.py +4 -2
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +3 -0
- package/packages/omo-codex/plugin/skills/ulw-research/AGENTS.md +8 -4
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +7 -259
- package/packages/omo-codex/plugin/skills/ulw-research/references/deliverable-phase.md +68 -24
- package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger-grammar.md +7 -3
- package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger.md +42 -8
- package/packages/omo-codex/plugin/skills/ulw-research/references/fidelity-claim-kinds.md +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/references/markdown-blocks.md +12 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/report-gates.md +14 -6
- package/packages/omo-codex/plugin/skills/ulw-research/references/research-collection.md +195 -0
- package/packages/omo-codex/plugin/skills/ulw-research/references/research-delivery.md +123 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/claim-kinds.mjs +33 -5
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/contracts.mjs +16 -15
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/conversion-probe.mjs +229 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/css-hiding.mjs +158 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/css-lite.mjs +4 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/entities.mjs +13 -4
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-fill.mjs +96 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +26 -30
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-polish.mjs +46 -19
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +37 -6
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands.mjs +40 -62
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-derive.mjs +7 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-fill.mjs +9 -6
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger-kinds.mjs +6 -7
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-locate.mjs +15 -9
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-claims.mjs +4 -3
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-csv.mjs +32 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-lexicon.mjs +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-originals.mjs +161 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-policy.mjs +183 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-records.mjs +81 -14
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-snapshot-readability.mjs +49 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-sources.mjs +76 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-trace.mjs +25 -11
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-value-unit.mjs +202 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-values.mjs +40 -39
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-fidelity.mjs +8 -6
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-static.mjs +10 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-lite.mjs +6 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-markup.mjs +2 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-text-map.mjs +140 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/markdown-closers.mjs +126 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/md-lite.mjs +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/number-grammar.mjs +33 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/numerals.mjs +18 -7
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/outcome-start.mjs +66 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/outcome.mjs +11 -22
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/placeholder.mjs +18 -6
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-apply.mjs +3 -2
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/raw-decode.mjs +110 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/raw-locator.mjs +47 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools-commands.mjs +1 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools.mjs +7 -1
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-commands.mjs +87 -29
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-refresh.mjs +82 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-snapshot.mjs +73 -69
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-view.mjs +89 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/sources-citation.mjs +203 -0
- package/packages/omo-codex/plugin/skills/ulw-research/scripts/units.mjs +14 -3
- package/packages/omo-codex/plugin/test/payload-equivalence.test.mjs +6 -4
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +4 -3
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +338 -237
- package/packages/prompts-core/prompts/ultrawork/codex.md +3 -0
- package/packages/shared-skills/skill-source-filter.mjs +6 -2
- package/packages/shared-skills/skills/ast-grep/README.md +1 -1
- package/packages/shared-skills/skills/ast-grep/install.ps1 +5 -3
- package/packages/shared-skills/skills/ast-grep/install.sh +4 -5
- package/packages/shared-skills/skills/ast-grep/references/install.md +2 -2
- package/packages/shared-skills/skills/ast-grep/scripts/ast_grep_helper.py +13 -3
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/shared-skills/skills/coding-agent-sessions/AGENTS.md +5 -4
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +11 -11
- package/packages/shared-skills/skills/coding-agent-sessions/references/all-platforms.md +2 -2
- package/packages/shared-skills/skills/coding-agent-sessions/references/codex.md +4 -4
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +1 -1
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/find-agent-sessions.py +6 -3
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +1 -1
- package/packages/shared-skills/skills/frontend/SKILL.md +34 -12
- package/packages/shared-skills/skills/frontend/references/design/README.md +2 -2
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +2 -1
- package/packages/shared-skills/skills/frontend/references/design/component-catalogs.md +14 -10
- package/packages/shared-skills/skills/frontend/references/design/design-system-architecture.md +19 -6
- package/packages/shared-skills/skills/frontend/references/design/grounding.md +29 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/scripts/design_system.py +2 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/scripts/search.py +2 -0
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +5 -4
- package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +2 -2
- package/packages/shared-skills/skills/ultimate-browsing/engine/__main__.py +9 -6
- package/packages/shared-skills/skills/ultimate-browsing/engine/summary.py +1 -1
- package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/README.md +4 -4
- package/packages/shared-skills/skills/ultimate-browsing/scripts/extract_cookies.py +4 -2
- package/packages/shared-skills/skills/ulw-research/AGENTS.md +8 -4
- package/packages/shared-skills/skills/ulw-research/SKILL.md +7 -259
- package/packages/shared-skills/skills/ulw-research/references/deliverable-phase.md +68 -24
- package/packages/shared-skills/skills/ulw-research/references/fact-ledger-grammar.md +7 -3
- package/packages/shared-skills/skills/ulw-research/references/fact-ledger.md +42 -8
- package/packages/shared-skills/skills/ulw-research/references/fidelity-claim-kinds.md +1 -1
- package/packages/shared-skills/skills/ulw-research/references/markdown-blocks.md +12 -0
- package/packages/shared-skills/skills/ulw-research/references/report-gates.md +14 -6
- package/packages/shared-skills/skills/ulw-research/references/research-collection.md +195 -0
- package/packages/shared-skills/skills/ulw-research/references/research-delivery.md +123 -0
- package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.mjs +33 -5
- package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.test.ts +37 -2
- package/packages/shared-skills/skills/ulw-research/scripts/claim-prefix.test.ts +76 -0
- package/packages/shared-skills/skills/ulw-research/scripts/contracts-validation.test.ts +83 -0
- package/packages/shared-skills/skills/ulw-research/scripts/contracts.mjs +16 -15
- package/packages/shared-skills/skills/ulw-research/scripts/contracts.test.ts +6 -109
- package/packages/shared-skills/skills/ulw-research/scripts/conversion-altered.test.ts +154 -0
- package/packages/shared-skills/skills/ulw-research/scripts/conversion-originals.test.ts +297 -0
- package/packages/shared-skills/skills/ulw-research/scripts/conversion-probe-classes.test.ts +361 -0
- package/packages/shared-skills/skills/ulw-research/scripts/conversion-probe.mjs +229 -0
- package/packages/shared-skills/skills/ulw-research/scripts/conversion-probe.test.ts +218 -0
- package/packages/shared-skills/skills/ulw-research/scripts/copy-returns-fidelity-policy.test.ts +156 -0
- package/packages/shared-skills/skills/ulw-research/scripts/copy-returns-polish.test.ts +10 -9
- package/packages/shared-skills/skills/ulw-research/scripts/css-hiding.mjs +158 -0
- package/packages/shared-skills/skills/ulw-research/scripts/css-lite.mjs +4 -2
- package/packages/shared-skills/skills/ulw-research/scripts/delivery-barrier-meaning.test.ts +186 -0
- package/packages/shared-skills/skills/ulw-research/scripts/delivery-barrier.test.ts +40 -87
- package/packages/shared-skills/skills/ulw-research/scripts/entities.mjs +13 -4
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-fill.mjs +96 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-meaning.mjs +26 -30
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-polish.mjs +46 -19
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-verify.mjs +37 -6
- package/packages/shared-skills/skills/ulw-research/scripts/fact-commands.mjs +40 -62
- package/packages/shared-skills/skills/ulw-research/scripts/fact-derive-2.test.ts +149 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.mjs +7 -2
- package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.test.ts +7 -192
- package/packages/shared-skills/skills/ulw-research/scripts/fact-fill.mjs +9 -6
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.mjs +6 -7
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.test.ts +2 -1
- package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-legacy.test.ts +2 -1
- package/packages/shared-skills/skills/ulw-research/scripts/fact-locate.mjs +15 -9
- package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-dimensions-2.test.ts +149 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-dimensions.test.ts +4 -168
- package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-rules.test.ts +3 -229
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-claims.mjs +4 -3
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-csv.mjs +32 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-lexicon.mjs +1 -1
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-originals.mjs +161 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-policy.mjs +183 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-records.mjs +81 -14
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-snapshot-readability.mjs +49 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-sources.mjs +76 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-trace.mjs +25 -11
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-value-unit.mjs +202 -0
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.mjs +40 -39
- package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.test.ts +8 -29
- package/packages/shared-skills/skills/ulw-research/scripts/gates-fidelity.mjs +8 -6
- package/packages/shared-skills/skills/ulw-research/scripts/gates-static-headings.test.ts +17 -0
- package/packages/shared-skills/skills/ulw-research/scripts/gates-static.mjs +10 -1
- package/packages/shared-skills/skills/ulw-research/scripts/html-lite.mjs +6 -2
- package/packages/shared-skills/skills/ulw-research/scripts/html-markup.mjs +2 -2
- package/packages/shared-skills/skills/ulw-research/scripts/html-text-map.mjs +140 -0
- package/packages/shared-skills/skills/ulw-research/scripts/html-text-map.test.ts +148 -0
- package/packages/shared-skills/skills/ulw-research/scripts/markdown-closers.mjs +126 -0
- package/packages/shared-skills/skills/ulw-research/scripts/md-lite-boundaries.test.ts +46 -0
- package/packages/shared-skills/skills/ulw-research/scripts/md-lite.mjs +1 -1
- package/packages/shared-skills/skills/ulw-research/scripts/number-grammar.mjs +33 -0
- package/packages/shared-skills/skills/ulw-research/scripts/number-grammar.test.ts +36 -0
- package/packages/shared-skills/skills/ulw-research/scripts/numerals.mjs +18 -7
- package/packages/shared-skills/skills/ulw-research/scripts/numerals.test.ts +3 -0
- package/packages/shared-skills/skills/ulw-research/scripts/outcome-start.mjs +66 -0
- package/packages/shared-skills/skills/ulw-research/scripts/outcome-start.test.ts +109 -0
- package/packages/shared-skills/skills/ulw-research/scripts/outcome.mjs +11 -22
- package/packages/shared-skills/skills/ulw-research/scripts/page-source-locator.test.ts +187 -0
- package/packages/shared-skills/skills/ulw-research/scripts/placeholder.mjs +18 -6
- package/packages/shared-skills/skills/ulw-research/scripts/polish-apply.mjs +3 -2
- package/packages/shared-skills/skills/ulw-research/scripts/polish-markup.test.ts +15 -1
- package/packages/shared-skills/skills/ulw-research/scripts/polish-partial.test.ts +42 -0
- package/packages/shared-skills/skills/ulw-research/scripts/raw-decode.mjs +110 -0
- package/packages/shared-skills/skills/ulw-research/scripts/raw-locator.mjs +47 -0
- package/packages/shared-skills/skills/ulw-research/scripts/raw-snapshot.test.ts +139 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-2.test.ts +233 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-3.test.ts +141 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-4.test.ts +135 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-5.test.ts +231 -0
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools-commands.mjs +1 -1
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools.mjs +7 -1
- package/packages/shared-skills/skills/ulw-research/scripts/report-tools.test.ts +6 -560
- package/packages/shared-skills/skills/ulw-research/scripts/snapshot-readability.test.ts +116 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-commands.mjs +87 -29
- package/packages/shared-skills/skills/ulw-research/scripts/source-integrity.test.ts +243 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-refresh.mjs +82 -0
- package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.mjs +73 -69
- package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.test.ts +7 -4
- package/packages/shared-skills/skills/ulw-research/scripts/source-view.mjs +89 -0
- package/packages/shared-skills/skills/ulw-research/scripts/sources-citation.mjs +203 -0
- package/packages/shared-skills/skills/ulw-research/scripts/sources-citation.test.ts +236 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/contracts-support.ts +147 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/delivery-barrier-session.ts +59 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/derive-clock.ts +4 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fact-derive-support.ts +65 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fact-unit-dimensions-support.ts +41 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fact-unit-rules-support.ts +241 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fidelity-values-support.ts +30 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/conversion-probe.html +14 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/sources-shapes.html +20 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/numeral-classes.ts +196 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/report-tools-support.ts +182 -0
- package/packages/shared-skills/skills/ulw-research/scripts/tests/value-mode-support.ts +48 -0
- package/packages/shared-skills/skills/ulw-research/scripts/units.mjs +14 -3
- package/packages/shared-skills/skills/ulw-research/scripts/units.test.ts +10 -0
- package/packages/shared-skills/skills/ulw-research/scripts/value-mode-unit-classes.test.ts +255 -0
- package/packages/shared-skills/skills/ulw-research/scripts/value-mode-unit.test.ts +179 -0
- package/packages/shared-skills/skills/ulw-research/scripts/value-rules-cli.test.ts +157 -0
- package/packages/shared-skills/skills/ulw-research/scripts/value-rules-followups.test.ts +72 -0
- package/packages/shared-skills/skills/ulw-research/scripts/value-rules-priority.test.ts +80 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/fixtures/amp_redirect_stub.html +0 -7
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/fixtures/search_interstitial.html +0 -19
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/fixtures/wayback_available.json +0 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/fixtures/wayback_snapshot.html +0 -1128
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_fetch_chain.py +0 -77
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +0 -86
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +0 -279
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_surrogate.py +0 -252
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_surrogate_validators.py +0 -78
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
// English number words one to twelve, an adjacent currency symbol or unit, and an adjacent bounding
|
|
7
7
|
// qualifier. No numeral is ever passed through Number(). Plain Node ESM, sibling imports only.
|
|
8
8
|
|
|
9
|
+
import { groupedNumberSource } from "./number-grammar.mjs"
|
|
9
10
|
import { add, fromDecimal, mul, toDecimal } from "./rational.mjs"
|
|
10
11
|
import { normalizeUnit } from "./units.mjs"
|
|
11
12
|
|
|
13
|
+
/** European digit grouping ("1.234.567"): two or more dot groups of three digits, never a version. */
|
|
14
|
+
export const DOT_GROUPED = "\\d{1,3}(?:\\.\\d{3}){2,}"
|
|
12
15
|
const MONTH = "(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\\.?"
|
|
13
16
|
/** Stripped before claim detection: dates, versions, figure refs, times, bare years. */
|
|
14
17
|
export const NOT_CLAIMS = [
|
|
@@ -19,7 +22,7 @@ export const NOT_CLAIMS = [
|
|
|
19
22
|
/(?:19|20)\d{2}\s*\uB144/g,
|
|
20
23
|
new RegExp(`\\b${MONTH}\\s+\\d{1,2}(?:st|nd|rd|th)?(?:,?\\s+\\d{4})?`, "gi"),
|
|
21
24
|
new RegExp(`\\b\\d{1,2}(?:st|nd|rd|th)?\\s+${MONTH}(?:\\s+\\d{4})?`, "gi"),
|
|
22
|
-
|
|
25
|
+
new RegExp(`\\bv\\d+(?:\\.\\d+)*\\b|\\b(?!${DOT_GROUPED}(?![\\d,]|\\.\\d))\\d+(?:\\.\\d+){2,}\\b`, "gi"),
|
|
23
26
|
/\b(?:version|ver\.?|release)\s*\d+(?:\.\d+)*/gi,
|
|
24
27
|
/\b(?:fig(?:ure)?\.?|table|chart|section|step|phase|wave|part)\s*\d+(?:\.\d+)*/gi,
|
|
25
28
|
/(?:\uADF8\uB9BC|\uB3C4\uD45C|\uD45C|\uBC84\uC804)\s*\d+(?:\.\d+)*/g,
|
|
@@ -45,8 +48,8 @@ const BIG = new Map([["\uB9CC", 10000n], ["\uC5B5", 100000000n], ["\uC870", 1000
|
|
|
45
48
|
/** A scale word that starts a longer word is not a scale: jogak (pieces), mankeum (as much as). */
|
|
46
49
|
const KO_GROUP = /^(\s?)(?:(\uCC9C)?([\uB9CC\uC5B5\uC870])|(\uCC9C))(?![\uAC01\uD07C])/
|
|
47
50
|
const KO_NEXT = new RegExp(`^\\s?(${NUM})(\uCC9C)?([\uB9CC\uC5B5\uC870])?`, "u")
|
|
48
|
-
const LATIN_SCALE = /^(?:(k|K|M|bn|B)|\s(thousand|million|billion|trillion|bn))(?![\p{L}\d])/u
|
|
49
|
-
const LATIN_FACTOR = { k: 1000n, K: 1000n, M: 1000000n, bn: 1000000000n, B: 1000000000n, thousand: 1000n, million: 1000000n, billion: 1000000000n, trillion: 1000000000000n }
|
|
51
|
+
const LATIN_SCALE = /^(?:(k|K|M|mn|bn|B)|\s(thousand|million|billion|trillion|mn|bn))(?![\p{L}\d])/u
|
|
52
|
+
const LATIN_FACTOR = { k: 1000n, K: 1000n, M: 1000000n, mn: 1000000n, bn: 1000000000n, B: 1000000000n, thousand: 1000n, million: 1000000n, billion: 1000000000n, trillion: 1000000000000n }
|
|
50
53
|
const CURRENCY = "$\u20AC\u00A3\u00A5\u20A9"
|
|
51
54
|
const SYMBOL_UNIT = /^\s?(%p|%|\u2030|\u00D7|\u00B0C|\u00B0F|\u2103|\u2109)/
|
|
52
55
|
const LATIN_UNIT = /^\s?([A-Za-z]+)(?![\p{L}\d])/u
|
|
@@ -60,15 +63,23 @@ const RANGE_SEP = /^(?:\s?[-\u2013~]\s?|\sto\s)/
|
|
|
60
63
|
const SIGN = "-\u2212"
|
|
61
64
|
/** Bounding qualifiers: before the value (Korean and English) and right after it (Korean). */
|
|
62
65
|
const QUALIFIERS_BEFORE = ["up to", "at least", "at most", "more than", "less than", "about", "approximately", "nearly", "over", "under", "\uCD5C\uB300", "\uCD5C\uC18C", "\uC57D"]
|
|
63
|
-
|
|
66
|
+
/** Korean bounding qualifiers written right after a value (isang, iha, miman, chogwa, naeoe, kkaji). */
|
|
67
|
+
export const QUALIFIERS_AFTER = Object.freeze(["\uC774\uC0C1", "\uC774\uD558", "\uBBF8\uB9CC", "\uCD08\uACFC", "\uB0B4\uC678", "\uAE4C\uC9C0"])
|
|
68
|
+
const QUALIFIER_AFTER = new RegExp(`^\\s?(${QUALIFIERS_AFTER.join("|")})`)
|
|
64
69
|
|
|
65
|
-
/**
|
|
70
|
+
/** Comma grouping from the one grouped-number grammar (number-grammar.mjs). */
|
|
71
|
+
const COMMA_GROUPED = new RegExp(`^${groupedNumberSource([","])}$`)
|
|
72
|
+
|
|
73
|
+
/** "1,237" -> "1237"; a malformed group ("1,23", "12,3451") keeps only the leading plain number. */
|
|
66
74
|
function cleanDigits(raw) {
|
|
67
|
-
if (
|
|
75
|
+
if (COMMA_GROUPED.test(raw)) return { digits: raw.replace(/,/g, ""), length: raw.length }
|
|
68
76
|
const plain = /^\d+(?:\.\d+)?/.exec(raw)[0]
|
|
69
77
|
return { digits: plain, length: plain.length }
|
|
70
78
|
}
|
|
71
79
|
|
|
80
|
+
/** A numeral's digits, reading a European period grouping ("1.234.567") as one integer. */
|
|
81
|
+
const digitsOf = (raw) => (new RegExp(`^${DOT_GROUPED}$`).test(raw) ? { digits: raw.replace(/\./g, ""), length: raw.length } : cleanDigits(raw))
|
|
82
|
+
|
|
72
83
|
/** The bare-year and four-digit-date patterns: a numeral they cover can still be a value. */
|
|
73
84
|
const YEAR_SHAPED = new Set([NOT_CLAIMS[0], NOT_CLAIMS[12]])
|
|
74
85
|
|
|
@@ -95,7 +106,7 @@ function findStart(text, from, ranges) {
|
|
|
95
106
|
let digit = null
|
|
96
107
|
for (const match of text.slice(from).matchAll(new RegExp(NUM, "gu"))) {
|
|
97
108
|
const at = from + match.index
|
|
98
|
-
const candidate = { at, ...
|
|
109
|
+
const candidate = { at, ...digitsOf(match[0]) }
|
|
99
110
|
const end = at + candidate.length
|
|
100
111
|
const cover = covering(at)
|
|
101
112
|
const lifted = cover.every(([s, e, yearShaped]) => yearShaped && s === at && e <= end)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// outcome-start.mjs - the run clock (outcome.json startedAt). `outcome init` is its one writer and
|
|
2
|
+
// records it once: --started-at from the orchestrator, else the startedAt of a valid manifest an
|
|
3
|
+
// earlier init wrote (a re-init keeps the clock), else terminal-state.json.started_at when a
|
|
4
|
+
// supervisor wrote one, else the YYYYMMDD-HHMMSS session dir name. A recorded value must be a real
|
|
5
|
+
// ISO time with Z or an offset, not after `now`, and within a day of a stamped dir name; otherwise
|
|
6
|
+
// init refuses instead of falling back. Never the interview's as-of date. No clock reads.
|
|
7
|
+
import { readFileSync } from "node:fs"
|
|
8
|
+
import { basename, join, resolve } from "node:path"
|
|
9
|
+
|
|
10
|
+
const ISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/
|
|
11
|
+
const SESSION_STAMP = /^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})$/
|
|
12
|
+
const DAY_MS = 86_400_000
|
|
13
|
+
|
|
14
|
+
/** A real calendar time (no 2026-02-30, no T24:00), or null. */
|
|
15
|
+
function strictIso(value) {
|
|
16
|
+
const match = typeof value === "string" ? ISO.exec(value) : null
|
|
17
|
+
if (!match) return null
|
|
18
|
+
const [y, mo, d, h, mi, s, oh = 0, om = 0] = match.slice(1).map((part) => Number(part ?? 0))
|
|
19
|
+
const day = new Date(Date.UTC(y, mo - 1, d))
|
|
20
|
+
if (day.getUTCMonth() !== mo - 1 || day.getUTCDate() !== d || h > 23 || mi > 59 || s > 59 || oh > 23 || om > 59) return null
|
|
21
|
+
const date = new Date(value)
|
|
22
|
+
return Number.isNaN(date.getTime()) ? null : date
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Local start time from a YYYYMMDD-HHMMSS dir name, null when the name is not a stamp. */
|
|
26
|
+
function dirStamp(sessionDir, fail) {
|
|
27
|
+
const match = SESSION_STAMP.exec(basename(sessionDir))
|
|
28
|
+
if (!match) return null
|
|
29
|
+
const [y, mo, d, h, mi, s] = match.slice(1).map(Number)
|
|
30
|
+
const date = new Date(y, mo - 1, d, h, mi, s)
|
|
31
|
+
if (date.getMonth() !== mo - 1 || date.getDate() !== d || date.getHours() !== h) fail(`session dir basename is not a real local time: ${sessionDir}`)
|
|
32
|
+
return date
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function readJson(sessionDir, file) {
|
|
36
|
+
try {
|
|
37
|
+
return { data: JSON.parse(readFileSync(join(sessionDir, file), "utf8")) }
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") return null
|
|
40
|
+
if (error instanceof SyntaxError) return { corrupt: `${join(sessionDir, file)} is not valid JSON (${error.message})` }
|
|
41
|
+
throw error
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {{ sessionDir: string, startedAt?: string, now?: Date, validManifest: (data: unknown) => boolean, fail: (message: string) => never }} input
|
|
47
|
+
* @returns {Date}
|
|
48
|
+
*/
|
|
49
|
+
export function runStart({ sessionDir, startedAt, now, validManifest, fail }) {
|
|
50
|
+
const dir = dirStamp(sessionDir, fail)
|
|
51
|
+
const check = (value, location) => {
|
|
52
|
+
const date = strictIso(value)
|
|
53
|
+
if (!date) fail(`invalid run timestamp in ${location}: ${JSON.stringify(value)} is not a real ISO time with Z or an offset`)
|
|
54
|
+
if (now && date > now) fail(`run timestamp in ${location} (${value}) is after now (${now.toISOString()})`)
|
|
55
|
+
if (dir && Math.abs(date - dir) > DAY_MS) fail(`run timestamp in ${location} (${value}) is not within a day of the session dir name ${basename(sessionDir)}: a copied or stale value`)
|
|
56
|
+
return date
|
|
57
|
+
}
|
|
58
|
+
if (startedAt !== undefined) return check(startedAt, "--started-at")
|
|
59
|
+
const manifest = readJson(sessionDir, "outcome.json")
|
|
60
|
+
if (manifest?.data && validManifest(manifest.data) && resolve(String(manifest.data.sessionDir)) === resolve(sessionDir)) return check(manifest.data.startedAt, "outcome.json.startedAt")
|
|
61
|
+
const terminal = readJson(sessionDir, "terminal-state.json")
|
|
62
|
+
if (terminal?.corrupt) fail(terminal.corrupt)
|
|
63
|
+
if (terminal?.data?.started_at !== undefined) return check(terminal.data.started_at, "terminal-state.json.started_at")
|
|
64
|
+
if (dir) return dir
|
|
65
|
+
return fail(`missing run timestamp: pass --started-at <ISO>, record terminal-state.json.started_at, or name the session dir YYYYMMDD-HHMMSS (${sessionDir})`)
|
|
66
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// outcome.mjs - the per-run outcome manifest (`outcome.json`) and the closing briefing. Manifest functions are pure (they return a new manifest).
|
|
2
2
|
// The briefing reads only the manifest, the sources-ledger text, and an injected `now`. node: builtins only.
|
|
3
|
-
|
|
4
3
|
import * as nodeFs from "node:fs"
|
|
5
4
|
import { basename, dirname, join } from "node:path"
|
|
6
5
|
|
|
7
6
|
import { DELIVERABLE_FORMATS, DELIVERABLE_STATUSES, GATE_NAMES, GATE_STATUSES, LANES, MANIFEST_CODES, normalizeManifest, SCHEMA_VERSION, validateOutcomeManifest } from "./contracts.mjs"
|
|
7
|
+
import { runStart } from "./outcome-start.mjs"
|
|
8
8
|
|
|
9
9
|
export const MANIFEST_FILENAME = "outcome.json"
|
|
10
10
|
const MISSING = MANIFEST_CODES[0]
|
|
11
|
-
const SESSION_STAMP = /^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})$/
|
|
12
11
|
const SOURCE_LINE = /^\[(S|Source )\d+\]/
|
|
13
12
|
const URL_PATTERN = /https?:\/\/[^\s)<>\]"'`]+/g
|
|
14
13
|
const DRAFT_MARKER = "STATUS: draft"
|
|
@@ -33,26 +32,20 @@ function assertOneOf(code, label, value, allowed) {
|
|
|
33
32
|
|
|
34
33
|
const clone = (manifest) => structuredClone(manifest)
|
|
35
34
|
const isMissing = (error) => error?.code === "ENOENT" || error?.code === "ENOTDIR"
|
|
36
|
-
|
|
37
35
|
function stamp(now) {
|
|
38
36
|
return (now ?? new Date()).toISOString()
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!match) throw new OutcomeError("invalid_session_dir", `session dir basename must be YYYYMMDD-HHMMSS: ${sessionDir}`)
|
|
45
|
-
const [y, mo, d, h, mi, s] = match.slice(1).map(Number)
|
|
46
|
-
const date = new Date(y, mo - 1, d, h, mi, s)
|
|
47
|
-
if (date.getMonth() !== mo - 1 || date.getDate() !== d || date.getHours() !== h) {
|
|
48
|
-
throw new OutcomeError("invalid_session_dir", `session dir basename is not a real local time: ${sessionDir}`)
|
|
38
|
+
/** The run clock outcome init records (outcome-start.mjs owns the contract). */
|
|
39
|
+
export function parseSessionStart(sessionDir, { startedAt, now } = {}) {
|
|
40
|
+
const fail = (message) => {
|
|
41
|
+
throw new OutcomeError("invalid_session_dir", message)
|
|
49
42
|
}
|
|
50
|
-
return
|
|
43
|
+
return runStart({ sessionDir, startedAt, now, validManifest: (data) => validateOutcomeManifest(normalizeManifest(data)).ok, fail })
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
/** @param {{ sessionDir: string, promised: string[], lane: string|null, interview?: object|null, now?: Date }} input */
|
|
54
|
-
export function initManifest({ sessionDir, promised, lane, interview = null, now }) {
|
|
55
|
-
const startedAt = parseSessionStart(sessionDir).toISOString()
|
|
46
|
+
/** @param {{ sessionDir: string, promised: string[], lane: string|null, interview?: object|null, now?: Date, startedAt?: string }} input */
|
|
47
|
+
export function initManifest({ sessionDir, promised, lane, interview = null, now, startedAt: recorded }) {
|
|
48
|
+
const startedAt = parseSessionStart(sessionDir, { startedAt: recorded, now }).toISOString()
|
|
56
49
|
if (lane !== null && lane !== undefined) assertOneOf("unknown_lane", "lane", lane, LANES)
|
|
57
50
|
const formats = [...new Set(promised)]
|
|
58
51
|
for (const format of formats) assertOneOf("unknown_format", "deliverable format", format, DELIVERABLE_FORMATS)
|
|
@@ -74,9 +67,7 @@ export function initManifest({ sessionDir, promised, lane, interview = null, now
|
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
/**
|
|
78
|
-
* Set one format's row; every other row is kept as is. An unpromised format gets a new
|
|
79
|
-
* row with promised=false. The row's detail fields are replaced by the ones given.
|
|
70
|
+
/** Set one format's row, keeping other rows. New formats have promised=false.
|
|
80
71
|
* @param {{ path?: string, reason?: string, pages?: number, bytes?: number, now?: Date }} [detail]
|
|
81
72
|
*/
|
|
82
73
|
export function setDeliverable(manifest, format, status, detail = {}) {
|
|
@@ -143,9 +134,7 @@ export function verifyManifest(manifest, fs = nodeFs) {
|
|
|
143
134
|
return { ok: problems.length === 0, problems }
|
|
144
135
|
}
|
|
145
136
|
|
|
146
|
-
/**
|
|
147
|
-
* none = missing or empty file; partial = `STATUS: draft` in the first 5 lines, or the
|
|
148
|
-
* manifest (given, else a sibling outcome.json) still has a pending row; else complete.
|
|
137
|
+
/** Missing/empty = none; draft marker or pending manifest = partial; else complete.
|
|
149
138
|
* @returns {"none"|"partial"|"complete"}
|
|
150
139
|
*/
|
|
151
140
|
export function deliverableState(deliverablePath, manifestOrNull) {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// placeholder.mjs - the fact pointer grammar of the fill step and its render helpers.
|
|
2
2
|
// Value pointers: {{F12:label}}, {{F12:label:value}}, {{F12:label:unit}}, {{F12:label:q}}.
|
|
3
|
+
// Claim prefixes from CLAIM_KINDS (V, D, A) precede any one pointer: {{D:F12:label:value}}, {{V:Q7:label:lead=18}}.
|
|
3
4
|
// Quote pointers: {{Q7:label}}, {{Q7:label:lead=18}}, {{Q7:label:from="x":to="y"}} (anchors are
|
|
4
5
|
// JSON strings, so they may hold a colon or an escaped quote). Labels are compared exactly by the
|
|
5
6
|
// caller; this module never guesses an id. Pure functions; node: builtins only.
|
|
6
7
|
|
|
7
8
|
import { parseNumeral } from "./numerals.mjs"
|
|
9
|
+
import { CLAIM_KINDS } from "./claim-kinds.mjs"
|
|
8
10
|
|
|
9
11
|
export const ELLIPSIS = "\u2026"
|
|
10
12
|
|
|
11
|
-
const ID = /^([FQ])\d
|
|
13
|
+
const ID = /^([FQ])[1-9]\d*$/
|
|
12
14
|
const LABEL = /^[^\s:{}"]+$/
|
|
13
15
|
const VALUE_MODES = new Set(["value", "unit", "q"])
|
|
14
16
|
const LEAD = /^lead=([1-9]\d*)$/
|
|
@@ -45,6 +47,12 @@ function parseAnchors(tail) {
|
|
|
45
47
|
export function parsePlaceholder(token) {
|
|
46
48
|
if (!token.startsWith("{{") || !token.endsWith("}}")) return { error: "a placeholder is {{ID:label...}}" }
|
|
47
49
|
const body = token.slice(2, -2)
|
|
50
|
+
const marked = Object.entries(CLAIM_KINDS).find(([, entry]) => entry.prefix && body.startsWith(`${entry.prefix}:`))
|
|
51
|
+
if (marked) {
|
|
52
|
+
const [claimKind, entry] = marked
|
|
53
|
+
const parsed = parsePlaceholder(`{{${body.slice(entry.prefix.length + 1)}}}`)
|
|
54
|
+
return parsed.error || parsed.claimKind ? { error: "a claim prefix must precede one fact or quote pointer" } : { ...parsed, claimKind }
|
|
55
|
+
}
|
|
48
56
|
const colon = body.indexOf(":")
|
|
49
57
|
const id = colon === -1 ? body : body.slice(0, colon)
|
|
50
58
|
const idMatch = ID.exec(id)
|
|
@@ -130,7 +138,7 @@ export function lead(quote, n) {
|
|
|
130
138
|
/** The value and unit parts of a row's raw text ("4.2 eok won" -> value "4.2 eok", unit "won"). */
|
|
131
139
|
export function valueParts(row) {
|
|
132
140
|
const unitText = parseNumeral(row.raw)?.unitRaw ?? row.unit
|
|
133
|
-
const valueText = unitText && row.raw.endsWith(unitText) ? row.raw.slice(0, -unitText.length).trimEnd() :
|
|
141
|
+
const valueText = unitText && row.raw.endsWith(unitText) ? row.raw.slice(0, -unitText.length).trimEnd() : row.raw
|
|
134
142
|
return { valueText, unitText: unitText ?? "" }
|
|
135
143
|
}
|
|
136
144
|
|
|
@@ -156,15 +164,19 @@ export function escapeHtml(text) {
|
|
|
156
164
|
/** The elements the renderers below emit as fact spans; recognizers build their patterns from this. */
|
|
157
165
|
export const FACT_ELEMENT_TAGS = Object.freeze(["data", "q", "blockquote"])
|
|
158
166
|
|
|
159
|
-
|
|
167
|
+
/** `mode` "value" marks a bare value whose unit verify checks beside it; `claimKind` is the claim mark. */
|
|
168
|
+
export function renderValueHtml(row, text, { mode = "full", claimKind = null } = {}) {
|
|
160
169
|
const unit = row.unit === null ? "" : ` data-unit="${escapeHtml(row.unit)}"`
|
|
161
|
-
|
|
170
|
+
const marker = mode === "value" ? ' data-fact-mode="value"' : ""
|
|
171
|
+
const mark = claimKind === null ? "" : ` data-claim-kind="${escapeHtml(claimKind)}"`
|
|
172
|
+
return `<data class="fact" value="${escapeHtml(row.value)}" data-fact="${row.fact_id}"${unit}${marker}${mark} data-lineage="${LINEAGE[row.kind]}">${escapeHtml(text)}</data>`
|
|
162
173
|
}
|
|
163
174
|
|
|
164
|
-
export function renderQuote(row, selector, text, format) {
|
|
175
|
+
export function renderQuote(row, selector, text, format, claimKind = null) {
|
|
165
176
|
const marker = `[${row.source_id}]`
|
|
166
177
|
if (format === "md") return `"${text}" ${marker}`
|
|
167
|
-
|
|
178
|
+
const mark = claimKind === null ? "" : ` data-claim-kind="${escapeHtml(claimKind)}"`
|
|
179
|
+
return `<q data-fact="${row.fact_id}"${mark} data-quote-sel="${escapeHtml(selector)}">${escapeHtml(text)}</q> ${marker}`
|
|
168
180
|
}
|
|
169
181
|
|
|
170
182
|
const RENDERED_MD_QUOTE = /^"([\s\S]*)" (\[S\d+\])$/u
|
|
@@ -54,9 +54,10 @@ export const POLISH_REFERENCE_REASON = "edit touches a character reference: rout
|
|
|
54
54
|
/** True when [start, end) overlaps a character reference of html or starts inside one. */
|
|
55
55
|
export function touchesReference(html, start, end) {
|
|
56
56
|
for (const match of String(html).matchAll(CHARACTER_REFERENCE)) {
|
|
57
|
-
|
|
57
|
+
const stop = match.index + match[0].length
|
|
58
|
+
if (match.index < end && (stop > start || (stop === start && !match[0].endsWith(";")))) return true
|
|
58
59
|
}
|
|
59
|
-
return
|
|
60
|
+
return false
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// raw-decode.mjs - decode a source's raw bytes in their declared encoding and keep a byte map.
|
|
2
|
+
//
|
|
3
|
+
// decodeRaw returns { text, encoding, bytes } where bytes[i] is the raw byte offset at which UTF-16
|
|
4
|
+
// unit i of `text` starts and bytes[text.length] === raw.length, so any text range maps back to the
|
|
5
|
+
// bytes the source actually holds (never to a lossy UTF-8 re-encode). The encoding comes from a
|
|
6
|
+
// BOM, then the caller's declared charset (HTTP header or meta.json), then an HTML <meta> charset,
|
|
7
|
+
// and defaults to UTF-8. node: builtins only (TextDecoder).
|
|
8
|
+
|
|
9
|
+
const SNIFF_BYTES = 1024
|
|
10
|
+
const META_CHARSET = /<meta\b[^>]*?charset\s*=\s*["']?\s*([\w.:-]+)/i
|
|
11
|
+
|
|
12
|
+
/** The WHATWG encoding name for a label, or null when the runtime does not know it. */
|
|
13
|
+
export function encodingOf(label) {
|
|
14
|
+
if (typeof label !== "string" || label.trim() === "") return null
|
|
15
|
+
try {
|
|
16
|
+
return new TextDecoder(label.trim()).encoding
|
|
17
|
+
} catch {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** charset=... from a Content-Type header value, as an encoding name, or null. */
|
|
23
|
+
export function headerCharset(contentType) {
|
|
24
|
+
const match = /charset\s*=\s*["']?([\w.:-]+)/i.exec(String(contentType ?? ""))
|
|
25
|
+
return match ? encodingOf(match[1]) : null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function bomOf(raw) {
|
|
29
|
+
if (raw[0] === 0xef && raw[1] === 0xbb && raw[2] === 0xbf) return { encoding: "utf-8", skip: 3 }
|
|
30
|
+
if (raw[0] === 0xff && raw[1] === 0xfe) return { encoding: "utf-16le", skip: 2 }
|
|
31
|
+
if (raw[0] === 0xfe && raw[1] === 0xff) return { encoding: "utf-16be", skip: 2 }
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** BOM, then the declared charset, then (for markup) a <meta> charset in the first 1 KiB, then UTF-8. */
|
|
36
|
+
export function detectEncoding(raw, declared = null, markup = false) {
|
|
37
|
+
const bom = bomOf(raw)
|
|
38
|
+
if (bom) return bom.encoding
|
|
39
|
+
const given = encodingOf(declared)
|
|
40
|
+
if (given) return given
|
|
41
|
+
if (markup) {
|
|
42
|
+
const sniffed = META_CHARSET.exec(Buffer.from(raw.subarray(0, SNIFF_BYTES)).toString("latin1"))
|
|
43
|
+
const named = sniffed ? encodingOf(sniffed[1]) : null
|
|
44
|
+
// A page that is already decoded to UTF-16 cannot declare a UTF-16 charset in ASCII bytes.
|
|
45
|
+
if (named && !named.startsWith("utf-16")) return named
|
|
46
|
+
}
|
|
47
|
+
return "utf-8"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function utf8Map(text, bytes, from) {
|
|
51
|
+
let at = from
|
|
52
|
+
for (let i = 0; i < text.length; i++) {
|
|
53
|
+
bytes[i] = at
|
|
54
|
+
const code = text.charCodeAt(i)
|
|
55
|
+
if (code >= 0xd800 && code <= 0xdbff && i + 1 < text.length) {
|
|
56
|
+
bytes[++i] = at
|
|
57
|
+
at += 4
|
|
58
|
+
} else at += code < 0x80 ? 1 : code < 0x800 ? 2 : 3
|
|
59
|
+
}
|
|
60
|
+
return at
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Byte-at-a-time streaming decode: correct for any encoding, used when no shortcut applies. */
|
|
64
|
+
function streamMap(raw, encoding, from) {
|
|
65
|
+
const decoder = new TextDecoder(encoding)
|
|
66
|
+
const units = []
|
|
67
|
+
const starts = []
|
|
68
|
+
let pending = from
|
|
69
|
+
for (let i = from; i < raw.length; i++) {
|
|
70
|
+
const out = decoder.decode(raw.subarray(i, i + 1), { stream: true })
|
|
71
|
+
if (out.length === 0) continue
|
|
72
|
+
// A replacement for an earlier broken sequence can arrive with this byte's own character.
|
|
73
|
+
const own = out.length > 1 && raw[i] < 0x80 ? 1 : 0
|
|
74
|
+
for (let k = 0; k < out.length; k++) starts.push(k >= out.length - own ? i : pending)
|
|
75
|
+
units.push(out)
|
|
76
|
+
pending = i + 1
|
|
77
|
+
}
|
|
78
|
+
const tail = decoder.decode()
|
|
79
|
+
for (let k = 0; k < tail.length; k++) starts.push(pending)
|
|
80
|
+
units.push(tail)
|
|
81
|
+
return { text: units.join(""), starts }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Decode raw bytes; bytes is an Int32Array of length text.length + 1 (see the file comment). */
|
|
85
|
+
export function decodeRaw(raw, declared = null, markup = false) {
|
|
86
|
+
const buffer = Buffer.from(raw)
|
|
87
|
+
const encoding = detectEncoding(buffer, declared, markup)
|
|
88
|
+
const skip = bomOf(buffer)?.encoding === encoding ? bomOf(buffer).skip : 0
|
|
89
|
+
if (encoding === "utf-8") {
|
|
90
|
+
try {
|
|
91
|
+
const text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(buffer.subarray(skip))
|
|
92
|
+
const bytes = new Int32Array(text.length + 1)
|
|
93
|
+
bytes[text.length] = utf8Map(text, bytes, skip)
|
|
94
|
+
return { text, encoding, bytes }
|
|
95
|
+
} catch {
|
|
96
|
+
// invalid UTF-8: fall through to the streaming map, which counts each broken byte once
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (encoding !== "utf-8" && !encoding.startsWith("utf-16")) {
|
|
100
|
+
const text = new TextDecoder(encoding).decode(buffer.subarray(skip))
|
|
101
|
+
if (text.length === buffer.length - skip) {
|
|
102
|
+
const bytes = new Int32Array(text.length + 1)
|
|
103
|
+
for (let i = 0; i <= text.length; i++) bytes[i] = skip + i
|
|
104
|
+
return { text, encoding, bytes }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const { text, starts } = streamMap(buffer, encoding, skip)
|
|
108
|
+
const bytes = Int32Array.from([...starts, buffer.length])
|
|
109
|
+
return { text, encoding, bytes }
|
|
110
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Byte locators over a source view (source-view.mjs) and exact, context-bound re-anchoring.
|
|
2
|
+
// Matching always happens on the view's text (text nodes of a page, never markup); only the
|
|
3
|
+
// stored offsets are bytes of the view's artifact. value_span remains quote-relative text.
|
|
4
|
+
|
|
5
|
+
const chars = (text) => [...text]
|
|
6
|
+
|
|
7
|
+
/** Context is copied before normalization, around the value (or the whole quote for Q rows). */
|
|
8
|
+
export function quoteContext(text, start, end) {
|
|
9
|
+
return { prefix: chars(text.slice(0, start)).slice(-32).join(""), suffix: chars(text.slice(end)).slice(0, 32).join("") }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Convert a text-space locator from fact-locate.mjs into artifact byte offsets. */
|
|
13
|
+
export function rawLocated(view, found) {
|
|
14
|
+
if (found.error) return found
|
|
15
|
+
const { char_start: start, char_end: end } = found.locator
|
|
16
|
+
const from = start + (found.value_span?.[0] ?? 0)
|
|
17
|
+
const to = found.value_span ? start + found.value_span[1] : end
|
|
18
|
+
const [byteStart, byteEnd] = view.byteSpan(start, end)
|
|
19
|
+
return {
|
|
20
|
+
...found,
|
|
21
|
+
context: quoteContext(view.text, from, to),
|
|
22
|
+
locator: { ...found.locator, artifact: view.artifact, unit: "bytes", char_start: byteStart, char_end: byteEnd },
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function contextMatches(text, row, start, end) {
|
|
27
|
+
if (!row.context) return false
|
|
28
|
+
const from = row.value_span ? start + row.value_span[0] : start
|
|
29
|
+
const to = row.value_span ? start + row.value_span[1] : end
|
|
30
|
+
const { prefix, suffix } = row.context
|
|
31
|
+
return from >= prefix.length && text.slice(from - prefix.length, from) === prefix && text.slice(to, to + suffix.length) === suffix
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The row's quote in the view: unchanged when an exact occurrence sits at the pinned byte range,
|
|
36
|
+
* else exactly one occurrence whose context matches (relocated), else null. Never rewrites the row.
|
|
37
|
+
*/
|
|
38
|
+
export function reanchor(view, row) {
|
|
39
|
+
const quote = String(row.quote ?? "")
|
|
40
|
+
if (quote === "" || !view.byteSpan) return null
|
|
41
|
+
const { char_start: start, char_end: end } = row.locator
|
|
42
|
+
const hits = []
|
|
43
|
+
for (let at = view.text.indexOf(quote); at !== -1; at = view.text.indexOf(quote, at + 1)) hits.push({ at, span: view.byteSpan(at, at + quote.length) })
|
|
44
|
+
if (hits.some(({ span }) => span[0] === start && span[1] === end)) return { start, end, relocated: false }
|
|
45
|
+
const matching = hits.filter(({ at }) => contextMatches(view.text, row, at, at + quote.length))
|
|
46
|
+
return matching.length === 1 ? { start: matching[0].span[0], end: matching[0].span[1], relocated: true } : null
|
|
47
|
+
}
|
|
@@ -133,7 +133,7 @@ export async function runOutcome(argv) {
|
|
|
133
133
|
switch (sub) {
|
|
134
134
|
case "init": {
|
|
135
135
|
const promised = args.required("promised").split(",").map((s) => s.trim()).filter(Boolean)
|
|
136
|
-
const manifest = outcome.initManifest({ sessionDir: sessionDirFrom(args.flags), promised, lane: args.flags.lane ?? null, now: nowFrom(args.flags) })
|
|
136
|
+
const manifest = outcome.initManifest({ sessionDir: sessionDirFrom(args.flags), promised, lane: args.flags.lane ?? null, now: nowFrom(args.flags), startedAt: args.flags["started-at"] })
|
|
137
137
|
outcome.writeManifest(file, manifest)
|
|
138
138
|
return { json: { command: "outcome init", path: file, deliverables: manifest.deliverables }, exitCode: 0 }
|
|
139
139
|
}
|
|
@@ -28,6 +28,8 @@ export const COMMANDS = Object.freeze([
|
|
|
28
28
|
"fact verify",
|
|
29
29
|
"fact derive",
|
|
30
30
|
"source snapshot",
|
|
31
|
+
"source refresh",
|
|
32
|
+
"source probe-conversion",
|
|
31
33
|
"claims index",
|
|
32
34
|
])
|
|
33
35
|
|
|
@@ -53,7 +55,11 @@ export async function run(argv) {
|
|
|
53
55
|
return (await import("./source-commands.mjs")).runClaims(rest)
|
|
54
56
|
case "--help":
|
|
55
57
|
case "help":
|
|
56
|
-
if (rest.includes("--json"))
|
|
58
|
+
if (rest.includes("--json")) {
|
|
59
|
+
const { SNAPSHOT_USAGE } = await import("./source-commands.mjs")
|
|
60
|
+
const { REFRESH_USAGE } = await import("./source-refresh.mjs")
|
|
61
|
+
return { json: { commands: COMMANDS, usage: { "source snapshot": SNAPSHOT_USAGE, "source refresh": REFRESH_USAGE } }, exitCode: 0 }
|
|
62
|
+
}
|
|
57
63
|
return { text: `report-tools <command>\n${COMMANDS.map((name) => ` ${name}`).join("\n")}`, exitCode: 0 }
|
|
58
64
|
default:
|
|
59
65
|
throw new CliError(`usage: report-tools <${COMMANDS.join(" | ")}> (run --help)`)
|