decode_interface_builder returns the complete object, hierarchy and connection graph inline. XLD.app's graph is 6.7 MB (about 1.98M o200k tokens) and Transmission.app's 6.3 MB; over MCP the doubled text and structured content exceed the default response budget, so an agent got a resource_constraint error instead of any answer. Add the established opt-in delivery: omitted or complete detail keeps the complete result and its Evidence ID, while summary retains the complete Evidence and returns every decoded document with node-kind, edge-relation and coverage-status tallies (10k tokens for XLD). inspect_analysis_view kind interface-builder pages documents, nodes, edges or coverage; nodes and edges accept an exact decoded document path, matched against each row's recorded evidence, and an undecoded path is refused. Decoder truncation stays visible on every page. Related cleanup, since the new code repeated it a ninth time: - parseAnalysisViewResult owns parsing a view parent's normalized result with the operation's schema and mapping issues into the view source. - retainedSummaryDelivery owns the preflight/summary hook pair and the shared registration options for artifact, native and managed tools. - openProductionTarget owns the production MCP session test setup. Duplication drops from 3.02% to 2.98% (threshold 3.0%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
3.8 KiB
TypeScript
113 lines
3.8 KiB
TypeScript
import { z } from "zod";
|
|
import type { AnalysisError } from "../analysisErrorBase.js";
|
|
import { flutterResultSchemas } from "../flutter/flutterBuildAnalysis.js";
|
|
import { err, ok, type Result } from "../result.js";
|
|
import { parseAnalysisViewResult } from "./analysisViewParent.js";
|
|
import {
|
|
analysisViewInputError,
|
|
type AnalysisViewParent,
|
|
type AnalysisViewRequest,
|
|
type UnsignedAnalysisView,
|
|
} from "./analysisView.js";
|
|
import {
|
|
completeWithinViewCoverage,
|
|
pageViewCoverage,
|
|
} from "./analysisViewCoverage.js";
|
|
|
|
const aotSchema = flutterResultSchemas.inspect_dart_aot;
|
|
|
|
/** Snapshot identity and original coverage, without unrelated string inventories. */
|
|
export const dartAotSummarySchema = aotSchema.extend({
|
|
string_pool: aotSchema.shape.string_pool
|
|
.omit({ package_uris: true, dart_uris: true, class_like_tokens: true })
|
|
.extend({
|
|
returned_counts: z.strictObject({
|
|
package_uris: z.number().int().nonnegative(),
|
|
dart_uris: z.number().int().nonnegative(),
|
|
class_like_tokens: z.number().int().nonnegative(),
|
|
}),
|
|
}),
|
|
});
|
|
|
|
/** Pages of the producer-returned strings, preserving original order and scope. */
|
|
export const dartAotViewRequestSchema = z.strictObject({
|
|
kind: z.literal("dart-aot"),
|
|
collection: z.enum(["package_uris", "dart_uris", "class_like_tokens"]),
|
|
offset: z.number().int().nonnegative().default(0),
|
|
limit: z.number().int().positive().default(64),
|
|
});
|
|
|
|
export const dartAotViewContextSchema = z.strictObject({
|
|
abi: aotSchema.shape.abi,
|
|
libapp: aotSchema.shape.libapp,
|
|
source_coverage: aotSchema.shape.coverage,
|
|
string_pool: dartAotSummarySchema.shape.string_pool,
|
|
});
|
|
|
|
/** Reuse authenticated AOT Evidence without opening the APK or rescanning its ELF. */
|
|
export const projectDartAotView = (
|
|
parent: AnalysisViewParent,
|
|
view: AnalysisViewRequest,
|
|
): Result<UnsignedAnalysisView, AnalysisError> => {
|
|
if (view.kind !== "summary" && view.kind !== "dart-aot")
|
|
return err(
|
|
analysisViewInputError([
|
|
{
|
|
path: ["view"],
|
|
reason: "invalid_value",
|
|
message: "Dart AOT Evidence supports summary and string-pool pages.",
|
|
},
|
|
]),
|
|
);
|
|
const parsed = parseAnalysisViewResult(aotSchema, parent);
|
|
if (!parsed.ok) return parsed;
|
|
const report = parsed.value;
|
|
const { package_uris, dart_uris, class_like_tokens, ...pool } =
|
|
report.string_pool;
|
|
const string_pool = {
|
|
...pool,
|
|
returned_counts: {
|
|
package_uris: package_uris.length,
|
|
dart_uris: dart_uris.length,
|
|
class_like_tokens: class_like_tokens.length,
|
|
},
|
|
};
|
|
const shared = {
|
|
parent_evidence_id: parent.evidenceId,
|
|
parent_operation: "inspect_dart_aot" as const,
|
|
parent_digest: parent.evidenceId.slice(3),
|
|
artifact: { path: report.target.path, sha256: report.target.sha256 },
|
|
limitations: [...parent.limitations],
|
|
unknowns: [
|
|
"String-pool entries are byte-pattern observations, not recovered typed classes or functions.",
|
|
"Counts ending in _at_least remain lower bounds; exhausting returned strings does not establish a complete snapshot inventory.",
|
|
...(parent.subject == null
|
|
? [
|
|
"The parent has no recorded subject; its normalized target identity cannot be cross-checked against a subject digest.",
|
|
]
|
|
: []),
|
|
],
|
|
};
|
|
if (view.kind === "summary")
|
|
return ok({
|
|
kind: "summary",
|
|
view,
|
|
...shared,
|
|
summary: { ...report, string_pool },
|
|
coverage: completeWithinViewCoverage(1, 1),
|
|
});
|
|
const collection = report.string_pool[view.collection];
|
|
const items = collection.slice(view.offset, view.offset + view.limit);
|
|
return ok({
|
|
kind: "dart-aot",
|
|
view,
|
|
...shared,
|
|
items,
|
|
abi: report.abi,
|
|
libapp: report.libapp,
|
|
source_coverage: report.coverage,
|
|
string_pool,
|
|
coverage: pageViewCoverage(view.offset, items.length, collection.length),
|
|
});
|
|
};
|