@pretorian-worx/runclaudia-core 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/adapters/nextjs.d.ts +27 -0
- package/dist/adapters/nextjs.js +457 -0
- package/dist/adapters/nextjs.js.map +1 -0
- package/dist/adapters/prisma.d.ts +22 -0
- package/dist/adapters/prisma.js +80 -0
- package/dist/adapters/prisma.js.map +1 -0
- package/dist/adapters/specs.d.ts +13 -0
- package/dist/adapters/specs.js +126 -0
- package/dist/adapters/specs.js.map +1 -0
- package/dist/adapters/terraform.d.ts +17 -0
- package/dist/adapters/terraform.js +82 -0
- package/dist/adapters/terraform.js.map +1 -0
- package/dist/diff.d.ts +13 -0
- package/dist/diff.js +187 -0
- package/dist/diff.js.map +1 -0
- package/dist/gating.d.ts +29 -0
- package/dist/gating.js +59 -0
- package/dist/gating.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +24 -0
- package/dist/llm.js +135 -0
- package/dist/llm.js.map +1 -0
- package/dist/map.d.ts +9 -0
- package/dist/map.js +55 -0
- package/dist/map.js.map +1 -0
- package/dist/plan-format.d.ts +3 -0
- package/dist/plan-format.js +71 -0
- package/dist/plan-format.js.map +1 -0
- package/dist/plan.d.ts +21 -0
- package/dist/plan.js +44 -0
- package/dist/plan.js.map +1 -0
- package/dist/prompt.d.ts +40 -0
- package/dist/prompt.js +266 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runner.d.ts +53 -0
- package/dist/runner.js +119 -0
- package/dist/runner.js.map +1 -0
- package/dist/select.d.ts +31 -0
- package/dist/select.js +108 -0
- package/dist/select.js.map +1 -0
- package/dist/types.d.ts +176 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface FileChange {
|
|
3
|
+
path: string;
|
|
4
|
+
status: "added" | "modified" | "deleted" | "renamed";
|
|
5
|
+
oldPath?: string;
|
|
6
|
+
additions: number;
|
|
7
|
+
deletions: number;
|
|
8
|
+
hunks: string[];
|
|
9
|
+
binary: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface Diff {
|
|
12
|
+
base: string;
|
|
13
|
+
head: string;
|
|
14
|
+
files: FileChange[];
|
|
15
|
+
}
|
|
16
|
+
export interface RouteEntry {
|
|
17
|
+
route: string;
|
|
18
|
+
files: string[];
|
|
19
|
+
}
|
|
20
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
21
|
+
export interface EndpointEntry {
|
|
22
|
+
/** URL path including the method prefix, e.g. "POST /api/bugs/move" */
|
|
23
|
+
route: string;
|
|
24
|
+
/** Bare URL path, e.g. "/api/bugs/move" */
|
|
25
|
+
path: string;
|
|
26
|
+
method: HttpMethod;
|
|
27
|
+
/** Source file that defines this handler. */
|
|
28
|
+
file: string;
|
|
29
|
+
/** Best-effort guess at the request body shape, e.g. "json", "formData", "text", or null if no body parsing detected. */
|
|
30
|
+
bodyShape: "json" | "formData" | "text" | "arrayBuffer" | null;
|
|
31
|
+
/** Files statically detected to call this endpoint (fetch/axios/SWR). Best-effort. */
|
|
32
|
+
callers: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Cloud services this endpoint touches, inferred from `@aws-sdk/client-*`
|
|
35
|
+
* imports in the handler source. E.g. ["s3", "dynamodb"]. Best-effort.
|
|
36
|
+
*/
|
|
37
|
+
services: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Database model/table names this endpoint touches, inferred from ORM
|
|
40
|
+
* client usage in the handler source (e.g. `prisma.bug.create(...)` →
|
|
41
|
+
* `["Bug"]`). Names are the canonical schema-side names. Best-effort.
|
|
42
|
+
*/
|
|
43
|
+
tables: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface DbModelEntry {
|
|
46
|
+
/** ORM that owns this model. */
|
|
47
|
+
orm: "prisma";
|
|
48
|
+
/** Canonical model name as declared in the schema (PascalCase for Prisma). */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Schema file that declares this model. */
|
|
51
|
+
file: string;
|
|
52
|
+
}
|
|
53
|
+
export interface SpecEntry {
|
|
54
|
+
/** Test framework this spec was written for. */
|
|
55
|
+
framework: "playwright" | "cypress";
|
|
56
|
+
/** Spec file (relative to rootDir). */
|
|
57
|
+
file: string;
|
|
58
|
+
/** Test name from `test("name", ...)` / `it("name", ...)`. */
|
|
59
|
+
name: string;
|
|
60
|
+
/** URL paths the spec visits (page.goto, cy.visit). */
|
|
61
|
+
routesCovered: string[];
|
|
62
|
+
/** Method-prefixed endpoint routes the spec calls directly (e.g. "POST /api/bugs"). */
|
|
63
|
+
endpointsCovered: string[];
|
|
64
|
+
/**
|
|
65
|
+
* True if the spec lives inside a describe block with a beforeAll / before()
|
|
66
|
+
* hook — selecting one test from such a block requires running the whole
|
|
67
|
+
* describe to honor the setup. Flagged for downstream Stage C selection logic.
|
|
68
|
+
*/
|
|
69
|
+
hasSharedSetup: boolean;
|
|
70
|
+
/** Explicit `// @claudia flow: <name>` annotation overriding heuristic coverage. */
|
|
71
|
+
flowAnnotations: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface InfraEntry {
|
|
74
|
+
/** IaC tool that defines this resource. */
|
|
75
|
+
tool: "terraform";
|
|
76
|
+
/** Terraform resource type, e.g. "aws_s3_bucket". */
|
|
77
|
+
type: string;
|
|
78
|
+
/** Local name from the resource declaration, e.g. "attachments". */
|
|
79
|
+
name: string;
|
|
80
|
+
/** Address-style identifier, e.g. "aws_s3_bucket.attachments". */
|
|
81
|
+
address: string;
|
|
82
|
+
/** File that declares this resource. */
|
|
83
|
+
file: string;
|
|
84
|
+
}
|
|
85
|
+
export interface AppMap {
|
|
86
|
+
framework: "nextjs-app" | "unknown";
|
|
87
|
+
generatedAt: string;
|
|
88
|
+
rootDir: string;
|
|
89
|
+
routes: RouteEntry[];
|
|
90
|
+
endpoints: EndpointEntry[];
|
|
91
|
+
infra: InfraEntry[];
|
|
92
|
+
dbModels: DbModelEntry[];
|
|
93
|
+
specs: SpecEntry[];
|
|
94
|
+
fileToRoutes: Record<string, string[]>;
|
|
95
|
+
/** Reverse index: file path → endpoint route strings (e.g. "POST /api/bugs") that file calls. */
|
|
96
|
+
fileToEndpoints: Record<string, string[]>;
|
|
97
|
+
/** Reverse index: file path → infra resource addresses declared in that file. */
|
|
98
|
+
fileToInfra: Record<string, string[]>;
|
|
99
|
+
/** Reverse index: file path → DB model names declared in that file. */
|
|
100
|
+
fileToTables: Record<string, string[]>;
|
|
101
|
+
/** Reverse index: spec file path → list of test names declared in that file. */
|
|
102
|
+
fileToSpecs: Record<string, string[]>;
|
|
103
|
+
}
|
|
104
|
+
export declare const PlanFlowSchema: z.ZodObject<{
|
|
105
|
+
name: z.ZodString;
|
|
106
|
+
routes: z.ZodArray<z.ZodString, "many">;
|
|
107
|
+
risk: z.ZodEnum<["low", "medium", "high"]>;
|
|
108
|
+
reasoning: z.ZodString;
|
|
109
|
+
suggestedChecks: z.ZodArray<z.ZodString, "many">;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
name: string;
|
|
112
|
+
routes: string[];
|
|
113
|
+
risk: "low" | "medium" | "high";
|
|
114
|
+
reasoning: string;
|
|
115
|
+
suggestedChecks: string[];
|
|
116
|
+
}, {
|
|
117
|
+
name: string;
|
|
118
|
+
routes: string[];
|
|
119
|
+
risk: "low" | "medium" | "high";
|
|
120
|
+
reasoning: string;
|
|
121
|
+
suggestedChecks: string[];
|
|
122
|
+
}>;
|
|
123
|
+
export declare const PlanSchema: z.ZodObject<{
|
|
124
|
+
verdict: z.ZodEnum<["test", "skip"]>;
|
|
125
|
+
skipReason: z.ZodOptional<z.ZodString>;
|
|
126
|
+
summary: z.ZodString;
|
|
127
|
+
flows: z.ZodArray<z.ZodObject<{
|
|
128
|
+
name: z.ZodString;
|
|
129
|
+
routes: z.ZodArray<z.ZodString, "many">;
|
|
130
|
+
risk: z.ZodEnum<["low", "medium", "high"]>;
|
|
131
|
+
reasoning: z.ZodString;
|
|
132
|
+
suggestedChecks: z.ZodArray<z.ZodString, "many">;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
name: string;
|
|
135
|
+
routes: string[];
|
|
136
|
+
risk: "low" | "medium" | "high";
|
|
137
|
+
reasoning: string;
|
|
138
|
+
suggestedChecks: string[];
|
|
139
|
+
}, {
|
|
140
|
+
name: string;
|
|
141
|
+
routes: string[];
|
|
142
|
+
risk: "low" | "medium" | "high";
|
|
143
|
+
reasoning: string;
|
|
144
|
+
suggestedChecks: string[];
|
|
145
|
+
}>, "many">;
|
|
146
|
+
unmappedFiles: z.ZodArray<z.ZodString, "many">;
|
|
147
|
+
coverageGaps: z.ZodArray<z.ZodString, "many">;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
verdict: "test" | "skip";
|
|
150
|
+
summary: string;
|
|
151
|
+
flows: {
|
|
152
|
+
name: string;
|
|
153
|
+
routes: string[];
|
|
154
|
+
risk: "low" | "medium" | "high";
|
|
155
|
+
reasoning: string;
|
|
156
|
+
suggestedChecks: string[];
|
|
157
|
+
}[];
|
|
158
|
+
unmappedFiles: string[];
|
|
159
|
+
coverageGaps: string[];
|
|
160
|
+
skipReason?: string | undefined;
|
|
161
|
+
}, {
|
|
162
|
+
verdict: "test" | "skip";
|
|
163
|
+
summary: string;
|
|
164
|
+
flows: {
|
|
165
|
+
name: string;
|
|
166
|
+
routes: string[];
|
|
167
|
+
risk: "low" | "medium" | "high";
|
|
168
|
+
reasoning: string;
|
|
169
|
+
suggestedChecks: string[];
|
|
170
|
+
}[];
|
|
171
|
+
unmappedFiles: string[];
|
|
172
|
+
coverageGaps: string[];
|
|
173
|
+
skipReason?: string | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
export type PlanFlow = z.infer<typeof PlanFlowSchema>;
|
|
176
|
+
export type Plan = z.infer<typeof PlanSchema>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const PlanFlowSchema = z.object({
|
|
3
|
+
name: z.string().describe("Short user-facing name of the flow, e.g. 'Checkout' or 'Sign-in'"),
|
|
4
|
+
routes: z.array(z.string()).describe("URL paths the flow exercises"),
|
|
5
|
+
risk: z.enum(["low", "medium", "high"]),
|
|
6
|
+
reasoning: z.string().describe("Why this flow is implicated by the diff. Cite specific files."),
|
|
7
|
+
suggestedChecks: z.array(z.string()).describe("Concrete checks a tester should perform"),
|
|
8
|
+
});
|
|
9
|
+
export const PlanSchema = z.object({
|
|
10
|
+
verdict: z.enum(["test", "skip"]),
|
|
11
|
+
skipReason: z.string().optional(),
|
|
12
|
+
summary: z.string().describe("One-paragraph summary of what changed and what to test"),
|
|
13
|
+
flows: z.array(PlanFlowSchema),
|
|
14
|
+
unmappedFiles: z.array(z.string()).describe("Changed files not associated with any known flow"),
|
|
15
|
+
coverageGaps: z.array(z.string()).describe("Risks not covered by any inferred flow"),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiHxB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kEAAkE,CAAC;IAC7F,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACpE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;IAC/F,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CACzF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;IACtF,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;IAC9B,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IAC/F,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC;CACrF,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pretorian-worx/runclaudia-core",
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "Core library for claudia — diff parser, framework adapters (Next.js / Terraform / Prisma / Playwright), prompt builder, Anthropic SDK wrapper, plan + selection + gating + runner primitives. Consumed by @pretorian-worx/runclaudia-cli and the runclaudia GitHub Action.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Paul Schneider",
|
|
8
|
+
"homepage": "https://github.com/pretorian-worx/runclaudia#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/pretorian-worx/runclaudia/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/pretorian-worx/runclaudia.git",
|
|
15
|
+
"directory": "packages/core"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ci",
|
|
19
|
+
"testing",
|
|
20
|
+
"playwright",
|
|
21
|
+
"post-deploy",
|
|
22
|
+
"diff",
|
|
23
|
+
"qa",
|
|
24
|
+
"claude",
|
|
25
|
+
"anthropic"
|
|
26
|
+
],
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@anthropic-ai/sdk": "^0.40.0",
|
|
42
|
+
"zod": "^3.23.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "^5.6.0",
|
|
46
|
+
"vitest": "^2.1.0",
|
|
47
|
+
"@types/node": "^22.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
53
|
+
}
|
|
54
|
+
}
|