feat(javascript): analyze selected application sources
Analyze exact selected sources in first-request order before unrelated static scopes, preserving full artifact identity and byte verification. Retain selection in CLI/MCP Evidence and summaries, with explicit unknowns and partial coverage for unselected sources. Keep default full analysis. Fixes #1848 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Kaoru0822
parent
0d8b728d24
commit
85c1d2587a
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { javaScriptSourceSelectionSchema } from "../javascript/javascriptSourceSelection.js";
|
||||
|
||||
import {
|
||||
AnalysisInputError,
|
||||
@@ -170,6 +171,7 @@ const javascriptSummarySchema = z.strictObject({
|
||||
input_path: z.string().min(1),
|
||||
format: z.enum(["asar", "directory"]),
|
||||
root_artifact_sha256: digestSchema,
|
||||
source_selection: javaScriptSourceSelectionSchema.exactOptional(),
|
||||
statistics: jsonObjectSchema,
|
||||
electron: jsonObjectSchema,
|
||||
coverage: jsonObjectSchema,
|
||||
|
||||
@@ -255,6 +255,11 @@ export const projectJavaScriptApplicationView = (
|
||||
input_path: analysis.input_path,
|
||||
format: analysis.format,
|
||||
root_artifact_sha256: analysis.root_artifact_sha256,
|
||||
...(analysis.source_selection === undefined
|
||||
? {}
|
||||
: {
|
||||
source_selection: analysis.source_selection,
|
||||
}),
|
||||
statistics: jsonObjectSchema.parse(analysis.statistics),
|
||||
electron: jsonObjectSchema.parse(analysis.summary),
|
||||
coverage: jsonObjectSchema.parse({
|
||||
|
||||
@@ -16,6 +16,10 @@ import { integrityContradictionSchema } from "../artifactGraph.js";
|
||||
import { artifactIntegrityPolicySchema } from "../artifactIntegrityPolicy.js";
|
||||
import { localPathStringSchema } from "../localPath.js";
|
||||
import { javaScriptAnalysisResourceControlsSchema } from "./javascriptAnalysisResourceControls.js";
|
||||
import {
|
||||
javaScriptSourcePathsSchema,
|
||||
javaScriptSourceSelectionSchema,
|
||||
} from "./javascriptSourceSelection.js";
|
||||
|
||||
const countSchema = z.number().int().min(0);
|
||||
|
||||
@@ -24,6 +28,7 @@ export const analyzeJavaScriptApplicationInputSchema = z.strictObject({
|
||||
input_path: localPathStringSchema,
|
||||
format: z.enum(["auto", "asar", "directory"]).default("auto"),
|
||||
integrity_policy: artifactIntegrityPolicySchema,
|
||||
source_paths: javaScriptSourcePathsSchema.optional(),
|
||||
...javaScriptAnalysisResourceControlsSchema.shape,
|
||||
});
|
||||
|
||||
@@ -71,6 +76,7 @@ const applicationAnalysisResultShape = z.strictObject({
|
||||
inventory_manifest_id: prefixedDigestSchema("agm"),
|
||||
inventory_graph_sha256: digestSchema,
|
||||
integrity_contradictions: z.array(integrityContradictionSchema),
|
||||
source_selection: javaScriptSourceSelectionSchema.exactOptional(),
|
||||
graph: javascriptApplicationGraphSchema,
|
||||
summary: electronBoundarySummarySchema,
|
||||
statistics: reconstructionStatisticsSchema,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { JavaScriptSourceSelection } from "./javascriptSourceSelection.js";
|
||||
|
||||
/** Relevant file categories projected from the complete artifact inventory. */
|
||||
export type JavaScriptArtifactFileKind =
|
||||
| "package-json"
|
||||
@@ -20,7 +22,10 @@ export interface JavaScriptArtifactFile {
|
||||
| { readonly included: true; readonly value: string }
|
||||
| {
|
||||
readonly included: false;
|
||||
readonly reason: "not-applicable" | "invalid-utf8";
|
||||
readonly reason:
|
||||
| "not-applicable"
|
||||
| "invalid-utf8"
|
||||
| "outside-analysis-scope";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,4 +43,5 @@ export interface JavaScriptArtifactFileSet {
|
||||
readonly containers: readonly JavaScriptArtifactContainer[];
|
||||
readonly text_bytes_read: number;
|
||||
readonly invalid_utf8_files: number;
|
||||
readonly source_selection?: JavaScriptSourceSelection;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/** Exact inventoried paths selected for text acquisition and static analysis. */
|
||||
export const javaScriptSourcePathsSchema = z
|
||||
.array(z.string().min(1))
|
||||
.min(1)
|
||||
.describe(
|
||||
"Exact relevant file paths from the artifact inventory, relative to the application root, analyzed in first-request order before unselected scopes; no globs or implicit dependencies. Omit to analyze all sources.",
|
||||
);
|
||||
|
||||
/** Caller scope retained independently of analysis success or completeness. */
|
||||
export const javaScriptSourceSelectionSchema = z.strictObject({
|
||||
requested_paths: javaScriptSourcePathsSchema,
|
||||
unselected_files: z.number().int().min(0),
|
||||
});
|
||||
|
||||
/** Explicit selected-source boundary for an otherwise complete inventory. */
|
||||
export type JavaScriptSourceSelection = z.infer<
|
||||
typeof javaScriptSourceSelectionSchema
|
||||
>;
|
||||
Reference in New Issue
Block a user