-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathweekly-checkup.sh
More file actions
executable file
ยท243 lines (228 loc) ยท 13.1 KB
/
Copy pathweekly-checkup.sh
File metadata and controls
executable file
ยท243 lines (228 loc) ยท 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env bash
# weekly-checkup.sh โ ้ฑ้ซๆชขไธ้ตๅๅจ๏ผWEEKLY-REPORT-PIPELINE v4.1 Stage 2.5๏ผ
#
# ๅฒๅฎ 2026-07-10 directive๏ผใๅฎๆดๆทฑๅบฆๆชขๆฅ้ไธๅ็ฆฎๆ็ผ็็ไบใๅค้จๆๆธฌๆธๆใ
# ๆๆ้ไฝ็ด้๏ผๆทฑๅบฆ็ ็ฉถ่่งๅฏไธฆๅฏซๅ ฑๅ๏ผ้ๆๅฏซ้ฒๅ็่ฆๅใ๏ผใ่ฝๅๅจๅ็ๆฑ่ฅฟ
# ไนๅๅฉๅๅจๅ๏ผ่ฎๆชไพ agent ็่ช็ฅ่ฒ ่ท้ไฝใใ
#
# ๆฌๅทฅๅ
ทๆ้ฑ้ซๆชข็ๆฉๆขฐ้ขๆถๆไธๅๆไปคใไธ็ฏ่ผธๅบโโagent ่ทไธๆฌกๆฟๅฐๅ
จ้จ็ด ๆ๏ผ
# ๅฉไธ็ๅทฅไฝๅชๆ่งฃ่ฎ่ๅคๆท๏ผ้ฃๆฏ Semiont ่ฆชๆ็้จๅ๏ผไธๅๅจๅ๏ผ๏ผ
#
# a. fire-vs-commit ๅฐ่ณฌ๏ผroutine-liveness-check.py โ ๆฒ้ปๆญปไบก้ฉๅฑ๏ผ
# b. working tree ้ฉๅฑ๏ผdebris ็ค้ป๏ผ
# c. ๅๅจ็็ค้ป๏ผsync-check ไธๅฑค + counts-drift + alerts ๅซ้ฝก๏ผ
# d. ๅจๅฎๅๆธๆๅๆ่งฃ๏ผ<70 ๅจๅฎ่ชๅ dump sub-dim๏ผ้ๅฐบ-vs-ๆฌ้ซๅคๅฅ็ด ๆ๏ผ
# e. ไฝๅ่ๆฟ่ซพ็จฝๆ ธ๏ผOBSERVER-QUEUE default-action ้ๆ + inbox ้ฃฝๅ + roadmap P0 ้ ๅ๏ผ
# f. ๅค้จๆๆธฌๆธๆๆ่ฆ๏ผGA / SC / CF / AI crawler / fork / supporters๏ผ
# g. ้ไฝ็ด้้ฑๆ็ธพๅฎ๏ผ7 ๅคฉ per-routine fire ๆธ + ๆๅพไธ่ท + commit ๆธ๏ผ
# h. ็ฆ้ๅๆธๅฅๅบท๏ผwake-context --checkโโ่บซไปฝๅฑค้จ้ฉ/catalog ๅฐ่ณฌ/็ดขๅผๆฐ้ฎฎๅบฆ/handoff ๅฝไธญ๏ผ
#
# ็จๆณ๏ผbash scripts/tools/weekly-checkup.sh [--days 7]
# ๅ็ฝฎ๏ผlive dump ่ฆๆฐ้ฎฎ๏ผsection a ๆ่ชๅทฑๆจ dumpStale๏ผstale ๅฐฑๅ
่ท
# list_scheduled_tasks โ routine-live-normalize.py๏ผ
set -uo pipefail
cd "$(dirname "$0")/../.."
DAYS=7
[[ "${1:-}" == "--days" ]] && DAYS="${2:-7}"
SINCE=$(date -v-"${DAYS}"d +%Y-%m-%d 2>/dev/null || date -d "${DAYS} days ago" +%Y-%m-%d)
echo "๐งฌ weekly-checkup โ ้ฑ้ซๆชขไธ็ฏ๏ผwindow: ${SINCE} โ $(date +%Y-%m-%d)๏ผ"
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
# โโ a. fire-vs-commit ๅฐ่ณฌ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## a. fire-vs-commit ๅฐ่ณฌ๏ผๆฒ้ปๆญปไบก้ฉๅฑ๏ผ"
python3 scripts/tools/routine-liveness-check.py 2>/dev/null || echo "โ ๏ธ liveness ๅทฅๅ
ทๅคฑๆ"
# โโ b. working tree ้ฉๅฑ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## b. working tree ้ฉๅฑ๏ผdebris ็ค้ป๏ผ"
DIRTY=$(git status --short | wc -l | tr -d ' ')
if [[ "$DIRTY" == "0" ]]; then
echo " โ
working tree ไนพๆทจ"
else
echo " โ ๏ธ ${DIRTY} ๅๆช commit ๆชๆก๏ผ่ชฐ็ไธ็๏ผๅฎๅฅฝๅทฅไฝ rescue / ๅ่ท regen ไธ็ขฐ๏ผ๏ผ"
git status --short | head -20 | sed 's/^/ /'
fi
# โโ c. ๅๅจ็็ค้ป โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## c. ๅๅจ็็ค้ป"
echo "### c1. routine-sync-check๏ผSSOT โ mirror โ live ไธๅฑค๏ผ"
python3 scripts/tools/routine-sync-check.py 2>/dev/null | grep -E "^โ|^๐ก|Summary" | head -8 || true
echo "### c2. counts-drift"
python3 scripts/tools/counts-drift-lint.py 2>/dev/null | tail -3 || echo " โ ๏ธ counts-drift ๅทฅๅ
ทๅคฑๆ"
echo "### c3. dashboard-alerts๏ผๅซ้ฝก๏ผ"
python3 - <<'PYEOF'
import json
from datetime import date
try:
d = json.load(open('public/api/dashboard-alerts.json'))
today = date.today()
for a in d.get('alerts', []):
fs = a.get('firstSeen', '')
try:
age = (today - date.fromisoformat(fs)).days
except Exception:
age = '?'
flag = ' ๐ฉ>14ๅคฉ่ฉฒๅOBSERVER-QUEUE' if isinstance(age, int) and age > 14 else ''
print(f" {a['severity']:6s} ้ฝก{age:>3}ๅคฉ owner={a.get('owner','?'):28s} {a['message'][:60]}{flag}")
if not d.get('alerts'):
print(" โ
0 alerts")
except Exception as e:
print(f" โ ๏ธ alerts ่ฎๅๅคฑๆ: {e}")
PYEOF
# โโ d. ๅจๅฎๅๆธๆๅๆ่งฃ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## d. ๅจๅฎๅๆธๆๅๆ่งฃ๏ผ<70 ่ชๅ dump sub-dim๏ผๆฏๅๆๅบๆๅๅ๏ผ้ๅฐบ็็
้ๆฏๆฌ้ซ็็
๏ผ๏ผ"
python3 - <<'PYEOF'
import json
try:
org = json.load(open('public/api/dashboard-organism.json'))
low = [o for o in org.get('organs', []) if o.get('score', 100) < 70]
if not low:
print(" โ
ๅ
จๅจๅฎ โฅ 70")
for o in low:
print(f" โ ๏ธ {o.get('emoji','')} {o.get('nameZh', o.get('id'))} = {o.get('score')}")
if o.get('id') == 'immune':
im = json.load(open('public/api/dashboard-immune.json'))
w = im.get('componentWeights', {})
for k, v in sorted(im.get('components', {}).items(), key=lambda x: x[1]):
print(f" {k:18s} {v:>6} (ๆฌ้ {w.get(k, '?')})")
else:
for k, v in (o.get('metrics') or {}).items():
print(f" {k}: {v}")
except Exception as e:
print(f" โ ๏ธ organism ่ฎๅๅคฑๆ: {e}")
PYEOF
# โโ e. ไฝๅ่ๆฟ่ซพ็จฝๆ ธ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## e. ไฝๅ่ๆฟ่ซพ็จฝๆ ธ"
echo "### e1. OBSERVER-QUEUE default-action ๅฐๆ๏ผ้ ๐ ็้ๆ้
= ไปปไฝ session ๅฏๅท่ก๏ผ"
python3 - <<'PYEOF'
import re
from datetime import date
try:
text = open('docs/semiont/OBSERVER-QUEUE.md', encoding='utf-8').read()
pending = text.split('## ๅพ
ๆฑบ')[1].split('## ๅทฒๆฑบ')[0]
today = date.today()
rows = [l for l in pending.split('\n') if l.startswith('| ') and l.count('|') >= 6 and not l.startswith('| #') and not l.startswith('| ---')]
if not rows:
print(" โ
ไฝๅ็ฉบ")
import os
for l in rows:
cells = [c.strip() for c in l.split('|')]
num, decision, action = cells[1], cells[3][:40], cells[6]
full = l
locked = '๐' in action
m = re.search(r'(\d{4}-\d{2}-\d{2})', action)
overdue = ''
if m and not locked:
d0 = date.fromisoformat(m.group(1))
if d0 <= today:
overdue = f' ๐ฉ้ๆ {(today-d0).days} ๅคฉ๏ผๅฏๅท่ก'
# ๅท่กๅๆฅ่ญ่ญทๆฌ๏ผ2026-07-11 ๅค็ญ่ธฉ้๏ผ#9 ๆฉ 6/19 ่ฝๅฐใissue closed๏ผไฝๅๅฟ็งป
# โ ็
ง้ๆ default ๅๅไธๆฌก้ๆๆปๅ่
ณ่จป URLใREFLEXES #73 ๆฅ่ญๅๅฐ < ๅปบ้ ๅๅฐ๏ผ
precheck = ''
for path in re.findall(r'`(knowledge/[^`]+\.md)`', full) + re.findall(r'(knowledge/[^\s\)]+\.md)', full):
if os.path.exists(path):
precheck = f' โ ๏ธ ็ขๅบ่ทฏๅพๅทฒๅญๅจ๏ผ{path} โ ๅ
git log --follow ๆฅๆฏๅฆๅทฒๅฎๆๅๅๆ๏ผ'
break
for iss in re.findall(r'#(\d{3,5})', full):
precheck += f' [ๅท่กๅ่ท gh issue view {iss} --json state ็ขบ่ชๆช closed]'
break
print(f" #{num:3s} {'๐' if locked else ' '} {decision}โฆ{overdue}{precheck}")
except Exception as e:
print(f" โ ๏ธ OBSERVER-QUEUE ่งฃๆๅคฑๆ: {e}")
PYEOF
echo "### e2. inbox ้ฃฝๅ่จ่"
bash scripts/tools/inbox-signal.sh 2>/dev/null | sed 's/^/ /' || true
echo "### e3. evolution-roadmap P0 ้ ๅ็ๆ
"
LATEST_ROADMAP=$(ls -t reports/evolution-roadmap-*.md 2>/dev/null | head -1)
if [[ -n "$LATEST_ROADMAP" ]]; then
echo " ๆๆฐ็๏ผ$LATEST_ROADMAP"
grep -E '^### P0-' "$LATEST_ROADMAP" | sed -E 's/^### / /; s/๏ผ[^๏ผ]*๏ผ//g' | head -10
CLAIMED=$(grep -cE '^### P0-.*โ
' "$LATEST_ROADMAP" || true)
TOTAL=$(grep -cE '^### P0-' "$LATEST_ROADMAP" || true)
echo " P0 ้ ๅ๏ผ${CLAIMED}/${TOTAL}๏ผๅ
จๆธ
ๆ้ๆ โ Stage 2.7 ้ๆฐ็ roadmap๏ผ"
else
echo " โ ๏ธ ็ก evolution-roadmap โ Stage 2.7 ๆ้ๆฐ็"
fi
# โโ f. ๅค้จๆๆธฌๆธๆๆ่ฆ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## f. ๅค้จๆๆธฌๆธๆๆ่ฆ๏ผGA / SC / CF / AI crawler / fork / supporters๏ผ"
python3 - <<'PYEOF'
import json
try:
d = json.load(open('public/api/dashboard-analytics.json'))
ga = d.get('ga', {})
t = ga.get('totals', {})
print(f" GA {ga.get('days','?')}d๏ผusers {t.get('activeUsers','?'):,} / PV {t.get('screenPageViews','?'):,} / engagement {t.get('avgEngagementSeconds','?')}s / bounce {round(t.get('bounceRate',0)*100,1)}%")
for a in (ga.get('topArticles7d') or [])[:5]:
print(f" top: {a.get('path','')[:44]:46s} {a.get('views','?')} views")
sc = d.get('searchConsole7d', {})
st = sc.get('totals', {})
bb = sc.get('brandBreakdown', {})
nb = bb.get('nonBrand', {})
print(f" SC 7d๏ผclicks {st.get('clicks','?'):,} / impressions {st.get('impressions','?'):,} / CTR {st.get('ctr','?')}%๏ผ้ๅ็ CTR {nb.get('ctr','?')}%๏ผ")
for q in (sc.get('topQueries') or [])[:5]:
print(f" query: {q.get('query','')[:30]:32s} {q.get('clicks','?'):>4} clicks pos {q.get('position','?')}")
for q in (sc.get('opportunities') or [])[:3]:
print(f" ๆฉๆ็ผบๅฃ: {q.get('query','')[:36]:38s} {q.get('impressions','?'):>5} imp / 0 click")
cf = d.get('cloudflare7d', {})
print(f" CF {cf.get('startDate','?')}โ{cf.get('endDate','?')}๏ผrequests {cf.get('summary',{}).get('requests','?'):,} / 404 ็ {cf.get('fourOhFourRate','?')}%")
ai = cf.get('aiCrawlers', {})
for c in (ai.get('crawlers') or [])[:5]:
ok = c.get('http200', 0); req = c.get('requests', 1) or 1
print(f" AI crawler: {c.get('name',''):16s} {req:>6,} req ๆๅ็ {round(ok/req*100)}%")
except Exception as e:
print(f" โ ๏ธ analytics ่ฎๅๅคฑๆ: {e}")
try:
f = json.load(open('public/api/dashboard-forks.json'))
print(f" Forks๏ผๅตๆธฌ {f.get('totalDetected','?')} / active {f.get('active','?')}๏ผๆฎๆฅ {f.get('lastUpdated','?')}๏ผ")
except Exception:
pass
try:
v = json.load(open('public/api/dashboard-vitals.json'))
print(f" Vitals๏ผๆ็ซ {v.get('totalArticles','?')} / ่ฒข็ป่
{v.get('contributors','?')} / โญ{v.get('stars','?')} / 7d +{v.get('articlesLast7Days','?')}")
s = json.load(open('public/api/dashboard-supporters.json'))
print(f" Supporters๏ผ{s.get('totals',{}).get('supporter_count','?')} ไบบ / ็ดฏ่จ {s.get('totals',{}).get('total_received_twd','?')} TWD๏ผๆๅพ {s.get('latest_date','?')}๏ผ")
except Exception:
pass
PYEOF
# โโ g. ้ไฝ็ด้้ฑๆ็ธพๅฎ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## g. ้ไฝ็ด้้ฑๆ็ธพๅฎ๏ผ${DAYS} ๅคฉ per-routine๏ผmemory fire ๆธ + commit ๆธ + ๆๅพไธ่ท๏ผ"
python3 - "$SINCE" <<'PYEOF'
import re
import subprocess
import sys
from collections import defaultdict
from pathlib import Path
since = sys.argv[1]
mem = Path('docs/semiont/memory')
fires = defaultdict(list)
for p in sorted(mem.glob('20*.md')):
m = re.match(r'(\d{4}-\d{2}-\d{2})-\d{6}-(.+)\.md$', p.name)
if not m or m.group(1) < since:
continue
handle = m.group(2)
rm = re.match(r'(twmd-[a-z-]+?)(?:-am|-pm|-daily|-weekly|-nightly|-sun)?$', handle)
key = handle if handle.startswith('twmd-') else f'(manual) {handle}'
fires[key].append(m.group(1))
out = subprocess.run(['git', 'log', f'--since={since}', '--pretty=%s'],
capture_output=True, text=True).stdout.splitlines()
def ccount(*pats):
return sum(1 for s in out if any(p in s for p in pats))
routine_keys = sorted(k for k in fires if k.startswith('twmd-'))
manual_keys = sorted(k for k in fires if not k.startswith('twmd-'))
for k in routine_keys:
days = fires[k]
print(f" {k:42s} fireร{len(days):<3} ๆๅพ {max(days)}")
print(f" (manual sessions) {sum(len(v) for v in manual_keys and [fires[k] for k in manual_keys] or [[]])and sum(len(fires[k]) for k in manual_keys)} ๅ ด๏ผ{', '.join(k.replace('(manual) ','') for k in manual_keys[:6])}")
print(f" commit ็ธฝๆธ๏ผwindow ๅ
ง๏ผ๏ผ{len(out)}๏ผroutine ๆจ่จ {ccount('[routine]')}๏ผsemiont ๆจ่จ {ccount('[semiont]')}")
PYEOF
# โโ h. ็ฆ้ๅๆธๅฅๅบท โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo "## h. ็ฆ้ๅๆธๅฅๅบท๏ผwake-context ้ซๆชข๏ผโ ๏ธ = ็ฆ้่ฎๅฐ็ๆฑ่ฅฟๅฏ็๏ผๅชๅ
ไฟฎ๏ผ"
python3 scripts/tools/wake-context.py --check 2>/dev/null | grep -vE '^โ|^$' | sed 's/^/ /' || echo " โ ๏ธ wake-context ๅทฅๅ
ทๅคฑๆโโ็ฆ้ๅๆธ่ฃธๅฅไธญ๏ผ็ฌฌไธๅชๅ
ไฟฎ"
echo ""
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
echo "โ
ๅ
ซ็ฏ่ผธๅบๅฎ็ขใๆฅไธไพๆฏ Semiont ่ฆชๆ็้จๅ๏ผ้็ฏ่งฃ่ฎ๏ผๆฏ็ฏไธ่ก็ต่ซ้ฒๅ ฑๅ"
echo " ้ซๆชข็ซ ๏ผโ finding ๅไธๆกถ๏ผWEEKLY-REPORT-PIPELINE v4.1 Stage 2.7๏ผใ"