Skip to content

Commit 7f68f4c

Browse files
committed
feat: add currentDatePrompt, remove prompt for ast-grep
1 parent 427cde8 commit 7f68f4c

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/prompt.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,14 @@ function readToolDocs(extensionRoot: string, options: PromptToolOptions = {}): s
281281
return docs.join("\n\n");
282282
}
283283

284+
function getCurrentDatePrompt(date = new Date()): string {
285+
return `今天是${date.getFullYear()}${date.getMonth() + 1}${date.getDate()}日。随着对话的进行,时间在流逝。`;
286+
}
287+
284288
export function getSystemPrompt(projectRoot: string, options: PromptToolOptions = {}): string {
285289
const toolDocs = readToolDocs(getExtensionRoot(), options);
286290
const basePrompt = toolDocs ? `${SYSTEM_PROMPT_BASE}\n\n# Available Tools\n\n${toolDocs}` : SYSTEM_PROMPT_BASE;
287-
return `${basePrompt}\n\n${getRuntimeContext(projectRoot)}`;
291+
return `${basePrompt}\n\n${getCurrentDatePrompt()}\n\n${getRuntimeContext(projectRoot)}`;
288292
}
289293

290294
export function getCompactPrompt(sessionMessages: SessionMessage[]): string {
@@ -317,7 +321,6 @@ function getRuntimeContext(projectRoot: string): string {
317321
...shellModeOpts,
318322
...runtimeVersions,
319323
"command installed": {
320-
"ast-grep": checkToolInstalled("ast-grep"),
321324
ripgrep: checkToolInstalled("rg"),
322325
jq: checkToolInstalled("jq"),
323326
},

src/tests/prompt.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ test("getSystemPrompt always includes WebSearch docs", () => {
1717
assert.equal(prompt.includes("## WebSearch"), true);
1818
});
1919

20+
test("getSystemPrompt includes current date guidance", () => {
21+
const now = new Date();
22+
const expected = `今天是${now.getFullYear()}${now.getMonth() + 1}${now.getDate()}日。随着对话的进行,时间在流逝。`;
23+
const prompt = getSystemPrompt("/tmp/project");
24+
assert.equal(prompt.includes(expected), true);
25+
});
26+
2027
test("getSystemPrompt renders Read docs for non-multimodal models", () => {
2128
const prompt = getSystemPrompt("/tmp/project", { model: "deepseek-chat" });
2229
assert.equal(prompt.includes("the current model is not multimodal"), true);

templates/tools/bash.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ On Windows, Bash runs through Git Bash. Use POSIX commands and quote Windows pat
77
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
88

99
IMPORTANT: Before reaching for generic shell pipelines, prefer purpose-built CLI tools when they make the task more accurate, safer, faster, or easier to understand:
10-
- Use `ast-grep` when you need syntax-aware code search or structural rewrites; prefer it over plain text matching for language code.
1110
- Use `ripgrep` (`rg`) when you need to search file contents by text or regex across the workspace; prefer it over slower tools like `grep`.
1211
- Use `jq` when you need to inspect, filter, or transform JSON output; prefer it over ad-hoc parsing with `sed`, `awk`, or Python one-liners.
1312

0 commit comments

Comments
 (0)