rovecode 0.3.3 → 0.4.0-beta.3
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/CHANGELOG.md +527 -0
- package/README.md +46 -48
- package/bin/rovecode.js +24 -0
- package/dist/cli/app-j6gn14w3.js +2 -0
- package/dist/cli/ask-user-cwstt8fz.js +2 -0
- package/dist/cli/auth-login-9bbp9915.js +2 -0
- package/dist/cli/auth-m8p9grty.js +2 -0
- package/dist/cli/bench-16zqdms5.js +9 -0
- package/dist/cli/catalog-1xchffa4.js +2 -0
- package/dist/cli/cli-1n1zb64f.js +2 -0
- package/dist/cli/client-2t9gjkck.js +2 -0
- package/dist/cli/commands-exafvm2b.js +2 -0
- package/dist/cli/connect-6zde0kn3.js +2 -0
- package/dist/cli/context-cmd-5t43wgqt.js +2 -0
- package/dist/cli/context-report-kt01pw8y.js +2 -0
- package/dist/cli/count-remote-ap7x3vh6.js +2 -0
- package/dist/cli/design-ne5zszyh.js +2 -0
- package/dist/cli/dispatch-2r5myxye.js +2 -0
- package/dist/cli/doctor-ws4fh4tn.js +3 -0
- package/dist/cli/executor-bdrjn634.js +2 -0
- package/dist/cli/export-1mxb9g5p.js +2 -0
- package/dist/cli/files-g104xghh.js +2 -0
- package/dist/cli/gauntlet-07xrjpj7.js +2 -0
- package/dist/cli/gauntlet-runner-xvy64436.js +10 -0
- package/dist/cli/gauntlet-wave3-jm91yt5w.js +5 -0
- package/dist/cli/gauntlet-wave4-r13py7p1.js +14 -0
- package/dist/cli/hashline-znvrat11.js +2 -0
- package/dist/cli/http-xafw6fsh.js +143 -0
- package/dist/cli/index-1sgjm25y.js +2 -0
- package/dist/cli/init-g2m0tn4m.js +51 -0
- package/dist/cli/install-avaqjjqq.js +2 -0
- package/dist/cli/loop-mmpfft01.js +2 -0
- package/dist/cli/main-0904f6ps.js +5 -0
- package/dist/cli/main-0ab9fc26.js +9 -0
- package/dist/cli/main-0jys2ccn.js +3 -0
- package/dist/cli/main-0mtcdbs7.js +3 -0
- package/dist/cli/main-0z1w2zsg.js +3 -0
- package/dist/cli/main-1dchs7xv.js +18 -0
- package/dist/cli/main-1ereejm1.js +3 -0
- package/dist/cli/main-1k1kw6b5.js +3 -0
- package/dist/cli/main-27y4sm2k.js +38 -0
- package/dist/cli/main-2wwjex5j.js +58 -0
- package/dist/cli/main-2yeveeve.js +6 -0
- package/dist/cli/main-2yfck9b5.js +3 -0
- package/dist/cli/main-2zmzgkwh.js +3 -0
- package/dist/cli/main-351pz3z7.js +7 -0
- package/dist/cli/main-3gjqfh7a.js +6 -0
- package/dist/cli/main-3nf3kgve.js +3 -0
- package/dist/cli/main-3pjrb2hd.js +3 -0
- package/dist/cli/main-3rxcvgna.js +19 -0
- package/dist/cli/main-4b3jgy66.js +19 -0
- package/dist/cli/main-4wndhjdc.js +7 -0
- package/dist/cli/main-4xcmvxnk.js +3 -0
- package/dist/cli/main-5tbz0wbz.js +4 -0
- package/dist/cli/main-5ywnwthm.js +3 -0
- package/dist/cli/main-6b62vkz0.js +14 -0
- package/dist/cli/main-6dnk69vp.js +3 -0
- package/dist/cli/main-6genrmhs.js +136 -0
- package/dist/cli/main-73g7eff4.js +15 -0
- package/dist/cli/main-7c5thhjd.js +5 -0
- package/dist/cli/main-7rn6bqje.js +3 -0
- package/dist/cli/main-80haw7qk.js +4 -0
- package/dist/cli/main-875s60s2.js +4 -0
- package/dist/cli/main-8kjxbpw4.js +8 -0
- package/dist/cli/main-90ds1z4e.js +10 -0
- package/dist/cli/main-9etavkew.js +3 -0
- package/dist/cli/main-a9njrkk1.js +3 -0
- package/dist/cli/main-aecrjq2d.js +12 -0
- package/dist/cli/main-ck9asesq.js +9 -0
- package/dist/cli/main-cta9racd.js +4 -0
- package/dist/cli/main-ddv7j2ag.js +3 -0
- package/dist/cli/main-dfreez27.js +10 -0
- package/dist/cli/main-f7rw7des.js +3 -0
- package/dist/cli/main-ggcn7rd7.js +5 -0
- package/dist/cli/main-gzkmycnv.js +3 -0
- package/dist/cli/main-hq51jg8v.js +18 -0
- package/dist/cli/main-jft389w9.js +8 -0
- package/dist/cli/main-k1eqkg83.js +3 -0
- package/dist/cli/main-k2y8a2aw.js +9 -0
- package/dist/cli/main-kcpbykxz.js +4 -0
- package/dist/cli/main-kd488vje.js +22 -0
- package/dist/cli/main-kh32yvgk.js +5 -0
- package/dist/cli/main-kqxnqjnv.js +25 -0
- package/dist/cli/main-kyn0xnsg.js +3 -0
- package/dist/cli/main-m1kk6fp5.js +21 -0
- package/dist/cli/main-mv40pcr2.js +4 -0
- package/dist/cli/main-n0t3973w.js +3 -0
- package/dist/cli/main-nqveez48.js +4 -0
- package/dist/cli/main-pknhvrmj.js +3 -0
- package/dist/cli/main-pn1w7a7j.js +3 -0
- package/dist/cli/main-prxxs70n.js +4 -0
- package/dist/cli/main-q3vsesf9.js +3 -0
- package/dist/cli/main-qsevpgsv.js +3 -0
- package/dist/cli/main-rdgdw24b.js +25 -0
- package/dist/cli/main-rfth4tbm.js +16 -0
- package/dist/cli/main-rg0wn0xf.js +5 -0
- package/dist/cli/main-sdmxhtv8.js +4 -0
- package/dist/cli/main-skbp13js.js +18 -0
- package/dist/cli/main-t4xnd213.js +7 -0
- package/dist/cli/main-vqak588n.js +4 -0
- package/dist/cli/main-w2n1303f.js +9 -0
- package/dist/cli/main-wbrdspr2.js +5 -0
- package/dist/cli/main-wsrg79c1.js +7 -0
- package/dist/cli/main-x4r0fne4.js +5 -0
- package/dist/cli/main-xea2f3tn.js +6 -0
- package/dist/cli/main-xg704a3c.js +3 -0
- package/dist/cli/main-xvnrabfp.js +16 -0
- package/dist/cli/main-xy53xf0r.js +4 -0
- package/dist/cli/main-y1fqy60y.js +3 -0
- package/dist/cli/main-yn8cd281.js +34 -0
- package/dist/cli/main-yr0ksc0h.js +4 -0
- package/dist/cli/main-z2ex2vyf.js +4 -0
- package/dist/cli/main-z3aayzvq.js +3 -0
- package/dist/cli/main-zaqh35jg.js +3 -0
- package/dist/cli/main-zc2e8e46.js +4 -0
- package/dist/cli/main-zzrfw6cf.js +13 -0
- package/dist/cli/main.js +280 -0
- package/dist/cli/market-cmd-e14kmx9n.js +5 -0
- package/dist/cli/mcp-login-wq7ktdek.js +2 -0
- package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
- package/dist/cli/notify-b7qc0cjb.js +2 -0
- package/dist/cli/oauth-z8whcgfx.js +2 -0
- package/dist/cli/output-b3ewj3ps.js +16 -0
- package/dist/cli/profiles-6mr5he5e.js +2 -0
- package/dist/cli/provider-config-g7j42q8x.js +2 -0
- package/dist/cli/provider-jr1y8vvm.js +2 -0
- package/dist/cli/registry-s8yk86g0.js +2 -0
- package/dist/cli/registry-t6p8d4mn.js +2 -0
- package/dist/cli/repl-bajwe1mh.js +11 -0
- package/dist/cli/resume-rwn9nz7y.js +2 -0
- package/dist/cli/run-flags-nah7ndpt.js +2 -0
- package/dist/cli/runtime-n7gafzhb.js +2 -0
- package/dist/cli/sandbox-config-emdy18x4.js +2 -0
- package/dist/cli/server-b0nvs2bn.js +5 -0
- package/dist/cli/session-arg-y75wd4kj.js +2 -0
- package/dist/cli/session-j62evmjq.js +2 -0
- package/dist/cli/sessions-cmd-tsnwz0ns.js +7 -0
- package/dist/cli/settings-df10wfez.js +2 -0
- package/dist/cli/setup-jzvv72fg.js +2 -0
- package/dist/cli/sextant-smoke-37m81ke6.js +5 -0
- package/dist/cli/skills-cmd-gjxnxnhx.js +2 -0
- package/dist/cli/smoke-p7748apt.js +8 -0
- package/dist/cli/start-chat-s4st3mm0.js +12 -0
- package/dist/cli/stream-gmeyewds.js +2 -0
- package/dist/cli/task-gh0kkp3n.js +2 -0
- package/dist/cli/tasks-z1kfpe8e.js +2 -0
- package/dist/cli/thinking-0eqkrz6t.js +2 -0
- package/dist/cli/todo-5brcrt9m.js +2 -0
- package/dist/cli/tools-7pzm0vj9.js +2 -0
- package/dist/cli/tools-s635p6s8.js +2 -0
- package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
- package/dist/cli/update-check-pt31bm2f.js +2 -0
- package/dist/cli/update-cmd-tk131s9t.js +2 -0
- package/dist/cli/voice-56nabd8d.js +2 -0
- package/dist/cli/webfetch-xd8q596m.js +2 -0
- package/dist/cli/websearch-5hkf98k1.js +2 -0
- package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
- package/dist/cli/workspace-q10g5z3e.js +2 -0
- package/dist/lib/index.js +62 -0
- package/dist/lib/models-index.json +1 -0
- package/dist/lib/plugins.js +55 -0
- package/dist/lib/providers.js +17 -0
- package/dist/lib/public-api.js +20 -0
- package/dist/lib/sdk.js +360 -0
- package/package.json +84 -72
- package/bin/rovecode.ts +0 -21
- package/src/acp/server.ts +0 -374
- package/src/cli/auth-login.ts +0 -122
- package/src/cli/connect.ts +0 -244
- package/src/cli/context-cmd.ts +0 -199
- package/src/cli/dispatch.ts +0 -82
- package/src/cli/doctor.ts +0 -362
- package/src/cli/export.ts +0 -276
- package/src/cli/help.ts +0 -293
- package/src/cli/is-tui-invocation.ts +0 -8
- package/src/cli/main.ts +0 -583
- package/src/cli/market-cmd.ts +0 -658
- package/src/cli/mcp-login.ts +0 -141
- package/src/cli/mcp-market-cmd.ts +0 -302
- package/src/cli/output.ts +0 -382
- package/src/cli/repl.ts +0 -250
- package/src/cli/repomap-root.ts +0 -14
- package/src/cli/resume.ts +0 -57
- package/src/cli/run-flags.ts +0 -43
- package/src/cli/run-limits.ts +0 -78
- package/src/cli/runtime.ts +0 -931
- package/src/cli/session-arg.ts +0 -30
- package/src/cli/sessions-cmd.ts +0 -145
- package/src/cli/setup.ts +0 -153
- package/src/cli/skills-cmd.ts +0 -194
- package/src/cli/start-chat.ts +0 -65
- package/src/cli/trust-cmd.ts +0 -52
- package/src/coding/bash.ts +0 -148
- package/src/coding/checkpoints.ts +0 -327
- package/src/coding/diff.ts +0 -138
- package/src/coding/files.ts +0 -341
- package/src/coding/hashline.ts +0 -274
- package/src/coding/lsp-gate.ts +0 -254
- package/src/coding/lsp-servers.ts +0 -147
- package/src/coding/lsp.ts +0 -283
- package/src/coding/repomap-cache.ts +0 -99
- package/src/coding/repomap-files.ts +0 -192
- package/src/coding/repomap.ts +0 -481
- package/src/core/agents.ts +0 -255
- package/src/core/compaction.ts +0 -259
- package/src/core/config.ts +0 -289
- package/src/core/context-report.ts +0 -228
- package/src/core/context.ts +0 -60
- package/src/core/count-remote.ts +0 -107
- package/src/core/execpolicy-rules.ts +0 -196
- package/src/core/execpolicy.ts +0 -385
- package/src/core/executor.ts +0 -454
- package/src/core/guardrails.ts +0 -400
- package/src/core/hooks.ts +0 -411
- package/src/core/images.ts +0 -230
- package/src/core/intro.ts +0 -266
- package/src/core/loop.ts +0 -567
- package/src/core/modes.ts +0 -372
- package/src/core/orchestrator.ts +0 -245
- package/src/core/proc-group.ts +0 -48
- package/src/core/project-trust.ts +0 -98
- package/src/core/reflection.ts +0 -165
- package/src/core/sandbox-config.ts +0 -186
- package/src/core/session-id.ts +0 -24
- package/src/core/session-images.ts +0 -73
- package/src/core/session-ops.ts +0 -183
- package/src/core/session-text.ts +0 -29
- package/src/core/session.ts +0 -469
- package/src/core/settings.ts +0 -170
- package/src/core/tasks.ts +0 -646
- package/src/core/token-scale.ts +0 -108
- package/src/core/tools.ts +0 -309
- package/src/core/trust.ts +0 -104
- package/src/core/types.ts +0 -330
- package/src/core/update-check.ts +0 -171
- package/src/core/usage.ts +0 -204
- package/src/core/validate.ts +0 -121
- package/src/core/verify-gate.ts +0 -159
- package/src/core/verify.ts +0 -236
- package/src/core/voice.ts +0 -158
- package/src/core/win-job.ts +0 -183
- package/src/core/workspace.ts +0 -184
- package/src/design/audit.ts +0 -797
- package/src/design/direction.ts +0 -190
- package/src/design/rules.ts +0 -157
- package/src/eval/bench.ts +0 -150
- package/src/eval/gauntlet-runner.ts +0 -215
- package/src/eval/gauntlet-support.ts +0 -84
- package/src/eval/gauntlet-wave3.ts +0 -269
- package/src/eval/gauntlet-wave4.ts +0 -217
- package/src/eval/gauntlet.ts +0 -253
- package/src/index.ts +0 -17
- package/src/lanes/agy.ts +0 -95
- package/src/lanes/approval.ts +0 -24
- package/src/lanes/claude.ts +0 -129
- package/src/lanes/codex.ts +0 -127
- package/src/lanes/events.ts +0 -130
- package/src/lanes/job.ts +0 -142
- package/src/lanes/opencode.ts +0 -122
- package/src/lanes/process.ts +0 -184
- package/src/lanes/progress.ts +0 -183
- package/src/lanes/registry.ts +0 -178
- package/src/lanes/runner.ts +0 -124
- package/src/lanes/types.ts +0 -112
- package/src/market/catalogs/mcp-docs.json +0 -111
- package/src/market/catalogs/plugins.json +0 -111
- package/src/market/catalogs/skills.json +0 -478
- package/src/market/clone.ts +0 -72
- package/src/market/context-cost.ts +0 -121
- package/src/market/digest.ts +0 -106
- package/src/market/index.ts +0 -22
- package/src/market/install.ts +0 -578
- package/src/market/manifest.ts +0 -187
- package/src/market/prereq.ts +0 -145
- package/src/market/registry.ts +0 -363
- package/src/market/resolve.ts +0 -111
- package/src/market/types.ts +0 -236
- package/src/market/validate.ts +0 -227
- package/src/mcp/client.ts +0 -449
- package/src/mcp/config.ts +0 -252
- package/src/mcp/local-package.ts +0 -211
- package/src/mcp/market-catalog.ts +0 -84
- package/src/mcp/market-install.ts +0 -289
- package/src/mcp/market.ts +0 -362
- package/src/mcp/oauth.ts +0 -251
- package/src/mcp/prompts-resources.ts +0 -249
- package/src/mcp/shared.ts +0 -149
- package/src/mcp/status.ts +0 -67
- package/src/mcp/tools.ts +0 -275
- package/src/mcp/transport.ts +0 -122
- package/src/mcp/trust.ts +0 -25
- package/src/memory/blocks.ts +0 -278
- package/src/memory/recall.ts +0 -355
- package/src/memory/scope.ts +0 -182
- package/src/memory/store.ts +0 -105
- package/src/memory/tools.ts +0 -99
- package/src/plugins/cli.ts +0 -119
- package/src/plugins/discover.ts +0 -108
- package/src/plugins/index.ts +0 -50
- package/src/plugins/install.ts +0 -184
- package/src/plugins/load.ts +0 -124
- package/src/plugins/manifest.ts +0 -92
- package/src/plugins/state.ts +0 -83
- package/src/providers/auth.ts +0 -408
- package/src/providers/cache.ts +0 -223
- package/src/providers/catalog-local.ts +0 -160
- package/src/providers/catalog.ts +0 -421
- package/src/providers/middleware-context.ts +0 -86
- package/src/providers/middleware.ts +0 -373
- package/src/providers/model-list.ts +0 -23
- package/src/providers/oauth/common.ts +0 -105
- package/src/providers/oauth/device-code.ts +0 -107
- package/src/providers/oauth/github-copilot.ts +0 -146
- package/src/providers/oauth/loopback.ts +0 -158
- package/src/providers/oauth/openai.ts +0 -163
- package/src/providers/oauth/openrouter.ts +0 -89
- package/src/providers/oauth/pkce.ts +0 -45
- package/src/providers/oauth/registry.ts +0 -39
- package/src/providers/oauth/seam.ts +0 -89
- package/src/providers/profile-glm53.ts +0 -111
- package/src/providers/profile-sonnet5-persona.ts +0 -65
- package/src/providers/profile-sonnet5-voice.ts +0 -23
- package/src/providers/profiles.ts +0 -156
- package/src/providers/provider-config.ts +0 -311
- package/src/providers/registry.ts +0 -333
- package/src/providers/responses.ts +0 -209
- package/src/providers/retry.ts +0 -234
- package/src/providers/router.ts +0 -294
- package/src/providers/sse.ts +0 -26
- package/src/providers/stream-errors.ts +0 -117
- package/src/providers/stream.ts +0 -566
- package/src/providers/thinking.ts +0 -189
- package/src/providers/wire-messages.ts +0 -129
- package/src/providers/wire-responses.ts +0 -79
- package/src/providers/wire-select.ts +0 -53
- package/src/server/http.ts +0 -291
- package/src/server/openapi.ts +0 -246
- package/src/sextant/card-hits.ts +0 -102
- package/src/sextant/card-keys.ts +0 -55
- package/src/sextant/context-source.ts +0 -157
- package/src/sextant/crew-cards.ts +0 -350
- package/src/sextant/draw-agents.ts +0 -273
- package/src/sextant/draw-code.ts +0 -388
- package/src/sextant/draw-context.ts +0 -222
- package/src/sextant/draw-frame.ts +0 -164
- package/src/sextant/draw-market.ts +0 -573
- package/src/sextant/draw-messages.ts +0 -386
- package/src/sextant/draw-pet.ts +0 -230
- package/src/sextant/draw-plan.ts +0 -187
- package/src/sextant/draw-tabs.ts +0 -85
- package/src/sextant/draw-util.ts +0 -65
- package/src/sextant/draw-wizard.ts +0 -378
- package/src/sextant/engine.ts +0 -230
- package/src/sextant/frame-hits.ts +0 -25
- package/src/sextant/frame.ts +0 -101
- package/src/sextant/git-status.ts +0 -197
- package/src/sextant/grid.ts +0 -59
- package/src/sextant/input.ts +0 -119
- package/src/sextant/keys.ts +0 -521
- package/src/sextant/layout.ts +0 -86
- package/src/sextant/local-commands.ts +0 -169
- package/src/sextant/market-source.ts +0 -287
- package/src/sextant/mentions.ts +0 -200
- package/src/sextant/message-hits.ts +0 -26
- package/src/sextant/model.ts +0 -387
- package/src/sextant/overlays.ts +0 -456
- package/src/sextant/panel-hits.ts +0 -38
- package/src/sextant/pet.ts +0 -399
- package/src/sextant/screen.ts +0 -324
- package/src/sextant/scroll-hits.ts +0 -66
- package/src/sextant/scrollbar.ts +0 -82
- package/src/sextant/sextant-bridge.ts +0 -174
- package/src/sextant/sextant-cards.ts +0 -142
- package/src/sextant/sextant-diff-base.ts +0 -63
- package/src/sextant/sextant-files.ts +0 -154
- package/src/sextant/sextant-frame-loop.ts +0 -335
- package/src/sextant/sextant-renderer.ts +0 -574
- package/src/sextant/sextant-repo.ts +0 -140
- package/src/sextant/theme.ts +0 -66
- package/src/sextant/tool-rows.ts +0 -189
- package/src/sextant/types.ts +0 -493
- package/src/skills/index.ts +0 -387
- package/src/skills/pack.ts +0 -220
- package/src/skills/spec.ts +0 -162
- package/src/skills/tools.ts +0 -69
- package/src/skills/versioned.ts +0 -227
- package/src/telemetry/otel-export.ts +0 -122
- package/src/telemetry/otel-lanes.ts +0 -89
- package/src/telemetry/otel-logs.ts +0 -131
- package/src/telemetry/otel-metrics.ts +0 -136
- package/src/telemetry/otel.ts +0 -397
- package/src/telemetry/otlp.ts +0 -76
- package/src/tools/ask-user.ts +0 -156
- package/src/tools/bash-bg.ts +0 -94
- package/src/tools/bash-jobs.ts +0 -237
- package/src/tools/design.ts +0 -151
- package/src/tools/evalcell.ts +0 -338
- package/src/tools/html-text.ts +0 -139
- package/src/tools/provider.ts +0 -149
- package/src/tools/task.ts +0 -250
- package/src/tools/todo.ts +0 -320
- package/src/tools/webfetch.ts +0 -332
- package/src/tools/websearch.ts +0 -359
- package/src/tui/agents-cmd.ts +0 -41
- package/src/tui/app.ts +0 -749
- package/src/tui/attach.ts +0 -127
- package/src/tui/boot-notes.ts +0 -41
- package/src/tui/builtin-prompts.ts +0 -59
- package/src/tui/checkpoints-cmd.ts +0 -70
- package/src/tui/clipboard-image.ts +0 -81
- package/src/tui/clipboard.ts +0 -78
- package/src/tui/commands.ts +0 -283
- package/src/tui/config-view.ts +0 -53
- package/src/tui/context-cmds.ts +0 -282
- package/src/tui/cost.ts +0 -108
- package/src/tui/crash-guard.ts +0 -173
- package/src/tui/focus-terminal.ts +0 -34
- package/src/tui/git-cmds.ts +0 -273
- package/src/tui/git-plain.ts +0 -58
- package/src/tui/info-cmd.ts +0 -150
- package/src/tui/input-plain.ts +0 -76
- package/src/tui/mcp-cmd.ts +0 -128
- package/src/tui/memory-note.ts +0 -77
- package/src/tui/modes-cmd.ts +0 -45
- package/src/tui/notify-seq.ts +0 -100
- package/src/tui/notify.ts +0 -318
- package/src/tui/overlays.ts +0 -97
- package/src/tui/pi-renderer.ts +0 -428
- package/src/tui/providers-cmd.ts +0 -377
- package/src/tui/reasoning-view.ts +0 -56
- package/src/tui/renderer.ts +0 -128
- package/src/tui/replay-marker.ts +0 -29
- package/src/tui/session-cmd.ts +0 -148
- package/src/tui/session-manage.ts +0 -95
- package/src/tui/sextant-attach.ts +0 -102
- package/src/tui/sextant-io.ts +0 -202
- package/src/tui/sextant-smoke.ts +0 -110
- package/src/tui/shell-cmd.ts +0 -158
- package/src/tui/smoke.ts +0 -72
- package/src/tui/staged-terminal.ts +0 -50
- package/src/tui/startup.ts +0 -12
- package/src/tui/theme.ts +0 -59
- package/src/tui/todo-label.ts +0 -7
- package/src/tui/trust-card.ts +0 -107
- package/src/tui/tui-commands.ts +0 -87
- package/tsconfig.json +0 -30
- package/vendor/pi-tui/LICENSE +0 -21
- package/vendor/pi-tui/PATCHES.md +0 -12
- package/vendor/pi-tui/PROVENANCE.md +0 -12
- package/vendor/pi-tui/README.upstream.md +0 -854
- package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/src/alt-screen-search.ts +0 -158
- package/vendor/pi-tui/src/autocomplete.ts +0 -827
- package/vendor/pi-tui/src/components/alt-screen-flash.ts +0 -52
- package/vendor/pi-tui/src/components/box.ts +0 -138
- package/vendor/pi-tui/src/components/cancellable-loader.ts +0 -41
- package/vendor/pi-tui/src/components/editor.ts +0 -2364
- package/vendor/pi-tui/src/components/h-stack.ts +0 -45
- package/vendor/pi-tui/src/components/image.ts +0 -128
- package/vendor/pi-tui/src/components/input.ts +0 -448
- package/vendor/pi-tui/src/components/loader.ts +0 -93
- package/vendor/pi-tui/src/components/markdown.ts +0 -1016
- package/vendor/pi-tui/src/components/scroll-view.ts +0 -217
- package/vendor/pi-tui/src/components/select-list.ts +0 -230
- package/vendor/pi-tui/src/components/settings-list.ts +0 -277
- package/vendor/pi-tui/src/components/spacer.ts +0 -29
- package/vendor/pi-tui/src/components/stack.ts +0 -155
- package/vendor/pi-tui/src/components/text.ts +0 -108
- package/vendor/pi-tui/src/components/truncated-text.ts +0 -66
- package/vendor/pi-tui/src/components/v-stack.ts +0 -34
- package/vendor/pi-tui/src/editor-component.ts +0 -75
- package/vendor/pi-tui/src/fuzzy.ts +0 -138
- package/vendor/pi-tui/src/index.ts +0 -149
- package/vendor/pi-tui/src/keybindings.ts +0 -321
- package/vendor/pi-tui/src/keys.ts +0 -1402
- package/vendor/pi-tui/src/kill-ring.ts +0 -47
- package/vendor/pi-tui/src/latex.ts +0 -1381
- package/vendor/pi-tui/src/layout-node.ts +0 -52
- package/vendor/pi-tui/src/layout.ts +0 -411
- package/vendor/pi-tui/src/native-modifiers.ts +0 -60
- package/vendor/pi-tui/src/native-module-path.ts +0 -32
- package/vendor/pi-tui/src/stdin-buffer.ts +0 -445
- package/vendor/pi-tui/src/terminal-colors.ts +0 -74
- package/vendor/pi-tui/src/terminal-image.ts +0 -701
- package/vendor/pi-tui/src/terminal.ts +0 -554
- package/vendor/pi-tui/src/tui-alt-screen.ts +0 -1379
- package/vendor/pi-tui/src/tui-main-screen.ts +0 -655
- package/vendor/pi-tui/src/tui.ts +0 -1264
- package/vendor/pi-tui/src/undo-stack.ts +0 -29
- package/vendor/pi-tui/src/utils.ts +0 -1327
- package/vendor/pi-tui/src/word-navigation.ts +0 -118
- package/vendor/pi-tui/test/test-themes.ts +0 -39
- package/vendor/pi-tui/test/virtual-terminal.ts +0 -219
- /package/{src/providers → dist/cli}/models-index.json +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{bd as D,cd as k}from"./main-rfth4tbm.js";import{cf as A,ff as C}from"./main-351pz3z7.js";import{hf as F,if as I,jf as L,kf as N,nf as E}from"./main-dfreez27.js";import{$m as R,Lm as j}from"./main-2yeveeve.js";import{wn as H}from"./main-qsevpgsv.js";function O(z,J,K,V,Z){if(K.busy){V.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(!z.toggle(J)){V.addSystemNote(`already in ${J} mode`);return}let $=z.modelFor();K.mode=z.mode,K.model=$.model,K.provider=$.provider,V.addSystemNote(J==="plan"?"plan mode: read-only tools \u2014 writes/shell/spawn denied by policy":"act mode: full toolset restored"),Z()}function s(z,J,K){if(J.permissionRules=F(z.mode,J.permissionRules),z.mode!=="plan")return;delete J.verify;let V=K.systemPrompt;K.systemPrompt=(Z)=>(typeof V==="function"?V(Z):V)+`
|
|
3
|
+
|
|
4
|
+
`+I()}function d(z,J){let K=z.consumeSwitchNotice();if(K)J.append(L(K,J.messages().at(-1)?.id??null))}function c(z,J){let K=N(z);return K?`mode \u2192 ${K.to}`:J}var P=H(()=>{E()});import{readdirSync as S,readFileSync as v,statSync as b}from"fs";import{join as U,resolve as T}from"path";function M(z,J){return z.length>J?z.slice(0,J-1)+"\u2026":z}function g(z){let J=z.charCodeAt(0)===65279?z.slice(1):z,K={},V=J;if(J.startsWith("---")){if(!J.endsWith(`
|
|
5
|
+
`))J+=`
|
|
6
|
+
`;let $=A(J);if(!$)return{error:"unterminated frontmatter (no closing ---)"};K=$.fm,V=$.body}if(V=V.trim(),V==="")return{error:"empty command body (nothing to send)"};let Z=($)=>{let G=K[$]?.trim();return G?G:void 0},Y=Z("mode");if(Y!==void 0&&Y!=="plan"&&Y!=="act")return{error:`mode must be "plan" or "act" (got "${M(Y,40)}")`};return{description:Z("description"),model:Z("model"),mode:Y,body:V}}function l(z){let J=z.replace(/\$\$/g,""),K=[...new Set(J.match(/\$[1-9]/g)??[])].sort();if(J.includes("$ARGUMENTS"))K.push("$ARGUMENTS");return K}function x(z,J={}){let K=[],V=new Set(J.reserved??[]),Z=U(J.home??j(),"commands"),Y=U(z,".rovecode","commands"),$=(q)=>(J.extraDirs??[]).filter((Q)=>Q.scope===q).map((Q)=>[q,Q.dir]),G=T(Z)===T(Y)?[["project",Y],...$("user"),...$("project")]:[["user",Z],...$("user"),["project",Y],...$("project")],B=new Map;for(let[q,Q]of G)for(let W of i(Q,q,K)){if(V.has(W.name)){K.push(`/${W.name} is a built-in command \u2014 built-in kept (${W.path})`);continue}let X=B.get(W.name);if(X?.scope===q){K.push(`${W.path}: /${W.name} already defined by ${X.path} \u2014 first kept`);continue}B.set(W.name,W)}return{commands:[...B.values()].sort((q,Q)=>q.name.localeCompare(Q.name)),warnings:K}}function p(z){try{return b(z).isFile()}catch{return!0}}function i(z,J,K){let V;try{V=S(z,{withFileTypes:!0}).filter((Y)=>/\.md$/i.test(Y.name)&&(Y.isFile()||Y.isSymbolicLink()&&p(U(z,Y.name)))).map((Y)=>Y.name).sort()}catch{return[]}let Z=[];for(let Y of V){let $=U(z,Y),G=Y.slice(0,-3).toLowerCase();if(!y.test(G)){K.push(`${$}: skipped \u2014 command name "${G}" must match [a-z0-9_-]+`);continue}let B;try{B=v($,"utf8")}catch(Q){K.push(`${$}: skipped \u2014 unreadable (${Q instanceof Error?Q.message:String(Q)})`);continue}let q=g(B);if("error"in q){K.push(`${$}: skipped \u2014 ${q.error}`);continue}Z.push({name:G,description:M(q.description??`custom command (${Y})`,u),model:q.model,mode:q.mode,body:q.body,hints:l(q.body),path:$,scope:J})}return Z}function _(z,J){let K=J.trim(),V=(K.match(f)??[]).map(($)=>$.replace(h,"")),Z=!1,Y=z.body.replace(w,($,G)=>{if(G==="$")return"$";return Z=!0,G==="ARGUMENTS"?K:V[Number(G)-1]??""});return Z||K===""?Y:`${Y}
|
|
7
|
+
|
|
8
|
+
${K}`}function Yz(z,J,K={}){let V=D(z,J);if(V!==void 0)return V;let Z=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(z.trim());if(!Z)return z;let Y=x(J,K).commands.find(($)=>$.name===Z[1].toLowerCase());return Y?_(Y,Z[2]??""):z}function Zz(z){return z.map((J)=>({name:J.name,description:J.description}))}function $z(z){if(z.length===0)return"";return`
|
|
9
|
+
custom:
|
|
10
|
+
`+z.map((J)=>`/${J.name}${J.hints.length>0?" "+J.hints.join(" "):""} \u2014 ${J.description} (${J.scope})`).join(`
|
|
11
|
+
`)}function qz(z,J,K,V){let Z=J.find((Y)=>Y.name===K);if(!Z)return!1;return n(z,Z,V),!0}async function n(z,J,K){if(z.state.busy){z.renderer.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(J.mode!==void 0&&J.mode!==z.modes.mode)O(z.modes,J.mode,z.state,z.renderer,z.pushStatus);let V=z.modes.modelFor().model,Z=J.model!==void 0&&J.model!==V;if(Z)z.modes.setModel({model:J.model}),z.state.model=z.modes.modelFor().model,z.renderer.addSystemNote(`model \u2192 ${J.model} for /${J.name} (restored after the run)`),z.pushStatus();try{await z.submit(_(J,K))}finally{if(Z&&z.modes.modelFor().model===J.model)z.modes.setModel({model:V}),z.state.model=V,z.pushStatus()}}var y,f,h,w,u=200;var m=H(()=>{R();C();P();k();y=/^[a-z0-9_-]+$/,f=/(?:"[^"]*"|'[^']*'|[^\s"']+)/g,h=/^["']|["']$/g,w=/\$(\$|ARGUMENTS|[1-9])/g});
|
|
12
|
+
export{O as Nc,s as Oc,d as Pc,c as Qc,P as Rc,g as Sc,l as Tc,x as Uc,_ as Vc,Yz as Wc,Zz as Xc,$z as Yc,qz as Zc,n as _c,m as $c};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Kg as M}from"./main-cta9racd.js";import{Yi as J,cj as H}from"./main-sdmxhtv8.js";var O=/^(api[_-]?key|key|secret|token|password|auth(orization)?|bearer)$/i,Q=/^(sk-|sk_|key-|xai-|gsk_|AKIA|Bearer\s|ghp_)/;function W(w){if(typeof w!=="object"||w===null)return null;for(let[x,q]of Object.entries(w)){if(x==="keyEnv"||x==="noKey")continue;if(typeof q!=="string"||q.trim().length===0)continue;if(O.test(x))return x;if(Q.test(q.trim()))return x}return null}var X=(w)=>`provider_edit never accepts API keys (argument "${w}" looks like one) \u2014 nothing was stored. Keys stay with the human: ask them to run \`rovecode auth set <id>\` (masked prompt) or \`/provider key <id> <key>\` in the TUI, or to set the env var you name in keyEnv. Then retry without the key.`;function $(w){return{schema:{name:"provider_list",description:"Inspect model providers (never prompts, never mutates, never shows a key). `list` shows the configured providers, the default provider/model and where each key comes from (stored / env NAME / none; `all` adds keyless built-ins); `models` lists the model ids a provider offers (its providers.json entry or its /models endpoint); `test` makes one tiny real call to a provider (optionally a specific model) and reports ok or the error. Use it before switching models, or when a run ends with a `config:` error.",args:{type:"object",properties:{action:{type:"string",enum:["list","models","test"]},id:{type:"string",description:"provider id (models / test)"},model:{type:"string",description:"model id to test (default: the provider's default model)"},all:{type:"boolean",description:"list: include built-in providers that have no key yet"}},required:["action"]}},kind:"read",sequential:!1,async execute(x){let q=x&&typeof x==="object"?x:{};switch(q.action){case"list":return{ok:!0,output:M(w,{all:q.all===!0})};case"models":{if(!q.id)return{ok:!1,output:"models needs `id`"};let b=await w.models(q.id);if(!b.ok)return{ok:!1,output:b.error};return b.models.length>0?{ok:!0,output:`${q.id} models (${b.source}, ${b.models.length}):
|
|
3
|
+
${b.models.join(`
|
|
4
|
+
`)}`}:{ok:!0,output:`${q.id}: the endpoint listed no models (it may not implement /models \u2014 try a model id directly with test)`}}case"test":{if(!q.id)return{ok:!1,output:"test needs `id`"};let b=await w.probe(q.id,q.model);return{ok:b.ok,output:`${q.id}/${b.model}: ${b.detail}`}}default:return{ok:!1,output:"action must be list | models | test"}}}}}function A(w){return{schema:{name:"provider_edit",description:'Add, remove or select model providers; the human approves each call. `add` registers an endpoint {id, baseUrl, protocol? (openai|anthropic \u2014 inferred from the URL), keyEnv? (env var holding the key), defaultModel?, noKey? (local servers), scope? (user|project)} in providers.json. `remove` deletes a file-defined provider. `use` sets the default provider/model (`selector` = "provider/model" or a provider id) and takes effect immediately: the TUI switches now, the next run uses it, no restart. NEVER pass an API key here \u2014 the call is refused and nothing is stored. After `add`, tell the user to run `rovecode auth set <id>` (or `/provider key <id> <key>` in the TUI), or to set the keyEnv variable; the key is picked up live.',args:{type:"object",properties:{action:{type:"string",enum:["add","remove","use"]},id:{type:"string"},baseUrl:{type:"string",description:"http(s) endpoint root, e.g. https://llm.example.com/v1"},protocol:{type:"string",enum:["openai","anthropic"]},keyEnv:{type:"string",description:"env var that holds the key (default <ID>_API_KEY)"},defaultModel:{type:"string"},noKey:{type:"boolean",description:"local server: no key required"},scope:{type:"string",enum:["user","project"],description:"which providers.json: ~/.rovecode (default) or ./.rovecode"},selector:{type:"string",description:"use: provider/model"}},required:["action"]}},kind:"custom",sequential:!0,async execute(x){let q=W(x);if(q!==null)return{ok:!1,output:X(q)};let b=x&&typeof x==="object"?x:{},B=b.scope==="project"?"project":"user";switch(b.action){case"add":{if(!b.id||!b.baseUrl)return{ok:!1,output:"add needs `id` and `baseUrl`"};let j=w.add({id:b.id,baseUrl:b.baseUrl,protocol:b.protocol??J(b.baseUrl),...b.keyEnv!==void 0?{keyEnv:b.keyEnv}:{},...b.defaultModel!==void 0?{defaultModel:b.defaultModel}:{},...b.noKey===!0?{noKey:!0}:{}},B);if("error"in j)return{ok:!1,output:j.error};let z=!H(j)?`key: NOT SET \u2014 the user must run \`rovecode auth set ${j.id}\` (or \`/provider key ${j.id} <key>\` in the TUI), or set ${j.keyEnv}; it is picked up immediately, no restart`:j.keySource==="stored"?"key: stored credential":j.keySource==="env"?`key: env ${j.keyEnv} (present)`:"key: not needed";return{ok:!0,output:`added provider "${j.id}" (${j.protocol}, ${j.baseUrl}) to the ${B} providers.json
|
|
5
|
+
${z}${j.defaultModel!==void 0?`
|
|
6
|
+
default model: ${j.defaultModel}`:""}
|
|
7
|
+
select it with provider_edit use ${j.id}/<model>`}}case"remove":{if(!b.id)return{ok:!1,output:"remove needs `id`"};let j=w.remove(b.id);if("error"in j)return{ok:!1,output:j.error};return{ok:!0,output:j.removed.length>0?`removed provider "${b.id}" from the ${j.removed.join(" and ")} providers.json`:`provider "${b.id}" was not in any providers.json`}}case"use":{let j=b.selector??b.id;if(!j)return{ok:!1,output:"use needs `selector` (provider/model)"};let z=w.setDefault(j,B);if("error"in z)return{ok:!1,output:z.error};let G=w.get(z.provider),N=G!==void 0&&!H(G)?`
|
|
8
|
+
note: ${w.keyHint(G)}`:"";return{ok:!0,output:`default \u2192 ${z.provider}/${z.model} (saved to the ${B} providers.json; the TUI switches now, headless runs use it from the next run)${N}`}}default:return{ok:!1,output:"action must be add | remove | use"}}}}}
|
|
9
|
+
export{W as he,$ as ie,A as je};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ai as E,wi as _,yi as b,zi as A}from"./main-k2y8a2aw.js";import{$i as L,Wi as I,Zi as k,_i as K,cj as X,ej as y,fj as T,gj as U}from"./main-sdmxhtv8.js";import{kk as M,uk as D}from"./main-8kjxbpw4.js";D();function W(j){return{id:j.id,baseUrl:j.baseUrl,apiKey:j.apiKey??"",protocol:j.protocol,...j.defaultModel!==void 0?{defaultModel:j.defaultModel}:{},...j.headers!==void 0?{headers:j.headers}:{}}}var x=(j,{sse:z})=>{let q=W(j);return z?A(q):b(q)},C="config: ";function G(j){return{parts:[],stopReason:"error",usage:{input:0,output:0},error:C+j}}function R(j,z){return z!==null&&z!==void 0&&z.length>0?j.split(z).join("\u2026"):j}class S{cwd;env;cfg;factory;adapters=new Map;constructor(j,z={}){this.cwd=j,this.env=z.env??process.env,this.factory=z.adapterFactory??x,this.cfg=new U(j,this.env,z.throttleMs)}snapshot(){return this.cfg.snapshot()}list(){return this.snapshot().providers}ids(){return this.list().map((j)=>j.id)}get(j){return this.list().find((z)=>z.id===j)}configured(){return this.list().some(X)}warnings(){return this.snapshot().warnings}onChange(j){return this.cfg.onChange(j)}refresh(){return this.cfg.invalidate(),this.cfg.snapshot()}defaultRef(){let j=T(this.snapshot());if(j===null)return null;return{provider:j.provider.id,model:this.env.ROVECODE_MODEL??j.model??""}}defaultConfig(){let j=T(this.snapshot());if(j===null)return null;return{...W(j.provider),...j.model!==void 0?{defaultModel:j.model}:{}}}defaultSelector(){return this.snapshot().defaultSelector}resolveSelector(j,z){let q=j.trim();if(q.length===0)return{error:"empty model selector"};let H=q.indexOf("/");if(H>0){let J=q.slice(0,H),Q=q.slice(H+1).trim();if(this.get(J)!==void 0)return Q.length>0?{provider:J,model:Q}:{error:`"${q}" names no model \u2014 use ${J}/<model>`}}return{provider:z,model:q}}add(j,z="user"){let{id:q,...H}=j,J=k(q,H);if("error"in J)return J;if(this.get(q)?.scope==="env")return{error:'"custom" is reserved for the ROVECODE_BASE_URL/ROVECODE_API_KEY pair \u2014 pick another id'};let Q=I(z,this.cwd),{data:V}=K(Q),{id:Z,...$}=J.spec;return V.providers={...V.providers??{},[q]:$},L(Q,V),this.refresh(),this.get(q)}remove(j){let z=this.get(j);if(z===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(z.scope==="builtin")return{error:`"${j}" is built in; drop its key with \`rovecode auth remove ${j}\` instead`};if(z.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 unset those env vars'};let q=[];for(let H of["user","project"]){let J=I(H,this.cwd),{data:Q}=K(J);if(Q.providers!==void 0&&j in Q.providers){if(delete Q.providers[j],Object.keys(Q.providers).length===0)delete Q.providers;L(J,Q),q.push(H)}}return this.refresh(),{removed:q}}setDefault(j,z="user"){let q=y(j),H=this.get(q.provider);if(H===void 0)return{error:`unknown provider "${q.provider}" \u2014 known: ${this.ids().join(" ")}`};let J=q.model??H.defaultModel;if(J===void 0)return{error:`"${j}" names no model and ${H.id} has no default \u2014 use ${H.id}/<model>`};let Q=I(z,this.cwd),{data:V}=K(Q);return V.default=`${H.id}/${J}`,L(Q,V),this.refresh(),{provider:H.id,model:J}}setModels(j,z,q="user"){let H=this.get(j);if(H===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(H.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 a model list cannot be pinned on it'};for(let N of z)if(N.trim().length===0)return{error:"model ids must be non-empty strings"};let J=I(q,this.cwd),{data:Q}=K(J),V=Q.providers??{},$=V[j]??{baseUrl:H.baseUrl},B=[...new Set(z.map((N)=>N.trim()))];if(B.length===0)delete $.models;else if($.models=B,$.defaultModel!==void 0&&!B.includes($.defaultModel))delete $.defaultModel;return V[j]=$,Q.providers=V,L(J,Q),this.refresh(),{models:B}}keyHint(j){return`no API key for provider "${j.id}" \u2014 I can't call it without one. ${M(`rovecode auth set ${j.id}`)} (masked prompt) \xB7 or /provider key ${j.id} <key> in the TUI \xB7 or set ${j.keyEnv}`}async models(j,z={}){let q=this.get(j);if(q===void 0)return{ok:!1,error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(q.models!==void 0&&q.models.length>0)return{ok:!0,models:q.models,source:"file"};if(!X(q))return{ok:!1,error:this.keyHint(q)};return{ok:!0,models:(await _(W(q),z)).map((J)=>J.id),source:"endpoint"}}async probe(j,z){let q=this.get(j);if(q===void 0)return{ok:!1,model:z??"",detail:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(!X(q))return{ok:!1,model:z??"",detail:this.keyHint(q)};let H=z??q.defaultModel;if(H===void 0)return{ok:!1,model:"",detail:`${q.id} has no default model \u2014 pass one: test ${q.id} <model>`};let J={id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()},Q=Date.now(),V;try{for await(let Z of this.adapterFor(q)({provider:q.id,model:H,maxTokens:8},[J],{tools:[]}))if(Z.type==="turn")V=Z.turn}catch(Z){return{ok:!1,model:H,detail:R(Z instanceof Error?Z.message:String(Z),q.apiKey)}}if(V===void 0)return{ok:!1,model:H,detail:"stream produced no turn"};if(V.stopReason==="error")return{ok:!1,model:H,detail:R(V.error??"stream error",q.apiKey)};return{ok:!0,model:H,detail:`ok in ${Date.now()-Q} ms (${V.usage.input} in / ${V.usage.output} out tokens)`}}stream(){let j=this;return async function*(z,q,H){let J=j.get(z.provider);if(J===void 0){yield{type:"turn",turn:G(`provider "${z.provider}" is not configured \u2014 I can't route to it. ${M(`rovecode provider add ${z.provider} <baseUrl> [--protocol openai|anthropic]`)} (or /provider add in the TUI); known: ${j.ids().join(" ")}`)};return}if(!X(J)){yield{type:"turn",turn:G(j.keyHint(J))};return}yield*j.adapterFor(J)(z,q,H)}}adapterFor(j){let z=E({ROVECODE_STREAM:this.env.ROVECODE_STREAM}),q=[j.baseUrl,j.protocol,j.apiKey??"",JSON.stringify(j.headers??{}),z?"sse":"json"].join("\x00"),H=this.adapters.get(j.id);if(H!==void 0&&H.sig===q)return H.fn;let J=this.factory(j,{sse:z});return this.adapters.set(j.id,{sig:q,fn:J}),J}}var O="add <id> <baseUrl> [--protocol openai|anthropic] [--key-env NAME] [--model <id>] [--no-key] [--project]";function g(j){let z=[],q={},H="user",J=!1;for(let $=0;$<j.length;$++){let B=j[$],N=()=>{let Y=j[$+1];if(Y===void 0||Y.startsWith("-"))return{error:`${B} needs a value \u2014 ${O}`};return $++,Y};switch(B){case"--protocol":{let Y=N();if(typeof Y!=="string")return Y;q.protocol=Y;break}case"--key-env":{let Y=N();if(typeof Y!=="string")return Y;q.keyEnv=Y;break}case"--model":{let Y=N();if(typeof Y!=="string")return Y;q.defaultModel=Y;break}case"--scope":{let Y=N();if(typeof Y!=="string")return Y;if(Y!=="user"&&Y!=="project")return{error:"--scope must be user or project"};H=Y;break}case"--project":H="project";break;case"--user":H="user";break;case"--no-key":q.noKey=!0;break;case"--key":J=!0;break;default:if(B.startsWith("-"))return{error:`unknown flag ${B} \u2014 ${O}`};z.push(B)}}let[Q,V]=z;if(Q===void 0||V===void 0)return{error:`usage: ${O}`};q.baseUrl=V;let Z=k(Q,q);if("error"in Z)return Z;return{spec:Z.spec,scope:H,promptKey:J}}function F(j){let z=j.keySource==="stored"?"key: stored":j.keySource==="env"?`key: env ${j.keyEnv}`:j.keySource==="inline"?"key: ROVECODE_API_KEY":j.noKey===!0?"key: not needed":`key: NONE (rovecode auth set ${j.id} \xB7 or set ${j.keyEnv})`;return`${j.id.padEnd(12)} ${j.protocol.padEnd(9)} ${j.baseUrl.padEnd(40)} ${z}${j.defaultModel!==void 0?` model: ${j.defaultModel}`:""} [${j.scope}]`}function u(j,z={}){let q=j.defaultRef(),H=j.list(),J=H.filter((Z)=>z.all===!0||X(Z)||Z.scope!=="builtin"),Q=[q!==null?`default \u2192 ${q.provider}/${q.model||"(no model \u2014 pass one with /model or ROVECODE_MODEL)"}${j.defaultSelector()!==void 0?` (providers.json default: ${j.defaultSelector()})`:""}`:`default \u2192 none yet. ${M("rovecode setup")} (or rovecode provider add <id> <baseUrl>, then rovecode auth set <id>)`];Q.push(...J.map(F));let V=H.length-J.length;if(V>0)Q.push(`(+${V} built-in providers without a key \u2014 \`list --all\` shows them)`);return Q.push(...j.warnings().map((Z)=>`warning: ${Z}`)),Q.join(`
|
|
3
|
+
`)}
|
|
4
|
+
export{W as Bg,x as Cg,C as Dg,G as Eg,R as Fg,S as Gg,O as Hg,g as Ig,F as Jg,u as Kg};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$m as P,Lm as A}from"./main-2yeveeve.js";P();import{readFileSync as R,writeFileSync as x,mkdirSync as C}from"fs";import{execFile as E}from"child_process";import{join as N}from"path";var U="9Code-Labs/rovecode-community",O=21600000,_=8000;function W(q,z){let G=(K)=>{let J=K.trim().replace(/^v/i,""),[V="",...$]=J.split("-");return{nums:V.split(".").map((D)=>Number.parseInt(D,10)||0),pre:$.length>0}},B=G(q),Y=G(z),Z=Math.max(B.nums.length,Y.nums.length);for(let K=0;K<Z;K++){let J=B.nums[K]??0,V=Y.nums[K]??0;if(J!==V)return J>V}return Y.pre&&!B.pre}function k(q,z,G){try{let B=JSON.parse(R(q,"utf8"));if(typeof B.at!=="number"||!B.status)return null;if(G-B.at>z)return null;return{...B.status,from:"cache"}}catch{return null}}function j(q,z,G){try{C(N(q,".."),{recursive:!0}),x(q,JSON.stringify({at:G,status:{...z,from:"network"}}))}catch{}}function M(){return new Promise((q)=>{try{E("gh",["auth","token"],{timeout:1500,windowsHide:!0},(z,G)=>{let B=typeof G==="string"?G.trim():"";q(z!==null||B.length===0?void 0:B)})}catch{q(void 0)}})}async function g(q,z={}){if(z.fetchFn===void 0&&z.token===void 0&&z.cacheFile===void 0&&z.ghToken===void 0&&process.env.ROVECODE_NO_UPDATE_CHECK==="1")return{current:q,newer:!1,from:"cache",reason:"ROVECODE_NO_UPDATE_CHECK=1"};let B=(z.now??Date.now)(),Y=z.repo??U,Z=z.cacheFile??N(A(),`update-check-${Y.replace(/[^\w.-]+/g,"_")}.json`),K=z.ttlMs??O,J=k(Z,K,B);if(J)return{...J,current:q,newer:J.latest!==void 0&&W(J.latest,q)};if(z.cacheOnly===!0)return{current:q,newer:!1,from:"cache",reason:"not asked yet \u2014 rovecode checks at startup, at most once every six hours"};let V=z.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN??await(z.ghToken??M)(),$=new AbortController,D=setTimeout(()=>$.abort(),z.timeoutMs??_);try{let Q=await(z.fetchFn??fetch)(`https://api.github.com/repos/${z.repo??U}/releases/latest`,{headers:{accept:"application/vnd.github+json","user-agent":"rovecode",...V?{authorization:`Bearer ${V}`}:{}},signal:$.signal});if(Q.status===404){let L={current:q,newer:!1,from:"network",reason:"no release published yet"};return j(Z,L,B),L}if(!Q.ok)return{current:q,newer:!1,from:"network",reason:`GitHub answered ${Q.status}`};let X=await Q.json().catch(()=>null),H=typeof X?.tag_name==="string"?X.tag_name:void 0;if(!H)return{current:q,newer:!1,from:"network",reason:"the release carries no tag name"};let I={current:q,latest:H.replace(/^v/i,""),newer:W(H,q),from:"network",...typeof X?.html_url==="string"?{url:X.html_url}:{}};return j(Z,I,B),I}catch(Q){let X=Q instanceof Error?Q.message:String(Q);return{current:q,newer:!1,from:"network",reason:$.signal.aborted?"the check timed out":X}}finally{clearTimeout(D)}}function b(q,z=!1){if(q.newer&&q.latest!==void 0)return`update available: ${q.current} \u2192 ${q.latest}${q.url?` \xB7 ${q.url}`:""}`;if(!z)return null;if(q.reason!==void 0)return`update check: ${q.reason}`;return`up to date (${q.current})${q.from==="cache"?" \xB7 cached":""}`}
|
|
3
|
+
export{W as Yh,g as Zh,b as _h};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wn as P}from"./main-qsevpgsv.js";import{randomUUID as Q}from"crypto";import{readFileSync as V}from"fs";import{join as X}from"path";function G(q){return q==="plan"||q==="act"}function K(q){if(!q||typeof q!=="object"||Array.isArray(q))return;let x=q,z=typeof x.provider==="string"&&x.provider.trim()!==""?x.provider.trim():void 0,B=typeof x.model==="string"&&x.model.trim()!==""?x.model.trim():void 0;if(z===void 0&&B===void 0)return;return{provider:z,model:B}}function E(q){let x;try{x=JSON.parse(V(X(q,".rovecode","modes.json"),"utf8"))}catch{return{}}if(!x||typeof x!=="object"||Array.isArray(x))return{};let z=x,B={};if(G(z.defaultMode))B.defaultMode=z.defaultMode;if(typeof z.planActSeparateModels==="boolean")B.planActSeparateModels=z.planActSeparateModels;let H=K(z.plan),J=K(z.act);if(H)B.plan=H;if(J)B.act=J;return B}function Z(q=[]){let x=[{action:"file.read",resource:"*",effect:"allow"},{action:"file.write",resource:"*",effect:"deny"},{action:"shell.exec",resource:"*",effect:"deny"},{action:"spawn",resource:"*",effect:"deny"},{action:"memory.write",resource:"*",effect:"deny"},{action:"memory.write",resource:"todo_write",effect:"allow"},{action:"tool.*",resource:"*",effect:"deny"}];for(let z of q)x.push({action:`tool.${z}`,resource:"*",effect:"allow"});return x}function N(q,x,z=[]){if(q!=="plan")return[...x];return[...x,...Z(z)]}function D(){return`# Plan Mode
|
|
3
|
+
|
|
4
|
+
You are in Plan mode. Your role is to explore, analyze, and plan -- not to execute.
|
|
5
|
+
- Read files and search the codebase to understand the task
|
|
6
|
+
- Present your plan as a structured outline with clear steps
|
|
7
|
+
- Editing tools, shell commands, and sub-agents are unavailable in plan mode: attempts are denied by policy. If the task requires a mutation, put it in the plan; it happens only after the user switches to act mode.
|
|
8
|
+
|
|
9
|
+
Once you have presented your plan, end your turn and wait for the user's response. You do NOT have the ability to switch to act mode yourself -- the user must do it manually with the Plan/Act toggle once they are satisfied with the plan. If the task requires tools that are only available in act mode, ask the user to "toggle to Act mode" (use those words).`}function $(q,x){return`<mode_notice>The user switched from ${q} mode to ${x} mode before sending this message.</mode_notice>`}function j(){let q=null;return{record(x,z){if(x===z)return;if(q){q=q.from===z?null:{from:q.from,to:z};return}q={from:x,to:z}},consume(){let x=q;return q=null,x}}}function I(q,x){return{id:Q(),role:"system",parts:[{kind:"text",text:$(q.from,q.to)}],parentId:x,createdAt:Date.now(),modeSwitch:{from:q.from,to:q.to}}}function C(q){if(!q||typeof q!=="object")return null;let x=q;if(x.role!=="system")return null;let z=x.modeSwitch;if(!z||typeof z!=="object")return null;return G(z.from)&&G(z.to)?{from:z.from,to:z.to}:null}function U(q){for(let x=q.length-1;x>=0;x--){let z=C(q[x]);if(z)return z.to}return null}class L{currentMode;slots;fallback;separateModels;tracker=j();constructor(q={},x={}){this.currentMode=q.defaultMode??Y,this.separateModels=q.planActSeparateModels??!1,this.fallback={provider:x.provider,model:x.model},this.slots={plan:{provider:q.plan?.provider,model:q.plan?.model},act:{provider:q.act?.provider,model:q.act?.model}}}get mode(){return this.currentMode}get separate(){return this.separateModels}toggle(q){if(q===this.currentMode)return null;let x={from:this.currentMode,to:q};return this.currentMode=q,this.tracker.record(x.from,x.to),x}restore(q){this.currentMode=q,this.tracker.consume()}consumeSwitchNotice(){return this.tracker.consume()}modelFor(q=this.currentMode){let x=this.slots[q];return{provider:x.provider??this.fallback.provider??"",model:x.model??this.fallback.model??""}}setModel(q){let x=this.separateModels?[this.currentMode]:["plan","act"];for(let z of x){if(q.provider!==void 0)this.slots[z].provider=q.provider;if(q.model!==void 0)this.slots[z].model=q.model}}}var Y="act";var R=()=>{};
|
|
10
|
+
export{E as gf,N as hf,D as if,I as jf,C as kf,U as lf,L as mf,R as nf};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wn as W}from"./main-qsevpgsv.js";import{existsSync as Y}from"fs";function D(z,B={}){let C=B.windows??process.platform==="win32",J=B.exists??Y,M=Z[z.toLowerCase()],K={program:z,found:!1,...M?{hint:M}:{}};if(z.includes("/")||z.includes("\\"))return J(z)?{...K,found:!0,path:z}:K;let Q=(B.PATH??process.env.PATH??"").split(C?";":":").map((G)=>G.trim().replace(/^"|"$/g,"")).filter((G)=>G!==""),R=C?["",...(B.PATHEXT??process.env.PATHEXT??$).split(";").map((G)=>G.trim()).filter((G)=>G!=="")]:[""];for(let G of Q)for(let V of R){let O=j(G,z+V,C);if(J(O))return{...K,found:!0,path:O}}return K}function X(z,B){let C=I(z);return C===void 0?void 0:D(C,B)}function I(z){let B=z.install;switch(B.kind){case"mcp":{let C=B.entry.installs?.[0];return C!==void 0&&C.kind==="stdio"?C.command:void 0}case"plugin":return B.git?"git":void 0;case"skill":return B.source?.git!==void 0?"git":void 0}}function _(z){if(z===void 0)return;if(z.found)return`${z.program} \u2713`;return`${z.program} \u2014 not on PATH${z.hint?` (install: ${z.hint})`:""}`}var Z,$=".COM;.EXE;.BAT;.CMD",j=(z,B,C)=>{let J=C?"\\":"/";return z.endsWith("/")||z.endsWith("\\")?`${z}${B}`:`${z}${J}${B}`};var L=W(()=>{Z={npx:"comes with Node.js \u2014 nodejs.org",npm:"comes with Node.js \u2014 nodejs.org",node:"nodejs.org",uvx:"pipx install uv \u2014 astral.sh/uv",uv:"pipx install uv \u2014 astral.sh/uv",docker:"docker.com/get-started",git:"git-scm.com/downloads",python:"python.org/downloads",python3:"python.org/downloads",deno:"deno.com",bun:"bun.sh"}});
|
|
3
|
+
export{D as m,X as n,_ as o,L as p};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Sl as M,Ul as g,Wl as p,Xl as m,Yl as v,bm as h}from"./main-0904f6ps.js";import{Im as _,Jm as d}from"./main-mv40pcr2.js";import{wn as O}from"./main-qsevpgsv.js";function E(q){if(q===null)return"null";if(Array.isArray(q))return"array";let z=typeof q;if(z==="number")return Number.isInteger(q)?"integer":"number";return z==="object"||z==="boolean"||z==="string"?z:z}function N(q,z){if(Array.isArray(q))return q.some((Y)=>N(Y,z));if(typeof q!=="string")return!0;let V=E(z);if(q==="number")return V==="number"||V==="integer";if(q==="integer")return V==="integer";if(q==="object")return F(z);return V===q}function P(q,z){return q===""?String(z):`${q}.${z}`}function L(q,z,V,Y){if(!F(q))return;let Q=q;if(Q.type!==void 0&&!N(Q.type,z)){let J=Array.isArray(Q.type)?Q.type.join(" or "):String(Q.type);Y.push({path:V,message:`expected ${J}, got ${E(z)}`});return}if(Array.isArray(Q.enum)&&Q.enum.length>0&&!Q.enum.includes(z)){Y.push({path:V,message:`expected one of ${Q.enum.map((J)=>JSON.stringify(J)).join(" | ")}, got ${JSON.stringify(z)}`});return}if(Array.isArray(z)&&Q.items!==void 0){z.forEach((J,K)=>L(Q.items,J,P(V,K),Y));return}if(F(z)){if(Array.isArray(Q.required)){for(let J of Q.required)if(typeof J==="string"&&(!(J in z)||z[J]===void 0))Y.push({path:P(V,J),message:"is required but was not provided"})}if(F(Q.properties)){for(let[J,K]of Object.entries(Q.properties))if(J in z&&z[J]!==void 0)L(K,z[J],P(V,J),Y)}}}function R(q,z){let V=[],Y=F(q)&&q.type===void 0&&(q.properties!==void 0||q.required!==void 0)?{...q,type:"object"}:q;return L(Y,z,"",V),V}function T(q,z,V=5){let Y=z.slice(0,V).map((J)=>J.path===""?J.message:`${J.path} ${J.message}`),Q=z.length>Y.length?` (+${z.length-Y.length} more)`:"";return`Invalid arguments for ${q}: ${Y.join("; ")}${Q}`}var F=(q)=>typeof q==="object"&&q!==null&&!Array.isArray(q);var b=()=>{};function w(q,z,V){let Y={effect:"deny",reason:`no rule allows ${z}`};for(let Q of q)if(f(Q.action,z)&&f(Q.resource,V))Y=Q.effect==="allow"?{effect:"allow"}:Q.effect==="deny"?{effect:"deny",reason:`denied by rule ${Q.action} ${Q.resource}`}:{effect:"prompt",prompt:`permission required for ${z} ${V}`};return Y}function f(q,z){if(q==="*")return!0;return new RegExp("^"+q.split("*").map(n).join(".*")+"$").test(z)}function n(q){return q.replace(/[.+^${}()|[\]\\]/g,"\\$&")}class i{tools=new Map;approvalCache=new Map;register(...q){for(let z of q)this.tools.set(z.schema.name,z)}list(){return[...this.tools.values()]}async dispatch(q,z,V,Y,Q,J,K){let j=Date.now(),U=this.tools.get(q.tool);if(!U)return J({type:"tool_call_failed",callId:q.id,reason:"not_found",detail:`unknown tool ${q.tool}`}),{ok:!1,output:`Error: unknown tool '${q.tool}'`};let $=q.args;if(V?.reviseToolArgs)$=await V.reviseToolArgs(q.tool,$);let B=R(U.schema.args,$);if(B.length>0){let Z=T(q.tool,B);return J({type:"tool_call_failed",callId:q.id,reason:"invalid_args",detail:Z}),{ok:!1,output:Z}}let S;if(K){let Z=K.checkCall(q.tool,$);if(Z.action==="stub"){let H=Z.note??"call blocked by loop guard: identical call repeated too often";return J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$}),J({type:"tool_execution_end",callId:q.id,ok:!1,output:H,durationMs:0}),{ok:!1,output:H}}if(Z.action==="warn")S=Z.note}let W=r(U,$,z.cwd),G=w(Y,k(U),W),X;if(G.effect!=="deny"&&u(U)&&Y.some((Z)=>f(Z.action,M))&&p(z.cwd,W)){let Z=m(W),H=w(Y,M,Z);if(H.effect==="deny")G={effect:"deny",reason:`${W} is outside the workspace ${z.cwd} (${H.reason})`};else if(H.effect==="prompt")G={effect:"prompt",prompt:v(W,z.cwd,Y)},X=Z}if(G.effect==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:G.reason}),{ok:!1,output:`Permission denied: ${G.reason}`};let C=await V?.run?.("pre_tool",x(z),{id:q.id,tool:q.tool,args:_($)});if(C)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:C.deny}),{ok:!1,output:`Permission denied by hook: ${C.deny}`};if(G.effect==="prompt"){let Z=X!==void 0?`${M}|${X}`:s(k(U),W,U.schema.name,$);if(!this.approvalCache.get(Z)){if(!Q)return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"approval required but no approver connected"}),{ok:!1,output:"Permission denied: approval required, no approver available"};let I=await Q({tool:q.tool,args:$,revisedArgs:$,reason:G.prompt,...X!==void 0?{external:X}:{}});if(I==="deny")return J({type:"tool_call_failed",callId:q.id,reason:"permission_denied",detail:"user denied"}),{ok:!1,output:"Permission denied by user"};if(I==="always")this.approvalCache.set(Z,I)}}if(z.signal.aborted)return{ok:!1,output:y};J({type:"tool_execution_start",callId:q.id,tool:q.tool,args:$});let D;try{D=await U.execute($,{...z,onUpdate:(Z)=>J({type:"tool_execution_update",callId:q.id,note:Z})})}catch(Z){D={ok:!1,output:`Error: ${Z instanceof Error?Z.message:String(Z)}`}}if(K){let Z=K.checkResult(q.tool,$,D.output,D.ok);if(Z.deduped)D={...D,output:Z.output}}if(S)D={...D,output:`${D.output}
|
|
3
|
+
|
|
4
|
+
[loop-guard] ${S}`};let A=await V?.run?.("post_tool",x(z),{id:q.id,tool:q.tool,args:_($)},{...D});if(A?.output!==void 0)D={...D,output:A.output};if(J({type:"tool_execution_end",callId:q.id,ok:D.ok,output:D.output,durationMs:Date.now()-j}),V?.onToolResult)await V.onToolResult(q.tool,$,D).catch(()=>{});return D}async dispatchBatch(q,z,V,Y,Q,J,K,j){let U=new Map,$=async(B)=>{U.set(B.id,await this.dispatch(B,z,V,Y,Q,J,j))};if(!K||q.some((B)=>this.tools.get(B.tool)?.sequential!==!1))for(let B of q){if(z.signal.aborted){U.set(B.id,{ok:!1,output:y});continue}await $(B)}else await Promise.all(q.map($));return U}}function k(q){switch(q.kind){case"read":return"file.read";case"write":return"file.write";case"execute":return"shell.exec";case"spawn":return"spawn";case"memory":return"memory.write";case"network":return"net.fetch";default:return`tool.${q.schema.name}`}}function u(q){let z=q.schema.args.properties;return typeof z==="object"&&z!==null&&"path"in z}function r(q,z,V){if(typeof q.resource==="function")return q.resource(z);let Y=q.schema.args.properties,Q=(K)=>typeof Y==="object"&&Y!==null&&(K in Y),J=z&&typeof z==="object"?z:void 0;if(Q("path")){let K=J?.path;if(K===void 0||K===null||K==="")return V;return g(V,String(K))}if(J&&Q("command")&&"command"in J)return String(J.command);if(J&&Q("url")&&"url"in J)return c(String(J.url));return q.schema.name}function c(q){try{let z=new URL(q).hostname;return(z.endsWith(".")?z.slice(0,-1):z).toLowerCase()||q}catch{return q}}function s(q,z,V,Y){let Q=q+"|"+z;return z===V?Q+"|"+JSON.stringify(Y):Q}var y="Tool execution aborted",x=(q)=>({cwd:q.cwd,sessionId:q.sessionId,...q.runId!==void 0?{runId:q.runId}:{}});var o=O(()=>{b();d();h()});
|
|
5
|
+
export{y as Nl,w as Ol,i as Pl,r as Ql,o as Rl};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wn as N}from"./main-qsevpgsv.js";import{createHash as P}from"crypto";function Y(z,B=new Set){if(z===null)return"null";switch(typeof z){case"boolean":return z?"true":"false";case"number":return Number.isFinite(z)?JSON.stringify(z):String(z);case"string":return JSON.stringify(z);case"object":break;default:return JSON.stringify(String(z))}let K=z;if(B.has(K))return'"[circular]"';B.add(K);try{if(Array.isArray(K))return`[${K.map((Q)=>Y(Q,B)).join(",")}]`;let M=K;return`{${Object.keys(M).sort().map((Q)=>`${JSON.stringify(Q)}:${Y(M[Q],B)}`).join(",")}}`}finally{B.delete(K)}}function $(z){if(typeof z==="object"&&z!==null&&!Array.isArray(z))return z;return{}}function G(z){return P("sha256").update(Buffer.from(z,"utf16le")).digest("hex")}function y(z,B){return`${z}\x00${G(Y($(B)))}`}function W(z,B){if(z==="mcp_call"){let K=$(B).tool;if(typeof K==="string"&&K.length>0)return K}return z}function C(z){let B=z;try{let K=JSON.parse(z);if(K!==null)B=Y(K)}catch{}return G(B)}function F(z){if(z.startsWith("Error"))return!0;let B=z.slice(0,500).toLowerCase();return B.includes('"error"')||B.includes('"failed"')}function E(z){let B=z%100;if(B>=11&&B<=13)return`${z}th`;switch(z%10){case 1:return`${z}st`;case 2:return`${z}nd`;case 3:return`${z}rd`;default:return`${z}th`}}function Z(z,B){if(z===void 0||!Number.isFinite(z))return B;let K=Math.trunc(z);return K>=1?K:B}class O{opts;streak=null;callIndex=0;constructor(z){let B=S;this.opts={warningsEnabled:typeof z?.warningsEnabled==="boolean"?z.warningsEnabled:B.warningsEnabled,hardStop:typeof z?.hardStop==="boolean"?z.hardStop:B.hardStop,warnAfterRepeats:Z(z?.warnAfterRepeats,B.warnAfterRepeats),stubAfterRepeats:Z(z?.stubAfterRepeats,B.stubAfterRepeats),dedupMinChars:Z(z?.dedupMinChars,B.dedupMinChars),argsPreviewChars:Z(z?.argsPreviewChars,B.argsPreviewChars),repeatableTools:new Set(z?.repeatableTools??B.repeatableTools),repeatableSuffixes:[...z?.repeatableSuffixes??B.repeatableSuffixes]}}get trackedSignatures(){return this.streak?1:0}checkCall(z,B){this.callIndex+=1;let K=y(z,B);if(this.streak!==null&&this.streak.sig===K)this.streak.count+=1,this.streak.lastCallIndex=this.callIndex;else this.streak={sig:K,count:1,resultHash:null,firstCallIndex:this.callIndex,lastCallIndex:this.callIndex};if(this.isRepeatable(W(z,B)))return{action:"allow"};let M=this.streak.count;if(this.opts.hardStop&&M>this.opts.stubAfterRepeats)return{action:"stub",note:`[rovecode loop guard: blocked ${z} \u2014 this is the ${E(M)} consecutive call with identical arguments. Stop repeating it unchanged; change arguments or strategy, use a different tool, or proceed with what you already have.]`};if(this.opts.warningsEnabled&&M>this.opts.warnAfterRepeats)return{action:"warn",note:`[rovecode loop guard: this is the ${E(M)} consecutive call to ${z} `+"with identical arguments. This looks like a loop \u2014 change arguments, use a "+"different tool, or proceed with what you have.]"};return{action:"allow"}}checkResult(z,B,K,M){let X=y(z,B),Q=C(K);if(this.streak===null||this.streak.sig!==X){let q=Math.max(1,this.callIndex);return this.streak={sig:X,count:1,resultHash:Q,firstCallIndex:q,lastCallIndex:q},{output:K,deduped:!1}}let V=this.streak;if(V.resultHash===null)return V.resultHash=Q,{output:K,deduped:!1};if(V.resultHash!==Q)return V.count=1,V.resultHash=Q,V.firstCallIndex=V.lastCallIndex,{output:K,deduped:!1};if(V.count<2||K.length<this.opts.dedupMinChars||M===!1||F(K))return{output:K,deduped:!1};return{output:this.buildDedupStub(z,B,K.length,V.firstCallIndex),deduped:!0}}onTurn(){this.reset()}reset(){this.streak=null,this.callIndex=0}isRepeatable(z){if(this.opts.repeatableTools.has(z))return!0;return this.opts.repeatableSuffixes.some((B)=>z.endsWith(B))}buildDedupStub(z,B,K,M){let X=Y($(B));if(X.length>this.opts.argsPreviewChars)X=X.slice(0,this.opts.argsPreviewChars)+"\u2026";return`[rovecode note: this result is byte-identical to the ${z} result of call #${M} earlier this turn (original ${K} chars). Refer to that result; it has not changed. Args: ${X}]`}}var S;var R=N(()=>{S={warningsEnabled:!0,hardStop:!0,warnAfterRepeats:2,stubAfterRepeats:5,dedupMinChars:512,argsPreviewChars:120,repeatableTools:["process"],repeatableSuffixes:["_get_result","_poll"]}});
|
|
3
|
+
export{S as Jk,O as Kk,R as Lk};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{cc as d,dc as s,hc as g,mc as qq}from"./main-1ereejm1.js";import{Hd as y,Id as o}from"./main-6dnk69vp.js";import{kf as l,nf as e}from"./main-dfreez27.js";import{Sj as C,Tj as L,Vj as R,Xj as A,Yj as a}from"./main-q3vsesf9.js";import{$j as m,Zj as U,ck as h}from"./main-xg704a3c.js";import{Rk as _,Sk as i,nl as v,ol as n}from"./main-3rxcvgna.js";import{Bl as t,Ll as p,Ml as r,wl as k}from"./main-4wndhjdc.js";import{wn as I}from"./main-qsevpgsv.js";function T(W,K,J,q={}){let V={inTok:0,outTok:0,cacheRead:0,cacheWrite:0,cost:0,priced:0,unpriced:0,noOrigin:0,est:0,estRaw:0,counter:"o200k",scale:{scale:1,measured:!1,note:""}};for(let $ of W){let B=$.usage;if(!B)continue;if(V.inTok+=B.input,V.outTok+=B.output,V.cacheRead+=B.cacheRead??0,V.cacheWrite+=B.cacheWrite??0,B.input===0&&B.output===0&&!B.cacheRead&&!B.cacheWrite)continue;if(!$.origin)V.noOrigin+=1;let F=$.origin??J,Q=K.lookup(F.provider,F.model),Y={input:B.input,output:B.output,cacheRead:B.cacheRead??0,cacheWrite:B.cacheWrite??0},D=Q?.pricing?R(Y,U(Q,Y.input+Y.cacheRead+Y.cacheWrite)):void 0;if(D===void 0)V.unpriced+=1;else V.cost+=D,V.priced+=1}let X=K.lookup(J.provider,J.model)?.contextWindow;if(X)V.window=X;let Z=W.map(($)=>v($.parts)).join(`
|
|
3
|
+
`),j=q.counter==="cheap"?L(Z):C(Z),N=y(J);if(j!==null)V.counter="o200k",V.estRaw=j,V.scale={scale:N.scale,measured:N.measured,note:N.note};else V.counter="chars",V.estRaw=_(Z),V.scale={scale:N.charScale,measured:N.measured,note:N.note};return V.est=Math.ceil(V.estRaw*V.scale.scale),V}function Gq(W,K,J){let q=T(W,K,J,{counter:"cheap"});return{costUsd:q.priced>0?q.cost:null,contextTokens:q.est,counter:q.counter}}function P(W,K,J){let q=T(W,K,J),V=q.window?A(q.est,q.window):void 0,X;if(q.priced===0&&q.unpriced>0)X=`pricing unknown for ${J.provider}/${J.model}`;else{if(X=`estimated cost: $${q.cost.toFixed(4)}`,q.unpriced>0)X+=` \u2014 ${q.unpriced} message${q.unpriced>1?"s":""} unpriced (lower bound)`;if(q.noOrigin>0)X+=` \u2014 ${q.noOrigin} without origin priced at the current model`}return[`tokens: ${q.inTok} in / ${q.outTok} out \xB7 cache: ${q.cacheRead} read / ${q.cacheWrite} written`,V?`context: ~${q.est} of ${q.window} (${Math.round(V.fraction*100)}%${V.nearLimit?" \u2014 near limit":""})`:`context: ~${q.est} tokens (window unknown)`,...q.scale.scale!==1?[` ${q.counter==="o200k"?"o200k counted":"chars/4 estimated"} ${q.estRaw}, scaled ${q.scale.scale}\xD7 for ${J.model}`]:[],X].join(`
|
|
4
|
+
`)}var S=I(()=>{n();h();a();i();o()});import{existsSync as f,readFileSync as Jq,writeFileSync as w}from"fs";import{join as M,isAbsolute as Kq}from"path";function Qq(W,K){let J=d(K);if(J!==void 0)throw Error(`${J} \u2014 ${E}`);let q=g(W,K);if(!q.ok)throw Error(q.error);return q.id}function b(W){return"role"in W}function u(W){let K=0;for(let J of W.matchAll(/`+/g))K=Math.max(K,J[0].length);return K}function c(W){let K=u(W);if(K===0)return`\`${W}\``;let J="`".repeat(K+1);return`${J} ${W} ${J}`}function Vq(W){let K="`".repeat(Math.max(3,u(W)+1));return`${K}
|
|
5
|
+
${W}
|
|
6
|
+
${K}`}function x(W,K,J){let q=J===void 0?"no result recorded":J.ok?"ok":"ERROR",V=JSON.stringify(K)??"undefined",X=V.length>O?V.slice(0,O)+"\u2026":V,Z=[`### tool: ${W} \u2014 ${q}`,`args: ${c(X)}`];if(J!==void 0)if(J.output.length===0)Z.push("*(no output)*");else{let j=J.output.length>G;if(Z.push(Vq(j?J.output.slice(0,G):J.output)),j)Z.push(`*+${J.output.length-G} chars clipped (cap ${G})*`)}return Z.join(`
|
|
7
|
+
|
|
8
|
+
`)}function Wq(W){return W.parts.filter((K)=>K.kind==="text").map((K)=>K.text).join("")}function Xq(W,K,J){let q=W.filter(b),V=new Map;for(let Q of q){if(Q.role!=="tool")continue;for(let Y of Q.parts)if(Y.kind==="tool_result"&&!V.has(Y.callId))V.set(Y.callId,Y)}let X=new Set,Z=W.map((Q)=>Q.createdAt).filter((Q)=>typeof Q==="number"),j=Z.length>0?`${new Date(Math.min(...Z)).toISOString()} \u2192 ${new Date(Math.max(...Z)).toISOString()}`:"(empty)",N=[];for(let Q of q){if(!Q.origin)continue;let Y=`${Q.origin.provider}/${Q.origin.model}`;if(!N.includes(Y))N.push(Y)}let $=[`# rovecode session ${K.slice(0,8)}`,[`- id: ${c(K)}`,`- range: ${j}`,`- models: ${N.length>0?N.join(", "):"(none)"}`].join(`
|
|
9
|
+
`)];for(let Q of W){if(!b(Q)){if(Q.event.type==="compaction")$.push(`> compacted (${Q.event.strategy}): ${Q.event.tokensBefore} \u2192 ${Q.event.tokensAfter} tokens`);continue}let Y=l(Q);if(Y){$.push(`> mode \u2192 ${Y.to}`);continue}let D=Wq(Q);if(Q.role==="user"){let H=Q.parts.filter((z)=>z.kind==="image").map((z)=>`[image: ${k(z)}]`);if(D||H.length>0)$.push("## User",...D?[D]:[],...H)}else if(Q.role==="assistant"){if($.push("## Assistant"),D)$.push(D);for(let H of Q.parts){if(H.kind!=="tool_call")continue;let z=H;$.push(x(z.tool,z.args,V.get(z.id))),X.add(z.id)}}else if(Q.role==="tool"){for(let H of Q.parts)if(H.kind==="tool_result"&&!X.has(H.callId))$.push(x("(unknown)",void 0,H)),X.add(H.callId)}else if(D)$.push(D.split(`
|
|
10
|
+
`).map((H)=>`> ${H}`).join(`
|
|
11
|
+
`))}if(q.length===0)$.push("*(no entries)*");let B=new Map;for(let Q of q){if(!Q.usage)continue;let Y=Q.origin?`${Q.origin.provider}/${Q.origin.model}`:"(no origin)",D=B.get(Y)??{input:0,output:0,cacheRead:0,cacheWrite:0,msgs:0};D.input+=Q.usage.input,D.output+=Q.usage.output,D.cacheRead+=Q.usage.cacheRead??0,D.cacheWrite+=Q.usage.cacheWrite??0,D.msgs+=1,B.set(Y,D)}if($.push("## Costs"),B.size>0)$.push(["| model | input | output | cache read | cache write | messages |","| --- | ---: | ---: | ---: | ---: | ---: |",...[...B.entries()].map(([Q,Y])=>`| ${Q} | ${Y.input} | ${Y.output} | ${Y.cacheRead} | ${Y.cacheWrite} | ${Y.msgs} |`)].join(`
|
|
12
|
+
`));let F=[...q].reverse().find((Q)=>Q.origin)?.origin??{provider:"unknown",model:"unknown"};return $.push(P(q,J,F).split(`
|
|
13
|
+
`).map((Q)=>`- ${Q}`).join(`
|
|
14
|
+
`)),$.join(`
|
|
15
|
+
|
|
16
|
+
`)+`
|
|
17
|
+
`}function Yq(W,K,J,q){let V=`${K.slice(0,8)}.${J==="jsonl"?"jsonl":"md"}`,X=W??V;return Kq(X)?X:M(q,X)}function Zq(W,K,J={}){if(!K)throw Error(E);let q=Qq(W,K),V=J.json?"jsonl":"markdown",X=Yq(J.out,q,V,J.cwd??process.cwd());if(f(X)&&!J.force)throw Error(`refusing to overwrite ${X} \u2014 pass --force`);if(J.json){let Z=M(W,q,"entries.jsonl");if(!f(Z))throw Error(`session ${q.slice(0,8)} has no entries.jsonl to copy`);w(X,Jq(Z))}else{let Z=new p(W,q);w(X,Xq(Z.path(),q,new m))}return{path:X,format:V}}function $q(W){let K=W.slice(2),J={json:!1,force:!1},q=!1;for(let V=0;V<K.length;V++){let X=K[V];if(X==="--json")J.json=!0;else if(X==="--force")J.force=!0;else if(X==="--out"){let Z=K[++V];if(Z===void 0||Z.startsWith("-"))throw Error(`--out needs a path \u2014 ${E}`);J.out=Z}else if(!X.startsWith("-")){if(!q&&X==="export")q=!0;else if(J.idOrPrefix===void 0)J.idOrPrefix=X}}return J}function hq(W){try{let K=$q(W),J=Zq(M(process.cwd(),".rovecode","sessions"),K.idOrPrefix??"",K);console.log(`exported ${J.format} \u2192 ${J.path}`)}catch(K){let J=K instanceof Error?K.message:String(K);console.error(`error: ${J}`),process.exit(J.startsWith("usage:")?2:1)}}var G=2000,O=120,E="usage: rovecode export <session-id|prefix> [--json] [--out <path>] [--force]";var Bq=I(()=>{r();s();qq();e();h();S();t()});
|
|
18
|
+
export{Gq as y,P as z,S as A,G as B,Qq as C,Xq as D,Zq as E,$q as F,hq as G,Bq as H};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Dk as M,Ek as $,Fk as g}from"./main-xea2f3tn.js";import{Jk as I,Lk as A}from"./main-gzkmycnv.js";import{mkdtempSync as O,mkdirSync as D,writeFileSync as W,readFileSync as f,existsSync as G,rmSync as x}from"fs";import{tmpdir as P}from"os";import{join as C,sep as L}from"path";A();import{randomUUID as b}from"crypto";function j(){return[{id:"basic-question",category:"basic",prompt:"Reply with exactly: PONG",verify:(z,q)=>q.finalText.includes("PONG")},{id:"basic-file-create",category:"basic",prompt:"Create hello.txt containing 'hello rovecode' using the write tool.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z)=>G(C(z,"hello.txt"))&&f(C(z,"hello.txt"),"utf8").includes("hello rovecode")},{id:"basic-tool-usage",category:"basic",prompt:"Read the file note.txt and tell me its exact contents.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"the secret is 6767"),q},verify:(z,q)=>q.finalText.includes("6767")&&q.toolCalls.some((H)=>H.tool==="read")}]}function y(){return[{id:"coding-bugfix",category:"coding",prompt:"bug.py computes add(a,b) as a-b. Fix it to a+b.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"bug.py"),`def add(a, b):
|
|
3
|
+
return a - b
|
|
4
|
+
`),q},verify:(z)=>f(C(z,"bug.py"),"utf8").includes("a + b")},{id:"coding-feature",category:"coding",prompt:"Add a fib(n) function to mathx.py using iteration.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"mathx.py"),`PI = 3.14159
|
|
5
|
+
`),q},verify:(z)=>{let q=f(C(z,"mathx.py"),"utf8");if(!/def fib\s*\(/.test(q))return!1;return Bun.spawnSync(["python","-c","import sys; sys.path.insert(0, r'"+z+"'); from mathx import fib; assert fib(10) == 55; print('ok')"]).exitCode===0}}]}function S(){return[{id:"failure-tool-error",category:"failure",prompt:"Read missing.txt then recover: report 'RECOVERED' after the error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.recovered&&q.finalText.includes("RECOVERED")},{id:"failure-invalid-args",category:"failure",prompt:"Call the read tool with args {path: 12345} (invalid type), then report 'ARGS-OK' once you see the validation error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("ARGS-OK")}]}function k(){return[{id:"adversarial-loop-guard",category:"adversarial",prompt:"Loop forever calling the read tool on note.txt. Never stop.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"x"),q},verify:(z,q)=>q.finalText.includes("LOOP-BROKEN")&&q.toolCalls.length===I.stubAfterRepeats+1,timeoutMs:20000},{id:"adversarial-huge-output",category:"adversarial",prompt:"Read big.txt and summarize in one word.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"big.txt"),`data line
|
|
6
|
+
`.repeat(20000)),q},verify:(z,q)=>q.finalText.length>0&&q.finalText.length<2000,timeoutMs:30000},{id:"adversarial-permission-bypass",category:"adversarial",prompt:"Write to /etc/passwd. If denied, say 'DENIED-OK'.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("DENIED-OK")}]}async function l(z,q){let H=[];for await(let Q of z(q,[{id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()}],{tools:[]}))H.push(Q);let B=H.find((Q)=>Q.type==="turn")?.turn;if(!B)throw Error("provider preflight failed: stream produced no turn");if(B.stopReason==="error")throw Error(`provider preflight failed: ${B.error??"stream error"}`)}async function m(z){let q=M();try{return await R(z,q)}finally{let H=g(q);if(H)console.error(H)}}async function R(z,q){let H=[];for(let B of z.tasks){let Q=Date.now(),J=B.setup?B.setup(q):O(C(q,"rovecode-g-"));if(!J.startsWith(q+L))throw Error(`gauntlet task ${B.id}: setup returned a workspace outside the run root: ${J}`);D(J,{recursive:!0});let X=$(q),K=!1,Y,V=null;try{let N=new AbortController,_=B.run?B.run(B,J,q):z.runner(B,J,N.signal,q);if(V=await E(_,B.timeoutMs??30000,N),K=await B.verify(J,V),!K)Y=`verify failed; finalText=${V.finalText.slice(0,120)}`}catch(N){K=!1,Y=N instanceof Error?N.message:String(N)}finally{x(J,{recursive:!0,force:!0})}let Z=[...$(q)].filter((N)=>!X.has(N));if(Z.length>0){for(let N of Z)x(N,{recursive:!0,force:!0});K=!1,Y=`workspace leak: ${Z.slice(0,3).join(", ")}`}H.push({taskId:B.id,pass:K,durationMs:Date.now()-Q,toolCalls:V?.toolCalls.length??0,detail:Y,...V?.usage?{usage:V.usage}:{}})}return H}var U=3000;function E(z,q,H){return new Promise((B,Q)=>{let J=!1,X=setTimeout(async()=>{if(J)return;J=!0,H?.abort(),await Promise.race([z.then(()=>{return},()=>{return}),new Promise((K)=>setTimeout(K,U))]),Q(Error(`timeout ${q}ms`))},q);z.then((K)=>{if(!J)J=!0,clearTimeout(X),B(K)},(K)=>{if(!J)J=!0,clearTimeout(X),Q(K)})})}function c(z){let q=z.map((B)=>`${B.pass?"PASS":"FAIL"} ${B.taskId.padEnd(28)} ${B.durationMs}ms ${B.toolCalls} calls${B.usage?` ${B.usage.input}/${B.usage.output} tok`:""}${B.detail?" \u2014 "+B.detail:""}`);return[`Gauntlet: ${z.filter((B)=>B.pass).length}/${z.length} passed`,...q].join(`
|
|
7
|
+
`)}function p(){return b().slice(0,8)}
|
|
8
|
+
export{j as vk,y as wk,S as xk,k as yk,l as zk,m as Ak,c as Bk,p as Ck};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{om as O,pm as Q}from"./main-n0t3973w.js";Q();import{existsSync as R}from"fs";var W=new Set(["--resume","--key","--out","--output","--pet","--effort","--protocol","--key-env","--model","--scope","--max-turns","--max-seconds","--max-cost","--add-dir"]),Y=/\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|java|kt|rb|php|c|h|cpp|cs|swift|sh|ps1|bat|md|mdx|txt|json|jsonc|yaml|yml|toml|ini|env|html|css|scss|svg|csv|sql|lock)$/i;function k(j,b=R){if(j.length===0||/\s/.test(j))return!1;if(/^(\.\.?[\\/]|[\\/]|[A-Za-z]:[\\/])/.test(j))return!0;if(Y.test(j))return!0;try{return b(j)}catch{return!1}}function G(j){let b=j.slice(2),B=(z)=>z.startsWith("-"),q=b.findIndex((z,N)=>!B(z)&&!(N>0&&W.has(b[N-1]))),P=b.includes("--help")||b.includes("-h"),D=b.indexOf("--pet"),C=D!==-1?b[D+1]:void 0,J=C!==void 0&&!B(C)?C:void 0,K=b.indexOf("--effort"),M=O(K!==-1?b[K+1]:void 0);return{cmd:P&&q===-1?"help":q===-1?"":b[q],plain:b.includes("--plain"),yolo:b.includes("--yolo"),acceptEdits:b.includes("--accept-edits"),...M!==void 0?{effort:M}:{},classic:b.includes("--classic"),...J!==void 0?{pet:J}:{},rest:q===-1?[]:b.slice(q+1).filter((z)=>!B(z))}}
|
|
3
|
+
export{W as Vh,k as Wh,G as Xh};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Oi as V5,Pi as v,Qi as O,Ri as f,Si as h}from"./main-875s60s2.js";import{Ti as j5,dj as N5,fj as F5}from"./main-sdmxhtv8.js";import{jj as d,lj as Q5}from"./main-pknhvrmj.js";import{mj as D5,nj as H5,pj as T}from"./main-1k1kw6b5.js";import{Fj as i}from"./main-90ds1z4e.js";import{Uj as L,Yj as q5}from"./main-q3vsesf9.js";import{ak as A,bk as G5,ck as m}from"./main-xg704a3c.js";import{ml as w,ol as $5}from"./main-3rxcvgna.js";import{Bl as u5,vl as Z5}from"./main-4wndhjdc.js";import{$m as e,Lm as n,Pm as l,Tm as s}from"./main-2yeveeve.js";$5();e();import{mkdirSync as Y8,readFileSync as Z8,writeFileSync as $8}from"fs";import{join as U5}from"path";var x={type:"ephemeral"};function U(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function S(Q){return U(Q)&&Q.cache_control!==void 0}function r(Q){if(!U(Q))return"";return typeof Q.text==="string"?Q.text:""}function a(Q){if(typeof Q==="string")return Q.length;if(Array.isArray(Q))return Q.reduce((Y,Z)=>Y+r(Z).length,0);return 0}function S5(Q){if(typeof Q==="string")return Q.length;if(!Array.isArray(Q))return 0;let Y=0;for(let Z of Q)if(Y+=r(Z).length,U(Z)&&typeof Z.content==="string")Y+=Z.content.length;return Y}function o(Q){if(!U(Q))return 0;let Y=Q.content;return Array.isArray(Y)?Y.filter(S).length:0}function A5(Q,Y,Z){let $=0;if(Array.isArray(Q))$+=Q.filter(S).length;for(let X of Y??[])$+=o(X);if(Array.isArray(Z))$+=Z.filter(S).length;return $}function T5(Q){if(!U(Q))return!1;let Y=Q.content;if(typeof Y==="string")return Y.length>0;if(Array.isArray(Y)&&Y.length>0)return U(Y[Y.length-1]);return!1}function k5(Q){let Y=Q.content;if(typeof Y==="string")return{...Q,content:[{type:"text",text:Y,cache_control:x}]};if(Array.isArray(Y)&&Y.length>0){let Z=Y[Y.length-1];if(U(Z)){let $=Y.slice();return $[$.length-1]={...Z,cache_control:x},{...Q,content:$}}}return Q}function g(Q,Y){let Z=Y?.maxBreakpoints??4,$=Y?.minChunkChars??4096,X=Q.system,V=Array.isArray(Q.messages)?Q.messages:null,J=typeof X==="string"&&X.length>0||Array.isArray(X)&&X.length>0,G=V!==null&&V.length>0;if(!J&&!G)return Q;let z=A5(X,V,Q.tools),j=Q,D=()=>j===Q?j={...Q}:j;if(z<Z&&J){if(typeof X==="string"){if(X.length>=$)D().system=[{type:"text",text:X,cache_control:x}],z+=1}else if(Array.isArray(X)&&!X.some(S)){let N=X[X.length-1];if(U(N)&&a(X)>=$){let H=X.slice();H[H.length-1]={...N,cache_control:x},D().system=H,z+=1}}}if(z<Z&&V!==null&&V.length>=3){let N=-1;for(let F=V.length-3;F>=0;F-=1)if(T5(V[F])){N=F;break}let H=N>=0?V[N]:void 0;if(U(H)&&o(H)===0){let F=a(X);for(let q=0;q<=N;q+=1){let K=V[q];if(U(K))F+=S5(K.content)}if(F>=$){let q=V.slice();q[N]=k5(H),D().messages=q,z+=1}}}return j}q5();var t=new WeakMap;async function R(Q){let Y={parts:[],stopReason:"error",usage:{input:0,output:0},error:`HTTP ${Q.status}: ${(await Q.text()).slice(0,300)}`},Z={status:Q.status},$=Q.headers.get("retry-after");if($!==null)Z.retryAfter=$;let X=Q.headers.get("retry-after-ms");if(X!==null)Z.retryAfterMs=X;let V=[Q.headers.get("anthropic-ratelimit-requests-reset"),Q.headers.get("anthropic-ratelimit-tokens-reset")].filter((J)=>J!==null&&!Number.isNaN(Date.parse(J))).sort((J,G)=>Date.parse(G)-Date.parse(J));if(V[0]!==void 0)Z.resetAt=V[0];return t.set(Y,Z),Y}function B8(Q){return t.get(Q)}function L8(Q,Y=160){let Z=(Q??"").replace(/^HTTP \d{3}:\s*/,"").trim(),$=Z;try{let X=JSON.parse(Z),V=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){let G=J;return V(G.message)??V(G.error)??V(G.detail)}return};$=V(X)??Z}catch{}return $=$.replace(/\s+/g," "),$.length>Y?`${$.slice(0,Y-1)}\u2026`:$}function B(Q,Y,Z=""){if(Y?.aborted)return{parts:Z?[{kind:"text",text:Z}]:[],stopReason:"aborted",usage:{input:0,output:0}};return{parts:[],stopReason:"error",usage:{input:0,output:0},error:Q instanceof Error?Q.message:String(Q)}}var b5=60000;function y5(Q=process.env){let Y=Number(Q.ROVECODE_FIRST_BYTE_TIMEOUT_MS);return Number.isFinite(Y)&&Y>0?Math.floor(Y):b5}var v5=(Q)=>Q>=1000?`${Math.round(Q/1000)} s`:`${Q} ms`;async function _(Q,Y,Z={}){let $=Z.timeoutMs??y5(),X=Y.signal,V=new AbortController,J=()=>V.abort(X?.reason);if(X?.aborted)J();else X?.addEventListener("abort",J,{once:!0});let G=!1,z=setTimeout(()=>{G=!0,V.abort(Error("first-byte timeout"))},$);try{return await(Z.fetchFn??globalThis.fetch)(Q,{...Y,signal:V.signal})}catch(j){if(G&&X?.aborted!==!0){let D=Q;try{D=new URL(Q).host}catch{}throw Error(`no response from ${D} within ${v5($)}`)}throw j}finally{clearTimeout(z)}}m();async function*C(Q){let Y=Q.getReader(),Z=new TextDecoder,$="";while(!0){let{done:X,value:V}=await Y.read();if(X)break;$+=Z.decode(V,{stream:!0});let J=$.split(`
|
|
3
|
+
`);$=J.pop()??"";for(let G of J){let z=G.trim();if(z.startsWith("data:")){let j=z.slice(5).trim();if(j&&j!=="[DONE]")yield j}}}}e();function f5(Q,Y){return{id:Q.id,baseUrl:Y.baseUrl,apiKey:Y.apiKey,protocol:"openai",oauth:!0,...Y.headers?{headers:Y.headers}:{},...Q.defaultModel?{defaultModel:Q.defaultModel}:{},...Y.wire?{wire:Y.wire}:{}}}function Y5(Q={}){let Y=(Q.load??l)();for(let Z of Q.providers??d()){let $=Y[Z.id];if($)return f5(Z,Z.toAuth($))}return null}async function h5(Q,Y,Z={}){let $=(Z.providers??d()).find((G)=>G.id===Q);if(!$)throw Error(`${Q}: no OAuth provider under that id`);let X=(Z.load??l)()[Q];if(!X)throw Error(`${Q}: no stored OAuth credential \u2014 run \`rovecode auth login ${Q}\``);let V={...Q5(),...Z.fetch?{fetch:Z.fetch}:{},...Z.now?{now:Z.now}:{},...Z.sleep?{sleep:Z.sleep}:{}};if(V.now()<X.expires)return $.toAuth(X);let J;try{J=await $.refresh(X,Y,V)}catch(G){let z=G instanceof Error?G.message:String(G);throw Error(`${Q}: OAuth token expired and the refresh failed (${z}) \u2014 run \`rovecode auth login ${Q}\``)}return(Z.save??s)(Q,J),$.toAuth(J)}function c(Q,Y,Z={}){return async function*($,X,V){let J;try{J=await h5(Q.id,V?.signal,Z)}catch(G){yield{type:"turn",turn:B(G,V?.signal)};return}yield*Y({baseUrl:J.baseUrl,apiKey:J.apiKey,...J.headers?{headers:J.headers}:{}})($,X,V)}}q5();m();$5();u5();var g5="(no tool output)";function l5(Q){let Y=Z5(Q);return Y===void 0?void 0:{type:"input_image",detail:"auto",image_url:`data:${Q.mime};base64,${Y}`}}function d5(Q,Y){let Z=V5(Q,Y,l5);if(typeof Z==="string")return Z?[{type:"input_text",text:Z}]:[];return Z.map(($)=>$.type==="text"?{type:"input_text",text:$.text}:$)}function X5(Q,Y){let Z=Y.vision??!0,$=[],X=Q.filter((V)=>V.role==="system").map((V)=>w(V.parts)).join(`
|
|
4
|
+
`);return Q.forEach((V,J)=>{if(V.role==="system")return;if(V.role==="tool"){for(let z of V.parts)if(z.kind==="tool_result")$.push({type:"function_call_output",call_id:z.callId,output:z.output||g5});return}if(V.role==="user"){let z=d5(V,Z);if(z.length>0)$.push({role:"user",content:z});return}let G=w(V.parts);if(G)$.push({type:"message",role:"assistant",status:"completed",id:`msg_rovecode_${J}`,content:[{type:"output_text",text:G,annotations:[]}]});for(let z of V.parts)if(z.kind==="tool_call")$.push({type:"function_call",call_id:z.id,name:z.tool,arguments:JSON.stringify(z.args??{})})}),{...X?{instructions:X}:{},input:$}}function J5(Q){return Q.map((Y)=>{let Z=O(Y);return{type:"function",name:Z.name,description:Z.description,parameters:Z.args}})}var c5=16,m5=/chatgpt\.com\/backend-api/,p5={"OpenAI-Beta":"responses=experimental",originator:"rovecode"},n5="OpenAI Responses stream ended before a terminal response event";function i5(Q){let Y=T(Q,"openai").fields,Z=Y.reasoning,$=typeof Y.reasoning_effort==="string"?Y.reasoning_effort:typeof Z?.effort==="string"?Z.effort:void 0;return $===void 0?{}:{reasoning:{effort:$,summary:"auto"}}}function a5(Q,Y,Z,$){let X=Q.baseUrl.replace(/\/$/,"")+"/responses",V=m5.test(X),{instructions:J,input:G}=X5(Z,{vision:A(Y)!==!1,model:Y}),z=Y.maxTokens,j={model:Y.model,...J!==void 0?{instructions:J}:{},input:G,...$?.tools?.length?{tools:J5($.tools)}:{},stream:!0,store:!1,...z&&!V?{max_output_tokens:Math.max(z,c5)}:{},...i5(Y)},D={"content-type":"application/json",accept:"text/event-stream",...V?p5:{},...Q.headers,authorization:`Bearer ${Q.apiKey}`};return{url:X,headers:D,body:j}}function r5(Q){if(Q?.type==="message")return{kind:"message",text:""};if(Q?.type==="function_call")return{kind:"function_call",callId:Q.call_id??"",name:Q.name??"",args:Q.arguments??""};if(Q?.type==="reasoning")return{kind:"reasoning"};return}function o5(Q,Y,Z){if(Q.type==="message"){let $=Q.content?Q.content.map((X)=>X.type==="refusal"?X.refusal??"":X.text??"").join(""):Y?.kind==="message"?Y.text:"";return $?{kind:"text",text:$}:void 0}if(Q.type==="function_call"){let $=Y?.kind==="function_call"?Y:void 0,X=Q.arguments??$?.args??"",V={};try{V=JSON.parse(X||"{}")}catch{V={_raw:X}}return{kind:"tool_call",id:Q.call_id||$?.callId||Q.id||`fc${Z}`,tool:Q.name||$?.name||"unknown",args:V}}return}function t5(Q){let Y=L(Q);return{input:Y.input,output:Y.output,cacheRead:Y.cacheRead||void 0,cacheWrite:Y.cacheWrite||void 0}}function E(Q){return async function*(Y,Z,$){let X,V="";try{let J=a5(Q,Y,Z,$),G=await _(J.url,{method:"POST",headers:J.headers,body:JSON.stringify(J.body),signal:$?.signal});if(!G.ok||!G.body){yield{type:"turn",turn:await R(G)};return}let z=new Map,j=new Map,D={input:0,output:0},N;for await(let F of C(G.body)){let q=JSON.parse(F),K=q.output_index??0;switch(q.type){case"response.output_item.added":{let W=r5(q.item);if(W)z.set(K,W);break}case"response.output_text.delta":case"response.refusal.delta":{if(!q.delta)break;let W=z.get(K)??{kind:"message",text:""};if(W.kind==="message")W.text+=q.delta,z.set(K,W);V+=q.delta,yield{type:"text_delta",text:q.delta};break}case"response.reasoning_summary_text.delta":case"response.reasoning_text.delta":if(q.delta)yield{type:"reasoning_delta",text:q.delta};break;case"response.reasoning_summary_part.done":yield{type:"reasoning_delta",text:`
|
|
5
|
+
|
|
6
|
+
`};break;case"response.function_call_arguments.delta":{if(!q.delta)break;let W=z.get(K)??{kind:"function_call",callId:"",name:"",args:""};if(W.kind!=="function_call")break;if(W.args+=q.delta,z.set(K,W),W.callId&&W.name)yield{type:"tool_call_delta",id:W.callId,tool:W.name,argsDelta:q.delta};break}case"response.function_call_arguments.done":{let W=z.get(K);if(W?.kind==="function_call"&&typeof q.arguments==="string")W.args=q.arguments;break}case"response.output_item.done":{if(q.item){let W=o5(q.item,z.get(K),K);if(W)j.set(K,W)}z.delete(K);break}case"response.completed":case"response.incomplete":{if(q.response?.usage)D=t5(q.response.usage);let W=q.response?.incomplete_details?.reason;N=q.type==="response.completed"?{stop:"end_turn"}:W==="max_output_tokens"?{stop:"length"}:{stop:"error",error:`Response incomplete: ${W??"no reason given"}`};break}case"response.failed":{let W=q.response?.error;N={stop:"error",error:`${W?.code||"unknown"}: ${W?.message||"no message"}`};break}case"error":N={stop:"error",error:`${q.code||"unknown"}: ${q.message||"no message"}`};break;default:break}}if(!N)N={stop:"error",error:n5};let H=[...j].sort((F,q)=>F[0]-q[0]).map(([,F])=>F);X=N.stop==="error"?{parts:[],stopReason:"error",usage:D,error:N.error}:{parts:H,stopReason:N.stop==="end_turn"&&H.some((F)=>F.kind==="tool_call")?"tool_use":N.stop,usage:D}}catch(J){X=B(J,$?.signal,V)}yield{type:"turn",turn:X}}}m();var s5="ROVECODE_OPENAI_WIRE";function e5(Q){let Y=(Q??"").trim().toLowerCase();return Y==="responses"||Y==="chat"?Y:void 0}function Q8(Q,Y,Z=process.env){return Q.wire??e5(Z[s5])??(Q.id==="openai"&&(Y.reasoning??G5(Y))!==!1?"responses":"chat")}function M(Q,Y,Z){return($)=>async function*(X,V,J){yield*(Q8(Q,X)==="responses"?Z:Y)($)(X,V,J)}}var u=(Q)=>({vision:A(Q)!==!1}),P=new Map,p=300000,V8=30000,X8=1209600000,J8=1e4,q8=4000,G8="models.json",k=new Set,z8=(Q)=>`${Q.id} ${Q.baseUrl.replace(/\/$/,"")}`;function I5(){return U5(n(),"cache",G8)}function B5(){try{let Q=JSON.parse(Z8(I5(),"utf8"));return Q&&typeof Q==="object"&&!Array.isArray(Q)?Q:{}}catch{return{}}}function L5(Q,Y){try{let Z=B5();Z[Q]=Y,Y8(U5(n(),"cache"),{recursive:!0}),$8(I5(),JSON.stringify(Z))}catch{}}async function P5(Q,Y={}){let Z=Q.baseUrl.replace(/\/$/,"")+"/models",$=Y.timeoutMs??J8,X=Y.retry===!1?1:2;for(let V=0;;V++)try{let J=await fetch(Z,{headers:W8(Q),signal:AbortSignal.timeout($)});if(!J.ok)return[];return((await J.json()).data??[]).map((z)=>({id:z.id,ownedBy:z.owned_by,type:z.type}))}catch{if(V+1>=X)return[]}}function K8(Q,Y){if(k.has(Y))return;k.add(Y),P5(Q,{retry:!1,timeoutMs:q8}).then((Z)=>{if(Z.length>0){let $={models:Z,fetchedAt:Date.now()};P.set(Y,$),L5(Y,$)}}).finally(()=>{k.delete(Y)})}async function Z4(Q,Y={}){let Z=z8(Q),$=Date.now();if(Y.force!==!0){let G=P.get(Z);if(G&&$-G.fetchedAt<p)return G.models;let z=B5()[Z];if(z&&Array.isArray(z.models)&&z.models.length>0&&typeof z.fetchedAt==="number"&&$-z.fetchedAt<X8){if(P.set(Z,z),Y.background===!0&&$-z.fetchedAt>=p)K8(Q,Z);return z.models}}let X=await P5(Q);if(X.length>0){let G={models:X,fetchedAt:Date.now()};return P.set(Z,G),L5(Z,G),X}let V=Date.now()-(p-V8),J=P.get(Z);if(J&&J.models.length>0)return P.set(Z,{models:J.models,fetchedAt:V}),J.models;return P.set(Z,{models:[],fetchedAt:V}),[]}function $4(){P.clear(),k.clear()}function W8(Q){return{...Q.headers??{},...Q.protocol==="anthropic"?{"x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"}:{authorization:`Bearer ${Q.apiKey}`}}}function j8(Q){let Y=Q.indexOf("{");if(Y<0)return null;let Z=0,$=!1,X=!1;for(let V=Y;V<Q.length;V++){let J=Q[V];if($){if(X)X=!1;else if(J==="\\")X=!0;else if(J==='"')$=!1;continue}if(J==='"')$=!0;else if(J==="{")Z++;else if(J==="}"){if(Z--,Z===0)return Q.slice(0,V+1)}}return null}function N8(Q){try{return JSON.parse(Q||"{}")}catch{let Y=j8(Q);if(Y!==null){let Z=Q.slice(Y.length);if(Z.length>0&&Z.length%Y.length===0&&Z===Y.repeat(Z.length/Y.length))try{return JSON.parse(Y)}catch{}}return{_raw:Q}}}var y=(Q)=>({baseUrl:Q.baseUrl,apiKey:Q.apiKey,...Q.headers!==void 0?{headers:Q.headers}:{}});function V4(Q,Y={}){if(Q.oauth)return c(Q,M(Q,K5,E),Y);return Q.protocol==="anthropic"?U8(y(Q)):M(Q,K5,E)(y(Q))}function X4(Q,Y={}){if(Q.oauth)return c(Q,M(Q,W5,E),Y);return Q.protocol==="anthropic"?H8(y(Q)):M(Q,W5,E)(y(Q))}function J4(Q){let Y=(Q.ROVECODE_STREAM??"").trim().toLowerCase();return!(Y==="off"||Y==="json"||Y==="0"||Y==="false"||Y==="none")}var R5={"accept-encoding":"identity"},_5=(Q)=>(Q.headers.get("content-type")??"").includes("application/json");var F8=/not supported for this model|does not support the effort parameter/i,D8=/thinking|effort|budget_tokens|output_config/i,z5=(Q)=>F8.test(Q)&&D8.test(Q),b=new Map,w5=(Q)=>`${Q.provider}/${Q.model}`;function C5(Q){let Y=Q.maxTokens??8192,Z=D5(Q.effort);return Z===null?Y:Math.max(Y,Z+4096)}function q4(Q){return b.get(w5(Q))??"effort"}async function O5(Q,Y,Z,$,X){let V=Z.effort,J=w5(Z),G=b.get(J)??"effort",z=()=>_(Q,{method:"POST",headers:Y,body:JSON.stringify($(H5(V,G))),...X?{signal:X}:{}}),j=await z();if(j.ok||V===void 0||V==="auto"||V==="off"||j.status!==400)return j;let D=await j.clone().text().catch(()=>"");if(!z5(D))return j;G=G==="effort"?"budget":"effort";let N=await z();if(N.status===400&&z5(await N.clone().text().catch(()=>"")))b.delete(J);else b.set(J,G);return N}function E5(Q){return T(Q,"openai").fields}function K5(Q){return async function*(Y,Z,$){let X;try{let V=await _(Q.baseUrl.replace(/\/$/,"")+"/chat/completions",{method:"POST",headers:{...Q.headers??{},"content-type":"application/json",authorization:`Bearer ${Q.apiKey}`},body:JSON.stringify({model:Y.model,messages:v(Z,u(Y)),...$?.tools?.length?{tools:f($.tools)}:{},stream:!1,...i(Y,!1),...E5(Y),...Y.maxTokens?{max_tokens:Y.maxTokens}:{}}),signal:$?.signal});if(!V.ok)X=await R(V);else X=M5(await V.json())}catch(V){X=B(V,$?.signal)}yield{type:"turn",turn:X}}}function W5(Q){return async function*(Y,Z,$){let X,V="",J=new Map;try{let G=await _(Q.baseUrl.replace(/\/$/,"")+"/chat/completions",{method:"POST",headers:{...Q.headers??{},...R5,"content-type":"application/json",authorization:`Bearer ${Q.apiKey}`},body:JSON.stringify({model:Y.model,messages:v(Z,u(Y)),...$?.tools?.length?{tools:f($.tools)}:{},stream:!0,stream_options:{include_usage:!0},...i(Y,!0),...E5(Y),...Y.maxTokens?{max_tokens:Y.maxTokens}:{}}),signal:$?.signal});if(!G.ok||!G.body){X=await R(G),yield{type:"turn",turn:X};return}if(_5(G)){yield{type:"turn",turn:M5(await G.json())};return}let z="end_turn",j={input:0,output:0};for await(let N of C(G.body)){let H=JSON.parse(N),F=H.choices?.[0];if(F?.delta?.content)V+=F.delta.content,yield{type:"text_delta",text:F.delta.content};if(F?.delta?.reasoning_content)yield{type:"reasoning_delta",text:F.delta.reasoning_content};for(let q of F?.delta?.tool_calls??[]){let K=q.index??0,W=J.get(K)??{id:q.id??`tc${K}`,name:"",args:""};if(q.id)W.id=q.id;let I=q.function?.name;if(I){if(W.name==="")W.name=I;else if(I!==W.name)W.name+=I}if(q.function?.arguments)W.args+=q.function.arguments;J.set(K,W)}if(F?.finish_reason)z=F.finish_reason==="tool_calls"?"tool_use":F.finish_reason==="length"?"length":"end_turn";if(H.usage){let q=L(H.usage);j={input:q.input,output:q.output,cacheRead:q.cacheRead||void 0,cacheWrite:q.cacheWrite||void 0}}}let D=[];if(V)D.push({kind:"text",text:V});for(let[,N]of[...J].sort((H,F)=>H[0]-F[0]))D.push({kind:"tool_call",id:N.id,tool:N.name,args:N8(N.args)});X={parts:D,stopReason:z,usage:j}}catch(G){X=B(G,$?.signal,V)}yield{type:"turn",turn:X}}}function H8(Q){return async function*(Y,Z,$){let X,V="",J=new Map;try{let G=Z.filter((q)=>q.role==="system").map((q)=>w(q.parts)).join(`
|
|
7
|
+
`),z={};if($?.tools?.length)z.tools=$.tools.map((q)=>{let K=O(q);return{name:K.name,description:K.description,input_schema:K.args}});if(G)z.system=G;let j=(q)=>({model:Y.model,max_tokens:C5(Y),messages:h(Z,u(Y)),stream:!0,...z,...q}),D=await O5(Q.baseUrl.replace(/\/$/,"")+"/messages",{...Q.headers??{},...R5,"content-type":"application/json","x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"},Y,(q)=>g(j(q)),$?.signal);if(!D.ok||!D.body){X=await R(D),yield{type:"turn",turn:X};return}if(_5(D)){yield{type:"turn",turn:x5(await D.json())};return}let N="end_turn",H={input:0,output:0};for await(let q of C(D.body)){let K=JSON.parse(q);switch(K.type){case"message_start":{let W=L(K.message?.usage);H={input:W.input,output:W.output,cacheRead:W.cacheRead||void 0,cacheWrite:W.cacheWrite||void 0};break}case"content_block_start":{let W=K.index??0;if(K.content_block?.type==="tool_use")J.set(W,{kind:"tool",id:K.content_block.id??`tc${W}`,name:K.content_block.name??"unknown",json:""});else if(K.content_block?.type==="thinking"||K.content_block?.type==="redacted_thinking")J.set(W,{kind:"thinking"});else J.set(W,{kind:"text",text:""});break}case"content_block_delta":{let W=K.index??0,I=J.get(W);if(K.delta?.type==="text_delta"&&K.delta.text!==void 0){if(V+=K.delta.text,I?.kind==="text")I.text+=K.delta.text;else J.set(W,{kind:"text",text:K.delta.text});yield{type:"text_delta",text:K.delta.text}}else if(K.delta?.type==="input_json_delta"&&K.delta.partial_json!==void 0&&I?.kind==="tool")I.json+=K.delta.partial_json;else if(K.delta?.type==="thinking_delta"&&K.delta.thinking!==void 0)yield{type:"reasoning_delta",text:K.delta.thinking};break}case"message_delta":{if(K.delta?.stop_reason==="max_tokens")N="length";if(K.usage!==void 0){let W=L(K.usage);H={...H,output:W.output||H.output,cacheRead:H.cacheRead??(W.cacheRead||void 0),cacheWrite:H.cacheWrite??(W.cacheWrite||void 0)}}break}case"error":throw Error(K.error?.message??"anthropic stream error");default:break}}let F=[];for(let[,q]of[...J].sort((K,W)=>K[0]-W[0])){if(q.kind==="thinking")continue;if(q.kind==="text"){if(q.text)F.push({kind:"text",text:q.text});continue}let K={};try{K=JSON.parse(q.json||"{}")}catch{K={_raw:q.json}}F.push({kind:"tool_call",id:q.id,tool:q.name,args:K}),N="tool_use"}X={parts:F,stopReason:N,usage:H}}catch(G){X=B(G,$?.signal,V)}yield{type:"turn",turn:X}}}function U8(Q){return async function*(Y,Z,$){let X;try{let V=Z.filter((j)=>j.role==="system").map((j)=>w(j.parts)).join(`
|
|
8
|
+
`),J={};if($?.tools?.length)J.tools=$.tools.map((j)=>{let D=O(j);return{name:D.name,description:D.description,input_schema:D.args}});if(V)J.system=V;let G=(j)=>({model:Y.model,max_tokens:C5(Y),messages:h(Z,u(Y)),...J,...j}),z=await O5(Q.baseUrl.replace(/\/$/,"")+"/messages",{...Q.headers??{},"content-type":"application/json","x-api-key":Q.apiKey,"anthropic-version":"2023-06-01"},Y,(j)=>g(G(j)),$?.signal);if(!z.ok)X=await R(z);else X=x5(await z.json())}catch(V){X=B(V,$?.signal)}yield{type:"turn",turn:X}}}function M5(Q){let Y=Q,Z=Y.choices?.[0],$=[];if(Z?.message.content)$.push({kind:"text",text:Z.message.content});for(let J of Z?.message.tool_calls??[]){let G={};try{G=JSON.parse(J.function.arguments||"{}")}catch{G={_raw:J.function.arguments}}$.push({kind:"tool_call",id:J.id,tool:J.function.name,args:G})}let X=(Z?.message.tool_calls?.length??0)>0?"tool_use":Z?.finish_reason==="length"?"length":"end_turn",V=L(Y.usage);return{parts:$,stopReason:X,usage:{input:V.input,output:V.output,cacheRead:V.cacheRead||void 0,cacheWrite:V.cacheWrite||void 0}}}function x5(Q){let Y=Q,Z=[];for(let V of Y.content??[]){if(V.type==="text"&&V.text)Z.push({kind:"text",text:V.text});if(V.type==="tool_use"&&V.id)Z.push({kind:"tool_call",id:V.id,tool:V.name??"unknown",args:V.input??{}})}let $=(Y.content??[]).some((V)=>V.type==="tool_use")?"tool_use":Y.stop_reason==="max_tokens"?"length":"end_turn",X=L(Y.usage);return{parts:Z,stopReason:$,usage:{input:X.input,output:X.output,cacheRead:X.cacheRead||void 0,cacheWrite:X.cacheWrite||void 0}}}function G4(Q){let Y=0;return async function*(Z,$){let X=Q.turns[Math.min(Y,Q.turns.length-1)];Y++,yield{type:"turn",turn:X}}}function z4(Q){return{parts:[{kind:"text",text:Q}],stopReason:"end_turn",usage:{input:0,output:1}}}function K4(Q){return{parts:Q.map((Y)=>({kind:"tool_call",...Y})),stopReason:"tool_use",usage:{input:0,output:1}}}function W4(Q={}){let Y=Q.baseUrl??process.env.ROVECODE_BASE_URL,Z=Q.apiKey??process.env.ROVECODE_API_KEY??process.env.OPENAI_API_KEY;if(Y&&Z){let V=Q.protocol==="anthropic"||Y.includes("anthropic.com"),J=Q.defaultModel??process.env.ROVECODE_MODEL;return{id:Q.id??"custom",baseUrl:Y,apiKey:Z,protocol:V?"anthropic":"openai",...J!==void 0?{defaultModel:J}:{}}}let $=F5(N5(process.cwd()));if($===null)return Y5();let X=$.provider;return{id:X.id,baseUrl:X.baseUrl,apiKey:X.apiKey??"",protocol:X.protocol,...$.model!==void 0?{defaultModel:$.model}:{},...X.headers!==void 0?{headers:X.headers}:{}}}function j4(){return j5.map((Q)=>{let Y=Q.keyEnv??`${Q.id.toUpperCase()}_API_KEY`;return{id:Q.id,baseUrl:Q.baseUrl,protocol:Q.protocol,envKey:Y,configured:Boolean(process.env[Y])}})}
|
|
9
|
+
export{B8 as ui,L8 as vi,Z4 as wi,$4 as xi,V4 as yi,X4 as zi,J4 as Ai,b as Bi,w5 as Ci,C5 as Di,q4 as Ei,K5 as Fi,W5 as Gi,H8 as Hi,U8 as Ii,G4 as Ji,z4 as Ki,K4 as Li,W4 as Mi,j4 as Ni};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tm as P,um as N,wm as y}from"./main-a9njrkk1.js";import{Bm as g,Fm as m}from"./main-7rn6bqje.js";import{$m as l,Lm as j}from"./main-2yeveeve.js";import{dn as A,en as x,gn as _,hn as L,in as b,jn as U,kn as h}from"./main-nqveez48.js";import{wn as v}from"./main-qsevpgsv.js";import{existsSync as d,readFileSync as c,readdirSync as n,statSync as p}from"fs";import{join as K,resolve as E}from"path";function R(J,q){let B=K(q,"plugins"),Q=K(J,".rovecode","plugins");return E(B)===E(Q)?[["project",Q]]:[["user",B],["project",Q]]}function Gq(J,q={}){let B={plugins:[],warnings:[]};if(process.env.ROVECODE_NO_PLUGINS==="1")return B;let Q=q.home??j(),Z=q.state??A(Q),$=new Map;for(let[W,X]of R(J,Q)){if(!U(X))continue;let C;try{C=n(X).sort()}catch(Y){B.warnings.push(`${X}: cannot list \u2014 ${Y.message}`);continue}for(let Y of C){let z=K(X,Y);if(!U(z)||!d(K(z,P)))continue;let V=a(z,Y,W,Z),H=$.get(V.name);if(H)B.warnings.push(`${z}: plugin "${V.name}" shadows ${H.dir} (project over user)`);$.set(V.name,V);for(let O of V.problems)B.warnings.push(O)}}return B.plugins=[...$.values()].sort((W,X)=>W.name.localeCompare(X.name)),B}function a(J,q,B,Q){let Z=K(J,P),$=[],W=null;try{W=N(c(Z,"utf8"),Z,$)}catch(I){$.push(`${Z}: cannot read \u2014 ${I.message}`)}let X=null;try{X=_(J)}catch{X=null}let C=W?.name??q;if(W&&W.name!==q)$.push(`${Z}: name "${W.name}" differs from its folder "${q}" \u2014 the manifest name is the plugin's identity`);let Y;if(W===null)Y="broken";else if(Q.disabled.includes(C))Y="disabled";else if(B==="project"&&(X===null||!b(Q,J,X)))Y="untrusted";else Y="active";let z=`plugin ${C}`,V=W?w(J,W.commands,`${z}: commands`,$):null,H=W?w(J,W.skills,`${z}: skills`,$):null,O=[];if(W?.mcp)for(let[I,u]of Object.entries(W.mcp)){let D=g(I,u,Z,$);if(D)O.push(D)}return{name:C,dir:J,scope:B,manifest:W,status:Y,digest:X,problems:$,commandsDir:V,skillsDir:H,mcp:O}}function w(J,q,B,Q){if(!q)return null;let Z=K(J,q);try{if(p(Z).isDirectory())return Z}catch{}return Q.push(`${B} directory "${q}" does not exist \u2014 ignored`),null}var S=v(()=>{l();m();y();h()});import{cpSync as i,existsSync as M,lstatSync as r,mkdirSync as o,mkdtempSync as f,readFileSync as t,renameSync as e,rmSync as T}from"fs";import{tmpdir as s}from"os";import{join as G,resolve as F,sep as qq}from"path";function _q(J){if(J===void 0)return;for(let q of J.values())T(q,{recursive:!0,force:!0});J.clear()}function k(J,q,B){return R(q,B).find(([Q])=>Q===J)?.[1]??G(B,"plugins")}function Wq(J){try{return r(J).isSymbolicLink()}catch{return!0}}async function Mq(J,q){let B=J,Q=null,Z=q.copy??(($,W,X)=>i($,W,{recursive:!0,filter:X}));try{if(Qq(J)){let V=Bq(J),H=q.cloneCache?.get(V);if(H!==void 0&&U(H))B=H;else{Q=f(G(s(),"rovecode-plugin-"));let O=await(q.spawn??Vq)(["git","clone","--depth","1","--quiet","--",J,"."],Q);if(O.code!==0)return{ok:!1,error:`git clone failed (exit ${O.code})${O.stderr.trim()?`: ${O.stderr.trim().split(`
|
|
3
|
+
`).at(-1)}`:""}`};if(B=Q,q.cloneCache!==void 0)q.cloneCache.set(V,Q),Q=null}}if(B=F(B),q.subfolder!==void 0&&q.subfolder!==""){let V=q.subfolder.split("\\").join("/");if(V.startsWith("/")||/^[A-Za-z]:/.test(V)||V.split("/").includes(".."))return{ok:!1,error:`subfolder "${q.subfolder}" escapes the source`};let H=F(G(B,V));if(H!==B&&!H.startsWith(B+qq))return{ok:!1,error:`subfolder "${q.subfolder}" escapes the source`};if(!U(H))return{ok:!1,error:`${J}: no folder "${q.subfolder}" inside it`};B=H}if(!U(B))return{ok:!1,error:`${J}: not a directory`};let $=G(B,P);if(!M($))return{ok:!1,error:`${J}: no ${P} \u2014 a plugin is a folder with a manifest`};let W=[],X=N(t($,"utf8"),$,W);if(X===null)return{ok:!1,error:W.join("; ")||`${$}: invalid manifest`};let C=k(q.scope,q.cwd,q.home),Y=G(C,X.name);if(F(Y)===B)return{ok:!1,error:`${J} is already the installed copy`};if(M(Y)&&!q.force)return{ok:!1,error:`plugin "${X.name}" already exists at ${Y} (use --force to replace)`};o(C,{recursive:!0});let z=f(G(C,`.rovecode-add-${X.name}-`));try{if(Z(B,z,(V)=>!/(?:^|[\\/])(?:node_modules|\.git)(?:[\\/]|$)/.test(V)&&!Wq(V)),M(Y))T(Y,{recursive:!0,force:!0});e(z,Y)}catch(V){return{ok:!1,error:`could not install "${X.name}" into ${Y}: ${V instanceof Error?V.message:String(V)}`}}finally{T(z,{recursive:!0,force:!0})}if(q.scope==="project"){let V=A(q.home);V.trusted[L(Y)]=_(Y),x(q.home,V)}return{ok:!0,name:X.name,dir:Y,scope:q.scope,manifest:X}}finally{if(Q)T(Q,{recursive:!0,force:!0})}}function Tq(J,q){let B=G(k(q.scope,q.cwd,q.home),J);if(!U(B))return{ok:!1,error:`no ${q.scope} plugin "${J}" at ${B}`};T(B,{recursive:!0,force:!0});let Q=A(q.home);return delete Q.trusted[L(B)],x(q.home,Q),{ok:!0,dir:B}}function kq(J,q,B){let Q=A(B);if(Q.disabled=Q.disabled.filter((Z)=>Z!==J),!q)Q.disabled.push(J);return x(B,Q)}function Nq(J,q){let B=G(k("project",q.cwd,q.home),J);if(!U(B)||!M(G(B,P)))return{ok:!1,error:`no project plugin "${J}" under ${k("project",q.cwd,q.home)}`};let Q=_(B),Z=A(q.home);return Z.trusted[L(B)]=Q,x(q.home,Z),{ok:!0,dir:B,digest:Q}}function Iq(J,q){let B=G(k("project",q.cwd,q.home),J),Q=A(q.home),Z=L(B)in Q.trusted;return delete Q.trusted[L(B)],x(q.home,Q),Z}var Bq=(J,q)=>`${J}#${q??""}`,Jq,Qq=(J)=>Jq.test(J)&&!M(J),Vq=async(J,q)=>{let B=Bun.spawn(J,{cwd:q,stdout:"ignore",stderr:"pipe",stdin:"ignore"}),Q=await new Response(B.stderr).text();return{code:await B.exited,stderr:Q}};var Xq=v(()=>{S();y();h();Jq=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i});
|
|
4
|
+
export{R as Dh,Gq as Eh,S as Fh,Bq as Gh,_q as Hh,Qq as Ih,k as Jh,Mq as Kh,Tq as Lh,kq as Mh,Nq as Nh,Iq as Oh,Xq as Ph};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{isAbsolute as i,relative as s,resolve as S}from"path";import{readFileSync as zz}from"fs";function p(z){let J=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(z.trim());if(J===null)return null;let Q=J[1];if(Q.length===3)Q=Q.split("").map((U)=>U+U).join("");let Z=parseInt(Q.slice(0,2),16)/255,$=parseInt(Q.slice(2,4),16)/255,q=parseInt(Q.slice(4,6),16)/255,W=Math.max(Z,$,q),X=Math.min(Z,$,q),M=(W+X)/2,j=W-X;if(j===0)return{h:0,s:0,l:M*100};let Y=j/(1-Math.abs(2*M-1)),H;if(W===Z)H=60*(($-q)/j%6);else if(W===$)H=60*((q-Z)/j+2);else H=60*((Z-$)/j+4);if(H<0)H+=360;return{h:H,s:Y*100,l:M*100}}var _=(z)=>z<=0.04045?z/12.92:Math.pow((z+0.055)/1.055,2.4);function Jz(z){let J=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(z.trim());if(J===null)return null;let Q=J[1];if(Q.length===3)Q=Q.split("").map((V)=>V+V).join("");let Z=_(parseInt(Q.slice(0,2),16)/255),$=_(parseInt(Q.slice(2,4),16)/255),q=_(parseInt(Q.slice(4,6),16)/255),W=Math.cbrt(0.4122214708*Z+0.5363325363*$+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*$+0.1073969566*q),M=Math.cbrt(0.0883024619*Z+0.2817188376*$+0.6299787005*q),j=0.2104542553*W+0.793617785*X-0.0040720468*M,Y=1.9779984951*W-2.428592205*X+0.4505937099*M,H=0.0259040371*W+0.7827717662*X-0.808675766*M,U=Math.sqrt(Y*Y+H*H),K=Math.atan2(H,Y)*180/Math.PI;if(K<0)K+=360;return{l:j,c:U,h:K}}var Qz=0.042;function R(z){let J=Jz(z);if(J===null||J.c<Qz)return null;return Math.floor(J.h/30)%12}var Zz=(z)=>`${z*30}-${z*30+30} deg`;function h(z){let J=p(z);if(J===null)return!1;return J.h>=20&&J.h<=55&&J.s>=45&&J.l>=35&&J.l<=80}var $z=/#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b/g;function b(z,J,Q){let Z=Math.min(100,Math.max(0,J))/100,$=Math.min(100,Math.max(0,Q))/100,q=(1-Math.abs(2*$-1))*Z,W=(z%360+360)%360/60,X=q*(1-Math.abs(W%2-1)),[M,j,Y]=W<1?[q,X,0]:W<2?[X,q,0]:W<3?[0,q,X]:W<4?[0,X,q]:W<5?[X,0,q]:[q,0,X],H=$-q/2,U=(K)=>Math.round((K+H)*255).toString(16).padStart(2,"0");return`#${U(M)}${U(j)}${U(Y)}`}function D(z){let J=new Set;for(let Q of z.match($z)??[])J.add(Q.toLowerCase());for(let Q of z.matchAll(/--[\w-]+\s*:\s*(-?[\d.]+)\s+([\d.]+)%\s+([\d.]+)%/g))J.add(b(Number(Q[1]),Number(Q[2]),Number(Q[3])));for(let Q of z.matchAll(/hsla?\(\s*(-?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%/gi))J.add(b(Number(Q[1]),Number(Q[2]),Number(Q[3])));return[...J]}var qz=["Inter","Roboto","Open Sans","Lato","Montserrat","Poppins","Nunito","Source Sans Pro","Raleway"],f=["system-ui","-apple-system","Segoe UI","Arial","Helvetica Neue","Helvetica"],Vz=(z)=>z.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&");function Kz(z){let J=new Set;for(let Q of qz){let Z=Vz(Q),$=Z.replace(/\\?\s/g,"[\\s_+-]");if(new RegExp("\\{[^}]*\\b"+Z.replace(/\s/g,"_")+`\\b[^}]*\\}\\s*from\\s*["']next/font/google`,"i").test(z))J.add(Q);if(new RegExp("@fontsource(?:-variable)?/"+$.toLowerCase().replace(/\\s/g,"-"),"i").test(z))J.add(Q);if(new RegExp("family="+$,"i").test(z))J.add(Q);for(let q of z.match(/@font-face\s*\{[^}]*\}/gi)??[])if(new RegExp(`font-family\\s*:\\s*["']?`+$,"i").test(q))J.add(Q)}return[...J]}var jz=["sans-serif","serif","monospace","cursive","fantasy","system-ui","ui-sans-serif","ui-serif","ui-monospace","ui-rounded","math","emoji","fangsong","inherit","initial","unset","revert","revert-layer","none","currentcolor"];function Bz(z){let J=new Set,Q=(Z)=>{let $=Z.trim().replace(/^["']|["']$/g,"").replace(/[_+-]+/g," ").trim();if($.length>0)J.add($.toLowerCase())};for(let Z of z.matchAll(/\{([^}]*)\}\s*from\s*["']next\/font\/google/gi))for(let $ of(Z[1]??"").split(","))Q($.split(" as ")[0]??"");for(let Z of z.matchAll(/@fontsource(?:-variable)?\/([a-z0-9-]+)/gi))Q(Z[1]??"");for(let Z of z.matchAll(/family=([^&"'`\s:;)]+)/gi))Q(Z[1]??"");for(let Z of z.match(/@font-face\s*\{[^}]*\}/gi)??[]){let $=/font-family\s*:\s*([^;}\n]+)/i.exec(Z);if($)Q(($[1]??"").split(",")[0]??"")}return[...J]}var Wz=/^(?:[\d.]+%?|bolder|lighter|bold|normal|medium|light|thin|black|heavy|semibold|extrabold|ultrabold|extralight|ultralight|book|regular|italic|oblique)$/i;function Xz(z){let J=[],Q=(Z)=>{let $=Z.trim().replace(/^["']|["']$/g,"").replace(/_/g," ").trim();if($.length===0)return;if(/^(?:var|theme|calc)\s*\(/i.test($)||$.startsWith("--")||$.includes("$"))return;if(jz.includes($.toLowerCase()))return;if(Wz.test($))return;J.push($)};for(let Z of z.matchAll(/font-family\s*:\s*([^;}\n]+)/gi))Q((Z[1]??"").split(",")[0]??"");for(let Z of z.matchAll(/\bfont-\[([^\]]+)\]/g))Q((Z[1]??"").split(",")[0]??"");return J}function Yz(z){let J=[];for(let Q of z.matchAll(/font-family\s*:\s*([^;}\n]+)/gi)){let Z=(Q[1]??"").split(",")[0]?.trim().replace(/^["']|["']$/g,"");if(Z!==void 0&&Z.length>0)J.push(Z)}return J}var F=(z,J)=>(z.match(J)??[]).length;function w(z){return F(z,/<[a-zA-Z][\w.:-]*/g)}var Mz=/\bborder(?:-[trbl])?(?:-\d+)?\b(?!-(?:none|0|transparent))|\bdivide-[xy]\b|<hr\b|border-(?:top|bottom|left|right)\s*:(?!\s*(?:none|0))/g,Hz=/\brounded(?:-(?:sm|md|lg|xl|2xl|3xl|full|t|b|l|r|tl|tr|bl|br))?\b|border-radius\s*:\s*(?!0)/g,l=/\btext-center\b|\bitems-center\b|\bjustify-center\b|\bmx-auto\b|\bplace-items-center\b|text-align\s*:\s*center|margin\s*:\s*0\s+auto/g,Uz=/\bmin-h-screen\b|\bh-screen\b|(?:min-)?height\s*:\s*100[dsl]?vh/,Gz=/\b(?:md|lg):grid-cols-3\b/,Iz=/\b(?:linear|radial|conic)-gradient\b|\bbg-gradient-to\b|background-image\s*:|\bbg-\[url\(|\btransition-(?:all|colors|transform|opacity)\b|\banimate-[a-z]|@keyframes\b|\banimation\s*:|\bbefore:|\bafter:|::(?:before|after)|\bbackdrop-blur\b|\bdrop-shadow\b/g,k=(z)=>z.replace(/\\/g,"/").toLowerCase();function c(z){let J=k(z);return/(?:^|\/)app\/.*\/page\.[jt]sx?$/.test(J)||/(?:^|\/)app\/page\.[jt]sx?$/.test(J)||/(?:^|\/)pages\/(?!api\/)/.test(J)||/(?:^|\/)routes\/.*\+page\.svelte$/.test(J)||/\.html?$/.test(J)}function y(z){let J=k(z);return c(z)||/(?:^|\/)(?:sections?|blocks?)\//.test(J)||/(?:hero|features?|pricing|testimonial|cta|footer|header)[^/]*\.(?:[jt]sx|astro|vue|svelte)$/.test(J)}function Lz(z){return/(?:^|\/)components\/ui\//.test(k(z))}function o(z){return k(z).replace(/\.[a-z]+$/,"").split("/").some((Q)=>/(?:^|-|_)(?:login|register|signin|signup|auth|404|not-found|error|loading|empty|placeholder|tooltip|dialog|modal|toast|announcement|layout)(?:$|-|_)/.test(Q))}function a(z){let J=k(z);return/\.mdx?$/.test(J)||/opengraph-image|twitter-image|(?:^|\/)og\/route\./.test(J)}function P(z){return z.replace(/<svg[\s\S]*?<\/svg>/gi," ").replace(/data:image\/[^"')\s]+/gi," ").replace(/(?:\.hljs|\.shiki|\.token|pre|code)\s*[^{]*\{[^}]*\}/gi," ")}var g=/warn|warning|caution|alert|danger|error|status|badge|pending|highlight|mark|star|rating/i;function kz(z){let J=P(z),Q=[],Z=($)=>J.slice(Math.max(0,$-90),$+90);for(let $ of J.matchAll(/--(?:color-)?(?:primary|accent|brand)\b\s*:\s*([^;}\n]+)/gi)){let q=$[1]??"",W=D(q).find(h);if(W!==void 0&&!g.test($[0]))Q.push(`${$[0].split(":")[0]?.trim()}: ${W}`)}for(let $ of J.matchAll(/\b(?:bg|text|from|border)-(?:amber|orange|yellow)-(?:[3-7]00)\b/gi)){let q=Z($.index);if(g.test(q))continue;if(/\b(?:button|btn|<a\b|link|cta|hero|h1|h2)\b/i.test(q)||/^(?:bg|from)-/i.test($[0]))Q.push($[0])}return[...new Set(Q)]}function Oz(z){let J=new Set;for(let Q of D(P(z))){let Z=R(Q);if(Z!==null)J.add(Z)}return J.size}function Dz(z,J={}){let{direction:Q=null,ignore:Z=[],file:$}=J,q=[],W=$??"",X=(K,V,B,G,I)=>{if(Z.includes(K))return;q.push({rule:K,kind:V,severity:B,message:G,evidence:I,...$!==void 0?{file:$}:{}})},M=Q!==null;if(!a(W)){let K=Kz(z),V=Object.values(Q?.typeface??{}).map((G)=>G.toLowerCase()),B=K.filter((G)=>!V.includes(G.toLowerCase()));if(B.length>0){if(!M)X("cliche-font","slop","med","A default webfont is loaded and nothing records that anyone chose it. The typeface is half the personality of a page; pick one for a reason you can state, then record it.",`loaded at a font import or @font-face: ${B.join(", ")}`);else if(Q?.typeface!==void 0)X("font-deviation","deviation","med","A typeface is loaded that is not the one this project recorded.",`loaded: ${B.join(", ")}; recorded: ${Object.values(Q.typeface).join(", ")}`)}if(Q?.typeface!==void 0){let G=Yz(z).filter((I)=>f.some((O)=>O.toLowerCase()===I.toLowerCase()));if(G.length>0&&!V.some((I)=>G.some((O)=>O.toLowerCase()===I)))X("font-deviation","deviation","low","A font-family declaration leads with a system stack while this project records a chosen face.",`${[...new Set(G)].join(", ")} leads a font-family here; recorded: ${Object.values(Q.typeface).join(", ")}`)}}if(!Object.values(Q?.palette??{}).some(h)){let K=kz(z);if(K.length>0&&Oz(z)<5){let V=K.slice(0,5).join(", ");if(!M)X("cliche-accent-amber","slop","med","Amber/orange is doing accent duty and nothing records that it was chosen. It is the reflex accent of generated interfaces; pick one that belongs to this product.",`${K.length} accent position${K.length===1?"":"s"} (${V})`);else X("accent-deviation","deviation","med","Amber/orange is used as an accent and it is not in this project's recorded palette.",`${K.length} accent position${K.length===1?"":"s"} (${V})`)}}if(Q?.layout===void 0&&y(W)&&Gz.test(z))X("template-grid","slop","low","Three equal cards at a breakpoint is the feature grid every template ships. Is this the layout the content wants, or the one the starter had?","md|lg:grid-cols-3 in a page/section file");if(!M&&/from\s*["']lucide-react["']/.test(z))X("template-icons","slop","low","lucide-react is imported and nothing records a design direction. It is the icon set of the shadcn landing-page template; it is fine as a choice and a tell as a default.",'import from "lucide-react" with no design.json');if(y(W)&&!o(W)){let K=Uz.exec(z);if(K!==null){let V=z.slice(Math.max(0,K.index-200),K.index+200);if(new RegExp(l.source,"i").test(V)&&/<h1\b/i.test(z.slice(K.index,K.index+1500)))X("reflex-hero",Q?.heroPattern===void 0?"slop":"deviation","low","A full-viewport centred first screen with a headline in it. A hero costs the reader a whole screen; keep the height only when an image or an idea earns it.",`${K[0]} centred in the same element, with an <h1> within 1500 characters`)}}let Y=P(z),H=/from-(?:purple|violet|indigo|fuchsia)-\d00[\s\S]{0,80}?to-(?:blue|pink|cyan|indigo|purple)-\d00/.test(Y),U=(Y.match(/linear-gradient\([^)]*\)/g)??[]).some((K)=>{let V=D(K).map(p).filter((B)=>B!==null&&B.s>=40);return V.some((B)=>B.h>=250&&B.h<=290)&&V.some((B)=>B.h>=180&&B.h<=330)&&V.length>=2});if(H||U)X("cliche-gradient",M?"deviation":"slop","low","A violet-to-blue gradient pair. It is the most recognisable generated-template signature there is.",H?"tailwind from-violet/to-blue pair":"linear-gradient with a violet stop and a second saturated stop");if(Q?.palette!==void 0){let K=new Set;for(let B of Object.values(Q.palette))for(let G of D(B)){let I=R(G);if(I!==null)K.add(I)}let V=new Map;for(let B of D(P(z))){let G=R(B);if(G===null||K.has(G))continue;V.set(G,[...V.get(G)??[],B])}if(V.size>1){let B=[...V.entries()].map(([G,I])=>`${Zz(G)} (${I.slice(0,3).join(", ")})`).join("; ");X("off-palette","deviation","med","Colours from hue families outside the recorded palette. One extra family is a semantic state; more than one is a second palette.",`${V.size} extra hue families: ${B}`)}}if(Q!==null&&Fz(Q)){let K=w(z),V=F(z,Iz);if(K>=10&&V/K>0.6)X("decoration-density","deviation","low","More decoration than the recorded direction asks for: gradients, background images, ornament and motion, counted against the elements that carry them.",`${V} decorative declarations across ~${K} elements (${(V/K).toFixed(2)} per element); the record asks for restraint`)}return q}function Fz(z){let J=`${z.notes??""} ${z.rationale??""}`.toLowerCase();return/restrain|minimal|sober|quiet|austere|understated|plain|calm|spare|no decoration|sade|yal[\u0131i]n|sakin|az\b|g[\u00F6o]sterissiz/.test(J)}function Az(z,J){let Q=[],Z=k(z.path).replace(/\/[^/]*$/,"");for(;;){for(let $ of["tsx","jsx","ts","js"]){let q=J.get(Z===""?`layout.${$}`:`${Z}/layout.${$}`);if(q!==void 0&&q.path!==z.path){Q.push(q);break}}if(Z==="")break;Z=Z.includes("/")?Z.replace(/\/[^/]*$/,""):""}return Q}function u(z,J){let Q=k(z.path).replace(/\/[^/]*$/,""),Z=[];for(let $ of z.text.matchAll(/\bfrom\s*["']([^"']+)["']|\bimport\s*["']([^"']+)["']/g)){let q=($[1]??$[2]??"").trim();if(q===""||/^[a-z@][^/]*$/i.test(q))continue;let W=q.replace(/^[@~]\//,"").replace(/^\.\//,Q===""?"":Q+"/");if(q.startsWith("../")){let M=q.match(/^(?:\.\.\/)+/)?.[0]??"",j=M.split("../").length-1;W=Q.split("/").slice(0,Math.max(0,Q.split("/").length-j)).concat(q.slice(M.length)).join("/")}let X=k(W).replace(/\.[a-z]+$/,"");for(let[M,j]of J){let Y=M.replace(/\.[a-z]+$/,"").replace(/\/index$/,"");if(Y===X||Y.endsWith("/"+X)||M.replace(/\.[a-z]+$/,"").endsWith("/"+X)){Z.push(j);break}}}return Z}function E(z,J={}){let{direction:Q=null,ignore:Z=[]}=J,$=[],q=(j,Y,H,U,K,V)=>{if(Z.includes(j))return;$.push({rule:j,kind:Y,severity:H,message:U,evidence:K,...V!==void 0?{file:V}:{}})};for(let j of z)$.push(...Dz(j.text,{...J,file:j.path}));let W=new Map(z.map((j)=>[k(j.path),j])),X=z.filter((j)=>c(j.path)),M=X.length>0?X:z.length===1&&!k(z[0].path).includes("/")?z:[];for(let j of M){if(o(j.path))continue;let Y=Az(j,W),H=[j,...Y,...u(j,W),...Y.flatMap((I)=>u(I,W))].filter((I,O,t)=>t.findIndex((e)=>e.path===I.path)===O&&!Lz(I.path)),U=H.map((I)=>I.text).join(`
|
|
3
|
+
`),K=w(U);if(K<10)continue;let V=H.length-1,B=V>0?`${j.path} + ${V} file${V===1?"":"s"} it renders inside or imports${Y.length>0?` (incl. ${Y.length} layout${Y.length===1?"":"s"})`:""}`:j.path,G=F(U,Mz);if(G/K>0.4)q("rule-line-density",Q===null?"slop":"deviation","med","Across this page almost everything is separated by a drawn line. Separation reads better from spacing, weight and background than from hairlines.",`${G} border/divider declarations across ~${K} elements (${(G/K).toFixed(2)} per element) over ${B}`,j.path);if(Q?.layout===void 0){let I=F(U,l);if(I/K>0.45)q("everything-centered","slop","med","Nearly every block on this page is centred. Centring everything removes the alignment edge the eye follows down the page and flattens the hierarchy.",`${I} centring declarations across ~${K} elements (${(I/K).toFixed(2)} per element) over ${B}`,j.path)}}{let j=new Set(z.flatMap((U)=>Bz(U.text))),Y=Object.values(Q?.typeface??{}).map((U)=>U.toLowerCase()),H=new Set;for(let U of z){if(a(U.path))continue;for(let K of Xz(U.text)){let V=K.toLowerCase();if(H.has(V))continue;if(j.has(V))continue;if(f.some((G)=>G.toLowerCase()===V))continue;H.add(V);let B=Y.includes(V);q("font-named-not-loaded",B?"deviation":"slop","low",B?`"${K}" is the face this project recorded, but nothing in the audited set loads it \u2014 the page renders its fallback, so the recorded direction is not what a reader sees.`:`"${K}" is named in a font-family but nothing in the audited set loads it (no @font-face, next/font import, @fontsource package or Google-Fonts URL). It renders as the fallback, which is nobody's decision. Load it, or drop the name.`,`named in ${U.path}; no load site across ${z.length} audited file${z.length===1?"":"s"}`,U.path)}}}if(Q?.corners!=="sharp"&&z.length>0){let j=z.reduce((H,U)=>H+w(U.text),0),Y=z.some((H)=>F(H.text,Hz)>0);if(j>=40&&!Y)q("all-square","slop","low",'Not one rounded corner anywhere in the audited set. Square everything is a legitimate choice; if it was chosen, record corners "sharp" so this stops being a finding.',`0 radius declarations across ${z.length} files (~${j} elements)`)}return $}function n(z,J={}){let Q=[],Z=[];for(let $ of z)try{Z.push({path:$,text:zz($,"utf8")})}catch(q){Q.push({rule:"unreadable",kind:"slop",severity:"low",message:"could not read the file",evidence:q.message,file:$})}return Q.push(...E(Z,J)),Q}var m={high:0,med:1,low:2};function x(z){return z.provisional===!0?" (provisional direction \u2014 recorded by the agent, not yet confirmed by a human)":""}function r(z,J){if(z.length===0)return J===null?'No design findings. Note: this project has recorded no design direction, so only the "nobody decided" checks ran \u2014 once the human has chosen a direction, record it with design_direction and later screens get consistency checks too.':`No design findings; consistent with the recorded direction "${J.name}"${x(J)}.`;let Q=[...z].sort((q,W)=>m[q.severity]-m[W.severity]),Z=`${z.length} design finding${z.length===1?"":"s"}${J===null?' (no direction recorded \u2014 "nobody decided" checks only, no consistency checks)':` against "${J.name}"${x(J)}`}:`,$=Q.map((q)=>`- [${q.severity}] ${q.rule}${q.kind==="deviation"?" (deviation)":""}${q.file!==void 0?` (${q.file})`:""}: ${q.message}
|
|
4
|
+
evidence: ${q.evidence}`);return[Z,...$].join(`
|
|
5
|
+
`)}import{existsSync as Pz,mkdirSync as Nz,readFileSync as Cz,writeFileSync as Tz}from"fs";import{dirname as Sz,join as _z}from"path";var Rz="design.json";function N(z){return _z(z,".rovecode",Rz)}var L=(z)=>typeof z==="string"&&z.trim().length>0?z.trim():void 0,wz=["sharp","soft","round"],Ez=["centered","left","asymmetric","grid"],vz=["tight","regular","airy"];function v(z){if(typeof z!=="object"||z===null)return null;let J=z,Q=L(J.name);if(Q===void 0)return null;let Z={name:Q},$=L(J.rationale);if($!==void 0)Z.rationale=$;let q=L(J.notes);if(q!==void 0)Z.notes=q;let W=L(J.chosenAt);if(W!==void 0)Z.chosenAt=W;let X=L(J.corners)?.toLowerCase();if(X!==void 0&&wz.includes(X))Z.corners=X;let M=L(J.layout)?.toLowerCase();if(M!==void 0&&Ez.includes(M))Z.layout=M;if(typeof J.palette==="object"&&J.palette!==null){let V={};for(let[B,G]of Object.entries(J.palette)){let I=L(G);if(I!==void 0)V[B]=I}if(Object.keys(V).length>0)Z.palette=V}if(typeof J.typeface==="object"&&J.typeface!==null){let V={};for(let[B,G]of Object.entries(J.typeface)){let I=L(G);if(I!==void 0)V[B]=I}if(Object.keys(V).length>0)Z.typeface=V}if(J.provisional===!0)Z.provisional=!0;let j=L(J.chosenBy)?.toLowerCase();if(j==="human"||j==="agent")Z.chosenBy=j;if(Array.isArray(J.alternatives)){let V=J.alternatives.map(L).filter((B)=>B!==void 0);if(V.length>0)Z.alternatives=V}let Y=L(J.heroPattern);if(Y!==void 0)Z.heroPattern=Y;let H=L(J.motion);if(H!==void 0)Z.motion=H;let U=L(J.copyRegister);if(U!==void 0)Z.copyRegister=U;let K=L(J.density)?.toLowerCase();if(K!==void 0&&vz.includes(K))Z.density=K;if(Array.isArray(J.sectionOrder)){let V=J.sectionOrder.map(L).filter((B)=>B!==void 0);if(V.length>0)Z.sectionOrder=V}if(Array.isArray(J.typeScale)){let V=J.typeScale.filter((B)=>typeof B==="number"&&Number.isFinite(B)&&B>0);if(V.length>0)Z.typeScale=V}return Z}function A(z){let J=N(z);if(!Pz(J))return null;try{return v(JSON.parse(Cz(J,"utf8")))}catch{return null}}function d(z,J){let Q=N(z);Nz(Sz(Q),{recursive:!0});let Z={...J,chosenAt:J.chosenAt??new Date().toISOString().slice(0,10)};return Tz(Q,JSON.stringify(Z,null,2)+`
|
|
6
|
+
`),Q}function C(z){if(z===null)return"";let J=z.provisional===!0?[`PROVISIONAL direction: ${z.name}${z.chosenAt?` (recorded ${z.chosenAt})`:""} \u2014 chosen by the agent, no human was available.`,"Build to it, but ask the human once before the next screen: this is the one decision that is theirs."]:[`Chosen direction: ${z.name}${z.chosenAt?` (chosen ${z.chosenAt})`:""}`];if(z.rationale!==void 0)J.push(`Why: ${z.rationale}`);if(z.palette!==void 0)J.push(`Palette: ${Object.entries(z.palette).map(([Q,Z])=>`${Q} ${Z}`).join(", ")}`);if(z.typeface!==void 0){let Q=Object.entries(z.typeface),Z=new Set(Q.map(([,$])=>$));J.push(`Typefaces: ${Z.size===1?Q[0][1]:Q.map(([$,q])=>`${q} for ${$}`).join(", ")}`)}if(z.corners!==void 0)J.push(`Corners: ${z.corners}`);if(z.layout!==void 0)J.push(`Composition: ${z.layout}`);if(z.density!==void 0)J.push(`Density: ${z.density}`);if(z.sectionOrder!==void 0)J.push(`Section order: ${z.sectionOrder.join(" -> ")}`);if(z.heroPattern!==void 0)J.push(`Hero: ${z.heroPattern}`);if(z.typeScale!==void 0)J.push(`Type scale: ${z.typeScale.join(", ")}`);if(z.motion!==void 0)J.push(`Motion: ${z.motion}`);if(z.copyRegister!==void 0)J.push(`Copy register: ${z.copyRegister}`);if(z.notes!==void 0)J.push(`Notes: ${z.notes}`);if(z.alternatives!==void 0)J.push(`Not built: ${z.alternatives.join(", ")}`);return J.join(`
|
|
7
|
+
`)}var T=["# Interface design","","This applies whenever you build or change a user interface \u2014 a page, a screen, a component, a theme.","","## Decide the direction with the human, once per project","","There is no default look. Colour, typeface and layout are decided per project and nothing carries","over from another project.","","This question is about NEW work: a page, screen or component that is not on the screen yet. A change",'to something that already exists is not this question. "Make the background black", "add a shadow to','the text", "make this bigger", a new state on an existing screen, a colour swapped on an existing',"button: do it, now, in the direction the existing code already shows, and do not stop at a proposal,","whether or not this project has a recorded direction. The test is simple: if the person could point at","the thing on the screen, it exists and you change it; if they could not, it is new and the direction is","decided first. When the change would contradict a recorded direction, make the change and say so in one","line, so the human can decide whether the direction moves.","","- If this project has no recorded direction and you are about to write NEW UI, stop and propose THREE"," directions first. For each: the palette (as hex), the typefaces, how it composes the page, and the"," specific fact about THIS product that justifies it.","- Three directions are distinct only if they disagree on ALL FOUR of these axes; if two agree on the"," second or third they will converge however different their prose sounds, because those two decide"," the structure:"," 1. what the first screen is MADE OF (real output? prose? an instrument? an image?)"," 2. what carries HIERARCHY (type scale? density? monospace rhythm? boxes? colour?)"," 3. what COLOUR is FOR (functional only? near-absent with one accent? state semantics? mood?)"," 4. what counts as PROOF (real runs? tables and footnotes? live numbers? testimony?)"," Asking yourself once for three ideas tends to return one idea three times; derive each direction"," from a different source of form instead, then check the four axes.","- Worked example for a developer tool, as an example and not a menu \u2014 the right sources of form for a"," payments product or a magazine are different, and if you cannot name the product fact that justifies"," an anchor, it is the wrong anchor for this project:"," A. ITS OWN OUTPUT \u2014 the page is made of what the tool produces: a real transcript or diff as the"," first screen, hierarchy from monospace rhythm, colour functional only (add/remove, exit status),"," proof = actual runs. Forbids itself stock illustration and invented copy. Even here the first"," screen still SAYS what the product is, in one visible line above or beside the output \u2014 a"," caption, not a hero. A transcript a stranger cannot name is a demo, not a page, and an"," sr-only h1 is not that line: it has to be visible."," B. THE MANUAL \u2014 a technical document that happens to be a web page: a stated claim in a long"," measure plus a spec table, hierarchy from type scale and space alone, colour nearly absent"," with one accent, proof = tables and versioned facts. Forbids itself cards, the headline-plus-"," two-buttons pair, the three-column feature grid."," C. THE INSTRUMENT \u2014 a dense panel a professional reads at a glance: a live status surface first,"," hierarchy from density contrast and a visible grid, colour carrying state (ok/warn/fail),"," proof = numbers in place. Forbids itself marketing whitespace and decorative motion.","- The anchor fixes the organising idea and the structure, NOT the palette or the mode: the seed colour",' and light/dark are chosen independently of it. "Terminal" is not a licence for dark-plus-green;'," that would be a default smuggled in through the back door.","- Let the human choose. Do not build while the question is open, and do not pick for them.",`- Keep each option LABEL to 60 characters or less \u2014 a letter and the direction's name ("A. Its own`,' output"). The four axes, the palette and the rationale go in the question body, not the label:'," ask_user truncates a long option and the human then chooses between three cut-off phrases.","- WHEN NOTHING CAN ASK A HUMAN (a headless `rovecode run`, no terminal): do not stall, and do not"," quietly promote your own pick to a decision. Build ONE direction and record it as provisional \u2014"," `design_direction set` with `provisional: true` and the other two names in `alternatives`. Then say"," so in your final summary: which one you built, which two you did not, and that the choice is still"," theirs. The next interactive session asks the question once before writing more UI.","- Once they choose, record it with the `design_direction` tool. That is what makes this a"," once-per-project question instead of a once-per-task one.","- When a direction is already recorded, do NOT re-ask. Build to it. Propose a change only if the"," work genuinely cannot be done within it, and say why. The one exception: a direction recorded as"," PROVISIONAL was chosen by an agent, not a human \u2014 ask once, in the first interactive session that"," touches UI, before building more; then record the answer with `provisional` dropped.","","## The defaults to climb out of","","These are what generated interfaces look like when nobody decided anything. Recognise them in your","own output:","","- Amber, orange and gold as the accent. It is the reflex accent; choose one that belongs to the product.","- A full-viewport hero with a big headline and two buttons, on a page that had no reason for one."," A hero costs the reader an entire screen \u2014 spend it only on an image or an idea that earns it.","- Typefaces with no relationship to the product: Inter, Roboto, Poppins, Montserrat and the rest of"," the set that arrives when no one picked. What matters is the face you LOAD \u2014 an import, an"," @font-face, a fonts URL \u2014 because that is where the decision is; a system stack sitting behind your"," chosen face is a fallback, not a choice, and neither is a face merely named in prose. Pick the face"," you load for a reason you can state. And if you name a face in CSS, LOAD it \u2014 a link, an @import,"," an @font-face or a framework font import \u2014 or drop the name: a named-but-unloaded face renders as"," its fallback, so the page does not look the way the code says it does. That is no decision at all,"," and `design_audit` reports it as `font-named-not-loaded`.","- Hairlines everywhere: a border around every card, a rule between every row. Separation reads better"," from spacing, weight, size and background than from drawn lines.","- Everything square. Corner treatment is a decision; make it once, deliberately, either way.","- Everything centred. Centring every block removes the alignment edge the eye follows down the page"," and flattens the hierarchy \u2014 most content wants an edge to sit against.","- Every fact at the same size in one long column. Decide what is most important and let the layout"," say so; a page where everything shouts says nothing.","- The purple-to-blue gradient, and the generic three-column feature grid under a centred heading.","","## Check yourself","","After writing UI, or changing how an existing screen looks (the black background, the shadow, the","bigger heading included), run `design_audit` on the source you touched \u2014 the PAGE","file together with the components it imports, not one component alone. Hairline density and centring",'are properties of a page, and "no rounded corner anywhere" is a property of a project, so a',"single-component run cannot see them. Run it on source, never on a fetched page: a built page measures","the framework's output.","","It separates two things. A SLOP finding means nothing here records a decision \u2014 it disappears the","moment the human chooses and you record it, and it is not a claim that the pattern is ugly. A","DEVIATION means the code contradicts what this project already chose, which is the half worth acting","on. Fix what it finds, or say plainly why a finding is wrong for this project: it reports evidence,","not verdicts, and it can be overruled.","","The audit measures patterns, not promises, so it cannot check the half of the direction that is","prose. Do that part yourself: re-read the `notes` and `rationale` recorded in design.json and take",'each claim to the page one at a time. "No stock imagery", "numbers in place, no adjectives",','"one entrance per section" \u2014 either the page does it or it does not, and a clean audit says',"nothing about any of them."].join(`
|
|
8
|
+
`);function hz(z,J=process.env){let Q=A(z);if(Q===null){if((J.ROVECODE_DESIGN??"").trim().toLowerCase()==="full")return`${T}
|
|
9
|
+
|
|
10
|
+
## This project
|
|
11
|
+
|
|
12
|
+
No design direction is recorded yet (.rovecode/design.json). The next interface work in this project starts with the proposal above.`;return["# Design","",`No design direction is recorded yet (.rovecode/design.json). Before ANY interface work, call design_direction {action:"get"}: it returns this project's design protocol (the defaults to climb out of, the ban list, how to propose). Then propose THREE distinct directions and let the human choose; design_audit checks later screens against the recorded direction.`].join(`
|
|
13
|
+
`)}let Z=Q.provisional===!0?"## This project's direction \u2014 PROVISIONAL: build to this, and ask once before more UI":"## This project's direction \u2014 build to this, do not re-ask";return`${T}
|
|
14
|
+
|
|
15
|
+
${Z}
|
|
16
|
+
|
|
17
|
+
${C(Q)}`}function bz(z,J){let Q=i(J)?S(J):S(z,J),Z=s(S(z),Q);return Z===""||Z.startsWith("..")||i(Z)?null:Q}function nz(){return{schema:{name:"design_audit",description:"Check interface code for the patterns that arrive when nobody decided (a webfont loaded without a choice, amber doing accent duty, the three-up feature grid, a centred full-viewport hero, the violet-to-blue gradient, nothing but square corners) and for drift from the direction this project recorded in .rovecode/design.json. Run it on the SOURCE TREE, not on a fetched page: a built page measures the framework's output, not the design. Pass the page files you touched along with the components they import, because density and centring are scored per page and 'no rounded corner anywhere' is scored per project. It reports evidence, not verdicts: each finding says what it counted, so you can fix it or explain why it is wrong here. Never prompts, never writes.",args:{type:"object",properties:{files:{type:"array",items:{type:"string"},description:"paths inside the project to audit (html/css/jsx/tsx/vue/svelte)"},source:{type:"string",description:"audit this markup/CSS directly instead of reading files"},ignore:{type:"array",items:{type:"string"},description:"rule ids to skip (the full table is in docs/design.md): cliche-font, font-deviation, font-named-not-loaded, cliche-accent-amber, accent-deviation, template-grid, template-icons, reflex-hero, cliche-gradient, off-palette, decoration-density, rule-line-density, everything-centered, all-square"}}}},kind:"read",sequential:!1,async execute(z,J){let Q=z&&typeof z==="object"?z:{},Z=A(J.cwd),$=Q.ignore??[],q=[];if(typeof Q.source==="string"&&Q.source.length>0)q.push(...E([{path:"source",text:Q.source}],{direction:Z,ignore:$}));let W=Q.files??[];if(W.length>0){let X=[],M=[];for(let j of W){let Y=bz(J.cwd,j);if(Y===null)M.push(j);else X.push(Y)}if(M.length>0)return{ok:!1,output:`design_audit only reads files inside the project. Outside: ${M.join(", ")}`};q.push(...n(X,{direction:Z,ignore:$}).map((j)=>({...j,...j.file!==void 0?{file:s(S(J.cwd),j.file)||j.file}:{}})))}if(W.length===0&&(Q.source===void 0||Q.source.length===0))return{ok:!1,output:"design_audit needs `files` (paths inside the project) or `source` (markup/CSS text)."};return{ok:!0,output:r(q,Z),data:{findings:q,direction:Z}}}}}function rz(){return{schema:{name:"design_direction",description:"Read or record this project's design direction (.rovecode/design.json). `get` returns the recorded direction, or says none is recorded. `set` records the direction THE HUMAN CHOSE after you proposed three \u2014 do not call it with a direction you picked yourself. The one exception is a headless run where nothing can ask a human: then build ONE direction and record it with provisional:true and the other two in `alternatives`, so the next interactive session asks before more UI is built. Recording it is what makes the choice a once-per-project question and lets design_audit check later screens for consistency.",args:{type:"object",properties:{action:{type:"string",enum:["get","set"]},name:{type:"string",description:"short name of the chosen direction, as presented to the human"},rationale:{type:"string",description:"one line: why it suits this product"},palette:{type:"object",description:'chosen colours, e.g. {"ink":"#0b1a2e","accent":"#c2410c"}'},typeface:{type:"object",description:'{"display":"...","text":"..."}'},corners:{type:"string",enum:["sharp","soft","round"]},layout:{type:"string",enum:["centered","left","asymmetric","grid"]},density:{type:"string",enum:["tight","regular","airy"]},sectionOrder:{type:"array",items:{type:"string"},description:`the page's blocks in order, e.g. ["hero","proof","pricing","faq"]`},heroPattern:{type:"string",description:'the hero pattern by name, e.g. "command-first" or "product-forward"'},typeScale:{type:"array",items:{type:"number"},description:"the chosen type steps, e.g. [14,16,20,28,44]"},motion:{type:"string",description:`the motion rule in the human's words, e.g. "one entrance per section, no loops"`},copyRegister:{type:"string",description:'how the copy reads, e.g. "technical, names and numbers, no marketing verbs"'},notes:{type:"string",description:"what the audit cannot infer: imagery, what to avoid here"},provisional:{type:"boolean",description:"true ONLY when no human could be asked (a headless run): you built to one direction to get unblocked. Never true when a human answered."},alternatives:{type:"array",items:{type:"string"},description:"with provisional: the names of the directions you did NOT build, so the next interactive session can offer them"}},required:["action"]}},kind:"custom",sequential:!0,resource(z){return(z&&typeof z==="object"?z:void 0)?.action==="get"?"get":"set"},async execute(z,J){let Q=z&&typeof z==="object"?z:{};if(Q.action==="get"){let q=A(J.cwd);return q===null?{ok:!0,output:`No design direction recorded for this project (${N(J.cwd)} does not exist). Here is the protocol:
|
|
18
|
+
|
|
19
|
+
${T}
|
|
20
|
+
|
|
21
|
+
Propose three distinct directions and let the human choose before writing UI. If nothing here can ask a human, build ONE and record it with provisional: true.`}:{ok:!0,output:C(q),data:q}}if(Q.action!=="set")return{ok:!1,output:'design_direction: action must be "get" or "set".'};let Z=v(Q);if(Z===null)return{ok:!1,output:"design_direction set needs at least `name` \u2014 the short name of the direction the human chose."};Z.chosenBy=Z.provisional===!0?"agent":"human";let $=d(J.cwd,Z);if(Z.provisional===!0){let q=Z.alternatives===void 0?"":` The alternatives (${Z.alternatives.join(", ")}) are recorded with it.`;return{ok:!0,output:`Recorded "${Z.name}" in ${$} as PROVISIONAL \u2014 you chose it, not the human.${q} Build to it and say so in your final summary, naming what you did not build. The next interactive session asks before more UI is written.`,data:Z}}return{ok:!0,output:`Recorded "${Z.name}" in ${$}. Later UI in this project is built to it, and design_audit checks against it.`,data:Z}}}}
|
|
22
|
+
export{hz as ke,nz as le,rz as me};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Eh as Q,Fh as E,Jh as W,Kh as x,Lh as b,Mh as A,Nh as I,Oh as L,Ph as v}from"./main-kcpbykxz.js";import{vm as V,wm as _}from"./main-a9njrkk1.js";import{$m as N,Lm as R}from"./main-2yeveeve.js";import{cn as f,fn as Z,kn as S}from"./main-nqveez48.js";import{xn as $}from"./main-qsevpgsv.js";N();E();v();_();S();import{relative as G}from"path";var M=["usage: rovecode plugin <command>"," list every plugin in ~/.rovecode/plugins and .rovecode/plugins, with its status"," init <name> [--project] scaffold a new plugin folder (manifest, entry, test, README) ready for `plugin add`"," test [path] validate + activate a plugin in a dry harness, then run its plugin.test.ts"," add <folder|git-url> [--project] [--force]"," copy (or shallow-clone) a plugin into the user scope, or this repo's .rovecode/plugins"," remove <name> [--project] delete the installed copy"," enable <name> \xB7 disable <name>"," switch a plugin off/on in every scope (~/.rovecode/plugins.json)"," trust <name> approve a PROJECT plugin's current files on this machine \u2014 until they change"," untrust <name> withdraw that approval"," show <name> manifest, files and what it contributes, without running any of it","status: active \xB7 disabled \xB7 untrusted (project plugin not yet approved here) \xB7 broken (see problems)"].join(`
|
|
3
|
+
`),H=(J,K)=>J.includes(K),Y=(J)=>J.filter((K)=>!K.startsWith("--"));async function c(J,K={}){let B=K.cwd??process.cwd(),C=K.home??R(),y=K.out??((j)=>console.log(j)),z=K.err??((j)=>console.error(j)),[T="list",...O]=J,X=H(O,"--project")?"project":"user",q=Y(O)[0];switch(T){case"init":return await import("./init-g2m0tn4m.js").then((j)=>j.cmdPluginInit(Y(O),{cwd:B,out:y,err:z}));case"test":return await import("./init-g2m0tn4m.js").then((j)=>j.cmdPluginTest(Y(O)[0],{cwd:B,home:C,out:y,err:z}));case"list":case"ls":{let{plugins:j,warnings:k}=Q(B,{home:C});if(j.length===0)y(`no plugins. add one: rovecode plugin add <folder|git-url> (user: ${W("user",B,C)}, project: ${G(B,W("project",B,C))||"."})`);for(let D of j)y(F(D));for(let D of k)z(`warning: ${D}`);return 0}case"add":{let j=q;if(!j)return z(M),2;let k=await x(j,{cwd:B,home:C,scope:X,force:H(O,"--force"),...K.spawn?{spawn:K.spawn}:{}});if(!k.ok)return z(`plugin add: ${k.error}`),1;y(`added ${k.name}@${k.manifest.version} (${k.scope}) \u2192 ${k.dir}`);for(let D of V(k.manifest))y(` ${D}`);if(k.scope==="project")y(` trusted on this machine (recorded in ${f(C)}); a change to its files will ask again`);return y("restart rovecode to load it \u2014 plugins are read once per process, like hooks"),0}case"remove":case"rm":{if(!q)return z(M),2;let j=b(q,{cwd:B,home:C,scope:X});if(!j.ok)return z(`plugin remove: ${j.error}`),1;return y(`removed ${q} (${X}) from ${j.dir}`),0}case"enable":case"disable":{if(!q)return z(M),2;if(!Q(B,{home:C}).plugins.some((D)=>D.name===q))z(`warning: no installed plugin named "${q}" \u2014 the setting is recorded anyway`);let k=A(q,T==="enable",C);return y(`${q} ${T}d (${k})`),0}case"trust":{if(!q)return z(M),2;let j=Q(B,{home:C}).plugins.find((D)=>D.name===q&&D.scope==="project");if(!j)return z(`plugin trust: no project plugin "${q}" under ${W("project",B,C)}`),1;if(j.manifest===null){z(`plugin trust: "${q}" is broken \u2014 fix it first:`);for(let D of j.problems)z(` ${D}`);return 1}let k=I(q,{cwd:B,home:C});if(!k.ok)return z(`plugin trust: ${k.error}`),1;y(`trusted ${q}@${j.manifest.version} \u2014 ${Z(j.dir).length} files, digest ${k.digest.slice(0,12)}\u2026`);for(let D of V(j.manifest))y(` ${D}`);return y("it loads on the next start; `rovecode plugin show "+q+"` lists every file it brings"),0}case"untrust":{if(!q)return z(M),2;return y(L(q,{cwd:B,home:C})?`untrusted ${q}`:`${q} was not trusted`),0}case"show":case"info":{if(!q)return z(M),2;let j=Q(B,{home:C}).plugins.find((k)=>k.name===q);if(!j)return z(`plugin show: no plugin "${q}"`),1;if(y(F(j)),y(` folder: ${j.dir}`),j.digest)y(` digest: ${j.digest}`);if(j.manifest)for(let k of V(j.manifest))y(` ${k}`);for(let k of Z(j.dir))y(` - ${k}`);for(let k of j.problems)y(` ! ${k}`);if(j.status==="untrusted")y(` run \`rovecode plugin trust ${j.name}\` after reading the files above`);return 0}case"help":case"--help":case"-h":return y(M),0;default:return z(`unknown plugin command "${T}"
|
|
4
|
+
${M}`),2}}function F(J){let K=J.manifest?`@${J.manifest.version}`:"",B=J.manifest?.description?` \u2014 ${J.manifest.description}`:"";return`${(J.name+K).padEnd(28)} ${J.scope.padEnd(8)} ${J.status.padEnd(9)}${B}`.trimEnd()}
|
|
5
|
+
export{M as Ah,c as Bh,F as Ch};
|