pi-subagent-manager 0.2.0 → 0.3.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/README.md +97 -18
- package/agents/architect.md +37 -2
- package/agents/coder.md +41 -0
- package/agents/reviewer.md +32 -0
- package/agents/tasker.md +38 -0
- package/agents/writer.md +34 -0
- package/docs/default-agents.md +105 -0
- package/docs/research-claude.md +258 -0
- package/docs/research-codex.md +143 -0
- package/docs/research-model-roles-coding.md +99 -0
- package/docs/research-model-roles-writing.md +78 -0
- package/package.json +8 -3
- package/src/agent-import.ts +245 -0
- package/src/config.ts +23 -9
- package/src/dialog.ts +631 -0
- package/src/import-discovery.ts +643 -0
- package/src/import-instructions.ts +156 -0
- package/src/import-picker.ts +231 -0
- package/src/index.ts +102 -24
- package/src/manager.ts +67 -2
- package/src/model-picker.ts +194 -92
- package/src/models.ts +8 -2
- package/src/runtime.ts +70 -15
- package/src/settings-ui.ts +173 -0
- package/src/settings.ts +153 -8
- package/src/status-ui.ts +288 -0
- package/src/thread-tree.ts +134 -0
- package/src/tools.ts +21 -10
- package/src/types.ts +24 -1
- package/src/ui.ts +760 -102
- package/agents/researcher.md +0 -14
- package/agents/worker.md +0 -6
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Technical Research: advisory model roles for writing and evidence research
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Requested cutoff: **2026-10-03**; freshest dated Arena snapshot discovered: **2026-10-02**. The confirmed five defaults are **architect (absorbs research), reviewer (GPT-only), coder, tasker, writer**. Recommend keeping writing separate from evidence gathering. All names below are advisory `modelSuggestions`, not runtime pins or configuration edits.
|
|
6
|
+
|
|
7
|
+
**Tool disclosure:** the parent confirms Exa MCP search/fetch tools are accessible through its codemode. This child session does **not** expose codemode or those MCP tools and does not inherit parent tools. This research used `web_search` with `provider: "exa"` for Exa-based discovery and `fetch_content` for selected pages, not Exa MCP fetch. Context7 and code-search tools are unavailable here. Read the requested web-research skill. Only this document was written; no source/config edits or git operations were performed.
|
|
8
|
+
|
|
9
|
+
## Advisory modelSuggestions: confirmed five roles
|
|
10
|
+
|
|
11
|
+
| Role | Suggestions for evaluation | Evidence / limitation |
|
|
12
|
+
| ----------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| Architect, including research | Claude Opus 5.5; GPT-6 Astra; accessible Gemini reasoning-class model | Long-horizon planning and source synthesis; choose using identical retrieval budgets and claim-support tests, not writing preference. |
|
|
14
|
+
| Reviewer — GPT-only | GPT-6 Astra; another verified available GPT reasoning-class model if cost requires | Astra is officially documented for research and complex reasoning. Require independent source-entailment checking; do not recommend non-GPT alternatives for this role. |
|
|
15
|
+
| Coder | Claude Opus 5.5; Muse Spark 1.3 | Official releases emphasize agentic coding. This is a candidate shortlist, not a comprehensive coding benchmark ranking. |
|
|
16
|
+
| Tasker | Muse Spark 1.3; verified available Gemini Flash-class model | Cost-sensitive bounded execution candidate. Evidence here does not establish a tasker winner; test instruction following, tool-call correctness, and latency. |
|
|
17
|
+
| Writer | Claude Opus 5.5; Claude Fable 5 / 5.1; GPT-6 Astra; Gemini 4 Argon when accessible | Opus 5.5 combines strong human preference and verified general availability. Fable/Astra merit fiction and voice trials; Argon is phased/restricted. No universal writing winner. |
|
|
18
|
+
|
|
19
|
+
Do not turn the table into a mandatory provider/model lookup. Resolve actual available models against the runtime registry when implementation is requested. Fable's benchmark names do not establish an accessible provider route; Argon's Arena configuration is not an API ID.
|
|
20
|
+
|
|
21
|
+
This table records exploratory candidates from the writing/research sweep, not the finalized bundled lists. Coding/tasker choices defer to the coding report; Fable is omitted from the shipped writer suggestions because no provider route was verified. See the [final five-role suggestions](default-agents.md).
|
|
22
|
+
|
|
23
|
+
### Research-tool contract for architect
|
|
24
|
+
|
|
25
|
+
The current child runtime does not inherit MCP/parent tools. Architect must consume a **supplied research packet** or use **authorized shell retrieval**, including an Exa CLI/API only if it is actually installed/configured and authorized. Do not hardcode unavailable Exa MCP tool names into child instructions, promise nonexistent tool access, or embed credentials. If retrieval is unavailable, explicitly state that limitation and ask for parent-supplied sources. Parent-side codemode Exa access can produce the packet: URLs, dates, fetched passages, contradictions, and unresolved questions. Model ability and retrieval availability are separate decisions.
|
|
26
|
+
|
|
27
|
+
### Five versus six responsibilities
|
|
28
|
+
|
|
29
|
+
**Prefer architect + researcher:** architectural decisions naturally depend on requirements, documentation, constraints, and alternatives. Keep the writer separate so evidence collection is not optimized for compelling narrative. Risk: confirmation bias toward a preferred design; mitigate with competing hypotheses and GPT-only review.
|
|
30
|
+
|
|
31
|
+
**Writer + researcher alternative:** reduces handoffs and is useful for short, low-stakes editorial work. It couples prose preference with source selection and unsupported interpolation. If used, require research first, a frozen evidence packet, composition second, and separate citation verification. These are workflow recommendations, not leaderboard findings.
|
|
32
|
+
|
|
33
|
+
## Findings
|
|
34
|
+
|
|
35
|
+
1. **Arena measures human preference, not factuality.** The Oct 2 creative-writing index lists `gemini-4-argon-high` 1519±19 (preliminary; 1,097 votes), `claude-opus-5.5-high` 1516±20 (1,058), `claude-fable-5-high` 1503±8 (8,182), and `claude-opus-4-6-high` 1501±6 (14,085). Intervals overlap substantially. Writing/literature/language similarly lists Argon 1522±17 and Opus 5.5 1519±17. These category-specific blind preferences are not citation or editorial fact-check scores. `high` denotes a tested configuration, not necessarily an API name. [Creative writing](https://arena.ai/leaderboard/text/creative-writing), [Writing/literature/language](https://arena.ai/leaderboard/text/industry-writing-and-literature-and-language), [Overall text](https://arena.ai/leaderboard/text). **Original-child provenance:** readable fetches exposed little table content; numbers initially came from Exa's source-linked index rather than an independently captured table. **Parent verification addendum, 2026-10-03:** Exa MCP full-page fetch subsequently recovered the primary creative-writing table and confirmed Argon **1519±19** (1,097 votes), Opus **1516±20** (1,058), Fable **1503±8**, and Muse Spark 1.3 max **1459±12**. This resolves creative-table recovery, not the overall or writing/literature/language table gap; these are live source checks, not benchmark reproductions. Small vote counts and overlapping intervals still preclude a clear Argon-over-Opus win.
|
|
36
|
+
|
|
37
|
+
2. **EQ-Bench supplies a different writing signal.** Its official JS data (`v=1.0.91`), fetched for this research, reports GPT-6 Astra Elo 2173.3, Claude Fable 5.1 2162.0, Claude Opus 5 2132.6, GPT-6 Sol 2124.7, and Claude Opus 5.5 2050.1. Muse Spark 1.3 is 1905.9; Gemini 3.8 Flash 1747.9. These are LLM-judged short-form outputs, not human preference or source fidelity. Some entries have a `*` prefix whose meaning was not verified; treat those provisionally. The asset has no verified evaluation date, so it is a live snapshot rather than an archived Oct 3 guarantee. Elo is relative to the comparison pool and is not comparable to Arena's scale or a percentage. [Leaderboard](https://eqbench.com/creative_writing.html), [Actual data](https://eqbench.com/creative_writing.js?v=1.0.91). Short-form success does not establish long-form editorial revision quality.
|
|
38
|
+
|
|
39
|
+
3. **Gemini is a strong large-context candidate; availability and retrieval remain constraints.** Google's Sep 30 announcement verifies **Gemini 4 Argon**, including creative writing and long-horizon knowledge work, but describes phased rollout to trusted defenders/testers before broader access. Its Oct 2 recap describes a 1M-token window. Do not invent an API identifier from the Arena name or assume immediate access. [Announcement](https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-4-argon/), [Oct 2 recap](https://blog.google/innovation-and-ai/technology/ai/google-ai-updates-september-2026/). Google's documentation explicitly warns that multi-needle retrieval may be substantially worse than single-needle retrieval: window capacity is not retrieval accuracy or source fidelity. [Long-context docs](https://ai.google.dev/gemini-api/docs/long-context).
|
|
40
|
+
|
|
41
|
+
4. **Muse Spark 1.3 is verified; strongest evidence here concerns engineering.** Meta's Sep 2 release emphasizes long-horizon agentic/coding work. The official page lists 1M context and separate standard/contributor tiers; Vercel independently confirms integration the same day. The parent-fetched primary Arena creative-writing table places its max configuration at **1459±12**, below the leading candidates; EQ-Bench is competitive but not leading. No current citation-fidelity result was verified. [Meta release](https://research.meta.ai/blog/introducing-muse-spark-1-3), [Official model page](https://developer.meta.com/ai/models/muse-spark/), [Vercel](https://vercel.com/changelog/muse-spark-1-3-now-available-on-ai-gateway), [Arena mirror](https://www.benchleader.com/benchmarks/lmarena_text_creative). Contributor changes data-use terms and available reasoning effort: **max is Standard-only**. Equivalent performance at shared efforts was not established. Do not silently use Contributor for confidential work. [Official reasoning docs](https://ai.developer.meta.com/docs/reasoning/). We interpreted the user's `must-spark-1.3` as Muse Spark 1.3; this is an interpretation, not a verified alias. Standard `muse-spark-1.3` and Contributor `muse-spark-1.3-contributor` are distinct tier identifiers. [Official model identities](https://ai.developer.meta.com/docs/models/).
|
|
42
|
+
|
|
43
|
+
5. **BrowseComp evaluates difficult web answers, not faithful report writing.** It is not a long-context retention or citation-entailment benchmark. Secondary Sep/Oct 2026 tables disagree: BenchLM reports GPT-5.6 Sol 92.2 while AnotherWrapper reports 90.4 and names Astra its leader. Coverage/configuration differences prevent declaring a current global winner. [Official benchmark](https://openai.com/index/browsecomp/), [BenchLM, updated Sep 24](https://benchlm.ai/benchmarks/browsecomp), [AnotherWrapper, Oct 2](https://anotherwrapper.com/tools/llm-pricing/leaderboards/browsecomp). Official readable fetch returned 403; raw fetch returned text. Astra's name and availability are separately established by [API docs](https://developers.openai.com/api/docs/models/gpt-6-astra) and [announcement](https://openai.com/index/gpt-6-astra/), not proof of benchmark superiority on this project's scaffold.
|
|
44
|
+
|
|
45
|
+
6. **DeepResearchBench separates report quality from citation support.** Historical primary results give Gemini-2.5-Pro Deep Research RACE overall 48.88 versus OpenAI Deep Research 46.98, but citation accuracy 81.44% versus 77.96%; Perplexity Deep Research has 90.24% citation accuracy despite lower report-quality score (42.25). Gemini's 111.21 effective citations is a count, not a percentage. These are historical agent-system results, not an Oct 2026 raw-model ranking. [Primary results/methodology](https://deepresearch-bench.github.io/). The indexed project repository's May 2026 migration notice changes evaluators from Gemini 2.5 Pro to GPT-5.5; evaluator eras are not directly comparable. The migrated current official leaderboard was not verified. [Repository notice](https://github.com/Ayanami0730/deep_research_bench?tab=readme-ov-file).
|
|
46
|
+
|
|
47
|
+
7. **Two research benchmarks have similar names.** FutureSearch's **Deep Research Bench** uses 89 tasks and frozen RetroSearch to control web drift, studying hallucination/tool-use/forgetting and separately evaluating commercial products versus model-driven agents. It differs from RACE/FACT **DeepResearch Bench** above. [FutureSearch paper, June 2025](https://arxiv.org/html/2506.06287v1). Neither directly tests this project's exact Exa retrieval workflow or guarantees faithful million-token synthesis.
|
|
48
|
+
|
|
49
|
+
8. **Gemini Deep Research is a service/agent, not a drop-in model suggestion.** Current docs name preview agents `deep-research-preview-04-2026` and `deep-research-max-preview-04-2026`, accessed through Interactions API with background execution rather than `generate_content`. Built-in Search/URL Context/Code Execution plus optional MCP/file search constitute a different scaffold from a local Exa-equipped model. [Current docs](https://ai.google.dev/gemini-api/docs/deep-research). The earlier announcement's Gemini 3 Pro core and 59.2 BrowseComp / 66.1 DeepSearchQA claims belong to that release, not automatically newer previews or Argon. [Release article](https://blog.google/innovation-and-ai/technology/developers-tools/deep-research-agent-gemini-api/).
|
|
50
|
+
|
|
51
|
+
9. **Verify names without pinning runtime choices.** Anthropic's Sep 22 release/product page establish **Claude Opus 5.5**, general availability, and API name `claude-opus-5-5`. OpenAI docs establish **GPT-6 Astra** and `gpt-6-astra`. Meta establishes **Muse Spark 1.3**, with Vercel documenting provider-qualified routing. These are naming evidence, not configuration instructions. [Anthropic release](https://www.anthropic.com/claude-opus-5-5), [Anthropic product](https://www.anthropic.com/claude/opus), [OpenAI API docs](https://developers.openai.com/api/docs/models/gpt-6-astra), [Meta docs](https://developer.meta.com/ai/models/muse-spark/). Fable names are present in benchmark data; local provider availability was not verified.
|
|
52
|
+
|
|
53
|
+
## Source fidelity and Exa: acceptance criteria
|
|
54
|
+
|
|
55
|
+
Exa supplies discovery/retrieval; the model chooses searches, reconciles sources, and writes claims. An agent-product score cannot be transferred automatically to an Exa-equipped raw model. Links alone do not prove claim support.
|
|
56
|
+
|
|
57
|
+
Evaluate suggestions with identical available retrieval tools, budgets, prompts, and sources:
|
|
58
|
+
|
|
59
|
+
- Writing: blind voice preference, stock-phrase avoidance, style-guide adherence, revision fidelity, long-form consistency.
|
|
60
|
+
- Research: factual correctness, supported-citation precision, material-claim coverage, primary-source proportion, correct dates/versions, contradictions/abstention, long-document retrieval recall.
|
|
61
|
+
- Preserve URL, publication date where available, retrieval timestamp, and quotation/span for each material claim. Check citations against fetched text, not snippets, and recheck after composition.
|
|
62
|
+
- For child agents without retrieval, use identical supplied evidence packets and evaluate synthesis separately from discovery.
|
|
63
|
+
- Test representative tasks and inspect failures, latency, and cost before changing defaults. No source found establishes a universal writing-plus-citation winner.
|
|
64
|
+
|
|
65
|
+
## Sources: kept and dropped
|
|
66
|
+
|
|
67
|
+
**Kept:** primary Arena categories (human preference, indexed-table caveat); EQ-Bench page and actual JS (writing scores); official Google/Anthropic/OpenAI/Meta releases/docs (names and capabilities); Vercel (Muse corroboration); DeepResearch Bench primary page and FutureSearch paper (methodology distinctions). Secondary mirrors were retained for corroboration/disagreement, not definitive rank claims.
|
|
68
|
+
|
|
69
|
+
**Dropped as ranking authority:** BasedAGI EQ-Bench table (placeholder `2000-01-01` dates/inconsistent score interpretation); AnotherWrapper DeepResearchBench winner claim (unverified evaluator/scaffold comparability); Sophon's summary (superseded by primary EQ-Bench data). `www.deepresearchbench.com` failed DNS and was not treated as official.
|
|
70
|
+
|
|
71
|
+
## Gaps
|
|
72
|
+
|
|
73
|
+
- No frozen Oct 3 archive; live pages may change. These are retrieved snapshots, not guaranteed historical reconstruction.
|
|
74
|
+
- Parent Exa MCP fetch subsequently recovered the primary creative-writing table (see the dated addendum above). Overall and writing/literature/language tables were not independently recovered.
|
|
75
|
+
- No current official migrated RACE/FACT ranking, exact-model citation-fidelity comparison, or equal-scaffold Exa comparison was verified.
|
|
76
|
+
- Argon general API availability, Fable provider routes, EQ-Bench asterisk semantics, and local model/tool registry remain unverified.
|
|
77
|
+
- Tasker and comprehensive coding rankings were outside the deep-writing/research evidence scope.
|
|
78
|
+
- Next: parent can supply its now-fetched Exa MCP passages through codemode; child architect uses supplied research or actually available authorized shell retrieval. Run blind writing and claim-entailment trials before promoting advisory suggestions.
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-subagent-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Hierarchical, steerable subagent threads for pi",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.19.0"
|
|
8
|
+
},
|
|
6
9
|
"keywords": [
|
|
7
10
|
"pi-package",
|
|
8
11
|
"pi",
|
|
@@ -24,6 +27,7 @@
|
|
|
24
27
|
"files": [
|
|
25
28
|
"src",
|
|
26
29
|
"agents",
|
|
30
|
+
"docs",
|
|
27
31
|
"README.md"
|
|
28
32
|
],
|
|
29
33
|
"pi": {
|
|
@@ -34,8 +38,9 @@
|
|
|
34
38
|
"scripts": {
|
|
35
39
|
"check": "tsc --noEmit",
|
|
36
40
|
"test": "tsx --test tests/*.test.ts",
|
|
37
|
-
"
|
|
38
|
-
"format
|
|
41
|
+
"prepublishOnly": "npm run check && npm test",
|
|
42
|
+
"format": "prettier --write --print-width 100 src tests agents docs/default-agents.md README.md",
|
|
43
|
+
"format:check": "prettier --check --print-width 100 src tests agents docs/default-agents.md README.md"
|
|
39
44
|
},
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"shell-quote": "^1.8.3",
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { constants, lstatSync, mkdirSync, openSync, closeSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { AGENT_COLORS, type ConfigStore } from "./config.ts";
|
|
6
|
+
import { discoverImportCandidates, type ImportCandidate } from "./import-discovery.ts";
|
|
7
|
+
import { selectImportAgents } from "./import-picker.ts";
|
|
8
|
+
import { MIGRATION_INSTRUCTIONS } from "./import-instructions.ts";
|
|
9
|
+
import { dialogText } from "./dialog.ts";
|
|
10
|
+
|
|
11
|
+
export const IMPORT_REQUEST_PREFIX =
|
|
12
|
+
"Import ONLY the agents I selected in the pi-subagent-manager migration picker.";
|
|
13
|
+
|
|
14
|
+
export const IMPORT_CHILD_TOOLS = [
|
|
15
|
+
"read",
|
|
16
|
+
"bash",
|
|
17
|
+
"powershell",
|
|
18
|
+
"edit",
|
|
19
|
+
"write",
|
|
20
|
+
"grep",
|
|
21
|
+
"find",
|
|
22
|
+
"ls",
|
|
23
|
+
"agent_types",
|
|
24
|
+
"agent_spawn",
|
|
25
|
+
"agent_wait",
|
|
26
|
+
"agent_steer",
|
|
27
|
+
"agent_status",
|
|
28
|
+
"agent_update",
|
|
29
|
+
"agent_pause",
|
|
30
|
+
"agent_stop",
|
|
31
|
+
"agent_output",
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// This records onboarding only. Limits remain in subagent-manager/settings.json.
|
|
35
|
+
const OFFER_MARKER = ".import-offered";
|
|
36
|
+
|
|
37
|
+
function statIfPresent(path: string) {
|
|
38
|
+
try {
|
|
39
|
+
const stat = lstatSync(path);
|
|
40
|
+
if (stat.isSymbolicLink()) throw new Error(`Unsafe import-state symlink: ${path}`);
|
|
41
|
+
return stat;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function stateDirectory(agentDir: string, create: boolean): string | undefined {
|
|
49
|
+
const directory = join(agentDir, "subagent-manager");
|
|
50
|
+
for (const path of [agentDir, directory]) {
|
|
51
|
+
let stat = statIfPresent(path);
|
|
52
|
+
if (!stat && create) {
|
|
53
|
+
// The host owns agentDir. Do not recursively create or follow unchecked parents.
|
|
54
|
+
mkdirSync(path);
|
|
55
|
+
stat = statIfPresent(path);
|
|
56
|
+
}
|
|
57
|
+
if (!stat) return undefined;
|
|
58
|
+
if (!stat.isDirectory()) throw new Error(`Import-state directory is not a directory: ${path}`);
|
|
59
|
+
}
|
|
60
|
+
return directory;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function importWasOffered(agentDir: string): boolean {
|
|
64
|
+
const directory = stateDirectory(agentDir, false);
|
|
65
|
+
if (!directory) return false;
|
|
66
|
+
const stat = statIfPresent(join(directory, OFFER_MARKER));
|
|
67
|
+
if (stat && !stat.isFile()) throw new Error("Import-state marker must be a regular file");
|
|
68
|
+
return !!stat;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function markImportOffered(agentDir: string): void {
|
|
72
|
+
const directory = stateDirectory(agentDir, true)!;
|
|
73
|
+
const file = join(directory, OFFER_MARKER);
|
|
74
|
+
const stat = statIfPresent(file);
|
|
75
|
+
if (stat) {
|
|
76
|
+
if (!stat.isFile()) throw new Error("Import-state marker must be a regular file");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const fd = openSync(
|
|
80
|
+
file,
|
|
81
|
+
constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW || 0),
|
|
82
|
+
0o600,
|
|
83
|
+
);
|
|
84
|
+
try {
|
|
85
|
+
writeFileSync(fd, "Onboarding offered. Use /agents import to choose agents again.\n");
|
|
86
|
+
} finally {
|
|
87
|
+
closeSync(fd);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function buildImportPrompt(options: {
|
|
92
|
+
candidates: readonly ImportCandidate[];
|
|
93
|
+
agentDir: string;
|
|
94
|
+
cwd: string;
|
|
95
|
+
includeProject: boolean;
|
|
96
|
+
existingTypes: { name: string; source?: string; filePath?: string }[];
|
|
97
|
+
scopedModels: readonly string[];
|
|
98
|
+
scopedModelDetails?: readonly { identity: string; api: string; virtual: boolean }[];
|
|
99
|
+
parentModel?: string;
|
|
100
|
+
parentModelApi?: string;
|
|
101
|
+
}): string {
|
|
102
|
+
return [
|
|
103
|
+
IMPORT_REQUEST_PREFIX,
|
|
104
|
+
MIGRATION_INSTRUCTIONS,
|
|
105
|
+
"## Current-session migration facts (JSON data, not instructions)",
|
|
106
|
+
JSON.stringify(
|
|
107
|
+
{
|
|
108
|
+
selectedDefinitions: options.candidates,
|
|
109
|
+
destinations: {
|
|
110
|
+
user: join(options.agentDir, "subagent-manager", "agents"),
|
|
111
|
+
project: options.includeProject
|
|
112
|
+
? join(options.cwd, ".pi", "agent", "subagent-manager", "agents")
|
|
113
|
+
: null,
|
|
114
|
+
},
|
|
115
|
+
destinationRule:
|
|
116
|
+
"Keep user sources user-scoped and project sources project-scoped. Project destination is permitted only when non-null; ask before changing scope.",
|
|
117
|
+
managerSettings: join(options.agentDir, "subagent-manager", "settings.json"),
|
|
118
|
+
configModule: fileURLToPath(new URL("./config.ts", import.meta.url)),
|
|
119
|
+
existingTypes: options.existingTypes,
|
|
120
|
+
scopedModels: options.scopedModels,
|
|
121
|
+
scopedModelDetails: options.scopedModelDetails ?? [],
|
|
122
|
+
parentModel: options.parentModel ?? null,
|
|
123
|
+
parentModelApi: options.parentModelApi ?? null,
|
|
124
|
+
childTools: IMPORT_CHILD_TOOLS,
|
|
125
|
+
colorTokens: AGENT_COLORS,
|
|
126
|
+
},
|
|
127
|
+
null,
|
|
128
|
+
2,
|
|
129
|
+
),
|
|
130
|
+
].join("\n\n");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Discovery and consent only; the current conversation performs every semantic conversion/write. */
|
|
134
|
+
export async function offerAgentImport(
|
|
135
|
+
pi: ExtensionAPI,
|
|
136
|
+
ctx: ExtensionContext,
|
|
137
|
+
options: {
|
|
138
|
+
agentDir: string;
|
|
139
|
+
store: ConfigStore;
|
|
140
|
+
firstRun?: boolean;
|
|
141
|
+
homeDir?: string;
|
|
142
|
+
extraAgentDirs?: string;
|
|
143
|
+
select?: typeof selectImportAgents;
|
|
144
|
+
},
|
|
145
|
+
): Promise<boolean> {
|
|
146
|
+
const firstRun = options.firstRun ?? false;
|
|
147
|
+
if (!ctx.hasUI || ctx.mode !== "tui") {
|
|
148
|
+
if (!firstRun)
|
|
149
|
+
ctx.ui.notify(
|
|
150
|
+
"Agent import requires TUI mode. Run /agents import in an interactive session.",
|
|
151
|
+
"warning",
|
|
152
|
+
);
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
if (firstRun && importWasOffered(options.agentDir)) return false;
|
|
157
|
+
const found = discoverImportCandidates({
|
|
158
|
+
cwd: ctx.cwd,
|
|
159
|
+
agentDir: options.agentDir,
|
|
160
|
+
includeProject: ctx.isProjectTrusted(),
|
|
161
|
+
homeDir: options.homeDir,
|
|
162
|
+
extraAgentDirs: options.extraAgentDirs,
|
|
163
|
+
});
|
|
164
|
+
if (found.diagnostics.length)
|
|
165
|
+
ctx.ui.notify(dialogText(found.diagnostics.join("\n")), "warning");
|
|
166
|
+
const remember = () => {
|
|
167
|
+
try {
|
|
168
|
+
markImportOffered(options.agentDir);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
ctx.ui.notify(
|
|
171
|
+
dialogText(`Could not save import onboarding state: ${String(error)}`),
|
|
172
|
+
"warning",
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
if (!found.candidates.length) {
|
|
177
|
+
// Retry an incomplete scan next startup, rather than permanently hiding unreadable definitions.
|
|
178
|
+
if (!found.diagnostics.length) remember();
|
|
179
|
+
if (!firstRun)
|
|
180
|
+
ctx.ui.notify(
|
|
181
|
+
"No external agent definitions found. Package-provided defaults are not scanned.",
|
|
182
|
+
"info",
|
|
183
|
+
);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
if (
|
|
187
|
+
firstRun &&
|
|
188
|
+
!(await ctx.ui.confirm(
|
|
189
|
+
"Import existing agents?",
|
|
190
|
+
`Found ${found.candidates.length} external agent definitions. Choose individual agents in a checkbox picker, then the current session model will migrate only your selection. Originals stay unchanged. You can also use /agents import later.`,
|
|
191
|
+
))
|
|
192
|
+
) {
|
|
193
|
+
remember();
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
const ids = await (options.select ?? selectImportAgents)(
|
|
197
|
+
ctx,
|
|
198
|
+
found.candidates.map((candidate) => ({
|
|
199
|
+
id: candidate.id,
|
|
200
|
+
label: `${candidate.name} (${candidate.scope})`,
|
|
201
|
+
detail: `${candidate.path}\n${candidate.description}`,
|
|
202
|
+
})),
|
|
203
|
+
);
|
|
204
|
+
if (!ids?.length) {
|
|
205
|
+
remember();
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const selected = new Set(ids);
|
|
209
|
+
const candidates = found.candidates.filter((candidate) => selected.has(candidate.id));
|
|
210
|
+
if (!candidates.length) return false;
|
|
211
|
+
options.store.reload();
|
|
212
|
+
const prompt = buildImportPrompt({
|
|
213
|
+
candidates,
|
|
214
|
+
agentDir: options.agentDir,
|
|
215
|
+
cwd: ctx.cwd,
|
|
216
|
+
includeProject: ctx.isProjectTrusted(),
|
|
217
|
+
existingTypes: options.store
|
|
218
|
+
.list()
|
|
219
|
+
.map(({ name, source, filePath }) => ({ name, source, filePath })),
|
|
220
|
+
scopedModels: (ctx.scopedModels ?? []).map(({ model }) => `${model.provider}/${model.id}`),
|
|
221
|
+
scopedModelDetails: (ctx.scopedModels ?? []).map(({ model }) => ({
|
|
222
|
+
identity: `${model.provider}/${model.id}`,
|
|
223
|
+
api: model.api,
|
|
224
|
+
virtual: model.api === "pi-virtual",
|
|
225
|
+
})),
|
|
226
|
+
parentModel: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined,
|
|
227
|
+
parentModelApi: ctx.model?.api,
|
|
228
|
+
});
|
|
229
|
+
// This starts (or queues) a turn in the active root session, not another SDK session.
|
|
230
|
+
pi.sendUserMessage(prompt, { deliverAs: "followUp" });
|
|
231
|
+
// sendUserMessage is fire-and-forget. The root before_agent_start hook acknowledges
|
|
232
|
+
// accepted requests; authentication/model failures must leave first-run retryable.
|
|
233
|
+
ctx.ui.notify(
|
|
234
|
+
`Asked the current session model to import ${candidates.length} selected agent(s).`,
|
|
235
|
+
"info",
|
|
236
|
+
);
|
|
237
|
+
return true;
|
|
238
|
+
} catch (error) {
|
|
239
|
+
ctx.ui.notify(
|
|
240
|
+
dialogText(`Agent import failed: ${String(error)}. Retry with /agents import.`),
|
|
241
|
+
"warning",
|
|
242
|
+
);
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -74,6 +74,7 @@ const FIELDS = new Set([
|
|
|
74
74
|
"description",
|
|
75
75
|
"models",
|
|
76
76
|
"model",
|
|
77
|
+
"modelSuggestions",
|
|
77
78
|
"thinkingLevel",
|
|
78
79
|
"color",
|
|
79
80
|
"tools",
|
|
@@ -136,6 +137,22 @@ function record(value: unknown, label: string): Record<string, unknown> {
|
|
|
136
137
|
return value as Record<string, unknown>;
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
/** Advisory display names only. Empty means no suggestions; never a model pin. */
|
|
141
|
+
function modelSuggestionNames(value: unknown): string[] {
|
|
142
|
+
if (!Array.isArray(value))
|
|
143
|
+
throw new Error("modelSuggestions must be an array of nonempty display names");
|
|
144
|
+
const suggestions = value.map((entry, index) => {
|
|
145
|
+
if (typeof entry !== "string")
|
|
146
|
+
throw new Error(`modelSuggestions[${index}] must be a nonempty display name`);
|
|
147
|
+
const name = entry.trim();
|
|
148
|
+
if (!name) throw new Error(`modelSuggestions[${index}] must be a nonempty display name`);
|
|
149
|
+
return name;
|
|
150
|
+
});
|
|
151
|
+
if (new Set(suggestions).size !== suggestions.length)
|
|
152
|
+
throw new Error("modelSuggestions contains duplicate display names");
|
|
153
|
+
return [...suggestions];
|
|
154
|
+
}
|
|
155
|
+
|
|
139
156
|
function toolNames(value: unknown, label: string): string[] {
|
|
140
157
|
if (
|
|
141
158
|
!Array.isArray(value) ||
|
|
@@ -189,6 +206,8 @@ export function parseAgentType(content: string, filePath?: string): AgentType {
|
|
|
189
206
|
model: data.model,
|
|
190
207
|
});
|
|
191
208
|
if (models !== undefined) result.models = models;
|
|
209
|
+
if (Object.hasOwn(data, "modelSuggestions"))
|
|
210
|
+
result.modelSuggestions = modelSuggestionNames(data.modelSuggestions);
|
|
192
211
|
if (Object.hasOwn(data, "thinkingLevel")) {
|
|
193
212
|
if (
|
|
194
213
|
!THINKING_LEVELS.includes(
|
|
@@ -226,6 +245,8 @@ export function serializeAgentType(type: AgentType): string {
|
|
|
226
245
|
};
|
|
227
246
|
const models = getModelPreferences(type);
|
|
228
247
|
if (models !== undefined) data.models = models;
|
|
248
|
+
if (type.modelSuggestions !== undefined)
|
|
249
|
+
data.modelSuggestions = modelSuggestionNames(type.modelSuggestions);
|
|
229
250
|
for (const key of ["thinkingLevel", "color", "tools"] as const)
|
|
230
251
|
if (type[key] !== undefined) data[key] = type[key];
|
|
231
252
|
const content = `---\n${stringify(data)}---\n${type.systemPrompt}`;
|
|
@@ -384,16 +405,9 @@ export class ConfigStore {
|
|
|
384
405
|
);
|
|
385
406
|
}
|
|
386
407
|
|
|
408
|
+
// Manager-owned storage only. Do not scan legacy Pi agent packages.
|
|
387
409
|
private scopeDirectories(scope: AgentScope): string[] {
|
|
388
|
-
return scope
|
|
389
|
-
? [
|
|
390
|
-
resolve(this.options.agentDir, AGENTS_DIR),
|
|
391
|
-
this.preferredScopeDirectory(scope),
|
|
392
|
-
]
|
|
393
|
-
: [
|
|
394
|
-
resolve(this.options.cwd, ".pi", AGENTS_DIR),
|
|
395
|
-
this.preferredScopeDirectory(scope),
|
|
396
|
-
];
|
|
410
|
+
return [this.preferredScopeDirectory(scope)];
|
|
397
411
|
}
|
|
398
412
|
|
|
399
413
|
private destinationBasePaths(scope: AgentScope, directory: string): string[] {
|