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,31 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import { executeBuiltinTool } from '../builtin.mjs';
|
|
8
|
-
|
|
9
|
-
test('grep rendered output is capped at 10 KiB', async () => {
|
|
10
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-grep-budget-'));
|
|
11
|
-
try {
|
|
12
|
-
const file = join(root, 'large.txt');
|
|
13
|
-
const body = Array.from(
|
|
14
|
-
{ length: 400 },
|
|
15
|
-
(_, index) => `${index + 1} needle ${'x'.repeat(160)}`,
|
|
16
|
-
).join('\n');
|
|
17
|
-
await writeFile(file, body);
|
|
18
|
-
const out = await executeBuiltinTool('grep', {
|
|
19
|
-
pattern: 'needle',
|
|
20
|
-
path: file,
|
|
21
|
-
mode: 'content',
|
|
22
|
-
limit: 250,
|
|
23
|
-
offset: 0,
|
|
24
|
-
context: 2,
|
|
25
|
-
}, root);
|
|
26
|
-
assert.ok(Buffer.byteLength(out, 'utf8') <= 10 * 1024);
|
|
27
|
-
assert.match(out, /\[grep output capped at 10240 bytes;/);
|
|
28
|
-
} finally {
|
|
29
|
-
await rm(root, { recursive: true, force: true });
|
|
30
|
-
}
|
|
31
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// A file scope the shared native search server could not serve is answered by
|
|
2
|
-
// reading that one file, so a starved queue costs a bounded wait instead of a
|
|
3
|
-
// whole turn. The scanner declines whenever it cannot reproduce the request.
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import test from 'node:test';
|
|
9
|
-
|
|
10
|
-
import { runGrepSingleFileRescue } from './lib/grep-single-file-rescue.mjs';
|
|
11
|
-
|
|
12
|
-
const STATUS = 'Name:\tnode\nUid:\t0\t0\t0\t0\nGid:\t0\t0\t0\t0\nCapEff:\t000001ffffffffff\n';
|
|
13
|
-
|
|
14
|
-
function request(overrides) {
|
|
15
|
-
return {
|
|
16
|
-
caseInsensitive: false,
|
|
17
|
-
multilineMode: false,
|
|
18
|
-
onlyMatching: false,
|
|
19
|
-
fileType: null,
|
|
20
|
-
outputMode: 'content',
|
|
21
|
-
showLineNumbers: true,
|
|
22
|
-
withFilename: false,
|
|
23
|
-
filenameOmitted: true,
|
|
24
|
-
beforeN: 0,
|
|
25
|
-
afterN: 0,
|
|
26
|
-
contextN: 0,
|
|
27
|
-
headLimit: 250,
|
|
28
|
-
offset: 0,
|
|
29
|
-
patternCapNote: '',
|
|
30
|
-
globPatterns: [],
|
|
31
|
-
...overrides,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function withStatusFile(run) {
|
|
36
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-grep-rescue-'));
|
|
37
|
-
try {
|
|
38
|
-
const file = join(root, 'status');
|
|
39
|
-
await writeFile(file, STATUS);
|
|
40
|
-
return await run({ root, file });
|
|
41
|
-
} finally {
|
|
42
|
-
await rm(root, { recursive: true, force: true });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
test('a missed file scope is scanned directly and reports the same matches', async () => {
|
|
47
|
-
await withStatusFile(async ({ root, file }) => {
|
|
48
|
-
const out = await runGrepSingleFileRescue(request({
|
|
49
|
-
filePath: file,
|
|
50
|
-
searchPath: file,
|
|
51
|
-
grepResolvedPath: file,
|
|
52
|
-
workDir: root,
|
|
53
|
-
patterns: ['^(Uid|Gid|Cap(Inh|Prm|Eff|Bnd|Amb))'],
|
|
54
|
-
}));
|
|
55
|
-
assert.match(out, /2:Uid:/);
|
|
56
|
-
assert.match(out, /3:Gid:/);
|
|
57
|
-
assert.match(out, /4:CapEff:/);
|
|
58
|
-
assert.doesNotMatch(out, /Name:/);
|
|
59
|
-
assert.match(out, /scanned directly/);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('counts and no-match answers keep the ordinary grep shapes', async () => {
|
|
64
|
-
await withStatusFile(async ({ root, file }) => {
|
|
65
|
-
const counted = await runGrepSingleFileRescue(request({
|
|
66
|
-
filePath: file,
|
|
67
|
-
searchPath: file,
|
|
68
|
-
grepResolvedPath: file,
|
|
69
|
-
workDir: root,
|
|
70
|
-
outputMode: 'count',
|
|
71
|
-
patterns: ['^(Uid|Gid)'],
|
|
72
|
-
}));
|
|
73
|
-
assert.match(counted, /\b2\b/);
|
|
74
|
-
|
|
75
|
-
const empty = await runGrepSingleFileRescue(request({
|
|
76
|
-
filePath: file,
|
|
77
|
-
searchPath: file,
|
|
78
|
-
grepResolvedPath: file,
|
|
79
|
-
workDir: root,
|
|
80
|
-
patterns: ['NoSuchFieldHere'],
|
|
81
|
-
}));
|
|
82
|
-
assert.match(empty, /\(no matches\)/);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('a request the scanner cannot reproduce declines instead of guessing', async () => {
|
|
87
|
-
await withStatusFile(async ({ root, file }) => {
|
|
88
|
-
const base = {
|
|
89
|
-
filePath: file,
|
|
90
|
-
searchPath: file,
|
|
91
|
-
grepResolvedPath: file,
|
|
92
|
-
workDir: root,
|
|
93
|
-
};
|
|
94
|
-
// Regex JS cannot compile: the caller keeps the native error.
|
|
95
|
-
assert.equal(await runGrepSingleFileRescue(request({
|
|
96
|
-
...base,
|
|
97
|
-
patterns: ['a{2,1}'],
|
|
98
|
-
})), null);
|
|
99
|
-
// Multiline matching spans lines; this scanner is line-oriented.
|
|
100
|
-
assert.equal(await runGrepSingleFileRescue(request({
|
|
101
|
-
...base,
|
|
102
|
-
patterns: ['Uid'],
|
|
103
|
-
multilineMode: true,
|
|
104
|
-
})), null);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
completeShellJobRecord,
|
|
10
|
-
listShellJobRecords,
|
|
11
|
-
publishShellJobRecord,
|
|
12
|
-
readShellJobRecord,
|
|
13
|
-
retireShellJobRecord,
|
|
14
|
-
} from './shell-job-records.mjs';
|
|
15
|
-
import { executeTaskTool } from '../task-tool.mjs';
|
|
16
|
-
import { shellJobsStatus } from '../../../../../../ui/statusline-segments.mjs';
|
|
17
|
-
|
|
18
|
-
// The reader caches for 1s and refreshes in the background, so a probe polls
|
|
19
|
-
// until the scan lands instead of assuming the first call is populated.
|
|
20
|
-
async function readStatus(predicate) {
|
|
21
|
-
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
22
|
-
const value = shellJobsStatus({ clientHostPid: process.pid });
|
|
23
|
-
if (predicate(value)) return value;
|
|
24
|
-
await delay(60);
|
|
25
|
-
}
|
|
26
|
-
return shellJobsStatus({ clientHostPid: process.pid });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
test('a running shell job publishes a record the statusline reader counts', async () => {
|
|
30
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-shell-records-'));
|
|
31
|
-
const previous = process.env.MIXDOG_DATA_DIR;
|
|
32
|
-
process.env.MIXDOG_DATA_DIR = root;
|
|
33
|
-
try {
|
|
34
|
-
publishShellJobRecord({
|
|
35
|
-
jobId: 'job_probe_1',
|
|
36
|
-
pid: process.pid,
|
|
37
|
-
command: 'sleep 30',
|
|
38
|
-
cwd: root,
|
|
39
|
-
startedAt: new Date().toISOString(),
|
|
40
|
-
}, { ownerSessionId: 'sess-probe', clientHostPid: process.pid });
|
|
41
|
-
|
|
42
|
-
const running = await readStatus((value) => value.count > 0);
|
|
43
|
-
assert.equal(running.count, 1);
|
|
44
|
-
assert.equal(running.jobs[0].command, 'sleep 30');
|
|
45
|
-
assert.equal(running.sessions['sess-probe'].count, 1);
|
|
46
|
-
// Pane scope: the desktop chip asks for one session's own bucket.
|
|
47
|
-
assert.equal(shellJobsStatus({ clientHostPid: process.pid, sessionId: 'sess-probe' }).count, 1);
|
|
48
|
-
assert.equal(shellJobsStatus({ clientHostPid: process.pid, sessionId: 'other' }).count, 0);
|
|
49
|
-
|
|
50
|
-
retireShellJobRecord('job_probe_1');
|
|
51
|
-
const settled = await readStatus((value) => value.count === 0);
|
|
52
|
-
assert.equal(settled.count, 0);
|
|
53
|
-
} finally {
|
|
54
|
-
if (previous === undefined) delete process.env.MIXDOG_DATA_DIR;
|
|
55
|
-
else process.env.MIXDOG_DATA_DIR = previous;
|
|
56
|
-
rmSync(root, { recursive: true, force: true });
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('a completed shell job remains owner-scoped and recoverable after memory loss', async () => {
|
|
61
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-shell-records-terminal-'));
|
|
62
|
-
const previous = process.env.MIXDOG_DATA_DIR;
|
|
63
|
-
process.env.MIXDOG_DATA_DIR = root;
|
|
64
|
-
const jobId = `job_terminal_${process.pid}`;
|
|
65
|
-
try {
|
|
66
|
-
publishShellJobRecord({
|
|
67
|
-
jobId,
|
|
68
|
-
pid: process.pid,
|
|
69
|
-
command: 'node --version',
|
|
70
|
-
cwd: root,
|
|
71
|
-
startedAt: new Date(Date.now() - 100).toISOString(),
|
|
72
|
-
}, { ownerSessionId: 'sess-owner', clientHostPid: process.pid });
|
|
73
|
-
assert.equal(await completeShellJobRecord(jobId, {
|
|
74
|
-
status: 'failed',
|
|
75
|
-
exitCode: 2,
|
|
76
|
-
command: 'node --version',
|
|
77
|
-
cwd: root,
|
|
78
|
-
ownerSessionId: 'sess-owner',
|
|
79
|
-
stdoutPreview: 'version output',
|
|
80
|
-
finishedAt: new Date().toISOString(),
|
|
81
|
-
}), true);
|
|
82
|
-
const record = await readShellJobRecord(jobId);
|
|
83
|
-
assert.equal(record.status, 'failed');
|
|
84
|
-
assert.equal(record.exitCode, 2);
|
|
85
|
-
assert.equal(record.ownerSessionId, 'sess-owner');
|
|
86
|
-
assert.equal(record.terminal, true);
|
|
87
|
-
assert.ok((await listShellJobRecords()).some((item) => item.jobId === jobId));
|
|
88
|
-
assert.match(await executeTaskTool(
|
|
89
|
-
{ action: 'read', task_id: jobId },
|
|
90
|
-
{ sessionId: 'sess-owner' },
|
|
91
|
-
), /recovered: true/);
|
|
92
|
-
assert.match(await executeTaskTool(
|
|
93
|
-
{ action: 'read', task_id: jobId },
|
|
94
|
-
{ sessionId: 'sess-other' },
|
|
95
|
-
), /task not found/);
|
|
96
|
-
} finally {
|
|
97
|
-
retireShellJobRecord(jobId);
|
|
98
|
-
if (previous === undefined) delete process.env.MIXDOG_DATA_DIR;
|
|
99
|
-
else process.env.MIXDOG_DATA_DIR = previous;
|
|
100
|
-
rmSync(root, { recursive: true, force: true });
|
|
101
|
-
}
|
|
102
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join, resolve } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import { recordRuntimeDirectoryReadSuccess } from '../../../../shared/session-runtime-health.mjs';
|
|
8
|
-
import { executeListTool, executeTreeTool } from './list-tool.mjs';
|
|
9
|
-
|
|
10
|
-
function readdirError(code, message = 'injected readdir failure') {
|
|
11
|
-
const error = new Error(message);
|
|
12
|
-
error.code = code;
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
test('aborted list work cannot poison the result cache', async () => {
|
|
17
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-list-abort-'));
|
|
18
|
-
try {
|
|
19
|
-
await writeFile(join(root, 'entry.txt'), 'ok');
|
|
20
|
-
const controller = new AbortController();
|
|
21
|
-
controller.abort(new Error('probe abort'));
|
|
22
|
-
await assert.rejects(
|
|
23
|
-
executeListTool({ path: root, hidden: true }, process.cwd(), { signal: controller.signal }),
|
|
24
|
-
/aborted|probe abort/i,
|
|
25
|
-
);
|
|
26
|
-
assert.match(
|
|
27
|
-
await executeListTool({ path: root, hidden: true }, process.cwd()),
|
|
28
|
-
/entry\.txt\tfile/,
|
|
29
|
-
);
|
|
30
|
-
} finally {
|
|
31
|
-
await rm(root, { recursive: true, force: true });
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('list defaults to a 100-entry page with an offset continuation', async () => {
|
|
36
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-list-default-page-'));
|
|
37
|
-
try {
|
|
38
|
-
await Promise.all(Array.from({ length: 101 }, (_, index) => (
|
|
39
|
-
writeFile(join(root, `entry-${String(index).padStart(3, '0')}.txt`), 'ok')
|
|
40
|
-
)));
|
|
41
|
-
const out = await executeListTool({ path: root, hidden: true }, process.cwd());
|
|
42
|
-
assert.equal(out.split('\n').filter((line) => line.endsWith('\tfile')).length, 100);
|
|
43
|
-
assert.match(out, /\[entries 1-100 of 101; pass offset:100 to continue\]/);
|
|
44
|
-
const oversized = await executeListTool(
|
|
45
|
-
{ path: root, hidden: true, head_limit: 200 },
|
|
46
|
-
process.cwd(),
|
|
47
|
-
);
|
|
48
|
-
assert.equal(oversized.split('\n').filter((line) => line.endsWith('\tfile')).length, 100);
|
|
49
|
-
assert.match(oversized, /\[entries 1-100 of 101; pass offset:100 to continue\]/);
|
|
50
|
-
} finally {
|
|
51
|
-
await rm(root, { recursive: true, force: true });
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('root readdir failures are errors, stay uncached, and mark a repeatedly failing runtime worker unhealthy', async () => {
|
|
56
|
-
const originalRuntimeWorkerPid = process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID;
|
|
57
|
-
const roots = [];
|
|
58
|
-
let unhealthy = null;
|
|
59
|
-
const onUnhealthy = (detail) => { unhealthy = detail; };
|
|
60
|
-
process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID = String(process.pid);
|
|
61
|
-
process.on('mixdog:session-runtime-worker-unhealthy', onUnhealthy);
|
|
62
|
-
recordRuntimeDirectoryReadSuccess();
|
|
63
|
-
try {
|
|
64
|
-
for (let index = 0; index < 3; index += 1) {
|
|
65
|
-
const root = await mkdtemp(join(tmpdir(), `mixdog-list-root-fail-${index}-`));
|
|
66
|
-
roots.push(root);
|
|
67
|
-
await writeFile(join(root, `entry-${index}.txt`), 'ok');
|
|
68
|
-
const out = await executeListTool(
|
|
69
|
-
{ path: root, hidden: true },
|
|
70
|
-
process.cwd(),
|
|
71
|
-
{ readdirImpl: async () => { throw readdirError('EIO'); } },
|
|
72
|
-
);
|
|
73
|
-
assert.match(out, /^Error: readdir failed \(EIO\):/);
|
|
74
|
-
}
|
|
75
|
-
assert.equal(unhealthy?.distinctRoots, 3);
|
|
76
|
-
assert.match(
|
|
77
|
-
await executeListTool({ path: roots[0], hidden: true }, process.cwd()),
|
|
78
|
-
/entry-0\.txt\tfile/,
|
|
79
|
-
);
|
|
80
|
-
} finally {
|
|
81
|
-
recordRuntimeDirectoryReadSuccess();
|
|
82
|
-
process.off('mixdog:session-runtime-worker-unhealthy', onUnhealthy);
|
|
83
|
-
if (originalRuntimeWorkerPid === undefined) delete process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID;
|
|
84
|
-
else process.env.MIXDOG_SESSION_RUNTIME_WORKER_PID = originalRuntimeWorkerPid;
|
|
85
|
-
await Promise.all(roots.map((root) => rm(root, { recursive: true, force: true })));
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('list and tree surface skipped subdirectories and never cache partial walks', async () => {
|
|
90
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-list-partial-'));
|
|
91
|
-
const child = join(root, 'child');
|
|
92
|
-
try {
|
|
93
|
-
await mkdir(child);
|
|
94
|
-
await writeFile(join(child, 'nested.txt'), 'ok');
|
|
95
|
-
const partialReaddir = async (path, options) => {
|
|
96
|
-
if (resolve(path) === resolve(child)) throw readdirError('EIO');
|
|
97
|
-
return readdir(path, options);
|
|
98
|
-
};
|
|
99
|
-
const listTelemetry = {};
|
|
100
|
-
const listPartial = await executeListTool(
|
|
101
|
-
{ path: root, depth: 2, hidden: true, head_limit: 0 },
|
|
102
|
-
process.cwd(),
|
|
103
|
-
{ readdirImpl: partialReaddir, resultTelemetry: listTelemetry },
|
|
104
|
-
);
|
|
105
|
-
assert.match(listPartial, /\[warning\] readdir failed \(EIO\):/);
|
|
106
|
-
assert.equal(listTelemetry.integrity?.status, 'partial');
|
|
107
|
-
assert.doesNotMatch(listPartial, /nested\.txt/);
|
|
108
|
-
assert.match(
|
|
109
|
-
await executeListTool({ path: root, depth: 2, hidden: true, head_limit: 0 }, process.cwd()),
|
|
110
|
-
/child[\\/]nested\.txt\tfile/,
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const treeTelemetry = {};
|
|
114
|
-
const treePartial = await executeTreeTool(
|
|
115
|
-
{ path: root, depth: 2, hidden: true, head_limit: 0 },
|
|
116
|
-
process.cwd(),
|
|
117
|
-
{ readdirImpl: partialReaddir, resultTelemetry: treeTelemetry },
|
|
118
|
-
);
|
|
119
|
-
assert.match(treePartial, /\[warning\] readdir failed \(EIO\):/);
|
|
120
|
-
assert.equal(treeTelemetry.integrity?.status, 'partial');
|
|
121
|
-
assert.doesNotMatch(treePartial, /nested\.txt/);
|
|
122
|
-
assert.match(
|
|
123
|
-
await executeTreeTool({ path: root, depth: 2, hidden: true, head_limit: 0 }, process.cwd()),
|
|
124
|
-
/nested\.txt/,
|
|
125
|
-
);
|
|
126
|
-
} finally {
|
|
127
|
-
await rm(root, { recursive: true, force: true });
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('a successful empty walk is explicitly traceable as integrity-checked', async () => {
|
|
132
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-list-empty-'));
|
|
133
|
-
const resultTelemetry = {};
|
|
134
|
-
try {
|
|
135
|
-
assert.match(
|
|
136
|
-
await executeListTool(
|
|
137
|
-
{ path: root, hidden: true },
|
|
138
|
-
process.cwd(),
|
|
139
|
-
{ resultTelemetry },
|
|
140
|
-
),
|
|
141
|
-
/\(empty directory\)/,
|
|
142
|
-
);
|
|
143
|
-
assert.deepEqual(resultTelemetry.integrity, {
|
|
144
|
-
kind: 'directory-walk',
|
|
145
|
-
status: 'empty',
|
|
146
|
-
entriesVisited: 0,
|
|
147
|
-
warnings: 0,
|
|
148
|
-
});
|
|
149
|
-
} finally {
|
|
150
|
-
await rm(root, { recursive: true, force: true });
|
|
151
|
-
}
|
|
152
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
_noteSearchTimeoutForTest,
|
|
6
|
-
_resetNativeSearchClientForTest,
|
|
7
|
-
} from './native-search-client.mjs';
|
|
8
|
-
|
|
9
|
-
// `noteSearchTimeout` returns 'runtime' for a recurrence inside the window;
|
|
10
|
-
// that is the only branch the caller acts on (settleTimeout →
|
|
11
|
-
// reportRuntimeWorkerUnhealthy), so 'shard' was a stale expectation.
|
|
12
|
-
test('native search keeps the server on a first timeout and marks the runtime worker on a 30s recurrence', () => {
|
|
13
|
-
_resetNativeSearchClientForTest();
|
|
14
|
-
const startedAt = 1_000_000;
|
|
15
|
-
const firstServer = {};
|
|
16
|
-
const replacementServer = {};
|
|
17
|
-
const laterServer = {};
|
|
18
|
-
assert.equal(_noteSearchTimeoutForTest(firstServer, startedAt), 'server');
|
|
19
|
-
assert.equal(_noteSearchTimeoutForTest(firstServer, startedAt + 1), 'none');
|
|
20
|
-
assert.equal(_noteSearchTimeoutForTest(replacementServer, startedAt + 29_999), 'runtime');
|
|
21
|
-
assert.equal(_noteSearchTimeoutForTest(replacementServer, startedAt + 30_000), 'none');
|
|
22
|
-
assert.equal(_noteSearchTimeoutForTest(laterServer, startedAt + 60_001), 'server');
|
|
23
|
-
_resetNativeSearchClientForTest();
|
|
24
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
bindChildLifecycle,
|
|
6
|
-
createNativeSearchTransport,
|
|
7
|
-
} from './native-search-transport.mjs';
|
|
8
|
-
|
|
9
|
-
test('search transport stays unavailable until the verified child binary exists', () => {
|
|
10
|
-
assert.equal(createNativeSearchTransport({ binaryPath: null, cwd: process.cwd() }), null);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('child stdin failures are routed through the lifecycle error handler', () => {
|
|
14
|
-
const errors = [];
|
|
15
|
-
const listeners = {};
|
|
16
|
-
const child = {
|
|
17
|
-
on(name, handler) { listeners[name] = handler; },
|
|
18
|
-
stdin: { on(name, handler) { listeners[`stdin:${name}`] = handler; } },
|
|
19
|
-
};
|
|
20
|
-
bindChildLifecycle(child, { onError: (error) => errors.push(error) });
|
|
21
|
-
const expected = new Error('EPIPE');
|
|
22
|
-
listeners['stdin:error'](expected);
|
|
23
|
-
assert.deepEqual(errors, [expected]);
|
|
24
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Dependency/cache trees stay hidden by default, but a caller who NAMES one is
|
|
2
|
-
// asking for it, and a clean fuzzy miss must not report a file that exists as
|
|
3
|
-
// absent.
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import test from 'node:test';
|
|
9
|
-
|
|
10
|
-
import { executeBuiltinTool } from '../builtin.mjs';
|
|
11
|
-
|
|
12
|
-
async function withNoiseTree(run) {
|
|
13
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-noise-vis-'));
|
|
14
|
-
try {
|
|
15
|
-
await mkdir(join(root, '__pycache__'), { recursive: true });
|
|
16
|
-
await mkdir(join(root, 'src'), { recursive: true });
|
|
17
|
-
await writeFile(join(root, '__pycache__', 'convert_masks.cpython-311.pyc'), 'cached MARKER blob\n');
|
|
18
|
-
await writeFile(join(root, 'src', 'app.py'), 'print("hello")\n');
|
|
19
|
-
return await run(root);
|
|
20
|
-
} finally {
|
|
21
|
-
await rm(root, { recursive: true, force: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
test('a glob that names a pruned directory searches inside it', async () => {
|
|
26
|
-
await withNoiseTree(async (root) => {
|
|
27
|
-
const named = String(await executeBuiltinTool('glob', { pattern: '__pycache__/*.pyc' }, root));
|
|
28
|
-
assert.match(named, /convert_masks\.cpython-311\.pyc/);
|
|
29
|
-
|
|
30
|
-
// Unnamed: the default prune still applies, so noise stays out of a
|
|
31
|
-
// broad sweep.
|
|
32
|
-
const broad = String(await executeBuiltinTool('glob', { pattern: '**/*.pyc' }, root));
|
|
33
|
-
assert.match(broad, /no files found/);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('a grep glob filter that names a pruned directory searches inside it', async () => {
|
|
38
|
-
await withNoiseTree(async (root) => {
|
|
39
|
-
const out = String(await executeBuiltinTool('grep', {
|
|
40
|
-
pattern: 'MARKER',
|
|
41
|
-
path: '.',
|
|
42
|
-
glob: '__pycache__/*.pyc',
|
|
43
|
-
mode: 'files',
|
|
44
|
-
}, root));
|
|
45
|
-
assert.match(out, /convert_masks/);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('a clean fuzzy miss reports that the hit exists in a skipped tree', async () => {
|
|
50
|
-
await withNoiseTree(async (root) => {
|
|
51
|
-
const out = String(await executeBuiltinTool('find', { query: 'convert_masks' }, root));
|
|
52
|
-
assert.match(out, /no fuzzy match/);
|
|
53
|
-
assert.match(out, /include_noise:true/);
|
|
54
|
-
// The default answer still lists no dependency path.
|
|
55
|
-
assert.doesNotMatch(out, /convert_masks\.cpython-311\.pyc/);
|
|
56
|
-
|
|
57
|
-
// The flag it names actually produces the file.
|
|
58
|
-
const noisy = String(await executeBuiltinTool('find', {
|
|
59
|
-
query: 'convert_masks',
|
|
60
|
-
include_noise: true,
|
|
61
|
-
}, root));
|
|
62
|
-
assert.match(noisy, /convert_masks\.cpython-311\.pyc/);
|
|
63
|
-
|
|
64
|
-
// A query with no file behind it stays a plain miss.
|
|
65
|
-
const missing = String(await executeBuiltinTool('find', { query: 'no_such_artifact_here' }, root));
|
|
66
|
-
assert.match(missing, /no fuzzy match/);
|
|
67
|
-
assert.doesNotMatch(missing, /include_noise:true/);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
|
|
7
|
-
import { executeBuiltinTool } from '../builtin.mjs';
|
|
8
|
-
|
|
9
|
-
function lines(fileTag, count) {
|
|
10
|
-
return Array.from({ length: count }, (_, i) => `${fileTag} line-${i + 1}`).join('\n') + '\n';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
test('multi-file glob fan-out caps the survey window at 25 lines per file', async () => {
|
|
14
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-read-glob-survey-'));
|
|
15
|
-
try {
|
|
16
|
-
await writeFile(join(root, 'a.log'), lines('alpha', 200));
|
|
17
|
-
await writeFile(join(root, 'b.log'), lines('beta', 200));
|
|
18
|
-
const out = await executeBuiltinTool('read', { file_path: join(root, '*.log') }, root);
|
|
19
|
-
assert.equal(typeof out, 'string');
|
|
20
|
-
// Head of each file is present…
|
|
21
|
-
assert.match(out, /alpha line-1\b/);
|
|
22
|
-
assert.match(out, /beta line-1\b/);
|
|
23
|
-
assert.match(out, /alpha line-25\b/);
|
|
24
|
-
assert.match(out, /beta line-25\b/);
|
|
25
|
-
assert.doesNotMatch(out, /alpha line-26\b/);
|
|
26
|
-
assert.doesNotMatch(out, /beta line-26\b/);
|
|
27
|
-
} finally {
|
|
28
|
-
await rm(root, { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('explicit limit is clamped to 25 lines per glob-expanded file', async () => {
|
|
33
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-read-glob-explicit-'));
|
|
34
|
-
try {
|
|
35
|
-
await writeFile(join(root, 'a.log'), lines('alpha', 200));
|
|
36
|
-
await writeFile(join(root, 'b.log'), lines('beta', 200));
|
|
37
|
-
const out = await executeBuiltinTool('read', { file_path: join(root, '*.log'), limit: 150 }, root);
|
|
38
|
-
assert.match(out, /alpha line-25\b/);
|
|
39
|
-
assert.doesNotMatch(out, /alpha line-26\b/);
|
|
40
|
-
} finally {
|
|
41
|
-
await rm(root, { recursive: true, force: true });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('glob fan-out shares a 10 KB output budget across files', async () => {
|
|
46
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-read-glob-budget-'));
|
|
47
|
-
try {
|
|
48
|
-
const payload = 'x'.repeat(300);
|
|
49
|
-
for (let i = 0; i < 10; i++) {
|
|
50
|
-
await writeFile(join(root, `${i}.log`), lines(`${i}-${payload}`, 25));
|
|
51
|
-
}
|
|
52
|
-
const out = await executeBuiltinTool('read', { file_path: join(root, '*.log'), limit: 25 }, root);
|
|
53
|
-
assert.ok(Buffer.byteLength(out, 'utf8') <= 10 * 1024);
|
|
54
|
-
assert.match(out, /0\.log/);
|
|
55
|
-
assert.match(out, /9\.log/);
|
|
56
|
-
} finally {
|
|
57
|
-
await rm(root, { recursive: true, force: true });
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('single-file glob match uses the same 25-line cap', async () => {
|
|
62
|
-
const root = await mkdtemp(join(tmpdir(), 'mixdog-read-glob-single-'));
|
|
63
|
-
try {
|
|
64
|
-
await writeFile(join(root, 'only.log'), lines('solo', 200));
|
|
65
|
-
const out = await executeBuiltinTool('read', { file_path: join(root, '*.log') }, root);
|
|
66
|
-
assert.match(out, /solo line-25\b/);
|
|
67
|
-
assert.doesNotMatch(out, /solo line-26\b/);
|
|
68
|
-
} finally {
|
|
69
|
-
await rm(root, { recursive: true, force: true });
|
|
70
|
-
}
|
|
71
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import test from 'node:test';
|
|
7
|
-
|
|
8
|
-
import { describeGitStartupState } from './runtime-capabilities.mjs';
|
|
9
|
-
|
|
10
|
-
const gitAvailable = spawnSync('git', ['--version'], {
|
|
11
|
-
encoding: 'utf8',
|
|
12
|
-
windowsHide: true,
|
|
13
|
-
}).status === 0;
|
|
14
|
-
|
|
15
|
-
test('Git startup state reports clean and dirty repository snapshots', {
|
|
16
|
-
skip: gitAvailable ? false : 'git is unavailable',
|
|
17
|
-
}, () => {
|
|
18
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-git-startup-'));
|
|
19
|
-
try {
|
|
20
|
-
assert.equal(spawnSync('git', ['init', '-q'], {
|
|
21
|
-
cwd: root,
|
|
22
|
-
encoding: 'utf8',
|
|
23
|
-
windowsHide: true,
|
|
24
|
-
}).status, 0);
|
|
25
|
-
|
|
26
|
-
const clean = describeGitStartupState({
|
|
27
|
-
cwd: root,
|
|
28
|
-
capabilities: { available: ['git'] },
|
|
29
|
-
});
|
|
30
|
-
assert.match(clean, /Git startup state: repository root /);
|
|
31
|
-
assert.match(clean, /; clean\.$/);
|
|
32
|
-
|
|
33
|
-
writeFileSync(join(root, 'dirty.txt'), 'dirty\n');
|
|
34
|
-
const dirty = describeGitStartupState({
|
|
35
|
-
cwd: root,
|
|
36
|
-
capabilities: { available: ['git'] },
|
|
37
|
-
});
|
|
38
|
-
assert.match(dirty, /; changes present\.$/);
|
|
39
|
-
} finally {
|
|
40
|
-
rmSync(root, { recursive: true, force: true });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('Git startup state preserves the non-repository message', () => {
|
|
45
|
-
const root = mkdtempSync(join(tmpdir(), 'mixdog-nonrepo-startup-'));
|
|
46
|
-
try {
|
|
47
|
-
const state = describeGitStartupState({
|
|
48
|
-
cwd: root,
|
|
49
|
-
capabilities: { available: ['git'] },
|
|
50
|
-
});
|
|
51
|
-
assert.match(state, /was not inside a git repository at startup/);
|
|
52
|
-
assert.doesNotMatch(state, /; (?:clean|changes present)\./);
|
|
53
|
-
} finally {
|
|
54
|
-
rmSync(root, { recursive: true, force: true });
|
|
55
|
-
}
|
|
56
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { rootScanIgnoreGlobs } from './search-builders.mjs';
|
|
4
|
-
|
|
5
|
-
test('root-anchored kernel-tree prunes apply only to a posix filesystem-root scan', () => {
|
|
6
|
-
assert.deepEqual(
|
|
7
|
-
rootScanIgnoreGlobs('/', 'linux'),
|
|
8
|
-
['!proc/**', '!sys/**', '!dev/**'],
|
|
9
|
-
);
|
|
10
|
-
// Scans rooted elsewhere — including inside a kernel tree — are untouched.
|
|
11
|
-
assert.deepEqual(rootScanIgnoreGlobs('/proc', 'linux'), []);
|
|
12
|
-
assert.deepEqual(rootScanIgnoreGlobs('/home/user/project', 'linux'), []);
|
|
13
|
-
assert.deepEqual(rootScanIgnoreGlobs('', 'linux'), []);
|
|
14
|
-
// Windows has no kernel-virtual mounts; the helper is a no-op there.
|
|
15
|
-
assert.deepEqual(rootScanIgnoreGlobs('/', 'win32'), []);
|
|
16
|
-
});
|