hoi4-agent-tools 0.2.0 → 1.1.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/CHANGELOG.md +21 -118
- package/README.md +38 -124
- package/SECURITY.md +5 -7
- package/dist/bin/http.js +0 -1
- package/dist/bin/setup.js +141 -92
- package/dist/bin/stdio.js +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.js +0 -1
- package/dist/hoi4_agent_tools/core/canonical.js +0 -1
- package/dist/hoi4_agent_tools/core/configuration.js +28 -28
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.js +0 -1
- package/dist/hoi4_agent_tools/core/diff.js +0 -1
- package/dist/hoi4_agent_tools/core/engine.js +6 -21
- package/dist/hoi4_agent_tools/core/image-diff.js +0 -1
- package/dist/hoi4_agent_tools/core/index.js +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.js +0 -1
- package/dist/hoi4_agent_tools/core/result.js +0 -1
- package/dist/hoi4_agent_tools/core/scanner.js +0 -1
- package/dist/hoi4_agent_tools/core/server-state.js +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.js +0 -1
- package/dist/hoi4_agent_tools/core/source/index.js +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.js +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.js +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.js +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.js +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.js +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.js +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.js +0 -1
- package/dist/hoi4_agent_tools/core/transactions.js +2 -30
- package/dist/hoi4_agent_tools/core/workspace.js +112 -396
- package/dist/hoi4_agent_tools/focus/compact.js +432 -0
- package/dist/hoi4_agent_tools/focus/compiler.js +1 -8
- package/dist/hoi4_agent_tools/focus/continuous-render.js +0 -1
- package/dist/hoi4_agent_tools/focus/drift.js +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.js +203 -17
- package/dist/hoi4_agent_tools/focus/importer.js +0 -1
- package/dist/hoi4_agent_tools/focus/index.js +1 -1
- package/dist/hoi4_agent_tools/focus/layout.js +1256 -93
- package/dist/hoi4_agent_tools/focus/limits.js +1 -2
- package/dist/hoi4_agent_tools/focus/lint.js +11 -4
- package/dist/hoi4_agent_tools/focus/model.js +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js +0 -1
- package/dist/hoi4_agent_tools/focus/planning.js +6 -2
- package/dist/hoi4_agent_tools/focus/presentation.js +0 -1
- package/dist/hoi4_agent_tools/focus/render.js +14 -10
- package/dist/hoi4_agent_tools/focus/service.js +7 -8
- package/dist/hoi4_agent_tools/focus/source-update.js +1 -2
- package/dist/hoi4_agent_tools/gui/animation-manifest.js +0 -1
- package/dist/hoi4_agent_tools/gui/assets.js +0 -1
- package/dist/hoi4_agent_tools/gui/dds.js +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.js +1 -2
- package/dist/hoi4_agent_tools/gui/index.js +0 -1
- package/dist/hoi4_agent_tools/gui/layout.js +0 -1
- package/dist/hoi4_agent_tools/gui/limits.js +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.js +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.js +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.js +1 -2
- package/dist/hoi4_agent_tools/gui/studio.js +247 -104
- package/dist/hoi4_agent_tools/gui/tga.js +0 -1
- package/dist/hoi4_agent_tools/gui/types.js +0 -1
- package/dist/hoi4_agent_tools/gui/validators.js +0 -1
- package/dist/hoi4_agent_tools/map/bmp.js +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js +0 -1
- package/dist/hoi4_agent_tools/map/index.js +0 -1
- package/dist/hoi4_agent_tools/map/limits.js +2 -1
- package/dist/hoi4_agent_tools/map/model.js +0 -1
- package/dist/hoi4_agent_tools/map/operations.js +0 -1
- package/dist/hoi4_agent_tools/map/render.js +0 -1
- package/dist/hoi4_agent_tools/map/service.js +171 -33
- package/dist/hoi4_agent_tools/map/validation.js +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.js +61 -187
- package/dist/hoi4_agent_tools/mcp/security/auth.js +1 -2
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +24 -750
- package/dist/hoi4_agent_tools/mcp/server/context-schemas.js +8 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js +2 -12
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +0 -71
- package/dist/hoi4_agent_tools/mcp/server/progress.js +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.js +146 -81
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +10 -14
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +309 -279
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +156 -254
- package/dist/hoi4_agent_tools/mcp/tools/map.js +259 -338
- package/dist/hoi4_agent_tools/mcp/tools/mods.js +54 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js +1 -12
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +0 -1
- package/dist/hoi4_agent_tools/runtime.js +5 -2
- package/dist/hoi4_agent_tools/schemas/common.js +1 -2
- package/dist/hoi4_agent_tools/schemas/focus.js +64 -9
- package/dist/hoi4_agent_tools/schemas/map.js +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js +0 -1
- package/dist/hoi4_agent_tools/version.js +1 -2
- package/docs/README.md +8 -21
- package/docs/development.md +22 -0
- package/docs/focus.md +50 -0
- package/docs/gui.md +37 -0
- package/docs/http.md +53 -0
- package/docs/map.md +39 -0
- package/docs/setup.md +39 -0
- package/package.json +12 -13
- package/server.json +3 -12
- package/dist/bin/http.d.ts +0 -3
- package/dist/bin/http.d.ts.map +0 -1
- package/dist/bin/http.js.map +0 -1
- package/dist/bin/setup.d.ts +0 -3
- package/dist/bin/setup.d.ts.map +0 -1
- package/dist/bin/setup.js.map +0 -1
- package/dist/bin/stdio.d.ts +0 -3
- package/dist/bin/stdio.d.ts.map +0 -1
- package/dist/bin/stdio.js.map +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.d.ts +0 -117
- package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.js.map +0 -1
- package/dist/hoi4_agent_tools/core/canonical.d.ts +0 -13
- package/dist/hoi4_agent_tools/core/canonical.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/canonical.js.map +0 -1
- package/dist/hoi4_agent_tools/core/configuration.d.ts +0 -138
- package/dist/hoi4_agent_tools/core/configuration.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/configuration.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +0 -18
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts +0 -26
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diff.d.ts +0 -22
- package/dist/hoi4_agent_tools/core/diff.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diff.js.map +0 -1
- package/dist/hoi4_agent_tools/core/engine.d.ts +0 -57
- package/dist/hoi4_agent_tools/core/engine.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/engine.js.map +0 -1
- package/dist/hoi4_agent_tools/core/image-diff.d.ts +0 -14
- package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/image-diff.js.map +0 -1
- package/dist/hoi4_agent_tools/core/index.d.ts +0 -64
- package/dist/hoi4_agent_tools/core/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/index.js.map +0 -1
- package/dist/hoi4_agent_tools/core/index.public.d.ts +0 -16
- package/dist/hoi4_agent_tools/core/index.public.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/index.public.js +0 -16
- package/dist/hoi4_agent_tools/core/index.public.js.map +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.d.ts +0 -51
- package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.js.map +0 -1
- package/dist/hoi4_agent_tools/core/result.d.ts +0 -45
- package/dist/hoi4_agent_tools/core/result.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/result.js.map +0 -1
- package/dist/hoi4_agent_tools/core/scanner.d.ts +0 -28
- package/dist/hoi4_agent_tools/core/scanner.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/scanner.js.map +0 -1
- package/dist/hoi4_agent_tools/core/server-state.d.ts +0 -31
- package/dist/hoi4_agent_tools/core/server-state.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/server-state.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts +0 -10
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/index.d.ts +0 -7
- package/dist/hoi4_agent_tools/core/source/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/index.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts +0 -30
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.d.ts +0 -21
- package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts +0 -20
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.d.ts +0 -44
- package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +0 -10
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.js.map +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.d.ts +0 -34
- package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.js.map +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +0 -9
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.js.map +0 -1
- package/dist/hoi4_agent_tools/core/transactions.d.ts +0 -164
- package/dist/hoi4_agent_tools/core/transactions.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/transactions.js.map +0 -1
- package/dist/hoi4_agent_tools/core/workspace.d.ts +0 -68
- package/dist/hoi4_agent_tools/core/workspace.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/workspace.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/compiler.d.ts +0 -10
- package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/compiler.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +0 -32
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/continuous-render.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/drift.d.ts +0 -22
- package/dist/hoi4_agent_tools/focus/drift.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/drift.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.d.ts +0 -17
- package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/importer.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/importer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/importer.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/index.d.ts +0 -14
- package/dist/hoi4_agent_tools/focus/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/index.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/layout.d.ts +0 -5
- package/dist/hoi4_agent_tools/focus/layout.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/layout.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/limits.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/lint.d.ts +0 -14
- package/dist/hoi4_agent_tools/focus/lint.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/lint.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/model.d.ts +0 -307
- package/dist/hoi4_agent_tools/focus/model.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/model.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/planning.d.ts +0 -15
- package/dist/hoi4_agent_tools/focus/planning.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/planning.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/presentation.d.ts +0 -24
- package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/presentation.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/render.d.ts +0 -39
- package/dist/hoi4_agent_tools/focus/render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/render.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/service.d.ts +0 -82
- package/dist/hoi4_agent_tools/focus/service.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/service.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/source-update.d.ts +0 -6
- package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/source-update.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +0 -37
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/assets.d.ts +0 -71
- package/dist/hoi4_agent_tools/gui/assets.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/assets.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/dds.d.ts +0 -17
- package/dist/hoi4_agent_tools/gui/dds.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/dds.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.d.ts +0 -101
- package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/index.d.ts +0 -15
- package/dist/hoi4_agent_tools/gui/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/index.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/layout.d.ts +0 -6
- package/dist/hoi4_agent_tools/gui/layout.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/layout.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/limits.d.ts +0 -25
- package/dist/hoi4_agent_tools/gui/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.d.ts +0 -18
- package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.d.ts +0 -66
- package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts +0 -7
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts +0 -13
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/studio.d.ts +0 -86
- package/dist/hoi4_agent_tools/gui/studio.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/studio.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/tga.d.ts +0 -16
- package/dist/hoi4_agent_tools/gui/tga.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/tga.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/types.d.ts +0 -322
- package/dist/hoi4_agent_tools/gui/types.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/types.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/validators.d.ts +0 -8
- package/dist/hoi4_agent_tools/gui/validators.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/validators.js.map +0 -1
- package/dist/hoi4_agent_tools/map/bmp.d.ts +0 -62
- package/dist/hoi4_agent_tools/map/bmp.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/bmp.js.map +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +0 -5
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +0 -1
- package/dist/hoi4_agent_tools/map/index.d.ts +0 -8
- package/dist/hoi4_agent_tools/map/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/index.js.map +0 -1
- package/dist/hoi4_agent_tools/map/limits.d.ts +0 -13
- package/dist/hoi4_agent_tools/map/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/map/model.d.ts +0 -269
- package/dist/hoi4_agent_tools/map/model.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/model.js.map +0 -1
- package/dist/hoi4_agent_tools/map/operations.d.ts +0 -401
- package/dist/hoi4_agent_tools/map/operations.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/operations.js.map +0 -1
- package/dist/hoi4_agent_tools/map/render.d.ts +0 -90
- package/dist/hoi4_agent_tools/map/render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/render.js.map +0 -1
- package/dist/hoi4_agent_tools/map/service.d.ts +0 -81
- package/dist/hoi4_agent_tools/map/service.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/service.js.map +0 -1
- package/dist/hoi4_agent_tools/map/validation.d.ts +0 -23
- package/dist/hoi4_agent_tools/map/validation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/validation.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +0 -4
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/prompts/register.js +0 -72
- package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +0 -9
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js +0 -10
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +0 -24
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/security/auth.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +0 -47
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/create.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +0 -138
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +0 -8
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/progress.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts +0 -232
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts +0 -31
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +0 -117
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/map.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +0 -58
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +0 -26
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +0 -28
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +0 -15
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +0 -1
- package/dist/hoi4_agent_tools/runtime.d.ts +0 -4
- package/dist/hoi4_agent_tools/runtime.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/runtime.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/common.d.ts +0 -74
- package/dist/hoi4_agent_tools/schemas/common.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/common.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/focus.d.ts +0 -784
- package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/focus.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/index.d.ts +0 -5
- package/dist/hoi4_agent_tools/schemas/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/index.js +0 -5
- package/dist/hoi4_agent_tools/schemas/index.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/map.d.ts +0 -654
- package/dist/hoi4_agent_tools/schemas/map.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/map.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts +0 -259
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js.map +0 -1
- package/dist/hoi4_agent_tools/version.d.ts +0 -6
- package/dist/hoi4_agent_tools/version.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/version.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/docs/adr/0001-runtime-and-language.md +0 -16
- package/docs/adr/0002-lossless-source-model.md +0 -18
- package/docs/adr/0003-image-and-font-codecs.md +0 -18
- package/docs/adr/0004-focus-layout.md +0 -16
- package/docs/adr/0005-offline-rendering.md +0 -18
- package/docs/adr/0006-mcp-sdk-and-protocol.md +0 -16
- package/docs/adr/0007-storage-and-transactions.md +0 -24
- package/docs/adr/0008-test-strategy.md +0 -18
- package/docs/adr/0009-packaging-and-registry.md +0 -16
- package/docs/adr/0010-unsupported-and-refusal-policy.md +0 -18
- package/docs/adr/0011-http-security.md +0 -16
- package/docs/adr/0012-autonomous-rewrites.md +0 -55
- package/docs/adr/README.md +0 -14
- package/docs/agent-integration.md +0 -146
- package/docs/architecture.md +0 -76
- package/docs/artifacts.md +0 -136
- package/docs/compatibility.md +0 -33
- package/docs/completion-report.md +0 -122
- package/docs/configuration.md +0 -305
- package/docs/focus-workflow.md +0 -197
- package/docs/gui-workflow.md +0 -125
- package/docs/limitations.md +0 -32
- package/docs/map-workflow.md +0 -95
- package/docs/performance.md +0 -117
- package/docs/release.md +0 -222
- package/docs/research/mcp-2026-07-10.md +0 -52
- package/docs/research/source-ledger.md +0 -68
- package/docs/security.md +0 -145
- package/docs/self-hosting.md +0 -170
- package/docs/testing.md +0 -43
- package/docs/third-party-notices.md +0 -11
- package/docs/transactions.md +0 -180
- package/docs/troubleshooting.md +0 -54
- package/schemas/configuration.schema.json +0 -795
- package/schemas/continuous-focus-palette.schema.json +0 -325
- package/schemas/focus-plan.schema.json +0 -927
- package/schemas/focus-planning-sidecar.schema.json +0 -379
- package/schemas/gui-animation-source.schema.json +0 -176
- package/schemas/gui-helper.schema.json +0 -301
- package/schemas/gui-scenario.schema.json +0 -298
- package/schemas/map-operation.schema.json +0 -2284
- package/schemas/operation-result.schema.json +0 -344
- package/schemas/transaction-manifest.schema.json +0 -685
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { compareCodeUnits } from '../core/canonical.js';
|
|
2
|
+
import { ServiceError } from '../core/result.js';
|
|
3
|
+
import { focusPlanHash, } from './model.js';
|
|
4
|
+
import { FOCUS_LAYOUT_WORK_MAX } from './limits.js';
|
|
5
|
+
import { FocusLayoutWorkBudget, layoutFocusTree, layoutFocusTreeAsync } from './layout.js';
|
|
6
|
+
const COMPACT_SAME_ROW_SPACING = 2;
|
|
7
|
+
const COMPACT_LANE_SPACING = 8;
|
|
8
|
+
const SMALL_COMPACT_SCALES = [0.2, 0.3, 0.4, 0.55, 0.7, 0.9];
|
|
9
|
+
const LARGE_COMPACT_SCALES = [0.55, 0.6, 0.7, 0.8];
|
|
10
|
+
const COMPACT_LAYOUT_WORK_MAX = FOCUS_LAYOUT_WORK_MAX * 10;
|
|
11
|
+
const COMPACT_HARD_DIAGNOSTICS = new Set([
|
|
12
|
+
'FOCUS_LAYOUT_CONNECTOR_CROSSING_UNSATISFIED',
|
|
13
|
+
'FOCUS_LAYOUT_COORDINATE_CONFLICT',
|
|
14
|
+
'FOCUS_LAYOUT_LANE_BOUNDS_UNSATISFIED',
|
|
15
|
+
'FOCUS_LAYOUT_MUTUAL_EXCLUSION_SPACING_UNSATISFIED',
|
|
16
|
+
'FOCUS_LAYOUT_PARENT_ORDER_UNSATISFIED',
|
|
17
|
+
'FOCUS_LAYOUT_SAME_ROW_SPACING_UNSATISFIED',
|
|
18
|
+
'FOCUS_LAYOUT_VISIBLE_OVERLAP',
|
|
19
|
+
]);
|
|
20
|
+
function compactLimits(focusCount, connectorCount) {
|
|
21
|
+
const graphScale = Math.sqrt(Math.max(1, focusCount));
|
|
22
|
+
const maximumHorizontalSpan = Math.max(14, Math.ceil(graphScale * 3));
|
|
23
|
+
const maximumVerticalSpan = Math.max(4, Math.ceil(Math.log2(Math.max(2, focusCount))));
|
|
24
|
+
return {
|
|
25
|
+
maximumColumns: Math.max(16, Math.ceil(graphScale * 5)),
|
|
26
|
+
maximumHorizontalSpan,
|
|
27
|
+
maximumVerticalSpan,
|
|
28
|
+
maximumManhattanSpan: maximumHorizontalSpan + maximumVerticalSpan,
|
|
29
|
+
maximumLongConnectors: Math.ceil(connectorCount * 0.05),
|
|
30
|
+
maximumNodeIntersections: Math.ceil(connectorCount * 0.12),
|
|
31
|
+
maximumSiblingDeviation: Math.max(2, Math.ceil(graphScale * 2)),
|
|
32
|
+
maximumTotalSiblingDeviation: Math.max(4, Math.ceil(focusCount * 0.5)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function requiredMetrics(layout) {
|
|
36
|
+
if (layout.metrics !== undefined)
|
|
37
|
+
return layout.metrics;
|
|
38
|
+
throw new ServiceError('FOCUS_COMPACT_METRICS_REQUIRED', 'Compact focus reflow requires current layout quality metrics', { treeId: layout.treeId });
|
|
39
|
+
}
|
|
40
|
+
function absoluteCompactRegressions(layout) {
|
|
41
|
+
const metrics = requiredMetrics(layout);
|
|
42
|
+
const limits = compactLimits(layout.nodes.length, metrics.connectors.count);
|
|
43
|
+
return [
|
|
44
|
+
...(layout.diagnostics.some(({ code }) => COMPACT_HARD_DIAGNOSTICS.has(code))
|
|
45
|
+
? ['hardLayoutDiagnostics']
|
|
46
|
+
: []),
|
|
47
|
+
...(metrics.connectors.crossingCount > 0 ? ['connectorCrossingCount'] : []),
|
|
48
|
+
...(metrics.connectors.nodeIntersectionCount > limits.maximumNodeIntersections
|
|
49
|
+
? ['connectorNodeIntersectionBudget']
|
|
50
|
+
: []),
|
|
51
|
+
...(metrics.spacing.tooCloseSameRowPairCount > 0 ? ['sameRowSpacing'] : []),
|
|
52
|
+
...(metrics.symmetry.maximumSiblingDeviation > 1 ? ['siblingMirrorDeviation'] : []),
|
|
53
|
+
...(metrics.symmetry.totalSiblingDeviation > metrics.symmetry.siblingCohortCount
|
|
54
|
+
? ['totalSiblingMirrorDeviation']
|
|
55
|
+
: []),
|
|
56
|
+
...(metrics.symmetry.maximumSiblingAnchorDeviation > limits.maximumSiblingDeviation
|
|
57
|
+
? ['maximumSiblingDeviationBudget']
|
|
58
|
+
: []),
|
|
59
|
+
...(metrics.symmetry.totalSiblingAnchorDeviation > limits.maximumTotalSiblingDeviation
|
|
60
|
+
? ['totalSiblingDeviationBudget']
|
|
61
|
+
: []),
|
|
62
|
+
...(metrics.symmetry.boundingCenterOffsetTwice > 1 ? ['boundingCenter'] : []),
|
|
63
|
+
...(metrics.bounds.columnCount > limits.maximumColumns ? ['columnBudget'] : []),
|
|
64
|
+
...(metrics.connectors.maximumHorizontalSpan > limits.maximumHorizontalSpan
|
|
65
|
+
? ['maximumHorizontalConnectorBudget']
|
|
66
|
+
: []),
|
|
67
|
+
...(metrics.connectors.maximumVerticalSpan > limits.maximumVerticalSpan
|
|
68
|
+
? ['maximumVerticalConnectorBudget']
|
|
69
|
+
: []),
|
|
70
|
+
...(metrics.connectors.maximumManhattanSpan > limits.maximumManhattanSpan
|
|
71
|
+
? ['maximumManhattanConnectorBudget']
|
|
72
|
+
: []),
|
|
73
|
+
...(metrics.connectors.longConnectorCount > limits.maximumLongConnectors
|
|
74
|
+
? ['longConnectorBudget']
|
|
75
|
+
: []),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function relativeCompactRegressions(current, proposed) {
|
|
79
|
+
const before = requiredMetrics(current);
|
|
80
|
+
const after = requiredMetrics(proposed);
|
|
81
|
+
return [
|
|
82
|
+
...(after.connectors.crossingCount > before.connectors.crossingCount
|
|
83
|
+
? ['connectorCrossingCount']
|
|
84
|
+
: []),
|
|
85
|
+
...(after.connectors.nodeIntersectionCount > before.connectors.nodeIntersectionCount
|
|
86
|
+
? ['connectorNodeIntersectionCount']
|
|
87
|
+
: []),
|
|
88
|
+
...(after.connectors.maximumHorizontalSpan > before.connectors.maximumHorizontalSpan
|
|
89
|
+
? ['maximumHorizontalConnectorSpan']
|
|
90
|
+
: []),
|
|
91
|
+
...(after.connectors.maximumVerticalSpan > before.connectors.maximumVerticalSpan
|
|
92
|
+
? ['maximumVerticalConnectorSpan']
|
|
93
|
+
: []),
|
|
94
|
+
...(after.connectors.maximumManhattanSpan > before.connectors.maximumManhattanSpan
|
|
95
|
+
? ['maximumManhattanConnectorSpan']
|
|
96
|
+
: []),
|
|
97
|
+
...(after.connectors.longConnectorCount > before.connectors.longConnectorCount
|
|
98
|
+
? ['longConnectorCount']
|
|
99
|
+
: []),
|
|
100
|
+
...(after.connectors.totalHorizontalSpan > before.connectors.totalHorizontalSpan
|
|
101
|
+
? ['totalHorizontalConnectorSpan']
|
|
102
|
+
: []),
|
|
103
|
+
...(after.connectors.totalManhattanSpan > before.connectors.totalManhattanSpan
|
|
104
|
+
? ['totalManhattanConnectorSpan']
|
|
105
|
+
: []),
|
|
106
|
+
...(after.bounds.columnCount > before.bounds.columnCount ? ['columnCount'] : []),
|
|
107
|
+
...(after.bounds.rowCount > before.bounds.rowCount ? ['rowCount'] : []),
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function compactShape(plan, layout) {
|
|
111
|
+
return (plan.focuses.every(({ position }) => position.mode === 'auto') &&
|
|
112
|
+
plan.laneGroups.every(({ minimumX, maximumX }) => minimumX === undefined && maximumX === undefined) &&
|
|
113
|
+
absoluteCompactRegressions(layout).length === 0);
|
|
114
|
+
}
|
|
115
|
+
function prerequisiteIds(plan, focusId) {
|
|
116
|
+
const focus = plan.focuses.find(({ id }) => id === focusId);
|
|
117
|
+
return (focus?.prerequisites.groups
|
|
118
|
+
.flatMap(({ focusIds }) => focusIds)
|
|
119
|
+
.sort((left, right) => compareCodeUnits(left, right)) ?? []);
|
|
120
|
+
}
|
|
121
|
+
function focusLaneId(plan, focus) {
|
|
122
|
+
if (focus.laneId !== undefined)
|
|
123
|
+
return focus.laneId;
|
|
124
|
+
if (focus.branchId !== undefined) {
|
|
125
|
+
const branch = plan.branchGroups.find(({ id }) => id === focus.branchId);
|
|
126
|
+
return branch?.laneId ?? focus.branchId;
|
|
127
|
+
}
|
|
128
|
+
return 'default';
|
|
129
|
+
}
|
|
130
|
+
function compactLaneBases(plan) {
|
|
131
|
+
const configured = [...plan.laneGroups].sort((left, right) => left.order - right.order || compareCodeUnits(left.id, right.id));
|
|
132
|
+
const configuredIds = new Set(configured.map(({ id }) => id));
|
|
133
|
+
const discovered = [...new Set(plan.focuses.map((focus) => focusLaneId(plan, focus)))]
|
|
134
|
+
.filter((id) => !configuredIds.has(id))
|
|
135
|
+
.sort((left, right) => compareCodeUnits(left, right));
|
|
136
|
+
const laneIds = [...configured.map(({ id }) => id), ...discovered];
|
|
137
|
+
return new Map(laneIds.map((id, index) => [
|
|
138
|
+
id,
|
|
139
|
+
Math.round((index - (laneIds.length - 1) / 2) * COMPACT_LANE_SPACING),
|
|
140
|
+
]));
|
|
141
|
+
}
|
|
142
|
+
function compactStructuralAnchorX(plan, focus, parents, preferredX, laneBases) {
|
|
143
|
+
const parentCoordinates = parents
|
|
144
|
+
.flatMap((focusId) => {
|
|
145
|
+
const coordinate = preferredX.get(focusId);
|
|
146
|
+
return coordinate === undefined ? [] : [coordinate];
|
|
147
|
+
})
|
|
148
|
+
.sort((left, right) => left - right);
|
|
149
|
+
if (parentCoordinates.length > 1 && focus.convergence) {
|
|
150
|
+
return Math.floor(parentCoordinates.reduce((total, coordinate) => total + coordinate, 0) /
|
|
151
|
+
parentCoordinates.length);
|
|
152
|
+
}
|
|
153
|
+
if (parentCoordinates.length > 0) {
|
|
154
|
+
const middle = Math.floor(parentCoordinates.length / 2);
|
|
155
|
+
if (parentCoordinates.length % 2 === 1)
|
|
156
|
+
return parentCoordinates[middle] ?? 0;
|
|
157
|
+
return Math.floor(((parentCoordinates[middle - 1] ?? 0) + (parentCoordinates[middle] ?? 0)) / 2);
|
|
158
|
+
}
|
|
159
|
+
return laneBases.get(focusLaneId(plan, focus)) ?? 0;
|
|
160
|
+
}
|
|
161
|
+
function mirrorSiblingCohorts(plan, preferredX, preferredY) {
|
|
162
|
+
const cohorts = new Map();
|
|
163
|
+
const laneBases = compactLaneBases(plan);
|
|
164
|
+
const childCounts = new Map();
|
|
165
|
+
for (const focus of plan.focuses) {
|
|
166
|
+
const parents = prerequisiteIds(plan, focus.id);
|
|
167
|
+
for (const parentId of parents)
|
|
168
|
+
childCounts.set(parentId, (childCounts.get(parentId) ?? 0) + 1);
|
|
169
|
+
const key = JSON.stringify([
|
|
170
|
+
parents.length === 0 ? focusLaneId(plan, focus) : null,
|
|
171
|
+
parents,
|
|
172
|
+
preferredY.get(focus.id) ?? 0,
|
|
173
|
+
]);
|
|
174
|
+
const cohort = cohorts.get(key) ?? [];
|
|
175
|
+
cohort.push(focus.id);
|
|
176
|
+
cohorts.set(key, cohort);
|
|
177
|
+
}
|
|
178
|
+
for (const cohort of cohorts.values()) {
|
|
179
|
+
if (cohort.length < 2)
|
|
180
|
+
continue;
|
|
181
|
+
cohort.sort((left, right) => (preferredX.get(left) ?? 0) - (preferredX.get(right) ?? 0) || compareCodeUnits(left, right));
|
|
182
|
+
const coordinates = cohort.map((id) => preferredX.get(id) ?? 0);
|
|
183
|
+
const pairCount = Math.floor(coordinates.length / 2);
|
|
184
|
+
const focus = plan.focuses.find(({ id }) => id === cohort[0]);
|
|
185
|
+
if (focus === undefined)
|
|
186
|
+
continue;
|
|
187
|
+
// A leaf fan can be mirrored directly around its structural parent. For
|
|
188
|
+
// rooted subtrees, moving only the entry focuses would push the long
|
|
189
|
+
// connectors into their descendants; keep the subtree envelope's center
|
|
190
|
+
// until the bounded gateway refinement can move the common parent.
|
|
191
|
+
const leafFan = cohort.every((focusId) => (childCounts.get(focusId) ?? 0) === 0);
|
|
192
|
+
const mirroredAt = (centerTwice) => {
|
|
193
|
+
const mirrored = [...coordinates];
|
|
194
|
+
for (let index = 0; index < pairCount; index += 1) {
|
|
195
|
+
const opposite = coordinates.length - 1 - index;
|
|
196
|
+
const left = Math.round(((coordinates[index] ?? 0) + centerTwice - (coordinates[opposite] ?? 0)) / 2);
|
|
197
|
+
mirrored[index] = left;
|
|
198
|
+
mirrored[opposite] = centerTwice - left;
|
|
199
|
+
}
|
|
200
|
+
if (coordinates.length % 2 === 1)
|
|
201
|
+
mirrored[pairCount] = Math.round(centerTwice / 2);
|
|
202
|
+
let maximumLeft = centerTwice / 2 - (coordinates.length % 2 === 1 ? 2 : 1);
|
|
203
|
+
for (let index = pairCount - 1; index >= 0; index -= 1) {
|
|
204
|
+
const opposite = coordinates.length - 1 - index;
|
|
205
|
+
const left = Math.min(mirrored[index] ?? maximumLeft, maximumLeft);
|
|
206
|
+
mirrored[index] = left;
|
|
207
|
+
mirrored[opposite] = centerTwice - left;
|
|
208
|
+
maximumLeft = left - COMPACT_SAME_ROW_SPACING;
|
|
209
|
+
}
|
|
210
|
+
return mirrored;
|
|
211
|
+
};
|
|
212
|
+
const selfCenterTwice = (coordinates[0] ?? 0) + (coordinates.at(-1) ?? 0);
|
|
213
|
+
const anchorCenterTwice = 2 *
|
|
214
|
+
compactStructuralAnchorX(plan, focus, prerequisiteIds(plan, focus.id), preferredX, laneBases);
|
|
215
|
+
let mirrored = mirroredAt(leafFan ? anchorCenterTwice : selfCenterTwice);
|
|
216
|
+
if (leafFan) {
|
|
217
|
+
const cohortIds = new Set(cohort);
|
|
218
|
+
const y = preferredY.get(cohort[0] ?? '');
|
|
219
|
+
const otherCoordinates = plan.focuses.flatMap((candidate) => !cohortIds.has(candidate.id) && preferredY.get(candidate.id) === y
|
|
220
|
+
? [preferredX.get(candidate.id) ?? 0]
|
|
221
|
+
: []);
|
|
222
|
+
if (mirrored.some((coordinate) => otherCoordinates.some((otherCoordinate) => Math.abs(coordinate - otherCoordinate) < COMPACT_SAME_ROW_SPACING))) {
|
|
223
|
+
mirrored = mirroredAt(selfCenterTwice);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const [index, focusId] of cohort.entries())
|
|
227
|
+
preferredX.set(focusId, mirrored[index] ?? 0);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function compactCandidate(plan, layout, scale, compressRows) {
|
|
231
|
+
const minimumX = Math.min(...layout.nodes.map(({ x }) => x));
|
|
232
|
+
const maximumX = Math.max(...layout.nodes.map(({ x }) => x));
|
|
233
|
+
const minimumY = Math.min(...layout.nodes.map(({ y }) => y));
|
|
234
|
+
const centerX = (minimumX + maximumX) / 2;
|
|
235
|
+
const preferredX = new Map(layout.nodes.map((node) => [node.id, Math.round((node.x - centerX) * scale)]));
|
|
236
|
+
const sourceRows = [...new Set(layout.nodes.map(({ y }) => y))].sort((left, right) => left - right);
|
|
237
|
+
const compactRows = new Map(sourceRows.map((row, index) => [row, index]));
|
|
238
|
+
const preferredY = new Map(layout.nodes.map((node) => [
|
|
239
|
+
node.id,
|
|
240
|
+
compressRows ? (compactRows.get(node.y) ?? node.y - minimumY) : node.y - minimumY,
|
|
241
|
+
]));
|
|
242
|
+
const rows = new Map();
|
|
243
|
+
for (const node of layout.nodes) {
|
|
244
|
+
const row = rows.get(node.y) ?? [];
|
|
245
|
+
row.push(node);
|
|
246
|
+
rows.set(node.y, row);
|
|
247
|
+
}
|
|
248
|
+
for (const row of rows.values()) {
|
|
249
|
+
row.sort((left, right) => left.x - right.x || compareCodeUnits(left.id, right.id));
|
|
250
|
+
const placed = [];
|
|
251
|
+
for (const [index, node] of row.entries()) {
|
|
252
|
+
const requested = preferredX.get(node.id) ?? 0;
|
|
253
|
+
placed.push(index === 0
|
|
254
|
+
? requested
|
|
255
|
+
: Math.max(requested, (placed[index - 1] ?? 0) + COMPACT_SAME_ROW_SPACING));
|
|
256
|
+
}
|
|
257
|
+
const drift = Math.round(row.reduce((total, node, index) => total + (preferredX.get(node.id) ?? 0) - (placed[index] ?? 0), 0) / row.length);
|
|
258
|
+
for (const [index, node] of row.entries())
|
|
259
|
+
preferredX.set(node.id, (placed[index] ?? 0) + drift);
|
|
260
|
+
}
|
|
261
|
+
mirrorSiblingCohorts(plan, preferredX, preferredY);
|
|
262
|
+
const compacted = structuredClone(plan);
|
|
263
|
+
compacted.laneGroups = compacted.laneGroups.map(({ id, label, order }) => ({
|
|
264
|
+
id,
|
|
265
|
+
label,
|
|
266
|
+
order,
|
|
267
|
+
}));
|
|
268
|
+
for (const focus of compacted.focuses) {
|
|
269
|
+
focus.position = {
|
|
270
|
+
mode: 'auto',
|
|
271
|
+
pinned: false,
|
|
272
|
+
preferredX: preferredX.get(focus.id) ?? 0,
|
|
273
|
+
preferredY: preferredY.get(focus.id) ?? 0,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
compacted.provenance.importedPlanHash = focusPlanHash(compacted);
|
|
277
|
+
return compacted;
|
|
278
|
+
}
|
|
279
|
+
function compactScore(layout) {
|
|
280
|
+
const metrics = requiredMetrics(layout);
|
|
281
|
+
return [
|
|
282
|
+
metrics.connectors.longConnectorCount,
|
|
283
|
+
metrics.connectors.maximumHorizontalSpan,
|
|
284
|
+
metrics.bounds.columnCount,
|
|
285
|
+
metrics.connectors.nodeIntersectionCount,
|
|
286
|
+
metrics.connectors.totalHorizontalSpan,
|
|
287
|
+
metrics.connectors.maximumManhattanSpan,
|
|
288
|
+
metrics.bounds.rowCount,
|
|
289
|
+
metrics.connectors.totalVerticalSpan,
|
|
290
|
+
layout.layoutHash,
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
function betterScore(candidate, current) {
|
|
294
|
+
for (let index = 0; index < candidate.length; index += 1) {
|
|
295
|
+
const left = candidate[index];
|
|
296
|
+
const right = current[index];
|
|
297
|
+
if (left === right)
|
|
298
|
+
continue;
|
|
299
|
+
if (typeof left === 'number' && typeof right === 'number')
|
|
300
|
+
return left < right;
|
|
301
|
+
return String(left) < String(right);
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
function compactScales(focusCount) {
|
|
306
|
+
return focusCount <= 50
|
|
307
|
+
? SMALL_COMPACT_SCALES
|
|
308
|
+
: focusCount <= 500
|
|
309
|
+
? LARGE_COMPACT_SCALES
|
|
310
|
+
: focusCount <= 2_000
|
|
311
|
+
? [0.55, 0.65, 0.75]
|
|
312
|
+
: [0.65];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Produces a gameplay-neutral compact-reflow plan. Several deterministic
|
|
316
|
+
* compression candidates are measured with the same layout engine; only a
|
|
317
|
+
* centered, crossing-free, evenly spaced, branch-balanced candidate that
|
|
318
|
+
* stays within absolute and source-relative connector budgets can win.
|
|
319
|
+
*/
|
|
320
|
+
export function compactFocusTreePlan(plan) {
|
|
321
|
+
const currentLayout = layoutFocusTree(plan);
|
|
322
|
+
if (compactShape(plan, currentLayout)) {
|
|
323
|
+
const stable = structuredClone(plan);
|
|
324
|
+
stable.provenance.importedPlanHash = focusPlanHash(stable);
|
|
325
|
+
return stable;
|
|
326
|
+
}
|
|
327
|
+
const scales = compactScales(plan.focuses.length);
|
|
328
|
+
let selected;
|
|
329
|
+
let fallback;
|
|
330
|
+
for (const scale of scales) {
|
|
331
|
+
for (const compressRows of plan.focuses.length <= 500 ? [false, true] : [false]) {
|
|
332
|
+
const candidate = compactCandidate(plan, currentLayout, scale, compressRows);
|
|
333
|
+
let layout;
|
|
334
|
+
try {
|
|
335
|
+
layout = layoutFocusTree(candidate);
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
if (error instanceof ServiceError && error.code === 'FOCUS_LAYOUT_WORK_BUDGET_BLOCKED')
|
|
339
|
+
continue;
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
if (fallback === undefined ||
|
|
343
|
+
betterScore(compactScore(layout), compactScore(fallback.layout)))
|
|
344
|
+
fallback = { plan: candidate, layout };
|
|
345
|
+
if (absoluteCompactRegressions(layout).length > 0 ||
|
|
346
|
+
relativeCompactRegressions(currentLayout, layout).length > 0)
|
|
347
|
+
continue;
|
|
348
|
+
if (selected === undefined ||
|
|
349
|
+
betterScore(compactScore(layout), compactScore(selected.layout)))
|
|
350
|
+
selected = { plan: candidate, layout };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (selected !== undefined)
|
|
354
|
+
return selected.plan;
|
|
355
|
+
if (fallback !== undefined) {
|
|
356
|
+
assertCompactLayoutQuality(currentLayout, fallback.layout);
|
|
357
|
+
return fallback.plan;
|
|
358
|
+
}
|
|
359
|
+
throw new ServiceError('FOCUS_COMPACT_LAYOUT_REQUIRED', 'Compact focus planning did not produce a measurable layout candidate', { treeId: plan.id });
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Cooperative compact planning for protocol handlers. Candidate layouts share
|
|
363
|
+
* one work budget, and the selected layout is returned for validation/rendering.
|
|
364
|
+
*/
|
|
365
|
+
export async function compactFocusTreePlanAsync(plan, options = {}) {
|
|
366
|
+
const workBudget = new FocusLayoutWorkBudget(options.maximumWork ?? COMPACT_LAYOUT_WORK_MAX);
|
|
367
|
+
const layoutOptions = {
|
|
368
|
+
workBudget,
|
|
369
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
370
|
+
};
|
|
371
|
+
const currentLayout = await layoutFocusTreeAsync(plan, layoutOptions);
|
|
372
|
+
if (compactShape(plan, currentLayout)) {
|
|
373
|
+
const stable = structuredClone(plan);
|
|
374
|
+
stable.provenance.importedPlanHash = focusPlanHash(stable);
|
|
375
|
+
return { plan: stable, currentLayout, proposedLayout: currentLayout };
|
|
376
|
+
}
|
|
377
|
+
let selected;
|
|
378
|
+
let fallback;
|
|
379
|
+
let exhausted;
|
|
380
|
+
candidateSearch: for (const scale of compactScales(plan.focuses.length)) {
|
|
381
|
+
for (const compressRows of plan.focuses.length <= 500 ? [false, true] : [false]) {
|
|
382
|
+
options.signal?.throwIfAborted();
|
|
383
|
+
const candidate = compactCandidate(plan, currentLayout, scale, compressRows);
|
|
384
|
+
let layout;
|
|
385
|
+
try {
|
|
386
|
+
layout = await layoutFocusTreeAsync(candidate, layoutOptions);
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
if (error instanceof ServiceError && error.code === 'FOCUS_LAYOUT_WORK_BUDGET_BLOCKED') {
|
|
390
|
+
exhausted = error;
|
|
391
|
+
break candidateSearch;
|
|
392
|
+
}
|
|
393
|
+
throw error;
|
|
394
|
+
}
|
|
395
|
+
if (fallback === undefined ||
|
|
396
|
+
betterScore(compactScore(layout), compactScore(fallback.layout)))
|
|
397
|
+
fallback = { plan: candidate, layout };
|
|
398
|
+
if (absoluteCompactRegressions(layout).length > 0 ||
|
|
399
|
+
relativeCompactRegressions(currentLayout, layout).length > 0)
|
|
400
|
+
continue;
|
|
401
|
+
if (selected === undefined ||
|
|
402
|
+
betterScore(compactScore(layout), compactScore(selected.layout)))
|
|
403
|
+
selected = { plan: candidate, layout };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (selected !== undefined) {
|
|
407
|
+
return { plan: selected.plan, currentLayout, proposedLayout: selected.layout };
|
|
408
|
+
}
|
|
409
|
+
if (exhausted !== undefined)
|
|
410
|
+
throw exhausted;
|
|
411
|
+
if (fallback !== undefined) {
|
|
412
|
+
assertCompactLayoutQuality(currentLayout, fallback.layout);
|
|
413
|
+
return { plan: fallback.plan, currentLayout, proposedLayout: fallback.layout };
|
|
414
|
+
}
|
|
415
|
+
throw new ServiceError('FOCUS_COMPACT_LAYOUT_REQUIRED', 'Compact focus planning did not produce a measurable layout candidate', { treeId: plan.id });
|
|
416
|
+
}
|
|
417
|
+
/** Refuses compact rewrites that are not clean or trade readability for a smaller canvas. */
|
|
418
|
+
export function assertCompactLayoutQuality(current, proposed) {
|
|
419
|
+
const regressions = [
|
|
420
|
+
...absoluteCompactRegressions(proposed),
|
|
421
|
+
...(current === undefined ? [] : relativeCompactRegressions(current, proposed)),
|
|
422
|
+
].filter((value, index, all) => all.indexOf(value) === index);
|
|
423
|
+
if (regressions.length === 0)
|
|
424
|
+
return;
|
|
425
|
+
throw new ServiceError('FOCUS_COMPACT_QUALITY_BLOCKED', 'Compact focus reflow failed the absolute or relative layout-quality gate', {
|
|
426
|
+
treeId: proposed.treeId,
|
|
427
|
+
regressions,
|
|
428
|
+
limits: compactLimits(proposed.nodes.length, requiredMetrics(proposed).connectors.count),
|
|
429
|
+
...(current === undefined ? {} : { before: requiredMetrics(current) }),
|
|
430
|
+
proposed: requiredMetrics(proposed),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
@@ -90,13 +90,7 @@ function positionLines(focus, layout) {
|
|
|
90
90
|
if (focus.position.mode === 'fixed') {
|
|
91
91
|
return [`x = ${focus.position.x}`, `y = ${focus.position.y}`];
|
|
92
92
|
}
|
|
93
|
-
const placed = layoutNodeMap(layout
|
|
94
|
-
treeId: '',
|
|
95
|
-
nodes: [],
|
|
96
|
-
decisions: [],
|
|
97
|
-
diagnostics: [],
|
|
98
|
-
layoutHash: '',
|
|
99
|
-
}).get(focus.id);
|
|
93
|
+
const placed = layout === undefined ? undefined : layoutNodeMap(layout).get(focus.id);
|
|
100
94
|
if (placed === undefined) {
|
|
101
95
|
throw new ServiceError('FOCUS_LAYOUT_REQUIRED', `Automatic focus ${focus.id} has no layout position`, {
|
|
102
96
|
focusId: focus.id,
|
|
@@ -280,4 +274,3 @@ export function compileContinuousFocusPaletteWithSourceMap(plan, generatedPath =
|
|
|
280
274
|
},
|
|
281
275
|
};
|
|
282
276
|
}
|
|
283
|
-
//# sourceMappingURL=compiler.js.map
|