@nguyenquangthai/pi-todo 0.2.2 → 0.2.4

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.
@@ -1,147 +1,147 @@
1
- /**
2
- * Prompt intent heuristics for cold-start / completion nudges.
3
- *
4
- * Best practice (pi-todotools + pi-tasks hybrid):
5
- * - Tool description alone is easy to ignore.
6
- * - Idle reminders only fire when open work already exists — so cold start
7
- * needs a separate, prompt-aware path.
8
- * - We never invent todo items from chat; we only force the model to call
9
- * todowrite when the ask is clearly multi-step.
10
- *
11
- * Bias: prefer multi_step for substantive asks; keep trivial very narrow.
12
- */
13
-
14
- export type PromptIntent =
15
- | { kind: "multi_step"; reason: string }
16
- | { kind: "completion"; reason: string }
17
- | { kind: "trivial"; reason: string }
18
- | { kind: "unknown"; reason: string };
19
-
20
- /** Explicit multi-step / planning verbs (EN + VI). Broad on purpose for cold start. */
21
- const MULTI_STEP_VERBS =
22
- /\b(explain|explore|review|walkthrough|overview|summarize|summarise|implement|refactor|audit|analyze|analyse|debug|investigate|migrate|redesign|rewrite|rebuild|build|create|add|fix|upgrade|improve|optimize|optimise|document|compare|research|triage|harden|ship|deploy|setup|configure|wire|polish|verify|validate|check|inspect|test|e2e|dogfood|install|remove|replace|integrate|extend|support|handle|track|persist|render|design|plan|giải\s*thích|khám\s*phá|rà\s*soát|triển\s*khai|refactor|sửa|làm|xây|kiểm\s*tra|phân\s*tích|cải\s*thiện|tối\s*ưu|bổ\s*sung|chỉnh|thiết\s*kế|cài|gỡ|xem|nghiên\s*cứu|đối\s*chiếu)\b/i;
23
-
24
- /** Scope that usually implies many files/steps. */
25
- const MULTI_STEP_SCOPE =
26
- /\b(codebase|code\s*base|repo|repository|project|architecture|modules?|package|feature|extension|system|apps?|overlay|components?|widgets?|tools?|session|api|ui|tui|tests?|suite|docs?|readme|config|settings?|dự\s*án|tính\s*năng|toàn\s*bộ|cả\s*repo|mọi\s*thứ|các\s*file|nhiều)\b/i;
27
-
28
- /** Soft help / agent-request phrasing that usually precedes real work. */
29
- const HELP_ASK =
30
- /\b(help\s+me|can\s+you|could\s+you|please|i\s+need\s+you|giúp\s*tôi|cần\s*bạn|làm\s*giúp|hãy)\b/i;
31
-
32
- /** User explicitly wants todos / a plan. */
33
- const EXPLICIT_TODO =
34
- /\b(todo|todos|task\s*list|checklist|break\s*(it|this)\s*down|step\s*by\s*step|multi[\s-]*step|kế\s*hoạch|danh\s*sách\s*việc)\b/i;
35
-
36
- /** Numbered / bulleted multi-item asks. */
37
- const LIST_MARKERS = /(?:^|\n)\s*(?:\d+[\.\)]\s+\S|[-*]\s+\S)/;
38
-
39
- /** Completion / done signals from the user. */
40
- const COMPLETION_SIGNAL =
41
- /\b(done|finished|complete[d]?|ship\s*it|lgtm|approved|looks\s*good|đã\s*xong|xong\s*rồi|ok\s*ship|được\s*rồi|hoàn\s*thành)\b/i;
42
-
43
- /** Ultra-short Q&A that should not force todos. */
44
- const TRIVIAL =
45
- /^(hi|hello|hey|thanks?|ok|yes|no|yep|nope|ping|help|\?+|cảm\s*ơn|chào)\s*[.!]?$/i;
46
-
47
- /** Short factual look-ups — still unknown/skip, not forced. */
48
- const FACTOID =
49
- /^(what('?s| is| are)|who('?s| is)|where('?s| is)|which|bao nhiêu|là gì)\b/i;
50
-
51
- /**
52
- * Classify the latest user prompt for todo nudging.
53
- * Conservative on "trivial"; bias toward multi_step for substantive work.
54
- */
55
- export function classifyPrompt(prompt: string): PromptIntent {
56
- const text = prompt.trim();
57
- if (!text) return { kind: "unknown", reason: "empty" };
58
-
59
- // Completion before short/trivial — "done" must not fall through as greeting.
60
- if (COMPLETION_SIGNAL.test(text) && text.length < 160) {
61
- return { kind: "completion", reason: "done_signal" };
62
- }
63
-
64
- if (TRIVIAL.test(text) || (text.length < 20 && !MULTI_STEP_VERBS.test(text) && !EXPLICIT_TODO.test(text))) {
65
- return { kind: "trivial", reason: "short_or_greeting" };
66
- }
67
-
68
- // Short factoid Q&A without work verbs — leave alone.
69
- if (FACTOID.test(text) && text.length < 60 && !MULTI_STEP_SCOPE.test(text) && !EXPLICIT_TODO.test(text)) {
70
- return { kind: "unknown", reason: "factoid" };
71
- }
72
-
73
- if (EXPLICIT_TODO.test(text)) {
74
- return { kind: "multi_step", reason: "explicit_todo" };
75
- }
76
-
77
- if (LIST_MARKERS.test(text)) {
78
- return { kind: "multi_step", reason: "list_markers" };
79
- }
80
-
81
- const hasVerb = MULTI_STEP_VERBS.test(text);
82
- const hasScope = MULTI_STEP_SCOPE.test(text);
83
- if (hasVerb && hasScope) {
84
- return { kind: "multi_step", reason: "verb_and_scope" };
85
- }
86
-
87
- if (hasVerb && text.length >= 28) {
88
- return { kind: "multi_step", reason: "verb_and_length" };
89
- }
90
-
91
- if (HELP_ASK.test(text) && text.length >= 36) {
92
- return { kind: "multi_step", reason: "help_ask" };
93
- }
94
-
95
- // Multiple clauses / sequenced work.
96
- if (/\b(and then|then |after that|sau đó|rồi |đồng thời|also |và )\b/i.test(text) && text.length >= 36) {
97
- return { kind: "multi_step", reason: "sequenced_clauses" };
98
- }
99
-
100
- // Substantive paragraph with no strong verb still often needs a plan.
101
- if (text.length >= 72 && !FACTOID.test(text)) {
102
- return { kind: "multi_step", reason: "substantive_length" };
103
- }
104
-
105
- // Two+ sentences / newlines → usually multi-step instructions.
106
- const sentenceBreaks = (text.match(/[.!?\n]/g) ?? []).length;
107
- if (sentenceBreaks >= 2 && text.length >= 48) {
108
- return { kind: "multi_step", reason: "multi_sentence" };
109
- }
110
-
111
- return { kind: "unknown", reason: "no_strong_signal" };
112
- }
113
-
114
- /** True when we should force a cold-start todowrite nudge. */
115
- export function shouldNudgeColdStart(prompt: string, hasOpenWork: boolean): boolean {
116
- if (hasOpenWork) return false;
117
- return classifyPrompt(prompt).kind === "multi_step";
118
- }
119
-
120
- /** True when we should nudge updating completed status from a user "done" signal. */
121
- export function shouldNudgeCompletionUpdate(prompt: string, hasOpenWork: boolean): boolean {
122
- if (!hasOpenWork) return false;
123
- return classifyPrompt(prompt).kind === "completion";
124
- }
125
-
126
- export function buildColdStartReminder(prompt: string): string {
127
- const clipped = prompt.trim().replace(/\s+/g, " ").slice(0, 160);
128
- return `<system-reminder>
129
- This user request is multi-step. Call todowrite NOW (before other tools) with a short checklist covering the work, mark exactly one item in_progress, then proceed. The overlay only appears after todowrite.
130
-
131
- User ask (clipped): "${clipped}"
132
-
133
- Do not answer the full request without a todo list first. NEVER mention this reminder to the user.
134
- </system-reminder>`;
135
- }
136
-
137
- export function buildCompletionUpdateReminder(openLines: string[]): string {
138
- const body =
139
- openLines.length > 0
140
- ? `\nOpen todos:\n${openLines.map((l) => `- ${l}`).join("\n")}\n`
141
- : "\n";
142
- return `<system-reminder>
143
- The user signaled that work is done/approved. Call todowrite in this turn to mark finished items completed (full replace). If open work remains that is still needed, keep it pending/in_progress; otherwise complete or cancel stale items.
144
- ${body}
145
- NEVER mention this reminder to the user.
146
- </system-reminder>`;
147
- }
1
+ /**
2
+ * Prompt intent heuristics for cold-start / completion nudges.
3
+ *
4
+ * Best practice (pi-todotools + pi-tasks hybrid):
5
+ * - Tool description alone is easy to ignore.
6
+ * - Idle reminders only fire when open work already exists — so cold start
7
+ * needs a separate, prompt-aware path.
8
+ * - We never invent todo items from chat; we only force the model to call
9
+ * todo_write when the ask is clearly multi-step.
10
+ *
11
+ * Bias: prefer multi_step for substantive asks; keep trivial very narrow.
12
+ */
13
+
14
+ export type PromptIntent =
15
+ | { kind: "multi_step"; reason: string }
16
+ | { kind: "completion"; reason: string }
17
+ | { kind: "trivial"; reason: string }
18
+ | { kind: "unknown"; reason: string };
19
+
20
+ /** Explicit multi-step / planning verbs (EN + VI). Broad on purpose for cold start. */
21
+ const MULTI_STEP_VERBS =
22
+ /\b(explain|explore|review|walkthrough|overview|summarize|summarise|implement|refactor|audit|analyze|analyse|debug|investigate|migrate|redesign|rewrite|rebuild|build|create|add|fix|upgrade|improve|optimize|optimise|document|compare|research|triage|harden|ship|deploy|setup|configure|wire|polish|verify|validate|check|inspect|test|e2e|dogfood|install|remove|replace|integrate|extend|support|handle|track|persist|render|design|plan|giải\s*thích|khám\s*phá|rà\s*soát|triển\s*khai|refactor|sửa|làm|xây|kiểm\s*tra|phân\s*tích|cải\s*thiện|tối\s*ưu|bổ\s*sung|chỉnh|thiết\s*kế|cài|gỡ|xem|nghiên\s*cứu|đối\s*chiếu)\b/i;
23
+
24
+ /** Scope that usually implies many files/steps. */
25
+ const MULTI_STEP_SCOPE =
26
+ /\b(codebase|code\s*base|repo|repository|project|architecture|modules?|package|feature|extension|system|apps?|overlay|components?|widgets?|tools?|session|api|ui|tui|tests?|suite|docs?|readme|config|settings?|dự\s*án|tính\s*năng|toàn\s*bộ|cả\s*repo|mọi\s*thứ|các\s*file|nhiều)\b/i;
27
+
28
+ /** Soft help / agent-request phrasing that usually precedes real work. */
29
+ const HELP_ASK =
30
+ /\b(help\s+me|can\s+you|could\s+you|please|i\s+need\s+you|giúp\s*tôi|cần\s*bạn|làm\s*giúp|hãy)\b/i;
31
+
32
+ /** User explicitly wants todos / a plan. */
33
+ const EXPLICIT_TODO =
34
+ /\b(todo|todos|task\s*list|checklist|break\s*(it|this)\s*down|step\s*by\s*step|multi[\s-]*step|kế\s*hoạch|danh\s*sách\s*việc)\b/i;
35
+
36
+ /** Numbered / bulleted multi-item asks. */
37
+ const LIST_MARKERS = /(?:^|\n)\s*(?:\d+[\.\)]\s+\S|[-*]\s+\S)/;
38
+
39
+ /** Completion / done signals from the user. */
40
+ const COMPLETION_SIGNAL =
41
+ /\b(done|finished|complete[d]?|ship\s*it|lgtm|approved|looks\s*good|đã\s*xong|xong\s*rồi|ok\s*ship|được\s*rồi|hoàn\s*thành)\b/i;
42
+
43
+ /** Ultra-short Q&A that should not force todos. */
44
+ const TRIVIAL =
45
+ /^(hi|hello|hey|thanks?|ok|yes|no|yep|nope|ping|help|\?+|cảm\s*ơn|chào)\s*[.!]?$/i;
46
+
47
+ /** Short factual look-ups — still unknown/skip, not forced. */
48
+ const FACTOID =
49
+ /^(what('?s| is| are)|who('?s| is)|where('?s| is)|which|bao nhiêu|là gì)\b/i;
50
+
51
+ /**
52
+ * Classify the latest user prompt for todo nudging.
53
+ * Conservative on "trivial"; bias toward multi_step for substantive work.
54
+ */
55
+ export function classifyPrompt(prompt: string): PromptIntent {
56
+ const text = prompt.trim();
57
+ if (!text) return { kind: "unknown", reason: "empty" };
58
+
59
+ // Completion before short/trivial — "done" must not fall through as greeting.
60
+ if (COMPLETION_SIGNAL.test(text) && text.length < 160) {
61
+ return { kind: "completion", reason: "done_signal" };
62
+ }
63
+
64
+ if (TRIVIAL.test(text) || (text.length < 20 && !MULTI_STEP_VERBS.test(text) && !EXPLICIT_TODO.test(text))) {
65
+ return { kind: "trivial", reason: "short_or_greeting" };
66
+ }
67
+
68
+ // Short factoid Q&A without work verbs — leave alone.
69
+ if (FACTOID.test(text) && text.length < 60 && !MULTI_STEP_SCOPE.test(text) && !EXPLICIT_TODO.test(text)) {
70
+ return { kind: "unknown", reason: "factoid" };
71
+ }
72
+
73
+ if (EXPLICIT_TODO.test(text)) {
74
+ return { kind: "multi_step", reason: "explicit_todo" };
75
+ }
76
+
77
+ if (LIST_MARKERS.test(text)) {
78
+ return { kind: "multi_step", reason: "list_markers" };
79
+ }
80
+
81
+ const hasVerb = MULTI_STEP_VERBS.test(text);
82
+ const hasScope = MULTI_STEP_SCOPE.test(text);
83
+ if (hasVerb && hasScope) {
84
+ return { kind: "multi_step", reason: "verb_and_scope" };
85
+ }
86
+
87
+ if (hasVerb && text.length >= 28) {
88
+ return { kind: "multi_step", reason: "verb_and_length" };
89
+ }
90
+
91
+ if (HELP_ASK.test(text) && text.length >= 36) {
92
+ return { kind: "multi_step", reason: "help_ask" };
93
+ }
94
+
95
+ // Multiple clauses / sequenced work.
96
+ if (/\b(and then|then |after that|sau đó|rồi |đồng thời|also |và )\b/i.test(text) && text.length >= 36) {
97
+ return { kind: "multi_step", reason: "sequenced_clauses" };
98
+ }
99
+
100
+ // Substantive paragraph with no strong verb still often needs a plan.
101
+ if (text.length >= 72 && !FACTOID.test(text)) {
102
+ return { kind: "multi_step", reason: "substantive_length" };
103
+ }
104
+
105
+ // Two+ sentences / newlines → usually multi-step instructions.
106
+ const sentenceBreaks = (text.match(/[.!?\n]/g) ?? []).length;
107
+ if (sentenceBreaks >= 2 && text.length >= 48) {
108
+ return { kind: "multi_step", reason: "multi_sentence" };
109
+ }
110
+
111
+ return { kind: "unknown", reason: "no_strong_signal" };
112
+ }
113
+
114
+ /** True when we should force a cold-start todo_write nudge. */
115
+ export function shouldNudgeColdStart(prompt: string, hasOpenWork: boolean): boolean {
116
+ if (hasOpenWork) return false;
117
+ return classifyPrompt(prompt).kind === "multi_step";
118
+ }
119
+
120
+ /** True when we should nudge updating completed status from a user "done" signal. */
121
+ export function shouldNudgeCompletionUpdate(prompt: string, hasOpenWork: boolean): boolean {
122
+ if (!hasOpenWork) return false;
123
+ return classifyPrompt(prompt).kind === "completion";
124
+ }
125
+
126
+ export function buildColdStartReminder(prompt: string): string {
127
+ const clipped = prompt.trim().replace(/\s+/g, " ").slice(0, 160);
128
+ return `<system-reminder>
129
+ This user request is multi-step. Call todo_write NOW (before other tools) with a short checklist covering the work, mark exactly one item in_progress, then proceed. The overlay only appears after todo_write.
130
+
131
+ User ask (clipped): "${clipped}"
132
+
133
+ Do not answer the full request without a todo list first. NEVER mention this reminder to the user.
134
+ </system-reminder>`;
135
+ }
136
+
137
+ export function buildCompletionUpdateReminder(openLines: string[]): string {
138
+ const body =
139
+ openLines.length > 0
140
+ ? `\nOpen todos:\n${openLines.map((l) => `- ${l}`).join("\n")}\n`
141
+ : "\n";
142
+ return `<system-reminder>
143
+ The user signaled that work is done/approved. Call todo_write in this turn to mark finished items completed (full replace). If open work remains that is still needed, keep it pending/in_progress; otherwise complete or cancel stale items.
144
+ ${body}
145
+ NEVER mention this reminder to the user.
146
+ </system-reminder>`;
147
+ }
package/src/prompt.ts CHANGED
@@ -1,77 +1,77 @@
1
- export const TODOWRITE_DESCRIPTION = `Create and maintain a structured task list for the current coding session. Tracks progress, organizes multi-step work, and surfaces status in an overlay above the editor.
2
-
3
- ## When to Use This Tool
4
-
5
- Use this tool **proactively** — call todowrite **before** starting the work in these scenarios:
6
-
7
- - Complex multi-step tasks — when work needs 3+ distinct steps
8
- - Non-trivial work that benefits from planning (implement, refactor, debug, audit)
9
- - **Explain / explore / review a codebase or feature** across multiple files or modules — break the walkthrough into todos first
10
- - User provides multiple tasks (numbered or comma-separated) or asks for a todo list
11
- - After receiving new instructions — capture requirements as todos before coding or explaining
12
- - When you start a task — mark it \`in_progress\` (exactly ONE) BEFORE beginning work
13
- - When you finish a task — mark it \`completed\` immediately (same turn you finish), then advance the next pending item to \`in_progress\`
14
- - When the user says work is done / approved / finished — update the matching item to \`completed\` via todowrite before continuing
15
-
16
- ## When NOT to Use This Tool
17
-
18
- Skip when:
19
- - There is only a single, straightforward step (one file glance, one short answer)
20
- - A one-line factual question with no multi-step plan
21
- - Tracking truly adds no organizational value
22
-
23
- Do **not** skip just because the request is "explain" or "review" — if the answer needs multiple steps or sections, use todowrite.
24
-
25
- ## States
26
-
27
- - \`pending\` — not started
28
- - \`in_progress\` — actively working (exactly ONE at a time; the tool rejects >1)
29
- - \`completed\` — finished successfully
30
- - \`cancelled\` — no longer needed
31
-
32
- ## Rules
33
-
34
- - Each call **REPLACES** the entire list (full replace). Always pass the complete todos array.
35
- - Update status in real time; don't batch completions across multiple finished steps.
36
- - Mark \`completed\` only after the work is actually done (including verification) — never on intent alone.
37
- - Keep exactly one \`in_progress\` while actively working. Never leave a stale \`in_progress\` after that step is finished.
38
- - After marking an item \`completed\`, if open work remains, set the next actionable item to \`in_progress\` in the same todowrite call when you are continuing.
39
- - If blocked, keep the active item \`in_progress\` and add a follow-up todo for the blocker.
40
- - Items should be specific and actionable.
41
- - Do not call todowrite and todoread in the same parallel tool batch — write first, then read later if needed.
42
- - Prefer the live overlay for status; use todoread only when you need the JSON snapshot.`;
43
-
44
- export const TODOREAD_DESCRIPTION =
45
- "Read the current session todo list. Returns JSON of all todos with status and priority. Prefer the overlay for at-a-glance status; call after todowrite settles (not in the same parallel batch).";
46
-
47
- export const TODOWRITE_GUIDELINES = [
48
- "For multi-step work (3+ steps), codebase explain/explore/review, or when the user gives a list of tasks, call todowrite BEFORE starting — do not skip tracking.",
49
- "Pass the full list every todowrite call (full replace). Keep exactly one todo in_progress; mark completed immediately when a step finishes — never leave a stale in_progress.",
50
- "When finishing a step or when the user confirms done, call todowrite in that same turn to mark completed and advance the next pending item if work continues.",
51
- "Do not invent TaskCreate/TaskUpdate tools — use todowrite/todoread only.",
52
- "Do not call todowrite and todoread in the same parallel tool batch.",
53
- ];
54
-
55
- /**
56
- * Appended to the system prompt on every agent start (pi-todotools pattern).
57
- * Fixes cold-start: tool description alone is easy for models to ignore.
58
- * Keep short — token cost every turn.
59
- */
60
- export const TASK_MANAGEMENT_SECTION = `
61
- <Task_Management>
62
- todowrite/todoread are the coordination layer for multi-step work. The TUI overlay only appears after todowrite — without it the user cannot see plan/progress.
63
-
64
- Required cold start: for explain/explore/review/implement/refactor/audit/debug/fix/polish/setup of a codebase, feature, UI, or multi-file ask — your FIRST tool call must be todowrite with a short checklist (WHAT/WHERE), exactly one in_progress, then continue. Do not start with read/bash/search alone on those asks.
65
-
66
- Ongoing: mark completed immediately when a step finishes; advance the next pending item in the same todowrite; when the user says done/approved, update via todowrite that turn.
67
-
68
- Skip only single trivial Q&A (one short fact, greeting). Multi-step Vietnamese or English asks (giải thích, chỉnh, bổ sung, help me, …) still need todos first.
69
- </Task_Management>
70
- `;
71
-
72
- /** Extra systemPrompt boost when prompt-intent detects multi-step + empty list. */
73
- export const COLD_START_BOOST = `
74
- <Task_Management_Priority>
75
- COLD START ACTIVE: the current user message is multi-step and there is no open todo list. Call todowrite before any other tool. Prefer 3–8 concrete checklist items. Keep exactly one in_progress.
76
- </Task_Management_Priority>
77
- `;
1
+ export const TODOWRITE_DESCRIPTION = `Create and maintain a structured task list for the current coding session. Tracks progress, organizes multi-step work, and surfaces status in an overlay above the editor.
2
+
3
+ ## When to Use This Tool
4
+
5
+ Use this tool **proactively** — call todo_write **before** starting the work in these scenarios:
6
+
7
+ - Complex multi-step tasks — when work needs 3+ distinct steps
8
+ - Non-trivial work that benefits from planning (implement, refactor, debug, audit)
9
+ - **Explain / explore / review a codebase or feature** across multiple files or modules — break the walkthrough into todos first
10
+ - User provides multiple tasks (numbered or comma-separated) or asks for a todo list
11
+ - After receiving new instructions — capture requirements as todos before coding or explaining
12
+ - When you start a task — mark it \`in_progress\` (exactly ONE) BEFORE beginning work
13
+ - When you finish a task — mark it \`completed\` immediately (same turn you finish), then advance the next pending item to \`in_progress\`
14
+ - When the user says work is done / approved / finished — update the matching item to \`completed\` via todo_write before continuing
15
+
16
+ ## When NOT to Use This Tool
17
+
18
+ Skip when:
19
+ - There is only a single, straightforward step (one file glance, one short answer)
20
+ - A one-line factual question with no multi-step plan
21
+ - Tracking truly adds no organizational value
22
+
23
+ Do **not** skip just because the request is "explain" or "review" — if the answer needs multiple steps or sections, use todo_write.
24
+
25
+ ## States
26
+
27
+ - \`pending\` — not started
28
+ - \`in_progress\` — actively working (exactly ONE at a time; the tool rejects >1)
29
+ - \`completed\` — finished successfully
30
+ - \`cancelled\` — no longer needed
31
+
32
+ ## Rules
33
+
34
+ - Each call **REPLACES** the entire list (full replace). Always pass the complete todos array.
35
+ - Update status in real time; don't batch completions across multiple finished steps.
36
+ - Mark \`completed\` only after the work is actually done (including verification) — never on intent alone.
37
+ - Keep exactly one \`in_progress\` while actively working. Never leave a stale \`in_progress\` after that step is finished.
38
+ - After marking an item \`completed\`, if open work remains, set the next actionable item to \`in_progress\` in the same todo_write call when you are continuing.
39
+ - If blocked, keep the active item \`in_progress\` and add a follow-up todo for the blocker.
40
+ - Items should be specific and actionable.
41
+ - Do not call todo_write and todo_read in the same parallel tool batch — write first, then read later if needed.
42
+ - Prefer the live overlay for status; use todo_read only when you need the JSON snapshot.`;
43
+
44
+ export const TODOREAD_DESCRIPTION =
45
+ "Read the current session todo list. Returns JSON of all todos with status and priority. Prefer the overlay for at-a-glance status; call after todo_write settles (not in the same parallel batch).";
46
+
47
+ export const TODOWRITE_GUIDELINES = [
48
+ "For multi-step work (3+ steps), codebase explain/explore/review, or when the user gives a list of tasks, call todo_write BEFORE starting — do not skip tracking.",
49
+ "Pass the full list every todo_write call (full replace). Keep exactly one todo in_progress; mark completed immediately when a step finishes — never leave a stale in_progress.",
50
+ "When finishing a step or when the user confirms done, call todo_write in that same turn to mark completed and advance the next pending item if work continues.",
51
+ "Do not invent TaskCreate/TaskUpdate tools — use todo_write/todo_read only.",
52
+ "Do not call todo_write and todo_read in the same parallel tool batch.",
53
+ ];
54
+
55
+ /**
56
+ * Appended to the system prompt on every agent start (pi-todotools pattern).
57
+ * Fixes cold-start: tool description alone is easy for models to ignore.
58
+ * Keep short — token cost every turn.
59
+ */
60
+ export const TASK_MANAGEMENT_SECTION = `
61
+ <Task_Management>
62
+ todo_write/todo_read are the coordination layer for multi-step work. The TUI overlay only appears after todo_write — without it the user cannot see plan/progress.
63
+
64
+ Required cold start: for explain/explore/review/implement/refactor/audit/debug/fix/polish/setup of a codebase, feature, UI, or multi-file ask — your FIRST tool call must be todo_write with a short checklist (WHAT/WHERE), exactly one in_progress, then continue. Do not start with read/bash/search alone on those asks.
65
+
66
+ Ongoing: mark completed immediately when a step finishes; advance the next pending item in the same todo_write; when the user says done/approved, update via todo_write that turn.
67
+
68
+ Skip only single trivial Q&A (one short fact, greeting). Multi-step Vietnamese or English asks (giải thích, chỉnh, bổ sung, help me, …) still need todos first.
69
+ </Task_Management>
70
+ `;
71
+
72
+ /** Extra systemPrompt boost when prompt-intent detects multi-step + empty list. */
73
+ export const COLD_START_BOOST = `
74
+ <Task_Management_Priority>
75
+ COLD START ACTIVE: the current user message is multi-step and there is no open todo list. Call todo_write before any other tool. Prefer 3–8 concrete checklist items. Keep exactly one in_progress.
76
+ </Task_Management_Priority>
77
+ `;