Skip to content

Commit ed4b671

Browse files
mrjfclaude
andcommitted
Bootstrap program template on first run via pre-step
Since add-wizard only installs the workflow .md file and can't copy companion files, the pre-step now creates .github/autoloop/programs/ and writes the template example.md on first run if the directory doesn't exist. Commits and pushes the template so the user can find and edit it in their repo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 38de506 commit ed4b671

1 file changed

Lines changed: 51 additions & 3 deletions

File tree

workflows/autoloop.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,57 @@ steps:
7272
7373
programs_dir = ".github/autoloop/programs"
7474
memory_dir = ".github/repo-memory/autoloop"
75+
template_file = os.path.join(programs_dir, "example.md")
76+
77+
# Bootstrap: create programs directory and template if missing
78+
if not os.path.isdir(programs_dir):
79+
os.makedirs(programs_dir, exist_ok=True)
80+
with open(template_file, "w") as f:
81+
f.write("""\
82+
<!-- AUTOLOOP:UNCONFIGURED -->
83+
<!-- Remove the line above once you have filled in your program. -->
84+
<!-- Autoloop will NOT run until you do. -->
85+
86+
# Autoloop Program
87+
88+
<!-- Rename this file to something meaningful (e.g. training.md, coverage.md).
89+
The filename (minus .md) becomes the program name used in issues, PRs,
90+
and slash commands. Want multiple loops? Add more .md files here. -->
91+
92+
## Goal
93+
94+
<!-- Describe what you want to optimize. Be specific about what "better" means. -->
95+
96+
REPLACE THIS with your optimization goal.
97+
98+
## Target
99+
100+
<!-- List files Autoloop may modify. Everything else is off-limits. -->
101+
102+
Only modify these files:
103+
- `REPLACE_WITH_FILE` — (describe what this file does)
104+
105+
Do NOT modify:
106+
- (list files that must not be touched)
107+
108+
## Evaluation
109+
110+
<!-- Provide a command and the metric to extract. -->
111+
112+
```bash
113+
REPLACE_WITH_YOUR_EVALUATION_COMMAND
114+
```
115+
116+
The metric is `REPLACE_WITH_METRIC_NAME`. **Lower/Higher is better.** (pick one)
117+
""")
118+
# Commit the template so the user can see and edit it
119+
os.system(f'git add "{template_file}"')
120+
os.system('git commit -m "[Autoloop] Bootstrap: add program template for configuration"')
121+
os.system('git push')
122+
print(f"BOOTSTRAPPED: created {template_file} and pushed to repo")
75123

76124
# Find all program files
77-
program_files = []
78-
if os.path.isdir(programs_dir):
79-
program_files = sorted(glob.glob(os.path.join(programs_dir, "*.md")))
125+
program_files = sorted(glob.glob(os.path.join(programs_dir, "*.md")))
80126
if not program_files:
81127
# Fallback to single-file locations
82128
for path in [".github/autoloop/program.md", "program.md"]:
@@ -86,10 +132,12 @@ steps:
86132

87133
if not program_files:
88134
print("NO_PROGRAMS_FOUND")
135+
os.makedirs("/tmp/gh-aw", exist_ok=True)
89136
with open("/tmp/gh-aw/autoloop.json", "w") as f:
90137
json.dump({"due": [], "skipped": [], "unconfigured": [], "no_programs": True}, f)
91138
sys.exit(0)
92139

140+
os.makedirs("/tmp/gh-aw", exist_ok=True)
93141
now = datetime.now(timezone.utc)
94142
due = []
95143
skipped = []

0 commit comments

Comments
 (0)