def _index_of_first_non_option(tokens: list[str]):
    """
    Find the index of the first token that doesn't start with `-`, and isn't directly
    preceded by either `--project` or `--directory`.

    Returns len(tokens) if none is found.
    """

    options_with_args = ("--project", "--directory")
    previous_token = ""
    for index, token in enumerate(tokens):
        if token[0] != "-" and previous_token not in options_with_args:
            return index
        previous_token = token

    return len(tokens)

    Find the index of the first token that doesn't start with `-`, and isn't directly
    preceded by either `--project` or `--directory`.

    Returns len(tokens) if none is found.
    
poethepoet/plugin.py