mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 19:51:20 -05:00
a67525cdf1
* docs: organize canonical documentation layout (URGENTE) Group all existing authored guides by domain and ownership, expose complete navigation, and preserve their public routes. Update physical path consumers and release configuration while retaining historical records. Document domain-based specs and ADR slugs without global numbering. Co-Authored-By: Codex <noreply@openai.com> * fix(docs): honor home layout in all-page route verification * style: format reviewed source changes * fix(docs): preserve routes and navigation cache inputs * fix: repair the static-check failures on the default branch (#2895) * fix: repair the static-check failures on the default branch The default branch fails its own required `Static checks` job three ways, so every pull request reports that job as failed regardless of its own change. - `npm run format:check` reports `src/domain/functionComparison.test.ts` and `src/ida/IdaOperationRunner.ts`. - `npm run lint` reports a duplicate `import { join } from "node:path"` in `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17). - `npm run typecheck` reports `format: "devin"` missing from the client format union in `src/application/SupportedClients.ts`, and an unchecked index in `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is inferred as `string[][]`. Apply the pinned formatter, drop the duplicate import, list the `"devin"` format that its own definition already uses, and mark the pair array `as const`. Validation: `npm run check:fast` and `npm run format:check` pass. * fix(setup): keep Devin on the JSON configuration dialect --------- Co-authored-by: 吴佳浩 <wujiahao@supremind.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> * fix(docs): update links after guide relocation * docs: correct verified documentation route counts * fix(docs): update browser capture guide link after move (#2820) Refresh gettext protected-link comments alongside the authored href. Co-authored-by: Codex <noreply@openai.com> * fix(docs): include http3 lab in stable routes * fix(docs): preserve historical release evidence and links * fix(ghidra): restore Windows verifier identity import * docs(wakaru): preserve pinned upstream policy link * docs(index): retain recently added guide links * docs(mcp): preserve parent retention clarification * fix(cli): preserve standalone import guidance * fix(test): preserve translated guide link drift coverage --------- Co-authored-by: Matheus Breguêz <matbrgz@gmail.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: morluto <17176810+morluto@users.noreply.github.com> Co-authored-by: 吴佳浩Alben <35291372+XiaoBinGan@users.noreply.github.com> Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
214 lines
7.2 KiB
TypeScript
214 lines
7.2 KiB
TypeScript
import { z } from "zod";
|
|
import { RegularFileCleanupFailure } from "../filesystem/OwnedRegularFile.js";
|
|
|
|
import {
|
|
readClientRegistrationInspections,
|
|
type ClientRegistrationStatus,
|
|
} from "./ClientRegistrationStatus.js";
|
|
import {
|
|
existingSkillDestinations,
|
|
type SkillPathIssue,
|
|
} from "./SetupSkill.js";
|
|
import type { SetupAction } from "./SetupTypes.js";
|
|
import type { Result } from "../domain/result.js";
|
|
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
|
|
|
/** Existing REA integrations selected for maintenance, without discovering new targets. */
|
|
export interface MaintenanceScope {
|
|
readonly clients: readonly string[];
|
|
readonly skill: boolean;
|
|
readonly unresolved?: readonly ClientRegistrationStatus[];
|
|
readonly skillIssues?: readonly SkillPathIssue[];
|
|
readonly skillDestinations?: readonly {
|
|
readonly client: string;
|
|
readonly path: string;
|
|
}[];
|
|
}
|
|
|
|
/** Unapplied maintenance evidence produced by the updated setup executable. */
|
|
export type IntegrationMaintenance =
|
|
| { readonly status: "current"; readonly plannedActions: readonly [] }
|
|
| {
|
|
readonly status: "planned";
|
|
readonly scope: MaintenanceScope;
|
|
readonly command: readonly string[];
|
|
readonly plannedActions: readonly SetupAction[];
|
|
}
|
|
| {
|
|
readonly status: "unavailable";
|
|
readonly remediation: string;
|
|
readonly scope?: MaintenanceScope;
|
|
};
|
|
|
|
const setupPlanSchema = z.object({
|
|
status: z.literal("planned"),
|
|
plannedActions: z.array(
|
|
z.object({
|
|
id: z.string(),
|
|
kind: z.enum(["configure_client", "install_skill"]),
|
|
label: z.string(),
|
|
target: z.string(),
|
|
detail: z.string(),
|
|
external: z.literal(false),
|
|
operation: z.enum(["create", "update", "install"]),
|
|
backupPath: z.string().optional(),
|
|
commands: z.array(z.string()).optional(),
|
|
}),
|
|
),
|
|
});
|
|
|
|
/** Discover owned registrations and REA skills without writes. */
|
|
export const existingMaintenanceScope = async (
|
|
home: string,
|
|
entryPoint: string,
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
resources?: ArtifactResourceScope,
|
|
): Promise<MaintenanceScope> => {
|
|
const registrations = await readClientRegistrationInspections(
|
|
home,
|
|
entryPoint,
|
|
{
|
|
environment,
|
|
// A registration REA wrote must be refreshed even when the product
|
|
// profile is absent, so maintenance reads ownership evidence instead of
|
|
// product applicability. Owned rows stay the only ones selected below.
|
|
evidence: "ownership",
|
|
...(resources === undefined ? {} : { resources }),
|
|
},
|
|
);
|
|
const clients: string[] = [];
|
|
const unresolved: ClientRegistrationStatus[] = [];
|
|
for (const {
|
|
status: registration,
|
|
activation,
|
|
commandIdentity,
|
|
} of registrations) {
|
|
if (registration.state === "unknown" || registration.state === "invalid") {
|
|
unresolved.push(registration);
|
|
continue;
|
|
}
|
|
if (
|
|
activation !== "enabled" ||
|
|
(registration.state !== "aligned" && registration.state !== "stale") ||
|
|
commandIdentity !== "owned"
|
|
)
|
|
continue;
|
|
clients.push(registration.client);
|
|
}
|
|
// Each setup action rewrites only that client's own configuration path, so
|
|
// maintenance keeps every selected client instead of deferring one view of
|
|
// a registration to another client's inspection: ZCode writes
|
|
// ~/.zcode/cli/config.json and deliberately leaves the ~/.agents/mcp.json
|
|
// fallback untouched (docs/getting-started/client-configuration.md), while FreeBuff writes
|
|
// the shared file itself. Dropping FreeBuff because ZCode reads that
|
|
// fallback would leave the row both products load pinned to the old
|
|
// version.
|
|
const skills = await existingSkillDestinations(
|
|
home,
|
|
environment,
|
|
process.platform,
|
|
resources,
|
|
);
|
|
return {
|
|
clients,
|
|
skill: skills.destinations.length > 0,
|
|
skillDestinations: skills.destinations,
|
|
...(skills.issues.length === 0 ? {} : { skillIssues: skills.issues }),
|
|
...(unresolved.length === 0 ? {} : { unresolved }),
|
|
};
|
|
};
|
|
|
|
/** Ask the verified new executable to plan only existing REA integrations. */
|
|
export const planIntegrationMaintenance = async (
|
|
home: string,
|
|
entryPoint: string,
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
execute: (command: readonly string[]) => Promise<Result<string, string>>,
|
|
resources?: ArtifactResourceScope,
|
|
): Promise<IntegrationMaintenance> => {
|
|
try {
|
|
const scope = await existingMaintenanceScope(
|
|
home,
|
|
entryPoint,
|
|
environment,
|
|
resources,
|
|
);
|
|
if (
|
|
(scope.unresolved?.length ?? 0) > 0 ||
|
|
(scope.skillIssues?.length ?? 0) > 0
|
|
)
|
|
return {
|
|
status: "unavailable",
|
|
scope,
|
|
remediation: `Integration maintenance is unresolved: ${[
|
|
...(scope.unresolved ?? []).map(
|
|
({ client, config_path, remediation }) =>
|
|
`${client} (${config_path}): ${remediation ?? "Registration identity is unresolved"}`,
|
|
),
|
|
...(scope.skillIssues ?? []).map(
|
|
({ client, path, detail }) =>
|
|
`${client ?? "skill"} (${path}): ${detail}`,
|
|
),
|
|
].join(" ")}`,
|
|
};
|
|
const skillDestinations = scope.skillDestinations ?? [];
|
|
if (scope.clients.length === 0 && !scope.skill)
|
|
return { status: "current", plannedActions: [] };
|
|
const command = [
|
|
process.execPath,
|
|
entryPoint,
|
|
"setup",
|
|
...scope.clients.flatMap((client) => ["--client", client]),
|
|
...skillDestinations.flatMap(({ client }) => ["--skill-client", client]),
|
|
`--skill=${String(scope.skill)}`,
|
|
];
|
|
const execution = await execute([...command, "--dry-run", "--json"]);
|
|
if (!execution.ok)
|
|
return { status: "unavailable", remediation: execution.error };
|
|
const plan = setupPlanSchema.safeParse(JSON.parse(execution.value));
|
|
if (!plan.success)
|
|
return {
|
|
status: "unavailable",
|
|
remediation: `The updated setup executable returned an invalid maintenance plan: ${plan.error.message}`,
|
|
};
|
|
if (plan.data.plannedActions.length === 0)
|
|
return { status: "current", plannedActions: [] };
|
|
const allowedIds = new Set(
|
|
scope.clients.map((client) => `configure_client:${client}`),
|
|
);
|
|
const skillTargets = new Set(skillDestinations.map(({ path }) => path));
|
|
if (
|
|
plan.data.plannedActions.some((action) =>
|
|
action.kind === "install_skill"
|
|
? !skillTargets.has(action.target)
|
|
: !allowedIds.has(action.id),
|
|
)
|
|
)
|
|
return {
|
|
status: "unavailable",
|
|
remediation:
|
|
"The updated setup plan included an integration outside the existing REA maintenance scope.",
|
|
};
|
|
return {
|
|
status: "planned",
|
|
scope,
|
|
command,
|
|
plannedActions: plan.data.plannedActions.map(
|
|
({ backupPath, commands, ...action }) => ({
|
|
...action,
|
|
...(backupPath === undefined ? {} : { backupPath }),
|
|
...(commands === undefined ? {} : { commands }),
|
|
}),
|
|
),
|
|
};
|
|
} catch (cause: unknown) {
|
|
// Without a supplied scope, the typed failure is the caller's cleanup capability.
|
|
if (resources === undefined && cause instanceof RegularFileCleanupFailure)
|
|
throw cause;
|
|
return {
|
|
status: "unavailable",
|
|
remediation: cause instanceof Error ? cause.message : String(cause),
|
|
};
|
|
}
|
|
};
|