Skip to content

Commit 48afaa6

Browse files
committed
style: apply Prettier formatting across web package
1 parent 6e9820d commit 48afaa6

File tree

30 files changed

+334
-185
lines changed

30 files changed

+334
-185
lines changed

web/scripts/discord/index.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function shutdown(exitCode: number = 0) {
2424
isShuttingDown = true
2525

2626
console.log('Shutting down Discord bot...')
27-
27+
2828
if (discordClient) {
2929
try {
3030
discordClient.destroy()
@@ -33,12 +33,12 @@ async function shutdown(exitCode: number = 0) {
3333
}
3434
discordClient = null
3535
}
36-
36+
3737
if (lockHandle) {
3838
await lockHandle.release()
3939
lockHandle = null
4040
}
41-
41+
4242
process.exit(exitCode)
4343
}
4444

@@ -51,7 +51,9 @@ async function main() {
5151

5252
while (!isShuttingDown) {
5353
attemptCount++
54-
console.log(`Attempting to acquire Discord bot lock (attempt ${attemptCount})...`)
54+
console.log(
55+
`Attempting to acquire Discord bot lock (attempt ${attemptCount})...`,
56+
)
5557

5658
let acquired = false
5759
let handle: LockHandle | null = null
@@ -63,14 +65,17 @@ async function main() {
6365
consecutiveErrors = 0 // Reset on successful DB connection
6466
} catch (error) {
6567
consecutiveErrors++
66-
console.error(`Error acquiring lock (${consecutiveErrors}/${MAX_CONSECUTIVE_ERRORS}):`, error)
67-
68+
console.error(
69+
`Error acquiring lock (${consecutiveErrors}/${MAX_CONSECUTIVE_ERRORS}):`,
70+
error,
71+
)
72+
6873
if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
6974
console.error('Too many consecutive errors, exiting...')
7075
await shutdown(1)
7176
return
7277
}
73-
78+
7479
await sleep(LOCK_RETRY_INTERVAL_MS)
7580
continue
7681
}
@@ -112,12 +117,12 @@ async function main() {
112117
return
113118
} catch (error) {
114119
console.error('Failed to start Discord bot:', error)
115-
120+
116121
// Release the lock so another instance can try
117122
await handle.release()
118123
lockHandle = null
119124
discordClient = null
120-
125+
121126
// Continue polling - maybe another instance will have better luck,
122127
// or maybe the issue is transient (Discord outage)
123128
console.log(`Will retry in ${LOCK_RETRY_INTERVAL_MS / 1000} seconds...`)

web/scripts/prebuild-agents-cache.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ async function main() {
1717
const agents = await fetchAgentsWithMetrics()
1818
const duration = Date.now() - startTime
1919

20-
console.log(`[Prebuild] Successfully fetched ${agents.length} agents in ${duration}ms`)
20+
console.log(
21+
`[Prebuild] Successfully fetched ${agents.length} agents in ${duration}ms`,
22+
)
2123
console.log('[Prebuild] Data pipeline validated - ready for deployment')
2224

2325
process.exit(0)
2426
} catch (error) {
2527
console.error('[Prebuild] Failed to fetch agents data:', error)
2628
// Don't fail the build - health check will warm cache at runtime
27-
console.error('[Prebuild] WARNING: Data fetch failed, relying on runtime health check')
29+
console.error(
30+
'[Prebuild] WARNING: Data fetch failed, relying on runtime health check',
31+
)
2832
process.exit(0)
2933
}
3034
}

web/src/__tests__/docs/content-integrity.test.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import path from 'path'
1010
import matter from 'gray-matter'
1111

1212
const CONTENT_DIR = path.join(process.cwd(), 'src/content')
13-
const VALID_SECTIONS = ['help', 'tips', 'advanced', 'agents', 'walkthroughs', 'case-studies']
13+
const VALID_SECTIONS = [
14+
'help',
15+
'tips',
16+
'advanced',
17+
'agents',
18+
'walkthroughs',
19+
'case-studies',
20+
]
1421

1522
// Get all MDX files recursively
1623
function getMdxFiles(dir: string): string[] {
@@ -38,7 +45,12 @@ function extractInternalLinks(content: string): string[] {
3845
while ((match = linkRegex.exec(content)) !== null) {
3946
const url = match[2]
4047
// Only collect internal links (starting with / or relative paths to docs)
41-
if (url.startsWith('/docs/') || url.startsWith('/publishers/') || url.startsWith('/pricing') || url.startsWith('/store')) {
48+
if (
49+
url.startsWith('/docs/') ||
50+
url.startsWith('/publishers/') ||
51+
url.startsWith('/pricing') ||
52+
url.startsWith('/store')
53+
) {
4254
links.push(url)
4355
}
4456
}
@@ -63,20 +75,20 @@ describe('Documentation Content Integrity', () => {
6375
mdxFiles.map((f) => {
6476
const relative = path.relative(CONTENT_DIR, f)
6577
return relative.split(path.sep)[0]
66-
})
78+
}),
6779
)
6880

6981
// At least some expected sections should exist
7082
const hasExpectedSections = VALID_SECTIONS.some((section) =>
71-
categories.has(section)
83+
categories.has(section),
7284
)
7385
expect(hasExpectedSections).toBe(true)
7486
})
7587
})
7688

7789
describe('Frontmatter Validation', () => {
7890
it.each(
79-
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f])
91+
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f]),
8092
)('%s has valid frontmatter', (relativePath, filePath) => {
8193
const content = fs.readFileSync(filePath as string, 'utf-8')
8294
const { data: frontmatter } = matter(content)
@@ -120,7 +132,9 @@ describe('Documentation Content Integrity', () => {
120132

121133
// Check for duplicates
122134
if (slugsByCategory[category].includes(slug)) {
123-
throw new Error(`Duplicate slug "${slug}" found in category "${category}"`)
135+
throw new Error(
136+
`Duplicate slug "${slug}" found in category "${category}"`,
137+
)
124138
}
125139

126140
slugsByCategory[category].push(slug)
@@ -148,7 +162,7 @@ describe('Documentation Content Integrity', () => {
148162
})
149163

150164
it.each(
151-
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f])
165+
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f]),
152166
)('%s has valid internal doc links', (relativePath, filePath) => {
153167
const content = fs.readFileSync(filePath as string, 'utf-8')
154168
const links = extractInternalLinks(content)
@@ -181,7 +195,7 @@ describe('Documentation Content Integrity', () => {
181195

182196
describe('Content Quality', () => {
183197
it.each(
184-
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f])
198+
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f]),
185199
)('%s has non-empty content', (relativePath, filePath) => {
186200
const content = fs.readFileSync(filePath as string, 'utf-8')
187201
const { content: mdxContent } = matter(content)
@@ -191,7 +205,7 @@ describe('Documentation Content Integrity', () => {
191205
})
192206

193207
it.each(
194-
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f])
208+
getMdxFiles(CONTENT_DIR).map((f) => [path.relative(CONTENT_DIR, f), f]),
195209
)('%s has a heading', (relativePath, filePath) => {
196210
const content = fs.readFileSync(filePath as string, 'utf-8')
197211
const { content: mdxContent } = matter(content)

web/src/__tests__/e2e/docs.spec.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
1111
test.describe('Doc Landing Page', () => {
1212
test('loads the docs index page', async ({ page }) => {
1313
await page.goto('/docs')
14-
14+
1515
// Should have documentation content or redirect to first doc
1616
await expect(page).toHaveURL(/\/docs/)
1717
})
@@ -57,7 +57,9 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
5757

5858
// Click and verify navigation
5959
await firstLink.click()
60-
await expect(page).toHaveURL(new RegExp(href!.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')))
60+
await expect(page).toHaveURL(
61+
new RegExp(href!.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')),
62+
)
6163
}
6264
})
6365
})
@@ -67,7 +69,9 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
6769
await page.goto('/docs/help/quick-start')
6870

6971
// Look for next button
70-
const nextButton = page.locator('a:has-text("Next"), a[href*="/docs/"]:has(svg)')
72+
const nextButton = page.locator(
73+
'a:has-text("Next"), a[href*="/docs/"]:has(svg)',
74+
)
7175
const count = await nextButton.count()
7276

7377
if (count > 0) {
@@ -107,11 +111,15 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
107111
await expect(heading).toContainText(/best practices/i)
108112
})
109113

110-
test('agents overview renders mermaid diagrams or code', async ({ page }) => {
114+
test('agents overview renders mermaid diagrams or code', async ({
115+
page,
116+
}) => {
111117
await page.goto('/docs/agents/overview')
112118

113119
// Should have either mermaid diagram or code block for the flowchart
114-
const mermaidOrCode = page.locator('.mermaid, pre:has-text("flowchart"), [class*="mermaid"]')
120+
const mermaidOrCode = page.locator(
121+
'.mermaid, pre:has-text("flowchart"), [class*="mermaid"]',
122+
)
115123
const count = await mermaidOrCode.count()
116124

117125
// Page should at least render without errors - mermaid may or may not render in test env
@@ -128,7 +136,9 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
128136
await page.goto('/docs/help/quick-start')
129137

130138
// Should have a mobile menu trigger (bottom sheet or hamburger)
131-
const mobileMenu = page.locator('button:has(svg), [class*="lg:hidden"]').first()
139+
const mobileMenu = page
140+
.locator('button:has(svg), [class*="lg:hidden"]')
141+
.first()
132142
await expect(mobileMenu).toBeVisible()
133143
})
134144
})
@@ -142,7 +152,9 @@ test.describe('Documentation Pages', { tag: '@docs' }, () => {
142152
expect(h1Count).toBeGreaterThanOrEqual(1)
143153

144154
// h1 should come before h2s in the main content
145-
const headings = await page.locator('article h1, article h2, article h3').allTextContents()
155+
const headings = await page
156+
.locator('article h1, article h2, article h3')
157+
.allTextContents()
146158
expect(headings.length).toBeGreaterThan(0)
147159
})
148160

web/src/__tests__/e2e/store-hydration.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ if (isBun) {
5959

6060
if (html.match(/Copy: .*--agent/)) {
6161
// SSR already provided agents; hydration fetch is not expected.
62-
await expect(
63-
page.getByTitle(/Copy: .*--agent/).first(),
64-
).toBeVisible()
62+
await expect(page.getByTitle(/Copy: .*--agent/).first()).toBeVisible()
6563
return
6664
}
6765

6866
// Expect the agent card to render after hydration by checking the copy button title
69-
await expect(
70-
page.getByTitle(/Copy: .*--agent/).first(),
71-
).toBeVisible()
67+
await expect(page.getByTitle(/Copy: .*--agent/).first()).toBeVisible()
7268
})
7369
}

web/src/app/affiliates/affiliates-client.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,9 @@ function SetHandleForm({
107107

108108
export default function AffiliatesClient() {
109109
const { status: sessionStatus } = useSession()
110-
const [
111-
userProfile,
112-
setUserProfile,
113-
] = useState<{ handle: string | null; referralCode: string | null } | undefined>(
114-
undefined,
115-
)
110+
const [userProfile, setUserProfile] = useState<
111+
{ handle: string | null; referralCode: string | null } | undefined
112+
>(undefined)
116113
const [fetchError, setFetchError] = useState<string | null>(null)
117114

118115
const fetchUserProfile = useCallback(() => {

web/src/app/api/admin/relabel-for-user/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ interface BigQueryTimestamp {
4040
value?: string | number
4141
}
4242

43-
4443
const STATIC_SESSION_ID = 'relabel-trace-api'
4544
const DEFAULT_RELABEL_LIMIT = 10
4645
const FULL_FILE_CONTEXT_SUFFIX = '-with-full-file-context'
@@ -115,9 +114,10 @@ export async function POST(req: NextRequest) {
115114
const apiKey = getApiKeyFromRequest(req)
116115
if (!apiKey) {
117116
return NextResponse.json(
118-
{
117+
{
119118
error: 'API key required',
120-
details: 'Provide your API key via Authorization header (Bearer token).',
119+
details:
120+
'Provide your API key via Authorization header (Bearer token).',
121121
hint: 'Visit /usage in the web app to create an API key.',
122122
},
123123
{ status: 401 },
@@ -317,7 +317,7 @@ async function relabelUsingFullFilesForUser(params: {
317317
}
318318

319319
const results = await Promise.allSettled(relabelPromises)
320-
320+
321321
// Log any failures from parallel relabeling
322322
for (const result of results) {
323323
if (result.status === 'rejected') {

web/src/app/api/agents/[publisherId]/[agentId]/[version]/dependencies/_get.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@ interface PendingLookup {
3232
/**
3333
* Creates a batching agent lookup function that automatically batches
3434
* concurrent requests into a single database query.
35-
*
35+
*
3636
* This solves the N+1 query problem: when the tree builder processes siblings
3737
* in parallel with Promise.all, all their lookupAgent calls will be queued
3838
* and executed in a single batch query.
39-
*
39+
*
4040
* Query reduction: ~2N queries -> ~maxDepth queries (typically ≤6 total)
4141
*/
42-
function createBatchingAgentLookup(
43-
publisherSet: Set<string>,
44-
logger: Logger,
45-
) {
42+
function createBatchingAgentLookup(publisherSet: Set<string>, logger: Logger) {
4643
const cache = new Map<string, AgentLookupResult | null>()
4744
const pending: PendingLookup[] = []
4845
let batchScheduled = false
@@ -95,13 +92,16 @@ function createBatchingAgentLookup(
9592
// Create lookup map for quick access
9693
const agentMap = new Map<string, typeof schema.agentConfig.$inferSelect>()
9794
for (const agent of agents) {
98-
agentMap.set(`${agent.publisher_id}:${agent.id}:${agent.version}`, agent)
95+
agentMap.set(
96+
`${agent.publisher_id}:${agent.id}:${agent.version}`,
97+
agent,
98+
)
9999
}
100100

101101
// Resolve all pending requests
102102
for (const req of batch) {
103103
const cacheKey = `${req.publisher}/${req.agentId}@${req.version}`
104-
104+
105105
// Resolve duplicates from cache
106106
if (cache.has(cacheKey)) {
107107
req.resolve(cache.get(cacheKey) ?? null)

web/src/app/api/auth/cli/logout/__tests__/helpers.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ describe('logout/_helpers', () => {
1515

1616
describe('when fingerprintMatchFound is false', () => {
1717
test('returns true when stored hash matches provided hash', () => {
18-
expect(shouldUnclaim(false, 'matching-hash', 'matching-hash')).toBe(true)
18+
expect(shouldUnclaim(false, 'matching-hash', 'matching-hash')).toBe(
19+
true,
20+
)
1921
})
2022

2123
test('returns false when stored hash does not match provided hash', () => {
22-
expect(shouldUnclaim(false, 'stored-hash', 'different-hash')).toBe(false)
24+
expect(shouldUnclaim(false, 'stored-hash', 'different-hash')).toBe(
25+
false,
26+
)
2327
})
2428

2529
test('returns false when stored hash is null', () => {

web/src/app/api/auth/cli/logout/_helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ export function shouldUnclaim(
33
storedHash: string | null | undefined,
44
providedHash: string,
55
): boolean {
6-
return fingerprintMatchFound || (storedHash != null && storedHash === providedHash)
6+
return (
7+
fingerprintMatchFound || (storedHash != null && storedHash === providedHash)
8+
)
79
}

0 commit comments

Comments
 (0)