@methiu/raigal 1.0.1 → 1.0.3

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.
@@ -20,11 +20,21 @@ const resolveRaigalRunRequest = (framework, options = {}) => {
20
20
  };
21
21
  };
22
22
  const runRaigal = async (request) => new Promise((resolve) => {
23
- spawn(request.bin, request.args, {
23
+ const child = spawn(request.bin, request.args, {
24
24
  cwd: request.cwd,
25
25
  env: request.env,
26
26
  stdio: "inherit"
27
- }).on("close", (exitCode, signal) => {
27
+ });
28
+ child.on("error", () => {
29
+ resolve({
30
+ command: request.bin,
31
+ args: request.args,
32
+ exitCode: 1,
33
+ signal: null,
34
+ skipped: false
35
+ });
36
+ });
37
+ child.on("close", (exitCode, signal) => {
28
38
  resolve({
29
39
  command: request.bin,
30
40
  args: request.args,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as APP_VERSION } from "./version-om7oAIVO.js";
1
+ import { t as APP_VERSION } from "./version-gBpAhuDc.js";
2
2
  import { a as getEngineLabel, i as ENGINE_INFO, r as scoreImpactForRule, t as summarizeFindingAssessments } from "./finding-assessment-M5fUTE-C.js";
3
3
  import { n as isSecretClassRule, r as maskSecrets, t as FIXED_SECRET_DIAGNOSTIC_MESSAGE } from "./mask-secrets-BXn-ZSEh.js";
4
4
  import { createRequire, isBuiltin } from "node:module";
@@ -15803,7 +15803,8 @@ const Finding = z.object({
15803
15803
  severity: Severity,
15804
15804
  path: z.string().max(500),
15805
15805
  line: z.number().int().nonnegative(),
15806
- fingerprint: z.string().length(32)
15806
+ fingerprint: z.string().length(32),
15807
+ message: z.string().max(500).optional()
15807
15808
  });
15808
15809
  const RepoRef = z.object({
15809
15810
  provider: z.literal("github"),
@@ -15818,12 +15819,21 @@ const Step = z.object({
15818
15819
  ms: z.number().int().nonnegative(),
15819
15820
  counts: z.record(z.string(), z.number()).optional()
15820
15821
  });
15822
+ const AgentTelemetry = z.object({
15823
+ provider: z.string().max(80),
15824
+ before_score: z.number().min(0).max(100).nullable(),
15825
+ after_score: z.number().min(0).max(100).nullable(),
15826
+ pr_url: z.string().url().max(500).optional(),
15827
+ patch_diff: z.string().max(2e4).optional(),
15828
+ duration_ms: z.number().int().nonnegative().optional()
15829
+ });
15821
15830
  const Report = z.object({
15822
15831
  score: z.number().min(0).max(100).nullable(),
15823
15832
  scoreable: z.boolean(),
15824
15833
  engine_scores: z.record(z.string(), z.number()).optional(),
15825
15834
  files_scanned: z.number().int().nonnegative(),
15826
- findings: z.array(Finding).max(5e3)
15835
+ findings: z.array(Finding).max(5e3),
15836
+ agent_telemetry: AgentTelemetry.optional()
15827
15837
  });
15828
15838
  z.object({
15829
15839
  run_id: z.uuid(),
@@ -15840,7 +15850,13 @@ z.object({
15840
15850
  branch: z.string().max(200).optional(),
15841
15851
  head_sha: z.string().max(64).optional(),
15842
15852
  base_ref: z.string().max(200).optional(),
15843
- pr_number: z.number().int().optional()
15853
+ pr_number: z.number().int().optional(),
15854
+ diff_summary: z.object({
15855
+ files_changed: z.number().int().nonnegative(),
15856
+ additions: z.number().int().nonnegative(),
15857
+ deletions: z.number().int().nonnegative()
15858
+ }).optional(),
15859
+ diff_preview: z.string().max(1e4).optional()
15844
15860
  }),
15845
15861
  ci: z.object({
15846
15862
  provider: z.string().max(40),
@@ -15856,7 +15872,8 @@ z.object({
15856
15872
  ended_at: z.iso.datetime(),
15857
15873
  exit_code: z.number().int(),
15858
15874
  steps: z.array(Step).max(200),
15859
- report: Report.optional()
15875
+ report: Report.optional(),
15876
+ agent_telemetry: AgentTelemetry.optional()
15860
15877
  });
15861
15878
  const Policy = z.object({
15862
15879
  version: z.number().int(),
@@ -16051,7 +16068,7 @@ const verifyEntitlementJwt = (jwt, options = {}) => {
16051
16068
  const claims = parsed.data;
16052
16069
  const expectedIssuer = process.env.RAIGAL_ISSUER?.trim() || "https://app.raigal.dev";
16053
16070
  if (claims.iss !== expectedIssuer) throw new JwtVerificationError(`Untrusted issuer: ${claims.iss}`, "invalid_issuer");
16054
- if (!isVersionAtLeast("1.0.1", claims.min_cli_version)) throw new JwtVerificationError(`CLI version ${APP_VERSION} is below required minimum ${claims.min_cli_version}. Run "raigal update" or "npm install -g @methiu/raigal@latest".`, "cli_version_unsupported");
16071
+ if (!isVersionAtLeast("1.0.3", claims.min_cli_version)) throw new JwtVerificationError(`CLI version ${APP_VERSION} is below required minimum ${claims.min_cli_version}. Run "raigal update" or "npm install -g @methiu/raigal@latest".`, "cli_version_unsupported");
16055
16072
  const now = options.nowSeconds ?? Math.floor(Date.now() / 1e3);
16056
16073
  const grace = options.allowGraceSeconds ?? 0;
16057
16074
  if (now > claims.exp + grace) {
@@ -16218,7 +16235,7 @@ const getEntitlement = async () => {
16218
16235
  };
16219
16236
  //#endregion
16220
16237
  //#region src/cloud/owner.ts
16221
- const GITHUB_REMOTE_RE = /^(?:git@github\.com:|https:\/\/(?:[^@]+@)?github\.com\/)([^/]+)\/([^/.\s]+?)(?:\.git)?\s*$/;
16238
+ const GITHUB_REMOTE_RE = /^(?:(?:git@|ssh:\/\/(?:git@)?)github\.com(?::(?:\d+\/)?|[:/])|https:\/\/(?:[^@]+@)?github\.com\/)([^/]+)\/([^/.\s]+?)(?:\.git)?\s*$/;
16222
16239
  const parseGitRemote = (rawUrl) => {
16223
16240
  if (!rawUrl) return {
16224
16241
  owner: null,
@@ -17916,6 +17933,17 @@ const detectRepoRef = (directory, ownerId) => {
17916
17933
  };
17917
17934
  };
17918
17935
  //#endregion
17936
+ //#region src/output/rule-message.ts
17937
+ /**
17938
+ * Pure deterministic formatter for diagnostic messages.
17939
+ * Secret-class rules (or redactSource: true) unconditionally return FIXED_SECRET_DIAGNOSTIC_MESSAGE.
17940
+ * Non-secret rules return diagnostic.message (clamped to max 500 chars).
17941
+ */
17942
+ const formatFindingMessage = (diagnostic) => {
17943
+ if (diagnostic.redactSource || isSecretClassRule(diagnostic.rule)) return FIXED_SECRET_DIAGNOSTIC_MESSAGE;
17944
+ return diagnostic.message.slice(0, 500);
17945
+ };
17946
+ //#endregion
17919
17947
  //#region src/cloud/fingerprint.ts
17920
17948
  /**
17921
17949
  * Normalizes line text: trims leading/trailing whitespace and compresses
@@ -17955,7 +17983,8 @@ const toContractFinding = (diagnostic, rootDirectory, lineTextOverride) => {
17955
17983
  severity,
17956
17984
  path: relativePath,
17957
17985
  line: Math.max(0, diagnostic.line),
17958
- fingerprint
17986
+ fingerprint,
17987
+ message: formatFindingMessage(diagnostic)
17959
17988
  };
17960
17989
  };
17961
17990
  //#endregion
@@ -19171,12 +19200,12 @@ const runScanBody = async (resolvedDir, config, options, projectInfo, scanScope,
19171
19200
  scoreFileCount
19172
19201
  });
19173
19202
  if (options.sarif) {
19174
- const { buildSarifLog } = await import("./sarif-C9k9QYGi.js");
19203
+ const { buildSarifLog } = await import("./sarif-CuuawcSp.js");
19175
19204
  console.log(JSON.stringify(buildSarifLog(results), null, 2));
19176
19205
  return completion;
19177
19206
  }
19178
19207
  if (options.json) {
19179
- const { buildJsonOutput } = await import("./json-Be-AUuDb.js");
19208
+ const { buildJsonOutput } = await import("./json-BpPaIvrn.js");
19180
19209
  const jsonOut = buildJsonOutput(results, scoreResult, scoreFileCount, elapsedMs, scanCoverage);
19181
19210
  console.log(JSON.stringify(jsonOut, null, 2));
19182
19211
  return completion;
@@ -1,4 +1,4 @@
1
- import { t as APP_VERSION } from "./version-om7oAIVO.js";
1
+ import { t as APP_VERSION } from "./version-gBpAhuDc.js";
2
2
  import { i as ENGINE_INFO, n as withFindingAssessments, t as summarizeFindingAssessments } from "./finding-assessment-M5fUTE-C.js";
3
3
  //#region src/output/json.ts
4
4
  const buildJsonOutput = (results, scoreResult, fileCount, elapsedMs, coverage) => {
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as APP_VERSION, n as withFindingAssessments, r as ENGINE_INFO, t as summarizeFindingAssessments } from "./cli.js";
2
+ import { n as withFindingAssessments, r as ENGINE_INFO, s as APP_VERSION, t as summarizeFindingAssessments } from "./cli.js";
3
3
  //#region src/output/json.ts
4
4
  const buildJsonOutput = (results, scoreResult, fileCount, elapsedMs, coverage) => {
5
5
  const allDiagnostics = results.flatMap((r) => r.diagnostics);
package/dist/mcp.js CHANGED
@@ -84,7 +84,7 @@ const getActiveToken = () => {
84
84
  };
85
85
  //#endregion
86
86
  //#region src/version.ts
87
- const APP_VERSION = "1.0.1";
87
+ const APP_VERSION = "1.0.3";
88
88
  //#endregion
89
89
  //#region src/cloud/contract.ts
90
90
  const Severity = z.enum(["error", "warning"]);
@@ -94,7 +94,8 @@ const Finding = z.object({
94
94
  severity: Severity,
95
95
  path: z.string().max(500),
96
96
  line: z.number().int().nonnegative(),
97
- fingerprint: z.string().length(32)
97
+ fingerprint: z.string().length(32),
98
+ message: z.string().max(500).optional()
98
99
  });
99
100
  const RepoRef = z.object({
100
101
  provider: z.literal("github"),
@@ -109,12 +110,21 @@ const Step = z.object({
109
110
  ms: z.number().int().nonnegative(),
110
111
  counts: z.record(z.string(), z.number()).optional()
111
112
  });
113
+ const AgentTelemetry = z.object({
114
+ provider: z.string().max(80),
115
+ before_score: z.number().min(0).max(100).nullable(),
116
+ after_score: z.number().min(0).max(100).nullable(),
117
+ pr_url: z.string().url().max(500).optional(),
118
+ patch_diff: z.string().max(2e4).optional(),
119
+ duration_ms: z.number().int().nonnegative().optional()
120
+ });
112
121
  const Report = z.object({
113
122
  score: z.number().min(0).max(100).nullable(),
114
123
  scoreable: z.boolean(),
115
124
  engine_scores: z.record(z.string(), z.number()).optional(),
116
125
  files_scanned: z.number().int().nonnegative(),
117
- findings: z.array(Finding).max(5e3)
126
+ findings: z.array(Finding).max(5e3),
127
+ agent_telemetry: AgentTelemetry.optional()
118
128
  });
119
129
  z.object({
120
130
  run_id: z.uuid(),
@@ -131,7 +141,13 @@ z.object({
131
141
  branch: z.string().max(200).optional(),
132
142
  head_sha: z.string().max(64).optional(),
133
143
  base_ref: z.string().max(200).optional(),
134
- pr_number: z.number().int().optional()
144
+ pr_number: z.number().int().optional(),
145
+ diff_summary: z.object({
146
+ files_changed: z.number().int().nonnegative(),
147
+ additions: z.number().int().nonnegative(),
148
+ deletions: z.number().int().nonnegative()
149
+ }).optional(),
150
+ diff_preview: z.string().max(1e4).optional()
135
151
  }),
136
152
  ci: z.object({
137
153
  provider: z.string().max(40),
@@ -147,7 +163,8 @@ z.object({
147
163
  ended_at: z.iso.datetime(),
148
164
  exit_code: z.number().int(),
149
165
  steps: z.array(Step).max(200),
150
- report: Report.optional()
166
+ report: Report.optional(),
167
+ agent_telemetry: AgentTelemetry.optional()
151
168
  });
152
169
  z.object({
153
170
  version: z.number().int(),
@@ -342,7 +359,7 @@ const verifyEntitlementJwt = (jwt, options = {}) => {
342
359
  const claims = parsed.data;
343
360
  const expectedIssuer = process.env.RAIGAL_ISSUER?.trim() || "https://app.raigal.dev";
344
361
  if (claims.iss !== expectedIssuer) throw new JwtVerificationError(`Untrusted issuer: ${claims.iss}`, "invalid_issuer");
345
- if (!isVersionAtLeast("1.0.1", claims.min_cli_version)) throw new JwtVerificationError(`CLI version ${APP_VERSION} is below required minimum ${claims.min_cli_version}. Run "raigal update" or "npm install -g @methiu/raigal@latest".`, "cli_version_unsupported");
362
+ if (!isVersionAtLeast("1.0.3", claims.min_cli_version)) throw new JwtVerificationError(`CLI version ${APP_VERSION} is below required minimum ${claims.min_cli_version}. Run "raigal update" or "npm install -g @methiu/raigal@latest".`, "cli_version_unsupported");
346
363
  const now = options.nowSeconds ?? Math.floor(Date.now() / 1e3);
347
364
  const grace = options.allowGraceSeconds ?? 0;
348
365
  if (now > claims.exp + grace) {
@@ -509,7 +526,7 @@ const getEntitlement = async () => {
509
526
  };
510
527
  //#endregion
511
528
  //#region src/cloud/owner.ts
512
- const GITHUB_REMOTE_RE = /^(?:git@github\.com:|https:\/\/(?:[^@]+@)?github\.com\/)([^/]+)\/([^/.\s]+?)(?:\.git)?\s*$/;
529
+ const GITHUB_REMOTE_RE = /^(?:(?:git@|ssh:\/\/(?:git@)?)github\.com(?::(?:\d+\/)?|[:/])|https:\/\/(?:[^@]+@)?github\.com\/)([^/]+)\/([^/.\s]+?)(?:\.git)?\s*$/;
513
530
  const parseGitRemote = (rawUrl) => {
514
531
  if (!rawUrl) return {
515
532
  owner: null,
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import { a as requestApi, c as log, i as detectRepoRef, o as getActiveToken } from "./cli.js";
3
+ import fs from "node:fs";
4
+ //#region src/commands/report-pr-closed.ts
5
+ const reportPrClosedCommand = async (options = {}) => {
6
+ try {
7
+ let prNumber = options.prNumber;
8
+ let merged = options.merged ?? false;
9
+ const eventPath = process.env.GITHUB_EVENT_PATH;
10
+ if (eventPath && fs.existsSync(eventPath)) try {
11
+ const eventData = JSON.parse(fs.readFileSync(eventPath, "utf-8"));
12
+ if (typeof eventData.pull_request?.number === "number") prNumber = eventData.pull_request.number;
13
+ else if (typeof eventData.number === "number") prNumber = eventData.number;
14
+ if (typeof eventData.pull_request?.merged === "boolean") merged = eventData.pull_request.merged;
15
+ } catch {}
16
+ if (!prNumber) {
17
+ log.info("No pull request number detected to report closed.");
18
+ return { exitCode: 0 };
19
+ }
20
+ const repo = detectRepoRef(process.cwd());
21
+ if (!repo) {
22
+ log.info("No repository detected.");
23
+ return { exitCode: 0 };
24
+ }
25
+ const token = getActiveToken()?.token;
26
+ await requestApi("/v1/pr-events", {
27
+ method: "POST",
28
+ token,
29
+ body: {
30
+ repo,
31
+ pr_number: prNumber,
32
+ event: "closed",
33
+ merged
34
+ },
35
+ timeoutMs: 3e3
36
+ });
37
+ log.info(`Reported PR #${prNumber} as ${merged ? "merged" : "closed"}.`);
38
+ return { exitCode: 0 };
39
+ } catch {
40
+ return { exitCode: 0 };
41
+ }
42
+ };
43
+ //#endregion
44
+ export { reportPrClosedCommand };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as FIXED_SECRET_DIAGNOSTIC_MESSAGE, i as APP_VERSION, o as isSecretClassRule } from "./cli.js";
2
+ import { l as FIXED_SECRET_DIAGNOSTIC_MESSAGE, s as APP_VERSION, u as isSecretClassRule } from "./cli.js";
3
3
  import path from "node:path";
4
4
  //#region src/output/sarif.ts
5
5
  const SARIF_VERSION = "2.1.0";
@@ -1,4 +1,4 @@
1
- import { t as APP_VERSION } from "./version-om7oAIVO.js";
1
+ import { t as APP_VERSION } from "./version-gBpAhuDc.js";
2
2
  import { n as isSecretClassRule, t as FIXED_SECRET_DIAGNOSTIC_MESSAGE } from "./mask-secrets-BXn-ZSEh.js";
3
3
  import path from "node:path";
4
4
  //#region src/output/sarif.ts
@@ -1,6 +1,6 @@
1
1
  import "node:fs";
2
2
  import "node:url";
3
3
  //#region src/version.ts
4
- const APP_VERSION = "1.0.1";
4
+ const APP_VERSION = "1.0.3";
5
5
  //#endregion
6
6
  export { APP_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@methiu/raigal",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },