@event4u/agent-config 14.12.0 → 14.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +118 -155
- package/CONTRIBUTING.md +38 -0
- package/CREDITS.md +135 -0
- package/NOTICE +13 -0
- package/README.md +8 -6
- package/dist/agent-src/commands/analyze/inbox.md +145 -2
- package/dist/agent-src/commands/feature/dev.md +7 -2
- package/dist/agent-src/commands/ghostwriter/write.md +5 -1
- package/dist/agent-src/commands/implement-ticket.md +1 -1
- package/dist/agent-src/commands/mission/upgrade.md +1 -1
- package/dist/agent-src/commands/orchestrate.md +2 -2
- package/dist/agent-src/commands/post-as/me.md +5 -1
- package/dist/agent-src/commands/pr/merge.md +19 -6
- package/dist/agent-src/commands/roadmap/process-full.md +19 -5
- package/dist/agent-src/commands/tdd/red.md +12 -2
- package/dist/agent-src/commands/work.md +1 -1
- package/dist/agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +40 -0
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +5 -2
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +21 -0
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +1 -0
- package/dist/agent-src/contexts/execution/subagent-response-contract.md +40 -0
- package/dist/agent-src/contexts/execution/subagent-steering.md +13 -1
- package/dist/agent-src/contexts/execution/terminal-states.md +96 -0
- package/dist/agent-src/rules/artifact-drafting-protocol.md +1 -1
- package/dist/agent-src/rules/broken-access-control.md +4 -0
- package/dist/agent-src/rules/code-comment-discipline.md +6 -0
- package/dist/agent-src/rules/code-provenance.md +4 -0
- package/dist/agent-src/rules/design-fidelity.md +1 -1
- package/dist/agent-src/rules/domain-safety-pii.md +4 -0
- package/dist/agent-src/rules/domain-safety-retention.md +4 -0
- package/dist/agent-src/rules/engineering-safety-floor.md +2 -0
- package/dist/agent-src/rules/external-code-graph-interop.md +14 -12
- package/dist/agent-src/rules/improve-before-implement.md +6 -8
- package/dist/agent-src/rules/laravel-routing.md +1 -1
- package/dist/agent-src/rules/lethal-trifecta-guard.md +4 -0
- package/dist/agent-src/rules/secret-vcs-guard.md +2 -0
- package/dist/agent-src/rules/security-sensitive-stop.md +2 -0
- package/dist/agent-src/rules/source-confidentiality.md +12 -34
- package/dist/agent-src/rules/symfony-routing.md +1 -1
- package/dist/agent-src/rules/token-efficiency.md +14 -0
- package/dist/agent-src/rules/tool-safety.md +4 -0
- package/dist/agent-src/rules/untrusted-input-defense.md +4 -0
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +252 -8
- package/dist/agent-src/scripts/guarded_baseline.ts +343 -0
- package/dist/agent-src/scripts/roadmap_set_step.ts +253 -0
- package/dist/agent-src/scripts/stub_queue.ts +82 -0
- package/dist/agent-src/scripts/stubs_due.ts +516 -0
- package/dist/agent-src/scripts/ticket_bundles.ts +84 -0
- package/dist/agent-src/scripts/update_roadmap_progress.ts +16 -12
- package/dist/agent-src/skills/brand-asset-generation/SKILL.md +17 -4
- package/dist/agent-src/skills/brand-audit/SKILL.md +33 -0
- package/dist/agent-src/skills/code-intelligence/SKILL.md +57 -0
- package/dist/agent-src/skills/database/SKILL.md +8 -0
- package/dist/agent-src/skills/dependency-upgrade/SKILL.md +27 -0
- package/dist/agent-src/skills/design-review/SKILL.md +1 -1
- package/dist/agent-src/skills/doc-coauthoring/SKILL.md +1 -1
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +17 -1
- package/dist/agent-src/skills/feature-planning/SKILL.md +9 -2
- package/dist/agent-src/skills/frontend-render-security/SKILL.md +44 -0
- package/dist/agent-src/skills/git-workflow/SKILL.md +1 -1
- package/dist/agent-src/skills/js-library-packaging/scripts/check_package_surface.ts +38 -4
- package/dist/agent-src/skills/judge-artifact-completeness/rubrics/ticket-quality-score.json +2 -2
- package/dist/agent-src/skills/laravel/SKILL.md +35 -0
- package/dist/agent-src/skills/laravel-migration/SKILL.md +57 -3
- package/dist/agent-src/skills/monorepo-workspace/SKILL.md +26 -0
- package/dist/agent-src/skills/playbook-authoring/SKILL.md +28 -1
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +1 -1
- package/dist/agent-src/skills/skill-writing/references/procedure.md +5 -5
- package/dist/agent-src/skills/sql-writing/SKILL.md +7 -1
- package/dist/agent-src/skills/standards-from-config/SKILL.md +27 -4
- package/dist/agent-src/skills/supply-chain-intake/SKILL.md +11 -4
- package/dist/agent-src/skills/symfony-workflow/SKILL.md +35 -0
- package/dist/agent-src/skills/test-case-discovery/SKILL.md +85 -0
- package/dist/agent-src/skills/test-driven-development/SKILL.md +33 -9
- package/dist/agent-src/skills/testing-anti-patterns/SKILL.md +1 -1
- package/dist/agent-src/skills/testing-anti-patterns/process-anti-patterns.md +37 -0
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +45 -2
- package/dist/agent-src/skills/upstream-contribute/SKILL.md +38 -1
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +9 -4
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +97 -3
- package/dist/agent-src/templates/scripts/check_memory.ts +258 -17
- package/dist/agent-src/templates/scripts/check_memory_proposal.ts +9 -3
- package/dist/agent-src/templates/scripts/memory_lookup.ts +86 -0
- package/dist/agent-src/templates/scripts/memory_signal.ts +44 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/implement.ts +90 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/index.ts +11 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +23 -1
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +10 -1
- package/dist/agent-src/templates/scripts/work_engine/directives/mixed/stitch.ts +5 -1
- package/dist/agent-src/templates/scripts/work_engine/stack/runner.ts +102 -14
- package/dist/cli/commands/uiAudit.js +124 -5
- package/dist/cli/registry.js +2 -0
- package/dist/cli-delegate/{chunk-HYWSRNUX.js → chunk-2DK2VJWG.js} +3 -3
- package/dist/cli-delegate/{chunk-JCW7ZLHK.js → chunk-4FS4WRXP.js} +5 -0
- package/dist/cli-delegate/{chunk-OMIVVCG2.js → chunk-A4QJ6ENT.js} +24 -0
- package/dist/cli-delegate/{chunk-JJA2QEWA.js → chunk-AKJGUQNO.js} +466 -285
- package/dist/cli-delegate/{chunk-E46KPN6K.js → chunk-BTWUYDGN.js} +424 -363
- package/dist/cli-delegate/{chunk-K4FFODTS.js → chunk-ILMUPLGW.js} +1227 -316
- package/dist/cli-delegate/{chunk-FF7WAFMR.js → chunk-KPBWFOPZ.js} +5 -1
- package/dist/cli-delegate/cmd_adr_effective.js +102 -0
- package/dist/cli-delegate/cmd_conformance.js +80 -11
- package/dist/cli-delegate/cmd_doctor.js +3 -3
- package/dist/cli-delegate/cmd_export.js +3 -2
- package/dist/cli-delegate/cmd_fleet.js +2 -2
- package/dist/cli-delegate/cmd_handoff.js +1 -1
- package/dist/cli-delegate/cmd_preflight.js +2 -2
- package/dist/cli-delegate/cmd_prune.js +3 -2
- package/dist/cli-delegate/cmd_settings_get.js +1 -1
- package/dist/cli-delegate/cmd_settings_migrate.js +3 -2
- package/dist/cli-delegate/cmd_settings_set.js +2 -2
- package/dist/cli-delegate/cmd_sync.js +3 -2
- package/dist/cli-delegate/cmd_uninstall.js +3 -2
- package/dist/cli-delegate/cmd_validate.js +3 -2
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +58 -58
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/hooks/dispatch.js +2900 -1049
- package/dist/install/claudeRuleRewrite.js +254 -0
- package/dist/install/detect.js +29 -16
- package/dist/install/detect_php_shape.js +159 -0
- package/dist/install/install.mjs +634 -428
- package/dist/mcp/awesome-mcp-servers.row.md +1 -1
- package/dist/mcp/mcp-cloudflare-catalogue.json +1 -1
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +3 -3
- package/dist/mcp/server.mjs +4895 -2627
- package/dist/server/schemas/settings.js +3 -0
- package/dist/ui/assets/index-D0jaCRPM.js +29 -0
- package/dist/ui/index.html +1 -1
- package/docs/MIGRATION.md +1 -1
- package/docs/THIRD-PARTY-NOTICES.md +25 -0
- package/docs/contracts/provider-lifecycle.md +1 -1
- package/docs/contracts/settings-classes.md +10 -4
- package/docs/guidelines/agent-infra/5w2h-analysis.md +3 -3
- package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +1 -0
- package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +58 -3
- package/docs/guidelines/agent-infra/ask-when-uncertain-demos.md +2 -2
- package/docs/guidelines/agent-infra/asking-and-brevity-examples.md +3 -3
- package/docs/guidelines/agent-infra/break-glass-usage.md +7 -7
- package/docs/guidelines/agent-infra/carve-out-predicates.md +3 -3
- package/docs/guidelines/agent-infra/comparison-matrix.md +1 -1
- package/docs/guidelines/agent-infra/critical-thinking.md +4 -4
- package/docs/guidelines/agent-infra/direct-answers-demos.md +2 -2
- package/docs/guidelines/agent-infra/domain-eval-anti-pattern.md +1 -1
- package/docs/guidelines/agent-infra/engineering-memory-data-format.md +3 -3
- package/docs/guidelines/agent-infra/existence-question-verdicts.md +80 -0
- package/docs/guidelines/agent-infra/first-principles.md +2 -2
- package/docs/guidelines/agent-infra/framework-neutrality-patterns.md +2 -2
- package/docs/guidelines/agent-infra/guarded-baseline.md +39 -0
- package/docs/guidelines/agent-infra/inversion-thinking.md +5 -5
- package/docs/guidelines/agent-infra/language-and-tone-examples.md +1 -1
- package/docs/guidelines/agent-infra/layered-settings.md +10 -10
- package/docs/guidelines/agent-infra/memory-access.md +1 -1
- package/docs/guidelines/agent-infra/mental-models.md +3 -3
- package/docs/guidelines/agent-infra/reuse-verdict-mechanics.md +71 -0
- package/docs/guidelines/agent-infra/review-routing-data-format.md +7 -7
- package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +13 -7
- package/docs/guidelines/agent-infra/role-contracts.md +2 -2
- package/docs/guidelines/agent-infra/role-mode-router.md +3 -3
- package/docs/guidelines/agent-infra/rule-type-governance.md +2 -2
- package/docs/guidelines/agent-infra/scqa-framework.md +5 -5
- package/docs/guidelines/agent-infra/self-improvement-pipeline.md +6 -6
- package/docs/guidelines/agent-infra/simplicity-and-goal-demos.md +2 -2
- package/docs/guidelines/agent-infra/six-hats.md +3 -3
- package/docs/guidelines/agent-infra/skill-quality-checklist.md +6 -6
- package/docs/guidelines/agent-infra/source-confidentiality-mechanics.md +109 -0
- package/docs/guidelines/agent-infra/systems-thinking.md +1 -1
- package/docs/guidelines/agent-infra/verify-before-complete-demos.md +2 -2
- package/docs/guidelines/augment-portability-patterns.md +6 -4
- package/docs/guidelines/code-clarity.md +18 -0
- package/docs/guidelines/component-oriented-and-oop-development.md +3 -2
- package/docs/guidelines/cross-role-handoff.md +2 -2
- package/docs/guidelines/design-fidelity-mechanics.md +1 -1
- package/docs/guidelines/docs/readme-size-and-splitting.md +3 -3
- package/docs/guidelines/php/database.md +90 -7
- package/docs/guidelines/prompt-templates.md +7 -7
- package/llms.txt +2 -2
- package/package.json +5 -2
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +252 -8
- package/src/agent-src/scripts/guarded_baseline.ts +343 -0
- package/src/agent-src/scripts/roadmap_set_step.ts +253 -0
- package/src/agent-src/scripts/stub_queue.ts +82 -0
- package/src/agent-src/scripts/stubs_due.ts +516 -0
- package/src/agent-src/scripts/ticket_bundles.ts +84 -0
- package/src/agent-src/scripts/update_roadmap_progress.ts +16 -12
- package/src/agent-src/templates/scripts/check_memory.ts +258 -17
- package/src/agent-src/templates/scripts/check_memory_proposal.ts +9 -3
- package/src/agent-src/templates/scripts/memory_lookup.ts +86 -0
- package/src/agent-src/templates/scripts/memory_signal.ts +44 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/implement.ts +90 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/index.ts +11 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +23 -1
- package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +10 -1
- package/src/agent-src/templates/scripts/work_engine/directives/mixed/stitch.ts +5 -1
- package/src/agent-src/templates/scripts/work_engine/stack/runner.ts +102 -14
- package/src/config/agent-settings.template.yml +32 -3
- package/src/config/assurance-capability-registry.json +21 -9
- package/src/config/canonical-terms.yml +119 -0
- package/src/config/capability-native-outcome-bars.json +81 -0
- package/src/config/ci-local-parity.yml +80 -0
- package/src/config/drafting-channels.yml +43 -0
- package/src/config/estate-count-budget.json +57 -36
- package/src/config/evaluator-budgets.json +14 -14
- package/src/config/gate-coverage.yml +729 -63
- package/src/config/gate-reachability-exemptions.json +21 -0
- package/src/config/gate-violation-baselines.json +42 -19
- package/src/config/harness-evolution-budget.json +25 -0
- package/src/config/lapsed-beta-baseline.json +96 -0
- package/src/config/memory-twin-verdicts.yml +129 -0
- package/src/config/metric-registry.yml +124 -0
- package/src/config/pack-size-budget.json +16 -15
- package/src/config/preamble-payload-budget.json +12 -4
- package/src/config/profiles/balanced.ini +27 -0
- package/src/config/profiles/full.ini +27 -0
- package/src/config/profiles/minimal.ini +27 -0
- package/src/config/publish-surface.json +9 -2
- package/src/config/routing-coverage-seed.json +16 -2
- package/src/config/rule-stub-ceilings.json +133 -112
- package/src/config/turnaround-budget.json +66 -0
- package/src/install/claudeRuleRewrite.ts +288 -0
- package/src/install/detect.ts +60 -17
- package/src/install/detect_php_shape.ts +191 -0
- package/src/scripts/_cli/cmd_doctor.ts +27 -112
- package/src/scripts/_dispatch.bash +23 -0
- package/src/scripts/_lib/activation_ladder.ts +255 -0
- package/src/scripts/_lib/activation_receipt_producer.ts +341 -0
- package/src/scripts/_lib/activation_states.ts +88 -0
- package/src/scripts/_lib/adherence_detectors.ts +143 -0
- package/src/scripts/_lib/adr_frontmatter.ts +26 -0
- package/src/scripts/_lib/arith_claims.ts +181 -0
- package/src/scripts/_lib/arm_ranking.ts +62 -0
- package/src/scripts/_lib/asset_delivery_ledger.ts +303 -0
- package/src/scripts/_lib/audit_field_provenance.ts +54 -0
- package/src/scripts/_lib/auto_dispatch.ts +32 -3
- package/src/scripts/_lib/bench_ab_size_claim.ts +98 -4
- package/src/scripts/_lib/benchmark_cache_fields.ts +158 -0
- package/src/scripts/_lib/candidate_pair_delta.ts +349 -0
- package/src/scripts/_lib/candidate_proposer.ts +402 -0
- package/src/scripts/_lib/candidate_record.ts +601 -0
- package/src/scripts/_lib/capture_rate.ts +319 -0
- package/src/scripts/_lib/carrier_status.ts +118 -0
- package/src/scripts/_lib/cascade_stage_enumeration.ts +92 -0
- package/src/scripts/_lib/collector_denominator.ts +771 -0
- package/src/scripts/_lib/collector_record.ts +340 -0
- package/src/scripts/_lib/collector_store.ts +664 -0
- package/src/scripts/_lib/collector_supervision.ts +827 -0
- package/src/scripts/_lib/concern_estate.ts +77 -0
- package/src/scripts/_lib/config_chain.ts +477 -0
- package/src/scripts/_lib/config_cost.ts +209 -0
- package/src/scripts/_lib/corpus_manifest.ts +726 -0
- package/src/scripts/_lib/council_settings_block.ts +6 -0
- package/src/scripts/_lib/curator_ops.ts +172 -0
- package/src/scripts/_lib/delivery_arm_experiment.ts +282 -0
- package/src/scripts/_lib/delivery_criticality.ts +126 -0
- package/src/scripts/_lib/doctor_runtime_checks.ts +70 -0
- package/src/scripts/_lib/empty_cycles.ts +88 -0
- package/src/scripts/_lib/estate_carrier_cases.ts +72 -0
- package/src/scripts/_lib/eval_publication.ts +354 -0
- package/src/scripts/_lib/evaluation_cascade.ts +452 -0
- package/src/scripts/_lib/evaluation_vector.ts +283 -0
- package/src/scripts/_lib/evaluator_promotion.ts +225 -0
- package/src/scripts/_lib/evidence_basis.ts +118 -0
- package/src/scripts/_lib/evolution_roi.ts +562 -0
- package/src/scripts/_lib/exec_evidence.ts +8 -0
- package/src/scripts/_lib/experience_card.ts +272 -0
- package/src/scripts/_lib/experience_report.ts +151 -0
- package/src/scripts/_lib/experiment_freeze.ts +112 -0
- package/src/scripts/_lib/generated_by.ts +66 -0
- package/src/scripts/_lib/harness_evolution_guards.ts +239 -0
- package/src/scripts/_lib/hook_effect_probe.ts +141 -0
- package/src/scripts/_lib/host_denominator.ts +687 -0
- package/src/scripts/_lib/host_projection_reach.ts +157 -0
- package/src/scripts/_lib/ignored_blocker.ts +148 -0
- package/src/scripts/_lib/install_reach_checks.ts +495 -0
- package/src/scripts/_lib/json_duplicate_keys.ts +150 -0
- package/src/scripts/_lib/judge_hygiene.ts +228 -0
- package/src/scripts/_lib/legacy_boundary_map.ts +228 -0
- package/src/scripts/_lib/lexical_shortlist.ts +215 -0
- package/src/scripts/_lib/llm_candidate_proposer.ts +461 -0
- package/src/scripts/_lib/llm_proposer_transport.ts +153 -0
- package/src/scripts/_lib/loop_guards.ts +299 -0
- package/src/scripts/_lib/loss_class.ts +129 -0
- package/src/scripts/_lib/machine_wake.ts +51 -0
- package/src/scripts/_lib/md_prose_lines.ts +177 -0
- package/src/scripts/_lib/minimality_tiebreak.ts +168 -0
- package/src/scripts/_lib/one_resolver_invariant.ts +449 -0
- package/src/scripts/_lib/orchestration_record.ts +253 -5
- package/src/scripts/_lib/outcome_envelope.ts +227 -0
- package/src/scripts/_lib/outcome_vocabularies.ts +125 -0
- package/src/scripts/_lib/paired_stats.ts +245 -0
- package/src/scripts/_lib/paired_verdict.ts +226 -0
- package/src/scripts/_lib/pathology_archive.ts +393 -0
- package/src/scripts/_lib/prefix_stable_surfaces.ts +123 -0
- package/src/scripts/_lib/privacy_class.ts +47 -0
- package/src/scripts/_lib/promotion_capability.ts +315 -0
- package/src/scripts/_lib/promotion_evidence.ts +414 -0
- package/src/scripts/_lib/promotion_review.ts +294 -0
- package/src/scripts/_lib/prompt_shape.ts +92 -0
- package/src/scripts/_lib/regression_neighbourhood.ts +259 -0
- package/src/scripts/_lib/release_highlights.ts +70 -1
- package/src/scripts/_lib/release_material.ts +125 -2
- package/src/scripts/_lib/repeated_failure.ts +105 -0
- package/src/scripts/_lib/repo_root.ts +111 -0
- package/src/scripts/_lib/review_skipped_record.ts +37 -0
- package/src/scripts/_lib/role_split.ts +338 -0
- package/src/scripts/_lib/routing_corpus.ts +307 -0
- package/src/scripts/_lib/routing_index_input.ts +104 -0
- package/src/scripts/_lib/rule_injection.ts +22 -1
- package/src/scripts/_lib/runtime_journal.ts +1499 -0
- package/src/scripts/_lib/runtime_wiring_checks.ts +430 -0
- package/src/scripts/_lib/semantic_noop.ts +167 -0
- package/src/scripts/_lib/skill_catalogue.ts +11 -1
- package/src/scripts/_lib/source_digest.ts +200 -0
- package/src/scripts/_lib/source_redact.ts +260 -0
- package/src/scripts/_lib/source_shape.ts +502 -0
- package/src/scripts/_lib/source_snapshot_dedup.ts +199 -0
- package/src/scripts/_lib/strip_comments.d.mts +8 -0
- package/src/scripts/_lib/strip_comments.mjs +65 -0
- package/src/scripts/_lib/test_red_state.ts +154 -0
- package/src/scripts/_lib/trigger_shift.ts +144 -0
- package/src/scripts/_lib/untrusted_content.ts +82 -7
- package/src/scripts/activation_receipt.ts +258 -0
- package/src/scripts/adoption_report.ts +1 -1
- package/src/scripts/adr/evidence_census.ts +1 -1
- package/src/scripts/adr/regenerate_index.ts +26 -2
- package/src/scripts/adr_cite_check.ts +164 -1
- package/src/scripts/ai_council/blind_review.ts +11 -1
- package/src/scripts/ai_council/clients.ts +4 -0
- package/src/scripts/ai_council/config.ts +3 -0
- package/src/scripts/ai_council/consensus.ts +28 -8
- package/src/scripts/ai_council/consensus_round.ts +226 -0
- package/src/scripts/ai_council/cross_exam.ts +128 -0
- package/src/scripts/ai_council/disagreement_signal.ts +338 -0
- package/src/scripts/ai_council/explain_route.ts +157 -0
- package/src/scripts/ai_council/information_gain.ts +293 -0
- package/src/scripts/ai_council/inline_findings.ts +340 -0
- package/src/scripts/ai_council/judge_position_bias.ts +197 -0
- package/src/scripts/ai_council/leakage_corpus.ts +385 -0
- package/src/scripts/ai_council/leakage_patterns.ts +453 -0
- package/src/scripts/ai_council/minority_retention.ts +171 -0
- package/src/scripts/ai_council/orchestrator.ts +16 -203
- package/src/scripts/ai_council/orchestrator_results.ts +23 -3
- package/src/scripts/ai_council/pricing.ts +106 -0
- package/src/scripts/ai_council/prompts.ts +74 -7
- package/src/scripts/ai_council/provider_leakage_bench.ts +327 -0
- package/src/scripts/ai_council/py_format.ts +14 -3
- package/src/scripts/ai_council/recouncil_guard.ts +293 -0
- package/src/scripts/ai_council/recouncil_savings.ts +299 -0
- package/src/scripts/ai_council/replay_route.ts +223 -0
- package/src/scripts/ai_council/response_record.ts +50 -0
- package/src/scripts/ai_council/reviewer_assignment.ts +279 -0
- package/src/scripts/ai_council/routing_training_row.ts +197 -0
- package/src/scripts/ai_council/synthesis_strategy.ts +159 -0
- package/src/scripts/ai_council/topology_bench_manifest.ts +860 -0
- package/src/scripts/ai_council/topology_vocabulary.ts +175 -0
- package/src/scripts/asset_delivery_ledger.ts +157 -0
- package/src/scripts/attest_artifact.ts +193 -0
- package/src/scripts/audit_auto_rules.ts +2 -1
- package/src/scripts/audit_command_surface.ts +1 -1
- package/src/scripts/audit_mcp_tools.ts +2 -2
- package/src/scripts/audit_skill_overlap_allowlist.json +6 -1
- package/src/scripts/audit_user_type_axis.ts +2 -1
- package/src/scripts/bench_ab_clone.ts +215 -10
- package/src/scripts/bench_ab_integrity.ts +119 -5
- package/src/scripts/bench_ab_v2_stats.ts +40 -213
- package/src/scripts/build_archive_index.ts +1 -1
- package/src/scripts/build_linear_digest.ts +1 -1
- package/src/scripts/build_proof.ts +11 -4
- package/src/scripts/build_rule_trigger_matrix.ts +1 -1
- package/src/scripts/build_source_digests.ts +157 -0
- package/src/scripts/cache_realization_report.ts +103 -0
- package/src/scripts/check_adr_frontmatter.ts +131 -10
- package/src/scripts/check_benchmark_report_fields.ts +207 -0
- package/src/scripts/check_beta_review_markers.ts +235 -6
- package/src/scripts/check_bundle_path_leakage.ts +34 -1
- package/src/scripts/check_claims.ts +576 -6
- package/src/scripts/check_composite_arming.ts +35 -0
- package/src/scripts/check_concern_admissions.ts +365 -0
- package/src/scripts/check_enforcement_coverage.ts +28 -0
- package/src/scripts/check_estate_count.ts +347 -25
- package/src/scripts/check_gate_reachability.ts +383 -0
- package/src/scripts/check_host_loadability.ts +104 -0
- package/src/scripts/check_loss_class_declared.ts +308 -0
- package/src/scripts/check_md_language.ts +15 -98
- package/src/scripts/check_memory_proposal.ts +18 -11
- package/src/scripts/check_no_currency_in_cost_surfaces.ts +225 -0
- package/src/scripts/check_no_external_sources.ts +281 -6
- package/src/scripts/check_pack_conformance_fixture.ts +11 -1
- package/src/scripts/check_pack_size.ts +59 -2
- package/src/scripts/check_preamble_payload_budget.ts +114 -3
- package/src/scripts/check_prefix_stable_mutation.ts +372 -0
- package/src/scripts/check_publish_surface.ts +10 -1
- package/src/scripts/check_references.ts +24 -1
- package/src/scripts/check_release_highlights.ts +96 -13
- package/src/scripts/check_roadmap_trackable.ts +17 -2
- package/src/scripts/check_rule_evidence_declaration.ts +316 -0
- package/src/scripts/check_rule_projection_integrity.ts +14 -4
- package/src/scripts/check_score_contract.ts +26 -3
- package/src/scripts/check_static_parity.ts +285 -0
- package/src/scripts/check_supervision_claim_atomicity.ts +498 -0
- package/src/scripts/check_suppression_hygiene.ts +15 -0
- package/src/scripts/ci_settle.ts +39 -2
- package/src/scripts/code_graph/build.ts +60 -3
- package/src/scripts/code_graph/extract.ts +44 -0
- package/src/scripts/code_graph/types.ts +24 -0
- package/src/scripts/collector_daemon.ts +714 -0
- package/src/scripts/config_cost_report.ts +302 -0
- package/src/scripts/consumer_matrix.ts +74 -1
- package/src/scripts/corpus_manifest.ts +235 -0
- package/src/scripts/cost/budget.mjs +10 -3
- package/src/scripts/cost/track.mjs +10 -3
- package/src/scripts/council_cli.ts +37 -54
- package/src/scripts/dispatch_r2_reviewer.ts +46 -5
- package/src/scripts/evolution_lab.ts +1153 -0
- package/src/scripts/external_sources_denylist.json +5 -18
- package/src/scripts/extract_audit_patterns.ts +21 -0
- package/src/scripts/fold_intake.ts +12 -1
- package/src/scripts/gen_discovery_baseline.ts +1 -1
- package/src/scripts/generate_capabilities_index.ts +12 -5
- package/src/scripts/generate_capability_matrix.ts +3 -3
- package/src/scripts/generate_command_flows.ts +2 -2
- package/src/scripts/generate_cookbook.ts +2 -2
- package/src/scripts/generate_index.ts +8 -1
- package/src/scripts/generate_knowledge_index.ts +2 -1
- package/src/scripts/generate_ownership_matrix.ts +2 -1
- package/src/scripts/generate_pack_manifests.ts +10 -2
- package/src/scripts/generate_role_experiences_catalog.ts +2 -2
- package/src/scripts/generate_settings_reference.ts +1 -1
- package/src/scripts/git_authorization_hook.ts +22 -1
- package/src/scripts/grade_target_readiness.ts +48 -5
- package/src/scripts/hook_effect_doctor.ts +261 -0
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +125 -16
- package/src/scripts/hooks/block_speaking_inbox_dir.ts +271 -0
- package/src/scripts/hooks/block_unauthorized_git.ts +18 -0
- package/src/scripts/hooks/comment_discipline_hook.ts +146 -0
- package/src/scripts/hooks/concern_registry.ts +6 -0
- package/src/scripts/hooks/dispatch_hook.ts +32 -0
- package/src/scripts/hooks/journal_record_hook.ts +345 -0
- package/src/scripts/hooks/prepush_metadata_sources.sh +110 -0
- package/src/scripts/hooks/run_continuation_hook.ts +44 -9
- package/src/scripts/hooks/shims/install.sh +61 -0
- package/src/scripts/hooks/shims/php +101 -0
- package/src/scripts/hooks/suggestion_capture_hook.ts +10 -0
- package/src/scripts/hooks/turn_end_gate_hook.ts +9 -1
- package/src/scripts/hot_context_hook.ts +16 -0
- package/src/scripts/install-hooks.sh +20 -5
- package/src/scripts/install.ts +17 -35
- package/src/scripts/inventory_frontmatter.ts +2 -1
- package/src/scripts/language_mirror_hook.ts +14 -2
- package/src/scripts/lint_adr_sweep_routing.ts +12 -0
- package/src/scripts/lint_canonical_terms.ts +604 -0
- package/src/scripts/lint_carrier_integrity.ts +820 -0
- package/src/scripts/lint_code_comments.ts +643 -0
- package/src/scripts/lint_composition_review.ts +619 -0
- package/src/scripts/lint_consolidation_lineage.ts +666 -0
- package/src/scripts/lint_eval_specs.ts +593 -0
- package/src/scripts/lint_hook_manifest.ts +19 -0
- package/src/scripts/lint_host_portability.ts +373 -0
- package/src/scripts/lint_judge_prompt_expectation.ts +27 -1
- package/src/scripts/lint_memory_twin_parity.ts +335 -0
- package/src/scripts/lint_metric_consumers.ts +355 -0
- package/src/scripts/lint_plan_risk_register.ts +39 -19
- package/src/scripts/lint_promotion_paths.ts +779 -0
- package/src/scripts/lint_skill_descriptions.ts +18 -1
- package/src/scripts/lint_skill_frontmatter_safety.ts +58 -0
- package/src/scripts/lint_skill_link_reach.ts +252 -0
- package/src/scripts/lint_skill_trigger_corpus.ts +426 -23
- package/src/scripts/lint_ticket_buildable.ts +17 -1
- package/src/scripts/llm_propose.ts +256 -0
- package/src/scripts/mcp_server/consumer_tool_catalog.json +1 -1
- package/src/scripts/mcp_server/tool_catalog_source.ts +1 -1
- package/src/scripts/measure_delivery_sets.ts +361 -0
- package/src/scripts/measure_docs_dead_links.ts +348 -0
- package/src/scripts/measure_host_capture.ts +461 -0
- package/src/scripts/measure_routing_signal.ts +307 -0
- package/src/scripts/migration_status.ts +3 -3
- package/src/scripts/model_rule_injection.ts +76 -0
- package/src/scripts/orchestration_record.ts +14 -0
- package/src/scripts/preamble_byte_census.ts +139 -10
- package/src/scripts/prepack-check.mjs +4 -1
- package/src/scripts/probe_council_retention.ts +495 -0
- package/src/scripts/probe_turnaround.ts +384 -0
- package/src/scripts/probe_unblocked_ask.ts +279 -0
- package/src/scripts/release.ts +21 -37
- package/src/scripts/release_drill.ts +143 -0
- package/src/scripts/release_env.ts +35 -0
- package/src/scripts/release_publication.ts +84 -0
- package/src/scripts/render_benchmark_md.ts +1 -1
- package/src/scripts/rule_activation_census.ts +70 -9
- package/src/scripts/rule_backlinks.ts +1 -1
- package/src/scripts/run_lifecycle_suite.ts +208 -0
- package/src/scripts/run_skill_evals.ts +40 -0
- package/src/scripts/schemas/delivery-manifest.schema.json +43 -0
- package/src/scripts/schemas/drafting-channels.schema.json +43 -0
- package/src/scripts/schemas/evals.schema.json +24 -1
- package/src/scripts/schemas/rule.schema.json +52 -1
- package/src/scripts/schemas/skill.schema.json +17 -2
- package/src/scripts/skill_overlap.ts +7 -1
- package/src/scripts/skill_tools/run_block_d_eval.ts +8 -1
- package/src/scripts/skill_tools/score_skill_relevance.ts +84 -3
- package/src/scripts/skill_tools/suggest_skill_for_task.ts +8 -1
- package/src/scripts/skill_usage_report.ts +2 -1
- package/src/scripts/stubs_due.ts +211 -0
- package/src/scripts/sweep_source_surfaces.ts +678 -0
- package/src/scripts/sync_pr_branch.ts +3 -3
- package/src/scripts/trigger_eval_grandfather.json +202 -222
- package/src/scripts/utilization_report.ts +22 -2
- package/src/server/schemas/settings.ts +5 -0
- package/src/templates/marketing-copy.yml +1 -1
- package/dist/ui/assets/index-Cxgy63kz.js +0 -26
|
@@ -1297,24 +1297,32 @@ function collectionTagName(state, event, defaultTagName) {
|
|
|
1297
1297
|
function isMappingTag(tag) {
|
|
1298
1298
|
return tag.nodeKind === "mapping";
|
|
1299
1299
|
}
|
|
1300
|
+
function chargeMergeWork(state) {
|
|
1301
|
+
state.totalMergeKeys++;
|
|
1302
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1303
|
+
}
|
|
1300
1304
|
function mergeKeys(state, frame, source, sourceTag) {
|
|
1305
|
+
chargeMergeWork(state);
|
|
1301
1306
|
for (const sourceKey of sourceTag.keys(source)) {
|
|
1302
|
-
|
|
1307
|
+
chargeMergeWork(state);
|
|
1303
1308
|
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1304
1309
|
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1305
1310
|
if (err) throwError$1(state, err);
|
|
1306
|
-
|
|
1311
|
+
frame.overridable ??= /* @__PURE__ */ new Set();
|
|
1312
|
+
frame.overridable.add(sourceKey);
|
|
1307
1313
|
}
|
|
1308
1314
|
}
|
|
1309
1315
|
function mergeSource(state, frame, source, sourceTag) {
|
|
1310
1316
|
state.position = frame.keyPosition;
|
|
1311
1317
|
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1312
|
-
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source))
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
+
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) {
|
|
1319
|
+
if (source.length > 100) throwError$1(state, "abnormal merge sequence size");
|
|
1320
|
+
for (const element of source) {
|
|
1321
|
+
const elementTag = state.nodeTags.get(element);
|
|
1322
|
+
if (!elementTag) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1323
|
+
mergeKeys(state, frame, element, elementTag);
|
|
1324
|
+
}
|
|
1325
|
+
} else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1318
1326
|
}
|
|
1319
1327
|
function addMappingValue(state, frame, key, value, tag) {
|
|
1320
1328
|
state.position = frame.keyPosition;
|
|
@@ -1657,6 +1665,24 @@ function testDocumentSeparator(state, position = state.position) {
|
|
|
1657
1665
|
}
|
|
1658
1666
|
return false;
|
|
1659
1667
|
}
|
|
1668
|
+
function skipByteOrderMark(state) {
|
|
1669
|
+
if (state.position === state.lineStart && state.input.charCodeAt(state.position) === 65279) {
|
|
1670
|
+
state.position++;
|
|
1671
|
+
state.lineStart = state.position;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
function testDocumentBoundary(state) {
|
|
1675
|
+
if (state.position !== state.lineStart) return false;
|
|
1676
|
+
if (testDocumentSeparator(state)) return true;
|
|
1677
|
+
if (state.input.charCodeAt(state.position) !== 65279) return false;
|
|
1678
|
+
const snapshot = snapshotState(state);
|
|
1679
|
+
skipByteOrderMark(state);
|
|
1680
|
+
skipSeparationSpace(state, true);
|
|
1681
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1682
|
+
const result = state.position === state.lineStart && (ch === 37 || ch === 45 && testDocumentSeparator(state));
|
|
1683
|
+
restoreState(state, snapshot);
|
|
1684
|
+
return result;
|
|
1685
|
+
}
|
|
1660
1686
|
function skipUntilLineEnd(state) {
|
|
1661
1687
|
let ch = state.input.charCodeAt(state.position);
|
|
1662
1688
|
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
@@ -1840,7 +1866,7 @@ function readBlockScalar(state, parentIndent, props) {
|
|
|
1840
1866
|
} else if (column > 0) valueEnd = linePosition + column;
|
|
1841
1867
|
break;
|
|
1842
1868
|
}
|
|
1843
|
-
if (
|
|
1869
|
+
if (testDocumentBoundary(state)) break;
|
|
1844
1870
|
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
1845
1871
|
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
1846
1872
|
if (first === 9 && column < parentIndent) {
|
|
@@ -1893,7 +1919,7 @@ function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
|
1893
1919
|
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
1894
1920
|
let multiline = false;
|
|
1895
1921
|
while (ch !== 0) {
|
|
1896
|
-
if (
|
|
1922
|
+
if (testDocumentBoundary(state)) break;
|
|
1897
1923
|
if (ch === 58) {
|
|
1898
1924
|
const following = state.input.charCodeAt(state.position + 1);
|
|
1899
1925
|
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
@@ -2250,7 +2276,7 @@ function readDocument(state) {
|
|
|
2250
2276
|
const documentEvent = state.events[documentEventIndex];
|
|
2251
2277
|
if (documentEvent?.type === EVENT_ID.DOCUMENT) documentEvent.explicitEnd = explicitEnd;
|
|
2252
2278
|
addPopEvent(state);
|
|
2253
|
-
if (!explicitEnd && state.position < state.length && !(state
|
|
2279
|
+
if (!explicitEnd && state.position < state.length && !testDocumentBoundary(state)) throwError(state, "end of the stream or a document separator is expected");
|
|
2254
2280
|
}
|
|
2255
2281
|
function parseEvents(input, options) {
|
|
2256
2282
|
const length = input.length;
|
|
@@ -2271,8 +2297,8 @@ function parseEvents(input, options) {
|
|
|
2271
2297
|
};
|
|
2272
2298
|
const nullpos = input.indexOf("\0");
|
|
2273
2299
|
if (nullpos !== -1) YAMLException.throwAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2274
|
-
if (state.input.charCodeAt(state.position) === 65279) state.position++;
|
|
2275
2300
|
while (state.position < state.length) {
|
|
2301
|
+
skipByteOrderMark(state);
|
|
2276
2302
|
skipSeparationSpace(state, true);
|
|
2277
2303
|
if (state.position >= state.length) break;
|
|
2278
2304
|
const documentStart = state.position;
|
|
@@ -2305,15 +2331,6 @@ function load(input, options) {
|
|
|
2305
2331
|
if (documents.length === 1) return documents[0];
|
|
2306
2332
|
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2307
2333
|
}
|
|
2308
|
-
var Style = class {
|
|
2309
|
-
/** Whether to print the node's tag explicitly. */
|
|
2310
|
-
tagged = false;
|
|
2311
|
-
flow = false;
|
|
2312
|
-
singleQuoted = false;
|
|
2313
|
-
doubleQuoted = false;
|
|
2314
|
-
literal = false;
|
|
2315
|
-
folded = false;
|
|
2316
|
-
};
|
|
2317
2334
|
var INVALID = /* @__PURE__ */ Symbol("INVALID");
|
|
2318
2335
|
function buildRepresentTypes(schema) {
|
|
2319
2336
|
const defaultTags = new Set([
|
|
@@ -2362,8 +2379,6 @@ function build(state, object) {
|
|
|
2362
2379
|
if (existing.anchor === void 0) existing.anchor = `ref_${state.refCounter++}`;
|
|
2363
2380
|
return {
|
|
2364
2381
|
kind: "alias",
|
|
2365
|
-
tag: "",
|
|
2366
|
-
style: new Style(),
|
|
2367
2382
|
anchor: existing.anchor
|
|
2368
2383
|
};
|
|
2369
2384
|
}
|
|
@@ -2376,24 +2391,20 @@ function build(state, object) {
|
|
|
2376
2391
|
}
|
|
2377
2392
|
const { tag, tagName, implicitTag } = matched;
|
|
2378
2393
|
const nodeTagName = implicitTag ? tagName : tagNameShort(tagName);
|
|
2379
|
-
if (tag.nodeKind === "scalar") {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
value: tag.represent(object)
|
|
2387
|
-
};
|
|
2388
|
-
}
|
|
2394
|
+
if (tag.nodeKind === "scalar") return {
|
|
2395
|
+
kind: "scalar",
|
|
2396
|
+
tag: nodeTagName,
|
|
2397
|
+
tagged: !implicitTag,
|
|
2398
|
+
style: SCALAR_STYLE.PLAIN,
|
|
2399
|
+
value: tag.represent(object)
|
|
2400
|
+
};
|
|
2389
2401
|
if (tag.nodeKind === "sequence") {
|
|
2390
2402
|
const container = tag.represent(object);
|
|
2391
|
-
const style2 = new Style();
|
|
2392
|
-
style2.tagged = !implicitTag;
|
|
2393
2403
|
const node2 = {
|
|
2394
2404
|
kind: "sequence",
|
|
2395
2405
|
tag: nodeTagName,
|
|
2396
|
-
|
|
2406
|
+
tagged: !implicitTag,
|
|
2407
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2397
2408
|
items: []
|
|
2398
2409
|
};
|
|
2399
2410
|
if (!state.noRefs) state.refs.set(object, node2);
|
|
@@ -2406,12 +2417,11 @@ function build(state, object) {
|
|
|
2406
2417
|
return node2;
|
|
2407
2418
|
}
|
|
2408
2419
|
const map = tag.represent(object);
|
|
2409
|
-
const style = new Style();
|
|
2410
|
-
style.tagged = !implicitTag;
|
|
2411
2420
|
const node = {
|
|
2412
2421
|
kind: "mapping",
|
|
2413
2422
|
tag: nodeTagName,
|
|
2414
|
-
|
|
2423
|
+
tagged: !implicitTag,
|
|
2424
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2415
2425
|
items: []
|
|
2416
2426
|
};
|
|
2417
2427
|
if (!state.noRefs) state.refs.set(object, node);
|
|
@@ -2479,82 +2489,203 @@ function visit(documents, visitor) {
|
|
|
2479
2489
|
isKey: false
|
|
2480
2490
|
})) return;
|
|
2481
2491
|
}
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
var
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
var CHAR_ASTERISK = 42;
|
|
2494
|
-
var CHAR_COMMA = 44;
|
|
2495
|
-
var CHAR_MINUS = 45;
|
|
2496
|
-
var CHAR_COLON = 58;
|
|
2497
|
-
var CHAR_EQUALS = 61;
|
|
2498
|
-
var CHAR_GREATER_THAN = 62;
|
|
2499
|
-
var CHAR_QUESTION = 63;
|
|
2500
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2501
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2502
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2503
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2504
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2505
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2506
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2507
|
-
var ESCAPE_SEQUENCES = {};
|
|
2508
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2509
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2510
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2511
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2512
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2513
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2514
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2515
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2516
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2517
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2518
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2519
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2520
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2521
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2522
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2523
|
-
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2524
|
-
indent: 2,
|
|
2525
|
-
seqNoIndent: false,
|
|
2526
|
-
seqInlineFirst: true,
|
|
2527
|
-
sortKeys: false,
|
|
2528
|
-
lineWidth: 80,
|
|
2529
|
-
flowBracketPadding: false,
|
|
2530
|
-
flowSkipCommaSpace: false,
|
|
2531
|
-
flowSkipColonSpace: false,
|
|
2532
|
-
quoteFlowKeys: false,
|
|
2533
|
-
quoteStyle: "single",
|
|
2534
|
-
forceQuotes: false,
|
|
2535
|
-
tagBeforeAnchor: false
|
|
2492
|
+
function hasBit(mask, bit) {
|
|
2493
|
+
return (mask & 1 << bit) !== 0;
|
|
2494
|
+
}
|
|
2495
|
+
var DEFAULT_SCALAR_STYLE_RULES = {
|
|
2496
|
+
applyQuoteFlowKeysOption,
|
|
2497
|
+
doubleQuoteForInvisibles,
|
|
2498
|
+
doubleQuoteWhitespaceOnly,
|
|
2499
|
+
applyForceQuotesOption,
|
|
2500
|
+
tryLongOrMultilineAsBlock,
|
|
2501
|
+
quoteInvalidPlain,
|
|
2502
|
+
fallbackToDoubleQuoted
|
|
2536
2503
|
};
|
|
2537
|
-
function
|
|
2538
|
-
|
|
2504
|
+
function _preferredQuotedStyle(layout) {
|
|
2505
|
+
if (layout.presenterOptions.quoteStyle === "single" && hasBit(layout.allowedStylesMask, SCALAR_STYLE.SINGLE_QUOTED)) return SCALAR_STYLE.SINGLE_QUOTED;
|
|
2506
|
+
return SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2507
|
+
}
|
|
2508
|
+
function applyQuoteFlowKeysOption(layout) {
|
|
2509
|
+
if (!layout.presenterOptions.quoteFlowKeys) return;
|
|
2510
|
+
if (!layout.isKey || !layout.flowOnly || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
2511
|
+
layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2512
|
+
}
|
|
2513
|
+
function doubleQuoteForInvisibles(layout) {
|
|
2514
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2515
|
+
}
|
|
2516
|
+
function doubleQuoteWhitespaceOnly(layout) {
|
|
2517
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /^\s+$/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2518
|
+
}
|
|
2519
|
+
function applyForceQuotesOption(layout) {
|
|
2520
|
+
if (!layout.presenterOptions.forceQuotes) return;
|
|
2521
|
+
if (layout.isKey || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
2522
|
+
layout.style = layout.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout);
|
|
2523
|
+
}
|
|
2524
|
+
function tryLongOrMultilineAsBlock(layout) {
|
|
2525
|
+
if (layout.style !== SCALAR_STYLE.PLAIN || layout.isKey) return;
|
|
2526
|
+
const value = layout.node.value;
|
|
2527
|
+
const multiline = value.indexOf("\n") !== -1;
|
|
2528
|
+
if (!hasBit(layout.allowedStylesMask, SCALAR_STYLE.LITERAL_BLOCK)) {
|
|
2529
|
+
if (multiline) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2530
|
+
return;
|
|
2531
|
+
}
|
|
2532
|
+
const w = layout.presenterOptions.lineWidth;
|
|
2533
|
+
if (w === -1) {
|
|
2534
|
+
if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2537
|
+
const availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
2538
|
+
let position = 0;
|
|
2539
|
+
let shouldFold = false;
|
|
2540
|
+
while (position <= value.length) {
|
|
2541
|
+
let lineEnd = value.length;
|
|
2542
|
+
const nextLineBreak = value.indexOf("\n", position);
|
|
2543
|
+
if (nextLineBreak !== -1) lineEnd = nextLineBreak;
|
|
2544
|
+
const line = value.slice(position, lineEnd);
|
|
2545
|
+
if (line.length > availableWidth && line[0] !== " " && / [^ \t]/.test(line)) shouldFold = true;
|
|
2546
|
+
if (nextLineBreak === -1) break;
|
|
2547
|
+
position = nextLineBreak + 1;
|
|
2548
|
+
}
|
|
2549
|
+
if (shouldFold) layout.style = SCALAR_STYLE.FOLDED_BLOCK;
|
|
2550
|
+
else if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2551
|
+
}
|
|
2552
|
+
function quoteInvalidPlain(layout) {
|
|
2553
|
+
if (layout.style === SCALAR_STYLE.PLAIN && !hasBit(layout.allowedStylesMask, SCALAR_STYLE.PLAIN)) layout.style = _preferredQuotedStyle(layout);
|
|
2554
|
+
}
|
|
2555
|
+
function fallbackToDoubleQuoted(layout) {
|
|
2556
|
+
if (!hasBit(layout.allowedStylesMask, layout.style)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2557
|
+
}
|
|
2558
|
+
function setBit(mask, bit) {
|
|
2559
|
+
return mask | 1 << bit;
|
|
2560
|
+
}
|
|
2561
|
+
var SRC_C_PRINTABLE = "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
|
|
2562
|
+
var SRC_B_CHAR = "[\\n\\r]";
|
|
2563
|
+
var SRC_C_BYTE_ORDER_MARK = "\\uFEFF";
|
|
2564
|
+
var SRC_S_WHITE = "[ \\t]";
|
|
2565
|
+
var SRC_NB_CHAR = `(?:(?!(?:${SRC_B_CHAR}|${SRC_C_BYTE_ORDER_MARK}))${SRC_C_PRINTABLE})`;
|
|
2566
|
+
var SRC_NS_CHAR = `(?:(?!${SRC_S_WHITE})${SRC_NB_CHAR})`;
|
|
2567
|
+
var SRC_NB_JSON = "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
|
|
2568
|
+
var SRC_C_INDICATOR = "[-?:,\\[\\]{}#&*!|>'\"%@`]";
|
|
2569
|
+
var SRC_C_FLOW_INDICATOR = "[,\\[\\]{}]";
|
|
2570
|
+
var SRC_NS_PLAIN_SAFE_FLOW_OUT = SRC_NS_CHAR;
|
|
2571
|
+
var SRC_NS_PLAIN_SAFE_FLOW_IN = `(?:(?!${SRC_C_FLOW_INDICATOR})${SRC_NS_CHAR})`;
|
|
2572
|
+
var SRC_NS_PLAIN_FIRST_FLOW_OUT = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))`;
|
|
2573
|
+
var SRC_NS_PLAIN_FIRST_FLOW_IN = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))`;
|
|
2574
|
+
var SRC_NS_PLAIN_CHAR_FLOW_OUT = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))#*`;
|
|
2575
|
+
var SRC_NS_PLAIN_CHAR_FLOW_IN = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))#*`;
|
|
2576
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_OUT})*`;
|
|
2577
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_IN})*`;
|
|
2578
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT = `${SRC_NS_PLAIN_FIRST_FLOW_OUT}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2579
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_IN = `${SRC_NS_PLAIN_FIRST_FLOW_IN}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2580
|
+
var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
|
|
2581
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
|
|
2582
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2583
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2584
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT = `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT})*`;
|
|
2585
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN = `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN})*`;
|
|
2586
|
+
var NS_PLAIN_FLOW_OUT = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT})$`, "u");
|
|
2587
|
+
var NS_PLAIN_FLOW_IN = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN})$`, "u");
|
|
2588
|
+
var NS_PLAIN_BLOCK_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY})$`, "u");
|
|
2589
|
+
var NS_PLAIN_FLOW_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY})$`, "u");
|
|
2590
|
+
var NB_SINGLE_ONE_LINE = new RegExp(`^(?:${SRC_NB_JSON})*$`, "u");
|
|
2591
|
+
var NB_SINGLE_MULTI_LINE = new RegExp(`^(?:${SRC_NB_JSON}|\\n)*$`, "u");
|
|
2592
|
+
var BLOCK_SCALAR_CONTENT = new RegExp(`^(?:${SRC_NB_CHAR}|\\n)*$`, "u");
|
|
2593
|
+
var C_FORBIDDEN_FIRST_LINE = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/;
|
|
2594
|
+
var C_FORBIDDEN_CONTENT = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/m;
|
|
2595
|
+
function canUsePlain(layout) {
|
|
2596
|
+
const str = layout.node.value;
|
|
2597
|
+
if (str !== "") {
|
|
2598
|
+
if (!(layout.isKey ? layout.flowOnly ? NS_PLAIN_FLOW_KEY : NS_PLAIN_BLOCK_KEY : layout.flowOnly ? NS_PLAIN_FLOW_IN : NS_PLAIN_FLOW_OUT).test(str)) return false;
|
|
2599
|
+
if (layout.shiftOfFirstLine === 0 && C_FORBIDDEN_FIRST_LINE.test(str)) return false;
|
|
2600
|
+
if (layout.shiftOfContent === 0) {
|
|
2601
|
+
const firstLineBreak = str.indexOf("\n");
|
|
2602
|
+
if (firstLineBreak !== -1) {
|
|
2603
|
+
const content = str.slice(firstLineBreak + 1);
|
|
2604
|
+
if (C_FORBIDDEN_CONTENT.test(content)) return false;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
const resolvedTag = layout.presenterOptions.schema.resolveImplicitScalarTag(str).tag.tagName;
|
|
2609
|
+
if (!layout.node.tagged && resolvedTag !== layout.node.tag) return false;
|
|
2610
|
+
if (!layout.node.tagged && str === "=" && resolvedTag === layout.presenterOptions.schema.defaultScalarTag.tagName) return false;
|
|
2611
|
+
return true;
|
|
2539
2612
|
}
|
|
2540
|
-
function
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2613
|
+
function canUseSingleQuoted(layout) {
|
|
2614
|
+
const str = layout.node.value;
|
|
2615
|
+
if (!(layout.isKey ? NB_SINGLE_ONE_LINE : NB_SINGLE_MULTI_LINE).test(str)) return false;
|
|
2616
|
+
if (/[ \t]\n|\n[ \t]/.test(str)) return false;
|
|
2617
|
+
if (!layout.isKey && layout.shiftOfContent === 0) {
|
|
2618
|
+
const firstLineBreak = str.indexOf("\n");
|
|
2619
|
+
if (firstLineBreak !== -1 && C_FORBIDDEN_CONTENT.test(str.slice(firstLineBreak + 1))) return false;
|
|
2620
|
+
}
|
|
2621
|
+
return true;
|
|
2549
2622
|
}
|
|
2550
|
-
function
|
|
2551
|
-
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2554
|
-
|
|
2623
|
+
function canUseBlock(layout) {
|
|
2624
|
+
if (layout.flowOnly || !BLOCK_SCALAR_CONTENT.test(layout.node.value)) return false;
|
|
2625
|
+
const contentIndent = layout.shiftOfContent - layout.shiftOfParent;
|
|
2626
|
+
if (contentIndent < 1) return false;
|
|
2627
|
+
if (contentIndent > 9 && /^\n* /.test(layout.node.value)) return false;
|
|
2628
|
+
if (layout.shiftOfContent === 0 && C_FORBIDDEN_CONTENT.test(layout.node.value)) return false;
|
|
2629
|
+
return true;
|
|
2630
|
+
}
|
|
2631
|
+
function detectAllowedStyles(layout) {
|
|
2632
|
+
let mask = setBit(0, SCALAR_STYLE.DOUBLE_QUOTED);
|
|
2633
|
+
if (canUsePlain(layout)) mask = setBit(mask, SCALAR_STYLE.PLAIN);
|
|
2634
|
+
if (canUseSingleQuoted(layout)) mask = setBit(mask, SCALAR_STYLE.SINGLE_QUOTED);
|
|
2635
|
+
if (canUseBlock(layout)) mask = setBit(setBit(mask, SCALAR_STYLE.LITERAL_BLOCK), SCALAR_STYLE.FOLDED_BLOCK);
|
|
2636
|
+
layout.allowedStylesMask = mask;
|
|
2637
|
+
}
|
|
2638
|
+
function renderScalar(layout) {
|
|
2639
|
+
switch (layout.style) {
|
|
2640
|
+
case SCALAR_STYLE.PLAIN:
|
|
2641
|
+
return renderPlain(layout);
|
|
2642
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
2643
|
+
return renderSingleQuoted(layout);
|
|
2644
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
2645
|
+
return renderLiteralBlock(layout);
|
|
2646
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
2647
|
+
return renderFoldedBlock(layout);
|
|
2648
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
2649
|
+
return renderDoubleQuoted(layout);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
function renderPlain(layout) {
|
|
2653
|
+
return encodeFlowBreaks(layout.node.value, layout.shiftOfContent);
|
|
2654
|
+
}
|
|
2655
|
+
function renderSingleQuoted(layout) {
|
|
2656
|
+
return `'${encodeFlowBreaks(layout.node.value, layout.shiftOfContent).replace(/'/g, "''")}'`;
|
|
2657
|
+
}
|
|
2658
|
+
function renderLiteralBlock(layout) {
|
|
2659
|
+
const value = layout.node.value;
|
|
2660
|
+
return "|" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(value, layout.shiftOfContent));
|
|
2661
|
+
}
|
|
2662
|
+
function renderFoldedBlock(layout) {
|
|
2663
|
+
const value = layout.node.value;
|
|
2664
|
+
const w = layout.presenterOptions.lineWidth;
|
|
2665
|
+
let availableWidth = Infinity;
|
|
2666
|
+
if (w !== -1) availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
2667
|
+
return ">" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(foldBlockScalar(value, availableWidth), layout.shiftOfContent));
|
|
2668
|
+
}
|
|
2669
|
+
function renderDoubleQuoted(layout) {
|
|
2670
|
+
return `"${escapeString(layout.node.value)}"`;
|
|
2671
|
+
}
|
|
2672
|
+
function encodeFlowBreaks(string, shiftOfContent) {
|
|
2673
|
+
let nextLF = string.indexOf("\n");
|
|
2674
|
+
if (nextLF === -1) return string;
|
|
2675
|
+
const pad = " ".repeat(shiftOfContent);
|
|
2676
|
+
let result = string.slice(0, nextLF);
|
|
2677
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
2678
|
+
lineRe.lastIndex = nextLF;
|
|
2679
|
+
let match;
|
|
2680
|
+
while (match = lineRe.exec(string)) {
|
|
2681
|
+
const breaks = match[1].length;
|
|
2682
|
+
const line = match[2];
|
|
2683
|
+
result += "\n".repeat(breaks + 1) + pad + line;
|
|
2684
|
+
}
|
|
2685
|
+
return result;
|
|
2555
2686
|
}
|
|
2556
2687
|
function indentString(string, spaces) {
|
|
2557
|
-
const
|
|
2688
|
+
const indent = " ".repeat(spaces);
|
|
2558
2689
|
let position = 0;
|
|
2559
2690
|
let result = "";
|
|
2560
2691
|
const length = string.length;
|
|
@@ -2568,191 +2699,26 @@ function indentString(string, spaces) {
|
|
|
2568
2699
|
line = string.slice(position, next + 1);
|
|
2569
2700
|
position = next + 1;
|
|
2570
2701
|
}
|
|
2571
|
-
if (line.length && line !== "\n") result +=
|
|
2702
|
+
if (line.length && line !== "\n") result += indent;
|
|
2572
2703
|
result += line;
|
|
2573
2704
|
}
|
|
2574
2705
|
return result;
|
|
2575
2706
|
}
|
|
2576
|
-
function generateNextLine(state, level) {
|
|
2577
|
-
return `
|
|
2578
|
-
${" ".repeat(state.indent * level)}`;
|
|
2579
|
-
}
|
|
2580
|
-
function scalarLayout(state, level) {
|
|
2581
|
-
const indent = state.indent * Math.max(1, level);
|
|
2582
|
-
return {
|
|
2583
|
-
indent,
|
|
2584
|
-
blockIndent: level === 0 ? state.indent + 1 : state.indent,
|
|
2585
|
-
lineWidth: state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent)
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
function isWhitespace(c) {
|
|
2589
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2590
|
-
}
|
|
2591
|
-
function startsWithDocumentSeparator(string) {
|
|
2592
|
-
const marker = string.charCodeAt(0);
|
|
2593
|
-
if (marker !== CHAR_MINUS && marker !== 46 || string.charCodeAt(1) !== marker || string.charCodeAt(2) !== marker) return false;
|
|
2594
|
-
if (string.length === 3) return true;
|
|
2595
|
-
const following = string.charCodeAt(3);
|
|
2596
|
-
return isWhitespace(following) || following === CHAR_CARRIAGE_RETURN || following === CHAR_LINE_FEED;
|
|
2597
|
-
}
|
|
2598
|
-
function isPrintable(c) {
|
|
2599
|
-
return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
|
|
2600
|
-
}
|
|
2601
|
-
function isNsCharOrWhitespace(c) {
|
|
2602
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2603
|
-
}
|
|
2604
|
-
function isPlainSafe(c, prev, inblock) {
|
|
2605
|
-
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2606
|
-
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2607
|
-
return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar && (inblock || c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET);
|
|
2608
|
-
}
|
|
2609
|
-
function isPlainSafeFirst(c) {
|
|
2610
|
-
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2611
|
-
}
|
|
2612
|
-
function isPlainSafeAtStart(string, inblock) {
|
|
2613
|
-
const first = codePointAt(string, 0);
|
|
2614
|
-
if (isPlainSafeFirst(first)) return true;
|
|
2615
|
-
if (string.length > 1 && (first === CHAR_MINUS || first === CHAR_QUESTION || first === CHAR_COLON)) {
|
|
2616
|
-
const second = codePointAt(string, 1);
|
|
2617
|
-
return !isWhitespace(second) && isPlainSafe(second, first, inblock);
|
|
2618
|
-
}
|
|
2619
|
-
return false;
|
|
2620
|
-
}
|
|
2621
|
-
function isPlainSafeLast(c) {
|
|
2622
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2623
|
-
}
|
|
2624
|
-
function codePointAt(string, pos) {
|
|
2625
|
-
const first = string.charCodeAt(pos);
|
|
2626
|
-
let second;
|
|
2627
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2628
|
-
second = string.charCodeAt(pos + 1);
|
|
2629
|
-
if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2630
|
-
}
|
|
2631
|
-
return first;
|
|
2632
|
-
}
|
|
2633
2707
|
function needIndentIndicator(string) {
|
|
2634
2708
|
return /^\n* /.test(string);
|
|
2635
2709
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
var STYLE_LITERAL = 3;
|
|
2639
|
-
var STYLE_FOLDED = 4;
|
|
2640
|
-
var STYLE_DOUBLE = 5;
|
|
2641
|
-
function chooseScalarStyle(state, string, layout, singleLineOnly, forceQuote, inblock) {
|
|
2642
|
-
const { blockIndent, lineWidth } = layout;
|
|
2643
|
-
let i;
|
|
2644
|
-
let char = 0;
|
|
2645
|
-
let prevChar = -1;
|
|
2646
|
-
let hasLineBreak = false;
|
|
2647
|
-
let hasFoldableLine = false;
|
|
2648
|
-
const shouldTrackWidth = lineWidth !== -1;
|
|
2649
|
-
let previousLineBreak = -1;
|
|
2650
|
-
let plain = !startsWithDocumentSeparator(string) && isPlainSafeAtStart(string, inblock) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2651
|
-
if (singleLineOnly || forceQuote) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2652
|
-
char = codePointAt(string, i);
|
|
2653
|
-
if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
2654
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2655
|
-
prevChar = char;
|
|
2656
|
-
}
|
|
2657
|
-
else {
|
|
2658
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2659
|
-
char = codePointAt(string, i);
|
|
2660
|
-
if (char === CHAR_LINE_FEED) {
|
|
2661
|
-
hasLineBreak = true;
|
|
2662
|
-
if (shouldTrackWidth) {
|
|
2663
|
-
hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
|
|
2664
|
-
previousLineBreak = i;
|
|
2665
|
-
}
|
|
2666
|
-
} else if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
2667
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2668
|
-
prevChar = char;
|
|
2669
|
-
}
|
|
2670
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
|
|
2671
|
-
}
|
|
2672
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2673
|
-
if (plain && !forceQuote) return STYLE_PLAIN;
|
|
2674
|
-
return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2675
|
-
}
|
|
2676
|
-
if (blockIndent > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
|
|
2677
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2678
|
-
}
|
|
2679
|
-
function renderScalarStyle(string, style, layout) {
|
|
2680
|
-
const { indent, blockIndent, lineWidth } = layout;
|
|
2681
|
-
switch (style) {
|
|
2682
|
-
case STYLE_PLAIN:
|
|
2683
|
-
return encodeFlowBreaks(string, indent);
|
|
2684
|
-
case STYLE_SINGLE:
|
|
2685
|
-
return `'${encodeFlowBreaks(string, indent).replace(/'/g, "''")}'`;
|
|
2686
|
-
case STYLE_LITERAL:
|
|
2687
|
-
return "|" + blockHeader(string, blockIndent) + dropEndingNewline(indentString(string, indent));
|
|
2688
|
-
case STYLE_FOLDED:
|
|
2689
|
-
return ">" + blockHeader(string, blockIndent) + dropEndingNewline(indentString(foldBlockScalar(string, lineWidth), indent));
|
|
2690
|
-
case STYLE_DOUBLE:
|
|
2691
|
-
return `"${escapeString(string)}"`;
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
function resolveScalarStyle(state, node, layout, iskey, inblock) {
|
|
2695
|
-
const singleLineOnly = iskey || !inblock;
|
|
2696
|
-
if (node.style.singleQuoted) return STYLE_SINGLE;
|
|
2697
|
-
if (node.style.doubleQuoted) return STYLE_DOUBLE;
|
|
2698
|
-
if (!singleLineOnly) {
|
|
2699
|
-
if (node.style.literal) return STYLE_LITERAL;
|
|
2700
|
-
if (node.style.folded) return STYLE_FOLDED;
|
|
2701
|
-
}
|
|
2702
|
-
const string = node.value;
|
|
2703
|
-
if (string.length === 0) {
|
|
2704
|
-
if (node.style.tagged || state.schema.resolveImplicitScalarTag(string).tag.tagName === node.tag) return STYLE_PLAIN;
|
|
2705
|
-
return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2706
|
-
}
|
|
2707
|
-
const style = chooseScalarStyle(state, string, layout, singleLineOnly, state.forceQuotes && !iskey, inblock);
|
|
2708
|
-
if (style === STYLE_PLAIN && !node.style.tagged && state.schema.resolveImplicitScalarTag(string).tag.tagName !== node.tag) return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2709
|
-
return style;
|
|
2710
|
-
}
|
|
2711
|
-
function blockHeader(string, indentPerLevel) {
|
|
2712
|
-
const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2710
|
+
function blockHeader(string, shiftOfParent, shiftOfContent) {
|
|
2711
|
+
const indentIndicator = needIndentIndicator(string) ? String(shiftOfContent - shiftOfParent) : "";
|
|
2713
2712
|
const clip = string[string.length - 1] === "\n";
|
|
2714
2713
|
return `${indentIndicator}${clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-"}
|
|
2715
2714
|
`;
|
|
2716
2715
|
}
|
|
2717
|
-
function encodeFlowBreaks(string, indent) {
|
|
2718
|
-
let nextLF = string.indexOf("\n");
|
|
2719
|
-
if (nextLF === -1) return string;
|
|
2720
|
-
const pad = " ".repeat(indent);
|
|
2721
|
-
let result = string.slice(0, nextLF);
|
|
2722
|
-
const lineRe = /(\n+)([^\n]*)/g;
|
|
2723
|
-
lineRe.lastIndex = nextLF;
|
|
2724
|
-
let match;
|
|
2725
|
-
while (match = lineRe.exec(string)) {
|
|
2726
|
-
const breaks = match[1].length;
|
|
2727
|
-
const line = match[2];
|
|
2728
|
-
result += "\n".repeat(breaks + 1) + pad + line;
|
|
2729
|
-
}
|
|
2730
|
-
return result;
|
|
2731
|
-
}
|
|
2732
2716
|
function dropEndingNewline(string) {
|
|
2733
2717
|
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2734
2718
|
}
|
|
2735
2719
|
function isMoreIndented(char) {
|
|
2736
2720
|
return char === " " || char === " ";
|
|
2737
2721
|
}
|
|
2738
|
-
function foldBlockScalar(string, width) {
|
|
2739
|
-
const lineRe = /(\n+)([^\n]*)/g;
|
|
2740
|
-
let nextLF = string.indexOf("\n");
|
|
2741
|
-
if (nextLF === -1) nextLF = string.length;
|
|
2742
|
-
lineRe.lastIndex = nextLF;
|
|
2743
|
-
let result = foldLine(string.slice(0, nextLF), width);
|
|
2744
|
-
let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
|
|
2745
|
-
let moreIndented;
|
|
2746
|
-
let match;
|
|
2747
|
-
while (match = lineRe.exec(string)) {
|
|
2748
|
-
const prefix = match[1];
|
|
2749
|
-
const line = match[2];
|
|
2750
|
-
moreIndented = line !== "" && isMoreIndented(line[0]);
|
|
2751
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2752
|
-
prevMoreIndented = moreIndented;
|
|
2753
|
-
}
|
|
2754
|
-
return result;
|
|
2755
|
-
}
|
|
2756
2722
|
function foldLine(line, width) {
|
|
2757
2723
|
if (line === "" || isMoreIndented(line[0])) return line;
|
|
2758
2724
|
const breakRe = / [^ \t]/g;
|
|
@@ -2778,43 +2744,133 @@ ${line.slice(curr + 1)}`;
|
|
|
2778
2744
|
else result += line.slice(start);
|
|
2779
2745
|
return result.slice(1);
|
|
2780
2746
|
}
|
|
2781
|
-
function
|
|
2782
|
-
|
|
2783
|
-
let
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
result += encodeNonPrintable(char);
|
|
2747
|
+
function foldBlockScalar(string, width) {
|
|
2748
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
2749
|
+
let nextLF = string.indexOf("\n");
|
|
2750
|
+
if (nextLF === -1) nextLF = string.length;
|
|
2751
|
+
lineRe.lastIndex = nextLF;
|
|
2752
|
+
let result = foldLine(string.slice(0, nextLF), width);
|
|
2753
|
+
let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
|
|
2754
|
+
let moreIndented;
|
|
2755
|
+
let match;
|
|
2756
|
+
while (match = lineRe.exec(string)) {
|
|
2757
|
+
const prefix = match[1];
|
|
2758
|
+
const line = match[2];
|
|
2759
|
+
moreIndented = line !== "" && isMoreIndented(line[0]);
|
|
2760
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2761
|
+
prevMoreIndented = moreIndented;
|
|
2797
2762
|
}
|
|
2798
2763
|
return result;
|
|
2799
2764
|
}
|
|
2765
|
+
var CHARACTERS_TO_ESCAPE = /["\\\x00-\x1F\x7F-\xA0\u2028\u2029\uD800-\uDFFF\uFEFF\uFFFE\uFFFF]/gu;
|
|
2766
|
+
function escapeCharacter(character) {
|
|
2767
|
+
switch (character) {
|
|
2768
|
+
case "\0":
|
|
2769
|
+
return "\\0";
|
|
2770
|
+
case "\x07":
|
|
2771
|
+
return "\\a";
|
|
2772
|
+
case "\b":
|
|
2773
|
+
return "\\b";
|
|
2774
|
+
case " ":
|
|
2775
|
+
return "\\t";
|
|
2776
|
+
case "\n":
|
|
2777
|
+
return "\\n";
|
|
2778
|
+
case "\v":
|
|
2779
|
+
return "\\v";
|
|
2780
|
+
case "\f":
|
|
2781
|
+
return "\\f";
|
|
2782
|
+
case "\r":
|
|
2783
|
+
return "\\r";
|
|
2784
|
+
case "\x1B":
|
|
2785
|
+
return "\\e";
|
|
2786
|
+
case '"':
|
|
2787
|
+
return '\\"';
|
|
2788
|
+
case "\\":
|
|
2789
|
+
return "\\\\";
|
|
2790
|
+
case "\x85":
|
|
2791
|
+
return "\\N";
|
|
2792
|
+
case "\xA0":
|
|
2793
|
+
return "\\_";
|
|
2794
|
+
case "\u2028":
|
|
2795
|
+
return "\\L";
|
|
2796
|
+
case "\u2029":
|
|
2797
|
+
return "\\P";
|
|
2798
|
+
}
|
|
2799
|
+
const code = character.charCodeAt(0);
|
|
2800
|
+
const hex = code.toString(16).toUpperCase();
|
|
2801
|
+
if (code <= 255) return `\\x${"0".repeat(2 - hex.length)}${hex}`;
|
|
2802
|
+
return `\\u${"0".repeat(4 - hex.length)}${hex}`;
|
|
2803
|
+
}
|
|
2804
|
+
function escapeString(string) {
|
|
2805
|
+
return string.replace(CHARACTERS_TO_ESCAPE, escapeCharacter);
|
|
2806
|
+
}
|
|
2807
|
+
var CHAR_LINE_FEED = 10;
|
|
2808
|
+
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2809
|
+
indent: 2,
|
|
2810
|
+
seqNoIndent: false,
|
|
2811
|
+
seqInlineFirst: true,
|
|
2812
|
+
lineWidth: 80,
|
|
2813
|
+
flowBracketPadding: false,
|
|
2814
|
+
flowSkipCommaSpace: false,
|
|
2815
|
+
flowSkipColonSpace: false,
|
|
2816
|
+
quoteFlowKeys: false,
|
|
2817
|
+
quoteStyle: "single",
|
|
2818
|
+
forceQuotes: false,
|
|
2819
|
+
scalarStyleRules: Object.keys(DEFAULT_SCALAR_STYLE_RULES).map((name) => Reflect.get(DEFAULT_SCALAR_STYLE_RULES, name)),
|
|
2820
|
+
tagBeforeAnchor: false
|
|
2821
|
+
};
|
|
2822
|
+
function nodeTagShort(node) {
|
|
2823
|
+
return node.tagged ? node.tag : tagNameShort(node.tag);
|
|
2824
|
+
}
|
|
2825
|
+
function createPresenterState(options) {
|
|
2826
|
+
const opts = {
|
|
2827
|
+
...DEFAULT_PRESENTER_OPTIONS,
|
|
2828
|
+
...options
|
|
2829
|
+
};
|
|
2830
|
+
if (opts.flowSkipColonSpace) opts.quoteFlowKeys = true;
|
|
2831
|
+
return {
|
|
2832
|
+
...opts,
|
|
2833
|
+
defaultScalarTagName: opts.schema.defaultScalarTag.tagName,
|
|
2834
|
+
openEnded: false
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
function generateNextLine(state, level) {
|
|
2838
|
+
return `
|
|
2839
|
+
${" ".repeat(state.indent * level)}`;
|
|
2840
|
+
}
|
|
2841
|
+
function scalarLayout(state, node, parent, level, isKey, flowOnly) {
|
|
2842
|
+
return {
|
|
2843
|
+
node,
|
|
2844
|
+
parent,
|
|
2845
|
+
level,
|
|
2846
|
+
isKey,
|
|
2847
|
+
flowOnly,
|
|
2848
|
+
shiftOfParent: level === 0 ? -1 : state.indent * (level - 1),
|
|
2849
|
+
shiftOfContent: state.indent * Math.max(1, level),
|
|
2850
|
+
shiftOfFirstLine: level === 0 ? 0 : state.indent * level,
|
|
2851
|
+
presenterOptions: state,
|
|
2852
|
+
allowedStylesMask: 0,
|
|
2853
|
+
style: node.style
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2800
2856
|
function writeFlowSequence(state, level, node) {
|
|
2801
2857
|
let result = "";
|
|
2802
2858
|
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2803
|
-
const item = writeNode(state, level, node.items[index], {});
|
|
2804
|
-
if (
|
|
2859
|
+
const item = writeNode(state, level, node.items[index], node, {}).text;
|
|
2860
|
+
if (index > 0) result += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
2805
2861
|
result += item;
|
|
2806
2862
|
}
|
|
2807
|
-
const pad = state.flowBracketPadding &&
|
|
2863
|
+
const pad = state.flowBracketPadding && node.items.length > 0 ? " " : "";
|
|
2808
2864
|
return `[${pad}${result}${pad}]`;
|
|
2809
2865
|
}
|
|
2810
2866
|
function writeBlockSequence(state, level, node, compact) {
|
|
2811
2867
|
let result = "";
|
|
2812
2868
|
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2813
|
-
const item = writeNode(state, level + 1, node.items[index], {
|
|
2869
|
+
const item = writeNode(state, level + 1, node.items[index], node, {
|
|
2814
2870
|
block: true,
|
|
2815
2871
|
compact: state.seqInlineFirst,
|
|
2816
2872
|
isblockseq: true
|
|
2817
|
-
});
|
|
2873
|
+
}).text;
|
|
2818
2874
|
if (!compact || result !== "") result += generateNextLine(state, level);
|
|
2819
2875
|
if (item === "" || CHAR_LINE_FEED === item.charCodeAt(0)) result += "-";
|
|
2820
2876
|
else result += "- ";
|
|
@@ -2824,70 +2880,51 @@ function writeBlockSequence(state, level, node, compact) {
|
|
|
2824
2880
|
}
|
|
2825
2881
|
function writeFlowMapping(state, level, node) {
|
|
2826
2882
|
let result = "";
|
|
2827
|
-
const
|
|
2828
|
-
for (const { key, value } of items) {
|
|
2883
|
+
for (const { key, value } of node.items) {
|
|
2829
2884
|
let pairBuffer = "";
|
|
2830
2885
|
if (result !== "") pairBuffer += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
2831
|
-
const
|
|
2832
|
-
const
|
|
2833
|
-
|
|
2834
|
-
else if (state.quoteFlowKeys) pairBuffer += '"';
|
|
2835
|
-
const valueText = writeNode(state, level, value, {});
|
|
2886
|
+
const keyRender = writeNode(state, level, key, node, { iskey: true });
|
|
2887
|
+
const keyText = keyRender.text;
|
|
2888
|
+
const valueText = writeNode(state, level, value, node, {}).text;
|
|
2836
2889
|
const sep = state.flowSkipColonSpace || valueText === "" ? "" : " ";
|
|
2837
|
-
|
|
2890
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
2891
|
+
const keyColonSep = key.kind === "alias" || keyIsBareProps ? " " : "";
|
|
2892
|
+
pairBuffer += `${keyText}${keyColonSep}:${sep}${valueText}`;
|
|
2838
2893
|
result += pairBuffer;
|
|
2839
2894
|
}
|
|
2840
2895
|
const pad = state.flowBracketPadding && result !== "" ? " " : "";
|
|
2841
2896
|
return `{${pad}${result}${pad}}`;
|
|
2842
2897
|
}
|
|
2843
|
-
function sortKeyValue(key) {
|
|
2844
|
-
return key.kind === "scalar" ? key.value : key;
|
|
2845
|
-
}
|
|
2846
|
-
function sortMappingItems(state, items) {
|
|
2847
|
-
if (!state.sortKeys) return items;
|
|
2848
|
-
const copy = items.slice();
|
|
2849
|
-
if (state.sortKeys === true) copy.sort((a, b) => {
|
|
2850
|
-
const x = sortKeyValue(a.key);
|
|
2851
|
-
const y = sortKeyValue(b.key);
|
|
2852
|
-
if (x < y) return -1;
|
|
2853
|
-
if (x > y) return 1;
|
|
2854
|
-
return 0;
|
|
2855
|
-
});
|
|
2856
|
-
else {
|
|
2857
|
-
const fn = state.sortKeys;
|
|
2858
|
-
copy.sort((a, b) => fn(sortKeyValue(a.key), sortKeyValue(b.key)));
|
|
2859
|
-
}
|
|
2860
|
-
return copy;
|
|
2861
|
-
}
|
|
2862
2898
|
function writeBlockMapping(state, level, node, compact) {
|
|
2863
2899
|
let result = "";
|
|
2864
|
-
|
|
2865
|
-
for (let index = 0, length = items.length; index < length; index += 1) {
|
|
2900
|
+
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2866
2901
|
let pairBuffer = "";
|
|
2867
2902
|
if (!compact || result !== "") pairBuffer += generateNextLine(state, level);
|
|
2868
|
-
const { key, value } = items[index];
|
|
2869
|
-
const keyIsBlock = (key.kind === "mapping" || key.kind === "sequence") &&
|
|
2870
|
-
const
|
|
2903
|
+
const { key, value } = node.items[index];
|
|
2904
|
+
const keyIsBlock = (key.kind === "mapping" || key.kind === "sequence") && key.style === COLLECTION_STYLE.BLOCK && key.items.length !== 0 || key.kind === "scalar" && (key.style === SCALAR_STYLE.LITERAL_BLOCK || key.style === SCALAR_STYLE.FOLDED_BLOCK);
|
|
2905
|
+
const keyRender = keyIsBlock ? writeNode(state, level + 1, key, node, {
|
|
2871
2906
|
block: true,
|
|
2872
2907
|
compact: true,
|
|
2873
2908
|
isblockseq: !cannotBeCompact(state, key, level + 1)
|
|
2874
|
-
}) : writeNode(state, level + 1, key, {
|
|
2909
|
+
}) : writeNode(state, level + 1, key, node, {
|
|
2875
2910
|
block: true,
|
|
2876
2911
|
compact: true,
|
|
2877
2912
|
iskey: true
|
|
2878
2913
|
});
|
|
2914
|
+
const keyText = keyRender.text;
|
|
2879
2915
|
const keyHasLineBreak = key.kind === "scalar" && key.value.indexOf("\n") !== -1;
|
|
2880
|
-
const
|
|
2916
|
+
const keyIsTooLong = keyText.length > 1024 && /^[\s\S]{1025}/u.test(keyText);
|
|
2917
|
+
const explicitPair = keyIsBlock || keyHasLineBreak || keyIsTooLong;
|
|
2881
2918
|
if (explicitPair) if (keyText && CHAR_LINE_FEED === keyText.charCodeAt(0)) pairBuffer += "?";
|
|
2882
2919
|
else pairBuffer += "? ";
|
|
2883
2920
|
pairBuffer += keyText;
|
|
2884
2921
|
if (explicitPair) pairBuffer += generateNextLine(state, level);
|
|
2885
|
-
const valueText = writeNode(state, level + 1, value, {
|
|
2922
|
+
const valueText = writeNode(state, level + 1, value, node, {
|
|
2886
2923
|
block: true,
|
|
2887
2924
|
compact: explicitPair,
|
|
2888
2925
|
isblockseq: explicitPair && !cannotBeCompact(state, value, level + 1)
|
|
2889
|
-
});
|
|
2890
|
-
const keyIsBareProps = key.kind === "scalar" &&
|
|
2926
|
+
}).text;
|
|
2927
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
2891
2928
|
const keyColonSep = !explicitPair && (key.kind === "alias" || keyIsBareProps) ? " " : "";
|
|
2892
2929
|
if (valueText === "" || CHAR_LINE_FEED === valueText.charCodeAt(0)) pairBuffer += `${keyColonSep}:`;
|
|
2893
2930
|
else pairBuffer += `${keyColonSep}: `;
|
|
@@ -2897,29 +2934,41 @@ function writeBlockMapping(state, level, node, compact) {
|
|
|
2897
2934
|
return result;
|
|
2898
2935
|
}
|
|
2899
2936
|
function cannotBeCompact(state, node, level) {
|
|
2900
|
-
|
|
2937
|
+
if (node.kind === "alias") return true;
|
|
2938
|
+
return node.tagged || node.anchor !== void 0 || state.indent < 2 && level > 0;
|
|
2901
2939
|
}
|
|
2902
|
-
function writeNode(state, level, node, ctx) {
|
|
2903
|
-
if (node.kind === "alias")
|
|
2940
|
+
function writeNode(state, level, node, parent, ctx) {
|
|
2941
|
+
if (node.kind === "alias") {
|
|
2942
|
+
state.openEnded = false;
|
|
2943
|
+
return {
|
|
2944
|
+
text: `*${node.anchor}`,
|
|
2945
|
+
noBody: false
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2904
2948
|
const { block = false, iskey = false, isblockseq = false } = ctx;
|
|
2905
2949
|
let compact = ctx.compact ?? false;
|
|
2906
2950
|
const hasAnchor = node.anchor !== void 0;
|
|
2907
2951
|
if (cannotBeCompact(state, node, level)) compact = false;
|
|
2908
2952
|
let body;
|
|
2909
|
-
let shouldPrintTag = node.
|
|
2910
|
-
const useBlockCollection = block && (node.kind === "mapping" || node.kind === "sequence") &&
|
|
2953
|
+
let shouldPrintTag = node.tagged;
|
|
2954
|
+
const useBlockCollection = block && (node.kind === "mapping" || node.kind === "sequence") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0;
|
|
2911
2955
|
if (node.kind === "mapping") if (useBlockCollection) body = writeBlockMapping(state, level, node, compact);
|
|
2912
2956
|
else body = writeFlowMapping(state, level, node);
|
|
2913
2957
|
else if (node.kind === "sequence") if (useBlockCollection) if (state.seqNoIndent && !isblockseq && level > 0) body = writeBlockSequence(state, level - 1, node, compact);
|
|
2914
2958
|
else body = writeBlockSequence(state, level, node, compact);
|
|
2915
2959
|
else body = writeFlowSequence(state, level, node);
|
|
2916
2960
|
else {
|
|
2917
|
-
const layout = scalarLayout(state, level);
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2961
|
+
const layout = scalarLayout(state, node, parent, level, iskey, !block);
|
|
2962
|
+
detectAllowedStyles(layout);
|
|
2963
|
+
for (const rule of state.scalarStyleRules) rule(layout);
|
|
2964
|
+
body = renderScalar(layout);
|
|
2965
|
+
state.openEnded = (layout.style === SCALAR_STYLE.LITERAL_BLOCK || layout.style === SCALAR_STYLE.FOLDED_BLOCK) && (node.value === "\n" || node.value.endsWith("\n\n"));
|
|
2966
|
+
shouldPrintTag = node.tagged || body === "" && layout.flowOnly && parent?.kind === "sequence" && !hasAnchor || layout.style !== SCALAR_STYLE.PLAIN && node.tag !== state.defaultScalarTagName;
|
|
2967
|
+
}
|
|
2968
|
+
if ((node.kind === "mapping" || node.kind === "sequence") && !useBlockCollection) state.openEnded = false;
|
|
2922
2969
|
if (useBlockCollection && compact && level > 0 && state.indent > 2) body = `${" ".repeat(state.indent - 2)}${body}`;
|
|
2970
|
+
const noBody = body === "";
|
|
2971
|
+
let text = body;
|
|
2923
2972
|
if (shouldPrintTag || hasAnchor) {
|
|
2924
2973
|
const props = [];
|
|
2925
2974
|
const tag = shouldPrintTag ? nodeTagShort(node) : null;
|
|
@@ -2932,19 +2981,15 @@ function writeNode(state, level, node, ctx) {
|
|
|
2932
2981
|
if (tag !== null) props.push(tag);
|
|
2933
2982
|
}
|
|
2934
2983
|
const sep = body === "" || body.charCodeAt(0) === CHAR_LINE_FEED ? "" : " ";
|
|
2935
|
-
|
|
2984
|
+
text = `${props.join(" ")}${sep}${body}`;
|
|
2936
2985
|
}
|
|
2937
|
-
return
|
|
2986
|
+
return {
|
|
2987
|
+
text,
|
|
2988
|
+
noBody
|
|
2989
|
+
};
|
|
2938
2990
|
}
|
|
2939
2991
|
function rootStartsOwnLine(node) {
|
|
2940
|
-
return (node.kind === "sequence" || node.kind === "mapping") &&
|
|
2941
|
-
}
|
|
2942
|
-
function isOpenEnded(node) {
|
|
2943
|
-
let leaf = node;
|
|
2944
|
-
while ((leaf.kind === "sequence" || leaf.kind === "mapping") && !leaf.style.flow && leaf.items.length !== 0) leaf = leaf.kind === "sequence" ? leaf.items[leaf.items.length - 1] : leaf.items[leaf.items.length - 1].value;
|
|
2945
|
-
if (leaf.kind !== "scalar" || !(leaf.style.literal || leaf.style.folded)) return false;
|
|
2946
|
-
const { value } = leaf;
|
|
2947
|
-
return value.endsWith("\n\n") || value === "\n";
|
|
2992
|
+
return (node.kind === "sequence" || node.kind === "mapping") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0 && !node.tagged && node.anchor === void 0;
|
|
2948
2993
|
}
|
|
2949
2994
|
function writeDocumentDirectives(doc) {
|
|
2950
2995
|
let result = "";
|
|
@@ -2966,6 +3011,7 @@ function present(documents, options) {
|
|
|
2966
3011
|
let previousEnded = false;
|
|
2967
3012
|
for (let index = 0; index < documents.length; index += 1) {
|
|
2968
3013
|
const doc = documents[index];
|
|
3014
|
+
state.openEnded = false;
|
|
2969
3015
|
const directives = writeDocumentDirectives(doc);
|
|
2970
3016
|
const hasDirectives = directives !== "";
|
|
2971
3017
|
const marker = doc.explicitStart || hasDirectives || index > 0 && !previousEnded;
|
|
@@ -2973,18 +3019,18 @@ function present(documents, options) {
|
|
|
2973
3019
|
if (doc.contents === null) {
|
|
2974
3020
|
if (marker) result += "---\n";
|
|
2975
3021
|
} else if (marker) {
|
|
2976
|
-
const body = writeNode(state, 0, doc.contents, {
|
|
3022
|
+
const body = writeNode(state, 0, doc.contents, null, {
|
|
2977
3023
|
block: true,
|
|
2978
3024
|
compact: true
|
|
2979
|
-
});
|
|
3025
|
+
}).text;
|
|
2980
3026
|
const sep = body === "" ? "" : hasDirectives || rootStartsOwnLine(doc.contents) ? "\n" : " ";
|
|
2981
3027
|
result += `---${sep}${body}
|
|
2982
3028
|
`;
|
|
2983
|
-
} else result += writeNode(state, 0, doc.contents, {
|
|
3029
|
+
} else result += writeNode(state, 0, doc.contents, null, {
|
|
2984
3030
|
block: true,
|
|
2985
3031
|
compact: true
|
|
2986
|
-
}) + "\n";
|
|
2987
|
-
previousEnded = doc.explicitEnd ||
|
|
3032
|
+
}).text + "\n";
|
|
3033
|
+
previousEnded = doc.explicitEnd || state.openEnded;
|
|
2988
3034
|
if (previousEnded) result += "...\n";
|
|
2989
3035
|
}
|
|
2990
3036
|
return result;
|
|
@@ -2995,9 +3041,17 @@ var DEFAULT_DUMP_OPTIONS = {
|
|
|
2995
3041
|
skipInvalid: false,
|
|
2996
3042
|
noRefs: false,
|
|
2997
3043
|
flowLevel: -1,
|
|
3044
|
+
sortKeys: false,
|
|
2998
3045
|
transform: () => {
|
|
2999
3046
|
}
|
|
3000
3047
|
};
|
|
3048
|
+
function defaultCompareFn(a, b) {
|
|
3049
|
+
const x = String(a);
|
|
3050
|
+
const y = String(b);
|
|
3051
|
+
if (x < y) return -1;
|
|
3052
|
+
if (x > y) return 1;
|
|
3053
|
+
return 0;
|
|
3054
|
+
}
|
|
3001
3055
|
function dump(input, options = {}) {
|
|
3002
3056
|
const opts = {
|
|
3003
3057
|
...DEFAULT_DUMP_OPTIONS,
|
|
@@ -3009,9 +3063,16 @@ function dump(input, options = {}) {
|
|
|
3009
3063
|
});
|
|
3010
3064
|
if (opts.flowLevel >= 0) visit(documents, (node, ctx) => {
|
|
3011
3065
|
if (ctx.depth < opts.flowLevel) return;
|
|
3012
|
-
node.
|
|
3066
|
+
if (node.kind === "sequence" || node.kind === "mapping") node.style = COLLECTION_STYLE.FLOW;
|
|
3013
3067
|
return VISIT_SKIP;
|
|
3014
3068
|
});
|
|
3069
|
+
if (opts.sortKeys) {
|
|
3070
|
+
const compareFn = opts.sortKeys === true ? defaultCompareFn : opts.sortKeys;
|
|
3071
|
+
visit(documents, (node) => {
|
|
3072
|
+
if (node.kind !== "mapping") return;
|
|
3073
|
+
node.items.sort((a, b) => compareFn(a.key.kind === "scalar" ? a.key.value : "", b.key.kind === "scalar" ? b.key.value : ""));
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3015
3076
|
opts.transform(documents);
|
|
3016
3077
|
return present(documents, {
|
|
3017
3078
|
...pick(opts, Object.keys(DEFAULT_PRESENTER_OPTIONS)),
|
|
@@ -3042,5 +3103,5 @@ export {
|
|
|
3042
3103
|
/*! Bundled license information:
|
|
3043
3104
|
|
|
3044
3105
|
js-yaml/dist/js-yaml.mjs:
|
|
3045
|
-
(*! js-yaml 5.
|
|
3106
|
+
(*! js-yaml 5.4.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
3046
3107
|
*/
|