[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78DEWQM3PJM1EBH5E4X0NRT":3,"skill-same:01M78DEWQM3PJM1EBH5E4X0NRT":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},"01M78DEWQM3PJM1EBH5E4X0NRT","codesync-queue-and-sync",null,"Managing the CommitQueue state machine, deduplication, directory templating, atomic Git tree batching, and in-repo codesync_state persistence.","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-queue-and-sync\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: codesync-queue-and-sync\ndescription: Managing the CommitQueue state machine, deduplication, directory templating, atomic Git tree batching, and in-repo codesync_state persistence.\n---\n\n# CodeSync Queue, Deduplication & Synchronization Guide\n\nUse this skill when modifying the submission queue, storage serialization, directory layout generation, or GitHub commit preparation in `src\u002Fqueue\u002F` and `src\u002Freadme\u002F`.\n\n---\n\n## 1. Queue Architecture & State Machine\n\nThe `CommitQueue` class (`src\u002Fqueue\u002Findex.ts`) manages incoming submissions asynchronously. To prevent race conditions from concurrent judge completions, all enqueue operations are chained onto a sequential Promise queue (`enqueuePromise`):\n\n```typescript\nexport class CommitQueue {\n  private isProcessing = false;\n  private enqueuePromise: Promise\u003Cvoid> = Promise.resolve();\n\n  async enqueue(submission: Submission): Promise\u003Cvoid> {\n    this.enqueuePromise = this.enqueuePromise.then(() => this.enqueueInternal(submission));\n    return this.enqueuePromise;\n  }\n}\n```\n\n---\n\n## 2. Deduplication Invariant\n\nBefore appending a submission to the queue, `CommitQueue` performs two checks:\n1. **Submission ID Deduplication**: If `submission.id` is already in `settings.commitQueue`, skip.\n2. **Problem Slug & Language Deduplication**: If a prior submission exists for the same problem slug and the same programming language:\n   - Remove the old submission ID from `commitQueue`.\n   - Remove the old temporary storage key `sub_${oldId}` from `chrome.storage.local`.\n   - Insert the new submission ID.\n\nThis guarantees that re-solving a problem updates existing pending files rather than creating duplicate commits or conflicting files.\n\n---\n\n## 3. Configurable Repository Layouts\n\nCodeSync supports 3 user-configurable directory hierarchies defined in `src\u002Fstorage\u002Findex.ts`:\n\n```typescript\nexport type FolderLayout = 'difficulty' | 'platform' | 'flat';\n```\n\n### Path Generation Rules (`src\u002Fqueue\u002Findex.ts`)\n```typescript\nfunction getFolderPath(\n  layout: FolderLayout,\n  platform: string,\n  difficulty: string,\n  slug: string\n): string {\n  switch (layout) {\n    case 'difficulty':\n      \u002F\u002F Default: e.g. leetcode\u002FEasy\u002Ftwo-sum\u002F\n      return `${platform}\u002F${difficulty}\u002F${slug}`;\n    case 'platform':\n      \u002F\u002F e.g. leetcode\u002Ftwo-sum\u002F\n      return `${platform}\u002F${slug}`;\n    case 'flat':\n      \u002F\u002F e.g. two-sum\u002F\n      return slug;\n    default:\n      return `${platform}\u002F${difficulty}\u002F${slug}`;\n  }\n}\n```\n\nFiles committed under each problem directory:\n- Solution source file: `{folderPath}\u002Fsolution.{ext}`\n- Solution README: `{folderPath}\u002FREADME.md`\n\n---\n\n## 4. In-Repository Preference Synchronization (`codesync_state`)\n\nTo allow users to switch laptops or browsers (Chrome $\\leftrightarrow$ Edge) without resetting preferences or creating folder collisions, CodeSync stores an opaque, base64-encoded state string inside `stats.json` in the root of the user's repository:\n\n```json\n{\n  \"solved\": 42,\n  \"codesync_state\": \"cs:eyJsYXlvdXQiOiJkaWZmaWN1bHR5Iiwic3luY09uQWNjZXB0Ijp0cnVlLCJzeW5jSGlzdG9yaWNhbE9uVmlldyI6ZmFsc2UsImRlc2t0b3BOb3RpZmljYXRpb25zIjpmYWxzZSwidGhlbWUiOiJkcmFjdWxhIn0=\",\n  \"shas\": {}\n}\n```\n\n### Encapsulated Settings\n1. `layout`: Directory structure preference (`difficulty` | `platform` | `flat`)\n2. `syncOnAccept`: Immediate background sync toggle (`true` | `false`)\n3. `syncHistoricalOnView`: Historical submissions sync toggle (`true` | `false`)\n4. `desktopNotifications`: OS notifications toggle (`true` | `false`)\n5. `theme`: Selected UI theme identifier (`amoled`, `dracula`, `tokyo_night`, etc.)\n\nWhen a repository is selected in `src\u002Fstore\u002Findex.ts`, `parseRepoCodesyncState()` automatically decodes this payload and synchronizes local extension storage.\n\n---\n\n## 5. README & Problems Table Indexing\n\nThe root `README.md` of the target GitHub repository contains an automatically updated Markdown index table of all solved problems.\n\n### Key Rules (`src\u002Fqueue\u002FreadmeTable.ts`):\n- Pure string parsing: Never parse entire Markdown with heavy external libraries.\n- Header anchor markers: Detect `## Solved Problems` or table delimiters (`| Problem | Difficulty | Language | Solution | Date |`).\n- Deduplication: If the problem slug already exists in the table, update the existing row with the latest solve timestamp and solution link.\n- Chronological or ID ordering: Consistent formatting across all platforms.\n\n---\n\n## 6. Commit Processing Flow\n\nWhen `processQueue()` executes:\n1. Acquire execution lock: Set `codesync_is_syncing: true` in storage.\n2. Load all pending submissions in a single batched `chrome.storage.local.get()` call.\n3. Sort pending submissions chronologically (oldest to newest) to preserve authentic progression.\n4. Prepare Git Tree payload:\n   - Solution code blob\n   - Problem description `README.md`\n   - Updated root `README.md` table\n   - Updated `stats.json` (with updated `solved` count and `codesync_state`)\n5. Execute atomic commit via `GitHubClient.commitTree()`.\n6. Clear processed submission IDs and `sub_\u003Cid>` keys from storage.\n7. Release execution lock: Set `codesync_is_syncing: false`.\n\n---\n\n## 7. Testing & Verification\n\nUnit tests for queue deduplication and table formatting are located in `src\u002Fqueue\u002F__tests__\u002F`:\n```bash\nnpm run test -- src\u002Fqueue\u002F__tests__\u002FreadmeTable.test.ts\nnpm run test -- src\u002Fqueue\u002F__tests__\u002FfileExtension.test.ts\n```\n","# CodeSync Queue, Deduplication & Synchronization Guide\n\nUse this skill when modifying the submission queue, storage serialization, directory layout generation, or GitHub commit preparation in `src\u002Fqueue\u002F` and `src\u002Freadme\u002F`.\n\n---\n\n## 1. Queue Architecture & State Machine\n\nThe `CommitQueue` class (`src\u002Fqueue\u002Findex.ts`) manages incoming submissions asynchronously. To prevent race conditions from concurrent judge completions, all enqueue operations are chained onto a sequential Promise queue (`enqueuePromise`):\n\n```typescript\nexport class CommitQueue {\n  private isProcessing = false;\n  private enqueuePromise: Promise\u003Cvoid> = Promise.resolve();\n\n  async enqueue(submission: Submission): Promise\u003Cvoid> {\n    this.enqueuePromise = this.enqueuePromise.then(() => this.enqueueInternal(submission));\n    return this.enqueuePromise;\n  }\n}\n```\n\n---\n\n## 2. Deduplication Invariant\n\nBefore appending a submission to the queue, `CommitQueue` performs two checks:\n1. **Submission ID Deduplication**: If `submission.id` is already in `settings.commitQueue`, skip.\n2. **Problem Slug & Language Deduplication**: If a prior submission exists for the same problem slug and the same programming language:\n   - Remove the old submission ID from `commitQueue`.\n   - Remove the old temporary storage key `sub_${oldId}` from `chrome.storage.local`.\n   - Insert the new submission ID.\n\nThis guarantees that re-solving a problem updates existing pending files rather than creating duplicate commits or conflicting files.\n\n---\n\n## 3. Configurable Repository Layouts\n\nCodeSync supports 3 user-configurable directory hierarchies defined in `src\u002Fstorage\u002Findex.ts`:\n\n```typescript\nexport type FolderLayout = 'difficulty' | 'platform' | 'flat';\n```\n\n### Path Generation Rules (`src\u002Fqueue\u002Findex.ts`)\n```typescript\nfunction getFolderPath(\n  layout: FolderLayout,\n  platform: string,\n  difficulty: string,\n  slug: string\n): string {\n  switch (layout) {\n    case 'difficulty':\n      \u002F\u002F Default: e.g. leetcode\u002FEasy\u002Ftwo-sum\u002F\n      return `${platform}\u002F${difficulty}\u002F${slug}`;\n    case 'platform':\n      \u002F\u002F e.g. leetcode\u002Ftwo-sum\u002F\n      return `${platform}\u002F${slug}`;\n    case 'flat':\n      \u002F\u002F e.g. two-sum\u002F\n      return slug;\n    default:\n      return `${platform}\u002F${difficulty}\u002F${slug}`;\n  }\n}\n```\n\nFiles committed under each problem directory:\n- Solution source file: `{folderPath}\u002Fsolution.{ext}`\n- Solution README: `{folderPath}\u002FREADME.md`\n\n---\n\n## 4. In-Repository Preference Synchronization (`codesync_state`)\n\nTo allow users to switch laptops or browsers (Chrome $\\leftrightarrow$ Edge) without resetting preferences or creating folder collisions, CodeSync stores an opaque, base64-encoded state string inside `stats.json` in the root of the user's repository:\n\n```json\n{\n  \"solved\": 42,\n  \"codesync_state\": \"cs:eyJsYXlvdXQiOiJkaWZmaWN1bHR5Iiwic3luY09uQWNjZXB0Ijp0cnVlLCJzeW5jSGlzdG9yaWNhbE9uVmlldyI6ZmFsc2UsImRlc2t0b3BOb3RpZmljYXRpb25zIjpmYWxzZSwidGhlbWUiOiJkcmFjdWxhIn0=\",\n  \"shas\": {}\n}\n```\n\n### Encapsulated Settings\n1. `layout`: Directory structure preference (`difficulty` | `platform` | `flat`)\n2. `syncOnAccept`: Immediate background sync toggle (`true` | `false`)\n3. `syncHistoricalOnView`: Historical submissions sync toggle (`true` | `false`)\n4. `desktopNotifications`: OS notifications toggle (`true` | `false`)\n5. `theme`: Selected UI theme identifier (`amoled`, `dracula`, `tokyo_night`, etc.)\n\nWhen a repository is selected in `src\u002Fstore\u002Findex.ts`, `parseRepoCodesyncState()` automatically decodes this payload and synchronizes local extension storage.\n\n---\n\n## 5. README & Problems Table Indexing\n\nThe root `README.md` of the target GitHub repository contains an automatically updated Markdown index table of all solved problems.\n\n### Key Rules (`src\u002Fqueue\u002FreadmeTable.ts`):\n- Pure string parsing: Never parse entire Markdown with heavy external libraries.\n- Header anchor markers: Detect `## Solved Problems` or table delimiters (`| Problem | Difficulty | Language | Solution | Date |`).\n- Deduplication: If the problem slug already exists in the table, update the existing row with the latest solve timestamp and solution link.\n- Chronological or ID ordering: Consistent formatting across all platforms.\n\n---\n\n## 6. Commit Processing Flow\n\nWhen `processQueue()` executes:\n1. Acquire execution lock: Set `codesync_is_syncing: true` in storage.\n2. Load all pending submissions in a single batched `chrome.storage.local.get()` call.\n3. Sort pending submissions chronologically (oldest to newest) to preserve authentic progression.\n4. Prepare Git Tree payload:\n   - Solution code blob\n   - Problem description `README.md`\n   - Updated root `README.md` table\n   - Updated `stats.json` (with updated `solved` count and `codesync_state`)\n5. Execute atomic commit via `GitHubClient.commitTree()`.\n6. Clear processed submission IDs and `sub_\u003Cid>` keys from storage.\n7. Release execution lock: Set `codesync_is_syncing: false`.\n\n---\n\n## 7. Testing & Verification\n\nUnit tests for queue deduplication and table formatting are located in `src\u002Fqueue\u002F__tests__\u002F`:\n```bash\nnpm run test -- src\u002Fqueue\u002F__tests__\u002FreadmeTable.test.ts\nnpm run test -- src\u002Fqueue\u002F__tests__\u002FfileExtension.test.ts\n```\n",{"name":5,"description":7},"main","f2a54fba6f9faab5c8991fc4a98973e74303f925",".agent\u002Fskills\u002Fcodesync-queue-and-sync","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-queue-and-sync",{"tool":38,"command":39},"bunx","bunx skills add pardeep1916P\u002FcodeSync --skill codesync-queue-and-sync",{"tool":41,"command":42},"pnpm","pnpm dlx skills add pardeep1916P\u002FcodeSync --skill codesync-queue-and-sync","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpardeep1916P\u002FcodeSync\u002Fblob\u002Fmain\u002F.agent\u002Fskills\u002Fcodesync-queue-and-sync\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",[],[]]