-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·143 lines (114 loc) · 4 KB
/
install.sh
File metadata and controls
executable file
·143 lines (114 loc) · 4 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
#!/usr/bin/env bash
set -euo pipefail
DESKCLAW_ROOT="${HOME}/.deskclaw"
WORKSPACE="${DESKCLAW_ROOT}/nanobot/workspace"
DATA_DIR="${WORKSPACE}/meta-learning-data"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# ---------- preflight checks ----------
if [ ! -d "${DESKCLAW_ROOT}" ]; then
echo "ERROR: DeskClaw not found at ${DESKCLAW_ROOT}"
echo "Please install DeskClaw / Nobot first."
exit 1
fi
python_bin=""
for cmd in python3.12 python3.13 python3; do
if command -v "$cmd" &>/dev/null; then
ver=$("$cmd" -c 'import sys; print(sys.version_info[:2] >= (3,12))' 2>/dev/null || echo "False")
if [ "$ver" = "True" ]; then
python_bin="$cmd"
break
fi
fi
done
if [ -z "$python_bin" ]; then
echo "ERROR: Python >= 3.12 not found. Please install Python 3.12+."
exit 1
fi
echo "Using Python: $($python_bin --version)"
# ---------- venv & dependencies ----------
cd "${SCRIPT_DIR}"
if [ ! -d ".venv" ]; then
echo "Creating virtual environment..."
if command -v uv &>/dev/null; then
uv venv .venv --python "$python_bin"
else
"$python_bin" -m venv .venv
fi
fi
echo "Installing dependencies..."
if command -v uv &>/dev/null; then
uv pip install --python .venv/bin/python -e ".[mcp]"
else
.venv/bin/pip install -e ".[mcp]"
fi
# ---------- data directory & config ----------
mkdir -p "${DATA_DIR}"
if [ ! -f "${DATA_DIR}/config.yaml" ]; then
cp "${SCRIPT_DIR}/config.deskclaw.yaml" "${DATA_DIR}/config.yaml"
echo "Created config at ${DATA_DIR}/config.yaml"
else
echo "Config already exists at ${DATA_DIR}/config.yaml — skipping."
fi
# ---------- bootstrap SKILL.md ----------
SKILL_DIR="${WORKSPACE}/skills/meta-learning"
SKILL_PATH="${SKILL_DIR}/SKILL.md"
if [ ! -f "${SKILL_PATH}" ]; then
mkdir -p "${SKILL_DIR}"
"${SCRIPT_DIR}/.venv/bin/python" -c \
"from meta_learning.sync_nobot import render_bootstrap_skill_md; print(render_bootstrap_skill_md(), end='')" \
> "${SKILL_PATH}"
echo "Created bootstrap SKILL.md at ${SKILL_PATH}"
else
echo "SKILL.md already exists at ${SKILL_PATH} — skipping."
fi
# ---------- inject AGENTS.md instructions ----------
AGENTS_MD="${WORKSPACE}/AGENTS.md"
"${SCRIPT_DIR}/.venv/bin/python" -c "
from meta_learning.sync_nobot import inject_agents_md
changed = inject_agents_md('${AGENTS_MD}')
if changed:
print('Injected meta-learning instructions into ${AGENTS_MD}')
else:
print('AGENTS.md already up to date — skipping.')
"
# ---------- register MCP in config.json ----------
NANOBOT_CONFIG="${DESKCLAW_ROOT}/nanobot/config.json"
MCP_CMD="${SCRIPT_DIR}/.venv/bin/meta-learning-mcp"
"${SCRIPT_DIR}/.venv/bin/python" -c "
import json, sys
from pathlib import Path
config_path = Path('${NANOBOT_CONFIG}')
if not config_path.exists():
print('WARNING: ${NANOBOT_CONFIG} not found — skipping MCP registration.')
print('You will need to manually add the meta-learning MCP entry.')
sys.exit(0)
with open(config_path, encoding='utf-8') as f:
cfg = json.load(f)
servers = cfg.setdefault('tools', {}).setdefault('mcp_servers', {})
new_entry = {
'type': 'stdio',
'command': '${MCP_CMD}',
'args': [],
'tool_timeout': 120,
'env': {
'META_LEARNING_WORKSPACE': '${DATA_DIR}',
'META_LEARNING_CONFIG': '${DATA_DIR}/config.yaml',
'META_LEARNING_SESSIONS_ROOT': '${WORKSPACE}/sessions',
},
}
if 'meta-learning' in servers and servers['meta-learning'] == new_entry:
print('MCP already registered in config.json — skipping.')
sys.exit(0)
servers['meta-learning'] = new_entry
with open(config_path, 'w', encoding='utf-8') as f:
json.dump(cfg, f, indent=2, ensure_ascii=False)
f.write('\n')
print('Registered meta-learning MCP in ${NANOBOT_CONFIG}')
"
# ---------- done ----------
echo ""
echo "============================================================"
echo " Installation complete!"
echo "============================================================"
echo ""
echo "Restart DeskClaw / Nobot to activate the plugin."