File size: 10,354 Bytes
1dbc34b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | /**
* Query Keys Factory
*
* Centralized query key definitions for React Query.
* Following the factory pattern for type-safe, consistent query keys.
*
* @see https://tkdodo.eu/blog/effective-react-query-keys
*/
/**
* Query keys for all API endpoints
*
* Structure follows the pattern:
* - ['entity'] for listing/global
* - ['entity', id] for single item
* - ['entity', id, 'sub-resource'] for nested resources
*/
export const queryKeys = {
// ============================================
// Features
// ============================================
features: {
/** All features for a project */
all: (projectPath: string) => ['features', projectPath] as const,
/** Single feature */
single: (projectPath: string, featureId: string) =>
['features', projectPath, featureId] as const,
/** Agent output for a feature */
agentOutput: (projectPath: string, featureId: string) =>
['features', projectPath, featureId, 'output'] as const,
},
// ============================================
// Worktrees
// ============================================
worktrees: {
/** All worktrees for a project */
all: (projectPath: string) => ['worktrees', projectPath] as const,
/** Single worktree info */
single: (projectPath: string, featureId: string) =>
['worktrees', projectPath, featureId] as const,
/** Branches for a worktree */
branches: (worktreePath: string, includeRemote = false) =>
['worktrees', 'branches', worktreePath, { includeRemote }] as const,
/** Worktree status */
status: (projectPath: string, featureId: string) =>
['worktrees', projectPath, featureId, 'status'] as const,
/** Worktree diffs */
diffs: (projectPath: string, featureId: string) =>
['worktrees', projectPath, featureId, 'diffs'] as const,
/** Init script for a project */
initScript: (projectPath: string) => ['worktrees', projectPath, 'init-script'] as const,
/** Available editors */
editors: () => ['worktrees', 'editors'] as const,
},
// ============================================
// GitHub
// ============================================
github: {
/** GitHub issues for a project */
issues: (projectPath: string) => ['github', 'issues', projectPath] as const,
/** GitHub PRs for a project */
prs: (projectPath: string) => ['github', 'prs', projectPath] as const,
/** GitHub validations for a project */
validations: (projectPath: string) => ['github', 'validations', projectPath] as const,
/** Single validation */
validation: (projectPath: string, issueNumber: number) =>
['github', 'validations', projectPath, issueNumber] as const,
/** Issue comments */
issueComments: (projectPath: string, issueNumber: number) =>
['github', 'issues', projectPath, issueNumber, 'comments'] as const,
/** PR review comments */
prReviewComments: (projectPath: string, prNumber: number) =>
['github', 'prs', projectPath, prNumber, 'review-comments'] as const,
/** Remote info */
remote: (projectPath: string) => ['github', 'remote', projectPath] as const,
},
// ============================================
// Settings
// ============================================
settings: {
/** Global settings */
global: () => ['settings', 'global'] as const,
/** Project-specific settings */
project: (projectPath: string) => ['settings', 'project', projectPath] as const,
/** Settings status */
status: () => ['settings', 'status'] as const,
/** Credentials (API keys) */
credentials: () => ['settings', 'credentials'] as const,
/** Discovered agents */
agents: (projectPath: string, sources?: Array<'user' | 'project'>) =>
['settings', 'agents', projectPath, sources ?? []] as const,
},
// ============================================
// Usage & Billing
// ============================================
usage: {
/** Claude API usage */
claude: () => ['usage', 'claude'] as const,
/** Codex API usage */
codex: () => ['usage', 'codex'] as const,
/** z.ai API usage */
zai: () => ['usage', 'zai'] as const,
/** Gemini API usage */
gemini: () => ['usage', 'gemini'] as const,
},
// ============================================
// Models
// ============================================
models: {
/** Available models */
available: () => ['models', 'available'] as const,
/** Codex models */
codex: () => ['models', 'codex'] as const,
/** OpenCode models */
opencode: () => ['models', 'opencode'] as const,
/** OpenCode providers */
opencodeProviders: () => ['models', 'opencode', 'providers'] as const,
/** Provider status */
providers: () => ['models', 'providers'] as const,
},
// ============================================
// Sessions
// ============================================
sessions: {
/** All sessions */
all: (includeArchived?: boolean) => ['sessions', { includeArchived }] as const,
/** Session history */
history: (sessionId: string) => ['sessions', sessionId, 'history'] as const,
/** Session queue */
queue: (sessionId: string) => ['sessions', sessionId, 'queue'] as const,
},
// ============================================
// Running Agents
// ============================================
runningAgents: {
/** All running agents */
all: () => ['runningAgents'] as const,
},
// ============================================
// Auto Mode
// ============================================
autoMode: {
/** Auto mode status */
status: (projectPath?: string) => ['autoMode', 'status', projectPath] as const,
/** Context exists check */
contextExists: (projectPath: string, featureId: string) =>
['autoMode', projectPath, featureId, 'context'] as const,
},
// ============================================
// Ideation
// ============================================
ideation: {
/** Ideation prompts */
prompts: () => ['ideation', 'prompts'] as const,
/** Ideas for a project */
ideas: (projectPath: string) => ['ideation', 'ideas', projectPath] as const,
/** Single idea */
idea: (projectPath: string, ideaId: string) =>
['ideation', 'ideas', projectPath, ideaId] as const,
/** Session */
session: (projectPath: string, sessionId: string) =>
['ideation', 'session', projectPath, sessionId] as const,
},
// ============================================
// CLI Status
// ============================================
cli: {
/** Claude CLI status */
claude: () => ['cli', 'claude'] as const,
/** Cursor CLI status */
cursor: () => ['cli', 'cursor'] as const,
/** Codex CLI status */
codex: () => ['cli', 'codex'] as const,
/** OpenCode CLI status */
opencode: () => ['cli', 'opencode'] as const,
/** Gemini CLI status */
gemini: () => ['cli', 'gemini'] as const,
/** Copilot SDK status */
copilot: () => ['cli', 'copilot'] as const,
/** GitHub CLI status */
github: () => ['cli', 'github'] as const,
/** API keys status */
apiKeys: () => ['cli', 'apiKeys'] as const,
/** Platform info */
platform: () => ['cli', 'platform'] as const,
},
// ============================================
// Cursor Permissions
// ============================================
cursorPermissions: {
/** Cursor permissions for a project */
permissions: (projectPath?: string) => ['cursorPermissions', projectPath] as const,
},
// ============================================
// Workspace
// ============================================
workspace: {
/** Workspace config */
config: () => ['workspace', 'config'] as const,
/** Workspace directories */
directories: () => ['workspace', 'directories'] as const,
},
// ============================================
// MCP (Model Context Protocol)
// ============================================
mcp: {
/** MCP server tools */
tools: (serverId: string) => ['mcp', 'tools', serverId] as const,
},
// ============================================
// Pipeline
// ============================================
pipeline: {
/** Pipeline config for a project */
config: (projectPath: string) => ['pipeline', projectPath] as const,
},
// ============================================
// Suggestions
// ============================================
suggestions: {
/** Suggestions status */
status: () => ['suggestions', 'status'] as const,
},
// ============================================
// Spec Regeneration
// ============================================
specRegeneration: {
/** Spec regeneration status */
status: (projectPath?: string) => ['specRegeneration', 'status', projectPath] as const,
},
// ============================================
// Spec
// ============================================
spec: {
/** Spec file content */
file: (projectPath: string) => ['spec', 'file', projectPath] as const,
},
// ============================================
// Context
// ============================================
context: {
/** File description */
file: (filePath: string) => ['context', 'file', filePath] as const,
/** Image description */
image: (imagePath: string) => ['context', 'image', imagePath] as const,
},
// ============================================
// File System
// ============================================
fs: {
/** Directory listing */
readdir: (dirPath: string) => ['fs', 'readdir', dirPath] as const,
/** File existence */
exists: (filePath: string) => ['fs', 'exists', filePath] as const,
/** File stats */
stat: (filePath: string) => ['fs', 'stat', filePath] as const,
},
// ============================================
// Git
// ============================================
git: {
/** Git diffs for a project */
diffs: (projectPath: string) => ['git', 'diffs', projectPath] as const,
/** File diff */
fileDiff: (projectPath: string, filePath: string) =>
['git', 'diffs', projectPath, filePath] as const,
},
} as const;
/**
* Type helper to extract query key types
*/
export type QueryKeys = typeof queryKeys;
|