Skip to content

ficilcom/otame4-work-skills / skills/offer/offer-decline

offer-decline

Verified

Work out the order and the loose ends before turning down an offer or withdrawing from a selection process: whether the offer being kept is actually settled in writing, whether each decline is mid-selection, post-offer, or after acceptance, who besides the employer has to be told when the application came through an agent, a school recommendation, or a referral, which reply deadlines have passed, and what documents, expenses, or borrowed items are still outstanding. Use when a user holds more than one offer and needs to decline the rest, wants to withdraw from a process they are no longer pursuing, or has been asked to turn down other employers as a condition; do not use to decide whether to decline, to rule on what declining after acceptance means legally, or to send any message.

FileKindSize
SKILL.mdskill md5.7 KB
references/declining.mdmarkdown6.1 KB
references/report-format.mdmarkdown2.0 KB
scripts/_common.pyscript9.9 KB
scripts/check_decline_plan.pyscript10.4 KB

scripts/_common.py

View on GitHub
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# 生成物。直接編集しない。
# 編集するのは scripts/_common_source.py で、`python3 scripts/sync_common.py`
# で各スキルへ配り直す。CI は `--check` で差分を落とす。
# ---------------------------------------------------------------------------
"""Shared helpers for the deterministic scripts bundled with each skill.

**このファイルが唯一の編集点である。** スキル配下の `scripts/_common.py` は
`python3 scripts/sync_common.py` が生成したコピーであり、直接編集しない。
CI は `sync_common.py --check` で差分を落とす。

なぜコピーを配るのか。スキルは `skills/<category>/<skill-name>/` を単位として
単独でインストールされ、それより上の階層は利用者の環境に届かない。
`SKILL.md` は `python3 scripts/<name>.py` と相対で呼ぶため、リポジトリ共通の
モジュールを import すると、インストール後に実行時エラーになる。
各スキルへ同一の内容を配り、CI で同期を検証するのが唯一の方法である。

方針として、ここに入れるのは入力の形を確かめる処理と CLI の定型だけにする。
何を欠落とみなすか、どの条件を注意として出すかといった判断はスキル固有であり、
各スクリプトに残す。
"""

from __future__ import annotations

import argparse
import json
import re
import sys
from datetime import date
from decimal import Decimal, ROUND_HALF_UP
from pathlib import Path
from typing import Any, Callable


MONTH_PATTERN = re.compile(r"^(\d{4})-(\d{2})$")
WHITESPACE_RUN_PATTERN = re.compile(r"\s+")
YEN = Decimal("1")
HOUR = Decimal("0.01")

# 本文に混ざった個人情報を見つけるための検査。scripts/validate_skills.py も
# リポジトリ側のガードとしてこの定義を import して使う。
# 数字の並びは \b ではなく前後の数字だけを見て区切る。このリポジトリが扱う本文は
# 日本語で、「電話は03-1234-5678です」のように地の文へ直接続くと、\b は日本語の
# 文字も語構成文字として扱うため境界にならず、検出漏れになる。
EMAIL_PATTERN = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
PHONE_PATTERN = re.compile(r"(?<!\d)0\d{1,4}-\d{1,4}-\d{3,4}(?!\d)")
MYNUMBER_PATTERN = re.compile(r"(?<!\d)\d{4}[- ]?\d{4}[- ]?\d{4}(?!\d)")


# --- 入力の形を確かめる ------------------------------------------------------


def require_object(value: object, path: str) -> dict[str, Any]:
    if not isinstance(value, dict):
        raise ValueError(f"{path} must be an object")
    return value


def require_list(value: object, path: str) -> list[Any]:
    if not isinstance(value, list):
        raise ValueError(f"{path} must be a list")
    return value


def require_text(value: object, path: str) -> str:
    """空でない文字列を前後の空白を落として返す。"""
    if not isinstance(value, str) or not value.strip():
        raise ValueError(f"{path} must be a non-empty string")
    return value.strip()


def require_raw_text(value: object, path: str) -> str:
    """空でない文字列を原文のまま返す。

    前後の空白が意味を持つ入力だけに使う。応募書類の本文がこれにあたり、
    提出時の文字数には前後の空白も含まれるため、strip すると文字数の判定が
    実際の提出内容とずれる。迷うときは require_text を使う。
    """
    if not isinstance(value, str) or not value.strip():
        raise ValueError(f"{path} must be a non-empty string")
    return value


def optional_text(value: object, path: str) -> str | None:
    return None if value is None else require_text(value, path)


def optional_choice(value: object, path: str, allowed: tuple[str, ...], default: str) -> str:
    """決められた選択肢の1つを返す。未指定と null は `default` として扱う。"""
    if value is None:
        return default
    if value not in allowed:
        raise ValueError(f"{path} must be one of {list(allowed)}")
    return str(value)


def optional_bool(value: object, path: str) -> bool | None:
    if value is None:
        return None
    if not isinstance(value, bool):
        raise ValueError(f"{path} must be a boolean or null")
    return value


def require_date(value: object, path: str) -> date:
    text = require_text(value, path)
    try:
        return date.fromisoformat(text)
    except ValueError as error:
        raise ValueError(f"{path} must be an ISO date (YYYY-MM-DD): {error}") from None


def optional_date(value: object, path: str) -> date | None:
    return None if value is None else require_date(value, path)


def require_month_index(value: object, path: str) -> int:
    """`YYYY-MM` を月単位の通し番号に変換する。期間の重なりや空白の計算に使う。"""
    text = require_text(value, path)
    match = MONTH_PATTERN.match(text)
    if not match:
        raise ValueError(f"{path} must look like YYYY-MM: {value!r}")
    year, month = int(match.group(1)), int(match.group(2))
    if not 1 <= month <= 12:
        raise ValueError(f"{path} has a month outside 1-12: {value!r}")
    return year * 12 + (month - 1)


def optional_month_index(value: object, path: str) -> int | None:
    if value is None:
        return None
    if not isinstance(value, str):
        raise ValueError(f"{path} must be a YYYY-MM string or null")
    return require_month_index(value, path)


def optional_int(value: object, path: str) -> int | None:
    """0以上の整数、または null。"""
    if value is None:
        return None
    if isinstance(value, bool) or not isinstance(value, int):
        raise ValueError(f"{path} must be an integer or null")
    if value < 0:
        raise ValueError(f"{path} must not be negative")
    return value


def optional_positive_int(value: object, path: str) -> int | None:
    """1以上の整数、または null。"""
    if value is None:
        return None
    if isinstance(value, bool) or not isinstance(value, int) or value <= 0:
        raise ValueError(f"{path} must be a positive integer or null")
    return value


def optional_amount(value: object, path: str) -> int | None:
    """0以上の金額を整数に丸めて返す。小数を受け取っても切り捨てる。"""
    if value is None:
        return None
    if isinstance(value, bool) or not isinstance(value, (int, float)):
        raise ValueError(f"{path} must be a number or null")
    if value < 0:
        raise ValueError(f"{path} must not be negative")
    return int(value)


def optional_number(value: object, path: str, *, allow_zero: bool = True) -> Decimal | None:
    """金額の計算に使う数値を Decimal で返す。float の丸め誤差を持ち込まない。"""
    if value is None:
        return None
    if isinstance(value, bool) or not isinstance(value, (int, float)):
        raise ValueError(f"{path} must be a number or null")
    number = Decimal(str(value))
    if number < 0:
        raise ValueError(f"{path} must not be negative")
    if number == 0 and not allow_zero:
        raise ValueError(f"{path} must be greater than zero")
    return number


# --- 出力を整える ------------------------------------------------------------


def round_yen(value: Decimal | None) -> int | None:
    """円単位に四捨五入する。銀行丸めだと表示額が入力とずれるため使わない。"""
    if value is None:
        return None
    return int(value.quantize(YEN, rounding=ROUND_HALF_UP))


def round_hours(value: Decimal | None) -> float | None:
    """時間を0.01時間単位に丸めて返す。None は None のままにする。"""
    if value is None:
        return None
    return float(value.quantize(HOUR))


def strip_whitespace(text: str) -> str:
    """空白の入れ方だけが違う記述を同じものとして比べるために正規化する。"""
    return WHITESPACE_RUN_PATTERN.sub("", text)


def flag_collector(key: str = "items") -> tuple[list[dict[str, Any]], Callable[..., None]]:
    """注意事項を集める `(flags, add)` を返す。

    `add(code, message)` で1件、対象を絞れる場合は `add(code, message, [...])`
    で対象も添える。空のリストは出力に入れない。対象の入る項目名を `items` から
    変えたいときだけ `key` を渡す。
    """
    flags: list[dict[str, Any]] = []

    def add(code: str, message: str, items: list[str] | None = None) -> None:
        flag: dict[str, Any] = {"code": code, "message": message}
        if items:
            flag[key] = items
        flags.append(flag)

    return flags, add


# --- CLI ---------------------------------------------------------------------


def run_cli(
    entry: Callable[[object], Any],
    description: str | None = None,
    argv: list[str] | None = None,
) -> int:
    """JSONを読み、`entry` にかけ、結果をJSONで書き出す。

    終了コードは 0(成功)と 2(入力が不正)だけを使う。入力の誤りは
    利用者が直せるものなので、traceback ではなく1行のメッセージで返す。
    """
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument("input", nargs="?", help="入力JSONのパス。省略した場合は標準入力から読む")
    args = parser.parse_args(argv)

    raw = Path(args.input).read_text(encoding="utf-8") if args.input else sys.stdin.read()
    try:
        payload = json.loads(raw)
    except json.JSONDecodeError as error:
        print(f"input is not valid JSON: {error}", file=sys.stderr)
        return 2

    try:
        report = entry(payload)
    except ValueError as error:
        print(str(error), file=sys.stderr)
        return 2

    json.dump(report, sys.stdout, ensure_ascii=False, indent=2)
    sys.stdout.write("\n")
    return 0
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall