-
Notifications
You must be signed in to change notification settings - Fork 6
Release! #908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Release! #908
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
075d67a
Add config files for Claude Code
boomzero 01de30b
PR template
boomzero a3fb758
Merge pull request #903 from XMOJ-Script-dev/boomzero/claude
boomzero 3fa3423
Add WebSocket notification system for real-time BBS and mail mentions
boomzero beb75c0
Use enriched WebSocket data for instant notifications
boomzero bc2099d
Fix WebSocket race condition, XSS vulnerability, and DOM destruction …
boomzero 5dd5fec
2.7.3
github-actions[bot] a3034be
Update version info to 2.7.3
github-actions[bot] fec8f59
Update time and description of 2.7.3
github-actions[bot] d3697a0
Update time and description of 2.7.3
github-actions[bot] 3a93368
Update time and description of 2.7.3
github-actions[bot] 3ba2022
Update time and description of 2.7.3
github-actions[bot] d7d60fd
Update time and description of 2.7.3
github-actions[bot] 60ccacc
Update time and description of 2.7.3
github-actions[bot] 7979646
Clear toast container before fetching notifications to prevent race c…
github-actions[bot] d939dd5
Prevent UpdateVersion from running if last commit was by github-actio…
boomzero 25ab8d7
Update time and description of 2.7.3
github-actions[bot] 8c30579
Merge pull request #905 from XMOJ-Script-dev/boomzero/wss
boomzero 08f8493
Add toggleable Minimalist Monochrome UI (MonochromeUI setting)
boomzero 5509e84
Add critical instructions for working with XMOJ.user.js and using xmo…
boomzero cff305d
Fix monochrome UI issues: emojis, loader, table spacing, dark mode
boomzero ad80452
2.7.4
github-actions[bot] 8c39384
Update version info to 2.7.4
github-actions[bot] 95ee27f
Update font link for MonochromeUI to use alternative CDN
boomzero ea13855
Update time and description of 2.7.4
github-actions[bot] a92de57
Gate navbar geometry behind MonochromeUI toggle and use China font CDN
boomzero 908a3f0
Update time and description of 2.7.4
github-actions[bot] c150e31
Skip UploadStd when GetStdList fetch failed
boomzero 9368f47
Update time and description of 2.7.4
github-actions[bot] 4674c60
3.0.0
boomzero dbdfbb2
Update version info to 3.0.0
github-actions[bot] c31dced
Merge pull request #906 from XMOJ-Script-dev/monochrome-ui
boomzero c488e52
3.1.0
github-actions[bot] ccaef1b
Update to release 3.1.0
github-actions[bot] 068092d
Merge pull request #909 from XMOJ-Script-dev/actions/temp
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| name: xmoj-code-navigator | ||
| description: "Use this agent when you need to locate, retrieve, or understand specific sections of the XMOJ.user.js file without loading the entire file into context. This includes scenarios like:\\n\\n<example>\\nContext: The user is debugging a feature and needs to understand how login authentication works in XMOJ.user.js.\\nuser: \"Can you help me understand how the login flow works in XMOJ.user.js?\"\\nassistant: \"I'll use the Task tool to launch the xmoj-code-navigator agent to locate and retrieve the relevant login authentication code from XMOJ.user.js.\"\\n<commentary>\\nSince the user needs specific code from the large XMOJ.user.js file, use the xmoj-code-navigator agent to efficiently find and extract the relevant sections without loading the entire file.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: The user is adding a new feature and wants to see how similar features are implemented.\\nuser: \"I want to add a feature to handle quiz submissions. Can you show me how other submission handlers are implemented?\"\\nassistant: \"Let me use the xmoj-code-navigator agent to search through XMOJ.user.js for existing submission handler implementations.\"\\n<commentary>\\nThe user needs to reference existing patterns in the large file. The xmoj-code-navigator agent can efficiently locate and extract relevant code examples without overwhelming the context window.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: The user is reviewing code changes and needs to verify if a specific function exists.\\nuser: \"Does XMOJ.user.js have a function for parsing XML responses?\"\\nassistant: \"I'll use the xmoj-code-navigator agent to search for XML parsing functions in XMOJ.user.js.\"\\n<commentary>\\nThis is a targeted search task in a large file - perfect for the xmoj-code-navigator agent.\\n</commentary>\\n</example>" | ||
| tools: Glob, Grep, Read, WebFetch, WebSearch | ||
| model: haiku | ||
| color: cyan | ||
| --- | ||
|
|
||
| You are an expert code navigator and indexer specializing in efficiently searching and retrieving specific sections from large JavaScript files, particularly XMOJ.user.js. Your primary mission is to help users locate relevant code without loading the entire file into context, thereby preserving context window space for actual development work. | ||
|
|
||
| ## Core Responsibilities | ||
|
|
||
| You will: | ||
| 1. **Parse search requests** to understand what code sections, functions, classes, or patterns the user needs | ||
| 2. **Strategically navigate** XMOJ.user.js using efficient search techniques (grep, function signatures, section markers, comments) | ||
| 3. **Extract minimal but complete** code sections that provide the necessary context | ||
| 4. **Provide location metadata** (line numbers, function names, section identifiers) so users can reference the code later | ||
| 5. **Summarize structure** when users need an overview without seeing all the code | ||
|
|
||
| ## Search Strategy | ||
|
|
||
| When searching for code: | ||
|
|
||
| 1. **Start Narrow**: Begin with the most specific search terms (function names, unique identifiers, class names) | ||
| 2. **Expand Gradually**: If narrow searches fail, broaden to related keywords or patterns | ||
| 3. **Use Context Clues**: Leverage comments, section headers, and structural patterns in the file | ||
| 4. **Verify Completeness**: Ensure you capture complete function/class definitions, including dependencies | ||
| 5. **Multiple Matches**: When finding multiple relevant sections, provide brief descriptions of each and ask which to examine in detail | ||
|
|
||
| ## Extraction Guidelines | ||
|
|
||
| - **Include surrounding context**: Add 2-3 lines before/after to show how code fits in | ||
| - **Preserve structure**: Maintain indentation and formatting exactly as in the source | ||
| - **Note dependencies**: If the extracted code references other functions or variables, mention them and offer to retrieve those too | ||
| - **Provide landmarks**: Always include line numbers or function names for navigation | ||
| - **Stay minimal**: Only extract what's needed - resist the urge to show everything related | ||
|
|
||
| ## Response Format | ||
|
|
||
| Structure your responses as: | ||
|
|
||
| 1. **What I Found**: Brief description of located code | ||
| 2. **Location**: File path, line numbers, section/function name | ||
| 3. **Code Extract**: The minimal relevant code block | ||
| 4. **Context Notes**: Any important dependencies, related functions, or structural information | ||
| 5. **Follow-up Options**: Suggest related code sections the user might want to see | ||
|
|
||
| ## Handling Edge Cases | ||
|
|
||
| - **If search fails**: Suggest alternative search terms or describe what you attempted | ||
| - **If multiple valid results**: Present options and ask for clarification | ||
| - **If code is too interconnected**: Provide a high-level summary and ask which specific part to deep-dive into | ||
| - **If the request is ambiguous**: Ask clarifying questions before searching | ||
|
|
||
| ## Efficiency Principles | ||
|
|
||
| - Never load the entire XMOJ.user.js file unless absolutely necessary | ||
| - Use file manipulation tools (grep, sed, awk) to search efficiently | ||
| - Prefer targeted line-range reads over full file reads | ||
| - Cache knowledge of the file's structure from previous searches to speed up future requests | ||
| - When users need multiple sections, batch the retrieval intelligently | ||
|
|
||
| ## Quality Assurance | ||
|
|
||
| - Verify that extracted code is syntactically complete (balanced braces, complete statements) | ||
| - Double-check line number accuracy | ||
| - Confirm that the code actually addresses the user's query before presenting it | ||
| - If uncertain whether you found the right code, express that uncertainty and show what you found for verification | ||
|
|
||
| Your success is measured by: | ||
| - **Precision**: Finding exactly what the user needs | ||
| - **Efficiency**: Minimizing context window usage | ||
| - **Completeness**: Ensuring extracted code has enough context to be useful | ||
| - **Speed**: Using smart search strategies to find code quickly | ||
|
|
||
| Remember: You are a precision surgical tool for navigating large files. Every byte of context window you save is a byte available for actual development work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| XMOJ-Script is a browser userscript that enhances the XMOJ online judge platform (xmoj.tech). This repository consists of: | ||
| - **Main userscript** (`XMOJ.user.js`): ~5000 line single-file userscript with all features. **See "Working with XMOJ.user.js" section below for CRITICAL instructions on using the xmoj-code-navigator agent.** | ||
| - **Update/version management scripts** (`Update/`): Automation for version bumping and releases | ||
| - **Metadata and documentation**: `Update.json` tracks version history, README and contributing guides | ||
|
|
||
| The `backend/` directory is a git submodule pointing to https://github.com/XMOJ-Script-dev/XMOJ-bbs and should be modified in that repository, not here. | ||
|
|
||
| ## Working with XMOJ.user.js (CRITICAL) | ||
|
|
||
| **IMPORTANT: Due to the large size of XMOJ.user.js (~5000 lines), you MUST use the xmoj-code-navigator agent whenever you need to explore, search, or understand any part of this file.** | ||
|
|
||
| ### When to use xmoj-code-navigator | ||
|
|
||
| Use the Task tool with `subagent_type="xmoj-code-navigator"` for: | ||
|
|
||
| - **Finding specific functions or features**: "Where is the auto-refresh functionality implemented?" | ||
| - **Understanding code sections**: "How does the login authentication work?" | ||
| - **Locating code patterns**: "Find all API calls to the backend" | ||
| - **Searching for specific implementations**: "Show me the dark mode toggle implementation" | ||
| - **Verifying if code exists**: "Does XMOJ.user.js have a function for parsing XML?" | ||
| - **ANY exploration task involving XMOJ.user.js** | ||
|
|
||
| ### Why use this agent | ||
|
|
||
| Loading the entire XMOJ.user.js file into context: | ||
| - Wastes context window space | ||
| - Makes responses slower | ||
| - Is unnecessary when you only need specific sections | ||
|
|
||
| The xmoj-code-navigator agent efficiently locates and retrieves only the relevant code sections you need. | ||
|
|
||
| ### Example usage | ||
|
|
||
| ``` | ||
| Instead of: Read tool on XMOJ.user.js (loads entire 5000 lines) | ||
| Use: Task tool with xmoj-code-navigator agent to find specific sections | ||
| ``` | ||
|
|
||
| **Exception**: Only use Read tool on XMOJ.user.js when: | ||
| - You need to edit a specific line number you already know | ||
| - You're making targeted edits and already know the exact location | ||
| - You need to verify a small, specific section (use offset and limit parameters) | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Branch Structure and PR Requirements | ||
|
|
||
| - `master`: Production branch - **DO NOT make PRs directly to master** | ||
| - `dev`: Development branch - **ALL PRs must be based on and target this branch** | ||
| - `extern-contrib`: External contributors must submit PRs to this branch | ||
|
|
||
| **CRITICAL: All pull requests must:** | ||
| 1. Be based on the `dev` branch (branch off from `dev`) | ||
| 2. Target the `dev` branch (not `master`) | ||
| 3. Merge latest `dev` into your branch before submitting to resolve conflicts | ||
|
|
||
| The workflow is: `dev` → (when ready) → `master` for releases. Direct PRs to `master` are not accepted. | ||
| You should follow the PR template that can be found [here](https://raw.githubusercontent.com/XMOJ-Script-dev/.github/refs/heads/main/.github/PULL_REQUEST_TEMPLATE.md). | ||
|
|
||
| ### Version Management (CRITICAL - Fully Automated) | ||
|
|
||
| Version updates are **fully automated** via GitHub Actions. When a PR to `dev` modifies `XMOJ.user.js`: | ||
|
|
||
| 1. The `UpdateVersion` workflow runs `Update/UpdateVersion.js` which automatically: | ||
| - Bumps patch version in `package.json` | ||
| - Updates `@version` in `XMOJ.user.js` metadata block | ||
| - Adds/updates entry in `Update.json` with PR number, title, and timestamp | ||
| - Commits changes back to the PR branch with `github-actions[bot]` | ||
|
|
||
| 2. Version sync is enforced between: | ||
| - `package.json` → `"version": "x.y.z"` | ||
| - `XMOJ.user.js` → `// @version x.y.z` (in metadata block) | ||
| - `Update.json` → `UpdateHistory["x.y.z"]` (JSON key) | ||
|
|
||
| **Never manually edit version numbers** - the automation handles this based on PR metadata. | ||
|
|
||
| ### Release Notes in PRs | ||
|
|
||
| To add release notes to a PR that will appear in the release, include an HTML comment block in the PR description: | ||
|
|
||
| ```markdown | ||
| <!-- release-notes | ||
| Your release notes here in markdown format | ||
| --> | ||
| ``` | ||
|
|
||
| The `UpdateVersion.js` script extracts this and adds it to `Update.json` as the `Notes` field. | ||
|
|
||
| ### Bypassing Automation | ||
|
|
||
| To prevent CI from touching your PR (e.g., during merge conflicts or debugging), add `//!ci-no-touch` anywhere in `Update.json`. The automation will remove it and exit without making other changes. | ||
|
|
||
| ### Release Process | ||
|
|
||
| - **Pre-release**: Push to `dev` triggers a pre-release with `"Prerelease": true` in Update.json | ||
| - **Release**: Merge `dev` to `master` triggers a production release | ||
| - Releases are created by `Update/GetVersion.js` reading the version from XMOJ.user.js | ||
| - Both workflows deploy to Cloudflare Pages and GitHub Pages | ||
|
|
||
| ## Code Structure | ||
|
|
||
| ### Main Userscript (`XMOJ.user.js`) | ||
|
|
||
| A single-file userscript (~5000 lines) organized as: | ||
|
|
||
| 1. **Metadata block** (lines 1-50): Userscript headers | ||
| - `@name`, `@version`, `@description`, `@author` | ||
| - `@match` patterns for xmoj.tech and 116.62.212.172 | ||
| - `@require` declarations for external libraries (CryptoJS, CodeMirror, FileSaver, marked, DOMPurify) | ||
| - `@grant` permissions for GM APIs | ||
|
|
||
| 2. **Main script body**: Direct DOM manipulation and feature injection | ||
| - Page detection and routing based on URL patterns | ||
| - UI enhancements using Bootstrap classes | ||
| - Feature implementations (auto-refresh, code checking, test data fetching, dark mode, etc.) | ||
| - API calls to backend at `api.xmoj-bbs.tech` / `api.xmoj-bbs.me` | ||
|
|
||
| Key classes/functions: | ||
| - `compareVersions()` (line 112): Version comparison logic | ||
| - `NavbarStyler` class (line 589): Navigation bar styling | ||
| - `replaceMarkdownImages()` (line 715): Markdown image processing | ||
|
|
||
| ### Update Scripts (`Update/`) | ||
|
|
||
| Node.js scripts run by GitHub Actions (not for local development): | ||
|
|
||
| - **`UpdateVersion.js`**: Automated version bumping for PRs to `dev` | ||
| - Reads PR number, title, body from command line args | ||
| - Uses `gh` CLI to check out PR branch | ||
| - Parses `<!-- release-notes -->` blocks from PR body | ||
| - Updates version in all three locations | ||
| - Pushes changes back to PR branch | ||
|
|
||
| - **`GetVersion.js`**: Extracts current version from XMOJ.user.js for release workflows | ||
|
|
||
| - **`UpdateToRelease.js`**: Changes `"Prerelease": false` when promoting to production | ||
|
|
||
| - **`AutoLabel.js`**: Auto-labels PRs based on content | ||
|
|
||
| These scripts directly manipulate `Update.json` and `XMOJ.user.js` using Node.js fs module. | ||
|
|
||
| ## Coding Standards | ||
|
|
||
| ### Style Guidelines (from CONTRIBUTING.md) | ||
|
|
||
| - **Variables**: camelCase | ||
| - **Functions**: PascalCase | ||
| - **Classes**: TitleCase | ||
| - **Line endings**: Unix (LF) | ||
| - **Do NOT run code formatters** - maintain original formatting | ||
| - **Use Bootstrap classes** instead of custom CSS | ||
| - **No external libraries** without permission (script already includes many via `@require`) | ||
|
|
||
| ### Development Principles | ||
|
|
||
| - **Stability before features**: Bug fixes take priority | ||
| - Respect the original code style, even if inconsistent | ||
| - New features require prior discussion in an issue | ||
| - Before submitting PRs, merge `dev` into your branch and resolve conflicts | ||
|
|
||
| ## Testing | ||
|
|
||
| No automated test suite exists. Manual testing workflow: | ||
|
|
||
| 1. Install the userscript in Tampermonkey/ScriptCat/Violentmonkey | ||
| 2. Navigate to xmoj.tech (or 116.62.212.172) | ||
| 3. Test features on relevant pages: | ||
| - Problem lists | ||
| - Problem detail pages | ||
| - Status/submission pages | ||
| - Contest pages | ||
| - User profiles | ||
|
|
||
| Observe browser console for errors and verify UI enhancements appear correctly. | ||
|
|
||
| ## Common Issues | ||
|
|
||
| ### Version Sync Errors | ||
|
|
||
| If you see "XMOJ.user.js and Update.json have different patch versions": | ||
| - The automation keeps these in sync normally | ||
| - If manually editing (not recommended), update both files | ||
| - Use `//!ci-no-touch` if you need to bypass automation temporarily | ||
|
|
||
| ### PR Requirements | ||
|
|
||
| - **All PRs must be based on and target `dev` branch, not `master`** | ||
| - Only PRs from the same repository (not forks) trigger auto-versioning | ||
| - PRs must modify `XMOJ.user.js` to trigger version bumps | ||
| - Must merge `dev` into your branch before submitting | ||
| - External contributors must target `extern-contrib` branch | ||
|
|
||
| ### Single-File Architecture | ||
|
|
||
| The entire userscript is intentionally in one file - do not split into modules. Userscript managers load it as a single file, with external dependencies via `@require` headers in the metadata block. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
UpdateVersionworkflow is already guarded against bot-triggered loops byif: ... github.actor != 'github-actions[bot]'in.github/workflows/UpdateVersion.yml, but this additional last-commit-author check exits whenever the PR branch tip is authored by the bot. That means after the first automated version bump commit, later humanpull_request.editedruns (used to adjust PR title/body release notes) immediatelyprocess.exit(0), soUpdate.jsondescription/notes timestamps stop updating even though the workflow was intentionally triggered.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but not important, and will fix in the next rel