opencode-team-memory 1.1.0 → 1.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/CHANGELOG.md +7 -0
- package/bin/omo-resume +147 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
- Add `omo-resume` CLI — auto-restore team context on opencode launch
|
|
6
|
+
- Three modes: `--always`, `--ask` (default), `--never`
|
|
7
|
+
- Reads latest role state from `.omo/team-memory/`
|
|
8
|
+
- Generates continuation prompt and passes to `opencode run`
|
|
9
|
+
|
|
3
10
|
## 1.1.0
|
|
4
11
|
|
|
5
12
|
- Add `formatContinuation()` — generates role-aware continuation prompt
|
package/bin/omo-resume
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# omo-resume — 前回のチーム状態を復元して opencode を起動
|
|
3
|
+
# Usage: omo-resume [--always|--ask|--never]
|
|
4
|
+
|
|
5
|
+
set -eu
|
|
6
|
+
|
|
7
|
+
MEMORY_DIR="${OPENCODE_TEAM_MEMORY_DIR:-$(pwd)/.omo/team-memory}"
|
|
8
|
+
MODE="${OPENCODE_TEAM_CONTINUE:-ask}"
|
|
9
|
+
ROLES="engineer tester designer director"
|
|
10
|
+
|
|
11
|
+
# CLI引数でモード上書き
|
|
12
|
+
case "${1:-}" in
|
|
13
|
+
--always) MODE=always ;;
|
|
14
|
+
--ask) MODE=ask ;;
|
|
15
|
+
--never) MODE=never ;;
|
|
16
|
+
"") ;;
|
|
17
|
+
*) echo "Usage: omo-resume [--always|--ask|--never]" >&2; exit 1 ;;
|
|
18
|
+
esac
|
|
19
|
+
|
|
20
|
+
# never モード: 通常起動
|
|
21
|
+
if [ "$MODE" = "never" ]; then
|
|
22
|
+
echo "Team continuation disabled. Starting opencode normally." >&2
|
|
23
|
+
exec opencode
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# メモリ読み取り
|
|
27
|
+
latest_role=""
|
|
28
|
+
latest_time=""
|
|
29
|
+
found=0
|
|
30
|
+
for role in $ROLES; do
|
|
31
|
+
file="$MEMORY_DIR/$role/context.json"
|
|
32
|
+
[ -f "$file" ] || continue
|
|
33
|
+
found=1
|
|
34
|
+
last_updated=$(python3 -c "
|
|
35
|
+
import json,sys
|
|
36
|
+
try:
|
|
37
|
+
d=json.load(open('$file'))
|
|
38
|
+
print(d.get('last_updated',''))
|
|
39
|
+
except: pass
|
|
40
|
+
" 2>/dev/null)
|
|
41
|
+
[ -n "$last_updated" ] || continue
|
|
42
|
+
if [ -z "$latest_time" ] || [ "$last_updated" \> "$latest_time" ]; then
|
|
43
|
+
latest_time="$last_updated"
|
|
44
|
+
latest_role="$role"
|
|
45
|
+
fi
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
# メモリがない場合: 通常起動
|
|
49
|
+
if [ "$found" -eq 0 ] || [ -z "$latest_role" ]; then
|
|
50
|
+
echo "No previous team context found. Starting opencode normally." >&2
|
|
51
|
+
exec opencode
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# 復元プロンプト生成
|
|
55
|
+
prompt=$(python3 -c "
|
|
56
|
+
import json, sys
|
|
57
|
+
|
|
58
|
+
file = '$MEMORY_DIR/$latest_role/context.json'
|
|
59
|
+
with open(file) as f:
|
|
60
|
+
d = json.load(f)
|
|
61
|
+
|
|
62
|
+
decisions = '; '.join(d.get('previous_decisions', [])[-3:]) or 'none'
|
|
63
|
+
ng = d.get('ng_history', [])[-2:]
|
|
64
|
+
handoff = d.get('handoff_to', '')
|
|
65
|
+
confirmed = d.get('confirmed_scope', [])
|
|
66
|
+
excluded = d.get('excluded_scope', [])
|
|
67
|
+
|
|
68
|
+
lines = [
|
|
69
|
+
'Resume team work as $latest_role.',
|
|
70
|
+
'',
|
|
71
|
+
'## Team Continuation (omo-resume)',
|
|
72
|
+
'',
|
|
73
|
+
'### Your Role: $latest_role',
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
if handoff:
|
|
77
|
+
lines.append('### Handoff \u2192 ' + handoff)
|
|
78
|
+
|
|
79
|
+
lines.extend([
|
|
80
|
+
'### Status: ng_count=' + str(len(d.get('ng_history', []))),
|
|
81
|
+
'',
|
|
82
|
+
'### Critical Context',
|
|
83
|
+
decisions,
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
if ng:
|
|
87
|
+
lines.append('')
|
|
88
|
+
lines.append('### Recent NG Items')
|
|
89
|
+
for item in ng:
|
|
90
|
+
lines.append('- ' + item)
|
|
91
|
+
|
|
92
|
+
if confirmed:
|
|
93
|
+
lines.append('')
|
|
94
|
+
lines.append('### Confirmed Scope')
|
|
95
|
+
for s in confirmed:
|
|
96
|
+
lines.append('- ' + s)
|
|
97
|
+
|
|
98
|
+
if excluded:
|
|
99
|
+
lines.append('')
|
|
100
|
+
lines.append('### Excluded (DO NOT TOUCH)')
|
|
101
|
+
for s in excluded:
|
|
102
|
+
lines.append('- ' + s)
|
|
103
|
+
|
|
104
|
+
lines.extend([
|
|
105
|
+
'',
|
|
106
|
+
'### Instructions',
|
|
107
|
+
'1. role_memory_load(role=\"$latest_role\") to restore full context',
|
|
108
|
+
])
|
|
109
|
+
|
|
110
|
+
if handoff:
|
|
111
|
+
lines.append(\"2. Handoff target is '\" + handoff + \"'. Prepare accordingly.\")
|
|
112
|
+
if len(d.get('ng_history', [])) > 0:
|
|
113
|
+
lines.append('3. Address NG items before handoff.')
|
|
114
|
+
elif len(d.get('ng_history', [])) > 0:
|
|
115
|
+
lines.append('2. Address NG items first.')
|
|
116
|
+
|
|
117
|
+
lines.append('')
|
|
118
|
+
print('\n'.join(lines))
|
|
119
|
+
" 2>/dev/null)
|
|
120
|
+
|
|
121
|
+
if [ -z "$prompt" ]; then
|
|
122
|
+
echo "Failed to generate continuation prompt. Starting opencode normally." >&2
|
|
123
|
+
exec opencode
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# 復元プロンプトを表示
|
|
127
|
+
echo "" >&2
|
|
128
|
+
echo "========================================" >&2
|
|
129
|
+
echo " Team Continuation" >&2
|
|
130
|
+
echo "========================================" >&2
|
|
131
|
+
echo " Role: $latest_role" >&2
|
|
132
|
+
echo " Updated: $latest_time" >&2
|
|
133
|
+
echo " Mode: $MODE" >&2
|
|
134
|
+
echo "========================================" >&2
|
|
135
|
+
echo "" >&2
|
|
136
|
+
|
|
137
|
+
# ask モード: 確認
|
|
138
|
+
if [ "$MODE" = "ask" ]; then
|
|
139
|
+
printf "Resume with this context? [Y/n] " >&2
|
|
140
|
+
read -r answer
|
|
141
|
+
case "$answer" in
|
|
142
|
+
[Nn]*) echo "Starting fresh session." >&2; exec opencode ;;
|
|
143
|
+
esac
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# always / ask(確認済み): opencode を起動
|
|
147
|
+
exec opencode run "$prompt"
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-team-memory",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Persistent role-based memory for OpenCode/OmO Team Mode — survives across sessions and runs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"omo-resume": "bin/omo-resume"
|
|
9
|
+
},
|
|
7
10
|
"files": [
|
|
8
11
|
"index.ts",
|
|
9
12
|
"types.ts",
|
|
10
13
|
"memory.ts",
|
|
14
|
+
"bin/",
|
|
11
15
|
"scripts/",
|
|
12
16
|
"README.md",
|
|
13
17
|
"LICENSE",
|