commits
This commit adds tests for the `countStarterPacks`, `checkPosts`, and
`checkProfiles` functions. These tests cover various scenarios,
including whitelisting, language filtering, URL resolution, and
moderation actions.
The URL regex was updated to be case-insensitive to ensure that
shortened URLs are correctly resolved. Also added more logging for
debugging purposes.
Allowlists are now checked via an array. Added more logging. Improved
error handling.
Refactor countStarterPacks rule
Use a whitelist for allowed DIDs and improve logging.
- Use HEAD requests first, falling back to GET - Add a user agent to the
request headers - Improve error logging - Increase the timeout to 15
seconds
This commit splits the `utils.ts` file into three separate files: -
`utils/utils.ts`: Contains the `normalizeUnicode` function. -
`utils/getFinalUrl.ts`: Contains the `getFinalUrl` function. -
`utils/getLanguage.ts`: Contains the `getLanguage` function. This
improves code organization and readability.
feat: Split utils into separate files
Move rule-related files into dedicated subdirectories to improve
organization.
1. line 124: changed replyingDid → actorDid (this was causing your
error) 2. line 126: added replyToPostURI to capture the full parent
URI 3. lines 133-158: added quote post monitoring - now detects when
someone quotes a monitored DID or post
the error should be gone now. the system will now: - monitor replies
to your configured government DIDs - monitor quote posts of those same
DIDs - monitor specific post URIs if you add them to monitoredPostURIs
Use the correct PLC URL.
Improve account age lookup by fetching the audit log from the PLC and
using `createdAt` instead of `indexedAt` from the profile.
This commit adds a check to the `checkAccountAge` function to prevent
duplicate labels from being applied to the same account. It uses the
`checkAccountLabels` function to determine if a label already exists
before attempting to create a new one. This prevents redundant labeling
and improves efficiency. Also includes unit tests for the
`checkAccountLabels` function to ensure correct behavior.
This change updates the account age check to use a date window defined
by the anchor date and max age days. Instead of calculating the age, it
now checks if the account creation date falls within the specified
window. This simplifies the logic and makes it more readable.
Additionally, the test suite has been updated to reflect the new
behavior, and a more descriptive comment has been added.
- Renamed files and directories to the `rules` structure. - Added global
allowlist check.
This adds a global allowlist to bypass moderation checks for specified
DIDs. This is to allow certain accounts to bypass checks for testing and
other use cases.
The allowlist is checked in checkHandles, checkPosts, checkProfiles, and
checkDisplayName functions.
refactor: code quality improvements and franc language detection
- Replace lande with franc for language detection
- Simplify API from probability map to single detection
- Handle "und" (undetermined) response by defaulting to "eng"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)
- Revert language detection from franc back to lande
- Add label deduplication checks in moderation functions
- Improve type safety with explicit type assertions
- Simplify check iteration logic across handle/post/profile checks
- Remove unused monitor.ts and processJetstream.ts files
- Remove test files and vitest config
- Remove temporary PLAN.md and PRD.md files
- Add duration support for post labels
- Fix import ordering and formatting issues
- Add modTool metadata to moderation events
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)
feat(language-detection): replace lande with franc
- Add unit tests for getLanguage function with franc
- Test input validation, language detection for 10+ languages
- Add critical moderation tests for English vs French 'retard' disambiguation
- Verify franc can distinguish French 'delay' from English slur usage
- Include edge cases: emojis, special chars, mixed languages
- Add vitest configuration and test scripts
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced lande v1.0.10 with franc v6.2.0 for better maintenance and performance
- Simplified getLanguage function to use franc's simpler API
- Fixed redundant null check lint issue
- Removed invalid stylistic/comma-trailing package that was breaking npm install
- Updated implementation to handle franc's "und" (undetermined) response
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit introduces new files that provide comprehensive guidelines
for contributing to the project. The updated documentation enhances
maintainability and clarity for all contributors.
Feat/env validation
Adds a function to validate environment variables. This will catch any
issues early in the startup process.
Improve async error handling
Includes tasks to validate environment and add files.
- Add validateEnv.ts with validation for all required and optional environment variables
- Validate DID format (must start with 'did:')
- Validate OZONE_URL and OZONE_PDS as domain names
- Validate BSKY_HANDLE format (must contain '.')
- Support arithmetic expressions for LABEL_LIMIT and LABEL_LIMIT_WAIT (e.g., "2900 * 1000")
- Validate numeric values for ports and intervals
- Validate LOG_LEVEL and NODE_ENV against allowed values
- Exit with code 1 and clear error messages if validation fails
- Integrated validation call at application startup in main.ts
This addresses the security concern of missing environment variable validation identified in the code review.
This commit introduces an ESLint configuration file to the project. It
includes recommended rules and best practices for TypeScript projects.
The configuration also sets up various plugins and specifies ignores to
prevent linting of certain files.
- Updated TODO section to show completed async error handling work
- Listed all resolved issues including type safety, error handling, and code quality
- Added status for all cleaned files (7 files with zero linting errors)
- Clarified remaining tasks are configuration-related, not code quality
- Fixed constants.ts.example to use type import and include knownVectors property
The codebase is now production-ready with robust error handling and modern TypeScript practices.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed unnecessary conditional check in getLanguage function
- Since parameter is typed as string, typeof check and null check are redundant
- Simplified to check for falsy values only
- Updated log message to be more accurate
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed checkHandles.ts: removed require-await, added void for floating promises, fixed template literals, removed non-null assertions
- Fixed checkPosts.ts: removed unused imports, added void for floating promises, fixed template literals, removed non-null assertions
- Fixed checkStarterPack.ts: added correct imports for STARTERPACK_CHECKS, fixed floating promises, template literals, and logic issues
All three check modules now have zero linting errors and follow TypeScript best practices.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed unused imports (login, langs)
- Fixed unnecessary optional chain conditions
- Added void operator to floating promises for fire-and-forget operations
- Fixed template literal expressions by converting number to string
- Improved code quality and type safety
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed return-await issues by properly awaiting emitEvent calls
- Replaced template literal expressions with nullish coalescing for agent.did
- Removed unused parameter from checkAccountLabels function
- Made checkAccountLabels function non-async since it only returns null
- Applied nullish coalescing operator for better type safety
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed unsafe type assertions for metricsServer variable
- Added proper type conversions for template literal expressions
- Replaced hasOwnProperty with Object.hasOwn for better practice
- Converted async event handlers to non-async with void for fire-and-forget
- Added comprehensive error type annotations throughout
- Used Promise.allSettled for concurrent operations
- Removed unused imports and applied destructuring
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
fix: resolve unsafe type assertions in main.ts
- Fixed unsafe type assertions on lines 152 and 158 where embed.external
could potentially be undefined
- Added proper type checking before accessing nested properties
- Improves type safety and prevents potential runtime errors when
processing external embeds
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added comprehensive error handling throughout the codebase to ensure
robustness. - Enhanced logging for improved debugging capabilities. -
Improved shutdown process with graceful exit and cleanup.
This commit splits the `utils.ts` file into three separate files: -
`utils/utils.ts`: Contains the `normalizeUnicode` function. -
`utils/getFinalUrl.ts`: Contains the `getFinalUrl` function. -
`utils/getLanguage.ts`: Contains the `getLanguage` function. This
improves code organization and readability.
feat: Split utils into separate files
1. line 124: changed replyingDid → actorDid (this was causing your
error) 2. line 126: added replyToPostURI to capture the full parent
URI 3. lines 133-158: added quote post monitoring - now detects when
someone quotes a monitored DID or post
the error should be gone now. the system will now: - monitor replies
to your configured government DIDs - monitor quote posts of those same
DIDs - monitor specific post URIs if you add them to monitoredPostURIs
This commit adds a check to the `checkAccountAge` function to prevent
duplicate labels from being applied to the same account. It uses the
`checkAccountLabels` function to determine if a label already exists
before attempting to create a new one. This prevents redundant labeling
and improves efficiency. Also includes unit tests for the
`checkAccountLabels` function to ensure correct behavior.
This change updates the account age check to use a date window defined
by the anchor date and max age days. Instead of calculating the age, it
now checks if the account creation date falls within the specified
window. This simplifies the logic and makes it more readable.
Additionally, the test suite has been updated to reflect the new
behavior, and a more descriptive comment has been added.
- Revert language detection from franc back to lande
- Add label deduplication checks in moderation functions
- Improve type safety with explicit type assertions
- Simplify check iteration logic across handle/post/profile checks
- Remove unused monitor.ts and processJetstream.ts files
- Remove test files and vitest config
- Remove temporary PLAN.md and PRD.md files
- Add duration support for post labels
- Fix import ordering and formatting issues
- Add modTool metadata to moderation events
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)
- Add unit tests for getLanguage function with franc
- Test input validation, language detection for 10+ languages
- Add critical moderation tests for English vs French 'retard' disambiguation
- Verify franc can distinguish French 'delay' from English slur usage
- Include edge cases: emojis, special chars, mixed languages
- Add vitest configuration and test scripts
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced lande v1.0.10 with franc v6.2.0 for better maintenance and performance
- Simplified getLanguage function to use franc's simpler API
- Fixed redundant null check lint issue
- Removed invalid stylistic/comma-trailing package that was breaking npm install
- Updated implementation to handle franc's "und" (undetermined) response
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add validateEnv.ts with validation for all required and optional environment variables
- Validate DID format (must start with 'did:')
- Validate OZONE_URL and OZONE_PDS as domain names
- Validate BSKY_HANDLE format (must contain '.')
- Support arithmetic expressions for LABEL_LIMIT and LABEL_LIMIT_WAIT (e.g., "2900 * 1000")
- Validate numeric values for ports and intervals
- Validate LOG_LEVEL and NODE_ENV against allowed values
- Exit with code 1 and clear error messages if validation fails
- Integrated validation call at application startup in main.ts
This addresses the security concern of missing environment variable validation identified in the code review.
- Updated TODO section to show completed async error handling work
- Listed all resolved issues including type safety, error handling, and code quality
- Added status for all cleaned files (7 files with zero linting errors)
- Clarified remaining tasks are configuration-related, not code quality
- Fixed constants.ts.example to use type import and include knownVectors property
The codebase is now production-ready with robust error handling and modern TypeScript practices.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed unnecessary conditional check in getLanguage function
- Since parameter is typed as string, typeof check and null check are redundant
- Simplified to check for falsy values only
- Updated log message to be more accurate
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed checkHandles.ts: removed require-await, added void for floating promises, fixed template literals, removed non-null assertions
- Fixed checkPosts.ts: removed unused imports, added void for floating promises, fixed template literals, removed non-null assertions
- Fixed checkStarterPack.ts: added correct imports for STARTERPACK_CHECKS, fixed floating promises, template literals, and logic issues
All three check modules now have zero linting errors and follow TypeScript best practices.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed unused imports (login, langs)
- Fixed unnecessary optional chain conditions
- Added void operator to floating promises for fire-and-forget operations
- Fixed template literal expressions by converting number to string
- Improved code quality and type safety
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed return-await issues by properly awaiting emitEvent calls
- Replaced template literal expressions with nullish coalescing for agent.did
- Removed unused parameter from checkAccountLabels function
- Made checkAccountLabels function non-async since it only returns null
- Applied nullish coalescing operator for better type safety
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed unsafe type assertions for metricsServer variable
- Added proper type conversions for template literal expressions
- Replaced hasOwnProperty with Object.hasOwn for better practice
- Converted async event handlers to non-async with void for fire-and-forget
- Added comprehensive error type annotations throughout
- Used Promise.allSettled for concurrent operations
- Removed unused imports and applied destructuring
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed unsafe type assertions on lines 152 and 158 where embed.external
could potentially be undefined
- Added proper type checking before accessing nested properties
- Improves type safety and prevents potential runtime errors when
processing external embeds
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>