[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78DEKFPVPAMPTFH1C44ZEXE":3,"skill-same:01M78DEKFPVPAMPTFH1C44ZEXE":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M78DEKFPVPAMPTFH1C44ZEXE","codesync-network-interception",null,"Architecture, monkey-patching, GraphQL detection, and bridge communication for CodeSync's native Manifest V3 network interceptors.","pardeep1916P\u002FcodeSync","pardeep1916P","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F168327487?v=4","01M78DE87WVVWDH8M849ATQ25Y","Devanaboyina Charan Chaitanya","01M78DE890X74HPFK91EMX91W5",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fcodesync-network-interception\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: codesync-network-interception\ndescription: Architecture, monkey-patching, GraphQL detection, and bridge communication for CodeSync's native Manifest V3 network interceptors.\n---\n\n# CodeSync Network Interception & Content Script Architecture\n\nUse this skill when modifying, maintaining, or debugging the real-time submission detection pipeline in `src\u002Fcontent\u002Finterceptor.ts` and `src\u002Fcontent\u002Findex.ts`.\n\n---\n\n## 1. Architectural Overview & Context Worlds\n\nIn Chrome Manifest V3, content scripts run in an isolated execution environment. To intercept network calls made by single-page application frameworks (such as Next.js on LeetCode), CodeSync uses a two-stage bridge:\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│ Web Page Context (MAIN World)                               │\n│ src\u002Fcontent\u002Finterceptor.ts                                  │\n│ - Monkey-patches window.fetch and window.XMLHttpRequest     │\n│ - Inspects responses without consuming stream (cloned)      │\n│ - Detects judging success: statusCode === 10                │\n└──────────────────────────────┬──────────────────────────────┘\n                               │ window.postMessage\n                               │ (CODESYNC_JUDGING_ACCEPTED)\n┌──────────────────────────────▼──────────────────────────────┐\n│ Extension Content Script (ISOLATED World)                   │\n│ src\u002Fcontent\u002Findex.ts                                        │\n│ - Listens to window messages                                │\n│ - Resolves question metadata via LRUCache                   │\n│ - Fetches full submissionDetails if needed                  │\n│ - Normalizes Problem and Submission objects                 │\n└──────────────────────────────┬──────────────────────────────┘\n                               │ chrome.runtime.sendMessage\n                               │ (action: 'ENQUEUE_SUBMISSION')\n┌──────────────────────────────▼──────────────────────────────┐\n│ Background Service Worker                                   │\n│ src\u002Fbackground\u002Findex.ts -> src\u002Fqueue\u002Findex.ts               │\n└─────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## 2. Manifest V3 Registration\n\nThe interceptor is declared in `public\u002Fmanifest.json` under `content_scripts` with `\"world\": \"MAIN\"` and `\"run_at\": \"document_start\"`:\n\n```json\n{\n  \"content_scripts\": [\n    {\n      \"matches\": [\n        \"*:\u002F\u002F*.leetcode.com\u002F*\",\n        \"*:\u002F\u002Fleetcode.com\u002F*\",\n        \"*:\u002F\u002F*.leetcode.cn\u002F*\",\n        \"*:\u002F\u002Fleetcode.cn\u002F*\"\n      ],\n      \"js\": [\"interceptor.js\"],\n      \"run_at\": \"document_start\",\n      \"world\": \"MAIN\"\n    },\n    {\n      \"matches\": [\n        \"*:\u002F\u002F*.leetcode.com\u002F*\",\n        \"*:\u002F\u002Fleetcode.com\u002F*\",\n        \"*:\u002F\u002F*.leetcode.cn\u002F*\",\n        \"*:\u002F\u002Fleetcode.cn\u002F*\"\n      ],\n      \"js\": [\"content.js\"],\n      \"run_at\": \"document_idle\"\n    }\n  ]\n}\n```\n\n---\n\n## 3. Monkey-Patching Invariants\n\n### 1. Non-Destructive Response Cloning\nYou must **never** consume the original response body stream, as the host application needs it to render the UI:\n\n```typescript\nconst originalFetch = window.fetch;\nwindow.fetch = async function(...args) {\n  const response = await originalFetch(...args);\n\n  try {\n    const url = typeof args[0] === 'string' ? args[0] : (args[0] instanceof Request ? args[0].url : '');\n    \n    if (url.includes('\u002Fgraphql') || url.includes('\u002Fcheck\u002F') || url.includes('\u002Fsubmit')) {\n      \u002F\u002F CLONE before reading JSON\n      const cloned = response.clone();\n      cloned.json().then((json) => {\n        handleInterceptedPayload(url, json);\n      }).catch(() => {});\n    }\n  } catch (err) {\n    \u002F\u002F Interceptor must never crash host page operations\n  }\n\n  return response;\n};\n```\n\n### 2. LeetCode Judging Status Codes\nLeetCode assigns integer status codes to submissions:\n- **`10`**: **Accepted (AC)** $\\rightarrow$ **Trigger synchronization**\n- `11`: Wrong Answer (WA) $\\rightarrow$ Ignore\n- `12`: Memory Limit Exceeded $\\rightarrow$ Ignore\n- `13`: Output Limit Exceeded $\\rightarrow$ Ignore\n- `14`: Time Limit Exceeded (TLE) $\\rightarrow$ Ignore\n- `15`: Runtime Error $\\rightarrow$ Ignore\n- `16`: Compile Error $\\rightarrow$ Ignore\n- `20`: Pending \u002F Judging $\\rightarrow$ Wait for subsequent check polling\n\n---\n\n## 4. Zero-Latency Metadata Pre-Caching\n\nTo enqueue submissions in under 10 milliseconds without making blocking network requests after judge completion, `interceptor.ts` intercepts GraphQL queries containing question details and caches them immediately:\n\n```typescript\n\u002F\u002F Detect question metadata during normal problem page load\nif (json?.data?.question) {\n  const q = json.data.question;\n  window.postMessage({\n    type: 'CODESYNC_QUESTION_METADATA',\n    payload: {\n      questionId: q.questionId,\n      title: q.title,\n      titleSlug: q.titleSlug,\n      difficulty: q.difficulty,\n      content: q.content,\n      topicTags: q.topicTags,\n    }\n  }, '*');\n}\n```\n\nIn `src\u002Fcontent\u002Findex.ts`, incoming metadata is stored in an in-memory `LRUCache`:\n```typescript\nconst questionCache = new LRUCache\u003Cstring, QuestionMetadata>(50);\nconst processedSubmissionIds = new LRUCache\u003Cstring, boolean>(200);\n```\n\n---\n\n## 5. Message Contracts\n\n### MAIN $\\rightarrow$ ISOLATED Bridge:\n- `CODESYNC_LOG`: Diagnostic logging relayed to extension logger.\n- `CODESYNC_QUESTION_METADATA`: Pre-cached problem definition and HTML description.\n- `CODESYNC_JUDGING_ACCEPTED`: Emitted when judging returns `statusCode: 10`. Contains `submissionId`.\n\n### ISOLATED $\\rightarrow$ Background Bridge:\n```typescript\nchrome.runtime.sendMessage({\n  action: 'ENQUEUE_SUBMISSION',\n  payload: submissionObject,\n}, (response) => {\n  if (response?.success) {\n    logToBackground('Successfully enqueued submission:', submissionObject.id);\n  }\n});\n```\n\n---\n\n## 6. Troubleshooting Guide\n\n| Issue | Root Cause | Resolution |\n| :--- | :--- | :--- |\n| **Submissions not captured** | Page uses dynamic URL patterns or GraphQL query names changed | Check service worker logs (`action: 'LOG'`) and verify if URL matches `\u002Fgraphql`, `\u002Fcheck\u002F`, or `\u002Fsubmit\u002F`. |\n| **Response body already read error** | Interceptor called `.json()` or `.text()` on original response | Ensure `response.clone()` is called before reading the stream. |\n| **Extension context invalidated** | Extension reloaded during development while tab remained open | Wrap calls with `isContextInvalidated()` check in `src\u002Fcontent\u002Findex.ts` to prevent runtime exception spam. |\n| **Duplicate submissions enqueued** | Both fetch and XHR captured the same poll event | Enforce bounded deduplication using `processedSubmissionIds.has(submissionId)` in `src\u002Fcontent\u002Findex.ts`. |\n","# CodeSync Network Interception & Content Script Architecture\n\nUse this skill when modifying, maintaining, or debugging the real-time submission detection pipeline in `src\u002Fcontent\u002Finterceptor.ts` and `src\u002Fcontent\u002Findex.ts`.\n\n---\n\n## 1. Architectural Overview & Context Worlds\n\nIn Chrome Manifest V3, content scripts run in an isolated execution environment. To intercept network calls made by single-page application frameworks (such as Next.js on LeetCode), CodeSync uses a two-stage bridge:\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│ Web Page Context (MAIN World)                               │\n│ src\u002Fcontent\u002Finterceptor.ts                                  │\n│ - Monkey-patches window.fetch and window.XMLHttpRequest     │\n│ - Inspects responses without consuming stream (cloned)      │\n│ - Detects judging success: statusCode === 10                │\n└──────────────────────────────┬──────────────────────────────┘\n                               │ window.postMessage\n                               │ (CODESYNC_JUDGING_ACCEPTED)\n┌──────────────────────────────▼──────────────────────────────┐\n│ Extension Content Script (ISOLATED World)                   │\n│ src\u002Fcontent\u002Findex.ts                                        │\n│ - Listens to window messages                                │\n│ - Resolves question metadata via LRUCache                   │\n│ - Fetches full submissionDetails if needed                  │\n│ - Normalizes Problem and Submission objects                 │\n└──────────────────────────────┬──────────────────────────────┘\n                               │ chrome.runtime.sendMessage\n                               │ (action: 'ENQUEUE_SUBMISSION')\n┌──────────────────────────────▼──────────────────────────────┐\n│ Background Service Worker                                   │\n│ src\u002Fbackground\u002Findex.ts -> src\u002Fqueue\u002Findex.ts               │\n└─────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## 2. Manifest V3 Registration\n\nThe interceptor is declared in `public\u002Fmanifest.json` under `content_scripts` with `\"world\": \"MAIN\"` and `\"run_at\": \"document_start\"`:\n\n```json\n{\n  \"content_scripts\": [\n    {\n      \"matches\": [\n        \"*:\u002F\u002F*.leetcode.com\u002F*\",\n        \"*:\u002F\u002Fleetcode.com\u002F*\",\n        \"*:\u002F\u002F*.leetcode.cn\u002F*\",\n        \"*:\u002F\u002Fleetcode.cn\u002F*\"\n      ],\n      \"js\": [\"interceptor.js\"],\n      \"run_at\": \"document_start\",\n      \"world\": \"MAIN\"\n    },\n    {\n      \"matches\": [\n        \"*:\u002F\u002F*.leetcode.com\u002F*\",\n        \"*:\u002F\u002Fleetcode.com\u002F*\",\n        \"*:\u002F\u002F*.leetcode.cn\u002F*\",\n        \"*:\u002F\u002Fleetcode.cn\u002F*\"\n      ],\n      \"js\": [\"content.js\"],\n      \"run_at\": \"document_idle\"\n    }\n  ]\n}\n```\n\n---\n\n## 3. Monkey-Patching Invariants\n\n### 1. Non-Destructive Response Cloning\nYou must **never** consume the original response body stream, as the host application needs it to render the UI:\n\n```typescript\nconst originalFetch = window.fetch;\nwindow.fetch = async function(...args) {\n  const response = await originalFetch(...args);\n\n  try {\n    const url = typeof args[0] === 'string' ? args[0] : (args[0] instanceof Request ? args[0].url : '');\n    \n    if (url.includes('\u002Fgraphql') || url.includes('\u002Fcheck\u002F') || url.includes('\u002Fsubmit')) {\n      \u002F\u002F CLONE before reading JSON\n      const cloned = response.clone();\n      cloned.json().then((json) => {\n        handleInterceptedPayload(url, json);\n      }).catch(() => {});\n    }\n  } catch (err) {\n    \u002F\u002F Interceptor must never crash host page operations\n  }\n\n  return response;\n};\n```\n\n### 2. LeetCode Judging Status Codes\nLeetCode assigns integer status codes to submissions:\n- **`10`**: **Accepted (AC)** $\\rightarrow$ **Trigger synchronization**\n- `11`: Wrong Answer (WA) $\\rightarrow$ Ignore\n- `12`: Memory Limit Exceeded $\\rightarrow$ Ignore\n- `13`: Output Limit Exceeded $\\rightarrow$ Ignore\n- `14`: Time Limit Exceeded (TLE) $\\rightarrow$ Ignore\n- `15`: Runtime Error $\\rightarrow$ Ignore\n- `16`: Compile Error $\\rightarrow$ Ignore\n- `20`: Pending \u002F Judging $\\rightarrow$ Wait for subsequent check polling\n\n---\n\n## 4. Zero-Latency Metadata Pre-Caching\n\nTo enqueue submissions in under 10 milliseconds without making blocking network requests after judge completion, `interceptor.ts` intercepts GraphQL queries containing question details and caches them immediately:\n\n```typescript\n\u002F\u002F Detect question metadata during normal problem page load\nif (json?.data?.question) {\n  const q = json.data.question;\n  window.postMessage({\n    type: 'CODESYNC_QUESTION_METADATA',\n    payload: {\n      questionId: q.questionId,\n      title: q.title,\n      titleSlug: q.titleSlug,\n      difficulty: q.difficulty,\n      content: q.content,\n      topicTags: q.topicTags,\n    }\n  }, '*');\n}\n```\n\nIn `src\u002Fcontent\u002Findex.ts`, incoming metadata is stored in an in-memory `LRUCache`:\n```typescript\nconst questionCache = new LRUCache\u003Cstring, QuestionMetadata>(50);\nconst processedSubmissionIds = new LRUCache\u003Cstring, boolean>(200);\n```\n\n---\n\n## 5. Message Contracts\n\n### MAIN $\\rightarrow$ ISOLATED Bridge:\n- `CODESYNC_LOG`: Diagnostic logging relayed to extension logger.\n- `CODESYNC_QUESTION_METADATA`: Pre-cached problem definition and HTML description.\n- `CODESYNC_JUDGING_ACCEPTED`: Emitted when judging returns `statusCode: 10`. Contains `submissionId`.\n\n### ISOLATED $\\rightarrow$ Background Bridge:\n```typescript\nchrome.runtime.sendMessage({\n  action: 'ENQUEUE_SUBMISSION',\n  payload: submissionObject,\n}, (response) => {\n  if (response?.success) {\n    logToBackground('Successfully enqueued submission:', submissionObject.id);\n  }\n});\n```\n\n---\n\n## 6. Troubleshooting Guide\n\n| Issue | Root Cause | Resolution |\n| :--- | :--- | :--- |\n| **Submissions not captured** | Page uses dynamic URL patterns or GraphQL query names changed | Check service worker logs (`action: 'LOG'`) and verify if URL matches `\u002Fgraphql`, `\u002Fcheck\u002F`, or `\u002Fsubmit\u002F`. |\n| **Response body already read error** | Interceptor called `.json()` or `.text()` on original response | Ensure `response.clone()` is called before reading the stream. |\n| **Extension context invalidated** | Extension reloaded during development while tab remained open | Wrap calls with `isContextInvalidated()` check in `src\u002Fcontent\u002Findex.ts` to prevent runtime exception spam. |\n| **Duplicate submissions enqueued** | Both fetch and XHR captured the same poll event | Enforce bounded deduplication using `processedSubmissionIds.has(submissionId)` in `src\u002Fcontent\u002Findex.ts`. |\n",{"name":5,"description":7},"main","f2a54fba6f9faab5c8991fc4a98973e74303f925",".agent\u002Fskills\u002Fcodesync-network-interception","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync","https:\u002F\u002Fpardeep1916p.github.io\u002FcodeSync\u002F","https:\u002F\u002Fgithub.com\u002Fpardeep1916P","https:\u002F\u002Fcharan-chaitanya-devanaboyina.vercel.app\u002F","2026-11-10 02:31:26",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add pardeep1916P\u002FcodeSync --skill codesync-network-interception",{"tool":38,"command":39},"bunx","bunx skills add pardeep1916P\u002FcodeSync --skill codesync-network-interception",{"tool":41,"command":42},"pnpm","pnpm dlx skills add pardeep1916P\u002FcodeSync --skill codesync-network-interception","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fcodesync-network-interception\u002FSKILL.md",true,[],[47,55,62,69,76,83],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M78DFT64JJNAQR5TETTT7S5A","openspec-update-change","Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Never edits code.","MIT","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-update-change\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M78DFQNNEY55FD44WZAC85MS","openspec-sync-specs","Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-sync-specs\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M78DFMM7Q03FQ00QRDB9KY53","openspec-propose","Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-propose\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M78DFHBCWK1VE0GCKJ9FZC9T","openspec-explore","Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-explore\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M78DFEZR53TXK69N8X00MBH3","openspec-archive-change","Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-archive-change\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":51,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M78DFB8AXAA18VTCV22PYGG4","openspec-apply-change","Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.","https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fopenspec-apply-change\u002FSKILL.md",[],[]]