create-arete-workspace 0.2.0
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 +77 -0
- package/bin/arete.js +156 -0
- package/bin/create.js +111 -0
- package/lib/install-openclaw.js +50 -0
- package/lib/scaffold.js +213 -0
- package/lib/setup-wizard.js +88 -0
- package/lib/updater.js +130 -0
- package/package.json +34 -0
- package/packages/gatsaeng-os/README.md +36 -0
- package/packages/gatsaeng-os/components.json +23 -0
- package/packages/gatsaeng-os/eslint.config.mjs +18 -0
- package/packages/gatsaeng-os/next.config.ts +7 -0
- package/packages/gatsaeng-os/package.json +59 -0
- package/packages/gatsaeng-os/postcss.config.mjs +7 -0
- package/packages/gatsaeng-os/public/file.svg +1 -0
- package/packages/gatsaeng-os/public/globe.svg +1 -0
- package/packages/gatsaeng-os/public/next.svg +1 -0
- package/packages/gatsaeng-os/public/vercel.svg +1 -0
- package/packages/gatsaeng-os/public/window.svg +1 -0
- package/packages/gatsaeng-os/python/api_server.py +248 -0
- package/packages/gatsaeng-os/python/briefing.py +145 -0
- package/packages/gatsaeng-os/python/config.py +55 -0
- package/packages/gatsaeng-os/python/goal_context_agent.py +193 -0
- package/packages/gatsaeng-os/python/gyeokguk.py +171 -0
- package/packages/gatsaeng-os/python/proactive.py +158 -0
- package/packages/gatsaeng-os/python/requirements.txt +11 -0
- package/packages/gatsaeng-os/python/run.py +28 -0
- package/packages/gatsaeng-os/python/scoring.py +44 -0
- package/packages/gatsaeng-os/python/streak.py +70 -0
- package/packages/gatsaeng-os/python/telegram_bot.py +331 -0
- package/packages/gatsaeng-os/python/timing_engine.py +117 -0
- package/packages/gatsaeng-os/python/vault_io.py +423 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/areas/[id]/page.tsx +215 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/areas/page.tsx +161 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/books/[id]/page.tsx +215 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/books/page.tsx +268 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/calendar/page.tsx +379 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/error.tsx +30 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/focus/page.tsx +293 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/goals/[id]/page.tsx +426 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/goals/page.tsx +178 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/layout.tsx +29 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/notes/[id]/page.tsx +147 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/notes/page.tsx +254 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/page.tsx +26 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/projects/[id]/page.tsx +86 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/projects/page.tsx +215 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/review/page.tsx +475 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/routines/page.tsx +436 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/tasks/[id]/page.tsx +210 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/tasks/page.tsx +307 -0
- package/packages/gatsaeng-os/src/app/(dashboard)/voice/page.tsx +212 -0
- package/packages/gatsaeng-os/src/app/api/areas/[id]/route.ts +26 -0
- package/packages/gatsaeng-os/src/app/api/areas/route.ts +22 -0
- package/packages/gatsaeng-os/src/app/api/auth/login/route.ts +52 -0
- package/packages/gatsaeng-os/src/app/api/auth/logout/route.ts +8 -0
- package/packages/gatsaeng-os/src/app/api/books/[id]/route.ts +27 -0
- package/packages/gatsaeng-os/src/app/api/books/route.ts +20 -0
- package/packages/gatsaeng-os/src/app/api/calendar/[id]/route.ts +24 -0
- package/packages/gatsaeng-os/src/app/api/calendar/import/route.ts +52 -0
- package/packages/gatsaeng-os/src/app/api/calendar/route.ts +37 -0
- package/packages/gatsaeng-os/src/app/api/daily/route.ts +51 -0
- package/packages/gatsaeng-os/src/app/api/goals/[id]/route.ts +34 -0
- package/packages/gatsaeng-os/src/app/api/goals/route.ts +30 -0
- package/packages/gatsaeng-os/src/app/api/logs/energy/route.ts +40 -0
- package/packages/gatsaeng-os/src/app/api/logs/focus/route.ts +22 -0
- package/packages/gatsaeng-os/src/app/api/logs/routine/route.ts +54 -0
- package/packages/gatsaeng-os/src/app/api/milestones/[id]/route.ts +26 -0
- package/packages/gatsaeng-os/src/app/api/milestones/route.ts +47 -0
- package/packages/gatsaeng-os/src/app/api/notes/[id]/route.ts +29 -0
- package/packages/gatsaeng-os/src/app/api/notes/route.ts +37 -0
- package/packages/gatsaeng-os/src/app/api/profile/route.ts +17 -0
- package/packages/gatsaeng-os/src/app/api/projects/[id]/route.ts +27 -0
- package/packages/gatsaeng-os/src/app/api/projects/route.ts +25 -0
- package/packages/gatsaeng-os/src/app/api/reviews/[id]/route.ts +26 -0
- package/packages/gatsaeng-os/src/app/api/reviews/route.ts +29 -0
- package/packages/gatsaeng-os/src/app/api/routines/[id]/route.ts +26 -0
- package/packages/gatsaeng-os/src/app/api/routines/route.ts +28 -0
- package/packages/gatsaeng-os/src/app/api/tasks/[id]/route.ts +28 -0
- package/packages/gatsaeng-os/src/app/api/tasks/route.ts +66 -0
- package/packages/gatsaeng-os/src/app/api/timing/current/route.ts +63 -0
- package/packages/gatsaeng-os/src/app/api/voice/chat/route.ts +50 -0
- package/packages/gatsaeng-os/src/app/api/voice/transcribe/route.ts +25 -0
- package/packages/gatsaeng-os/src/app/api/voice/tts/route.ts +36 -0
- package/packages/gatsaeng-os/src/app/error.tsx +30 -0
- package/packages/gatsaeng-os/src/app/favicon.ico +0 -0
- package/packages/gatsaeng-os/src/app/globals.css +208 -0
- package/packages/gatsaeng-os/src/app/layout.tsx +33 -0
- package/packages/gatsaeng-os/src/app/login/page.tsx +87 -0
- package/packages/gatsaeng-os/src/app/providers.tsx +27 -0
- package/packages/gatsaeng-os/src/components/ErrorBoundary.tsx +46 -0
- package/packages/gatsaeng-os/src/components/dashboard/DashboardGrid.tsx +86 -0
- package/packages/gatsaeng-os/src/components/dashboard/DdayWidget.tsx +88 -0
- package/packages/gatsaeng-os/src/components/dashboard/EnergyTracker.tsx +87 -0
- package/packages/gatsaeng-os/src/components/dashboard/FocusTimer.tsx +139 -0
- package/packages/gatsaeng-os/src/components/dashboard/GatsaengScore.tsx +30 -0
- package/packages/gatsaeng-os/src/components/dashboard/GoalRings.tsx +107 -0
- package/packages/gatsaeng-os/src/components/dashboard/ProactiveBar.tsx +98 -0
- package/packages/gatsaeng-os/src/components/dashboard/RoutineChecklist.tsx +81 -0
- package/packages/gatsaeng-os/src/components/dashboard/TimingWidget.tsx +86 -0
- package/packages/gatsaeng-os/src/components/dashboard/WidgetCustomizer.tsx +95 -0
- package/packages/gatsaeng-os/src/components/dashboard/WidgetWrapper.tsx +33 -0
- package/packages/gatsaeng-os/src/components/dashboard/ZeigarnikPanel.tsx +43 -0
- package/packages/gatsaeng-os/src/components/editor/EditorToolbar.tsx +186 -0
- package/packages/gatsaeng-os/src/components/editor/TiptapEditor.tsx +114 -0
- package/packages/gatsaeng-os/src/components/layout/Header.tsx +47 -0
- package/packages/gatsaeng-os/src/components/layout/MobileBottomNav.tsx +122 -0
- package/packages/gatsaeng-os/src/components/layout/MobileSidebar.tsx +29 -0
- package/packages/gatsaeng-os/src/components/layout/Sidebar.tsx +142 -0
- package/packages/gatsaeng-os/src/components/onboarding/OnboardingFlow.tsx +229 -0
- package/packages/gatsaeng-os/src/components/onboarding/OnboardingGate.tsx +78 -0
- package/packages/gatsaeng-os/src/components/projects/CalendarView.tsx +152 -0
- package/packages/gatsaeng-os/src/components/projects/KanbanView.tsx +180 -0
- package/packages/gatsaeng-os/src/components/projects/ListView.tsx +82 -0
- package/packages/gatsaeng-os/src/components/projects/TableView.tsx +206 -0
- package/packages/gatsaeng-os/src/components/projects/TaskCard.tsx +154 -0
- package/packages/gatsaeng-os/src/components/projects/TaskForm.tsx +128 -0
- package/packages/gatsaeng-os/src/components/projects/ViewSwitcher.tsx +40 -0
- package/packages/gatsaeng-os/src/components/search/GlobalSearch.tsx +179 -0
- package/packages/gatsaeng-os/src/components/shared/InlineEdit.tsx +77 -0
- package/packages/gatsaeng-os/src/components/shared/PinButton.tsx +42 -0
- package/packages/gatsaeng-os/src/components/tasks/DDayBadge.tsx +34 -0
- package/packages/gatsaeng-os/src/components/ui/badge.tsx +48 -0
- package/packages/gatsaeng-os/src/components/ui/button.tsx +64 -0
- package/packages/gatsaeng-os/src/components/ui/card.tsx +92 -0
- package/packages/gatsaeng-os/src/components/ui/checkbox.tsx +32 -0
- package/packages/gatsaeng-os/src/components/ui/command.tsx +184 -0
- package/packages/gatsaeng-os/src/components/ui/dialog.tsx +158 -0
- package/packages/gatsaeng-os/src/components/ui/input.tsx +21 -0
- package/packages/gatsaeng-os/src/components/ui/label.tsx +24 -0
- package/packages/gatsaeng-os/src/components/ui/popover.tsx +89 -0
- package/packages/gatsaeng-os/src/components/ui/progress.tsx +31 -0
- package/packages/gatsaeng-os/src/components/ui/select.tsx +190 -0
- package/packages/gatsaeng-os/src/components/ui/sheet.tsx +143 -0
- package/packages/gatsaeng-os/src/components/ui/tabs.tsx +91 -0
- package/packages/gatsaeng-os/src/components/ui/toggle-group.tsx +83 -0
- package/packages/gatsaeng-os/src/components/ui/toggle.tsx +47 -0
- package/packages/gatsaeng-os/src/components/ui/tooltip.tsx +57 -0
- package/packages/gatsaeng-os/src/hooks/useAreas.ts +53 -0
- package/packages/gatsaeng-os/src/hooks/useBooks.ts +62 -0
- package/packages/gatsaeng-os/src/hooks/useCalendar.ts +59 -0
- package/packages/gatsaeng-os/src/hooks/useDaily.ts +15 -0
- package/packages/gatsaeng-os/src/hooks/useGlobalTasks.ts +45 -0
- package/packages/gatsaeng-os/src/hooks/useGoals.ts +53 -0
- package/packages/gatsaeng-os/src/hooks/useMilestones.ts +75 -0
- package/packages/gatsaeng-os/src/hooks/useNotes.ts +65 -0
- package/packages/gatsaeng-os/src/hooks/useProjects.ts +102 -0
- package/packages/gatsaeng-os/src/hooks/useRoutines.ts +76 -0
- package/packages/gatsaeng-os/src/hooks/useTiming.ts +27 -0
- package/packages/gatsaeng-os/src/lib/apiFetch.ts +14 -0
- package/packages/gatsaeng-os/src/lib/auth.ts +32 -0
- package/packages/gatsaeng-os/src/lib/date.ts +7 -0
- package/packages/gatsaeng-os/src/lib/editor/markdown.ts +35 -0
- package/packages/gatsaeng-os/src/lib/llm-governor.ts +167 -0
- package/packages/gatsaeng-os/src/lib/neuroscience/energyCycle.ts +35 -0
- package/packages/gatsaeng-os/src/lib/neuroscience/habitStack.ts +22 -0
- package/packages/gatsaeng-os/src/lib/neuroscience/scoring.ts +32 -0
- package/packages/gatsaeng-os/src/lib/routes.ts +15 -0
- package/packages/gatsaeng-os/src/lib/utils.ts +6 -0
- package/packages/gatsaeng-os/src/lib/vault/config.ts +29 -0
- package/packages/gatsaeng-os/src/lib/vault/frontmatter.ts +84 -0
- package/packages/gatsaeng-os/src/lib/vault/index.ts +180 -0
- package/packages/gatsaeng-os/src/lib/vault/schemas.ts +274 -0
- package/packages/gatsaeng-os/src/middleware.ts +34 -0
- package/packages/gatsaeng-os/src/stores/dashboardStore.ts +26 -0
- package/packages/gatsaeng-os/src/stores/favoritesStore.ts +47 -0
- package/packages/gatsaeng-os/src/stores/timerStore.ts +65 -0
- package/packages/gatsaeng-os/src/types/index.ts +320 -0
- package/packages/gatsaeng-os/tsconfig.json +34 -0
- package/templates/scripts/forge_qa.sh.tmpl +237 -0
- package/templates/scripts/forge_ship.sh.tmpl +183 -0
- package/templates/scripts/session_indexer.py.tmpl +420 -0
- package/templates/scripts/tracer.py.tmpl +266 -0
- package/templates/workspace/AGENTS.md.tmpl +190 -0
- package/templates/workspace/BOOTSTRAP.md.tmpl +27 -0
- package/templates/workspace/HEARTBEAT.md.tmpl +23 -0
- package/templates/workspace/MEMORY.md.tmpl +35 -0
- package/templates/workspace/SOUL.md.tmpl +258 -0
- package/templates/workspace/TOOLS.md.tmpl +28 -0
- package/templates/workspace/USER.md.tmpl +43 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Tracer Agent — Evidence-based causal reasoning tracker.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python3 scripts/tracer.py start --id ID --symptom "..."
|
|
7
|
+
python3 scripts/tracer.py hypothesis --id ID --text "..." --confidence 0.7
|
|
8
|
+
python3 scripts/tracer.py evidence --id ID --type for|against --text "..."
|
|
9
|
+
python3 scripts/tracer.py status --id ID
|
|
10
|
+
python3 scripts/tracer.py conclude --id ID --root-cause "..." --fix "..."
|
|
11
|
+
python3 scripts/tracer.py list
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import json
|
|
17
|
+
import sys
|
|
18
|
+
from datetime import datetime, timezone
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
TRACES_DIR = Path("{{WORKSPACE_PATH}}/data/traces")
|
|
22
|
+
MEMORY_MD = Path("{{WORKSPACE_PATH}}/MEMORY.md")
|
|
23
|
+
|
|
24
|
+
LESSONS_HEADER = "## Lessons Learned"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _now() -> str:
|
|
28
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _trace_path(trace_id: str) -> Path:
|
|
32
|
+
return TRACES_DIR / f"{trace_id}.json"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _load(trace_id: str) -> dict:
|
|
36
|
+
p = _trace_path(trace_id)
|
|
37
|
+
if not p.exists():
|
|
38
|
+
print(f"Error: Trace '{trace_id}' not found.")
|
|
39
|
+
sys.exit(1)
|
|
40
|
+
return json.loads(p.read_text(encoding="utf-8"))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _save(trace: dict) -> None:
|
|
44
|
+
TRACES_DIR.mkdir(parents=True, exist_ok=True)
|
|
45
|
+
p = _trace_path(trace["id"])
|
|
46
|
+
p.write_text(json.dumps(trace, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# ── Commands ─────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
def cmd_start(args: argparse.Namespace) -> None:
|
|
52
|
+
p = _trace_path(args.id)
|
|
53
|
+
if p.exists():
|
|
54
|
+
print(f"Error: Trace '{args.id}' already exists.")
|
|
55
|
+
sys.exit(1)
|
|
56
|
+
trace = {
|
|
57
|
+
"id": args.id,
|
|
58
|
+
"symptom": args.symptom,
|
|
59
|
+
"status": "open",
|
|
60
|
+
"hypotheses": [],
|
|
61
|
+
"evidence": [],
|
|
62
|
+
"root_cause": None,
|
|
63
|
+
"fix": None,
|
|
64
|
+
"created_at": _now(),
|
|
65
|
+
"concluded_at": None,
|
|
66
|
+
}
|
|
67
|
+
_save(trace)
|
|
68
|
+
print(f"Trace '{args.id}' started.")
|
|
69
|
+
print(f" Symptom: {args.symptom}")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def cmd_hypothesis(args: argparse.Namespace) -> None:
|
|
73
|
+
trace = _load(args.id)
|
|
74
|
+
if trace["status"] == "concluded":
|
|
75
|
+
print(f"Warning: Trace '{args.id}' is already concluded.")
|
|
76
|
+
sys.exit(1)
|
|
77
|
+
h = {
|
|
78
|
+
"text": args.text,
|
|
79
|
+
"confidence": args.confidence,
|
|
80
|
+
"status": "active",
|
|
81
|
+
"added_at": _now(),
|
|
82
|
+
}
|
|
83
|
+
trace["hypotheses"].append(h)
|
|
84
|
+
_save(trace)
|
|
85
|
+
print(f"Hypothesis added (confidence={args.confidence}):")
|
|
86
|
+
print(f" {args.text}")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def cmd_evidence(args: argparse.Namespace) -> None:
|
|
90
|
+
trace = _load(args.id)
|
|
91
|
+
if trace["status"] == "concluded":
|
|
92
|
+
print(f"Warning: Trace '{args.id}' is already concluded.")
|
|
93
|
+
sys.exit(1)
|
|
94
|
+
e = {
|
|
95
|
+
"type": args.type,
|
|
96
|
+
"text": args.text,
|
|
97
|
+
"timestamp": _now(),
|
|
98
|
+
}
|
|
99
|
+
trace["evidence"].append(e)
|
|
100
|
+
_save(trace)
|
|
101
|
+
label = "FOR" if args.type == "for" else "AGAINST"
|
|
102
|
+
print(f"Evidence added [{label}]:")
|
|
103
|
+
print(f" {args.text}")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _rank_hypotheses(trace: dict) -> list[dict]:
|
|
107
|
+
"""Rank hypotheses by adjusted confidence = base confidence x evidence factor."""
|
|
108
|
+
evidence = trace["evidence"]
|
|
109
|
+
ranked = []
|
|
110
|
+
for h in trace["hypotheses"]:
|
|
111
|
+
n_for = sum(1 for e in evidence if e["type"] == "for")
|
|
112
|
+
n_against = sum(1 for e in evidence if e["type"] == "against")
|
|
113
|
+
total = n_for + n_against
|
|
114
|
+
if total > 0:
|
|
115
|
+
evidence_factor = (n_for - n_against) / total
|
|
116
|
+
adjusted = h["confidence"] * (1 + 0.3 * evidence_factor)
|
|
117
|
+
adjusted = max(0.0, min(1.0, adjusted))
|
|
118
|
+
else:
|
|
119
|
+
adjusted = h["confidence"]
|
|
120
|
+
ranked.append({**h, "adjusted_confidence": round(adjusted, 3)})
|
|
121
|
+
ranked.sort(key=lambda x: x["adjusted_confidence"], reverse=True)
|
|
122
|
+
return ranked
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def cmd_status(args: argparse.Namespace) -> None:
|
|
126
|
+
trace = _load(args.id)
|
|
127
|
+
evidence = trace["evidence"]
|
|
128
|
+
n_for = sum(1 for e in evidence if e["type"] == "for")
|
|
129
|
+
n_against = sum(1 for e in evidence if e["type"] == "against")
|
|
130
|
+
|
|
131
|
+
print(f"== Trace: {trace['id']} ==")
|
|
132
|
+
print(f" Status : {trace['status'].upper()}")
|
|
133
|
+
print(f" Symptom : {trace['symptom']}")
|
|
134
|
+
print(f" Created : {trace['created_at']}")
|
|
135
|
+
if trace["concluded_at"]:
|
|
136
|
+
print(f" Concluded: {trace['concluded_at']}")
|
|
137
|
+
print(f" Evidence : {len(evidence)} total ({n_for} for / {n_against} against)")
|
|
138
|
+
print("== Hypotheses (ranked) ==")
|
|
139
|
+
|
|
140
|
+
ranked = _rank_hypotheses(trace)
|
|
141
|
+
if not ranked:
|
|
142
|
+
print(" (none)")
|
|
143
|
+
for i, h in enumerate(ranked, 1):
|
|
144
|
+
status_icon = {"active": "o", "confirmed": "+", "rejected": "x"}.get(h["status"], "?")
|
|
145
|
+
print(f" {i}. [{status_icon}] [{h['adjusted_confidence']:.2f}] {h['text']}")
|
|
146
|
+
|
|
147
|
+
if evidence:
|
|
148
|
+
print("== Evidence ==")
|
|
149
|
+
for e in evidence:
|
|
150
|
+
icon = "[FOR]" if e["type"] == "for" else "[AGAINST]"
|
|
151
|
+
print(f" {icon} {e['text']} ({e['timestamp']})")
|
|
152
|
+
|
|
153
|
+
if trace["root_cause"]:
|
|
154
|
+
print("== Conclusion ==")
|
|
155
|
+
print(f" Root cause: {trace['root_cause']}")
|
|
156
|
+
print(f" Fix: {trace['fix']}")
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def cmd_conclude(args: argparse.Namespace) -> None:
|
|
160
|
+
trace = _load(args.id)
|
|
161
|
+
if trace["status"] == "concluded":
|
|
162
|
+
print(f"Warning: Trace '{args.id}' is already concluded.")
|
|
163
|
+
sys.exit(1)
|
|
164
|
+
|
|
165
|
+
trace["status"] = "concluded"
|
|
166
|
+
trace["root_cause"] = args.root_cause
|
|
167
|
+
trace["fix"] = args.fix
|
|
168
|
+
trace["concluded_at"] = _now()
|
|
169
|
+
|
|
170
|
+
ranked = _rank_hypotheses(trace)
|
|
171
|
+
if ranked:
|
|
172
|
+
top_text = ranked[0]["text"]
|
|
173
|
+
for h in trace["hypotheses"]:
|
|
174
|
+
h["status"] = "confirmed" if h["text"] == top_text else "rejected"
|
|
175
|
+
|
|
176
|
+
_save(trace)
|
|
177
|
+
_append_lesson(trace)
|
|
178
|
+
|
|
179
|
+
print(f"Trace '{args.id}' concluded.")
|
|
180
|
+
print(f" Root cause: {args.root_cause}")
|
|
181
|
+
print(f" Fix: {args.fix}")
|
|
182
|
+
print(f" Lesson appended to MEMORY.md")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _append_lesson(trace: dict) -> None:
|
|
186
|
+
"""Append root_cause + fix to MEMORY.md Lessons Learned. APPEND ONLY."""
|
|
187
|
+
date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
|
188
|
+
lesson = f"- **[{trace['id']}]** {trace['root_cause']} -> {trace['fix']} ({date}).\n"
|
|
189
|
+
|
|
190
|
+
content = MEMORY_MD.read_text(encoding="utf-8")
|
|
191
|
+
lines = content.split("\n")
|
|
192
|
+
|
|
193
|
+
ll_idx = None
|
|
194
|
+
next_section_idx = None
|
|
195
|
+
for i, line in enumerate(lines):
|
|
196
|
+
if line.strip().startswith(LESSONS_HEADER):
|
|
197
|
+
ll_idx = i
|
|
198
|
+
continue
|
|
199
|
+
if ll_idx is not None and line.startswith("## ") and i > ll_idx:
|
|
200
|
+
next_section_idx = i
|
|
201
|
+
break
|
|
202
|
+
|
|
203
|
+
if ll_idx is None:
|
|
204
|
+
content += f"\n{LESSONS_HEADER}\n{lesson}"
|
|
205
|
+
else:
|
|
206
|
+
insert_at = next_section_idx if next_section_idx else len(lines)
|
|
207
|
+
while insert_at > ll_idx + 1 and lines[insert_at - 1].strip() == "":
|
|
208
|
+
insert_at -= 1
|
|
209
|
+
lines.insert(insert_at, lesson.rstrip())
|
|
210
|
+
content = "\n".join(lines)
|
|
211
|
+
|
|
212
|
+
MEMORY_MD.write_text(content, encoding="utf-8")
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def cmd_list(_args: argparse.Namespace) -> None:
|
|
216
|
+
if not TRACES_DIR.exists():
|
|
217
|
+
print("No traces yet.")
|
|
218
|
+
return
|
|
219
|
+
files = sorted(TRACES_DIR.glob("*.json"))
|
|
220
|
+
if not files:
|
|
221
|
+
print("No traces yet.")
|
|
222
|
+
return
|
|
223
|
+
print(f"{'ID':<30} {'Status':<12} {'Symptom'}")
|
|
224
|
+
print("-" * 80)
|
|
225
|
+
for f in files:
|
|
226
|
+
t = json.loads(f.read_text(encoding="utf-8"))
|
|
227
|
+
print(f"{t['id']:<30} {t['status']:<12} {t['symptom']}")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
# ── CLI ──────────────────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
def main() -> None:
|
|
233
|
+
parser = argparse.ArgumentParser(description="Tracer Agent - Evidence-based causal tracking")
|
|
234
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
235
|
+
|
|
236
|
+
p_start = sub.add_parser("start", help="Start new trace")
|
|
237
|
+
p_start.add_argument("--id", required=True)
|
|
238
|
+
p_start.add_argument("--symptom", required=True)
|
|
239
|
+
|
|
240
|
+
p_hyp = sub.add_parser("hypothesis", help="Add hypothesis")
|
|
241
|
+
p_hyp.add_argument("--id", required=True)
|
|
242
|
+
p_hyp.add_argument("--text", required=True)
|
|
243
|
+
p_hyp.add_argument("--confidence", type=float, default=0.5)
|
|
244
|
+
|
|
245
|
+
p_ev = sub.add_parser("evidence", help="Add evidence")
|
|
246
|
+
p_ev.add_argument("--id", required=True)
|
|
247
|
+
p_ev.add_argument("--type", required=True, choices=["for", "against"])
|
|
248
|
+
p_ev.add_argument("--text", required=True)
|
|
249
|
+
|
|
250
|
+
p_st = sub.add_parser("status", help="Check status")
|
|
251
|
+
p_st.add_argument("--id", required=True)
|
|
252
|
+
|
|
253
|
+
p_con = sub.add_parser("conclude", help="Record conclusion")
|
|
254
|
+
p_con.add_argument("--id", required=True)
|
|
255
|
+
p_con.add_argument("--root-cause", required=True)
|
|
256
|
+
p_con.add_argument("--fix", required=True)
|
|
257
|
+
|
|
258
|
+
sub.add_parser("list", help="List all traces")
|
|
259
|
+
|
|
260
|
+
args = parser.parse_args()
|
|
261
|
+
{"start": cmd_start, "hypothesis": cmd_hypothesis, "evidence": cmd_evidence,
|
|
262
|
+
"status": cmd_status, "conclude": cmd_conclude, "list": cmd_list}[args.command](args)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if __name__ == "__main__":
|
|
266
|
+
main()
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# AGENTS.md - System Operation Framework
|
|
2
|
+
|
|
3
|
+
> **SSOT (Single Source of Truth)**: This file is the canonical source for **agent operation protocols**. Other files reference this file instead of duplicating rules.
|
|
4
|
+
> Related sources: Agent behavior → `SOUL.md` | User preferences → `USER.md` | Memory policy → `MEMORY.md`
|
|
5
|
+
|
|
6
|
+
## Skill Graph
|
|
7
|
+
Main agent ({{AGENT_NAME}}) entry point: `{{OPENCLAW_PATH}}/skill-graph/_agent-{{AGENT_NAME | lowercase}}/SKILL.md`
|
|
8
|
+
Other agents: see BOOTSTRAP.md § 0 for agent-specific entry points.
|
|
9
|
+
|
|
10
|
+
## Command Triggers
|
|
11
|
+
- **`[SAVE]`**: Store context into `memory/YYYY-MM-DD.md` (daily log)
|
|
12
|
+
- **`[SAVE:PERMANENT]`**: Store to `MEMORY.md` (permanent)
|
|
13
|
+
- **`[SEARCH:ARCHIVE]`**: Search historical memory files (7+ days old)
|
|
14
|
+
- **`[PRUNE]`**: Review and compress memory files
|
|
15
|
+
- **`[OPTIMIZE]`**: Run AgentLinter and self-correct
|
|
16
|
+
|
|
17
|
+
## Self-Improvement Protocol
|
|
18
|
+
- On error → auto-record in `.learnings/`
|
|
19
|
+
- Accumulated patterns → reviewed in weekly memory synthesis for MEMORY.md promotion
|
|
20
|
+
- Memory hierarchy/promotion/Anti-Bloat → `MEMORY.md` § Memory Protocol (canonical)
|
|
21
|
+
|
|
22
|
+
## On-Demand File Routing (ref/ directory)
|
|
23
|
+
These files are NOT auto-injected into system prompt. Load with `read` only when relevant.
|
|
24
|
+
|
|
25
|
+
| File | Path | When to Read |
|
|
26
|
+
|------|------|-------------|
|
|
27
|
+
| SUBAGENT-POLICY.md | `ref/SUBAGENT-POLICY.md` | Before sub-agent spawn (complex orchestration) |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## {{AGENT_NAME}} Harness Routing (MANDATORY)
|
|
32
|
+
User talks to {{AGENT_NAME}} only. {{AGENT_NAME}} routes to domain agents.
|
|
33
|
+
|
|
34
|
+
### Domain Routing
|
|
35
|
+
|
|
36
|
+
{{DOMAIN_AGENTS_TABLE}}
|
|
37
|
+
|
|
38
|
+
| Request Type | Routing | Rationale |
|
|
39
|
+
|-------------|---------|-----------|
|
|
40
|
+
| Quick answer in a domain | Memory Bridge daily log summary | Minimize latency |
|
|
41
|
+
| Deep analysis (30min+ expected) | Spawn domain sub-agent | Context isolation |
|
|
42
|
+
| Code/system design — small fix | {{AGENT_NAME}} handles directly | No spawn needed |
|
|
43
|
+
| Code/system design — large impl | FORGE or {{AGENT_NAME}}-opus spawn | Work isolation needed |
|
|
44
|
+
|
|
45
|
+
### Spawn vs Skill Load Criteria
|
|
46
|
+
- **Skill load**: Answer needed in <5 seconds + no domain KB required
|
|
47
|
+
- **Sub-agent spawn**: 30min+ expected work / specialized KB required / context dilution risk
|
|
48
|
+
|
|
49
|
+
### Memory Bridge
|
|
50
|
+
- `session_indexer.py` — Indexes sessions from main + domain agents
|
|
51
|
+
- Runs on cron: domain agent results → memory/YYYY-MM-DD.md auto-append
|
|
52
|
+
- {{AGENT_NAME}} reads today's daily log at session start to know all agent work results
|
|
53
|
+
|
|
54
|
+
### FORGE Completion Protocol
|
|
55
|
+
After FORGE work completes, {{AGENT_NAME}} must:
|
|
56
|
+
1. Run `git -C <repo> log --oneline -5` → verify commit summary
|
|
57
|
+
2. Record in daily log: `⚒️ FORGE [repo] N new commits:` format
|
|
58
|
+
3. Include commit hash + changed files in completion report to user
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Eve Plan Review (MANDATORY — before FORGE spawn)
|
|
63
|
+
|
|
64
|
+
> **Executor: {{AGENT_NAME}}-opus (Opus + thinking)**. Strategy + architecture = Opus domain.
|
|
65
|
+
> {{AGENT_NAME}} (Sonnet) receives request, delegates to {{AGENT_NAME}}-opus, delivers result to user.
|
|
66
|
+
|
|
67
|
+
### Plan-CEO Review (auto-triggered on new feature/product requests)
|
|
68
|
+
|
|
69
|
+
When user suggests a new feature, {{AGENT_NAME}} spawns **{{AGENT_NAME}}-opus sub-agent**:
|
|
70
|
+
|
|
71
|
+
**Step 0: Deep Interview**
|
|
72
|
+
Before any code, Socratic questions to eliminate hidden assumptions:
|
|
73
|
+
- "Why does this need to be built now?"
|
|
74
|
+
- "What happens if we don't build it?"
|
|
75
|
+
- "What's the success metric? In numbers?"
|
|
76
|
+
- "Is there something similar that already exists but isn't being used?"
|
|
77
|
+
→ Score clarity. Unclear → more questions. Clear → next step.
|
|
78
|
+
|
|
79
|
+
**Steps 1-3: Analysis**
|
|
80
|
+
1. **Real user problem**: "What's the actual problem behind this request?"
|
|
81
|
+
2. **10-star version**: Current request = how many stars? Where's 10-star?
|
|
82
|
+
3. **Mode selection** (user decides):
|
|
83
|
+
|
|
84
|
+
| Mode | Position | When |
|
|
85
|
+
|------|----------|------|
|
|
86
|
+
| **EXPANSION** | CEO perspective | Scope open. Explore bigger impact. |
|
|
87
|
+
| **HOLD SCOPE** | Strict reviewer | Scope locked. Focus on completeness + edge cases. |
|
|
88
|
+
| **REDUCTION** | Surgeon | Fast MVP needed. Strip everything except core. |
|
|
89
|
+
|
|
90
|
+
### Plan-Eng Review (after scope lock, before FORGE spawn)
|
|
91
|
+
|
|
92
|
+
{{AGENT_NAME}}-opus produces:
|
|
93
|
+
- Affected files/API list
|
|
94
|
+
- 3+ edge cases
|
|
95
|
+
- Failure modes (network/timeout/empty response)
|
|
96
|
+
- Architecture diagram (text)
|
|
97
|
+
|
|
98
|
+
→ Include in FORGE spawn prompt's `WHAT` + `CONSTRAINTS`.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Sub-Agent Policy
|
|
103
|
+
|
|
104
|
+
### When to Spawn
|
|
105
|
+
- Code/config tasks requiring `claude-opus-4-6`
|
|
106
|
+
- Long-running analysis (>5min expected)
|
|
107
|
+
- Parallel research (multiple independent domains)
|
|
108
|
+
- Isolated experiments (don't pollute main session context)
|
|
109
|
+
|
|
110
|
+
### Spawn Prompt Format (MANDATORY)
|
|
111
|
+
Sub-agent/ACP session prompts must follow this 3-part structure:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
WHY
|
|
115
|
+
- Why this task is being done (purpose / business context / timing)
|
|
116
|
+
|
|
117
|
+
WHAT
|
|
118
|
+
- Exact deliverable expected
|
|
119
|
+
- Expected output: scope, tests, commits, report format
|
|
120
|
+
|
|
121
|
+
CONSTRAINTS
|
|
122
|
+
- Absolute prohibitions / limits / quality bar
|
|
123
|
+
- e.g.: Test First, absolute paths only, specific directory read-only, perf/security conditions
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Minimum Rules
|
|
127
|
+
- No `WHY` = no instruction — never let agents guess the purpose
|
|
128
|
+
- No `WHAT` = no instruction — no "look at it/fix it" without completion criteria
|
|
129
|
+
- No `CONSTRAINTS` = no instruction — high-risk areas (auth/payment/config) need explicit limits
|
|
130
|
+
- Even 3-line tasks maintain this structure
|
|
131
|
+
- {{AGENT_NAME}} compresses user requests into this structure before delegation
|
|
132
|
+
|
|
133
|
+
#### FORGE IMPACT MAP (MANDATORY for FORGE spawns)
|
|
134
|
+
Include in WHAT section:
|
|
135
|
+
```
|
|
136
|
+
IMPACT MAP
|
|
137
|
+
- Files to modify: [list]
|
|
138
|
+
- Indirectly affected files/features: [list]
|
|
139
|
+
- Existing feature conflict potential: [yes/no + reason]
|
|
140
|
+
- Key edge cases: [2+ items]
|
|
141
|
+
```
|
|
142
|
+
No impact map = bug reservation. {{AGENT_NAME}} writes during plan-eng-review, passes to FORGE.
|
|
143
|
+
|
|
144
|
+
### When NOT to Spawn
|
|
145
|
+
- Simple file edits, single-file reads, quick web searches → use native tools
|
|
146
|
+
- NEVER spawn for tasks in workspace (main agent handles)
|
|
147
|
+
|
|
148
|
+
### Failure Handling
|
|
149
|
+
- `consecutiveErrors > 2` → kill + alert user
|
|
150
|
+
- Timeout `> 10min` → kill + log reason
|
|
151
|
+
- No response `5min` → check status + steer or kill
|
|
152
|
+
|
|
153
|
+
### Concurrency
|
|
154
|
+
- **Max 8** parallel sub-agents
|
|
155
|
+
- **Max 1** Opus sub-agent (cost control)
|
|
156
|
+
|
|
157
|
+
### Sub-Agent Memory Rules
|
|
158
|
+
Sub-agents MUST follow `MEMORY.md` § Memory Protocol:
|
|
159
|
+
1. On spawn: Read `MEMORY.md` for core context
|
|
160
|
+
2. During work: Write to daily logs only (`memory/YYYY-MM-DD.md`)
|
|
161
|
+
3. Never write directly to `MEMORY.md`
|
|
162
|
+
4. Flag promotable items: `[PROMOTABLE] <summary>`
|
|
163
|
+
|
|
164
|
+
### Anti-Patterns
|
|
165
|
+
- Sub-agents spawning sub-agents (max depth: 1)
|
|
166
|
+
- Passing {{AGENT_NAME}}'s identity to sub-agents
|
|
167
|
+
- Generic instructions ("do your best")
|
|
168
|
+
- Spawning without checking native tools first
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## File Path Rule (MANDATORY)
|
|
173
|
+
**Never use `~/` in write/edit/exec tools.**
|
|
174
|
+
Always use absolute paths: `{{WORKSPACE_PATH}}/...`
|
|
175
|
+
|
|
176
|
+
## Config File Modification Protocol
|
|
177
|
+
Before modifying config files:
|
|
178
|
+
1. Read entire file first
|
|
179
|
+
2. Search for existing keys
|
|
180
|
+
3. Verify section location
|
|
181
|
+
4. Never infer — always confirm structure
|
|
182
|
+
|
|
183
|
+
## Decision Log
|
|
184
|
+
- **When**: Model changes, architecture changes, major operational decisions
|
|
185
|
+
- **Where**: `{{WORKSPACE_PATH}}/decision_log.md`
|
|
186
|
+
- **Format**: `| Date | Decision | Reason | Alternatives | Outcome |`
|
|
187
|
+
|
|
188
|
+
## Response Protocol
|
|
189
|
+
- **Conciseness**: Max 5 sentences unless structured report. Style details → `SOUL.md`.
|
|
190
|
+
- **Error Handling**: On tool failure, report the specific error and a proposed fix in 1 sentence.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# BOOTSTRAP.md - Session Startup Protocol
|
|
2
|
+
|
|
3
|
+
## 0. Skill Graph Entry (main agent only)
|
|
4
|
+
Main agent ({{AGENT_NAME}}) entry point:
|
|
5
|
+
- `{{OPENCLAW_PATH}}/skill-graph/_agent-{{AGENT_NAME}}/SKILL.md`
|
|
6
|
+
|
|
7
|
+
Follow wikilinks to load domain knowledge as needed.
|
|
8
|
+
|
|
9
|
+
## 1. Context Restoration
|
|
10
|
+
Upon waking up in a new session, the agent MUST:
|
|
11
|
+
1. Read `BOOTSTRAP.md` to understand current protocols.
|
|
12
|
+
2. Read `MEMORY.md` to restore Core Missions and System Identity — especially `§ Pending Items`.
|
|
13
|
+
3. Search for the latest file in `memory/` (e.g., `memory/YYYY-MM-DD_checkpoint.md`) to sync with the last active state.
|
|
14
|
+
4. Check latest daily log in `memory/` for pending tasks and Next Action.
|
|
15
|
+
5. **[SessionStart Hook]** Check current time and apply time-slot logic:
|
|
16
|
+
- 02:00–04:59 → warn + surface Pending Top1 only
|
|
17
|
+
- 22:00–01:59 → surface High Pending + suggest 1 focus item
|
|
18
|
+
- Other hours → standard briefing or silent load
|
|
19
|
+
|
|
20
|
+
## 2. Initial Health Check
|
|
21
|
+
Immediately run a background check to:
|
|
22
|
+
- Verify token usage via `session_status`.
|
|
23
|
+
- Check browser tab status if applicable.
|
|
24
|
+
|
|
25
|
+
## 3. Tool Preparation
|
|
26
|
+
- Ensure `profile="openclaw"` is ready for headless tasks.
|
|
27
|
+
- If external tools are connected, verify path accessibility in `TOOLS.md`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# HEARTBEAT.md - Active Task Monitoring
|
|
2
|
+
|
|
3
|
+
## Recursive Health Check
|
|
4
|
+
1. **Memory Persistence**: Ensure all `[SAVE]` requests from the previous hour are committed to `memory/`.
|
|
5
|
+
2. **Context Management (Auto-Compaction)**:
|
|
6
|
+
- **Cron (every 2 hours)**: `scripts/memory_maintenance.sh` auto-runs
|
|
7
|
+
- 7+ day daily logs → `memory/archive/YYYY-MM/`
|
|
8
|
+
- Checkpoint/heartbeat dedup cleanup
|
|
9
|
+
- New checkpoint creation (only if none in last hour)
|
|
10
|
+
- **Line count trigger**: MEMORY.md Anti-Bloat Rules
|
|
11
|
+
- **Sub-agents**: Follow `AGENTS.md` § Sub-Agent Policy → Sub-Agent Memory Rules
|
|
12
|
+
3. **Pending Items Scan**: Scan `MEMORY.md` § Pending Items:
|
|
13
|
+
- High priority items stale >48 hours → alert user
|
|
14
|
+
- "User action needed" items stale >3 days → reminder
|
|
15
|
+
- Completed items → remove from table immediately
|
|
16
|
+
- Over 15 items → move low-priority to daily log
|
|
17
|
+
4. **Agent Score**: Run `npx agentlinter` daily. Report if score drops below 85.
|
|
18
|
+
|
|
19
|
+
## System Health Checks (Cron-Automated)
|
|
20
|
+
5. **Disk Space**: <20GB warning, <10GB critical (weekly Sunday 02:00)
|
|
21
|
+
6. **Cron Health**: `jobs.json` consecutiveErrors > 2 → alert (every 30min)
|
|
22
|
+
7. **Gateway Health**: Error log review, last 24 hours (daily 23:00)
|
|
23
|
+
8. **Memory Synthesis**: Weekly daily notes → MEMORY.md synthesis (Sunday 03:40)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# MEMORY.md — {{AGENT_NAME}} Memory System
|
|
2
|
+
|
|
3
|
+
## 🎯 Missions
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## 📋 Active Projects
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## 🔁 Pending Items
|
|
10
|
+
|
|
11
|
+
| Priority | Item | Owner | Deadline | Status |
|
|
12
|
+
|----------|------|-------|----------|--------|
|
|
13
|
+
| | | | | |
|
|
14
|
+
|
|
15
|
+
## 🧠 Lessons Learned
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 🗂 Memory Protocol
|
|
19
|
+
|
|
20
|
+
### Hierarchy
|
|
21
|
+
1. **MEMORY.md** (this file): Core missions, active projects, pending items, lessons. Permanent.
|
|
22
|
+
2. **memory/YYYY-MM-DD.md**: Daily logs. Auto-generated by session_indexer. Archived after 7 days.
|
|
23
|
+
3. **memory/archive/**: Compressed older logs, organized by month.
|
|
24
|
+
|
|
25
|
+
### Rules
|
|
26
|
+
- **Write**: Only {{AGENT_NAME}} writes to this file (with user approval for permanent items).
|
|
27
|
+
- **Promotion**: Daily log items → MEMORY.md only when confirmed as stable patterns (3+ occurrences).
|
|
28
|
+
- **Anti-Bloat**: MEMORY.md max 200 lines. Pending Items max 15 rows. Overflow → daily log.
|
|
29
|
+
- **Sub-agents**: Write to daily logs only. Flag promotable items with `[PROMOTABLE]`.
|
|
30
|
+
- **Weekly Synthesis**: Sunday auto-job reviews daily logs → proposes MEMORY.md updates.
|
|
31
|
+
|
|
32
|
+
### Checkpoint Protocol
|
|
33
|
+
- Auto-created every 2 hours by maintenance cron
|
|
34
|
+
- Contains: active context snapshot, open loops, next actions
|
|
35
|
+
- Location: `memory/YYYY-MM-DD_checkpoint.md`
|