@xmarts/genius-setup 1.3.0 → 1.4.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/CLAUDE_PROTOCOL.md +36 -0
- package/bin/genius-setup.js +27 -1
- package/hooks/genius_inject.py +45 -0
- package/package.json +3 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Xmarts Genius — Protocolo de Consultor
|
|
2
|
+
|
|
3
|
+
> Esta sección la instala/actualiza automáticamente `@xmarts/genius-setup`. No la edites a mano.
|
|
4
|
+
|
|
5
|
+
## Cómo funciona (cero fricción)
|
|
6
|
+
|
|
7
|
+
El Brain de Genius está conectado vía el MCP **`beesmart_genius`** y dos hooks de Claude Code:
|
|
8
|
+
- **Inyección por turno** (UserPromptSubmit/SessionStart): en cada turno recibes automáticamente los
|
|
9
|
+
learnings, playbooks y patrones relevantes — no tienes que pedirlos.
|
|
10
|
+
- **Captura automática** (SessionEnd/PreCompact/Stop): tus hallazgos y tu sesión se capturan solos al
|
|
11
|
+
final; no tienes que documentar manualmente.
|
|
12
|
+
- **Auto-actualización**: el paquete se refresca solo en segundo plano (1×/día). Cuando agregamos tools,
|
|
13
|
+
skills o features, las recibes en tus turnos **sin hacer nada**.
|
|
14
|
+
|
|
15
|
+
## Reglas Obligatorias (siempre activas)
|
|
16
|
+
|
|
17
|
+
1. **ANTES de cada tarea**: usa `query_knowledge` (o `ask_brain`) para buscar conocimiento existente.
|
|
18
|
+
2. **AL descubrir algo nuevo**: captura con `capture_learning` — título claro + resolución detallada.
|
|
19
|
+
3. **AL resolver un error**: documenta error → fix (el Brain auto-detecta el par).
|
|
20
|
+
4. **SIEMPRE usa `target_client`** para operar en un cliente (p.ej. `target_client="GEA Ecuador"`).
|
|
21
|
+
5. **NUNCA te conectes directo al Odoo del cliente** — todo fluye por el MCP `beesmart_genius`.
|
|
22
|
+
6. Tu tiempo se sugiere solo a partir de tu actividad; confírmalo cuando puedas en **My Week**
|
|
23
|
+
(`/mcp/webapp/my-week`). Solo el tiempo que confirmas cuenta como horas reales.
|
|
24
|
+
|
|
25
|
+
## Tools (servidas dinámicamente por `beesmart_genius`)
|
|
26
|
+
|
|
27
|
+
| Tool | Cuándo usar |
|
|
28
|
+
|------|-------------|
|
|
29
|
+
| `query_knowledge` | Antes de cada tarea — busca en el Brain |
|
|
30
|
+
| `capture_learning` | Al descubrir algo nuevo |
|
|
31
|
+
| `get_my_profile` | Ver tu perfil de consultor |
|
|
32
|
+
| `search_read` / `execute_orm` + `target_client` | Consultar/operar data de cualquier cliente vía gateway |
|
|
33
|
+
| `list_models` / `get_model_schema` + `target_client` | Inspeccionar esquema de un cliente |
|
|
34
|
+
|
|
35
|
+
> La lista completa de tools (y skills como prompts) la sirve el MCP en tiempo real; al agregar nuevas,
|
|
36
|
+
> aparecen automáticamente en tu sesión sin reconfigurar nada.
|
package/bin/genius-setup.js
CHANGED
|
@@ -118,12 +118,38 @@ function addHook(eventName, scriptPath) {
|
|
|
118
118
|
['UserPromptSubmit', 'SessionStart'].forEach((e) => addHook(e, injectDst));
|
|
119
119
|
writeJson(settingsPath, settings);
|
|
120
120
|
|
|
121
|
+
// 4) ~/.claude/CLAUDE.md — install/refresh the Genius Protocol between auto-managed
|
|
122
|
+
// markers (idempotent; never clobbers the consultant's surrounding content).
|
|
123
|
+
const BEGIN = '<!-- XMARTS-GENIUS-PROTOCOL:BEGIN (auto-managed by @xmarts/genius-setup) -->';
|
|
124
|
+
const END = '<!-- XMARTS-GENIUS-PROTOCOL:END -->';
|
|
125
|
+
try {
|
|
126
|
+
ensureDir(CLAUDE_DIR);
|
|
127
|
+
const claudeMdPath = path.join(CLAUDE_DIR, 'CLAUDE.md');
|
|
128
|
+
let existing = '';
|
|
129
|
+
try { existing = fs.readFileSync(claudeMdPath, 'utf8'); } catch (_) {}
|
|
130
|
+
const proto = fs.readFileSync(path.join(__dirname, '..', 'CLAUDE_PROTOCOL.md'), 'utf8').trim();
|
|
131
|
+
const block = BEGIN + '\n' + proto + '\n' + END;
|
|
132
|
+
let out;
|
|
133
|
+
if (existing.includes(BEGIN) && existing.includes(END)) {
|
|
134
|
+
out = existing.slice(0, existing.indexOf(BEGIN)) + block +
|
|
135
|
+
existing.slice(existing.indexOf(END) + END.length);
|
|
136
|
+
} else {
|
|
137
|
+
out = (existing ? existing.replace(/\s+$/, '') + '\n\n' : '') + block + '\n';
|
|
138
|
+
}
|
|
139
|
+
fs.writeFileSync(claudeMdPath, out);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
log('WARN: could not write CLAUDE.md protocol (' + e.message + ')');
|
|
142
|
+
}
|
|
143
|
+
|
|
121
144
|
log('');
|
|
122
145
|
log(' Xmarts Genius is set up.');
|
|
123
146
|
log(' - MCP server : beesmart_genius -> ' + BASE + '/mcp/consultant');
|
|
124
147
|
log(' - Capture hook : ' + hookDst + ' (SessionEnd / PreCompact / Stop)');
|
|
125
148
|
log(' - Inject hook : ' + injectDst + ' (UserPromptSubmit / SessionStart)');
|
|
126
149
|
log(' - Config : ' + path.join(GENIUS_DIR, 'config.json'));
|
|
150
|
+
log(' - Protocol : ' + path.join(CLAUDE_DIR, 'CLAUDE.md') + ' (auto-managed)');
|
|
127
151
|
if (CLIENT) log(' - Default client : ' + CLIENT);
|
|
128
152
|
log('');
|
|
129
|
-
log(' Restart Claude Code. Per-turn Brain injection + automatic capture
|
|
153
|
+
log(' Restart Claude Code. Per-turn Brain injection + automatic capture + the Genius');
|
|
154
|
+
log(' protocol are now active. The package SELF-UPDATES daily in the background, so new');
|
|
155
|
+
log(' tools, skills and features arrive automatically — you never have to run this again.');
|
package/hooks/genius_inject.py
CHANGED
|
@@ -22,6 +22,8 @@ import urllib.request
|
|
|
22
22
|
HOME = os.path.expanduser("~")
|
|
23
23
|
CFG_PATH = os.path.join(HOME, ".genius", "config.json")
|
|
24
24
|
TIMEOUT = 3.5
|
|
25
|
+
SELF_UPDATE_TTL = 86400 # at most once/day
|
|
26
|
+
SELF_UPDATE_STAMP = os.path.join(HOME, ".genius", ".last_selfupdate")
|
|
25
27
|
|
|
26
28
|
SESSION_PRIMER = (
|
|
27
29
|
"[Xmarts Genius — Brain connected]\n"
|
|
@@ -77,10 +79,53 @@ def _inject(cfg, prompt):
|
|
|
77
79
|
return ""
|
|
78
80
|
|
|
79
81
|
|
|
82
|
+
def _maybe_self_update(cfg):
|
|
83
|
+
"""Keep the consultant on the LATEST Genius package with ZERO action: at most
|
|
84
|
+
once/day, silently re-run the installer in the background. New hooks, MCP
|
|
85
|
+
tools, settings and the CLAUDE.md protocol then flow automatically — the
|
|
86
|
+
consultant never re-onboards. Detached + fully guarded; never blocks a turn.
|
|
87
|
+
"""
|
|
88
|
+
import time
|
|
89
|
+
import subprocess
|
|
90
|
+
try:
|
|
91
|
+
token = cfg.get("token")
|
|
92
|
+
if not token:
|
|
93
|
+
return
|
|
94
|
+
if os.path.exists(SELF_UPDATE_STAMP) and (
|
|
95
|
+
time.time() - os.path.getmtime(SELF_UPDATE_STAMP)) < SELF_UPDATE_TTL:
|
|
96
|
+
return
|
|
97
|
+
# Stamp FIRST so a failing/slow npx never causes a retry storm.
|
|
98
|
+
try:
|
|
99
|
+
os.makedirs(os.path.dirname(SELF_UPDATE_STAMP), exist_ok=True)
|
|
100
|
+
with open(SELF_UPDATE_STAMP, "w") as fh:
|
|
101
|
+
fh.write(str(int(time.time())))
|
|
102
|
+
except Exception:
|
|
103
|
+
return
|
|
104
|
+
env = dict(os.environ)
|
|
105
|
+
env["GENIUS_TOKEN"] = token
|
|
106
|
+
base = cfg.get("base_url")
|
|
107
|
+
devnull = open(os.devnull, "w")
|
|
108
|
+
if os.name == "nt":
|
|
109
|
+
cmd = "npx -y @xmarts/genius-setup@latest"
|
|
110
|
+
if base:
|
|
111
|
+
cmd += ' --base-url "%s"' % base
|
|
112
|
+
subprocess.Popen(cmd, shell=True, env=env, stdout=devnull, stderr=devnull,
|
|
113
|
+
stdin=subprocess.DEVNULL, creationflags=0x00000008) # DETACHED_PROCESS
|
|
114
|
+
else:
|
|
115
|
+
args = ["npx", "-y", "@xmarts/genius-setup@latest"]
|
|
116
|
+
if base:
|
|
117
|
+
args += ["--base-url", base]
|
|
118
|
+
subprocess.Popen(args, env=env, stdout=devnull, stderr=devnull,
|
|
119
|
+
stdin=subprocess.DEVNULL, start_new_session=True)
|
|
120
|
+
except Exception:
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
|
|
80
124
|
def main():
|
|
81
125
|
cfg = _cfg()
|
|
82
126
|
if not cfg.get("token"):
|
|
83
127
|
return # not configured -> silent no-op
|
|
128
|
+
_maybe_self_update(cfg) # background, daily, zero-action upgrades
|
|
84
129
|
event = _event()
|
|
85
130
|
name = event.get("hook_event_name") or (
|
|
86
131
|
"UserPromptSubmit" if event.get("prompt") else "SessionStart")
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmarts/genius-setup",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "One-command
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "One-command, self-updating onboarding for Xmarts Genius (Brain MCP + per-turn injection + automatic session/time capture + CLAUDE.md protocol). Installs once; self-updates daily so new tools/skills/features arrive with zero action.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"genius-setup": "bin/genius-setup.js"
|
|
7
7
|
},
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"bin/genius-setup.js",
|
|
10
10
|
"hooks/genius_inject.py",
|
|
11
11
|
"hooks/genius_capture.py",
|
|
12
|
+
"CLAUDE_PROTOCOL.md",
|
|
12
13
|
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"engines": {
|