@codacy/verity-cli 0.30.0-experimental.43e7755 → 0.30.0-experimental.5188287
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/bin/verity.js +220 -157
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -13714,6 +13714,160 @@ var import_node_fs14 = require("node:fs");
|
|
|
13714
13714
|
var import_node_crypto7 = require("node:crypto");
|
|
13715
13715
|
var import_node_path13 = require("node:path");
|
|
13716
13716
|
|
|
13717
|
+
// src/lib/analysis-mode.ts
|
|
13718
|
+
var DEBUG_PHRASES = [
|
|
13719
|
+
"not working",
|
|
13720
|
+
"doesn't work",
|
|
13721
|
+
"doesn't work",
|
|
13722
|
+
"does not work",
|
|
13723
|
+
"isn't working",
|
|
13724
|
+
"is not working",
|
|
13725
|
+
"can't figure out",
|
|
13726
|
+
"stack trace"
|
|
13727
|
+
];
|
|
13728
|
+
var DEBUG_WORDS = [
|
|
13729
|
+
"fix",
|
|
13730
|
+
"bug",
|
|
13731
|
+
"broken",
|
|
13732
|
+
"crash",
|
|
13733
|
+
"crashing",
|
|
13734
|
+
"failing",
|
|
13735
|
+
"debug",
|
|
13736
|
+
"debugging",
|
|
13737
|
+
"investigate",
|
|
13738
|
+
"troubleshoot",
|
|
13739
|
+
"regression",
|
|
13740
|
+
"wrong"
|
|
13741
|
+
];
|
|
13742
|
+
var DEBUG_PATTERN = new RegExp(
|
|
13743
|
+
[
|
|
13744
|
+
...DEBUG_PHRASES.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")),
|
|
13745
|
+
...DEBUG_WORDS.map((w) => `\\b${w}\\b`)
|
|
13746
|
+
].join("|"),
|
|
13747
|
+
"i"
|
|
13748
|
+
);
|
|
13749
|
+
var FALSE_POSITIVE_PATTERNS = [
|
|
13750
|
+
/\b(?:add|create|implement|write|build|design|set\s*up)\b.{0,20}\berror\b/i,
|
|
13751
|
+
/\berror\s+handling\b/i,
|
|
13752
|
+
/\berror\s+boundar(?:y|ies)\b/i,
|
|
13753
|
+
/\berror\s+(?:type|class|page|component|message|code|enum)\b/i,
|
|
13754
|
+
/\b(?:add|create|implement|write|build)\b.{0,20}\b(?:fix|debug|issue)\b/i
|
|
13755
|
+
];
|
|
13756
|
+
function hasDebugIntent(prompt) {
|
|
13757
|
+
if (!DEBUG_PATTERN.test(prompt)) return false;
|
|
13758
|
+
for (const fp of FALSE_POSITIVE_PATTERNS) {
|
|
13759
|
+
if (fp.test(prompt)) return false;
|
|
13760
|
+
}
|
|
13761
|
+
return true;
|
|
13762
|
+
}
|
|
13763
|
+
var GIT_ONLY_PATTERN = /\b(commit|push|deploy|merge|rebase|tag|release|publish|ship)\b/i;
|
|
13764
|
+
var CODE_AUTHORING_PATTERN = /\b(add|create|implement|build|write|fix|update|change|refactor|modify|remove|delete|move|rename)\b.*\b(function|component|feature|endpoint|test|file|module|class|type|interface|hook|page|route|style|migration|code|bug|error|issue)\b/i;
|
|
13765
|
+
function isGitOnlyPrompt(prompt) {
|
|
13766
|
+
if (!GIT_ONLY_PATTERN.test(prompt)) return false;
|
|
13767
|
+
if (CODE_AUTHORING_PATTERN.test(prompt)) return false;
|
|
13768
|
+
return true;
|
|
13769
|
+
}
|
|
13770
|
+
function reconcileAnalysisMode(predictedMode, signals) {
|
|
13771
|
+
const mode2 = resolveAnalysisMode(predictedMode, signals);
|
|
13772
|
+
if (mode2 !== "skip") return mode2;
|
|
13773
|
+
const windowIsOrphaned = signals.actionSummary?.transcript_windowed === "orphaned";
|
|
13774
|
+
if (windowIsOrphaned && !signals.sessionAuthoredCode) return "standard";
|
|
13775
|
+
return mode2;
|
|
13776
|
+
}
|
|
13777
|
+
function resolveAnalysisMode(predictedMode, signals) {
|
|
13778
|
+
if (!predictedMode || !isValidMode(predictedMode)) {
|
|
13779
|
+
return detectAnalysisMode(
|
|
13780
|
+
signals.noFilesChanged,
|
|
13781
|
+
signals.assistantResponse,
|
|
13782
|
+
signals.conversationPrompts,
|
|
13783
|
+
signals.actionSummary,
|
|
13784
|
+
signals.sessionAuthoredCode
|
|
13785
|
+
);
|
|
13786
|
+
}
|
|
13787
|
+
const agentAuthoredCode = !!(signals.actionSummary && (signals.actionSummary.files_edited.length > 0 || signals.actionSummary.files_created.length > 0)) || !!signals.sessionAuthoredCode;
|
|
13788
|
+
const agentInvestigated = didAgentInvestigate(signals.actionSummary);
|
|
13789
|
+
switch (predictedMode) {
|
|
13790
|
+
case "skip":
|
|
13791
|
+
if (agentAuthoredCode) return "standard";
|
|
13792
|
+
return "skip";
|
|
13793
|
+
case "plan":
|
|
13794
|
+
if (agentAuthoredCode) return "standard";
|
|
13795
|
+
return "plan";
|
|
13796
|
+
case "debug":
|
|
13797
|
+
return "debug";
|
|
13798
|
+
case "standard":
|
|
13799
|
+
if (!!signals.actionSummary && !agentAuthoredCode && !!signals.assistantResponse) {
|
|
13800
|
+
return agentInvestigated ? "plan" : "skip";
|
|
13801
|
+
}
|
|
13802
|
+
return "standard";
|
|
13803
|
+
}
|
|
13804
|
+
}
|
|
13805
|
+
function didAgentInvestigate(summary) {
|
|
13806
|
+
if (!summary) return false;
|
|
13807
|
+
return summary.files_read.length > 0 || summary.searches > 0 || summary.commands.length > 0 || summary.subagents > 0 || summary.web_fetches > 0;
|
|
13808
|
+
}
|
|
13809
|
+
function isValidMode(mode2) {
|
|
13810
|
+
return mode2 === "standard" || mode2 === "plan" || mode2 === "debug" || mode2 === "skip";
|
|
13811
|
+
}
|
|
13812
|
+
function detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts, actionSummary, sessionAuthoredCode) {
|
|
13813
|
+
const agentAuthoredCode = !!(actionSummary && (actionSummary.files_edited.length > 0 || actionSummary.files_created.length > 0)) || !!sessionAuthoredCode;
|
|
13814
|
+
if (conversationPrompts.length > 0 && conversationPrompts.every(isGitOnlyPrompt)) {
|
|
13815
|
+
if (!agentAuthoredCode) return "skip";
|
|
13816
|
+
}
|
|
13817
|
+
if (noFilesChanged && !!assistantResponse && !agentAuthoredCode) {
|
|
13818
|
+
return "plan";
|
|
13819
|
+
}
|
|
13820
|
+
if (!!actionSummary && !agentAuthoredCode && !!assistantResponse) {
|
|
13821
|
+
return didAgentInvestigate(actionSummary) ? "plan" : "skip";
|
|
13822
|
+
}
|
|
13823
|
+
for (const prompt of conversationPrompts) {
|
|
13824
|
+
if (hasDebugIntent(prompt)) {
|
|
13825
|
+
return "debug";
|
|
13826
|
+
}
|
|
13827
|
+
}
|
|
13828
|
+
return "standard";
|
|
13829
|
+
}
|
|
13830
|
+
var FILE_MUTATE_RE = /(?:^|[\s|&;(`])(?:sed\s+-i|perl\s+-i|awk\b|tee\b|dd\b|cp\b|mv\b|ln\b|install\b|touch\b|patch\b|git\s+(?:apply|am)\b|cargo\s+build|go\s+generate|make\b|--write\b|--fix\b|--in-place\b)|>>?(?![&>])/i;
|
|
13831
|
+
var GIT_PLUMBING_RE = /^\s*git\s+(?:merge|rebase|stash|cherry-pick|revert|pull|fetch|checkout|switch|reset|restore|clean)\b/i;
|
|
13832
|
+
var READ_ONLY_RE = /^\s*(?:git\s+(?:status|diff|log|show|branch|remote|config|rev-parse|ls-files|blame|describe)|ls|cat|head|tail|less|grep|rg|find|pwd|echo|printf|wc|which|type|tree|stat|file|env|printenv|date|whoami)\b/i;
|
|
13833
|
+
var CHAIN_RE = /&&|\||;|\$\(|\x60/;
|
|
13834
|
+
function isNonAuthoringCommand(cmd) {
|
|
13835
|
+
if (typeof cmd !== "string" || cmd.trim().length === 0) return false;
|
|
13836
|
+
if (FILE_MUTATE_RE.test(cmd)) return false;
|
|
13837
|
+
if (CHAIN_RE.test(cmd)) return false;
|
|
13838
|
+
return GIT_PLUMBING_RE.test(cmd) || READ_ONLY_RE.test(cmd);
|
|
13839
|
+
}
|
|
13840
|
+
function hasNonEditAuthorship(actionSummary, sessionAuthoredCode) {
|
|
13841
|
+
if (!actionSummary) return sessionAuthoredCode;
|
|
13842
|
+
if ((actionSummary.subagents ?? 0) > 0) return true;
|
|
13843
|
+
if (Object.keys(actionSummary.tool_counts ?? {}).some((t) => t.startsWith("mcp__"))) return true;
|
|
13844
|
+
const commands = actionSummary.commands ?? [];
|
|
13845
|
+
if (commands.some((c) => FILE_MUTATE_RE.test(c))) return true;
|
|
13846
|
+
if (sessionAuthoredCode) {
|
|
13847
|
+
const allSafe = commands.length > 0 && commands.every(isNonAuthoringCommand);
|
|
13848
|
+
if (!allSafe) return true;
|
|
13849
|
+
}
|
|
13850
|
+
return false;
|
|
13851
|
+
}
|
|
13852
|
+
function scopeToAuthored(files, actionSummary) {
|
|
13853
|
+
if (!actionSummary) return { files, signal: "no-transcript" };
|
|
13854
|
+
const touched = [...actionSummary.files_edited ?? [], ...actionSummary.files_created ?? []];
|
|
13855
|
+
if (touched.length === 0) return { files: [], signal: "none-authored" };
|
|
13856
|
+
return { files: narrowToAgentAuthored(files, actionSummary), signal: "authored" };
|
|
13857
|
+
}
|
|
13858
|
+
function narrowToAgentAuthored(files, actionSummary) {
|
|
13859
|
+
if (!actionSummary) return files;
|
|
13860
|
+
const touched = [
|
|
13861
|
+
...actionSummary.files_edited,
|
|
13862
|
+
...actionSummary.files_created
|
|
13863
|
+
];
|
|
13864
|
+
if (touched.length === 0) return files;
|
|
13865
|
+
return files.filter((f) => {
|
|
13866
|
+
const suffix = "/" + f;
|
|
13867
|
+
return touched.some((t) => t === f || t.endsWith(suffix));
|
|
13868
|
+
});
|
|
13869
|
+
}
|
|
13870
|
+
|
|
13717
13871
|
// src/lib/skip-detection.ts
|
|
13718
13872
|
function isBareAckPrompt(prompt) {
|
|
13719
13873
|
if (typeof prompt !== "string") return false;
|
|
@@ -13777,6 +13931,15 @@ function shouldSkipForBareAck(input) {
|
|
|
13777
13931
|
if (input.turnAuthoredCode) return false;
|
|
13778
13932
|
return input.canSeeTurnAuthorship;
|
|
13779
13933
|
}
|
|
13934
|
+
function isCommandOnlyTurn(input) {
|
|
13935
|
+
if (!input.authorshipIsObservable) return false;
|
|
13936
|
+
if (input.userCommandsTruncated) return false;
|
|
13937
|
+
const commands = input.userCommands ?? [];
|
|
13938
|
+
if (commands.length === 0) return false;
|
|
13939
|
+
if (input.agentAuthoredFiles > 0) return false;
|
|
13940
|
+
if (input.agentToolCalls > 0) return false;
|
|
13941
|
+
return commands.every(isNonAuthoringCommand);
|
|
13942
|
+
}
|
|
13780
13943
|
|
|
13781
13944
|
// src/lib/pending-repeat.ts
|
|
13782
13945
|
var STOP = /* @__PURE__ */ new Set([
|
|
@@ -17187,6 +17350,8 @@ var MAX_COMMAND_CHARS = 80;
|
|
|
17187
17350
|
var MAX_TOOL_BLOCKS = 200;
|
|
17188
17351
|
var MAX_SUMMARY_BYTES = 4096;
|
|
17189
17352
|
var HOME = process.env.HOME ?? "";
|
|
17353
|
+
var BASH_INPUT_RE = /^\s*<bash-input>([\s\S]*?)<\/bash-input>/;
|
|
17354
|
+
var BASH_ECHO_RE = /^\s*<bash-(?:stdout|stderr)>/;
|
|
17190
17355
|
async function extractActionSummary(transcriptPath) {
|
|
17191
17356
|
try {
|
|
17192
17357
|
const read = readTurnLines(transcriptPath);
|
|
@@ -17250,7 +17415,7 @@ function isRealUserMessage(parsed) {
|
|
|
17250
17415
|
const message = parsed.message;
|
|
17251
17416
|
if (!message) return false;
|
|
17252
17417
|
const content = message.content;
|
|
17253
|
-
if (typeof content === "string") return
|
|
17418
|
+
if (typeof content === "string") return !BASH_ECHO_RE.test(content);
|
|
17254
17419
|
if (Array.isArray(content)) {
|
|
17255
17420
|
return content.some((b) => {
|
|
17256
17421
|
if (typeof b !== "object" || b === null) return false;
|
|
@@ -17265,6 +17430,8 @@ function buildSummary(lines) {
|
|
|
17265
17430
|
const filesEdited = /* @__PURE__ */ new Set();
|
|
17266
17431
|
const filesCreated = /* @__PURE__ */ new Set();
|
|
17267
17432
|
const commands = [];
|
|
17433
|
+
const userCommands = [];
|
|
17434
|
+
let userCommandsTruncated = false;
|
|
17268
17435
|
let searches = 0;
|
|
17269
17436
|
let subagents = 0;
|
|
17270
17437
|
let webFetches = 0;
|
|
@@ -17282,6 +17449,17 @@ function buildSummary(lines) {
|
|
|
17282
17449
|
if (entry.type === "user" && !firstTimestamp) {
|
|
17283
17450
|
firstTimestamp = entry.timestamp ?? null;
|
|
17284
17451
|
}
|
|
17452
|
+
if (entry.type === "user") {
|
|
17453
|
+
const typed = userTypedCommands(entry);
|
|
17454
|
+
if (typed.truncated) userCommandsTruncated = true;
|
|
17455
|
+
for (const cmd of typed.commands) {
|
|
17456
|
+
if (userCommands.length >= MAX_COMMANDS) {
|
|
17457
|
+
userCommandsTruncated = true;
|
|
17458
|
+
break;
|
|
17459
|
+
}
|
|
17460
|
+
userCommands.push(cmd);
|
|
17461
|
+
}
|
|
17462
|
+
}
|
|
17285
17463
|
if (entry.type !== "assistant") continue;
|
|
17286
17464
|
turnMessages++;
|
|
17287
17465
|
lastTimestamp = entry.timestamp ?? lastTimestamp;
|
|
@@ -17359,6 +17537,8 @@ function buildSummary(lines) {
|
|
|
17359
17537
|
],
|
|
17360
17538
|
searches,
|
|
17361
17539
|
commands,
|
|
17540
|
+
user_commands: userCommands,
|
|
17541
|
+
...userCommandsTruncated ? { user_commands_truncated: true } : {},
|
|
17362
17542
|
subagents,
|
|
17363
17543
|
web_fetches: webFetches,
|
|
17364
17544
|
total_tool_calls: totalToolCalls,
|
|
@@ -17367,6 +17547,8 @@ function buildSummary(lines) {
|
|
|
17367
17547
|
};
|
|
17368
17548
|
if (JSON.stringify(summary).length > MAX_SUMMARY_BYTES) {
|
|
17369
17549
|
summary.commands = [];
|
|
17550
|
+
summary.user_commands = [];
|
|
17551
|
+
summary.user_commands_truncated = true;
|
|
17370
17552
|
if (JSON.stringify(summary).length > MAX_SUMMARY_BYTES) {
|
|
17371
17553
|
summary.files_read = summary.files_read.slice(0, 10);
|
|
17372
17554
|
summary.files_edited = summary.files_edited.slice(0, 10);
|
|
@@ -17384,6 +17566,22 @@ function addPath(set, rawPath) {
|
|
|
17384
17566
|
if (p.length > 200) p = p.slice(0, 200);
|
|
17385
17567
|
set.add(p);
|
|
17386
17568
|
}
|
|
17569
|
+
function userTypedCommands(entry) {
|
|
17570
|
+
const none = { commands: [], truncated: false };
|
|
17571
|
+
const message = entry.message;
|
|
17572
|
+
const content = message?.content;
|
|
17573
|
+
if (typeof content !== "string") return none;
|
|
17574
|
+
const m = BASH_INPUT_RE.exec(content);
|
|
17575
|
+
if (!m) return none;
|
|
17576
|
+
const commands = [];
|
|
17577
|
+
let truncated = false;
|
|
17578
|
+
for (const line of m[1].split("\n")) {
|
|
17579
|
+
if (line.length > MAX_COMMAND_CHARS) truncated = true;
|
|
17580
|
+
const cmd = sanitizeCommand(line);
|
|
17581
|
+
if (cmd) commands.push(cmd);
|
|
17582
|
+
}
|
|
17583
|
+
return { commands, truncated };
|
|
17584
|
+
}
|
|
17387
17585
|
function sanitizeCommand(rawCmd) {
|
|
17388
17586
|
if (typeof rawCmd !== "string" || !rawCmd) return null;
|
|
17389
17587
|
let cmd = rawCmd.split("\n")[0];
|
|
@@ -17618,7 +17816,7 @@ function truncateToCap(text) {
|
|
|
17618
17816
|
function buildHookOutput(gateDecision, systemMessage, agentContext) {
|
|
17619
17817
|
return {
|
|
17620
17818
|
gate_decision: gateDecision,
|
|
17621
|
-
systemMessage,
|
|
17819
|
+
...systemMessage === null ? {} : { systemMessage },
|
|
17622
17820
|
...agentContext ? {
|
|
17623
17821
|
hookSpecificOutput: {
|
|
17624
17822
|
hookEventName: "Stop",
|
|
@@ -17639,7 +17837,7 @@ function channelSilence(input) {
|
|
|
17639
17837
|
// src/lib/cli-version.ts
|
|
17640
17838
|
function cliVersion() {
|
|
17641
17839
|
try {
|
|
17642
|
-
return true ? "0.30.0-experimental.
|
|
17840
|
+
return true ? "0.30.0-experimental.5188287" : "dev";
|
|
17643
17841
|
} catch {
|
|
17644
17842
|
return "dev";
|
|
17645
17843
|
}
|
|
@@ -17925,6 +18123,7 @@ async function passAndExit(run, reason, skip, kindOverride) {
|
|
|
17925
18123
|
"verity-command",
|
|
17926
18124
|
"bare-acknowledgment",
|
|
17927
18125
|
"reflection-prompt",
|
|
18126
|
+
"command-only-turn",
|
|
17928
18127
|
"skip-mode",
|
|
17929
18128
|
"zero-increment",
|
|
17930
18129
|
"debounce",
|
|
@@ -17943,10 +18142,12 @@ async function passAndExit(run, reason, skip, kindOverride) {
|
|
|
17943
18142
|
}
|
|
17944
18143
|
const AGENT_SILENT_SKIPS = /* @__PURE__ */ new Set([]);
|
|
17945
18144
|
const agentNote = AGENT_SILENT_SKIPS.has(skip) ? null : note;
|
|
18145
|
+
const HUMAN_SILENT_SKIPS = /* @__PURE__ */ new Set(["command-only-turn"]);
|
|
18146
|
+
const humanNote = HUMAN_SILENT_SKIPS.has(skip) ? null : `Verity: ${reason}`;
|
|
17946
18147
|
printJsonCompact(
|
|
17947
18148
|
buildHookOutput(
|
|
17948
18149
|
verdict,
|
|
17949
|
-
|
|
18150
|
+
humanNote,
|
|
17950
18151
|
// `additionalContext` is the agent's ONLY input. Writing only
|
|
17951
18152
|
// `systemMessage` — the human's field — tells the agent nothing at all,
|
|
17952
18153
|
// which is what sixteen of the nineteen terminating paths used to do.
|
|
@@ -18096,6 +18297,15 @@ function discoverPlans() {
|
|
|
18096
18297
|
// src/commands/analyze/phases/03-intent-inputs.ts
|
|
18097
18298
|
async function intentInputs(run) {
|
|
18098
18299
|
const { actionSummary, allForReview, assistantResponse, baseline, baselineSessionId } = run;
|
|
18300
|
+
if (isCommandOnlyTurn({
|
|
18301
|
+
userCommands: actionSummary?.user_commands,
|
|
18302
|
+
userCommandsTruncated: actionSummary?.user_commands_truncated,
|
|
18303
|
+
agentAuthoredFiles: (actionSummary?.files_edited.length ?? 0) + (actionSummary?.files_created.length ?? 0),
|
|
18304
|
+
agentToolCalls: actionSummary?.total_tool_calls ?? 0,
|
|
18305
|
+
authorshipIsObservable: !!actionSummary && actionSummary.transcript_windowed !== "orphaned"
|
|
18306
|
+
})) {
|
|
18307
|
+
await passAndExit(run, "User command only \u2014 skipping analysis", "command-only-turn");
|
|
18308
|
+
}
|
|
18099
18309
|
const conversation = await readAndClearConversationBuffer(baselineSessionId);
|
|
18100
18310
|
const specs = discoverSpecs(actionSummary?.files_read ?? []);
|
|
18101
18311
|
const plans = discoverPlans();
|
|
@@ -18136,156 +18346,6 @@ async function connect(run) {
|
|
|
18136
18346
|
Object.assign(run, { urlResult, serviceUrl: urlResult.data, token: tokenResult.data.token });
|
|
18137
18347
|
}
|
|
18138
18348
|
|
|
18139
|
-
// src/lib/analysis-mode.ts
|
|
18140
|
-
var DEBUG_PHRASES = [
|
|
18141
|
-
"not working",
|
|
18142
|
-
"doesn't work",
|
|
18143
|
-
"doesn't work",
|
|
18144
|
-
"does not work",
|
|
18145
|
-
"isn't working",
|
|
18146
|
-
"is not working",
|
|
18147
|
-
"can't figure out",
|
|
18148
|
-
"stack trace"
|
|
18149
|
-
];
|
|
18150
|
-
var DEBUG_WORDS = [
|
|
18151
|
-
"fix",
|
|
18152
|
-
"bug",
|
|
18153
|
-
"broken",
|
|
18154
|
-
"crash",
|
|
18155
|
-
"crashing",
|
|
18156
|
-
"failing",
|
|
18157
|
-
"debug",
|
|
18158
|
-
"debugging",
|
|
18159
|
-
"investigate",
|
|
18160
|
-
"troubleshoot",
|
|
18161
|
-
"regression",
|
|
18162
|
-
"wrong"
|
|
18163
|
-
];
|
|
18164
|
-
var DEBUG_PATTERN = new RegExp(
|
|
18165
|
-
[
|
|
18166
|
-
...DEBUG_PHRASES.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")),
|
|
18167
|
-
...DEBUG_WORDS.map((w) => `\\b${w}\\b`)
|
|
18168
|
-
].join("|"),
|
|
18169
|
-
"i"
|
|
18170
|
-
);
|
|
18171
|
-
var FALSE_POSITIVE_PATTERNS = [
|
|
18172
|
-
/\b(?:add|create|implement|write|build|design|set\s*up)\b.{0,20}\berror\b/i,
|
|
18173
|
-
/\berror\s+handling\b/i,
|
|
18174
|
-
/\berror\s+boundar(?:y|ies)\b/i,
|
|
18175
|
-
/\berror\s+(?:type|class|page|component|message|code|enum)\b/i,
|
|
18176
|
-
/\b(?:add|create|implement|write|build)\b.{0,20}\b(?:fix|debug|issue)\b/i
|
|
18177
|
-
];
|
|
18178
|
-
function hasDebugIntent(prompt) {
|
|
18179
|
-
if (!DEBUG_PATTERN.test(prompt)) return false;
|
|
18180
|
-
for (const fp of FALSE_POSITIVE_PATTERNS) {
|
|
18181
|
-
if (fp.test(prompt)) return false;
|
|
18182
|
-
}
|
|
18183
|
-
return true;
|
|
18184
|
-
}
|
|
18185
|
-
var GIT_ONLY_PATTERN = /\b(commit|push|deploy|merge|rebase|tag|release|publish|ship)\b/i;
|
|
18186
|
-
var CODE_AUTHORING_PATTERN = /\b(add|create|implement|build|write|fix|update|change|refactor|modify|remove|delete|move|rename)\b.*\b(function|component|feature|endpoint|test|file|module|class|type|interface|hook|page|route|style|migration|code|bug|error|issue)\b/i;
|
|
18187
|
-
function isGitOnlyPrompt(prompt) {
|
|
18188
|
-
if (!GIT_ONLY_PATTERN.test(prompt)) return false;
|
|
18189
|
-
if (CODE_AUTHORING_PATTERN.test(prompt)) return false;
|
|
18190
|
-
return true;
|
|
18191
|
-
}
|
|
18192
|
-
function reconcileAnalysisMode(predictedMode, signals) {
|
|
18193
|
-
const mode2 = resolveAnalysisMode(predictedMode, signals);
|
|
18194
|
-
if (mode2 !== "skip") return mode2;
|
|
18195
|
-
const windowIsOrphaned = signals.actionSummary?.transcript_windowed === "orphaned";
|
|
18196
|
-
if (windowIsOrphaned && !signals.sessionAuthoredCode) return "standard";
|
|
18197
|
-
return mode2;
|
|
18198
|
-
}
|
|
18199
|
-
function resolveAnalysisMode(predictedMode, signals) {
|
|
18200
|
-
if (!predictedMode || !isValidMode(predictedMode)) {
|
|
18201
|
-
return detectAnalysisMode(
|
|
18202
|
-
signals.noFilesChanged,
|
|
18203
|
-
signals.assistantResponse,
|
|
18204
|
-
signals.conversationPrompts,
|
|
18205
|
-
signals.actionSummary,
|
|
18206
|
-
signals.sessionAuthoredCode
|
|
18207
|
-
);
|
|
18208
|
-
}
|
|
18209
|
-
const agentAuthoredCode = !!(signals.actionSummary && (signals.actionSummary.files_edited.length > 0 || signals.actionSummary.files_created.length > 0)) || !!signals.sessionAuthoredCode;
|
|
18210
|
-
const agentInvestigated = didAgentInvestigate(signals.actionSummary);
|
|
18211
|
-
switch (predictedMode) {
|
|
18212
|
-
case "skip":
|
|
18213
|
-
if (agentAuthoredCode) return "standard";
|
|
18214
|
-
return "skip";
|
|
18215
|
-
case "plan":
|
|
18216
|
-
if (agentAuthoredCode) return "standard";
|
|
18217
|
-
return "plan";
|
|
18218
|
-
case "debug":
|
|
18219
|
-
return "debug";
|
|
18220
|
-
case "standard":
|
|
18221
|
-
if (!!signals.actionSummary && !agentAuthoredCode && !!signals.assistantResponse) {
|
|
18222
|
-
return agentInvestigated ? "plan" : "skip";
|
|
18223
|
-
}
|
|
18224
|
-
return "standard";
|
|
18225
|
-
}
|
|
18226
|
-
}
|
|
18227
|
-
function didAgentInvestigate(summary) {
|
|
18228
|
-
if (!summary) return false;
|
|
18229
|
-
return summary.files_read.length > 0 || summary.searches > 0 || summary.commands.length > 0 || summary.subagents > 0 || summary.web_fetches > 0;
|
|
18230
|
-
}
|
|
18231
|
-
function isValidMode(mode2) {
|
|
18232
|
-
return mode2 === "standard" || mode2 === "plan" || mode2 === "debug" || mode2 === "skip";
|
|
18233
|
-
}
|
|
18234
|
-
function detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts, actionSummary, sessionAuthoredCode) {
|
|
18235
|
-
const agentAuthoredCode = !!(actionSummary && (actionSummary.files_edited.length > 0 || actionSummary.files_created.length > 0)) || !!sessionAuthoredCode;
|
|
18236
|
-
if (conversationPrompts.length > 0 && conversationPrompts.every(isGitOnlyPrompt)) {
|
|
18237
|
-
if (!agentAuthoredCode) return "skip";
|
|
18238
|
-
}
|
|
18239
|
-
if (noFilesChanged && !!assistantResponse && !agentAuthoredCode) {
|
|
18240
|
-
return "plan";
|
|
18241
|
-
}
|
|
18242
|
-
if (!!actionSummary && !agentAuthoredCode && !!assistantResponse) {
|
|
18243
|
-
return didAgentInvestigate(actionSummary) ? "plan" : "skip";
|
|
18244
|
-
}
|
|
18245
|
-
for (const prompt of conversationPrompts) {
|
|
18246
|
-
if (hasDebugIntent(prompt)) {
|
|
18247
|
-
return "debug";
|
|
18248
|
-
}
|
|
18249
|
-
}
|
|
18250
|
-
return "standard";
|
|
18251
|
-
}
|
|
18252
|
-
var FILE_MUTATE_RE = /(?:^|[\s|&;(`])(?:sed\s+-i|perl\s+-i|awk\b|tee\b|dd\b|cp\b|mv\b|ln\b|install\b|touch\b|patch\b|git\s+(?:apply|am)\b|cargo\s+build|go\s+generate|make\b|--write\b|--fix\b|--in-place\b)|>>?(?![&>])/i;
|
|
18253
|
-
var GIT_PLUMBING_RE = /^\s*git\s+(?:merge|rebase|stash|cherry-pick|revert|pull|fetch|checkout|switch|reset|restore|clean)\b/i;
|
|
18254
|
-
var READ_ONLY_RE = /^\s*(?:git\s+(?:status|diff|log|show|branch|remote|config|rev-parse|ls-files|blame|describe)|ls|cat|head|tail|less|grep|rg|find|pwd|echo|printf|wc|which|type|tree|stat|file|env|printenv|date|whoami)\b/i;
|
|
18255
|
-
var CHAIN_RE = /&&|\||;|\$\(|\x60/;
|
|
18256
|
-
function hasNonEditAuthorship(actionSummary, sessionAuthoredCode) {
|
|
18257
|
-
if (!actionSummary) return sessionAuthoredCode;
|
|
18258
|
-
if ((actionSummary.subagents ?? 0) > 0) return true;
|
|
18259
|
-
if (Object.keys(actionSummary.tool_counts ?? {}).some((t) => t.startsWith("mcp__"))) return true;
|
|
18260
|
-
const commands = actionSummary.commands ?? [];
|
|
18261
|
-
if (commands.some((c) => FILE_MUTATE_RE.test(c))) return true;
|
|
18262
|
-
if (sessionAuthoredCode) {
|
|
18263
|
-
const allSafe = commands.length > 0 && commands.every(
|
|
18264
|
-
(c) => !CHAIN_RE.test(c) && (GIT_PLUMBING_RE.test(c) || READ_ONLY_RE.test(c))
|
|
18265
|
-
);
|
|
18266
|
-
if (!allSafe) return true;
|
|
18267
|
-
}
|
|
18268
|
-
return false;
|
|
18269
|
-
}
|
|
18270
|
-
function scopeToAuthored(files, actionSummary) {
|
|
18271
|
-
if (!actionSummary) return { files, signal: "no-transcript" };
|
|
18272
|
-
const touched = [...actionSummary.files_edited ?? [], ...actionSummary.files_created ?? []];
|
|
18273
|
-
if (touched.length === 0) return { files: [], signal: "none-authored" };
|
|
18274
|
-
return { files: narrowToAgentAuthored(files, actionSummary), signal: "authored" };
|
|
18275
|
-
}
|
|
18276
|
-
function narrowToAgentAuthored(files, actionSummary) {
|
|
18277
|
-
if (!actionSummary) return files;
|
|
18278
|
-
const touched = [
|
|
18279
|
-
...actionSummary.files_edited,
|
|
18280
|
-
...actionSummary.files_created
|
|
18281
|
-
];
|
|
18282
|
-
if (touched.length === 0) return files;
|
|
18283
|
-
return files.filter((f) => {
|
|
18284
|
-
const suffix = "/" + f;
|
|
18285
|
-
return touched.some((t) => t === f || t.endsWith(suffix));
|
|
18286
|
-
});
|
|
18287
|
-
}
|
|
18288
|
-
|
|
18289
18349
|
// src/commands/analyze/phases/05-mode.ts
|
|
18290
18350
|
async function mode(run) {
|
|
18291
18351
|
const { opts, globals } = run;
|
|
@@ -20138,7 +20198,10 @@ async function buildRequest(run) {
|
|
|
20138
20198
|
}
|
|
20139
20199
|
if (specs.length > 0) intentContext.specs = specs;
|
|
20140
20200
|
if (plans.length > 0) intentContext.plans = plans;
|
|
20141
|
-
if (actionSummary)
|
|
20201
|
+
if (actionSummary) {
|
|
20202
|
+
const { user_commands: _uc, user_commands_truncated: _uct, ...onTheWire } = actionSummary;
|
|
20203
|
+
intentContext.action_summary = onTheWire;
|
|
20204
|
+
}
|
|
20142
20205
|
for (const key of Object.keys(intentContext)) {
|
|
20143
20206
|
if (intentContext[key] == null) delete intentContext[key];
|
|
20144
20207
|
}
|
|
@@ -22802,8 +22865,8 @@ function registerTelemetryCommands(program2) {
|
|
|
22802
22865
|
}
|
|
22803
22866
|
|
|
22804
22867
|
// src/cli.ts
|
|
22805
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.30.0-experimental.
|
|
22806
|
-
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.30.0-experimental.
|
|
22868
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.30.0-experimental.5188287").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
|
|
22869
|
+
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.30.0-experimental.5188287");
|
|
22807
22870
|
setUserNamedServiceUrl(program.opts().serviceUrl);
|
|
22808
22871
|
try {
|
|
22809
22872
|
await foldLegacyLocalCredential();
|
package/package.json
CHANGED