@codacy/gate-cli 0.8.1 → 0.9.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/bin/gate.js +74 -13
- package/package.json +1 -1
package/bin/gate.js
CHANGED
|
@@ -11993,6 +11993,64 @@ function buildOfflineFallback(reason, staticResults) {
|
|
|
11993
11993
|
};
|
|
11994
11994
|
}
|
|
11995
11995
|
|
|
11996
|
+
// src/lib/analysis-mode.ts
|
|
11997
|
+
var DEBUG_PHRASES = [
|
|
11998
|
+
"not working",
|
|
11999
|
+
"doesn't work",
|
|
12000
|
+
"doesn't work",
|
|
12001
|
+
"does not work",
|
|
12002
|
+
"isn't working",
|
|
12003
|
+
"is not working",
|
|
12004
|
+
"can't figure out",
|
|
12005
|
+
"stack trace"
|
|
12006
|
+
];
|
|
12007
|
+
var DEBUG_WORDS = [
|
|
12008
|
+
"fix",
|
|
12009
|
+
"bug",
|
|
12010
|
+
"broken",
|
|
12011
|
+
"crash",
|
|
12012
|
+
"crashing",
|
|
12013
|
+
"failing",
|
|
12014
|
+
"debug",
|
|
12015
|
+
"debugging",
|
|
12016
|
+
"investigate",
|
|
12017
|
+
"troubleshoot",
|
|
12018
|
+
"regression",
|
|
12019
|
+
"wrong"
|
|
12020
|
+
];
|
|
12021
|
+
var DEBUG_PATTERN = new RegExp(
|
|
12022
|
+
[
|
|
12023
|
+
...DEBUG_PHRASES.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")),
|
|
12024
|
+
...DEBUG_WORDS.map((w) => `\\b${w}\\b`)
|
|
12025
|
+
].join("|"),
|
|
12026
|
+
"i"
|
|
12027
|
+
);
|
|
12028
|
+
var FALSE_POSITIVE_PATTERNS = [
|
|
12029
|
+
/\b(?:add|create|implement|write|build|design|set\s*up)\b.{0,20}\berror\b/i,
|
|
12030
|
+
/\berror\s+handling\b/i,
|
|
12031
|
+
/\berror\s+boundar(?:y|ies)\b/i,
|
|
12032
|
+
/\berror\s+(?:type|class|page|component|message|code|enum)\b/i,
|
|
12033
|
+
/\b(?:add|create|implement|write|build)\b.{0,20}\b(?:fix|debug|issue)\b/i
|
|
12034
|
+
];
|
|
12035
|
+
function hasDebugIntent(prompt) {
|
|
12036
|
+
if (!DEBUG_PATTERN.test(prompt)) return false;
|
|
12037
|
+
for (const fp of FALSE_POSITIVE_PATTERNS) {
|
|
12038
|
+
if (fp.test(prompt)) return false;
|
|
12039
|
+
}
|
|
12040
|
+
return true;
|
|
12041
|
+
}
|
|
12042
|
+
function detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts) {
|
|
12043
|
+
if (noFilesChanged && !!assistantResponse) {
|
|
12044
|
+
return "plan";
|
|
12045
|
+
}
|
|
12046
|
+
for (const prompt of conversationPrompts) {
|
|
12047
|
+
if (hasDebugIntent(prompt)) {
|
|
12048
|
+
return "debug";
|
|
12049
|
+
}
|
|
12050
|
+
}
|
|
12051
|
+
return "standard";
|
|
12052
|
+
}
|
|
12053
|
+
|
|
11996
12054
|
// src/commands/analyze.ts
|
|
11997
12055
|
var MAX_ASSISTANT_RESPONSE_CHARS = 8e3;
|
|
11998
12056
|
async function readStopHookStdin() {
|
|
@@ -12051,11 +12109,12 @@ async function runAnalyze(opts, globals) {
|
|
|
12051
12109
|
if (noFilesChanged && !assistantResponse) {
|
|
12052
12110
|
passAndExit("No analyzable files changed");
|
|
12053
12111
|
}
|
|
12054
|
-
let planOnly = noFilesChanged && !!assistantResponse;
|
|
12055
12112
|
const allForReview = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable]));
|
|
12056
12113
|
const conversation = await readAndClearConversationBuffer();
|
|
12057
12114
|
const specs = discoverSpecs();
|
|
12058
12115
|
const plans = discoverPlans();
|
|
12116
|
+
const conversationPrompts = (conversation?.prompts ?? []).map((p) => p.prompt);
|
|
12117
|
+
let analysisMode = detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts);
|
|
12059
12118
|
let staticResults = {
|
|
12060
12119
|
tool: "@codacy/analysis-cli",
|
|
12061
12120
|
findings: [],
|
|
@@ -12070,40 +12129,40 @@ async function runAnalyze(opts, globals) {
|
|
|
12070
12129
|
let contentHash = null;
|
|
12071
12130
|
let iteration = 1;
|
|
12072
12131
|
let currentCommit = "";
|
|
12073
|
-
if (
|
|
12132
|
+
if (analysisMode !== "plan") {
|
|
12074
12133
|
const debounceSeconds = parseInt(opts.debounce, 10);
|
|
12075
12134
|
const debounceSkip = checkDebounce(debounceSeconds);
|
|
12076
12135
|
if (debounceSkip) {
|
|
12077
12136
|
if (assistantResponse) {
|
|
12078
|
-
|
|
12137
|
+
analysisMode = "plan";
|
|
12079
12138
|
} else {
|
|
12080
12139
|
passAndExit(debounceSkip);
|
|
12081
12140
|
}
|
|
12082
12141
|
}
|
|
12083
|
-
if (
|
|
12142
|
+
if (analysisMode !== "plan") {
|
|
12084
12143
|
const allCheckable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable, ...securityFiles]));
|
|
12085
12144
|
const mtimeSkip = checkMtime(allCheckable, hasRecentCommitFiles);
|
|
12086
12145
|
if (mtimeSkip) {
|
|
12087
12146
|
if (assistantResponse) {
|
|
12088
|
-
|
|
12147
|
+
analysisMode = "plan";
|
|
12089
12148
|
} else {
|
|
12090
12149
|
passAndExit(mtimeSkip);
|
|
12091
12150
|
}
|
|
12092
12151
|
}
|
|
12093
12152
|
}
|
|
12094
|
-
if (
|
|
12153
|
+
if (analysisMode !== "plan") {
|
|
12095
12154
|
recordAnalysisStart();
|
|
12096
12155
|
const allCheckable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable, ...securityFiles]));
|
|
12097
12156
|
const hashResult = checkContentHash(allCheckable);
|
|
12098
12157
|
if (hashResult.skip) {
|
|
12099
12158
|
if (assistantResponse) {
|
|
12100
|
-
|
|
12159
|
+
analysisMode = "plan";
|
|
12101
12160
|
} else {
|
|
12102
12161
|
passAndExit(hashResult.skip);
|
|
12103
12162
|
}
|
|
12104
12163
|
}
|
|
12105
12164
|
contentHash = hashResult.hash;
|
|
12106
|
-
if (
|
|
12165
|
+
if (analysisMode !== "plan") {
|
|
12107
12166
|
const recentForReview = narrowToRecent(allForReview);
|
|
12108
12167
|
if (!opts.skipStatic && isCodacyAvailable()) {
|
|
12109
12168
|
const allScannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles]));
|
|
@@ -12116,14 +12175,14 @@ async function runAnalyze(opts, globals) {
|
|
|
12116
12175
|
});
|
|
12117
12176
|
if (codeDelta.files.length === 0 && staticResults.findings.length === 0) {
|
|
12118
12177
|
if (assistantResponse) {
|
|
12119
|
-
|
|
12178
|
+
analysisMode = "plan";
|
|
12120
12179
|
} else {
|
|
12121
12180
|
passAndExit("No files within size limits to analyze");
|
|
12122
12181
|
}
|
|
12123
12182
|
}
|
|
12124
12183
|
}
|
|
12125
12184
|
}
|
|
12126
|
-
if (
|
|
12185
|
+
if (analysisMode !== "plan") {
|
|
12127
12186
|
snapshotResult = generateSnapshotDiffs(codeDelta.files);
|
|
12128
12187
|
currentCommit = getCurrentCommit();
|
|
12129
12188
|
const maxIterations = parseInt(opts.maxIterations, 10);
|
|
@@ -12132,7 +12191,7 @@ async function runAnalyze(opts, globals) {
|
|
|
12132
12191
|
iteration = iterResult.iteration;
|
|
12133
12192
|
}
|
|
12134
12193
|
}
|
|
12135
|
-
if (
|
|
12194
|
+
if (analysisMode === "plan") {
|
|
12136
12195
|
recordAnalysisStart();
|
|
12137
12196
|
currentCommit = getCurrentCommit();
|
|
12138
12197
|
}
|
|
@@ -12149,7 +12208,9 @@ async function runAnalyze(opts, globals) {
|
|
|
12149
12208
|
code_delta: codeDelta,
|
|
12150
12209
|
changed_files: allForReview,
|
|
12151
12210
|
standard_version: "latest",
|
|
12152
|
-
|
|
12211
|
+
analysis_mode: analysisMode,
|
|
12212
|
+
plan_only: analysisMode === "plan",
|
|
12213
|
+
// backwards compat
|
|
12153
12214
|
context: {
|
|
12154
12215
|
agent_model: process.env.CLAUDE_MODEL ?? "unknown",
|
|
12155
12216
|
agent_harness: "claude-code",
|
|
@@ -12542,7 +12603,7 @@ function registerInitCommand(program2) {
|
|
|
12542
12603
|
}
|
|
12543
12604
|
|
|
12544
12605
|
// src/cli.ts
|
|
12545
|
-
program.name("gate").description("CLI for GATE.md quality gate service").version("0.
|
|
12606
|
+
program.name("gate").description("CLI for GATE.md quality gate service").version("0.9.0").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
12546
12607
|
registerAuthCommands(program);
|
|
12547
12608
|
registerHooksCommands(program);
|
|
12548
12609
|
registerIntentCommands(program);
|