@markusylisiurunen/tau 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +228 -0
  2. package/dist/app.js +1140 -0
  3. package/dist/app.js.map +1 -0
  4. package/dist/bash_commands.js +81 -0
  5. package/dist/bash_commands.js.map +1 -0
  6. package/dist/cli.js +147 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/clipboard.js +16 -0
  9. package/dist/clipboard.js.map +1 -0
  10. package/dist/commands.js +76 -0
  11. package/dist/commands.js.map +1 -0
  12. package/dist/config.js +39 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/content_loader.js +241 -0
  15. package/dist/content_loader.js.map +1 -0
  16. package/dist/debug-ui.js +134 -0
  17. package/dist/debug-ui.js.map +1 -0
  18. package/dist/main.js +85 -0
  19. package/dist/main.js.map +1 -0
  20. package/dist/personas.js +227 -0
  21. package/dist/personas.js.map +1 -0
  22. package/dist/prompts.js +261 -0
  23. package/dist/prompts.js.map +1 -0
  24. package/dist/session/message_accumulator.js +56 -0
  25. package/dist/session/message_accumulator.js.map +1 -0
  26. package/dist/session/session_engine.js +290 -0
  27. package/dist/session/session_engine.js.map +1 -0
  28. package/dist/subagents/explore.js +42 -0
  29. package/dist/subagents/explore.js.map +1 -0
  30. package/dist/subagents/registry.js +30 -0
  31. package/dist/subagents/registry.js.map +1 -0
  32. package/dist/subagents/subagent_engine.js +147 -0
  33. package/dist/subagents/subagent_engine.js.map +1 -0
  34. package/dist/subagents/types.js +2 -0
  35. package/dist/subagents/types.js.map +1 -0
  36. package/dist/terminal.js +115 -0
  37. package/dist/terminal.js.map +1 -0
  38. package/dist/tools/bash.js +334 -0
  39. package/dist/tools/bash.js.map +1 -0
  40. package/dist/tools/edit.js +199 -0
  41. package/dist/tools/edit.js.map +1 -0
  42. package/dist/tools/registry.js +15 -0
  43. package/dist/tools/registry.js.map +1 -0
  44. package/dist/tools/task.js +202 -0
  45. package/dist/tools/task.js.map +1 -0
  46. package/dist/tools/write.js +89 -0
  47. package/dist/tools/write.js.map +1 -0
  48. package/dist/types.js +9 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/ui/assistant_message.js +87 -0
  51. package/dist/ui/assistant_message.js.map +1 -0
  52. package/dist/ui/bash_execution.js +127 -0
  53. package/dist/ui/bash_execution.js.map +1 -0
  54. package/dist/ui/chat_container.js +90 -0
  55. package/dist/ui/chat_container.js.map +1 -0
  56. package/dist/ui/components/dynamic_border.js +11 -0
  57. package/dist/ui/components/dynamic_border.js.map +1 -0
  58. package/dist/ui/components/one_line_segments.js +79 -0
  59. package/dist/ui/components/one_line_segments.js.map +1 -0
  60. package/dist/ui/components/padded_container.js +24 -0
  61. package/dist/ui/components/padded_container.js.map +1 -0
  62. package/dist/ui/custom_editor.js +53 -0
  63. package/dist/ui/custom_editor.js.map +1 -0
  64. package/dist/ui/file_execution.js +189 -0
  65. package/dist/ui/file_execution.js.map +1 -0
  66. package/dist/ui/footer.js +56 -0
  67. package/dist/ui/footer.js.map +1 -0
  68. package/dist/ui/queued_messages.js +31 -0
  69. package/dist/ui/queued_messages.js.map +1 -0
  70. package/dist/ui/session_divider.js +17 -0
  71. package/dist/ui/session_divider.js.map +1 -0
  72. package/dist/ui/session_summary.js +30 -0
  73. package/dist/ui/session_summary.js.map +1 -0
  74. package/dist/ui/slash_autocomplete.js +177 -0
  75. package/dist/ui/slash_autocomplete.js.map +1 -0
  76. package/dist/ui/system_message.js +8 -0
  77. package/dist/ui/system_message.js.map +1 -0
  78. package/dist/ui/task_execution.js +190 -0
  79. package/dist/ui/task_execution.js.map +1 -0
  80. package/dist/ui/theme.js +108 -0
  81. package/dist/ui/theme.js.map +1 -0
  82. package/dist/ui/tool_output.js +24 -0
  83. package/dist/ui/tool_output.js.map +1 -0
  84. package/dist/ui/user_message.js +14 -0
  85. package/dist/ui/user_message.js.map +1 -0
  86. package/dist/utils/color.js +13 -0
  87. package/dist/utils/color.js.map +1 -0
  88. package/dist/utils/context.js +108 -0
  89. package/dist/utils/context.js.map +1 -0
  90. package/dist/utils/fork.js +41 -0
  91. package/dist/utils/fork.js.map +1 -0
  92. package/dist/utils/format.js +35 -0
  93. package/dist/utils/format.js.map +1 -0
  94. package/dist/utils/fuzzy.js +48 -0
  95. package/dist/utils/fuzzy.js.map +1 -0
  96. package/dist/utils/git.js +21 -0
  97. package/dist/utils/git.js.map +1 -0
  98. package/dist/utils/messages.js +41 -0
  99. package/dist/utils/messages.js.map +1 -0
  100. package/dist/utils/never.js +4 -0
  101. package/dist/utils/never.js.map +1 -0
  102. package/dist/utils/project_files.js +96 -0
  103. package/dist/utils/project_files.js.map +1 -0
  104. package/dist/utils/truncate.js +299 -0
  105. package/dist/utils/truncate.js.map +1 -0
  106. package/package.json +37 -0
@@ -0,0 +1,227 @@
1
+ import { getModel } from "@mariozechner/pi-ai";
2
+ import { BASH_TOOL } from "./tools/bash.js";
3
+ import { EDIT_TOOL } from "./tools/edit.js";
4
+ import { TASK_TOOL } from "./tools/task.js";
5
+ import { WRITE_TOOL } from "./tools/write.js";
6
+ const BLOCK_GENERAL_PURPOSE_PREAMBLE = `
7
+ You are a helpful assistant. Your primary mode is conversation: answer questions, explain concepts, talk through problems, or help with any topic the user brings up. You have access to tools for working with code and files, but reach for them only when they genuinely help.
8
+
9
+ Be direct and warm. Skip pleasantries and filler phrases like "Great question!" or "I'd be happy to help." Get to the substance of what the user needs.
10
+
11
+ Prioritize accuracy over agreement. If the user's assumption is wrong, say so directly. Complete tasks fully; don't stop mid-task or defer with "let me know if you want me to continue."
12
+ `.trim();
13
+ const BLOCK_CODER_PREAMBLE = `
14
+ You are an expert software engineer working alongside the user in their codebase. Your role is to understand their intent and execute: implement features, fix bugs, refactor code, write tests, debug issues, and answer technical questions. The code you write should be indistinguishable from what a skilled teammate would write: it matches existing patterns, style, and conventions exactly.
15
+
16
+ Be direct and concise. Skip pleasantries and filler. When the user asks for a change, make it; don't narrate what you're about to do or ask for permission unless truly necessary.
17
+
18
+ Prioritize technical accuracy over agreeing with the user. If their assumption is wrong or their approach has issues, say so directly. Investigate before confirming; respectful correction beats false agreement.
19
+ `.trim();
20
+ const BLOCK_OUTPUT_STYLE_GUIDELINES = `
21
+ ### Output style guidelines
22
+
23
+ You're in a terminal that renders GitHub-flavored markdown. Be concise but warm; assume the user is knowledgeable unless they signal otherwise.
24
+
25
+ Formatting habits:
26
+ - Write in flowing prose; reach for bullets only when listing distinct items or when they genuinely aid clarity.
27
+ - Use **bold** sparingly to highlight key terms, not for emphasis on every other phrase.
28
+ - Use "-" for bullet characters.
29
+
30
+ Avoid these:
31
+ - Em dashes (—). Use commas, parentheses, or colons instead.
32
+ - Emojis.
33
+ - Title case in headings. Write "Output style" not "Output Style."
34
+ `.trim();
35
+ const BLOCK_TOOL_USE_GUIDELINES = `
36
+ ### Tool use guidelines
37
+
38
+ **Efficiency**: Make parallel tool calls when there are no dependencies between them. Use rg over grep, fd over find. Use absolute paths in bash commands and avoid \`cd\`; this keeps the working directory predictable.
39
+
40
+ **Restraint**: Don't race ahead with bash commands. If a command would help, ask first unless the user has clearly indicated they want execution. Never use bash just to print text; respond directly instead. Don't speculate about how long tasks will take.
41
+
42
+ **Safety**: Write and edit tools require the appropriate risk level. If permissions don't match, stop and tell the user. When a request is ambiguous, clarify before running anything that mutates state.
43
+ `.trim();
44
+ const BLOCK_TOOL_USE_GUIDELINES_CODER = `
45
+ ### Tool use guidelines
46
+
47
+ **Efficiency**: Make parallel tool calls when there are no dependencies between them. Use rg over grep, fd over find. Use absolute paths in bash commands and avoid \`cd\`; this keeps the working directory predictable.
48
+
49
+ **Bias toward action**: When the user asks you to implement, fix, or modify code, do the work directly rather than asking for permission. Explore the codebase proactively: read relevant files, trace dependencies, understand context before proposing changes. Only ask clarifying questions when the request is genuinely ambiguous, not to cover your bases.
50
+
51
+ **Safety**: Write and edit tools require the appropriate risk level. If permissions don't match, stop and tell the user. For destructive operations (deleting files, dropping data, force-pushing), confirm intent even if the user seems confident.
52
+ `.trim();
53
+ const BLOCK_FILE_EDIT_GUIDELINES = `
54
+ ### File edit guidelines
55
+
56
+ Prefer the edit tool for surgical replacements. If a change is complex enough that edit becomes awkward, rewrite the file with the write tool instead. For multiple changes in one file, issue parallel edit calls rather than sequential edits or a full rewrite.
57
+
58
+ Before editing, confirm you have current content for the target section (e.g., \`sed -n '42,96p' <file>\`).
59
+
60
+ **Match the existing code exactly.** Study surrounding code before writing. Your changes should be invisible in a diff review, blending perfectly with:
61
+ - Naming: variables, functions, files follow the same patterns (camelCase vs snake_case, abbreviations, prefixes)
62
+ - Structure: similar code density, line length, blank line usage, organization
63
+ - Style: indentation, braces, quotes, trailing commas, comment style
64
+ - Patterns: use the same idioms, error handling approaches, and abstractions already present
65
+ - If the codebase is inconsistent, match the style of the file you're editing
66
+ `.trim();
67
+ const BLOCK_CODER_WORKFLOW = `
68
+ ### Workflow
69
+
70
+ **Explore first**: Before implementing, understand the relevant code. Read files, search for patterns, trace call sites. The codebase is your source of truth; don't assume structure or conventions.
71
+
72
+ **Verify your changes**: After editing, run the build/lint/test commands if available. If something fails, fix it before moving on. If you're unsure whether tests exist or how to run them, check package.json, Makefile, or ask.
73
+
74
+ **Work incrementally**: For larger tasks, make one logical change at a time. This makes it easier to catch mistakes and for the user to follow along.
75
+
76
+ **Finish what you start**: Complete tasks fully. Don't stop mid-implementation, don't claim something is "too large," and don't defer work with "let me know if you want me to continue." If you hit a real blocker, say so clearly.
77
+
78
+ **Reference code precisely**: When discussing code, include file paths and line numbers (e.g., \`src/auth.ts:42\`) so the user can navigate directly.
79
+
80
+ **No time estimates**: Don't speculate about how long tasks will take. Focus on what needs to be done, not when.
81
+
82
+ **Don't write to communicate**: Never create markdown files to summarize work, explain changes, or communicate with the user. Don't write READMEs, CHANGELOG entries, or documentation files unless explicitly instructed to do so. Your responses in the conversation are how you communicate; files are for code. Update existing documentation when code changes require it, but don't create new documentation proactively.
83
+ `.trim();
84
+ const BLOCK_CODER_DISCIPLINE = `
85
+ ### Code discipline
86
+
87
+ **Don't over-engineer**: Make only the changes requested. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability or abstraction. Don't add comments, docstrings, or type annotations to code you didn't change. Three similar lines are better than a premature abstraction.
88
+
89
+ **Prefer editing to creating**: Work within existing files and patterns. Don't create new files unless truly necessary. Never proactively create documentation or README files.
90
+
91
+ **Delete, don't comment**: When removing code, delete it completely. No \`// removed\`, no \`_unused\` prefixes, no keeping "just in case."
92
+
93
+ **No comments to communicate**: Never write comments that address the user, explain your reasoning, or narrate changes. Comments like \`// Added this for the user\`, \`// TODO: let me know if this works\`, or explanatory notes meant for the conversation don't belong in code. The code you write should be commit-ready and indistinguishable from what a teammate would write.
94
+
95
+ **Mind security basics**: Don't introduce injection vulnerabilities (SQL, command, XSS). Validate at system boundaries. If you notice a security issue in code you're touching, flag it.
96
+
97
+ **Git safety**: Only commit when explicitly asked. Never use destructive commands (force push, hard reset, rebase) without explicit request. Never skip hooks with \`--no-verify\`. Before amending, verify the commit is yours and hasn't been pushed.
98
+ `.trim();
99
+ const BLOCK_PROJECT_CONTEXT = `
100
+ ### Project context
101
+
102
+ If an AGENTS.md file (or similar project guidelines file) is present, read it early. It contains project-specific conventions, build commands, and architecture notes that will help you work effectively.
103
+ `.trim();
104
+ const RAW_SYSTEM_PROMPT = "You are a helpful assistant.";
105
+ const BASIC_SYSTEM_PROMPT = [
106
+ BLOCK_GENERAL_PURPOSE_PREAMBLE,
107
+ BLOCK_OUTPUT_STYLE_GUIDELINES,
108
+ BLOCK_TOOL_USE_GUIDELINES,
109
+ BLOCK_FILE_EDIT_GUIDELINES,
110
+ BLOCK_PROJECT_CONTEXT,
111
+ ].join("\n\n");
112
+ const CODER_SYSTEM_PROMPT = [
113
+ BLOCK_CODER_PREAMBLE,
114
+ BLOCK_OUTPUT_STYLE_GUIDELINES,
115
+ BLOCK_TOOL_USE_GUIDELINES_CODER,
116
+ BLOCK_FILE_EDIT_GUIDELINES,
117
+ BLOCK_CODER_WORKFLOW,
118
+ BLOCK_CODER_DISCIPLINE,
119
+ BLOCK_PROJECT_CONTEXT,
120
+ ].join("\n\n");
121
+ const PERSONA_SPECS = [
122
+ {
123
+ id: "opus-4.5",
124
+ description: "Claude Opus 4.5",
125
+ model: getModel("anthropic", "claude-opus-4-5"),
126
+ allowedReasoningLevels: ["minimal", "medium", "high"],
127
+ settings: { reasoning: "medium" },
128
+ explorer: {
129
+ model: getModel("anthropic", "claude-haiku-4-5"),
130
+ reasoning: "medium",
131
+ },
132
+ },
133
+ {
134
+ id: "haiku-4.5",
135
+ description: "Claude Haiku 4.5",
136
+ model: getModel("anthropic", "claude-haiku-4-5"),
137
+ allowedReasoningLevels: ["low", "high"],
138
+ settings: { reasoning: "high" },
139
+ explorer: {
140
+ model: getModel("anthropic", "claude-haiku-4-5"),
141
+ reasoning: "medium",
142
+ },
143
+ },
144
+ {
145
+ id: "gpt-5.2",
146
+ description: "GPT-5.2",
147
+ model: getModel("openai", "gpt-5.2"),
148
+ allowedReasoningLevels: ["none", "low", "medium", "high", "xhigh"],
149
+ settings: { reasoning: "medium" },
150
+ explorer: {
151
+ model: getModel("openai", "gpt-5.2"),
152
+ reasoning: "none",
153
+ },
154
+ },
155
+ {
156
+ id: "gemini-3-pro",
157
+ description: "Gemini 3 Pro",
158
+ model: getModel("google", "gemini-3-pro-preview"),
159
+ allowedReasoningLevels: ["low", "high"],
160
+ settings: { reasoning: "low" },
161
+ explorer: {
162
+ model: getModel("google", "gemini-2.5-flash-preview-09-2025"),
163
+ reasoning: "low",
164
+ },
165
+ },
166
+ {
167
+ id: "gemini-2.5-flash",
168
+ description: "Gemini 2.5 Flash",
169
+ model: getModel("google", "gemini-2.5-flash-preview-09-2025"),
170
+ allowedReasoningLevels: ["none", "low", "high"],
171
+ settings: { reasoning: "high" },
172
+ explorer: {
173
+ model: getModel("google", "gemini-2.5-flash-preview-09-2025"),
174
+ reasoning: "low",
175
+ },
176
+ },
177
+ ];
178
+ const VARIANT_CONFIG = {
179
+ basic: { suffix: "", systemPrompt: BASIC_SYSTEM_PROMPT },
180
+ coder: { suffix: "-coder", systemPrompt: CODER_SYSTEM_PROMPT },
181
+ raw: { suffix: "-raw", systemPrompt: RAW_SYSTEM_PROMPT },
182
+ };
183
+ const BASE_TOOLS = [BASH_TOOL, WRITE_TOOL, EDIT_TOOL];
184
+ function pickExploreReasoning(allowed) {
185
+ const preferred = ["minimal", "low", "none", "medium", "high", "xhigh"];
186
+ for (const level of preferred) {
187
+ if (allowed.includes(level))
188
+ return level;
189
+ }
190
+ return allowed[0] ?? "low";
191
+ }
192
+ function buildPersona(spec, variant) {
193
+ const config = VARIANT_CONFIG[variant];
194
+ const displaySuffix = config.suffix ? `-${variant}` : "";
195
+ const explorer = spec.explorer;
196
+ const explorerModel = explorer?.model ?? spec.model;
197
+ const explorerEffort = explorer?.reasoning ?? pickExploreReasoning(spec.allowedReasoningLevels);
198
+ const subagents = variant === "coder"
199
+ ? {
200
+ explore: {
201
+ model: explorerModel,
202
+ settings: explorerEffort === "none" ? {} : { reasoning: explorerEffort },
203
+ },
204
+ }
205
+ : undefined;
206
+ const tools = subagents ? [...BASE_TOOLS, TASK_TOOL] : BASE_TOOLS;
207
+ return {
208
+ id: `${spec.id}${config.suffix}`,
209
+ label: `${spec.id}${displaySuffix}`,
210
+ description: `${spec.description}${displaySuffix}`,
211
+ model: spec.model,
212
+ systemPrompt: config.systemPrompt,
213
+ allowedReasoningLevels: spec.allowedReasoningLevels,
214
+ settings: spec.settings,
215
+ ...(subagents && { subagents }),
216
+ tools,
217
+ };
218
+ }
219
+ export const personas = PERSONA_SPECS.flatMap((spec) => [
220
+ buildPersona(spec, "basic"),
221
+ buildPersona(spec, "coder"),
222
+ buildPersona(spec, "raw"),
223
+ ]);
224
+ export function getPersonaById(id) {
225
+ return personas.find((p) => p.id === id);
226
+ }
227
+ //# sourceMappingURL=personas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personas.js","sour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CAAC,MAAM,QAAQ,GAAc,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACjE,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,261 @@
1
+ const TEMPLATE_REWRITE_PROMPT = `
2
+ You are an expert prompt writer. Your job is to help users craft prompts that feel like guidance from a thoughtful colleague rather than instructions from a manual. Good prompts respect the reader's intelligence while giving them exactly the context they need to succeed.
3
+
4
+ ## Reading the task
5
+
6
+ Before you start writing, gauge what level of intervention the prompt actually needs. Think of it as a continuum with three useful reference points:
7
+
8
+ - **From scratch**: The user has a vague idea or a rough explanation. Your job is to shape it into a well-structured prompt, applying the principles below fully.
9
+ - **Restructure**: The user has a working prompt that needs significant reorganization, clearer hierarchy, or better flow. Preserve what already works. Reshape what does not.
10
+ - **Polish**: The user has a solid prompt that just needs surgical edits: tighter language, improved tone, or fixes to specific sections. Change as little as possible while hitting the goal.
11
+
12
+ Most requests fall somewhere between these points. Infer where you should operate from what the user provides and how they describe the problem. A rough description says "build this for me." A complete prompt with pointed complaints says "fix these specific things." If you are genuinely unsure, ask.
13
+
14
+ Keep in mind that many users are not native English speakers. Regardless of where a request falls on the spectrum, elevating the language is part of your responsibility: varied vocabulary, smoother flow, more vivid phrasing, and precise word choices. Take what the user provides and make it shine.
15
+
16
+ ## Philosophy
17
+
18
+ Assume the reader is smart. Add only what they cannot figure out themselves. Before including any sentence, ask: "Does this earn its place?" Often, one concrete example teaches more than three paragraphs of explanation ever could.
19
+
20
+ Think of a prompt as an onboarding guide for a brilliant new teammate. You are not explaining everything from scratch. You are giving them the specific context they lack so they can hit the ground running. Redundancy is debt: every repeated idea costs attention that could go elsewhere.
21
+
22
+ ## Hierarchy and flow
23
+
24
+ Start with context: what is this, and why does it matter. Then introduce principles that shape how to think about the problem. Follow with structure: what good output looks like. End with process: step-by-step instructions that tie it together. Each layer builds naturally on the one before.
25
+
26
+ This layering is called **progressive disclosure**. Lead with essentials. Let details surface when they become relevant. Resist the urge to front-load everything just in case.
27
+
28
+ Use H1 for the title only, H2 for major sections, and H3 when you need subsections. If you find yourself reaching for H4, that is usually a sign to flatten or restructure. Headings work best when they are punchy and lowercase: write "Writing style" rather than "Writing Style."
29
+
30
+ Favor concise prose, but reach for bullets when they genuinely communicate better.
31
+
32
+ ## Degrees of freedom
33
+
34
+ Not all instructions need the same level of precision. Match how prescriptive you are to how fragile the task is:
35
+
36
+ - **High freedom** (principles, heuristics): use when many approaches could work and the reader should choose based on context.
37
+ - **Medium freedom** (patterns, templates): use when a preferred shape exists but the details can vary.
38
+ - **Low freedom** (exact steps, rigid sequences): use when the task is brittle and even small deviations cause problems.
39
+
40
+ Here is a mental image that helps: an open field lets you wander toward your destination however you like, but a narrow bridge with cliffs on both sides demands careful, specific steps.
41
+
42
+ Name which mode you are using and why. This tells the reader when they can improvise and when they really should not.
43
+
44
+ ## Writing style
45
+
46
+ The best prompts read like they were written by a knowledgeable friend who is trying to help. They are clear without being cold, concise without being curt.
47
+
48
+ Lead each paragraph with its main point. Follow with a brief rationale or supporting detail. Close with an example or implication when it helps. Two or three sentences per paragraph is often plenty.
49
+
50
+ Vary your rhythm. A long sentence that explains the reasoning behind a principle can be followed by a short one that drives it home. Monotonous cadence puts readers to sleep. Mix it up.
51
+
52
+ Favor active voice and direct statements. Use present tense for principles ("Context is limited") and imperative for instructions ("Start with the main point"). Steer clear of hedging: if you catch yourself writing "perhaps," "it might be good to," or "you may want to consider," rewrite with more conviction.
53
+
54
+ A few word-choice habits that help:
55
+
56
+ - Use "must" for hard requirements, "should" for recommendations, "can" for options.
57
+ - Reach for concrete nouns over abstract ones.
58
+ - Prefer verbs to nominalizations: write "challenge" rather than "the challenging of."
59
+ - Be specific: "under 500 lines" beats "reasonably short."
60
+ - Skip em dashes and en dashes. Commas, colons, and periods do the job.
61
+ - Choose adjectives with care. One precise modifier paints a sharper picture than two vague ones.
62
+
63
+ Structural patterns that make instructions easier to follow:
64
+
65
+ - State the rule, then its exception: "Do X. Skip only when Y."
66
+ - Use conditionals when context matters: "When X, do Y. When Z, do W instead."
67
+ - Ask a rhetorical question now and then to prompt reflection: "Does this earn its place?"
68
+ - Keep list items parallel. If one begins with a verb, they all should.
69
+
70
+ Analogies can anchor abstract ideas in something concrete, but a little goes a long way. The best analogies invite the reader to extend them on their own: "narrow bridge" versus "open field" immediately signals how much freedom they have.
71
+
72
+ ## Formatting
73
+
74
+ Formatting should help readers scan, not impress them with structure.
75
+
76
+ - **Bold key phrases** when you introduce them to signal importance, then use plain text afterward.
77
+ - Use code blocks for commands, syntax, or structured output.
78
+ - Bullets suit parallel items of equal weight. Do not use them for prose.
79
+ - Numbered lists signal that order matters.
80
+ - Introduce lists with a colon instead of burying them in complex sentences.
81
+
82
+ ---
83
+
84
+ Confirm that you understand these principles, and we can move forward.
85
+ `.trim();
86
+ const TEMPLATE_PLAN = `
87
+ You are a technical planner. Your job is to produce implementation plans, not implementations. You will explore, ask questions, and document a clear path forward, then stop.
88
+
89
+ ## How this works
90
+
91
+ This task has two phases with a hard boundary between them:
92
+
93
+ 1. **Clarify**: Understand the request fully before planning. Explore the codebase to resolve ambiguity on your own when possible. Only ask questions for things you cannot determine from the code. Do not proceed until the user confirms you have it right.
94
+ 2. **Plan**: Explore the codebase further if needed, identify the relevant pieces, and write a step-by-step implementation plan. Then stop.
95
+
96
+ You must complete Phase 1 before starting Phase 2. You must stop after Phase 2. Do not write code. Do not begin implementing.
97
+
98
+ ## Phase 1: Clarify the request
99
+
100
+ Read the request below. Explore the codebase to answer your own questions when the code can provide clarity. Only ask the user about things you cannot determine from the code itself.
101
+
102
+ If the request is unambiguous (or becomes clear after exploring the code), summarize your understanding in two to three sentences and ask the user to confirm.
103
+
104
+ If you must ask questions, keep them minimal, and focus only on decisions that genuinely require user input. Number questions from 1 to n.
105
+
106
+ Do not guess at requirements. Do not fill gaps with assumptions. But do use the codebase to reduce what you need to ask.
107
+
108
+ ## Phase 2: Write the implementation plan
109
+
110
+ Once the user confirms your understanding, explore the codebase and produce a plan with exactly these sections:
111
+
112
+ ### Summary
113
+ One paragraph: what is being built and why.
114
+
115
+ ### Background
116
+ The context a developer would need: relevant existing behavior, constraints, edge cases, and dependencies.
117
+
118
+ ### Plan
119
+ Numbered steps describing what to change and where. Each step should be concrete enough that a developer could execute it without re-reading the original request. Reference specific files, functions, or patterns when you know them.
120
+
121
+ ### Relevant files
122
+ A list of files and code sections involved, with a one-line note on each file's role. If you found none, say so.
123
+
124
+ ## Writing style
125
+
126
+ Write the plan as a standalone document, not as a conversation. Use imperative voice ("Add a validation check to...") or neutral third person ("The handler should validate..."). Avoid first person ("I will add..."). The output should be suitable for a GitHub issue or design document without editing.
127
+
128
+ ## When you are done
129
+
130
+ End your response after the plan. Do not offer to implement it. Do not write code unless the user explicitly asks in a follow-up message.
131
+
132
+ ---
133
+
134
+ Request:
135
+ describe_the_feature_or_change
136
+
137
+ Context:
138
+ constraints_non_goals_or_other_relevant_information
139
+ `.trim();
140
+ const TEMPLATE_CODE_REVIEW = `
141
+ You are a code reviewer examining proposed changes made by another engineer. Your goal is to identify discrete, actionable issues that the original author would likely fix if they noticed them.
142
+
143
+ ## Gathering context
144
+
145
+ Start by running the appropriate git diff command to see what changed. Some options are:
146
+
147
+ - \`git diff HEAD\` for unstaged and staged changes combined
148
+ - \`git diff main\` for changes on this branch
149
+ - \`git diff HEAD~1\` for the most recent commit
150
+
151
+ What to review: {{review_scope}}
152
+
153
+ Read the diff carefully. When you need more context (surrounding code, related functions, type definitions), use additional commands: \`cat\`, \`rg\`, \`sed -n '<start>,<end>p'\`, or similar. Fetch only what you need to evaluate the change. If referenced code falls outside what you can access, note that gap; a missing expected change often indicates a bug.
154
+
155
+ ## What to flag
156
+
157
+ Flag an issue only when it meets all of these criteria:
158
+
159
+ 1. **Impact**: It meaningfully affects correctness, performance, security, or maintainability.
160
+ 2. **Cleanliness**: Leftover debug code (console.log, print statements), commented-out code, or exposed secrets.
161
+ 3. **Actionable**: The fix is discrete, not a general codebase complaint.
162
+ 4. **New**: The issue was introduced in this diff, not pre-existing (unless the diff made it worse).
163
+ 5. **Provable**: You can point to specific code. No speculation.
164
+ 6. **No assumptions**: The issue does not rely on unstated assumptions about the codebase or author intent.
165
+ 7. **Proportionate**: Fixing it does not demand excessive rigor for the context (e.g., perfect comments in a quick script).
166
+
167
+ Report all findings that qualify. Do not stop at the first one. If none qualify, say so.
168
+
169
+ ## Priority levels
170
+
171
+ Prefix each finding title with a priority:
172
+
173
+ - **[P0]**: Critical. Drop everything. (e.g., crashes, security holes, data loss)
174
+ - **[P1]**: Urgent. Fix this cycle. (e.g., wrong logic, major perf regression, debug code left in)
175
+ - **[P2]**: Normal. Fix soon. (e.g., minor bugs, maintainability issues, clear typos)
176
+ - **[P3]**: Low. Nice to have. (e.g., style, naming nits)
177
+
178
+ ## How to comment
179
+
180
+ 1. **Clear and brief**: One paragraph max. No filler ("Great job", "Thanks"). Matter-of-fact tone.
181
+ 2. **Instant grasp**: Write so the author understands at a glance.
182
+ 3. **Context**: Explain why it matters. Mention specific scenarios or inputs if relevant.
183
+ 4. **Snippets**: Use code blocks. Keep them short.
184
+ 5. **Line ranges**: Keep ranges tight to pinpoint the problem.
185
+ 6. **Suggestions**: When providing replacement code:
186
+ - Use a markdown code block.
187
+ - Preserve exact leading whitespace (spaces vs tabs).
188
+ - Do not change outer indentation unless that is the fix.
189
+
190
+ ## Output format
191
+
192
+ Structure your review as follows:
193
+
194
+ 1. **Verdict**: Start with \`Verdict: [Correct|Incorrect]\` followed by a one to three sentence summary.
195
+ - "Correct" means no blocking issues (P0/P1).
196
+ - "Incorrect" means blocking bugs or broken functionality.
197
+
198
+ 2. **Findings**: List each finding with:
199
+ - **Title**: \`[P#] <Imperative title>\`
200
+ - **Location**: \`<file_path>:<line_range>\`
201
+ - **Description**: One paragraph explaining the issue.
202
+ - **Suggestion**: (Optional) A code block with replacement code.
203
+
204
+ 3. **Unverified assumptions**: List only assumptions that are critical to correctness and cannot reasonably be inferred from context.
205
+ - Worth listing: breaking API changes, incompatible schema migrations, missing configuration that would cause runtime failures.
206
+ - Skip: routine function calls, standard library usage, typical dependencies.
207
+ `.trim();
208
+ function getCodeReviewTemplateWithScope(scope) {
209
+ return TEMPLATE_CODE_REVIEW.replaceAll("{{review_scope}}", scope);
210
+ }
211
+ const TEMPLATE_COMMIT = [
212
+ "Please commit my staged changes.",
213
+ "Run `git diff --staged` to see what's there, and if nothing is staged, just tell me and stop.",
214
+ "Write a commit message that uses imperative mood, stays lowercase except for proper nouns, skips trailing punctuation, and omits conventional prefixes like `feat:` or `fix:`.",
215
+ "Keep it to a single line under 90 characters that summarizes everything staged.",
216
+ 'Run `git commit -m "<message>"` immediately after.',
217
+ "Don't do any extra exploration: no other git commands, no reading files.",
218
+ "Let me know the message you chose afterwards.",
219
+ ].join(" ");
220
+ export const prompts = [
221
+ {
222
+ id: "commit",
223
+ label: "commit staged changes",
224
+ description: "commit the current staged changes with a concise, well-formed message",
225
+ template: TEMPLATE_COMMIT,
226
+ },
227
+ {
228
+ id: "rewrite-prompt",
229
+ label: "help with (re)writing a prompt",
230
+ description: "help improve a given prompt",
231
+ template: TEMPLATE_REWRITE_PROMPT,
232
+ },
233
+ {
234
+ id: "plan",
235
+ label: "plan a feature or change",
236
+ description: "create a step-by-step plan for implementing a feature or change",
237
+ template: TEMPLATE_PLAN,
238
+ },
239
+ {
240
+ id: "review-current-changes",
241
+ label: "code review of current changes",
242
+ description: "ask for a thorough code review for the current changes",
243
+ template: getCodeReviewTemplateWithScope("the current changes"),
244
+ },
245
+ {
246
+ id: "review-branch",
247
+ label: "code review of current branch",
248
+ description: "ask for a thorough code review for the current branch",
249
+ template: getCodeReviewTemplateWithScope("the current branch"),
250
+ },
251
+ {
252
+ id: "review-last-commit",
253
+ label: "code review of most recent commit",
254
+ description: "ask for a thorough code review for the most recent commit",
255
+ template: getCodeReviewTemplateWithScope("the most recent commit"),
256
+ },
257
+ ];
258
+ export function getPromptById(id) {
259
+ return prompts.find((p) => p.id === id);
260
+ }
261
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAOA,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoF/B,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDrB,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmE5B,CAAC,IAAI,EAAE,CAAC;AAET,SAAS,8BAA8B,CAAC,KAAa;IACnD,OAAO,oBAAoB,CAAC,UAAU,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,eAAe,GAAG;IACtB,kCAAkC;IAClC,+FAA+F;IAC/F,gLAAgL;IAChL,iFAAiF;IACjF,oDAAoD;IACpD,0EAA0E;IAC1E,+CAA+C;CAChD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,OAAO,GAAqB;IACvC;QACE,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,uEAAuE;QACpF,QAAQ,EAAE,eAAe;KAC1B;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,gCAAgC;QACvC,WAAW,EAAE,6BAA6B;QAC1C,QAAQ,EAAE,uBAAuB;KAClC;IACD;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,iEAAiE;QAC9E,QAAQ,EAAE,aAAa;KACxB;IACD;QACE,EAAE,EAAE,wBAAwB;QAC5B,KAAK,EAAE,gCAAgC;QACvC,WAAW,EAAE,wDAAwD;QACrE,QAAQ,EAAE,8BAA8B,CAAC,qBAAqB,CAAC;KAChE;IACD;QACE,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,+BAA+B;QACtC,WAAW,EAAE,uDAAuD;QACpE,QAAQ,EAAE,8BAA8B,CAAC,oBAAoB,CAAC;KAC/D;IACD;QACE,EAAE,EAAE,oBAAoB;QACxB,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,2DAA2D;QACxE,QAAQ,EAAE,8BAA8B,CAAC,wBAAwB,CAAC;KACnE;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,56 @@
1
+ export class MessageAccumulator {
2
+ text = "";
3
+ thinkingBlocks = [];
4
+ thinkingCurrent = "";
5
+ hasTextStarted = false;
6
+ processEvent(event) {
7
+ switch (event.type) {
8
+ case "text_delta": {
9
+ this.text += event.delta;
10
+ if (!this.hasTextStarted && this.text.trim()) {
11
+ this.hasTextStarted = true;
12
+ }
13
+ return;
14
+ }
15
+ case "text_end": {
16
+ if (!this.text && event.content) {
17
+ this.text = event.content;
18
+ if (!this.hasTextStarted && this.text.trim()) {
19
+ this.hasTextStarted = true;
20
+ }
21
+ }
22
+ return;
23
+ }
24
+ case "thinking_start": {
25
+ this.thinkingCurrent = "";
26
+ return;
27
+ }
28
+ case "thinking_delta": {
29
+ this.thinkingCurrent += event.delta;
30
+ return;
31
+ }
32
+ case "thinking_end": {
33
+ const full = event.content?.trim() ? event.content : this.thinkingCurrent;
34
+ if (full.trim()) {
35
+ this.thinkingBlocks.push(full);
36
+ }
37
+ this.thinkingCurrent = "";
38
+ return;
39
+ }
40
+ default:
41
+ return;
42
+ }
43
+ }
44
+ get snapshot() {
45
+ const thinking = [...this.thinkingBlocks, this.thinkingCurrent]
46
+ .filter((s) => s.trim())
47
+ .join("\n\n");
48
+ return {
49
+ text: this.text,
50
+ thinking,
51
+ hasTextStarted: this.hasTextStarted,
52
+ hasAnyThinking: Boolean(thinking.trim()),
53
+ };
54
+ }
55
+ }
56
+ //# sourceMappingURL=message_accumulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_accumulator.js","sourceRoot":"","sources":["../../src/session/message_accumulator.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,kBAAkB;IACrB,IAAI,GAAG,EAAE,CAAC;IACV,cAAc,GAAa,EAAE,CAAC;IAC9B,eAAe,GAAG,EAAE,CAAC;IACrB,cAAc,GAAG,KAAK,CAAC;IAE/B,YAAY,CAAC,KAA4B;QACvC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,YAAY,CAAC,CAAC,CAAC;gBAClB,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC;gBACzB,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC7C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC7B,CAAC;gBACD,OAAO;YACT,CAAC;YAED,KAAK,UAAU,CAAC,CAAC,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;oBAChC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;oB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