Skip to content

Fix/test typescript errors#472

Merged
InfinityBowman merged 3 commits into
mainfrom
fix/test-typescript-errors
Apr 9, 2026
Merged

Fix/test typescript errors#472
InfinityBowman merged 3 commits into
mainfrom
fix/test-typescript-errors

Conversation

@InfinityBowman
Copy link
Copy Markdown
Owner

@InfinityBowman InfinityBowman commented Apr 7, 2026

Summary by CodeRabbit

Release Notes

  • Chores

    • Removed MCP (Model Context Protocol) server package and all associated tools (icons search, linting, documentation fetching, authentication docs, code review).
    • Updated development documentation to reference upstream library sources via local reference/ directory instead of MCP tools.
    • Removed MCP configuration from development environment setups.
  • Tests

    • Improved TypeScript type safety across test suites with explicit type annotations and improved type casting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

This PR removes the entire MCP (Model Context Protocol) server package (packages/mcp) and all related configurations, tooling references, and tests from the monorepo. It also updates multiple test files across the web package to add stricter TypeScript type annotations and improve type safety.

Changes

Cohort / File(s) Summary
Configuration Cleanup
knip.config.ts, package.json
Removed MCP workspace configuration and initialize-mcp script entry.
CI/CD & Build Configuration
.github/dependabot.yml, .mcp.json, .vscode/mcp.json, .mcp.md
Removed Dependabot configuration for MCP package and MCP server entries from tool configuration files.
Documentation & Guidance
.claude/CLAUDE.md, .github/Contributing.md, .github/copilot-instructions.md, README.md
Removed MCP package references and updated guidance to prefer local reference/ directories over MCP tools for accessing upstream library documentation.
MCP Package Deletion
packages/mcp/* (all contents including src/{server,constants,types,tools/*,docs/*,scrape-icons.ts}, .gitignore, package.json, tsconfig.json, vitest.config.ts, README.md, __tests__/*, iconSearch.js)
Complete removal of the MCP server package, including entrypoint, configuration files, seven tool modules (better-auth, code-review, drizzle, icons, lint, local-docs, stripe), tests, cached documentation, and utility scripts.
Status Documentation
packages/docs/STATUS.md
Removed @corates/mcp package entry from feature status table.
Web Package Type Safety
packages/web/src/api/__tests__/better-auth-store.test.ts, packages/web/src/components/checklist/__tests__/checklist*.test.ts, packages/web/src/components/checklist/ROBINSIChecklist/__tests__/robins-scoring.test.ts, packages/web/src/hooks/__tests__/useAddStudies/{deduplication,matching}.test.ts, packages/web/src/lib/__tests__/{access,checklist-domain,entitlements,form-errors,pdfUtils,pdfValidation,referenceLookup,referenceParser}.test.ts, packages/web/src/primitives/__tests__/{avatarCache,db,pdfCache}.test.ts, packages/web/src/primitives/useProject/checklists/handlers/{rob2,robins-i}.test.ts
Added stricter TypeScript type annotations, type imports, local helper wrappers, and type assertions across test utilities and fixtures to improve compile-time type safety and reduce type mismatches with production code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Fix/test typescript errors' is misleading and does not accurately represent the main changes in this pull request, which primarily involve removing the entire packages/mcp package and its related configurations. Update the title to reflect the primary change, such as 'Remove packages/mcp MCP server package' or 'Remove corates MCP server and related integrations'.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-typescript-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
corates 7907ad7 Apr 07 2026, 09:36 PM

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (5)
packages/web/src/lib/__tests__/referenceParser.test.ts (2)

156-176: Consider using Partial<NormalizedReference> instead of double assertion.

The as unknown as NormalizedReference pattern bypasses type safety entirely. If getRefDisplayName only needs firstAuthor and publicationYear, consider updating its signature to accept Partial<NormalizedReference> or Pick<NormalizedReference, 'firstAuthor' | 'publicationYear'>. This would allow test fixtures to remain partial without unsafe casts.

If changing the function signature isn't feasible, the current approach with the explanatory comment is acceptable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/lib/__tests__/referenceParser.test.ts` around lines 156 -
176, Update the tests to avoid the unsafe "as unknown as NormalizedReference"
cast by using proper partial types or adjusting the function signature: either
change the test fixtures to be typed as Partial<NormalizedReference> (or
Pick<NormalizedReference, 'firstAuthor' | 'publicationYear'>) when calling
getRefDisplayName, or change getRefDisplayName's parameter type from
NormalizedReference to Partial<NormalizedReference> (or the Pick variant) so
partial objects are accepted without double assertions; reference
getRefDisplayName and NormalizedReference when making the change.

6-12: Use the @/ import alias per project conventions.

The import should use the configured alias instead of a relative path.

As per coding guidelines: "Use import aliases from jsconfig.json, with @/ mapping to packages/web/src/"

Suggested fix
-import {
-  parseRIS,
-  parseBibTeX,
-  parseReferences,
-  getRefDisplayName,
-  type NormalizedReference,
-} from '../referenceParser.js';
+import {
+  parseRIS,
+  parseBibTeX,
+  parseReferences,
+  getRefDisplayName,
+  type NormalizedReference,
+} from '@/lib/referenceParser.js';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/lib/__tests__/referenceParser.test.ts` around lines 6 - 12,
Update the import path in the test to use the project alias: replace the
relative import of referenceParser.js with the "@/lib/referenceParser.js" alias
so the named imports (parseRIS, parseBibTeX, parseReferences, getRefDisplayName,
NormalizedReference) are imported via the configured jsconfig alias instead of a
relative path.
.claude/CLAUDE.md (1)

153-153: Harden the clone guidance for reproducibility and safety.

Line 153 is good, but the command should prefer pinning to a tag/commit and explicitly avoid executing code from reference/ clones. That reduces supply-chain and drift risk in agent workflows.

Proposed doc tweak
-- **External library docs**: Prefer reading source from cloned upstream repos in the `reference/` directory over ad-hoc web fetches. If a library isn't there yet and you need its source, clone it in with `git clone --depth 20 https://github.com/owner/repo.git reference/repo`. This works better than MCP-style doc fetchers for deep questions.
+- **External library docs**: Prefer reading source from cloned upstream repos in the `reference/` directory over ad-hoc web fetches. If a library isn't there yet, clone it with a pinned ref when possible (tag or commit), for example:
+- `git clone --depth 1 --branch <tag-or-release> https://github.com/owner/repo.git reference/repo`
+- Treat `reference/` as read-only documentation context; do not run code from cloned repos.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/CLAUDE.md at line 153, Update the "External library docs" guidance
(the paragraph that currently shows the git clone command) to recommend cloning
with a pinned tag or commit (e.g., mention using --branch <tag> or cloning then
checking out a specific commit) and add an explicit warning to never execute
code from the reference/ clones (treat them as read-only artifacts) to reduce
supply-chain and drift risk; ensure the revised text replaces the existing
sentence that contains the git clone example and keeps the intent of preferring
cloned upstream repos for deep questions.
packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts (1)

27-31: Consider resetting fixtureIdCounter in test setup.

The counter is never reset between test runs, which could cause non-deterministic IDs across test files if tests depend on specific ID values. While current tests don't appear to rely on specific IDs, consider adding a beforeEach reset for robustness.

Optional: Reset counter between tests
+beforeEach(() => {
+  fixtureIdCounter = 0;
+});
+
 let fixtureIdCounter = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts` around
lines 27 - 31, Reset the shared fixtureIdCounter between tests to avoid
non-deterministic IDs: add a test setup hook (e.g., a beforeEach in this test
file) that sets fixtureIdCounter = 0 so nextId(prefix) generates deterministic
IDs; reference the existing fixtureIdCounter and nextId helper to locate where
to add the beforeEach reset.
packages/web/src/lib/__tests__/checklist-domain.test.ts (1)

710-712: Remove unnecessary as string cast on enum value.

CHECKLIST_STATUS.IN_PROGRESS is already typed as the string literal 'in-progress'. This cast serves no purpose and is inconsistent with how the same constant is used throughout the codebase without casting. The test fixture's createChecklist() helper (line 27) demonstrates the correct pattern—no cast is needed. Remove the as string cast to maintain type safety and consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/lib/__tests__/checklist-domain.test.ts` around lines 710 -
712, Remove the unnecessary type cast on the enum value: delete the "as string"
cast on CHECKLIST_STATUS.IN_PROGRESS in the test fixture where checklists are
defined; use CHECKLIST_STATUS.IN_PROGRESS directly (matching the
createChecklist() helper usage) to restore correct typing and consistency with
the codebase.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/Contributing.md:
- Line 154: Change the mismatched singular/plural in the sentence "If asked to
create a plan file, agents will create them in `packages/docs/audits`" so the
subject and pronoun agree; either make the subject plural ("If asked to create
plan files, agents will create them in `packages/docs/audits`.") or make the
pronoun singular ("If asked to create a plan file, an agent will create it in
`packages/docs/audits`."). Update the sentence accordingly in Contributing.md.

In `@packages/web/src/api/__tests__/better-auth-store.test.ts`:
- Around line 382-384: Replace the direct assignment to window.location in the
test (the line using (global.window as { location: { origin: string }
}).location = { origin: 'http://localhost:5173' }) with the same
delete-then-assign pattern used elsewhere: delete (global.window as
any).location; then assign the new location object so the read-only DOM typing
is bypassed consistently; update any related teardown to restore location if
present.

In `@packages/web/src/lib/__tests__/form-errors.test.ts`:
- Line 10: The import uses a relative path; change it to the repo alias by
replacing "../form-errors.js" with the "@/lib/form-errors.js" alias so the test
imports handleFormError (handleFormErrorStrict) and createFormErrorState via the
configured `@/` mapping; update the import statement in form-errors.test.ts to use
"@/lib/form-errors.js" to comply with jsconfig.json aliasing rules.

In `@packages/web/src/primitives/__tests__/db.test.ts`:
- Around line 10-11: The test imports use relative paths—replace the two imports
of '../db.js' so they use the repo alias (@" mapping to packages/web/src/)
instead of relative imports; update both import lines that reference DbModule
and ProjectRow in db.test.ts to import from the aliased path (e.g.,
'@/primitives/db' or '@/primitives/db.js') so they follow the jsconfig.json `@/`
mapping and align with repo import policy.

---

Nitpick comments:
In @.claude/CLAUDE.md:
- Line 153: Update the "External library docs" guidance (the paragraph that
currently shows the git clone command) to recommend cloning with a pinned tag or
commit (e.g., mention using --branch <tag> or cloning then checking out a
specific commit) and add an explicit warning to never execute code from the
reference/ clones (treat them as read-only artifacts) to reduce supply-chain and
drift risk; ensure the revised text replaces the existing sentence that contains
the git clone example and keeps the intent of preferring cloned upstream repos
for deep questions.

In `@packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts`:
- Around line 27-31: Reset the shared fixtureIdCounter between tests to avoid
non-deterministic IDs: add a test setup hook (e.g., a beforeEach in this test
file) that sets fixtureIdCounter = 0 so nextId(prefix) generates deterministic
IDs; reference the existing fixtureIdCounter and nextId helper to locate where
to add the beforeEach reset.

In `@packages/web/src/lib/__tests__/checklist-domain.test.ts`:
- Around line 710-712: Remove the unnecessary type cast on the enum value:
delete the "as string" cast on CHECKLIST_STATUS.IN_PROGRESS in the test fixture
where checklists are defined; use CHECKLIST_STATUS.IN_PROGRESS directly
(matching the createChecklist() helper usage) to restore correct typing and
consistency with the codebase.

In `@packages/web/src/lib/__tests__/referenceParser.test.ts`:
- Around line 156-176: Update the tests to avoid the unsafe "as unknown as
NormalizedReference" cast by using proper partial types or adjusting the
function signature: either change the test fixtures to be typed as
Partial<NormalizedReference> (or Pick<NormalizedReference, 'firstAuthor' |
'publicationYear'>) when calling getRefDisplayName, or change
getRefDisplayName's parameter type from NormalizedReference to
Partial<NormalizedReference> (or the Pick variant) so partial objects are
accepted without double assertions; reference getRefDisplayName and
NormalizedReference when making the change.
- Around line 6-12: Update the import path in the test to use the project alias:
replace the relative import of referenceParser.js with the
"@/lib/referenceParser.js" alias so the named imports (parseRIS, parseBibTeX,
parseReferences, getRefDisplayName, NormalizedReference) are imported via the
configured jsconfig alias instead of a relative path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d04a1f94-48e1-4090-9561-e6aad1abf09c

📥 Commits

Reviewing files that changed from the base of the PR and between 771bce7 and 7907ad7.

⛔ Files ignored due to path filters (2)
  • packages/docs/plans/yjs-awareness.md is excluded by !packages/docs/plans/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (57)
  • .claude/CLAUDE.md
  • .github/Contributing.md
  • .github/copilot-instructions.md
  • .github/dependabot.yml
  • .mcp.json
  • .mcp.md
  • .vscode/mcp.json
  • README.md
  • knip.config.ts
  • package.json
  • packages/docs/STATUS.md
  • packages/mcp/.gitignore
  • packages/mcp/README.md
  • packages/mcp/__tests__/better-auth.test.ts
  • packages/mcp/__tests__/drizzle.test.ts
  • packages/mcp/__tests__/icons.test.ts
  • packages/mcp/__tests__/zag.test.ts
  • packages/mcp/iconSearch.js
  • packages/mcp/package.json
  • packages/mcp/src/constants.ts
  • packages/mcp/src/docs/d3/llms.txt
  • packages/mcp/src/docs/dexie/llms.txt
  • packages/mcp/src/docs/solidjs/llms.txt
  • packages/mcp/src/docs/tailwind/llms.txt
  • packages/mcp/src/docs/y-dexie/llms.txt
  • packages/mcp/src/docs/yjs/llms.txt
  • packages/mcp/src/scrape-icons.ts
  • packages/mcp/src/server.ts
  • packages/mcp/src/tools/better-auth.ts
  • packages/mcp/src/tools/code-review.ts
  • packages/mcp/src/tools/drizzle.ts
  • packages/mcp/src/tools/icons.ts
  • packages/mcp/src/tools/lint.ts
  • packages/mcp/src/tools/local-docs.ts
  • packages/mcp/src/tools/stripe.ts
  • packages/mcp/src/types.ts
  • packages/mcp/tsconfig.json
  • packages/mcp/vitest.config.ts
  • packages/web/src/api/__tests__/better-auth-store.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist-compare.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist.test.ts
  • packages/web/src/components/checklist/ROBINSIChecklist/__tests__/robins-scoring.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/matching.test.ts
  • packages/web/src/lib/__tests__/access.test.ts
  • packages/web/src/lib/__tests__/checklist-domain.test.ts
  • packages/web/src/lib/__tests__/entitlements.test.ts
  • packages/web/src/lib/__tests__/form-errors.test.ts
  • packages/web/src/lib/__tests__/pdfUtils.test.ts
  • packages/web/src/lib/__tests__/pdfValidation.test.ts
  • packages/web/src/lib/__tests__/referenceLookup.test.ts
  • packages/web/src/lib/__tests__/referenceParser.test.ts
  • packages/web/src/primitives/__tests__/avatarCache.test.ts
  • packages/web/src/primitives/__tests__/db.test.ts
  • packages/web/src/primitives/__tests__/pdfCache.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/rob2.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/robins-i.test.ts
💤 Files with no reviewable changes (33)
  • README.md
  • package.json
  • packages/mcp/tsconfig.json
  • .mcp.md
  • .mcp.json
  • .vscode/mcp.json
  • .github/dependabot.yml
  • packages/mcp/.gitignore
  • packages/mcp/src/constants.ts
  • packages/mcp/README.md
  • packages/mcp/tests/drizzle.test.ts
  • packages/mcp/tests/better-auth.test.ts
  • packages/mcp/tests/icons.test.ts
  • packages/mcp/src/types.ts
  • packages/mcp/src/scrape-icons.ts
  • packages/mcp/src/docs/yjs/llms.txt
  • packages/mcp/iconSearch.js
  • packages/mcp/package.json
  • packages/mcp/src/tools/icons.ts
  • packages/mcp/src/tools/better-auth.ts
  • packages/mcp/vitest.config.ts
  • packages/mcp/src/tools/lint.ts
  • packages/mcp/src/server.ts
  • packages/mcp/src/tools/local-docs.ts
  • packages/mcp/src/docs/y-dexie/llms.txt
  • packages/mcp/src/docs/d3/llms.txt
  • packages/mcp/src/tools/stripe.ts
  • packages/mcp/src/docs/tailwind/llms.txt
  • packages/mcp/tests/zag.test.ts
  • packages/mcp/src/tools/code-review.ts
  • knip.config.ts
  • packages/docs/STATUS.md
  • packages/mcp/src/tools/drizzle.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Workers Builds: corates
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Never use emojis or unicode symbols anywhere in code, comments, documentation, plan files, or commit messages

For UI icons, use lucide-react library or SVGs only (never emojis)

Use import aliases from jsconfig.json, with @/ mapping to packages/web/src/

Prefer modern ES6+ syntax and features

Prefer config files over hardcoding values

Code comments should explain why something is being done or provide context, not narrate what the code is saying

Keep files small, focused, and modular; extract large files into sub-modules or separate utilities

Ensure browser compatibility with Safari

Use TODO(agent): pattern for incomplete work or flags that need follow-up with brief description

Files:

  • packages/web/src/primitives/__tests__/pdfCache.test.ts
  • packages/web/src/lib/__tests__/pdfValidation.test.ts
  • packages/web/src/lib/__tests__/access.test.ts
  • packages/web/src/lib/__tests__/form-errors.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/matching.test.ts
  • packages/web/src/lib/__tests__/referenceLookup.test.ts
  • packages/web/src/lib/__tests__/checklist-domain.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/rob2.test.ts
  • packages/web/src/lib/__tests__/entitlements.test.ts
  • packages/web/src/lib/__tests__/pdfUtils.test.ts
  • packages/web/src/primitives/__tests__/db.test.ts
  • packages/web/src/components/checklist/ROBINSIChecklist/__tests__/robins-scoring.test.ts
  • packages/web/src/api/__tests__/better-auth-store.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist-compare.test.ts
  • packages/web/src/lib/__tests__/referenceParser.test.ts
  • packages/web/src/primitives/__tests__/avatarCache.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/robins-i.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts
packages/web/src/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use shadcn/ui for UI components from @/components/ui/

Use TanStack Router with file-based routing via createFileRoute

Use TanStack Query for server state management with useQuery and useMutation

Use Recharts for data visualization in admin charts

Use Better-Auth for authentication and user management

Files:

  • packages/web/src/primitives/__tests__/pdfCache.test.ts
  • packages/web/src/lib/__tests__/pdfValidation.test.ts
  • packages/web/src/lib/__tests__/access.test.ts
  • packages/web/src/lib/__tests__/form-errors.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/matching.test.ts
  • packages/web/src/lib/__tests__/referenceLookup.test.ts
  • packages/web/src/lib/__tests__/checklist-domain.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/rob2.test.ts
  • packages/web/src/lib/__tests__/entitlements.test.ts
  • packages/web/src/lib/__tests__/pdfUtils.test.ts
  • packages/web/src/primitives/__tests__/db.test.ts
  • packages/web/src/components/checklist/ROBINSIChecklist/__tests__/robins-scoring.test.ts
  • packages/web/src/api/__tests__/better-auth-store.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist.test.ts
  • packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist-compare.test.ts
  • packages/web/src/lib/__tests__/referenceParser.test.ts
  • packages/web/src/primitives/__tests__/avatarCache.test.ts
  • packages/web/src/primitives/useProject/checklists/handlers/robins-i.test.ts
  • packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
URL: 
File: .github/copilot-instructions.md:undefined-undefined
Timestamp: 2026-04-07T21:39:08.475Z
Learning: Maintain source of truth policy: Documentation is authoritative. If code conflicts with documentation, either fix the code or update the documentation
Learnt from: CR
URL: 
File: .github/copilot-instructions.md:undefined-undefined
Timestamp: 2026-04-07T21:39:08.475Z
Learning: Read documentation in order: core instructions, STATUS.md, AGENTS.md, then relevant guides from packages/docs/guides/
Learnt from: CR
URL: 
File: .github/copilot-instructions.md:undefined-undefined
Timestamp: 2026-04-07T21:39:08.475Z
Learning: Never bypass Drizzle for database access
Learnt from: CR
URL: 
File: .github/copilot-instructions.md:undefined-undefined
Timestamp: 2026-04-07T21:39:08.475Z
Learning: Never prop-drill shared state; import Zustand stores directly instead
Learnt from: CR
URL: 
File: .github/copilot-instructions.md:undefined-undefined
Timestamp: 2026-04-07T21:39:08.475Z
Learning: Group related components in subdirectories with barrel exports
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/{workers,shared}/**/*.{ts,tsx} : Use Better-Auth for authentication and user management

Applied to files:

  • .github/Contributing.md
  • .claude/CLAUDE.md
  • packages/web/src/api/__tests__/better-auth-store.test.ts
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/{workers,shared}/**/*.{ts,tsx} : Use Zod for schema and input validation on the backend

Applied to files:

  • .github/Contributing.md
  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/**/*.{tsx,ts} : Use `useSyncExternalStore` for external store subscriptions (e.g., Yjs awareness)

Applied to files:

  • packages/web/src/lib/__tests__/access.test.ts
  • packages/web/src/primitives/__tests__/db.test.ts
  • packages/web/src/api/__tests__/better-auth-store.test.ts
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/routes/**/*.{ts,tsx} : Use TanStack Router with file-based routing using `createFileRoute`

Applied to files:

  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/**/*.{tsx,ts} : Use TanStack Query for server state management with `useQuery` and `useMutation`

Applied to files:

  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Cloudflare Pages is NOT used; only Cloudflare Workers

Applied to files:

  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/**/*.{tsx,ts} : Use shadcn/ui for UI components (Radix-based, located in `@/components/ui/`)

Applied to files:

  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/components/**/*.{tsx,ts} : Group related components in subdirectories with barrel exports

Applied to files:

  • .claude/CLAUDE.md
  • .github/copilot-instructions.md
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/**/*.{tsx,ts} : Use `useId()` for unique IDs on form elements (radio buttons, checkboxes)

Applied to files:

  • packages/web/src/hooks/__tests__/useAddStudies/matching.test.ts
📚 Learning: 2026-01-17T00:25:03.945Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/instructions/api-routes.instructions.md:0-0
Timestamp: 2026-01-17T00:25:03.945Z
Learning: Applies to packages/workers/**/routes/**/*.{js,ts} : Create DB client from environment using `createDb(c.env.DB)` instead of creating DB connections directly

Applied to files:

  • packages/web/src/primitives/__tests__/db.test.ts
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/stores/**/*.{ts,tsx} : Use Zustand for client state management; store files should be located in `@/stores/`

Applied to files:

  • packages/web/src/api/__tests__/better-auth-store.test.ts
📚 Learning: 2026-03-29T04:40:36.262Z
Learnt from: CR
Repo: InfinityBowman/corates PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-29T04:40:36.262Z
Learning: Applies to packages/web/src/**/*.{ts,tsx,js,jsx} : Use import aliases from jsconfig.json; `@/` maps to `packages/web/src/`

Applied to files:

  • packages/web/src/lib/__tests__/referenceParser.test.ts
🪛 LanguageTool
.claude/CLAUDE.md

[style] ~153-~153: Consider a different adjective to strengthen your wording.
Context: ... better than MCP-style doc fetchers for deep questions. - TanStack documentation...

(DEEP_PROFOUND)

🔇 Additional comments (33)
packages/web/src/lib/__tests__/pdfValidation.test.ts (2)

8-17: Typed test helper update looks good.

MockFileOptions plus the typed createMockFile(...): File signature makes the helper safer and clearer without adding complexity.


170-172: Good type-safe assertion guard in skipped magic-bytes test.

Conditionally asserting result.error only when result.valid is false avoids unsafe access and keeps the expectation aligned with the result shape.

packages/web/src/lib/__tests__/pdfUtils.test.ts (3)

32-41: LGTM!

The TypeScript type annotation (title: string): string is correct and improves type safety for this test helper function.


153-162: LGTM!

The MockFileReader class now has properly typed properties and uses optional chaining (this.onerror?.()) for safe invocation. This is a clean approach for implementing a minimal mock that covers only the error handling path being tested.


164-164: Acceptable double-assertion for test mock.

The as unknown as typeof FileReader pattern is a pragmatic TypeScript workaround for mocking browser APIs with incomplete implementations. Since the mock intentionally implements only the subset needed for error testing, and the original FileReader is properly restored at line 170, this is fine for test code.

packages/web/src/lib/__tests__/referenceLookup.test.ts (2)

22-25: Type annotations on mock parser inputs look good.

This keeps the mock strict and improves test type safety without changing behavior.


45-45: DOMParser test override is acceptable for TypeScript compatibility.

The cast is clear in intent for a test-only global shim.

packages/web/src/lib/__tests__/access.test.ts (1)

9-17: Good test-only type relaxation with a single local alias.

This keeps defensive fixture coverage (Partial, null, undefined) explicit without scattering casts across the assertions.

packages/web/src/lib/__tests__/entitlements.test.ts (1)

9-41: Nice consolidation of permissive test typings for entitlements helpers.

The shared PartialSubscription and typed local aliases make the fixture surface explicit and reduce repetitive casting noise in individual tests.

.github/copilot-instructions.md (1)

142-142: Looks good — clear and actionable doc-source guidance.

The updated instruction is concise and aligns with the repo’s doc-first workflow.

packages/web/src/api/__tests__/better-auth-store.test.ts (6)

14-33: Good approach to typing the mocked auth client.

The MockedAuthClient interface paired with the loadMockedAuthClient() helper cleanly encapsulates the type bridging between the generic-heavy real client and the narrower mock surface. This avoids type gymnastics scattered throughout test cases.


101-107: Clean class-based mock for BroadcastChannel.

The class-based approach is clearer and more maintainable than function-based mocks for constructor APIs.


110-131: localStorage mock now fully implements Storage interface.

Adding length and key() with proper typing ensures the mock is complete and type-safe.


242-244: Type casts for test assertions are appropriate.

Using inline type assertions like as { twoFactorRequired: boolean } for test results is a reasonable trade-off. The assertions immediately validate the expected shape, maintaining runtime safety.


596-607: Standard fetch mock pattern.

The vi.fn() as unknown as typeof fetch assignment and subsequent vi.mocked(global.fetch) usage is the idiomatic way to mock fetch in Vitest while maintaining type safety.


37-43: Mock correctly replicates authFetch behavior.

The mock uses unknown instead of the generic T, which is appropriate for testing as it accepts any data type while preserving the error-handling semantics.

packages/web/src/primitives/useProject/checklists/handlers/robins-i.test.ts (1)

10-11: Type tightening is well-contained and test-safe.

The explicit handler/doc typing and Y.Text cast points are consistent with the runtime assertions in these tests.

Also applies to: 23-25, 36-38, 47-49, 60-63

packages/web/src/primitives/useProject/checklists/handlers/rob2.test.ts (1)

44-53: Good containment of dynamic typing in the test harness.

The typed declarations and centralized cast strategy keep dynamic Yjs access scoped and readable without changing runtime behavior.

Also applies to: 69-74, 78-79, 105-106, 125-126

packages/web/src/primitives/__tests__/db.test.ts (1)

18-28: Nice fixture refactor for ProjectRow validity and reuse.

projectFixture keeps test records schema-correct (ydoc included) and removes repeated inline setup across cases.

Also applies to: 82-83, 93-96, 87-89, 120-124, 202-204, 249-249

packages/web/src/lib/__tests__/checklist-domain.test.ts (1)

161-161: Non-null assertions are appropriate for these test assertions.

The functions getFinalizedChecklist and findReconciledChecklist return Checklist | null per their implementations. The test fixtures guarantee non-null results in these happy-path scenarios, so result!.id is the correct fix for TypeScript strict mode.

Also applies to: 175-175, 455-455, 466-466

packages/web/src/primitives/__tests__/avatarCache.test.ts (1)

31-34: Correct pattern for testing defensive runtime behavior.

The as unknown as string cast is the appropriate way to test that getCachedAvatar handles invalid inputs gracefully at runtime, while still satisfying TypeScript's type checker.

packages/web/src/primitives/__tests__/pdfCache.test.ts (1)

27-29: Non-null assertions follow prior null checks.

The tests assert expect(retrieved).not.toBeNull() before accessing properties, so the ! assertions are safe and appropriate for TypeScript narrowing.

Also applies to: 47-49

packages/web/src/hooks/__tests__/useAddStudies/matching.test.ts (1)

178-181: Non-null assertions follow toBeDefined() assertions.

Each result!.id access is preceded by expect(result).toBeDefined(), making the non-null assertions safe. This is the standard pattern when TypeScript cannot infer narrowing from test framework assertions.

Also applies to: 184-188, 199-203, 205-210, 231-234, 249-253, 259-263

packages/web/src/components/checklist/ROBINSIChecklist/__tests__/robins-scoring.test.ts (2)

10-17: Well-structured local type helpers.

The Judgement type derivation from JUDGEMENTS and the updated ans/answers helpers properly handle the nullable answer cases. The comment explains why the type is derived locally rather than imported.


861-884: Clean refactor of test fixtures with proper typing.

The score() helper encapsulates the boilerplate ScoringResult fields, and as const on judgementSource ensures the literal union type is preserved. This improves type safety without changing test semantics.

packages/web/src/hooks/__tests__/useAddStudies/deduplication.test.ts (1)

17-43: Well-designed test wrapper for partial fixtures.

The PartialSources interface and buildDeduplicatedStudies wrapper elegantly solve the problem of required id/_id fields while keeping test fixtures minimal. The auto-generated IDs ensure uniqueness, and the type casts are safe after filling required fields.

packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist-compare.test.ts (2)

26-61: Appropriate loose type wrappers for testing defensive behavior.

The LooseComparison interface and type-cast wrappers allow tests to verify null handling and partial input scenarios without fabricating full typed fixtures. The comment clearly explains the rationale.


279-282: Correct use of as const for literal union types.

The as const assertions ensure selections values are typed as 'reviewer1' | 'reviewer2' rather than string, matching the expected type of createReconciledChecklist.

packages/web/src/components/checklist/AMSTAR2Checklist/__tests__/checklist.test.ts (5)

20-23: KeyedChecklist helper type enables dynamic question access.

The intersection type AMSTAR2Checklist & Record<string, AMSTAR2Question> correctly allows indexing by dynamic question keys while preserving the base type. The comment clearly explains the need.


28-28: Standard pattern for testing validation error paths.

Using as any to bypass TypeScript for invalid input tests is the correct approach when verifying runtime validation behavior.

Also applies to: 46-46, 64-64, 68-68


179-181: Type annotations improve clarity in test helper.

The explicit Record<string, string> parameter type and AMSTAR2Checklist return type make the helper's contract clear. The KeyedChecklist cast inside enables dynamic property access.

Also applies to: 195-195


214-222: Correct casts for testing error handling.

Using null as unknown as AMSTAR2Checklist etc. allows testing that scoreChecklist handles invalid inputs gracefully while satisfying TypeScript.


502-502: Non-null assertions appropriate for consolidation tests.

The getAnswers(checklist)! pattern is acceptable here since tests verify the checklist is valid and getAnswers should return non-null for valid input. The assertions confirm expected consolidated values.

Also applies to: 511-511, 527-527, 538-538, 549-549, 560-560, 570-570, 580-580, 590-590

Comment thread .github/Contributing.md
# 2. Type "Open MCP Settings"
# 3. Find 'corates' and start it if it has not been found and started already
```
If asked to create a plan file, agents will create them in `packages/docs/audits`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix singular/plural wording for clarity.

Line 154 says “a plan file” but then uses “them.” Use singular (“it”) or pluralize the first phrase.

Proposed wording fix
-If asked to create a plan file, agents will create them in `packages/docs/audits`.
+If asked to create a plan file, agents will create it in `packages/docs/audits`.
Based on learnings: Maintain source of truth policy: Documentation is authoritative. If code conflicts with documentation, either fix the code or update the documentation.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
If asked to create a plan file, agents will create them in `packages/docs/audits`.
If asked to create a plan file, agents will create it in `packages/docs/audits`.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/Contributing.md at line 154, Change the mismatched singular/plural
in the sentence "If asked to create a plan file, agents will create them in
`packages/docs/audits`" so the subject and pronoun agree; either make the
subject plural ("If asked to create plan files, agents will create them in
`packages/docs/audits`.") or make the pronoun singular ("If asked to create a
plan file, an agent will create it in `packages/docs/audits`."). Update the
sentence accordingly in Contributing.md.

Comment on lines +382 to +384
(global.window as { location: { origin: string } }).location = {
origin: 'http://localhost:5173',
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent window.location replacement pattern.

This block directly assigns location without deleting it first, unlike lines 277-282 in the Social Auth tests which use delete before assignment. Since window.location is read-only in the DOM type definitions, the delete-first pattern is more robust.

Proposed fix for consistency
+    delete (global.window as { location?: unknown }).location;
     (global.window as { location: { origin: string } }).location = {
       origin: 'http://localhost:5173',
     };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(global.window as { location: { origin: string } }).location = {
origin: 'http://localhost:5173',
};
delete (global.window as { location?: unknown }).location;
(global.window as { location: { origin: string } }).location = {
origin: 'http://localhost:5173',
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/api/__tests__/better-auth-store.test.ts` around lines 382 -
384, Replace the direct assignment to window.location in the test (the line
using (global.window as { location: { origin: string } }).location = { origin:
'http://localhost:5173' }) with the same delete-then-assign pattern used
elsewhere: delete (global.window as any).location; then assign the new location
object so the read-only DOM typing is bypassed consistently; update any related
teardown to restore location if present.


import { describe, it, expect, vi } from 'vitest';
import { handleFormError, createFormErrorState } from '../form-errors.js';
import { handleFormError as handleFormErrorStrict, createFormErrorState } from '../form-errors.js';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Use @/ alias instead of relative import

Line 10 uses a relative import (../form-errors.js), which conflicts with the repo alias rule. Please switch to the @/ path (for example, @/lib/form-errors.js) for consistency.

As per coding guidelines: "Use import aliases from jsconfig.json, with @/ mapping to packages/web/src/"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/lib/__tests__/form-errors.test.ts` at line 10, The import
uses a relative path; change it to the repo alias by replacing
"../form-errors.js" with the "@/lib/form-errors.js" alias so the test imports
handleFormError (handleFormErrorStrict) and createFormErrorState via the
configured `@/` mapping; update the import statement in form-errors.test.ts to use
"@/lib/form-errors.js" to comply with jsconfig.json aliasing rules.

Comment on lines +10 to +11
import type * as DbModule from '../db.js';
import type { ProjectRow } from '../db.js';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use @/ aliases instead of relative imports in this test.

Line [10]-Line [11] currently use relative imports, which conflicts with repo import policy.

Proposed fix
-import type * as DbModule from '../db.js';
-import type { ProjectRow } from '../db.js';
+import type * as DbModule from '@/primitives/db.js';
+import type { ProjectRow } from '@/primitives/db.js';

As per coding guidelines **/*.{js,jsx,ts,tsx}: Use import aliases from jsconfig.json, with @/ mapping to packages/web/src/.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/primitives/__tests__/db.test.ts` around lines 10 - 11, The
test imports use relative paths—replace the two imports of '../db.js' so they
use the repo alias (@" mapping to packages/web/src/) instead of relative
imports; update both import lines that reference DbModule and ProjectRow in
db.test.ts to import from the aliased path (e.g., '@/primitives/db' or
'@/primitives/db.js') so they follow the jsconfig.json `@/` mapping and align with
repo import policy.

@InfinityBowman InfinityBowman merged commit 1526684 into main Apr 9, 2026
2 checks passed
@InfinityBowman InfinityBowman deleted the fix/test-typescript-errors branch April 9, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants