Skip to content

Commit 9b097f5

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr22883
# Conflicts: # pnpm-lock.yaml
2 parents b76383a + 4196708 commit 9b097f5

47 files changed

Lines changed: 3194 additions & 2374 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
105105
- Test meaningful logic or observable behavior. Do not render components to static markup to assert props or attributes, or add tests that merely assert callback wiring or mirror the implementation.
106106
- **Do not run repo-wide checks.** No `vp check`, no `vp run -r test`, no `vp run -r typecheck` unless I ask. CI owns the full suite.
107107
- Backend behavior changes ship with focused tests for that behavior.
108+
- Proof for a bug fix depends on the bug. Logic, data, state, and protocol bugs get a failing test first (the fewest that fail on `main` for that reason, in the module's existing test file), then the fix. Purely visual bugs (spacing, colour, alignment, a layout shift) get before/after captures as their proof and no test: do not add UI tests for nitpicks, and do not ask for one in review when a capture already shows it. A server-only fix with no visible surface ships the test plus a short runtime transcript.
108109
- The server is event-sourced, and side effects run after the command commits. In tests, drain the effect worker (`OrchestrationEffectWorkerV2.drain`) or await the specific persisted event or `Deferred` that marks the milestone. Never wait on sleeps or polling. A test that needs a timeout to pass is wrong. Concretely:
109110
- `it.effect` runs on a `TestClock`; `Effect.sleep` only advances through `TestClock.adjust`. `it.live` is wall-clock and only for subprocess or network fixtures.
110111
- No `yieldNow` or `sleep` polling loops. Await the `Deferred`, take from the `Queue`, or drain the worker.

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,42 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
25572557
}),
25582558
);
25592559

2560+
it.effect("includes CLAUDE.md for Claude writers only when it differs from AGENTS.md", () =>
2561+
Effect.gen(function* () {
2562+
const repoDir = yield* makeTempDir("t3code-git-manager-");
2563+
yield* initRepo(repoDir);
2564+
NodeFS.writeFileSync(NodePath.join(repoDir, "AGENTS.md"), "Use imperative subjects.\n");
2565+
NodeFS.copyFileSync(NodePath.join(repoDir, "AGENTS.md"), NodePath.join(repoDir, "CLAUDE.md"));
2566+
NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello\n");
2567+
const commitInstructions: Array<string | undefined> = [];
2568+
2569+
const { manager } = yield* makeManager({
2570+
serverSettings: {
2571+
textGenerationModelSelection: {
2572+
instanceId: ProviderInstanceId.make("claudeAgent"),
2573+
model: "claude-sonnet-4-5",
2574+
},
2575+
},
2576+
textGeneration: {
2577+
generateCommitMessage: (input) => {
2578+
commitInstructions.push(input.policy?.commitInstructions);
2579+
return Effect.succeed({ subject: "Update readme", body: "" });
2580+
},
2581+
},
2582+
});
2583+
2584+
yield* runStackedAction(manager, { cwd: repoDir, action: "commit" });
2585+
2586+
NodeFS.writeFileSync(NodePath.join(repoDir, "CLAUDE.md"), "Mention the Claude provider.\n");
2587+
NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello again\n");
2588+
yield* runStackedAction(manager, { cwd: repoDir, action: "commit" });
2589+
2590+
expect(commitInstructions[0]).toContain("Local AGENTS.md:\nUse imperative subjects.");
2591+
expect(commitInstructions[0]).not.toContain("Local CLAUDE.md:");
2592+
expect(commitInstructions[1]).toContain("Local CLAUDE.md:\nMention the Claude provider.");
2593+
}),
2594+
);
2595+
25602596
it.effect("falls back when the dedicated source control writer is unavailable", () =>
25612597
Effect.gen(function* () {
25622598
const repoDir = yield* makeTempDir("t3code-git-manager-");

‎apps/server/src/git/GitManager.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,10 @@ export const make = Effect.gen(function* () {
863863
? [["Recent commit subjects from this repository:", ...subjects].join("\n")]
864864
: []),
865865
...(agentInstructions ? [`Local AGENTS.md:\n${agentInstructions}`] : []),
866-
...(claudeInstructions ? [`Local CLAUDE.md:\n${claudeInstructions}`] : []),
866+
// CLAUDE.md is often a symlink or copy of AGENTS.md; skip the duplicate.
867+
...(claudeInstructions && claudeInstructions !== agentInstructions
868+
? [`Local CLAUDE.md:\n${claudeInstructions}`]
869+
: []),
867870
].join("\n\n");
868871
if (!examples) {
869872
return repositoryConventionsTextGenerationPolicy;

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
EnvironmentId,
66
MessageId,
77
NodeId,
8+
type OrchestratorMcpCapabilitiesResult,
89
OrchestratorMcpTarget,
910
type OrchestrationV2ThreadShell,
1011
type ScheduledTask,
@@ -1156,6 +1157,176 @@ describe("OrchestratorMcpService provider resolution", () => {
11561157
}),
11571158
);
11581159

1160+
describe("listed models", () => {
1161+
const opencodeInstanceId = ProviderInstanceId.make("opencode");
1162+
const model = (slug: string, extra: Partial<ServerProvider["models"][number]> = {}) => ({
1163+
slug,
1164+
name: slug,
1165+
isCustom: false,
1166+
capabilities: null,
1167+
...extra,
1168+
});
1169+
const opencodeSlugs = Array.from(
1170+
{ length: 12 },
1171+
(_, index) => `oc/m${String(index + 1).padStart(2, "0")}`,
1172+
);
1173+
const catalog: ReadonlyArray<ServerProvider> = [
1174+
{
1175+
...providerSnapshot({
1176+
instanceId: codexInstanceId,
1177+
driver: ProviderDriverKind.make("codex"),
1178+
}),
1179+
models: [
1180+
model("gpt-6", {
1181+
name: "Sol",
1182+
capabilities: {
1183+
optionDescriptors: [
1184+
{
1185+
id: "effort",
1186+
label: "Reasoning",
1187+
description: "How hard the model thinks.",
1188+
type: "select",
1189+
options: [
1190+
{ id: "low", label: "Low", description: "Fast." },
1191+
{ id: "high", label: "High", isDefault: true },
1192+
],
1193+
promptInjectedValues: ["high"],
1194+
},
1195+
{ id: "fastMode", label: "Fast", type: "boolean" },
1196+
{
1197+
id: "agent",
1198+
label: "Agent",
1199+
type: "select",
1200+
options: [{ id: "build", label: "Build" }],
1201+
currentValue: "build",
1202+
},
1203+
],
1204+
},
1205+
}),
1206+
model("gpt-5", { isLegacy: true }),
1207+
model("gpt-4", { isLegacy: true }),
1208+
model("gpt-3", { name: "GPT-3", isLegacy: true }),
1209+
model("my-alpha", { isCustom: true }),
1210+
],
1211+
},
1212+
{
1213+
...providerSnapshot({
1214+
instanceId: opencodeInstanceId,
1215+
driver: ProviderDriverKind.make("opencode"),
1216+
}),
1217+
models: [
1218+
...opencodeSlugs.map((slug) => model(slug, { isLegacy: slug === "oc/m03" })),
1219+
model("oc-custom", { isCustom: true }),
1220+
],
1221+
},
1222+
];
1223+
1224+
const capabilitiesWith = (search?: string) =>
1225+
Effect.gen(function* () {
1226+
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1227+
return yield* service.capabilities(scope, search === undefined ? {} : { search });
1228+
}).pipe(
1229+
Effect.provide(
1230+
layerOrchestratorService.pipe(
1231+
Layer.provide(
1232+
Layer.mergeAll(
1233+
NodeServices.layer,
1234+
Layer.mock(ThreadManagementService.ThreadManagementService)({
1235+
getThreadRecords: () =>
1236+
Effect.succeed(
1237+
parentProjection([], { instanceId: codexInstanceId, model: "gpt-3" }),
1238+
),
1239+
}),
1240+
ServerSettings.layerTest({
1241+
favorites: [
1242+
{ provider: codexInstanceId, model: "gpt-4" },
1243+
{ provider: opencodeInstanceId, model: "oc/m10" },
1244+
],
1245+
providerModelPreferences: {
1246+
[opencodeInstanceId]: { hiddenModels: ["oc/m02"], modelOrder: ["oc/m12"] },
1247+
},
1248+
}),
1249+
providerRegistryLayer(catalog),
1250+
adapterRegistryLayer([codexInstanceId, opencodeInstanceId]),
1251+
Layer.mock(ProjectService.ProjectService)({}),
1252+
Layer.mock(SecretRequests.SecretRequests)({}),
1253+
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
1254+
),
1255+
),
1256+
),
1257+
),
1258+
);
1259+
1260+
const listing = (capabilities: OrchestratorMcpCapabilitiesResult) =>
1261+
capabilities.providers.map((provider) => ({
1262+
id: provider.providerInstanceId,
1263+
models: provider.models.map((entry) => entry.id),
1264+
omitted: provider.omittedModels ?? 0,
1265+
}));
1266+
1267+
it.effect(
1268+
"skips legacy models, lists the first 8 of large catalogs, and keeps pinned models",
1269+
() =>
1270+
Effect.gen(function* () {
1271+
assert.deepEqual(listing(yield* capabilitiesWith()), [
1272+
// gpt-4 is a favorite and gpt-3 is the caller's model; legacy gpt-5 is left out.
1273+
{ id: codexInstanceId, models: ["gpt-6", "gpt-4", "gpt-3", "my-alpha"], omitted: 1 },
1274+
{
1275+
id: opencodeInstanceId,
1276+
models: [
1277+
"oc/m12",
1278+
"oc/m01",
1279+
"oc/m04",
1280+
"oc/m05",
1281+
"oc/m06",
1282+
"oc/m07",
1283+
"oc/m08",
1284+
"oc/m09",
1285+
"oc/m10",
1286+
"oc-custom",
1287+
],
1288+
omitted: 2,
1289+
},
1290+
]);
1291+
}),
1292+
);
1293+
1294+
it.effect("search matches every word and caps each provider's matches", () =>
1295+
Effect.gen(function* () {
1296+
assert.deepEqual(listing(yield* capabilitiesWith("GPT 5")), [
1297+
{ id: codexInstanceId, models: ["gpt-5"], omitted: 0 },
1298+
{ id: opencodeInstanceId, models: [], omitted: 0 },
1299+
]);
1300+
const opencode = listing(yield* capabilitiesWith("oc/m"))[1];
1301+
assert.deepEqual(opencode, {
1302+
id: opencodeInstanceId,
1303+
models: ["oc/m12", "oc/m01", "oc/m03", "oc/m04", "oc/m05", "oc/m06", "oc/m07", "oc/m08"],
1304+
omitted: 3,
1305+
});
1306+
}),
1307+
);
1308+
1309+
it.effect("describes models by id, distinct label, and option values", () =>
1310+
Effect.gen(function* () {
1311+
const codex = (yield* capabilitiesWith()).providers[0];
1312+
assert.deepEqual(codex?.models.slice(0, 4), [
1313+
{
1314+
id: "gpt-6",
1315+
label: "Sol",
1316+
options: [
1317+
{ id: "effort", values: ["low", "high"], default: "high" },
1318+
{ id: "fastMode", values: [false, true] },
1319+
{ id: "agent", values: ["build"], default: "build" },
1320+
],
1321+
},
1322+
{ id: "gpt-4" },
1323+
{ id: "gpt-3" },
1324+
{ id: "my-alpha" },
1325+
]);
1326+
}),
1327+
);
1328+
});
1329+
11591330
it.effect("rejects delegation to a provider without a registered adapter", () =>
11601331
Effect.gen(function* () {
11611332
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
@@ -2315,3 +2486,79 @@ describe("OrchestratorMcpService provider resolution", () => {
23152486
);
23162487
});
23172488
});
2489+
2490+
describe("OrchestratorMcpService thread lookup", () => {
2491+
const bareId = ThreadId.make("5d0b4a3e-8c1f-4a52-9d37-2f6c7e1b9a04");
2492+
const launched = liveThreadShell(ThreadId.make(`mcp:${bareId}`));
2493+
const deletedLaunched = { ...launched, deletedAt: DateTime.makeUnsafe("2026-10-05T00:00:00Z") };
2494+
const client: McpInvocationScope = {
2495+
environmentId: EnvironmentId.make("environment:thread-lookup"),
2496+
requestNamespace: "client:thread-lookup",
2497+
thread: undefined,
2498+
client: { sessionId: "thread-lookup", label: "Claude Code", access: "full-access" },
2499+
capabilities: new Set(["orchestration"]),
2500+
issuedAt: 1,
2501+
};
2502+
const service = (shells: ReadonlyArray<OrchestrationV2ThreadShell>, sent: Ref.Ref<number>) =>
2503+
layerOrchestratorService.pipe(
2504+
Layer.provide(
2505+
Layer.mergeAll(
2506+
NodeServices.layer,
2507+
Layer.mock(ThreadManagementService.ThreadManagementService)({
2508+
getThreadShell: (threadId) =>
2509+
Effect.succeed(shells.find((shell) => shell.id === threadId) ?? null),
2510+
sendToThread: () => Ref.update(sent, (count) => count + 1).pipe(Effect.as({} as never)),
2511+
}),
2512+
ServerSettings.layerTest(),
2513+
Layer.mock(ProviderRegistry.ProviderRegistry)({ getProviders: Effect.succeed([]) }),
2514+
Layer.mock(ProviderAdapterRegistry.ProviderAdapterRegistryV2)({
2515+
list: () => Effect.succeed([]),
2516+
}),
2517+
Layer.mock(ProjectService.ProjectService)({}),
2518+
Layer.mock(SecretRequests.SecretRequests)({}),
2519+
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
2520+
),
2521+
),
2522+
);
2523+
const failuresFor = (shells: ReadonlyArray<OrchestrationV2ThreadShell>) =>
2524+
Effect.gen(function* () {
2525+
const sent = yield* Ref.make(0);
2526+
return yield* Effect.gen(function* () {
2527+
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
2528+
const read = yield* mcp.readThread(client, { threadId: bareId }).pipe(Effect.flip);
2529+
const send = yield* mcp
2530+
.sendToThread(client, { threadId: bareId, message: "hello" })
2531+
.pipe(Effect.flip);
2532+
return { read, send, sends: yield* Ref.get(sent) };
2533+
}).pipe(Effect.provide(service(shells, sent)));
2534+
});
2535+
2536+
it.effect("points a bare uuid at the mcp: thread it belongs to", () =>
2537+
Effect.gen(function* () {
2538+
const { read, send, sends } = yield* failuresFor([launched]);
2539+
for (const error of [read, send]) {
2540+
assert.equal(error.code, "thread_not_found");
2541+
assert.include(error.message, `mcp:${bareId}`);
2542+
}
2543+
assert.equal(sends, 0);
2544+
}),
2545+
);
2546+
2547+
it.effect("keeps the plain message for an id that matches nothing", () =>
2548+
Effect.gen(function* () {
2549+
const { read, send } = yield* failuresFor([]);
2550+
assert.equal(read.code, "thread_not_found");
2551+
assert.equal(read.message, `Thread ${bareId} is no longer available.`);
2552+
assert.equal(send.code, "thread_not_found");
2553+
assert.equal(send.message, `Thread ${bareId} was not found.`);
2554+
}),
2555+
);
2556+
2557+
it.effect("does not name an mcp: thread that was deleted", () =>
2558+
Effect.gen(function* () {
2559+
const { read, send } = yield* failuresFor([deletedLaunched]);
2560+
assert.equal(read.message, `Thread ${bareId} is no longer available.`);
2561+
assert.equal(send.message, `Thread ${bareId} was not found.`);
2562+
}),
2563+
);
2564+
});

0 commit comments

Comments
 (0)