carthagent 0.0.0-stage → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +219 -2
- package/bin/ctg.mjs +736 -0
- package/docs/budgets.md +72 -0
- package/docs/compaction.md +34 -0
- package/docs/context-efficiency-plan.md +24 -0
- package/docs/context-efficiency-review.md +27 -0
- package/docs/context-efficiency.md +49 -0
- package/docs/deepseek-jev-benchmark-plan.md +70 -0
- package/docs/deepseek-jev-benchmark-repair-plan.md +20 -0
- package/docs/deepseek-jev-benchmark-restart.md +9 -0
- package/docs/deepseek-jev-benchmark-results.md +77 -0
- package/docs/deepseek-jev-benchmark-running.md +60 -0
- package/docs/deepseek-jev-benchmark-v3-results.md +41 -0
- package/docs/deepseek-jev-benchmark-v4-protocol.md +15 -0
- package/docs/deepseek-jev-benchmark-v4-results.md +119 -0
- package/docs/deepseek-jev-http400-diagnosis.md +45 -0
- package/docs/delivery-review-evidence.md +53 -0
- package/docs/delivery-timeout-repair-plan.md +51 -0
- package/docs/evaluation-readiness.md +31 -0
- package/docs/evaluation.md +70 -0
- package/docs/extending.md +354 -0
- package/docs/glm-pilot-execution.md +9 -0
- package/docs/glm-pilot-plan.md +15 -0
- package/docs/glm-pilot-results.md +71 -0
- package/docs/graph-context-optimization.md +15 -0
- package/docs/jev-repository-pilot-plan.md +25 -0
- package/docs/jev-repository-pilot-protocol.md +39 -0
- package/docs/jev-repository-pilot-restart.md +7 -0
- package/docs/jev-repository-pilot-results.md +79 -0
- package/docs/jev.md +32 -0
- package/docs/model-registry.md +25 -0
- package/docs/native-compatibility.md +117 -0
- package/docs/opencode-archive.md +9 -0
- package/docs/opencode-migration.md +115 -0
- package/docs/opencode-runtime.md +94 -0
- package/docs/opencode-workspace.md +31 -0
- package/docs/owned-runtime-workflow-registration.md +17 -0
- package/docs/plan-advisor-evaluation.md +38 -0
- package/docs/planning-startup-fix-plan.md +23 -0
- package/docs/planning-startup-fix-review.md +24 -0
- package/docs/planning.md +118 -0
- package/docs/production-merge-review.md +23 -0
- package/docs/quality.md +35 -0
- package/docs/repository-benchmark-design.md +111 -0
- package/docs/review-assurance.md +9 -0
- package/docs/review-experiment-results.md +59 -0
- package/docs/tested-planning-roadmap.md +58 -0
- package/docs/tested-planning.md +58 -0
- package/docs/tui-pickers.md +9 -0
- package/docs/webdriver.md +83 -0
- package/docs/workflow-modes.md +26 -0
- package/docs/workflow.d2 +17 -0
- package/docs/workflow.svg +149 -0
- package/docs/workspace-coordination.md +9 -0
- package/evaluate.mjs +249 -0
- package/extensions/codegraph.ts +36 -0
- package/extensions/delivery.ts +819 -0
- package/extensions/experiential.ts +21 -0
- package/extensions/subscriptions.ts +21 -0
- package/guidance/profiles/authenticated-web.json +24 -0
- package/guidance/profiles/data-visualization.json +25 -0
- package/guidance/profiles/database-change.json +24 -0
- package/guidance/profiles/external-api.json +24 -0
- package/guidance/profiles/transactional-data.json +25 -0
- package/guidance/profiles/web-application.json +26 -0
- package/lib/acceptance-review.mjs +4 -0
- package/lib/browser-bin.mjs +160 -0
- package/lib/browser-errors.mjs +54 -0
- package/lib/browser.mjs +219 -0
- package/lib/budget.mjs +37 -0
- package/lib/cdp.mjs +221 -0
- package/lib/cloud/client.mjs +275 -0
- package/lib/cloud/control-plane.mjs +350 -0
- package/lib/cloud/gateway.mjs +380 -0
- package/lib/cloud/http.mjs +135 -0
- package/lib/cloud/ledger.mjs +215 -0
- package/lib/codegraph-query.mjs +60 -0
- package/lib/codegraph.mjs +378 -0
- package/lib/context-archive.mjs +18 -0
- package/lib/delivery-context.mjs +132 -0
- package/lib/delivery-guidance.mjs +9 -0
- package/lib/delivery-review.mjs +94 -0
- package/lib/delivery.mjs +610 -0
- package/lib/engine.mjs +137 -0
- package/lib/guidance.mjs +71 -0
- package/lib/jev-advisor.mjs +47 -0
- package/lib/opencode/archive.mjs +122 -0
- package/lib/opencode/compatibility.mjs +19 -0
- package/lib/opencode/credentials.mjs +205 -0
- package/lib/opencode/evaluation-budget-plugin/index.ts +147 -0
- package/lib/opencode/evaluation.mjs +242 -0
- package/lib/opencode/file-lock.mjs +86 -0
- package/lib/opencode/headless.mjs +200 -0
- package/lib/opencode/review.mjs +213 -0
- package/lib/opencode/runtime.mjs +246 -0
- package/lib/opencode/service.mjs +249 -0
- package/lib/opencode/session-options.mjs +60 -0
- package/lib/opencode/workspace.mjs +133 -0
- package/lib/openrouter-jev.mjs +37 -0
- package/lib/outcome-contract.mjs +21 -0
- package/lib/plan-advisor.mjs +38 -0
- package/lib/planning-access.mjs +7 -0
- package/lib/planning-advice.mjs +28 -0
- package/lib/planning-discovery.mjs +14 -0
- package/lib/planning-guide.mjs +34 -0
- package/lib/planning-view.mjs +57 -0
- package/lib/planning.mjs +155 -0
- package/lib/probe-diagnostics.mjs +13 -0
- package/lib/providers/experiential.mjs +292 -0
- package/lib/providers/model-catalog.json +700 -0
- package/lib/providers/model-catalog.mjs +7 -0
- package/lib/providers/names.mjs +13 -0
- package/lib/providers/subscription-models.mjs +483 -0
- package/lib/reports.mjs +80 -0
- package/lib/review-state.mjs +49 -0
- package/lib/review.mjs +114 -0
- package/lib/scenarios.mjs +99 -0
- package/lib/ship-auth.mjs +44 -0
- package/lib/ship-jev.mjs +59 -0
- package/lib/ship-telemetry.mjs +183 -0
- package/lib/tui/ansi.mjs +255 -0
- package/lib/tui/app.mjs +2445 -0
- package/lib/tui/auth.mjs +249 -0
- package/lib/tui/carthage.mjs +109 -0
- package/lib/tui/clipboard.mjs +122 -0
- package/lib/tui/d2.mjs +431 -0
- package/lib/tui/feed.mjs +467 -0
- package/lib/tui/framing.mjs +80 -0
- package/lib/tui/glyphs.mjs +172 -0
- package/lib/tui/hash-worker.mjs +11 -0
- package/lib/tui/mock-engine.mjs +222 -0
- package/lib/tui/models.mjs +73 -0
- package/lib/tui/picker.mjs +18 -0
- package/lib/tui/theme.mjs +663 -0
- package/lib/tui/title.mjs +7 -0
- package/lib/update-channel.mjs +62 -0
- package/lib/update.mjs +230 -0
- package/lib/webdriver.mjs +82 -0
- package/lib/workflow.mjs +88 -0
- package/lib/workspace.mjs +39 -0
- package/metadata.json +8 -0
- package/package.json +94 -4
- package/plugins/carthagent/index.ts +3 -0
- package/plugins/carthagent/package.json +28 -0
- package/plugins/carthagent/src/archive-rpc.ts +46 -0
- package/plugins/carthagent/src/bootstrap.ts +38 -0
- package/plugins/carthagent/src/index.ts +62 -0
- package/plugins/carthagent/src/pull-request-rpc.ts +54 -0
- package/plugins/carthagent/src/rpc.ts +76 -0
- package/plugins/carthagent/src/server/archive-rpc.ts +327 -0
- package/plugins/carthagent/src/server/budgets.ts +21 -0
- package/plugins/carthagent/src/server/codegraph.ts +46 -0
- package/plugins/carthagent/src/server/delivery.ts +488 -0
- package/plugins/carthagent/src/server/device-auth.ts +91 -0
- package/plugins/carthagent/src/server/native-delivery.ts +26 -0
- package/plugins/carthagent/src/server/orchestration.ts +56 -0
- package/plugins/carthagent/src/server/policy.ts +24 -0
- package/plugins/carthagent/src/server/providers.ts +424 -0
- package/plugins/carthagent/src/server/pull-request-rpc.ts +387 -0
- package/plugins/carthagent/src/server/session-controls.ts +82 -0
- package/plugins/carthagent/src/server/telemetry.ts +92 -0
- package/plugins/carthagent/src/server/workspace-rpc.ts +349 -0
- package/plugins/carthagent/src/session-rpc.ts +31 -0
- package/plugins/carthagent/src/testing.ts +85 -0
- package/plugins/carthagent/src/workspace-rpc.ts +133 -0
- package/plugins/carthagent/test-plugin/index.ts +4 -0
- package/plugins/carthagent/test-plugin/package.json +1 -0
- package/plugins/carthagent/tsconfig.json +19 -0
- package/plugins/carthagent/tui.ts +1 -0
- package/prompts/delivery.md +7 -0
- package/public/index.html +983 -0
- package/scenarios/cli/grade_cli.py +69 -0
- package/scenarios/cli/scenario.json +21 -0
- package/scenarios/game/baseline/minecraft.py +193 -0
- package/scenarios/game/context.md +1 -0
- package/scenarios/game/grade_minecraft_clone.py +603 -0
- package/scenarios/game/requirements.txt +2 -0
- package/scenarios/game/scenario.json +33 -0
- package/server.mjs +341 -0
- package/skills/game-development/SKILL.md +36 -0
- package/skills/game-development/assets/ursina_starter.py +98 -0
- package/skills/game-development/scripts/verify_ursina.py +80 -0
- package/skills/software-delivery/SKILL.md +50 -0
- package/skills/typescript-delivery/SKILL.md +69 -0
- package/tests/acceptance-review.test.mjs +13 -0
- package/tests/auth.test.mjs +234 -0
- package/tests/bounded-summary.test.mjs +68 -0
- package/tests/browser-bin.test.mjs +91 -0
- package/tests/browser.test.mjs +96 -0
- package/tests/budget-engine.test.mjs +110 -0
- package/tests/budget.test.mjs +23 -0
- package/tests/cli.test.mjs +245 -0
- package/tests/clipboard.test.mjs +79 -0
- package/tests/cloud-client.test.mjs +129 -0
- package/tests/cloud-control-plane.test.mjs +144 -0
- package/tests/cloud-gateway.test.mjs +147 -0
- package/tests/cloud-http.test.mjs +102 -0
- package/tests/cloud-ledger.test.mjs +75 -0
- package/tests/codegraph-query.test.mjs +66 -0
- package/tests/codegraph.test.mjs +142 -0
- package/tests/delivery-context.test.mjs +66 -0
- package/tests/delivery-review.test.mjs +139 -0
- package/tests/delivery.test.mjs +343 -0
- package/tests/engine-api.mjs +24 -0
- package/tests/experiential-extension.test.mjs +37 -0
- package/tests/experiential.test.mjs +300 -0
- package/tests/extension.test.mjs +921 -0
- package/tests/fixtures/archive-plugin/index.ts +10 -0
- package/tests/guidance.test.mjs +78 -0
- package/tests/model-registry.test.mjs +68 -0
- package/tests/models.test.mjs +70 -0
- package/tests/openai-idempotency.test.mjs +99 -0
- package/tests/opencode-archive-rpc.test.mjs +82 -0
- package/tests/opencode-delivery.test.mjs +231 -0
- package/tests/opencode-providers.test.mjs +414 -0
- package/tests/opencode-runtime.test.mjs +455 -0
- package/tests/opencode-session-controls.test.mjs +115 -0
- package/tests/opencode-session-options.test.mjs +26 -0
- package/tests/opencode-workspace.test.mjs +339 -0
- package/tests/outcome-contract.test.mjs +17 -0
- package/tests/picker.test.mjs +34 -0
- package/tests/plan-advisor.test.mjs +88 -0
- package/tests/plan-review-loop.test.mjs +53 -0
- package/tests/planning-advice.test.mjs +27 -0
- package/tests/planning-contract.test.mjs +65 -0
- package/tests/planning-startup.test.mjs +38 -0
- package/tests/planning-view.test.mjs +33 -0
- package/tests/planning.test.mjs +223 -0
- package/tests/probe-diagnostics.test.mjs +21 -0
- package/tests/pull-request-rpc.test.mjs +366 -0
- package/tests/review-state.test.mjs +32 -0
- package/tests/review.test.mjs +127 -0
- package/tests/server.test.mjs +252 -0
- package/tests/ship-jev.test.mjs +77 -0
- package/tests/ship-telemetry.test.mjs +333 -0
- package/tests/standard-workflow.test.mjs +28 -0
- package/tests/subscription-models.test.mjs +416 -0
- package/tests/subscriptions-extension.test.mjs +27 -0
- package/tests/terminal-title.test.mjs +13 -0
- package/tests/test_grade_minecraft_clone.py +199 -0
- package/tests/test_starter.py +78 -0
- package/tests/theme.test.mjs +175 -0
- package/tests/tui-copy-paste.test.mjs +54 -0
- package/tests/tui.test.mjs +808 -0
- package/tests/update-channels.test.mjs +129 -0
- package/tests/update.test.mjs +175 -0
- package/tests/webdriver.test.mjs +31 -0
- package/tests/workflow.test.mjs +47 -0
- package/tests/workspace-rpc.test.mjs +236 -0
- package/tests/workspace.test.mjs +24 -0
- package/tools/benchmark/advisor.test.mjs +7 -0
- package/tools/benchmark/advisor.ts +27 -0
- package/tools/benchmark/campaign.mjs +45 -0
- package/tools/benchmark/diagnose-request.mjs +40 -0
- package/tools/benchmark/eval-common.mjs +32 -0
- package/tools/benchmark/eval-ledger.mjs +22 -0
- package/tools/benchmark/eval-shop.mjs +26 -0
- package/tools/benchmark/eval-voxel.mjs +20 -0
- package/tools/benchmark/evaluate.mjs +24 -0
- package/tools/benchmark/evaluators.test.mjs +13 -0
- package/tools/benchmark/fixtures/shop/server.mjs +18 -0
- package/tools/benchmark/fixtures/shop/ui.html +8 -0
- package/tools/benchmark/freeze.mjs +30 -0
- package/tools/benchmark/gateway.mjs +91 -0
- package/tools/benchmark/gateway.test.mjs +38 -0
- package/tools/benchmark/generator.mjs +11 -0
- package/tools/benchmark/generator.test.mjs +26 -0
- package/tools/benchmark/guard.test.mjs +133 -0
- package/tools/benchmark/guard.ts +136 -0
- package/tools/benchmark/native-plugin/index.ts +24 -0
- package/tools/benchmark/planning-startup.test.mjs +47 -0
- package/tools/benchmark/preflight-live.mjs +31 -0
- package/tools/benchmark/preflight.mjs +22 -0
- package/tools/benchmark/replay-diagnostic.mjs +23 -0
- package/tools/benchmark/runner.mjs +141 -0
- package/tools/benchmark/runner.test.mjs +93 -0
- package/tools/benchmark/runtime.mjs +23 -0
- package/tools/benchmark/selftest.mjs +47 -0
- package/tools/benchmark/smoke-jev.mjs +5 -0
- package/tools/benchmark/tasks.mjs +20 -0
- package/tools/benchmark/transport.mjs +65 -0
- package/tools/benchmark/transport.test.mjs +44 -0
- package/tools/benchmark/upstream-error.mjs +18 -0
- package/tools/benchmark/upstream-error.test.mjs +10 -0
- package/tools/browser-check.mjs +109 -0
- package/tools/check-syntax.mjs +27 -0
- package/tools/evaluate-plan-advisor.mjs +20 -0
- package/tools/native-fixture.mjs +194 -0
- package/tools/native-pty-smoke.py +108 -0
- package/tools/native-report-plugin/index.ts +50 -0
- package/tools/native-report-plugin/package.json +7 -0
- package/tools/patch-compaction.mjs +24 -0
- package/tools/patch-model-catalog.mjs +12 -0
- package/tools/patch-print-shutdown.mjs +39 -0
- package/tools/repo-pilot/evaluator.cjs +32 -0
- package/tools/repo-pilot/reference.mjs +43 -0
- package/tools/repo-pilot/runner.mjs +85 -0
- package/tools/repo-pilot/sandbox-entry.mjs +12 -0
- package/tools/repo-pilot/tasks.mjs +20 -0
- package/tools/repo-pilot/type-evaluator.cjs +6 -0
- package/tools/test-native-controls.mjs +84 -0
- package/tools/test-native-delivery-host.mjs +307 -0
- package/tools/test-native-evaluation.mjs +46 -0
- package/tools/test-native-host.mjs +385 -0
- package/tools/test-native-outcomes.mjs +73 -0
- package/tools/test-native-package.mjs +70 -0
- package/tools/test-native-pty.mjs +20 -0
- package/tools/test-native-report.mjs +88 -0
- package/tools/test-native-swe-host.mjs +132 -0
- package/tools/test-native-swe.mjs +122 -0
- package/tools/test-picker-pty.py +45 -0
- package/tools/test-python.mjs +29 -0
- package/tools/test-webdriver.mjs +54 -0
- package/tools/verify-release-version.mjs +37 -0
- package/tools/webdriver-check.mjs +52 -0
- package/vendor/agent/bounded-summary.mjs +88 -0
- package/vendor/agent/chunks/anthropic-messages-VWZZOSJQ.js +6 -0
- package/vendor/agent/chunks/anthropic.js +75 -0
- package/vendor/agent/chunks/azure-openai-responses-BJLAM6CD.js +2 -0
- package/vendor/agent/chunks/bedrock-converse-stream.js +74 -0
- package/vendor/agent/chunks/chord-context.js +96 -0
- package/vendor/agent/chunks/chunk-4L3WN2XY.js +2 -0
- package/vendor/agent/chunks/chunk-6CYCI3EJ.js +12 -0
- package/vendor/agent/chunks/chunk-6R7UI4IY.js +2 -0
- package/vendor/agent/chunks/chunk-7ZC4UXSL.js +2 -0
- package/vendor/agent/chunks/chunk-AXIIZGTV.js +2 -0
- package/vendor/agent/chunks/chunk-CLNPYIDP.js +42 -0
- package/vendor/agent/chunks/chunk-DRQDKNXA.js +2 -0
- package/vendor/agent/chunks/chunk-GMWCTUPB.js +2 -0
- package/vendor/agent/chunks/chunk-IDDQWTHI.js +2 -0
- package/vendor/agent/chunks/chunk-JVUZSMYM.js +1548 -0
- package/vendor/agent/chunks/chunk-L2ZPNLYD.js +2 -0
- package/vendor/agent/chunks/chunk-NUHFSC37.js +25 -0
- package/vendor/agent/chunks/chunk-OUXLLA64.js +11 -0
- package/vendor/agent/chunks/chunk-PGXDEOVV.js +2 -0
- package/vendor/agent/chunks/chunk-PJACZCIR.js +2 -0
- package/vendor/agent/chunks/chunk-PRRNXB7S.js +2 -0
- package/vendor/agent/chunks/chunk-TEPMHNKQ.js +2 -0
- package/vendor/agent/chunks/chunk-TRDNDS6A.js +4 -0
- package/vendor/agent/chunks/chunk-U6ZMQKGD.js +50 -0
- package/vendor/agent/chunks/chunk-UAQELI3K.js +2 -0
- package/vendor/agent/chunks/chunk-USJZMAIR.js +2 -0
- package/vendor/agent/chunks/chunk-XDUWOHPL.js +6 -0
- package/vendor/agent/chunks/chunk-XNGRGP62.js +2 -0
- package/vendor/agent/chunks/github-copilot.js +2 -0
- package/vendor/agent/chunks/google-generative-ai-Q2K7FBDI.js +2 -0
- package/vendor/agent/chunks/google-vertex-7UJBF4S7.js +2 -0
- package/vendor/agent/chunks/https-proxy-agent-2VXB7436.js +13 -0
- package/vendor/agent/chunks/image-resize-worker.js +2 -0
- package/vendor/agent/chunks/kimi-coding.js +2 -0
- package/vendor/agent/chunks/lib-HGQMNYVT.js +9 -0
- package/vendor/agent/chunks/mistral-conversations-4M6BZBX6.js +5 -0
- package/vendor/agent/chunks/multipart-parser-SQ6GDJL7.js +3 -0
- package/vendor/agent/chunks/node-KG362ECQ.js +16 -0
- package/vendor/agent/chunks/node-TWVVAGPO.js +2 -0
- package/vendor/agent/chunks/openai-codex-responses-R6VYZTVY.js +10 -0
- package/vendor/agent/chunks/openai-codex.js +75 -0
- package/vendor/agent/chunks/openai-completions-EKZT2IH2.js +7 -0
- package/vendor/agent/chunks/openai-responses-TFDINO6W.js +2 -0
- package/vendor/agent/chunks/openrouter-images-N4XVVFSD.js +2 -0
- package/vendor/agent/chunks/openrouter.js +75 -0
- package/vendor/agent/chunks/pi-messages-PML4SPVJ.js +8 -0
- package/vendor/agent/chunks/radius.js +75 -0
- package/vendor/agent/chunks/src-UK77SYZE.js +4 -0
- package/vendor/agent/chunks/xai.js +2 -0
- package/vendor/agent/cli.js +3 -0
- package/vendor/agent/dist/modes/interactive/theme/dark.json +91 -0
- package/vendor/agent/dist/modes/interactive/theme/light.json +90 -0
- package/vendor/agent/dist/modes/interactive/theme/theme-schema.json +356 -0
- package/vendor/agent/index.js +2 -0
- package/vendor/agent/modes/interactive/theme/dark.json +91 -0
- package/vendor/agent/modes/interactive/theme/light.json +90 -0
- package/vendor/agent/modes/interactive/theme/theme-schema.json +356 -0
- package/vendor/agent/package.json +14 -0
- package/vendor/agent/rpc-entry.js +3 -0
- package/vendor/agent/theme/dark.json +91 -0
- package/vendor/agent/theme/light.json +90 -0
- package/vendor/agent/theme/theme-schema.json +356 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Import-safe tests for the verified starter's nonblank framebuffer assertion.
|
|
2
|
+
|
|
3
|
+
Runs without any graphics context: assert_nonblank works on plain image files.
|
|
4
|
+
"""
|
|
5
|
+
import importlib.util
|
|
6
|
+
import sys
|
|
7
|
+
import tempfile
|
|
8
|
+
import unittest
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from PIL import Image
|
|
12
|
+
|
|
13
|
+
STARTER = Path(__file__).resolve().parents[1] / 'skills' / 'game-development' / 'assets' / 'ursina_starter.py'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def load_starter():
|
|
17
|
+
spec = importlib.util.spec_from_file_location('ursina_starter_under_test', STARTER)
|
|
18
|
+
module = importlib.util.module_from_spec(spec)
|
|
19
|
+
spec.loader.exec_module(module)
|
|
20
|
+
return module
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def image_file(colors):
|
|
24
|
+
"""Write a small PNG whose top rows hold the given distinct colors."""
|
|
25
|
+
width, height = 64, 64
|
|
26
|
+
band = max(1, height // len(colors))
|
|
27
|
+
image = Image.new('RGB', (width, height))
|
|
28
|
+
for y in range(height):
|
|
29
|
+
image.paste(Image.new('RGB', (width, 1), colors[min(y // band, len(colors) - 1)]), (0, y))
|
|
30
|
+
handle = tempfile.NamedTemporaryFile(prefix='nonblank-', suffix='.png', delete=False)
|
|
31
|
+
image.save(handle, format='PNG')
|
|
32
|
+
handle.close()
|
|
33
|
+
return Path(handle.name)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class NonblankAssertionTests(unittest.TestCase):
|
|
37
|
+
@classmethod
|
|
38
|
+
def setUpClass(cls):
|
|
39
|
+
cls.starter = load_starter()
|
|
40
|
+
|
|
41
|
+
def track(self, path):
|
|
42
|
+
self.addCleanup(lambda: path.unlink(missing_ok=True))
|
|
43
|
+
return path
|
|
44
|
+
|
|
45
|
+
def test_importing_starter_never_opens_a_window(self):
|
|
46
|
+
self.assertTrue(hasattr(self.starter, 'assert_nonblank'))
|
|
47
|
+
self.assertNotIn('Ursina', sys.modules, 'starter import must not load the graphics stack')
|
|
48
|
+
|
|
49
|
+
def test_color_varied_image_passes_and_reports_color_count(self):
|
|
50
|
+
path = self.track(image_file([(10, 40, 90), (200, 180, 60), (255, 255, 255), (0, 0, 0)]))
|
|
51
|
+
colors = self.starter.assert_nonblank(path, min_colors=3)
|
|
52
|
+
self.assertGreaterEqual(colors, 3)
|
|
53
|
+
|
|
54
|
+
def test_flat_single_color_image_is_rejected_as_blank(self):
|
|
55
|
+
path = self.track(image_file([(120, 120, 120)]))
|
|
56
|
+
with self.assertRaises(AssertionError) as caught:
|
|
57
|
+
self.starter.assert_nonblank(path)
|
|
58
|
+
self.assertIn('sampled colors', str(caught.exception))
|
|
59
|
+
|
|
60
|
+
def test_pure_black_image_is_rejected(self):
|
|
61
|
+
path = self.track(image_file([(0, 0, 0)]))
|
|
62
|
+
with self.assertRaises(AssertionError):
|
|
63
|
+
self.starter.assert_nonblank(path)
|
|
64
|
+
|
|
65
|
+
def test_two_colors_fail_the_default_three_color_bar(self):
|
|
66
|
+
path = self.track(image_file([(20, 20, 20), (240, 240, 240)]))
|
|
67
|
+
with self.assertRaises(AssertionError):
|
|
68
|
+
self.starter.assert_nonblank(path)
|
|
69
|
+
# The threshold is an argument, matching the external probe's coarse bar.
|
|
70
|
+
self.assertGreaterEqual(self.starter.assert_nonblank(path, min_colors=2), 2)
|
|
71
|
+
|
|
72
|
+
def test_missing_image_file_raises(self):
|
|
73
|
+
with self.assertRaises(Exception):
|
|
74
|
+
self.starter.assert_nonblank(Path(tempfile.gettempdir()) / 'definitely-not-rendered-9x7.png')
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if __name__ == '__main__':
|
|
78
|
+
unittest.main()
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { THEMES, flattenTheme, detectTermMode } from '../lib/tui/theme.mjs';
|
|
7
|
+
|
|
8
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
const html = readFileSync(join(root, 'public', 'index.html'), 'utf8');
|
|
10
|
+
|
|
11
|
+
const TOKENS = [
|
|
12
|
+
'bg', 'chrome', 'panel', 'panel-2', 'sunken',
|
|
13
|
+
'border', 'border-strong', 'border-hover', 'control-border',
|
|
14
|
+
'text', 'muted', 'faint', 'code',
|
|
15
|
+
'accent', 'accent-ink', 'accent-bg', 'hover-bg',
|
|
16
|
+
'success', 'warning', 'error',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// Normal text (AA 4.5:1): role color -> the surfaces it renders on.
|
|
20
|
+
const TEXT_PAIRS = [
|
|
21
|
+
['text', 'bg'], ['text', 'panel'], ['text', 'panel-2'], ['text', 'sunken'], ['text', 'chrome'],
|
|
22
|
+
['muted', 'bg'], ['muted', 'panel'], ['muted', 'sunken'], ['muted', 'chrome'],
|
|
23
|
+
['faint', 'bg'], ['faint', 'panel'], ['faint', 'chrome'],
|
|
24
|
+
['code', 'sunken'], ['code', 'panel'],
|
|
25
|
+
['accent', 'bg'], ['accent', 'panel'], ['accent', 'panel-2'], ['accent', 'chrome'], ['accent', 'accent-bg'],
|
|
26
|
+
['accent-ink', 'accent'],
|
|
27
|
+
['success', 'panel'], ['success', 'sunken'],
|
|
28
|
+
['warning', 'panel'], ['warning', 'sunken'],
|
|
29
|
+
['error', 'panel'], ['error', 'sunken'], ['error', 'panel-2'],
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
// Non-text UI elements (AA 3:1): control outlines, status dots, nav underline.
|
|
33
|
+
const UI_PAIRS = [
|
|
34
|
+
['control-border', 'sunken'], ['control-border', 'panel'],
|
|
35
|
+
['success', 'chrome'], ['warning', 'chrome'], ['error', 'chrome'],
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function luminance(hex) {
|
|
39
|
+
const [r, g, b] = [1, 3, 5].map(i => {
|
|
40
|
+
const v = parseInt(hex.slice(i, i + 2), 16) / 255;
|
|
41
|
+
return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
42
|
+
});
|
|
43
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const contrast = (a, b) => {
|
|
47
|
+
const [l1, l2] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
48
|
+
return (l1 + 0.05) / (l2 + 0.05);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Collect theme blocks: ':root, [data-theme="x"] { --token: #hex; ... }'.
|
|
52
|
+
const themes = {};
|
|
53
|
+
for (const match of html.matchAll(/([^{}]+)\{([^}]*--[a-z-]+\s*:[^}]*)\}/g)) {
|
|
54
|
+
const [, selector, body] = match;
|
|
55
|
+
const vars = {};
|
|
56
|
+
for (const decl of body.matchAll(/(--[a-z0-9-]+)\s*:\s*(#[0-9a-fA-F]{6})\b/g)) vars[decl[1]] = decl[2].toLowerCase();
|
|
57
|
+
for (const name of selector.split(',').map(s => s.trim())) {
|
|
58
|
+
const theme = name === ':root' ? 'carthage' : name.match(/^\[data-theme="([^"]+)"\]$/)?.[1];
|
|
59
|
+
if (theme) themes[theme] = { ...themes[theme], ...vars };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
test('every theme picker option has a matching theme block', () => {
|
|
64
|
+
const options = [...html.matchAll(/data-theme-value="([^"]+)"/g)].map(m => m[1]).filter(v => v !== 'system');
|
|
65
|
+
assert.deepEqual(options.sort(), Object.keys(themes).sort());
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
for (const [name, vars] of Object.entries(themes)) {
|
|
69
|
+
test(`theme "${name}" defines the full token set`, () => {
|
|
70
|
+
const missing = TOKENS.filter(t => !vars[`--${t}`]);
|
|
71
|
+
assert.deepEqual(missing, []);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test(`theme "${name}" meets WCAG AA contrast`, () => {
|
|
75
|
+
const failures = [];
|
|
76
|
+
for (const [fg, bg] of TEXT_PAIRS) {
|
|
77
|
+
const r = contrast(vars[`--${fg}`], vars[`--${bg}`]);
|
|
78
|
+
if (r < 4.5) failures.push(`${fg}/${bg} = ${r.toFixed(2)}`);
|
|
79
|
+
}
|
|
80
|
+
for (const [fg, bg] of UI_PAIRS) {
|
|
81
|
+
const r = contrast(vars[`--${fg}`], vars[`--${bg}`]);
|
|
82
|
+
if (r < 3.0) failures.push(`${fg}/${bg} = ${r.toFixed(2)} (UI)`);
|
|
83
|
+
}
|
|
84
|
+
assert.deepEqual(failures, []);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------- TUI
|
|
89
|
+
|
|
90
|
+
// Normal text (AA 4.5:1) for the TUI token set.
|
|
91
|
+
const TUI_TEXT_PAIRS = [
|
|
92
|
+
['text', 'background'], ['text', 'backgroundPanel'], ['text', 'backgroundElement'],
|
|
93
|
+
['textMuted', 'background'], ['textMuted', 'backgroundPanel'], ['textMuted', 'backgroundElement'],
|
|
94
|
+
['primary', 'backgroundPanel'], ['secondary', 'backgroundPanel'], ['accent', 'backgroundPanel'],
|
|
95
|
+
['info', 'backgroundPanel'], ['error', 'backgroundPanel'], ['warning', 'backgroundPanel'],
|
|
96
|
+
['success', 'backgroundPanel'],
|
|
97
|
+
['markdownText', 'backgroundPanel'], ['markdownBlockQuote', 'backgroundPanel'],
|
|
98
|
+
['markdownCode', 'backgroundPanel'], ['markdownCodeBlock', 'backgroundPanel'],
|
|
99
|
+
['markdownLink', 'backgroundPanel'], ['markdownLinkText', 'backgroundPanel'],
|
|
100
|
+
['markdownEmph', 'backgroundPanel'], ['markdownHeading', 'backgroundPanel'],
|
|
101
|
+
['markdownStrong', 'backgroundPanel'],
|
|
102
|
+
['syntaxComment', 'background'], ['syntaxKeyword', 'background'],
|
|
103
|
+
['syntaxFunction', 'background'], ['syntaxVariable', 'background'],
|
|
104
|
+
['syntaxString', 'background'], ['syntaxNumber', 'background'],
|
|
105
|
+
['syntaxType', 'background'], ['syntaxOperator', 'background'],
|
|
106
|
+
['syntaxPunctuation', 'background'],
|
|
107
|
+
['diffAdded', 'diffAddedBg'], ['diffRemoved', 'diffRemovedBg'],
|
|
108
|
+
['diffContext', 'diffContextBg'], ['diffHunkHeader', 'backgroundPanel'],
|
|
109
|
+
['diffHighlightAdded', 'diffAddedBg'], ['diffHighlightRemoved', 'diffRemovedBg'],
|
|
110
|
+
['diffLineNumber', 'diffAddedLineNumberBg'], ['diffLineNumber', 'diffRemovedLineNumberBg'],
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
// Non-text UI elements (AA 3:1): focused-pane border.
|
|
114
|
+
const TUI_UI_PAIRS = [['borderActive', 'backgroundPanel']];
|
|
115
|
+
|
|
116
|
+
// Decorative separators: visible but intentionally subtle.
|
|
117
|
+
const TUI_DECO_PAIRS = [
|
|
118
|
+
['border', 'backgroundPanel'],
|
|
119
|
+
['borderSubtle', 'backgroundPanel'],
|
|
120
|
+
['markdownHorizontalRule', 'backgroundPanel'],
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
for (const [name, raw] of Object.entries(THEMES)) {
|
|
124
|
+
for (const mode of ['dark', 'light']) {
|
|
125
|
+
test(`tui theme "${name}" (${mode}) meets WCAG AA contrast`, () => {
|
|
126
|
+
const t = flattenTheme(raw, mode);
|
|
127
|
+
const failures = [];
|
|
128
|
+
for (const [fgC, bgC] of TUI_TEXT_PAIRS) {
|
|
129
|
+
if (t[fgC] === 'none' || t[bgC] === 'none') continue;
|
|
130
|
+
const r = contrast(t[fgC], t[bgC]);
|
|
131
|
+
if (r < 4.5) failures.push(`${fgC}/${bgC} = ${r.toFixed(2)}`);
|
|
132
|
+
}
|
|
133
|
+
for (const [fgC, bgC] of TUI_UI_PAIRS) {
|
|
134
|
+
const r = contrast(t[fgC], t[bgC]);
|
|
135
|
+
if (r < 3.0) failures.push(`${fgC}/${bgC} = ${r.toFixed(2)} (UI)`);
|
|
136
|
+
}
|
|
137
|
+
for (const [fgC, bgC] of TUI_DECO_PAIRS) {
|
|
138
|
+
const r = contrast(t[fgC], t[bgC]);
|
|
139
|
+
if (r < 1.2) failures.push(`${fgC}/${bgC} = ${r.toFixed(2)} (deco)`);
|
|
140
|
+
}
|
|
141
|
+
assert.deepEqual(failures, []);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
test('detectTermMode reads COLORFGBG / CARTHAGENT_THEME_MODE', () => {
|
|
147
|
+
assert.equal(detectTermMode({}), 'dark');
|
|
148
|
+
assert.equal(detectTermMode({ COLORFGBG: '15;0' }), 'dark');
|
|
149
|
+
assert.equal(detectTermMode({ COLORFGBG: '0;15' }), 'light');
|
|
150
|
+
assert.equal(detectTermMode({ COLORFGBG: '0;7' }), 'light');
|
|
151
|
+
assert.equal(detectTermMode({ COLORFGBG: '0;15', CARTHAGENT_THEME_MODE: 'dark' }), 'dark');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Light themes: the d2 graph renderer uses the plain panel as the node fill
|
|
155
|
+
// (state carried by the border). Verify that text/label/glyph colors have
|
|
156
|
+
// ≥4.5:1 contrast against the panel — the surface text actually renders on.
|
|
157
|
+
for (const name of ['paper', 'daylight', 'solarized-light', 'contrast-light', 'okabe-light']) {
|
|
158
|
+
test(`tui light theme "${name}" text is readable on the panel fill`, () => {
|
|
159
|
+
const t = flattenTheme(THEMES[name], 'light');
|
|
160
|
+
const panelBg = t.backgroundPanel || t.background;
|
|
161
|
+
const ok = t.diffAdded || t.success;
|
|
162
|
+
const err = t.diffRemoved || t.error;
|
|
163
|
+
const warn = t.warning;
|
|
164
|
+
const accent = t.primary || t.accent;
|
|
165
|
+
const pairs = [
|
|
166
|
+
[t.text, panelBg], [t.textMuted, panelBg],
|
|
167
|
+
[ok, panelBg], [err, panelBg], [warn, panelBg], [accent, panelBg],
|
|
168
|
+
[t.borderActive, panelBg],
|
|
169
|
+
];
|
|
170
|
+
for (const [fg, bg] of pairs) {
|
|
171
|
+
const r = contrast(fg, bg);
|
|
172
|
+
assert.ok(r >= 4.5, `${fg} on ${bg} = ${r.toFixed(2)} < 4.5`);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { makeKeyParser, matchSlash, selectionText } from '../lib/tui/app.mjs';
|
|
4
|
+
|
|
5
|
+
test('/copy is discoverable in command autocomplete', () => {
|
|
6
|
+
assert.ok(matchSlash('/cop').some(c => c.name === '/copy'));
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('bracketed paste survives every byte boundary, Unicode and CRLF', () => {
|
|
10
|
+
const text = 'first\r\n日本語 😀\rlast\n' + 'long text '.repeat(10000);
|
|
11
|
+
const bytes = Buffer.from(`a\x1b[200~${text}\x1b[201~b\r`);
|
|
12
|
+
const keys = [];
|
|
13
|
+
const parse = makeKeyParser(k => keys.push(k));
|
|
14
|
+
for (const byte of bytes) parse(Buffer.from([byte]));
|
|
15
|
+
assert.deepEqual(keys, [
|
|
16
|
+
{ key: 'char', ch: 'a' },
|
|
17
|
+
{ key: 'paste', text: text.replace(/\r\n?/g, '\n') },
|
|
18
|
+
{ key: 'char', ch: 'b' },
|
|
19
|
+
{ key: 'enter' },
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('mixed mouse, plain input and consecutive pastes are all consumed', () => {
|
|
24
|
+
const keys = [];
|
|
25
|
+
const parse = makeKeyParser(k => keys.push(k));
|
|
26
|
+
parse('a\x1b[<0;10;8M\x1b[<32;4;2M\x1b[<0;4;2m\x1b[200~one\x1b[201~\x1b[200~two\x1b[201~');
|
|
27
|
+
assert.deepEqual(keys.map(k => k.key), ['char', 'mousedown', 'mousedrag', 'mouseup', 'paste', 'paste']);
|
|
28
|
+
assert.deepEqual(keys.slice(-2).map(k => k.text), ['one', 'two']);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('split paste end marker never leaks into pasted text', () => {
|
|
32
|
+
for (let split = 1; split < 6; split++) {
|
|
33
|
+
const keys = [];
|
|
34
|
+
const parse = makeKeyParser(k => keys.push(k));
|
|
35
|
+
parse('\x1b[200~content' + '\x1b[201~'.slice(0, split));
|
|
36
|
+
parse('\x1b[201~'.slice(split));
|
|
37
|
+
assert.deepEqual(keys, [{ key: 'paste', text: 'content' }]);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('upward and downward selections copy identical text and preserve Unicode', () => {
|
|
42
|
+
const lines = ['hello', '日本語 😀', 'last line'];
|
|
43
|
+
const forward = { ax: 2, ay: 1, bx: 4, by: 3 };
|
|
44
|
+
const reverse = { ax: 4, ay: 3, bx: 2, by: 1 };
|
|
45
|
+
assert.equal(selectionText(lines, forward, 20), 'ello\n日本語 😀\nlast');
|
|
46
|
+
assert.equal(selectionText(lines, reverse, 20), selectionText(lines, forward, 20));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('logical selection includes offscreen rows without truncation', () => {
|
|
50
|
+
const lines = Array.from({ length: 1000 }, (_, i) => `${i}: ${'x'.repeat(80)}`);
|
|
51
|
+
const text = selectionText(lines, { ax: 90, ay: 1000, bx: 1, by: 1 }, 90);
|
|
52
|
+
assert.equal(text, lines.join('\n'));
|
|
53
|
+
assert.ok(Buffer.byteLength(text) > 50000);
|
|
54
|
+
});
|