Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .claude/.dev/update_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def update_tags(tag_names=None):
with open(output_file, "w") as f:
json.dump(update_tags, f, indent=4)

tags_file = (
Path(__file__).parent.parent.parent
/ "src/leetcode_py/cli/resources/leetcode/json/tags.json5"
)
print(f"\nUpdate tags with missing problems written to {output_file}")
print(f"Target file to update: {tags_file}")
print(f"Total tags with missing problems: {len(update_tags)}")


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
---
name: batch-problem-creation
argument-hint: "[count]"
description: Batch creation workflow for multiple LeetCode problems - loops through problem creation, solution implementation, and quality assurance for a specified count. Accepts optional count argument (e.g., /batch-problem-creation 10). Defaults to 5 if no argument. Use ONLY when user explicitly requests batch creation via /batch-problem-creation command.
---

# Batch Problem Creation Command

## Assistant Workflow

When user requests **batch creation of multiple problems**, the assistant will:

1. **Get count from user** (default: 5 problems)
1. **Parse count**: Use `$ARGUMENTS` as count if provided (must be valid integer). Otherwise ask user (default: 5 problems)
2. **Loop through each problem** following the complete workflow
3. **For each problem**:
- Find next problem via `uv run python .claude/.dev/next_problem.py`
- Follow all steps from @.claude/commands/problem-creation.md
- **MANDATORY**: Read and follow @.claude/commands/test-quality-assurance.md for quality verification
- Follow all steps from @.claude/skills/problem-creation.md
- **MANDATORY**: Read and follow @.claude/skills/test-quality-assurance.md for quality verification
4. **Provide batch summary** at the end

**CRITICAL INSTRUCTION**: You MUST read the test-quality-assurance.md file before executing quality assurance for any problem. Do not rely on memory or assumptions about the workflow.
Expand Down Expand Up @@ -38,7 +44,7 @@ uv run python .claude/.dev/next_problem.py

#### 2.2: Follow Problem Creation Workflow

Execute complete workflow from @.claude/commands/problem-creation.md:
Execute complete workflow from @.claude/skills/problem-creation.md:

1. **Scrape** problem data using `uv run lcpy scrape`
2. **Transform** data into proper JSON template format
Expand All @@ -58,11 +64,11 @@ Execute complete workflow from @.claude/commands/problem-creation.md:

#### 2.4: Quality Assurance & Reproducibility Verification

**MANDATORY**: You MUST read and follow the complete workflow from `.claude/commands/test-quality-assurance.md` for EVERY problem.
**MANDATORY**: You MUST read and follow the complete workflow from `.claude/skills/test-quality-assurance.md` for EVERY problem.

**REQUIRED ACTION**: Before proceeding with quality assurance, you MUST:

1. **Read the file**: @.claude/commands/test-quality-assurance.md
1. **Read the file**: @.claude/skills/test-quality-assurance.md
2. **Follow the exact 4-step process** described in that file
3. **Execute each step** as specified in the test-quality-assurance.md workflow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
name: problem-creation
description: Guide for creating a single LeetCode problem scaffold - scrape, transform to JSON template, generate files, and verify. Use ONLY when user explicitly requests problem creation via /problem-creation command or provides a specific LeetCode problem number/name.
---

# Problem Creation Guide

## Assistant Workflow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
name: test-quality-assurance
description: Test quality assurance workflow for LeetCode problems - verifies reproducibility, fixes linting issues, and ensures test structure matches JSON templates. Use ONLY when user explicitly requests test quality assurance via /test-quality-assurance command.
---

# Test Quality Assurance Rules

## CRITICAL: Follow These Steps EXACTLY - No Deviations
Expand Down Expand Up @@ -33,20 +38,20 @@ rm -rf leetcode/{problem_name}_backup

### 3. What NOT to Do

- **NEVER edit cookiecutter templates** (`{{cookiecutter.problem_name}}/` files)
- **NEVER use `uv run python -m leetcode_py.cli.main gen`** - use `bake p-gen` instead
- **NEVER modify helpers.py manually** - let regeneration handle it
- **NEVER skip ty verification** - this is the main CI issue
- **NEVER assume tests will pass** - they may fail if solution is incomplete
- **NEVER use `null` in JSON templates** - use `None` for Python None values
- **NEVER edit cookiecutter templates** (`{{cookiecutter.problem_name}}/` files)
- **NEVER use `uv run python -m leetcode_py.cli.main gen`** - use `bake p-gen` instead
- **NEVER modify helpers.py manually** - let regeneration handle it
- **NEVER skip ty verification** - this is the main CI issue
- **NEVER assume tests will pass** - they may fail if solution is incomplete
- **NEVER use `null` in JSON templates** - use `None` for Python None values

### 4. What to Do

- **ALWAYS use `bake p-gen -p {problem_name} -f`** for regeneration
- **ALWAYS verify ty passes** before considering task complete
- **ALWAYS restore original solution** after regeneration
- **ALWAYS check JSON template** if ty fails (look for `assert_assert_` bugs)
- **ALWAYS use `None` not `null` in JSON templates** for Python None values
- **ALWAYS use `bake p-gen -p {problem_name} -f`** for regeneration
- **ALWAYS verify ty passes** before considering task complete
- **ALWAYS restore original solution** after regeneration
- **ALWAYS check JSON template** if ty fails (look for `assert_assert_` bugs)
- **ALWAYS use `None` not `null` in JSON templates** for Python None values

## Test Case Standards

Expand Down Expand Up @@ -99,42 +104,42 @@ bake p-gen -p {problem_name} -f

## Common Issues & Solutions

### Issue: `assert_assert_missing_number` Error
### Issue: \`assert_assert_missing_number\` Error

**Cause**: JSON template has `helpers_assert_name: "assert_missing_number"` but template adds `assert_` prefix
**Solution**: Change JSON to `helpers_assert_name: "missing_number"` so template generates `assert_missing_number`
**Cause**: JSON template has \`helpers*assert_name: "assert_missing_number"\` but template adds \`assert*\` prefix
**Solution**: Change JSON to \`helpers_assert_name: "missing_number"\` so template generates \`assert_missing_number\`

### Issue: ty Import Errors

**Cause**: Regenerated helpers.py doesn't match test imports
**Solution**: Use `bake p-gen` (not uv run) and verify JSON template is correct
**Solution**: Use \`bake p-gen\` (not uv run) and verify JSON template is correct

### Issue: Tests Fail After Regeneration

**Expected**: Tests may fail if solution is incomplete (returns 0 or placeholder)
**Action**: This is normal - focus on ty passing, not test results

### Issue: `null` vs `None` in JSON Templates
### Issue: \`null\` vs \`None\` in JSON Templates

**Cause**: JSON template uses `null` which causes linting errors in generated Python code
**Cause**: JSON template uses \`null\` which causes linting errors in generated Python code

- Error: `F821 Undefined name 'null'` from ruff/ty
- Generated test files contain `null` which is not valid Python
- Error: \`F821 Undefined name 'null'\` from ruff/ty
- Generated test files contain \`null\` which is not valid Python

**Solution**: Update JSON template to use `None` instead of `null`
**Solution**: Update JSON template to use \`None\` instead of \`null\`

- Change: `"([1, null, 2], 3, 1)"` → `"([1, None, 2], 3, 1)"`
- This applies to `test_cases` list and `playground_setup` fields
- After fixing JSON, regenerate with `bake p-gen -p {problem_name} -f`
- Change: \`"([1, null, 2], 3, 1)"\` → \`"([1, None, 2], 3, 1)"\`
- This applies to \`test_cases\` list and \`playground_setup\` fields
- After fixing JSON, regenerate with \`bake p-gen -p {problem_name} -f\`
- Generated code will now pass linting without manual edits

## Success Criteria

- **ty passes** with no errors (CRITICAL for CI)
- **Test structure matches JSON template** exactly
- **Original solution preserved** (user's code intact)
- **helpers.py generated correctly** (no `assert_assert_` bugs)
- **Reproducibility verified** (can regenerate consistently)
- **ty passes** with no errors (CRITICAL for CI)
- **Test structure matches JSON template** exactly
- **Original solution preserved** (user's code intact)
- **helpers.py generated correctly** (no \`assert*assert*\` bugs)
- **Reproducibility verified** (can regenerate consistently)

## When to Use This Workflow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
name: update-tags
description: Updates .tags.json5 by running update_tags.py script, sorting output alphabetically, and cleaning up temp files. Use ONLY when user explicitly requests "update tags" or "/update-tags".
---

# Update Tags Command

## Description
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
# ====================================================
semantic-release:
name: semantic-release
uses: wislertt/zerv/.github/workflows/shared-semantic-release.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-semantic-release.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
with:
allowed_workflow_dispatch_branches: '["main"]'
fail_on_invalid_workflow_dispatch_ref: true

zerv-versioning:
needs: semantic-release
if: needs.semantic-release.outputs.is_valid_semantic_release == 'true'
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15

create-version-prefix-tags:
needs: zerv-versioning
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
with:
tags: >-
[
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# ====================================================
check-pre-release:
name: check-pre-release
uses: wislertt/zerv/.github/workflows/shared-check-pr-label-and-branch.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-check-pr-label-and-branch.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
with:
target_label: "pre-release"
branch_prefixes: '["release/"]'
Expand All @@ -23,7 +23,7 @@ jobs:
zerv-versioning:
name: zerv-versioning
needs: check-pre-release
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
with:
schema: >-
${{ (needs.check-pre-release.outputs.is_valid == 'true'
Expand All @@ -34,7 +34,7 @@ jobs:
name: tag-pre-release
needs: [zerv-versioning, check-pre-release]
if: needs.check-pre-release.outputs.is_valid == 'true'
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@643777b9a3573497fd9f8edabe340f256acce981 # v0.8.13
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@bab11cb3fe35f4f9b4fd746f7ea159ba00e0109d # v0.8.15
with:
tags: '["${{ fromJson(needs.zerv-versioning.outputs.versions).v_semver }}"]'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Run Trivy dependency scan
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # 0.35.0
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
format: table
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test-reproducibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ jobs:
- name: run-linting-to-verify-reproducibility
run: bake lint

- name: convert-notebooks-to-python
run: bake nb-to-py

- name: run-linting-to-verify-reproducibility-after-convert-nb-to-py
run: bake lint

- name: check-consistency-with-json
run: bake check-consistency --backup .cache/leetcode

- name: copy-solution-files-from-backup
run: |
for problem in .cache/leetcode/*/; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ jobs:

- name: sonarqube-scan
if: matrix.python-version == inputs.target_python_version && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
uses: SonarSource/sonarqube-scan-action@299e4b793aaa83bf2aba7c9c14bedbb485688ec4 # v7.1.0
uses: SonarSource/sonarqube-scan-action@59db25f34e16620e48ab4bb9e4a5dce155cb5432 # v8.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Loading
Loading