Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a862c49
Add 1193. Monthly Transactions I and update notebook kernelspec
myoshi2891 Feb 26, 2026
72bf3ca
build: auto-generate public directory
myoshi2891 Feb 26, 2026
663dcb5
fix(1193): address code review findings for Monthly Transactions I
myoshi2891 Feb 26, 2026
474600a
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
d643a02
build: auto-generate public directory
myoshi2891 Feb 26, 2026
62ce079
Fix code review findings in Monthly_Transactions_I and generate_index.py
myoshi2891 Feb 26, 2026
7898bd7
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
bfbfa6b
build: auto-generate public directory
myoshi2891 Feb 26, 2026
1c6d58b
Fix SQL vs pandas GROUP BY explanation, XSS in generate_index.py, and…
myoshi2891 Feb 26, 2026
1ad6688
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
f76671d
build: auto-generate public directory
myoshi2891 Feb 26, 2026
f70495f
chore: add code-review-guidelines skill
myoshi2891 Feb 26, 2026
f3d1bf9
docs: add Gemini.md and general-implementation-rules skill
myoshi2891 Feb 26, 2026
7cf22fc
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
82dcc39
build: auto-generate public directory
myoshi2891 Feb 26, 2026
61381a9
Merge branch 'main' into dev-from-macmini
myoshi2891 Feb 26, 2026
9a3c530
build: auto-generate public directory
myoshi2891 Feb 26, 2026
d4e68be
fix: resolve final code review comments for Prism, regex, and Tailwind
myoshi2891 Feb 26, 2026
f8ed852
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
1b01105
build: auto-generate public directory
myoshi2891 Feb 26, 2026
e583f37
fix: resolve 4th batch of code review comments (Prism regex, duplicat…
myoshi2891 Feb 26, 2026
a510e71
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
bd7d004
build: auto-generate public directory
myoshi2891 Feb 26, 2026
d3ee5fc
📝 Add docstrings to `dev-from-macmini`
coderabbitai[bot] Feb 26, 2026
1c22fcf
build: auto-generate public directory
coderabbitai[bot] Feb 26, 2026
3bae412
📝 Add docstrings to `dev-from-macmini`
coderabbitai[bot] Feb 26, 2026
8237ef7
build: auto-generate public directory
coderabbitai[bot] Feb 26, 2026
60ae269
fix: resolve 5th batch of code review comments (generate_index typing…
myoshi2891 Feb 26, 2026
8e8875b
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
7a3948f
build: auto-generate public directory
myoshi2891 Feb 26, 2026
cdb281c
fix(script): resolve code review findings in generate_index.py
myoshi2891 Feb 26, 2026
b770071
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStu…
myoshi2891 Feb 26, 2026
227d557
build: auto-generate public directory
myoshi2891 Feb 26, 2026
0c73108
Merge branch 'main' into dev-from-macmini
myoshi2891 Feb 26, 2026
1eb5c3e
build: auto-generate public directory
myoshi2891 Feb 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .agent/skills/code-review-guidelines/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: code-review-guidelines
description: >
Applies accumulated project-specific codebase review rules and best practices.
Use when generating, refactoring, or reviewing frontend HTML, rendering logic, or Python generation scripts (like generate_index.py).
---

# Code Review Guidelines Skill

## Goal

To maintain security, robustness, idempotency, and technical accuracy across the project's frontend and generator code, based on accumulated review feedback.

## Instructions

Whenever you write, refactor, or review code for this project, you **MUST** ensure the following rules are met:

### 1. Security & XSS Prevention

- Never use `innerHTML` in templates or frontend JavaScript. Always use `textContent` and DOM APIs.
- When embedding variables into HTML attributes (e.g., `href`, `class`) or text from backend/generator scripts (like `generate_index.py`), you **MUST** escape them using native escaping functions (e.g., `html.escape(..., quote=True)` in Python).

### 2. Asset Management & CDN Links

- **Regex Replacing:** When rewriting CDN URLs to local `/vendor/...` paths, use robust regex patterns (e.g., matching `@<version>` segments) rather than literal string replacements.
- **SRI Stripping:** If an asset link is changed from an external CDN to a local `/vendor/` path, you **MUST** strip any `integrity="..."` and `crossorigin="..."` attributes from the corresponding `<script>` or `<link>` tags to prevent the browser from blocking the local file due to hash mismatch.

### 3. Rendering Robustness (PrismJS & UI)

- Do not rely on brittle `setTimeout` delays to wait for the DOM or dynamic content to render.
- **High-Performance Scheduling:** Use `requestIdleCallback` (with a `requestAnimationFrame` and `setTimeout` fallback for Safari/older browsers) to trigger UI updates like `Prism.highlightAll()`.
- **Dynamic Content Observation:** Attach a `MutationObserver` to re-trigger highlighting or UI updates automatically when new elements are injected into the DOM.

### 4. Data Handling & Idempotency

- **UI Data Types:** Use the correct native data types in source data (e.g., use the primitive `null` instead of the string `"NULL"` in JSON/JS objects). Convert them to display strings (like `"NULL"`) _only_ at the rendering/display layer.
- **Idempotency:** When appending labels, suffixes, or classes (e.g., appending " (detailed)" to a title), check if the string is already present before appending it to avoid duplicates.

### 5. Technical Accuracy

- Ensure that technical explanations in learning materials (e.g., `README.html`) are precise and accurately reflect the differences between tools.
- _Example:_ SQL `GROUP BY` treats `NULL` values as a single group, whereas `pandas.groupby` explicitly drops `NA` keys by default (`dropna=True`).

## Examples

### XSS Prevention in Python

**Input:** Outputting an encoded path to an href attribute.
**Output:**

```python
# GOOD
safe_encoded_path = html.escape(urllib.parse.quote(path), quote=True)
html_str = f'<a href="{safe_encoded_path}">'

# BAD
html_str = f'<a href="{urllib.parse.quote(path)}">'
```

### Robust Rendering in JavaScript

**Input:** Triggering Prism highlighting after React renders.
**Output:**

```javascript
// GOOD
const scheduleHighlight = () => {
const highlight = () => {
if (window.Prism) {
Prism.highlightAll();
}
};
if (window.requestIdleCallback) {
requestIdleCallback(highlight, { timeout: 1000 });
} else {
requestAnimationFrame(() => setTimeout(highlight, 0));
}
};

const observer = new MutationObserver((mutations) => {
if (mutations.some((m) => m.addedNodes.length > 0)) {
scheduleHighlight();
}
});
observer.observe(document.getElementById('root'), { childList: true, subtree: true });
scheduleHighlight();
```

## Constraints

- Do not bypass security validations for the sake of brevity.
- Do not add external library dependencies to solve these issues; use native browser/language features (e.g., vanilla JS `MutationObserver`, standard lib `html`).
79 changes: 79 additions & 0 deletions .agent/skills/general-implementation-rules/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: general-implementation-rules
description: >
Applies general implementation best practices, coding conventions, and architectural constraints.
Use when writing new code, implementing algorithms, scaffolding new features, or deciding on technical approaches.
---

# General Implementation Rules Skill

## Goal

To ensure high-quality, secure, maintainable, and predictable code implementation across all languages and scripts within the project.

## Instructions

Whenever you are writing new implementation code, scripts, or frontend UI, you **MUST** adhere to the following rules:

### 1. Language & Library Constraints

- **Algorithmic Code (Python/DataStructures/Math)**: You MUST only use standard built-in libraries (e.g., `typing`, `collections`, `itertools`, `math`, `heapq` in Python). Third-party packages are strictly forbidden.
- **JavaScript/TypeScript**: Stick to Node.js/Deno/Browser built-ins. Do not use external utility libraries like `lodash`.
- **SQL Domain Exception**: For SQL domain `.ipynb` files only, data science libraries like `Pandas` or `NumPy` are permitted.
- **Package Manager**: Exclusively use `bun` (e.g., `bun install`, `bunx`) instead of `npm`.

### 2. Implementation Style & Types

- **TypeScript**: Enforce `strict: true` and `noImplicitAny: true`. Target ES2022. Write functions as: `function functionName(...): ReturnType { ... }`.
- **Python**: Always use type hints. Class methods must be strictly typed: `class Solution:\n def methodName(self, ...) -> ReturnType:`.
- **JavaScript**: Use module exports standard for the repo: `var functionName = function(...) { ... }; module.exports = { functionName };`.

### 3. Security & DOM Manipulation

- **Strict No `innerHTML`**: Never write to `innerHTML` directly. Use `document.createElement`, `textContent`, `replaceChildren`, and other standard DOM APIs to prevent XSS.
- **Variable Escaping**: Any dynamic strings interpolated into HTML output (including attributes like `href` in Python generation scripts) MUST be escaped using native libraries (e.g., `html.escape(str, quote=True)`).

### 4. Code Generation Rule

- **Do NOT manually edit output files**: Files under the `public/` directory (like `public/index.html`) are auto-generated. Do never edit them directly. Always edit the generator scripts (e.g., `generate_index.py`).

### 5. Robustness & Best Practices

- **Idempotency**: Write scripts and functions idempotently. E.g., before appending a specific suffix to a title or writing a log, verify it doesn't already exist.
- **Native Data Types**: When holding data state in memory (like JSON UI models), use native primitive types (e.g., `null`). Only convert them to string representations (like `"NULL"`) at the exact point of UI rendering.

## Examples

### Strict DOM Manipulation

**Input**: "Update the UI with the user's input"
**Output**:

```javascript
// GOOD
const div = document.getElementById('output');
div.textContent = userInput;

// BAD - XSS vulnerability
const div = document.getElementById('output');
div.innerHTML = `<span>${userInput}</span>`;
```

### Idempotency Example

**Input**: "Append ' (detailed)' to the title"
**Output**:

```python
# GOOD
if " (detailed)" not in title:
title += " (detailed)"

# BAD - Can duplicate
title += " (detailed)"
```

## Constraints

- Never bypass the standard library limitations (no `pip install <lib>` or `bun add <lib>` for algorithmic solutions).
- Do not write code that assumes synchronous execution for heavy DOM updates; prefer async scheduling like `requestIdleCallback`.
Original file line number Diff line number Diff line change
Expand Up @@ -934,12 +934,16 @@ <h4 class="font-bold text-blue-900 mb-2">💡 最適化ポイント</h4>
<script src="https://unpkg.com/@babel/standalone@7.24.0/babel.min.js"></script>

<!-- Prism.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-typescript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<script src="../../../../../vendor/prismjs/prism.js"></script>
<!-- Language Components -->
<script src="../../../../../vendor/prismjs/components/prism-python.js"></script>
<script src="../../../../../vendor/prismjs/components/prism-clike.js"></script>
<script src="../../../../../vendor/prismjs/components/prism-javascript.js"></script>
<script src="../../../../../vendor/prismjs/components/prism-typescript.js"></script>
<!-- The standalone PrismJS plugins -->
<script src="../../../../../vendor/prismjs/plugins/line-numbers/prism-line-numbers.js"></script>
<script src="../../../../../vendor/prismjs/plugins/toolbar/prism-toolbar.js"></script>
<script src="../../../../../vendor/prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard.js"></script>
Comment thread
coderabbitai[bot] marked this conversation as resolved.

<!-- React Component -->
<script type="text/babel">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ <h2>5. 時間計算量の説明</h2>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-python.min.js"></script>

<script>
// ==========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ <h2 class="text-xl font-semibold">5. 時間計算量の説明</h2>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-python.min.js"></script>

<!-- Interactions -->
<script>
Expand Down
62 changes: 62 additions & 0 deletions Gemini.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Gemini.md

This file provides guidance to Gemini (or other Google AI assistants) when working with code in this repository.

## プロジェクト概要

マルチ言語・マルチAIによる競技プログラミング学習リポジトリ。各問題に対して**2社 × Nモデル × 3言語 × 3ドキュメント階層**で成果物を生成することを目的としています。

## スタック

- **パッケージマネージャ**: Bun (Node.jsの代わりに `bun install` などを使用)
- **言語**: Python, TypeScript, JavaScript, SQL, HTML
- **フロントエンドライブラリ**: React 18 UMD, Babel Standalone, Tailwind CSS, Prism.js
- **テスト**: `pytest` (Python), `vitest` (JS/TS)
- **リント・フォーマット**: `ruff`, `black` (Python) / `prettier`, `eslint` (JS/TS)

## ルーティングルール(ディレクトリ構造)

基本的に以下の6階層ディレクトリ構造に従います。

```text
{Domain}/{Subcategory}/{Platform}/{Problem}/{AIProvider}/{Artifact}
```

- **Domain**: `Algorithm/`, `DataStructures/`, `Mathematics/`, `SQL/`, `Shell/`, `Concurrency/`
- **Platform**: `leetcode/`, `hackerrank/`, `atcoder/`, `codeforces/`
- **AIProvider**: `Claude Sonnet 4.5/`, `gpt-4o/`, `Gemini/` など
- **Artifact**: `*.py`, `*.ts`, `*.js`, `README.md`, `README.html`, `README_react.html`

**※例外**:

- `JavaScript/` ディレクトリは LeetCode 30-Day JS Challenge 専用であり、上記6階層に従いません。
- `SQL/` ドメインはAIプロバイダーが `gpt/` 単一フォルダで `.ipynb` 形式になる場合があります。

### ドキュメント構成(3階層)

1. `README.md`: 純粋Markdown(Overview / Algorithm / Complexity / Implementation / Optimization の5セクション構造)
2. `README.html`: Prism.js + Tailwind CSS を用いたステップコントロールUI、SVGフローチャート
3. `README_react.html`: React 18 UMD + Babel Standalone を用いたリアルタイム入力操作・AI比較用UI

## 禁止操作・制約事項

### 1. 依存関係の禁止(ビルトイン限定)

- **Algorithm / DataStructures / Mathematics**: 標準ライブラリのみ使用可能です(例: `typing`, `collections`, `itertools`, `math`, `heapq`)。サードパーティ製ライブラリのインポートは**禁止**です。
- **JS / TS実装**: Node.jsやDenoのビルトインのみ。`lodash` などの外部ライブラリの使用は**禁止**です。
- ※例外として `SQL` ドメインでのみ Pandas / NumPy の使用が許可されています(`.ipynb` 形式)。

### 2. ファイルの直接編集禁止

- `public/index.html` 等の `public/` 配下のファイルは、すべて自動生成される成果物です。手動での直接編集は**禁止**です。
- 変更が必要な場合は、必ずジェネレータである `generate_index.py` 側を修正して再生成 (`python generate_index.py`) してください。

### 3. セキュリティに係る禁止操作・必須操作

- テンプレート内JSで `innerHTML` を使用することは**禁止**です(セキュリティフックによるブロックを避けるため)。必ず `textContent` + DOM API を使用してください。
- HTML出力に動的な文字列を埋め込む際は、XSS防止のため `html.escape()` を**必須**で行ってください。

### 4. ブラウザテスト等のファイルパス制限

- `file://` URLでのアクセスはブロックされる前提で設計されています。
- テスト等で確認が必要な場合は `python -m http.server 8765 --directory public` でローカルサーバーを起動してアクセスしてください。
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
Loading