@esso0428/pi-subagents 0.17.16 → 0.17.18
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/CHANGELOG.md +11 -0
- package/ROADMAP.md +87 -0
- package/docs/post-0.17.6-agents-roster-viewer-spec.md +42 -0
- package/docs/post-0.17.6-durable-history-spec.md +41 -0
- package/docs/post-0.17.6-feature-specs.md +50 -0
- package/docs/post-0.17.6-nested-agents-spec.md +38 -0
- package/docs/post-0.17.6-recovery-shutdown-spec.md +46 -0
- package/docs/post-0.17.6-ui-latency-baseline-spec.md +46 -0
- package/docs/post-0.17.6-workflow-rpc-lifecycle-spec.md +54 -0
- package/package.json +1 -1
- package/src/agent-history.ts +2 -54
- package/src/agent-manager.ts +406 -1288
- package/src/agent-runner.ts +27 -251
- package/src/agent-types.ts +32 -188
- package/src/cross-extension-rpc.ts +20 -96
- package/src/custom-agents.ts +13 -170
- package/src/index.ts +480 -1920
- package/src/invocation-config.ts +3 -118
- package/src/model-resolver.ts +0 -18
- package/src/output-file.ts +6 -61
- package/src/prompts.ts +2 -45
- package/src/schedule.ts +14 -35
- package/src/settings.ts +2 -301
- package/src/status-note.ts +1 -66
- package/src/types.ts +10 -177
- package/src/ui/agent-widget.ts +57 -278
- package/src/ui/conversation-blocks.ts +0 -6
- package/src/ui/conversation-timeline.ts +25 -139
- package/src/ui/conversation-viewer.ts +48 -212
- package/src/ui/schedule-menu.ts +8 -9
- package/src/usage.ts +2 -109
- package/src/worktree.ts +55 -69
- package/dist/abortable.d.ts +0 -13
- package/dist/abortable.d.ts.map +0 -1
- package/dist/abortable.js +0 -43
- package/dist/abortable.js.map +0 -1
- package/dist/agent-color.d.ts +0 -36
- package/dist/agent-color.d.ts.map +0 -1
- package/dist/agent-color.js +0 -124
- package/dist/agent-color.js.map +0 -1
- package/dist/agent-file-toggle.d.ts +0 -126
- package/dist/agent-file-toggle.d.ts.map +0 -1
- package/dist/agent-file-toggle.js +0 -259
- package/dist/agent-file-toggle.js.map +0 -1
- package/dist/agent-history-list.d.ts +0 -19
- package/dist/agent-history-list.d.ts.map +0 -1
- package/dist/agent-history-list.js +0 -69
- package/dist/agent-history-list.js.map +0 -1
- package/dist/agent-history.d.ts +0 -35
- package/dist/agent-history.d.ts.map +0 -1
- package/dist/agent-history.js +0 -188
- package/dist/agent-history.js.map +0 -1
- package/dist/agent-manager.d.ts +0 -503
- package/dist/agent-manager.d.ts.map +0 -1
- package/dist/agent-manager.js +0 -1572
- package/dist/agent-manager.js.map +0 -1
- package/dist/agent-recovery.d.ts +0 -37
- package/dist/agent-recovery.d.ts.map +0 -1
- package/dist/agent-recovery.js +0 -171
- package/dist/agent-recovery.js.map +0 -1
- package/dist/agent-runner.d.ts +0 -303
- package/dist/agent-runner.d.ts.map +0 -1
- package/dist/agent-runner.js +0 -1003
- package/dist/agent-runner.js.map +0 -1
- package/dist/agent-types.d.ts +0 -120
- package/dist/agent-types.d.ts.map +0 -1
- package/dist/agent-types.js +0 -301
- package/dist/agent-types.js.map +0 -1
- package/dist/child-context.d.ts +0 -3
- package/dist/child-context.d.ts.map +0 -1
- package/dist/child-context.js +0 -13
- package/dist/child-context.js.map +0 -1
- package/dist/context.d.ts +0 -13
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -57
- package/dist/context.js.map +0 -1
- package/dist/cross-extension-rpc.d.ts +0 -67
- package/dist/cross-extension-rpc.d.ts.map +0 -1
- package/dist/cross-extension-rpc.js +0 -139
- package/dist/cross-extension-rpc.js.map +0 -1
- package/dist/custom-agents.d.ts +0 -55
- package/dist/custom-agents.d.ts.map +0 -1
- package/dist/custom-agents.js +0 -309
- package/dist/custom-agents.js.map +0 -1
- package/dist/default-agents.d.ts +0 -8
- package/dist/default-agents.d.ts.map +0 -1
- package/dist/default-agents.js +0 -123
- package/dist/default-agents.js.map +0 -1
- package/dist/enabled-models.d.ts +0 -50
- package/dist/enabled-models.d.ts.map +0 -1
- package/dist/enabled-models.js +0 -146
- package/dist/enabled-models.js.map +0 -1
- package/dist/env.d.ts +0 -7
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -29
- package/dist/env.js.map +0 -1
- package/dist/group-join.d.ts +0 -33
- package/dist/group-join.d.ts.map +0 -1
- package/dist/group-join.js +0 -117
- package/dist/group-join.js.map +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3687
- package/dist/index.js.map +0 -1
- package/dist/invocation-config.d.ts +0 -108
- package/dist/invocation-config.d.ts.map +0 -1
- package/dist/invocation-config.js +0 -84
- package/dist/invocation-config.js.map +0 -1
- package/dist/memory.d.ts +0 -54
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js +0 -166
- package/dist/memory.js.map +0 -1
- package/dist/mention-clone.d.ts +0 -88
- package/dist/mention-clone.d.ts.map +0 -1
- package/dist/mention-clone.js +0 -154
- package/dist/mention-clone.js.map +0 -1
- package/dist/mention.d.ts +0 -82
- package/dist/mention.d.ts.map +0 -1
- package/dist/mention.js +0 -132
- package/dist/mention.js.map +0 -1
- package/dist/model-resolver.d.ts +0 -37
- package/dist/model-resolver.d.ts.map +0 -1
- package/dist/model-resolver.js +0 -96
- package/dist/model-resolver.js.map +0 -1
- package/dist/model-scope.d.ts +0 -50
- package/dist/model-scope.d.ts.map +0 -1
- package/dist/model-scope.js +0 -49
- package/dist/model-scope.js.map +0 -1
- package/dist/nested-tools.d.ts +0 -57
- package/dist/nested-tools.d.ts.map +0 -1
- package/dist/nested-tools.js +0 -301
- package/dist/nested-tools.js.map +0 -1
- package/dist/nico-overrides.d.ts +0 -54
- package/dist/nico-overrides.d.ts.map +0 -1
- package/dist/nico-overrides.js +0 -170
- package/dist/nico-overrides.js.map +0 -1
- package/dist/output-file.d.ts +0 -44
- package/dist/output-file.d.ts.map +0 -1
- package/dist/output-file.js +0 -156
- package/dist/output-file.js.map +0 -1
- package/dist/prompts.d.ts +0 -56
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -92
- package/dist/prompts.js.map +0 -1
- package/dist/schedule-store.d.ts +0 -39
- package/dist/schedule-store.d.ts.map +0 -1
- package/dist/schedule-store.js +0 -156
- package/dist/schedule-store.js.map +0 -1
- package/dist/schedule.d.ts +0 -110
- package/dist/schedule.d.ts.map +0 -1
- package/dist/schedule.js +0 -360
- package/dist/schedule.js.map +0 -1
- package/dist/settings.d.ts +0 -354
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -247
- package/dist/settings.js.map +0 -1
- package/dist/skill-loader.d.ts +0 -25
- package/dist/skill-loader.d.ts.map +0 -1
- package/dist/skill-loader.js +0 -94
- package/dist/skill-loader.js.map +0 -1
- package/dist/status-note.d.ts +0 -62
- package/dist/status-note.d.ts.map +0 -1
- package/dist/status-note.js +0 -86
- package/dist/status-note.js.map +0 -1
- package/dist/structured-output.d.ts +0 -62
- package/dist/structured-output.d.ts.map +0 -1
- package/dist/structured-output.js +0 -113
- package/dist/structured-output.js.map +0 -1
- package/dist/types.d.ts +0 -372
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/ui/agent-mention.d.ts +0 -83
- package/dist/ui/agent-mention.d.ts.map +0 -1
- package/dist/ui/agent-mention.js +0 -188
- package/dist/ui/agent-mention.js.map +0 -1
- package/dist/ui/agent-widget.d.ts +0 -241
- package/dist/ui/agent-widget.d.ts.map +0 -1
- package/dist/ui/agent-widget.js +0 -992
- package/dist/ui/agent-widget.js.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts +0 -11
- package/dist/ui/ccstyle/diff/ansi-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/ansi-utils.js +0 -145
- package/dist/ui/ccstyle/diff/ansi-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts +0 -12
- package/dist/ui/ccstyle/diff/diff-presentation.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-presentation.js +0 -48
- package/dist/ui/ccstyle/diff/diff-presentation.js.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts +0 -46
- package/dist/ui/ccstyle/diff/diff-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/diff-renderer.js +0 -2049
- package/dist/ui/ccstyle/diff/diff-renderer.js.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts +0 -12
- package/dist/ui/ccstyle/diff/line-width-safety.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/line-width-safety.js +0 -58
- package/dist/ui/ccstyle/diff/line-width-safety.js.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.d.ts +0 -6
- package/dist/ui/ccstyle/diff/render-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/render-utils.js +0 -25
- package/dist/ui/ccstyle/diff/render-utils.js.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts +0 -19
- package/dist/ui/ccstyle/diff/shiki-highlight.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/shiki-highlight.js +0 -85
- package/dist/ui/ccstyle/diff/shiki-highlight.js.map +0 -1
- package/dist/ui/ccstyle/diff/types.d.ts +0 -22
- package/dist/ui/ccstyle/diff/types.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/types.js +0 -10
- package/dist/ui/ccstyle/diff/types.js.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts +0 -2
- package/dist/ui/ccstyle/diff/write-display-utils.d.ts.map +0 -1
- package/dist/ui/ccstyle/diff/write-display-utils.js +0 -12
- package/dist/ui/ccstyle/diff/write-display-utils.js.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.d.ts +0 -17
- package/dist/ui/ccstyle/tool-renderer.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-renderer.js +0 -74
- package/dist/ui/ccstyle/tool-renderer.js.map +0 -1
- package/dist/ui/ccstyle/tool-result.d.ts +0 -44
- package/dist/ui/ccstyle/tool-result.d.ts.map +0 -1
- package/dist/ui/ccstyle/tool-result.js +0 -423
- package/dist/ui/ccstyle/tool-result.js.map +0 -1
- package/dist/ui/conversation-blocks.d.ts +0 -46
- package/dist/ui/conversation-blocks.d.ts.map +0 -1
- package/dist/ui/conversation-blocks.js +0 -313
- package/dist/ui/conversation-blocks.js.map +0 -1
- package/dist/ui/conversation-nvim.d.ts +0 -8
- package/dist/ui/conversation-nvim.d.ts.map +0 -1
- package/dist/ui/conversation-nvim.js +0 -117
- package/dist/ui/conversation-nvim.js.map +0 -1
- package/dist/ui/conversation-role.d.ts +0 -13
- package/dist/ui/conversation-role.d.ts.map +0 -1
- package/dist/ui/conversation-role.js +0 -39
- package/dist/ui/conversation-role.js.map +0 -1
- package/dist/ui/conversation-search.d.ts +0 -39
- package/dist/ui/conversation-search.d.ts.map +0 -1
- package/dist/ui/conversation-search.js +0 -124
- package/dist/ui/conversation-search.js.map +0 -1
- package/dist/ui/conversation-timeline.d.ts +0 -102
- package/dist/ui/conversation-timeline.d.ts.map +0 -1
- package/dist/ui/conversation-timeline.js +0 -555
- package/dist/ui/conversation-timeline.js.map +0 -1
- package/dist/ui/conversation-viewer.d.ts +0 -138
- package/dist/ui/conversation-viewer.d.ts.map +0 -1
- package/dist/ui/conversation-viewer.js +0 -1175
- package/dist/ui/conversation-viewer.js.map +0 -1
- package/dist/ui/schedule-menu.d.ts +0 -17
- package/dist/ui/schedule-menu.d.ts.map +0 -1
- package/dist/ui/schedule-menu.js +0 -95
- package/dist/ui/schedule-menu.js.map +0 -1
- package/dist/ui/select-item.d.ts +0 -28
- package/dist/ui/select-item.d.ts.map +0 -1
- package/dist/ui/select-item.js +0 -35
- package/dist/ui/select-item.js.map +0 -1
- package/dist/ui/viewer-keys.d.ts +0 -21
- package/dist/ui/viewer-keys.d.ts.map +0 -1
- package/dist/ui/viewer-keys.js +0 -18
- package/dist/ui/viewer-keys.js.map +0 -1
- package/dist/ui/workflow-card.d.ts +0 -176
- package/dist/ui/workflow-card.d.ts.map +0 -1
- package/dist/ui/workflow-card.js +0 -333
- package/dist/ui/workflow-card.js.map +0 -1
- package/dist/ui/workflow-dialog.d.ts +0 -306
- package/dist/ui/workflow-dialog.d.ts.map +0 -1
- package/dist/ui/workflow-dialog.js +0 -844
- package/dist/ui/workflow-dialog.js.map +0 -1
- package/dist/ui/workflow-menu.d.ts +0 -42
- package/dist/ui/workflow-menu.d.ts.map +0 -1
- package/dist/ui/workflow-menu.js +0 -127
- package/dist/ui/workflow-menu.js.map +0 -1
- package/dist/usage.d.ts +0 -136
- package/dist/usage.d.ts.map +0 -1
- package/dist/usage.js +0 -121
- package/dist/usage.js.map +0 -1
- package/dist/workflow/collisions.d.ts +0 -96
- package/dist/workflow/collisions.d.ts.map +0 -1
- package/dist/workflow/collisions.js +0 -89
- package/dist/workflow/collisions.js.map +0 -1
- package/dist/workflow/entry.d.ts +0 -33
- package/dist/workflow/entry.d.ts.map +0 -1
- package/dist/workflow/entry.js +0 -30
- package/dist/workflow/entry.js.map +0 -1
- package/dist/workflow/host.d.ts +0 -63
- package/dist/workflow/host.d.ts.map +0 -1
- package/dist/workflow/host.js +0 -363
- package/dist/workflow/host.js.map +0 -1
- package/dist/workflow/journal.d.ts +0 -98
- package/dist/workflow/journal.d.ts.map +0 -1
- package/dist/workflow/journal.js +0 -121
- package/dist/workflow/journal.js.map +0 -1
- package/dist/workflow/json-schema.d.ts +0 -52
- package/dist/workflow/json-schema.d.ts.map +0 -1
- package/dist/workflow/json-schema.js +0 -112
- package/dist/workflow/json-schema.js.map +0 -1
- package/dist/workflow/meta.d.ts +0 -68
- package/dist/workflow/meta.d.ts.map +0 -1
- package/dist/workflow/meta.js +0 -318
- package/dist/workflow/meta.js.map +0 -1
- package/dist/workflow/progress.d.ts +0 -225
- package/dist/workflow/progress.d.ts.map +0 -1
- package/dist/workflow/progress.js +0 -362
- package/dist/workflow/progress.js.map +0 -1
- package/dist/workflow/runtime.d.ts +0 -335
- package/dist/workflow/runtime.d.ts.map +0 -1
- package/dist/workflow/runtime.js +0 -831
- package/dist/workflow/runtime.js.map +0 -1
- package/dist/workflow/saved.d.ts +0 -91
- package/dist/workflow/saved.d.ts.map +0 -1
- package/dist/workflow/saved.js +0 -204
- package/dist/workflow/saved.js.map +0 -1
- package/dist/workflow/task.d.ts +0 -137
- package/dist/workflow/task.d.ts.map +0 -1
- package/dist/workflow/task.js +0 -208
- package/dist/workflow/task.js.map +0 -1
- package/dist/workflow/tool-description.d.ts +0 -39
- package/dist/workflow/tool-description.d.ts.map +0 -1
- package/dist/workflow/tool-description.js +0 -200
- package/dist/workflow/tool-description.js.map +0 -1
- package/dist/workflow/worker-source.d.ts +0 -48
- package/dist/workflow/worker-source.d.ts.map +0 -1
- package/dist/workflow/worker-source.js +0 -779
- package/dist/workflow/worker-source.js.map +0 -1
- package/dist/worktree.d.ts +0 -53
- package/dist/worktree.d.ts.map +0 -1
- package/dist/worktree.js +0 -165
- package/dist/worktree.js.map +0 -1
- package/dist/write-execution.d.ts +0 -42
- package/dist/write-execution.d.ts.map +0 -1
- package/dist/write-execution.js +0 -138
- package/dist/write-execution.js.map +0 -1
- package/dist/xml.d.ts +0 -11
- package/dist/xml.d.ts.map +0 -1
- package/dist/xml.js +0 -13
- package/dist/xml.js.map +0 -1
- package/src/abortable.ts +0 -43
- package/src/agent-color.ts +0 -161
- package/src/agent-file-toggle.ts +0 -269
- package/src/child-context.ts +0 -15
- package/src/mention-clone.ts +0 -196
- package/src/mention.ts +0 -141
- package/src/model-scope.ts +0 -70
- package/src/nested-tools.ts +0 -424
- package/src/structured-output.ts +0 -130
- package/src/ui/agent-mention.ts +0 -216
- package/src/ui/select-item.ts +0 -45
- package/src/ui/workflow-card.ts +0 -470
- package/src/ui/workflow-dialog.ts +0 -1115
- package/src/ui/workflow-menu.ts +0 -166
- package/src/workflow/collisions.ts +0 -123
- package/src/workflow/entry.ts +0 -47
- package/src/workflow/host.ts +0 -403
- package/src/workflow/journal.ts +0 -164
- package/src/workflow/json-schema.ts +0 -128
- package/src/workflow/meta.ts +0 -325
- package/src/workflow/progress.ts +0 -550
- package/src/workflow/runtime.ts +0 -1219
- package/src/workflow/saved.ts +0 -217
- package/src/workflow/task.ts +0 -302
- package/src/workflow/tool-description.ts +0 -200
- package/src/workflow/worker-source.ts +0 -781
- package/src/xml.ts +0 -13
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-file-toggle.ts — Pure helpers for the `/agents` file-editing operations:
|
|
3
|
-
* locating an agent's .md file, toggling its `enabled:` frontmatter flag, and
|
|
4
|
-
* serializing an AgentConfig back to frontmatter for eject.
|
|
5
|
-
*
|
|
6
|
-
* These live outside src/index.ts so they can be tested directly: the `/agents`
|
|
7
|
-
* command handler is an ~890-line closure reached only through `registerCommand`,
|
|
8
|
-
* which every test mocks.
|
|
9
|
-
*
|
|
10
|
-
* The read side of this data (src/custom-agents.ts) parses frontmatter with a
|
|
11
|
-
* real YAML parser, so it honors `enabled: false` at any position in the block.
|
|
12
|
-
* This module must agree with it, and splits the work accordingly:
|
|
13
|
-
*
|
|
14
|
-
* - Deciding whether a file is disabled is a *read*, so it calls that same parser
|
|
15
|
-
* (`isDisabledContent`) instead of mirroring it. A mirror has to be right about
|
|
16
|
-
* YAML's boolean spellings and about pi's fence scan, and a regex was wrong
|
|
17
|
-
* about both.
|
|
18
|
-
* - *Editing* cannot go through the parser, because re-serializing a parsed
|
|
19
|
-
* document would reformat a file the README tells users to hand-author —
|
|
20
|
-
* discarding their comments, key order, and quoting. So the edits are line-wise
|
|
21
|
-
* and preserve everything they don't touch.
|
|
22
|
-
*
|
|
23
|
-
* That leaves removal best-effort: it recognizes a lowercase bare `false`, and
|
|
24
|
-
* reports `changed: false` for the spellings it cannot rewrite, so the caller
|
|
25
|
-
* refuses honestly rather than announcing a change it did not make.
|
|
26
|
-
*/
|
|
27
|
-
import { existsSync } from "node:fs";
|
|
28
|
-
import { join, sep } from "node:path";
|
|
29
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
30
|
-
import { parseAgentFrontmatter } from "./custom-agents.js";
|
|
31
|
-
export const projectAgentsDir = (cwd = process.cwd()) => join(cwd, ".pi", "agents");
|
|
32
|
-
export const workspaceAgentsDir = (cwd = process.cwd()) => join(cwd, ".agents", "agents");
|
|
33
|
-
export const personalAgentsDir = () => join(getAgentDir(), "agents");
|
|
34
|
-
/**
|
|
35
|
-
* Find the file path of a custom agent by name, in discovery-precedence order
|
|
36
|
-
* (project, workspace, then global). Mirrors the load-side precedence in
|
|
37
|
-
* src/custom-agents.ts — if the two drift, `/agents` edits a file the loader
|
|
38
|
-
* isn't reading.
|
|
39
|
-
*/
|
|
40
|
-
export function findAgentFile(name, cwd = process.cwd()) {
|
|
41
|
-
const projectPath = join(projectAgentsDir(cwd), `${name}.md`);
|
|
42
|
-
if (existsSync(projectPath))
|
|
43
|
-
return { path: projectPath, location: "project" };
|
|
44
|
-
const workspacePath = join(workspaceAgentsDir(cwd), `${name}.md`);
|
|
45
|
-
if (existsSync(workspacePath))
|
|
46
|
-
return { path: workspacePath, location: "workspace" };
|
|
47
|
-
const personalPath = join(personalAgentsDir(), `${name}.md`);
|
|
48
|
-
if (existsSync(personalPath))
|
|
49
|
-
return { path: personalPath, location: "personal" };
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Find the file behind a *loaded* agent, preferring the path the loader
|
|
54
|
-
* actually read (`AgentConfig.sourcePath`) over the `<type>.md` guess.
|
|
55
|
-
*
|
|
56
|
-
* An agent's type comes from its frontmatter `name:` now, so the two can
|
|
57
|
-
* disagree: `reviewer.md` declaring `name: code-reviewer` is loaded as
|
|
58
|
-
* `code-reviewer`, and probing for `code-reviewer.md` finds nothing. That is
|
|
59
|
-
* not a harmless miss — `/agents → Disable` would then take the no-file branch
|
|
60
|
-
* and write a NEW `code-reviewer.md` stub, which loses to `reviewer.md` on
|
|
61
|
-
* load, leaving the agent enabled while reporting success.
|
|
62
|
-
*
|
|
63
|
-
* The probe stays as the fallback: a built-in that was never ejected has no
|
|
64
|
-
* `sourcePath`, and a path can go stale between a load and this call.
|
|
65
|
-
*/
|
|
66
|
-
export function locateAgentFile(name, sourcePath, cwd = process.cwd()) {
|
|
67
|
-
if (sourcePath && existsSync(sourcePath)) {
|
|
68
|
-
return { path: sourcePath, location: classifyAgentDir(sourcePath, cwd) };
|
|
69
|
-
}
|
|
70
|
-
return findAgentFile(name, cwd);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Which discovery location a loaded agent's file came from. Only ever names
|
|
74
|
-
* a directory in a confirmation prompt, so an unrecognized parent — which
|
|
75
|
-
* loadCustomAgents cannot currently produce — reports as personal rather than
|
|
76
|
-
* widening the type for a case that has no better answer.
|
|
77
|
-
*/
|
|
78
|
-
function classifyAgentDir(path, cwd) {
|
|
79
|
-
if (path.startsWith(projectAgentsDir(cwd) + sep))
|
|
80
|
-
return "project";
|
|
81
|
-
if (path.startsWith(workspaceAgentsDir(cwd) + sep))
|
|
82
|
-
return "workspace";
|
|
83
|
-
return "personal";
|
|
84
|
-
}
|
|
85
|
-
/** A line that sets `enabled: false`, ignoring trailing whitespace / CR. */
|
|
86
|
-
const ENABLED_FALSE = /^enabled:[ \t]*false[ \t]*$/;
|
|
87
|
-
/** An opening or closing `---` fence line. */
|
|
88
|
-
const FENCE = /^---[ \t]*$/;
|
|
89
|
-
/**
|
|
90
|
-
* Split a file into its frontmatter lines and everything else, agreeing with
|
|
91
|
-
* what `parseAgentFrontmatter` (the load side) considers a frontmatter block —
|
|
92
|
-
* including its BOM normalisation, which is why the fence test looks past one.
|
|
93
|
-
* The BOM itself stays in `lines[0]`: it belongs to the file's encoding, not to
|
|
94
|
-
* the block, and an edit must not strip it from the user's file.
|
|
95
|
-
*
|
|
96
|
-
* Lines keep their terminators, so an edit preserves the file's existing line
|
|
97
|
-
* endings instead of rewriting CRLF to LF. Returns undefined when there is no
|
|
98
|
-
* usable block.
|
|
99
|
-
*/
|
|
100
|
-
function splitFrontmatter(content) {
|
|
101
|
-
const lines = content.split(/(?<=\n)/);
|
|
102
|
-
if (lines.length === 0)
|
|
103
|
-
return undefined;
|
|
104
|
-
// The BOM stays where it is — it belongs to the file, not the block — so the
|
|
105
|
-
// fence test looks past it and every index below is unaffected.
|
|
106
|
-
const bom = content.startsWith("\uFEFF");
|
|
107
|
-
const first = (bom ? lines[0].slice(1) : lines[0]).replace(/\r?\n$/, "");
|
|
108
|
-
if (!FENCE.test(first))
|
|
109
|
-
return undefined;
|
|
110
|
-
const closeIdx = lines.findIndex((l, i) => i > 0 && FENCE.test(l.replace(/\r?\n$/, "")));
|
|
111
|
-
if (closeIdx === -1)
|
|
112
|
-
return undefined;
|
|
113
|
-
return { lines, openIdx: 0, closeIdx, eol: lines[0].endsWith("\r\n") ? "\r\n" : "\n" };
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Does the loader consider this file disabled?
|
|
117
|
-
*
|
|
118
|
-
* Detection is a READ operation, so it asks the same parser the loader uses
|
|
119
|
-
* rather than mirroring it with a regex — that mirror has to be right about
|
|
120
|
-
* YAML's boolean spellings (`False`, `FALSE`, a trailing `# comment`, a quoted
|
|
121
|
-
* key) *and* about pi's fence scan, which closes the block on any line starting
|
|
122
|
-
* `---` and so ends it early on `----`. A throw means the file is already
|
|
123
|
-
* unparseable, which is what the loader sees too: it skips the agent, so there
|
|
124
|
-
* is no "disabled" state to report.
|
|
125
|
-
*/
|
|
126
|
-
export function isDisabledContent(content) {
|
|
127
|
-
try {
|
|
128
|
-
return parseAgentFrontmatter(content).frontmatter.enabled === false;
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Add `enabled: false` to a file's frontmatter.
|
|
136
|
-
*
|
|
137
|
-
* `outcome` distinguishes a real edit from a no-op so the caller can report
|
|
138
|
-
* honestly instead of unconditionally claiming success.
|
|
139
|
-
*/
|
|
140
|
-
export function disableInContent(content) {
|
|
141
|
-
const block = splitFrontmatter(content);
|
|
142
|
-
if (!block)
|
|
143
|
-
return { content, outcome: "no-frontmatter" };
|
|
144
|
-
if (isDisabledContent(content))
|
|
145
|
-
return { content, outcome: "already-disabled" };
|
|
146
|
-
const lines = [...block.lines];
|
|
147
|
-
lines.splice(1, 0, `enabled: false${block.eol}`);
|
|
148
|
-
return { content: lines.join(""), outcome: "disabled" };
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Remove `enabled: false` from a file's frontmatter, wherever it appears in the
|
|
152
|
-
* block — the loader honors the key at any position, so the two must agree or a
|
|
153
|
-
* hand-authored agent can be disabled and never re-enabled.
|
|
154
|
-
*
|
|
155
|
-
* `changed` is false when the key wasn't found, so the caller can avoid
|
|
156
|
-
* reporting "Enabled <name>" for a write that did nothing.
|
|
157
|
-
*/
|
|
158
|
-
export function enableInContent(content) {
|
|
159
|
-
const block = splitFrontmatter(content);
|
|
160
|
-
if (!block)
|
|
161
|
-
return { content, changed: false };
|
|
162
|
-
const kept = block.lines.filter((l, i) => !(i > 0 && i < block.closeIdx && ENABLED_FALSE.test(l.replace(/\r?\n$/, ""))));
|
|
163
|
-
if (kept.length === block.lines.length)
|
|
164
|
-
return { content, changed: false };
|
|
165
|
-
return { content: kept.join(""), changed: true };
|
|
166
|
-
}
|
|
167
|
-
/** Is this the empty stub `/agents` writes when disabling a built-in default? */
|
|
168
|
-
export function isEmptyStub(content) {
|
|
169
|
-
return content.replace(/\r\n/g, "\n").trim() === "---\n---";
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Build the .md file the create wizard writes.
|
|
173
|
-
*
|
|
174
|
-
* `description` and `model` come straight from a free-text prompt, so they are
|
|
175
|
-
* quoted rather than interpolated — `serializeAgentFile` above quotes the
|
|
176
|
-
* description for the same reason. An unquoted YAML scalar mishandles ordinary
|
|
177
|
-
* input in two ways, and both are silent: a colon ("Scout: find things") makes
|
|
178
|
-
* the file unparseable, and since #212 an unparseable agent file is *skipped*,
|
|
179
|
-
* so the wizard reports success for an agent that does not exist; a `#`
|
|
180
|
-
* ("audit #security") opens a comment and truncates the value. `model` can
|
|
181
|
-
* carry a colon too — pi accepts a `provider/model:thinking` suffix.
|
|
182
|
-
*
|
|
183
|
-
* `tools` and `thinking` are not quoted: both are chosen from fixed menus, and
|
|
184
|
-
* `tools` is a CSV that must stay a bare scalar for the loader's parser.
|
|
185
|
-
*/
|
|
186
|
-
export function buildNewAgentFile(input) {
|
|
187
|
-
const modelLine = input.model ? `\nmodel: ${JSON.stringify(input.model)}` : "";
|
|
188
|
-
const thinkingLine = input.thinking ? `\nthinking: ${input.thinking}` : "";
|
|
189
|
-
return `---
|
|
190
|
-
description: ${JSON.stringify(input.description)}
|
|
191
|
-
tools: ${input.tools}${modelLine}${thinkingLine}
|
|
192
|
-
prompt_mode: replace
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
${input.systemPrompt}
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
198
|
-
/** Render a built-in tool list as a `tools:` frontmatter value. */
|
|
199
|
-
function formatToolsField(tools) {
|
|
200
|
-
if (tools === undefined)
|
|
201
|
-
return "all";
|
|
202
|
-
if (tools.length === 0)
|
|
203
|
-
return "none";
|
|
204
|
-
return tools.join(", ");
|
|
205
|
-
}
|
|
206
|
-
/** Serialize an AgentConfig to a full .md file (frontmatter + system prompt) for eject. */
|
|
207
|
-
export function serializeAgentFile(cfg) {
|
|
208
|
-
const fmFields = [];
|
|
209
|
-
fmFields.push(`description: ${JSON.stringify(cfg.description)}`);
|
|
210
|
-
if (cfg.displayName)
|
|
211
|
-
fmFields.push(`display_name: ${cfg.displayName}`);
|
|
212
|
-
if (cfg.color)
|
|
213
|
-
fmFields.push(`color: ${JSON.stringify(cfg.color)}`);
|
|
214
|
-
// Absent means "all built-ins"; an EMPTY list means explicitly zero. Writing
|
|
215
|
-
// `all` for both would hand a deliberately tool-less agent the whole toolbox
|
|
216
|
-
// the first time it is ejected.
|
|
217
|
-
fmFields.push(`tools: ${formatToolsField(cfg.builtinToolNames)}`);
|
|
218
|
-
if (cfg.model)
|
|
219
|
-
fmFields.push(`model: ${cfg.model}`);
|
|
220
|
-
if (cfg.thinking)
|
|
221
|
-
fmFields.push(`thinking: ${cfg.thinking}`);
|
|
222
|
-
if (cfg.maxTurns)
|
|
223
|
-
fmFields.push(`max_turns: ${cfg.maxTurns}`);
|
|
224
|
-
if (cfg.allowedSubagents !== undefined) {
|
|
225
|
-
fmFields.push(`allowed_subagents: ${cfg.allowedSubagents === "all" ? "all" : cfg.allowedSubagents.join(", ")}`);
|
|
226
|
-
}
|
|
227
|
-
fmFields.push(`prompt_mode: ${cfg.promptMode}`);
|
|
228
|
-
if (cfg.extensions === false)
|
|
229
|
-
fmFields.push("extensions: false");
|
|
230
|
-
else if (Array.isArray(cfg.extensions))
|
|
231
|
-
fmFields.push(`extensions: ${cfg.extensions.join(", ")}`);
|
|
232
|
-
if (cfg.excludeExtensions?.length)
|
|
233
|
-
fmFields.push(`exclude_extensions: ${cfg.excludeExtensions.join(", ")}`);
|
|
234
|
-
if (cfg.skills === false)
|
|
235
|
-
fmFields.push("skills: false");
|
|
236
|
-
else if (Array.isArray(cfg.skills))
|
|
237
|
-
fmFields.push(`skills: ${cfg.skills.join(", ")}`);
|
|
238
|
-
if (cfg.disallowedTools?.length)
|
|
239
|
-
fmFields.push(`disallowed_tools: ${cfg.disallowedTools.join(", ")}`);
|
|
240
|
-
if (cfg.inheritContext)
|
|
241
|
-
fmFields.push("inherit_context: true");
|
|
242
|
-
// Both cases, not just `true`: with `backgroundByDefault` on, omitting the
|
|
243
|
-
// field means background, so `false` is the only way to pin an agent file to
|
|
244
|
-
// foreground and is no longer interchangeable with absence. No caller can
|
|
245
|
-
// reach it yet — Eject only handles built-in defaults, which omit the field —
|
|
246
|
-
// so this keeps the writer symmetric with the loader, nothing more.
|
|
247
|
-
if (cfg.runInBackground !== undefined)
|
|
248
|
-
fmFields.push(`run_in_background: ${cfg.runInBackground}`);
|
|
249
|
-
if (cfg.outputTranscript === false)
|
|
250
|
-
fmFields.push("output_transcript: false");
|
|
251
|
-
if (cfg.isolated)
|
|
252
|
-
fmFields.push("isolated: true");
|
|
253
|
-
if (cfg.memory)
|
|
254
|
-
fmFields.push(`memory: ${cfg.memory}`);
|
|
255
|
-
if (cfg.isolation)
|
|
256
|
-
fmFields.push(`isolation: ${cfg.isolation}`);
|
|
257
|
-
return `---\n${fmFields.join("\n")}\n---\n\n${cfg.systemPrompt}\n`;
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=agent-file-toggle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-file-toggle.js","sourceRoot":"","sources":["../src/agent-file-toggle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAK3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,MAAc,OAAO,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gB,CAAC,CAAC;IAClD,IAAI,GAAG,CAAC,MAAM;QAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,IAAI,GAAG,CAAC,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IAEhE,OAAO,QAAQ,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,YAAY,IAAI,CAAC;AACrE,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Helpers for separating openable active agents from terminal history. */
|
|
2
|
-
import type { AgentRecord } from "./types.js";
|
|
3
|
-
export type AgentHistoryStatus = "completed" | "steered" | "stopped" | "aborted" | "error";
|
|
4
|
-
/** Return whether a record status represents a terminal agent run. */
|
|
5
|
-
export declare function isTerminalAgentStatus(status: string): status is AgentHistoryStatus;
|
|
6
|
-
/** Return whether an active record has a live session that can be opened. */
|
|
7
|
-
export declare function canOpenActiveAgent(record: AgentRecord): boolean;
|
|
8
|
-
/** Return whether a terminal record has an in-memory or durable conversation. */
|
|
9
|
-
export declare function canOpenAgentHistory(record: AgentRecord, cwd: string | undefined): boolean;
|
|
10
|
-
/** Split records into openable active and terminal-history buckets. */
|
|
11
|
-
export declare function splitAgentRecords(records: readonly AgentRecord[], cwd: string | undefined): {
|
|
12
|
-
active: AgentRecord[];
|
|
13
|
-
history: AgentRecord[];
|
|
14
|
-
};
|
|
15
|
-
/** Format a bounded, single-line history menu option. */
|
|
16
|
-
export declare function formatAgentHistoryOption(record: AgentRecord, now: number): string;
|
|
17
|
-
/** Build the visible status-section labels for the agents menu. */
|
|
18
|
-
export declare function buildAgentStatusMenuEntries(records: readonly AgentRecord[], cwd: string | undefined): string[];
|
|
19
|
-
//# sourceMappingURL=agent-history-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history-list.d.ts","sourceRoot":"","sources":["../src/agent-history-list.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAI3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAUZ,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,kBAAkB,CAElF;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAG/D;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIzF;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAanD;AAWD,yDAAyD;AACzD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CASjF;AAED,mEAAmE;AACnE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,MAAM,EAAE,CAMV"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/** Helpers for separating openable active agents from terminal history. */
|
|
2
|
-
import { hasAgentHistory } from "./agent-history.js";
|
|
3
|
-
import { getAgentConfig } from "./agent-types.js";
|
|
4
|
-
import { formatDuration, getDisplayName } from "./ui/agent-widget.js";
|
|
5
|
-
const TERMINAL_STATUSES = new Set([
|
|
6
|
-
"completed",
|
|
7
|
-
"steered",
|
|
8
|
-
"stopped",
|
|
9
|
-
"aborted",
|
|
10
|
-
"error",
|
|
11
|
-
]);
|
|
12
|
-
/** Return whether a record status represents a terminal agent run. */
|
|
13
|
-
export function isTerminalAgentStatus(status) {
|
|
14
|
-
return TERMINAL_STATUSES.has(status);
|
|
15
|
-
}
|
|
16
|
-
/** Return whether an active record has a live session that can be opened. */
|
|
17
|
-
export function canOpenActiveAgent(record) {
|
|
18
|
-
return (record.status === "running" || record.status === "queued")
|
|
19
|
-
&& record.session !== undefined;
|
|
20
|
-
}
|
|
21
|
-
/** Return whether a terminal record has an in-memory or durable conversation. */
|
|
22
|
-
export function canOpenAgentHistory(record, cwd) {
|
|
23
|
-
if (!isTerminalAgentStatus(record.status))
|
|
24
|
-
return false;
|
|
25
|
-
return record.session !== undefined
|
|
26
|
-
|| (cwd !== undefined && hasAgentHistory(cwd, record.transcriptPath));
|
|
27
|
-
}
|
|
28
|
-
/** Split records into openable active and terminal-history buckets. */
|
|
29
|
-
export function splitAgentRecords(records, cwd) {
|
|
30
|
-
const active = [];
|
|
31
|
-
const history = [];
|
|
32
|
-
for (const record of records) {
|
|
33
|
-
if (canOpenActiveAgent(record)) {
|
|
34
|
-
active.push(record);
|
|
35
|
-
}
|
|
36
|
-
else if (canOpenAgentHistory(record, cwd)) {
|
|
37
|
-
history.push(record);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { active, history };
|
|
41
|
-
}
|
|
42
|
-
const DESCRIPTION_LIMIT = 72;
|
|
43
|
-
const LABEL_LIMIT = 140;
|
|
44
|
-
function boundedDescription(description) {
|
|
45
|
-
const line = description.split("\n").find((part) => part.trim())?.trim() ?? "";
|
|
46
|
-
if (line.length <= DESCRIPTION_LIMIT)
|
|
47
|
-
return line;
|
|
48
|
-
return `${line.slice(0, DESCRIPTION_LIMIT - 1)}…`;
|
|
49
|
-
}
|
|
50
|
-
/** Format a bounded, single-line history menu option. */
|
|
51
|
-
export function formatAgentHistoryOption(record, now) {
|
|
52
|
-
const duration = formatDuration(record.startedAt, record.completedAt ?? now);
|
|
53
|
-
// Unit consumers may format persisted records before the registry has been
|
|
54
|
-
// initialized; preserve the persisted type instead of falling back to
|
|
55
|
-
// general-purpose's generic display name in that case.
|
|
56
|
-
const displayName = getAgentConfig(record.type)?.displayName
|
|
57
|
-
?? (record.type === "general-purpose" ? getDisplayName(record.type) : record.type);
|
|
58
|
-
const option = `[${record.status}] ${displayName} · ${boundedDescription(record.description)} · ${duration}`;
|
|
59
|
-
return option.length <= LABEL_LIMIT ? option : `${option.slice(0, LABEL_LIMIT - 1)}…`;
|
|
60
|
-
}
|
|
61
|
-
/** Build the visible status-section labels for the agents menu. */
|
|
62
|
-
export function buildAgentStatusMenuEntries(records, cwd) {
|
|
63
|
-
const { active, history } = splitAgentRecords(records, cwd);
|
|
64
|
-
return [
|
|
65
|
-
...(active.length > 0 ? [`Running agents (${active.length})`] : []),
|
|
66
|
-
...(history.length > 0 ? [`Agent history (${history.length})`] : []),
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=agent-history-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history-list.js","sourceRoot":"","sources":["../src/agent-history-list.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAStE,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAqB;IACzE,WAAW;IACX,SAAS;IACT,SAAS;IACT,SAAS;IACT,OAAO;CACR,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,MAAmB;IACpD,OAAO,CAAC,MAA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AC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC"}
|
package/dist/agent-history.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** Durable, project-local transcript storage for subagents. */
|
|
2
|
-
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
/**
|
|
4
|
-
* Ensure project-local subagent artifacts are ignored by git.
|
|
5
|
-
*
|
|
6
|
-
* The rule is appended instead of rewriting the file. This preserves any
|
|
7
|
-
* existing user-owned rules and makes concurrent callers harmless (duplicate
|
|
8
|
-
* `*` rules are semantically equivalent).
|
|
9
|
-
*/
|
|
10
|
-
export declare function ensureSubagentsGitignore(cwd: string): string;
|
|
11
|
-
/** Return the durable transcript path for an agent. */
|
|
12
|
-
export declare function createAgentHistoryPath(cwd: string, agentId: string): string;
|
|
13
|
-
/** Return the project-relative path stored in the parent session record. */
|
|
14
|
-
export declare function agentHistoryLocator(cwd: string, historyPath: string): string;
|
|
15
|
-
/** Write the first user prompt without involving the optional `.output` file. */
|
|
16
|
-
export declare function writeAgentHistoryInitialEntry(path: string, agentId: string, prompt: string, cwd: string): void;
|
|
17
|
-
/** Stream every new session message to the mandatory durable history file. */
|
|
18
|
-
export declare function streamAgentHistory(session: AgentSession, path: string, agentId: string, cwd: string, startIndex?: number): () => void;
|
|
19
|
-
/** Resolve only paths in this package's project-local transcript namespace. */
|
|
20
|
-
export declare function resolveAgentHistoryPath(cwd: string, locator: string): string | undefined;
|
|
21
|
-
/** Return true only when a valid project-local transcript file exists. */
|
|
22
|
-
export declare function hasAgentHistory(cwd: string, locator: string | undefined): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Read persisted transcript entries into the message shape used by the live
|
|
25
|
-
* conversation viewer. Malformed lines and unknown records are skipped so one
|
|
26
|
-
* damaged entry cannot hide the rest of a history.
|
|
27
|
-
*/
|
|
28
|
-
export declare function readAgentHistory(cwd: string, locator: string): AgentSession["messages"] | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Read the last assistant text from a durable transcript. Runtime records may
|
|
31
|
-
* release their in-memory result after the retention TTL; the transcript then
|
|
32
|
-
* becomes the source of truth for get_subagent_result.
|
|
33
|
-
*/
|
|
34
|
-
export declare function readAgentHistoryResult(cwd: string, locator: string): string | undefined;
|
|
35
|
-
//# sourceMappingURL=agent-history.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history.d.ts","sourceRoot":"","sources":["../src/agent-history.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iCAAiC,CAAC;AAMvF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe5D;AAED,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3E;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5E;AAaD,iFAAiF;AACjF,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAG9G;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,UAAU,SAAI,GACb,MAAM,IAAI,CA0BZ;AAED,+EAA+E;AAC/E,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWxF;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIjF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CA2BnG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA+BvF"}
|
package/dist/agent-history.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/** Durable, project-local transcript storage for subagents. */
|
|
2
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
const SUBAGENTS_DIR = ".pi-subagents";
|
|
5
|
-
const TRANSCRIPTS_DIR = "agent-transcripts";
|
|
6
|
-
const MAX_HISTORY_BYTES = 20 * 1024 * 1024;
|
|
7
|
-
/**
|
|
8
|
-
* Ensure project-local subagent artifacts are ignored by git.
|
|
9
|
-
*
|
|
10
|
-
* The rule is appended instead of rewriting the file. This preserves any
|
|
11
|
-
* existing user-owned rules and makes concurrent callers harmless (duplicate
|
|
12
|
-
* `*` rules are semantically equivalent).
|
|
13
|
-
*/
|
|
14
|
-
export function ensureSubagentsGitignore(cwd) {
|
|
15
|
-
const directory = join(cwd, SUBAGENTS_DIR);
|
|
16
|
-
mkdirSync(directory, { recursive: true });
|
|
17
|
-
const path = join(directory, ".gitignore");
|
|
18
|
-
let content = "";
|
|
19
|
-
try {
|
|
20
|
-
content = readFileSync(path, "utf8");
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// The append below also creates a missing file.
|
|
24
|
-
}
|
|
25
|
-
if (!content.split(/\r?\n/).some((line) => line.trim() === "*")) {
|
|
26
|
-
const separator = content.length > 0 && !/[\r\n]$/.test(content) ? "\n" : "";
|
|
27
|
-
appendFileSync(path, `${separator}*\n`, "utf8");
|
|
28
|
-
}
|
|
29
|
-
return path;
|
|
30
|
-
}
|
|
31
|
-
/** Return the durable transcript path for an agent. */
|
|
32
|
-
export function createAgentHistoryPath(cwd, agentId) {
|
|
33
|
-
ensureSubagentsGitignore(cwd);
|
|
34
|
-
const directory = join(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
|
|
35
|
-
mkdirSync(directory, { recursive: true });
|
|
36
|
-
const safeId = agentId.replace(/[^A-Za-z0-9._-]+/g, "-") || "agent";
|
|
37
|
-
return join(directory, `${safeId}.jsonl`);
|
|
38
|
-
}
|
|
39
|
-
/** Return the project-relative path stored in the parent session record. */
|
|
40
|
-
export function agentHistoryLocator(cwd, historyPath) {
|
|
41
|
-
return relative(cwd, historyPath).split(sep).join("/");
|
|
42
|
-
}
|
|
43
|
-
function historyEntry(agentId, message, cwd) {
|
|
44
|
-
return JSON.stringify({
|
|
45
|
-
isSidechain: true,
|
|
46
|
-
agentId,
|
|
47
|
-
type: message.role === "assistant" ? "assistant" : message.role === "user" ? "user" : "toolResult",
|
|
48
|
-
message,
|
|
49
|
-
timestamp: new Date().toISOString(),
|
|
50
|
-
cwd,
|
|
51
|
-
}) + "\n";
|
|
52
|
-
}
|
|
53
|
-
/** Write the first user prompt without involving the optional `.output` file. */
|
|
54
|
-
export function writeAgentHistoryInitialEntry(path, agentId, prompt, cwd) {
|
|
55
|
-
if (existsSync(path))
|
|
56
|
-
return;
|
|
57
|
-
writeFileSync(path, historyEntry(agentId, { role: "user", content: prompt }, cwd), "utf8");
|
|
58
|
-
}
|
|
59
|
-
/** Stream every new session message to the mandatory durable history file. */
|
|
60
|
-
export function streamAgentHistory(session, path, agentId, cwd, startIndex = 1) {
|
|
61
|
-
let writtenCount = startIndex;
|
|
62
|
-
const messages = () => Array.isArray(session.messages) ? session.messages : [];
|
|
63
|
-
const flush = () => {
|
|
64
|
-
const currentMessages = messages();
|
|
65
|
-
while (writtenCount < currentMessages.length) {
|
|
66
|
-
try {
|
|
67
|
-
appendFileSync(path, historyEntry(agentId, currentMessages[writtenCount], cwd), "utf8");
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// A read-only project must not turn a model event into a failed run.
|
|
71
|
-
}
|
|
72
|
-
writtenCount++;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const unsubscribe = typeof session.subscribe === "function"
|
|
76
|
-
? session.subscribe((event) => {
|
|
77
|
-
if (event.type === "turn_end" || event.type === "compaction_start")
|
|
78
|
-
flush();
|
|
79
|
-
if (event.type === "compaction_end" && !event.aborted && event.result) {
|
|
80
|
-
queueMicrotask(() => { writtenCount = messages().length; });
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
: () => { };
|
|
84
|
-
return () => {
|
|
85
|
-
flush();
|
|
86
|
-
unsubscribe();
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/** Resolve only paths in this package's project-local transcript namespace. */
|
|
90
|
-
export function resolveAgentHistoryPath(cwd, locator) {
|
|
91
|
-
// Locators are persisted data, not arbitrary paths. Reject traversal syntax
|
|
92
|
-
// before resolving so a path which normalizes back inside the namespace is
|
|
93
|
-
// still not accepted as an unsafe locator.
|
|
94
|
-
if (!locator || isAbsolute(locator) || locator.includes("\0") || locator.includes("\\"))
|
|
95
|
-
return undefined;
|
|
96
|
-
const segments = locator.split("/");
|
|
97
|
-
if (segments.some((segment) => segment === ".." || segment === ""))
|
|
98
|
-
return undefined;
|
|
99
|
-
const root = resolve(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
|
|
100
|
-
const candidate = resolve(cwd, locator);
|
|
101
|
-
if (candidate !== root && !candidate.startsWith(`${root}${sep}`))
|
|
102
|
-
return undefined;
|
|
103
|
-
return candidate;
|
|
104
|
-
}
|
|
105
|
-
/** Return true only when a valid project-local transcript file exists. */
|
|
106
|
-
export function hasAgentHistory(cwd, locator) {
|
|
107
|
-
if (!locator)
|
|
108
|
-
return false;
|
|
109
|
-
const path = resolveAgentHistoryPath(cwd, locator);
|
|
110
|
-
return path !== undefined && existsSync(path);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Read persisted transcript entries into the message shape used by the live
|
|
114
|
-
* conversation viewer. Malformed lines and unknown records are skipped so one
|
|
115
|
-
* damaged entry cannot hide the rest of a history.
|
|
116
|
-
*/
|
|
117
|
-
export function readAgentHistory(cwd, locator) {
|
|
118
|
-
const path = resolveAgentHistoryPath(cwd, locator);
|
|
119
|
-
if (!path || !existsSync(path))
|
|
120
|
-
return undefined;
|
|
121
|
-
let raw;
|
|
122
|
-
try {
|
|
123
|
-
raw = readFileSync(path, "utf8");
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
if (raw.length > MAX_HISTORY_BYTES)
|
|
129
|
-
raw = raw.slice(0, MAX_HISTORY_BYTES);
|
|
130
|
-
const messages = [];
|
|
131
|
-
for (const line of raw.split(/\r?\n/)) {
|
|
132
|
-
if (!line.trim())
|
|
133
|
-
continue;
|
|
134
|
-
try {
|
|
135
|
-
const entry = JSON.parse(line);
|
|
136
|
-
const message = entry?.message;
|
|
137
|
-
if (!message || typeof message !== "object")
|
|
138
|
-
continue;
|
|
139
|
-
const role = message.role;
|
|
140
|
-
if (typeof role !== "string")
|
|
141
|
-
continue;
|
|
142
|
-
messages.push(message);
|
|
143
|
-
}
|
|
144
|
-
catch {
|
|
145
|
-
// Ignore malformed/truncated JSONL records.
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return messages.length > 0 ? messages : undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Read the last assistant text from a durable transcript. Runtime records may
|
|
152
|
-
* release their in-memory result after the retention TTL; the transcript then
|
|
153
|
-
* becomes the source of truth for get_subagent_result.
|
|
154
|
-
*/
|
|
155
|
-
export function readAgentHistoryResult(cwd, locator) {
|
|
156
|
-
const messages = readAgentHistory(cwd, locator);
|
|
157
|
-
if (!messages)
|
|
158
|
-
return undefined;
|
|
159
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
160
|
-
const message = messages[i];
|
|
161
|
-
if (message.role !== "assistant")
|
|
162
|
-
continue;
|
|
163
|
-
// AgentSession types currently model content as an array, but the
|
|
164
|
-
// persisted JSONL format may also contain a plain string. Cross the
|
|
165
|
-
// runtime/parser boundary through unknown so both shapes remain safe.
|
|
166
|
-
const content = message.content;
|
|
167
|
-
if (typeof content === "string") {
|
|
168
|
-
const text = content.trim();
|
|
169
|
-
if (text)
|
|
170
|
-
return text;
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
if (!Array.isArray(content))
|
|
174
|
-
continue;
|
|
175
|
-
const text = content
|
|
176
|
-
.filter((part) => typeof part === "object"
|
|
177
|
-
&& part !== null
|
|
178
|
-
&& part.type === "text"
|
|
179
|
-
&& typeof part.text === "string")
|
|
180
|
-
.map((part) => part.text)
|
|
181
|
-
.join("\n")
|
|
182
|
-
.trim();
|
|
183
|
-
if (text)
|
|
184
|
-
return text;
|
|
185
|
-
}
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=agent-history.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../src/agent-history.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrE,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IA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