@katyella/legio 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.
- package/CHANGELOG.md +422 -0
- package/LICENSE +21 -0
- package/README.md +555 -0
- package/agents/builder.md +141 -0
- package/agents/coordinator.md +351 -0
- package/agents/cto.md +196 -0
- package/agents/gateway.md +276 -0
- package/agents/lead.md +281 -0
- package/agents/merger.md +156 -0
- package/agents/monitor.md +212 -0
- package/agents/reviewer.md +142 -0
- package/agents/scout.md +131 -0
- package/agents/supervisor.md +416 -0
- package/bin/legio.mjs +38 -0
- package/package.json +77 -0
- package/src/agents/checkpoint.test.ts +88 -0
- package/src/agents/checkpoint.ts +102 -0
- package/src/agents/hooks-deployer.test.ts +1820 -0
- package/src/agents/hooks-deployer.ts +574 -0
- package/src/agents/identity.test.ts +614 -0
- package/src/agents/identity.ts +385 -0
- package/src/agents/lifecycle.test.ts +202 -0
- package/src/agents/lifecycle.ts +184 -0
- package/src/agents/manifest.test.ts +558 -0
- package/src/agents/manifest.ts +297 -0
- package/src/agents/overlay.test.ts +592 -0
- package/src/agents/overlay.ts +316 -0
- package/src/beads/client.test.ts +210 -0
- package/src/beads/client.ts +227 -0
- package/src/beads/molecules.test.ts +320 -0
- package/src/beads/molecules.ts +209 -0
- package/src/commands/agents.test.ts +325 -0
- package/src/commands/agents.ts +286 -0
- package/src/commands/clean.test.ts +730 -0
- package/src/commands/clean.ts +653 -0
- package/src/commands/completions.test.ts +346 -0
- package/src/commands/completions.ts +950 -0
- package/src/commands/coordinator.test.ts +1524 -0
- package/src/commands/coordinator.ts +880 -0
- package/src/commands/costs.test.ts +1015 -0
- package/src/commands/costs.ts +473 -0
- package/src/commands/dashboard.test.ts +94 -0
- package/src/commands/dashboard.ts +607 -0
- package/src/commands/doctor.test.ts +295 -0
- package/src/commands/doctor.ts +213 -0
- package/src/commands/down.test.ts +308 -0
- package/src/commands/down.ts +124 -0
- package/src/commands/errors.test.ts +648 -0
- package/src/commands/errors.ts +255 -0
- package/src/commands/feed.test.ts +579 -0
- package/src/commands/feed.ts +368 -0
- package/src/commands/gateway.test.ts +698 -0
- package/src/commands/gateway.ts +419 -0
- package/src/commands/group.test.ts +262 -0
- package/src/commands/group.ts +539 -0
- package/src/commands/hooks.test.ts +292 -0
- package/src/commands/hooks.ts +210 -0
- package/src/commands/init.test.ts +211 -0
- package/src/commands/init.ts +622 -0
- package/src/commands/inspect.test.ts +670 -0
- package/src/commands/inspect.ts +455 -0
- package/src/commands/log.test.ts +1556 -0
- package/src/commands/log.ts +752 -0
- package/src/commands/logs.test.ts +379 -0
- package/src/commands/logs.ts +544 -0
- package/src/commands/mail.test.ts +1726 -0
- package/src/commands/mail.ts +926 -0
- package/src/commands/merge.test.ts +676 -0
- package/src/commands/merge.ts +374 -0
- package/src/commands/metrics.test.ts +444 -0
- package/src/commands/metrics.ts +150 -0
- package/src/commands/monitor.test.ts +151 -0
- package/src/commands/monitor.ts +394 -0
- package/src/commands/nudge.test.ts +230 -0
- package/src/commands/nudge.ts +373 -0
- package/src/commands/prime.test.ts +467 -0
- package/src/commands/prime.ts +386 -0
- package/src/commands/replay.test.ts +742 -0
- package/src/commands/replay.ts +367 -0
- package/src/commands/run.test.ts +443 -0
- package/src/commands/run.ts +365 -0
- package/src/commands/server.test.ts +626 -0
- package/src/commands/server.ts +298 -0
- package/src/commands/sling.test.ts +810 -0
- package/src/commands/sling.ts +700 -0
- package/src/commands/spec.test.ts +206 -0
- package/src/commands/spec.ts +171 -0
- package/src/commands/status.test.ts +276 -0
- package/src/commands/status.ts +339 -0
- package/src/commands/stop.test.ts +357 -0
- package/src/commands/stop.ts +119 -0
- package/src/commands/supervisor.test.ts +186 -0
- package/src/commands/supervisor.ts +544 -0
- package/src/commands/trace.test.ts +746 -0
- package/src/commands/trace.ts +332 -0
- package/src/commands/up.test.ts +597 -0
- package/src/commands/up.ts +275 -0
- package/src/commands/watch.test.ts +152 -0
- package/src/commands/watch.ts +238 -0
- package/src/commands/worktree.test.ts +648 -0
- package/src/commands/worktree.ts +266 -0
- package/src/config.test.ts +496 -0
- package/src/config.ts +616 -0
- package/src/doctor/agents.test.ts +448 -0
- package/src/doctor/agents.ts +396 -0
- package/src/doctor/config-check.test.ts +184 -0
- package/src/doctor/config-check.ts +185 -0
- package/src/doctor/consistency.test.ts +645 -0
- package/src/doctor/consistency.ts +294 -0
- package/src/doctor/databases.test.ts +284 -0
- package/src/doctor/databases.ts +211 -0
- package/src/doctor/dependencies.test.ts +150 -0
- package/src/doctor/dependencies.ts +179 -0
- package/src/doctor/logs.test.ts +244 -0
- package/src/doctor/logs.ts +295 -0
- package/src/doctor/merge-queue.test.ts +210 -0
- package/src/doctor/merge-queue.ts +144 -0
- package/src/doctor/structure.test.ts +285 -0
- package/src/doctor/structure.ts +195 -0
- package/src/doctor/types.ts +37 -0
- package/src/doctor/version.test.ts +130 -0
- package/src/doctor/version.ts +131 -0
- package/src/e2e/chat-flow.test.ts +346 -0
- package/src/e2e/init-sling-lifecycle.test.ts +288 -0
- package/src/errors.test.ts +21 -0
- package/src/errors.ts +246 -0
- package/src/events/store.test.ts +660 -0
- package/src/events/store.ts +344 -0
- package/src/events/tool-filter.test.ts +330 -0
- package/src/events/tool-filter.ts +126 -0
- package/src/global-setup.ts +14 -0
- package/src/index.ts +339 -0
- package/src/insights/analyzer.test.ts +466 -0
- package/src/insights/analyzer.ts +203 -0
- package/src/logging/color.test.ts +118 -0
- package/src/logging/color.ts +71 -0
- package/src/logging/logger.test.ts +812 -0
- package/src/logging/logger.ts +266 -0
- package/src/logging/reporter.test.ts +258 -0
- package/src/logging/reporter.ts +109 -0
- package/src/logging/sanitizer.test.ts +190 -0
- package/src/logging/sanitizer.ts +57 -0
- package/src/mail/broadcast.test.ts +203 -0
- package/src/mail/broadcast.ts +92 -0
- package/src/mail/client.test.ts +873 -0
- package/src/mail/client.ts +236 -0
- package/src/mail/store.test.ts +815 -0
- package/src/mail/store.ts +402 -0
- package/src/merge/queue.test.ts +449 -0
- package/src/merge/queue.ts +262 -0
- package/src/merge/resolver.test.ts +1453 -0
- package/src/merge/resolver.ts +759 -0
- package/src/metrics/store.test.ts +1167 -0
- package/src/metrics/store.ts +511 -0
- package/src/metrics/summary.test.ts +397 -0
- package/src/metrics/summary.ts +178 -0
- package/src/metrics/transcript.test.ts +643 -0
- package/src/metrics/transcript.ts +351 -0
- package/src/mulch/client.test.ts +547 -0
- package/src/mulch/client.ts +416 -0
- package/src/server/audit-store.test.ts +384 -0
- package/src/server/audit-store.ts +257 -0
- package/src/server/headless.test.ts +180 -0
- package/src/server/headless.ts +151 -0
- package/src/server/index.test.ts +241 -0
- package/src/server/index.ts +317 -0
- package/src/server/public/app.js +187 -0
- package/src/server/public/apple-touch-icon.png +0 -0
- package/src/server/public/components/agent-badge.js +37 -0
- package/src/server/public/components/data-table.js +114 -0
- package/src/server/public/components/gateway-chat.js +256 -0
- package/src/server/public/components/issue-card.js +96 -0
- package/src/server/public/components/layout.js +88 -0
- package/src/server/public/components/message-bubble.js +120 -0
- package/src/server/public/components/stat-card.js +26 -0
- package/src/server/public/components/terminal-panel.js +140 -0
- package/src/server/public/favicon-16.png +0 -0
- package/src/server/public/favicon-32.png +0 -0
- package/src/server/public/favicon.ico +0 -0
- package/src/server/public/favicon.png +0 -0
- package/src/server/public/index.html +64 -0
- package/src/server/public/lib/api.js +35 -0
- package/src/server/public/lib/markdown.js +8 -0
- package/src/server/public/lib/preact-setup.js +8 -0
- package/src/server/public/lib/state.js +99 -0
- package/src/server/public/lib/utils.js +309 -0
- package/src/server/public/lib/ws.js +79 -0
- package/src/server/public/views/chat.js +983 -0
- package/src/server/public/views/costs.js +692 -0
- package/src/server/public/views/dashboard.js +781 -0
- package/src/server/public/views/gateway-chat.js +622 -0
- package/src/server/public/views/inspect.js +399 -0
- package/src/server/public/views/issues.js +470 -0
- package/src/server/public/views/setup.js +94 -0
- package/src/server/public/views/task-detail.js +422 -0
- package/src/server/routes.test.ts +3816 -0
- package/src/server/routes.ts +1964 -0
- package/src/server/websocket.test.ts +288 -0
- package/src/server/websocket.ts +196 -0
- package/src/sessions/compat.test.ts +109 -0
- package/src/sessions/compat.ts +17 -0
- package/src/sessions/store.test.ts +969 -0
- package/src/sessions/store.ts +480 -0
- package/src/test-helpers.test.ts +97 -0
- package/src/test-helpers.ts +143 -0
- package/src/types.ts +708 -0
- package/src/watchdog/daemon.test.ts +1233 -0
- package/src/watchdog/daemon.ts +533 -0
- package/src/watchdog/health.test.ts +371 -0
- package/src/watchdog/health.ts +248 -0
- package/src/watchdog/triage.test.ts +162 -0
- package/src/watchdog/triage.ts +193 -0
- package/src/worktree/manager.test.ts +444 -0
- package/src/worktree/manager.ts +224 -0
- package/src/worktree/tmux.test.ts +1238 -0
- package/src/worktree/tmux.ts +644 -0
- package/templates/CLAUDE.md.tmpl +89 -0
- package/templates/hooks.json.tmpl +132 -0
- package/templates/overlay.md.tmpl +79 -0
package/src/errors.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Legio errors.
|
|
3
|
+
* Includes a machine-readable `code` field for programmatic handling.
|
|
4
|
+
*/
|
|
5
|
+
export class LegioError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
|
|
8
|
+
constructor(message: string, code: string, options?: ErrorOptions) {
|
|
9
|
+
super(message, options);
|
|
10
|
+
this.name = "LegioError";
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Raised when config loading or validation fails.
|
|
17
|
+
* Examples: missing config file, invalid YAML, schema violations.
|
|
18
|
+
*/
|
|
19
|
+
export class ConfigError extends LegioError {
|
|
20
|
+
readonly configPath: string | null;
|
|
21
|
+
readonly field: string | null;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
message: string,
|
|
25
|
+
context?: {
|
|
26
|
+
configPath?: string;
|
|
27
|
+
field?: string;
|
|
28
|
+
cause?: Error;
|
|
29
|
+
},
|
|
30
|
+
) {
|
|
31
|
+
super(message, "CONFIG_ERROR", { cause: context?.cause });
|
|
32
|
+
this.name = "ConfigError";
|
|
33
|
+
this.configPath = context?.configPath ?? null;
|
|
34
|
+
this.field = context?.field ?? null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Raised for agent lifecycle issues.
|
|
40
|
+
* Examples: spawn failure, agent not found, depth limit exceeded.
|
|
41
|
+
*/
|
|
42
|
+
export class AgentError extends LegioError {
|
|
43
|
+
readonly agentName: string | null;
|
|
44
|
+
readonly capability: string | null;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
message: string,
|
|
48
|
+
context?: {
|
|
49
|
+
agentName?: string;
|
|
50
|
+
capability?: string;
|
|
51
|
+
cause?: Error;
|
|
52
|
+
},
|
|
53
|
+
) {
|
|
54
|
+
super(message, "AGENT_ERROR", { cause: context?.cause });
|
|
55
|
+
this.name = "AgentError";
|
|
56
|
+
this.agentName = context?.agentName ?? null;
|
|
57
|
+
this.capability = context?.capability ?? null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Raised when hierarchy constraints are violated.
|
|
63
|
+
* Examples: coordinator spawning a builder directly instead of through a lead.
|
|
64
|
+
*/
|
|
65
|
+
export class HierarchyError extends LegioError {
|
|
66
|
+
readonly agentName: string | null;
|
|
67
|
+
readonly requestedCapability: string | null;
|
|
68
|
+
|
|
69
|
+
constructor(
|
|
70
|
+
message: string,
|
|
71
|
+
context?: {
|
|
72
|
+
agentName?: string;
|
|
73
|
+
requestedCapability?: string;
|
|
74
|
+
cause?: Error;
|
|
75
|
+
},
|
|
76
|
+
) {
|
|
77
|
+
super(message, "HIERARCHY_VIOLATION", { cause: context?.cause });
|
|
78
|
+
this.name = "HierarchyError";
|
|
79
|
+
this.agentName = context?.agentName ?? null;
|
|
80
|
+
this.requestedCapability = context?.requestedCapability ?? null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Raised when git worktree operations fail.
|
|
86
|
+
* Examples: worktree creation, branch conflicts, cleanup failures.
|
|
87
|
+
*/
|
|
88
|
+
export class WorktreeError extends LegioError {
|
|
89
|
+
readonly worktreePath: string | null;
|
|
90
|
+
readonly branchName: string | null;
|
|
91
|
+
|
|
92
|
+
constructor(
|
|
93
|
+
message: string,
|
|
94
|
+
context?: {
|
|
95
|
+
worktreePath?: string;
|
|
96
|
+
branchName?: string;
|
|
97
|
+
cause?: Error;
|
|
98
|
+
},
|
|
99
|
+
) {
|
|
100
|
+
super(message, "WORKTREE_ERROR", { cause: context?.cause });
|
|
101
|
+
this.name = "WorktreeError";
|
|
102
|
+
this.worktreePath = context?.worktreePath ?? null;
|
|
103
|
+
this.branchName = context?.branchName ?? null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Raised when mail system operations fail.
|
|
109
|
+
* Examples: DB access errors, invalid message format, delivery failures.
|
|
110
|
+
*/
|
|
111
|
+
export class MailError extends LegioError {
|
|
112
|
+
readonly agentName: string | null;
|
|
113
|
+
readonly messageId: string | null;
|
|
114
|
+
|
|
115
|
+
constructor(
|
|
116
|
+
message: string,
|
|
117
|
+
context?: {
|
|
118
|
+
agentName?: string;
|
|
119
|
+
messageId?: string;
|
|
120
|
+
cause?: Error;
|
|
121
|
+
},
|
|
122
|
+
) {
|
|
123
|
+
super(message, "MAIL_ERROR", { cause: context?.cause });
|
|
124
|
+
this.name = "MailError";
|
|
125
|
+
this.agentName = context?.agentName ?? null;
|
|
126
|
+
this.messageId = context?.messageId ?? null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Raised when merge or conflict resolution fails.
|
|
132
|
+
* Examples: unresolvable conflicts, merge queue errors, tier escalation failures.
|
|
133
|
+
*/
|
|
134
|
+
export class MergeError extends LegioError {
|
|
135
|
+
readonly branchName: string | null;
|
|
136
|
+
readonly conflictFiles: string[];
|
|
137
|
+
|
|
138
|
+
constructor(
|
|
139
|
+
message: string,
|
|
140
|
+
context?: {
|
|
141
|
+
branchName?: string;
|
|
142
|
+
conflictFiles?: string[];
|
|
143
|
+
cause?: Error;
|
|
144
|
+
},
|
|
145
|
+
) {
|
|
146
|
+
super(message, "MERGE_ERROR", { cause: context?.cause });
|
|
147
|
+
this.name = "MergeError";
|
|
148
|
+
this.branchName = context?.branchName ?? null;
|
|
149
|
+
this.conflictFiles = context?.conflictFiles ?? [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Raised when input validation fails.
|
|
155
|
+
* Examples: invalid agent names, malformed beadIds, bad CLI arguments.
|
|
156
|
+
*/
|
|
157
|
+
export class ValidationError extends LegioError {
|
|
158
|
+
readonly field: string | null;
|
|
159
|
+
readonly value: unknown;
|
|
160
|
+
|
|
161
|
+
constructor(
|
|
162
|
+
message: string,
|
|
163
|
+
context?: {
|
|
164
|
+
field?: string;
|
|
165
|
+
value?: unknown;
|
|
166
|
+
cause?: Error;
|
|
167
|
+
},
|
|
168
|
+
) {
|
|
169
|
+
super(message, "VALIDATION_ERROR", { cause: context?.cause });
|
|
170
|
+
this.name = "ValidationError";
|
|
171
|
+
this.field = context?.field ?? null;
|
|
172
|
+
this.value = context?.value ?? null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Raised when task group operations fail.
|
|
178
|
+
* Examples: group not found, duplicate member, auto-close failures.
|
|
179
|
+
*/
|
|
180
|
+
export class GroupError extends LegioError {
|
|
181
|
+
readonly groupId: string | null;
|
|
182
|
+
|
|
183
|
+
constructor(
|
|
184
|
+
message: string,
|
|
185
|
+
context?: {
|
|
186
|
+
groupId?: string;
|
|
187
|
+
cause?: Error;
|
|
188
|
+
},
|
|
189
|
+
) {
|
|
190
|
+
super(message, "GROUP_ERROR", { cause: context?.cause });
|
|
191
|
+
this.name = "GroupError";
|
|
192
|
+
this.groupId = context?.groupId ?? null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Raised when session lifecycle operations fail.
|
|
198
|
+
* Examples: checkpoint save/restore failures, handoff failures.
|
|
199
|
+
*/
|
|
200
|
+
export class LifecycleError extends LegioError {
|
|
201
|
+
readonly agentName: string | null;
|
|
202
|
+
readonly sessionId: string | null;
|
|
203
|
+
|
|
204
|
+
constructor(
|
|
205
|
+
message: string,
|
|
206
|
+
context?: {
|
|
207
|
+
agentName?: string;
|
|
208
|
+
sessionId?: string;
|
|
209
|
+
cause?: Error;
|
|
210
|
+
},
|
|
211
|
+
) {
|
|
212
|
+
super(message, "LIFECYCLE_ERROR", { cause: context?.cause });
|
|
213
|
+
this.name = "LifecycleError";
|
|
214
|
+
this.agentName = context?.agentName ?? null;
|
|
215
|
+
this.sessionId = context?.sessionId ?? null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns true if the current process is running as the root user (UID 0).
|
|
221
|
+
* Only guards on POSIX platforms — returns false on Windows where process.getuid
|
|
222
|
+
* is unavailable.
|
|
223
|
+
*/
|
|
224
|
+
export function isRunningAsRoot(): boolean {
|
|
225
|
+
return typeof process.getuid === "function" && process.getuid() === 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Raised when the web UI server fails to start or encounters a runtime error.
|
|
230
|
+
* Examples: port already in use, bind failure, static file not found.
|
|
231
|
+
*/
|
|
232
|
+
export class ServerError extends LegioError {
|
|
233
|
+
readonly port: number | null;
|
|
234
|
+
|
|
235
|
+
constructor(
|
|
236
|
+
message: string,
|
|
237
|
+
context?: {
|
|
238
|
+
port?: number;
|
|
239
|
+
cause?: Error;
|
|
240
|
+
},
|
|
241
|
+
) {
|
|
242
|
+
super(message, "SERVER_ERROR", { cause: context?.cause });
|
|
243
|
+
this.name = "ServerError";
|
|
244
|
+
this.port = context?.port ?? null;
|
|
245
|
+
}
|
|
246
|
+
}
|