mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
wip
This commit is contained in:
@@ -9,28 +9,35 @@ import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import toml
|
||||
import yaml
|
||||
from manager_utils.tasklib import TaskMeta, task_dir, worktree_dir, load_task
|
||||
from manager_utils.tasklib import task_dir, worktree_dir, load_task
|
||||
|
||||
|
||||
def skip_path(p: Path) -> bool:
|
||||
"""Return True for paths we should ignore in validations."""
|
||||
wt = worktree_dir()
|
||||
done = task_dir() / ".done"
|
||||
if p.is_relative_to(wt) or p.is_relative_to(done):
|
||||
return True
|
||||
if p.name in ("task-template.md",) or p.name.endswith("-plan.md"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def check_file_types():
|
||||
failures = []
|
||||
wt_root = worktree_dir()
|
||||
done_root = task_dir() / '.done'
|
||||
for f in task_dir().iterdir():
|
||||
if not f.is_file():
|
||||
failures: list[Path] = []
|
||||
for p in task_dir().iterdir():
|
||||
if skip_path(p) or p.is_dir():
|
||||
continue
|
||||
if f.is_relative_to(wt_root) or f.is_relative_to(done_root):
|
||||
continue
|
||||
if f.suffix.lower() != '.md':
|
||||
failures.append(f)
|
||||
if p.suffix.lower() != ".md":
|
||||
failures.append(p)
|
||||
return failures
|
||||
|
||||
|
||||
def check_frontmatter():
|
||||
failures = []
|
||||
wt_root = worktree_dir()
|
||||
for md in task_dir().rglob('[0-9][0-9]-*.md'):
|
||||
if md.name in ('task-template.md',) or md.name.endswith('-plan.md') or md.is_relative_to(wt_root):
|
||||
failures: list[tuple[Path, str]] = []
|
||||
wt = worktree_dir()
|
||||
for md in task_dir().rglob("[0-9][0-9]-*.md"):
|
||||
if skip_path(md):
|
||||
continue
|
||||
try:
|
||||
load_task(md)
|
||||
@@ -38,27 +45,28 @@ def check_frontmatter():
|
||||
failures.append((md, str(e)))
|
||||
return failures
|
||||
|
||||
|
||||
def check_cycles():
|
||||
merged = set()
|
||||
deps_map = {}
|
||||
wt_root = worktree_dir()
|
||||
for md in task_dir().rglob('[0-9][0-9]-*.md'):
|
||||
if md.name in ('task-template.md',) or md.name.endswith('-plan.md') or md.is_relative_to(wt_root):
|
||||
deps_map: dict[str, list[str]] = {}
|
||||
wt = worktree_dir()
|
||||
for md in task_dir().rglob("[0-9][0-9]-*.md"):
|
||||
if skip_path(md):
|
||||
continue
|
||||
meta, _ = load_task(md)
|
||||
if meta.status == 'Merged':
|
||||
if meta.status == "Merged":
|
||||
merged.add(meta.id)
|
||||
else:
|
||||
deps = re.findall(r"\d+", meta.dependencies)
|
||||
deps = [d for d in re.findall(r"\d+", meta.dependencies)]
|
||||
deps_map[meta.id] = [d for d in deps if d not in merged]
|
||||
|
||||
failures = []
|
||||
visited = set()
|
||||
stack = []
|
||||
failures: list[list[str]] = []
|
||||
visited: set[str] = set()
|
||||
stack: list[str] = []
|
||||
|
||||
def visit(n):
|
||||
def visit(n: str):
|
||||
if n in stack:
|
||||
cycle = stack[stack.index(n):] + [n]
|
||||
cycle = stack[stack.index(n) :] + [n]
|
||||
failures.append(cycle)
|
||||
return
|
||||
if n in visited:
|
||||
@@ -73,36 +81,38 @@ def check_cycles():
|
||||
visit(node)
|
||||
return failures
|
||||
|
||||
|
||||
def main():
|
||||
err = False
|
||||
|
||||
# File type check
|
||||
ft_fail = check_file_types()
|
||||
if ft_fail:
|
||||
print('Non-md files under tasks/:', file=sys.stderr)
|
||||
print("Non-md files under tasks/:", file=sys.stderr)
|
||||
for f in ft_fail:
|
||||
print(f' {f}', file=sys.stderr)
|
||||
print(f" {f}", file=sys.stderr)
|
||||
err = True
|
||||
|
||||
# Frontmatter check
|
||||
fm_fail = check_frontmatter()
|
||||
if fm_fail:
|
||||
print('\nFrontmatter errors:', file=sys.stderr)
|
||||
print("\nFrontmatter errors:", file=sys.stderr)
|
||||
for md, msg in fm_fail:
|
||||
print(f' {md}: {msg}', file=sys.stderr)
|
||||
print(f" {md}: {msg}", file=sys.stderr)
|
||||
err = True
|
||||
|
||||
# Dependency cycles
|
||||
cyc_fail = check_cycles()
|
||||
if cyc_fail:
|
||||
print('\nCircular dependency errors:', file=sys.stderr)
|
||||
print("\nCircular dependency errors:", file=sys.stderr)
|
||||
for cycle in cyc_fail:
|
||||
print(' ' + ' -> '.join(cycle), file=sys.stderr)
|
||||
print(" " + " -> ".join(cycle), file=sys.stderr)
|
||||
err = True
|
||||
|
||||
if err:
|
||||
sys.exit(1)
|
||||
print('All task checks passed.')
|
||||
print("All task checks passed.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -401,7 +401,7 @@ Maximum number of bytes to read from an `AGENTS.md` file to include in the instr
|
||||
The built-in system prompt (from `prompt.md`) can be overridden or disabled via environment variables:
|
||||
|
||||
- `CODEX_BASE_INSTRUCTIONS_FILE`: If unset, the built-in prompt (`prompt.md`) is used.
|
||||
If set to a valid file path, that file's contents will be used instead.
|
||||
If set to a valid file path, that file's contents will be used instead (failure to read will abort).
|
||||
If set to an empty string or `-`, no system prompt will be sent.
|
||||
|
||||
## tui
|
||||
|
||||
@@ -12,10 +12,11 @@ Codex composes the initial system message that seeds every chat completion turn
|
||||
4. Append the apply-patch tool instructions when using GPT-4.1 models.
|
||||
5. Finally, the user's command or prompt is sent as the first user message.
|
||||
|
||||
The base instructions behavior can be customized via environment variables:
|
||||
The base instructions behavior can be customized with `CODEX_BASE_INSTRUCTIONS_FILE`:
|
||||
|
||||
- `CODEX_BASE_INSTRUCTIONS_FILE`: path to a Markdown file to override the built-in prompt
|
||||
- `CODEX_DISABLE_BASE_INSTRUCTIONS=1`: skip sending any system prompt entirely
|
||||
- If unset, the built-in prompt (`prompt.md`) is used.
|
||||
- If set to a valid file path, that file's contents will be used instead (failure to read will abort).
|
||||
- If set to an empty string or `-`, no system prompt will be sent.
|
||||
|
||||
For implementation details, see `client_common.rs` and `project_doc.rs`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user