@asterxsk/kiln 0.1.0
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/LICENSE +21 -0
- package/README.md +170 -0
- package/agent/AGENTS.md +67 -0
- package/agent/README.md +5 -0
- package/agent/extensions/AGENTS.md +68 -0
- package/agent/extensions/ask-user/index.ts +418 -0
- package/agent/extensions/ask-user/install.ps1 +23 -0
- package/agent/extensions/ask-user/install.sh +21 -0
- package/agent/extensions/ask-user/package-lock.json +769 -0
- package/agent/extensions/ask-user/package.json +19 -0
- package/agent/extensions/ask-user/prompt.ts +45 -0
- package/agent/extensions/ask-user/tsconfig.json +7 -0
- package/agent/extensions/background-terminals/docs/implementation-guide.md +942 -0
- package/agent/extensions/background-terminals/index.ts +627 -0
- package/agent/extensions/background-terminals/install.ps1 +23 -0
- package/agent/extensions/background-terminals/install.sh +21 -0
- package/agent/extensions/background-terminals/manager.test.ts +735 -0
- package/agent/extensions/background-terminals/output.test.ts +109 -0
- package/agent/extensions/background-terminals/package-lock.json +769 -0
- package/agent/extensions/background-terminals/package.json +17 -0
- package/agent/extensions/background-terminals/prompt.test.ts +125 -0
- package/agent/extensions/background-terminals/ps.test.ts +82 -0
- package/agent/extensions/background-terminals/result-delivery.test.ts +44 -0
- package/agent/extensions/background-terminals/src/domain.ts +87 -0
- package/agent/extensions/background-terminals/src/manager.ts +907 -0
- package/agent/extensions/background-terminals/src/output.ts +84 -0
- package/agent/extensions/background-terminals/src/prompt.ts +142 -0
- package/agent/extensions/background-terminals/src/result-delivery.ts +27 -0
- package/agent/extensions/background-terminals/src/runtime.ts +36 -0
- package/agent/extensions/background-terminals/src/ui/output-view.ts +79 -0
- package/agent/extensions/background-terminals/src/ui/ps.ts +621 -0
- package/agent/extensions/background-terminals/tsconfig.json +7 -0
- package/agent/extensions/destructive/README.md +31 -0
- package/agent/extensions/destructive/index.ts +88 -0
- package/agent/extensions/destructive/install.ps1 +23 -0
- package/agent/extensions/destructive/install.sh +21 -0
- package/agent/extensions/file-search/index.spec.ts +443 -0
- package/agent/extensions/file-search/index.ts +459 -0
- package/agent/extensions/file-search/install.ps1 +23 -0
- package/agent/extensions/file-search/install.sh +21 -0
- package/agent/extensions/file-search/package-lock.json +2253 -0
- package/agent/extensions/file-search/package.json +23 -0
- package/agent/extensions/file-search/src/args.ts +122 -0
- package/agent/extensions/file-search/src/binaries.ts +422 -0
- package/agent/extensions/file-search/src/output.ts +126 -0
- package/agent/extensions/file-search/src/process.ts +146 -0
- package/agent/extensions/file-search/src/prompt.ts +52 -0
- package/agent/extensions/file-search/tsconfig.json +7 -0
- package/agent/extensions/goal/README.md +50 -0
- package/agent/extensions/goal/index.ts +155 -0
- package/agent/extensions/goal/install.ps1 +23 -0
- package/agent/extensions/goal/install.sh +21 -0
- package/agent/extensions/modelconf/PLAN.md +915 -0
- package/agent/extensions/modelconf/README.md +66 -0
- package/agent/extensions/modelconf/index.ts +296 -0
- package/agent/extensions/modelconf/install.ps1 +23 -0
- package/agent/extensions/modelconf/install.sh +21 -0
- package/agent/extensions/modelconf/package-lock.json +1809 -0
- package/agent/extensions/modelconf/package.json +13 -0
- package/agent/extensions/modelconf/src/fuzzy.ts +26 -0
- package/agent/extensions/modelconf/src/glob.ts +13 -0
- package/agent/extensions/modelconf/src/persistence.test.ts +46 -0
- package/agent/extensions/modelconf/src/persistence.ts +164 -0
- package/agent/extensions/modelconf/src/ui/ModelConfView.test.ts +75 -0
- package/agent/extensions/modelconf/src/ui/ModelConfView.ts +1101 -0
- package/agent/extensions/modelconf/tsconfig.json +15 -0
- package/agent/extensions/pi-web-access/CHANGELOG.md +690 -0
- package/agent/extensions/pi-web-access/LICENSE +21 -0
- package/agent/extensions/pi-web-access/README.md +470 -0
- package/agent/extensions/pi-web-access/SECURITY.md +5 -0
- package/agent/extensions/pi-web-access/activity.ts +101 -0
- package/agent/extensions/pi-web-access/auth-fetch.ts +148 -0
- package/agent/extensions/pi-web-access/banner.png +0 -0
- package/agent/extensions/pi-web-access/brightdata-unlocker.ts +272 -0
- package/agent/extensions/pi-web-access/chrome-cookies.ts +669 -0
- package/agent/extensions/pi-web-access/content-find.ts +139 -0
- package/agent/extensions/pi-web-access/credential-source.ts +191 -0
- package/agent/extensions/pi-web-access/data-uri-sanitize.ts +406 -0
- package/agent/extensions/pi-web-access/datalab-pdf-extract.ts +568 -0
- package/agent/extensions/pi-web-access/declared-web-links.ts +173 -0
- package/agent/extensions/pi-web-access/evidence/CONTRACT-EVIDENCE.md +496 -0
- package/agent/extensions/pi-web-access/evidence/contract-probe.mjs +140 -0
- package/agent/extensions/pi-web-access/exa.ts +526 -0
- package/agent/extensions/pi-web-access/extract.ts +1196 -0
- package/agent/extensions/pi-web-access/feature-config.ts +29 -0
- package/agent/extensions/pi-web-access/fetch-params.ts +111 -0
- package/agent/extensions/pi-web-access/gemini-adc.ts +298 -0
- package/agent/extensions/pi-web-access/gemini-api.ts +353 -0
- package/agent/extensions/pi-web-access/gemini-pdf-extract.ts +108 -0
- package/agent/extensions/pi-web-access/gemini-search.ts +21 -0
- package/agent/extensions/pi-web-access/gemini-url-context.ts +128 -0
- package/agent/extensions/pi-web-access/gemini-web-config.ts +101 -0
- package/agent/extensions/pi-web-access/gemini-web.ts +487 -0
- package/agent/extensions/pi-web-access/github-api.ts +197 -0
- package/agent/extensions/pi-web-access/github-extract.ts +746 -0
- package/agent/extensions/pi-web-access/github-issue-pr.ts +700 -0
- package/agent/extensions/pi-web-access/index.ts +1737 -0
- package/agent/extensions/pi-web-access/package-lock.json +5808 -0
- package/agent/extensions/pi-web-access/package.json +64 -0
- package/agent/extensions/pi-web-access/page-query.ts +96 -0
- package/agent/extensions/pi-web-access/pdf-extract.ts +409 -0
- package/agent/extensions/pi-web-access/pi-web-fetch-demo.mp4 +0 -0
- package/agent/extensions/pi-web-access/promise-try.d.ts +7 -0
- package/agent/extensions/pi-web-access/query-rewrite.ts +51 -0
- package/agent/extensions/pi-web-access/render-search-error.ts +170 -0
- package/agent/extensions/pi-web-access/rsc-extract.ts +338 -0
- package/agent/extensions/pi-web-access/search-types.ts +20 -0
- package/agent/extensions/pi-web-access/source-check.ts +282 -0
- package/agent/extensions/pi-web-access/ssrf-protection.ts +526 -0
- package/agent/extensions/pi-web-access/storage.ts +521 -0
- package/agent/extensions/pi-web-access/summary-model-scope.ts +125 -0
- package/agent/extensions/pi-web-access/test/auth-fetch.test.mjs +208 -0
- package/agent/extensions/pi-web-access/test/brightdata-unlocker.test.mjs +840 -0
- package/agent/extensions/pi-web-access/test/chrome-cookie-extraction.test.mjs +441 -0
- package/agent/extensions/pi-web-access/test/config-path.test.mjs +283 -0
- package/agent/extensions/pi-web-access/test/content-find.test.mjs +25 -0
- package/agent/extensions/pi-web-access/test/credential-source.test.mjs +118 -0
- package/agent/extensions/pi-web-access/test/data-uri-sanitize.test.mjs +210 -0
- package/agent/extensions/pi-web-access/test/datalab-pdf-extract.test.mjs +552 -0
- package/agent/extensions/pi-web-access/test/declared-web-links.test.mjs +212 -0
- package/agent/extensions/pi-web-access/test/fetch-answer-storage.test.mjs +40 -0
- package/agent/extensions/pi-web-access/test/fetch-cache-storage.test.mjs +334 -0
- package/agent/extensions/pi-web-access/test/fetch-content-domain-policy.test.mjs +95 -0
- package/agent/extensions/pi-web-access/test/fetch-modes.test.mjs +53 -0
- package/agent/extensions/pi-web-access/test/fetch-not-found-guidance.test.mjs +92 -0
- package/agent/extensions/pi-web-access/test/fetch-params.test.mjs +86 -0
- package/agent/extensions/pi-web-access/test/fetch-render-call.test.mjs +34 -0
- package/agent/extensions/pi-web-access/test/fetch-routing.test.mjs +173 -0
- package/agent/extensions/pi-web-access/test/gemini-adc-auth.test.mjs +257 -0
- package/agent/extensions/pi-web-access/test/gemini-api-transport.test.mjs +170 -0
- package/agent/extensions/pi-web-access/test/gemini-pdf-extract.test.mjs +133 -0
- package/agent/extensions/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +178 -0
- package/agent/extensions/pi-web-access/test/gemini-web-header-overflow.test.mjs +148 -0
- package/agent/extensions/pi-web-access/test/get-search-content.test.mjs +223 -0
- package/agent/extensions/pi-web-access/test/github-extract.test.mjs +378 -0
- package/agent/extensions/pi-web-access/test/github-issue-pr.test.mjs +565 -0
- package/agent/extensions/pi-web-access/test/inline-content-config.test.mjs +99 -0
- package/agent/extensions/pi-web-access/test/lazy-extract-load.test.mjs +118 -0
- package/agent/extensions/pi-web-access/test/local-video-oversize.test.mjs +52 -0
- package/agent/extensions/pi-web-access/test/package-typebox-dependency.test.mjs +50 -0
- package/agent/extensions/pi-web-access/test/page-query.test.mjs +51 -0
- package/agent/extensions/pi-web-access/test/pdf-config.test.mjs +140 -0
- package/agent/extensions/pi-web-access/test/pdf-extract.test.mjs +500 -0
- package/agent/extensions/pi-web-access/test/proxy-transport.test.mjs +286 -0
- package/agent/extensions/pi-web-access/test/query-rewrite.test.mjs +52 -0
- package/agent/extensions/pi-web-access/test/rsc-fallback.test.mjs +102 -0
- package/agent/extensions/pi-web-access/test/search-error-render.test.mjs +152 -0
- package/agent/extensions/pi-web-access/test/search-providers.test.mjs +274 -0
- package/agent/extensions/pi-web-access/test/source-check.test.mjs +179 -0
- package/agent/extensions/pi-web-access/test/ssrf-allow-ranges-config.test.mjs +205 -0
- package/agent/extensions/pi-web-access/test/ssrf-protection.test.mjs +456 -0
- package/agent/extensions/pi-web-access/test/summary-model-scope.test.mjs +106 -0
- package/agent/extensions/pi-web-access/test/tool-registration-config.test.mjs +182 -0
- package/agent/extensions/pi-web-access/test/web-search-answer-render.test.mjs +66 -0
- package/agent/extensions/pi-web-access/test/youtube-extract-errors.test.mjs +64 -0
- package/agent/extensions/pi-web-access/tsconfig.json +11 -0
- package/agent/extensions/pi-web-access/utils.ts +451 -0
- package/agent/extensions/pi-web-access/video-extract.ts +392 -0
- package/agent/extensions/pi-web-access/youtube-extract.ts +328 -0
- package/agent/extensions/shared/activity-status.ts +31 -0
- package/agent/extensions/shared/child-session.test.ts +270 -0
- package/agent/extensions/shared/child-session.ts +148 -0
- package/agent/extensions/shared/context-utilization.test.ts +48 -0
- package/agent/extensions/shared/context-utilization.ts +47 -0
- package/agent/extensions/shared/dashboard-state.ts +99 -0
- package/agent/extensions/shared/install.ps1 +23 -0
- package/agent/extensions/shared/install.sh +21 -0
- package/agent/extensions/shared/tool-call-timeout.test.ts +117 -0
- package/agent/extensions/shared/tool-call-timeout.ts +104 -0
- package/agent/extensions/skillsconf/README.md +74 -0
- package/agent/extensions/skillsconf/index.ts +92 -0
- package/agent/extensions/skillsconf/install.ps1 +23 -0
- package/agent/extensions/skillsconf/install.sh +21 -0
- package/agent/extensions/skillsconf/package-lock.json +1809 -0
- package/agent/extensions/skillsconf/package.json +18 -0
- package/agent/extensions/skillsconf/src/delete-skill.test.ts +64 -0
- package/agent/extensions/skillsconf/src/delete-skill.ts +45 -0
- package/agent/extensions/skillsconf/src/filter.test.ts +80 -0
- package/agent/extensions/skillsconf/src/filter.ts +74 -0
- package/agent/extensions/skillsconf/src/fuzzy.ts +26 -0
- package/agent/extensions/skillsconf/src/persistence.test.ts +72 -0
- package/agent/extensions/skillsconf/src/persistence.ts +169 -0
- package/agent/extensions/skillsconf/src/ui/SkillConfView.test.ts +337 -0
- package/agent/extensions/skillsconf/src/ui/SkillConfView.ts +758 -0
- package/agent/extensions/skillsconf/src/ui/text-input.ts +91 -0
- package/agent/extensions/skillsconf/src/ui/tui-helpers.ts +144 -0
- package/agent/extensions/skillsconf/tsconfig.json +15 -0
- package/agent/extensions/status line/index.ts +282 -0
- package/agent/extensions/status line/install.ps1 +23 -0
- package/agent/extensions/status line/install.sh +21 -0
- package/agent/extensions/subagents/by-the-way.test.ts +29 -0
- package/agent/extensions/subagents/claude.test.ts +119 -0
- package/agent/extensions/subagents/codex.test.ts +102 -0
- package/agent/extensions/subagents/context-usage.test.ts +107 -0
- package/agent/extensions/subagents/docs/design-plan.md +568 -0
- package/agent/extensions/subagents/docs/effect-v4-extension-guide.md +354 -0
- package/agent/extensions/subagents/docs/effect-v4-notes.md +571 -0
- package/agent/extensions/subagents/index.ts +779 -0
- package/agent/extensions/subagents/install.ps1 +23 -0
- package/agent/extensions/subagents/install.sh +21 -0
- package/agent/extensions/subagents/manager.test.ts +276 -0
- package/agent/extensions/subagents/package-lock.json +2244 -0
- package/agent/extensions/subagents/package.json +19 -0
- package/agent/extensions/subagents/result-delivery.test.ts +27 -0
- package/agent/extensions/subagents/src/backend.ts +73 -0
- package/agent/extensions/subagents/src/backends/claude.ts +701 -0
- package/agent/extensions/subagents/src/backends/codex.ts +1060 -0
- package/agent/extensions/subagents/src/backends/pi.ts +575 -0
- package/agent/extensions/subagents/src/backends/stub.ts +300 -0
- package/agent/extensions/subagents/src/by-the-way.ts +21 -0
- package/agent/extensions/subagents/src/domain.ts +253 -0
- package/agent/extensions/subagents/src/format.ts +74 -0
- package/agent/extensions/subagents/src/manager.ts +736 -0
- package/agent/extensions/subagents/src/prompt.ts +92 -0
- package/agent/extensions/subagents/src/result-delivery.ts +20 -0
- package/agent/extensions/subagents/src/runtime.ts +53 -0
- package/agent/extensions/subagents/src/ui/takeover.ts +583 -0
- package/agent/extensions/subagents/src/ui/transcript.ts +201 -0
- package/agent/extensions/subagents/takeover.test.ts +29 -0
- package/agent/extensions/subagents/tsconfig.json +7 -0
- package/agent/extensions/taste/index.ts +443 -0
- package/agent/extensions/taste/install.ps1 +23 -0
- package/agent/extensions/taste/install.sh +21 -0
- package/agent/extensions/todo/AGENTS.md +38 -0
- package/agent/extensions/todo/LICENSE +21 -0
- package/agent/extensions/todo/config.ts +55 -0
- package/agent/extensions/todo/index.ts +151 -0
- package/agent/extensions/todo/install.ps1 +23 -0
- package/agent/extensions/todo/install.sh +21 -0
- package/agent/extensions/todo/locales/de.json +17 -0
- package/agent/extensions/todo/locales/en.json +15 -0
- package/agent/extensions/todo/locales/es.json +17 -0
- package/agent/extensions/todo/locales/fr.json +17 -0
- package/agent/extensions/todo/locales/pt-BR.json +17 -0
- package/agent/extensions/todo/locales/pt.json +17 -0
- package/agent/extensions/todo/locales/ru.json +17 -0
- package/agent/extensions/todo/locales/uk.json +17 -0
- package/agent/extensions/todo/locales/zh.json +17 -0
- package/agent/extensions/todo/package-lock.json +3358 -0
- package/agent/extensions/todo/package.json +67 -0
- package/agent/extensions/todo/state/i18n-bridge.ts +64 -0
- package/agent/extensions/todo/state/invariants.ts +20 -0
- package/agent/extensions/todo/state/replay.ts +38 -0
- package/agent/extensions/todo/state/selectors.ts +107 -0
- package/agent/extensions/todo/state/state-reducer.ts +326 -0
- package/agent/extensions/todo/state/state.ts +18 -0
- package/agent/extensions/todo/state/store.ts +82 -0
- package/agent/extensions/todo/state/task-graph.ts +57 -0
- package/agent/extensions/todo/todo-overlay.ts +200 -0
- package/agent/extensions/todo/todo.ts +155 -0
- package/agent/extensions/todo/tool/response-envelope.ts +109 -0
- package/agent/extensions/todo/tool/types.ts +206 -0
- package/agent/extensions/todo/verify-ref-system.js +0 -0
- package/agent/extensions/todo/view/format.ts +177 -0
- package/agent/extensions/trim-context/README.md +54 -0
- package/agent/extensions/trim-context/index.ts +487 -0
- package/agent/extensions/trim-context/install.ps1 +23 -0
- package/agent/extensions/trim-context/install.sh +21 -0
- package/agent/install.ps1 +527 -0
- package/agent/install.sh +511 -0
- package/agent/keybindings.json +7 -0
- package/bin/kiln.js +359 -0
- package/package.json +21 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
|
+
import { type Static, Type } from "typebox";
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Tool / command identity — verbatim string boundaries.
|
|
6
|
+
// Tool name "todo" is the persistence key for branch replay (filtering
|
|
7
|
+
// `toolResult.toolName === "todo"`) AND the permissions entry at
|
|
8
|
+
// `templates/pi-permissions.jsonc:26`. DO NOT rename.
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
export const TOOL_NAME = "todo";
|
|
12
|
+
export const TOOL_LABEL = "Todo";
|
|
13
|
+
export const COMMAND_NAME = "todos";
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// User-facing strings (kept stable for /todos UX parity).
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export const ERR_REQUIRES_INTERACTIVE = "/todos requires interactive mode";
|
|
20
|
+
export const MSG_NO_TODOS = "No todos yet. Ask the agent to add some!";
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Public domain types
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export type TaskStatus = "pending" | "in_progress" | "completed" | "deleted";
|
|
27
|
+
|
|
28
|
+
export type TaskAction = "create" | "update" | "list" | "get" | "delete" | "clear" | "batch";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A single operation within a batch call. Mirrors TaskMutationParams minus
|
|
32
|
+
* the `items` field (batches cannot be nested).
|
|
33
|
+
*/
|
|
34
|
+
export interface BatchItem {
|
|
35
|
+
action: Exclude<TaskAction, "batch" | "list" | "get">;
|
|
36
|
+
subject?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
activeForm?: string;
|
|
39
|
+
status?: TaskStatus;
|
|
40
|
+
blockedBy?: number[];
|
|
41
|
+
addBlockedBy?: number[];
|
|
42
|
+
removeBlockedBy?: number[];
|
|
43
|
+
owner?: string;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
id?: number;
|
|
46
|
+
subjects?: string[];
|
|
47
|
+
ids?: number[];
|
|
48
|
+
/** Labels to assign to created tasks (index-aligned with subjects, create only) */
|
|
49
|
+
as?: string[];
|
|
50
|
+
/** Reference labels from earlier batch items instead of numeric ids */
|
|
51
|
+
refs?: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Task {
|
|
55
|
+
id: number;
|
|
56
|
+
subject: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
activeForm?: string;
|
|
59
|
+
status: TaskStatus;
|
|
60
|
+
blockedBy?: number[];
|
|
61
|
+
owner?: string;
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Persistence + replay snapshot. Every successful `todo` tool call returns this
|
|
67
|
+
* shape under `details`; `state/replay.ts` reads the latest one from the branch
|
|
68
|
+
* to reconstruct module state. Field order and field names are pinned by
|
|
69
|
+
* cross-version replay compatibility.
|
|
70
|
+
*/
|
|
71
|
+
export interface TaskDetails {
|
|
72
|
+
action: TaskAction;
|
|
73
|
+
params: Record<string, unknown>;
|
|
74
|
+
tasks: Task[];
|
|
75
|
+
nextId: number;
|
|
76
|
+
error?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Open-shape input bag the reducer accepts. Stays an interface so the index
|
|
81
|
+
* signature (`[key: string]: unknown`) lets the runtime pass through TypeBox
|
|
82
|
+
* `Static<typeof TodoParamsSchema>` without `as` casts.
|
|
83
|
+
*/
|
|
84
|
+
export interface TaskMutationParams {
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
subject?: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
activeForm?: string;
|
|
89
|
+
status?: TaskStatus;
|
|
90
|
+
blockedBy?: number[];
|
|
91
|
+
addBlockedBy?: number[];
|
|
92
|
+
removeBlockedBy?: number[];
|
|
93
|
+
owner?: string;
|
|
94
|
+
metadata?: Record<string, unknown>;
|
|
95
|
+
id?: number;
|
|
96
|
+
includeDeleted?: boolean;
|
|
97
|
+
/** Batch mode: list of sub-operations to apply atomically in order. */
|
|
98
|
+
items?: BatchItem[];
|
|
99
|
+
/** Batch create: task subjects for multiple creates in one call. */
|
|
100
|
+
subjects?: string[];
|
|
101
|
+
/** Batch update/get/delete: task ids for operating on multiple tasks in one call. */
|
|
102
|
+
ids?: number[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
// TypeBox parameter schema — every `description` doubles as LLM-facing prompt
|
|
107
|
+
// copy. Field order and wording are pinned by registration tests and the
|
|
108
|
+
// pre-refactor schema at `packages/rpiv-todo/todo.ts:512-573`.
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
const BatchItemSchema = Type.Object({
|
|
112
|
+
action: StringEnum(["create", "update", "delete", "clear"] as const, {
|
|
113
|
+
description: "create | update | delete | clear",
|
|
114
|
+
}),
|
|
115
|
+
subject: Type.Optional(Type.String({ description: "Subject (required for create)" })),
|
|
116
|
+
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
117
|
+
activeForm: Type.Optional(Type.String({ description: "In-progress spinner label" })),
|
|
118
|
+
status: Type.Optional(
|
|
119
|
+
StringEnum(["pending", "in_progress", "completed", "deleted"] as const, {
|
|
120
|
+
description: "Target status",
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
blockedBy: Type.Optional(Type.Array(Type.Number(), { description: "blockedBy ids (create only)" })),
|
|
124
|
+
addBlockedBy: Type.Optional(Type.Array(Type.Number(), { description: "Add to blockedBy" })),
|
|
125
|
+
removeBlockedBy: Type.Optional(Type.Array(Type.Number(), { description: "Remove from blockedBy" })),
|
|
126
|
+
owner: Type.Optional(Type.String({ description: "Owner" })),
|
|
127
|
+
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Arbitrary metadata" })),
|
|
128
|
+
id: Type.Optional(Type.Number({ description: "Task id (required for update/delete)" })),
|
|
129
|
+
subjects: Type.Optional(Type.Array(Type.String(), { description: "Batch-create subjects" })),
|
|
130
|
+
ids: Type.Optional(Type.Array(Type.Number(), { description: "Batch task ids" })),
|
|
131
|
+
as: Type.Optional(
|
|
132
|
+
Type.Array(Type.String(), {
|
|
133
|
+
description: "Labels for new task ids (e.g. ['$t1'])",
|
|
134
|
+
}),
|
|
135
|
+
),
|
|
136
|
+
refs: Type.Optional(
|
|
137
|
+
Type.Array(Type.String(), {
|
|
138
|
+
description: "Reference earlier item labels (e.g. ['$t1'])",
|
|
139
|
+
}),
|
|
140
|
+
),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export const TodoParamsSchema = Type.Object({
|
|
144
|
+
action: StringEnum(["create", "update", "list", "get", "delete", "clear", "batch"] as const),
|
|
145
|
+
subject: Type.Optional(Type.String({ description: "Task subject line (required for create)" })),
|
|
146
|
+
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
147
|
+
activeForm: Type.Optional(
|
|
148
|
+
Type.String({
|
|
149
|
+
description: "Present-continuous label while in_progress (e.g. 'writing tests')",
|
|
150
|
+
}),
|
|
151
|
+
),
|
|
152
|
+
status: Type.Optional(
|
|
153
|
+
StringEnum(["pending", "in_progress", "completed", "deleted"] as const, {
|
|
154
|
+
description: "Target status (update) or list filter (list)",
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
blockedBy: Type.Optional(
|
|
158
|
+
Type.Array(Type.Number(), {
|
|
159
|
+
description: "Initial blockedBy ids (create only)",
|
|
160
|
+
}),
|
|
161
|
+
),
|
|
162
|
+
addBlockedBy: Type.Optional(
|
|
163
|
+
Type.Array(Type.Number(), {
|
|
164
|
+
description: "Task ids to add to blockedBy (update only, additive merge)",
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
removeBlockedBy: Type.Optional(
|
|
168
|
+
Type.Array(Type.Number(), {
|
|
169
|
+
description: "Task ids to remove from blockedBy (update only, additive merge)",
|
|
170
|
+
}),
|
|
171
|
+
),
|
|
172
|
+
owner: Type.Optional(Type.String({ description: "Agent/owner assigned to this task" })),
|
|
173
|
+
metadata: Type.Optional(
|
|
174
|
+
Type.Record(Type.String(), Type.Unknown(), {
|
|
175
|
+
description: "Arbitrary metadata; pass null value for a key to delete that key on update",
|
|
176
|
+
}),
|
|
177
|
+
),
|
|
178
|
+
id: Type.Optional(
|
|
179
|
+
Type.Number({
|
|
180
|
+
description: "Task id (required for update, get, delete)",
|
|
181
|
+
}),
|
|
182
|
+
),
|
|
183
|
+
subjects: Type.Optional(
|
|
184
|
+
Type.Array(Type.String(), {
|
|
185
|
+
description: "Batch-create subjects (multiple creates in one call).",
|
|
186
|
+
}),
|
|
187
|
+
),
|
|
188
|
+
ids: Type.Optional(
|
|
189
|
+
Type.Array(Type.Number(), {
|
|
190
|
+
description: "Batch update/get/delete: task ids for operating on multiple tasks in one call.",
|
|
191
|
+
}),
|
|
192
|
+
),
|
|
193
|
+
includeDeleted: Type.Optional(
|
|
194
|
+
Type.Boolean({
|
|
195
|
+
description: "If true, list action returns deleted (tombstoned) tasks as well. Default: false.",
|
|
196
|
+
}),
|
|
197
|
+
),
|
|
198
|
+
items: Type.Optional(
|
|
199
|
+
Type.Array(BatchItemSchema, {
|
|
200
|
+
description:
|
|
201
|
+
"Batch mode only: ordered create/update/delete/clear sub-ops. Use 'as'/'refs' to label and cross-reference new ids.",
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export type TodoParams = Static<typeof TodoParamsSchema>;
|
|
File without changes
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import { formatStatusLabel } from "../state/i18n-bridge.js";
|
|
4
|
+
import { selectTaskSubjectById } from "../state/selectors.js";
|
|
5
|
+
import type { TaskState } from "../state/state.js";
|
|
6
|
+
import type { Task, TaskAction, TaskDetails, TaskMutationParams, TaskStatus } from "../tool/types.js";
|
|
7
|
+
|
|
8
|
+
// Re-export so legacy import paths (todo.ts, tests) continue to resolve;
|
|
9
|
+
// the canonical definition lives in the i18n bridge.
|
|
10
|
+
export { formatStatusLabel };
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Status presentation tables — the single source of truth for glyph/color.
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export const STATUS_GLYPH: Record<TaskStatus, string> = {
|
|
17
|
+
pending: "○",
|
|
18
|
+
in_progress: "◐",
|
|
19
|
+
completed: "●",
|
|
20
|
+
deleted: "⊘",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Color palette for the renderResult status echo. `deleted` uses `muted` so a
|
|
25
|
+
* successful delete is visually distinct from the error branch (which uses
|
|
26
|
+
* `error` + `✗`). Mirrors pre-refactor `todo.ts:444-450`.
|
|
27
|
+
*/
|
|
28
|
+
export const STATUS_COLOR: Record<TaskStatus, "dim" | "warning" | "success" | "muted"> = {
|
|
29
|
+
pending: "dim",
|
|
30
|
+
in_progress: "warning",
|
|
31
|
+
completed: "success",
|
|
32
|
+
deleted: "muted",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Per-action prefix glyph for renderCall. `+` create, `→` update, `×` delete,
|
|
37
|
+
* `›` get, `☰` list, `∅` clear. Pre-refactor `todo.ts:457-464`.
|
|
38
|
+
*/
|
|
39
|
+
export const ACTION_GLYPH: Record<TaskAction, string> = {
|
|
40
|
+
create: "+",
|
|
41
|
+
update: "→",
|
|
42
|
+
delete: "×",
|
|
43
|
+
get: "›",
|
|
44
|
+
list: "☰",
|
|
45
|
+
clear: "∅",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Glyph for the persistent overlay's per-task row. Differs from `STATUS_GLYPH`
|
|
50
|
+
* for `completed` (`✓` vs `●`) and `deleted` (`✗` vs `⊘`) because the
|
|
51
|
+
* overlay caller never renders a `deleted` row but uses `✗` in its
|
|
52
|
+
* error-toned palette. Mirrors pre-refactor `todo-overlay.ts:23-33`.
|
|
53
|
+
*/
|
|
54
|
+
export function overlayStatusGlyph(status: TaskStatus, theme: Theme): string {
|
|
55
|
+
switch (status) {
|
|
56
|
+
case "pending":
|
|
57
|
+
return "○";
|
|
58
|
+
case "in_progress":
|
|
59
|
+
return "●";
|
|
60
|
+
case "completed":
|
|
61
|
+
return theme.fg("success", "✓");
|
|
62
|
+
case "deleted":
|
|
63
|
+
return theme.fg("error", "✗");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Format a single task for the overlay (with theme + glyph + dep suffix).
|
|
69
|
+
* Used by `TodoOverlay.formatTaskLine` post-refactor; behavior is unchanged.
|
|
70
|
+
*/
|
|
71
|
+
export function formatOverlayTaskLine(t: Task, theme: Theme, showId: boolean, prefix: string): string {
|
|
72
|
+
const glyph = overlayStatusGlyph(t.status, theme);
|
|
73
|
+
const greyPrefix = theme.fg("dim", prefix);
|
|
74
|
+
|
|
75
|
+
if (t.status === "completed") {
|
|
76
|
+
return greyPrefix + glyph + ` ${theme.fg("dim", theme.strikethrough(t.subject))}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let line = greyPrefix + glyph + ` ${t.subject}`;
|
|
80
|
+
if (t.status === "in_progress" && t.activeForm) {
|
|
81
|
+
line += ` (${t.activeForm})`;
|
|
82
|
+
}
|
|
83
|
+
if (t.blockedBy && t.blockedBy.length > 0) {
|
|
84
|
+
line += ` ${theme.fg("dim", `⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}`)}`;
|
|
85
|
+
}
|
|
86
|
+
return line;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Format a single task line for the `/todos` slash command (no glyph color,
|
|
91
|
+
* indented bullet prefix). Pre-refactor `todo.ts:670-674`.
|
|
92
|
+
*/
|
|
93
|
+
export function formatCommandTaskLine(t: Task, glyph: string): string {
|
|
94
|
+
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
95
|
+
const block = t.blockedBy?.length ? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}` : "";
|
|
96
|
+
return ` ${glyph} #${t.id} ${t.subject}${form}${block}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Tool render hooks — wrapped so `todo.ts` becomes a thin call-site.
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `renderCall` body. Receives the parsed args, the theme, and the live
|
|
105
|
+
* `TaskState` (resolved by the caller via `getState()`). Returns a `Text`
|
|
106
|
+
* node identical to pre-refactor `todo.ts:507-525`.
|
|
107
|
+
*/
|
|
108
|
+
export function renderTodoCall(
|
|
109
|
+
args: TaskMutationParams & { action: TaskAction },
|
|
110
|
+
theme: Theme,
|
|
111
|
+
state: TaskState,
|
|
112
|
+
): Text {
|
|
113
|
+
const glyph = ACTION_GLYPH[args.action] ?? args.action;
|
|
114
|
+
let text = theme.fg("toolTitle", theme.bold("todo ")) + theme.fg("muted", glyph);
|
|
115
|
+
|
|
116
|
+
if (args.action === "create" && args.subjects?.length) {
|
|
117
|
+
text += ` ${theme.fg("dim", `+${args.subjects.length} tasks`)}`;
|
|
118
|
+
} else if (args.action === "create" && args.subject) {
|
|
119
|
+
text += ` ${theme.fg("dim", args.subject)}`;
|
|
120
|
+
} else if (
|
|
121
|
+
(args.action === "update" || args.action === "get" || args.action === "delete") &&
|
|
122
|
+
args.ids?.length
|
|
123
|
+
) {
|
|
124
|
+
const idsStr = args.ids.map((id) => `#${id}`).join(",");
|
|
125
|
+
text += ` ${theme.fg("accent", idsStr)}`;
|
|
126
|
+
} else if (
|
|
127
|
+
(args.action === "update" || args.action === "get" || args.action === "delete") &&
|
|
128
|
+
args.id !== undefined
|
|
129
|
+
) {
|
|
130
|
+
const subject = selectTaskSubjectById(state, args.id);
|
|
131
|
+
text += ` ${theme.fg("accent", subject ?? `#${args.id}`)}`;
|
|
132
|
+
} else if (args.action === "list" && args.status) {
|
|
133
|
+
text += ` ${theme.fg("muted", formatStatusLabel(args.status))}`;
|
|
134
|
+
}
|
|
135
|
+
return new Text(text, 0, 0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* `renderResult` body. Inspects `details` to pick the per-action status echo
|
|
140
|
+
* (only `create`/`update`/`delete` advertise a status; `list`/`get`/`clear`
|
|
141
|
+
* fall back to plain `✓`). Identical visual output to pre-refactor
|
|
142
|
+
* `todo.ts:533-565`.
|
|
143
|
+
*/
|
|
144
|
+
export function renderTodoResult(result: { details?: unknown }, theme: Theme): Text {
|
|
145
|
+
const details = result.details as TaskDetails | undefined;
|
|
146
|
+
let status: TaskStatus | undefined;
|
|
147
|
+
if (details) {
|
|
148
|
+
const params = details.params as TaskMutationParams;
|
|
149
|
+
switch (details.action) {
|
|
150
|
+
case "create":
|
|
151
|
+
status = details.tasks[details.tasks.length - 1]?.status;
|
|
152
|
+
break;
|
|
153
|
+
case "update":
|
|
154
|
+
if (params.ids?.length) {
|
|
155
|
+
status = params.status ?? details.tasks[details.tasks.length - 1]?.status;
|
|
156
|
+
} else {
|
|
157
|
+
status = params.status ?? details.tasks.find((t) => t.id === params.id)?.status;
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case "delete":
|
|
161
|
+
if (params.ids?.length) {
|
|
162
|
+
status = "deleted";
|
|
163
|
+
} else {
|
|
164
|
+
status = details.tasks.find((t) => t.id === params.id)?.status;
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case "list":
|
|
168
|
+
case "get":
|
|
169
|
+
case "clear":
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (status) {
|
|
174
|
+
return new Text(theme.fg(STATUS_COLOR[status], `${STATUS_GLYPH[status]} ${formatStatusLabel(status)}`), 0, 0);
|
|
175
|
+
}
|
|
176
|
+
return new Text(theme.fg("success", "✓"), 0, 0);
|
|
177
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# trim-context — crush/amp/lsp style context manager for pi
|
|
2
|
+
|
|
3
|
+
Aggressive context savings so pi behaves like `opencode` / `crush` / `amp`.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
| Layer | Hook | Behavior |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| **Caching** | `process.env.PI_CACHE_RETENTION=long` + `before_provider_request` | Forces 1h Anthropic / 24h OpenAI cache. Adds `cache_control: {type:"ephemeral", ttl:"1h"}` to system + last user block if pi's built-in misses. |
|
|
10
|
+
| **Output compression** | `tool_result` | Truncates any tool result >30KB or >400 lines to 30KB/400 lines (head 75% + tail 25%). Full output saved to `tmpdir/pi-trim-*/full-output.txt` and path is inlined. |
|
|
11
|
+
| **Trim context** | `context` (before each LLM call) | Keeps last `KEEP_RECENT_TURNS=6` turns verbatim. Older turns: strip `thinking` blocks, compress `toolResult` to 800 chars / 30 lines, bash tail to 20 lines, dedupe superseded `read` results, and if still >80k tokens, hard-prune oldest toolResults. |
|
|
12
|
+
|
|
13
|
+
This matches crush's `trimContext` and amp's `context pruning` — pi's default keeps 20k recent tokens until 184k/200k, this keeps ~6 turns fully and aggressively compresses the rest.
|
|
14
|
+
|
|
15
|
+
## Config
|
|
16
|
+
|
|
17
|
+
Edit `index.ts` `CONFIG` block:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
KEEP_RECENT_TURNS: 6
|
|
21
|
+
IMMEDIATE_MAX_BYTES: 30*1024
|
|
22
|
+
IMMEDIATE_MAX_LINES: 400
|
|
23
|
+
OLD_MAX_CHARS: 800
|
|
24
|
+
OLD_MAX_LINES: 30
|
|
25
|
+
SOFT_TOKEN_LIMIT: 80_000
|
|
26
|
+
DEDUPE_READS: true
|
|
27
|
+
STRIP_OLD_THINKING: true
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`settings.json` also tuned:
|
|
31
|
+
```json
|
|
32
|
+
"compaction": { "keepRecentTokens": 12000, "reserveTokens": 24000 }
|
|
33
|
+
```
|
|
34
|
+
(compacts earlier than pi default 20k/16k)
|
|
35
|
+
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
- `/trimContext` — stats + config
|
|
39
|
+
- `/trim-context` — alias
|
|
40
|
+
|
|
41
|
+
Footer shows `cache:long keep:6t` while active.
|
|
42
|
+
|
|
43
|
+
## Verify
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pi --no-session -p "test" # should not throw
|
|
47
|
+
# in interactive pi:
|
|
48
|
+
# /trimContext -> shows ~0 compressed initially, grows as you work
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## How it saves vs vanilla pi
|
|
52
|
+
|
|
53
|
+
Vanilla pi: 5x reads of 10KB files = 50KB paid every turn until compaction at 184k.
|
|
54
|
+
With trim-context: same 5 reads = only last read kept fully, older 4 compressed to 1 line each + immediate truncation to 30KB. Typical saving: 60-80% input tokens on long sessions.
|