pi-harness-runtime 1.1.440 → 1.1.441
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/harness/e2e/auto-test-loop.ts +2 -0
- package/harness/e2e/browser-scrapers/base-browser-scraper.ts +2 -0
- package/harness/e2e/browser-scrapers/chrome-profile-manager.ts +2 -0
- package/harness/e2e/browser-scrapers/codex-browser-scraper.ts +2 -0
- package/harness/e2e/tools-detector.ts +2 -0
- package/harness/key-loader.ts +2 -0
- package/harness/langchain/checkpointer.ts +2 -0
- package/harness/langchain/cron-cli.ts +2 -0
- package/harness/langchain/graph.ts +2 -0
- package/harness/notification-center.ts +2 -0
- package/harness/secret-provider.ts +2 -0
- package/index.ts +2 -0
- package/package.json +7 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/dist/extension.d.ts.map +1 -1
- package/packages/agent-policy/dist/extension.js +2 -0
- package/packages/agent-policy/dist/extension.js.map +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/agent-policy/src/extension.ts +2 -0
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/dist/minimax-browser-auth.d.ts.map +1 -1
- package/packages/auth/dist/minimax-browser-auth.js +23 -1
- package/packages/auth/dist/minimax-browser-auth.js.map +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/auth/src/minimax-browser-auth.ts +30 -5
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/dist/inbox.d.ts.map +1 -1
- package/packages/autonomous-runtime/dist/inbox.js +2 -0
- package/packages/autonomous-runtime/dist/inbox.js.map +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/autonomous-runtime/src/inbox.ts +2 -0
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
- package/packages/clipboard/dist/src/clipboard.js +2 -0
- package/packages/clipboard/dist/src/clipboard.js.map +1 -1
- package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -1
- package/packages/clipboard/dist/src/copy-sync.js +2 -0
- package/packages/clipboard/dist/src/copy-sync.js.map +1 -1
- package/packages/clipboard/dist/src/gist-relay.d.ts.map +1 -1
- package/packages/clipboard/dist/src/gist-relay.js +2 -0
- package/packages/clipboard/dist/src/gist-relay.js.map +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard/src/clipboard.ts +2 -0
- package/packages/clipboard/src/copy-sync.ts +2 -0
- package/packages/clipboard/src/gist-relay.ts +2 -0
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/delegation-store.js +1 -4
- package/packages/contracts/dist/workspace-env.js +28 -1
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/src/delegation-store.ts +9 -4
- package/packages/contracts/src/workspace-env.ts +29 -4
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/dist/src/store.d.ts.map +1 -1
- package/packages/event-store/dist/src/store.js +2 -0
- package/packages/event-store/dist/src/store.js.map +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/event-store/src/store.ts +3 -0
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/dist/analyzer.d.ts.map +1 -1
- package/packages/generic-web-plugin/dist/analyzer.js +2 -0
- package/packages/generic-web-plugin/dist/analyzer.js.map +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/generic-web-plugin/src/analyzer.ts +3 -0
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/dist/mcp-client.d.ts.map +1 -1
- package/packages/knowledge-retrieval/dist/mcp-client.js +0 -1
- package/packages/knowledge-retrieval/dist/mcp-client.js.map +1 -1
- package/packages/knowledge-retrieval/package.json +1 -4
- package/packages/knowledge-retrieval/src/mcp-client.ts +0 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/mcp-adapter/dist/server.d.ts.map +1 -1
- package/packages/mcp-adapter/dist/server.js +2 -0
- package/packages/mcp-adapter/dist/server.js.map +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/mcp-adapter/src/server.ts +3 -0
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/dist/index.d.ts.map +1 -1
- package/packages/paperclip-integration/dist/index.js +2 -0
- package/packages/paperclip-integration/dist/index.js.map +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/paperclip-integration/src/index.ts +2 -0
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/dist/audit.d.ts.map +1 -1
- package/packages/privilege-broker/dist/audit.js +2 -0
- package/packages/privilege-broker/dist/audit.js.map +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/privilege-broker/src/audit.ts +2 -0
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/dist/compiler.d.ts.map +1 -1
- package/packages/prompt-compiler/dist/compiler.js +2 -0
- package/packages/prompt-compiler/dist/compiler.js.map +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-compiler/src/compiler.ts +2 -0
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/dist/client.d.ts.map +1 -1
- package/packages/skill-mcp-client/dist/client.js +0 -1
- package/packages/skill-mcp-client/dist/client.js.map +1 -1
- package/packages/skill-mcp-client/package.json +1 -4
- package/packages/skill-mcp-client/src/client.ts +0 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/dist/parser.d.ts.map +1 -1
- package/packages/skills/dist/parser.js +2 -0
- package/packages/skills/dist/parser.js.map +1 -1
- package/packages/skills/dist/skill-versioning.d.ts.map +1 -1
- package/packages/skills/dist/skill-versioning.js +2 -0
- package/packages/skills/dist/skill-versioning.js.map +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/skills/src/parser.ts +3 -0
- package/packages/skills/src/skill-versioning.ts +2 -0
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/dist/index.js +0 -2
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/webmcp-tester/src/index.ts +0 -3
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/dist/trigger.d.ts.map +1 -1
- package/packages/write-review/dist/trigger.js +1 -2
- package/packages/write-review/dist/trigger.js.map +1 -1
- package/packages/write-review/package.json +1 -1
- package/packages/write-review/src/trigger.ts +1 -2
- package/scripts/lib/runtime-imports.ts +189 -3
- package/scripts/telegram-webhook-server.ts +2 -0
- package/scripts/verify-package-contents.ts +148 -1
- package/harness/e2e/tools-detector.test.ts +0 -155
- package/harness/glm-quota-countdown.test.ts +0 -323
- package/harness/langchain/agents.test.ts +0 -39
- package/harness/langchain/checkpointer.test.ts +0 -243
- package/harness/langchain/daemon.test.ts +0 -459
- package/harness/langchain/model-router.test.ts +0 -191
- package/harness/langchain/ping-pong-middleware.test.ts +0 -69
- package/harness/langchain/scoreboard.test.ts +0 -267
- package/harness/langchain/status-line.test.ts +0 -106
- package/harness/langchain/surge.test.ts +0 -467
- package/harness/langchain/widget.test.ts +0 -251
- package/harness/skill-sync.test.ts +0 -57
- package/harness/ssh-detach-interceptor.test.ts +0 -263
- package/harness/ssh-hang-recovery.test.ts +0 -86
- package/packages/a2a-adapter/test/a2a.test.ts +0 -151
- package/packages/agent-policy/test/interlock.test.ts +0 -101
- package/packages/agent-policy/test/policy-retention.test.ts +0 -380
- package/packages/agent-policy/test/policy.test.ts +0 -387
- package/packages/auth/test/auth.test.ts +0 -238
- package/packages/autonomous-refactor/test/refactor.test.ts +0 -202
- package/packages/autonomous-runtime/test/types.test.ts +0 -95
- package/packages/cache-strategy/test/cache.test.ts +0 -137
- package/packages/capability-registry/test/registry.test.ts +0 -204
- package/packages/checkpoint/test/engine.test.ts +0 -265
- package/packages/cli-plugin-sdk/test/cli.test.ts +0 -45
- package/packages/code-generation/test/generator.test.ts +0 -238
- package/packages/code-review/test/engine.test.ts +0 -302
- package/packages/codex-adapter/test/provider.test.ts +0 -142
- package/packages/codex-watcher/test/watch.test.ts +0 -453
- package/packages/context-compiler/test/context-compiler.test.ts +0 -746
- package/packages/context-manager/test/context.test.ts +0 -198
- package/packages/contracts/test/delegation.test.ts +0 -350
- package/packages/contracts/test/workspace-env.test.ts +0 -802
- package/packages/cookie-sanitizer/test/infer.test.ts +0 -110
- package/packages/cookie-sanitizer/test/normalize.test.ts +0 -113
- package/packages/cookie-sanitizer/test/parse.test.ts +0 -204
- package/packages/cookie-sanitizer/test/sync.test.ts +0 -237
- package/packages/cookie-sanitizer/test/watcher.test.ts +0 -27
- package/packages/cost-optimizer/test/cost-optimizer.test.ts +0 -438
- package/packages/dependency-analyzer/test/analyzer.test.ts +0 -49
- package/packages/django-plugin/test/analyzer.test.ts +0 -195
- package/packages/doc-generator/test/docs.test.ts +0 -168
- package/packages/durable-review/test/acceptance.test.ts +0 -357
- package/packages/durable-review/test/smoke.test.ts +0 -107
- package/packages/evaluation-engine/test/engine.test.ts +0 -277
- package/packages/evaluation-runner/test/runner.test.ts +0 -168
- package/packages/event-bus/test/bus.test.ts +0 -100
- package/packages/event-store/test/store.test.ts +0 -115
- package/packages/experience-replay/test/replay.test.ts +0 -267
- package/packages/feedback-collector/test/collector.test.ts +0 -142
- package/packages/framework-detector/test/detector.test.ts +0 -75
- package/packages/framework-plugin-sdk/test/manager.test.ts +0 -320
- package/packages/frappe-plugin/test/analyzer.test.ts +0 -250
- package/packages/generic-web-plugin/test/analyzer.test.ts +0 -134
- package/packages/health-monitor/test/health.test.ts +0 -231
- package/packages/intent-analyzer/test/analyzer.test.ts +0 -72
- package/packages/intent-analyzer/test/ping-pong.test.ts +0 -96
- package/packages/jev-judge/tests/auto-continue-context.test.ts +0 -280
- package/packages/jev-judge/tests/continuation-controller.test.ts +0 -1396
- package/packages/jev-judge/tests/jev-provider-chain.test.ts +0 -536
- package/packages/jev-judge/tests/outcome-application.test.ts +0 -132
- package/packages/jev-judge/tests/question-risk.test.ts +0 -129
- package/packages/jev-judge/tests/typesafe-provider.test.ts +0 -640
- package/packages/jev-judge/tests/validation-ledger.test.ts +0 -181
- package/packages/jev-judge/tests/validation-plan.test.ts +0 -170
- package/packages/jev-judge/tests/validation-tie-breaker.test.ts +0 -88
- package/packages/laravel-plugin/test/analyzer.test.ts +0 -220
- package/packages/learning-engine/test/engine.test.ts +0 -331
- package/packages/logging/test/buffer.test.ts +0 -44
- package/packages/logging/test/classification.test.ts +0 -137
- package/packages/logging/test/config.test.ts +0 -97
- package/packages/logging/test/fanout.test.ts +0 -186
- package/packages/logging/test/identity-transport.test.ts +0 -197
- package/packages/logging/test/incidents.test.ts +0 -404
- package/packages/logging/test/ingest-schema.test.ts +0 -184
- package/packages/logging/test/integration.test.ts +0 -140
- package/packages/logging/test/log-http.test.ts +0 -246
- package/packages/logging/test/redact.test.ts +0 -109
- package/packages/logging/test/sampler.test.ts +0 -57
- package/packages/logging/test/server.test.ts +0 -444
- package/packages/logging/test/shipper.test.ts +0 -152
- package/packages/logging/test/spool.test.ts +0 -96
- package/packages/mcp-adapter/test/server.test.ts +0 -91
- package/packages/memory-engine/test/engine.test.ts +0 -456
- package/packages/model-registry/test/registry.test.ts +0 -342
- package/packages/nextjs-plugin/test/analyzer.test.ts +0 -149
- package/packages/notification/test/approval-payload.test.ts +0 -269
- package/packages/notification/test/detail-format.test.ts +0 -106
- package/packages/notification/test/notification.test.ts +0 -375
- package/packages/notification/test/pending-question-lifecycle.test.ts +0 -195
- package/packages/notification/test/pending-question.test.ts +0 -331
- package/packages/notification/test/tooling-proposal-payload.test.ts +0 -212
- package/packages/observability/test/observability.test.ts +0 -1350
- package/packages/performance-optimizer/test/optimizer.test.ts +0 -267
- package/packages/project-analyzer/test/index.test.ts +0 -1719
- package/packages/prompt-compiler/test/prompt-compiler.test.ts +0 -813
- package/packages/prompt-versioning/test/versioning.test.ts +0 -112
- package/packages/provider-adapter-sdk/test/sdk.test.ts +0 -220
- package/packages/provider-router/test/provider-router.test.ts +0 -405
- package/packages/provider-selector/test/selector.test.ts +0 -192
- package/packages/providers/test/providers.test.ts +0 -225
- package/packages/qdrant-skills/test/collection-info.test.ts +0 -165
- package/packages/qdrant-skills/test/embedder-batch.test.ts +0 -184
- package/packages/qdrant-skills/test/embedder.test.ts +0 -97
- package/packages/quota-manager/test/quota.test.ts +0 -432
- package/packages/rate-limiter/test/limiter.test.ts +0 -128
- package/packages/react-vite-plugin/test/analyzer.test.ts +0 -139
- package/packages/relay/test/client.test.ts +0 -446
- package/packages/relay/test/relay-e2e.test.ts +0 -299
- package/packages/relay/test/relay-endpoint.test.ts +0 -278
- package/packages/release-manager/test/release.test.ts +0 -215
- package/packages/requirement-compiler/test/requirement-compiler.test.ts +0 -743
- package/packages/runtime/test/runtime-api.test.ts +0 -169
- package/packages/runtime/test/runtime.test.ts +0 -297
- package/packages/scheduler/test/scheduler.test.ts +0 -125
- package/packages/session/test/manager.test.ts +0 -233
- package/packages/shared-context/test/shared-context.test.ts +0 -114
- package/packages/skill-registry/test/registry.test.ts +0 -508
- package/packages/skills/test/init-skills.test.ts +0 -114
- package/packages/skills/test/remote-skills.test.ts +0 -360
- package/packages/skills/test/remote-source.test.ts +0 -248
- package/packages/skills/test/sanitize.test.ts +0 -250
- package/packages/skills/test/vector-indexing.test.ts +0 -205
- package/packages/skills/test/vector-schema.test.ts +0 -180
- package/packages/skills/test/vector-threshold.test.ts +0 -108
- package/packages/sprint-planner/test/planner.test.ts +0 -187
- package/packages/task-compiler/test/task-compiler.test.ts +0 -628
- package/packages/test-data-generator/test/generator.test.ts +0 -265
- package/packages/test-generator/test/generator.test.ts +0 -156
- package/packages/token-estimation/test/token-estimation.test.ts +0 -207
- package/packages/token-optimizer/test/optimizer.test.ts +0 -141
- package/packages/tooling-preference/tests/changed-files.test.ts +0 -124
- package/packages/tooling-preference/tests/detect.test.ts +0 -188
- package/packages/tooling-preference/tests/proposal.test.ts +0 -107
- package/packages/tooling-preference/tests/quality-check.test.ts +0 -272
- package/packages/tooling-preference/tests/registry.test.ts +0 -51
- package/packages/tooling-preference/tests/store.test.ts +0 -99
- package/packages/trajectory/test/store.test.ts +0 -250
- package/packages/tui/test/harness-footer.test.ts +0 -559
- package/packages/tui/test/harness-header.test.ts +0 -590
- package/packages/two-phase-review/test/classify.test.ts +0 -102
- package/packages/two-phase-review/test/helpers.ts +0 -72
- package/packages/two-phase-review/test/rules.test.ts +0 -150
- package/packages/two-phase-review/test/runtime.test.ts +0 -362
- package/packages/two-phase-review/test/scope.test.ts +0 -186
- package/packages/two-phase-review/test/signals.test.ts +0 -183
- package/packages/two-phase-review/test/state.test.ts +0 -201
- package/packages/wiki/test/basic.test.ts +0 -242
- package/packages/workspace-scanner/test/scanner.test.ts +0 -43
- package/packages/worktree/test/worktree.test.ts +0 -163
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The post-change quality check.
|
|
3
|
-
*
|
|
4
|
-
* The saved preference decides the tool: Biome when the user asked for it,
|
|
5
|
-
* the project's own script otherwise. The check never writes and never runs
|
|
6
|
-
* without a decision of the user.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect, afterEach } from "bun:test";
|
|
10
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
-
import { tmpdir } from "node:os";
|
|
12
|
-
import { join } from "node:path";
|
|
13
|
-
import {
|
|
14
|
-
formatQualityCheckStatus,
|
|
15
|
-
runQualityCheck,
|
|
16
|
-
selectQualityCheck,
|
|
17
|
-
} from "../src/quality-check.js";
|
|
18
|
-
import type { ToolingContext } from "../src/detect.js";
|
|
19
|
-
|
|
20
|
-
const cleanups: string[] = [];
|
|
21
|
-
|
|
22
|
-
function workspace(pkg: unknown, files: Record<string, string> = {}): string {
|
|
23
|
-
const root = mkdtempSync(join(tmpdir(), "tooling-check-"));
|
|
24
|
-
cleanups.push(root);
|
|
25
|
-
writeFileSync(join(root, "package.json"), JSON.stringify(pkg), "utf8");
|
|
26
|
-
for (const [name, content] of Object.entries(files)) {
|
|
27
|
-
writeFileSync(join(root, name), content, "utf8");
|
|
28
|
-
}
|
|
29
|
-
return root;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function context(root: string, overrides: Partial<ToolingContext> = {}): ToolingContext {
|
|
33
|
-
return {
|
|
34
|
-
root,
|
|
35
|
-
hasPackageJson: true,
|
|
36
|
-
isJavaScriptTypeScript: true,
|
|
37
|
-
isNextJs: false,
|
|
38
|
-
isReact: false,
|
|
39
|
-
usesBiome: false,
|
|
40
|
-
usesEslint: true,
|
|
41
|
-
usesPrettier: false,
|
|
42
|
-
packageManager: "npm",
|
|
43
|
-
frameworks: [],
|
|
44
|
-
...overrides,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
while (cleanups.length > 0) {
|
|
50
|
-
const root = cleanups.pop();
|
|
51
|
-
if (root) rmSync(root, { recursive: true, force: true });
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("the check selection", () => {
|
|
56
|
-
it("runs Biome on the changed files when the preference asks for it", () => {
|
|
57
|
-
const root = workspace({ name: "web" });
|
|
58
|
-
const plan = selectQualityCheck({
|
|
59
|
-
context: context(root, { usesBiome: true, packageManager: "bun" }),
|
|
60
|
-
preference: "prefer_biome",
|
|
61
|
-
files: ["src/app.ts"],
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
expect(plan.tool).toBe("biome");
|
|
65
|
-
expect(plan.command).toBe("bunx");
|
|
66
|
-
expect(plan.args).toEqual(["biome", "check", "src/app.ts"]);
|
|
67
|
-
expect(plan.files).toEqual(["src/app.ts"]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("never asks Biome to fix the files", () => {
|
|
71
|
-
const root = workspace({ name: "web" });
|
|
72
|
-
const plan = selectQualityCheck({
|
|
73
|
-
context: context(root, { usesBiome: true }),
|
|
74
|
-
preference: "prefer_biome",
|
|
75
|
-
files: ["src/app.ts"],
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
expect(plan.args.join(" ")).not.toContain("--write");
|
|
79
|
-
expect(plan.args.join(" ")).not.toContain("--fix");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("runs the project script when the preference keeps the project tools", () => {
|
|
83
|
-
const root = workspace({ name: "web", scripts: { lint: "eslint ." } });
|
|
84
|
-
const plan = selectQualityCheck({
|
|
85
|
-
context: context(root),
|
|
86
|
-
preference: "use_project_tools",
|
|
87
|
-
files: ["src/app.ts"],
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(plan.tool).toBe("project");
|
|
91
|
-
expect(plan.command).toBe("npm");
|
|
92
|
-
expect(plan.args).toEqual(["run", "lint"]);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("falls back to the project script when Biome is not installed yet", () => {
|
|
96
|
-
const root = workspace({ name: "web", scripts: { lint: "eslint ." } });
|
|
97
|
-
const plan = selectQualityCheck({
|
|
98
|
-
context: context(root, { usesBiome: false }),
|
|
99
|
-
preference: "prefer_biome",
|
|
100
|
-
files: ["src/app.ts"],
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
expect(plan.tool).toBe("project");
|
|
104
|
-
expect(plan.reason).toContain("Biome is not installed");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("checks nothing without a decision of the user", () => {
|
|
108
|
-
const root = workspace({ name: "web", scripts: { lint: "eslint ." } });
|
|
109
|
-
const plan = selectQualityCheck({
|
|
110
|
-
context: context(root),
|
|
111
|
-
preference: undefined,
|
|
112
|
-
files: ["src/app.ts"],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
expect(plan.tool).toBe("none");
|
|
116
|
-
expect(plan.command).toBeNull();
|
|
117
|
-
expect(plan.reason).toContain("not chosen");
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("checks nothing when no file changed", () => {
|
|
121
|
-
const root = workspace({ name: "web", scripts: { lint: "eslint ." } });
|
|
122
|
-
const plan = selectQualityCheck({
|
|
123
|
-
context: context(root),
|
|
124
|
-
preference: "use_project_tools",
|
|
125
|
-
files: [],
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
expect(plan.tool).toBe("none");
|
|
129
|
-
expect(plan.reason).toContain("no JavaScript/TypeScript file changed");
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("checks nothing when the project has no script to run", () => {
|
|
133
|
-
const root = workspace({ name: "web" });
|
|
134
|
-
const plan = selectQualityCheck({
|
|
135
|
-
context: context(root),
|
|
136
|
-
preference: "use_project_tools",
|
|
137
|
-
files: ["src/app.ts"],
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
expect(plan.tool).toBe("none");
|
|
141
|
-
expect(plan.reason).toContain("neither a lint nor a typecheck");
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("uses the typecheck script when there is no lint script", () => {
|
|
145
|
-
const root = workspace({ name: "web", scripts: { typecheck: "tsc --noEmit" } });
|
|
146
|
-
const plan = selectQualityCheck({
|
|
147
|
-
context: context(root),
|
|
148
|
-
preference: "use_project_tools",
|
|
149
|
-
files: ["src/app.ts"],
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
expect(plan.command).toBe("npm");
|
|
153
|
-
expect(plan.args).toEqual(["run", "typecheck"]);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe("the check itself", () => {
|
|
158
|
-
it("reports a passing check", () => {
|
|
159
|
-
const root = workspace({ name: "web" });
|
|
160
|
-
const plan = selectQualityCheck({
|
|
161
|
-
context: context(root),
|
|
162
|
-
preference: "use_project_tools",
|
|
163
|
-
files: ["src/app.ts"],
|
|
164
|
-
});
|
|
165
|
-
const pass = {
|
|
166
|
-
tool: plan.tool,
|
|
167
|
-
command: "node",
|
|
168
|
-
args: ["-e", "process.exit(0)"],
|
|
169
|
-
files: ["src/app.ts"],
|
|
170
|
-
reason: "test",
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const result = runQualityCheck(pass, { cwd: root, timeoutMs: 10_000 });
|
|
174
|
-
|
|
175
|
-
expect(result.ran).toBe(true);
|
|
176
|
-
expect(result.passed).toBe(true);
|
|
177
|
-
expect(result.reason).toContain("passed");
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("reports a failing check", () => {
|
|
181
|
-
const root = workspace({ name: "web" });
|
|
182
|
-
const fail = {
|
|
183
|
-
tool: "project" as const,
|
|
184
|
-
command: "node",
|
|
185
|
-
args: ["-e", "process.stderr.write('problem'); process.exit(2)"],
|
|
186
|
-
files: ["src/app.ts"],
|
|
187
|
-
reason: "test",
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const result = runQualityCheck(fail, { cwd: root, timeoutMs: 10_000 });
|
|
191
|
-
|
|
192
|
-
expect(result.ran).toBe(true);
|
|
193
|
-
expect(result.passed).toBe(false);
|
|
194
|
-
expect(result.exitCode).toBe(2);
|
|
195
|
-
expect(result.output).toContain("problem");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("reports a check that cannot start", () => {
|
|
199
|
-
const result = runQualityCheck(
|
|
200
|
-
{
|
|
201
|
-
tool: "project",
|
|
202
|
-
command: "definitely-not-a-command",
|
|
203
|
-
args: [],
|
|
204
|
-
files: ["src/app.ts"],
|
|
205
|
-
reason: "test",
|
|
206
|
-
},
|
|
207
|
-
{ cwd: process.cwd(), timeoutMs: 10_000 },
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
expect(result.ran).toBe(false);
|
|
211
|
-
expect(result.reason).toContain("could not start");
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("runs nothing when the plan has no command", () => {
|
|
215
|
-
const result = runQualityCheck(
|
|
216
|
-
{ tool: "none", command: null, args: [], files: [], reason: "nothing to do" },
|
|
217
|
-
{ cwd: process.cwd(), timeoutMs: 10_000 },
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
expect(result.ran).toBe(false);
|
|
221
|
-
expect(result.passed).toBe(false);
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
describe("the status line", () => {
|
|
226
|
-
it("names the tool and the outcome", () => {
|
|
227
|
-
const line = formatQualityCheckStatus({
|
|
228
|
-
ran: true,
|
|
229
|
-
passed: true,
|
|
230
|
-
tool: "biome",
|
|
231
|
-
fileCount: 3,
|
|
232
|
-
exitCode: 0,
|
|
233
|
-
timedOut: false,
|
|
234
|
-
output: "",
|
|
235
|
-
reason: "the check passed",
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
expect(line).toBe("[TOOL] biome: 3 file(s), ok");
|
|
239
|
-
expect(/[^\x20-\x7e]/.test(line)).toBe(false);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it("names the reason when no check ran", () => {
|
|
243
|
-
const line = formatQualityCheckStatus({
|
|
244
|
-
ran: false,
|
|
245
|
-
passed: false,
|
|
246
|
-
tool: "none",
|
|
247
|
-
fileCount: 0,
|
|
248
|
-
exitCode: null,
|
|
249
|
-
timedOut: false,
|
|
250
|
-
output: "",
|
|
251
|
-
reason: "no JavaScript/TypeScript file changed",
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
expect(line).toContain("no check");
|
|
255
|
-
expect(line).toContain("no JavaScript/TypeScript file changed");
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("names a timeout", () => {
|
|
259
|
-
const line = formatQualityCheckStatus({
|
|
260
|
-
ran: true,
|
|
261
|
-
passed: false,
|
|
262
|
-
tool: "project",
|
|
263
|
-
fileCount: 2,
|
|
264
|
-
exitCode: null,
|
|
265
|
-
timedOut: true,
|
|
266
|
-
output: "",
|
|
267
|
-
reason: "the check hit the timeout",
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
expect(line).toContain("timeout");
|
|
271
|
-
});
|
|
272
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { ToolingRequestRegistry } from "../src/registry.ts";
|
|
3
|
-
|
|
4
|
-
const request = {
|
|
5
|
-
requestId: "biome-abc123",
|
|
6
|
-
workspaceRoot: "/work/web",
|
|
7
|
-
userKey: "user-1",
|
|
8
|
-
frameworks: ["next"],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe("ToolingRequestRegistry", () => {
|
|
12
|
-
it("registers a proposal once", () => {
|
|
13
|
-
const registry = new ToolingRequestRegistry();
|
|
14
|
-
expect(registry.register(request)).toBe(true);
|
|
15
|
-
expect(registry.register(request)).toBe(false);
|
|
16
|
-
expect(registry.has(request.requestId)).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("lets the first answer win", () => {
|
|
20
|
-
const registry = new ToolingRequestRegistry();
|
|
21
|
-
registry.register(request);
|
|
22
|
-
|
|
23
|
-
const first = registry.claim(request.requestId, "yes", "telegram");
|
|
24
|
-
expect(first?.resolution.preference).toBe("prefer_biome");
|
|
25
|
-
expect(first?.request.workspaceRoot).toBe("/work/web");
|
|
26
|
-
|
|
27
|
-
// The second click finds nothing - the first answer stays.
|
|
28
|
-
expect(registry.claim(request.requestId, "no", "line")).toBeNull();
|
|
29
|
-
expect(registry.resolutionOf(request.requestId)?.preference).toBe("prefer_biome");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("maps a no to the current tools", () => {
|
|
33
|
-
const registry = new ToolingRequestRegistry();
|
|
34
|
-
registry.register(request);
|
|
35
|
-
const claimed = registry.claim(request.requestId, "no", "line");
|
|
36
|
-
expect(claimed?.resolution.preference).toBe("use_project_tools");
|
|
37
|
-
expect(claimed?.resolution.channel).toBe("line");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("refuses a claim for an unknown request", () => {
|
|
41
|
-
const registry = new ToolingRequestRegistry();
|
|
42
|
-
expect(registry.claim("biome-unknown", "yes")).toBeNull();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("does not register a request that was already answered", () => {
|
|
46
|
-
const registry = new ToolingRequestRegistry();
|
|
47
|
-
registry.register(request);
|
|
48
|
-
registry.claim(request.requestId, "no");
|
|
49
|
-
expect(registry.register(request)).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
shouldAskAgain,
|
|
7
|
-
ToolingPreferenceStore,
|
|
8
|
-
toolingPreferenceKey,
|
|
9
|
-
} from "../src/store.ts";
|
|
10
|
-
|
|
11
|
-
function storePath(): string {
|
|
12
|
-
return join(mkdtempSync(join(tmpdir(), "tooling-store-")), "tooling-preference.json");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe("ToolingPreferenceStore", () => {
|
|
16
|
-
it("has no record for an unknown user and workspace", () => {
|
|
17
|
-
const path = storePath();
|
|
18
|
-
const store = new ToolingPreferenceStore(path);
|
|
19
|
-
expect(store.read("user-1", "/work/web")).toBeUndefined();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("keeps the record of a user in a workspace apart", () => {
|
|
23
|
-
const path = storePath();
|
|
24
|
-
const store = new ToolingPreferenceStore(path);
|
|
25
|
-
store.recordDecision("user-1", "/work/web", "prefer_biome", "biome-1");
|
|
26
|
-
store.recordDecision("user-2", "/work/web", "use_project_tools", "biome-2");
|
|
27
|
-
store.recordDecision("user-1", "/work/other", "use_project_tools", "biome-3");
|
|
28
|
-
|
|
29
|
-
expect(store.read("user-1", "/work/web")?.decision).toBe("prefer_biome");
|
|
30
|
-
expect(store.read("user-2", "/work/web")?.decision).toBe("use_project_tools");
|
|
31
|
-
expect(store.read("user-1", "/work/other")?.decision).toBe("use_project_tools");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("remembers that the proposal was sent", () => {
|
|
35
|
-
const path = storePath();
|
|
36
|
-
const store = new ToolingPreferenceStore(path);
|
|
37
|
-
store.markAsked("user-1", "/work/web", "biome-1");
|
|
38
|
-
const record = store.read("user-1", "/work/web");
|
|
39
|
-
expect(record?.askedAt).toBeTruthy();
|
|
40
|
-
expect(record?.requestId).toBe("biome-1");
|
|
41
|
-
expect(record?.decision).toBeUndefined();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("keeps a decision across a new store instance", () => {
|
|
45
|
-
const path = storePath();
|
|
46
|
-
new ToolingPreferenceStore(path).recordDecision(
|
|
47
|
-
"user-1",
|
|
48
|
-
"/work/web",
|
|
49
|
-
"prefer_biome",
|
|
50
|
-
"biome-1",
|
|
51
|
-
"telegram",
|
|
52
|
-
);
|
|
53
|
-
const record = new ToolingPreferenceStore(path).read("user-1", "/work/web");
|
|
54
|
-
expect(record?.decision).toBe("prefer_biome");
|
|
55
|
-
expect(record?.channel).toBe("telegram");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("survives a broken store file", () => {
|
|
59
|
-
const path = storePath();
|
|
60
|
-
const store = new ToolingPreferenceStore(path);
|
|
61
|
-
store.markAsked("user-1", "/work/web", "biome-1");
|
|
62
|
-
// A store that cannot be read must not stop the harness.
|
|
63
|
-
Bun.write(path, "not json");
|
|
64
|
-
expect(store.read("user-1", "/work/web")).toBeUndefined();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("keys a record by the user and the workspace", () => {
|
|
68
|
-
expect(toolingPreferenceKey("user-1", "/work/web")).not.toBe(
|
|
69
|
-
toolingPreferenceKey("user-2", "/work/web"),
|
|
70
|
-
);
|
|
71
|
-
expect(toolingPreferenceKey("user-1", "/work/web")).toBe(
|
|
72
|
-
toolingPreferenceKey("user-1", "/work/web"),
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("shouldAskAgain", () => {
|
|
78
|
-
const day = 24 * 60 * 60 * 1000;
|
|
79
|
-
const now = new Date("2026-10-24T12:00:00.000Z");
|
|
80
|
-
|
|
81
|
-
it("asks a workspace that was never asked", () => {
|
|
82
|
-
expect(shouldAskAgain(undefined, 30 * day, now)).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("never asks a workspace with a decision", () => {
|
|
86
|
-
const record = { decision: "prefer_biome" as const, askedAt: "2026-01-01T00:00:00.000Z" };
|
|
87
|
-
expect(shouldAskAgain(record, 30 * day, now)).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("does not ask again inside the cooldown", () => {
|
|
91
|
-
const record = { askedAt: new Date(now.getTime() - day).toISOString() };
|
|
92
|
-
expect(shouldAskAgain(record, 30 * day, now)).toBe(false);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("asks again after the cooldown", () => {
|
|
96
|
-
const record = { askedAt: new Date(now.getTime() - 31 * day).toISOString() };
|
|
97
|
-
expect(shouldAskAgain(record, 30 * day, now)).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { describe, it, beforeEach } from "node:test";
|
|
2
|
-
import assert from "node:assert";
|
|
3
|
-
import { rmSync, mkdirSync, readdirSync, readFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { homedir } from "node:os";
|
|
6
|
-
import { TrajectoryStore, resetTrajectoryStore } from "../src/store.js";
|
|
7
|
-
|
|
8
|
-
const TEST_DIR = join(homedir(), ".pi-harness-test-trajectories");
|
|
9
|
-
|
|
10
|
-
function freshStore(): TrajectoryStore {
|
|
11
|
-
rmSync(TEST_DIR, { force: true, recursive: true });
|
|
12
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
13
|
-
return new TrajectoryStore(TEST_DIR);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("TrajectoryStore", () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
rmSync(TEST_DIR, { force: true, recursive: true });
|
|
19
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
20
|
-
resetTrajectoryStore();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("start() returns a UUID", () => {
|
|
24
|
-
const store = freshStore();
|
|
25
|
-
const id = store.start("test task");
|
|
26
|
-
assert.match(id, /^[0-9a-f-]{36}$/);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("append() writes NDJSON to the correct daily file", () => {
|
|
30
|
-
const store = freshStore();
|
|
31
|
-
const id = "test-id-123";
|
|
32
|
-
const now = new Date();
|
|
33
|
-
|
|
34
|
-
store.append({
|
|
35
|
-
id,
|
|
36
|
-
taskRequest: "fix the login bug",
|
|
37
|
-
createdAt: now.toISOString(),
|
|
38
|
-
durationMs: 5000,
|
|
39
|
-
iterations: 2,
|
|
40
|
-
verdict: "approved",
|
|
41
|
-
reason: "reviewer approved",
|
|
42
|
-
plan: "# Plan\n1. Fix it",
|
|
43
|
-
code: "// fixed",
|
|
44
|
-
files: ["auth.ts"],
|
|
45
|
-
comments: [{ file: "auth.ts", comment: "looks good", severity: "minor" }],
|
|
46
|
-
summary: "looks good",
|
|
47
|
-
classified: false,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Should have created a daily file
|
|
51
|
-
const files = readdirSync(TEST_DIR);
|
|
52
|
-
assert.ok(files.length > 0, "should create at least one directory");
|
|
53
|
-
|
|
54
|
-
// Navigate to the daily file
|
|
55
|
-
const monthDir = files[0];
|
|
56
|
-
const monthFiles = readdirSync(join(TEST_DIR, monthDir));
|
|
57
|
-
assert.ok(monthFiles.length > 0, "should create daily ndjson file");
|
|
58
|
-
|
|
59
|
-
const content = readFileSync(join(TEST_DIR, monthDir, monthFiles[0]), "utf8");
|
|
60
|
-
const record = JSON.parse(content.split("\n").find((l) => l.trim())!);
|
|
61
|
-
assert.strictEqual(record.id, id);
|
|
62
|
-
assert.strictEqual(record.verdict, "approved");
|
|
63
|
-
assert.strictEqual(record.iterations, 2);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("list() returns records newest-first", () => {
|
|
67
|
-
const store = freshStore();
|
|
68
|
-
|
|
69
|
-
const id1 = store.start("task 1");
|
|
70
|
-
store.append({
|
|
71
|
-
id: id1,
|
|
72
|
-
taskRequest: "task 1",
|
|
73
|
-
createdAt: "2025-07-01T10:00:00.000Z",
|
|
74
|
-
durationMs: 1000,
|
|
75
|
-
iterations: 1,
|
|
76
|
-
verdict: "approved",
|
|
77
|
-
reason: "ok",
|
|
78
|
-
plan: "p1",
|
|
79
|
-
code: "c1",
|
|
80
|
-
files: [],
|
|
81
|
-
comments: [],
|
|
82
|
-
summary: "s1",
|
|
83
|
-
classified: false,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const id2 = store.start("task 2");
|
|
87
|
-
store.append({
|
|
88
|
-
id: id2,
|
|
89
|
-
taskRequest: "task 2",
|
|
90
|
-
createdAt: "2025-07-02T10:00:00.000Z",
|
|
91
|
-
durationMs: 2000,
|
|
92
|
-
iterations: 2,
|
|
93
|
-
verdict: "changes_requested",
|
|
94
|
-
reason: "converged: only minor comments",
|
|
95
|
-
plan: "p2",
|
|
96
|
-
code: "c2",
|
|
97
|
-
files: [],
|
|
98
|
-
comments: [],
|
|
99
|
-
summary: "s2",
|
|
100
|
-
classified: false,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const all = store.list();
|
|
104
|
-
assert.strictEqual(all.length, 2);
|
|
105
|
-
assert.strictEqual(all[0].id, id2, "newest first");
|
|
106
|
-
assert.strictEqual(all[1].id, id1);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("stats() aggregates correctly", () => {
|
|
110
|
-
const store = freshStore();
|
|
111
|
-
|
|
112
|
-
store.append({
|
|
113
|
-
id: "s1",
|
|
114
|
-
taskRequest: "t1",
|
|
115
|
-
createdAt: "2025-07-01T10:00:00.000Z",
|
|
116
|
-
durationMs: 1000,
|
|
117
|
-
iterations: 1,
|
|
118
|
-
verdict: "approved",
|
|
119
|
-
reason: "reviewer approved",
|
|
120
|
-
plan: "p",
|
|
121
|
-
code: "c",
|
|
122
|
-
files: ["a.ts"],
|
|
123
|
-
comments: [],
|
|
124
|
-
summary: "s",
|
|
125
|
-
classified: false,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
store.append({
|
|
129
|
-
id: "s2",
|
|
130
|
-
taskRequest: "t2",
|
|
131
|
-
createdAt: "2025-07-01T11:00:00.000Z",
|
|
132
|
-
durationMs: 3000,
|
|
133
|
-
iterations: 3,
|
|
134
|
-
verdict: "changes_requested",
|
|
135
|
-
reason: "max iterations (3) reached with changes still requested",
|
|
136
|
-
plan: "p",
|
|
137
|
-
code: "c",
|
|
138
|
-
files: ["a.ts", "b.ts"],
|
|
139
|
-
comments: [],
|
|
140
|
-
summary: "s",
|
|
141
|
-
classified: false,
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const stats = store.stats();
|
|
145
|
-
assert.strictEqual(stats.total, 2);
|
|
146
|
-
assert.strictEqual(stats.byVerdict.approved, 1);
|
|
147
|
-
assert.strictEqual(stats.byVerdict.changes_requested, 1);
|
|
148
|
-
assert.strictEqual(stats.avgIterations, 2);
|
|
149
|
-
assert.strictEqual(stats.avgDurationMs, 2000);
|
|
150
|
-
assert.strictEqual(stats.byFile["a.ts"], 2);
|
|
151
|
-
assert.strictEqual(stats.byFile["b.ts"], 1);
|
|
152
|
-
assert.strictEqual(stats.byLabel["max-iterations"], 1);
|
|
153
|
-
assert.strictEqual(stats.byLabel["converged"], 1);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("classify() returns correct label for converged", () => {
|
|
157
|
-
const store = freshStore();
|
|
158
|
-
const cls = store.classify({
|
|
159
|
-
id: "x",
|
|
160
|
-
taskRequest: "x",
|
|
161
|
-
createdAt: new Date().toISOString(),
|
|
162
|
-
durationMs: 1000,
|
|
163
|
-
iterations: 1,
|
|
164
|
-
verdict: "approved",
|
|
165
|
-
reason: "reviewer approved",
|
|
166
|
-
plan: "",
|
|
167
|
-
code: "",
|
|
168
|
-
files: [],
|
|
169
|
-
comments: [],
|
|
170
|
-
summary: "",
|
|
171
|
-
classified: false,
|
|
172
|
-
});
|
|
173
|
-
assert.strictEqual(cls.label, "converged");
|
|
174
|
-
assert.strictEqual(cls.trajectoryId, "x");
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("classify() returns stuck for same-file reason", () => {
|
|
178
|
-
const store = freshStore();
|
|
179
|
-
const cls = store.classify({
|
|
180
|
-
id: "y",
|
|
181
|
-
taskRequest: "y",
|
|
182
|
-
createdAt: new Date().toISOString(),
|
|
183
|
-
durationMs: 1000,
|
|
184
|
-
iterations: 2,
|
|
185
|
-
verdict: "changes_requested",
|
|
186
|
-
reason: "stuck: same file (auth.ts) flagged for 3 comment(s)",
|
|
187
|
-
plan: "",
|
|
188
|
-
code: "",
|
|
189
|
-
files: ["auth.ts"],
|
|
190
|
-
comments: [],
|
|
191
|
-
summary: "",
|
|
192
|
-
classified: false,
|
|
193
|
-
});
|
|
194
|
-
assert.strictEqual(cls.label, "stuck");
|
|
195
|
-
assert.strictEqual(cls.pattern, "same-file-repeated");
|
|
196
|
-
assert.ok(cls.confidence < 1.0);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("byVerdict() filters correctly", () => {
|
|
200
|
-
const store = freshStore();
|
|
201
|
-
store.append({
|
|
202
|
-
id: "v1",
|
|
203
|
-
taskRequest: "v1",
|
|
204
|
-
createdAt: "2025-07-01T10:00:00.000Z",
|
|
205
|
-
durationMs: 1000,
|
|
206
|
-
iterations: 1,
|
|
207
|
-
verdict: "approved",
|
|
208
|
-
reason: "ok",
|
|
209
|
-
plan: "",
|
|
210
|
-
code: "",
|
|
211
|
-
files: [],
|
|
212
|
-
comments: [],
|
|
213
|
-
summary: "",
|
|
214
|
-
classified: false,
|
|
215
|
-
});
|
|
216
|
-
store.append({
|
|
217
|
-
id: "v2",
|
|
218
|
-
taskRequest: "v2",
|
|
219
|
-
createdAt: "2025-07-02T10:00:00.000Z",
|
|
220
|
-
durationMs: 1000,
|
|
221
|
-
iterations: 1,
|
|
222
|
-
verdict: "blocked",
|
|
223
|
-
reason: "blocked",
|
|
224
|
-
plan: "",
|
|
225
|
-
code: "",
|
|
226
|
-
files: [],
|
|
227
|
-
comments: [],
|
|
228
|
-
summary: "",
|
|
229
|
-
classified: false,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const approved = store.byVerdict("approved");
|
|
233
|
-
assert.strictEqual(approved.length, 1);
|
|
234
|
-
assert.strictEqual(approved[0].id, "v1");
|
|
235
|
-
|
|
236
|
-
const blocked = store.byVerdict("blocked");
|
|
237
|
-
assert.strictEqual(blocked.length, 1);
|
|
238
|
-
assert.strictEqual(blocked[0].id, "v2");
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("stats() handles empty store gracefully", () => {
|
|
242
|
-
rmSync(TEST_DIR, { force: true, recursive: true });
|
|
243
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
244
|
-
// Remove the month dir so the store sees an empty directory
|
|
245
|
-
const store = freshStore();
|
|
246
|
-
const stats = store.stats();
|
|
247
|
-
assert.strictEqual(stats.total, 0);
|
|
248
|
-
assert.strictEqual(stats.avgIterations, 0);
|
|
249
|
-
});
|
|
250
|
-
});
|