@fifine/aim-studio 0.0.4 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -41
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +42 -8
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +4 -104
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/templates/aim/scripts/export.py +2 -2
- package/dist/templates/claude/commands/aim/legitimize.md +268 -0
- package/dist/templates/claude/commands/aim/start.md +92 -179
- package/dist/templates/claude/commands/aim/story.md +60 -10
- package/dist/templates/markdown/index.d.ts +1 -0
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +1 -0
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/spec/story/style-guide.md.txt +96 -0
- package/package.json +1 -1
- package/dist/migrations/manifests/0.3.0-rc.2.json +0 -9
- package/dist/templates/aim/scripts/multi_agent/__init__.py +0 -5
- package/dist/templates/aim/scripts/multi_agent/cleanup.py +0 -403
- package/dist/templates/aim/scripts/multi_agent/create_pr.py +0 -329
- package/dist/templates/aim/scripts/multi_agent/plan.py +0 -233
- package/dist/templates/aim/scripts/multi_agent/start.py +0 -461
- package/dist/templates/aim/scripts/multi_agent/status.py +0 -817
- package/dist/templates/aim/scripts-shell-archive/add-session.sh +0 -384
- package/dist/templates/aim/scripts-shell-archive/common/developer.sh +0 -129
- package/dist/templates/aim/scripts-shell-archive/common/git-context.sh +0 -263
- package/dist/templates/aim/scripts-shell-archive/common/paths.sh +0 -208
- package/dist/templates/aim/scripts-shell-archive/common/phase.sh +0 -150
- package/dist/templates/aim/scripts-shell-archive/common/registry.sh +0 -247
- package/dist/templates/aim/scripts-shell-archive/common/task-queue.sh +0 -142
- package/dist/templates/aim/scripts-shell-archive/common/task-utils.sh +0 -151
- package/dist/templates/aim/scripts-shell-archive/common/worktree.sh +0 -128
- package/dist/templates/aim/scripts-shell-archive/create-bootstrap.sh +0 -299
- package/dist/templates/aim/scripts-shell-archive/get-context.sh +0 -7
- package/dist/templates/aim/scripts-shell-archive/get-developer.sh +0 -15
- package/dist/templates/aim/scripts-shell-archive/init-developer.sh +0 -34
- package/dist/templates/aim/scripts-shell-archive/multi-agent/cleanup.sh +0 -396
- package/dist/templates/aim/scripts-shell-archive/multi-agent/create-pr.sh +0 -241
- package/dist/templates/aim/scripts-shell-archive/multi-agent/plan.sh +0 -207
- package/dist/templates/aim/scripts-shell-archive/multi-agent/start.sh +0 -317
- package/dist/templates/aim/scripts-shell-archive/multi-agent/status.sh +0 -828
- package/dist/templates/aim/scripts-shell-archive/task.sh +0 -1204
- package/dist/templates/claude/agents/check.md +0 -122
- package/dist/templates/claude/agents/debug.md +0 -106
- package/dist/templates/claude/agents/dispatch.md +0 -230
- package/dist/templates/claude/agents/implement.md +0 -96
- package/dist/templates/claude/agents/plan.md +0 -396
- package/dist/templates/claude/agents/research.md +0 -120
- package/dist/templates/claude/commands/aim/before-backend-dev.md +0 -13
- package/dist/templates/claude/commands/aim/before-frontend-dev.md +0 -13
- package/dist/templates/claude/commands/aim/break-loop.md +0 -153
- package/dist/templates/claude/commands/aim/check-backend.md +0 -13
- package/dist/templates/claude/commands/aim/check-cross-layer.md +0 -153
- package/dist/templates/claude/commands/aim/check-frontend.md +0 -13
- package/dist/templates/claude/commands/aim/create-command.md +0 -154
- package/dist/templates/claude/commands/aim/integrate-skill.md +0 -219
- package/dist/templates/claude/commands/aim/parallel.md +0 -217
- package/dist/templates/claude/commands/aim/update-spec.md +0 -285
- package/dist/templates/claude/hooks/ralph-loop.py +0 -388
- package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +0 -51
- package/dist/templates/markdown/spec/backend/directory-structure.md.txt +0 -54
- package/dist/templates/markdown/spec/backend/error-handling.md.txt +0 -51
- package/dist/templates/markdown/spec/backend/index.md +0 -40
- package/dist/templates/markdown/spec/backend/index.md.txt +0 -38
- package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +0 -51
- package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +0 -51
- package/dist/templates/markdown/spec/backend/script-conventions.md +0 -467
- package/dist/templates/markdown/spec/cli/directory-structure.md.txt +0 -71
- package/dist/templates/markdown/spec/cli/error-handling.md.txt +0 -91
- package/dist/templates/markdown/spec/cli/index.md.txt +0 -37
- package/dist/templates/markdown/spec/cli/options-flags.md.txt +0 -71
- package/dist/templates/markdown/spec/cli/output-formatting.md.txt +0 -93
- package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +0 -59
- package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +0 -54
- package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +0 -51
- package/dist/templates/markdown/spec/frontend/index.md.txt +0 -39
- package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +0 -51
- package/dist/templates/markdown/spec/frontend/state-management.md.txt +0 -51
- package/dist/templates/markdown/spec/frontend/type-safety.md.txt +0 -51
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md +0 -118
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +0 -92
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +0 -94
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md +0 -394
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +0 -319
- package/dist/templates/markdown/spec/guides/index.md.txt +0 -89
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
Ralph Loop - SubagentStop Hook for Check Agent Loop Control
|
|
5
|
-
|
|
6
|
-
Based on the Ralph Wiggum technique for autonomous agent loops.
|
|
7
|
-
Uses completion promises to control when the check agent can stop.
|
|
8
|
-
|
|
9
|
-
Mechanism:
|
|
10
|
-
- Intercepts when check subagent tries to stop (SubagentStop event)
|
|
11
|
-
- If verify commands configured in worktree.yaml, runs them to verify
|
|
12
|
-
- Otherwise, reads check.jsonl to get dynamic completion markers ({reason}_FINISH)
|
|
13
|
-
- Blocks stopping until verification passes or all markers found
|
|
14
|
-
- Has max iterations as safety limit
|
|
15
|
-
|
|
16
|
-
State file: .aim-studio/.ralph-state.json
|
|
17
|
-
- Tracks current iteration count per session
|
|
18
|
-
- Resets when task changes
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
# IMPORTANT: Suppress all warnings FIRST
|
|
22
|
-
import warnings
|
|
23
|
-
warnings.filterwarnings("ignore")
|
|
24
|
-
|
|
25
|
-
import json
|
|
26
|
-
import os
|
|
27
|
-
import subprocess
|
|
28
|
-
import sys
|
|
29
|
-
from datetime import datetime
|
|
30
|
-
from pathlib import Path
|
|
31
|
-
|
|
32
|
-
# IMPORTANT: Force stdout to use UTF-8 on Windows
|
|
33
|
-
# This fixes UnicodeEncodeError when outputting non-ASCII characters
|
|
34
|
-
if sys.platform == "win32":
|
|
35
|
-
import io as _io
|
|
36
|
-
if hasattr(sys.stdout, "reconfigure"):
|
|
37
|
-
sys.stdout.reconfigure(encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
38
|
-
elif hasattr(sys.stdout, "detach"):
|
|
39
|
-
sys.stdout = _io.TextIOWrapper(sys.stdout.detach(), encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
40
|
-
|
|
41
|
-
# =============================================================================
|
|
42
|
-
# Configuration
|
|
43
|
-
# =============================================================================
|
|
44
|
-
|
|
45
|
-
MAX_ITERATIONS = 5 # Safety limit to prevent infinite loops
|
|
46
|
-
STATE_TIMEOUT_MINUTES = 30 # Reset state if older than this
|
|
47
|
-
STATE_FILE = ".aim-studio/.ralph-state.json"
|
|
48
|
-
WORKTREE_YAML = ".aim-studio/worktree.yaml"
|
|
49
|
-
DIR_WORKFLOW = ".aim-studio"
|
|
50
|
-
FILE_CURRENT_TASK = ".current-task"
|
|
51
|
-
|
|
52
|
-
# Only control loop for check agent
|
|
53
|
-
TARGET_AGENT = "check"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def find_repo_root(start_path: str) -> str | None:
|
|
57
|
-
"""Find git repo root from start_path upwards"""
|
|
58
|
-
current = Path(start_path).resolve()
|
|
59
|
-
while current != current.parent:
|
|
60
|
-
if (current / ".git").exists():
|
|
61
|
-
return str(current)
|
|
62
|
-
current = current.parent
|
|
63
|
-
return None
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def get_current_task(repo_root: str) -> str | None:
|
|
67
|
-
"""Read current task directory path"""
|
|
68
|
-
current_task_file = os.path.join(repo_root, DIR_WORKFLOW, FILE_CURRENT_TASK)
|
|
69
|
-
if not os.path.exists(current_task_file):
|
|
70
|
-
return None
|
|
71
|
-
|
|
72
|
-
try:
|
|
73
|
-
with open(current_task_file, "r", encoding="utf-8") as f:
|
|
74
|
-
content = f.read().strip()
|
|
75
|
-
return content if content else None
|
|
76
|
-
except Exception:
|
|
77
|
-
return None
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def get_verify_commands(repo_root: str) -> list[str]:
|
|
81
|
-
"""
|
|
82
|
-
Read verify commands from worktree.yaml.
|
|
83
|
-
|
|
84
|
-
Returns list of commands to run, or empty list if not configured.
|
|
85
|
-
Uses simple YAML parsing without external dependencies.
|
|
86
|
-
"""
|
|
87
|
-
yaml_path = os.path.join(repo_root, WORKTREE_YAML)
|
|
88
|
-
if not os.path.exists(yaml_path):
|
|
89
|
-
return []
|
|
90
|
-
|
|
91
|
-
try:
|
|
92
|
-
with open(yaml_path, "r", encoding="utf-8") as f:
|
|
93
|
-
content = f.read()
|
|
94
|
-
|
|
95
|
-
# Simple YAML parsing for verify section
|
|
96
|
-
# Look for "verify:" followed by list items
|
|
97
|
-
lines = content.split("\n")
|
|
98
|
-
in_verify_section = False
|
|
99
|
-
commands = []
|
|
100
|
-
|
|
101
|
-
for line in lines:
|
|
102
|
-
stripped = line.strip()
|
|
103
|
-
|
|
104
|
-
# Check for section start
|
|
105
|
-
if stripped.startswith("verify:"):
|
|
106
|
-
in_verify_section = True
|
|
107
|
-
continue
|
|
108
|
-
|
|
109
|
-
# Check for new section (not indented, ends with :)
|
|
110
|
-
if (
|
|
111
|
-
not line.startswith(" ")
|
|
112
|
-
and not line.startswith("\t")
|
|
113
|
-
and stripped.endswith(":")
|
|
114
|
-
and stripped != ""
|
|
115
|
-
):
|
|
116
|
-
in_verify_section = False
|
|
117
|
-
continue
|
|
118
|
-
|
|
119
|
-
# If in verify section, look for list items
|
|
120
|
-
if in_verify_section:
|
|
121
|
-
# Skip comments and empty lines
|
|
122
|
-
if stripped.startswith("#") or stripped == "":
|
|
123
|
-
continue
|
|
124
|
-
# Parse list item (- command)
|
|
125
|
-
if stripped.startswith("- "):
|
|
126
|
-
cmd = stripped[2:].strip()
|
|
127
|
-
if cmd:
|
|
128
|
-
commands.append(cmd)
|
|
129
|
-
|
|
130
|
-
return commands
|
|
131
|
-
except Exception:
|
|
132
|
-
return []
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def run_verify_commands(repo_root: str, commands: list[str]) -> tuple[bool, str]:
|
|
136
|
-
"""
|
|
137
|
-
Run verify commands and return (success, message).
|
|
138
|
-
|
|
139
|
-
All commands must pass for success.
|
|
140
|
-
"""
|
|
141
|
-
for cmd in commands:
|
|
142
|
-
try:
|
|
143
|
-
result = subprocess.run(
|
|
144
|
-
cmd,
|
|
145
|
-
shell=True,
|
|
146
|
-
cwd=repo_root,
|
|
147
|
-
capture_output=True,
|
|
148
|
-
timeout=120, # 2 minute timeout per command
|
|
149
|
-
)
|
|
150
|
-
if result.returncode != 0:
|
|
151
|
-
stderr = result.stderr.decode("utf-8", errors="replace")
|
|
152
|
-
stdout = result.stdout.decode("utf-8", errors="replace")
|
|
153
|
-
error_output = stderr or stdout
|
|
154
|
-
# Truncate long output
|
|
155
|
-
if len(error_output) > 500:
|
|
156
|
-
error_output = error_output[:500] + "..."
|
|
157
|
-
return False, f"Command failed: {cmd}\n{error_output}"
|
|
158
|
-
except subprocess.TimeoutExpired:
|
|
159
|
-
return False, f"Command timed out: {cmd}"
|
|
160
|
-
except Exception as e:
|
|
161
|
-
return False, f"Command error: {cmd} - {str(e)}"
|
|
162
|
-
|
|
163
|
-
return True, "All verify commands passed"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def get_completion_markers(repo_root: str, task_dir: str) -> list[str]:
|
|
167
|
-
"""
|
|
168
|
-
Read check.jsonl and generate completion markers from reasons.
|
|
169
|
-
|
|
170
|
-
Each entry's "reason" field becomes {REASON}_FINISH marker.
|
|
171
|
-
Example: {"file": "...", "reason": "TypeCheck"} -> "TYPECHECK_FINISH"
|
|
172
|
-
"""
|
|
173
|
-
check_jsonl_path = os.path.join(repo_root, task_dir, "check.jsonl")
|
|
174
|
-
markers = []
|
|
175
|
-
|
|
176
|
-
if not os.path.exists(check_jsonl_path):
|
|
177
|
-
# Fallback: if no check.jsonl, use default marker
|
|
178
|
-
return ["ALL_CHECKS_FINISH"]
|
|
179
|
-
|
|
180
|
-
try:
|
|
181
|
-
with open(check_jsonl_path, "r", encoding="utf-8") as f:
|
|
182
|
-
for line in f:
|
|
183
|
-
line = line.strip()
|
|
184
|
-
if not line:
|
|
185
|
-
continue
|
|
186
|
-
try:
|
|
187
|
-
item = json.loads(line)
|
|
188
|
-
reason = item.get("reason", "")
|
|
189
|
-
if reason:
|
|
190
|
-
# Convert to uppercase and add _FINISH suffix
|
|
191
|
-
marker = f"{reason.upper().replace(' ', '_')}_FINISH"
|
|
192
|
-
if marker not in markers:
|
|
193
|
-
markers.append(marker)
|
|
194
|
-
except json.JSONDecodeError:
|
|
195
|
-
continue
|
|
196
|
-
except Exception:
|
|
197
|
-
pass
|
|
198
|
-
|
|
199
|
-
# If no markers found, use default
|
|
200
|
-
if not markers:
|
|
201
|
-
markers = ["ALL_CHECKS_FINISH"]
|
|
202
|
-
|
|
203
|
-
return markers
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
def load_state(repo_root: str) -> dict:
|
|
207
|
-
"""Load Ralph Loop state from file"""
|
|
208
|
-
state_path = os.path.join(repo_root, STATE_FILE)
|
|
209
|
-
if not os.path.exists(state_path):
|
|
210
|
-
return {"task": None, "iteration": 0, "started_at": None}
|
|
211
|
-
|
|
212
|
-
try:
|
|
213
|
-
with open(state_path, "r", encoding="utf-8") as f:
|
|
214
|
-
return json.load(f)
|
|
215
|
-
except Exception:
|
|
216
|
-
return {"task": None, "iteration": 0, "started_at": None}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
def save_state(repo_root: str, state: dict) -> None:
|
|
220
|
-
"""Save Ralph Loop state to file"""
|
|
221
|
-
state_path = os.path.join(repo_root, STATE_FILE)
|
|
222
|
-
try:
|
|
223
|
-
# Ensure directory exists
|
|
224
|
-
os.makedirs(os.path.dirname(state_path), exist_ok=True)
|
|
225
|
-
with open(state_path, "w", encoding="utf-8") as f:
|
|
226
|
-
json.dump(state, f, indent=2, ensure_ascii=False)
|
|
227
|
-
except Exception:
|
|
228
|
-
pass
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
def check_completion(agent_output: str, markers: list[str]) -> tuple[bool, list[str]]:
|
|
232
|
-
"""
|
|
233
|
-
Check if all completion markers are present in agent output.
|
|
234
|
-
|
|
235
|
-
Returns:
|
|
236
|
-
(all_complete, missing_markers)
|
|
237
|
-
"""
|
|
238
|
-
missing = []
|
|
239
|
-
for marker in markers:
|
|
240
|
-
if marker not in agent_output:
|
|
241
|
-
missing.append(marker)
|
|
242
|
-
|
|
243
|
-
return len(missing) == 0, missing
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def main():
|
|
247
|
-
try:
|
|
248
|
-
input_data = json.load(sys.stdin)
|
|
249
|
-
except json.JSONDecodeError:
|
|
250
|
-
# If can't parse input, allow stop
|
|
251
|
-
sys.exit(0)
|
|
252
|
-
|
|
253
|
-
# Get event info
|
|
254
|
-
hook_event = input_data.get("hook_event_name", "")
|
|
255
|
-
|
|
256
|
-
# Only handle SubagentStop event
|
|
257
|
-
if hook_event != "SubagentStop":
|
|
258
|
-
sys.exit(0)
|
|
259
|
-
|
|
260
|
-
# Get subagent info
|
|
261
|
-
subagent_type = input_data.get("subagent_type", "")
|
|
262
|
-
agent_output = input_data.get("agent_output", "")
|
|
263
|
-
original_prompt = input_data.get("prompt", "")
|
|
264
|
-
cwd = input_data.get("cwd", os.getcwd())
|
|
265
|
-
|
|
266
|
-
# Only control check agent
|
|
267
|
-
if subagent_type != TARGET_AGENT:
|
|
268
|
-
sys.exit(0)
|
|
269
|
-
|
|
270
|
-
# Skip Ralph Loop for finish phase (already verified in check phase)
|
|
271
|
-
if "[finish]" in original_prompt.lower():
|
|
272
|
-
sys.exit(0)
|
|
273
|
-
|
|
274
|
-
# Find repo root
|
|
275
|
-
repo_root = find_repo_root(cwd)
|
|
276
|
-
if not repo_root:
|
|
277
|
-
sys.exit(0)
|
|
278
|
-
|
|
279
|
-
# Get current task
|
|
280
|
-
task_dir = get_current_task(repo_root)
|
|
281
|
-
if not task_dir:
|
|
282
|
-
sys.exit(0)
|
|
283
|
-
|
|
284
|
-
# Load state
|
|
285
|
-
state = load_state(repo_root)
|
|
286
|
-
|
|
287
|
-
# Reset state if task changed or state is too old
|
|
288
|
-
should_reset = False
|
|
289
|
-
if state.get("task") != task_dir:
|
|
290
|
-
should_reset = True
|
|
291
|
-
elif state.get("started_at"):
|
|
292
|
-
try:
|
|
293
|
-
started = datetime.fromisoformat(state["started_at"])
|
|
294
|
-
if (datetime.now() - started).total_seconds() > STATE_TIMEOUT_MINUTES * 60:
|
|
295
|
-
should_reset = True
|
|
296
|
-
except (ValueError, TypeError):
|
|
297
|
-
should_reset = True
|
|
298
|
-
|
|
299
|
-
if should_reset:
|
|
300
|
-
state = {
|
|
301
|
-
"task": task_dir,
|
|
302
|
-
"iteration": 0,
|
|
303
|
-
"started_at": datetime.now().isoformat(),
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
# Increment iteration
|
|
307
|
-
state["iteration"] = state.get("iteration", 0) + 1
|
|
308
|
-
current_iteration = state["iteration"]
|
|
309
|
-
|
|
310
|
-
# Save state
|
|
311
|
-
save_state(repo_root, state)
|
|
312
|
-
|
|
313
|
-
# Safety check: max iterations
|
|
314
|
-
if current_iteration >= MAX_ITERATIONS:
|
|
315
|
-
# Allow stop, reset state for next run
|
|
316
|
-
state["iteration"] = 0
|
|
317
|
-
save_state(repo_root, state)
|
|
318
|
-
output = {
|
|
319
|
-
"decision": "allow",
|
|
320
|
-
"reason": f"Max iterations ({MAX_ITERATIONS}) reached. Stopping to prevent infinite loop.",
|
|
321
|
-
}
|
|
322
|
-
print(json.dumps(output, ensure_ascii=False))
|
|
323
|
-
sys.exit(0)
|
|
324
|
-
|
|
325
|
-
# Check if verify commands are configured
|
|
326
|
-
verify_commands = get_verify_commands(repo_root)
|
|
327
|
-
|
|
328
|
-
if verify_commands:
|
|
329
|
-
# Use programmatic verification
|
|
330
|
-
passed, message = run_verify_commands(repo_root, verify_commands)
|
|
331
|
-
|
|
332
|
-
if passed:
|
|
333
|
-
# All verify commands passed, allow stop
|
|
334
|
-
state["iteration"] = 0
|
|
335
|
-
save_state(repo_root, state)
|
|
336
|
-
output = {
|
|
337
|
-
"decision": "allow",
|
|
338
|
-
"reason": "All verify commands passed. Check phase complete.",
|
|
339
|
-
}
|
|
340
|
-
print(json.dumps(output, ensure_ascii=False))
|
|
341
|
-
sys.exit(0)
|
|
342
|
-
else:
|
|
343
|
-
# Verification failed, block stop
|
|
344
|
-
output = {
|
|
345
|
-
"decision": "block",
|
|
346
|
-
"reason": f"Iteration {current_iteration}/{MAX_ITERATIONS}. Verification failed:\n{message}\n\nPlease fix the issues and try again.",
|
|
347
|
-
}
|
|
348
|
-
print(json.dumps(output, ensure_ascii=False))
|
|
349
|
-
sys.exit(0)
|
|
350
|
-
else:
|
|
351
|
-
# No verify commands, fall back to completion markers
|
|
352
|
-
markers = get_completion_markers(repo_root, task_dir)
|
|
353
|
-
all_complete, missing = check_completion(agent_output, markers)
|
|
354
|
-
|
|
355
|
-
if all_complete:
|
|
356
|
-
# All checks complete, allow stop
|
|
357
|
-
state["iteration"] = 0
|
|
358
|
-
save_state(repo_root, state)
|
|
359
|
-
output = {
|
|
360
|
-
"decision": "allow",
|
|
361
|
-
"reason": "All completion markers found. Check phase complete.",
|
|
362
|
-
}
|
|
363
|
-
print(json.dumps(output, ensure_ascii=False))
|
|
364
|
-
sys.exit(0)
|
|
365
|
-
else:
|
|
366
|
-
# Missing markers, block stop and continue
|
|
367
|
-
output = {
|
|
368
|
-
"decision": "block",
|
|
369
|
-
"reason": f"""Iteration {current_iteration}/{MAX_ITERATIONS}. Missing completion markers: {", ".join(missing)}.
|
|
370
|
-
|
|
371
|
-
IMPORTANT: You must ACTUALLY run the checks, not just output the markers.
|
|
372
|
-
- Did you run lint? What was the output?
|
|
373
|
-
- Did you run typecheck? What was the output?
|
|
374
|
-
- Did they actually pass with zero errors?
|
|
375
|
-
|
|
376
|
-
Only output a marker (e.g., LINT_FINISH) AFTER:
|
|
377
|
-
1. You have executed the corresponding command
|
|
378
|
-
2. The command completed with zero errors
|
|
379
|
-
3. You have shown the command output in your response
|
|
380
|
-
|
|
381
|
-
Do NOT output markers just to escape the loop. The loop exists to ensure quality.""",
|
|
382
|
-
}
|
|
383
|
-
print(json.dumps(output, ensure_ascii=False))
|
|
384
|
-
sys.exit(0)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if __name__ == "__main__":
|
|
388
|
-
main()
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Database Guidelines
|
|
2
|
-
|
|
3
|
-
> Database patterns and conventions for this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
Document your project's database conventions here.
|
|
11
|
-
|
|
12
|
-
Questions to answer:
|
|
13
|
-
- What ORM/query library do you use?
|
|
14
|
-
- How are migrations managed?
|
|
15
|
-
- What are the naming conventions for tables/columns?
|
|
16
|
-
- How do you handle transactions?
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
(To be filled by the team)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Query Patterns
|
|
24
|
-
|
|
25
|
-
<!-- How should queries be written? Batch operations? -->
|
|
26
|
-
|
|
27
|
-
(To be filled by the team)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Migrations
|
|
32
|
-
|
|
33
|
-
<!-- How to create and run migrations -->
|
|
34
|
-
|
|
35
|
-
(To be filled by the team)
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Naming Conventions
|
|
40
|
-
|
|
41
|
-
<!-- Table names, column names, index names -->
|
|
42
|
-
|
|
43
|
-
(To be filled by the team)
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Common Mistakes
|
|
48
|
-
|
|
49
|
-
<!-- Database-related mistakes your team has made -->
|
|
50
|
-
|
|
51
|
-
(To be filled by the team)
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Directory Structure
|
|
2
|
-
|
|
3
|
-
> How backend code is organized in this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
Document your project's backend directory structure here.
|
|
11
|
-
|
|
12
|
-
Questions to answer:
|
|
13
|
-
- How are modules/packages organized?
|
|
14
|
-
- Where does business logic live?
|
|
15
|
-
- Where are API endpoints defined?
|
|
16
|
-
- How are utilities and helpers organized?
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
(To be filled by the team)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Directory Layout
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
<!-- Replace with your actual structure -->
|
|
27
|
-
src/
|
|
28
|
-
├── ...
|
|
29
|
-
└── ...
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Module Organization
|
|
35
|
-
|
|
36
|
-
<!-- How should new features/modules be organized? -->
|
|
37
|
-
|
|
38
|
-
(To be filled by the team)
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Naming Conventions
|
|
43
|
-
|
|
44
|
-
<!-- File and folder naming rules -->
|
|
45
|
-
|
|
46
|
-
(To be filled by the team)
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## Examples
|
|
51
|
-
|
|
52
|
-
<!-- Link to well-organized modules as examples -->
|
|
53
|
-
|
|
54
|
-
(To be filled by the team)
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Error Handling
|
|
2
|
-
|
|
3
|
-
> How errors are handled in this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
Document your project's error handling conventions here.
|
|
11
|
-
|
|
12
|
-
Questions to answer:
|
|
13
|
-
- What error types do you define?
|
|
14
|
-
- How are errors propagated?
|
|
15
|
-
- How are errors logged?
|
|
16
|
-
- How are errors returned to clients?
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
(To be filled by the team)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Error Types
|
|
24
|
-
|
|
25
|
-
<!-- Custom error classes/types -->
|
|
26
|
-
|
|
27
|
-
(To be filled by the team)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Error Handling Patterns
|
|
32
|
-
|
|
33
|
-
<!-- Try-catch patterns, error propagation -->
|
|
34
|
-
|
|
35
|
-
(To be filled by the team)
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## API Error Responses
|
|
40
|
-
|
|
41
|
-
<!-- Standard error response format -->
|
|
42
|
-
|
|
43
|
-
(To be filled by the team)
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Common Mistakes
|
|
48
|
-
|
|
49
|
-
<!-- Error handling mistakes your team has made -->
|
|
50
|
-
|
|
51
|
-
(To be filled by the team)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Backend Development Guidelines
|
|
2
|
-
|
|
3
|
-
> Best practices for backend development in this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
This directory contains guidelines for backend development. Fill in each file with your project's specific conventions.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Guidelines Index
|
|
14
|
-
|
|
15
|
-
| Guide | Description | Status |
|
|
16
|
-
|-------|-------------|--------|
|
|
17
|
-
| [Directory Structure](./directory-structure.md) | Module organization and file layout | Done |
|
|
18
|
-
| [Script Conventions](./script-conventions.md) | Python script standards for .aim-studio/scripts/ | Done |
|
|
19
|
-
| [Error Handling](./error-handling.md) | Error types, handling strategies | Done |
|
|
20
|
-
| [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | Done |
|
|
21
|
-
| [Logging Guidelines](./logging-guidelines.md) | Structured logging, log levels | Done |
|
|
22
|
-
| [Migrations](./migrations.md) | Version migration system for template files | Done |
|
|
23
|
-
| [Database Guidelines](./database-guidelines.md) | ORM patterns, queries, migrations | N/A (CLI project) |
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## How to Fill These Guidelines
|
|
28
|
-
|
|
29
|
-
For each guideline file:
|
|
30
|
-
|
|
31
|
-
1. Document your project's **actual conventions** (not ideals)
|
|
32
|
-
2. Include **code examples** from your codebase
|
|
33
|
-
3. List **forbidden patterns** and why
|
|
34
|
-
4. Add **common mistakes** your team has made
|
|
35
|
-
|
|
36
|
-
The goal is to help AI assistants and new team members understand how YOUR project works.
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
**Language**: All documentation should be written in **English**.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Backend Development Guidelines
|
|
2
|
-
|
|
3
|
-
> Best practices for backend development in this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
This directory contains guidelines for backend development. Fill in each file with your project's specific conventions.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Guidelines Index
|
|
14
|
-
|
|
15
|
-
| Guide | Description | Status |
|
|
16
|
-
|-------|-------------|--------|
|
|
17
|
-
| [Directory Structure](./directory-structure.md) | Module organization and file layout | To fill |
|
|
18
|
-
| [Database Guidelines](./database-guidelines.md) | ORM patterns, queries, migrations | To fill |
|
|
19
|
-
| [Error Handling](./error-handling.md) | Error types, handling strategies | To fill |
|
|
20
|
-
| [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | To fill |
|
|
21
|
-
| [Logging Guidelines](./logging-guidelines.md) | Structured logging, log levels | To fill |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## How to Fill These Guidelines
|
|
26
|
-
|
|
27
|
-
For each guideline file:
|
|
28
|
-
|
|
29
|
-
1. Document your project's **actual conventions** (not ideals)
|
|
30
|
-
2. Include **code examples** from your codebase
|
|
31
|
-
3. List **forbidden patterns** and why
|
|
32
|
-
4. Add **common mistakes** your team has made
|
|
33
|
-
|
|
34
|
-
The goal is to help AI assistants and new team members understand how YOUR project works.
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
**Language**: All documentation should be written in **English**.
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Logging Guidelines
|
|
2
|
-
|
|
3
|
-
> How logging is done in this project.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
Document your project's logging conventions here.
|
|
11
|
-
|
|
12
|
-
Questions to answer:
|
|
13
|
-
- What logging library do you use?
|
|
14
|
-
- What are the log levels and when to use each?
|
|
15
|
-
- What should be logged?
|
|
16
|
-
- What should NOT be logged (PII, secrets)?
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
(To be filled by the team)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Log Levels
|
|
24
|
-
|
|
25
|
-
<!-- When to use each level: debug, info, warn, error -->
|
|
26
|
-
|
|
27
|
-
(To be filled by the team)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Structured Logging
|
|
32
|
-
|
|
33
|
-
<!-- Log format, required fields -->
|
|
34
|
-
|
|
35
|
-
(To be filled by the team)
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## What to Log
|
|
40
|
-
|
|
41
|
-
<!-- Important events to log -->
|
|
42
|
-
|
|
43
|
-
(To be filled by the team)
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## What NOT to Log
|
|
48
|
-
|
|
49
|
-
<!-- Sensitive data, PII, secrets -->
|
|
50
|
-
|
|
51
|
-
(To be filled by the team)
|