Marketplace catalog discovery, install, removal, and installed-item detection
lived in the VS Code extension, so any other editor client would have had to
reimplement catalog parsing, scope resolution, config writing, and archive
extraction.
Move that logic behind three CLI endpoints and make the extension a client of
them, so every editor shares one marketplace implementation over the SDK:
GET /kilocode/marketplace catalog + installed detection per scope
POST /kilocode/marketplace/install install an MCP server, agent, or skill
POST /kilocode/marketplace/remove remove an MCP server, agent, or skill
No user-visible change in VS Code. The panel UI and suggestion relevance stay
client-side, since relevance depends on installed VS Code extensions.
The contract is shaped for generated clients so the JetBrains plugin can build
on it: response and model schemas are named rather than inline, and install
takes an item's type, id, and content instead of a full catalog entry.
- narrow the retry gate to active scenarios (TodoScenario has no reset field)
and type the retry accumulator as Result; both surfaced only in the PR
typecheck job because the scenario union changed in the main merge
- annotate every changed line in shared upstream files with kilocode_change
markers (websearch Env migration, exerciser isolation/retry, pty deadline,
storage layer-injection tests)
- drop duplicate .inProject({ git: true }) calls on the worktree scenarios
left behind by the main merge (main and this branch each added one)
Main landed the same httpapi design (git-opt-in fixtures, --shard flag)
and the same permission.create readiness wait. Resolution adopts main's
implementations and keeps this branch's unique work on top: the
--shards child-process orchestrator (adapted to main's zero-based
shard indexing), scenario retry with backoff gated on state-reset,
project.update isolation, and exerciser env stripping. Removed the
superseded agentsReady/probe machinery and this branch's duplicate
round-robin filter (double-sharding silently dropped scenarios).
Validated: coverage, auth, and 4-shard effect passes all green
(315 checks, 0 failures).
project.update PATCHes its project row; in a non-git directory that row
is the shared global project and the mutation leaked into every later
non-git scenario in the pass. It runs in an isolated git project now.
Scenario retries are gated on scenario.reset: preserveDatabase scenarios
skip resetState between attempts, so retrying them runs against state
the failed attempt already mutated and can mask a regression as FLAKY.
agentsReady refuses to run without a project directory instead of
observing a process.cwd() fallback instance the scenario never targets.
Validated: full 4-shard effect pass, 315 checks, 0 failures.
agentsReady rebuilt the x-kilo-directory header inline; it now uses the
same builder the rest of the context uses, so a future required header
cannot silently diverge. The retry loop tracks its last result instead
of index bookkeeping with an unreachable trailing return.
The agent projection fills asynchronously after instance load; a
permission evaluated before it fills resolves no agent and hits the
deny-all fallback (effect 'deny' instead of 'ask'). Sleep-based retries
recreated the race on every attempt because each retry seeds a fresh
instance. The scenario now polls GET /api/agent until the projection
is warm — gating on the precondition itself.
The git:false default left GET /vcs covering only the no-VCS
short-circuit; opting it back in restores coverage of the git
detection and branch-info path.
Shard children now strip KILO_HTTPAPI_EXERCISE_* so a pinned database
or global root cannot make concurrent shards collide on shared state.
The scenario retry gains a second, longer backoff (1s then 3s): sharded
children run fewer scenarios each, so early scenarios can land before
agent projections warm and one second is not always enough.
After #13091 isolated this scenario on a fresh project, permission.create can race AgentPlugin boot and get deny-all. Wait for the default build agent over GET /api/agent before asserting ask.
CI run 31737021189 captured the flake with the new diagnostics:
v2.session.permission.create returns {"effect":"deny"} because the
agent projection is still warming when the request lands, so permission
evaluation hits the deny-all missing-agent fallback. An immediate retry
on the saturated runner reproduced the same race; a short pause lets
projections settle before the second attempt.
The proper fix (block HttpApi requests until projections are ready) is
the readiness-race work package tracked in #12986.
Two hardening changes surfaced by CI run 31730610337, where
v2.session.permission.create failed on one shard but passes 15/15 in
isolation, and a local shard loop failed kilocode.commandFiles once in
4 passes — i.e. background per-scenario flakiness under load, not a
specific broken route.
- Retry a failed scenario once before failing the pass (state resets
between attempts via resetState). Mirrors the unit runner's
pass-after-retry policy; retries are logged as RETRY/FLAKY so they
stay visible instead of silently masking regressions.
- Append the actual response (status + body) to assertion failures so
CI logs show what the route returned, not just which check broke.
Completes #12999 (with the fixture change in the previous commit).
Adds --shard <i>/<n> (round-robin scenario subset) and --shards <n>
(spawns n child processes, each with its own PID-keyed database and
global root, tagged output, combined exit code). test:httpapi runs the
effect pass with --shards 2.
Route coverage (missing/extra) is still computed against the full
scenario list in every child, so --fail-on-missing stays correct.
Local effect-mode wall clock: 4m11s -> 2m39s (6m37s before this PR).
315/315 scenarios pass across both shards.
Part of #12986, addresses the fixture half of #12999.
Every exerciser scenario defaulted to project: { git: true }, spinning up a
full git repo (~6 subprocess spawns) per scenario even though only 13 of the
82 routes exercise VCS, worktree, or project-identity behavior. Flip the
default to git: false and opt those 13 in explicitly.
Non-git directories resolve to the global project (worktree "/"), so
path.get, project.current, and v2.session.permission.create — which assert
per-project semantics — keep their git fixture.
Local effect-mode wall clock: 6m37s -> ~3m45s (315/315 pass in all modes).
Coverage mode was measured at ~3s and is already static; no change needed
for that part of #12999.
* test(cli): optimize httpapi exerciser by removing redundant git fixtures and isolating scenario passes
- Default scenario project fixture is now in-memory; only VCS/worktree/diff
routes opt into git init via .inProject({ git: true }).
- mode coverage becomes a standalone fast static check that skips the full
runtime/LLM/DB allocation.
- --shard <index>/<total> flag lets CI runners fan the exerciser out across
processes; each shard already owns an isolated PID-keyed DB.
Refs #12999
* test(cli): keep coverage mode off the runtime and run llm scenario guard statically
- Move the runtime() finalizer below the coverage early-return so the
static OpenAPI comparison path never imports session/worktree/project.
- Hoist the llmScenarios consistency check above the coverage branch so a
scenario missing .withLlm() is still caught in static mode.
- Coverage branch now runs cleanupExercisePaths directly before returning.
- Fix typo HEAD-baseed -> HEAD-based in dsl.ts comment.
* test(cli): opt three scenarios into git init that depend on a git-backed project
CI surfaced three regressions after switching the default scenario
fixture to in-memory. Each scenario asserts behavior that requires
the project directory to be a git worktree:
- path.get: `body.worktree === ctx.directory`
- project.current: `body.worktree === ctx.directory`
- v2.session.permission.create: `body.data.effect === "ask"`
for an untracked resource (the permission resolver consults VCS
state before deciding to ask).
Adding `.inProject({ git: true })` to each restores the prior
behavior without re-introducing the global git init default.
* fix(cli): stabilize Windows CI tests and rebalance slow shards
Three Windows-only instabilities in the CLI unit suite:
1. httpapi-instance-route-auth.test.ts failed with an uncaught
"Invalid handle" error. The test's ConfigProvider.layer(
fromUnknown(...)) replaced the ambient config provider, blinding
KILO_EXPERIMENTAL_DISABLE_FILEWATCHER=true that CI/preload sets. With
the flag hidden, the @parcel/watcher Windows backend subscribed on the
temp repo's .git; the tmpdir fixture then deleted that directory while
the never-disposed per-test runtime still held the subscription, and
CreateFileW failed with the hardcoded "Invalid handle" (napi rejection
with no JS stack). Add the disable-filewatcher flag to every test
config map that boots instances via the HttpApi app (instance-route-auth,
cors, ui, exercise backend, kilo-edit, memory).
2. config-overlay.test.ts intermittently returned HTTP 500 on Windows.
Filesystem.write's atomic temp-file+rename had no retry for Windows
transient locked-file errors (EPERM/EACCES/EBUSY) from Defender/indexer
and the detached background plugin install racing the rename in the same
tmpdir. Mirror the proven cleanup.ts locked-error retry pattern with a
short backoff, Windows-only.
3. Windows shards were badly imbalanced: the sharder weighted files by
byte size, which concentrated every slow spawn/FS/lock-heavy file
(snapshot, prompt, provider, run-process, instance-bootstrap,
httpapi-session) into one shard (~612s vs ~356s siblings), and the
resulting contention forced whole-file retries that doubled cost. Add
TestShard.timedWeight and a committed test-timings.json seeded from CI
junit data so shards balance by measured runtime (spread collapses from
~200s to ~18s) and contention-prone files spread across shards.
Platforms without manifest entries fall back to size weighting.
* fix(cli): skip stale manifest entries in timed shard weighting
Bun.file().size returns 0 (never throws) for missing paths, so the
try/catch in timedWeight was dead code and stale/renamed manifest entries
added their time to the scale numerator with zero size, inflating the
size-to-time ratio that estimates unknown files. Skip entries with a
non-positive on-disk size instead of catching a throw that never happens.
* revert(cli): drop hardcoded test-timings manifest
The committed test-timings.json (482 entries) was a maintenance burden:
it goes stale as tests are added/renamed and no size-based heuristic can
replace it (slow subprocess outliers like run-process.test.ts are 7kb but
112s, 10x the runtime-per-byte of other files). Revert the timing-weighted
sharding to the prior size-based LPT. The Windows reliability fixes
(ConfigProvider filewatcher flag + Filesystem.write locked-file retry)
remain and are what eliminate the failures and the ~360s of retry overhead
that dominated the 12m50s shard. A maintainable runtime-based rebalance
(self-updating CI cache fed from the junit artifacts CI already uploads)
is a separate follow-up.
The auth mode probes every protected route with valid credentials to
prove the route accepts them. Two routes intentionally block after a
valid request: tui.control.next waits for queued TUI input, and
instance.reload can outlive the one second probe. The probe won by
timeout, marked the scenario passed, and left the request alive inside
the cached web handler. Final disposeApps() then waited for those
requests forever, so any run that rebuilt the app (cold turbo cache)
never exited and CI cancelled the job at 15 minutes.
Add a scenario flag that keeps the missing-credentials check (the route
must still return 401) but skips the valid-credential probe for routes
whose valid requests intentionally block, and mark tui.control.next and
instance.reload with it.