@linxiraos/pi-messenger 1.1.1 → 1.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +741 -676
  2. package/LICENSE +45 -0
  3. package/README.md +424 -424
  4. package/THIRD-PARTY-NOTICES.txt +22951 -0
  5. package/config-overlay.ts +175 -171
  6. package/config.ts +221 -209
  7. package/crew/agents/crew-plan-sync.md +66 -64
  8. package/crew/agents/crew-planner.md +173 -172
  9. package/crew/agents/crew-reviewer.md +58 -58
  10. package/crew/agents/crew-worker.md +130 -129
  11. package/crew/agents.ts +507 -434
  12. package/crew/handlers/coordination.ts +350 -332
  13. package/crew/handlers/plan.ts +988 -906
  14. package/crew/handlers/review.ts +354 -333
  15. package/crew/handlers/revise.ts +400 -376
  16. package/crew/handlers/status.ts +303 -295
  17. package/crew/handlers/sync.ts +237 -233
  18. package/crew/handlers/task.ts +820 -792
  19. package/crew/handlers/team.ts +294 -235
  20. package/crew/handlers/work.ts +467 -425
  21. package/crew/id-allocator.ts +30 -30
  22. package/crew/index.ts +297 -257
  23. package/crew/live-progress.ts +58 -58
  24. package/crew/lobby.ts +504 -473
  25. package/crew/prompt.ts +262 -252
  26. package/crew/registry.ts +114 -114
  27. package/crew/spawn.ts +135 -111
  28. package/crew/state-autonomous.ts +163 -164
  29. package/crew/state-planning.ts +264 -263
  30. package/crew/state.ts +20 -20
  31. package/crew/store.ts +646 -642
  32. package/crew/task-actions.ts +162 -131
  33. package/crew/team/store.ts +572 -479
  34. package/crew/team/subagent-roles.ts +105 -87
  35. package/crew/team/types.ts +50 -50
  36. package/crew/types.ts +194 -194
  37. package/crew/utils/artifacts.ts +57 -62
  38. package/crew/utils/config.ts +158 -156
  39. package/crew/utils/discover.ts +221 -219
  40. package/crew/utils/install.ts +94 -85
  41. package/crew/utils/migrations.ts +126 -0
  42. package/crew/utils/progress.ts +191 -187
  43. package/crew/utils/result.ts +16 -16
  44. package/crew/utils/risk-labels.ts +5 -7
  45. package/crew/utils/task-format.ts +14 -14
  46. package/crew/utils/team-roles.ts +44 -28
  47. package/crew/utils/truncate.ts +76 -79
  48. package/crew/utils/verdict.ts +55 -55
  49. package/editor-binary.ts +150 -0
  50. package/editor-command.ts +107 -0
  51. package/editor-target.ts +40 -0
  52. package/feed.ts +321 -268
  53. package/handlers.ts +1041 -1107
  54. package/index.ts +1314 -1206
  55. package/install.mjs +187 -189
  56. package/lib.ts +587 -467
  57. package/overlay-actions.ts +519 -511
  58. package/overlay-coordinator.ts +150 -150
  59. package/overlay-render.ts +770 -676
  60. package/overlay.ts +872 -830
  61. package/package.json +64 -60
  62. package/paths.ts +60 -0
  63. package/skills/pi-messenger-crew/SKILL.md +375 -347
  64. package/store.ts +1147 -1139
  65. package/teamagent-command.ts +321 -0
  66. package/vitest.config.ts +10 -10
package/config-overlay.ts CHANGED
@@ -1,171 +1,175 @@
1
- /**
2
- * Pi Messenger - Config Overlay Component
3
- */
4
-
5
- import type { Component, Focusable, TUI } from "@earendil-works/pi-tui";
6
- import { matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
7
- import type { Theme } from "@earendil-works/pi-coding-agent";
8
- import { getAutoRegisterPaths, saveAutoRegisterPaths, matchesAutoRegisterPath } from "./config.ts";
9
-
10
- export class MessengerConfigOverlay implements Component, Focusable {
11
- readonly width = 60;
12
- focused = false;
13
-
14
- private paths: string[];
15
- private selectedIndex = 0;
16
- private dirty = false;
17
- private statusMessage = "";
18
-
19
- constructor(
20
- private tui: TUI,
21
- private theme: Theme,
22
- private done: () => void,
23
- private cwd: string,
24
- ) {
25
- this.paths = getAutoRegisterPaths();
26
- }
27
-
28
- handleInput(data: string): void {
29
- if (matchesKey(data, "escape") || matchesKey(data, "q")) {
30
- if (this.dirty) {
31
- saveAutoRegisterPaths(this.paths);
32
- }
33
- this.done();
34
- return;
35
- }
36
-
37
- if (matchesKey(data, "a")) {
38
- this.addCurrentPath();
39
- this.tui.requestRender();
40
- return;
41
- }
42
-
43
- if (matchesKey(data, "d") || matchesKey(data, "backspace")) {
44
- this.deleteSelected();
45
- this.tui.requestRender();
46
- return;
47
- }
48
-
49
- if (matchesKey(data, "up")) {
50
- if (this.paths.length > 0) {
51
- this.selectedIndex = Math.max(0, this.selectedIndex - 1);
52
- this.tui.requestRender();
53
- }
54
- return;
55
- }
56
-
57
- if (matchesKey(data, "down")) {
58
- if (this.paths.length > 0) {
59
- this.selectedIndex = Math.min(this.paths.length - 1, this.selectedIndex + 1);
60
- this.tui.requestRender();
61
- }
62
- return;
63
- }
64
- }
65
-
66
- private addCurrentPath(): void {
67
- if (this.paths.includes(this.cwd)) {
68
- this.statusMessage = "Already in list";
69
- return;
70
- }
71
- this.paths.push(this.cwd);
72
- this.selectedIndex = this.paths.length - 1;
73
- this.dirty = true;
74
- this.statusMessage = "Added current folder";
75
- }
76
-
77
- private deleteSelected(): void {
78
- if (this.paths.length === 0) return;
79
-
80
- const removed = this.paths[this.selectedIndex];
81
- this.paths.splice(this.selectedIndex, 1);
82
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.paths.length - 1));
83
- this.dirty = true;
84
- this.statusMessage = `Removed: ${removed.split("/").pop()}`;
85
- }
86
-
87
- render(_width: number): string[] {
88
- const w = this.width;
89
- const innerW = w - 2;
90
- const lines: string[] = [];
91
- const isCurrentInList = matchesAutoRegisterPath(this.cwd, this.paths);
92
-
93
- const border = (s: string) => this.theme.fg("dim", s);
94
- const pad = (s: string, len: number) => s + " ".repeat(Math.max(0, len - visibleWidth(s)));
95
- const row = (content: string) => border("│") + pad(" " + content, innerW) + border("│");
96
- const emptyRow = () => border("│") + " ".repeat(innerW) + border("│");
97
-
98
- // Top border with title
99
- const titleText = " Messenger Config ";
100
- const borderLen = innerW - titleText.length;
101
- const leftBorder = Math.floor(borderLen / 2);
102
- const rightBorder = borderLen - leftBorder;
103
- lines.push(border("╭" + "─".repeat(leftBorder)) + this.theme.fg("accent", titleText) + border("─".repeat(rightBorder) + "╮"));
104
-
105
- lines.push(emptyRow());
106
-
107
- // Current folder status
108
- const cwdDisplay = truncateToWidth(this.cwd, Math.max(10, innerW - 20));
109
- lines.push(row(`Current folder: ${cwdDisplay}`));
110
- const statusColor = isCurrentInList ? "accent" : "dim";
111
- lines.push(row(`Auto-register: ${this.theme.fg(statusColor, isCurrentInList ? "YES" : "NO")}`));
112
-
113
- lines.push(emptyRow());
114
-
115
- // Divider
116
- lines.push(border("├" + "─".repeat(innerW) + "┤"));
117
-
118
- lines.push(emptyRow());
119
- lines.push(row(this.theme.fg("dim", "Auto-register paths:")));
120
- lines.push(emptyRow());
121
-
122
- if (this.paths.length === 0) {
123
- lines.push(row(this.theme.fg("dim", " (none configured)")));
124
- } else {
125
- for (let i = 0; i < this.paths.length; i++) {
126
- const path = this.paths[i];
127
- const isSelected = i === this.selectedIndex;
128
- const isCurrent = path === this.cwd;
129
-
130
- const marker = isSelected ? this.theme.fg("accent", "▸") : " ";
131
- const suffix = isCurrent ? this.theme.fg("dim", " (current)") : "";
132
- const pathDisplay = truncateToWidth(path, Math.max(10, innerW - 15));
133
-
134
- if (isSelected) {
135
- lines.push(row(`${marker} ${this.theme.fg("accent", pathDisplay)}${suffix}`));
136
- } else {
137
- lines.push(row(`${marker} ${pathDisplay}${suffix}`));
138
- }
139
- }
140
- }
141
-
142
- lines.push(emptyRow());
143
-
144
- // Divider
145
- lines.push(border("├" + "─".repeat(innerW) + "┤"));
146
-
147
- lines.push(emptyRow());
148
-
149
- // Status message
150
- if (this.statusMessage) {
151
- lines.push(row(this.theme.fg("accent", this.statusMessage)));
152
- } else {
153
- lines.push(emptyRow());
154
- }
155
-
156
- // Help
157
- const help = "a add d delete ↑↓ navigate Esc save & close";
158
- lines.push(row(this.theme.fg("dim", help)));
159
-
160
- // Bottom border
161
- lines.push(border("╰" + "─".repeat(innerW) + "╯"));
162
-
163
- return lines;
164
- }
165
-
166
- invalidate(): void {
167
- this.statusMessage = "";
168
- }
169
-
170
- dispose(): void {}
171
- }
1
+ /**
2
+ * Pi Messenger - Config Overlay Component
3
+ */
4
+
5
+ import type { Component, Focusable, TUI } from "@linxiraos/pi-tui";
6
+ import { matchesKey, truncateToWidth, visibleWidth } from "@linxiraos/pi-tui";
7
+ import type { Theme } from "@linxiraos/zeta";
8
+ import { getAutoRegisterPaths, saveAutoRegisterPaths, matchesAutoRegisterPath } from "./config.ts";
9
+
10
+ export class MessengerConfigOverlay implements Component, Focusable {
11
+ readonly width = 60;
12
+ focused = false;
13
+
14
+ private paths: string[];
15
+ private selectedIndex = 0;
16
+ private dirty = false;
17
+ private statusMessage = "";
18
+
19
+ constructor(
20
+ private tui: TUI,
21
+ private theme: Theme,
22
+ private done: () => void,
23
+ private cwd: string,
24
+ ) {
25
+ this.paths = getAutoRegisterPaths();
26
+ }
27
+
28
+ handleInput(data: string): void {
29
+ if (matchesKey(data, "escape") || matchesKey(data, "q")) {
30
+ if (this.dirty) {
31
+ saveAutoRegisterPaths(this.paths);
32
+ }
33
+ this.done();
34
+ return;
35
+ }
36
+
37
+ if (matchesKey(data, "a")) {
38
+ this.addCurrentPath();
39
+ this.tui.requestRender();
40
+ return;
41
+ }
42
+
43
+ if (matchesKey(data, "d") || matchesKey(data, "backspace")) {
44
+ this.deleteSelected();
45
+ this.tui.requestRender();
46
+ return;
47
+ }
48
+
49
+ if (matchesKey(data, "up")) {
50
+ if (this.paths.length > 0) {
51
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
52
+ this.tui.requestRender();
53
+ }
54
+ return;
55
+ }
56
+
57
+ if (matchesKey(data, "down")) {
58
+ if (this.paths.length > 0) {
59
+ this.selectedIndex = Math.min(this.paths.length - 1, this.selectedIndex + 1);
60
+ this.tui.requestRender();
61
+ }
62
+ return;
63
+ }
64
+ }
65
+
66
+ private addCurrentPath(): void {
67
+ if (this.paths.includes(this.cwd)) {
68
+ this.statusMessage = "Already in list";
69
+ return;
70
+ }
71
+ this.paths.push(this.cwd);
72
+ this.selectedIndex = this.paths.length - 1;
73
+ this.dirty = true;
74
+ this.statusMessage = "Added current folder";
75
+ }
76
+
77
+ private deleteSelected(): void {
78
+ if (this.paths.length === 0) return;
79
+
80
+ const removed = this.paths[this.selectedIndex];
81
+ this.paths.splice(this.selectedIndex, 1);
82
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.paths.length - 1));
83
+ this.dirty = true;
84
+ this.statusMessage = `Removed: ${removed.split("/").pop()}`;
85
+ }
86
+
87
+ render(_width: number): string[] {
88
+ const w = this.width;
89
+ const innerW = w - 2;
90
+ const lines: string[] = [];
91
+ const isCurrentInList = matchesAutoRegisterPath(this.cwd, this.paths);
92
+
93
+ const border = (s: string) => this.theme.fg("dim", s);
94
+ const pad = (s: string, len: number) => s + " ".repeat(Math.max(0, len - visibleWidth(s)));
95
+ const row = (content: string) => border("│") + pad(" " + content, innerW) + border("│");
96
+ const emptyRow = () => border("│") + " ".repeat(innerW) + border("│");
97
+
98
+ // Top border with title
99
+ const titleText = " Messenger Config ";
100
+ const borderLen = innerW - titleText.length;
101
+ const leftBorder = Math.floor(borderLen / 2);
102
+ const rightBorder = borderLen - leftBorder;
103
+ lines.push(
104
+ border("╭" + "─".repeat(leftBorder)) +
105
+ this.theme.fg("accent", titleText) +
106
+ border("─".repeat(rightBorder) + "╮"),
107
+ );
108
+
109
+ lines.push(emptyRow());
110
+
111
+ // Current folder status
112
+ const cwdDisplay = truncateToWidth(this.cwd, Math.max(10, innerW - 20));
113
+ lines.push(row(`Current folder: ${cwdDisplay}`));
114
+ const statusColor = isCurrentInList ? "accent" : "dim";
115
+ lines.push(row(`Auto-register: ${this.theme.fg(statusColor, isCurrentInList ? "YES" : "NO")}`));
116
+
117
+ lines.push(emptyRow());
118
+
119
+ // Divider
120
+ lines.push(border("├" + "─".repeat(innerW) + "┤"));
121
+
122
+ lines.push(emptyRow());
123
+ lines.push(row(this.theme.fg("dim", "Auto-register paths:")));
124
+ lines.push(emptyRow());
125
+
126
+ if (this.paths.length === 0) {
127
+ lines.push(row(this.theme.fg("dim", " (none configured)")));
128
+ } else {
129
+ for (let i = 0; i < this.paths.length; i++) {
130
+ const path = this.paths[i];
131
+ const isSelected = i === this.selectedIndex;
132
+ const isCurrent = path === this.cwd;
133
+
134
+ const marker = isSelected ? this.theme.fg("accent", "▸") : " ";
135
+ const suffix = isCurrent ? this.theme.fg("dim", " (current)") : "";
136
+ const pathDisplay = truncateToWidth(path, Math.max(10, innerW - 15));
137
+
138
+ if (isSelected) {
139
+ lines.push(row(`${marker} ${this.theme.fg("accent", pathDisplay)}${suffix}`));
140
+ } else {
141
+ lines.push(row(`${marker} ${pathDisplay}${suffix}`));
142
+ }
143
+ }
144
+ }
145
+
146
+ lines.push(emptyRow());
147
+
148
+ // Divider
149
+ lines.push(border("├" + "─".repeat(innerW) + "┤"));
150
+
151
+ lines.push(emptyRow());
152
+
153
+ // Status message
154
+ if (this.statusMessage) {
155
+ lines.push(row(this.theme.fg("accent", this.statusMessage)));
156
+ } else {
157
+ lines.push(emptyRow());
158
+ }
159
+
160
+ // Help
161
+ const help = "a add d delete ↑↓ navigate Esc save & close";
162
+ lines.push(row(this.theme.fg("dim", help)));
163
+
164
+ // Bottom border
165
+ lines.push(border("╰" + "─".repeat(innerW) + "╯"));
166
+
167
+ return lines;
168
+ }
169
+
170
+ invalidate(): void {
171
+ this.statusMessage = "";
172
+ }
173
+
174
+ dispose(): void {}
175
+ }