Structure Analysis

L3
ModelContextProtocolFilesystemFolder Structure

Perform thorough analysis of complex folder hierarchy to generate a detailed structural summary report with comprehensive file statistics.

Created by Lingjun Chen
2025-08-16
Pattern AnalysisData Extraction

Model Ranking

Click on the dots to view the trajectory of each task run
Model
Run Results
Pass@4
Pass^4
Avg Time
Avg Turns
Input Tokens
Output Tokens
Total Tokens
Claude
claude-4-1-opus
0
/1
--
146.5s
13.0
167,036
1,881
168,917
Claude
claude-4-sonnet
0
/4
236.7s
14.5
249,888
2,813
252,700
DeepSeek
deepseek-chat
0
/4
176.3s
14.8
271,215
2,027
273,241
Gemini
gemini-2-5-pro
0
/4
164.1s
6.3
50,455
11,486
61,941
OpenAI
gpt-5
0
/4
1055.5s
12.8
265,030
77,520
342,550
Grok
grok-4
0
/4
1090.3s
14.3
-
-
-
MoonshotAI
k2
0
/4
135.9s
27.5
294,298
2,997
297,295
OpenAI
o3
0
/4
1039.5s
17.5
280,404
85,037
365,441
Qwen
qwen-3-coder
0
/4
279.0s
58.3
622,837
6,536
629,372

Task State

Task Initial State Files
Download ZIP package to view the complete file structure
folder_structure/ └── complex_structure/ ├── deeply/ │ └── nested/ │ └── folder/ │ └── structure/ ├── empty_folder/ ├── folder_lxkHt_0_1/ │ └── file_PeLzC_0.txt ├── folder_QdTAj_0_2/ │ ├── folder_eXccj_1_0/ │ │ ├── folder_Mqlwh_2_1/ │ │ │ ├── folder_cKxcP_3_3/ │ │ │ │ ├── folder_BPTMK_4_1/ │ │ │ │ │ └── file_RHtBP_0.txt │ │ │ │ ├── folder_QNqjq_4_0/ │ │ │ │ │ ├── folder_gRwPE_5_1/ │ │ │ │ │ │ ├── file_jVlpp_0.txt │ │ │ │ │ │ └── file_vJuHz_1.txt │ │ │ │ │ ├── folder_XdXYJ_5_0/ │ │ │ │ │ │ └── file_KvkKi_0.txt │ │ │ │ │ ├── file_gGxLG_2.txt │ │ │ │ │ ├── file_Hzkxo_0.txt │ │ │ │ │ └── file_XRjeh_1.txt │ │ │ │ ├── folder_vIBIt_4_2/ │ │ │ │ │ ├── folder_kRDNS_5_0/ │ │ │ │ │ │ └── file_wFSjJ_0.txt │ │ │ │ │ └── file_NyBSO_0.txt │ │ │ │ ├── file_EOCNf_1.txt │ │ │ │ └── file_gmrXA_0.txt │ │ │ ├── folder_NcruA_3_1/ │ │ │ │ ├── file_bLWDj_1.txt │ │ │ │ └── file_WAftR_0.txt │ │ │ ├── folder_qCDFI_3_2/ │ │ │ │ ├── file_eSMOJ_0.txt │ │ │ │ ├── file_oxADy_2.txt │ │ │ │ └── file_RTbbc_1.txt │ │ │ ├── folder_QVHUU_3_0/ │ │ │ │ ├── folder_FEPTK_4_1/ │ │ │ │ │ ├── folder_GHoMC_5_1/ │ │ │ │ │ │ └── file_rAMYd_0.txt │ │ │ │ │ ├── folder_iBDUY_5_0/ │ │ │ │ │ │ └── file_IJCaw_0.txt │ │ │ │ │ ├── folder_VRXgp_5_2/ │ │ │ │ │ │ └── file_hkUmS_0.txt │ │ │ │ │ ├── file_nqLAf_1.txt │ │ │ │ │ └── file_XflmA_0.txt │ │ │ │ ├── folder_FlPoK_4_3/ │ │ │ │ │ ├── folder_hSVNm_5_3/ │ │ │ │ │ │ └── file_klnbn_0.txt │ │ │ │ │ ├── folder_iZuEl_5_0/ │ │ │ │ │ │ └── file_LqAmy_0.txt │ │ │ │ │ ├── folder_LcURj_5_2/ │ │ │ │ │ │ ├── file_RgwOS_1.txt │ │ │ │ │ │ └── file_ZHnYb_0.txt │ │ │ │ │ ├── folder_tuZQJ_5_1/ │ │ │ │ │ │ └── file_LHuIx_0.txt │ │ │ │ │ ├── file_asJnB_1.txt │ │ │ │ │ └── file_EzLdu_0.txt │ │ │ │ ├── folder_ndhsJ_4_0/ │ │ │ │ │ ├── folder_CUSXK_5_0/ │ │ │ │ │ │ ├── file_DpiuM_1.txt │ │ │ │ │ │ └── file_pSqeG_0.txt │ │ │ │ │ ├── folder_pstmE_5_1/ │ │ │ │ │ │ └── file_YwdJt_0.txt │ │ │ │ │ ├── folder_StlsP_5_2/ │ │ │ │ │ │ ├── file_kriBJ_0.txt │ │ │ │ │ │ └── file_XCEdm_1.txt │ │ │ │ │ ├── file_ToDjh_1.txt │ │ │ │ │ └── file_xbIVx_0.txt │ │ │ │ ├── folder_PJBok_4_4/ │ │ │ │ │ ├── folder_mzxaf_5_0/ │ │ │ │ │ │ ├── file_ILBzj_2.txt │ │ │ │ │ │ ├── file_MTGMm_1.txt │ │ │ │ │ │ └── file_zBDqz_0.txt │ │ │ │ │ ├── folder_sULMj_5_1/ │ │ │ │ │ │ ├── file_BHziw_1.txt │ │ │ │ │ │ ├── file_sIjiu_2.txt │ │ │ │ │ │ └── file_VqNkB_0.txt │ │ │ │ │ ├── folder_vypSi_5_3/ │ │ │ │ │ │ ├── file_kZbIm_1.txt │ │ │ │ │ │ └── file_sOBtE_0.txt │ │ │ │ │ ├── folder_ZLGHy_5_2/ │ │ │ │ │ │ ├── file_azaFF_0.txt │ │ │ │ │ │ └── file_nAFRe_1.txt │ │ │ │ │ ├── file_mIkQU_0.txt │ │ │ │ │ └── file_sGPxd_1.txt │ │ │ │ ├── folder_VTbEG_4_2/ │ │ │ │ │ ├── file_HtYLg_0.txt │ │ │ │ │ ├── file_JXjMd_1.txt │ │ │ │ │ └── file_tPccB_2.txt │ │ │ │ ├── file_BuOSw_1.txt │ │ │ │ └── file_TpoqE_0.txt │ │ │ ├── folder_wTvun_3_4/ │ │ │ │ ├── file_GyhyE_1.txt │ │ │ │ ├── file_POsla_2.txt │ │ │ │ └── file_tSsvk_0.txt │ │ │ ├── file_irNju_0.txt │ │ │ └── file_jYBRm_1.txt │ │ ├── folder_YlJLI_2_0/ │ │ │ └── file_FpFSL_0.txt │ │ ├── file_cFgBr_2.txt │ │ ├── file_lKEWN_1.txt │ │ └── file_ZEWFP_0.txt │ └── file_ayUCH_0.txt ├── folder_xtgyi_0_0/ │ └── file_BvSOB_0.txt ├── mixed_content/ │ └── images_and_text/ │ └── notes.txt ├── project/ │ ├── docs/ │ │ └── archive/ │ │ └── 2023/ │ │ └── reports/ │ │ ├── report_0.txt │ │ ├── report_1.txt │ │ └── report_2.txt │ └── src/ │ └── main/ │ └── resources/ └── m.py

Instruction



Verify

*.py
Python
#!/usr/bin/env python3
"""
Verification script for Directory Structure Analysis Task
"""

import sys
from pathlib import Path
import os
import re

def get_test_directory() -> Path:
    """Get the test directory from FILESYSTEM_TEST_DIR env var."""
    test_root = os.environ.get("FILESYSTEM_TEST_DIR")
    if not test_root:
        raise ValueError("FILESYSTEM_TEST_DIR environment variable is required")
    return Path(test_root)

def verify_structure_analysis_file_exists(test_dir: Path) -> bool:
    """Verify that the structure_analysis.txt file exists."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    if not analysis_file.exists():
        print("❌ File 'structure_analysis.txt' not found")
        return False
    
    print("✅ structure_analysis.txt file found")
    return True

def verify_structure_analysis_file_readable(test_dir: Path) -> bool:
    """Verify that the structure_analysis.txt file is readable."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    try:
        content = analysis_file.read_text()
        if not content.strip():
            print("❌ structure_analysis.txt file is empty")
            return False
        
        print("✅ structure_analysis.txt file is readable")
        return True
        
    except Exception as e:
        print(f"❌ Error reading structure_analysis.txt file: {e}")
        return False

def verify_subtask1_file_statistics(test_dir: Path) -> bool:
    """Verify subtask 1: File Statistics - files must be 69, folders must be 51, 58097 allows +-1000."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    try:
        content = analysis_file.read_text()
        
        # Extract numbers from the content
        file_count_match = re.search(r'total number of files:\s*(\d+)', content)
        folder_count_match = re.search(r'total number of folders:\s*(\d+)', content)
        size_match = re.search(r'total size of all files:\s*(\d+)', content)
        
        if not file_count_match or not folder_count_match or not size_match:
            print("❌ Could not extract file statistics from structure_analysis.txt")
            return False
        
        file_count = int(file_count_match.group(1))
        folder_count = int(folder_count_match.group(1))
        total_size = int(size_match.group(1))
        
        print(f"📊 Found: files={file_count}, folders={folder_count}, size={total_size}")
        
        # Check if file count is exactly 69
        if file_count != 69:
            print(f"❌ File count must be 69, found: {file_count}")
            return False
        
        # Check if folder count is exactly 51
        if folder_count != 51:
            print(f"❌ Folder count must be 51, found: {folder_count}")
            return False
        
        # Check if size is within acceptable range (58097 ± 1000)
        expected_size = 58097
        size_tolerance = 1000
        if abs(total_size - expected_size) > size_tolerance:
            print(f"❌ Total size ({total_size}) is not within acceptable range ({expected_size} ± {size_tolerance})")
            return False
        
        print(f"✅ File statistics verified: files={file_count}, folders={folder_count}, size={total_size} (within tolerance)")
        return True
        
    except Exception as e:
        print(f"❌ Error verifying file statistics: {e}")
        return False

def verify_subtask2_depth_analysis(test_dir: Path) -> bool:
    """Verify subtask 2: Depth Analysis - depth must be 7, verify path exists."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    try:
        content = analysis_file.read_text()
        
        # Extract depth and path
        depth_match = re.search(r'depth:\s*(\d+)', content)
        path_match = re.search(r'^([^\n]+)$', content, re.MULTILINE)
        
        if not depth_match:
            print("❌ Could not extract depth from structure_analysis.txt")
            return False
        
        depth = int(depth_match.group(1))
        
        # Check if depth is exactly 7
        if depth != 7:
            print(f"❌ Depth must be 7, found: {depth}")
            return False
        
        print(f"✅ Depth verified: {depth}")
        
        # Extract the path (it should be on a separate line after "depth: 7")
        lines = content.split('\n')
        path_line = None
        for i, line in enumerate(lines):
            if line.strip() == f"depth: {depth}":
                if i + 1 < len(lines):
                    path_line = lines[i + 1].strip()
                    break
        
        if not path_line:
            print("❌ Could not find path line after depth specification")
            return False
        
        print(f"📁 Found path: {path_line}")
        
        # Verify that the path depth matches the declared depth
        path_parts = path_line.split('/')
        actual_depth = len(path_parts)
        
        if actual_depth != depth:
            print(f"❌ Path depth mismatch: declared depth is {depth}, but path has {actual_depth} levels")
            print(f"   Path: {path_line}")
            print(f"   Path parts: {path_parts}")
            return False
        
        print(f"✅ Path depth verified: {actual_depth} levels")
        
        # Verify that this path exists in the test environment
        expected_path = test_dir / path_line
        if not expected_path.exists():
            print(f"❌ Path does not exist: {expected_path}")
            return False
        
        if not expected_path.is_dir():
            print(f"❌ Path exists but is not a directory: {expected_path}")
            return False
        
        print(f"✅ Path verified and exists: {path_line}")
        return True
        
    except Exception as e:
        print(f"❌ Error verifying depth analysis: {e}")
        return False

def verify_subtask3_file_type_classification(test_dir: Path) -> bool:
    """Verify subtask 3: File Type Classification - 68 and 1 must be accurate."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    try:
        content = analysis_file.read_text()
        
        # Extract file type counts
        txt_match = re.search(r'txt:\s*(\d+)', content)
        py_match = re.search(r'py:\s*(\d+)', content)
        
        if not txt_match or not py_match:
            print("❌ Could not extract file type counts from structure_analysis.txt")
            return False
        
        txt_count = int(txt_match.group(1))
        py_count = int(py_match.group(1))
        
        print(f"📁 Found: txt={txt_count}, py={py_count}")
        
        # Check if txt count is exactly 68
        if txt_count != 68:
            print(f"❌ txt count must be 68, found: {txt_count}")
            return False
        
        # Check if py count is exactly 1
        if py_count != 1:
            print(f"❌ py count must be 1, found: {py_count}")
            return False
        
        print(f"✅ File type classification verified: txt={txt_count}, py={py_count}")
        return True
        
    except Exception as e:
        print(f"❌ Error verifying file type classification: {e}")
        return False

def verify_file_format(test_dir: Path) -> bool:
    """Verify that the structure_analysis.txt file has proper format."""
    analysis_file = test_dir / "structure_analysis.txt"
    
    try:
        content = analysis_file.read_text()
        lines = content.split('\n')
        
        # Check if file has the expected structure
        if len(lines) < 5:  # Should have at least 5 lines
            print("❌ File seems too short to contain all required information")
            return False
        
        # Basic format check - ensure it's not completely corrupted
        if not content.strip():
            print("❌ File is completely empty")
            return False
        
        print("✅ File format is acceptable")
        return True
        
    except Exception as e:
        print(f"❌ Error checking file format: {e}")
        return False

def main():
    """Main verification function."""
    try:
        test_dir = get_test_directory()
        print(f"🔍 Verifying Directory Structure Analysis Task in: {test_dir}")
        
        # Define verification steps
        verification_steps = [
            ("Structure Analysis File Exists", verify_structure_analysis_file_exists),
            ("File is Readable", verify_structure_analysis_file_readable),
            ("Subtask 1: File Statistics", verify_subtask1_file_statistics),
            ("Subtask 2: Depth Analysis", verify_subtask2_depth_analysis),
            ("Subtask 3: File Type Classification", verify_subtask3_file_type_classification),
            ("File Format", verify_file_format),
        ]
        
        # Run all verification steps
        all_passed = True
        for step_name, verify_func in verification_steps:
            print(f"\n--- {step_name} ---")
            if not verify_func(test_dir):
                all_passed = False
        
        # Final result
        print("\n" + "="*50)
        if all_passed:
            print("✅ Directory Structure Analysis completed correctly!")
            print("🎉 Structure Analysis verification: PASS")
            sys.exit(0)
        else:
            print("❌ Structure Analysis verification: FAIL")
            sys.exit(1)
            
    except Exception as e:
        print(f"❌ Verification failed with error: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()