fix(cli): match managed prompt files by exact path

This commit is contained in:
Tam Nhu Tran
2026-04-13 08:39:59 -04:00
parent 45c231a717
commit 7fc39f7c03
7 changed files with 135 additions and 57 deletions
+4 -11
View File
@@ -7,8 +7,8 @@
import {
buildSteeringArg,
hasManagedPromptFileArg,
PROMPT_FLAG_INLINE,
PROMPT_FLAG_FILE,
} from '../prompt-injection-strategy';
const NATIVE_WEBSEARCH_TOOL = 'WebSearch';
@@ -83,9 +83,8 @@ function hasExactFlagValue(params: {
args: string[];
flag: string;
expectedValue: string;
allowPartiallyMatch?: boolean;
}): boolean {
const { args, flag, expectedValue, allowPartiallyMatch } = params;
const { args, flag, expectedValue } = params;
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
@@ -97,10 +96,6 @@ function hasExactFlagValue(params: {
return true;
}
if (allowPartiallyMatch && value?.includes(expectedValue)) {
return true;
}
continue;
}
@@ -169,11 +164,9 @@ function ensureWebSearchSteeringPrompt(args: string[]): string[] {
}
if (
hasExactFlagValue({
hasManagedPromptFileArg({
args: optionArgs,
flag: PROMPT_FLAG_FILE,
expectedValue: THIRD_PARTY_WEBSEARCH_STEERING_PROMPT.name,
allowPartiallyMatch: true,
promptName: THIRD_PARTY_WEBSEARCH_STEERING_PROMPT.name,
})
) {
return args;
+3 -15
View File
@@ -11,7 +11,7 @@ import * as os from 'os';
import * as path from 'path';
import { getCcsDir } from '../config-manager';
import { createLogger } from '../../services/logging';
import { PROMPT_FLAG_INLINE, PROMPT_FLAG_FILE } from '../prompt-injection-strategy';
import { hasManagedPromptFileArg, PROMPT_FLAG_INLINE } from '../prompt-injection-strategy';
import { THIRD_PARTY_WEBSEARCH_STEERING_PROMPT } from './claude-tool-args';
const TRACE_FILE_NAME = 'websearch-trace.jsonl';
@@ -61,9 +61,8 @@ function hasExactFlagValue(params: {
args: string[];
flag: string;
expectedValue: string;
allowIncludesValue?: boolean;
}): boolean {
const { args, flag, expectedValue, allowIncludesValue } = params;
const { args, flag, expectedValue } = params;
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
@@ -75,10 +74,6 @@ function hasExactFlagValue(params: {
return true;
}
if (allowIncludesValue && immediateFlagValue?.includes(expectedValue)) {
return true;
}
continue;
}
@@ -203,14 +198,7 @@ function hasSteeringPromptInArgs(args: string[]): boolean {
return true;
}
if (
hasExactFlagValue({
args,
flag: PROMPT_FLAG_FILE,
expectedValue: THIRD_PARTY_WEBSEARCH_STEERING_PROMPT.name,
allowIncludesValue: true,
})
) {
if (hasManagedPromptFileArg({ args, promptName: THIRD_PARTY_WEBSEARCH_STEERING_PROMPT.name })) {
return true;
}