@leing2021/super-pi 0.22.0 → 0.22.1

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -361
  3. package/THIRD-PARTY-NOTICES.md +35 -0
  4. package/extensions/subagent/__tests__/async-job-tracker.test.ts +21 -0
  5. package/extensions/subagent/__tests__/execution-activity.test.ts +15 -0
  6. package/extensions/subagent/__tests__/parallel-render-stress.test.ts +82 -0
  7. package/extensions/subagent/__tests__/render-dedup.test.ts +98 -0
  8. package/extensions/subagent/__tests__/render-widget.test.ts +28 -0
  9. package/extensions/subagent/__tests__/throttle.test.ts +90 -0
  10. package/extensions/subagent/agent-management.ts +3 -2
  11. package/extensions/subagent/agent-manager-chain-detail.ts +3 -2
  12. package/extensions/subagent/agent-manager-detail.ts +3 -2
  13. package/extensions/subagent/agent-manager-edit.ts +3 -2
  14. package/extensions/subagent/agent-manager-list.ts +3 -2
  15. package/extensions/subagent/agent-manager-parallel.ts +3 -2
  16. package/extensions/subagent/agent-manager.ts +3 -2
  17. package/extensions/subagent/agent-scope.ts +3 -2
  18. package/extensions/subagent/agent-selection.ts +3 -2
  19. package/extensions/subagent/agent-serializer.ts +3 -2
  20. package/extensions/subagent/agent-templates.ts +3 -2
  21. package/extensions/subagent/agents.ts +3 -2
  22. package/extensions/subagent/artifacts.ts +3 -2
  23. package/extensions/subagent/async-execution.ts +3 -2
  24. package/extensions/subagent/async-job-tracker.ts +28 -4
  25. package/extensions/subagent/async-status.ts +3 -2
  26. package/extensions/subagent/chain-clarify.ts +3 -2
  27. package/extensions/subagent/chain-execution.ts +3 -2
  28. package/extensions/subagent/chain-serializer.ts +3 -2
  29. package/extensions/subagent/completion-dedupe.ts +3 -2
  30. package/extensions/subagent/doctor.ts +3 -2
  31. package/extensions/subagent/execution.ts +13 -3
  32. package/extensions/subagent/file-coalescer.ts +3 -2
  33. package/extensions/subagent/fork-context.ts +3 -2
  34. package/extensions/subagent/formatters.ts +3 -2
  35. package/extensions/subagent/frontmatter.ts +3 -2
  36. package/extensions/subagent/index.ts +3 -2
  37. package/extensions/subagent/intercom-bridge.ts +3 -2
  38. package/extensions/subagent/jsonl-writer.ts +3 -2
  39. package/extensions/subagent/model-fallback.ts +3 -2
  40. package/extensions/subagent/notify.ts +3 -2
  41. package/extensions/subagent/parallel-utils.ts +3 -2
  42. package/extensions/subagent/pi-args.ts +3 -2
  43. package/extensions/subagent/pi-spawn.ts +3 -2
  44. package/extensions/subagent/post-exit-stdio-guard.ts +3 -2
  45. package/extensions/subagent/prompt-template-bridge.ts +3 -2
  46. package/extensions/subagent/render-helpers.ts +3 -2
  47. package/extensions/subagent/render.ts +81 -9
  48. package/extensions/subagent/result-intercom.ts +3 -2
  49. package/extensions/subagent/result-watcher.ts +3 -2
  50. package/extensions/subagent/run-history.ts +3 -2
  51. package/extensions/subagent/run-status.ts +3 -2
  52. package/extensions/subagent/schemas.ts +3 -2
  53. package/extensions/subagent/session-tokens.ts +3 -2
  54. package/extensions/subagent/settings.ts +3 -2
  55. package/extensions/subagent/single-output.ts +3 -2
  56. package/extensions/subagent/skills.ts +3 -2
  57. package/extensions/subagent/slash-bridge.ts +3 -2
  58. package/extensions/subagent/slash-commands.ts +3 -2
  59. package/extensions/subagent/slash-live-state.ts +3 -2
  60. package/extensions/subagent/subagent-control.ts +3 -2
  61. package/extensions/subagent/subagent-executor.ts +19 -3
  62. package/extensions/subagent/subagent-prompt-runtime.ts +3 -2
  63. package/extensions/subagent/subagent-runner.ts +3 -2
  64. package/extensions/subagent/subagents-status.ts +3 -2
  65. package/extensions/subagent/text-editor.ts +3 -2
  66. package/extensions/subagent/throttle.ts +77 -0
  67. package/extensions/subagent/top-level-async.ts +3 -2
  68. package/extensions/subagent/types.ts +3 -2
  69. package/extensions/subagent/utils.ts +3 -2
  70. package/extensions/subagent/worktree.ts +3 -2
  71. package/package.json +3 -1
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Throttle utility for subagent event streams.
3
+ * Prevents render storms by coalescing high-frequency onUpdate calls.
4
+ */
5
+
6
+ /**
7
+ * Resolve the throttle interval based on parallel task count.
8
+ * Returns 0 for single task (no throttling needed).
9
+ */
10
+ export function resolveThrottleInterval(taskCount: number): number {
11
+ if (taskCount <= 1) return 0;
12
+ if (taskCount <= 4) return 200;
13
+ if (taskCount <= 8) return 500;
14
+ return 1000;
15
+ }
16
+
17
+ /**
18
+ * Create a throttled version of a function.
19
+ *
20
+ * - First call executes immediately.
21
+ * - Subsequent calls within `intervalMs` are coalesced; only the latest args are kept.
22
+ * - After `intervalMs`, if there was a pending call, it fires with the latest args.
23
+ * - `flush()` immediately executes any pending call.
24
+ * - `dispose()` cancels the timer and prevents future trailing calls.
25
+ */
26
+ export function createThrottle<T extends (...args: any[]) => void>(
27
+ fn: T,
28
+ intervalMs: number,
29
+ ): T & { flush(): void; dispose(): void } {
30
+ let pendingArgs: any[] | null = null;
31
+ let timer: ReturnType<typeof setTimeout> | null = null;
32
+
33
+ function execute(args: any[]) {
34
+ pendingArgs = null;
35
+ timer = null;
36
+ fn(...args);
37
+ }
38
+
39
+ const throttled = function (this: unknown, ...args: any[]) {
40
+ if (timer === null) {
41
+ // First call — execute immediately
42
+ execute(args);
43
+ timer = setTimeout(() => {
44
+ if (pendingArgs !== null) {
45
+ execute(pendingArgs);
46
+ } else {
47
+ timer = null;
48
+ }
49
+ }, intervalMs);
50
+ if (timer && typeof timer === "object" && "unref" in timer) {
51
+ (timer as ReturnType<typeof setTimeout> & { unref(): void }).unref();
52
+ }
53
+ } else {
54
+ // Within interval — save latest args
55
+ pendingArgs = args;
56
+ }
57
+ } as T & { flush(): void; dispose(): void };
58
+
59
+ throttled.flush = () => {
60
+ if (pendingArgs !== null) {
61
+ if (timer !== null) {
62
+ clearTimeout(timer);
63
+ }
64
+ execute(pendingArgs);
65
+ }
66
+ };
67
+
68
+ throttled.dispose = () => {
69
+ if (timer !== null) {
70
+ clearTimeout(timer);
71
+ timer = null;
72
+ }
73
+ pendingArgs = null;
74
+ };
75
+
76
+ return throttled;
77
+ }
@@ -1,5 +1,6 @@
1
- // Based on pi-subagents by Nico Bailon (https://github.com/nicobailon/pi-subagents)
2
- // MIT License
1
+ // SPDX-FileCopyrightText: 2025 Nico Bailon
2
+ // SPDX-License-Identifier: MIT
3
+ // Source: https://github.com/nicobailon/pi-subagents
3
4
  export interface AsyncOverrideParams {
4
5
  async?: boolean;
5
6
  clarify?: boolean;
@@ -1,5 +1,6 @@
1
- // Based on pi-subagents by Nico Bailon (https://github.com/nicobailon/pi-subagents)
2
- // MIT License
1
+ // SPDX-FileCopyrightText: 2025 Nico Bailon
2
+ // SPDX-License-Identifier: MIT
3
+ // Source: https://github.com/nicobailon/pi-subagents
3
4
  /**
4
5
  * Type definitions for the subagent extension
5
6
  */
@@ -1,5 +1,6 @@
1
- // Based on pi-subagents by Nico Bailon (https://github.com/nicobailon/pi-subagents)
2
- // MIT License
1
+ // SPDX-FileCopyrightText: 2025 Nico Bailon
2
+ // SPDX-License-Identifier: MIT
3
+ // Source: https://github.com/nicobailon/pi-subagents
3
4
  /**
4
5
  * General utility functions for the subagent extension
5
6
  */
@@ -1,5 +1,6 @@
1
- // Based on pi-subagents by Nico Bailon (https://github.com/nicobailon/pi-subagents)
2
- // MIT License
1
+ // SPDX-FileCopyrightText: 2025 Nico Bailon
2
+ // SPDX-License-Identifier: MIT
3
+ // Source: https://github.com/nicobailon/pi-subagents
3
4
  import { spawnSync } from "node:child_process";
4
5
  import * as fs from "node:fs";
5
6
  import * as os from "node:os";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -25,6 +25,8 @@
25
25
  "skills",
26
26
  "extensions",
27
27
  "rules",
28
+ "THIRD-PARTY-NOTICES.md",
29
+ "LICENSE",
28
30
  "README.md",
29
31
  "package.json"
30
32
  ],