@pi-unipi/unipi 2.6.4 → 2.7.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.
Files changed (49) hide show
  1. package/package.json +16 -11
  2. package/packages/autocomplete/src/constants.ts +5 -0
  3. package/packages/subagents/README.md +89 -78
  4. package/packages/subagents/package.json +8 -2
  5. package/packages/subagents/skills/council-mode/SKILL.md +230 -0
  6. package/packages/subagents/skills/subagents/SKILL.md +49 -0
  7. package/packages/subagents/skills/subagents/references/constraints-and-recipes.md +259 -0
  8. package/packages/subagents/skills/subagents/references/execution-controls.md +454 -0
  9. package/packages/subagents/skills/subagents/references/management-authoring-rpc.md +161 -0
  10. package/packages/subagents/skills/subagents/references/multi-lane-orchestration.md +39 -0
  11. package/packages/subagents/skills/subagents/references/prompting-and-roles.md +267 -0
  12. package/packages/subagents/src/acceptance.ts +331 -0
  13. package/packages/subagents/src/agent-manager.ts +89 -6
  14. package/packages/subagents/src/agent-memory.ts +300 -0
  15. package/packages/subagents/src/agent-overrides.ts +183 -0
  16. package/packages/subagents/src/agent-runner.ts +10 -0
  17. package/packages/subagents/src/async-runner.ts +417 -0
  18. package/packages/subagents/src/authority-policy.ts +47 -0
  19. package/packages/subagents/src/budgets.ts +285 -0
  20. package/packages/subagents/src/child-safety.ts +140 -0
  21. package/packages/subagents/src/config.ts +80 -1
  22. package/packages/subagents/src/custom-agents.ts +236 -38
  23. package/packages/subagents/src/file-system-retry.ts +50 -0
  24. package/packages/subagents/src/fleet-data.ts +61 -0
  25. package/packages/subagents/src/fleet-view.ts +316 -0
  26. package/packages/subagents/src/foreground-detach.ts +59 -0
  27. package/packages/subagents/src/fork-context.ts +285 -0
  28. package/packages/subagents/src/guide.ts +129 -0
  29. package/packages/subagents/src/index.ts +515 -197
  30. package/packages/subagents/src/mission-state.ts +133 -0
  31. package/packages/subagents/src/mission-store.ts +434 -0
  32. package/packages/subagents/src/output-limits.ts +142 -0
  33. package/packages/subagents/src/parity-types.ts +315 -0
  34. package/packages/subagents/src/pi-args.ts +161 -0
  35. package/packages/subagents/src/pi-spawn.ts +147 -0
  36. package/packages/subagents/src/result-files.ts +232 -0
  37. package/packages/subagents/src/result-watcher.ts +221 -0
  38. package/packages/subagents/src/retained-children.ts +176 -0
  39. package/packages/subagents/src/run-fanout-budget.ts +356 -0
  40. package/packages/subagents/src/scheduled-runs.ts +351 -0
  41. package/packages/subagents/src/schemas.ts +263 -0
  42. package/packages/subagents/src/slash-commands.ts +77 -0
  43. package/packages/subagents/src/supervisor-channel.ts +249 -0
  44. package/packages/subagents/src/tool-handler.ts +1144 -0
  45. package/packages/subagents/src/types.ts +103 -2
  46. package/packages/subagents/src/workflow-script.ts +737 -0
  47. package/packages/subagents/src/workflow-worker.ts +384 -0
  48. package/packages/subagents/src/worktree.ts +614 -0
  49. package/packages/unipi/bundled.js +6577 -1093
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @pi-unipi/subagents — Guide topics (action: "guide")
3
+ *
4
+ * Bundled quick-reference for the spawn_helper guide action. Adapted from
5
+ * pi-subagents docs/ (condensed to agent-facing essentials, our tool names).
6
+ */
7
+
8
+ import { SUBAGENT_ACTIONS } from "./parity-types.js";
9
+
10
+ const TOPICS: Record<string, string> = {
11
+ overview: `# Subagents overview
12
+
13
+ spawn_helper delegates work to focused child agents; get_helper_result waits on
14
+ or inspects them. Builtins: explore/work (unipi) + scout/researcher/worker/
15
+ reviewer/oracle/delegate (parity). Custom agents live in
16
+ ~/.unipi/config/agents/*.md and <workspace>/.unipi/config/agents/*.md.
17
+
18
+ Execution modes:
19
+ - single child: { agent, task } (foreground or run_in_background)
20
+ - workflow: { workflowScript } — runs.run/runs.all/runs.steer in a sandbox
21
+ - management: { action } for list/get/status/children.list/resume/doctor/...
22
+
23
+ Rule of thumb: scout before you understand code, researcher before you trust
24
+ external facts, worker to implement, reviewer to check, oracle when the
25
+ decision itself feels risky.`,
26
+
27
+ workflows: `# Workflows
28
+
29
+ All orchestration is code-driven through workflowScript:
30
+
31
+ // sequential
32
+ const scan = await runs.run("scan", { agent: "scout", task: "Analyze auth" });
33
+ const fix = await runs.run("fix", { agent: "worker", task: "Implement: " + scan.output });
34
+ return fix.output;
35
+
36
+ // parallel fanout (await it; do not read .output from unawaited launches)
37
+ const reviews = await runs.all([
38
+ { key: "correctness", agent: "reviewer", task: "Review correctness" },
39
+ { key: "tests", agent: "reviewer", task: "Review tests" }
40
+ ]);
41
+ return reviews.map((r) => r.output);
42
+
43
+ Steering: await runs.steer(key, message, { mode: "auto" }) after a launch.
44
+ Plain helper functions returning runs.run(...) are fine; nested async helpers
45
+ are rejected. Recommended loop: clarify → scout → worker → fresh reviewers → worker.`,
46
+
47
+ agents: `# Agents
48
+
49
+ An agent is a markdown file: YAML frontmatter + system prompt.
50
+
51
+ Fields: name, description, tools (comma list), model, thinking, aliases,
52
+ systemPromptMode (replace|append), inheritProjectContext, inheritSkills,
53
+ defaultContext (fresh|fork), timeoutMs, toolTimeoutMs, maxSubagentDepth,
54
+ memory ({ scope: user|project, path: role-name }), enabled.
55
+
56
+ Discovery priority: project .unipi/config/agents > global ~/.unipi/config/agents
57
+ > builtin files > code builtins. agentOverrides in the subagents.json
58
+ "subagents" block can override any builtin field per agent; disableBuiltins
59
+ disables all builtins while custom agents keep working.`,
60
+
61
+ observability: `# Observability
62
+
63
+ FleetView (persistent panel): active work from both transports — in-process
64
+ agents and child-process runs. ↓/← activates; j/k navigate; enter inspects
65
+ (live transcript for local agents, result tail for process runs); esc closes.
66
+
67
+ spawn_helper({ action: "status" }) reports active work + spawn budgets.
68
+ children.list shows retained (completed) children with resumability.
69
+ Async completions arrive as <task-notification> follow-ups automatically.`,
70
+
71
+ "tool-reference": `# spawn_helper reference
72
+
73
+ Execution: { agent, task, async?, context?, timeoutMs?, maxTurns?, turnBudget?,
74
+ toolBudget?, usageBudget?, model?, thinking?, worktree? }
75
+ Legacy aliases: type (= agent), prompt (= task), run_in_background (= async),
76
+ max_turns (= maxTurns).
77
+
78
+ workflowScript: { workflowScript, async?, timeoutMs?, maxOutput? }
79
+
80
+ Management actions: ${SUBAGENT_ACTIONS.slice(0, 12).join(", ")}, ...
81
+
82
+ get_helper_result: { id, wait?, nonBlocking?, all?, timeoutMs?, stopOnAttention? }
83
+ - blocking wait returns when a run needs attention (default) or completes
84
+ - nonBlocking: persist a subscription and return immediately; the session is
85
+ woken on completion/failure/attention`,
86
+
87
+ configuration: `# Configuration
88
+
89
+ ~/.unipi/config/subagents.json (global) + <workspace>/.unipi/config/subagents.json
90
+ (workspace overrides global). The "subagents" block carries parity settings:
91
+
92
+ { "subagents": { "defaultModel", "defaultThinking", "agentOverrides",
93
+ "disableBuiltins", "asyncByDefault", "defaultSubagentContext", "timeoutMs",
94
+ "toolTimeoutMs", "maxSubagentSpawnsPerRun" (64), "maxSubagentSpawnsPerSession",
95
+ "maxActiveAsyncRunsPerSession", "maxSubagentDepth" (2), "parallel",
96
+ "fleetView", "fleetViewPlacement", "inlineToolDisplay", "resultScanLogging" } }
97
+
98
+ Env overrides: UNIPI_SUBAGENT_PI_BINARY, UNIPI_SUBAGENT_TASK_DELIVERY,
99
+ UNIPI_SUBAGENT_TOOL_TIMEOUT_MS, UNIPI_SUBAGENTS_WORKTREE_DIR, UNIPI_SUBAGENT_MAX_DEPTH.`,
100
+
101
+ missions: `# Missions (planned phase)
102
+
103
+ Durable mission records with delivery receipts, timed and recurring runs.
104
+ Not yet wired in this build — see the roadmap in the package README.`,
105
+
106
+ models: `# Models
107
+
108
+ Children inherit the parent model by default. Override per call ({ model }),
109
+ per agent (frontmatter model), or globally (subagents.defaultModel).
110
+ Thinking: per call ({ thinking }), per agent, or subagents.defaultThinking.
111
+ Fallback models: agent frontmatter fallbackModels (ordered).`,
112
+
113
+ watchdog: `# Watchdog (planned phase)
114
+
115
+ Opt-in adversarial change reviewer, scope monitoring, LSP diagnostics, child
116
+ tool permissions. Not yet wired in this build.`,
117
+
118
+ "extension-api": `# Extension API (planned phase)
119
+
120
+ Runtime agent registration (AgentManager.registerRuntimeAgent) exists; the
121
+ full RPC bridge for external hosts lands in a later phase.`,
122
+ };
123
+
124
+ export function buildGuideText(topic: string): string {
125
+ const normalized = topic.toLowerCase().trim();
126
+ const doc = TOPICS[normalized];
127
+ if (doc) return doc;
128
+ return `Unknown guide topic "${topic}". Available topics: ${Object.keys(TOPICS).join(", ")}.`;
129
+ }