@tt-a1i/openpi 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 (114) hide show
  1. package/README.md +643 -0
  2. package/SETUP.md +74 -0
  3. package/THIRD_PARTY_NOTICES.md +16 -0
  4. package/assets/openpi-package.png +0 -0
  5. package/assets/readme-hero-mobile.svg +72 -0
  6. package/assets/readme-hero.svg +118 -0
  7. package/assets/readme-runtime-mobile.svg +91 -0
  8. package/assets/readme-runtime.svg +111 -0
  9. package/extensions/ask-user/handoff.ts +205 -0
  10. package/extensions/ask-user/index.ts +1110 -0
  11. package/extensions/ask-user/limits.ts +89 -0
  12. package/extensions/ask-user/prompt.ts +76 -0
  13. package/extensions/background-terminals/index.ts +653 -0
  14. package/extensions/background-terminals/src/domain.ts +99 -0
  15. package/extensions/background-terminals/src/manager.ts +989 -0
  16. package/extensions/background-terminals/src/output.ts +84 -0
  17. package/extensions/background-terminals/src/prompt.ts +195 -0
  18. package/extensions/background-terminals/src/result-delivery.ts +43 -0
  19. package/extensions/background-terminals/src/runtime.ts +36 -0
  20. package/extensions/background-terminals/src/ui/output-view.ts +55 -0
  21. package/extensions/background-terminals/src/ui/ps.ts +642 -0
  22. package/extensions/background-terminals/src/ui/tool-result.ts +146 -0
  23. package/extensions/background-terminals/src/watch.ts +192 -0
  24. package/extensions/context-pivot/index.ts +222 -0
  25. package/extensions/copy-all/index.ts +65 -0
  26. package/extensions/cron/index.ts +173 -0
  27. package/extensions/cron/schedule.ts +127 -0
  28. package/extensions/file-mutation-display/index.ts +105 -0
  29. package/extensions/file-mutation-display/render.ts +107 -0
  30. package/extensions/file-search/index.ts +515 -0
  31. package/extensions/file-search/src/args.ts +129 -0
  32. package/extensions/file-search/src/binaries.ts +419 -0
  33. package/extensions/file-search/src/output.ts +142 -0
  34. package/extensions/file-search/src/process.ts +309 -0
  35. package/extensions/file-search/src/prompt.ts +53 -0
  36. package/extensions/git-info/index.ts +272 -0
  37. package/extensions/git-info/src/changed-files-view.ts +414 -0
  38. package/extensions/git-info/src/process.ts +107 -0
  39. package/extensions/git-info/src/refresh-coordinator.ts +13 -0
  40. package/extensions/git-info/src/runtime.ts +28 -0
  41. package/extensions/goal/controller.ts +794 -0
  42. package/extensions/goal/index.ts +521 -0
  43. package/extensions/goal/prompts.ts +122 -0
  44. package/extensions/goal/state.ts +763 -0
  45. package/extensions/goal/ui.ts +158 -0
  46. package/extensions/model-info/index.ts +234 -0
  47. package/extensions/plan-mode/bash-policy.ts +313 -0
  48. package/extensions/plan-mode/index.ts +539 -0
  49. package/extensions/post-edit/index.ts +129 -0
  50. package/extensions/sessions/LICENSE.upstream +21 -0
  51. package/extensions/sessions/git-stats.ts +226 -0
  52. package/extensions/sessions/index.ts +1092 -0
  53. package/extensions/sessions/sessions.ts +385 -0
  54. package/extensions/setup/index.ts +408 -0
  55. package/extensions/shared/activity-status.ts +65 -0
  56. package/extensions/shared/below-editor-navigation.ts +343 -0
  57. package/extensions/shared/child-session.ts +352 -0
  58. package/extensions/shared/context-utilization.ts +47 -0
  59. package/extensions/shared/dashboard-state.ts +102 -0
  60. package/extensions/shared/plan-mode-state.ts +65 -0
  61. package/extensions/shared/setup-config.ts +971 -0
  62. package/extensions/shared/subagent-roles.ts +22 -0
  63. package/extensions/shared/terminal-text.ts +38 -0
  64. package/extensions/shared/tool-call-timeout.ts +104 -0
  65. package/extensions/shared/worktree.ts +526 -0
  66. package/extensions/subagents/index.ts +1225 -0
  67. package/extensions/subagents/navigation.ts +121 -0
  68. package/extensions/subagents/src/agent-types.ts +543 -0
  69. package/extensions/subagents/src/backend.ts +63 -0
  70. package/extensions/subagents/src/backends/pi.ts +493 -0
  71. package/extensions/subagents/src/backends/stub.ts +296 -0
  72. package/extensions/subagents/src/by-the-way.ts +21 -0
  73. package/extensions/subagents/src/domain.ts +271 -0
  74. package/extensions/subagents/src/format.ts +48 -0
  75. package/extensions/subagents/src/manager.ts +769 -0
  76. package/extensions/subagents/src/prompt.ts +190 -0
  77. package/extensions/subagents/src/result-delivery.ts +20 -0
  78. package/extensions/subagents/src/runtime.ts +51 -0
  79. package/extensions/subagents/src/ui/takeover.ts +615 -0
  80. package/extensions/subagents/src/ui/transcript.ts +293 -0
  81. package/extensions/subagents/src/ui/wait-result.ts +89 -0
  82. package/extensions/suggestions/index.ts +172 -0
  83. package/extensions/suggestions/src/config.ts +12 -0
  84. package/extensions/suggestions/src/predictor.ts +147 -0
  85. package/extensions/suggestions/src/prompt.ts +20 -0
  86. package/extensions/suggestions/src/transcript.ts +233 -0
  87. package/extensions/suggestions/src/ui.ts +224 -0
  88. package/extensions/tasks/index.ts +512 -0
  89. package/extensions/tasks/tasks.ts +649 -0
  90. package/extensions/tasks/ui.ts +421 -0
  91. package/extensions/turn-time/index.ts +61 -0
  92. package/extensions/ui-customization/footer.ts +512 -0
  93. package/extensions/ui-customization/index.ts +217 -0
  94. package/extensions/workflows/acceptance.ts +298 -0
  95. package/extensions/workflows/artifacts.ts +225 -0
  96. package/extensions/workflows/controller.ts +210 -0
  97. package/extensions/workflows/dashboard.ts +1226 -0
  98. package/extensions/workflows/index.ts +1884 -0
  99. package/extensions/workflows/journal.ts +188 -0
  100. package/extensions/workflows/meta.ts +250 -0
  101. package/extensions/workflows/model.ts +423 -0
  102. package/extensions/workflows/navigation.ts +93 -0
  103. package/extensions/workflows/prompt.ts +212 -0
  104. package/extensions/workflows/replay-safety.ts +577 -0
  105. package/extensions/workflows/runner.ts +786 -0
  106. package/extensions/workflows/sandbox-child.cjs +402 -0
  107. package/extensions/workflows/sandbox.ts +397 -0
  108. package/extensions/workflows/serialization.ts +162 -0
  109. package/extensions/workflows/worktree-handoff.ts +216 -0
  110. package/package.json +87 -0
  111. package/scripts/prepare-effect-tsgo.mjs +16 -0
  112. package/skills/background-terminals/SKILL.md +30 -0
  113. package/skills/subagents/SKILL.md +15 -0
  114. package/themes/github-dark-default.json +89 -0
@@ -0,0 +1,47 @@
1
+ /** Compact, defensive context-window utilization formatting for child agents. */
2
+
3
+ export interface ContextUtilization {
4
+ /** Current conversation context occupancy; null while it is unknown after compaction. */
5
+ tokens?: number | null;
6
+ /** Capacity of the model currently serving the conversation. */
7
+ contextWindow?: number | null;
8
+ }
9
+
10
+ function usableTokens(value: number | null | undefined) {
11
+ return typeof value === "number" && Number.isFinite(value) && value >= 0
12
+ ? value
13
+ : undefined;
14
+ }
15
+
16
+ function usableCapacity(value: number | null | undefined) {
17
+ return typeof value === "number" && Number.isFinite(value) && value > 0
18
+ ? value
19
+ : undefined;
20
+ }
21
+
22
+ export function contextPercent(usage: ContextUtilization) {
23
+ const tokens = usableTokens(usage.tokens);
24
+ const capacity = usableCapacity(usage.contextWindow);
25
+ if (tokens === undefined || capacity === undefined) return undefined;
26
+ return Math.round(Math.min(100, Math.max(0, (tokens / capacity) * 100)));
27
+ }
28
+
29
+ export function formatCompactTokens(count: number) {
30
+ if (count < 1000) return Math.round(count).toString();
31
+ if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
32
+ if (count < 1000000) return `${Math.round(count / 1000)}k`;
33
+ return `${(count / 1000000).toFixed(1)}M`;
34
+ }
35
+
36
+ /**
37
+ * Render `%/capacity`. If occupancy is temporarily unknown (notably directly
38
+ * after compaction), retain the useful model capacity as `?%/capacity`. If no
39
+ * valid capacity is available, omit the statistic because no percentage can
40
+ * be computed.
41
+ */
42
+ export function formatContextUtilization(usage: ContextUtilization) {
43
+ const capacity = usableCapacity(usage.contextWindow);
44
+ if (capacity === undefined) return "";
45
+ const percent = contextPercent(usage);
46
+ return `${percent === undefined ? "?" : percent}%/${formatCompactTokens(capacity)}`;
47
+ }
@@ -0,0 +1,102 @@
1
+ export const MODEL_INFO_CHANNEL = "dashboard:model-info";
2
+ export const GIT_INFO_CHANNEL = "dashboard:git-info";
3
+ export const REFRESH_CHANNEL = "dashboard:refresh";
4
+
5
+ export interface ModelInfoState {
6
+ provider: string;
7
+ modelId: string;
8
+ modelName: string;
9
+ thinking: string;
10
+ contextTokens: number | null;
11
+ contextWindow: number;
12
+ contextPercent: number | null;
13
+ cachePercent: number | null;
14
+ cost: number;
15
+ tokensPerSecond: number | null;
16
+ generating: boolean;
17
+ }
18
+
19
+ export interface PullRequestInfo {
20
+ number: number;
21
+ url: string;
22
+ isDraft: boolean;
23
+ }
24
+
25
+ export interface GitInfoState {
26
+ isRepository: boolean;
27
+ branch: string | null;
28
+ changedFiles: number;
29
+ pullRequest: PullRequestInfo | null;
30
+ }
31
+
32
+ export function emptyModelInfoState(): ModelInfoState {
33
+ return {
34
+ provider: "",
35
+ modelId: "no-model",
36
+ modelName: "No model",
37
+ thinking: "off",
38
+ contextTokens: null,
39
+ contextWindow: 0,
40
+ contextPercent: null,
41
+ cachePercent: null,
42
+ cost: 0,
43
+ tokensPerSecond: null,
44
+ generating: false,
45
+ };
46
+ }
47
+
48
+ export function emptyGitInfoState(): GitInfoState {
49
+ return {
50
+ isRepository: false,
51
+ branch: null,
52
+ changedFiles: 0,
53
+ pullRequest: null,
54
+ };
55
+ }
56
+
57
+ function isRecord(value: unknown): value is Record<string, unknown> {
58
+ return typeof value === "object" && value !== null;
59
+ }
60
+
61
+ function isNullableNumber(value: unknown) {
62
+ return value === null || typeof value === "number";
63
+ }
64
+
65
+ export function isModelInfoState(value: unknown): value is ModelInfoState {
66
+ if (!isRecord(value)) return false;
67
+
68
+ return (
69
+ typeof value.provider === "string" &&
70
+ typeof value.modelId === "string" &&
71
+ typeof value.modelName === "string" &&
72
+ typeof value.thinking === "string" &&
73
+ isNullableNumber(value.contextTokens) &&
74
+ typeof value.contextWindow === "number" &&
75
+ isNullableNumber(value.contextPercent) &&
76
+ isNullableNumber(value.cachePercent) &&
77
+ typeof value.cost === "number" &&
78
+ isNullableNumber(value.tokensPerSecond) &&
79
+ typeof value.generating === "boolean"
80
+ );
81
+ }
82
+
83
+ function isPullRequestInfo(value: unknown): value is PullRequestInfo {
84
+ if (!isRecord(value)) return false;
85
+
86
+ return (
87
+ typeof value.number === "number" &&
88
+ typeof value.url === "string" &&
89
+ typeof value.isDraft === "boolean"
90
+ );
91
+ }
92
+
93
+ export function isGitInfoState(value: unknown): value is GitInfoState {
94
+ if (!isRecord(value)) return false;
95
+
96
+ return (
97
+ typeof value.isRepository === "boolean" &&
98
+ (value.branch === null || typeof value.branch === "string") &&
99
+ typeof value.changedFiles === "number" &&
100
+ (value.pullRequest === null || isPullRequestInfo(value.pullRequest))
101
+ );
102
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The read-only stance `/plan` puts a session in, shared between the extension
3
+ * that owns it (plan-mode) and the extensions that must honour it (subagents).
4
+ *
5
+ * Why a shared module rather than a check inside plan-mode: a `tool_call`
6
+ * handler only sees THIS session, and a subagent runs in its own. Blocking
7
+ * delegation outright was the first answer and it was wrong — exploring a
8
+ * codebase across several subsystems in parallel, without dragging the noise
9
+ * into the main context, is one of the most useful things to do while
10
+ * planning. What makes it safe is that the child tool allowlist is enforced by
11
+ * the harness, not by prompt: a child spawned with these tools has no `write`,
12
+ * `edit`, or `bash` to call, so it cannot break the promise that nothing
13
+ * changes before the user approves.
14
+ */
15
+
16
+ /**
17
+ * Tools a child may keep while the parent is planning. Investigation only:
18
+ * anything that mutates a file, runs a command, or reaches the network is
19
+ * absent, and unknown tools (including a third party's) are excluded by the
20
+ * allowlist being an allowlist.
21
+ *
22
+ * `bash` is absent even though plan mode admits read-only commands in the
23
+ * parent: that gate reads the command string, and nothing here can inspect
24
+ * what a child would run before it runs it.
25
+ */
26
+ export const PLAN_MODE_CHILD_TOOLS: readonly string[] = [
27
+ "read",
28
+ "grep",
29
+ "find",
30
+ "ls",
31
+ "fd",
32
+ "rg",
33
+ ];
34
+
35
+ /** Broadcast when the session's planning stance changes. */
36
+ export const PLAN_MODE_CHANNEL = "my-pi-setup:plan-mode";
37
+
38
+ export interface PlanModeState {
39
+ /** True while `/plan` is armed and nothing may change yet. */
40
+ readonly planning: boolean;
41
+ }
42
+
43
+ /**
44
+ * Narrow an agent type's allowlist to what planning permits.
45
+ *
46
+ * Intersects rather than replaces, so a type that already restricts itself
47
+ * further keeps its own limit: planning may only ever REMOVE capability, never
48
+ * hand a child something its type withheld.
49
+ */
50
+ export function planModeChildTools(
51
+ requested: readonly string[] | undefined,
52
+ ): readonly string[] {
53
+ if (!requested) return [...PLAN_MODE_CHILD_TOOLS];
54
+ return requested.filter((tool) => PLAN_MODE_CHILD_TOOLS.includes(tool));
55
+ }
56
+
57
+ /** Whether a selected type can run unchanged under plan mode. */
58
+ export function planModeAllowsDeclaredTools(tools?: readonly string[]) {
59
+ // Omitting `tools` inherits the normal write-capable child set, so selecting
60
+ // that type would still pair its unchanged prompt with narrowed capabilities.
61
+ return (
62
+ tools !== undefined &&
63
+ tools.every((tool) => PLAN_MODE_CHILD_TOOLS.includes(tool))
64
+ );
65
+ }