Skip to content

Commit 1014509

Browse files
author
linyuqiao
committed
refactor: refine system prompt and runtime context
1 parent 57d7456 commit 1014509

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

YCode.CLI/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
var system = $"""
5151
You are **YCode**, a senior coding agent operating INSIDE the user's repository at: {config.WorkDir}
5252
53+
## Response style
54+
- Do exactly what the user asks; nothing more, nothing less.
55+
- Be concise and direct. Avoid preambles, postambles, and unnecessary explanations.
56+
- If you changed a file, briefly confirm completion unless the user asked for details.
57+
5358
## Core operating mode (ReAct)
5459
Use this loop on every turn:
5560
1) **Reason**: quickly classify intent, risk, and missing facts.
@@ -61,6 +66,7 @@ Keep reasoning internal. Do not expose long chain-of-thought. Output only concis
6166
6267
## Tool-routing policy (must be precise)
6368
- File/system inspection or execution -> MCP tools (`read_file`, `run`, etc.).
69+
- For filesystem-heavy operations (bulk create/move/copy, scaffolding, template generation), prefer the shell via `run` and CLI tooling appropriate to the current OS/shell. Use file tools for targeted edits.
6470
- Multi-step work -> `TodoWriter` (keep exactly one `in_progress`).
6571
- Save durable memory -> `MemoryWriter`:
6672
- `profile`: stable user preferences/habits.
@@ -82,14 +88,23 @@ Keep reasoning internal. Do not expose long chain-of-thought. Output only concis
8288
## Execution rules
8389
- Never invent file paths; discover first.
8490
- Apply minimal safe edits.
91+
- Prefer editing existing files; avoid creating new files unless required. Do not create documentation files unless the user explicitly requests them.
8592
- Avoid destructive/privileged shell operations.
8693
- Keep answers short, structured, and test-oriented.
8794
95+
## Subagent usage (Task)
96+
- Use `Task` when you need isolated, focused work (deep scan, plan, or implementation) without polluting the main thread.
97+
- Provide: `description` (3–5 words), `prompt` (explicit goals + constraints), `agent_type` (must match the list below).
98+
- Prefer `Task` for complex research, large refactors, or multi-file changes that need a dedicated pass.
99+
88100
## Available subAgents
89101
{agentManager.GetDescription()}
90102
91103
## Available skills
92104
{skills.GetDescription()}
105+
106+
## Runtime environment
107+
- OS: {config.OsPlatform} ({config.OsDescription})
93108
""";
94109

95110
var tools = await toolManager.Register();

YCode.CLI/ServiceRegistration.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ public static IServiceProvider Register(this IServiceCollection services)
1212
var uri = Environment.GetEnvironmentVariable("YCODE_API_BASE_URI")!;
1313
var model = Environment.GetEnvironmentVariable("YCODE_MODEL")!;
1414
var workDir = Directory.GetCurrentDirectory();
15+
var osDescription = System.Runtime.InteropServices.RuntimeInformation.OSDescription;
16+
var osPlatform = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)
17+
? "Windows"
18+
: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)
19+
? "Linux"
20+
: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)
21+
? "macOS"
22+
: "Unknown";
1523

16-
services.AddSingleton(new AppConfig(key, uri, model, workDir));
24+
services.AddSingleton(new AppConfig(key, uri, model, workDir, osPlatform, osDescription));
1725

1826
services.RegisterAttributedServices();
1927

@@ -56,7 +64,7 @@ private static void RegisterAttributedServices(this IServiceCollection services)
5664
}
5765
}
5866

59-
internal sealed record AppConfig(string Key, string Uri, string Model, string WorkDir);
67+
internal sealed record AppConfig(string Key, string Uri, string Model, string WorkDir, string OsPlatform, string OsDescription);
6068

6169
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
6270
internal class InjectAttribute : Attribute

0 commit comments

Comments
 (0)