staklink 0.3.65 → 0.3.66
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/dist/proxy-server.cjs +2 -1
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
- package/notes/big-json.json +0 -7
- package/notes/large.json +0 -7
- package/notes/resume.json +0 -7
package/dist/proxy-server.cjs
CHANGED
|
@@ -61229,7 +61229,7 @@ var SSEManager = class {
|
|
|
61229
61229
|
var sseManager = new SSEManager();
|
|
61230
61230
|
|
|
61231
61231
|
// src/proxy/version.ts
|
|
61232
|
-
var VERSION = "0.3.
|
|
61232
|
+
var VERSION = "0.3.66";
|
|
61233
61233
|
|
|
61234
61234
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61235
61235
|
var byteToHex = [];
|
|
@@ -121489,6 +121489,7 @@ function goose_env(apiKey) {
|
|
|
121489
121489
|
};
|
|
121490
121490
|
}
|
|
121491
121491
|
async function runAgent({ prompt, apiKey, cwd, system_prompt, session, resume, summarize }) {
|
|
121492
|
+
createGooseConfig();
|
|
121492
121493
|
const env = goose_env(apiKey);
|
|
121493
121494
|
console.log("RUN goose with env", env);
|
|
121494
121495
|
const cleanPrompt = sanitizeShellArg(prompt);
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10967,7 +10967,7 @@ var glob = Object.assign(glob_, {
|
|
|
10967
10967
|
glob.glob = glob;
|
|
10968
10968
|
|
|
10969
10969
|
// src/proxy/version.ts
|
|
10970
|
-
var VERSION = "0.3.
|
|
10970
|
+
var VERSION = "0.3.66";
|
|
10971
10971
|
|
|
10972
10972
|
// src/cli.ts
|
|
10973
10973
|
var STAKLINK_PROXY = "staklink-proxy";
|
package/package.json
CHANGED
package/notes/big-json.json
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"prompt": "<initial_request>1. Add SharedConversation model to prisma/schema.prisma with fields: id (cuid), workspaceId (FK to Workspace), userId (FK to User), title (nullable, auto-generated from first user message), messages (Json - serialized Message[] array), provenanceData (Json, nullable), followUpQuestions (Json), createdAt, updatedAt. Add indexes on workspaceId and userId.\r\n\r\n2. Run prisma migration: `npx prisma migrate dev --name add_shared_conversation`.\r\n\r\n3. Create POST endpoint at src/app/api/w/[slug]/chat/share/route.ts that:\r\n - Uses getMiddlewareContext and requireAuth for authentication\r\n - Validates workspace member via validateWorkspaceAccess\r\n - Accepts { messages, provenanceData, followUpQuestions } in request body\r\n - Creates SharedConversation record with auto-generated title from first user message (limit to 100 chars)\r\n - Returns { shareId, url } where url is `/w/{slug}/chat/shared/{shareId}`\r\n - Include error handling for validation failures\r\n\r\n4. Create GET endpoint at src/app/api/w/[slug]/chat/shared/[shareId]/route.ts that:\r\n - Uses getMiddlewareContext and requireAuth for authentication\r\n - Validates workspace member access via validateWorkspaceAccess\r\n - Fetches SharedConversation by shareId and validates workspaceId matches\r\n - Returns conversation data if user is workspace member\r\n - Returns 403 if not workspace member, 404 if conversation not found\r\n\r\n5. Create type definitions in src/types/shared-conversation.ts with interfaces: SharedConversationData, CreateSharedConversationRequest, CreateSharedConversationResponse.\r\n\r\n6. Write integration tests for both endpoints covering: successful share creation, unauthorized access, invalid workspace, successful retrieval, access denied scenarios.\r\n</initial_request>\r\n<additional_information>[[\"# Agent Chat\\n\\nAI-powered chat interface that integrates with Goose to provide tool-using assistance (web search, learning retrieval, Q\\u0026A) with streaming responses, conversation persistence, and image support. Uses dedicated pods for isolated Goose sessions with automatic lifecycle management.\\n\\n## Core Files\\n\\n- **src/app/api/agent/route.ts** - Main agent streaming endpoint with Goose integration and background processing\\n- **src/app/w/[slug]/task/[...taskParams]/components/AgentChatArea.tsx** - Agent chat UI container with auto-scroll and message rendering\\n- **src/app/w/[slug]/task/[...taskParams]/components/AgentChatMessage.tsx** - Message component rendering user/assistant/tool messages\\n- **src/app/w/[slug]/task/[...taskParams]/components/ChatInput.tsx** - Input component with drag-and-drop image upload\\n- **src/app/w/[slug]/task/[...taskParams]/page.tsx** - Task page orchestrating agent chat initialization\\n- **src/lib/pods/utils.ts** - Pod management utilities for Goose service lifecycle\\n- **src/lib/streaming/useStreamProcessor.ts** - Client-side stream processing hook\\n- **src/lib/chat.ts** - Chat utilities and type definitions\\n- **src/types/agent.ts** - Agent-specific TypeScript types\\n- **src/app/api/upload/presigned-url/route.ts** - S3 presigned URL generation for image uploads\\n- **prisma/schema.prisma** - Task model with mode, agentUrl, agentPassword fields\\n\\n## Key Concepts\\n\\n**Goose Integration**\\n- Uses Goose AI provider via REST API for tool-capable chat\\n- Persistent sessions identified by timestamp-based IDs stored in chat history\\n- Session validation with retry logic before starting conversations\\n\\n**Pod Management**\\n- Automatic claiming of dedicated pods when agent tasks start\\n- Dropping pods on task end or navigation away\\n- Pod credentials (URL, encrypted password) stored securely in database\\n- Supports local development via CUSTOM_GOOSE_URL environment variable\\n\\n**Streaming Architecture**\\n- Dual-stream approach: frontend stream for real-time UI + background stream for DB persistence\\n- Incremental message saving during streaming\\n- Graceful handling of client disconnects using after() for background processing\\n- Stream continues saving to DB even if frontend disconnects\\n\\n**Tools \\u0026 Artifacts**\\n- Tool processors for WEB_SEARCH, GET_LEARNINGS, ASK_QUESTION\\n- FINAL_ANSWER tool for user-facing responses\\n- Artifacts for code snippets, images, and IDE content\\n- Citation conversion to links in responses\\n\\n**Multi-Modal Support**\\n- Image upload via drag-and-drop or file picker\\n- S3 storage with presigned URLs\\n- Multi-part messages (text + images) using AI SDK ImagePart format\\n- Supports JPEG, PNG, GIF, WebP (max 10MB)\\n\\n## API Endpoints\\n\\n**POST /api/agent**\\n- Main streaming endpoint for agent conversations\\n- Accepts messages array, workspace ID, task ID, user ID\\n- Returns Server-Sent Events stream with tool calls and responses\\n- Handles session creation/resumption and pod validation\\n\\n**POST /api/tasks/:taskId/messages/save**\\n- Persists user and assistant messages to database\\n- Called incrementally during streaming\\n\\n**POST /api/pool-manager/claim-pod/[workspaceId]**\\n- Claims dedicated pod for workspace\\n- Saves encrypted pod credentials to task\\n- Auto-starts Goose service if not running\\n\\n**POST /api/pool-manager/drop-pod/[workspaceId]**\\n- Releases pod when task ends\\n\\n**POST /api/upload/presigned-url**\\n- Generates S3 upload URL for images\\n- Validates file type and size\\n\\n**GET /api/upload/presigned-url**\\n- Generates S3 download URL for images\\n\\n## Data Models\\n\\n**Task (Prisma)**\\n- `mode`: \\\"agent\\\" | \\\"live\\\" - distinguishes agent chat from live tasks\\n- `agentUrl`: Pod URL for Goose instance\\n- `agentPassword`: Encrypted pod password\\n- Relations to messages for conversation history\\n\\n**AgentStreamingMessage**\\n- Represents messages in agent conversations\\n- Supports text, tool calls, tool results, artifacts\\n\\n**ArtifactRequest**\\n- Defines artifact structure for code/image generation\\n- Types: CODE, IMAGE, IDE content\\n\\n## UI Components\\n\\n**AgentChatArea**\\n- Main chat container with message list and input\\n- Auto-scroll with manual override detection\\n- Back button with intelligent navigation (history vs tasks list)\\n- Thinking indicator during streaming\\n\\n**AgentChatMessage**\\n- Renders user, assistant, and tool messages\\n- Supports markdown, code blocks, and citations\\n- Displays tool calls with visual indicators\\n\\n**ChatInput**\\n- Text input with image attachment support\\n- Drag-and-drop zone with upload progress\\n- Image preview before sending\\n\\n**ThinkingIndicator**\\n- Animated indicator shown during agent processing\\n\\n## Key Functions\\n\\n**generateSessionId()** - Creates timestamp-based session identifiers\\n\\n**sanitizeTask/sanitizeTasks()** - Removes sensitive pod credentials before sending to frontend\\n\\n**checkGooseRunning()** - Validates Goose service availability on pod\\n\\n**startGoose()** - Launches Goose service on pod if not running\\n\\n**retryWithDelay()** - Exponential backoff retry for session validation\\n\\n**convertCitationsToLinks()** - Transforms citation references to clickable links\\n\\n## Developer Notes\\n\\n- Agent mode requires pod infrastructure with Goose deployment\\n- Session IDs must persist across conversations for context continuity\\n- Frontend never receives pod credentials - all requests proxied through backend\\n- Stream processing must handle client disconnects gracefully\\n- Tool call/result messages must maintain proper ordering for AI context\\n- Image uploads limited to 10MB, validated on both client and server\\n\\n---\\n\\n# Real-time Chat\\n\\nReal-time messaging system using Pusher for instant message delivery and synchronization across multiple clients and browser tabs. Supports task-based chat conversations with file attachments, multi-line input, and real-time task status updates.\\n\\n## Core Files\\n\\n- `src/lib/pusher.ts` - Pusher server/client initialization and channel name utilities\\n- `src/hooks/usePusherConnection.ts` - Main hook for Pusher channel subscriptions and event handling\\n- `src/hooks/useProjectLogWebSocket.ts` - WebSocket connection for Stakwork thinking logs\\n- `src/hooks/useTasksHighlight.ts` - Real-time task status update broadcasting\\n- `src/hooks/useWorkspaceTasks.ts` - Task list state management with real-time updates\\n- `src/app/api/chat/message/route.ts` - Message creation endpoint\\n- `src/app/api/chat/response/route.ts` - Chat response endpoint with Pusher event triggers (webhook-accessible, API token authenticated)\\n- `src/app/api/chat/messages/[messageId]/route.ts` - Individual message fetching by ID\\n- `src/app/api/tasks/[taskId]/title/route.ts` - Task title updates with Pusher broadcast\\n- `src/app/w/[slug]/task/[...taskParams]/page.tsx` - Main task page with Pusher and WebSocket connections\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatArea.tsx` - Chat container with auto-scroll management\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatInput.tsx` - Chat input with Shift+Enter multi-line support\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatMessage.tsx` - Memoized message component with multiline text support\\n\\n## Key Concepts\\n\\n**Channel Structure**:\\n- Task-specific channels: `task-{taskId}` for message delivery\\n- Workspace channels: `workspace-{workspaceSlug}` for recommendations and task list updates\\n\\n**Message Synchronization**:\\n- Pusher events send only message IDs (circumvents 10KB limit)\\n- Clients fetch full message data via REST endpoint when notified\\n- Prevents message duplication and flickering across tabs\\n\\n**Multi-Transport Architecture**:\\n- Pusher for chat messages, titles, and workspace events\\n- Separate WebSocket connection for Stakwork thinking logs (project-specific)\\n\\n**Auto-scroll Behavior**:\\n- Automatically scrolls to new messages when user is at bottom\\n- Disables auto-scroll when user manually scrolls up to read history\\n- Re-enables when user scrolls near bottom\\n\\n**Mobile Optimization**:\\n- Fixed positioning with 44px touch targets\\n- Tap-to-send interaction pattern\\n\\n## Pusher Events\\n\\n- `NEW_MESSAGE` - New chat message available (sends message ID only)\\n- `RECOMMENDATIONS_UPDATED` - New test recommendations in insights page\\n- `TASK_TITLE_UPDATE` - Task title changed (task channel)\\n- `WORKSPACE_TASK_TITLE_UPDATE` - Task title changed (workspace channel)\\n- `STAKWORK_RUN_UPDATE` - Task status/data updates from workflow runs\\n\\n## API Endpoints\\n\\n- `POST /api/chat/message` - Create new chat message (authenticated users only)\\n- `POST /api/chat/response` - Send chat response (webhook-accessible, requires API token)\\n- `GET /api/chat/messages/[messageId]` - Fetch specific message by ID\\n- `PUT /api/tasks/[taskId]/title` - Update task title with real-time broadcast\\n- `GET /api/tasks/[taskId]/messages` - Fetch all messages for task (cache disabled)\\n\\n## Data Flow\\n\\n1. User sends message → POST /api/chat/message\\n2. Message saved to database → Pusher event triggered with message ID\\n3. All connected clients receive event → Fetch full message via GET /api/chat/messages/[messageId]\\n4. Message rendered in chat UI without flickering/duplication\\n5. Workflow response → POST /api/chat/response → Same Pusher flow\\n\\n## Configuration Requirements\\n\\n- Pusher app credentials (key, secret, app ID, cluster)\\n- WebSocket connection for Stakwork thinking logs\\n- API token authentication for webhook endpoints\\n\\n## Testing\\n\\n- Integration tests: `src/__tests__/integration/api/chat/message.test.ts`\\n- Unit tests: `src/__tests__/unit/components/ChatInput.test.tsx`, `ChatMessage.test.tsx`\\n- Covers authentication, authorization, file attachments, Pusher notifications\\n\\n## Key Dependencies\\n\\n- `usePusherConnection` - Primary hook for feature integration\\n- `useWorkspaceTasks` - For task list real-time updates\\n- `useTasksHighlight` - For workflow status updates\\n- Component memoization (ChatMessage, WorkflowUrlLink) - Prevents flicker during re-renders\\n\\n## Related Features\\n\\n- Insights page recommendations (workspace-level Pusher events)\\n- Task title synchronization across task list and chat views\\n- Learning assistant chat (shares ChatInput component pattern)\\n- Sidebar auto-collapse on task pages for maximized chat area\\n\\n---\\n\\n# Task Management Feature Documentation\\n\\n## Overview\\nUsers create and manage tasks with real-time chat interface in two modes: Agent Mode (autonomous coding with pod-based development environments) and Workflow Mode (Stakwork workflow integration). Tasks support multiple artifact types, automatic PR creation, GitHub integration, and real-time collaboration.\\n\\n## Core Architecture\\n\\n### Key Files (15 Essential)\\n- `src/app/api/tasks/route.ts` - Task CRUD, search, filtering, pagination\\n- `src/app/api/tasks/[taskId]/route.ts` - Single task updates, patch operations\\n- `src/app/api/tasks/[taskId]/messages/route.ts` - Message history retrieval\\n- `src/app/api/tasks/[taskId]/messages/save/route.ts` - Save messages, auto-complete on PR creation\\n- `src/app/api/chat/message/route.ts` - Send chat messages, trigger Stakwork workflows\\n- `src/app/api/chat/response/route.ts` - SSE endpoint for real-time message streaming\\n- `src/app/w/[slug]/task/[...taskParams]/page.tsx` - Main task page, pod management, artifact coordination\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatArea.tsx` - Workflow mode chat interface\\n- `src/app/w/[slug]/task/[...taskParams]/components/AgentChatArea.tsx` - Agent mode chat with pod controls\\n- `src/app/w/[slug]/task/[...taskParams]/components/ArtifactsPanel.tsx` - Multi-artifact display with icon button navigation\\n- `src/components/tasks/TasksList.tsx` - Task list with search, filters, tabs (Active/Archived)\\n- `src/components/tasks/TaskCard.tsx` - Task card with status, PR info, badges, controls\\n- `src/hooks/useWorkspaceTasks.ts` - Task data fetching, pagination, search, filters\\n- `src/services/task-workflow.ts` - Workflow orchestration, feature context building\\n- `src/services/task-coordinator.ts` - Task execution coordination, status management\\n\\n## Data Models\\n\\n**Task** - Main model with fields: title, description, status (TODO/IN_PROGRESS/DONE/HALTED/BLOCKED), mode (agent/live/test), podId, workflowStatus, stakworkProjectId, featureId, phaseId, runBuild, runTestSuite, archived, dependsOnTaskIds\\n\\n**ChatMessage** - Chat history with fields: content, role (user/assistant), status, workflowUrl, artifacts, contextTags\\n\\n**Artifact** - Multiple types (CODE, BROWSER, FORM, DIFF, PULL_REQUEST, LONGFORM, IDE) with type-specific content\\n\\n## Task Modes\\n\\n**Agent Mode**: Autonomous coding with dedicated pod allocation. Claims pod from pool, executes code changes, generates diffs/commits, creates PRs automatically. Pod released on task completion or manual release.\\n\\n**Workflow Mode**: Stakwork workflow integration. Sends messages to external workflow system, receives responses via SSE, displays artifacts (forms, code, browser previews).\\n\\n**Test Mode**: Integration test generation mode (uses Stakwork workflows).\\n\\n## Core Capabilities\\n\\n### Task Lifecycle\\n- Create tasks via chat interface or roadmap phases\\n- Automatic status transitions (TODO → IN_PROGRESS when workflow starts)\\n- Auto-complete when PRs are created (Agent mode) or [Open PR] artifact (Workflow mode)\\n- Archive/unarchive tasks manually\\n- Soft delete with dependency cleanup\\n\\n### Artifacts System\\n- **CODE**: Syntax-highlighted code with file context\\n- **BROWSER**: Live preview with URL health checking, mobile toggle, refresh controls\\n- **FORM**: Interactive forms with markdown support, webhook submission, visual feedback\\n- **DIFF**: Collapsible file diffs with addition/deletion stats, unified/split view\\n- **PULL_REQUEST**: PR information with status badges, auto-merging detection\\n- **LONGFORM**: Rich content with modular icons (Code, Agent, Call, Message)\\n- **IDE**: IDE-like interface for code editing\\n\\n### Real-time Features\\n- SSE connection for streaming chat responses\\n- Pusher events for task updates, title changes, status changes\\n- Live workflow status tracking\\n- Pod release verification and ownership checks\\n- PR status polling from GitHub API\\n\\n### Search \\u0026 Filtering\\n- Search by title/description (case-insensitive, debounced)\\n- Filter by source type (manual/janitor/roadmap), status, priority, pod assignment\\n- Sort by updatedAt (most recent activity first)\\n- Pagination with state persistence (sessionStorage)\\n\\n### Views\\n- **List View**: Paginated task cards (10 per page)\\n- **Kanban View**: Status-based columns (In Progress, Completed, Error, Halted)\\n- Active/Archived tabs\\n- Notification badges for tasks waiting for input\\n\\n## API Endpoints\\n\\n**Task Operations**: GET/POST/PUT/DELETE `/api/tasks`, GET/PATCH `/api/tasks/[taskId]`, GET `/api/task/[taskId]`\\n\\n**Task Messages**: GET `/api/tasks/[taskId]/messages`, POST `/api/tasks/[taskId]/messages/save`\\n\\n**Chat**: POST `/api/chat/message`, GET `/api/chat/response` (SSE)\\n\\n**Task Title**: PUT `/api/tasks/[taskId]/title`\\n\\n**Statistics**: GET `/api/tasks/stats`, GET `/api/workspaces/[slug]/tasks/notifications-count`\\n\\n**Agent Operations**: POST `/api/agent/commit`, POST `/api/agent/diff`, POST `/api/agent/branch`\\n\\n**Pod Management**: POST `/api/pool-manager/claim-pod/[workspaceId]`, POST `/api/pool-manager/drop-pod/[workspaceId]`\\n\\n**Utilities**: GET `/api/check-url` (browser artifact health checks)\\n\\n**Reordering**: POST `/api/tickets/reorder` (roadmap task reordering with feature consistency validation)\\n\\n**Jarvis Integration**: POST `/api/swarm/jarvis/search-by-types` (Neo4j task tracking)\\n\\n## Integration Points\\n\\n**GitHub**: OAuth app token authentication for PR creation, status polling, commit/push operations\\n\\n**Stakwork**: External workflow system for Workflow Mode, receives full chat history and context\\n\\n**Pod Pool**: Development environment management with capacity checking and usage tracking\\n\\n**Neo4j/Jarvis**: Task tracking with media URL presigning for recordings\\n\\n**Pusher**: Real-time workspace-level and task-level event broadcasting\\n\\n## Key Hooks\\n\\n`useWorkspaceTasks` - Task fetching with search/filter/pagination\\n`useTaskStats` - Running tasks and waiting-for-input counts\\n`useSSEConnection` - Server-Sent Events connection management\\n`usePusherConnection` - Real-time task updates subscription\\n`useBrowserLoadingStatus` - Browser artifact URL health checking\\n`useChatForm` - Form artifact interaction handling\\n`useTasksHighlight` - Jarvis integration for in-progress tasks\\n\\n## Context \\u0026 State\\n\\n**WorkspaceContext**: Global task notification count, refresh triggers\\n**Session Storage**: Task list pagination state persistence\\n**Local Storage**: View preference (List/Kanban) persistence\\n\\n## Developer Notes\\n\\n- Tasks unified with Tickets model (featureId/phaseId for roadmap integration)\\n- Pod availability must be checked before creating Agent mode tasks\\n- Form webhooks require array length check (not truthiness) to prevent empty array bugs\\n- Browser artifacts poll only on 502/503 errors, immediately show on other status codes\\n- Task title updates broadcast to both task-specific and workspace-level Pusher channels\\n- Back button navigation uses referrer checking for intelligent history navigation\\n- Diff artifacts only show most recent to avoid confusion\",\"# Agent Chat\\n\\nAI-powered chat interface that integrates with Goose to provide tool-using assistance (web search, learning retrieval, Q\\u0026A) with streaming responses, conversation persistence, and image support. Uses dedicated pods for isolated Goose sessions with automatic lifecycle management.\\n\\n## Core Files\\n\\n- **src/app/api/agent/route.ts** - Main agent streaming endpoint with Goose integration and background processing\\n- **src/app/w/[slug]/task/[...taskParams]/components/AgentChatArea.tsx** - Agent chat UI container with auto-scroll and message rendering\\n- **src/app/w/[slug]/task/[...taskParams]/components/AgentChatMessage.tsx** - Message component rendering user/assistant/tool messages\\n- **src/app/w/[slug]/task/[...taskParams]/components/ChatInput.tsx** - Input component with drag-and-drop image upload\\n- **src/app/w/[slug]/task/[...taskParams]/page.tsx** - Task page orchestrating agent chat initialization\\n- **src/lib/pods/utils.ts** - Pod management utilities for Goose service lifecycle\\n- **src/lib/streaming/useStreamProcessor.ts** - Client-side stream processing hook\\n- **src/lib/chat.ts** - Chat utilities and type definitions\\n- **src/types/agent.ts** - Agent-specific TypeScript types\\n- **src/app/api/upload/presigned-url/route.ts** - S3 presigned URL generation for image uploads\\n- **prisma/schema.prisma** - Task model with mode, agentUrl, agentPassword fields\\n\\n## Key Concepts\\n\\n**Goose Integration**\\n- Uses Goose AI provider via REST API for tool-capable chat\\n- Persistent sessions identified by timestamp-based IDs stored in chat history\\n- Session validation with retry logic before starting conversations\\n\\n**Pod Management**\\n- Automatic claiming of dedicated pods when agent tasks start\\n- Dropping pods on task end or navigation away\\n- Pod credentials (URL, encrypted password) stored securely in database\\n- Supports local development via CUSTOM_GOOSE_URL environment variable\\n\\n**Streaming Architecture**\\n- Dual-stream approach: frontend stream for real-time UI + background stream for DB persistence\\n- Incremental message saving during streaming\\n- Graceful handling of client disconnects using after() for background processing\\n- Stream continues saving to DB even if frontend disconnects\\n\\n**Tools \\u0026 Artifacts**\\n- Tool processors for WEB_SEARCH, GET_LEARNINGS, ASK_QUESTION\\n- FINAL_ANSWER tool for user-facing responses\\n- Artifacts for code snippets, images, and IDE content\\n- Citation conversion to links in responses\\n\\n**Multi-Modal Support**\\n- Image upload via drag-and-drop or file picker\\n- S3 storage with presigned URLs\\n- Multi-part messages (text + images) using AI SDK ImagePart format\\n- Supports JPEG, PNG, GIF, WebP (max 10MB)\\n\\n## API Endpoints\\n\\n**POST /api/agent**\\n- Main streaming endpoint for agent conversations\\n- Accepts messages array, workspace ID, task ID, user ID\\n- Returns Server-Sent Events stream with tool calls and responses\\n- Handles session creation/resumption and pod validation\\n\\n**POST /api/tasks/:taskId/messages/save**\\n- Persists user and assistant messages to database\\n- Called incrementally during streaming\\n\\n**POST /api/pool-manager/claim-pod/[workspaceId]**\\n- Claims dedicated pod for workspace\\n- Saves encrypted pod credentials to task\\n- Auto-starts Goose service if not running\\n\\n**POST /api/pool-manager/drop-pod/[workspaceId]**\\n- Releases pod when task ends\\n\\n**POST /api/upload/presigned-url**\\n- Generates S3 upload URL for images\\n- Validates file type and size\\n\\n**GET /api/upload/presigned-url**\\n- Generates S3 download URL for images\\n\\n## Data Models\\n\\n**Task (Prisma)**\\n- `mode`: \\\"agent\\\" | \\\"live\\\" - distinguishes agent chat from live tasks\\n- `agentUrl`: Pod URL for Goose instance\\n- `agentPassword`: Encrypted pod password\\n- Relations to messages for conversation history\\n\\n**AgentStreamingMessage**\\n- Represents messages in agent conversations\\n- Supports text, tool calls, tool results, artifacts\\n\\n**ArtifactRequest**\\n- Defines artifact structure for code/image generation\\n- Types: CODE, IMAGE, IDE content\\n\\n## UI Components\\n\\n**AgentChatArea**\\n- Main chat container with message list and input\\n- Auto-scroll with manual override detection\\n- Back button with intelligent navigation (history vs tasks list)\\n- Thinking indicator during streaming\\n\\n**AgentChatMessage**\\n- Renders user, assistant, and tool messages\\n- Supports markdown, code blocks, and citations\\n- Displays tool calls with visual indicators\\n\\n**ChatInput**\\n- Text input with image attachment support\\n- Drag-and-drop zone with upload progress\\n- Image preview before sending\\n\\n**ThinkingIndicator**\\n- Animated indicator shown during agent processing\\n\\n## Key Functions\\n\\n**generateSessionId()** - Creates timestamp-based session identifiers\\n\\n**sanitizeTask/sanitizeTasks()** - Removes sensitive pod credentials before sending to frontend\\n\\n**checkGooseRunning()** - Validates Goose service availability on pod\\n\\n**startGoose()** - Launches Goose service on pod if not running\\n\\n**retryWithDelay()** - Exponential backoff retry for session validation\\n\\n**convertCitationsToLinks()** - Transforms citation references to clickable links\\n\\n## Developer Notes\\n\\n- Agent mode requires pod infrastructure with Goose deployment\\n- Session IDs must persist across conversations for context continuity\\n- Frontend never receives pod credentials - all requests proxied through backend\\n- Stream processing must handle client disconnects gracefully\\n- Tool call/result messages must maintain proper ordering for AI context\\n- Image uploads limited to 10MB, validated on both client and server\",\"# Real-time Chat\\n\\nReal-time messaging system using Pusher for instant message delivery and synchronization across multiple clients and browser tabs. Supports task-based chat conversations with file attachments, multi-line input, and real-time task status updates.\\n\\n## Core Files\\n\\n- `src/lib/pusher.ts` - Pusher server/client initialization and channel name utilities\\n- `src/hooks/usePusherConnection.ts` - Main hook for Pusher channel subscriptions and event handling\\n- `src/hooks/useProjectLogWebSocket.ts` - WebSocket connection for Stakwork thinking logs\\n- `src/hooks/useTasksHighlight.ts` - Real-time task status update broadcasting\\n- `src/hooks/useWorkspaceTasks.ts` - Task list state management with real-time updates\\n- `src/app/api/chat/message/route.ts` - Message creation endpoint\\n- `src/app/api/chat/response/route.ts` - Chat response endpoint with Pusher event triggers (webhook-accessible, API token authenticated)\\n- `src/app/api/chat/messages/[messageId]/route.ts` - Individual message fetching by ID\\n- `src/app/api/tasks/[taskId]/title/route.ts` - Task title updates with Pusher broadcast\\n- `src/app/w/[slug]/task/[...taskParams]/page.tsx` - Main task page with Pusher and WebSocket connections\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatArea.tsx` - Chat container with auto-scroll management\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatInput.tsx` - Chat input with Shift+Enter multi-line support\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatMessage.tsx` - Memoized message component with multiline text support\\n\\n## Key Concepts\\n\\n**Channel Structure**:\\n- Task-specific channels: `task-{taskId}` for message delivery\\n- Workspace channels: `workspace-{workspaceSlug}` for recommendations and task list updates\\n\\n**Message Synchronization**:\\n- Pusher events send only message IDs (circumvents 10KB limit)\\n- Clients fetch full message data via REST endpoint when notified\\n- Prevents message duplication and flickering across tabs\\n\\n**Multi-Transport Architecture**:\\n- Pusher for chat messages, titles, and workspace events\\n- Separate WebSocket connection for Stakwork thinking logs (project-specific)\\n\\n**Auto-scroll Behavior**:\\n- Automatically scrolls to new messages when user is at bottom\\n- Disables auto-scroll when user manually scrolls up to read history\\n- Re-enables when user scrolls near bottom\\n\\n**Mobile Optimization**:\\n- Fixed positioning with 44px touch targets\\n- Tap-to-send interaction pattern\\n\\n## Pusher Events\\n\\n- `NEW_MESSAGE` - New chat message available (sends message ID only)\\n- `RECOMMENDATIONS_UPDATED` - New test recommendations in insights page\\n- `TASK_TITLE_UPDATE` - Task title changed (task channel)\\n- `WORKSPACE_TASK_TITLE_UPDATE` - Task title changed (workspace channel)\\n- `STAKWORK_RUN_UPDATE` - Task status/data updates from workflow runs\\n\\n## API Endpoints\\n\\n- `POST /api/chat/message` - Create new chat message (authenticated users only)\\n- `POST /api/chat/response` - Send chat response (webhook-accessible, requires API token)\\n- `GET /api/chat/messages/[messageId]` - Fetch specific message by ID\\n- `PUT /api/tasks/[taskId]/title` - Update task title with real-time broadcast\\n- `GET /api/tasks/[taskId]/messages` - Fetch all messages for task (cache disabled)\\n\\n## Data Flow\\n\\n1. User sends message → POST /api/chat/message\\n2. Message saved to database → Pusher event triggered with message ID\\n3. All connected clients receive event → Fetch full message via GET /api/chat/messages/[messageId]\\n4. Message rendered in chat UI without flickering/duplication\\n5. Workflow response → POST /api/chat/response → Same Pusher flow\\n\\n## Configuration Requirements\\n\\n- Pusher app credentials (key, secret, app ID, cluster)\\n- WebSocket connection for Stakwork thinking logs\\n- API token authentication for webhook endpoints\\n\\n## Testing\\n\\n- Integration tests: `src/__tests__/integration/api/chat/message.test.ts`\\n- Unit tests: `src/__tests__/unit/components/ChatInput.test.tsx`, `ChatMessage.test.tsx`\\n- Covers authentication, authorization, file attachments, Pusher notifications\\n\\n## Key Dependencies\\n\\n- `usePusherConnection` - Primary hook for feature integration\\n- `useWorkspaceTasks` - For task list real-time updates\\n- `useTasksHighlight` - For workflow status updates\\n- Component memoization (ChatMessage, WorkflowUrlLink) - Prevents flicker during re-renders\\n\\n## Related Features\\n\\n- Insights page recommendations (workspace-level Pusher events)\\n- Task title synchronization across task list and chat views\\n- Learning assistant chat (shares ChatInput component pattern)\\n- Sidebar auto-collapse on task pages for maximized chat area\",\"# Task Management Feature Documentation\\n\\n## Overview\\nUsers create and manage tasks with real-time chat interface in two modes: Agent Mode (autonomous coding with pod-based development environments) and Workflow Mode (Stakwork workflow integration). Tasks support multiple artifact types, automatic PR creation, GitHub integration, and real-time collaboration.\\n\\n## Core Architecture\\n\\n### Key Files (15 Essential)\\n- `src/app/api/tasks/route.ts` - Task CRUD, search, filtering, pagination\\n- `src/app/api/tasks/[taskId]/route.ts` - Single task updates, patch operations\\n- `src/app/api/tasks/[taskId]/messages/route.ts` - Message history retrieval\\n- `src/app/api/tasks/[taskId]/messages/save/route.ts` - Save messages, auto-complete on PR creation\\n- `src/app/api/chat/message/route.ts` - Send chat messages, trigger Stakwork workflows\\n- `src/app/api/chat/response/route.ts` - SSE endpoint for real-time message streaming\\n- `src/app/w/[slug]/task/[...taskParams]/page.tsx` - Main task page, pod management, artifact coordination\\n- `src/app/w/[slug]/task/[...taskParams]/components/ChatArea.tsx` - Workflow mode chat interface\\n- `src/app/w/[slug]/task/[...taskParams]/components/AgentChatArea.tsx` - Agent mode chat with pod controls\\n- `src/app/w/[slug]/task/[...taskParams]/components/ArtifactsPanel.tsx` - Multi-artifact display with icon button navigation\\n- `src/components/tasks/TasksList.tsx` - Task list with search, filters, tabs (Active/Archived)\\n- `src/components/tasks/TaskCard.tsx` - Task card with status, PR info, badges, controls\\n- `src/hooks/useWorkspaceTasks.ts` - Task data fetching, pagination, search, filters\\n- `src/services/task-workflow.ts` - Workflow orchestration, feature context building\\n- `src/services/task-coordinator.ts` - Task execution coordination, status management\\n\\n## Data Models\\n\\n**Task** - Main model with fields: title, description, status (TODO/IN_PROGRESS/DONE/HALTED/BLOCKED), mode (agent/live/test), podId, workflowStatus, stakworkProjectId, featureId, phaseId, runBuild, runTestSuite, archived, dependsOnTaskIds\\n\\n**ChatMessage** - Chat history with fields: content, role (user/assistant), status, workflowUrl, artifacts, contextTags\\n\\n**Artifact** - Multiple types (CODE, BROWSER, FORM, DIFF, PULL_REQUEST, LONGFORM, IDE) with type-specific content\\n\\n## Task Modes\\n\\n**Agent Mode**: Autonomous coding with dedicated pod allocation. Claims pod from pool, executes code changes, generates diffs/commits, creates PRs automatically. Pod released on task completion or manual release.\\n\\n**Workflow Mode**: Stakwork workflow integration. Sends messages to external workflow system, receives responses via SSE, displays artifacts (forms, code, browser previews).\\n\\n**Test Mode**: Integration test generation mode (uses Stakwork workflows).\\n\\n## Core Capabilities\\n\\n### Task Lifecycle\\n- Create tasks via chat interface or roadmap phases\\n- Automatic status transitions (TODO → IN_PROGRESS when workflow starts)\\n- Auto-complete when PRs are created (Agent mode) or [Open PR] artifact (Workflow mode)\\n- Archive/unarchive tasks manually\\n- Soft delete with dependency cleanup\\n\\n### Artifacts System\\n- **CODE**: Syntax-highlighted code with file context\\n- **BROWSER**: Live preview with URL health checking, mobile toggle, refresh controls\\n- **FORM**: Interactive forms with markdown support, webhook submission, visual feedback\\n- **DIFF**: Collapsible file diffs with addition/deletion stats, unified/split view\\n- **PULL_REQUEST**: PR information with status badges, auto-merging detection\\n- **LONGFORM**: Rich content with modular icons (Code, Agent, Call, Message)\\n- **IDE**: IDE-like interface for code editing\\n\\n### Real-time Features\\n- SSE connection for streaming chat responses\\n- Pusher events for task updates, title changes, status changes\\n- Live workflow status tracking\\n- Pod release verification and ownership checks\\n- PR status polling from GitHub API\\n\\n### Search \\u0026 Filtering\\n- Search by title/description (case-insensitive, debounced)\\n- Filter by source type (manual/janitor/roadmap), status, priority, pod assignment\\n- Sort by updatedAt (most recent activity first)\\n- Pagination with state persistence (sessionStorage)\\n\\n### Views\\n- **List View**: Paginated task cards (10 per page)\\n- **Kanban View**: Status-based columns (In Progress, Completed, Error, Halted)\\n- Active/Archived tabs\\n- Notification badges for tasks waiting for input\\n\\n## API Endpoints\\n\\n**Task Operations**: GET/POST/PUT/DELETE `/api/tasks`, GET/PATCH `/api/tasks/[taskId]`, GET `/api/task/[taskId]`\\n\\n**Task Messages**: GET `/api/tasks/[taskId]/messages`, POST `/api/tasks/[taskId]/messages/save`\\n\\n**Chat**: POST `/api/chat/message`, GET `/api/chat/response` (SSE)\\n\\n**Task Title**: PUT `/api/tasks/[taskId]/title`\\n\\n**Statistics**: GET `/api/tasks/stats`, GET `/api/workspaces/[slug]/tasks/notifications-count`\\n\\n**Agent Operations**: POST `/api/agent/commit`, POST `/api/agent/diff`, POST `/api/agent/branch`\\n\\n**Pod Management**: POST `/api/pool-manager/claim-pod/[workspaceId]`, POST `/api/pool-manager/drop-pod/[workspaceId]`\\n\\n**Utilities**: GET `/api/check-url` (browser artifact health checks)\\n\\n**Reordering**: POST `/api/tickets/reorder` (roadmap task reordering with feature consistency validation)\\n\\n**Jarvis Integration**: POST `/api/swarm/jarvis/search-by-types` (Neo4j task tracking)\\n\\n## Integration Points\\n\\n**GitHub**: OAuth app token authentication for PR creation, status polling, commit/push operations\\n\\n**Stakwork**: External workflow system for Workflow Mode, receives full chat history and context\\n\\n**Pod Pool**: Development environment management with capacity checking and usage tracking\\n\\n**Neo4j/Jarvis**: Task tracking with media URL presigning for recordings\\n\\n**Pusher**: Real-time workspace-level and task-level event broadcasting\\n\\n## Key Hooks\\n\\n`useWorkspaceTasks` - Task fetching with search/filter/pagination\\n`useTaskStats` - Running tasks and waiting-for-input counts\\n`useSSEConnection` - Server-Sent Events connection management\\n`usePusherConnection` - Real-time task updates subscription\\n`useBrowserLoadingStatus` - Browser artifact URL health checking\\n`useChatForm` - Form artifact interaction handling\\n`useTasksHighlight` - Jarvis integration for in-progress tasks\\n\\n## Context \\u0026 State\\n\\n**WorkspaceContext**: Global task notification count, refresh triggers\\n**Session Storage**: Task list pagination state persistence\\n**Local Storage**: View preference (List/Kanban) persistence\\n\\n## Developer Notes\\n\\n- Tasks unified with Tickets model (featureId/phaseId for roadmap integration)\\n- Pod availability must be checked before creating Agent mode tasks\\n- Form webhooks require array length check (not truthiness) to prevent empty array bugs\\n- Browser artifacts poll only on 502/503 errors, immediately show on other status codes\\n- Task title updates broadcast to both task-specific and workspace-level Pusher channels\\n- Back button navigation uses referrer checking for intelligent history navigation\\n- Diff artifacts only show most recent to avoid confusion\"]]</additional_information>\r\n<history>\r\n\r\n</history>",
|
|
3
|
-
"system": "Do not run the build or tests - another agent will handle it.",
|
|
4
|
-
"summarize": true,
|
|
5
|
-
"resume": false,
|
|
6
|
-
"session": "feature/add-sharedconversation-model-and-api-endpoints-1768397672"
|
|
7
|
-
}
|
package/notes/large.json
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"prompt": "<initial_request>Add timestamp label to recommendation cards with relative time display\\n\\nDisplay when each recommendation was created using a timestamp label positioned in the top-right badge area. The timestamp should use the existing formatRelativeOrDate utility and be styled with muted colors.\\n\\nImplementation Steps:\\n1. Update the Recommendation interface in src/stores/useInsightsStore.ts to include the createdAt field (already returned by API)\\n2. Import formatRelativeOrDate utility in src/components/insights/RecommendationsSection/index.tsx\\n3. Add timestamp as the first element in the flex container (before Review Required and Priority badges)\\n4. Use text-xs text-muted-foreground classes for muted, small text styling\\n\\nAcceptance Criteria:\\n- createdAt field is added to Recommendation interface\\n- Timestamp displays relative time (e.g., '2 hrs ago', 'Yesterday', 'Nov 1, 2023')\\n- Timestamp appears in top-right section before other badges\\n- Timestamp uses muted text styling consistent with component design\\n- No visual regression in badge layout\\n\\nTechnical Details:\\n- File: src/stores/useInsightsStore.ts - Add createdAt?: string to Recommendation interface\\n- File: src/components/insights/RecommendationsSection/index.tsx\\n - Import: formatRelativeOrDate from '@/lib/date-utils'\\n - Location: In the second flex container (line ~123-131), add timestamp before badges\\n - Code pattern: <span className=\\\"text-xs text-muted-foreground\\\">{formatRelativeOrDate(recommendation.createdAt)}</span>\\n\\nTests:\\n- Verify timestamp renders correctly with mock data in different time ranges\\n- Test timestamp display with missing createdAt (graceful handling)\\n- Verify badge layout remains correct with timestamp added\r\n</initial_request>\r\n<additional_information>[[\"# Automated Test Recommendations\\n\\nSystem that automatically analyzes code repositories and generates intelligent recommendations for tests and improvements. Users can enable/disable different analysis types per workspace, trigger manual runs, and accept recommendations to create tasks. Supports both automated janitor runs and external workflow integrations.\\n\\n## Core Files\\n\\n```\\nprisma/schema.prisma # JanitorConfig, JanitorRun, JanitorRecommendation models\\nsrc/services/janitor.ts # Core service: runs, recommendations, accept/dismiss logic\\nsrc/services/task-workflow.ts # Creates tasks from accepted recommendations with Stakwork\\nsrc/services/janitor-cron.ts # Scheduled execution of janitor analysis runs\\nsrc/lib/constants/janitor.ts # Janitor type definitions and configuration\\nsrc/stores/useInsightsStore.ts # Zustand state management for recommendations UI\\nsrc/app/w/[slug]/recommendations/page.tsx # Main recommendations UI page\\nsrc/components/insights/RecommendationsSection/index.tsx # Recommendations list with accept/dismiss actions\\nsrc/components/insights/JanitorSection/index.tsx # Janitor type toggles and manual run triggers\\nsrc/app/api/workspaces/[slug]/janitors/config/route.ts # GET/PUT janitor configuration\\nsrc/app/api/workspaces/[slug]/janitors/[type]/run/route.ts # POST manual janitor run trigger\\nsrc/app/api/workspaces/[slug]/janitors/recommendations/route.ts # GET recommendations with filtering\\nsrc/app/api/janitors/recommendations/[id]/accept/route.ts # POST accept recommendation\\nsrc/app/api/janitors/webhook/route.ts # POST Stakwork webhook for results\\nsrc/services/github/PullRequestService.ts # Auto-labels PRs created by janitor tasks\\n```\\n\\n## Key Concepts\\n\\n**Janitor Types**: Six automated analyzers that scan repositories for improvement opportunities:\\n- UNIT_TESTS: Identifies missing unit test coverage\\n- INTEGRATION_TESTS: Suggests integration test scenarios\\n- E2E_TESTS: E2E test recommendations (hidden from UI, backend only)\\n- SECURITY_REVIEW: Security vulnerability scanning\\n- MOCK_GENERATION: Mock data and test fixture generation\\n- GENERAL_REFACTORING: Code refactoring opportunities\\n\\n**Recommendation Lifecycle**: Recommendations flow through states: PENDING → ACCEPTED → TASK_CREATED or PENDING → DISMISSED\\n\\n**Execution Modes**:\\n- Manual runs: Users trigger janitor analysis via UI\\n- Scheduled cron: Automated periodic execution\\n- External workflows: Recommendations created without janitor runs (e.g., from external CI systems)\\n\\n**Real-time Updates**: Pusher workspace channels notify users instantly when new recommendations arrive\\n\\n**Task Integration**: Accepting a recommendation creates a Stakwork task with automatic GitHub PR labeling when completed\\n\\n## Data Models\\n\\n**JanitorConfig**: Per-workspace settings with boolean toggles for each janitor type (unitTestsEnabled, integrationTestsEnabled, etc.)\\n\\n**JanitorRun**: Execution record tracking janitor analysis runs (status, trigger type, timestamps, repository)\\n\\n**JanitorRecommendation**: Individual suggestions with title, description, file paths, priority, status, and optional janitor run reference. External recommendations can exist without a janitor run.\\n\\n**Repository fields**: testingFrameworkSetup, playwrightSetup flags track test infrastructure installation status. ignoreDirs excludes directories from analysis.\\n\\n## API Endpoints\\n\\n**Configuration**: GET/PUT `/api/workspaces/[slug]/janitors/config`\\n\\n**Execution**: POST `/api/workspaces/[slug]/janitors/[type]/run`, GET `/api/workspaces/[slug]/janitors/runs`\\n\\n**Recommendations**: GET `/api/workspaces/[slug]/janitors/recommendations` (supports filtering by type, status, priority)\\n\\n**Actions**: POST `/api/janitors/recommendations/[id]/accept`, POST `/api/janitors/recommendations/[id]/dismiss`\\n\\n**Webhooks**: POST `/api/janitors/webhook` (Stakwork results), POST `/api/github/webhook/[workspaceId]` (PR labeling)\\n\\n## Service Functions\\n\\n**janitor.ts**: getOrCreateJanitorConfig, updateJanitorConfig, createJanitorRun, getJanitorRuns, getJanitorRecommendations, acceptJanitorRecommendation, dismissJanitorRecommendation, processJanitorWebhook, processExternalWorkflowRecommendations\\n\\n**task-workflow.ts**: createTaskWithStakworkWorkflow (creates task, integrates with Stakwork, triggers Pusher events)\\n\\n**janitor-cron.ts**: Scheduled execution logic for automated janitor runs\\n\\n## UI Components\\n\\n**RecommendationsSection**: Displays recommendation cards with accept/dismiss buttons, priority badges, \\\"Review Required\\\" badge for manual recommendations, and \\\"Janitor\\\" badge on task cards created from recommendations\\n\\n**JanitorSection**: Toggle switches for enabling/disabling janitor types with manual \\\"Run Now\\\" triggers\\n\\n**Page Organization**: Main recommendations page at `/w/[slug]/recommendations`, secondary defense page at `/w/[slug]/defense/insights`\\n\\n## Integration Points\\n\\n**Stakwork**: Janitor runs trigger Stakwork workflows that analyze code and return recommendations via webhook\\n\\n**Pusher**: Broadcasts `recommendations-updated` events on workspace channels when new recommendations arrive\\n\\n**GitHub**: Automatically adds \\\"janitor\\\" label to PRs created by tasks originating from accepted recommendations (includes retry logic for race conditions)\\n\\n**Task System**: Accepted recommendations automatically create tasks with proper source tracking (JANITOR source type)\\n\\n## Configuration\\n\\n**JANITOR_CONFIG** constant defines display names, descriptions, and defaults for each janitor type\\n\\n**Priority levels**: LOW, MEDIUM, HIGH, CRITICAL determine recommendation urgency\\n\\n**Filtering**: Recommendations support filtering by janitor type, status, and priority with pagination\",\"# Automated Test Recommendations\\n\\nSystem that automatically analyzes code repositories and generates intelligent recommendations for tests and improvements. Users can enable/disable different analysis types per workspace, trigger manual runs, and accept recommendations to create tasks. Supports both automated janitor runs and external workflow integrations.\\n\\n## Core Files\\n\\n```\\nprisma/schema.prisma # JanitorConfig, JanitorRun, JanitorRecommendation models\\nsrc/services/janitor.ts # Core service: runs, recommendations, accept/dismiss logic\\nsrc/services/task-workflow.ts # Creates tasks from accepted recommendations with Stakwork\\nsrc/services/janitor-cron.ts # Scheduled execution of janitor analysis runs\\nsrc/lib/constants/janitor.ts # Janitor type definitions and configuration\\nsrc/stores/useInsightsStore.ts # Zustand state management for recommendations UI\\nsrc/app/w/[slug]/recommendations/page.tsx # Main recommendations UI page\\nsrc/components/insights/RecommendationsSection/index.tsx # Recommendations list with accept/dismiss actions\\nsrc/components/insights/JanitorSection/index.tsx # Janitor type toggles and manual run triggers\\nsrc/app/api/workspaces/[slug]/janitors/config/route.ts # GET/PUT janitor configuration\\nsrc/app/api/workspaces/[slug]/janitors/[type]/run/route.ts # POST manual janitor run trigger\\nsrc/app/api/workspaces/[slug]/janitors/recommendations/route.ts # GET recommendations with filtering\\nsrc/app/api/janitors/recommendations/[id]/accept/route.ts # POST accept recommendation\\nsrc/app/api/janitors/webhook/route.ts # POST Stakwork webhook for results\\nsrc/services/github/PullRequestService.ts # Auto-labels PRs created by janitor tasks\\n```\\n\\n## Key Concepts\\n\\n**Janitor Types**: Six automated analyzers that scan repositories for improvement opportunities:\\n- UNIT_TESTS: Identifies missing unit test coverage\\n- INTEGRATION_TESTS: Suggests integration test scenarios\\n- E2E_TESTS: E2E test recommendations (hidden from UI, backend only)\\n- SECURITY_REVIEW: Security vulnerability scanning\\n- MOCK_GENERATION: Mock data and test fixture generation\\n- GENERAL_REFACTORING: Code refactoring opportunities\\n\\n**Recommendation Lifecycle**: Recommendations flow through states: PENDING → ACCEPTED → TASK_CREATED or PENDING → DISMISSED\\n\\n**Execution Modes**:\\n- Manual runs: Users trigger janitor analysis via UI\\n- Scheduled cron: Automated periodic execution\\n- External workflows: Recommendations created without janitor runs (e.g., from external CI systems)\\n\\n**Real-time Updates**: Pusher workspace channels notify users instantly when new recommendations arrive\\n\\n**Task Integration**: Accepting a recommendation creates a Stakwork task with automatic GitHub PR labeling when completed\\n\\n## Data Models\\n\\n**JanitorConfig**: Per-workspace settings with boolean toggles for each janitor type (unitTestsEnabled, integrationTestsEnabled, etc.)\\n\\n**JanitorRun**: Execution record tracking janitor analysis runs (status, trigger type, timestamps, repository)\\n\\n**JanitorRecommendation**: Individual suggestions with title, description, file paths, priority, status, and optional janitor run reference. External recommendations can exist without a janitor run.\\n\\n**Repository fields**: testingFrameworkSetup, playwrightSetup flags track test infrastructure installation status. ignoreDirs excludes directories from analysis.\\n\\n## API Endpoints\\n\\n**Configuration**: GET/PUT `/api/workspaces/[slug]/janitors/config`\\n\\n**Execution**: POST `/api/workspaces/[slug]/janitors/[type]/run`, GET `/api/workspaces/[slug]/janitors/runs`\\n\\n**Recommendations**: GET `/api/workspaces/[slug]/janitors/recommendations` (supports filtering by type, status, priority)\\n\\n**Actions**: POST `/api/janitors/recommendations/[id]/accept`, POST `/api/janitors/recommendations/[id]/dismiss`\\n\\n**Webhooks**: POST `/api/janitors/webhook` (Stakwork results), POST `/api/github/webhook/[workspaceId]` (PR labeling)\\n\\n## Service Functions\\n\\n**janitor.ts**: getOrCreateJanitorConfig, updateJanitorConfig, createJanitorRun, getJanitorRuns, getJanitorRecommendations, acceptJanitorRecommendation, dismissJanitorRecommendation, processJanitorWebhook, processExternalWorkflowRecommendations\\n\\n**task-workflow.ts**: createTaskWithStakworkWorkflow (creates task, integrates with Stakwork, triggers Pusher events)\\n\\n**janitor-cron.ts**: Scheduled execution logic for automated janitor runs\\n\\n## UI Components\\n\\n**RecommendationsSection**: Displays recommendation cards with accept/dismiss buttons, priority badges, \\\"Review Required\\\" badge for manual recommendations, and \\\"Janitor\\\" badge on task cards created from recommendations\\n\\n**JanitorSection**: Toggle switches for enabling/disabling janitor types with manual \\\"Run Now\\\" triggers\\n\\n**Page Organization**: Main recommendations page at `/w/[slug]/recommendations`, secondary defense page at `/w/[slug]/defense/insights`\\n\\n## Integration Points\\n\\n**Stakwork**: Janitor runs trigger Stakwork workflows that analyze code and return recommendations via webhook\\n\\n**Pusher**: Broadcasts `recommendations-updated` events on workspace channels when new recommendations arrive\\n\\n**GitHub**: Automatically adds \\\"janitor\\\" label to PRs created by tasks originating from accepted recommendations (includes retry logic for race conditions)\\n\\n**Task System**: Accepted recommendations automatically create tasks with proper source tracking (JANITOR source type)\\n\\n## Configuration\\n\\n**JANITOR_CONFIG** constant defines display names, descriptions, and defaults for each janitor type\\n\\n**Priority levels**: LOW, MEDIUM, HIGH, CRITICAL determine recommendation urgency\\n\\n**Filtering**: Recommendations support filtering by janitor type, status, and priority with pagination\"]]</additional_information>\r\n<history>\r\n\r\n</history>",
|
|
3
|
-
"system": "Do not run the build or tests - another agent will handle it.\r\n\r\nWhen writing tests, follow these principles:\r\n<testing_principles>\r\n <philosophy>\r\n Tests exist to catch bugs users would notice, not to document implementation.\r\n A test suite should make refactoring safe, not painful.\r\n Fewer meaningful tests beat many trivial ones.\r\n Reuse existing patterns before creating new ones.\r\n </philosophy>\r\n\r\n <non_negotiables>\r\n - Tests MUST verify externally observable behavior through public APIs\r\n - Tests MUST fail for user-visible bugs, not internal refactors\r\n - Tests MUST be deterministic, isolated, and fast\r\n - A failing test MUST explain what broke without reading source code\r\n </non_negotiables>\r\n\r\n <what_to_test>\r\n - Business rules, invariants, and decision logic\r\n - Boundary conditions and edge cases that affect outcomes\r\n - Error handling that users or callers would experience\r\n - Integration points at system boundaries (DB, APIs, file system)\r\n </what_to_test>\r\n\r\n <what_not_to_test>\r\n - Simple getters, setters, or pure delegation with no logic\r\n - Internal method calls, private functions, or implementation structure\r\n - Exact response shapes, field ordering, timestamps, or formatting\r\n - Framework, library, or serialization behavior\r\n - Code that merely wires components together without decisions\r\n - One-liner functions with no branching\r\n </what_not_to_test>\r\n\r\n <test_granularity>\r\n - One test = one user-meaningful outcome (may require multiple assertions)\r\n - Group related assertions about the same behavior in one test\r\n - Use parameterized/table-driven tests for same logic with different inputs\r\n - If a test name needs \"and\" to describe it, consider splitting\r\n </test_granularity>\r\n\r\n <assertion_rules>\r\n - Assert outcomes and invariants, not full object equality\r\n - Check presence, type, and meaning over exact structure\r\n - Never assert on generated IDs, timestamps, or non-deterministic values\r\n - Avoid asserting call counts unless contractually required\r\n\r\n <examples>\r\n <bad>expect(result).toEqual({ id: 1, name: \"foo\", createdAt: \"2024-01-01T00:00:00Z\" })</bad>\r\n <good>expect(result.name).toBe(\"foo\"); expect(result.id).toBeDefined()</good>\r\n\r\n <bad>expect(error.message).toBe(\"Invalid email: must contain @ symbol\")</bad>\r\n <good>expect(error.code).toBe(\"INVALID_EMAIL\")</good>\r\n </examples>\r\n </assertion_rules>\r\n\r\n <mocking_rules>\r\n - Mock ONLY at system boundaries (network, database, file system, time)\r\n - Prefer real implementations, in-memory fakes, or test containers\r\n - Never mock the unit under test or internal collaborators\r\n - If a test needs more than 2 mocks, reconsider the design\r\n\r\n <examples>\r\n <bad>mock(UserService); mock(Validator); mock(Logger);</bad>\r\n <good>mock(DatabaseClient); // real services, real validation</good>\r\n </examples>\r\n </mocking_rules>\r\n\r\n <reuse_first>\r\n Before creating any helper, mock, or test data:\r\n 1. Check existing codebase for test utilities, factories, and helpers\r\n 2. Use existing patterns wherever they fit\r\n 3. Only create new helpers if none exist for your use case\r\n 4. Place new helpers logically:\r\n - Project-wide → shared test utilities directory\r\n - Domain-specific → alongside related test files\r\n - Single-use → within the test file\r\n </reuse_first>\r\n\r\n <reduce_duplication>\r\n - Extract repeated data creation into factories/builders\r\n - Centralise mock configurations in shared utilities\r\n - Create custom assertions for repeated verification patterns\r\n - Use beforeEach/setUp for common initialisation (but keep minimal)\r\n </reduce_duplication>\r\n\r\n <test_structure>\r\n - Name states behavior and expected outcome clearly\r\n - Setup is minimal and local (no distant shared fixtures)\r\n - Arrange-Act-Assert with clear separation\r\n - No conditional logic or loops inside tests\r\n - Use describe/context blocks for logical grouping\r\n </test_structure>\r\n</testing_principles>",
|
|
4
|
-
"summarize": null,
|
|
5
|
-
"resume": null,
|
|
6
|
-
"session": null
|
|
7
|
-
}
|
package/notes/resume.json
DELETED