@codacy/gate-cli 0.8.1 → 0.10.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 +90 -13
- package/package.json +1 -1
package/bin/gate.js
CHANGED
|
@@ -11993,6 +11993,77 @@ 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
|
+
var GIT_ONLY_PATTERN = /\b(commit|push|deploy|merge|rebase|tag|release|publish|ship)\b/i;
|
|
12043
|
+
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;
|
|
12044
|
+
function isGitOnlyPrompt(prompt) {
|
|
12045
|
+
if (!GIT_ONLY_PATTERN.test(prompt)) return false;
|
|
12046
|
+
if (CODE_AUTHORING_PATTERN.test(prompt)) return false;
|
|
12047
|
+
return true;
|
|
12048
|
+
}
|
|
12049
|
+
function detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts) {
|
|
12050
|
+
if (conversationPrompts.length > 0) {
|
|
12051
|
+
const latestPrompt = conversationPrompts[conversationPrompts.length - 1];
|
|
12052
|
+
if (isGitOnlyPrompt(latestPrompt)) {
|
|
12053
|
+
return "skip";
|
|
12054
|
+
}
|
|
12055
|
+
}
|
|
12056
|
+
if (noFilesChanged && !!assistantResponse) {
|
|
12057
|
+
return "plan";
|
|
12058
|
+
}
|
|
12059
|
+
for (const prompt of conversationPrompts) {
|
|
12060
|
+
if (hasDebugIntent(prompt)) {
|
|
12061
|
+
return "debug";
|
|
12062
|
+
}
|
|
12063
|
+
}
|
|
12064
|
+
return "standard";
|
|
12065
|
+
}
|
|
12066
|
+
|
|
11996
12067
|
// src/commands/analyze.ts
|
|
11997
12068
|
var MAX_ASSISTANT_RESPONSE_CHARS = 8e3;
|
|
11998
12069
|
async function readStopHookStdin() {
|
|
@@ -12051,11 +12122,15 @@ async function runAnalyze(opts, globals) {
|
|
|
12051
12122
|
if (noFilesChanged && !assistantResponse) {
|
|
12052
12123
|
passAndExit("No analyzable files changed");
|
|
12053
12124
|
}
|
|
12054
|
-
let planOnly = noFilesChanged && !!assistantResponse;
|
|
12055
12125
|
const allForReview = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable]));
|
|
12056
12126
|
const conversation = await readAndClearConversationBuffer();
|
|
12057
12127
|
const specs = discoverSpecs();
|
|
12058
12128
|
const plans = discoverPlans();
|
|
12129
|
+
const conversationPrompts = (conversation?.prompts ?? []).map((p) => p.prompt);
|
|
12130
|
+
let analysisMode = detectAnalysisMode(noFilesChanged, assistantResponse, conversationPrompts);
|
|
12131
|
+
if (analysisMode === "skip") {
|
|
12132
|
+
passAndExit("Git operation only \u2014 no code authored to analyze");
|
|
12133
|
+
}
|
|
12059
12134
|
let staticResults = {
|
|
12060
12135
|
tool: "@codacy/analysis-cli",
|
|
12061
12136
|
findings: [],
|
|
@@ -12070,40 +12145,40 @@ async function runAnalyze(opts, globals) {
|
|
|
12070
12145
|
let contentHash = null;
|
|
12071
12146
|
let iteration = 1;
|
|
12072
12147
|
let currentCommit = "";
|
|
12073
|
-
if (
|
|
12148
|
+
if (analysisMode !== "plan") {
|
|
12074
12149
|
const debounceSeconds = parseInt(opts.debounce, 10);
|
|
12075
12150
|
const debounceSkip = checkDebounce(debounceSeconds);
|
|
12076
12151
|
if (debounceSkip) {
|
|
12077
12152
|
if (assistantResponse) {
|
|
12078
|
-
|
|
12153
|
+
analysisMode = "plan";
|
|
12079
12154
|
} else {
|
|
12080
12155
|
passAndExit(debounceSkip);
|
|
12081
12156
|
}
|
|
12082
12157
|
}
|
|
12083
|
-
if (
|
|
12158
|
+
if (analysisMode !== "plan") {
|
|
12084
12159
|
const allCheckable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable, ...securityFiles]));
|
|
12085
12160
|
const mtimeSkip = checkMtime(allCheckable, hasRecentCommitFiles);
|
|
12086
12161
|
if (mtimeSkip) {
|
|
12087
12162
|
if (assistantResponse) {
|
|
12088
|
-
|
|
12163
|
+
analysisMode = "plan";
|
|
12089
12164
|
} else {
|
|
12090
12165
|
passAndExit(mtimeSkip);
|
|
12091
12166
|
}
|
|
12092
12167
|
}
|
|
12093
12168
|
}
|
|
12094
|
-
if (
|
|
12169
|
+
if (analysisMode !== "plan") {
|
|
12095
12170
|
recordAnalysisStart();
|
|
12096
12171
|
const allCheckable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...reviewable, ...securityFiles]));
|
|
12097
12172
|
const hashResult = checkContentHash(allCheckable);
|
|
12098
12173
|
if (hashResult.skip) {
|
|
12099
12174
|
if (assistantResponse) {
|
|
12100
|
-
|
|
12175
|
+
analysisMode = "plan";
|
|
12101
12176
|
} else {
|
|
12102
12177
|
passAndExit(hashResult.skip);
|
|
12103
12178
|
}
|
|
12104
12179
|
}
|
|
12105
12180
|
contentHash = hashResult.hash;
|
|
12106
|
-
if (
|
|
12181
|
+
if (analysisMode !== "plan") {
|
|
12107
12182
|
const recentForReview = narrowToRecent(allForReview);
|
|
12108
12183
|
if (!opts.skipStatic && isCodacyAvailable()) {
|
|
12109
12184
|
const allScannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles]));
|
|
@@ -12116,14 +12191,14 @@ async function runAnalyze(opts, globals) {
|
|
|
12116
12191
|
});
|
|
12117
12192
|
if (codeDelta.files.length === 0 && staticResults.findings.length === 0) {
|
|
12118
12193
|
if (assistantResponse) {
|
|
12119
|
-
|
|
12194
|
+
analysisMode = "plan";
|
|
12120
12195
|
} else {
|
|
12121
12196
|
passAndExit("No files within size limits to analyze");
|
|
12122
12197
|
}
|
|
12123
12198
|
}
|
|
12124
12199
|
}
|
|
12125
12200
|
}
|
|
12126
|
-
if (
|
|
12201
|
+
if (analysisMode !== "plan") {
|
|
12127
12202
|
snapshotResult = generateSnapshotDiffs(codeDelta.files);
|
|
12128
12203
|
currentCommit = getCurrentCommit();
|
|
12129
12204
|
const maxIterations = parseInt(opts.maxIterations, 10);
|
|
@@ -12132,7 +12207,7 @@ async function runAnalyze(opts, globals) {
|
|
|
12132
12207
|
iteration = iterResult.iteration;
|
|
12133
12208
|
}
|
|
12134
12209
|
}
|
|
12135
|
-
if (
|
|
12210
|
+
if (analysisMode === "plan") {
|
|
12136
12211
|
recordAnalysisStart();
|
|
12137
12212
|
currentCommit = getCurrentCommit();
|
|
12138
12213
|
}
|
|
@@ -12149,7 +12224,9 @@ async function runAnalyze(opts, globals) {
|
|
|
12149
12224
|
code_delta: codeDelta,
|
|
12150
12225
|
changed_files: allForReview,
|
|
12151
12226
|
standard_version: "latest",
|
|
12152
|
-
|
|
12227
|
+
analysis_mode: analysisMode,
|
|
12228
|
+
plan_only: analysisMode === "plan",
|
|
12229
|
+
// backwards compat
|
|
12153
12230
|
context: {
|
|
12154
12231
|
agent_model: process.env.CLAUDE_MODEL ?? "unknown",
|
|
12155
12232
|
agent_harness: "claude-code",
|
|
@@ -12542,7 +12619,7 @@ function registerInitCommand(program2) {
|
|
|
12542
12619
|
}
|
|
12543
12620
|
|
|
12544
12621
|
// src/cli.ts
|
|
12545
|
-
program.name("gate").description("CLI for GATE.md quality gate service").version("0.
|
|
12622
|
+
program.name("gate").description("CLI for GATE.md quality gate service").version("0.10.0").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
12546
12623
|
registerAuthCommands(program);
|
|
12547
12624
|
registerHooksCommands(program);
|
|
12548
12625
|
registerIntentCommands(program);
|