@esso0428/pi-subagents 0.15.5 → 0.15.6

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 (73) hide show
  1. package/CHANGELOG.md +4 -22
  2. package/README.md +5 -5
  3. package/dist/agent-history-list.d.ts +18 -0
  4. package/dist/agent-history-list.js +68 -0
  5. package/dist/agent-history.d.ts +1 -1
  6. package/dist/agent-history.js +31 -34
  7. package/dist/agent-manager.d.ts +22 -8
  8. package/dist/agent-manager.js +100 -93
  9. package/dist/agent-runner.js +67 -86
  10. package/dist/agent-types.js +27 -45
  11. package/dist/context.js +2 -6
  12. package/dist/cross-extension-rpc.js +5 -9
  13. package/dist/custom-agents.js +15 -18
  14. package/dist/default-agents.js +1 -4
  15. package/dist/enabled-models.js +11 -16
  16. package/dist/env.js +1 -4
  17. package/dist/group-join.js +1 -5
  18. package/dist/index.js +273 -286
  19. package/dist/invocation-config.js +2 -6
  20. package/dist/memory.js +24 -34
  21. package/dist/model-resolver.js +1 -4
  22. package/dist/nico-overrides.js +14 -20
  23. package/dist/output-file.js +16 -22
  24. package/dist/prompts.js +1 -4
  25. package/dist/schedule-store.js +16 -21
  26. package/dist/schedule.js +8 -12
  27. package/dist/settings.js +15 -23
  28. package/dist/skill-loader.js +20 -23
  29. package/dist/status-note.js +1 -4
  30. package/dist/types.d.ts +0 -1
  31. package/dist/types.js +1 -4
  32. package/dist/ui/agent-widget.d.ts +1 -5
  33. package/dist/ui/agent-widget.js +25 -49
  34. package/dist/ui/conversation-blocks.d.ts +18 -0
  35. package/dist/ui/conversation-blocks.js +214 -0
  36. package/dist/ui/conversation-nvim.d.ts +7 -0
  37. package/dist/ui/conversation-nvim.js +116 -0
  38. package/dist/ui/conversation-search.d.ts +38 -0
  39. package/dist/ui/conversation-search.js +123 -0
  40. package/dist/ui/conversation-viewer.d.ts +55 -19
  41. package/dist/ui/conversation-viewer.js +398 -215
  42. package/dist/ui/fleet-list.d.ts +23 -11
  43. package/dist/ui/fleet-list.js +85 -78
  44. package/dist/ui/schedule-menu.js +1 -4
  45. package/dist/ui/viewer-keys.js +7 -10
  46. package/dist/usage.js +4 -10
  47. package/dist/worktree.js +26 -31
  48. package/package.json +1 -1
  49. package/src/agent-history-list.ts +91 -0
  50. package/src/agent-history.ts +12 -17
  51. package/src/agent-manager.ts +108 -81
  52. package/src/agent-runner.ts +5 -13
  53. package/src/index.ts +84 -89
  54. package/src/output-file.ts +1 -1
  55. package/src/types.ts +0 -1
  56. package/src/ui/agent-widget.ts +1 -8
  57. package/src/ui/conversation-blocks.ts +270 -0
  58. package/src/ui/conversation-nvim.ts +127 -0
  59. package/src/ui/conversation-search.ts +161 -0
  60. package/src/ui/conversation-viewer.ts +376 -205
  61. package/src/ui/fleet-list.ts +73 -52
  62. package/test/agent-history-list.test.ts +121 -0
  63. package/test/agent-manager-history.test.ts +59 -58
  64. package/test/agent-menu-history-navigation.test.ts +86 -0
  65. package/test/ui/conversation-blocks.test.ts +72 -0
  66. package/test/ui/conversation-search.test.ts +55 -0
  67. package/test/ui/conversation-viewer.test.ts +132 -0
  68. package/test/ui/fleet-list.test.ts +131 -0
  69. package/dist/ui/markdown-result.d.ts +0 -3
  70. package/dist/ui/markdown-result.js +0 -53
  71. package/src/ui/markdown-result.ts +0 -56
  72. package/test/agent-history.test.ts +0 -63
  73. package/test/ui/markdown-result.test.ts +0 -45
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /**
3
2
  * custom-agents.ts — Load user-defined agents from project (.pi/agents/, plus the shared .agents/agents/ workspace) and global ($PI_CODING_AGENT_DIR/agents/, default ~/.pi/agent/agents/) locations.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadCustomAgents = loadCustomAgents;
7
- const node_fs_1 = require("node:fs");
8
- const node_path_1 = require("node:path");
9
- const pi_coding_agent_1 = require("@earendil-works/pi-coding-agent");
10
- const agent_types_js_1 = require("./agent-types.js");
4
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
5
+ import { basename, join } from "node:path";
6
+ import { getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
7
+ import { BUILTIN_TOOL_NAMES } from "./agent-types.js";
11
8
  /**
12
9
  * Scan for custom agent .md files from multiple locations.
13
10
  * Discovery hierarchy (higher priority wins):
@@ -20,10 +17,10 @@ const agent_types_js_1 = require("./agent-types.js");
20
17
  * authority; .agents/agents is an additional read location.
21
18
  * Any name is allowed — names matching defaults (e.g. "Explore") override them.
22
19
  */
23
- function loadCustomAgents(cwd) {
24
- const globalDir = (0, node_path_1.join)((0, pi_coding_agent_1.getAgentDir)(), "agents");
25
- const workspaceProjectDir = (0, node_path_1.join)(cwd, ".agents", "agents");
26
- const projectDir = (0, node_path_1.join)(cwd, ".pi", "agents");
20
+ export function loadCustomAgents(cwd) {
21
+ const globalDir = join(getAgentDir(), "agents");
22
+ const workspaceProjectDir = join(cwd, ".agents", "agents");
23
+ const projectDir = join(cwd, ".pi", "agents");
27
24
  const agents = new Map();
28
25
  loadFromDir(globalDir, agents, "global"); // lowest priority
29
26
  loadFromDir(workspaceProjectDir, agents, "project"); // shared workspace
@@ -32,25 +29,25 @@ function loadCustomAgents(cwd) {
32
29
  }
33
30
  /** Load agent configs from a directory into the map. */
34
31
  function loadFromDir(dir, agents, source) {
35
- if (!(0, node_fs_1.existsSync)(dir))
32
+ if (!existsSync(dir))
36
33
  return;
37
34
  let files;
38
35
  try {
39
- files = (0, node_fs_1.readdirSync)(dir).filter(f => f.endsWith(".md"));
36
+ files = readdirSync(dir).filter(f => f.endsWith(".md"));
40
37
  }
41
38
  catch {
42
39
  return;
43
40
  }
44
41
  for (const file of files) {
45
- const name = (0, node_path_1.basename)(file, ".md");
42
+ const name = basename(file, ".md");
46
43
  let content;
47
44
  try {
48
- content = (0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, file), "utf-8");
45
+ content = readFileSync(join(dir, file), "utf-8");
49
46
  }
50
47
  catch {
51
48
  continue;
52
49
  }
53
- const { frontmatter: fm, body } = (0, pi_coding_agent_1.parseFrontmatter)(content);
50
+ const { frontmatter: fm, body } = parseFrontmatter(content);
54
51
  const { builtinToolNames, extSelectors } = parseToolsField(fm.tools);
55
52
  agents.set(name, {
56
53
  name,
@@ -119,13 +116,13 @@ function csvList(val, defaults) {
119
116
  * `tools:` present with only `ext:` entries → zero built-ins (use `*`).
120
117
  */
121
118
  function parseToolsField(val) {
122
- const entries = csvList(val, agent_types_js_1.BUILTIN_TOOL_NAMES);
119
+ const entries = csvList(val, BUILTIN_TOOL_NAMES);
123
120
  const isWildcard = (e) => e === "*" || e.toLowerCase() === "all";
124
121
  const hasWildcard = entries.some(isWildcard);
125
122
  const plain = entries.filter(e => !isWildcard(e) && !e.startsWith("ext:"));
126
123
  const extEntries = entries.filter(e => e.startsWith("ext:"));
127
124
  return {
128
- builtinToolNames: hasWildcard ? [...new Set([...agent_types_js_1.BUILTIN_TOOL_NAMES, ...plain])] : plain,
125
+ builtinToolNames: hasWildcard ? [...new Set([...BUILTIN_TOOL_NAMES, ...plain])] : plain,
129
126
  extSelectors: extEntries.length > 0 ? extEntries : undefined,
130
127
  };
131
128
  }
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /**
3
2
  * default-agents.ts — Embedded default agent configurations.
4
3
  *
5
4
  * These are always available but can be overridden by user .md files with the same name.
6
5
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.DEFAULT_AGENTS = void 0;
9
6
  const READ_ONLY_TOOLS = ["read", "bash", "grep", "find", "ls"];
10
- exports.DEFAULT_AGENTS = new Map([
7
+ export const DEFAULT_AGENTS = new Map([
11
8
  [
12
9
  "general-purpose",
13
10
  {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Reads `enabledModels` from pi's settings (global `<agentDir>/settings.json`
4
3
  * + project-local `<cwd>/.pi/settings.json`, project wins) and resolves
@@ -26,26 +25,22 @@
26
25
  * enabledModels = ["anthropic/claude-sonnet-4-6", "anthropic/claude-opus-4-6"]
27
26
  * → resolves to { "anthropic/claude-sonnet-4-6", "anthropic/claude-opus-4-6" }
28
27
  */
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.readEnabledModels = readEnabledModels;
31
- exports.resolveEnabledModels = resolveEnabledModels;
32
- exports.isModelInScope = isModelInScope;
33
- const node_fs_1 = require("node:fs");
34
- const node_path_1 = require("node:path");
35
- const pi_coding_agent_1 = require("@earendil-works/pi-coding-agent");
28
+ import { existsSync, readFileSync, statSync } from "node:fs";
29
+ import { join } from "node:path";
30
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
36
31
  /** Paths to pi's settings.json files: [project, global] (project takes precedence). */
37
32
  function settingsPaths(cwd) {
38
33
  return [
39
- (0, node_path_1.join)(cwd, ".pi", "settings.json"),
40
- (0, node_path_1.join)((0, pi_coding_agent_1.getAgentDir)(), "settings.json"),
34
+ join(cwd, ".pi", "settings.json"),
35
+ join(getAgentDir(), "settings.json"),
41
36
  ];
42
37
  }
43
38
  /** Read `enabledModels` from a single settings.json file. Undefined when missing or absent. */
44
39
  function readField(path) {
45
- if (!(0, node_fs_1.existsSync)(path))
40
+ if (!existsSync(path))
46
41
  return undefined;
47
42
  try {
48
- const raw = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
43
+ const raw = JSON.parse(readFileSync(path, "utf-8"));
49
44
  if (Array.isArray(raw?.enabledModels))
50
45
  return raw.enabledModels;
51
46
  }
@@ -60,7 +55,7 @@ function readField(path) {
60
55
  * (and matches our own loadSettings precedence in src/settings.ts).
61
56
  * Returns undefined when neither file has the field.
62
57
  */
63
- function readEnabledModels(cwd) {
58
+ export function readEnabledModels(cwd) {
64
59
  const [project, global] = settingsPaths(cwd);
65
60
  return readField(project) ?? readField(global);
66
61
  }
@@ -85,14 +80,14 @@ let cachedPatternsKey = "";
85
80
  /** mtime+size hash of one file, or "missing" if absent. */
86
81
  function hashOf(path) {
87
82
  try {
88
- const s = (0, node_fs_1.statSync)(path);
83
+ const s = statSync(path);
89
84
  return `${s.mtimeMs}-${s.size}`;
90
85
  }
91
86
  catch {
92
87
  return "missing";
93
88
  }
94
89
  }
95
- function resolveEnabledModels(patterns, registry, cwd = process.cwd()) {
90
+ export function resolveEnabledModels(patterns, registry, cwd = process.cwd()) {
96
91
  // Fast path: check cache (stat both project and global settings.json files)
97
92
  const patternsKey = JSON.stringify(patterns);
98
93
  const [project, global] = settingsPaths(cwd);
@@ -126,7 +121,7 @@ function resolveEnabledModels(patterns, registry, cwd = process.cwd()) {
126
121
  * (`provider/id` lowercase) so callers don't have to reproduce it —
127
122
  * both set-building (resolveExact) and lookup go through `modelKey`.
128
123
  */
129
- function isModelInScope(model, allowed) {
124
+ export function isModelInScope(model, allowed) {
130
125
  return allowed.has(modelKey(model));
131
126
  }
132
127
  /** Canonical lowercase `provider/id` key for the allowed set. */
package/dist/env.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * env.ts — Detect environment info (git, platform) for subagent system prompts.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.detectEnv = detectEnv;
7
- async function detectEnv(pi, cwd) {
4
+ export async function detectEnv(pi, cwd) {
8
5
  let isGitRepo = false;
9
6
  let branch = "";
10
7
  try {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * group-join.ts — Manages grouped background agent completion notifications.
4
3
  *
@@ -6,13 +5,11 @@
6
5
  * agents in a group are held until all complete (or a timeout fires),
7
6
  * then a single consolidated notification is sent.
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.GroupJoinManager = void 0;
11
8
  /** Default timeout: 30s after first completion in a group. */
12
9
  const DEFAULT_TIMEOUT = 30_000;
13
10
  /** Straggler re-batch timeout: 15s. */
14
11
  const STRAGGLER_TIMEOUT = 15_000;
15
- class GroupJoinManager {
12
+ export class GroupJoinManager {
16
13
  deliverCb;
17
14
  groupTimeout;
18
15
  groups = new Map();
@@ -117,4 +114,3 @@ class GroupJoinManager {
117
114
  this.agentToGroup.clear();
118
115
  }
119
116
  }
120
- exports.GroupJoinManager = GroupJoinManager;