lampson 0.3.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.
@@ -0,0 +1,342 @@
1
+ -- plugins/orders/plugin.syn — tomar pedidos: catálogo, cotización exacta, pedido guardado, clientes, stock
2
+ --
3
+ -- Lampson lo corre por cada llamada con el techo del manifiesto: solo puede tocar workspace/.lampson/orders/.
4
+ -- catalog.json el catálogo (lo escribe el dueño; ver docs/recipes): store, hours, delivery, payment, products, policies
5
+ -- producto: {sku, name, price, unit, stock, notes, pack: {qty, price}, second_half: true}
6
+ -- P-0001.json … un archivo por pedido
7
+ -- customers.json clientes por teléfono (o por nombre si no dio teléfono): nombre, dirección, pedidos
8
+ -- Los precios se calculan SIEMPRE acá desde el catálogo: el modelo nunca suma ni pone precios.
9
+ intent: "lampson plugin: take orders against a catalog — quote, place, customers, stock"
10
+
11
+ require env("PLUGIN_*")
12
+ require time
13
+ require file("workspace/.lampson/orders")
14
+ require file("workspace/.lampson/orders/*")
15
+
16
+ let DIR be "workspace/.lampson/orders"
17
+ let CATALOG be DIR + "/catalog.json"
18
+ let CUSTOMERS be DIR + "/customers.json"
19
+
20
+ task out(v)
21
+ print(json_encode(v))
22
+
23
+ task fail(msg)
24
+ out({"ok": false, "error": msg})
25
+
26
+ task load_catalog()
27
+ when not file_exists(CATALOG)
28
+ raise("no catalog yet: the store owner writes .lampson/orders/catalog.json")
29
+ give json_decode(read_file(CATALOG))
30
+
31
+ task num(m, k, fallback)
32
+ when contains(m, k) and m[k] != nothing
33
+ give number(m[k])
34
+ give fallback
35
+
36
+ task round_money(x)
37
+ give floor(x + 0.5)
38
+
39
+ -- montos enteros como enteros (3200, no 3200.0); con centavos, tal cual
40
+ task money(x)
41
+ let v be number(x)
42
+ give when v == floor(v) then floor(v) otherwise v
43
+
44
+ -- una línea del carrito: precio de lista, pack (p. ej. docena) y "segunda a mitad de precio"
45
+ task price_line(p, qty)
46
+ let unit be money(p["price"])
47
+ let plain be unit * qty
48
+ let amount be plain
49
+ let promo be ""
50
+ when contains(p, "pack") and p["pack"] != nothing
51
+ let n be floor(num(p["pack"], "qty", 0))
52
+ when n > 1 and qty >= n
53
+ let packs be floor(qty / n)
54
+ set amount to packs * money(p["pack"]["price"]) + (qty - packs * n) * unit
55
+ set promo to text(packs) + " x pack of " + text(n)
56
+ when contains(p, "second_half") and p["second_half"] == true and qty >= 2
57
+ let pairs be floor(qty / 2)
58
+ set amount to plain - round_money(pairs * unit / 2)
59
+ set promo to text(pairs) + " x second at half price"
60
+ give {"sku": p["sku"], "name": p["name"], "qty": qty, "unit_price": unit, "list": plain, "discount": plain - amount, "amount": amount, "promo": promo}
61
+
62
+ -- cotiza un carrito: {ok, lines, subtotal, discount, delivery_fee, total, short, unknown}
63
+ task quote_of(cat, items, delivery)
64
+ let by_sku be {}
65
+ each p in cat["products"]
66
+ set by_sku[upper(text(p["sku"]))] to p
67
+ let merged be {}
68
+ let order be []
69
+ each it in items
70
+ let sku be upper(trim(text(it["sku"])))
71
+ let qty be floor(num(it, "qty", 0))
72
+ when qty > 0
73
+ when not contains(merged, sku)
74
+ set merged[sku] to 0
75
+ set order to append(order, sku)
76
+ set merged[sku] to merged[sku] + qty
77
+ let lines be []
78
+ let short be []
79
+ let unknown be []
80
+ let subtotal be 0
81
+ let discount be 0
82
+ each sku in order
83
+ when not contains(by_sku, sku)
84
+ set unknown to append(unknown, sku)
85
+ otherwise
86
+ let p be by_sku[sku]
87
+ let ln be price_line(p, merged[sku])
88
+ set lines to append(lines, ln)
89
+ set subtotal to subtotal + ln["amount"]
90
+ set discount to discount + ln["discount"]
91
+ let stock be floor(num(p, "stock", 0))
92
+ when merged[sku] > stock
93
+ set short to append(short, {"sku": sku, "name": p["name"], "asked": merged[sku], "available": stock, "notes": when contains(p, "notes") then p["notes"] otherwise ""})
94
+ let fee be 0
95
+ let d be when contains(cat, "delivery") and cat["delivery"] != nothing then cat["delivery"] otherwise {}
96
+ when delivery == "delivery"
97
+ set fee to money(num(d, "fee", 0))
98
+ when contains(d, "free_from") and d["free_from"] != nothing and subtotal >= number(d["free_from"])
99
+ set fee to 0
100
+ -- un sku inventado (visto: "pan-sin-gluten-arroz-mijo") → la lista de los válidos, para que el modelo corrija solo
101
+ let hint be when length(unknown) > 0 then apply(cat["products"], (p) => text(p["sku"]) + " = " + text(p["name"])) otherwise []
102
+ give {"valid_skus": hint, "ok": length(short) == 0 and length(unknown) == 0 and length(lines) > 0, "lines": lines, "subtotal": subtotal, "discount": discount, "delivery": delivery, "delivery_fee": fee, "total": subtotal + fee, "short": short, "unknown": unknown, "currency": when contains(cat, "currency") then cat["currency"] otherwise ""}
103
+
104
+ task load_customers()
105
+ when not file_exists(CUSTOMERS)
106
+ give {}
107
+ give json_decode(read_file(CUSTOMERS))
108
+
109
+ task customer_key(c)
110
+ let phone be when contains(c, "phone") and c["phone"] != nothing then replace(replace(replace(trim(text(c["phone"])), " ", ""), "-", ""), "(", "") otherwise ""
111
+ when phone != ""
112
+ give "tel:" + replace(phone, ")", "")
113
+ give "name:" + lower(trim(text(c["name"])))
114
+
115
+ task order_ids()
116
+ give apply(where(list_dir(DIR), (e) => starts_with(e["name"], "P-") and ends_with(e["name"], ".json")), (e) => slice(e["name"], 0, length(e["name"]) - 5))
117
+
118
+ task next_id()
119
+ let n be length(order_ids()) + 1
120
+ let id be ""
121
+ while true
122
+ let digits be text(n)
123
+ each i in range(length(digits), 4)
124
+ set digits to "0" + digits
125
+ set id to "P-" + digits
126
+ when not file_exists(DIR + "/" + id + ".json")
127
+ give id
128
+ set n to n + 1
129
+
130
+ task arg(args, k)
131
+ when contains(args, k) and args[k] != nothing
132
+ give trim(text(args[k]))
133
+ give ""
134
+
135
+ -- ---------- stock y pedidos guardados (update_order / cancel_order) ----------
136
+ task qty_by_sku(lines)
137
+ let m be {}
138
+ each ln in lines
139
+ let k be upper(text(ln["sku"]))
140
+ set m[k] to (when contains(m, k) then m[k] otherwise 0) + floor(number(ln["qty"]))
141
+ give m
142
+
143
+ -- el catálogo con el stock movido: deltas = {sku: unidades que SALEN} (negativo = vuelven)
144
+ task shift_stock(cat, deltas)
145
+ let prods be []
146
+ each p in cat["products"]
147
+ let k be upper(text(p["sku"]))
148
+ when contains(deltas, k)
149
+ set p["stock"] to floor(num(p, "stock", 0)) - deltas[k]
150
+ set prods to append(prods, p)
151
+ set cat["products"] to prods
152
+ give cat
153
+
154
+ task negate(m)
155
+ let out be {}
156
+ each k in keys(m)
157
+ set out[k] to 0 - m[k]
158
+ give out
159
+
160
+ -- lo que cambia entre dos carritos: nuevo - viejo, por sku
161
+ task delta(new_q, old_q)
162
+ let out be {}
163
+ each k in keys(new_q)
164
+ set out[k] to new_q[k] - (when contains(old_q, k) then old_q[k] otherwise 0)
165
+ each k in keys(old_q)
166
+ when not contains(new_q, k)
167
+ set out[k] to 0 - old_q[k]
168
+ give out
169
+
170
+ task quote_problem(q)
171
+ give (when length(q["unknown"]) > 0 then "unknown sku " + join(q["unknown"], ", ") + " " otherwise "") + (when length(q["short"]) > 0 then "not enough stock for " + join(apply(q["short"], (s) => s["name"] + " (asked " + text(s["asked"]) + ", available " + text(s["available"]) + ")"), ", ") otherwise "") + (when length(q["lines"]) == 0 then "empty cart" otherwise "")
172
+
173
+ -- un pedido guardado que todavía se puede tocar: {ok, order} o {ok: false, error}
174
+ task editable(oid)
175
+ when not matches(oid, "P-[0-9]{1,8}") or not file_exists(DIR + "/" + oid + ".json")
176
+ give {"ok": false, "error": "no order " + oid}
177
+ let o be json_decode(read_file(DIR + "/" + oid + ".json"))
178
+ when o["status"] != "new"
179
+ give {"ok": false, "error": "order " + oid + " is '" + text(o["status"]) + "': it can't be changed or cancelled from here anymore — the customer has to talk to the store"}
180
+ give {"ok": true, "order": o}
181
+
182
+ let tool be env("PLUGIN_TOOL", "")
183
+ let args be json_decode(env("PLUGIN_ARGS", "{}"))
184
+
185
+ try
186
+ when tool == "catalog"
187
+ out(load_catalog())
188
+ otherwise when tool == "quote"
189
+ let items be when contains(args, "items") and args["items"] != nothing then args["items"] otherwise []
190
+ out(quote_of(load_catalog(), items, when arg(args, "delivery") == "" then "pickup" otherwise arg(args, "delivery")))
191
+ otherwise when tool == "place_order"
192
+ let cat be load_catalog()
193
+ let items be when contains(args, "items") and args["items"] != nothing then args["items"] otherwise []
194
+ let delivery be arg(args, "delivery")
195
+ let cust be when contains(args, "customer") and args["customer"] != nothing then args["customer"] otherwise {}
196
+ let name be arg(cust, "name")
197
+ let payment be arg(args, "payment")
198
+ let address be arg(args, "address")
199
+ let methods be when contains(cat, "payment") and cat["payment"] != nothing then cat["payment"] otherwise []
200
+ let missing be []
201
+ when length(items) == 0
202
+ set missing to append(missing, "items")
203
+ when name == ""
204
+ set missing to append(missing, "customer.name")
205
+ when delivery != "delivery" and delivery != "pickup"
206
+ set missing to append(missing, "delivery (delivery or pickup)")
207
+ when delivery == "delivery" and address == ""
208
+ set missing to append(missing, "address")
209
+ when payment == ""
210
+ set missing to append(missing, "payment")
211
+ when length(missing) > 0
212
+ fail("missing: " + join(missing, ", ") + " — ask the customer, then place the order")
213
+ otherwise when length(methods) > 0 and length(where(methods, (m) => lower(text(m)) == lower(payment))) == 0
214
+ fail("payment '" + payment + "' is not accepted; accepted: " + join(apply(methods, (m) => text(m)), ", "))
215
+ otherwise
216
+ when length(methods) > 0
217
+ set payment to text(where(methods, (m) => lower(text(m)) == lower(payment))[0])
218
+ let q be quote_of(cat, items, delivery)
219
+ when not q["ok"]
220
+ out({"ok": false, "error": "cannot place it: " + (when length(q["unknown"]) > 0 then "unknown sku " + join(q["unknown"], ", ") + " " otherwise "") + (when length(q["short"]) > 0 then "not enough stock for " + join(apply(q["short"], (s) => s["name"] + " (asked " + text(s["asked"]) + ", available " + text(s["available"]) + ")"), ", ") otherwise "") + (when length(q["lines"]) == 0 then "empty cart" otherwise ""), "quote": q})
221
+ otherwise
222
+ let id be next_id()
223
+ let ckey be customer_key(cust)
224
+ let d be when contains(cat, "delivery") and cat["delivery"] != nothing then cat["delivery"] otherwise {}
225
+ let order be {"id": id, "created": format_time(now(), "%Y-%m-%d %H:%M"), "status": "new", "customer": {"name": name, "phone": arg(cust, "phone"), "key": ckey}, "lines": q["lines"], "subtotal": q["subtotal"], "discount": q["discount"], "delivery": delivery, "address": address, "delivery_fee": q["delivery_fee"], "total": q["total"], "payment": payment, "when": arg(args, "when"), "notes": arg(args, "notes")}
226
+ write_file(DIR + "/" + id + ".json", json_encode(order))
227
+ -- stock: baja lo vendido en el catálogo
228
+ let sold be {}
229
+ each ln in q["lines"]
230
+ set sold[upper(text(ln["sku"]))] to ln["qty"]
231
+ let prods be []
232
+ each p in cat["products"]
233
+ let k be upper(text(p["sku"]))
234
+ when contains(sold, k)
235
+ set p["stock"] to floor(num(p, "stock", 0)) - sold[k]
236
+ set prods to append(prods, p)
237
+ set cat["products"] to prods
238
+ write_file(CATALOG, json_encode(cat))
239
+ -- cliente: nombre, teléfono, última dirección, sus pedidos
240
+ let cs be load_customers()
241
+ let prev be when contains(cs, ckey) then cs[ckey] otherwise {"orders": []}
242
+ set cs[ckey] to {"name": name, "phone": arg(cust, "phone"), "address": when address != "" then address otherwise (when contains(prev, "address") then prev["address"] otherwise ""), "orders": append(prev["orders"], id), "last": order["created"]}
243
+ write_file(CUSTOMERS, json_encode(cs))
244
+ out({"ok": true, "order_id": id, "total": q["total"], "subtotal": q["subtotal"], "discount": q["discount"], "delivery_fee": q["delivery_fee"], "delivery": delivery, "address": address, "payment": payment, "eta": when delivery == "delivery" and contains(d, "eta") then d["eta"] otherwise "", "lines": q["lines"]})
245
+ otherwise when tool == "update_order"
246
+ let ed be editable(upper(arg(args, "order_id")))
247
+ when not ed["ok"]
248
+ fail(ed["error"])
249
+ otherwise
250
+ let o be ed["order"]
251
+ let cat be load_catalog()
252
+ let old be qty_by_sku(o["lines"])
253
+ -- sin "items" el carrito queda como estaba (cambia solo la entrega, el pago, la hora o las notas)
254
+ let items be when contains(args, "items") and args["items"] != nothing then args["items"] otherwise apply(o["lines"], (l) => {"sku": l["sku"], "qty": l["qty"]})
255
+ let delivery be when arg(args, "delivery") != "" then arg(args, "delivery") otherwise o["delivery"]
256
+ let address be when arg(args, "address") != "" then arg(args, "address") otherwise o["address"]
257
+ let payment be when arg(args, "payment") != "" then arg(args, "payment") otherwise o["payment"]
258
+ let methods be when contains(cat, "payment") and cat["payment"] != nothing then cat["payment"] otherwise []
259
+ when delivery != "delivery" and delivery != "pickup"
260
+ fail("delivery must be delivery or pickup")
261
+ otherwise when delivery == "delivery" and address == ""
262
+ fail("missing: address — ask the customer, then update the order")
263
+ otherwise when length(methods) > 0 and length(where(methods, (m) => lower(text(m)) == lower(payment))) == 0
264
+ fail("payment '" + payment + "' is not accepted; accepted: " + join(apply(methods, (m) => text(m)), ", "))
265
+ otherwise
266
+ when length(methods) > 0
267
+ set payment to text(where(methods, (m) => lower(text(m)) == lower(payment))[0])
268
+ -- lo que este pedido ya tiene reservado cuenta como disponible para él
269
+ let q be quote_of(shift_stock(cat, negate(old)), items, delivery)
270
+ when not q["ok"]
271
+ out({"ok": false, "error": "cannot update it: " + quote_problem(q), "quote": q})
272
+ otherwise
273
+ write_file(CATALOG, json_encode(shift_stock(cat, delta(qty_by_sku(q["lines"]), old))))
274
+ let before be o["total"]
275
+ let stamp be format_time(now(), "%Y-%m-%d %H:%M")
276
+ let hist be when contains(o, "history") and o["history"] != nothing then o["history"] otherwise []
277
+ set o["history"] to append(hist, {"at": stamp, "change": "updated", "total_before": before})
278
+ set o["lines"] to q["lines"]
279
+ set o["subtotal"] to q["subtotal"]
280
+ set o["discount"] to q["discount"]
281
+ set o["delivery"] to delivery
282
+ set o["address"] to address
283
+ set o["delivery_fee"] to q["delivery_fee"]
284
+ set o["total"] to q["total"]
285
+ set o["payment"] to payment
286
+ set o["updated"] to stamp
287
+ when contains(args, "when") and args["when"] != nothing
288
+ set o["when"] to arg(args, "when")
289
+ when contains(args, "notes") and args["notes"] != nothing
290
+ set o["notes"] to arg(args, "notes")
291
+ write_file(DIR + "/" + o["id"] + ".json", json_encode(o))
292
+ when address != "" and contains(o["customer"], "key")
293
+ let cs be load_customers()
294
+ when contains(cs, o["customer"]["key"])
295
+ let c be cs[o["customer"]["key"]]
296
+ set c["address"] to address
297
+ set cs[o["customer"]["key"]] to c
298
+ write_file(CUSTOMERS, json_encode(cs))
299
+ let d be when contains(cat, "delivery") and cat["delivery"] != nothing then cat["delivery"] otherwise {}
300
+ out({"ok": true, "order_id": o["id"], "total": q["total"], "total_before": before, "subtotal": q["subtotal"], "discount": q["discount"], "delivery_fee": q["delivery_fee"], "delivery": delivery, "address": address, "payment": payment, "when": o["when"], "eta": when delivery == "delivery" and contains(d, "eta") then d["eta"] otherwise "", "lines": q["lines"]})
301
+ otherwise when tool == "cancel_order"
302
+ let ed be editable(upper(arg(args, "order_id")))
303
+ when not ed["ok"]
304
+ fail(ed["error"])
305
+ otherwise
306
+ let o be ed["order"]
307
+ -- el stock vuelve al catálogo
308
+ write_file(CATALOG, json_encode(shift_stock(load_catalog(), negate(qty_by_sku(o["lines"])))))
309
+ let stamp be format_time(now(), "%Y-%m-%d %H:%M")
310
+ let hist be when contains(o, "history") and o["history"] != nothing then o["history"] otherwise []
311
+ set o["history"] to append(hist, {"at": stamp, "change": "cancelled", "reason": arg(args, "reason")})
312
+ set o["status"] to "cancelled"
313
+ set o["cancelled"] to stamp
314
+ write_file(DIR + "/" + o["id"] + ".json", json_encode(o))
315
+ out({"ok": true, "order_id": o["id"], "status": "cancelled", "total_was": o["total"]})
316
+ otherwise when tool == "find_customer"
317
+ let cs be load_customers()
318
+ let key be ""
319
+ when arg(args, "phone") != ""
320
+ set key to customer_key({"phone": arg(args, "phone"), "name": ""})
321
+ otherwise when arg(args, "name") != ""
322
+ set key to customer_key({"name": arg(args, "name")})
323
+ when key == "" or not contains(cs, key)
324
+ out({"found": false})
325
+ otherwise
326
+ let c be cs[key]
327
+ let recent be []
328
+ each oid in slice(c["orders"], max(0, length(c["orders"]) - 3), length(c["orders"]))
329
+ when file_exists(DIR + "/" + oid + ".json")
330
+ let o be json_decode(read_file(DIR + "/" + oid + ".json"))
331
+ set recent to append(recent, {"id": oid, "created": o["created"], "total": o["total"], "status": o["status"], "items": apply(o["lines"], (l) => {"sku": l["sku"], "qty": l["qty"], "name": l["name"]}), "delivery": o["delivery"], "payment": o["payment"]})
332
+ out({"found": true, "name": c["name"], "phone": c["phone"], "address": c["address"], "orders": recent})
333
+ otherwise when tool == "order_status"
334
+ let oid be upper(arg(args, "order_id"))
335
+ when not matches(oid, "P-[0-9]{1,8}") or not file_exists(DIR + "/" + oid + ".json")
336
+ fail("no order " + oid)
337
+ otherwise
338
+ out(json_decode(read_file(DIR + "/" + oid + ".json")))
339
+ otherwise
340
+ fail("unknown tool '" + tool + "'")
341
+ recover err
342
+ fail(text(err))
@@ -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); }
@@ -0,0 +1,187 @@
1
+ /* teams.css — la pantalla de equipos y objetivos: tres columnas a pantalla completa (lista · detalle · registro).
2
+ Misma voz que el resto: tinta sobre papel, mono para estructura, serif para lo que se lee. */
3
+ body { display:flex; flex-direction:column; height:100vh; overflow:hidden; }
4
+ [hidden] { display:none !important; }
5
+
6
+ .tbar { display:flex; align-items:center; gap:14px; height:48px; padding:0 16px; border-bottom:1px solid var(--rule); flex:none; font-family:var(--mono); }
7
+ .tbar .back { color:var(--ink-2); text-decoration:none; font-size:16px; padding:2px 6px; border-radius:2px; }
8
+ .tbar .back:hover { color:var(--ink); background:var(--paper-2); }
9
+ .tbar .brand { font:600 13px/1 var(--mono); letter-spacing:.04em; }
10
+ .tbar .proj { color:var(--ink-3); font-weight:400; margin-left:8px; }
11
+ .tabs { display:flex; gap:4px; margin-left:12px; }
12
+ .tabs button { border:none; padding:8px 12px; border-radius:2px; }
13
+ .tabs button.on { color:var(--ink); background:var(--paper-3); }
14
+ .live { font:400 10.5px/1 var(--mono); color:var(--ink-3); text-transform:uppercase; letter-spacing:.09em; }
15
+ .live::before { content:""; display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--ok); margin-right:6px; vertical-align:1px; }
16
+ .live.off::before { background:var(--rubric); }
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); }
20
+
21
+ /* lo que espera a la persona */
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; }
23
+ .ask { display:flex; align-items:flex-start; gap:12px; }
24
+ .ask .who { font:600 11px/1.6 var(--mono); color:var(--amber); white-space:nowrap; text-transform:uppercase; letter-spacing:.06em; }
25
+ .ask.approval .who { color:var(--rubric); }
26
+ .ask .q { flex:1; min-width:0; }
27
+ .ask .q .ref { font:400 11px/1 var(--mono); color:var(--ink-3); cursor:pointer; }
28
+ .ask .acts { display:flex; gap:6px; flex:none; align-items:center; }
29
+ .ask input { font:400 13px/1.4 var(--serif); background:var(--paper); color:var(--ink); border:1px solid var(--rule-2); border-radius:2px; padding:6px 8px; width:260px; }
30
+ button.ok { color:var(--paper); background:var(--ok); border-color:var(--ok); }
31
+ button.no { color:var(--rubric); border-color:var(--rubric); }
32
+
33
+ /* tres columnas */
34
+ .view { flex:1; min-height:0; display:grid; grid-template-columns:300px minmax(0, 1fr) 360px; }
35
+ .view[hidden] { display:none; }
36
+ .col { min-height:0; overflow:auto; }
37
+ .col.list { border-right:1px solid var(--rule); }
38
+ .col.timeline { border-left:1px solid var(--rule); background:var(--paper-2); }
39
+ .colhead { position:sticky; top:0; z-index:2; display:flex; align-items:center; justify-content:space-between; padding:12px 16px; background:inherit; border-bottom:1px solid var(--rule); font:600 10.5px/1 var(--mono); color:var(--ink-2); text-transform:uppercase; letter-spacing:.09em; }
40
+ .col.list .colhead { background:var(--paper); }
41
+
42
+ .items { list-style:none; margin:0; padding:6px; }
43
+ .items li { padding:10px 10px; border-radius:3px; cursor:pointer; border:1px solid transparent; }
44
+ .items li:hover { background:var(--paper-2); }
45
+ .items li.on { background:var(--paper-3); border-color:var(--rule-2); }
46
+ .items .top { display:flex; align-items:center; gap:8px; font:400 11px/1.4 var(--mono); color:var(--ink-3); }
47
+ .items .txt { margin-top:4px; font-size:13.5px; line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
48
+ .hint { padding:14px 16px; color:var(--ink-3); font-size:13px; }
49
+ .hint code { font:400 12px/1.4 var(--mono); background:var(--paper-2); padding:1px 4px; border-radius:2px; }
50
+
51
+ /* estado */
52
+ .st { font:600 9.5px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; padding:3px 6px; border-radius:2px; border:1px solid var(--rule-2); color:var(--ink-2); }
53
+ .st.active { color:var(--accent); border-color:var(--accent); }
54
+ .st.waiting { color:var(--rubric); border-color:var(--rubric); }
55
+ .st.done { color:var(--ok); border-color:var(--ok); }
56
+ .st.failed, .st.cancelled { color:var(--ink-3); }
57
+ .st.paused { color:var(--amber); border-color:var(--amber); }
58
+ .dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--rule-2); flex:none; }
59
+ .dot.on { background:var(--accent); animation:pulse 1.4s ease-in-out infinite; }
60
+ @keyframes pulse { 50% { opacity:.35; } }
61
+
62
+ /* formulario */
63
+ .newform { padding:12px 16px 16px; border-bottom:1px solid var(--rule); display:flex; flex-direction:column; gap:10px; }
64
+ .newform label { display:flex; flex-direction:column; gap:4px; font:600 10px/1 var(--mono); color:var(--ink-2); text-transform:uppercase; letter-spacing:.08em; }
65
+ .newform select, .newform textarea, .newform input { font:400 13.5px/1.45 var(--serif); text-transform:none; letter-spacing:0; color:var(--ink); background:var(--paper-2); border:1px solid var(--rule-2); border-radius:2px; padding:7px 8px; }
66
+ .newform textarea { resize:vertical; }
67
+ .row2 { display:flex; gap:8px; }
68
+ .row2 > * { flex:1; }
69
+ .ferr { color:var(--rubric); font-size:12.5px; margin:0; min-height:1em; }
70
+
71
+ /* detalle de un objetivo */
72
+ .detail { padding:22px 28px 40px; }
73
+ .empty { color:var(--ink-3); max-width:520px; margin:12vh auto 0; text-align:center; }
74
+ .dhead { display:flex; align-items:center; gap:10px; flex-wrap:wrap; font:400 12px/1 var(--mono); color:var(--ink-3); }
75
+ .dhead .ref { font-weight:600; color:var(--ink); font-size:13px; }
76
+ .dtext { font-size:18px; line-height:1.5; margin:12px 0 16px; max-width:900px; }
77
+ .meter { height:4px; background:var(--rule); border-radius:2px; overflow:hidden; max-width:420px; }
78
+ .meter i { display:block; height:100%; background:var(--accent); }
79
+ .meter.hot i { background:var(--amber); }
80
+ .kv { display:flex; gap:22px; flex-wrap:wrap; margin:10px 0 18px; font:400 11.5px/1.4 var(--mono); color:var(--ink-3); }
81
+ .kv b { color:var(--ink); font-weight:600; }
82
+ .box { border:1px solid var(--rule); border-radius:3px; padding:12px 14px; margin:0 0 14px; max-width:900px; }
83
+ .box h5 { margin:0 0 6px; font:600 10px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); }
84
+ .box.q { border-color:var(--rubric); }
85
+ .box.res { border-color:var(--ok); }
86
+ .box p { margin:0; white-space:pre-wrap; }
87
+ .dacts { display:flex; gap:8px; margin:6px 0 20px; }
88
+
89
+ /* tablero (kanban) */
90
+ .board { display:grid; grid-template-columns:repeat(5, minmax(150px, 1fr)); gap:10px; margin-top:8px; }
91
+ .lane { background:var(--paper-2); border:1px solid var(--rule); border-radius:3px; min-height:80px; display:flex; flex-direction:column; }
92
+ .lane h6 { margin:0; padding:9px 10px; font:600 10px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); border-bottom:1px solid var(--rule); display:flex; justify-content:space-between; }
93
+ .cards { padding:8px; display:flex; flex-direction:column; gap:6px; }
94
+ .card { background:var(--paper); border:1px solid var(--rule-2); border-radius:3px; padding:8px 9px; font-size:13px; line-height:1.4; }
95
+ .card .cid { font:400 10.5px/1 var(--mono); color:var(--ink-3); }
96
+ .card .own { display:block; margin-top:6px; font:600 10px/1 var(--mono); color:var(--accent); }
97
+ .card .notes { margin-top:4px; color:var(--ink-2); font-size:12px; }
98
+ .card .dep { font:400 10px/1.4 var(--mono); color:var(--amber); }
99
+ .secttl { margin:22px 0 4px; font:600 10.5px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-2); }
100
+
101
+ /* registro */
102
+ .log { list-style:none; margin:0; padding:8px 16px 30px; }
103
+ .log li { padding:8px 0; border-bottom:1px dashed var(--rule); font-size:13px; line-height:1.45; }
104
+ .log .t { font:400 10.5px/1 var(--mono); color:var(--ink-3); }
105
+ .log .a { font:600 11px/1 var(--mono); color:var(--ink); margin:0 4px; }
106
+ .log .k { font:400 11px/1 var(--mono); color:var(--accent); }
107
+ .log .k.message { color:var(--str); }
108
+ .log .k.approval, .log .k.asked, .log .k.denied, .log .k.budget, .log .k.paused, .log .k.failed { color:var(--rubric); }
109
+ .log .k.done, .log .k.approved { color:var(--ok); }
110
+ .log .x { display:block; color:var(--ink-2); margin-top:3px; white-space:pre-wrap; word-break:break-word; }
111
+ .log li.fresh { animation:fresh 2.5s ease-out; }
112
+ @keyframes fresh { from { background:var(--accent-bg); } to { background:transparent; } }
113
+
114
+ /* grafo del equipo */
115
+ .graphwrap { border:1px solid var(--rule); border-radius:3px; background:var(--paper-2); height:min(46vh, 460px); }
116
+ #graph { width:100%; height:100%; display:block; }
117
+ #graph .edge { stroke:var(--rule-2); stroke-width:1.6; fill:none; }
118
+ #graph .edge.talk { stroke-dasharray:5 5; }
119
+ #graph .edge.hot { stroke:var(--str); stroke-width:2.6; }
120
+ #graph .node rect { fill:var(--paper); stroke:var(--rule-2); stroke-width:1.2; rx:6; }
121
+ #graph .node.working rect { stroke:var(--accent); stroke-width:2; }
122
+ #graph .node.missing rect { stroke:var(--rubric); stroke-dasharray:4 3; }
123
+ #graph .node .role { font:600 15px var(--mono); fill:var(--ink); }
124
+ #graph .node .id { font:400 12.5px var(--mono); fill:var(--ink-3); }
125
+ #graph .node .state { font:400 11.5px var(--mono); fill:var(--ink-3); }
126
+ #graph .node.working .state { fill:var(--accent); }
127
+ #graph .node .pip { fill:var(--rule-2); }
128
+ #graph .node.working .pip { fill:var(--accent); animation:pulse 1.4s ease-in-out infinite; }
129
+ .teaminfo { display:flex; gap:22px; flex-wrap:wrap; margin:12px 0 4px; font:400 11.5px/1.4 var(--mono); color:var(--ink-3); }
130
+ .teaminfo b { color:var(--ink); }
131
+
132
+ /* editor de equipos */
133
+ #teamBoard:has(.editor) { display:block; }
134
+ .row2 > * { min-width:0; }
135
+ .editor { display:grid; grid-template-columns:minmax(260px, 1fr) minmax(320px, 1.4fr); gap:18px; margin-top:6px; }
136
+ .edcol { display:flex; flex-direction:column; gap:10px; border:1px solid var(--rule); border-radius:3px; padding:14px; }
137
+ .edcol h5 { margin:0 0 2px; font:600 10px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); }
138
+ .edcol label { display:flex; flex-direction:column; gap:4px; font:600 10px/1.3 var(--mono); color:var(--ink-2); text-transform:uppercase; letter-spacing:.07em; }
139
+ .edcol input, .edcol select, .edcol textarea { font:400 13.5px/1.45 var(--serif); text-transform:none; letter-spacing:0; color:var(--ink); background:var(--paper-2); border:1px solid var(--rule-2); border-radius:2px; padding:7px 8px; }
140
+ .edcol input:disabled { opacity:.6; }
141
+ .edcol label.chk { flex-direction:row; align-items:center; gap:8px; text-transform:none; font:400 13px/1.4 var(--serif); letter-spacing:0; }
142
+ .chips { display:flex; flex-wrap:wrap; gap:6px; text-transform:none; }
143
+ .chip { flex-direction:row !important; align-items:center; gap:5px !important; font:400 12px/1 var(--mono) !important; letter-spacing:0 !important; text-transform:none !important; border:1px solid var(--rule-2); border-radius:2px; padding:5px 7px; }
144
+ #graph .node { cursor:default; }
145
+ #graph .node.sel rect { stroke:var(--amber); stroke-width:2.4; }
146
+ .teaminfo button { padding:5px 9px; }
147
+
148
+ @media (max-width: 1100px) {
149
+ .view { grid-template-columns:240px minmax(0, 1fr); }
150
+ .col.timeline { display:none; }
151
+ .board { grid-template-columns:repeat(2, 1fr); }
152
+ }
153
+ @media (max-width: 720px) {
154
+ body { overflow:auto; height:auto; }
155
+ .view { display:block; }
156
+ .col.list { border-right:none; border-bottom:1px solid var(--rule); max-height:40vh; }
157
+ .detail { padding:16px; }
158
+ .board { grid-template-columns:1fr; }
159
+ .ask { flex-direction:column; }
160
+ .ask input { width:100%; }
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/index.html CHANGED
@@ -32,6 +32,7 @@
32
32
  <span class="spacer"></span>
33
33
  <button class="hbtn upd" id="update" style="display:none"></button>
34
34
  <button class="hbtn" id="term" title="terminal real (shell en el workspace): lo abre, lo trae de vuelta si está minimizado y lo esconde si está a la vista — verde = shell abierta">&gt;_ terminal</button>
35
+ <button class="hbtn" id="teamsBtn" title="objetivos y equipos de agentes: lo que trabajan solos, sus tableros y quién reporta a quién (pantalla propia)">equipos</button>
35
36
  <button class="hbtn" id="new" title="empezar una conversación nueva">+ sesión</button>
36
37
  <button class="theme-toggle" id="cfgBtn" type="button" title="configuración: zona horaria, aprobaciones a distancia, proveedor"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3h.1a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8v.1a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/></svg></button>
37
38
  <button class="theme-toggle" id="theme" type="button" title="cambiar tema"></button>
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
- 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>`;
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);
@@ -62,6 +62,8 @@ async function openSession(id) {
62
62
  }
63
63
  loadSessions();
64
64
  }
65
+ // objetivos y equipos: su pantalla propia (public/teams.html)
66
+ $('#teamsBtn').onclick = () => { location.href = BASE + '/equipos'; };
65
67
  $('#new').onclick = () => { session = ''; localStorage.removeItem('lampson.session'); log.innerHTML = ''; showPane('log'); empty(); loadSessions(); loadTodo(); };
66
68
  // traza legible de una sesión (.lampson/trace/<sid>.log)
67
69
  async function openTrace(id) {