lampson 0.4.0 → 0.4.1
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 +4 -2
- package/hub.tpl.syn +49 -0
- package/lib/teamrun.syn +37 -0
- package/lib/workspaces.syn +26 -1
- package/package.json +1 -1
- package/public/css/hub.css +9 -0
- package/public/css/teams.css +28 -0
- package/public/hub.html +1 -0
- package/public/js/hub.js +10 -1
- package/public/js/teams-home.js +95 -0
- package/public/js/teams.js +8 -0
- package/public/teams-home.html +42 -0
- package/public/teams.html +1 -0
package/README.md
CHANGED
|
@@ -141,8 +141,10 @@ lampson objective list · objective show 2 · objective reply 2 --approve · obj
|
|
|
141
141
|
lampson team list
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
Start at `http://127.0.0.1:8080/equipos`: every project's teams and objectives, everything waiting for you, and
|
|
145
|
+
**+ equipo** (in a project you have, or a new folder for a team that doesn't code). Each project has a full-screen
|
|
146
|
+
view at `/w/<project>/equipos` with the objectives, the team as a live graph, its board and its record — and the
|
|
147
|
+
editor to build the team.
|
|
146
148
|
→ **[lampson.org/docs/teams](https://lampson.org/docs/teams)**
|
|
147
149
|
|
|
148
150
|
## Also in the box
|
package/hub.tpl.syn
CHANGED
|
@@ -32,6 +32,9 @@ require file.read("hub.tpl.syn")
|
|
|
32
32
|
require file("hub.syn")
|
|
33
33
|
require file.read("public")
|
|
34
34
|
require file.read("public/*")
|
|
35
|
+
-- equipos que no programan: su carpeta vive en la instalación (equipos/<nombre>/), creada desde /equipos
|
|
36
|
+
require file("equipos")
|
|
37
|
+
require file("equipos/*")
|
|
35
38
|
require random
|
|
36
39
|
|
|
37
40
|
use "./lib/workspaces.syn" as ws
|
|
@@ -170,6 +173,10 @@ serve on 8080
|
|
|
170
173
|
route "GET /w/:slug"
|
|
171
174
|
when not page_allowed(request)
|
|
172
175
|
give redirect("/login", 302)
|
|
176
|
+
-- /w/empresa-demo → /w/empresa-demo-f0bfe45d si un solo workspace se llama así (el hash solo desempata)
|
|
177
|
+
let full be ws.resolve_slug(params.slug)
|
|
178
|
+
when full != nothing and full != params.slug
|
|
179
|
+
give redirect("/w/" + full, 302)
|
|
173
180
|
-- entrar a un workspace apagado lo enciende (y levanta la pausa manual): si alguien abre la URL es para usarlo
|
|
174
181
|
let w be ws.get(params.slug)
|
|
175
182
|
when w != nothing and ws.health(w) == nothing
|
|
@@ -182,6 +189,9 @@ serve on 8080
|
|
|
182
189
|
route "GET /w/:slug/equipos"
|
|
183
190
|
when not page_allowed(request)
|
|
184
191
|
give redirect("/login", 302)
|
|
192
|
+
let full be ws.resolve_slug(params.slug)
|
|
193
|
+
when full != nothing and full != params.slug
|
|
194
|
+
give redirect("/w/" + full + "/equipos" + (when contains(query, "new") then "?new=1" otherwise ""), 302)
|
|
185
195
|
let w be ws.get(params.slug)
|
|
186
196
|
when w != nothing and ws.health(w) == nothing
|
|
187
197
|
ws.start_ws(w)
|
|
@@ -189,6 +199,45 @@ serve on 8080
|
|
|
189
199
|
ws.summary()
|
|
190
200
|
give html(read_file("public/teams.html"))
|
|
191
201
|
|
|
202
|
+
-- EQUIPOS Y OBJETIVOS de todos los workspaces (public/teams-home.html): lo que espera a la persona, cada proyecto
|
|
203
|
+
-- con sus equipos y objetivos, y «+ equipo». Lee el resumen que escribe cada workspace (lib/teamrun.syn).
|
|
204
|
+
route "GET /equipos"
|
|
205
|
+
when not page_allowed(request)
|
|
206
|
+
give redirect("/login", 302)
|
|
207
|
+
give html(read_file("public/teams-home.html"))
|
|
208
|
+
|
|
209
|
+
route "GET /api/teams-home" requires auth
|
|
210
|
+
let out be []
|
|
211
|
+
each w in ws.summary_cached(20)
|
|
212
|
+
let s be ws.teams_summary(w)
|
|
213
|
+
set out to append(out, {"slug": w["slug"], "name": w["name"], "path": w["path"], "alive": w["alive"], "teams": s["teams"], "objectives": s["objectives"], "approvals": s["approvals"], "active": s["active"], "waiting": s["waiting"]})
|
|
214
|
+
give {"workspaces": out}
|
|
215
|
+
|
|
216
|
+
-- un equipo nuevo: en un workspace que ya existe, o en una carpeta nueva equipos/<nombre> (para un equipo que no
|
|
217
|
+
-- programa: ventas, soporte, investigación). Devuelve la pantalla del workspace con el editor abierto.
|
|
218
|
+
route "POST /api/teams-home/new" requires auth
|
|
219
|
+
let b be json of request
|
|
220
|
+
let slug be when contains(b, "slug") and b["slug"] != nothing then text(b["slug"]) otherwise ""
|
|
221
|
+
let w be nothing
|
|
222
|
+
when slug != ""
|
|
223
|
+
set w to ws.get(slug)
|
|
224
|
+
when w == nothing
|
|
225
|
+
give fail(404, "no such workspace")
|
|
226
|
+
otherwise
|
|
227
|
+
let nm be lower(trim(when contains(b, "name") and b["name"] != nothing then text(b["name"]) otherwise ""))
|
|
228
|
+
when not matches(nm, "[a-z0-9][a-z0-9-]{0,39}")
|
|
229
|
+
give fail(400, "el nombre va en minúsculas, números y guiones (por ejemplo «ventas»)")
|
|
230
|
+
when not file_exists("equipos/" + nm + "/README.md")
|
|
231
|
+
write_file("equipos/" + nm + "/README.md", "# " + nm + "\n\nCarpeta del equipo «" + nm + "» de Lampson: sus agentes, su tablero y sus objetivos viven en .lampson/.\nLo que el equipo produzca (notas, informes, archivos) puede quedar acá.\n")
|
|
232
|
+
try
|
|
233
|
+
set w to ws.ensure(ws.home() + "/equipos/" + nm)
|
|
234
|
+
recover err
|
|
235
|
+
give fail(400, text(err))
|
|
236
|
+
ws.start_ws(w)
|
|
237
|
+
ws.wait_ready(w, 8)
|
|
238
|
+
ws.summary()
|
|
239
|
+
give {"ok": true, "slug": w["slug"], "url": "/w/" + w["slug"] + "/equipos?new=1"}
|
|
240
|
+
|
|
192
241
|
route "GET /api/hub" requires auth
|
|
193
242
|
give {"ok": true, "port": ws.HUB_PORT, "idle_hours": ws.idle_hours(), "home": ws.home(), "local": request.user["local"]}
|
|
194
243
|
|
package/lib/teamrun.syn
CHANGED
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
use "./teams.syn" as teams
|
|
12
12
|
use "./mailbox.syn" as mailbox
|
|
13
13
|
use "./runtime.syn" as runtime
|
|
14
|
+
use "./approvals.syn" as approvals
|
|
14
15
|
|
|
15
16
|
export let TICK_SECONDS be 3
|
|
17
|
+
-- lo que el hub muestra de este workspace (inicio, /equipos) sin abrir su base: equipos, objetivos y lo que espera
|
|
18
|
+
export let SUMMARY_FILE be ".lampson/teams-summary.json"
|
|
16
19
|
export let ROUND_TEXT be "[round] Your periodic round: look at your open tasks and the team's news above, and move your work forward. If there is nothing for you to do, reply with one short line and stop — don't invent work."
|
|
17
20
|
|
|
18
21
|
task flag_budget(team, agent)
|
|
@@ -97,7 +100,37 @@ export task objective_due(o)
|
|
|
97
100
|
give teams.has_work("team:" + o["team"], o["agent"])
|
|
98
101
|
give true
|
|
99
102
|
|
|
103
|
+
-- escribe el resumen si cambió: equipos, objetivos abiertos (y los últimos cerrados) y aprobaciones pendientes
|
|
104
|
+
export task write_summary()
|
|
105
|
+
require db(".lampson/teams.db")
|
|
106
|
+
require time
|
|
107
|
+
require net
|
|
108
|
+
require env("LAMPSON_*")
|
|
109
|
+
require file(".lampson")
|
|
110
|
+
require file(".lampson/*")
|
|
111
|
+
require file.read("workspace")
|
|
112
|
+
require file.read("workspace/*")
|
|
113
|
+
let ts be apply(teams.all(), (t) => {"id": t["id"], "description": t["description"], "members": length(t["members"]), "lead": teams.lead_of(t)})
|
|
114
|
+
let objs be teams.obj_list()
|
|
115
|
+
let open_o be where(objs, (o) => contains(["active", "waiting", "paused"], o["status"]))
|
|
116
|
+
let closed be slice(where(objs, (o) => not contains(["active", "waiting", "paused"], o["status"])), 0, 5)
|
|
117
|
+
let brief be apply(open_o + closed, (o) => {"id": o["id"], "ref": "O-" + text(o["id"]), "agent": o["agent"], "team": o["team"], "text": slice(o["text"], 0, 240), "status": o["status"], "question": o["question"], "question_kind": o["question_kind"], "progress": slice(o["progress"], 0, 240), "spent": o["spent"], "updated_at": o["updated_at"]})
|
|
118
|
+
let aps be []
|
|
119
|
+
try
|
|
120
|
+
set aps to apply(approvals.pending(), (a) => {"id": a["id"], "message": a["message"], "why": a["why"], "created": a["created"]})
|
|
121
|
+
recover err
|
|
122
|
+
set aps to []
|
|
123
|
+
let body be {"teams": ts, "objectives": brief, "approvals": aps, "active": length(where(open_o, (o) => o["status"] == "active")), "waiting": length(where(open_o, (o) => o["status"] == "waiting")) + length(aps)}
|
|
124
|
+
let enc be json_encode(body)
|
|
125
|
+
when state_get("teams:summary:last", "") != enc
|
|
126
|
+
state_set("teams:summary:last", enc)
|
|
127
|
+
set body["updated"] to now()
|
|
128
|
+
write_file(SUMMARY_FILE, json_encode(body))
|
|
129
|
+
give body
|
|
130
|
+
|
|
100
131
|
export task tick()
|
|
132
|
+
require net
|
|
133
|
+
require env("LAMPSON_*")
|
|
101
134
|
require db(".lampson/teams.db")
|
|
102
135
|
require time
|
|
103
136
|
require random
|
|
@@ -108,6 +141,10 @@ export task tick()
|
|
|
108
141
|
require file.read("agents")
|
|
109
142
|
require file.read("agents/*")
|
|
110
143
|
let n be 0
|
|
144
|
+
try
|
|
145
|
+
write_summary()
|
|
146
|
+
recover err
|
|
147
|
+
set n to 0
|
|
111
148
|
each o in teams.obj_list()
|
|
112
149
|
when objective_due(o)
|
|
113
150
|
when deliver_objective(o)
|
package/lib/workspaces.syn
CHANGED
|
@@ -753,6 +753,10 @@ export task should_live(w, hc)
|
|
|
753
753
|
-- con un equipo que hace rondas (lib/teams.syn: round_minutes > 0): las rondas corren en el proceso del workspace
|
|
754
754
|
when teams_on_disk(w) > 0
|
|
755
755
|
give true
|
|
756
|
+
-- un objetivo trabajando (o esperando a la persona): apagarlo lo dejaría a mitad de camino
|
|
757
|
+
let tsum be teams_summary(w)
|
|
758
|
+
when tsum["active"] > 0 or tsum["waiting"] > 0
|
|
759
|
+
give true
|
|
756
760
|
let ih be idle_hours()
|
|
757
761
|
when ih == 0
|
|
758
762
|
give true
|
|
@@ -783,6 +787,22 @@ export task channels_on_disk(w)
|
|
|
783
787
|
give 0
|
|
784
788
|
give n
|
|
785
789
|
|
|
790
|
+
-- el resumen de equipos y objetivos que escribe el workspace (lib/teamrun.syn) — lo que el hub muestra sin abrir su base
|
|
791
|
+
export task teams_summary(w)
|
|
792
|
+
try
|
|
793
|
+
give json_decode(read_file(dir_of(w["slug"]) + "/.lampson/teams-summary.json"))
|
|
794
|
+
recover err
|
|
795
|
+
give {"teams": [], "objectives": [], "approvals": [], "active": 0, "waiting": 0}
|
|
796
|
+
|
|
797
|
+
-- /w/<nombre> sin el hash: el slug completo si un solo workspace se llama así (si no, nothing)
|
|
798
|
+
export task resolve_slug(name)
|
|
799
|
+
require file(".lampson")
|
|
800
|
+
require file(".lampson/*")
|
|
801
|
+
when get(name) != nothing
|
|
802
|
+
give name
|
|
803
|
+
let hits be where(all(), (w) => starts_with(w["slug"], lower(name) + "-") and length(w["slug"]) == length(name) + 9)
|
|
804
|
+
give when length(hits) == 1 then hits[0]["slug"] otherwise nothing
|
|
805
|
+
|
|
786
806
|
-- equipos con rondas en el proyecto (leídos por el link workspace/ del ws: el hub no tiene permiso sobre el proyecto)
|
|
787
807
|
export task teams_on_disk(w)
|
|
788
808
|
let n be 0
|
|
@@ -846,6 +866,11 @@ export task tick()
|
|
|
846
866
|
give {"started": started, "stopped": stopped}
|
|
847
867
|
|
|
848
868
|
-- resumen para la UI del hub
|
|
869
|
+
-- contadores para la tarjeta del inicio: equipos, objetivos trabajando, lo que espera a la persona
|
|
870
|
+
task team_counts(w)
|
|
871
|
+
let s be teams_summary(w)
|
|
872
|
+
give {"teams": length(s["teams"]), "active": s["active"], "waiting": s["waiting"]}
|
|
873
|
+
|
|
849
874
|
export task summary()
|
|
850
875
|
require exec
|
|
851
876
|
require time
|
|
@@ -860,7 +885,7 @@ export task summary()
|
|
|
860
885
|
each e in enumerate(list)
|
|
861
886
|
let w be e["item"]
|
|
862
887
|
let hc be hcs[e["index"]]
|
|
863
|
-
set out to append(out, {"slug": w["slug"], "name": w["name"], "path": w["path"], "port": w["port"], "policy": when contains(w, "policy") then w["policy"] otherwise "auto", "created": w["created"], "last_used": when hc != nothing and contains(hc, "last_used") and hc["last_used"] != nothing then hc["last_used"] otherwise w["last_used"], "alive": hc != nothing, "paused": contains(w, "paused") and w["paused"] == true, "schedules_on": when hc != nothing and contains(hc, "schedules_on") then hc["schedules_on"] otherwise schedules_on_disk(w), "url": "/w/" + w["slug"]})
|
|
888
|
+
set out to append(out, {"slug": w["slug"], "name": w["name"], "path": w["path"], "port": w["port"], "policy": when contains(w, "policy") then w["policy"] otherwise "auto", "created": w["created"], "last_used": when hc != nothing and contains(hc, "last_used") and hc["last_used"] != nothing then hc["last_used"] otherwise w["last_used"], "alive": hc != nothing, "paused": contains(w, "paused") and w["paused"] == true, "schedules_on": when hc != nothing and contains(hc, "schedules_on") then hc["schedules_on"] otherwise schedules_on_disk(w), "url": "/w/" + w["slug"], "teams": team_counts(w)})
|
|
864
889
|
share out as "hub:summary"
|
|
865
890
|
share now() as "hub:summary_at"
|
|
866
891
|
give out
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lampson",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A coding agent written in Synsema: terminal + web, tools confined to the mounted project, plugins (your own tools, any language), LSP, MCP, sub-agents. Also an SDK: import { Lampson } from \"lampson\" (server or local mode).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/public/css/hub.css
CHANGED
|
@@ -23,3 +23,12 @@ body.hub #stage { display:flex; align-items:center; padding:20px 40px; }
|
|
|
23
23
|
body.hub #stage { padding:16px; align-items:flex-start; }
|
|
24
24
|
.wsgrid { grid-template-columns:1fr; }
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/* equipos y objetivos: la línea de cada proyecto y la tarjeta de /equipos */
|
|
28
|
+
.card.ws .tm { font:400 11px/1.4 var(--mono); color:var(--accent); margin:6px 0 0; padding-top:6px; border-top:1px dashed var(--rule); }
|
|
29
|
+
.card.ws .tm:hover { text-decoration:underline; }
|
|
30
|
+
.card.ws .tm b { color:var(--rubric); font-weight:600; }
|
|
31
|
+
.card.ws.teamscard { border-color:var(--rule-2); }
|
|
32
|
+
.card.ws.teamscard h3 { color:var(--accent); }
|
|
33
|
+
.card.ws.teamscard.wait { border-color:var(--rubric); }
|
|
34
|
+
.card.ws.teamscard.wait .nm { color:var(--rubric); }
|
package/public/css/teams.css
CHANGED
|
@@ -15,6 +15,8 @@ body { display:flex; flex-direction:column; height:100vh; overflow:hidden; }
|
|
|
15
15
|
.live::before { content:""; display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--ok); margin-right:6px; vertical-align:1px; }
|
|
16
16
|
.live.off::before { background:var(--rubric); }
|
|
17
17
|
.theme-toggle { border:none; padding:6px; }
|
|
18
|
+
.alllink { font:400 10.5px/1 var(--mono); color:var(--ink-2); text-transform:uppercase; letter-spacing:.09em; text-decoration:none; padding:6px 8px; border-radius:2px; }
|
|
19
|
+
.alllink:hover { color:var(--ink); background:var(--paper-2); }
|
|
18
20
|
|
|
19
21
|
/* lo que espera a la persona */
|
|
20
22
|
.attention { flex:none; border-bottom:1px solid var(--rule); background:var(--paper-2); padding:10px 16px; display:flex; flex-direction:column; gap:8px; max-height:30vh; overflow:auto; }
|
|
@@ -157,3 +159,29 @@ button.no { color:var(--rubric); border-color:var(--rubric); }
|
|
|
157
159
|
.ask { flex-direction:column; }
|
|
158
160
|
.ask input { width:100%; }
|
|
159
161
|
}
|
|
162
|
+
|
|
163
|
+
/* ---- /equipos: todos los proyectos (public/teams-home.html) ---- */
|
|
164
|
+
body.home .homegrid { flex:1; overflow:auto; padding:22px 28px 60px; }
|
|
165
|
+
.newteam { max-width:760px; border:1px solid var(--accent); border-radius:3px; padding:16px 18px; margin:0 0 22px; display:flex; flex-direction:column; gap:10px; }
|
|
166
|
+
.newteam h5 { margin:0; font:600 10.5px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-2); }
|
|
167
|
+
.newteam .hint0 { margin:0; color:var(--ink-2); font-size:13.5px; }
|
|
168
|
+
.newteam .opt { display:flex; align-items:center; gap:10px; flex-wrap:wrap; font-size:14px; }
|
|
169
|
+
.newteam input:not([type]), .newteam select { font:400 13.5px/1.4 var(--serif); color:var(--ink); background:var(--paper-2); border:1px solid var(--rule-2); border-radius:2px; padding:6px 8px; min-width:220px; }
|
|
170
|
+
.newteam .row2 { max-width:420px; }
|
|
171
|
+
.pblock { border:1px solid var(--rule); border-radius:3px; margin:0 0 18px; }
|
|
172
|
+
.projhead { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--rule); background:var(--paper-2); }
|
|
173
|
+
.pname { font:600 15px/1 var(--mono); color:var(--ink); text-decoration:none; }
|
|
174
|
+
.ppath { font:400 11px/1 var(--mono); color:var(--ink-3); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
175
|
+
.projhead .open { font:400 11px/1 var(--mono); color:var(--accent); text-decoration:none; }
|
|
176
|
+
.pcols { display:grid; grid-template-columns:minmax(0, 1fr) minmax(0, 1.6fr); gap:0; }
|
|
177
|
+
.pcols > div { padding:12px 16px; }
|
|
178
|
+
.pcols > div + div { border-left:1px solid var(--rule); }
|
|
179
|
+
.pcols h6 { margin:0 0 8px; font:600 10px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); }
|
|
180
|
+
.trow, .orow { display:block; padding:7px 8px; margin:0 -8px; border-radius:3px; color:var(--ink); text-decoration:none; font-size:13.5px; line-height:1.45; }
|
|
181
|
+
.trow:hover, .orow:hover { background:var(--paper-2); }
|
|
182
|
+
.trow span, .orow span:not(.st) { display:block; color:var(--ink-3); font-size:12.5px; }
|
|
183
|
+
.none { margin:0; color:var(--ink-3); font-size:13px; }
|
|
184
|
+
.others { color:var(--ink-3); font:400 12px/1.6 var(--mono); }
|
|
185
|
+
.others a { color:var(--ink-2); }
|
|
186
|
+
body.home .empty { margin:8vh auto; }
|
|
187
|
+
@media (max-width: 720px) { .pcols { grid-template-columns:1fr; } .pcols > div + div { border-left:none; border-top:1px solid var(--rule); } body.home .homegrid { padding:16px; } }
|
package/public/hub.html
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<div class="hrow">
|
|
24
24
|
<span class="brand">lampson<span class="proj">workspaces</span></span>
|
|
25
25
|
<span class="spacer"></span>
|
|
26
|
+
<a class="pill" href="/equipos" style="text-decoration:none" title="equipos y objetivos de todos tus proyectos">equipos</a>
|
|
26
27
|
<span class="pill" id="devicesBtn" role="button" tabindex="0">dispositivos</span>
|
|
27
28
|
<button class="theme-toggle" id="theme" type="button" title="cambiar tema"></button>
|
|
28
29
|
</div>
|
package/public/js/hub.js
CHANGED
|
@@ -25,7 +25,11 @@ async function paintGrid() {
|
|
|
25
25
|
grid.innerHTML = '';
|
|
26
26
|
for (const w of (r.workspaces || [])) {
|
|
27
27
|
const c = document.createElement('a'); c.className = 'card ws' + (w.alive ? ' on' : ' off'); c.href = w.url;
|
|
28
|
-
|
|
28
|
+
const t = w.teams || {};
|
|
29
|
+
const tline = (t.teams || t.active || t.waiting) ? `<p class="tm" data-href="${esc(w.url)}/equipos">${t.teams ? '◇ ' + t.teams + (t.teams === 1 ? ' equipo' : ' equipos') : '◇ objetivos'}${t.active ? ' · ' + t.active + ' trabajando' : ''}${t.waiting ? ' · <b>⚑ ' + t.waiting + ' te espera' + (t.waiting === 1 ? '' : 'n') + '</b>' : ''}</p>` : '';
|
|
30
|
+
c.innerHTML = `<h3>${w.alive ? '● vivo' : '○ apagado'}${w.schedules_on ? ' · ⏰ ' + w.schedules_on : ''}</h3><p class="nm">${esc(w.name)}</p><p class="pth">${esc(w.path)}</p><p class="meta">último uso ${esc(fmtWhen(w.last_used))}</p>${tline}`;
|
|
31
|
+
const tm = c.querySelector('.tm');
|
|
32
|
+
if (tm) tm.onclick = (e) => { e.preventDefault(); e.stopPropagation(); location.href = tm.dataset.href; };
|
|
29
33
|
// entrar = usarlo: si está apagado se enciende acá mismo (con aviso en la tarjeta) y después se abre. La ruta
|
|
30
34
|
// /w/<slug> del hub también lo enciende sola, así que un link directo funciona igual; esto solo da feedback.
|
|
31
35
|
if (!w.alive) c.onclick = async (e) => {
|
|
@@ -36,6 +40,11 @@ async function paintGrid() {
|
|
|
36
40
|
};
|
|
37
41
|
grid.appendChild(c);
|
|
38
42
|
}
|
|
43
|
+
// equipos y objetivos de todos los proyectos (/equipos): lo que te espera de un vistazo, y «+ equipo»
|
|
44
|
+
const tot = (r.workspaces || []).reduce((acc, w) => { const t = w.teams || {}; acc.teams += t.teams || 0; acc.active += t.active || 0; acc.waiting += t.waiting || 0; return acc; }, { teams: 0, active: 0, waiting: 0 });
|
|
45
|
+
const tc = document.createElement('a'); tc.className = 'card ws teamscard' + (tot.waiting ? ' wait' : ''); tc.href = '/equipos';
|
|
46
|
+
tc.innerHTML = `<h3>◇ equipos y objetivos</h3><p class="nm">${tot.waiting ? '⚑ ' + tot.waiting + ' te espera' + (tot.waiting === 1 ? '' : 'n') : tot.active ? tot.active + ' trabajando' : 'agentes que trabajan solos'}</p><p class="pth">${tot.teams ? tot.teams + (tot.teams === 1 ? ' equipo' : ' equipos') + ' en tus proyectos' : 'armá un equipo con roles o dale un objetivo a un agente'}</p>`;
|
|
47
|
+
grid.appendChild(tc);
|
|
39
48
|
const add = document.createElement('a'); add.className = 'card ws new'; add.href = '#'; add.innerHTML = '<h3>+</h3><p class="nm">nuevo workspace</p><p class="pth">elegí una carpeta de tu disco</p>';
|
|
40
49
|
add.onclick = (e) => { e.preventDefault(); openWorkspaces('__new'); };
|
|
41
50
|
grid.appendChild(add);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// teams-home.js — equipos y objetivos de todos los proyectos (public/teams-home.html, servido por el hub en /equipos).
|
|
2
|
+
// Lee GET /api/teams-home (el resumen que escribe cada workspace) cada 4 s. Responder, aprobar o denegar va directo al
|
|
3
|
+
// workspace por el proxy del hub: /w/<slug>/api/approve y /w/<slug>/api/objectives/<id>/reply.
|
|
4
|
+
const $ = (s) => document.querySelector(s);
|
|
5
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
6
|
+
const STATUS = { active: 'trabajando', waiting: 'te espera', done: 'hecho', failed: 'falló', cancelled: 'cancelado', paused: 'sin presupuesto' };
|
|
7
|
+
const short = (slug) => slug.replace(/-[0-9a-f]{8}$/, '');
|
|
8
|
+
let data = [];
|
|
9
|
+
|
|
10
|
+
async function post(path, body) {
|
|
11
|
+
const r = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
12
|
+
let d = {}; try { d = await r.json(); } catch (e) {}
|
|
13
|
+
if (r.status === 401) location.href = '/login';
|
|
14
|
+
return { ok: r.ok, data: d };
|
|
15
|
+
}
|
|
16
|
+
function setTheme(t) { document.documentElement.setAttribute('data-theme', t); try { localStorage.setItem('lampson.theme', t); } catch (e) {} $('#theme').textContent = t === 'dark' ? '☀' : '☾'; }
|
|
17
|
+
setTheme(document.documentElement.getAttribute('data-theme') || 'dark');
|
|
18
|
+
$('#theme').onclick = () => setTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
|
|
19
|
+
|
|
20
|
+
// ---------- lo que te espera, de todos los proyectos ----------
|
|
21
|
+
function renderAttention() {
|
|
22
|
+
const box = $('#attention');
|
|
23
|
+
const keep = {}; box.querySelectorAll('input[data-k]').forEach((i) => (keep[i.dataset.k] = i.value));
|
|
24
|
+
let html = '';
|
|
25
|
+
for (const w of data) {
|
|
26
|
+
for (const o of w.objectives.filter((o) => o.status === 'waiting')) {
|
|
27
|
+
const ap = o.question_kind === 'approval'; const k = w.slug + ':' + o.id;
|
|
28
|
+
html += `<div class="ask ${ap ? 'approval' : ''}"><span class="who">${esc(short(w.slug))} · ${esc(o.agent)} ${ap ? 'pide aprobación' : 'pregunta'}</span>
|
|
29
|
+
<div class="q"><a class="ref" href="/w/${esc(w.slug)}/equipos?o=${o.id}">${esc(o.ref)}</a> ${esc(o.question)}</div>
|
|
30
|
+
<div class="acts">${ap ? `<input data-k="${esc(k)}" placeholder="nota (opcional)"><button class="ok" data-ok="${esc(k)}">Aprobar</button><button class="no" data-no="${esc(k)}">Denegar</button>`
|
|
31
|
+
: `<input data-k="${esc(k)}" placeholder="tu respuesta"><button class="primary" data-ans="${esc(k)}">Responder</button>`}</div></div>`;
|
|
32
|
+
}
|
|
33
|
+
for (const a of w.approvals) {
|
|
34
|
+
const who = (String(a.why || '').match(/agent (\S+)/) || [])[1] || 'un agente';
|
|
35
|
+
html += `<div class="ask approval"><span class="who">${esc(short(w.slug))} · ${esc(who)} pide aprobación</span><div class="q"><code>${esc(a.message)}</code><br><span class="ref">${esc(String(a.why || '').replace(/ · agent \S+$/, ''))}</span></div>
|
|
36
|
+
<div class="acts"><button class="ok" data-qok="${esc(w.slug)}|${esc(a.id)}">Aprobar</button><button class="no" data-qno="${esc(w.slug)}|${esc(a.id)}">Denegar</button></div></div>`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
box.hidden = html === '';
|
|
40
|
+
box.innerHTML = html;
|
|
41
|
+
box.querySelectorAll('input[data-k]').forEach((i) => { if (keep[i.dataset.k]) i.value = keep[i.dataset.k]; });
|
|
42
|
+
const note = (k) => (box.querySelector(`input[data-k="${k}"]`) || {}).value || '';
|
|
43
|
+
const reply = async (k, text, approved) => { const [slug, id] = k.split(':'); await post(`/w/${slug}/api/objectives/${id}/reply`, { text, approved }); refresh(); };
|
|
44
|
+
box.querySelectorAll('[data-ok]').forEach((b) => (b.onclick = () => reply(b.dataset.ok, note(b.dataset.ok), true)));
|
|
45
|
+
box.querySelectorAll('[data-no]').forEach((b) => (b.onclick = () => reply(b.dataset.no, note(b.dataset.no), false)));
|
|
46
|
+
box.querySelectorAll('[data-ans]').forEach((b) => (b.onclick = () => { const t = note(b.dataset.ans); if (t.trim()) reply(b.dataset.ans, t, false); }));
|
|
47
|
+
const q = async (v, decision) => { const [slug, id] = v.split('|'); await post(`/w/${slug}/api/approve`, { id, decision }); refresh(); };
|
|
48
|
+
box.querySelectorAll('[data-qok]').forEach((b) => (b.onclick = () => q(b.dataset.qok, true)));
|
|
49
|
+
box.querySelectorAll('[data-qno]').forEach((b) => (b.onclick = () => q(b.dataset.qno, false)));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---------- cada proyecto: sus equipos y sus objetivos ----------
|
|
53
|
+
function renderProjects() {
|
|
54
|
+
const withStuff = data.filter((w) => w.teams.length || w.objectives.length);
|
|
55
|
+
const rest = data.filter((w) => !w.teams.length && !w.objectives.length);
|
|
56
|
+
$('#projects').innerHTML = (withStuff.length ? withStuff.map((w) => `
|
|
57
|
+
<section class="pblock">
|
|
58
|
+
<div class="projhead"><a href="/w/${esc(w.slug)}/equipos" class="pname">${esc(short(w.slug))}</a><span class="ppath">${esc(w.path)}</span>
|
|
59
|
+
<span class="spacer"></span>${w.alive ? '<span class="dot on"></span>' : '<span class="dot"></span>'}<a class="open" href="/w/${esc(w.slug)}/equipos">abrir →</a></div>
|
|
60
|
+
<div class="pcols">
|
|
61
|
+
<div><h6>Equipos</h6>${w.teams.length ? w.teams.map((t) => `<a class="trow" href="/w/${esc(w.slug)}/equipos?tab=teams"><b>${esc(t.id)}</b> · ${t.members} agentes · lo lidera ${esc(t.lead)}${t.description ? `<span>${esc(t.description)}</span>` : ''}</a>`).join('') : '<p class="none">sin equipos</p>'}</div>
|
|
62
|
+
<div><h6>Objetivos</h6>${w.objectives.length ? w.objectives.map((o) => `<a class="orow" href="/w/${esc(w.slug)}/equipos?o=${o.id}"><span class="st ${o.status}">${STATUS[o.status] || o.status}</span> <b>${esc(o.ref)}</b> ${o.team ? 'equipo ' + esc(o.team) : esc(o.agent)} — ${esc(o.text)}${o.progress && o.status === 'active' ? `<span>${esc(o.progress)}</span>` : ''}</a>`).join('') : '<p class="none">sin objetivos</p>'}</div>
|
|
63
|
+
</div>
|
|
64
|
+
</section>`).join('') : `<div class="empty">Todavía no hay equipos ni objetivos. Tocá <b>+ equipo</b> para armar el primero, o abrí un proyecto y dale un objetivo a uno de sus agentes.</div>`) +
|
|
65
|
+
(rest.length ? `<p class="others">Otros proyectos: ${rest.map((w) => `<a href="/w/${esc(w.slug)}/equipos">${esc(short(w.slug))}</a>`).join(' · ')}</p>` : '');
|
|
66
|
+
$('#nWs').innerHTML = data.map((w) => `<option value="${esc(w.slug)}">${esc(short(w.slug))} — ${esc(w.path)}</option>`).join('');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------- + equipo ----------
|
|
70
|
+
$('#newTeam').onclick = () => { $('#newBox').hidden = false; $('#nName').focus(); };
|
|
71
|
+
$('#nCancel').onclick = () => ($('#newBox').hidden = true);
|
|
72
|
+
$('#nName').onfocus = () => (document.querySelector('input[name=where][value=new]').checked = true);
|
|
73
|
+
$('#nWs').onfocus = () => (document.querySelector('input[name=where][value=ws]').checked = true);
|
|
74
|
+
$('#nGo').onclick = async () => {
|
|
75
|
+
const where = document.querySelector('input[name=where]:checked').value;
|
|
76
|
+
const body = where === 'ws' ? { slug: $('#nWs').value } : { name: $('#nName').value.trim().toLowerCase() };
|
|
77
|
+
if (where === 'new' && !/^[a-z0-9][a-z0-9-]{0,39}$/.test(body.name)) { $('#nErr').textContent = 'Un nombre corto, en minúsculas (por ejemplo «ventas»).'; return; }
|
|
78
|
+
$('#nGo').disabled = true; $('#nErr').textContent = '';
|
|
79
|
+
const r = await post('/api/teams-home/new', body);
|
|
80
|
+
$('#nGo').disabled = false;
|
|
81
|
+
if (!r.ok) { $('#nErr').textContent = r.data.error || 'no se pudo crear'; return; }
|
|
82
|
+
location.href = r.data.url;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
async function refresh() {
|
|
86
|
+
try {
|
|
87
|
+
const r = await fetch('/api/teams-home');
|
|
88
|
+
if (r.status === 401) { location.href = '/login'; return; }
|
|
89
|
+
data = (await r.json()).workspaces || [];
|
|
90
|
+
renderAttention(); renderProjects();
|
|
91
|
+
$('#live').classList.remove('off');
|
|
92
|
+
} catch (e) { $('#live').classList.add('off'); }
|
|
93
|
+
}
|
|
94
|
+
refresh();
|
|
95
|
+
setInterval(refresh, 4000);
|
package/public/js/teams.js
CHANGED
|
@@ -11,6 +11,7 @@ const STATUS = { active: 'trabajando', waiting: 'te espera', done: 'hecho', fail
|
|
|
11
11
|
const KIND = { added: 'agregó', claimed: 'tomó', updated: 'movió', message: 'escribió', report: 'informó', asked: 'preguntó', 'approval requested': 'pide aprobación', approved: 'aprobó', denied: 'denegó', answered: 'respondió', done: 'terminó', failed: 'falló', cancelled: 'canceló', paused: 'pausado', budget: 'presupuesto', objective: 'nuevo objetivo', error: 'error' };
|
|
12
12
|
|
|
13
13
|
const PRESETS = [['code', 'código (leer, editar, comandos)'], ['read', 'leer y correr comandos (no edita)'], ['none', 'ninguna (solo coordina)']];
|
|
14
|
+
if (new URLSearchParams(location.search).get('new')) { try { localStorage.setItem('lampson.teams.tab', 'teams'); } catch (e) {} }
|
|
14
15
|
const state = { approvals: [], teamsMeta: [], draft: null, sel: null, tab: new URLSearchParams(location.search).get('tab') || localStorage.getItem('lampson.teams.tab') || 'objectives', obj: Number(new URLSearchParams(location.search).get('o')) || null, team: null, objectives: [], agents: [], teams: [], seen: new Set() };
|
|
15
16
|
|
|
16
17
|
async function api(path, body) {
|
|
@@ -190,6 +191,7 @@ function draftFrom(team) {
|
|
|
190
191
|
members: team.members.map((m) => ({ agent: m.agent, role: m.role, reports_to: m.reports_to, description: m.description, system: m.system, preset: presetOf(m.tools), permission: m.permission || 'strict', dirty: false })) };
|
|
191
192
|
}
|
|
192
193
|
function presetOf(tools) { const t = tools || []; if (!t.length) return 'none'; if (t.includes('write') || t.includes('edit')) return 'code'; return 'read'; }
|
|
194
|
+
function slugName() { return (BASE ? BASE.slice(3) : 'equipo').replace(/-[0-9a-f]{8}$/, '').replace(/[^a-z0-9-]/g, '').slice(0, 40) || 'equipo'; }
|
|
193
195
|
function startNewTeam() {
|
|
194
196
|
state.draft = { isNew: true, id: '', description: '', round_minutes: 0, budget_daily_tokens: 300000, worktrees: true, talks: [], members: [{ agent: 'lider', role: 'Líder', reports_to: '', description: '', system: '', preset: 'code', permission: 'strict', dirty: true }] };
|
|
195
197
|
state.sel = 'lider'; renderTeams();
|
|
@@ -282,6 +284,12 @@ async function refreshTeams() {
|
|
|
282
284
|
const r = await api('teams');
|
|
283
285
|
if (!r.ok) return false;
|
|
284
286
|
state.teams = r.data.teams;
|
|
287
|
+
// ?new=1 (desde /equipos → «+ equipo»): el editor de un equipo nuevo, con el nombre del proyecto
|
|
288
|
+
if (new URLSearchParams(location.search).get('new') && !state.newOpened) {
|
|
289
|
+
state.newOpened = true; startNewTeam();
|
|
290
|
+
if (!state.teams.some((t) => t.id === slugName())) state.draft.id = slugName();
|
|
291
|
+
renderTeams(); history.replaceState(null, '', location.pathname + '?tab=teams'); return true;
|
|
292
|
+
}
|
|
285
293
|
// ?edit=<equipo> abre el editor de ese equipo (enlaces directos, capturas)
|
|
286
294
|
const ed = new URLSearchParams(location.search).get('edit');
|
|
287
295
|
if (ed && !state.editOpened) { state.editOpened = true; const t = state.teams.find((x) => x.id === ed); if (t) { state.team = t.id; state.draft = draftFrom(t); state.sel = t.lead || t.members[0].agent; renderTeams(); return true; } }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="es">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
6
|
+
<title>Lampson · equipos y objetivos</title>
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
8
|
+
<meta name="theme-color" content="#131412">
|
|
9
|
+
<link rel="manifest" href="/manifest.webmanifest">
|
|
10
|
+
<!-- equipos y objetivos de TODOS los proyectos (el hub): lo que te espera, cada proyecto con sus equipos y objetivos,
|
|
11
|
+
y «+ equipo». Cada proyecto tiene su pantalla propia en /w/<proyecto>/equipos (public/teams.html). -->
|
|
12
|
+
<link rel="stylesheet" href="/css/tokens.css">
|
|
13
|
+
<link rel="stylesheet" href="/css/teams.css">
|
|
14
|
+
<script>(function(){try{var t=localStorage.getItem('lampson.theme');if(t!=='light'&&t!=='dark'){t='dark';}document.documentElement.setAttribute('data-theme',t);}catch(e){}})();</script>
|
|
15
|
+
</head>
|
|
16
|
+
<body class="home">
|
|
17
|
+
<header class="tbar">
|
|
18
|
+
<a class="back" href="/" title="inicio: tus proyectos">←</a>
|
|
19
|
+
<span class="brand">lampson<span class="proj">equipos y objetivos</span></span>
|
|
20
|
+
<span class="spacer"></span>
|
|
21
|
+
<button class="primary" id="newTeam">+ equipo</button>
|
|
22
|
+
<span class="live" id="live" title="actualizado en vivo">en vivo</span>
|
|
23
|
+
<button class="theme-toggle" id="theme" type="button" title="cambiar tema"></button>
|
|
24
|
+
</header>
|
|
25
|
+
|
|
26
|
+
<section class="attention" id="attention" hidden></section>
|
|
27
|
+
|
|
28
|
+
<main class="homegrid">
|
|
29
|
+
<section class="newteam" id="newBox" hidden>
|
|
30
|
+
<h5>Un equipo nuevo</h5>
|
|
31
|
+
<p class="hint0">Un equipo vive en un proyecto: sus agentes trabajan sobre esa carpeta (y, si tiene git, cada uno en su rama). Para un equipo que no programa —ventas, soporte, investigación— Lampson le crea su carpeta.</p>
|
|
32
|
+
<label class="opt"><input type="radio" name="where" value="new" checked> carpeta nueva para el equipo <input id="nName" placeholder="ventas" autocomplete="off"></label>
|
|
33
|
+
<label class="opt"><input type="radio" name="where" value="ws"> en un proyecto que ya tenés <select id="nWs"></select></label>
|
|
34
|
+
<div class="row2"><button class="primary" id="nGo">Crear y armar el equipo</button><button id="nCancel">Cancelar</button></div>
|
|
35
|
+
<p class="ferr" id="nErr"></p>
|
|
36
|
+
</section>
|
|
37
|
+
<div id="projects"></div>
|
|
38
|
+
</main>
|
|
39
|
+
|
|
40
|
+
<script src="/js/teams-home.js"></script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
package/public/teams.html
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
<button data-tab="teams">Equipos</button>
|
|
23
23
|
</nav>
|
|
24
24
|
<span class="spacer"></span>
|
|
25
|
+
<a class="alllink" href="/equipos" title="equipos y objetivos de todos tus proyectos">todos los proyectos</a>
|
|
25
26
|
<span class="live" id="live" title="actualizado en vivo">en vivo</span>
|
|
26
27
|
<button class="theme-toggle" id="theme" type="button" title="cambiar tema"></button>
|
|
27
28
|
</header>
|