@wrongstack/core 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.
@@ -0,0 +1,3 @@
1
+ export { C as CacheStats, a as Capabilities, b as CompactReport, c as Compactor, d as Config, e as ConfigLoader, f as ContentBlock, g as ContextConfig, E as ErrorHandler, F as FeaturesConfig, I as ImageBlock, h as InputReader, J as JSONSchema, L as LogConfig, i as LogLevel, j as Logger, M as MCPServerConfig, k as MemoryEntry, l as MemoryScope, m as MemoryStore, n as Message, o as MessageRole, p as ModelsDevModel, q as ModelsDevPayload, r as ModelsDevProvider, s as ModelsRegistry, P as PathResolver, t as Permission, u as PermissionDecision, v as PermissionPolicy, w as PluginConfig, x as PromptOption, y as Provider, z as ProviderConfig, A as ProviderError, B as ProviderErrorBody, R as Renderer, D as Request, G as ResolvedModel, H as ResolvedProvider, K as Response, N as ResumedSession, O as RetryPolicy, S as SecretScrubber, Q as SessionData, T as SessionEvent, U as SessionMetadata, V as SessionStore, W as SessionSummary, X as SessionWriter, Y as SkillLoader, Z as SkillManifest, _ as StopReason, $ as StreamEvent, a0 as TextBlock, a1 as TokenCounter, a2 as Tool, a3 as ToolCallContext, a4 as ToolResultBlock, a5 as ToolUseBlock, a6 as ToolsConfig, a7 as TrustPolicy, a8 as Usage, a9 as WireFamily, aa as asBlocks, ab as asText, ac as isImageBlock, ad as isTextBlock, ae as isToolResultBlock, af as isToolUseBlock } from '../secret-scrubber-Dax_Ou_o.js';
2
+ export { A as AddAttachmentInput, a as AgentBridge, b as AgentBridgeConfig, c as Attachment, d as AttachmentKind, e as AttachmentMeta, f as AttachmentRef, g as AttachmentStore, B as BridgeMessage, h as BridgeMessageType, i as BridgeTransport, C as CoordinatorEvents, j as CoordinatorStatus, k as CriticalPathResult, D as DEFAULT_MODES, l as DEFAULT_SPEC_TEMPLATE, m as DoneCondition, E as ENCRYPTED_PREFIX, M as MCPRegistryView, n as Mode, o as ModeConfig, p as ModeManifest, q as ModeStore, r as MultiAgentConfig, s as MultiAgentCoordinator, P as Plugin, t as PluginAPI, u as PluginPipelines, v as ProviderFactory, w as ProviderRegistryView, S as SecretVault, x as SlashCommand, y as SlashCommandRegistryView, z as SpawnResult, F as SpecAnalysis, G as SpecApiEndpoint, H as SpecRequirement, I as SpecSection, J as SpecSectionType, K as SpecStatus, L as SpecTemplate, N as SpecValidationResult, O as Specification, Q as SubagentConfig, R as SubagentContext, T as TaskAssignment, U as TaskDelegation, V as TaskDependency, W as TaskEdge, X as TaskFilter, Y as TaskGraph, Z as TaskNode, _ as TaskPriority, $ as TaskProgress, a0 as TaskResult, a1 as TaskSort, a2 as TaskSpec, a3 as TaskStatus, a4 as TaskType, a5 as ToolBatchResult, a6 as ToolExecution, a7 as ToolExecutionOutput, a8 as ToolExecutorInit, a9 as ToolExecutorOptions, aa as ToolExecutorStrategy, ab as ToolRegistryView, ac as computeTaskProgress, ad as findCriticalPath, ae as topologicalSort } from '../tool-executor-DjnMELMV.js';
3
+ export { B as BuildContext, S as SystemPromptBuilder } from '../system-prompt-BG3nks8P.js';
@@ -0,0 +1,296 @@
1
+ // src/types/blocks.ts
2
+ function isTextBlock(b) {
3
+ return b.type === "text";
4
+ }
5
+ function isToolUseBlock(b) {
6
+ return b.type === "tool_use";
7
+ }
8
+ function isToolResultBlock(b) {
9
+ return b.type === "tool_result";
10
+ }
11
+ function isImageBlock(b) {
12
+ return b.type === "image";
13
+ }
14
+
15
+ // src/types/messages.ts
16
+ function asBlocks(content) {
17
+ return typeof content === "string" ? [{ type: "text", text: content }] : content;
18
+ }
19
+ function asText(content) {
20
+ if (typeof content === "string") return content;
21
+ return content.filter((b) => b.type === "text").map((b) => b.text).join("");
22
+ }
23
+
24
+ // src/types/provider.ts
25
+ var ProviderError = class extends Error {
26
+ status;
27
+ retryable;
28
+ providerId;
29
+ body;
30
+ cause;
31
+ constructor(message, status, retryable, providerId, opts = {}) {
32
+ super(message);
33
+ this.name = "ProviderError";
34
+ this.status = status;
35
+ this.retryable = retryable;
36
+ this.providerId = providerId;
37
+ this.body = opts.body;
38
+ this.cause = opts.cause;
39
+ }
40
+ /**
41
+ * Render a one-line, user-facing description. Designed for the CLI/TUI
42
+ * status line and the agent's retry warning. Avoids dumping raw JSON
43
+ * (which is what users see today when a 529 lands and the log message
44
+ * includes the full `{"type":"error",...}` body).
45
+ *
46
+ * Examples:
47
+ * "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
48
+ * "openai rate limited (429): Retry after 12s"
49
+ * "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
50
+ * "groq HTTP 500 (server error)"
51
+ */
52
+ describe() {
53
+ const kind = describeStatus(this.status, this.body?.type);
54
+ const head = `${this.providerId} ${kind}`;
55
+ const detail = this.body?.message?.trim();
56
+ const reqId = this.body?.requestId ? ` [req ${this.body.requestId.slice(0, 16)}${this.body.requestId.length > 16 ? "\u2026" : ""}]` : "";
57
+ if (detail && detail.length > 0) {
58
+ return `${head}: ${truncate(detail, 240)}${reqId}`;
59
+ }
60
+ return `${head}${reqId}`;
61
+ }
62
+ };
63
+ function describeStatus(status, type) {
64
+ if (status === 0) return "network error";
65
+ if (type === "overloaded_error" || status === 529) return `overloaded (${status})`;
66
+ if (type === "rate_limit_error" || status === 429) return `rate limited (${status})`;
67
+ if (type === "authentication_error" || status === 401) return `auth failed (${status})`;
68
+ if (type === "permission_error" || status === 403) return `forbidden (${status})`;
69
+ if (type === "not_found_error" || status === 404) return `not found (${status})`;
70
+ if (type === "invalid_request_error" || status === 400) return `invalid request (${status})`;
71
+ if (status === 408) return `timeout (${status})`;
72
+ if (status >= 500 && status < 600) return `HTTP ${status} (server error)`;
73
+ if (type) return `${type} (${status})`;
74
+ return `HTTP ${status}`;
75
+ }
76
+ function truncate(s, n) {
77
+ return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
78
+ }
79
+
80
+ // src/types/secret-vault.ts
81
+ var ENCRYPTED_PREFIX = "enc:v1:";
82
+
83
+ // src/types/mode.ts
84
+ var DEFAULT_MODES = [
85
+ {
86
+ id: "default",
87
+ name: "Default",
88
+ description: "General-purpose coding assistant",
89
+ prompt: "",
90
+ tags: ["general"]
91
+ },
92
+ {
93
+ id: "code-reviewer",
94
+ name: "Code Reviewer",
95
+ description: "Focus on code quality, best practices, and potential bugs",
96
+ prompt: `## Code Reviewer Mode
97
+
98
+ When reviewing code:
99
+ - Look for potential bugs, race conditions, and edge cases
100
+ - Check for security vulnerabilities (SQL injection, XSS, CSRF, etc.)
101
+ - Evaluate error handling completeness
102
+ - Assess code readability and maintainability
103
+ - Check for performance anti-patterns
104
+ - Verify test coverage for critical paths
105
+ - Ensure naming conventions are followed`,
106
+ tags: ["review", "quality", "security"],
107
+ toolPreferences: ["read", "grep", "git", "diff", "test"]
108
+ },
109
+ {
110
+ id: "code-auditor",
111
+ name: "Code Auditor",
112
+ description: "Security-focused code analysis",
113
+ prompt: `## Code Auditor Mode
114
+
115
+ When auditing code for security:
116
+ - Identify injection vulnerabilities (SQL, Command, XSS, LDAP)
117
+ - Check authentication and authorization patterns
118
+ - Look for sensitive data exposure (secrets, PII in logs)
119
+ - Verify cryptographic implementations
120
+ - Check for insecure dependencies or configurations
121
+ - Assess input validation and output encoding
122
+ - Look for timing attacks and information leakage`,
123
+ tags: ["security", "audit", "compliance"],
124
+ toolPreferences: ["grep", "read", "audit", "bash"]
125
+ },
126
+ {
127
+ id: "architect",
128
+ name: "Software Architect",
129
+ description: "Design patterns, scalability, and system design",
130
+ prompt: `## Architect Mode
131
+
132
+ When designing or reviewing architecture:
133
+ - Evaluate scalability and future growth
134
+ - Check for appropriate design patterns
135
+ - Assess coupling and cohesion
136
+ - Look forSOLID principle violations
137
+ - Evaluate data modeling decisions
138
+ - Check for eventual consistency issues
139
+ - Assess API design and contract stability
140
+ - Consider operational aspects (monitoring, logging, deployment)`,
141
+ tags: ["architecture", "design", "scalability"],
142
+ toolPreferences: ["read", "glob", "tree", "diff"]
143
+ },
144
+ {
145
+ id: "debugger",
146
+ name: "Debugger",
147
+ description: "Root cause analysis and error investigation",
148
+ prompt: `## Debugger Mode
149
+
150
+ When investigating bugs:
151
+ - Reproduce the issue with minimal steps
152
+ - Check error messages and stack traces thoroughly
153
+ - Look for related logs and historical context
154
+ - Verify assumptions about data flow
155
+ - Check for race conditions in async code
156
+ - Validate environment and configuration
157
+ - Use binary search to isolate the root cause
158
+ - Verify fixes with tests before considering done`,
159
+ tags: ["debug", "investigation", "error-resolution"],
160
+ toolPreferences: ["read", "grep", "bash", "logs", "test"]
161
+ },
162
+ {
163
+ id: "tester",
164
+ name: "QA Engineer",
165
+ description: "Test coverage, edge cases, and quality assurance",
166
+ prompt: `## Tester Mode
167
+
168
+ When testing or writing tests:
169
+ - Cover happy path and error paths equally
170
+ - Think about edge cases and boundary conditions
171
+ - Check for missing null/undefined handling tests
172
+ - Verify error messages are tested
173
+ - Look for race condition tests in async code
174
+ - Assess mutation testing opportunities
175
+ - Check for integration test gaps
176
+ - Verify test isolation and cleanup`,
177
+ tags: ["testing", "qa", "quality"],
178
+ toolPreferences: ["read", "grep", "test", "bash"]
179
+ },
180
+ {
181
+ id: "devops",
182
+ name: "DevOps Engineer",
183
+ description: "Infrastructure, deployment, and operations",
184
+ prompt: `## DevOps Mode
185
+
186
+ When working on infrastructure:
187
+ - Check for containerization and deployment readiness
188
+ - Verify CI/CD pipeline configurations
189
+ - Assess monitoring and alerting setup
190
+ - Look for health check endpoints
191
+ - Check for graceful shutdown handling
192
+ - Verify backup and disaster recovery plans
193
+ - Assess secrets management
194
+ - Check for resource limits and quotas`,
195
+ tags: ["devops", "infrastructure", "operations"],
196
+ toolPreferences: ["read", "bash", "grep", "logs", "git"]
197
+ },
198
+ {
199
+ id: "refactorer",
200
+ name: "Refactorer",
201
+ description: "Code improvement and modernization",
202
+ prompt: `## Refactorer Mode
203
+
204
+ When refactoring code:
205
+ - Maintain existing behavior \u2014 tests must pass before and after
206
+ - Make one change at a time, verify after each
207
+ - Prefer small, focused commits
208
+ - Preserve API contracts unless explicitly changing
209
+ - Remove dead code and comments
210
+ - Improve naming as you go
211
+ - Don't mix formatting changes with logic changes
212
+ - Keep performance in mind \u2014 don't regress`,
213
+ tags: ["refactor", "modernization", "improvement"],
214
+ toolPreferences: ["read", "edit", "test", "git", "grep"]
215
+ }
216
+ ];
217
+
218
+ // src/types/spec.ts
219
+ var DEFAULT_SPEC_TEMPLATE = {
220
+ id: "default",
221
+ name: "Default Feature Spec",
222
+ description: "Standard template for feature specifications",
223
+ sections: [
224
+ { type: "overview", title: "Overview", level: 1 },
225
+ { type: "requirements", title: "Requirements", level: 1 },
226
+ { type: "architecture", title: "Architecture", level: 1 },
227
+ { type: "api", title: "API Design", level: 1 },
228
+ { type: "data", title: "Data Model", level: 1 },
229
+ { type: "security", title: "Security", level: 1 },
230
+ { type: "acceptance", title: "Acceptance Criteria", level: 1 }
231
+ ],
232
+ defaultRequirements: [
233
+ { type: "functional", priority: "high", acceptanceCriteria: [], blockedBy: [], implements: [] },
234
+ { type: "non-functional", priority: "medium", acceptanceCriteria: [], blockedBy: [], implements: [] }
235
+ ]
236
+ };
237
+
238
+ // src/types/task-graph.ts
239
+ function computeTaskProgress(graph) {
240
+ const nodes = Array.from(graph.nodes.values());
241
+ const total = nodes.length;
242
+ const completed = nodes.filter((n) => n.status === "completed").length;
243
+ const pending = nodes.filter((n) => n.status === "pending").length;
244
+ const inProgress = nodes.filter((n) => n.status === "in_progress").length;
245
+ const blocked = nodes.filter((n) => n.status === "blocked").length;
246
+ const failed = nodes.filter((n) => n.status === "failed").length;
247
+ const review = nodes.filter((n) => n.status === "review").length;
248
+ const estimatedHours = nodes.reduce((sum, n) => sum + (n.estimateHours ?? 0), 0);
249
+ const actualHours = nodes.reduce((sum, n) => sum + (n.actualHours ?? 0), 0);
250
+ return {
251
+ total,
252
+ pending,
253
+ inProgress,
254
+ blocked,
255
+ failed,
256
+ review,
257
+ completed,
258
+ percentComplete: total > 0 ? Math.round(completed / total * 100) : 0,
259
+ estimatedHours,
260
+ actualHours
261
+ };
262
+ }
263
+ function findCriticalPath(graph) {
264
+ const nodes = Array.from(graph.nodes.values());
265
+ const criticalNodes = nodes.filter((n) => n.priority === "critical");
266
+ const bottleneckTasks = criticalNodes.filter((n) => graph.edges.some((e) => e.to === n.id && e.type === "depends_on")).map((n) => n.id);
267
+ const totalEstimateHours = criticalNodes.reduce((sum, n) => sum + (n.estimateHours ?? 0), 0);
268
+ return {
269
+ taskIds: criticalNodes.map((n) => n.id),
270
+ totalEstimateHours,
271
+ bottleneckTasks
272
+ };
273
+ }
274
+ function topologicalSort(graph) {
275
+ const visited = /* @__PURE__ */ new Set();
276
+ const result = [];
277
+ function visit(id) {
278
+ if (visited.has(id)) return;
279
+ visited.add(id);
280
+ const node = graph.nodes.get(id);
281
+ if (!node) return;
282
+ const outgoing = graph.edges.filter((e) => e.from === id);
283
+ for (const edge of outgoing) {
284
+ visit(edge.to);
285
+ }
286
+ result.push(id);
287
+ }
288
+ for (const rootId of graph.rootNodes) {
289
+ visit(rootId);
290
+ }
291
+ return result;
292
+ }
293
+
294
+ export { DEFAULT_MODES, DEFAULT_SPEC_TEMPLATE, ENCRYPTED_PREFIX, ProviderError, asBlocks, asText, computeTaskProgress, findCriticalPath, isImageBlock, isTextBlock, isToolResultBlock, isToolUseBlock, topologicalSort };
295
+ //# sourceMappingURL=index.js.map
296
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/blocks.ts","../../src/types/messages.ts","../../src/types/provider.ts","../../src/types/secret-vault.ts","../../src/types/mode.ts","../../src/types/spec.ts","../../src/types/task-graph.ts"],"names":[],"mappings":";AAuCO,SAAS,YAAY,CAAA,EAAiC;AAC3D,EAAA,OAAO,EAAE,IAAA,KAAS,MAAA;AACpB;AACO,SAAS,eAAe,CAAA,EAAoC;AACjE,EAAA,OAAO,EAAE,IAAA,KAAS,UAAA;AACpB;AACO,SAAS,kBAAkB,C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d;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["export interface TextBlock {\n type: 'text';\n text: string;\n cache_control?: { type: 'ephemeral' };\n}\n\nexport interface ToolUseBlock {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n}\n\nexport interface ToolResultBlock {\n type: 'tool_result';\n tool_use_id: string;\n /**\n * The original tool name. Useful for providers like Google Gemini that\n * need the tool name in `functionResponse.name` — the tool_use_id is\n * only a session-local identifier and is not stable across replays.\n * Always set by ToolExecutor; may be absent on manually-constructed blocks.\n */\n name?: string;\n content: string;\n is_error?: boolean;\n}\n\nexport interface ImageBlock {\n type: 'image';\n source: {\n type: 'base64' | 'url';\n media_type?: string;\n data?: string;\n url?: string;\n };\n}\n\nexport type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock | ImageBlock;\n\nexport function isTextBlock(b: ContentBlock): b is TextBlock {\n return b.type === 'text';\n}\nexport function isToolUseBlock(b: ContentBlock): b is ToolUseBlock {\n return b.type === 'tool_use';\n}\nexport function isToolResultBlock(b: ContentBlock): b is ToolResultBlock {\n return b.type === 'tool_result';\n}\nexport function isImageBlock(b: ContentBlock): b is ImageBlock {\n return b.type === 'image';\n}\n","import type { ContentBlock } from './blocks.js';\n\nexport type MessageRole = 'user' | 'assistant' | 'system';\n\nexport interface Message {\n role: MessageRole;\n content: string | ContentBlock[];\n}\n\nexport function asBlocks(content: string | ContentBlock[]): ContentBlock[] {\n return typeof content === 'string' ? [{ type: 'text', text: content }] : content;\n}\n\nexport function asText(content: string | ContentBlock[]): string {\n if (typeof content === 'string') return content;\n return content\n .filter((b) => b.type === 'text')\n .map((b) => (b as { text: string }).text)\n .join('');\n}\n","import type { ContentBlock, TextBlock } from './blocks.js';\nimport type { Message } from './messages.js';\nimport type { Tool } from './tool.js';\n\nexport interface Usage {\n input: number;\n output: number;\n cacheRead?: number;\n cacheWrite?: number;\n}\n\nexport interface Capabilities {\n tools: boolean;\n parallelTools: boolean;\n vision: boolean;\n streaming: boolean;\n promptCache: boolean;\n systemPrompt: boolean;\n jsonMode: boolean;\n maxContext: number;\n cacheControl: 'native' | 'auto' | 'none';\n}\n\nexport interface Request {\n model: string;\n system?: TextBlock[];\n messages: Message[];\n tools?: Tool[];\n maxTokens: number;\n temperature?: number;\n topP?: number;\n stopSequences?: string[];\n toolChoice?: 'auto' | 'required' | 'none' | { type: 'tool'; name: string };\n}\n\nexport type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'refusal';\n\nexport interface Response {\n content: ContentBlock[];\n stopReason: StopReason;\n usage: Usage;\n model: string;\n}\n\nexport type StreamEvent =\n | { type: 'message_start'; model: string }\n | { type: 'content_block_start'; kind: 'text' | 'tool_use'; id?: string; name?: string }\n | { type: 'content_block_stop'; index: number }\n | { type: 'text_delta'; text: string }\n | { type: 'tool_use_start'; id: string; name: string }\n | { type: 'tool_use_input_delta'; id: string; partial: string }\n | { type: 'tool_use_stop'; id: string; input: unknown }\n | { type: 'message_stop'; stopReason: StopReason; usage: Usage };\n\nexport interface Provider {\n readonly id: string;\n readonly capabilities: Capabilities;\n /** Canonical streaming entry point. `complete()` defaults to a wrapper that\n * aggregates this stream — providers may override for non-streaming wires. */\n stream(req: Request, opts: { signal: AbortSignal }): AsyncIterable<StreamEvent>;\n complete(req: Request, opts: { signal: AbortSignal }): Promise<Response>;\n}\n\n/**\n * Structured body parsed from a provider's HTTP error response. Populated\n * best-effort: providers return JSON shaped differently (Anthropic uses\n * `{error: {type, message}}`, OpenAI uses `{error: {message, code}}`,\n * Google uses `{error: {status, message}}`), so the fields here are the\n * intersection that's usable for rendering and routing.\n */\nexport interface ProviderErrorBody {\n /** Provider-specific kind, e.g. \"overloaded_error\", \"rate_limit_error\", \"invalid_request_error\". */\n type?: string;\n /** Human-readable explanation from the provider. */\n message?: string;\n /** Provider request id, when present in the body or headers. */\n requestId?: string;\n /** Parsed Retry-After header (or equivalent body hint) in milliseconds. */\n retryAfterMs?: number;\n /** The raw response body (truncated), kept for debugging. */\n raw?: string;\n}\n\nexport class ProviderError extends Error {\n public readonly status: number;\n public readonly retryable: boolean;\n public readonly providerId: string;\n public readonly body?: ProviderErrorBody;\n public override readonly cause?: unknown;\n\n constructor(\n message: string,\n status: number,\n retryable: boolean,\n providerId: string,\n opts: { body?: ProviderErrorBody; cause?: unknown } = {},\n ) {\n super(message);\n this.name = 'ProviderError';\n this.status = status;\n this.retryable = retryable;\n this.providerId = providerId;\n this.body = opts.body;\n this.cause = opts.cause;\n }\n\n /**\n * Render a one-line, user-facing description. Designed for the CLI/TUI\n * status line and the agent's retry warning. Avoids dumping raw JSON\n * (which is what users see today when a 529 lands and the log message\n * includes the full `{\"type\":\"error\",...}` body).\n *\n * Examples:\n * \"minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]\"\n * \"openai rate limited (429): Retry after 12s\"\n * \"anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'\"\n * \"groq HTTP 500 (server error)\"\n */\n describe(): string {\n const kind = describeStatus(this.status, this.body?.type);\n const head = `${this.providerId} ${kind}`;\n const detail = this.body?.message?.trim();\n const reqId = this.body?.requestId\n ? ` [req ${this.body.requestId.slice(0, 16)}${this.body.requestId.length > 16 ? '…' : ''}]`\n : '';\n if (detail && detail.length > 0) {\n return `${head}: ${truncate(detail, 240)}${reqId}`;\n }\n return `${head}${reqId}`;\n }\n}\n\nfunction describeStatus(status: number, type?: string): string {\n if (status === 0) return 'network error';\n if (type === 'overloaded_error' || status === 529) return `overloaded (${status})`;\n if (type === 'rate_limit_error' || status === 429) return `rate limited (${status})`;\n if (type === 'authentication_error' || status === 401) return `auth failed (${status})`;\n if (type === 'permission_error' || status === 403) return `forbidden (${status})`;\n if (type === 'not_found_error' || status === 404) return `not found (${status})`;\n if (type === 'invalid_request_error' || status === 400) return `invalid request (${status})`;\n if (status === 408) return `timeout (${status})`;\n if (status >= 500 && status < 600) return `HTTP ${status} (server error)`;\n if (type) return `${type} (${status})`;\n return `HTTP ${status}`;\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length <= n ? s : `${s.slice(0, n - 1)}…`;\n}\n","/**\n * SecretVault encrypts secrets-at-rest in config files. The wire format is\n * `enc:v1:<base64-iv>:<base64-tag>:<base64-ciphertext>`. Plaintext strings\n * (those that do not match this prefix) are passed through unchanged so that\n * existing configs and env-var-derived values keep working.\n *\n * The vault is intentionally NOT designed to defeat a determined local\n * attacker who can read both the config file and the key file — that level\n * of secrecy needs the OS keychain. The goal is to keep keys from being\n * visible in screen shares, accidental log captures, and `cat config.json`\n * over someone's shoulder.\n */\nexport interface SecretVault {\n encrypt(plaintext: string): string;\n decrypt(value: string): string;\n isEncrypted(value: string): boolean;\n}\n\nexport const ENCRYPTED_PREFIX = 'enc:v1:';\n","export interface Mode {\n id: string;\n name: string;\n description: string;\n /** Additional prompt text injected into system prompt when mode is active */\n prompt: string;\n /** Tags for tool_search filtering */\n tags?: string[];\n /** Tools that should be prioritized/highlighted when this mode is active */\n toolPreferences?: string[];\n}\n\nexport interface ModeManifest {\n modes: Mode[];\n defaultMode?: string;\n}\n\nexport interface ModeStore {\n getActiveMode(): Promise<Mode | null>;\n setActiveMode(modeId: string | null): Promise<void>;\n listModes(): Promise<Mode[]>;\n getMode(modeId: string): Promise<Mode | null>;\n}\n\nexport interface ModeConfig {\n directory: string;\n}\n\nexport const DEFAULT_MODES: Mode[] = [\n {\n id: 'default',\n name: 'Default',\n description: 'General-purpose coding assistant',\n prompt: '',\n tags: ['general'],\n },\n {\n id: 'code-reviewer',\n name: 'Code Reviewer',\n description: 'Focus on code quality, best practices, and potential bugs',\n prompt: `## Code Reviewer Mode\n\nWhen reviewing code:\n- Look for potential bugs, race conditions, and edge cases\n- Check for security vulnerabilities (SQL injection, XSS, CSRF, etc.)\n- Evaluate error handling completeness\n- Assess code readability and maintainability\n- Check for performance anti-patterns\n- Verify test coverage for critical paths\n- Ensure naming conventions are followed`,\n tags: ['review', 'quality', 'security'],\n toolPreferences: ['read', 'grep', 'git', 'diff', 'test'],\n },\n {\n id: 'code-auditor',\n name: 'Code Auditor',\n description: 'Security-focused code analysis',\n prompt: `## Code Auditor Mode\n\nWhen auditing code for security:\n- Identify injection vulnerabilities (SQL, Command, XSS, LDAP)\n- Check authentication and authorization patterns\n- Look for sensitive data exposure (secrets, PII in logs)\n- Verify cryptographic implementations\n- Check for insecure dependencies or configurations\n- Assess input validation and output encoding\n- Look for timing attacks and information leakage`,\n tags: ['security', 'audit', 'compliance'],\n toolPreferences: ['grep', 'read', 'audit', 'bash'],\n },\n {\n id: 'architect',\n name: 'Software Architect',\n description: 'Design patterns, scalability, and system design',\n prompt: `## Architect Mode\n\nWhen designing or reviewing architecture:\n- Evaluate scalability and future growth\n- Check for appropriate design patterns\n- Assess coupling and cohesion\n- Look forSOLID principle violations\n- Evaluate data modeling decisions\n- Check for eventual consistency issues\n- Assess API design and contract stability\n- Consider operational aspects (monitoring, logging, deployment)`,\n tags: ['architecture', 'design', 'scalability'],\n toolPreferences: ['read', 'glob', 'tree', 'diff'],\n },\n {\n id: 'debugger',\n name: 'Debugger',\n description: 'Root cause analysis and error investigation',\n prompt: `## Debugger Mode\n\nWhen investigating bugs:\n- Reproduce the issue with minimal steps\n- Check error messages and stack traces thoroughly\n- Look for related logs and historical context\n- Verify assumptions about data flow\n- Check for race conditions in async code\n- Validate environment and configuration\n- Use binary search to isolate the root cause\n- Verify fixes with tests before considering done`,\n tags: ['debug', 'investigation', 'error-resolution'],\n toolPreferences: ['read', 'grep', 'bash', 'logs', 'test'],\n },\n {\n id: 'tester',\n name: 'QA Engineer',\n description: 'Test coverage, edge cases, and quality assurance',\n prompt: `## Tester Mode\n\nWhen testing or writing tests:\n- Cover happy path and error paths equally\n- Think about edge cases and boundary conditions\n- Check for missing null/undefined handling tests\n- Verify error messages are tested\n- Look for race condition tests in async code\n- Assess mutation testing opportunities\n- Check for integration test gaps\n- Verify test isolation and cleanup`,\n tags: ['testing', 'qa', 'quality'],\n toolPreferences: ['read', 'grep', 'test', 'bash'],\n },\n {\n id: 'devops',\n name: 'DevOps Engineer',\n description: 'Infrastructure, deployment, and operations',\n prompt: `## DevOps Mode\n\nWhen working on infrastructure:\n- Check for containerization and deployment readiness\n- Verify CI/CD pipeline configurations\n- Assess monitoring and alerting setup\n- Look for health check endpoints\n- Check for graceful shutdown handling\n- Verify backup and disaster recovery plans\n- Assess secrets management\n- Check for resource limits and quotas`,\n tags: ['devops', 'infrastructure', 'operations'],\n toolPreferences: ['read', 'bash', 'grep', 'logs', 'git'],\n },\n {\n id: 'refactorer',\n name: 'Refactorer',\n description: 'Code improvement and modernization',\n prompt: `## Refactorer Mode\n\nWhen refactoring code:\n- Maintain existing behavior — tests must pass before and after\n- Make one change at a time, verify after each\n- Prefer small, focused commits\n- Preserve API contracts unless explicitly changing\n- Remove dead code and comments\n- Improve naming as you go\n- Don't mix formatting changes with logic changes\n- Keep performance in mind — don't regress`,\n tags: ['refactor', 'modernization', 'improvement'],\n toolPreferences: ['read', 'edit', 'test', 'git', 'grep'],\n },\n];","export type SpecStatus = 'draft' | 'review' | 'approved' | 'implemented' | 'deprecated';\nexport type SpecSectionType = 'overview' | 'requirements' | 'architecture' | 'api' | 'data' | 'security' | 'acceptance';\n\nexport interface SpecSection {\n type: SpecSectionType;\n title: string;\n content: string;\n level: number;\n children?: SpecSection[];\n}\n\nexport interface SpecRequirement {\n id: string;\n type: 'functional' | 'non-functional' | 'security' | 'performance' | 'ux';\n priority: 'critical' | 'high' | 'medium' | 'low';\n description: string;\n acceptanceCriteria: string[];\n blockedBy?: string[];\n implements?: string[];\n}\n\nexport interface SpecApiEndpoint {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n description: string;\n request?: Record<string, unknown>;\n response?: Record<string, unknown>;\n auth?: boolean;\n}\n\nexport interface Specification {\n id: string;\n title: string;\n version: string;\n status: SpecStatus;\n overview: string;\n sections: SpecSection[];\n requirements: SpecRequirement[];\n apiEndpoints?: SpecApiEndpoint[];\n dependencies?: string[];\n createdAt: number;\n updatedAt: number;\n metadata?: Record<string, unknown>;\n}\n\nexport interface SpecAnalysis {\n specId: string;\n completeness: number; // 0-100\n coverage: {\n requirements: number;\n apiEndpoints: number;\n edgeCases: number;\n errorHandling: number;\n };\n gaps: string[];\n risks: { requirement: string; risk: string; severity: 'high' | 'medium' | 'low' }[];\n suggestions: string[];\n}\n\nexport interface SpecValidationResult {\n valid: boolean;\n errors: { path: string; message: string }[];\n warnings: { path: string; message: string }[];\n}\n\nexport interface SpecTemplate {\n id: string;\n name: string;\n description: string;\n sections: Omit<SpecSection, 'content'>[];\n defaultRequirements: Omit<SpecRequirement, 'id' | 'description'>[];\n}\n\nexport const DEFAULT_SPEC_TEMPLATE: SpecTemplate = {\n id: 'default',\n name: 'Default Feature Spec',\n description: 'Standard template for feature specifications',\n sections: [\n { type: 'overview', title: 'Overview', level: 1 },\n { type: 'requirements', title: 'Requirements', level: 1 },\n { type: 'architecture', title: 'Architecture', level: 1 },\n { type: 'api', title: 'API Design', level: 1 },\n { type: 'data', title: 'Data Model', level: 1 },\n { type: 'security', title: 'Security', level: 1 },\n { type: 'acceptance', title: 'Acceptance Criteria', level: 1 },\n ],\n defaultRequirements: [\n { type: 'functional', priority: 'high', acceptanceCriteria: [], blockedBy: [], implements: [] },\n { type: 'non-functional', priority: 'medium', acceptanceCriteria: [], blockedBy: [], implements: [] },\n ],\n};","export type TaskStatus = 'pending' | 'in_progress' | 'blocked' | 'failed' | 'review' | 'completed';\nexport type TaskPriority = 'critical' | 'high' | 'medium' | 'low';\nexport type TaskType = 'feature' | 'bugfix' | 'refactor' | 'docs' | 'test' | 'chore';\n\nexport interface TaskNode {\n id: string;\n title: string;\n description: string;\n type: TaskType;\n priority: TaskPriority;\n status: TaskStatus;\n assignee?: string;\n estimateHours?: number;\n actualHours?: number;\n tags?: string[];\n specRequirementId?: string;\n parentId?: string;\n children?: string[];\n createdAt: number;\n updatedAt: number;\n completedAt?: number;\n metadata?: Record<string, unknown>;\n}\n\nexport interface TaskEdge {\n id: string;\n from: string;\n to: string;\n type: 'blocks' | 'depends_on' | 'relates_to' | 'implements';\n weight?: number;\n}\n\nexport interface TaskGraph {\n id: string;\n specId: string;\n title: string;\n nodes: Map<string, TaskNode>;\n edges: TaskEdge[];\n rootNodes: string[];\n createdAt: number;\n updatedAt: number;\n}\n\nexport interface TaskDependency {\n taskId: string;\n blockedBy: string[];\n blocking: string[];\n}\n\nexport interface TaskAssignment {\n taskId: string;\n assignee: string;\n assignedAt: number;\n}\n\nexport interface TaskProgress {\n total: number;\n pending: number;\n inProgress: number;\n blocked: number;\n failed: number;\n review: number;\n completed: number;\n percentComplete: number;\n estimatedHours: number;\n actualHours: number;\n}\n\nexport interface TaskFilter {\n status?: TaskStatus[];\n priority?: TaskPriority[];\n type?: TaskType[];\n assignee?: string[];\n tags?: string[];\n specRequirementId?: string;\n}\n\nexport interface TaskSort {\n field: 'priority' | 'createdAt' | 'updatedAt' | 'status';\n direction: 'asc' | 'desc';\n}\n\nexport interface CriticalPathResult {\n taskIds: string[];\n totalEstimateHours: number;\n bottleneckTasks: string[];\n}\n\nexport function computeTaskProgress(graph: TaskGraph): TaskProgress {\n const nodes = Array.from(graph.nodes.values());\n const total = nodes.length;\n const completed = nodes.filter((n) => n.status === 'completed').length;\n const pending = nodes.filter((n) => n.status === 'pending').length;\n const inProgress = nodes.filter((n) => n.status === 'in_progress').length;\n const blocked = nodes.filter((n) => n.status === 'blocked').length;\n const failed = nodes.filter((n) => n.status === 'failed').length;\n const review = nodes.filter((n) => n.status === 'review').length;\n\n const estimatedHours = nodes.reduce((sum, n) => sum + (n.estimateHours ?? 0), 0);\n const actualHours = nodes.reduce((sum, n) => sum + (n.actualHours ?? 0), 0);\n\n return {\n total,\n pending,\n inProgress,\n blocked,\n failed,\n review,\n completed,\n percentComplete: total > 0 ? Math.round((completed / total) * 100) : 0,\n estimatedHours,\n actualHours,\n };\n}\n\nexport function findCriticalPath(graph: TaskGraph): CriticalPathResult {\n const nodes = Array.from(graph.nodes.values());\n const criticalNodes = nodes.filter((n) => n.priority === 'critical');\n const bottleneckTasks = criticalNodes\n .filter((n) => graph.edges.some((e) => e.to === n.id && e.type === 'depends_on'))\n .map((n) => n.id);\n\n const totalEstimateHours = criticalNodes.reduce((sum, n) => sum + (n.estimateHours ?? 0), 0);\n\n return {\n taskIds: criticalNodes.map((n) => n.id),\n totalEstimateHours,\n bottleneckTasks,\n };\n}\n\nexport function topologicalSort(graph: TaskGraph): string[] {\n const visited = new Set<string>();\n const result: string[] = [];\n\n function visit(id: string) {\n if (visited.has(id)) return;\n visited.add(id);\n\n const node = graph.nodes.get(id);\n if (!node) return;\n\n const outgoing = graph.edges.filter((e) => e.from === id);\n for (const edge of outgoing) {\n visit(edge.to);\n }\n\n result.push(id);\n }\n\n for (const rootId of graph.rootNodes) {\n visit(rootId);\n }\n\n return result;\n}"]}
@@ -0,0 +1,88 @@
1
+ export { W as WstackPathOptions, a as WstackPaths, p as projectHash, r as resolveWstackPaths } from '../wstack-paths-D24ynAz1.js';
2
+
3
+ interface AtomicWriteOptions {
4
+ mode?: number;
5
+ encoding?: BufferEncoding;
6
+ }
7
+ declare function atomicWrite(targetPath: string, content: string | Uint8Array, opts?: AtomicWriteOptions): Promise<void>;
8
+ declare function ensureDir(dir: string): Promise<void>;
9
+
10
+ interface SafeParseResult<T> {
11
+ ok: boolean;
12
+ value?: T;
13
+ error?: string;
14
+ }
15
+ declare function safeParse<T = unknown>(input: string, maxBytes?: number): SafeParseResult<T>;
16
+ declare function safeStringify(value: unknown, pretty?: boolean): string;
17
+ /** Attempt to parse JSON5-style input and return a valid JSON string.
18
+ * Handles trailing commas, single-line comments, and unquoted keys
19
+ * that are common in provider output.
20
+ */
21
+ declare function sanitizeJsonString(s: string): string;
22
+
23
+ type NewlineStyle = 'lf' | 'crlf' | 'cr';
24
+ declare function detectNewlineStyle(text: string): NewlineStyle;
25
+ declare function toStyle(text: string, style: NewlineStyle): string;
26
+ declare function normalizeToLf(text: string): string;
27
+
28
+ declare const color: {
29
+ reset: (s: string) => string;
30
+ bold: (s: string) => string;
31
+ dim: (s: string) => string;
32
+ italic: (s: string) => string;
33
+ underline: (s: string) => string;
34
+ red: (s: string) => string;
35
+ green: (s: string) => string;
36
+ yellow: (s: string) => string;
37
+ blue: (s: string) => string;
38
+ magenta: (s: string) => string;
39
+ cyan: (s: string) => string;
40
+ gray: (s: string) => string;
41
+ amber: (s: string) => string;
42
+ pink: (s: string) => string;
43
+ bgRed: (s: string) => string;
44
+ bgGreen: (s: string) => string;
45
+ };
46
+ declare function stripAnsi(s: string): string;
47
+
48
+ /**
49
+ * Minimal glob matcher for trust patterns.
50
+ * Supports: *, **, ?, character classes [abc], [a-z], negation [!...] or [^...].
51
+ *
52
+ * Both `[!...]` (shell glob convention) and `[^...]` (regex convention) are
53
+ * accepted because users coming from either world will reach for what they
54
+ * know; rejecting one silently fails open in a security-sensitive context.
55
+ */
56
+ declare function compileGlob(pattern: string): RegExp;
57
+ declare function matchGlob(pattern: string, input: string): boolean;
58
+ declare function matchAny(patterns: string[], input: string): boolean;
59
+
60
+ /**
61
+ * Myers diff with unified-format output. No external dependencies.
62
+ * Operates on arrays of lines (newline-terminated or stripped).
63
+ */
64
+ interface UnifiedDiffOptions {
65
+ context?: number;
66
+ fromFile?: string;
67
+ toFile?: string;
68
+ }
69
+ declare function unifiedDiff(oldText: string, newText: string, opts?: UnifiedDiffOptions): string;
70
+
71
+ /**
72
+ * Tool output serialization utilities.
73
+ * Extracted from Agent.executeTools to allow reuse and consistent output handling.
74
+ */
75
+ interface ToolOutputSerializerOptions {
76
+ perIterationOutputCapBytes?: number;
77
+ estimator?: (text: string) => number;
78
+ }
79
+ declare function createToolOutputSerializer(opts?: ToolOutputSerializerOptions): {
80
+ serialize: (value: unknown) => string;
81
+ enforceCap: (text: string, remainingBudget: number) => {
82
+ text: string;
83
+ newBudget: number;
84
+ };
85
+ capBytes: number;
86
+ };
87
+
88
+ export { type AtomicWriteOptions, type NewlineStyle, type SafeParseResult, type ToolOutputSerializerOptions, type UnifiedDiffOptions, atomicWrite, color, compileGlob, createToolOutputSerializer, detectNewlineStyle, ensureDir, matchAny, matchGlob, normalizeToLf, safeParse, safeStringify, sanitizeJsonString, stripAnsi, toStyle, unifiedDiff };