@juicesharp/rpiv-todo 1.5.0 → 1.5.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.
- package/config.ts +43 -0
- package/package.json +2 -1
- package/todo.ts +15 -10
package/config.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const CONFIG_DIR = join(homedir(), ".config", "rpiv-todo");
|
|
6
|
+
const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
7
|
+
|
|
8
|
+
interface GuidanceFields {
|
|
9
|
+
promptSnippet?: string;
|
|
10
|
+
promptGuidelines?: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface TodoConfig {
|
|
14
|
+
guidance?: GuidanceFields;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function loadConfig(): TodoConfig {
|
|
18
|
+
if (!existsSync(CONFIG_PATH)) return {};
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf-8")) as unknown;
|
|
21
|
+
if (parsed === null || typeof parsed !== "object") return {};
|
|
22
|
+
return parsed as TodoConfig;
|
|
23
|
+
} catch {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function validateGuidanceFields(fields: unknown): GuidanceFields {
|
|
29
|
+
if (!fields || typeof fields !== "object") return {};
|
|
30
|
+
const g = fields as Record<string, unknown>;
|
|
31
|
+
const result: GuidanceFields = {};
|
|
32
|
+
if (typeof g.promptSnippet === "string" && g.promptSnippet.length > 0) {
|
|
33
|
+
result.promptSnippet = g.promptSnippet;
|
|
34
|
+
}
|
|
35
|
+
if (
|
|
36
|
+
Array.isArray(g.promptGuidelines) &&
|
|
37
|
+
g.promptGuidelines.length > 0 &&
|
|
38
|
+
g.promptGuidelines.every((s) => typeof s === "string" && s.length > 0)
|
|
39
|
+
) {
|
|
40
|
+
result.promptGuidelines = g.promptGuidelines;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Pi extension. A todo list for the model, rendered as a live overlay that survives /reload and conversation compaction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"test": "vitest run"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
|
+
"config.ts",
|
|
30
31
|
"index.ts",
|
|
31
32
|
"locales/",
|
|
32
33
|
"todo.ts",
|
package/todo.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import { loadConfig, validateGuidanceFields } from "./config.js";
|
|
16
17
|
import { formatStatusLabel, t } from "./state/i18n-bridge.js";
|
|
17
18
|
import { replayFromBranch } from "./state/replay.js";
|
|
18
19
|
import { selectTasksByStatus, selectTodoCounts, selectVisibleTasks } from "./state/selectors.js";
|
|
@@ -61,22 +62,26 @@ export function reconstructTodoState(ctx: Parameters<typeof replayFromBranch>[0]
|
|
|
61
62
|
// Tool registration
|
|
62
63
|
// ---------------------------------------------------------------------------
|
|
63
64
|
|
|
65
|
+
export const DEFAULT_PROMPT_SNIPPET = "Manage a task list to track multi-step progress";
|
|
66
|
+
export const DEFAULT_PROMPT_GUIDELINES: string[] = [
|
|
67
|
+
"Use `todo` for complex work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.",
|
|
68
|
+
"When starting any task, mark it in_progress BEFORE beginning work. Mark it completed IMMEDIATELY when done — never batch completions. Exactly one task should be in_progress at a time.",
|
|
69
|
+
"Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors — keep it in_progress and create a new task for the blocker instead.",
|
|
70
|
+
"Task status is a 4-state machine: pending → in_progress → completed, plus deleted as a tombstone. Pass activeForm (present-continuous label, e.g. 'researching existing tool') when marking in_progress.",
|
|
71
|
+
"Use blockedBy to express dependencies (A is blocked by B). On create, pass blockedBy as the initial set. On update, use addBlockedBy / removeBlockedBy (additive merge — do not resend the full array). Cycles are rejected.",
|
|
72
|
+
"list hides tombstoned (deleted) tasks by default; pass includeDeleted:true to see them. Pass status to filter by a single status.",
|
|
73
|
+
"Subject must be short and imperative (e.g. 'Research existing tool'); description is for long-form detail. activeForm is a present-continuous label shown while in_progress.",
|
|
74
|
+
];
|
|
75
|
+
|
|
64
76
|
export function registerTodoTool(pi: ExtensionAPI): void {
|
|
77
|
+
const guidance = validateGuidanceFields(loadConfig().guidance);
|
|
65
78
|
pi.registerTool({
|
|
66
79
|
name: TOOL_NAME,
|
|
67
80
|
label: TOOL_LABEL,
|
|
68
81
|
description:
|
|
69
82
|
"Manage a task list for tracking multi-step progress. Actions: create (new task), update (change status/fields/dependencies), list (all tasks, optionally filtered by status), get (single task details), delete (tombstone), clear (reset all). Status: pending → in_progress → completed, plus deleted tombstone. Use this to plan and track multi-step work like research, design, and implementation.",
|
|
70
|
-
promptSnippet:
|
|
71
|
-
promptGuidelines:
|
|
72
|
-
"Use `todo` for complex work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.",
|
|
73
|
-
"When starting any task, mark it in_progress BEFORE beginning work. Mark it completed IMMEDIATELY when done — never batch completions. Exactly one task should be in_progress at a time.",
|
|
74
|
-
"Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors — keep it in_progress and create a new task for the blocker instead.",
|
|
75
|
-
"Task status is a 4-state machine: pending → in_progress → completed, plus deleted as a tombstone. Pass activeForm (present-continuous label, e.g. 'researching existing tool') when marking in_progress.",
|
|
76
|
-
"Use blockedBy to express dependencies (A is blocked by B). On create, pass blockedBy as the initial set. On update, use addBlockedBy / removeBlockedBy (additive merge — do not resend the full array). Cycles are rejected.",
|
|
77
|
-
"list hides tombstoned (deleted) tasks by default; pass includeDeleted:true to see them. Pass status to filter by a single status.",
|
|
78
|
-
"Subject must be short and imperative (e.g. 'Research existing tool'); description is for long-form detail. activeForm is a present-continuous label shown while in_progress.",
|
|
79
|
-
],
|
|
83
|
+
promptSnippet: guidance.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,
|
|
84
|
+
promptGuidelines: guidance.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,
|
|
80
85
|
parameters: TodoParamsSchema,
|
|
81
86
|
|
|
82
87
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|