feat: dallins feedback
This commit is contained in:
parent
03e75521cd
commit
33b1d39946
6 changed files with 38 additions and 51 deletions
|
|
@ -723,6 +723,7 @@ export class Core {
|
|||
};
|
||||
|
||||
return await callTool(tool, toolCall.function.arguments, {
|
||||
config,
|
||||
ide: this.ide,
|
||||
llm: config.selectedModelByRole.chat,
|
||||
fetch: (url, init) =>
|
||||
|
|
|
|||
3
core/index.d.ts
vendored
3
core/index.d.ts
vendored
|
|
@ -975,6 +975,7 @@ export interface ToolExtras {
|
|||
toolCallId: string;
|
||||
contextItems: ContextItem[];
|
||||
}) => void;
|
||||
config: ContinueConfig;
|
||||
}
|
||||
|
||||
export interface Tool {
|
||||
|
|
@ -1147,7 +1148,7 @@ export interface StreamableHTTPOptions {
|
|||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
export type TransportOptions =
|
||||
export type TransportOptions =
|
||||
| StdioOptions
|
||||
| WebSocketOptions
|
||||
| SSEOptions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getRequestRuleDescription } from "./requestRule";
|
||||
import { RuleWithSource } from "../..";
|
||||
import { getRequestRuleDescription } from "./requestRule";
|
||||
|
||||
describe("getRequestRuleDescription", () => {
|
||||
it("should return no rules message when no agent-requested rules exist", () => {
|
||||
|
|
@ -25,7 +25,7 @@ describe("getRequestRuleDescription", () => {
|
|||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
expect(result).toBe(
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available."
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available.",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -68,14 +68,10 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Agent Rule 1\n" +
|
||||
"Description: First agent-requested rule\n" +
|
||||
"Filepath: /path/to/agent-rule1.md\n\n" +
|
||||
"Rule: Agent Rule 2\n" +
|
||||
"Description: Second agent-requested rule\n" +
|
||||
"Filepath: /path/to/agent-rule2.md";
|
||||
"Agent Rule 1: First agent-requested rule\n" +
|
||||
"Agent Rule 2: Second agent-requested rule";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -93,11 +89,9 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Rule Without Description\n" +
|
||||
"Description: undefined\n" +
|
||||
"Filepath: /path/to/no-desc-rule.md";
|
||||
"Rule Without Description: undefined";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -115,11 +109,9 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: undefined\n" +
|
||||
"Description: Rule without name\n" +
|
||||
"Filepath: /path/to/no-name-rule.md";
|
||||
"undefined: Rule without name";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -137,11 +129,9 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Rule Without File\n" +
|
||||
"Description: Rule without file path\n" +
|
||||
"Filepath: undefined";
|
||||
"Rule Without File: Rule without file path";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -168,11 +158,9 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Valid Agent Rule\n" +
|
||||
"Description: This should be included\n" +
|
||||
"Filepath: /path/to/valid-rule.md";
|
||||
"Valid Agent Rule: This should be included";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -191,7 +179,7 @@ describe("getRequestRuleDescription", () => {
|
|||
{
|
||||
name: "Rule with array globs",
|
||||
description: "This should also be filtered out",
|
||||
source: "rules-block",
|
||||
source: "rules-block",
|
||||
rule: "Some rule",
|
||||
alwaysApply: false,
|
||||
globs: ["**/*.ts", "**/*.js"],
|
||||
|
|
@ -209,11 +197,9 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Valid Agent Rule\n" +
|
||||
"Description: This should be included\n" +
|
||||
"Filepath: /path/to/valid-rule.md";
|
||||
"Valid Agent Rule: This should be included";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
@ -224,7 +210,7 @@ describe("getRequestRuleDescription", () => {
|
|||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
expect(result).toBe(
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available."
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available.",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -242,12 +228,10 @@ describe("getRequestRuleDescription", () => {
|
|||
|
||||
const result = getRequestRuleDescription(rules);
|
||||
|
||||
const expected =
|
||||
const expected =
|
||||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" +
|
||||
"Rule: Single Rule\n" +
|
||||
"Description: The only agent-requested rule\n" +
|
||||
"Filepath: /path/to/single-rule.md";
|
||||
"Single Rule: The only agent-requested rule";
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { ConfigDependentToolParams, GetTool } from "../..";
|
|||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export interface RequestRuleArgs {
|
||||
filepath: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
|
@ -18,11 +17,8 @@ export function getRequestRuleDescription(
|
|||
"Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n";
|
||||
|
||||
const body = agentRequestedRules
|
||||
.map(
|
||||
(rule) =>
|
||||
`Rule: ${rule.name}\nDescription: ${rule.description}\nFilepath: ${rule.ruleFile}`,
|
||||
)
|
||||
.join("\n\n");
|
||||
.map((rule) => `${rule.name}: ${rule.description}`)
|
||||
.join("\n");
|
||||
|
||||
if (body.length === 0) {
|
||||
return prefix + "No rules available.";
|
||||
|
|
@ -44,12 +40,8 @@ export const requestRuleTool: GetTool = ({ rules }) => ({
|
|||
description: getRequestRuleDescription(rules),
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["name", "filepath"],
|
||||
required: ["name"],
|
||||
properties: {
|
||||
filepath: {
|
||||
type: "string",
|
||||
description: "The path of the rule file",
|
||||
},
|
||||
name: {
|
||||
type: "string",
|
||||
description: "Name of the rule",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,16 @@ import { ToolImpl } from ".";
|
|||
import { parseMarkdownRule } from "../../config/markdown/parseMarkdownRule";
|
||||
|
||||
export const requestRuleImpl: ToolImpl = async (args, extras) => {
|
||||
const fileContent = await extras.ide.readFile(args.filepath);
|
||||
// Find the rule by name in the config
|
||||
const rule = extras.config.rules.find((r) => r.name === args.name);
|
||||
|
||||
if (!rule || !rule.ruleFile) {
|
||||
throw new Error(
|
||||
`Rule with name "${args.name}" not found or has no file path`,
|
||||
);
|
||||
}
|
||||
|
||||
const fileContent = await extras.ide.readFile(rule.ruleFile);
|
||||
const { markdown, frontmatter } = parseMarkdownRule(fileContent);
|
||||
|
||||
return [
|
||||
|
|
@ -12,7 +21,7 @@ export const requestRuleImpl: ToolImpl = async (args, extras) => {
|
|||
content: markdown,
|
||||
uri: {
|
||||
type: "file",
|
||||
value: args.filepath,
|
||||
value: rule.ruleFile,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export const uiSlice = createSlice({
|
|||
[BuiltInToolNames.ViewDiff]: "allowedWithoutPermission",
|
||||
[BuiltInToolNames.LSTool]: "allowedWithoutPermission",
|
||||
[BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission",
|
||||
[BuiltInToolNames.RequestRule]: "allowedWithoutPermission",
|
||||
[BuiltInToolNames.RequestRule]: "allowedWithPermission",
|
||||
},
|
||||
toolGroupSettings: {
|
||||
[BUILT_IN_GROUP_NAME]: "include",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue