shariq-pi-extensions 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -0
  3. package/THIRD_PARTY_NOTICES.md +11 -0
  4. package/docs/ARCHITECTURE.md +54 -0
  5. package/docs/DEVELOPMENT.md +88 -0
  6. package/docs/EXTENSIONS.md +89 -0
  7. package/extensions/antigravity-provider/LICENSE +21 -0
  8. package/extensions/antigravity-provider/README.md +23 -0
  9. package/extensions/antigravity-provider/antigravity/cloud-code-assist.ts +519 -0
  10. package/extensions/antigravity-provider/antigravity/index.ts +67 -0
  11. package/extensions/antigravity-provider/antigravity/models.ts +184 -0
  12. package/extensions/antigravity-provider/antigravity/oauth.ts +499 -0
  13. package/extensions/antigravity-provider/index.ts +3 -0
  14. package/extensions/ask-user/README.md +21 -0
  15. package/extensions/ask-user/index.ts +417 -0
  16. package/extensions/background-terminals/README.md +43 -0
  17. package/extensions/background-terminals/index.ts +400 -0
  18. package/extensions/background-terminals/src/manager.ts +480 -0
  19. package/extensions/background-terminals/src/output-buffer.ts +110 -0
  20. package/extensions/background-terminals/src/presentation.ts +74 -0
  21. package/extensions/background-terminals/src/types.ts +47 -0
  22. package/extensions/background-terminals/src/ui.ts +478 -0
  23. package/extensions/context-usage/LICENSE +21 -0
  24. package/extensions/context-usage/README.md +20 -0
  25. package/extensions/context-usage/index.ts +2006 -0
  26. package/extensions/context-usage/lib/ansi.ts +60 -0
  27. package/extensions/context-usage/lib/boundary.ts +27 -0
  28. package/extensions/context-usage/lib/chat.ts +190 -0
  29. package/extensions/context-usage/lib/config.ts +30 -0
  30. package/extensions/context-usage/lib/fmt.ts +59 -0
  31. package/extensions/context-usage/lib/style.ts +260 -0
  32. package/extensions/copy-all/README.md +15 -0
  33. package/extensions/copy-all/index.ts +72 -0
  34. package/extensions/factory-provider/API_KEYS.md +17 -0
  35. package/extensions/factory-provider/AUTH.md +15 -0
  36. package/extensions/factory-provider/README.md +90 -0
  37. package/extensions/factory-provider/REFRESH_MODELS.md +185 -0
  38. package/extensions/factory-provider/UPDATING.md +97 -0
  39. package/extensions/factory-provider/factory/api-keys.ts +407 -0
  40. package/extensions/factory-provider/factory/auth.ts +132 -0
  41. package/extensions/factory-provider/factory/constants.ts +15 -0
  42. package/extensions/factory-provider/factory/dashboard.ts +363 -0
  43. package/extensions/factory-provider/factory/droid.ts +84 -0
  44. package/extensions/factory-provider/factory/limits.ts +342 -0
  45. package/extensions/factory-provider/factory/models.ts +283 -0
  46. package/extensions/factory-provider/factory/responses.ts +331 -0
  47. package/extensions/factory-provider/factory/warm-theme.ts +53 -0
  48. package/extensions/factory-provider/factory/websocket.ts +130 -0
  49. package/extensions/factory-provider/index.ts +204 -0
  50. package/extensions/factory-provider/scripts/audit-reasoning-efforts.py +84 -0
  51. package/extensions/firecrawl-web/README.md +31 -0
  52. package/extensions/firecrawl-web/auth.ts +92 -0
  53. package/extensions/firecrawl-web/client.ts +238 -0
  54. package/extensions/firecrawl-web/index.ts +96 -0
  55. package/extensions/firecrawl-web/output.ts +125 -0
  56. package/extensions/git-info/README.md +25 -0
  57. package/extensions/git-info/index.ts +162 -0
  58. package/extensions/git-info/src/git.ts +206 -0
  59. package/extensions/git-info/src/ui.ts +291 -0
  60. package/extensions/goal/README.md +44 -0
  61. package/extensions/goal/constants.ts +4 -0
  62. package/extensions/goal/extension.ts +1064 -0
  63. package/extensions/goal/index.ts +2 -0
  64. package/extensions/goal/types.ts +56 -0
  65. package/extensions/goal/ui.ts +334 -0
  66. package/extensions/orchestration/README.md +58 -0
  67. package/extensions/orchestration/dashboard.ts +192 -0
  68. package/extensions/orchestration/engine.ts +706 -0
  69. package/extensions/orchestration/index.ts +243 -0
  70. package/extensions/orchestration/prompts.ts +124 -0
  71. package/extensions/orchestration/protocol.ts +116 -0
  72. package/extensions/orchestration/settings-ui.ts +41 -0
  73. package/extensions/orchestration/settings.ts +59 -0
  74. package/extensions/orchestration/storage.ts +49 -0
  75. package/extensions/orchestration/types.ts +105 -0
  76. package/extensions/performance-status/README.md +5 -0
  77. package/extensions/performance-status/index.ts +171 -0
  78. package/extensions/pi-memory/README.md +53 -0
  79. package/extensions/pi-memory/index.ts +326 -0
  80. package/extensions/pi-memory/src/config.ts +75 -0
  81. package/extensions/pi-memory/src/database.ts +617 -0
  82. package/extensions/pi-memory/src/extraction.ts +178 -0
  83. package/extensions/pi-memory/src/project.ts +80 -0
  84. package/extensions/pi-memory/src/projection.ts +59 -0
  85. package/extensions/pi-memory/src/redaction.ts +60 -0
  86. package/extensions/pi-memory/src/retrieval.ts +30 -0
  87. package/extensions/pi-memory/src/service.ts +194 -0
  88. package/extensions/pi-memory/src/session.ts +146 -0
  89. package/extensions/pi-memory/src/types.ts +82 -0
  90. package/extensions/shared/README.md +18 -0
  91. package/extensions/shared/activity-status.ts +31 -0
  92. package/extensions/shared/child-session.ts +150 -0
  93. package/extensions/shared/context-utilization.ts +47 -0
  94. package/extensions/shared/dashboard-state.ts +99 -0
  95. package/extensions/shared/tool-call-timeout.ts +104 -0
  96. package/extensions/shared/tui-dashboard.ts +139 -0
  97. package/extensions/shell-shortcuts/README.md +17 -0
  98. package/extensions/shell-shortcuts/features/exit-alias.ts +10 -0
  99. package/extensions/shell-shortcuts/index.ts +6 -0
  100. package/extensions/subagents/README.md +89 -0
  101. package/extensions/subagents/index.ts +1386 -0
  102. package/extensions/subagents/src/backend.ts +69 -0
  103. package/extensions/subagents/src/backends/pi.ts +781 -0
  104. package/extensions/subagents/src/catalog.ts +85 -0
  105. package/extensions/subagents/src/config.ts +241 -0
  106. package/extensions/subagents/src/context.ts +57 -0
  107. package/extensions/subagents/src/coordinator.ts +64 -0
  108. package/extensions/subagents/src/domain.ts +294 -0
  109. package/extensions/subagents/src/format.ts +74 -0
  110. package/extensions/subagents/src/manager.ts +813 -0
  111. package/extensions/subagents/src/prompt.ts +94 -0
  112. package/extensions/subagents/src/result-delivery.ts +20 -0
  113. package/extensions/subagents/src/runtime.ts +48 -0
  114. package/extensions/subagents/src/ui/takeover.ts +695 -0
  115. package/extensions/subagents/src/ui/transcript.ts +182 -0
  116. package/extensions/subagents/src/worktree.ts +175 -0
  117. package/extensions/web-fetch/README.md +13 -0
  118. package/extensions/web-fetch/index.ts +441 -0
  119. package/package.json +117 -0
  120. package/skills/background-terminals/SKILL.md +42 -0
  121. package/skills/orchestration/SKILL.md +33 -0
  122. package/skills/subagents/SKILL.md +89 -0
  123. package/themes/ember-warm-dark.json +85 -0
@@ -0,0 +1,94 @@
1
+ /** All model-facing strings for the canonical Pi subagent tools. */
2
+
3
+ export const SUBAGENT_SPAWN_TOOL_DESCRIPTION =
4
+ "Start a flat, background Pi subagent with an optional profile, capability policy, or parent-context fork. Children may message existing peers but cannot spawn agents. The shared workspace is the default; use an isolated git worktree only when requested or needed to prevent concurrent edits from interfering. Completed children can be resumed with their transcript and tool state.";
5
+
6
+ export const SUBAGENT_SPAWN_PROMPT_SNIPPET =
7
+ "Start an independent background worker with optional context or a configured profile";
8
+
9
+ export const WORKTREE_ISOLATION_DESCRIPTION =
10
+ "Workspace isolation. Default none. Use worktree only with a clean source checkout when the user requests it, a configured profile requires it, or concurrent write tasks are likely to overlap or interfere. Read-only work and clearly separate edits should share the workspace.";
11
+
12
+ export const SUBAGENT_SPAWN_PROMPT_GUIDELINES = [
13
+ "Use spawn_agent for work that can proceed independently. Children may coordinate with existing peers but cannot spawn agents.",
14
+ "Give spawn_agent a complete task when fork_turns is none. Use fork_turns only when prior conversation is materially required.",
15
+ "Use list_agent_profiles when a task needs a configured profile or persona whose name or defaults are unknown.",
16
+ "Use agent_type explore or capability read-only for investigation that must not modify files.",
17
+ "Keep isolation none by default. Use worktree only with a clean source checkout when the user requests it, a configured profile requires it, or concurrent write tasks are likely to overlap or interfere. Do not isolate read-only work or clearly separate edits.",
18
+ "After isolated work finishes, inspect it and use apply_agent_changes only when its changes should enter the source repository.",
19
+ "Use resume_from to continue a completed child's existing context instead of restating its original task.",
20
+ "After spawn_agent or task starts background work, continue useful parent work; otherwise end the turn so Pi remains available to the user.",
21
+ "Do not poll background agents. Completion notices arrive automatically and wake the parent; wait_agent only collects results already available and reports running agents without blocking.",
22
+ ];
23
+
24
+ export const SUBAGENT_SPAWN_PARAMETER_DESCRIPTIONS = {
25
+ prompt: "Standalone task with context, paths, constraints, and expected report.",
26
+ name: "Short name for listings/dashboard",
27
+ workingDir: "Working directory; default current directory",
28
+ model: 'Model hint ("provider/model-id" or id); default parent model.',
29
+ reasoningEffort: "Thinking level; default parent level.",
30
+ readonly: "Compatibility alias for read-only capability",
31
+ isolation: WORKTREE_ISOLATION_DESCRIPTION,
32
+ };
33
+
34
+ export function buildSubagentSpawnResult(options: {
35
+ id: string;
36
+ title: string;
37
+ modelLabel: string;
38
+ cwd: string;
39
+ agentType?: string;
40
+ capability?: string;
41
+ isolation?: string;
42
+ resumed?: boolean;
43
+ }) {
44
+ const attributes = [
45
+ options.modelLabel,
46
+ options.agentType,
47
+ options.capability,
48
+ options.isolation === "worktree" ? "isolated worktree" : undefined,
49
+ options.resumed ? "resumed" : undefined,
50
+ options.cwd,
51
+ ].filter(Boolean);
52
+ return (
53
+ `Started Pi subagent ${options.id} "${options.title}" (${attributes.join(", ")}).\n` +
54
+ "It will report and wake the parent when finished. Continue useful work or end the turn instead of polling."
55
+ );
56
+ }
57
+
58
+ export const SUBAGENT_WAIT_TOOL_DESCRIPTION =
59
+ "Collect outputs already available for selected subagents without blocking. Running agents are reported as pending and will send completion notices automatically; omit ids to check all running subagents.";
60
+
61
+ export const SUBAGENT_WAIT_PARAMETER_DESCRIPTIONS = {
62
+ ids: 'Optional Pi subagent ids, e.g. ["sa-1", "sa-2"]',
63
+ };
64
+
65
+ export const SUBAGENT_CANCEL_TOOL_DESCRIPTION =
66
+ "Close subagents, interrupting active work while preserving partial transcripts.";
67
+
68
+ export const SUBAGENT_CANCEL_PARAMETER_DESCRIPTIONS = {
69
+ ids: 'Pi subagent ids to close, e.g. ["sa-1", "sa-2"]',
70
+ };
71
+
72
+ export const SUBAGENT_CHECK_TOOL_DESCRIPTION =
73
+ "Inspect one subagent's status/latest activity without waiting or consuming its result.";
74
+
75
+ export const SUBAGENT_CHECK_PARAMETER_DESCRIPTIONS = {
76
+ id: "Pi subagent id",
77
+ };
78
+
79
+ export const SUBAGENT_LIST_TOOL_DESCRIPTION =
80
+ "List tracked subagents with status, model, context use, elapsed time, and cwd.";
81
+
82
+ export function buildSubagentResultMessage(options: {
83
+ id: string;
84
+ title: string;
85
+ status: "running" | "done" | "error";
86
+ errorText?: string;
87
+ output: string;
88
+ }) {
89
+ const verb = options.status === "error" ? "failed" : "finished";
90
+ let text = `Pi subagent ${options.id} "${options.title}" ${verb}.`;
91
+ if (options.errorText) text += `\nError: ${options.errorText}`;
92
+ text += `\n\n${options.output}`;
93
+ return text;
94
+ }
@@ -0,0 +1,20 @@
1
+ export function createDeferredResultDelivery<T extends { id: string }>() {
2
+ const pending = new Map<string, T>();
3
+
4
+ return {
5
+ defer(result: T) {
6
+ pending.set(result.id, result);
7
+ },
8
+ consume(ids: Iterable<string>) {
9
+ for (const id of ids) pending.delete(id);
10
+ },
11
+ drain() {
12
+ const results = [...pending.values()];
13
+ pending.clear();
14
+ return results;
15
+ },
16
+ clear() {
17
+ pending.clear();
18
+ },
19
+ };
20
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Layer composition and the async entry-point boundary.
3
+ *
4
+ * Everything inside the extension is Effect generators; this module is where
5
+ * tool handlers (plain async functions) run those effects against one shared
6
+ * ManagedRuntime.
7
+ */
8
+
9
+ import { Cause, Exit, Layer, ManagedRuntime, type Effect } from "effect";
10
+ import { BackendRegistry, type SubagentBackend } from "./backend.ts";
11
+ import { piBackend } from "./backends/pi.ts";
12
+ import type { BackendName } from "./domain.ts";
13
+
14
+ const BackendRegistryLive = Layer.sync(BackendRegistry, () =>
15
+ new Map<BackendName, SubagentBackend>([["pi", piBackend]]),
16
+ );
17
+
18
+ import { SubagentManagerLive } from "./manager.ts";
19
+
20
+ const AppLayer = SubagentManagerLive.pipe(Layer.provide(BackendRegistryLive));
21
+
22
+ export function createSubagentRuntime() {
23
+ return ManagedRuntime.make(AppLayer);
24
+ }
25
+
26
+ export type SubagentRuntime = ReturnType<typeof createSubagentRuntime>;
27
+
28
+ /**
29
+ * Run an effect from an async tool handler. Typed failures and defects are
30
+ * converted to thrown Errors (what pi's tool contract expects); interruption
31
+ * (tool AbortSignal) throws `interruptMessage`.
32
+ */
33
+ export async function runTool<A, E>(
34
+ runtime: SubagentRuntime,
35
+ effect: Effect.Effect<A, E>,
36
+ options: { signal?: AbortSignal; interruptMessage?: string } = {},
37
+ ) {
38
+ const exit = await runtime.runPromiseExit(
39
+ effect,
40
+ options.signal ? { signal: options.signal } : undefined,
41
+ );
42
+ if (Exit.isSuccess(exit)) return exit.value;
43
+ if (Cause.hasInterruptsOnly(exit.cause)) {
44
+ throw new Error(options.interruptMessage ?? "Operation was aborted.");
45
+ }
46
+ const [first] = Cause.prettyErrors(exit.cause);
47
+ throw new Error(first?.message ?? Cause.pretty(exit.cause));
48
+ }