mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 06:21:12 +00:00
refactor(setup): share Kiro agent selection (#15586)
This commit is contained in:
1 parent
14971020db
commit
5f226de4ae
2 files changed
+14
-30
No files matched your search
@@ -1067,8 +1067,8 @@ export const readEffectiveClientRegistrationConfiguration = async (
|
||||
sources.push(...upper);
|
||||
|
||||
if (client.name === "kiro" && project.mode !== "ownership") {
|
||||
const ambiguous = kiroAmbiguousAgentFailure(sources, client, platform);
|
||||
if (ambiguous !== undefined) return err(ambiguous);
|
||||
const agent = selectKiroAgentConfigurationPath(sources, client, platform);
|
||||
if (!agent.ok) return agent;
|
||||
}
|
||||
|
||||
const original = projectRegistration(sources, client, platform);
|
||||
@@ -1228,11 +1228,12 @@ const projectViewOfUserRegistration = (
|
||||
};
|
||||
};
|
||||
|
||||
const kiroAmbiguousAgentFailure = (
|
||||
/** Select the agent that defines REA, or report an ambiguous registration. */
|
||||
export const selectKiroAgentConfigurationPath = (
|
||||
sources: readonly ClientConfigurationSource[],
|
||||
client: Pick<SetupClient, "configPath">,
|
||||
platform: NodeJS.Platform,
|
||||
): ClientConfigurationFileError | undefined => {
|
||||
): Result<string | undefined, ClientConfigurationFileError> => {
|
||||
const distinctAgents = [
|
||||
...new Set(
|
||||
sources.flatMap((source) => {
|
||||
@@ -1248,13 +1249,13 @@ const kiroAmbiguousAgentFailure = (
|
||||
}),
|
||||
),
|
||||
];
|
||||
if (distinctAgents.length <= 1) return undefined;
|
||||
return {
|
||||
if (distinctAgents.length <= 1) return ok(distinctAgents[0]);
|
||||
return err({
|
||||
kind: "malformed",
|
||||
path: distinctAgents[0] ?? client.configPath,
|
||||
scope: "user",
|
||||
detail: `Kiro defines ${PRODUCT_IDENTITY.mcpServerKey} in more than one agent file (${distinctAgents.join(", ")}). Kiro loads the selected agent, so the registration stays unchanged until one agent file defines it.`,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const readEffectiveUserConfiguration = async (
|
||||
@@ -1271,12 +1272,12 @@ const readEffectiveUserConfiguration = async (
|
||||
);
|
||||
if (!nativeSources.ok) return nativeSources;
|
||||
if (client.name === "kiro") {
|
||||
const ambiguous = kiroAmbiguousAgentFailure(
|
||||
const agent = selectKiroAgentConfigurationPath(
|
||||
nativeSources.value,
|
||||
client,
|
||||
platform,
|
||||
);
|
||||
if (ambiguous !== undefined) return err(ambiguous);
|
||||
if (!agent.ok) return agent;
|
||||
}
|
||||
const nativeDocument = mergeClientConfigurationDocuments(
|
||||
nativeSources.value,
|
||||
|
||||
Reference in new issue
Block a user