@linxiraos/pi-messenger 1.1.0 → 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
@@ -1,263 +1,264 @@
1
- /**
2
- * Crew - Planning State & Observability
3
- *
4
- * Tracks planning runs, phases, overlay pending state, stale detection,
5
- * and cancellation.
6
- */
7
-
8
- import * as fs from "node:fs";
9
- import * as path from "node:path";
10
- import { randomUUID } from "node:crypto";
11
- import { normalizeCwd } from "./state.ts";
12
-
13
- export type PlanningPhase =
14
- | "idle"
15
- | "read-prd"
16
- | "scan-code"
17
- | "docs"
18
- | "refs"
19
- | "gap-analysis"
20
- | "build-steps"
21
- | "build-task-graph"
22
- | "review-pass"
23
- | "finalizing"
24
- | "completed"
25
- | "failed";
26
-
27
- export interface PlanningState {
28
- active: boolean;
29
- cwd: string | null;
30
- runId: string | null;
31
- pass: number;
32
- maxPasses: number;
33
- phase: PlanningPhase;
34
- updatedAt: string | null;
35
- pid: number | null;
36
- }
37
-
38
- export const planningState: PlanningState = {
39
- active: false,
40
- cwd: null,
41
- runId: null,
42
- pass: 0,
43
- maxPasses: 0,
44
- phase: "idle",
45
- updatedAt: null,
46
- pid: null,
47
- };
48
-
49
- interface PlanningOverlayRuntime {
50
- pendingRunId: string | null;
51
- pendingCwd: string | null;
52
- dismissedRunIds: Set<string>;
53
- }
54
-
55
- const planningOverlayRuntime: PlanningOverlayRuntime = {
56
- pendingRunId: null,
57
- pendingCwd: null,
58
- dismissedRunIds: new Set<string>(),
59
- };
60
-
61
- export const PLANNING_STALE_TIMEOUT_MS = 5 * 60 * 1000;
62
-
63
- export function isPlanningForCwd(cwd: string): boolean {
64
- if (!planningState.active || !planningState.cwd) return false;
65
- return normalizeCwd(planningState.cwd) === normalizeCwd(cwd);
66
- }
67
-
68
- function clearPlanningOverlayPending(): void {
69
- planningOverlayRuntime.pendingRunId = null;
70
- planningOverlayRuntime.pendingCwd = null;
71
- }
72
-
73
- export function markPlanningOverlayPending(cwd: string): void {
74
- if (!isPlanningForCwd(cwd)) return;
75
- const runId = planningState.runId;
76
- const planningCwd = planningState.cwd;
77
- if (!runId || !planningCwd) return;
78
- if (planningOverlayRuntime.dismissedRunIds.has(runId)) return;
79
-
80
- planningOverlayRuntime.pendingRunId = runId;
81
- planningOverlayRuntime.pendingCwd = planningCwd;
82
- }
83
-
84
- export function getPlanningOverlayPending(cwd: string): { runId: string; cwd: string } | null {
85
- if (!isPlanningForCwd(cwd)) return null;
86
- const runId = planningState.runId;
87
- const planningCwd = planningState.cwd;
88
- if (!runId || !planningCwd) return null;
89
- if (planningOverlayRuntime.pendingRunId !== runId) return null;
90
- if (planningOverlayRuntime.pendingCwd !== planningCwd) return null;
91
- return { runId, cwd: planningCwd };
92
- }
93
-
94
- export function consumePlanningOverlayPending(cwd: string): { runId: string; cwd: string } | null {
95
- const pending = getPlanningOverlayPending(cwd);
96
- if (!pending) return null;
97
- clearPlanningOverlayPending();
98
- return pending;
99
- }
100
-
101
- export function dismissPlanningOverlayRun(runId: string): void {
102
- planningOverlayRuntime.dismissedRunIds.add(runId);
103
- if (planningOverlayRuntime.pendingRunId === runId) {
104
- clearPlanningOverlayPending();
105
- }
106
- }
107
-
108
- export function resetPlanningOverlayRuntimeForTests(): void {
109
- planningOverlayRuntime.pendingRunId = null;
110
- planningOverlayRuntime.pendingCwd = null;
111
- planningOverlayRuntime.dismissedRunIds.clear();
112
- }
113
-
114
- function parseIsoMs(value: string | null): number | null {
115
- if (!value) return null;
116
- const parsed = Date.parse(value);
117
- return Number.isFinite(parsed) ? parsed : null;
118
- }
119
-
120
- export function getPlanningUpdateAgeMs(cwd: string, nowMs: number = Date.now()): number | null {
121
- if (!isPlanningForCwd(cwd)) return null;
122
- const updatedMs = parseIsoMs(planningState.updatedAt);
123
- if (updatedMs === null) return null;
124
- return Math.max(0, nowMs - updatedMs);
125
- }
126
-
127
- export function isPlanningStalled(
128
- cwd: string,
129
- nowMs: number = Date.now(),
130
- staleAfterMs: number = PLANNING_STALE_TIMEOUT_MS,
131
- ): boolean {
132
- if (!isPlanningForCwd(cwd)) return false;
133
- const ageMs = getPlanningUpdateAgeMs(cwd, nowMs);
134
- if (ageMs === null) return true;
135
- return ageMs >= Math.max(1, staleAfterMs);
136
- }
137
-
138
- function isProcessAlive(pid: number): boolean {
139
- try {
140
- process.kill(pid, 0);
141
- return true;
142
- } catch {
143
- return false;
144
- }
145
- }
146
-
147
- let planningCancelled = false;
148
-
149
- export function cancelPlanningRun(cwd: string): void {
150
- planningCancelled = true;
151
- clearPlanningState(cwd);
152
- }
153
-
154
- export function isPlanningCancelled(): boolean {
155
- return planningCancelled;
156
- }
157
-
158
- export function resetPlanningCancellation(): void {
159
- planningCancelled = false;
160
- }
161
-
162
- function planningStatePath(cwd: string): string {
163
- return path.join(cwd, ".pi", "messenger", "crew", "planning-state.json");
164
- }
165
-
166
- function persistPlanningState(cwd: string): void {
167
- const filePath = planningStatePath(cwd);
168
- try {
169
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
170
- fs.writeFileSync(filePath, JSON.stringify(planningState, null, 2));
171
- } catch {}
172
- }
173
-
174
- export function startPlanningRun(cwd: string, maxPasses: number): void {
175
- planningCancelled = false;
176
- const normalizedCwd = normalizeCwd(cwd);
177
- planningState.active = true;
178
- planningState.cwd = normalizedCwd;
179
- planningState.pid = process.pid;
180
- planningState.runId = randomUUID();
181
- planningState.pass = 0;
182
- planningState.maxPasses = Math.max(1, maxPasses);
183
- planningState.phase = "read-prd";
184
- planningState.updatedAt = new Date().toISOString();
185
- persistPlanningState(normalizedCwd);
186
- markPlanningOverlayPending(normalizedCwd);
187
- }
188
-
189
- export function setPlanningPhase(cwd: string, phase: PlanningPhase, pass?: number): void {
190
- if (planningCancelled) return;
191
- const normalizedCwd = normalizeCwd(cwd);
192
- planningState.active = true;
193
- planningState.cwd = normalizedCwd;
194
- if (!planningState.runId) planningState.runId = randomUUID();
195
- planningState.phase = phase;
196
- if (pass !== undefined) planningState.pass = pass;
197
- planningState.updatedAt = new Date().toISOString();
198
- persistPlanningState(normalizedCwd);
199
- }
200
-
201
- export function finishPlanningRun(cwd: string, status: "completed" | "failed", pass?: number): void {
202
- if (planningCancelled) return;
203
- const normalizedCwd = normalizeCwd(cwd);
204
- clearPlanningOverlayPending();
205
- planningState.active = false;
206
- planningState.cwd = normalizedCwd;
207
- planningState.runId = null;
208
- planningState.phase = status;
209
- if (pass !== undefined) planningState.pass = pass;
210
- planningState.updatedAt = new Date().toISOString();
211
- persistPlanningState(normalizedCwd);
212
- }
213
-
214
- export function clearPlanningState(cwd: string): void {
215
- const normalizedCwd = normalizeCwd(cwd);
216
- clearPlanningOverlayPending();
217
- planningState.active = false;
218
- planningState.cwd = normalizedCwd;
219
- planningState.runId = null;
220
- planningState.pass = 0;
221
- planningState.maxPasses = 0;
222
- planningState.phase = "idle";
223
- planningState.updatedAt = new Date().toISOString();
224
- planningState.pid = null;
225
- persistPlanningState(normalizedCwd);
226
- }
227
-
228
- export function restorePlanningState(cwd: string): { staleCleared: boolean } {
229
- const normalizedCwd = normalizeCwd(cwd);
230
- const filePath = planningStatePath(normalizedCwd);
231
- if (!fs.existsSync(filePath)) return { staleCleared: false };
232
- try {
233
- const raw = fs.readFileSync(filePath, "utf-8");
234
- const parsed = JSON.parse(raw) as Partial<PlanningState>;
235
-
236
- if (parsed.active) {
237
- const storedPid = typeof parsed.pid === "number" ? parsed.pid : null;
238
- if (!storedPid || !isProcessAlive(storedPid)) {
239
- clearPlanningState(normalizedCwd);
240
- return { staleCleared: true };
241
- }
242
- }
243
-
244
- planningState.active = parsed.active ?? false;
245
- planningState.cwd = normalizeCwd(parsed.cwd ?? normalizedCwd);
246
- planningState.runId = typeof parsed.runId === "string" ? parsed.runId : null;
247
- planningState.pass = Number(parsed.pass ?? 0);
248
- planningState.maxPasses = Number(parsed.maxPasses ?? 0);
249
- planningState.phase = parsed.phase ?? "idle";
250
- planningState.updatedAt = parsed.updatedAt ?? null;
251
- planningState.pid = typeof parsed.pid === "number" ? parsed.pid : null;
252
-
253
- const planningCwd = planningState.cwd;
254
- if (planningState.active && planningCwd && !planningState.runId) {
255
- planningState.runId = randomUUID();
256
- persistPlanningState(planningCwd);
257
- }
258
-
259
- return { staleCleared: false };
260
- } catch {
261
- return { staleCleared: false };
262
- }
263
- }
1
+ /**
2
+ * Crew - Planning State & Observability
3
+ *
4
+ * Tracks planning runs, phases, overlay pending state, stale detection,
5
+ * and cancellation.
6
+ */
7
+
8
+ import * as fs from "node:fs";
9
+ import * as path from "node:path";
10
+ import { randomUUID } from "node:crypto";
11
+ import { normalizeCwd } from "./state.ts";
12
+ import { getProjectCrewDir } from "../paths.ts";
13
+
14
+ export type PlanningPhase =
15
+ | "idle"
16
+ | "read-prd"
17
+ | "scan-code"
18
+ | "docs"
19
+ | "refs"
20
+ | "gap-analysis"
21
+ | "build-steps"
22
+ | "build-task-graph"
23
+ | "review-pass"
24
+ | "finalizing"
25
+ | "completed"
26
+ | "failed";
27
+
28
+ export interface PlanningState {
29
+ active: boolean;
30
+ cwd: string | null;
31
+ runId: string | null;
32
+ pass: number;
33
+ maxPasses: number;
34
+ phase: PlanningPhase;
35
+ updatedAt: string | null;
36
+ pid: number | null;
37
+ }
38
+
39
+ export const planningState: PlanningState = {
40
+ active: false,
41
+ cwd: null,
42
+ runId: null,
43
+ pass: 0,
44
+ maxPasses: 0,
45
+ phase: "idle",
46
+ updatedAt: null,
47
+ pid: null,
48
+ };
49
+
50
+ interface PlanningOverlayRuntime {
51
+ pendingRunId: string | null;
52
+ pendingCwd: string | null;
53
+ dismissedRunIds: Set<string>;
54
+ }
55
+
56
+ const planningOverlayRuntime: PlanningOverlayRuntime = {
57
+ pendingRunId: null,
58
+ pendingCwd: null,
59
+ dismissedRunIds: new Set<string>(),
60
+ };
61
+
62
+ export const PLANNING_STALE_TIMEOUT_MS = 5 * 60 * 1000;
63
+
64
+ export function isPlanningForCwd(cwd: string): boolean {
65
+ if (!planningState.active || !planningState.cwd) return false;
66
+ return normalizeCwd(planningState.cwd) === normalizeCwd(cwd);
67
+ }
68
+
69
+ function clearPlanningOverlayPending(): void {
70
+ planningOverlayRuntime.pendingRunId = null;
71
+ planningOverlayRuntime.pendingCwd = null;
72
+ }
73
+
74
+ export function markPlanningOverlayPending(cwd: string): void {
75
+ if (!isPlanningForCwd(cwd)) return;
76
+ const runId = planningState.runId;
77
+ const planningCwd = planningState.cwd;
78
+ if (!runId || !planningCwd) return;
79
+ if (planningOverlayRuntime.dismissedRunIds.has(runId)) return;
80
+
81
+ planningOverlayRuntime.pendingRunId = runId;
82
+ planningOverlayRuntime.pendingCwd = planningCwd;
83
+ }
84
+
85
+ export function getPlanningOverlayPending(cwd: string): { runId: string; cwd: string } | null {
86
+ if (!isPlanningForCwd(cwd)) return null;
87
+ const runId = planningState.runId;
88
+ const planningCwd = planningState.cwd;
89
+ if (!runId || !planningCwd) return null;
90
+ if (planningOverlayRuntime.pendingRunId !== runId) return null;
91
+ if (planningOverlayRuntime.pendingCwd !== planningCwd) return null;
92
+ return { runId, cwd: planningCwd };
93
+ }
94
+
95
+ export function consumePlanningOverlayPending(cwd: string): { runId: string; cwd: string } | null {
96
+ const pending = getPlanningOverlayPending(cwd);
97
+ if (!pending) return null;
98
+ clearPlanningOverlayPending();
99
+ return pending;
100
+ }
101
+
102
+ export function dismissPlanningOverlayRun(runId: string): void {
103
+ planningOverlayRuntime.dismissedRunIds.add(runId);
104
+ if (planningOverlayRuntime.pendingRunId === runId) {
105
+ clearPlanningOverlayPending();
106
+ }
107
+ }
108
+
109
+ export function resetPlanningOverlayRuntimeForTests(): void {
110
+ planningOverlayRuntime.pendingRunId = null;
111
+ planningOverlayRuntime.pendingCwd = null;
112
+ planningOverlayRuntime.dismissedRunIds.clear();
113
+ }
114
+
115
+ function parseIsoMs(value: string | null): number | null {
116
+ if (!value) return null;
117
+ const parsed = Date.parse(value);
118
+ return Number.isFinite(parsed) ? parsed : null;
119
+ }
120
+
121
+ export function getPlanningUpdateAgeMs(cwd: string, nowMs: number = Date.now()): number | null {
122
+ if (!isPlanningForCwd(cwd)) return null;
123
+ const updatedMs = parseIsoMs(planningState.updatedAt);
124
+ if (updatedMs === null) return null;
125
+ return Math.max(0, nowMs - updatedMs);
126
+ }
127
+
128
+ export function isPlanningStalled(
129
+ cwd: string,
130
+ nowMs: number = Date.now(),
131
+ staleAfterMs: number = PLANNING_STALE_TIMEOUT_MS,
132
+ ): boolean {
133
+ if (!isPlanningForCwd(cwd)) return false;
134
+ const ageMs = getPlanningUpdateAgeMs(cwd, nowMs);
135
+ if (ageMs === null) return true;
136
+ return ageMs >= Math.max(1, staleAfterMs);
137
+ }
138
+
139
+ function isProcessAlive(pid: number): boolean {
140
+ try {
141
+ process.kill(pid, 0);
142
+ return true;
143
+ } catch {
144
+ return false;
145
+ }
146
+ }
147
+
148
+ let planningCancelled = false;
149
+
150
+ export function cancelPlanningRun(cwd: string): void {
151
+ planningCancelled = true;
152
+ clearPlanningState(cwd);
153
+ }
154
+
155
+ export function isPlanningCancelled(): boolean {
156
+ return planningCancelled;
157
+ }
158
+
159
+ export function resetPlanningCancellation(): void {
160
+ planningCancelled = false;
161
+ }
162
+
163
+ function planningStatePath(cwd: string): string {
164
+ return path.join(getProjectCrewDir(cwd), "planning-state.json");
165
+ }
166
+
167
+ function persistPlanningState(cwd: string): void {
168
+ const filePath = planningStatePath(cwd);
169
+ try {
170
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
171
+ fs.writeFileSync(filePath, JSON.stringify(planningState, null, 2));
172
+ } catch {}
173
+ }
174
+
175
+ export function startPlanningRun(cwd: string, maxPasses: number): void {
176
+ planningCancelled = false;
177
+ const normalizedCwd = normalizeCwd(cwd);
178
+ planningState.active = true;
179
+ planningState.cwd = normalizedCwd;
180
+ planningState.pid = process.pid;
181
+ planningState.runId = randomUUID();
182
+ planningState.pass = 0;
183
+ planningState.maxPasses = Math.max(1, maxPasses);
184
+ planningState.phase = "read-prd";
185
+ planningState.updatedAt = new Date().toISOString();
186
+ persistPlanningState(normalizedCwd);
187
+ markPlanningOverlayPending(normalizedCwd);
188
+ }
189
+
190
+ export function setPlanningPhase(cwd: string, phase: PlanningPhase, pass?: number): void {
191
+ if (planningCancelled) return;
192
+ const normalizedCwd = normalizeCwd(cwd);
193
+ planningState.active = true;
194
+ planningState.cwd = normalizedCwd;
195
+ if (!planningState.runId) planningState.runId = randomUUID();
196
+ planningState.phase = phase;
197
+ if (pass !== undefined) planningState.pass = pass;
198
+ planningState.updatedAt = new Date().toISOString();
199
+ persistPlanningState(normalizedCwd);
200
+ }
201
+
202
+ export function finishPlanningRun(cwd: string, status: "completed" | "failed", pass?: number): void {
203
+ if (planningCancelled) return;
204
+ const normalizedCwd = normalizeCwd(cwd);
205
+ clearPlanningOverlayPending();
206
+ planningState.active = false;
207
+ planningState.cwd = normalizedCwd;
208
+ planningState.runId = null;
209
+ planningState.phase = status;
210
+ if (pass !== undefined) planningState.pass = pass;
211
+ planningState.updatedAt = new Date().toISOString();
212
+ persistPlanningState(normalizedCwd);
213
+ }
214
+
215
+ export function clearPlanningState(cwd: string): void {
216
+ const normalizedCwd = normalizeCwd(cwd);
217
+ clearPlanningOverlayPending();
218
+ planningState.active = false;
219
+ planningState.cwd = normalizedCwd;
220
+ planningState.runId = null;
221
+ planningState.pass = 0;
222
+ planningState.maxPasses = 0;
223
+ planningState.phase = "idle";
224
+ planningState.updatedAt = new Date().toISOString();
225
+ planningState.pid = null;
226
+ persistPlanningState(normalizedCwd);
227
+ }
228
+
229
+ export function restorePlanningState(cwd: string): { staleCleared: boolean } {
230
+ const normalizedCwd = normalizeCwd(cwd);
231
+ const filePath = planningStatePath(normalizedCwd);
232
+ if (!fs.existsSync(filePath)) return { staleCleared: false };
233
+ try {
234
+ const raw = fs.readFileSync(filePath, "utf-8");
235
+ const parsed = JSON.parse(raw) as Partial<PlanningState>;
236
+
237
+ if (parsed.active) {
238
+ const storedPid = typeof parsed.pid === "number" ? parsed.pid : null;
239
+ if (!storedPid || !isProcessAlive(storedPid)) {
240
+ clearPlanningState(normalizedCwd);
241
+ return { staleCleared: true };
242
+ }
243
+ }
244
+
245
+ planningState.active = parsed.active ?? false;
246
+ planningState.cwd = normalizeCwd(parsed.cwd ?? normalizedCwd);
247
+ planningState.runId = typeof parsed.runId === "string" ? parsed.runId : null;
248
+ planningState.pass = Number(parsed.pass ?? 0);
249
+ planningState.maxPasses = Number(parsed.maxPasses ?? 0);
250
+ planningState.phase = parsed.phase ?? "idle";
251
+ planningState.updatedAt = parsed.updatedAt ?? null;
252
+ planningState.pid = typeof parsed.pid === "number" ? parsed.pid : null;
253
+
254
+ const planningCwd = planningState.cwd;
255
+ if (planningState.active && planningCwd && !planningState.runId) {
256
+ planningState.runId = randomUUID();
257
+ persistPlanningState(planningCwd);
258
+ }
259
+
260
+ return { staleCleared: false };
261
+ } catch {
262
+ return { staleCleared: false };
263
+ }
264
+ }
package/crew/state.ts CHANGED
@@ -1,20 +1,20 @@
1
- /**
2
- * Crew - Shared Runtime State (barrel)
3
- *
4
- * Re-exports autonomous and planning state from focused sibling modules.
5
- * Shared utility functions used by both modules live here.
6
- */
7
-
8
- import * as fs from "node:fs";
9
- import * as path from "node:path";
10
-
11
- export function normalizeCwd(cwd: string): string {
12
- try {
13
- return fs.realpathSync.native(cwd);
14
- } catch {
15
- return path.resolve(cwd);
16
- }
17
- }
18
-
19
- export * from "./state-autonomous.ts";
20
- export * from "./state-planning.ts";
1
+ /**
2
+ * Crew - Shared Runtime State (barrel)
3
+ *
4
+ * Re-exports autonomous and planning state from focused sibling modules.
5
+ * Shared utility functions used by both modules live here.
6
+ */
7
+
8
+ import * as fs from "node:fs";
9
+ import * as path from "node:path";
10
+
11
+ export function normalizeCwd(cwd: string): string {
12
+ try {
13
+ return fs.realpathSync.native(cwd);
14
+ } catch {
15
+ return path.resolve(cwd);
16
+ }
17
+ }
18
+
19
+ export * from "./state-autonomous.ts";
20
+ export * from "./state-planning.ts";