Skip to content

Lucasuiii/modeling-workbench / .agents/skills/cumcm-workflow

cumcm-workflow

Verified

Build or resume mathematical-modeling competition work, including CUMCM, MCM/ICM, graduate and regional contests, data challenges, and open-topic statistical modeling. Guide problem framing, modeling, computation, validation, Chinese or English LaTeX writing, and reviewed PDF/source delivery using current official requirements. Not for ordinary paper polishing.

FileKindSize
SKILL.mdskill md9.0 KB
agents/openai.yamlconfig427 B
assets/latex-template/generic-ctex/macros.texother859 B
assets/latex-template/generic-ctex/main.tex.tmplother2.5 KB
assets/latex-template/generic-ctex/metadata.tex.tmplother272 B
assets/latex-template/generic-ctex/planned-section.tex.tmplother1.0 KB
assets/latex-template/generic-ctex/references.bibother155 B
assets/latex-template/generic-ctex/sections/00_abstract.texother935 B
assets/latex-template/generic-ctex/sections/98_references.texother221 B
assets/latex-template/generic-ctex/sections/99_appendix.texother264 B
assets/latex-template/generic-ctex/template.jsonconfig304 B
assets/latex-template/generic-en/macros.texother868 B
assets/latex-template/generic-en/main.tex.tmplother2.2 KB
assets/latex-template/generic-en/metadata.tex.tmplother278 B
assets/latex-template/generic-en/planned-section.tex.tmplother1013 B
assets/latex-template/generic-en/references.bibother155 B
assets/latex-template/generic-en/sections/00_abstract.texother454 B
assets/latex-template/generic-en/sections/98_references.texother201 B
assets/latex-template/generic-en/sections/99_appendix.texother240 B
assets/latex-template/generic-en/template.jsonconfig249 B
assets/latex-template/huawei-ctex/main.tex.tmplother3.3 KB
assets/latex-template/huawei-ctex/template.jsonconfig276 B
assets/plot-style/cumcm.mplstyleother953 B
references/01-intake.mdmarkdown3.9 KB
references/02-problem-analysis.mdmarkdown2.8 KB
references/03-model-design.mdmarkdown7.6 KB
references/04-computation.mdmarkdown13.4 KB
references/05-validation.mdmarkdown5.9 KB
references/06-paper-writing.mdmarkdown14.3 KB
references/07-compile-delivery.mdmarkdown6.1 KB
references/artifact-contracts.mdmarkdown3.1 KB
references/competition-adaptation.mdmarkdown6.8 KB
references/competition-writing.mdmarkdown5.6 KB
references/diagnostics.mdmarkdown4.5 KB
references/evidence-rules.mdmarkdown1.6 KB
references/handoffs.mdmarkdown3.5 KB
references/huawei-delivery.mdmarkdown10.1 KB
references/latex-template.mdmarkdown6.2 KB
references/mechanism-validation.mdmarkdown11.6 KB
references/open-topic-research.mdmarkdown4.9 KB
references/task-driven-modeling.mdmarkdown7.2 KB
schemas/claim-ledger.schema.jsonconfig5.5 KB
schemas/common.schema.jsonconfig2.5 KB
schemas/compile-receipt.schema.jsonconfig3.7 KB
schemas/cross-question-ledger.schema.jsonconfig1.3 KB
schemas/delivery-manifest.schema.jsonconfig7.9 KB
schemas/figure-manifest.schema.jsonconfig1.9 KB
schemas/handoff.schema.jsonconfig2.1 KB
schemas/independent-review-package.schema.jsonconfig3.4 KB
schemas/independent-review-result.schema.jsonconfig4.0 KB
schemas/latex-template-manifest.schema.jsonconfig2.4 KB
schemas/model-contract.schema.jsonconfig5.0 KB
schemas/paper-plan.schema.jsonconfig3.3 KB
schemas/paper-quality-report.schema.jsonconfig5.7 KB
schemas/paper-revision-log.schema.jsonconfig2.2 KB
schemas/paper-visible-text-report.schema.jsonconfig1.6 KB
schemas/problem-facts.schema.jsonconfig1.7 KB
schemas/results-index.schema.jsonconfig1.4 KB
schemas/run-manifest.schema.jsonconfig7.1 KB
schemas/source-manifest.schema.jsonconfig1.9 KB
schemas/task-capabilities.schema.jsonconfig3.9 KB
schemas/workflow-state.schema.jsonconfig2.4 KB
scripts/backend_selection.pyscript6.3 KB
scripts/build_handoff.pyscript20.4 KB
scripts/build_independent_review_package.pyscript14.9 KB
scripts/canonical_evidence.pyscript8.4 KB
scripts/compile_sources.pyscript2.4 KB
scripts/cumcm_check.pyscript2.9 KB
scripts/delivery_archives.pyscript7.0 KB
scripts/doctor.pyscript7.5 KB
scripts/index_result.pyscript10.9 KB
scripts/init_latex_paper.pyscript17.2 KB
scripts/init_project.pyscript11.1 KB
scripts/inventory_artifacts.pyscript4.1 KB
scripts/json_pointer.pyscript1.0 KB
scripts/official_materials.pyscript3.0 KB
scripts/paper_visible_text_check.pyscript5.4 KB
scripts/plan_redo.pyscript18.8 KB
scripts/project_status.pyscript5.8 KB
scripts/provenance.pyscript2.2 KB
scripts/record_compile.pyscript13.2 KB
scripts/record_decision.pyscript12.0 KB
scripts/record_run.pyscript28.1 KB
scripts/refresh_evidence.pyscript4.7 KB
scripts/set_mode.pyscript2.0 KB
scripts/submission_check.pyscript10.6 KB
scripts/workflow_checks.pyscript146.0 KB

scripts/init_project.py

View on GitHub
#!/usr/bin/env python3
"""Create a complete v0.6 modeling contest workspace and run intake preflight."""

from __future__ import annotations

import argparse
import json
import mimetypes
import os
import shutil
import tempfile
from datetime import datetime, timezone
from pathlib import Path
from typing import Any

from inventory_artifacts import sha256
from workflow_checks import check_project


WORKFLOW_VERSION = "0.6.0"
PROJECT_DIRECTORIES = (
    ".cumcm/tmp",
    ".cumcm/snapshots",
    "problem/official",
    "analysis",
    "model",
    "code",
    "data",
    "runs",
    "results",
    "validation",
    "figures",
    "paper",
    "delivery",
    "handoffs",
)
IGNORED_SOURCE_NAMES = {".DS_Store", "Thumbs.db", "desktop.ini"}


def utc_now() -> str:
    return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")


def write_json(path: Path, value: dict[str, Any]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")


def envelope(artifact_type: str, project_id: str, created_at: str) -> dict[str, Any]:
    return {
        "schema_version": WORKFLOW_VERSION,
        "artifact_type": artifact_type,
        "project_id": project_id,
        "updated_at": created_at,
        "producer": {"kind": "script", "name": "init_project.py", "version": WORKFLOW_VERSION},
    }


def ensure_safe_relationship(source: Path, target: Path) -> None:
    source_resolved = source.resolve()
    target_resolved = target.resolve(strict=False)
    if source_resolved == target_resolved:
        raise ValueError("official source and project target must be different paths")
    if source_resolved.is_dir():
        try:
            target_resolved.relative_to(source_resolved)
        except ValueError:
            pass
        else:
            raise ValueError("project target must not be created inside the official source directory")
    try:
        source_resolved.relative_to(target_resolved)
    except ValueError:
        pass
    else:
        raise ValueError("official source must not be located inside the project target")


def enumerate_source_files(source: Path) -> tuple[list[tuple[Path, Path]], list[str]]:
    if not source.exists():
        raise ValueError(f"official source does not exist: {source}")
    if source.is_symlink():
        raise ValueError(f"official source may not be a symlink: {source}")
    skipped: list[str] = []
    if source.is_file():
        if source.name in IGNORED_SOURCE_NAMES:
            raise ValueError(f"official source contains no usable files: {source}")
        return [(source, Path(source.name))], skipped
    if not source.is_dir():
        raise ValueError(f"official source must be a regular file or directory: {source}")
    records: list[tuple[Path, Path]] = []
    for path in sorted(source.rglob("*"), key=lambda item: item.as_posix()):
        rel = path.relative_to(source)
        if path.is_symlink():
            raise ValueError(f"official source tree may not contain symlinks: {rel.as_posix()}")
        if path.is_dir():
            continue
        if not path.is_file():
            raise ValueError(f"official source tree contains a non-regular file: {rel.as_posix()}")
        if path.name in IGNORED_SOURCE_NAMES:
            skipped.append(rel.as_posix())
            continue
        records.append((path, rel))
    if not records:
        raise ValueError(f"official source contains no usable files: {source}")
    return records, skipped


def copy_official_files(records: list[tuple[Path, Path]], official_dir: Path) -> None:
    for source, rel in records:
        destination = official_dir / rel
        destination.parent.mkdir(parents=True, exist_ok=True)
        shutil.copy2(source, destination)


def build_source_records(project: Path) -> list[dict[str, Any]]:
    official_dir = project / "problem" / "official"
    records: list[dict[str, Any]] = []
    for path in sorted(official_dir.rglob("*"), key=lambda item: item.as_posix()):
        if not path.is_file():
            continue
        records.append(
            {
                "source_id": f"SRC-{len(records) + 1:03d}",
                "path": path.relative_to(project).as_posix(),
                "sha256": sha256(path),
                "size": path.stat().st_size,
                "media_type": mimetypes.guess_type(path.name)[0] or "application/octet-stream",
                "origin": "official",
                "acquisition": {"method": "user_local_file", "provided_by_user": True, "source_reference": None},
                "authoritative_for": [],
                "derived_from": None,
                "mutable": False,
            }
        )
    return records


def write_project_brief(project: Path, project_id: str, created_at: str, source_count: int) -> None:
    text = f"""# 数学建模项目工作区

- 项目 ID:`{project_id}`
- 工作流版本:`{WORKFLOW_VERSION}`
- 工作模式:`working`(冻结前切换为 `finalizing`)
- 计算偏好:MATLAB 优先、Python fallback、按任务自动择优
- 初始化时间:`{created_at}`
- 官方输入文件数:{source_count}
- 当前阶段:`intake / working`

## 下一步

1. 查看 `problem/SOURCE_MANIFEST.json` 和 `problem/official/`,确认官方题目、附件及当年规则是否齐全。
2. 不要仅凭文件存在就批准;公式、表格或版式承载含义的 PDF 需要渲染检查。
3. 工作期可继续拆题和试算;进入 `finalizing` 前必须明确批准 intake,并记录 artifact-bound decision/snapshot。
4. 进入 `problem-analysis` 后再创建事实、能力和假设文件;初始化器没有推断任何题意、模型或结果。
5. 计算一律用 `record_run.py` 包装执行,结果一律用 `index_result.py` 索引;不要手写 hash 或 run manifest。

机器可读初始化记录位于 `.cumcm/init-report.json`,当前 preflight 位于 `.cumcm/validation-report.json`。
"""
    (project / "PROJECT_BRIEF.md").write_text(text, encoding="utf-8")


def create_staged_project(
    staging: Path,
    final_project: Path,
    project_id: str,
    source_records: list[tuple[Path, Path]],
    skipped_sources: list[str],
) -> dict[str, Any]:
    for rel in PROJECT_DIRECTORIES:
        (staging / rel).mkdir(parents=True, exist_ok=True)
    copy_official_files(source_records, staging / "problem" / "official")
    created_at = utc_now()

    state = envelope("workflow_state", project_id, created_at)
    state.update(
        {
            "workflow_version": WORKFLOW_VERSION,
            "mode": "working",
            "implementation": {"preferred": "matlab", "fallback": "python", "selection": "auto"},
            "current_stage": "intake",
            "stages": {
                "intake": "in_progress",
                "problem-analysis": "not_started",
                "model-design": "not_started",
                "computation": "not_started",
                "validation": "not_started",
                "paper": "not_started",
                "delivery": "not_started",
            },
        }
    )
    write_json(staging / ".cumcm" / "state.json", state)

    sources = envelope("source_manifest", project_id, created_at)
    sources["sources"] = build_source_records(staging)
    write_json(staging / "problem" / "SOURCE_MANIFEST.json", sources)
    write_project_brief(staging, project_id, created_at, len(sources["sources"]))

    findings, summary = check_project(staging, "intake", "preflight")
    if summary["blocking_error_count"]:
        messages = "; ".join(
            f"{item.rule_id}: {item.message}"
            for item in findings
            if item.severity == "error" and not item.gate_only
        )
        raise ValueError(f"generated project failed intake preflight: {messages}")
    validation_report = {
        "report_version": WORKFLOW_VERSION,
        "generated_at": utc_now(),
        "project_root": str(final_project),
        "summary": summary,
        "findings": [item.to_dict() for item in findings],
    }
    write_json(staging / ".cumcm" / "validation-report.json", validation_report)
    init_report = {
        "report_version": WORKFLOW_VERSION,
        "created_at": created_at,
        "project_id": project_id,
        "source_count": len(sources["sources"]),
        "skipped_source_metadata": skipped_sources,
        "current_stage": "intake",
        "gate_status": summary["gate_status"],
        "generated_paths": [
            ".cumcm/state.json",
            ".cumcm/init-report.json",
            ".cumcm/validation-report.json",
            "problem/SOURCE_MANIFEST.json",
            "PROJECT_BRIEF.md",
        ],
        "next_action": "review official input completeness; working mode may continue, finalizing requires an accepted intake snapshot",
    }
    write_json(staging / ".cumcm" / "init-report.json", init_report)
    return {"created_at": created_at, "summary": summary, "source_count": len(sources["sources"])}


def initialize(project: Path, project_id: str, official: Path) -> dict[str, Any]:
    project = project.resolve(strict=False)
    official = official.resolve()
    if project.exists():
        if project.is_symlink() or not project.is_dir():
            raise ValueError(f"project target must be a new or empty directory: {project}")
        if any(project.iterdir()):
            raise ValueError(f"refusing to overwrite non-empty project target: {project}")
    ensure_safe_relationship(official, project)
    source_records, skipped_sources = enumerate_source_files(official)
    project.parent.mkdir(parents=True, exist_ok=True)

    with tempfile.TemporaryDirectory(prefix=f".{project.name}.init-", dir=project.parent) as temp:
        staging = Path(temp) / "workspace"
        staging.mkdir()
        result = create_staged_project(staging, project, project_id, source_records, skipped_sources)
        if project.exists():
            project.rmdir()
        os.replace(staging, project)

    result.update({"project": str(project), "skipped_sources": skipped_sources})
    return result


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Create a complete v0.6 modeling contest workspace from official inputs and run intake preflight"
    )
    parser.add_argument("--project", required=True, type=Path, help="new or empty project directory")
    parser.add_argument("--project-id", required=True, help="stable project identifier, for example CUMCM-2026-B")
    parser.add_argument("--official", required=True, type=Path, help="official input file or directory")
    args = parser.parse_args()
    if not args.project_id.strip():
        parser.error("project-id must not be empty")
    try:
        result = initialize(args.project, args.project_id.strip(), args.official)
    except (OSError, ValueError, json.JSONDecodeError) as exc:
        parser.error(str(exc))
    print(f"initialized: {result['project']}")
    print(f"official sources: {result['source_count']}")
    if result["skipped_sources"]:
        print(f"ignored operating-system metadata: {', '.join(result['skipped_sources'])}")
    print(f"intake preflight: {result['summary']['gate_status']}")
    print("next: review PROJECT_BRIEF.md and problem/SOURCE_MANIFEST.json, then approve the intake gate")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall