mixdog 0.9.152 → 0.9.154
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/LICENSES/browser-import-NOTICE.txt +11 -0
- package/NOTICE.md +11 -0
- package/README.md +8 -10
- package/package.json +19 -3
- package/scripts/computer-task-cost-report.mjs +144 -0
- package/scripts/run-office-live-tests.mjs +32 -0
- package/src/agents/front-worker/AGENT.md +13 -0
- package/src/agents/front-worker/agent.json +6 -0
- package/src/agents/heavy-worker/AGENT.md +10 -11
- package/src/agents/heavy-worker/agent.json +1 -1
- package/src/agents/maintainer/AGENT.md +0 -2
- package/src/agents/reviewer/AGENT.md +9 -13
- package/src/agents/reviewer/agent.json +1 -1
- package/src/agents/security/AGENT.md +14 -0
- package/src/agents/security/agent.json +6 -0
- package/src/agents/worker/AGENT.md +8 -8
- package/src/agents/worker/agent.json +1 -1
- package/src/agents/writer/AGENT.md +14 -0
- package/src/agents/writer/agent.json +6 -0
- package/src/rules/agent/00-common.md +4 -7
- package/src/rules/lead/01-general.md +0 -3
- package/src/rules/shared/10-tool-workflow.md +10 -2
- package/src/rules/shared/60-verification.md +2 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
- package/src/runtime/agent/orchestrator/config.mjs +7 -2
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
- package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
- package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
- package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
- package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
- package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
- package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
- package/src/runtime/attachments/pdf-extract.mjs +3 -0
- package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
- package/src/runtime/browser-bridge/action-schema.mjs +251 -0
- package/src/runtime/browser-bridge/client.mjs +75 -26
- package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
- package/src/runtime/computer-bridge/action-schema.mjs +653 -0
- package/src/runtime/computer-bridge/client.mjs +211 -28
- package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
- package/src/runtime/office/assurance-benchmark.mjs +358 -0
- package/src/runtime/office/assurance.mjs +833 -0
- package/src/runtime/office/benchmark.mjs +496 -0
- package/src/runtime/office/capabilities.mjs +551 -0
- package/src/runtime/office/com-adapter.mjs +283 -0
- package/src/runtime/office/content-model.mjs +183 -0
- package/src/runtime/office/contract-benchmark.mjs +105 -0
- package/src/runtime/office/design-library.mjs +1562 -0
- package/src/runtime/office/design-system.mjs +1966 -0
- package/src/runtime/office/index.mjs +2413 -0
- package/src/runtime/office/journal.mjs +82 -0
- package/src/runtime/office/office-com-host.ps1 +3781 -0
- package/src/runtime/office/office-com-session-host.ps1 +855 -0
- package/src/runtime/office/ooxml-validator.mjs +271 -0
- package/src/runtime/office/pagination.mjs +132 -0
- package/src/runtime/office/pdf-adapter.mjs +591 -0
- package/src/runtime/office/pdf-analysis.mjs +372 -0
- package/src/runtime/office/pdf-render.mjs +167 -0
- package/src/runtime/office/pdf-security.mjs +63 -0
- package/src/runtime/office/polish-benchmark.mjs +190 -0
- package/src/runtime/office/portable-ooxml.mjs +1867 -0
- package/src/runtime/office/quality-live-benchmark.mjs +486 -0
- package/src/runtime/office/quality-pipeline.mjs +136 -0
- package/src/runtime/office/tabular.mjs +302 -0
- package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
- package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
- package/src/runtime/office/tool-defs.mjs +113 -0
- package/src/runtime/office/visual-diff.mjs +89 -0
- package/src/runtime/office/xlsx-assertions.mjs +172 -0
- package/src/runtime/office/xlsx-contract.mjs +147 -0
- package/src/runtime/shared/agent-route-config.mjs +9 -0
- package/src/runtime/shared/tool-execution-contract.mjs +16 -0
- package/src/runtime/shared/tool-surface.mjs +9 -0
- package/src/session-runtime/context-status.mjs +9 -3
- package/src/session-runtime/deferred-tool-delta.mjs +104 -0
- package/src/session-runtime/goal-runtime.mjs +617 -197
- package/src/session-runtime/lifecycle-api.mjs +50 -8
- package/src/session-runtime/provider-request-snapshot.mjs +33 -9
- package/src/session-runtime/resource-api.mjs +31 -94
- package/src/session-runtime/runtime-core.mjs +78 -26
- package/src/session-runtime/session-lifecycle.mjs +34 -12
- package/src/session-runtime/session-title.mjs +2 -2
- package/src/session-runtime/session-turn-api.mjs +15 -14
- package/src/session-runtime/tool-catalog-data.mjs +1 -1
- package/src/session-runtime/tool-catalog.mjs +38 -99
- package/src/session-runtime/tool-defs.mjs +6 -1
- package/src/session-runtime/tool-surface.mjs +18 -8
- package/src/session-runtime/workflow-agents-api.mjs +8 -25
- package/src/session-runtime/workflow.mjs +8 -6
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/agent-tool/job-views.mjs +3 -1
- package/src/standalone/agent-tool/notify.mjs +5 -1
- package/src/standalone/agent-tool/render.mjs +3 -0
- package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
- package/src/standalone/agent-tool/tool-def.mjs +1 -1
- package/src/standalone/agent-tool/worker-index.mjs +123 -0
- package/src/standalone/agent-tool/worker-rows.mjs +2 -1
- package/src/standalone/agent-tool.mjs +57 -10
- package/src/standalone/daemon.mjs +105 -6
- package/src/standalone/session-runtime-host.mjs +61 -48
- package/src/standalone/session-runtime-inline-host.mjs +34 -127
- package/src/standalone/session-runtime-worker.mjs +20 -198
- package/src/standalone/session-service.mjs +632 -7
- package/src/tui/dist/index.mjs +24 -1
- package/src/tui/lib/voice-setup.mjs +4 -1
- package/src/tui/session/context-state.mjs +2 -13
- package/src/tui/session/goal-continuation.mjs +38 -7
- package/src/tui/session/session-api-ext.mjs +9 -0
- package/src/tui/session/session-api.mjs +15 -1
- package/src/tui/session/session-flow.mjs +25 -1
- package/src/tui/session/turn.mjs +88 -16
- package/src/tui/session-local.mjs +25 -3
- package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
- package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
- package/scripts/native-binary-arch.test.mjs +0 -111
- package/scripts/patch-replay.test.mjs +0 -94
- package/src/headless-exec.test.mjs +0 -539
- package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
- package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
- package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
- package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
- package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
- package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
- package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
- package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
- package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
- package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
- package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
- package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
- package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
- package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
- package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
- package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
- package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
- package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
- package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
- package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
- package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
- package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
- package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
- package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
- package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
- package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
- package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
- package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
- package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
- package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
- package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
- package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
- package/src/runtime/attachments/store.test.mjs +0 -209
- package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
- package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
- package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
- package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
- package/src/runtime/media/download.test.mjs +0 -52
- package/src/runtime/media/renditions.test.mjs +0 -99
- package/src/runtime/media/store.test.mjs +0 -159
- package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
- package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
- package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
- package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
- package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
- package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
- package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
- package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
- package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
- package/src/runtime/shared/background-tasks.test.mjs +0 -78
- package/src/runtime/shared/bounded-download.test.mjs +0 -41
- package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
- package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
- package/src/runtime/shared/remote-intent.test.mjs +0 -40
- package/src/runtime/shared/resource-admission.test.mjs +0 -43
- package/src/runtime/shared/runtime-root.test.mjs +0 -34
- package/src/runtime/shared/schedule-time.test.mjs +0 -29
- package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
- package/src/runtime/shared/skill-document.test.mjs +0 -81
- package/src/runtime/shared/tool-surface.test.mjs +0 -87
- package/src/runtime/shared/update-checker.test.mjs +0 -33
- package/src/runtime/shared/user-cwd.test.mjs +0 -43
- package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
- package/src/session-runtime/agent-disable.test.mjs +0 -123
- package/src/session-runtime/cwd-plugins.test.mjs +0 -75
- package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
- package/src/session-runtime/global-extensions.test.mjs +0 -28
- package/src/session-runtime/goal-runtime.test.mjs +0 -108
- package/src/session-runtime/lifecycle-api.test.mjs +0 -21
- package/src/session-runtime/model-settings-persist.test.mjs +0 -105
- package/src/session-runtime/notification-bus.test.mjs +0 -148
- package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
- package/src/session-runtime/prewarm.test.mjs +0 -52
- package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
- package/src/session-runtime/resource-api-global.test.mjs +0 -69
- package/src/session-runtime/session-lifecycle.test.mjs +0 -125
- package/src/session-runtime/session-title.test.mjs +0 -36
- package/src/session-runtime/skills-api.test.mjs +0 -99
- package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
- package/src/standalone/agent-tool/helpers.test.mjs +0 -62
- package/src/standalone/agent-tool/notify.test.mjs +0 -37
- package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
- package/src/standalone/channel-restart.test.mjs +0 -145
- package/src/standalone/channel-session-router.test.mjs +0 -37
- package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
- package/src/standalone/hook-bus/handlers.test.mjs +0 -88
- package/src/standalone/plugin-admin.test.mjs +0 -173
- package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
- package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
- package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
- package/src/standalone/session-runtime-host-health.test.mjs +0 -160
- package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
- package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
- package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
- package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
- package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
- package/src/tui/app/panel-epoch.test.mjs +0 -1009
- package/src/tui/app/panel-handoff.test.mjs +0 -311
- package/src/tui/app/prompt-submit.test.mjs +0 -206
- package/src/tui/session/completion-card-restore.test.mjs +0 -111
- package/src/tui/session/goal-continuation.test.mjs +0 -84
- package/src/tui/session/oauth-flows.test.mjs +0 -134
- package/src/tui/session/queue-helpers.test.mjs +0 -46
- package/src/tui/session/session-action-surface.test.mjs +0 -108
- package/src/tui/session/task-wait-submit.test.mjs +0 -80
- package/src/tui/session/tool-result-status.test.mjs +0 -131
- package/src/tui/session/tui-steering-persist.test.mjs +0 -104
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { _createGlobMtimeTopK } from './search-glob-tool.mjs';
|
|
5
|
-
|
|
6
|
-
function entry(path, mtime, stat = {}) {
|
|
7
|
-
return { path, full: path, mtime, mtimeMs: mtime, stat };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
test('glob mtime top-K exactly matches full ordering and preserves failed-stat walk order', () => {
|
|
11
|
-
const entries = [
|
|
12
|
-
entry('z-old', 1),
|
|
13
|
-
entry('b-tie', 9),
|
|
14
|
-
entry('failed-first', 0, null),
|
|
15
|
-
entry('a-tie', 9),
|
|
16
|
-
entry('newest', 12),
|
|
17
|
-
entry('failed-second', 0, null),
|
|
18
|
-
entry('middle', 5),
|
|
19
|
-
];
|
|
20
|
-
const selector = _createGlobMtimeTopK(6);
|
|
21
|
-
const completionOrder = [5, 1, 6, 2, 4, 0, 3];
|
|
22
|
-
for (const index of completionOrder) selector.add(entries[index], index);
|
|
23
|
-
|
|
24
|
-
assert.deepEqual(
|
|
25
|
-
selector.values().map((item) => item.path),
|
|
26
|
-
['newest', 'a-tie', 'b-tie', 'middle', 'z-old', 'failed-first'],
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('glob mtime top-K retains only the requested bound', () => {
|
|
31
|
-
const selector = _createGlobMtimeTopK(3);
|
|
32
|
-
for (let index = 0; index < 100; index += 1) {
|
|
33
|
-
selector.add(entry(`file-${String(index).padStart(3, '0')}`, index), index);
|
|
34
|
-
}
|
|
35
|
-
assert.deepEqual(
|
|
36
|
-
selector.values().map((item) => item.path),
|
|
37
|
-
['file-099', 'file-098', 'file-097'],
|
|
38
|
-
);
|
|
39
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// Writing through a symlink must land on the file the link points at and leave
|
|
2
|
-
// the link in place. The atomic rename would otherwise replace the link with a
|
|
3
|
-
// regular file and silently detach layouts like nginx's sites-enabled/default
|
|
4
|
-
// from sites-available/default.
|
|
5
|
-
import { test } from 'node:test';
|
|
6
|
-
import assert from 'node:assert/strict';
|
|
7
|
-
import {
|
|
8
|
-
lstatSync,
|
|
9
|
-
mkdtempSync,
|
|
10
|
-
readFileSync,
|
|
11
|
-
realpathSync,
|
|
12
|
-
rmSync,
|
|
13
|
-
statSync,
|
|
14
|
-
symlinkSync,
|
|
15
|
-
writeFileSync,
|
|
16
|
-
} from 'node:fs';
|
|
17
|
-
import { tmpdir } from 'node:os';
|
|
18
|
-
import { join } from 'node:path';
|
|
19
|
-
|
|
20
|
-
import { atomicWrite, symlinkWriteTarget } from './atomic-write.mjs';
|
|
21
|
-
import { tryExecuteExternalToolAdapter } from './external-tool-adapters.mjs';
|
|
22
|
-
|
|
23
|
-
function makeDir() {
|
|
24
|
-
return mkdtempSync(join(tmpdir(), 'mixdog-write-symlink-'));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Windows without Developer Mode / admin rights refuses symlink creation
|
|
28
|
-
// (EPERM), so the host capability decides whether these cases can run.
|
|
29
|
-
function symlinkSupported(dir) {
|
|
30
|
-
try {
|
|
31
|
-
writeFileSync(join(dir, 'probe.txt'), 'x');
|
|
32
|
-
symlinkSync(join(dir, 'probe.txt'), join(dir, 'probe.link'));
|
|
33
|
-
return true;
|
|
34
|
-
} catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
test('symlinkWriteTarget resolves a live link and nothing else', (t) => {
|
|
40
|
-
const dir = makeDir();
|
|
41
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
42
|
-
if (!symlinkSupported(dir)) {
|
|
43
|
-
t.skip('symlink creation is not permitted on this host');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const real = join(dir, 'real.txt');
|
|
47
|
-
const link = join(dir, 'link.txt');
|
|
48
|
-
writeFileSync(real, 'a\n');
|
|
49
|
-
symlinkSync(real, link);
|
|
50
|
-
|
|
51
|
-
assert.equal(symlinkWriteTarget(link), realpathSync(real));
|
|
52
|
-
assert.equal(symlinkWriteTarget(real), null);
|
|
53
|
-
assert.equal(symlinkWriteTarget(join(dir, 'missing.txt')), null);
|
|
54
|
-
// A dangling link has no target to resolve, so the caller keeps its path.
|
|
55
|
-
const dangling = join(dir, 'dangling.link');
|
|
56
|
-
symlinkSync(join(dir, 'gone.txt'), dangling);
|
|
57
|
-
assert.equal(symlinkWriteTarget(dangling), null);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('atomicWrite writes through a symlink and keeps the link', async (t) => {
|
|
61
|
-
const dir = makeDir();
|
|
62
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
63
|
-
if (!symlinkSupported(dir)) {
|
|
64
|
-
t.skip('symlink creation is not permitted on this host');
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const real = join(dir, 'real.conf');
|
|
68
|
-
const link = join(dir, 'link.conf');
|
|
69
|
-
writeFileSync(real, 'old\n');
|
|
70
|
-
symlinkSync(real, link);
|
|
71
|
-
|
|
72
|
-
await atomicWrite(link, 'new\n');
|
|
73
|
-
|
|
74
|
-
assert.equal(readFileSync(real, 'utf8'), 'new\n');
|
|
75
|
-
assert.equal(lstatSync(link).isSymbolicLink(), true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('the expected-target guard still fires when the real file moved', async (t) => {
|
|
79
|
-
const dir = makeDir();
|
|
80
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
81
|
-
if (!symlinkSupported(dir)) {
|
|
82
|
-
t.skip('symlink creation is not permitted on this host');
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const real = join(dir, 'guard.conf');
|
|
86
|
-
const link = join(dir, 'guard.link');
|
|
87
|
-
writeFileSync(real, 'old\n');
|
|
88
|
-
symlinkSync(real, link);
|
|
89
|
-
const before = statSync(link);
|
|
90
|
-
|
|
91
|
-
// Somebody else rewrites the real file after the snapshot was taken.
|
|
92
|
-
writeFileSync(real, 'rewritten by another writer\n');
|
|
93
|
-
|
|
94
|
-
await assert.rejects(
|
|
95
|
-
() => atomicWrite(link, 'mine\n', {
|
|
96
|
-
expectedTargetSnapshot: {
|
|
97
|
-
exists: true,
|
|
98
|
-
size: before.size,
|
|
99
|
-
mtimeMs: before.mtimeMs,
|
|
100
|
-
ctimeMs: before.ctimeMs,
|
|
101
|
-
ino: before.ino,
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
(err) => err?.code === 'ESTALE_TARGET',
|
|
105
|
-
);
|
|
106
|
-
assert.equal(readFileSync(real, 'utf8'), 'rewritten by another writer\n');
|
|
107
|
-
assert.equal(lstatSync(link).isSymbolicLink(), true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('edit updates through a symlink and keeps the link', async (t) => {
|
|
111
|
-
const dir = makeDir();
|
|
112
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
113
|
-
if (!symlinkSupported(dir)) {
|
|
114
|
-
t.skip('symlink creation is not permitted on this host');
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const real = join(dir, 'sites-available.conf');
|
|
118
|
-
const link = join(dir, 'sites-enabled.conf');
|
|
119
|
-
writeFileSync(real, 'root /var/www/html;\nindex index.html;\n');
|
|
120
|
-
symlinkSync(real, link);
|
|
121
|
-
|
|
122
|
-
const result = String(await tryExecuteExternalToolAdapter('edit', {
|
|
123
|
-
file_path: link,
|
|
124
|
-
old_string: 'root /var/www/html;',
|
|
125
|
-
new_string: 'root /usr/share/novnc;',
|
|
126
|
-
}, dir, {}));
|
|
127
|
-
|
|
128
|
-
assert.match(result, /^Updated /);
|
|
129
|
-
assert.equal(readFileSync(real, 'utf8'), 'root /usr/share/novnc;\nindex index.html;\n');
|
|
130
|
-
assert.equal(lstatSync(link).isSymbolicLink(), true);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('write replaces content through a symlink and keeps the link', async (t) => {
|
|
134
|
-
const dir = makeDir();
|
|
135
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
136
|
-
if (!symlinkSupported(dir)) {
|
|
137
|
-
t.skip('symlink creation is not permitted on this host');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const real = join(dir, 'payload.txt');
|
|
141
|
-
const link = join(dir, 'payload.link');
|
|
142
|
-
writeFileSync(real, 'old\n');
|
|
143
|
-
symlinkSync(real, link);
|
|
144
|
-
|
|
145
|
-
const result = String(await tryExecuteExternalToolAdapter('write', {
|
|
146
|
-
file_path: link,
|
|
147
|
-
contents: 'fresh\n',
|
|
148
|
-
}, dir, {}));
|
|
149
|
-
|
|
150
|
-
assert.match(result, /^Updated /);
|
|
151
|
-
assert.equal(readFileSync(real, 'utf8'), 'fresh\n');
|
|
152
|
-
assert.equal(lstatSync(link).isSymbolicLink(), true);
|
|
153
|
-
});
|
package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// A sentinel-free cwd that HOLDS one project answers an anchored call by
|
|
2
|
-
// adopting that project; a genuinely ambiguous tree still refuses, but names
|
|
3
|
-
// where to anchor instead.
|
|
4
|
-
import test from 'node:test';
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import { tmpdir } from 'node:os';
|
|
9
|
-
|
|
10
|
-
import { executeCodeGraphTool } from './dispatch.mjs';
|
|
11
|
-
|
|
12
|
-
const PY = 'class Mean:\n def compute(self):\n return 42\n';
|
|
13
|
-
|
|
14
|
-
function makeRepo(root, name) {
|
|
15
|
-
const repo = join(root, name);
|
|
16
|
-
mkdirSync(join(repo, '.git'), { recursive: true });
|
|
17
|
-
mkdirSync(join(repo, 'tools'), { recursive: true });
|
|
18
|
-
writeFileSync(join(repo, 'tools', 'compute_mean.py'), PY);
|
|
19
|
-
return repo;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
test('a relative anchor held by exactly one child project adopts that project', async (t) => {
|
|
23
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-anchor-one-'));
|
|
24
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
25
|
-
makeRepo(root, 'caffe');
|
|
26
|
-
|
|
27
|
-
const out = String(await executeCodeGraphTool(
|
|
28
|
-
'code_graph',
|
|
29
|
-
{ mode: 'symbols', files: 'tools/compute_mean.py' },
|
|
30
|
-
root,
|
|
31
|
-
));
|
|
32
|
-
assert.doesNotMatch(out, /Refusing to index an arbitrary tree/);
|
|
33
|
-
assert.match(out, /compute/);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('two child projects holding the same anchor stay refused, with the roots named', async (t) => {
|
|
37
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-anchor-many-'));
|
|
38
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
39
|
-
makeRepo(root, 'caffe');
|
|
40
|
-
makeRepo(root, 'caffe-fork');
|
|
41
|
-
|
|
42
|
-
let message = '';
|
|
43
|
-
try {
|
|
44
|
-
await executeCodeGraphTool(
|
|
45
|
-
'code_graph',
|
|
46
|
-
{ mode: 'symbols', files: 'tools/compute_mean.py' },
|
|
47
|
-
root,
|
|
48
|
-
);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
message = String(error?.message || error);
|
|
51
|
-
}
|
|
52
|
-
assert.match(message, /Refusing to index an arbitrary tree/);
|
|
53
|
-
assert.match(message, /Project roots under this cwd/);
|
|
54
|
-
assert.match(message, /"caffe"/);
|
|
55
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
|
-
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import { join, resolve } from 'node:path';
|
|
7
|
-
|
|
8
|
-
import { _resolveBoundedSentinelFreeAggregateRootForTest } from './dispatch.mjs';
|
|
9
|
-
import { _spawnCodeGraphWorker } from './build.mjs';
|
|
10
|
-
|
|
11
|
-
test('successful code-graph build terminates its worker and releases the spawn slot', async () => {
|
|
12
|
-
let worker = null;
|
|
13
|
-
let releases = 0;
|
|
14
|
-
class FakeWorker extends EventEmitter {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
this.stdout = new EventEmitter();
|
|
18
|
-
this.stderr = new EventEmitter();
|
|
19
|
-
this.terminations = 0;
|
|
20
|
-
}
|
|
21
|
-
terminate() {
|
|
22
|
-
this.terminations += 1;
|
|
23
|
-
return Promise.resolve(0);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const pending = _spawnCodeGraphWorker(
|
|
28
|
-
process.cwd(),
|
|
29
|
-
process.cwd(),
|
|
30
|
-
0,
|
|
31
|
-
null,
|
|
32
|
-
() => { releases += 1; },
|
|
33
|
-
null,
|
|
34
|
-
null,
|
|
35
|
-
{
|
|
36
|
-
createWorker() {
|
|
37
|
-
worker = new FakeWorker();
|
|
38
|
-
return worker;
|
|
39
|
-
},
|
|
40
|
-
getGeneration: () => 0,
|
|
41
|
-
setMemoryCache: () => {},
|
|
42
|
-
setDiskCache: () => {},
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
46
|
-
worker.emit('message', { ok: true, graph: { files: [] }, signature: 'sig' });
|
|
47
|
-
|
|
48
|
-
assert.deepEqual(await pending, { files: [] });
|
|
49
|
-
assert.equal(worker.terminations, 1);
|
|
50
|
-
assert.equal(releases, 1);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('sentinel-free aggregate anchors adopt only their explicit bounded cwd', () => {
|
|
54
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-codegraph-bounded-'));
|
|
55
|
-
const outside = mkdtempSync(join(tmpdir(), 'mixdog-codegraph-outside-'));
|
|
56
|
-
try {
|
|
57
|
-
mkdirSync(join(root, 'src'));
|
|
58
|
-
const first = join(root, 'src', 'first.ts');
|
|
59
|
-
const second = join(root, 'src', 'second.ts');
|
|
60
|
-
const foreign = join(outside, 'foreign.ts');
|
|
61
|
-
writeFileSync(first, 'export const first = 1;\n');
|
|
62
|
-
writeFileSync(second, 'export const second = 2;\n');
|
|
63
|
-
writeFileSync(foreign, 'export const foreign = 3;\n');
|
|
64
|
-
|
|
65
|
-
assert.equal(
|
|
66
|
-
_resolveBoundedSentinelFreeAggregateRootForTest({ files: [first, second] }, root),
|
|
67
|
-
resolve(root),
|
|
68
|
-
);
|
|
69
|
-
assert.equal(
|
|
70
|
-
_resolveBoundedSentinelFreeAggregateRootForTest({ files: [first, foreign] }, root),
|
|
71
|
-
null,
|
|
72
|
-
);
|
|
73
|
-
assert.equal(
|
|
74
|
-
_resolveBoundedSentinelFreeAggregateRootForTest({ files: ['src/*.ts'] }, root),
|
|
75
|
-
null,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
mkdirSync(join(root, 'nested-project'));
|
|
79
|
-
writeFileSync(join(root, 'nested-project', 'package.json'), '{}\n');
|
|
80
|
-
assert.equal(
|
|
81
|
-
_resolveBoundedSentinelFreeAggregateRootForTest({ files: [first] }, root),
|
|
82
|
-
null,
|
|
83
|
-
);
|
|
84
|
-
} finally {
|
|
85
|
-
rmSync(root, { recursive: true, force: true });
|
|
86
|
-
rmSync(outside, { recursive: true, force: true });
|
|
87
|
-
}
|
|
88
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
|
|
7
|
-
import { executeCodeGraphTool } from './dispatch.mjs';
|
|
8
|
-
import { CODE_GRAPH_TOOL_DEFS } from '../code-graph-tool-defs.mjs';
|
|
9
|
-
|
|
10
|
-
const PY = 'class Term:\n def is_alive(self):\n return True\n';
|
|
11
|
-
|
|
12
|
-
test('an exact absolute file outside every project is a valid outline target', async () => {
|
|
13
|
-
const outside = mkdtempSync(join(tmpdir(), 'mixdog-loose-file-'));
|
|
14
|
-
try {
|
|
15
|
-
const target = join(outside, 'headless_terminal.py');
|
|
16
|
-
writeFileSync(target, PY);
|
|
17
|
-
// cwd is THIS project; the anchor lives outside it and under no sentinel.
|
|
18
|
-
const out = String(await executeCodeGraphTool(
|
|
19
|
-
'code_graph',
|
|
20
|
-
{ mode: 'symbols', files: target },
|
|
21
|
-
process.cwd(),
|
|
22
|
-
));
|
|
23
|
-
assert.doesNotMatch(out, /Refusing to index an arbitrary tree/);
|
|
24
|
-
assert.match(out, /is_alive/);
|
|
25
|
-
} finally {
|
|
26
|
-
rmSync(outside, { recursive: true, force: true });
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('a sentinel-free working directory outlines its own files with an implicit cwd', async () => {
|
|
31
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-implicit-cwd-'));
|
|
32
|
-
try {
|
|
33
|
-
writeFileSync(join(root, 'app.py'), PY);
|
|
34
|
-
const out = String(await executeCodeGraphTool(
|
|
35
|
-
'code_graph',
|
|
36
|
-
{ mode: 'symbols', files: 'app.py' },
|
|
37
|
-
root,
|
|
38
|
-
));
|
|
39
|
-
assert.doesNotMatch(out, /Refusing to index an arbitrary tree/);
|
|
40
|
-
assert.match(out, /is_alive/);
|
|
41
|
-
} finally {
|
|
42
|
-
rmSync(root, { recursive: true, force: true });
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('a directory anchor outside every project is still refused', async () => {
|
|
47
|
-
const outside = mkdtempSync(join(tmpdir(), 'mixdog-loose-dir-'));
|
|
48
|
-
try {
|
|
49
|
-
writeFileSync(join(outside, 'app.py'), PY);
|
|
50
|
-
let message = '';
|
|
51
|
-
try {
|
|
52
|
-
await executeCodeGraphTool('code_graph', { mode: 'overview', file: outside }, process.cwd());
|
|
53
|
-
} catch (error) {
|
|
54
|
-
message = String(error?.message || error);
|
|
55
|
-
}
|
|
56
|
-
// A directory names a tree to walk, not a target: the guard must hold.
|
|
57
|
-
assert.match(message, /no detectable project root|Refusing to index an arbitrary tree/);
|
|
58
|
-
} finally {
|
|
59
|
-
rmSync(outside, { recursive: true, force: true });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('the code_graph contract advertises the direct outline path', () => {
|
|
64
|
-
const def = CODE_GRAPH_TOOL_DEFS.find((tool) => tool.name === 'code_graph');
|
|
65
|
-
assert.ok(def, 'code_graph tool definition must exist');
|
|
66
|
-
assert.match(def.description, /mode:symbols with files\[\] is the cheap direct outline/);
|
|
67
|
-
assert.match(def.description, /no file body/);
|
|
68
|
-
const mode = def.inputSchema.properties.mode.description;
|
|
69
|
-
assert.match(mode, /needs no prior search/);
|
|
70
|
-
// Absolute anchors are supported, so the schema must not claim otherwise.
|
|
71
|
-
assert.match(def.inputSchema.properties.files.description, /project-relative or absolute/);
|
|
72
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
import { codeGraphCache } from '../code-graph-state.mjs';
|
|
5
|
-
import { _attachGraphRuntimeCaches, _estimateGraphRetainedBytes } from './graph-model.mjs';
|
|
6
|
-
import { _pruneCodeGraphMemoryCache } from './memory-cache.mjs';
|
|
7
|
-
|
|
8
|
-
function graphWithSource(text) {
|
|
9
|
-
const graph = _attachGraphRuntimeCaches({
|
|
10
|
-
cwd: '.',
|
|
11
|
-
nodes: new Map([['src/a.ts', {
|
|
12
|
-
rel: 'src/a.ts',
|
|
13
|
-
abs: 'src/a.ts',
|
|
14
|
-
lang: 'typescript',
|
|
15
|
-
symbols: [{ name: 'alpha', kind: 'function', line: 1, endLine: 1 }],
|
|
16
|
-
}]]),
|
|
17
|
-
reverse: new Map(),
|
|
18
|
-
});
|
|
19
|
-
graph._sourceTextCache.set('src/a.ts', { fingerprint: '', text });
|
|
20
|
-
return graph;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
test('memory pruning clears runtime data before evicting a base graph', () => {
|
|
24
|
-
codeGraphCache.clear();
|
|
25
|
-
try {
|
|
26
|
-
const graph = graphWithSource('x'.repeat(16_000));
|
|
27
|
-
const before = _estimateGraphRetainedBytes(graph);
|
|
28
|
-
graph._sourceTextCache.clear();
|
|
29
|
-
const base = _estimateGraphRetainedBytes(graph);
|
|
30
|
-
graph._sourceTextCache.set('src/a.ts', { fingerprint: '', text: 'x'.repeat(16_000) });
|
|
31
|
-
assert.ok(before > base);
|
|
32
|
-
codeGraphCache.set('a', { graph, ts: 1, lastAccess: 1 });
|
|
33
|
-
|
|
34
|
-
const result = _pruneCodeGraphMemoryCache({ maxBytes: base, maxEntries: 6 });
|
|
35
|
-
assert.equal(codeGraphCache.has('a'), true);
|
|
36
|
-
assert.equal(graph._sourceTextCache.size, 0);
|
|
37
|
-
assert.ok(result.totalRetainedBytes <= base);
|
|
38
|
-
} finally {
|
|
39
|
-
codeGraphCache.clear();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('memory pruning evicts a base graph that exceeds the total budget', () => {
|
|
44
|
-
codeGraphCache.clear();
|
|
45
|
-
try {
|
|
46
|
-
const graph = graphWithSource('');
|
|
47
|
-
codeGraphCache.set('a', { graph, ts: 1, lastAccess: 1 });
|
|
48
|
-
const result = _pruneCodeGraphMemoryCache({ maxBytes: 1, maxEntries: 6 });
|
|
49
|
-
assert.equal(codeGraphCache.size, 0);
|
|
50
|
-
assert.ok(result.evicted.some((row) => row.reason === 'max-bytes-graph'));
|
|
51
|
-
} finally {
|
|
52
|
-
codeGraphCache.clear();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import { _formatFullSymbolBody } from './search-references.mjs';
|
|
5
|
-
|
|
6
|
-
test('full symbol bodies are not elided at the old 120-line boundary', () => {
|
|
7
|
-
const source = Array.from({ length: 180 }, (_, index) => `line ${index + 1}`).join('\n');
|
|
8
|
-
const rendered = _formatFullSymbolBody(source, 1, 180);
|
|
9
|
-
|
|
10
|
-
assert.equal(rendered.split('\n').length, 180);
|
|
11
|
-
assert.match(rendered, /^1: line 1$/m);
|
|
12
|
-
assert.match(rendered, /^180: line 180$/m);
|
|
13
|
-
assert.doesNotMatch(rendered, /lines elided|full body: read/);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('full symbol body formatting stays inside the source file', () => {
|
|
17
|
-
const rendered = _formatFullSymbolBody('one\ntwo\nthree', 2, 99);
|
|
18
|
-
|
|
19
|
-
assert.equal(rendered, '2: two\n3: three');
|
|
20
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// A file/directory anchor scopes symbol_search: it used to scan the whole
|
|
2
|
-
// graph and silently ignore the anchor.
|
|
3
|
-
import { test } from 'node:test';
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
|
|
9
|
-
import { executeCodeGraphTool } from './dispatch.mjs';
|
|
10
|
-
|
|
11
|
-
function makeProject() {
|
|
12
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-cg-scope-'));
|
|
13
|
-
writeFileSync(join(root, 'package.json'), '{"name":"scope-fixture"}\n');
|
|
14
|
-
mkdirSync(join(root, 'inside'));
|
|
15
|
-
mkdirSync(join(root, 'outside'));
|
|
16
|
-
writeFileSync(join(root, 'inside', 'one.mjs'), 'export function alphaHelper() {\n return 1;\n}\n');
|
|
17
|
-
writeFileSync(join(root, 'outside', 'two.mjs'), 'export function alphaWidget() {\n return 2;\n}\n');
|
|
18
|
-
return root;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
test('symbol_search honours a directory anchor', async (t) => {
|
|
22
|
-
const root = makeProject();
|
|
23
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
24
|
-
|
|
25
|
-
const scoped = String(await executeCodeGraphTool('code_graph', {
|
|
26
|
-
mode: 'symbol_search',
|
|
27
|
-
symbol: 'alpha',
|
|
28
|
-
cwd: root,
|
|
29
|
-
files: [join(root, 'inside')],
|
|
30
|
-
}, root));
|
|
31
|
-
assert.match(scoped, /alphaHelper/);
|
|
32
|
-
assert.doesNotMatch(scoped, /alphaWidget/);
|
|
33
|
-
|
|
34
|
-
const wide = String(await executeCodeGraphTool('code_graph', {
|
|
35
|
-
mode: 'symbol_search',
|
|
36
|
-
symbol: 'alpha',
|
|
37
|
-
cwd: root,
|
|
38
|
-
}, root));
|
|
39
|
-
assert.match(wide, /alphaHelper/);
|
|
40
|
-
assert.match(wide, /alphaWidget/);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('symbol_search honours a single-file anchor', async (t) => {
|
|
44
|
-
const root = makeProject();
|
|
45
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
46
|
-
|
|
47
|
-
const scoped = String(await executeCodeGraphTool('code_graph', {
|
|
48
|
-
mode: 'symbol_search',
|
|
49
|
-
symbol: 'alpha',
|
|
50
|
-
cwd: root,
|
|
51
|
-
file: join(root, 'outside', 'two.mjs'),
|
|
52
|
-
}, root));
|
|
53
|
-
assert.match(scoped, /alphaWidget/);
|
|
54
|
-
assert.doesNotMatch(scoped, /alphaHelper/);
|
|
55
|
-
});
|