@astralyn/pi 0.87.2 → 0.87.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/bundle/chunks/{chunk-NBIUJDV6.js → chunk-ANT4TSUE.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-RFLBIA5Z.js → chunk-CUDKRZ2V.js} +37 -24
  4. package/dist/bundle/chunks/{virtual-modules-GOHLE5JL.js → virtual-modules-Y2YZRMU3.js} +1 -1
  5. package/dist/bundle/cli.js +1 -1
  6. package/dist/bundle/index.js +1 -1
  7. package/dist/bundle/rpc-entry.js +1 -1
  8. package/dist/core/background/service.d.ts.map +1 -1
  9. package/dist/core/background/service.js +4 -3
  10. package/dist/core/background/service.js.map +1 -1
  11. package/dist/core/background/types.d.ts +11 -0
  12. package/dist/core/background/types.d.ts.map +1 -1
  13. package/dist/core/background/types.js +14 -0
  14. package/dist/core/background/types.js.map +1 -1
  15. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  16. package/dist/core/tools/tool-definition-wrapper.js +121 -1
  17. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  18. package/dist/extensions/background/actions.d.ts.map +1 -1
  19. package/dist/extensions/background/actions.js +126 -67
  20. package/dist/extensions/background/actions.js.map +1 -1
  21. package/dist/extensions/background/index.js +3 -3
  22. package/dist/extensions/background/index.js.map +1 -1
  23. package/dist/extensions/question/index.d.ts.map +1 -1
  24. package/dist/extensions/question/index.js +3 -1
  25. package/dist/extensions/question/index.js.map +1 -1
  26. package/dist/extensions/question/schema.d.ts +18 -0
  27. package/dist/extensions/question/schema.d.ts.map +1 -1
  28. package/dist/extensions/question/schema.js +52 -0
  29. package/dist/extensions/question/schema.js.map +1 -1
  30. package/dist/extensions/subagent/index.d.ts.map +1 -1
  31. package/dist/extensions/subagent/index.js +3 -1
  32. package/dist/extensions/subagent/index.js.map +1 -1
  33. package/dist/extensions/subagent/resolve.d.ts +14 -1
  34. package/dist/extensions/subagent/resolve.d.ts.map +1 -1
  35. package/dist/extensions/subagent/resolve.js +32 -18
  36. package/dist/extensions/subagent/resolve.js.map +1 -1
  37. package/dist/extensions/subagent/runner.d.ts.map +1 -1
  38. package/dist/extensions/subagent/runner.js +4 -1
  39. package/dist/extensions/subagent/runner.js.map +1 -1
  40. package/dist/extensions/subagent/schema.d.ts +9 -0
  41. package/dist/extensions/subagent/schema.d.ts.map +1 -1
  42. package/dist/extensions/subagent/schema.js +30 -1
  43. package/dist/extensions/subagent/schema.js.map +1 -1
  44. package/dist/extensions/subagent/types.d.ts +2 -0
  45. package/dist/extensions/subagent/types.d.ts.map +1 -1
  46. package/dist/extensions/subagent/types.js.map +1 -1
  47. package/dist/extensions/todo/constants.d.ts +1 -1
  48. package/dist/extensions/todo/constants.d.ts.map +1 -1
  49. package/dist/extensions/todo/constants.js +8 -8
  50. package/dist/extensions/todo/constants.js.map +1 -1
  51. package/dist/extensions/todo/index.d.ts.map +1 -1
  52. package/dist/extensions/todo/index.js +2 -1
  53. package/dist/extensions/todo/index.js.map +1 -1
  54. package/dist/extensions/todo/schema.d.ts +30 -25
  55. package/dist/extensions/todo/schema.d.ts.map +1 -1
  56. package/dist/extensions/todo/schema.js +26 -20
  57. package/dist/extensions/todo/schema.js.map +1 -1
  58. package/dist/extensions/todo/state.d.ts +12 -8
  59. package/dist/extensions/todo/state.d.ts.map +1 -1
  60. package/dist/extensions/todo/state.js +257 -171
  61. package/dist/extensions/todo/state.js.map +1 -1
  62. package/dist/extensions/todo/view.d.ts +6 -2
  63. package/dist/extensions/todo/view.d.ts.map +1 -1
  64. package/dist/extensions/todo/view.js +234 -144
  65. package/dist/extensions/todo/view.js.map +1 -1
  66. package/docs/bundled/extensions/background.md +1 -1
  67. package/docs/bundled/extensions/question.md +1 -0
  68. package/docs/bundled/extensions/subagent.md +3 -1
  69. package/docs/bundled/extensions/todo.md +35 -23
  70. package/docs/extensions.md +2 -0
  71. package/npm-shrinkwrap.json +2 -2
  72. package/package.json +1 -1
@@ -10,7 +10,7 @@ export declare const TODO_MAX_BATCH_ITEMS = 20;
10
10
  /** Input limits keep task snapshots and model-facing output bounded. */
11
11
  export declare const TODO_MAX_SUBJECT_LENGTH = 160;
12
12
  export declare const TODO_MAX_DESCRIPTION_LENGTH = 500;
13
- export declare const TODO_TOOL_DESCRIPTION = "Manage the conversation's task list for multi-step coding work. create atomically adds pending tasks; update edits one task by id and requires at least one of subject, description, or status; list returns every remaining task with its description, active first; delete removes tasks by ids. The list holds at most 20 tasks including completed ones, and ids are never reused. Exactly one task may be in_progress, so setting one demotes any other active task to pending; any transition is allowed, including reopening a completed task. A call that fails validation, including a delete naming an id that does not exist, leaves the list unchanged.\n\n{\"action\": \"create\", \"items\": [{\"subject\": \"Wire parser\", \"description\": \"Parser handles the config format\"}, {\"subject\": \"Test parser\", \"description\": \"Parser tests pass\"}]}\n{\"action\": \"update\", \"id\": 2, \"status\": \"in_progress\"}\n{\"action\": \"update\", \"id\": 2, \"status\": \"completed\", \"description\": \"Parser verified against config fixtures\"}\n{\"action\": \"delete\", \"ids\": [3]}";
13
+ export declare const TODO_TOOL_DESCRIPTION = "Manage the conversation's task list for multi-step coding work. One call applies a patch: create adds tasks (status defaults to pending), update edits tasks by id (blank or omitted fields are kept), delete removes tasks by id. Omit or leave empty any group you do not need; call with {} to list every task with its description. Exactly one task may be in_progress: setting one demotes the others. The list holds 20 tasks; when full, the oldest completed tasks are removed automatically. A call that fails validation leaves the list unchanged.\n\n{\"create\": [{\"subject\": \"Wire parser\", \"description\": \"Parser handles the config format\", \"status\": \"in_progress\"}]}\n{\"update\": [{\"id\": 1, \"status\": \"completed\"}, {\"id\": 2, \"status\": \"in_progress\"}]}\n{\"delete\": [3]}";
14
14
  export declare const TODO_PROMPT_SNIPPET = "Track multi-step coding work with a small outcome-oriented task list";
15
15
  export declare const TODO_PROMPT_GUIDELINES: string[];
16
16
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,0EAA0E;AAC1E,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAM/C,eAAO,MAAM,qBAAqB,wjCAKD,CAAC;AAElC,eAAO,MAAM,mBAAmB,yEAAyE,CAAC;AAE1G,eAAO,MAAM,sBAAsB,UAKlC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,0EAA0E;AAC1E,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAO/C,eAAO,MAAM,qBAAqB,8xBAIlB,CAAC;AAEjB,eAAO,MAAM,mBAAmB,yEAAyE,CAAC;AAE1G,eAAO,MAAM,sBAAsB,UAKlC,CAAC"}
@@ -11,15 +11,15 @@ export const TODO_MAX_BATCH_ITEMS = 20;
11
11
  export const TODO_MAX_SUBJECT_LENGTH = 160;
12
12
  export const TODO_MAX_DESCRIPTION_LENGTH = 500;
13
13
  // Mechanism plus the cross-field rules TodoParamsSchema cannot state (total
14
- // capacity, id reuse, the update-needs-one-field rule). Per-parameter bounds and
15
- // wording live in the schema. The single-in_progress rule is stated in both
16
- // places on purpose: it is the invariant models break most often.
17
- export const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work. create atomically adds pending tasks; update edits one task by id and requires at least one of subject, description, or status; list returns every remaining task with its description, active first; delete removes tasks by ids. The list holds at most 20 tasks including completed ones, and ids are never reused. Exactly one task may be in_progress, so setting one demotes any other active task to pending; any transition is allowed, including reopening a completed task. A call that fails validation, including a delete naming an id that does not exist, leaves the list unchanged.
14
+ // capacity with automatic reclaim, the single-in_progress rule, atomicity).
15
+ // Per-parameter bounds and wording live in the schema. The single-in_progress
16
+ // rule is stated in both places on purpose: it is the invariant models break
17
+ // most often.
18
+ export const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work. One call applies a patch: create adds tasks (status defaults to pending), update edits tasks by id (blank or omitted fields are kept), delete removes tasks by id. Omit or leave empty any group you do not need; call with {} to list every task with its description. Exactly one task may be in_progress: setting one demotes the others. The list holds 20 tasks; when full, the oldest completed tasks are removed automatically. A call that fails validation leaves the list unchanged.
18
19
 
19
- {"action": "create", "items": [{"subject": "Wire parser", "description": "Parser handles the config format"}, {"subject": "Test parser", "description": "Parser tests pass"}]}
20
- {"action": "update", "id": 2, "status": "in_progress"}
21
- {"action": "update", "id": 2, "status": "completed", "description": "Parser verified against config fixtures"}
22
- {"action": "delete", "ids": [3]}`;
20
+ {"create": [{"subject": "Wire parser", "description": "Parser handles the config format", "status": "in_progress"}]}
21
+ {"update": [{"id": 1, "status": "completed"}, {"id": 2, "status": "in_progress"}]}
22
+ {"delete": [3]}`;
23
23
  export const TODO_PROMPT_SNIPPET = "Track multi-step coding work with a small outcome-oriented task list";
24
24
  export const TODO_PROMPT_GUIDELINES = [
25
25
  "Use `todo` for work with three or more meaningful steps, for user-provided task lists, and in long sessions where progress can drift; skip it for trivial single-step tasks and simple Q&A.",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAE1C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,4EAA4E;AAC5E,iFAAiF;AACjF,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;iCAKJ,CAAC;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,sEAAsE,CAAC;AAE1G,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,6LAA6L;IAC7L,gLAAgL;IAChL,6GAA6G;IAC7G,2HAA2H;CAC3H,CAAC","sourcesContent":["/**\n * todo/constants.ts — tool identity, command name, input bounds, and prompt copy.\n */\n\nexport const TODO_TOOL_NAME = \"todo\";\nexport const TODO_TOOL_LABEL = \"Todo\";\nexport const TODOS_COMMAND_NAME = \"todos\";\n\n/** Hard capacity of the task list and of a single create/delete batch. */\nexport const TODO_MAX_ITEMS = 20;\nexport const TODO_MAX_BATCH_ITEMS = 20;\n\n/** Input limits keep task snapshots and model-facing output bounded. */\nexport const TODO_MAX_SUBJECT_LENGTH = 160;\nexport const TODO_MAX_DESCRIPTION_LENGTH = 500;\n\n// Mechanism plus the cross-field rules TodoParamsSchema cannot state (total\n// capacity, id reuse, the update-needs-one-field rule). Per-parameter bounds and\n// wording live in the schema. The single-in_progress rule is stated in both\n// places on purpose: it is the invariant models break most often.\nexport const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work. create atomically adds pending tasks; update edits one task by id and requires at least one of subject, description, or status; list returns every remaining task with its description, active first; delete removes tasks by ids. The list holds at most 20 tasks including completed ones, and ids are never reused. Exactly one task may be in_progress, so setting one demotes any other active task to pending; any transition is allowed, including reopening a completed task. A call that fails validation, including a delete naming an id that does not exist, leaves the list unchanged.\n\n{\"action\": \"create\", \"items\": [{\"subject\": \"Wire parser\", \"description\": \"Parser handles the config format\"}, {\"subject\": \"Test parser\", \"description\": \"Parser tests pass\"}]}\n{\"action\": \"update\", \"id\": 2, \"status\": \"in_progress\"}\n{\"action\": \"update\", \"id\": 2, \"status\": \"completed\", \"description\": \"Parser verified against config fixtures\"}\n{\"action\": \"delete\", \"ids\": [3]}`;\n\nexport const TODO_PROMPT_SNIPPET = \"Track multi-step coding work with a small outcome-oriented task list\";\n\nexport const TODO_PROMPT_GUIDELINES = [\n\t\"Use `todo` for work with three or more meaningful steps, for user-provided task lists, and in long sessions where progress can drift; skip it for trivial single-step tasks and simple Q&A.\",\n\t\"Keep exactly one `todo` task in_progress: mark it before starting the work, and completed only after its description is satisfied — never while tests fail or work is partial.\",\n\t\"When blocked, leave the `todo` task pending and create a task for the blocker instead of faking completion.\",\n\t\"Keep the `todo` list short: list before create to avoid duplicates, work in id order, and delete obsolete tasks promptly.\",\n];\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAE1C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,cAAc;AACd,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;gBAIrB,CAAC;AAEjB,MAAM,CAAC,MAAM,mBAAmB,GAAG,sEAAsE,CAAC;AAE1G,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,6LAA6L;IAC7L,gLAAgL;IAChL,6GAA6G;IAC7G,2HAA2H;CAC3H,CAAC","sourcesContent":["/**\n * todo/constants.ts — tool identity, command name, input bounds, and prompt copy.\n */\n\nexport const TODO_TOOL_NAME = \"todo\";\nexport const TODO_TOOL_LABEL = \"Todo\";\nexport const TODOS_COMMAND_NAME = \"todos\";\n\n/** Hard capacity of the task list and of a single create/delete batch. */\nexport const TODO_MAX_ITEMS = 20;\nexport const TODO_MAX_BATCH_ITEMS = 20;\n\n/** Input limits keep task snapshots and model-facing output bounded. */\nexport const TODO_MAX_SUBJECT_LENGTH = 160;\nexport const TODO_MAX_DESCRIPTION_LENGTH = 500;\n\n// Mechanism plus the cross-field rules TodoParamsSchema cannot state (total\n// capacity with automatic reclaim, the single-in_progress rule, atomicity).\n// Per-parameter bounds and wording live in the schema. The single-in_progress\n// rule is stated in both places on purpose: it is the invariant models break\n// most often.\nexport const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work. One call applies a patch: create adds tasks (status defaults to pending), update edits tasks by id (blank or omitted fields are kept), delete removes tasks by id. Omit or leave empty any group you do not need; call with {} to list every task with its description. Exactly one task may be in_progress: setting one demotes the others. The list holds 20 tasks; when full, the oldest completed tasks are removed automatically. A call that fails validation leaves the list unchanged.\n\n{\"create\": [{\"subject\": \"Wire parser\", \"description\": \"Parser handles the config format\", \"status\": \"in_progress\"}]}\n{\"update\": [{\"id\": 1, \"status\": \"completed\"}, {\"id\": 2, \"status\": \"in_progress\"}]}\n{\"delete\": [3]}`;\n\nexport const TODO_PROMPT_SNIPPET = \"Track multi-step coding work with a small outcome-oriented task list\";\n\nexport const TODO_PROMPT_GUIDELINES = [\n\t\"Use `todo` for work with three or more meaningful steps, for user-provided task lists, and in long sessions where progress can drift; skip it for trivial single-step tasks and simple Q&A.\",\n\t\"Keep exactly one `todo` task in_progress: mark it before starting the work, and completed only after its description is satisfied — never while tests fail or work is partial.\",\n\t\"When blocked, leave the `todo` task pending and create a task for the blocker instead of faking completion.\",\n\t\"Keep the `todo` list short: list before create to avoid duplicates, work in id order, and delete obsolete tasks promptly.\",\n];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAEN,KAAK,YAAY,EAGjB,MAAM,gCAAgC,CAAC;AA6BxC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAwEnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAEN,KAAK,YAAY,EAGjB,MAAM,gCAAgC,CAAC;AA6BxC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAyEnD"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * todo — Pi-native task tracking for multi-step work.
3
3
  *
4
- * State is conversation-backed: every tool result carries a full v2 snapshot
4
+ * State is conversation-backed: every tool result carries a full v3 snapshot
5
5
  * in `details`, and lifecycle handlers replay the current branch into the
6
6
  * closure store created by createTodoStore(). Resume, /reload, and /tree
7
7
  * navigation stay aligned with the conversation without a disk database or
@@ -36,6 +36,7 @@ export default function todo(pi) {
36
36
  promptSnippet: TODO_PROMPT_SNIPPET,
37
37
  promptGuidelines: TODO_PROMPT_GUIDELINES,
38
38
  parameters: TodoParamsSchema,
39
+ constrainedSampling: { type: "json_schema", strict: "prefer" },
39
40
  executionMode: "sequential",
40
41
  // Consecutive todo calls collapse into one run like read/find's `explore`
41
42
  // group; the widget already carries the live list, so the transcript only
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAGN,4BAA4B,GAE5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAkB,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,SAAS,UAAU,CAAC,GAAmB,EAAE,KAAgB;IACxD,4EAA4E;IAC5E,yEAAyE;IACzE,wEAAwE;IACxE,IAAI,CAAC;QACJ,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;IACvD,CAAC;AACF,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAgB;IAC5C,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,MAA8B,CAAC;IAEnC,EAAE,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,qBAAqB;QAClC,aAAa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Pi-native task tracking for multi-step work.\n *\n * State is conversation-backed: every tool result carries a full v2 snapshot\n * in `details`, and lifecycle handlers replay the current branch into the\n * closure store created by createTodoStore(). Resume, /reload, and /tree\n * navigation stay aligned with the conversation without a disk database or\n * any per-session global state.\n */\nimport { Text } from \"@earendil-works/pi-tui\";\nimport {\n\ttype AgentToolResult,\n\ttype ExtensionAPI,\n\tisStaleExtensionContextError,\n\ttype ToolExecutionMode,\n} from \"../../core/extensions/types.ts\";\nimport {\n\tTODO_PROMPT_GUIDELINES,\n\tTODO_PROMPT_SNIPPET,\n\tTODO_TOOL_DESCRIPTION,\n\tTODO_TOOL_LABEL,\n\tTODO_TOOL_NAME,\n\tTODOS_COMMAND_NAME,\n} from \"./constants.ts\";\nimport { type TodoDetails, TodoParamsSchema } from \"./schema.ts\";\nimport { createTodoStore, replayTodosFromBranch, type TodoStore } from \"./state.ts\";\nimport { formatCommandList, formatTodoCall, formatTodoContent, formatTodoGroupCall } from \"./view.ts\";\nimport { TodoWidget } from \"./widget.ts\";\n\ninterface TodoSessionCtx {\n\tsessionManager: { getBranch(): Iterable<unknown> };\n}\n\nfunction safeReplay(ctx: TodoSessionCtx, store: TodoStore): void {\n\t// Every ctx.sessionManager access stays inside the guard: a lifecycle event\n\t// can race session replacement (resume, /tree, /reload), and a stale ctx\n\t// just means another session took over — nothing left to replay for it.\n\ttry {\n\t\tstore.replaceState(replayTodosFromBranch(ctx));\n\t} catch (error) {\n\t\tif (!isStaleExtensionContextError(error)) throw error;\n\t}\n}\n\nexport default function todo(pi: ExtensionAPI): void {\n\tconst store = createTodoStore();\n\tlet widget: TodoWidget | undefined;\n\n\tpi.registerTool({\n\t\tname: TODO_TOOL_NAME,\n\t\tlabel: TODO_TOOL_LABEL,\n\t\tdescription: TODO_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TODO_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TODO_PROMPT_GUIDELINES,\n\t\tparameters: TodoParamsSchema,\n\t\texecutionMode: \"sequential\" as ToolExecutionMode,\n\t\t// Consecutive todo calls collapse into one run like read/find's `explore`\n\t\t// group; the widget already carries the live list, so the transcript only\n\t\t// needs the sequence of operations.\n\t\ttoolGroup: TODO_TOOL_NAME,\n\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate): Promise<AgentToolResult<TodoDetails>> {\n\t\t\t// Validation errors throw before any state mutation, so the store is\n\t\t\t// untouched on failure.\n\t\t\tconst details = store.execute(params);\n\t\t\tconst text = formatTodoContent(details.change, details.state);\n\t\t\treturn { content: [{ type: \"text\", text }], details };\n\t\t},\n\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tcontext.toolGroupSummary\n\t\t\t\t\t? formatTodoGroupCall(args, theme, context)\n\t\t\t\t\t: formatTodoCall(args, theme, context.expanded, context.result),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t});\n\n\tpi.registerCommand(TODOS_COMMAND_NAME, {\n\t\tdescription: \"Show the complete todo list for the current conversation branch\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"/todos requires an interactive UI.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.ui.notify(formatCommandList(store.getState()), \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsafeReplay(ctx, store);\n\t\tif (ctx.hasUI) {\n\t\t\twidget ??= new TodoWidget(() => store.getState());\n\t\t\twidget.setUI(ctx.ui);\n\t\t\twidget.update();\n\t\t}\n\t});\n\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tsafeReplay(ctx, store);\n\t\twidget?.update();\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, _ctx) => {\n\t\t// The store belongs to this extension runtime and is collected with it;\n\t\t// the next runtime restores its own store during session_start.\n\t\twidget?.dispose();\n\t\twidget = undefined;\n\t});\n\n\tpi.on(\"tool_execution_end\", async (event) => {\n\t\tif (event.toolName !== TODO_TOOL_NAME || event.isError) return;\n\t\twidget?.update();\n\t});\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAGN,4BAA4B,GAE5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAkB,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,SAAS,UAAU,CAAC,GAAmB,EAAE,KAAgB;IACxD,4EAA4E;IAC5E,yEAAyE;IACzE,wEAAwE;IACxE,IAAI,CAAC;QACJ,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;IACvD,CAAC;AACF,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAgB;IAC5C,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,MAA8B,CAAC;IAEnC,EAAE,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,qBAAqB;QAClC,aAAa,EAAE,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M,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * todo — Pi-native task tracking for multi-step work.\n *\n * State is conversation-backed: every tool result carries a full v3 snapshot\n * in `details`, and lifecycle handlers replay the current branch into the\n * closure store created by createTodoStore(). Resume, /reload, and /tree\n * navigation stay aligned with the conversation without a disk database or\n * any per-session global state.\n */\nimport { Text } from \"@earendil-works/pi-tui\";\nimport {\n\ttype AgentToolResult,\n\ttype ExtensionAPI,\n\tisStaleExtensionContextError,\n\ttype ToolExecutionMode,\n} from \"../../core/extensions/types.ts\";\nimport {\n\tTODO_PROMPT_GUIDELINES,\n\tTODO_PROMPT_SNIPPET,\n\tTODO_TOOL_DESCRIPTION,\n\tTODO_TOOL_LABEL,\n\tTODO_TOOL_NAME,\n\tTODOS_COMMAND_NAME,\n} from \"./constants.ts\";\nimport { type TodoDetails, TodoParamsSchema } from \"./schema.ts\";\nimport { createTodoStore, replayTodosFromBranch, type TodoStore } from \"./state.ts\";\nimport { formatCommandList, formatTodoCall, formatTodoContent, formatTodoGroupCall } from \"./view.ts\";\nimport { TodoWidget } from \"./widget.ts\";\n\ninterface TodoSessionCtx {\n\tsessionManager: { getBranch(): Iterable<unknown> };\n}\n\nfunction safeReplay(ctx: TodoSessionCtx, store: TodoStore): void {\n\t// Every ctx.sessionManager access stays inside the guard: a lifecycle event\n\t// can race session replacement (resume, /tree, /reload), and a stale ctx\n\t// just means another session took over — nothing left to replay for it.\n\ttry {\n\t\tstore.replaceState(replayTodosFromBranch(ctx));\n\t} catch (error) {\n\t\tif (!isStaleExtensionContextError(error)) throw error;\n\t}\n}\n\nexport default function todo(pi: ExtensionAPI): void {\n\tconst store = createTodoStore();\n\tlet widget: TodoWidget | undefined;\n\n\tpi.registerTool({\n\t\tname: TODO_TOOL_NAME,\n\t\tlabel: TODO_TOOL_LABEL,\n\t\tdescription: TODO_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TODO_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TODO_PROMPT_GUIDELINES,\n\t\tparameters: TodoParamsSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\texecutionMode: \"sequential\" as ToolExecutionMode,\n\t\t// Consecutive todo calls collapse into one run like read/find's `explore`\n\t\t// group; the widget already carries the live list, so the transcript only\n\t\t// needs the sequence of operations.\n\t\ttoolGroup: TODO_TOOL_NAME,\n\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate): Promise<AgentToolResult<TodoDetails>> {\n\t\t\t// Validation errors throw before any state mutation, so the store is\n\t\t\t// untouched on failure.\n\t\t\tconst details = store.execute(params);\n\t\t\tconst text = formatTodoContent(details.change, details.state);\n\t\t\treturn { content: [{ type: \"text\", text }], details };\n\t\t},\n\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tcontext.toolGroupSummary\n\t\t\t\t\t? formatTodoGroupCall(args, theme, context)\n\t\t\t\t\t: formatTodoCall(args, theme, context.expanded, context.result),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t});\n\n\tpi.registerCommand(TODOS_COMMAND_NAME, {\n\t\tdescription: \"Show the complete todo list for the current conversation branch\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"/todos requires an interactive UI.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.ui.notify(formatCommandList(store.getState()), \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsafeReplay(ctx, store);\n\t\tif (ctx.hasUI) {\n\t\t\twidget ??= new TodoWidget(() => store.getState());\n\t\t\twidget.setUI(ctx.ui);\n\t\t\twidget.update();\n\t\t}\n\t});\n\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tsafeReplay(ctx, store);\n\t\twidget?.update();\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, _ctx) => {\n\t\t// The store belongs to this extension runtime and is collected with it;\n\t\t// the next runtime restores its own store during session_start.\n\t\twidget?.dispose();\n\t\twidget = undefined;\n\t});\n\n\tpi.on(\"tool_execution_end\", async (event) => {\n\t\tif (event.toolName !== TODO_TOOL_NAME || event.isError) return;\n\t\twidget?.update();\n\t});\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { type Static, Type } from "typebox";
2
2
  export type TodoStatus = "pending" | "in_progress" | "completed";
3
- export type TodoAction = "create" | "update" | "list" | "delete";
4
3
  export interface TodoItem {
5
4
  id: number;
6
5
  subject: string;
@@ -12,42 +11,48 @@ export interface TodoState {
12
11
  nextId: number;
13
12
  }
14
13
  /** Current shape of snapshots written to todo tool results. */
15
- export declare const TODO_DETAILS_SCHEMA_VERSION = 2;
16
- /** Single operation model: what one todo call did, independent of params. */
17
- export type TodoChange = {
18
- kind: "create";
19
- ids: number[];
20
- } | {
21
- kind: "update";
22
- id: number;
23
- from: TodoStatus;
24
- to: TodoStatus;
25
- demotedId?: number;
26
- } | {
27
- kind: "list";
28
- } | {
29
- kind: "delete";
30
- removed: Array<{
14
+ export declare const TODO_DETAILS_SCHEMA_VERSION = 3;
15
+ /**
16
+ * What one call changed, as a flat patch record. Every list is empty for a
17
+ * pure list call; `demotedId` is present only when an activation pushed the
18
+ * previously active task back to pending.
19
+ */
20
+ export interface TodoChange {
21
+ created: number[];
22
+ updated: Array<{
23
+ id: number;
24
+ from: TodoStatus;
25
+ to: TodoStatus;
26
+ }>;
27
+ deleted: Array<{
28
+ id: number;
29
+ subject: string;
30
+ }>;
31
+ absent: number[];
32
+ evicted: Array<{
31
33
  id: number;
32
34
  subject: string;
33
35
  }>;
34
- };
36
+ demotedId?: number;
37
+ }
35
38
  export interface TodoDetails {
36
39
  schemaVersion: typeof TODO_DETAILS_SCHEMA_VERSION;
37
40
  change: TodoChange;
38
41
  state: TodoState;
39
42
  }
40
43
  export declare const TodoParamsSchema: Type.TObject<{
41
- action: Type.TUnsafe<"update" | "list" | "delete" | "create">;
42
- items: Type.TOptional<Type.TArray<Type.TObject<{
44
+ create: Type.TOptional<Type.TArray<Type.TObject<{
43
45
  subject: Type.TString;
44
46
  description: Type.TString;
47
+ status: Type.TOptional<Type.TUnsafe<"pending" | "completed" | "in_progress">>;
48
+ }>>>;
49
+ update: Type.TOptional<Type.TArray<Type.TObject<{
50
+ id: Type.TInteger;
51
+ subject: Type.TOptional<Type.TString>;
52
+ description: Type.TOptional<Type.TString>;
53
+ status: Type.TOptional<Type.TUnsafe<"pending" | "completed" | "in_progress">>;
45
54
  }>>>;
46
- id: Type.TOptional<Type.TInteger>;
47
- subject: Type.TOptional<Type.TString>;
48
- description: Type.TOptional<Type.TString>;
49
- status: Type.TOptional<Type.TUnsafe<"pending" | "completed" | "in_progress">>;
50
- ids: Type.TOptional<Type.TArray<Type.TInteger>>;
55
+ delete: Type.TOptional<Type.TArray<Type.TInteger>>;
51
56
  }>;
52
57
  export type TodoParams = Static<typeof TodoParamsSchema>;
53
58
  export declare const EMPTY_TODO_STATE: TodoState;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACzB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,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KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,+DAA+D;AAC/D,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,EAAE,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACjE,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC3B,aAAa,EAAE,OAAO,2BAA2B,CAAC;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;CACjB;AA4CD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;EAsB5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,SAAoC,CAAC"}
@@ -1,17 +1,19 @@
1
1
  /**
2
- * todo/schema.ts — v2 tool parameters, state shape, and operation model.
2
+ * todo/schema.ts — v3 tool parameters, state shape, and operation model.
3
+ *
4
+ * One call is one patch: the three group fields (create, update, delete) are
5
+ * applied together, there is no action discriminator. The shape is built for
6
+ * strict constrained sampling: optional groups can be null or empty and every
7
+ * filler value a strict sampler may emit ([], "", null) is a harmless no-op.
3
8
  */
4
9
  import { StringEnum } from "@earendil-works/pi-ai";
5
10
  import { Type } from "typebox";
6
11
  import { TODO_MAX_BATCH_ITEMS, TODO_MAX_DESCRIPTION_LENGTH, TODO_MAX_SUBJECT_LENGTH } from "./constants.js";
7
12
  /** Current shape of snapshots written to todo tool results. */
8
- export const TODO_DETAILS_SCHEMA_VERSION = 2;
13
+ export const TODO_DETAILS_SCHEMA_VERSION = 3;
9
14
  const StatusSchema = StringEnum(["pending", "in_progress", "completed"], {
10
15
  description: "Task status: pending for future work, in_progress for the single active task, completed for verified done work. Exactly one task may be in_progress; setting one demotes any other active task to pending.",
11
16
  });
12
- const ActionSchema = StringEnum(["create", "update", "list", "delete"], {
13
- description: "Todo operation: create one or many pending tasks from the ordered items array, update one task by id, list all remaining tasks, or delete obsolete tasks by ids. Parameters that do not apply to the chosen action are rejected.",
14
- });
15
17
  const TaskIdSchema = Type.Integer({ minimum: 1, description: "Positive task id." });
16
18
  const CreateItemSchema = Type.Object({
17
19
  subject: Type.String({
@@ -22,29 +24,33 @@ const CreateItemSchema = Type.Object({
22
24
  maxLength: TODO_MAX_DESCRIPTION_LENGTH,
23
25
  description: "What done means for this task: acceptance criteria or verification detail.",
24
26
  }),
25
- });
26
- export const TodoParamsSchema = Type.Object({
27
- action: ActionSchema,
28
- items: Type.Optional(Type.Array(CreateItemSchema, {
29
- minItems: 1,
30
- maxItems: TODO_MAX_BATCH_ITEMS,
31
- description: "create only: 1 to 20 pending tasks, created atomically in input order.",
32
- })),
33
- id: Type.Optional(TaskIdSchema),
27
+ status: Type.Optional(StatusSchema),
28
+ }, { additionalProperties: false });
29
+ const UpdateItemSchema = Type.Object({
30
+ id: TaskIdSchema,
34
31
  subject: Type.Optional(Type.String({
35
32
  maxLength: TODO_MAX_SUBJECT_LENGTH,
36
- description: "update only: replacement subject.",
33
+ description: "Replacement subject; blank or omitted keeps the current one.",
37
34
  })),
38
35
  description: Type.Optional(Type.String({
39
36
  maxLength: TODO_MAX_DESCRIPTION_LENGTH,
40
- description: "update only: replacement description (what done means).",
37
+ description: "Replacement description (what done means); blank or omitted keeps the current one.",
41
38
  })),
42
39
  status: Type.Optional(StatusSchema),
43
- ids: Type.Optional(Type.Array(TaskIdSchema, {
44
- minItems: 1,
40
+ }, { additionalProperties: false });
41
+ export const TodoParamsSchema = Type.Object({
42
+ create: Type.Optional(Type.Array(CreateItemSchema, {
45
43
  maxItems: TODO_MAX_BATCH_ITEMS,
46
- description: "delete only: 1 to 20 ids to remove from the current list; duplicates are ignored.",
44
+ description: "Tasks to add, created atomically in input order; status defaults to pending.",
47
45
  })),
48
- });
46
+ update: Type.Optional(Type.Array(UpdateItemSchema, {
47
+ maxItems: TODO_MAX_BATCH_ITEMS,
48
+ description: "Task edits by id; blank or omitted fields keep their current values.",
49
+ })),
50
+ delete: Type.Optional(Type.Array(TaskIdSchema, {
51
+ maxItems: TODO_MAX_BATCH_ITEMS,
52
+ description: "Ids to remove from the current list; deleting an id that is already absent is a no-op.",
53
+ })),
54
+ }, { additionalProperties: false });
49
55
  export const EMPTY_TODO_STATE = { items: [], nextId: 1 };
50
56
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/extensions/todo/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAiB5G,+DAA+D;AAC/D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAe7C,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAU,EAAE;IACjF,WAAW,EACV,4MAA4M;CAC7M,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CA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C9B,WAAW,EAAE,mFAAmF;KAChG,CAAC,CACF;CACD,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC","sourcesContent":["/**\n * todo/schema.ts — v2 tool parameters, state shape, and operation model.\n */\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { TODO_MAX_BATCH_ITEMS, TODO_MAX_DESCRIPTION_LENGTH, TODO_MAX_SUBJECT_LENGTH } from \"./constants.ts\";\n\nexport type TodoStatus = \"pending\" | \"in_progress\" | \"completed\";\nexport type TodoAction = \"create\" | \"update\" | \"list\" | \"delete\";\n\nexport interface TodoItem {\n\tid: number;\n\tsubject: string;\n\tdescription: string;\n\tstatus: TodoStatus;\n}\n\nexport interface TodoState {\n\titems: TodoItem[];\n\tnextId: number;\n}\n\n/** Current shape of snapshots written to todo tool results. */\nexport const TODO_DETAILS_SCHEMA_VERSION = 2;\n\n/** Single operation model: what one todo call did, independent of params. */\nexport type TodoChange =\n\t| { kind: \"create\"; ids: number[] }\n\t| { kind: \"update\"; id: number; from: TodoStatus; to: TodoStatus; demotedId?: number }\n\t| { kind: \"list\" }\n\t| { kind: \"delete\"; removed: Array<{ id: number; subject: string }> };\n\nexport interface TodoDetails {\n\tschemaVersion: typeof TODO_DETAILS_SCHEMA_VERSION;\n\tchange: TodoChange;\n\tstate: TodoState;\n}\n\nconst StatusSchema = StringEnum([\"pending\", \"in_progress\", \"completed\"] as const, {\n\tdescription:\n\t\t\"Task status: pending for future work, in_progress for the single active task, completed for verified done work. Exactly one task may be in_progress; setting one demotes any other active task to pending.\",\n});\n\nconst ActionSchema = StringEnum([\"create\", \"update\", \"list\", \"delete\"] as const, {\n\tdescription:\n\t\t\"Todo operation: create one or many pending tasks from the ordered items array, update one task by id, list all remaining tasks, or delete obsolete tasks by ids. Parameters that do not apply to the chosen action are rejected.\",\n});\n\nconst TaskIdSchema = Type.Integer({ minimum: 1, description: \"Positive task id.\" });\n\nconst CreateItemSchema = Type.Object({\n\tsubject: Type.String({\n\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\tdescription: \"Short imperative task subject; a reviewable unit of work.\",\n\t}),\n\tdescription: Type.String({\n\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\tdescription: \"What done means for this task: acceptance criteria or verification detail.\",\n\t}),\n});\n\nexport const TodoParamsSchema = Type.Object({\n\taction: ActionSchema,\n\titems: Type.Optional(\n\t\tType.Array(CreateItemSchema, {\n\t\t\tminItems: 1,\n\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\tdescription: \"create only: 1 to 20 pending tasks, created atomically in input order.\",\n\t\t}),\n\t),\n\tid: Type.Optional(TaskIdSchema),\n\tsubject: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\t\tdescription: \"update only: replacement subject.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\t\tdescription: \"update only: replacement description (what done means).\",\n\t\t}),\n\t),\n\tstatus: Type.Optional(StatusSchema),\n\tids: Type.Optional(\n\t\tType.Array(TaskIdSchema, {\n\t\t\tminItems: 1,\n\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\tdescription: \"delete only: 1 to 20 ids to remove from the current list; duplicates are ignored.\",\n\t\t}),\n\t),\n});\n\nexport type TodoParams = Static<typeof TodoParamsSchema>;\n\nexport const EMPTY_TODO_STATE: TodoState = { items: [], nextId: 1 };\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/extensions/todo/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC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AEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAC1C;IACC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;QAC5B,QAAQ,EAAE,oBAAoB;QAC9B,WAAW,EAAE,8EAA8E;KAC3F,CAAC,CACF;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;QAC5B,QAAQ,EAAE,oBAAoB;QAC9B,WAAW,EAAE,sEAAsE;KACnF,CAAC,CACF;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACxB,QAAQ,EAAE,oBAAoB;QAC9B,WAAW,EAAE,wFAAwF;KACrG,CAAC,CACF;CACD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAIF,MAAM,CAAC,MAAM,gBAAgB,GAAc,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC","sourcesContent":["/**\n * todo/schema.ts — v3 tool parameters, state shape, and operation model.\n *\n * One call is one patch: the three group fields (create, update, delete) are\n * applied together, there is no action discriminator. The shape is built for\n * strict constrained sampling: optional groups can be null or empty and every\n * filler value a strict sampler may emit ([], \"\", null) is a harmless no-op.\n */\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { TODO_MAX_BATCH_ITEMS, TODO_MAX_DESCRIPTION_LENGTH, TODO_MAX_SUBJECT_LENGTH } from \"./constants.ts\";\n\nexport type TodoStatus = \"pending\" | \"in_progress\" | \"completed\";\n\nexport interface TodoItem {\n\tid: number;\n\tsubject: string;\n\tdescription: string;\n\tstatus: TodoStatus;\n}\n\nexport interface TodoState {\n\titems: TodoItem[];\n\tnextId: number;\n}\n\n/** Current shape of snapshots written to todo tool results. */\nexport const TODO_DETAILS_SCHEMA_VERSION = 3;\n\n/**\n * What one call changed, as a flat patch record. Every list is empty for a\n * pure list call; `demotedId` is present only when an activation pushed the\n * previously active task back to pending.\n */\nexport interface TodoChange {\n\tcreated: number[];\n\tupdated: Array<{ id: number; from: TodoStatus; to: TodoStatus }>;\n\tdeleted: Array<{ id: number; subject: string }>;\n\tabsent: number[];\n\tevicted: Array<{ id: number; subject: string }>;\n\tdemotedId?: number;\n}\n\nexport interface TodoDetails {\n\tschemaVersion: typeof TODO_DETAILS_SCHEMA_VERSION;\n\tchange: TodoChange;\n\tstate: TodoState;\n}\n\nconst StatusSchema = StringEnum([\"pending\", \"in_progress\", \"completed\"] as const, {\n\tdescription:\n\t\t\"Task status: pending for future work, in_progress for the single active task, completed for verified done work. Exactly one task may be in_progress; setting one demotes any other active task to pending.\",\n});\n\nconst TaskIdSchema = Type.Integer({ minimum: 1, description: \"Positive task id.\" });\n\nconst CreateItemSchema = Type.Object(\n\t{\n\t\tsubject: Type.String({\n\t\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\t\tdescription: \"Short imperative task subject; a reviewable unit of work.\",\n\t\t}),\n\t\tdescription: Type.String({\n\t\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\t\tdescription: \"What done means for this task: acceptance criteria or verification detail.\",\n\t\t}),\n\t\tstatus: Type.Optional(StatusSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst UpdateItemSchema = Type.Object(\n\t{\n\t\tid: TaskIdSchema,\n\t\tsubject: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\t\t\tdescription: \"Replacement subject; blank or omitted keeps the current one.\",\n\t\t\t}),\n\t\t),\n\t\tdescription: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\t\t\tdescription: \"Replacement description (what done means); blank or omitted keeps the current one.\",\n\t\t\t}),\n\t\t),\n\t\tstatus: Type.Optional(StatusSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const TodoParamsSchema = Type.Object(\n\t{\n\t\tcreate: Type.Optional(\n\t\t\tType.Array(CreateItemSchema, {\n\t\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\t\tdescription: \"Tasks to add, created atomically in input order; status defaults to pending.\",\n\t\t\t}),\n\t\t),\n\t\tupdate: Type.Optional(\n\t\t\tType.Array(UpdateItemSchema, {\n\t\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\t\tdescription: \"Task edits by id; blank or omitted fields keep their current values.\",\n\t\t\t}),\n\t\t),\n\t\tdelete: Type.Optional(\n\t\t\tType.Array(TaskIdSchema, {\n\t\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\t\tdescription: \"Ids to remove from the current list; deleting an id that is already absent is a no-op.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TodoParams = Static<typeof TodoParamsSchema>;\n\nexport const EMPTY_TODO_STATE: TodoState = { items: [], nextId: 1 };\n"]}
@@ -1,14 +1,17 @@
1
1
  import { type TodoChange, type TodoDetails, type TodoParams, type TodoState } from "./schema.ts";
2
2
  /** Snapshot clone: items are plain string/number records, so a shallow copy is safe. */
3
3
  export declare function cloneTodoState(state: TodoState): TodoState;
4
+ export interface TodoPatch {
5
+ state: TodoState;
6
+ change: TodoChange;
7
+ }
4
8
  /**
5
- * Pure action application: validates every runtime input and inapplicable
6
- * parameter (tool args can be tampered after schema validation), throws on
7
- * any invalid call, and never mutates the input state.
9
+ * Pure patch application: validates every runtime input (tool args can be
10
+ * tampered after schema validation), throws on any invalid call, and never
11
+ * mutates the input state. Application order is delete, then update, then
12
+ * create, so a delete in the same call frees capacity for the create.
8
13
  */
9
- export declare function applyTodoAction(state: TodoState, params: TodoParams): TodoState;
10
- /** Derive the operation model for one call from the before/after states. */
11
- export declare function buildTodoChange(params: TodoParams, before: TodoState, after: TodoState): TodoChange;
14
+ export declare function applyTodoPatch(before: TodoState, params: TodoParams): TodoPatch;
12
15
  export declare function buildTodoDetails(change: TodoChange, state: TodoState): TodoDetails;
13
16
  export interface TodoStore {
14
17
  getState(): TodoState;
@@ -18,9 +21,10 @@ export interface TodoStore {
18
21
  /** Closure-scoped store: one list per store, no module-global session state. */
19
22
  export declare function createTodoStore(initial?: TodoState): TodoStore;
20
23
  /**
21
- * Replay the newest valid v2 todo snapshot from a branch, scanning tail to
24
+ * Replay the newest valid v3 todo snapshot from a branch, scanning tail to
22
25
  * head so a malformed latest snapshot falls back to an earlier valid one.
23
- * v1 details are ignored, and the `change` field is not validated.
26
+ * Older schema versions (v1/v2) are ignored: restoring a session written
27
+ * before v3 starts from an empty list.
24
28
  */
25
29
  export declare function replayTodosFromBranch(ctx: {
26
30
  sessionManager: {
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/state.ts"],"names":[],"mappings":"AAYA,OAAO,EAIN,KAAK,UAAU,EACf,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,MAAM,aAAa,CAAC;AAgErB,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAE1D;AAiGD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAe/E;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,CA+BnG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,WAAW,CAElF;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,IAAI,SAAS,CAAC;IACtB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC,OAAO,CAAC,MAAM,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