talos-code 0.0.1 → 0.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/LICENSE +661 -0
- package/README.md +111 -3
- package/THIRD_PARTY_NOTICES.md +40 -0
- package/dist/archive/zip.js +73 -0
- package/dist/args.js +97 -0
- package/dist/automations/history-store.js +34 -0
- package/dist/automations/policy-store.js +43 -0
- package/dist/automations/runner.js +107 -0
- package/dist/automations/schedule.js +85 -0
- package/dist/automations/windows-task.js +53 -0
- package/dist/commands/advanced-cli.js +233 -0
- package/dist/commands/checkpoint-cli.js +45 -0
- package/dist/commands/config-cli.js +107 -0
- package/dist/commands/context.js +17 -0
- package/dist/commands/extensions-cli.js +207 -0
- package/dist/commands/project-cli.js +74 -0
- package/dist/commands/project-commands.js +143 -0
- package/dist/commands/provider-cli.js +185 -0
- package/dist/commands/services-cli.js +248 -0
- package/dist/commands/session-cli.js +171 -0
- package/dist/commands/system-cli.js +405 -0
- package/dist/config/commands.js +60 -0
- package/dist/config/load.js +382 -0
- package/dist/config/migrations.js +48 -0
- package/dist/config/types.js +11 -0
- package/dist/diagnostics/development-log.js +154 -0
- package/dist/diagnostics/doctor.js +104 -0
- package/dist/diagnostics/redact.js +80 -0
- package/dist/diagnostics/zip.js +52 -0
- package/dist/errors.js +156 -0
- package/dist/events/bridge.js +130 -0
- package/dist/extensions/installer.js +178 -0
- package/dist/extensions/package-schema.js +24 -0
- package/dist/headless/result.js +84 -0
- package/dist/headless/run.js +230 -0
- package/dist/i18n/en/approval.js +43 -0
- package/dist/i18n/en/common.js +9 -0
- package/dist/i18n/en/credentials.js +82 -0
- package/dist/i18n/en/errors.js +246 -0
- package/dist/i18n/en/firstrun.js +89 -0
- package/dist/i18n/en/providers.js +37 -0
- package/dist/i18n/en/screen.js +736 -0
- package/dist/i18n/en/tools.js +127 -0
- package/dist/i18n/en.js +14 -0
- package/dist/i18n/error-view.js +307 -0
- package/dist/i18n/index.js +19 -0
- package/dist/i18n/kernel-map.js +139 -0
- package/dist/io.js +45 -0
- package/dist/main.js +330 -0
- package/dist/paths.js +41 -0
- package/dist/protocol/v2/codec.js +9 -0
- package/dist/protocol/v2/events.js +555 -0
- package/dist/protocol/v2/index.js +4 -0
- package/dist/protocol/v2/replay.js +28 -0
- package/dist/protocol/v2/types.js +1 -0
- package/dist/provider/control-plane.js +135 -0
- package/dist/provider/environment-keys.js +275 -0
- package/dist/provider/health.js +110 -0
- package/dist/provider/missing-key.js +48 -0
- package/dist/provider/model-catalog.js +168 -0
- package/dist/provider/provider-text.js +13 -0
- package/dist/provider/store.js +95 -0
- package/dist/provider/system-keyring.js +214 -0
- package/dist/runtime/active-run.js +63 -0
- package/dist/runtime/agent-tree.js +74 -0
- package/dist/runtime/attachments.js +84 -0
- package/dist/runtime/brokered-executor.js +395 -0
- package/dist/runtime/context-status.js +76 -0
- package/dist/runtime/create-runtime.js +111 -0
- package/dist/runtime/model-profile.js +361 -0
- package/dist/runtime/output-store.js +137 -0
- package/dist/runtime/provider-attempts.js +185 -0
- package/dist/runtime/replay-buffer.js +153 -0
- package/dist/runtime/repo.js +95 -0
- package/dist/runtime/session-facade.js +135 -0
- package/dist/runtime/session-summary.js +125 -0
- package/dist/runtime/supervisor.js +262 -0
- package/dist/runtime/talos-composition.js +1006 -0
- package/dist/runtime/types.js +5 -0
- package/dist/runtime/usage-snapshot.js +82 -0
- package/dist/security/auto-classifier.js +38 -0
- package/dist/security/credential-free-environment.js +54 -0
- package/dist/security/evaluate.js +243 -0
- package/dist/security/execution-backends.js +236 -0
- package/dist/security/execution-broker.js +102 -0
- package/dist/security/forge-scan.js +74 -0
- package/dist/security/from-approval.js +39 -0
- package/dist/security/mxc-execution-backend.js +281 -0
- package/dist/security/permission-engine.js +138 -0
- package/dist/security/permission-explanation.js +54 -0
- package/dist/security/persist.js +179 -0
- package/dist/security/plugin-guard.js +230 -0
- package/dist/security/process-tree-evidence-store.js +74 -0
- package/dist/security/process-tree-probe.js +554 -0
- package/dist/security/project-resource-inventory.js +186 -0
- package/dist/security/project-trust-gate.js +38 -0
- package/dist/security/project-trust.js +367 -0
- package/dist/security/rule-parser.js +201 -0
- package/dist/security/shell-segmentation.js +68 -0
- package/dist/security/trust-authority.js +324 -0
- package/dist/security/types.js +1 -0
- package/dist/security/workspace-identity.js +102 -0
- package/dist/services/automation-facade.js +59 -0
- package/dist/services/forge-facade.js +77 -0
- package/dist/services/hook-facade.js +240 -0
- package/dist/services/index.js +16 -0
- package/dist/services/library-facade.js +174 -0
- package/dist/services/mcp-facade.js +348 -0
- package/dist/services/memory-facade.js +126 -0
- package/dist/services/notes-facade.js +157 -0
- package/dist/services/plugin-facade.js +308 -0
- package/dist/services/research-facade.js +110 -0
- package/dist/services/task-board-facade.js +236 -0
- package/dist/services/workflow-catalog.js +246 -0
- package/dist/sessions/export-format.js +98 -0
- package/dist/sessions/metadata-store.js +160 -0
- package/dist/sessions/share.js +122 -0
- package/dist/sessions/transfer.js +16 -0
- package/dist/subcommands.js +62 -0
- package/dist/tui/agent-roster.js +36 -0
- package/dist/tui/app.js +3761 -0
- package/dist/tui/approval.js +36 -0
- package/dist/tui/boot/boot-sequence.js +76 -0
- package/dist/tui/boot/cinematic.js +243 -0
- package/dist/tui/boot/desktop-logo.js +82 -0
- package/dist/tui/boot.js +3 -0
- package/dist/tui/busy-input.js +58 -0
- package/dist/tui/catalog-service.js +559 -0
- package/dist/tui/components/assistant-stream.js +1 -0
- package/dist/tui/components/command-menu.js +68 -0
- package/dist/tui/components/composer.js +219 -0
- package/dist/tui/components/diff.js +35 -0
- package/dist/tui/components/footer.js +48 -0
- package/dist/tui/components/header.js +6 -0
- package/dist/tui/components/markdown.js +305 -0
- package/dist/tui/components/status-indicator.js +32 -0
- package/dist/tui/components/terminal-shell.js +205 -0
- package/dist/tui/components/thinking-row.js +19 -0
- package/dist/tui/components/tool-row.js +97 -0
- package/dist/tui/components/transcript-virtualizer.js +165 -0
- package/dist/tui/components/transcript.js +43 -0
- package/dist/tui/diff-model.js +77 -0
- package/dist/tui/editor-history.js +21 -0
- package/dist/tui/editor.js +210 -0
- package/dist/tui/event-adapter.js +436 -0
- package/dist/tui/exit-output.js +58 -0
- package/dist/tui/external-editor.js +53 -0
- package/dist/tui/file-completion.js +89 -0
- package/dist/tui/focus-manager.js +5 -0
- package/dist/tui/highlight.js +30 -0
- package/dist/tui/input-router.js +18 -0
- package/dist/tui/interrupt.js +99 -0
- package/dist/tui/keybindings.js +194 -0
- package/dist/tui/keymap-resolver.js +91 -0
- package/dist/tui/launch-state.js +139 -0
- package/dist/tui/line-diff.js +57 -0
- package/dist/tui/live-activity.js +45 -0
- package/dist/tui/metrics.js +123 -0
- package/dist/tui/onboarding.js +36 -0
- package/dist/tui/overlays/agent-tree.js +39 -0
- package/dist/tui/overlays/approval-dialog.js +640 -0
- package/dist/tui/overlays/automation-center.js +51 -0
- package/dist/tui/overlays/checkpoint-picker.js +47 -0
- package/dist/tui/overlays/context-inspector.js +36 -0
- package/dist/tui/overlays/effort-line.js +110 -0
- package/dist/tui/overlays/forge-center.js +46 -0
- package/dist/tui/overlays/help-dialog.js +16 -0
- package/dist/tui/overlays/history-picker.js +37 -0
- package/dist/tui/overlays/hook-center.js +70 -0
- package/dist/tui/overlays/library-center.js +55 -0
- package/dist/tui/overlays/mcp-center.js +60 -0
- package/dist/tui/overlays/memory-center.js +63 -0
- package/dist/tui/overlays/model-picker.js +72 -0
- package/dist/tui/overlays/notes-center.js +53 -0
- package/dist/tui/overlays/overlay-host.js +8 -0
- package/dist/tui/overlays/plugin-center.js +76 -0
- package/dist/tui/overlays/provider-picker.js +145 -0
- package/dist/tui/overlays/queue-editor.js +32 -0
- package/dist/tui/overlays/research-center.js +59 -0
- package/dist/tui/overlays/scroll-window.js +234 -0
- package/dist/tui/overlays/session-picker.js +115 -0
- package/dist/tui/overlays/tasks-center.js +83 -0
- package/dist/tui/overlays/theme-picker.js +21 -0
- package/dist/tui/overlays/transcript-search.js +58 -0
- package/dist/tui/overlays/trust-center.js +29 -0
- package/dist/tui/overlays/workflow-center.js +46 -0
- package/dist/tui/project-file-index.js +214 -0
- package/dist/tui/project-references.js +85 -0
- package/dist/tui/project-trust-prompt.js +287 -0
- package/dist/tui/prompt-history-store.js +116 -0
- package/dist/tui/queue-store.js +110 -0
- package/dist/tui/regions/budget.js +59 -0
- package/dist/tui/regions/views.js +96 -0
- package/dist/tui/render-coordinator.js +148 -0
- package/dist/tui/render-scheduler.js +4 -0
- package/dist/tui/run.js +69 -0
- package/dist/tui/selection-list.js +29 -0
- package/dist/tui/session-controller.js +778 -0
- package/dist/tui/session-export.js +54 -0
- package/dist/tui/shell-input.js +35 -0
- package/dist/tui/shell-layout.js +48 -0
- package/dist/tui/shell-model.js +98 -0
- package/dist/tui/slash-commands.js +80 -0
- package/dist/tui/state.js +151 -0
- package/dist/tui/status-bar.js +125 -0
- package/dist/tui/status-view.js +40 -0
- package/dist/tui/terminal-capabilities.js +9 -0
- package/dist/tui/terminal-session.js +11 -0
- package/dist/tui/text-width.js +66 -0
- package/dist/tui/theme-catalog.js +25 -0
- package/dist/tui/theme-store.js +23 -0
- package/dist/tui/theme.js +23 -0
- package/dist/tui/tool-display.js +135 -0
- package/dist/tui/tool-facts.js +1 -0
- package/dist/tui/tools/bash-renderer.js +32 -0
- package/dist/tui/tools/change.js +61 -0
- package/dist/tui/tools/edit-renderer.js +17 -0
- package/dist/tui/tools/generic-renderer.js +13 -0
- package/dist/tui/tools/list-renderer.js +14 -0
- package/dist/tui/tools/read-renderer.js +13 -0
- package/dist/tui/tools/registry.js +20 -0
- package/dist/tui/tools/row-format.js +187 -0
- package/dist/tui/tools/search-renderer.js +38 -0
- package/dist/tui/tools/shared.js +97 -0
- package/dist/tui/tools/write-renderer.js +15 -0
- package/dist/tui/transcript-model.js +441 -0
- package/dist/tui/ui-preferences.js +79 -0
- package/dist/tui/usage-view.js +77 -0
- package/dist/tui/vim-mode.js +99 -0
- package/dist/update/check.js +15 -0
- package/dist/update/npm.js +51 -0
- package/dist/update/run.js +129 -0
- package/dist/version.js +2 -0
- package/dist/workspace/checkpoint-store.js +210 -0
- package/dist/workspace/checkpoint.js +413 -0
- package/dist/workspace/restore.js +232 -0
- package/package.json +63 -5
- package/vendor/context-engine/package.json +11 -0
- package/vendor/context-engine/src/compaction-planner.mjs +57 -0
- package/vendor/context-engine/src/contracts.mjs +48 -0
- package/vendor/context-engine/src/engine.mjs +445 -0
- package/vendor/context-engine/src/node/context-export.mjs +164 -0
- package/vendor/context-engine/src/node/legacy-import.mjs +92 -0
- package/vendor/context-engine/src/node/migrations/001-context.sql +126 -0
- package/vendor/context-engine/src/node/sqlite-store.mjs +85 -0
- package/vendor/context-engine/src/node/sqlite-worker.mjs +559 -0
- package/vendor/context-engine/src/profiles.mjs +10 -0
- package/vendor/context-engine/src/retrieval.mjs +104 -0
- package/vendor/context-engine/src/summary.mjs +97 -0
- package/vendor/context-engine/src/usage.mjs +34 -0
- package/vendor/harness-ui/package.json +38 -0
- package/vendor/harness-ui/src/acp-agent.mjs +350 -0
- package/vendor/harness-ui/src/agent-service.mjs +2188 -0
- package/vendor/harness-ui/src/agui-events.mjs +452 -0
- package/vendor/harness-ui/src/ambiente-solo-server.mjs +121 -0
- package/vendor/harness-ui/src/artifact-store.mjs +39 -0
- package/vendor/harness-ui/src/assistenza.mjs +123 -0
- package/vendor/harness-ui/src/automation-scheduler.mjs +69 -0
- package/vendor/harness-ui/src/automation-store.mjs +145 -0
- package/vendor/harness-ui/src/browser-annota.mjs +639 -0
- package/vendor/harness-ui/src/browser-frame.mjs +211 -0
- package/vendor/harness-ui/src/browser-proxy-universale.mjs +519 -0
- package/vendor/harness-ui/src/browser-proxy.mjs +87 -0
- package/vendor/harness-ui/src/browser-sessione-viva.mjs +329 -0
- package/vendor/harness-ui/src/browser-stream.mjs +445 -0
- package/vendor/harness-ui/src/browser-vivo.mjs +694 -0
- package/vendor/harness-ui/src/chat-image-attachments.mjs +72 -0
- package/vendor/harness-ui/src/config.mjs +697 -0
- package/vendor/harness-ui/src/contesto-del-progetto.mjs +385 -0
- package/vendor/harness-ui/src/context-asset-adapter.mjs +72 -0
- package/vendor/harness-ui/src/context-desktop-service.mjs +253 -0
- package/vendor/harness-ui/src/context-embedding-runtime.mjs +252 -0
- package/vendor/harness-ui/src/context-inference-scheduler.mjs +81 -0
- package/vendor/harness-ui/src/context-native-compaction.mjs +75 -0
- package/vendor/harness-ui/src/context-provider-adapter.mjs +141 -0
- package/vendor/harness-ui/src/context-runtime.mjs +118 -0
- package/vendor/harness-ui/src/context-token-counters.mjs +184 -0
- package/vendor/harness-ui/src/context-tool-catalog.mjs +86 -0
- package/vendor/harness-ui/src/context-tool-output.mjs +72 -0
- package/vendor/harness-ui/src/costo-elenco.mjs +252 -0
- package/vendor/harness-ui/src/custom-task.mjs +171 -0
- package/vendor/harness-ui/src/doctor.mjs +142 -0
- package/vendor/harness-ui/src/document-filename.mjs +97 -0
- package/vendor/harness-ui/src/document-generator.mjs +493 -0
- package/vendor/harness-ui/src/document-report.mjs +331 -0
- package/vendor/harness-ui/src/duckduckgo-search.mjs +155 -0
- package/vendor/harness-ui/src/elenco-profondo.mjs +337 -0
- package/vendor/harness-ui/src/favicon-proxy.mjs +113 -0
- package/vendor/harness-ui/src/forge-contract.mjs +221 -0
- package/vendor/harness-ui/src/frequent-dirs.mjs +134 -0
- package/vendor/harness-ui/src/generated-image-store.mjs +147 -0
- package/vendor/harness-ui/src/generation-idle.mjs +332 -0
- package/vendor/harness-ui/src/gguf-header.mjs +207 -0
- package/vendor/harness-ui/src/git-service.mjs +626 -0
- package/vendor/harness-ui/src/gitignore-elenco.mjs +604 -0
- package/vendor/harness-ui/src/harness-receipt-keypair.mjs +207 -0
- package/vendor/harness-ui/src/hf-direct-transfer.mjs +170 -0
- package/vendor/harness-ui/src/hf-hub-client.mjs +106 -0
- package/vendor/harness-ui/src/hf-image-proxy.mjs +105 -0
- package/vendor/harness-ui/src/hf-model-transfer.mjs +245 -0
- package/vendor/harness-ui/src/hook-registry.mjs +186 -0
- package/vendor/harness-ui/src/http-app.mjs +6259 -0
- package/vendor/harness-ui/src/http-lifecycle.mjs +132 -0
- package/vendor/harness-ui/src/id-archivio.mjs +27 -0
- package/vendor/harness-ui/src/image-generator.mjs +143 -0
- package/vendor/harness-ui/src/istruzioni-di-progetto.mjs +234 -0
- package/vendor/harness-ui/src/kernel/dist/kernelPerIlBanco.js +518 -0
- package/vendor/harness-ui/src/kernel/talosHarness.mjs +10437 -0
- package/vendor/harness-ui/src/library-policy-store.mjs +175 -0
- package/vendor/harness-ui/src/library-store.mjs +652 -0
- package/vendor/harness-ui/src/llama-server-supervisor.mjs +629 -0
- package/vendor/harness-ui/src/local-model-store.mjs +339 -0
- package/vendor/harness-ui/src/local-runtime-contract.mjs +66 -0
- package/vendor/harness-ui/src/local-runtime-events.mjs +44 -0
- package/vendor/harness-ui/src/local-runtime-llama-server.mjs +244 -0
- package/vendor/harness-ui/src/local-runtime-probe.mjs +401 -0
- package/vendor/harness-ui/src/machine-capacity.mjs +66 -0
- package/vendor/harness-ui/src/mappa-cartelle.mjs +491 -0
- package/vendor/harness-ui/src/mcp-client.mjs +98 -0
- package/vendor/harness-ui/src/mcp-registry.mjs +157 -0
- package/vendor/harness-ui/src/mcp-session.mjs +177 -0
- package/vendor/harness-ui/src/memory-store.mjs +227 -0
- package/vendor/harness-ui/src/model-catalog-models-dev.mjs +276 -0
- package/vendor/harness-ui/src/model-catalog.mjs +129 -0
- package/vendor/harness-ui/src/model-destination.mjs +189 -0
- package/vendor/harness-ui/src/modifica-ancorata.mjs +177 -0
- package/vendor/harness-ui/src/native-provider-adapter.mjs +205 -0
- package/vendor/harness-ui/src/notes-store.mjs +250 -0
- package/vendor/harness-ui/src/openai-compatible-runtime.mjs +428 -0
- package/vendor/harness-ui/src/openrouter-oauth.mjs +339 -0
- package/vendor/harness-ui/src/path-policy.mjs +442 -0
- package/vendor/harness-ui/src/plugin-registry.mjs +780 -0
- package/vendor/harness-ui/src/plugin-session.mjs +180 -0
- package/vendor/harness-ui/src/process-policy.mjs +345 -0
- package/vendor/harness-ui/src/prompt-enhancer-provider.mjs +94 -0
- package/vendor/harness-ui/src/provider-auth-cloud.mjs +95 -0
- package/vendor/harness-ui/src/provider-credential-store.mjs +541 -0
- package/vendor/harness-ui/src/provider-probe.mjs +582 -0
- package/vendor/harness-ui/src/provider-registry.mjs +1633 -0
- package/vendor/harness-ui/src/pty-terminal.mjs +312 -0
- package/vendor/harness-ui/src/public-problem.mjs +109 -0
- package/vendor/harness-ui/src/research/card.mjs +235 -0
- package/vendor/harness-ui/src/research/citations.mjs +142 -0
- package/vendor/harness-ui/src/research/collector.mjs +275 -0
- package/vendor/harness-ui/src/research/deposito-a-pezzi.mjs +139 -0
- package/vendor/harness-ui/src/research/dossier.mjs +114 -0
- package/vendor/harness-ui/src/research/esportazioni.mjs +560 -0
- package/vendor/harness-ui/src/research/fetch-cache.mjs +465 -0
- package/vendor/harness-ui/src/research/fidelity.mjs +122 -0
- package/vendor/harness-ui/src/research/independence.mjs +159 -0
- package/vendor/harness-ui/src/research/ledger.mjs +166 -0
- package/vendor/harness-ui/src/research/markdown-server.mjs +565 -0
- package/vendor/harness-ui/src/research/narration.mjs +181 -0
- package/vendor/harness-ui/src/research/open-cards.mjs +131 -0
- package/vendor/harness-ui/src/research/opposing.mjs +305 -0
- package/vendor/harness-ui/src/research/outline.mjs +111 -0
- package/vendor/harness-ui/src/research/page-budget.mjs +209 -0
- package/vendor/harness-ui/src/research/pdf.mjs +291 -0
- package/vendor/harness-ui/src/research/plan.mjs +301 -0
- package/vendor/harness-ui/src/research/raccolta-viva.mjs +452 -0
- package/vendor/harness-ui/src/research/recheck-document.mjs +69 -0
- package/vendor/harness-ui/src/research/recheck-history.mjs +192 -0
- package/vendor/harness-ui/src/research/recheck.mjs +194 -0
- package/vendor/harness-ui/src/research/report.mjs +203 -0
- package/vendor/harness-ui/src/research/run.mjs +527 -0
- package/vendor/harness-ui/src/research/synthesis.mjs +318 -0
- package/vendor/harness-ui/src/research/verification.mjs +572 -0
- package/vendor/harness-ui/src/research-orchestrator.mjs +2679 -0
- package/vendor/harness-ui/src/research-store.mjs +1133 -0
- package/vendor/harness-ui/src/runtime-build-manifest.mjs +26 -0
- package/vendor/harness-ui/src/runtime-contract.mjs +59 -0
- package/vendor/harness-ui/src/runtime-owner-adapter.mjs +1348 -0
- package/vendor/harness-ui/src/runtime-owner-contract.mjs +32 -0
- package/vendor/harness-ui/src/scheda-di-lavoro.mjs +249 -0
- package/vendor/harness-ui/src/search-source-store.mjs +172 -0
- package/vendor/harness-ui/src/session-registry.mjs +6095 -0
- package/vendor/harness-ui/src/session-store.mjs +220 -0
- package/vendor/harness-ui/src/sessione-pronta.mjs +73 -0
- package/vendor/harness-ui/src/setup-stato.mjs +31 -0
- package/vendor/harness-ui/src/sezioni-istruzioni.mjs +204 -0
- package/vendor/harness-ui/src/skill-registry.mjs +120 -0
- package/vendor/harness-ui/src/sse-replay-coalescente.mjs +0 -0
- package/vendor/harness-ui/src/static-files.mjs +96 -0
- package/vendor/harness-ui/src/stream-partition.mjs +123 -0
- package/vendor/harness-ui/src/subagent-orchestrator.mjs +453 -0
- package/vendor/harness-ui/src/task-catalog.mjs +65 -0
- package/vendor/harness-ui/src/tasks-store.mjs +220 -0
- package/vendor/harness-ui/src/terminal-registry.mjs +312 -0
- package/vendor/harness-ui/src/terminal-ws.mjs +170 -0
- package/vendor/harness-ui/src/tool-forge-store.mjs +299 -0
- package/vendor/harness-ui/src/tool-schema-normalize.mjs +100 -0
- package/vendor/harness-ui/src/usage-cache.mjs +315 -0
- package/vendor/harness-ui/src/workspace-browser.mjs +213 -0
- package/vendor/harness-ui/src/workspace-context.mjs +124 -0
- package/vendor/harness-ui/src/workspace-disk.mjs +62 -0
- package/vendor/harness-ui/src/workspace-files.mjs +589 -0
- package/vendor/harness-ui/src/workspace-info.mjs +189 -0
- package/vendor/harness-ui/src/workspace-launch-store.mjs +150 -0
- package/vendor/harness-ui/src/workspace-tree.mjs +67 -0
- package/vendor/harness-ui/src/workspace-watcher.mjs +161 -0
- package/vendor/manifest.json +170 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { mkdir, writeFile, readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
function discoNode(o) {
|
|
4
|
+
/*
|
|
5
|
+
* ⛔ 08/09/2026 — MISURATO, non dedotto: su Windows `"C:"` non è la radice del disco, è il
|
|
6
|
+
* percorso relativo al drive, cioè la DIRECTORY CORRENTE del processo.
|
|
7
|
+
* readdir("C:") → 34 voci: .automations .hooks-trust .local-models … (cioè harness-ui/)
|
|
8
|
+
* readdir("C:\\") → 47 voci: $RECYCLE.BIN AMD .cache … (la radice vera)
|
|
9
|
+
* Lo `replace` qui sotto toglieva la barra finale — giusto per `…/progetto/` → `…/progetto`,
|
|
10
|
+
* sbagliato per `C:\\` → `C:` — e una sessione con la radice come workspace finiva a leggere la
|
|
11
|
+
* cartella del server. Trovato mentre curavo le sessioni delegate che giravano in `C:\\`:
|
|
12
|
+
* quelle chiedevano `cerca` e ricevevano i 13 file del server, senza che niente lo dicesse.
|
|
13
|
+
*
|
|
14
|
+
* ⛔ Il difetto NON è in `join`, che normalizza `join("C:", x)` in `C:\\x`: è nel ramo di
|
|
15
|
+
* `dentro()` col percorso vuoto, che restituisce la radice grezza senza passare da `join`.
|
|
16
|
+
* (La prima ipotesi accusava `join`: la misura l'ha scagionato.)
|
|
17
|
+
*/
|
|
18
|
+
const spogliata = o.radice.replace(/[\\/]+$/, "");
|
|
19
|
+
const radice = /^[A-Za-z]:$/.test(spogliata) ? spogliata + "\\" : spogliata;
|
|
20
|
+
// Un percorso assoluto identifica il file richiesto, non un figlio della radice.
|
|
21
|
+
// Le autorizzazioni appartengono al kernel chiamante, prima della scrittura.
|
|
22
|
+
const dentro = (percorso) => percorso ? resolve(radice, percorso) : radice;
|
|
23
|
+
return {
|
|
24
|
+
async elenca(cartella) {
|
|
25
|
+
const voci = await readdir(dentro(cartella), { withFileTypes: true });
|
|
26
|
+
return Promise.all(voci.map(async (v) => {
|
|
27
|
+
const cartellaVera = v.isDirectory();
|
|
28
|
+
let byte = 0;
|
|
29
|
+
if (!cartellaVera) {
|
|
30
|
+
try {
|
|
31
|
+
byte = (await stat(join(dentro(cartella), v.name))).size;
|
|
32
|
+
} catch {
|
|
33
|
+
byte = 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { nome: v.name, cartella: cartellaVera, byte };
|
|
37
|
+
}));
|
|
38
|
+
},
|
|
39
|
+
async leggi(percorso) {
|
|
40
|
+
return readFile(dentro(percorso), "utf8");
|
|
41
|
+
},
|
|
42
|
+
/*
|
|
43
|
+
* ⛔⛔⛔ BC-11, 11/09/2026 — `modalita` E' IL TERZO ARGOMENTO, ED E' OPZIONALE APPOSTA.
|
|
44
|
+
*
|
|
45
|
+
* `'nuovo'` (assente, o qualunque altro valore) e' il comportamento di sempre, byte per byte:
|
|
46
|
+
* `writeFile` con il flag implicito `'w'`. `'accoda'` aggiunge in coda con il flag `'a'`.
|
|
47
|
+
*
|
|
48
|
+
* ⛔ MAI leggi-concatena-riscrivi: perderebbe in silenzio la scrittura di chiunque sia passato
|
|
49
|
+
* in mezzo. Node.js `fs` (letto 11/09/2026): su Windows `flock` non esiste, e una `write` con
|
|
50
|
+
* flag `'a'` e' la via per un'aggiunta atomica per singola chiamata. E' la stessa scelta gia'
|
|
51
|
+
* presa in `harness-ui/src/workspace-files.mjs` per `document_create`.
|
|
52
|
+
*
|
|
53
|
+
* ⛔ Un percorso VUOTO non e' piu' la radice, ed e' il bug EISDIR di BC-11 chiuso alla fonte:
|
|
54
|
+
* `dentro('')` torna la radice — legittimo per `elenca('')`, mai per una SCRITTURA, dove
|
|
55
|
+
* produceva `EISDIR: illegal operation on a directory` su una cartella. Il kernel lo ferma
|
|
56
|
+
* gia' prima con un messaggio che nomina il campo mancante; questa e' la seconda rete, per
|
|
57
|
+
* chiunque altro usi `discoNode` (il banco incluso).
|
|
58
|
+
*
|
|
59
|
+
* ⛔⛔ Questo file e' un BUNDLE rigenerato dal repo del kernel dell'owner: una rigenerazione che
|
|
60
|
+
* non porti anche questa modifica farebbe sparire l'aggiunta MENTRE lo schema di `scrivi`
|
|
61
|
+
* continua a prometterla — una bugia allo strumento, la cosa peggiore fra tutte. Per questo
|
|
62
|
+
* `harness-ui/tests/scrivi-percorso-e-modalita.test.mjs` prova `discoNode` DIRETTAMENTE: se il
|
|
63
|
+
* terzo argomento sparisce, la suite diventa rossa invece di mentire in silenzio.
|
|
64
|
+
*/
|
|
65
|
+
async scrivi(percorso, testo, modalita = "nuovo") {
|
|
66
|
+
if (!percorso) throw new Error("scrivi: percorso vuoto — una scrittura senza nome di file finirebbe sulla radice della sessione");
|
|
67
|
+
await mkdir(dirname(dentro(percorso)), { recursive: true });
|
|
68
|
+
await writeFile(dentro(percorso), testo, modalita === "accoda" ? { encoding: "utf8", flag: "a" } : "utf8");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const ESTENSIONI_SORGENTE = Object.freeze([".mjs", ".js", ".cjs", ".jsx", ".ts", ".tsx", ".mts", ".cts"]);
|
|
73
|
+
let compilatore = null;
|
|
74
|
+
async function caricaCompilatore() {
|
|
75
|
+
if (!compilatore) compilatore = (await import("typescript")).default ?? await import("typescript");
|
|
76
|
+
return compilatore;
|
|
77
|
+
}
|
|
78
|
+
function estensioneDi(nome) {
|
|
79
|
+
const punto = nome.lastIndexOf(".");
|
|
80
|
+
return punto < 0 ? "" : nome.slice(punto).toLowerCase();
|
|
81
|
+
}
|
|
82
|
+
function genereDi(ts, nomeFile) {
|
|
83
|
+
switch (estensioneDi(nomeFile)) {
|
|
84
|
+
case ".ts":
|
|
85
|
+
case ".mts":
|
|
86
|
+
case ".cts":
|
|
87
|
+
return ts.ScriptKind.TS;
|
|
88
|
+
case ".tsx":
|
|
89
|
+
return ts.ScriptKind.TSX;
|
|
90
|
+
case ".jsx":
|
|
91
|
+
return ts.ScriptKind.JSX;
|
|
92
|
+
default:
|
|
93
|
+
return ts.ScriptKind.JS;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function dichiaratiIn(testo, nomeFile) {
|
|
97
|
+
if (!ESTENSIONI_SORGENTE.includes(estensioneDi(nomeFile))) {
|
|
98
|
+
return {
|
|
99
|
+
copertura: "nonSupportato",
|
|
100
|
+
nomi: /* @__PURE__ */ new Set(),
|
|
101
|
+
perche: `estensione ${estensioneDi(nomeFile) || "(nessuna)"}`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const ts = await caricaCompilatore();
|
|
105
|
+
return dichiaratiConCompilatore(ts, testo, nomeFile);
|
|
106
|
+
}
|
|
107
|
+
function dichiaratiConCompilatore(ts, testo, nomeFile) {
|
|
108
|
+
if (!ESTENSIONI_SORGENTE.includes(estensioneDi(nomeFile))) {
|
|
109
|
+
return { copertura: "nonSupportato", nomi: /* @__PURE__ */ new Set(), perche: `estensione ${estensioneDi(nomeFile)}` };
|
|
110
|
+
}
|
|
111
|
+
const sorgente = ts.createSourceFile(
|
|
112
|
+
nomeFile,
|
|
113
|
+
testo,
|
|
114
|
+
ts.ScriptTarget.Latest,
|
|
115
|
+
true,
|
|
116
|
+
genereDi(ts, nomeFile)
|
|
117
|
+
);
|
|
118
|
+
const rotture = sorgente.parseDiagnostics ?? [];
|
|
119
|
+
if (rotture.length > 0) {
|
|
120
|
+
return {
|
|
121
|
+
copertura: "sorgenteInvalida",
|
|
122
|
+
nomi: /* @__PURE__ */ new Set(),
|
|
123
|
+
perche: `${rotture.length} errori di sintassi`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const genere = genereDi(ts, nomeFile);
|
|
127
|
+
if (genere === ts.ScriptKind.JS || genere === ts.ScriptKind.JSX) {
|
|
128
|
+
const soloTypeScript = contieneCostruttiTypeScript(ts, sorgente);
|
|
129
|
+
if (soloTypeScript) {
|
|
130
|
+
return { copertura: "sorgenteInvalida", nomi: /* @__PURE__ */ new Set(), perche: "costrutti TypeScript in un file JavaScript" };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { copertura: "completa", nomi: raccogliDichiarazioni(ts, sorgente) };
|
|
134
|
+
}
|
|
135
|
+
function tipoAnnotato(ts, nodo) {
|
|
136
|
+
const forse = nodo.type;
|
|
137
|
+
return forse !== void 0 && typeof forse === "object" && forse !== null && ts.isTypeNode(forse);
|
|
138
|
+
}
|
|
139
|
+
function contieneCostruttiTypeScript(ts, sorgente) {
|
|
140
|
+
let trovato = false;
|
|
141
|
+
const visita = (nodo) => {
|
|
142
|
+
if (trovato) return;
|
|
143
|
+
if (ts.isInterfaceDeclaration(nodo) || ts.isTypeAliasDeclaration(nodo) || ts.isEnumDeclaration(nodo) || ts.isModuleDeclaration(nodo) || ts.isAsExpression(nodo) || ts.isTypeAssertionExpression(nodo) || ts.isNonNullExpression(nodo) || ts.isTypeParameterDeclaration(nodo) || tipoAnnotato(ts, nodo)) {
|
|
144
|
+
trovato = true;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
ts.forEachChild(nodo, visita);
|
|
148
|
+
};
|
|
149
|
+
ts.forEachChild(sorgente, visita);
|
|
150
|
+
return trovato;
|
|
151
|
+
}
|
|
152
|
+
function raccogliDichiarazioni(ts, sorgente) {
|
|
153
|
+
const nomi = /* @__PURE__ */ new Set();
|
|
154
|
+
const prendi = (nodo) => {
|
|
155
|
+
if (!nodo) return;
|
|
156
|
+
if (ts.isIdentifier(nodo)) {
|
|
157
|
+
nomi.add(nodo.text);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (ts.isObjectBindingPattern(nodo) || ts.isArrayBindingPattern(nodo)) {
|
|
161
|
+
for (const el of nodo.elements) {
|
|
162
|
+
if (!ts.isOmittedExpression(el)) prendi(el.name);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const visita = (nodo) => {
|
|
167
|
+
if (ts.isFunctionDeclaration(nodo) || ts.isClassDeclaration(nodo)) prendi(nodo.name);
|
|
168
|
+
else if (ts.isVariableDeclaration(nodo)) prendi(nodo.name);
|
|
169
|
+
else if (ts.isTypeAliasDeclaration(nodo) || ts.isInterfaceDeclaration(nodo) || ts.isEnumDeclaration(nodo) || ts.isModuleDeclaration(nodo)) prendi(nodo.name);
|
|
170
|
+
else if (ts.isMethodDeclaration(nodo) || ts.isPropertyDeclaration(nodo)) prendi(nodo.name);
|
|
171
|
+
else if (ts.isExportSpecifier(nodo)) prendi(nodo.name);
|
|
172
|
+
else if (ts.isImportSpecifier(nodo)) prendi(nodo.name);
|
|
173
|
+
else if (ts.isImportClause(nodo)) prendi(nodo.name);
|
|
174
|
+
else if (ts.isNamespaceImport(nodo)) prendi(nodo.name);
|
|
175
|
+
ts.forEachChild(nodo, visita);
|
|
176
|
+
};
|
|
177
|
+
ts.forEachChild(sorgente, visita);
|
|
178
|
+
return nomi;
|
|
179
|
+
}
|
|
180
|
+
const ILLEGGIBILE = "sorgenteInvalida";
|
|
181
|
+
async function costruisciCatalogo(sorgenti, opzioni) {
|
|
182
|
+
const precedente = opzioni?.precedente;
|
|
183
|
+
const perFile = /* @__PURE__ */ new Map();
|
|
184
|
+
const perNome = /* @__PURE__ */ new Map();
|
|
185
|
+
const testi = /* @__PURE__ */ new Map();
|
|
186
|
+
for (const { percorso, testo } of sorgenti) {
|
|
187
|
+
const gia = precedente?.perFile.get(percorso);
|
|
188
|
+
if (gia && precedente.testi.get(percorso) === testo) {
|
|
189
|
+
perFile.set(percorso, gia);
|
|
190
|
+
for (const nome of gia.nomi) {
|
|
191
|
+
const dove = perNome.get(nome);
|
|
192
|
+
if (dove) dove.push(percorso);
|
|
193
|
+
else perNome.set(nome, [percorso]);
|
|
194
|
+
}
|
|
195
|
+
testi.set(percorso, testo);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (testo === null) {
|
|
199
|
+
perFile.set(percorso, { copertura: ILLEGGIBILE, nomi: /* @__PURE__ */ new Set() });
|
|
200
|
+
testi.set(percorso, null);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const esito = await dichiaratiIn(testo, percorso);
|
|
204
|
+
perFile.set(percorso, { copertura: esito.copertura, nomi: esito.nomi });
|
|
205
|
+
testi.set(percorso, testo);
|
|
206
|
+
for (const nome of esito.nomi) {
|
|
207
|
+
const dove = perNome.get(nome);
|
|
208
|
+
if (dove) dove.push(percorso);
|
|
209
|
+
else perNome.set(nome, [percorso]);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { perFile, perNome, testi, elenco: opzioni?.elenco ?? "completo" };
|
|
213
|
+
}
|
|
214
|
+
function ambitoEUnFile(ambito) {
|
|
215
|
+
return !ambito.endsWith("/") && /\.[a-z0-9]+$/i.test(ambito);
|
|
216
|
+
}
|
|
217
|
+
function dentroAmbito(percorso, ambito) {
|
|
218
|
+
if (ambitoEUnFile(ambito)) return percorso === ambito;
|
|
219
|
+
const cartella = ambito.endsWith("/") ? ambito : `${ambito}/`;
|
|
220
|
+
return percorso.startsWith(cartella);
|
|
221
|
+
}
|
|
222
|
+
function risolviSimbolo(catalogo, nome, ambito) {
|
|
223
|
+
const fatto = { famiglia: "symbol-declared", nome, ambito };
|
|
224
|
+
const parziale = catalogo.elenco === "completo" ? null : catalogo.elenco.troncato;
|
|
225
|
+
const file = [...catalogo.perFile.keys()].filter((p) => dentroAmbito(p, ambito));
|
|
226
|
+
if (file.length === 0) {
|
|
227
|
+
if (parziale) return { stato: "ignoto", perche: `the workspace listing is incomplete (${parziale}), so nothing can be ruled out in ${ambito}`, fatto };
|
|
228
|
+
if (ambitoEUnFile(ambito)) {
|
|
229
|
+
return { stato: "assente", perche: `"${nome}" is not declared in ${ambito} (the file does not exist)`, copertura: "completa", fatto };
|
|
230
|
+
}
|
|
231
|
+
return { stato: "ignoto", perche: `nothing is known about ${ambito}`, fatto };
|
|
232
|
+
}
|
|
233
|
+
const testimoni = (catalogo.perNome.get(nome) ?? []).filter((p) => dentroAmbito(p, ambito));
|
|
234
|
+
if (testimoni.length > 0) return { stato: "presente", fatto: { ...fatto, ambito: testimoni[0] } };
|
|
235
|
+
const scoperti = file.filter((f) => catalogo.perFile.get(f).copertura !== "completa");
|
|
236
|
+
if (scoperti.length > 0) {
|
|
237
|
+
const perche = catalogo.perFile.get(scoperti[0]).copertura;
|
|
238
|
+
return {
|
|
239
|
+
stato: "ignoto",
|
|
240
|
+
perche: `${scoperti.length} file(s) in ${ambito} could not be read (${perche}), starting with ${scoperti[0]}`,
|
|
241
|
+
fatto
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (parziale) {
|
|
245
|
+
return {
|
|
246
|
+
stato: "ignoto",
|
|
247
|
+
perche: `every listed file in ${ambito} was read, but the listing itself is incomplete (${parziale})`,
|
|
248
|
+
fatto
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const copertura = "completa";
|
|
252
|
+
return { stato: "assente", perche: `"${nome}" is not declared anywhere in ${ambito}`, copertura, fatto };
|
|
253
|
+
}
|
|
254
|
+
const CARTELLE_SALTATE = /* @__PURE__ */ new Set([
|
|
255
|
+
"node_modules",
|
|
256
|
+
".git",
|
|
257
|
+
"dist",
|
|
258
|
+
"build",
|
|
259
|
+
"out",
|
|
260
|
+
"coverage",
|
|
261
|
+
".svelte-kit",
|
|
262
|
+
".next",
|
|
263
|
+
".nuxt",
|
|
264
|
+
".cache",
|
|
265
|
+
".gradle",
|
|
266
|
+
".idea",
|
|
267
|
+
".vscode",
|
|
268
|
+
"android",
|
|
269
|
+
"ios",
|
|
270
|
+
"target",
|
|
271
|
+
"vendor",
|
|
272
|
+
"__pycache__"
|
|
273
|
+
]);
|
|
274
|
+
const TETTO_BYTE = 8 * 1024 * 1024;
|
|
275
|
+
const TETTO_FILE = 1500;
|
|
276
|
+
function fontiDaDisco(disco, opzioni = {}) {
|
|
277
|
+
const tettoByte = opzioni.tettoByte ?? TETTO_BYTE;
|
|
278
|
+
const tettoFile = opzioni.tettoFile ?? TETTO_FILE;
|
|
279
|
+
const salta = opzioni.salta ?? CARTELLE_SALTATE;
|
|
280
|
+
let ultimoLetto = /* @__PURE__ */ new Map();
|
|
281
|
+
return {
|
|
282
|
+
async leggiSpazio() {
|
|
283
|
+
const sorgenti = [];
|
|
284
|
+
let byte = 0;
|
|
285
|
+
let elenco = "completo";
|
|
286
|
+
const scendi = async (cartella) => {
|
|
287
|
+
if (elenco !== "completo") return;
|
|
288
|
+
let voci;
|
|
289
|
+
try {
|
|
290
|
+
voci = await disco.elenca(cartella);
|
|
291
|
+
} catch (e) {
|
|
292
|
+
elenco = { troncato: `"${cartella || "."}" could not be listed (${messaggio(e)})` };
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
for (const voce of voci) {
|
|
296
|
+
if (elenco !== "completo") return;
|
|
297
|
+
const percorso = cartella ? `${cartella}/${voce.nome}` : voce.nome;
|
|
298
|
+
if (voce.cartella) {
|
|
299
|
+
if (salta.has(voce.nome)) continue;
|
|
300
|
+
await scendi(percorso);
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (!ESTENSIONI_SORGENTE.includes(estensioneDi(percorso))) continue;
|
|
304
|
+
if (sorgenti.length >= tettoFile) {
|
|
305
|
+
elenco = { troncato: `the workspace has more than ${tettoFile} source files` };
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (byte + voce.byte > tettoByte) {
|
|
309
|
+
elenco = { troncato: `the workspace is larger than ${Math.round(tettoByte / 1024 / 1024)} MB of source` };
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
byte += voce.byte;
|
|
313
|
+
try {
|
|
314
|
+
sorgenti.push({ percorso, testo: await disco.leggi(percorso) });
|
|
315
|
+
} catch {
|
|
316
|
+
sorgenti.push({ percorso, testo: null });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
await scendi("");
|
|
321
|
+
ultimoLetto = new Map(sorgenti.map((s) => [s.percorso, s.testo]));
|
|
322
|
+
return { sorgenti, elenco };
|
|
323
|
+
},
|
|
324
|
+
async scrivi(sorgenti) {
|
|
325
|
+
for (const { percorso, testo } of sorgenti) {
|
|
326
|
+
if (testo === null) continue;
|
|
327
|
+
if (ultimoLetto.get(percorso) === testo) continue;
|
|
328
|
+
await disco.scrivi(percorso, testo);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function messaggio(e) {
|
|
334
|
+
return e instanceof Error ? e.message : String(e);
|
|
335
|
+
}
|
|
336
|
+
const CODICI_RIFERIMENTO_MANCANTE = Object.freeze(/* @__PURE__ */ new Set([
|
|
337
|
+
2304,
|
|
338
|
+
// Cannot find name 'X'
|
|
339
|
+
2305,
|
|
340
|
+
// Module 'Y' has no exported member 'X' ← trovato da un test, non a memoria
|
|
341
|
+
2307,
|
|
342
|
+
// Cannot find module 'X'
|
|
343
|
+
2339,
|
|
344
|
+
// Property 'X' does not exist on type 'Y'
|
|
345
|
+
2551,
|
|
346
|
+
// Property 'X' does not exist on type 'Y'. Did you mean 'Z'?
|
|
347
|
+
2552,
|
|
348
|
+
// Cannot find name 'X'. Did you mean 'Y'?
|
|
349
|
+
2503,
|
|
350
|
+
// Cannot find namespace 'X'
|
|
351
|
+
2724
|
|
352
|
+
// 'Y' has no exported member named 'X'. Did you mean 'Z'?
|
|
353
|
+
]));
|
|
354
|
+
function improntaDi(ts, d) {
|
|
355
|
+
return {
|
|
356
|
+
codice: d.code,
|
|
357
|
+
file: d.file ? d.file.fileName : null,
|
|
358
|
+
messaggio: ts.flattenDiagnosticMessageText(d.messageText, " ").trim()
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
const SEPARATORE = String.fromCharCode(31);
|
|
362
|
+
const chiaveDi = (i) => `${i.codice}${SEPARATORE}${i.file ?? ""}${SEPARATORE}${i.messaggio}`;
|
|
363
|
+
function introdotte(prima, dopo) {
|
|
364
|
+
const conto = /* @__PURE__ */ new Map();
|
|
365
|
+
for (const d of prima) {
|
|
366
|
+
const k = chiaveDi(d);
|
|
367
|
+
conto.set(k, (conto.get(k) ?? 0) + 1);
|
|
368
|
+
}
|
|
369
|
+
const nuove = [];
|
|
370
|
+
for (const d of dopo) {
|
|
371
|
+
const k = chiaveDi(d);
|
|
372
|
+
const restano = conto.get(k) ?? 0;
|
|
373
|
+
if (restano > 0) conto.set(k, restano - 1);
|
|
374
|
+
else nuove.push(d);
|
|
375
|
+
}
|
|
376
|
+
return nuove;
|
|
377
|
+
}
|
|
378
|
+
function hostInMemoria(ts, file, libreria) {
|
|
379
|
+
const trova = (f) => file.get(f) ?? libreria?.file.get(f);
|
|
380
|
+
return {
|
|
381
|
+
fileExists: (f) => trova(f) !== void 0,
|
|
382
|
+
readFile: (f) => trova(f),
|
|
383
|
+
getSourceFile: (f, target) => {
|
|
384
|
+
const testo = trova(f);
|
|
385
|
+
return testo === void 0 ? void 0 : ts.createSourceFile(f, testo, target, true, genereDi(ts, f));
|
|
386
|
+
},
|
|
387
|
+
getDefaultLibFileName: () => libreria?.predefinita ?? "/lib.d.ts",
|
|
388
|
+
/*
|
|
389
|
+
* ⛔ Il compilatore chiede le librerie per nome NUDO: senza una
|
|
390
|
+
* posizione vuota, i riferimenti `/// <reference lib="..." />` dentro i
|
|
391
|
+
* file di libreria non si risolvono, e si torna al falso positivo.
|
|
392
|
+
*/
|
|
393
|
+
getDefaultLibLocation: () => "",
|
|
394
|
+
writeFile: () => {
|
|
395
|
+
},
|
|
396
|
+
getCurrentDirectory: () => "/",
|
|
397
|
+
getCanonicalFileName: (f) => f,
|
|
398
|
+
useCaseSensitiveFileNames: () => true,
|
|
399
|
+
getNewLine: () => "\n"
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const SOPPRESSIONI = /@ts-(ignore|expect-error|nocheck)\b/g;
|
|
403
|
+
function contaSoppressioni(sorgenti) {
|
|
404
|
+
const per = /* @__PURE__ */ new Map();
|
|
405
|
+
for (const { percorso, testo } of sorgenti) {
|
|
406
|
+
if (testo === null) continue;
|
|
407
|
+
const quante = testo.match(SOPPRESSIONI)?.length ?? 0;
|
|
408
|
+
if (quante > 0) per.set(percorso, quante);
|
|
409
|
+
}
|
|
410
|
+
return per;
|
|
411
|
+
}
|
|
412
|
+
function soppressioniIntrodotte(prima, dopo) {
|
|
413
|
+
const eranO = contaSoppressioni(prima);
|
|
414
|
+
const fuori = [];
|
|
415
|
+
for (const [percorso, adesso] of contaSoppressioni(dopo)) {
|
|
416
|
+
const differenza = adesso - (eranO.get(percorso) ?? 0);
|
|
417
|
+
if (differenza > 0) fuori.push({ percorso, quante: differenza });
|
|
418
|
+
}
|
|
419
|
+
return fuori;
|
|
420
|
+
}
|
|
421
|
+
async function riferimentiNonRisolti(sorgenti, libreria) {
|
|
422
|
+
const ts = await caricaCompilatore();
|
|
423
|
+
const file = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const { percorso, testo } of sorgenti) {
|
|
425
|
+
if (testo === null) continue;
|
|
426
|
+
if (!ESTENSIONI_SORGENTE.includes(estensioneDi(percorso))) continue;
|
|
427
|
+
file.set(percorso, testo);
|
|
428
|
+
}
|
|
429
|
+
if (file.size === 0) return [];
|
|
430
|
+
const program = ts.createProgram(
|
|
431
|
+
[...file.keys()],
|
|
432
|
+
{ noEmit: true, skipLibCheck: true, allowJs: true, checkJs: false },
|
|
433
|
+
hostInMemoria(ts, file, libreria)
|
|
434
|
+
);
|
|
435
|
+
const fuori = [];
|
|
436
|
+
for (const nome of file.keys()) {
|
|
437
|
+
const sorgente = program.getSourceFile(nome);
|
|
438
|
+
if (!sorgente) continue;
|
|
439
|
+
for (const d of program.getSemanticDiagnostics(sorgente)) {
|
|
440
|
+
if (CODICI_RIFERIMENTO_MANCANTE.has(d.code)) fuori.push(improntaDi(ts, d));
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return fuori;
|
|
444
|
+
}
|
|
445
|
+
async function cancelloSemantico(prima, dopo, libreria) {
|
|
446
|
+
const fatto = { famiglia: "introduced-references", nome: "modifica candidata" };
|
|
447
|
+
let baseline;
|
|
448
|
+
let candidato;
|
|
449
|
+
try {
|
|
450
|
+
baseline = await riferimentiNonRisolti(prima, libreria);
|
|
451
|
+
candidato = await riferimentiNonRisolti(dopo, libreria);
|
|
452
|
+
} catch (errore) {
|
|
453
|
+
return {
|
|
454
|
+
stato: "ignoto",
|
|
455
|
+
perche: `the semantic guard could not run (${errore instanceof Error ? errore.message.slice(0, 80) : "errore"})`,
|
|
456
|
+
fatto
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
const zittite = soppressioniIntrodotte(prima, dopo);
|
|
460
|
+
if (zittite.length > 0) {
|
|
461
|
+
return {
|
|
462
|
+
stato: "assente",
|
|
463
|
+
perche: `the change adds ${zittite.reduce((s, z) => s + z.quante, 0)} new compiler-error suppression(s) (@ts-ignore / @ts-expect-error) in ${zittite.map((z) => z.percorso).join(", ")}. Silencing an error is not fixing it.`,
|
|
464
|
+
copertura: "completa",
|
|
465
|
+
fatto
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
const nuove = introdotte(baseline, candidato);
|
|
469
|
+
if (nuove.length === 0) return { stato: "presente", fatto };
|
|
470
|
+
return {
|
|
471
|
+
stato: "assente",
|
|
472
|
+
perche: `the change introduces ${nuove.length} unresolved reference(s): ${nuove.slice(0, 3).map((d) => d.messaggio).join("; ")}`,
|
|
473
|
+
/*
|
|
474
|
+
* ⛔ `completa` perché il confronto è fatto sullo STESSO insieme di file
|
|
475
|
+
* con lo STESSO compilatore: ciò che è nuovo è nuovo per costruzione.
|
|
476
|
+
* Non dice che il progetto sia corretto — dice che la modifica non ha
|
|
477
|
+
* aggiunto riferimenti rotti fra quelli che sappiamo vedere.
|
|
478
|
+
*/
|
|
479
|
+
copertura: "completa",
|
|
480
|
+
fatto
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
const CATENA_ES2022 = Object.freeze([
|
|
484
|
+
"lib.es5.d.ts",
|
|
485
|
+
"lib.es2015.d.ts",
|
|
486
|
+
"lib.es2016.d.ts",
|
|
487
|
+
"lib.es2017.d.ts",
|
|
488
|
+
"lib.es2018.d.ts",
|
|
489
|
+
"lib.es2019.d.ts",
|
|
490
|
+
"lib.es2020.d.ts",
|
|
491
|
+
"lib.es2021.d.ts",
|
|
492
|
+
"lib.es2022.d.ts",
|
|
493
|
+
"lib.decorators.d.ts",
|
|
494
|
+
"lib.decorators.legacy.d.ts"
|
|
495
|
+
]);
|
|
496
|
+
let inMano = null;
|
|
497
|
+
async function componiLibreria(leggi, nomi = CATENA_ES2022) {
|
|
498
|
+
const file = /* @__PURE__ */ new Map();
|
|
499
|
+
for (const nome of nomi) {
|
|
500
|
+
const testo = await leggi(nome);
|
|
501
|
+
if (testo !== null) file.set(nome, testo);
|
|
502
|
+
}
|
|
503
|
+
return { predefinita: "lib.es2022.d.ts", file };
|
|
504
|
+
}
|
|
505
|
+
async function libreriaStandard(leggi) {
|
|
506
|
+
if (!inMano) inMano = await componiLibreria(leggi);
|
|
507
|
+
return inMano;
|
|
508
|
+
}
|
|
509
|
+
export {
|
|
510
|
+
ESTENSIONI_SORGENTE,
|
|
511
|
+
cancelloSemantico,
|
|
512
|
+
costruisciCatalogo,
|
|
513
|
+
dichiaratiIn,
|
|
514
|
+
discoNode,
|
|
515
|
+
fontiDaDisco,
|
|
516
|
+
libreriaStandard,
|
|
517
|
+
risolviSimbolo
|
|
518
|
+
};
|