update apply diff
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import { DiffStrategy } from "../../diff/DiffStrategy"
|
||||
|
||||
function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Record<string, boolean>): string {
|
||||
function getEditingInstructions(diffStrategy?: DiffStrategy): string {
|
||||
const instructions: string[] = []
|
||||
const availableTools: string[] = []
|
||||
|
||||
const experiments = {
|
||||
insert_content: true,
|
||||
search_and_replace: true,
|
||||
}
|
||||
|
||||
// Collect available editing tools
|
||||
if (diffStrategy) {
|
||||
availableTools.push(
|
||||
@@ -90,7 +95,7 @@ RULES
|
||||
- Your current obsidian directory is: ${cwd.toPosix()}
|
||||
${getSearchInstructions(searchTool)}
|
||||
- When creating new notes in Obsidian, organize them according to the existing vault structure unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the content logically, adhering to Obsidian conventions with appropriate frontmatter, headings, lists, and formatting. Unless otherwise specified, new notes should follow Markdown syntax with appropriate use of links ([[note name]]), tags (#tag), callouts, and other Obsidian-specific formatting.
|
||||
${getEditingInstructions(diffStrategy, experiments)}
|
||||
${getEditingInstructions(diffStrategy)}
|
||||
- Be sure to consider the structure of the Obsidian vault (folders, naming conventions, note organization) when determining the appropriate format and content for new or modified notes. Also consider what files may be most relevant to accomplishing the task, for example examining backlinks, linked mentions, or tags would help you understand the relationships between notes, which you could incorporate into any content you write.
|
||||
- When making changes to content, always consider the context within the broader vault. Ensure that your changes maintain existing links, tags, and references, and that they follow the user's established formatting standards and organization.
|
||||
- Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the attempt_completion tool to present the result to the user. The user may provide feedback, which you can use to make improvements and try again.
|
||||
@@ -100,7 +105,7 @@ ${getEditingInstructions(diffStrategy, experiments)}
|
||||
- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.
|
||||
- You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the markdown" but instead something like "I've updated the markdown". It is important you be clear and technical in your messages.
|
||||
- When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
|
||||
- At the end of each user message, you will automatically receive environment_details. This information is not written by the user themselves, but is auto-generated to provide potentially relevant context about the Obsidian environment. This includes the current file being edited, open tabs, and the vault structure. While this information can be valuable for understanding the context, do not treat it as a direct part of the user's request or response. Use it to inform your actions and decisions, but don't assume the user is explicitly asking about or referring to this information unless they clearly do so in their message. When using environment_details, explain your actions clearly to ensure the user understands, as they may not be aware of these details.
|
||||
- At the end of the first user message, you will automatically receive environment_details. This information is not written by the user themselves, but is auto-generated to provide potentially relevant context about the Obsidian environment. This includes the current file being edited, open tabs, and the vault structure. While this information can be valuable for understanding the context, do not treat it as a direct part of the user's request or response. Use it to inform your actions and decisions, but don't assume the user is explicitly asking about or referring to this information unless they clearly do so in their message. When using environment_details, explain your actions clearly to ensure the user understands, as they may not be aware of these details.
|
||||
- Pay special attention to the open tabs in environment_details, as they indicate which notes the user is currently working with and may be most relevant to their task. Similarly, the current file information shows which note is currently in focus and likely the primary subject of the user's request.
|
||||
- It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to create a structured note, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.`
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ async function generatePrompt(
|
||||
// throw new Error("Extension context is required for generating system prompt")
|
||||
// }
|
||||
|
||||
// If diff is disabled, don't pass the diffStrategy
|
||||
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||
// // If diff is disabled, don't pass the diffStrategy
|
||||
// const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||
|
||||
// Get the full mode config to ensure we have the role definition
|
||||
const modeConfig = getModeBySlug(mode, customModeConfigs) || modes.find((m) => m.slug === mode) || modes[0]
|
||||
@@ -54,7 +54,7 @@ async function generatePrompt(
|
||||
const [modesSection, mcpServersSection] = await Promise.all([
|
||||
getModesSection(),
|
||||
modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp")
|
||||
? getMcpServersSection(mcpHub, effectiveDiffStrategy, enableMcpServerCreation)
|
||||
? getMcpServersSection(mcpHub, diffStrategy, enableMcpServerCreation)
|
||||
: Promise.resolve(""),
|
||||
])
|
||||
|
||||
@@ -67,7 +67,7 @@ ${getToolDescriptionsForMode(
|
||||
cwd,
|
||||
filesSearchMethod,
|
||||
supportsComputerUse,
|
||||
effectiveDiffStrategy,
|
||||
diffStrategy,
|
||||
browserViewportSize,
|
||||
mcpHub,
|
||||
customModeConfigs,
|
||||
@@ -91,7 +91,7 @@ ${getRulesSection(
|
||||
cwd,
|
||||
filesSearchMethod,
|
||||
supportsComputerUse,
|
||||
effectiveDiffStrategy,
|
||||
diffStrategy,
|
||||
experiments,
|
||||
)}
|
||||
|
||||
@@ -110,8 +110,8 @@ export const SYSTEM_PROMPT = async (
|
||||
mode: Mode = defaultModeSlug,
|
||||
filesSearchMethod: string = 'regex',
|
||||
preferredLanguage?: string,
|
||||
mcpHub?: McpHub,
|
||||
diffStrategy?: DiffStrategy,
|
||||
mcpHub?: McpHub,
|
||||
browserViewportSize?: string,
|
||||
customModePrompts?: CustomModePrompts,
|
||||
customModes?: ModeConfig[],
|
||||
@@ -150,8 +150,8 @@ export const SYSTEM_PROMPT = async (
|
||||
// ${await addCustomInstructions(promptComponent?.customInstructions || currentMode.customInstructions || "", globalCustomInstructions || "", cwd, mode, { preferredLanguage })}`
|
||||
// }
|
||||
|
||||
// If diff is disabled, don't pass the diffStrategy
|
||||
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||
// // If diff is disabled, don't pass the diffStrategy
|
||||
// const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
|
||||
|
||||
return generatePrompt(
|
||||
// context,
|
||||
@@ -160,7 +160,7 @@ export const SYSTEM_PROMPT = async (
|
||||
currentMode.slug,
|
||||
filesSearchMethod,
|
||||
mcpHub,
|
||||
effectiveDiffStrategy,
|
||||
diffStrategy,
|
||||
browserViewportSize,
|
||||
promptComponent,
|
||||
customModes,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function getAskFollowupQuestionDescription(userLanguage: string): string {
|
||||
export function getAskFollowupQuestionDescription(): string {
|
||||
return `## ask_followup_question
|
||||
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
||||
Parameters:
|
||||
@@ -10,5 +10,6 @@ Usage:
|
||||
|
||||
Example: Requesting to ask the user for their preferred citation style for an academic document
|
||||
<ask_followup_question>
|
||||
<question>Which citation style would you like to use for your academic paper (APA, MLA, Chicago, etc.)?</question>`
|
||||
<question>Which citation style would you like to use for your academic paper (APA, MLA, Chicago, etc.)?</question>
|
||||
</ask_followup_question>`
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ Usage:
|
||||
}
|
||||
]</operations>
|
||||
</insert_content>
|
||||
|
||||
Example: Insert a new section heading and paragraph
|
||||
<insert_content>
|
||||
<path>chapter1.md</path>
|
||||
|
||||
@@ -26,7 +26,7 @@ Usage:
|
||||
]</operations>
|
||||
</search_and_replace>
|
||||
|
||||
Example: Replace "climate change" with "climate crisis" in lines 1-10 of an essay
|
||||
Example 1: Replace "climate change" with "climate crisis" in lines 1-10 of an essay
|
||||
<search_and_replace>
|
||||
<path>essays/environmental-impact.md</path>
|
||||
<operations>[
|
||||
@@ -38,7 +38,8 @@ Example: Replace "climate change" with "climate crisis" in lines 1-10 of an essa
|
||||
}
|
||||
]</operations>
|
||||
</search_and_replace>
|
||||
Example: Update citation format throughout a document using regex
|
||||
|
||||
Example 2: Update citation format throughout a document using regex
|
||||
<search_and_replace>
|
||||
<path>research-paper.md</path>
|
||||
<operations>[
|
||||
|
||||
@@ -16,17 +16,17 @@ Usage:
|
||||
<query>Your search query here</query>
|
||||
</search_web>
|
||||
|
||||
Examples1:
|
||||
Example 1:
|
||||
<search_web>
|
||||
<query>capital of France population statistics 2023</query>
|
||||
</search_web>
|
||||
|
||||
Examples2:
|
||||
Example 2:
|
||||
<search_web>
|
||||
<query>"renewable energy" growth statistics Europe</query>
|
||||
</search_web>
|
||||
|
||||
Examples3:
|
||||
Example 3:
|
||||
<search_web>
|
||||
<query>react vs angular vs vue.js comparison</query>
|
||||
</search_web>`
|
||||
|
||||
Reference in New Issue
Block a user