lampson 0.5.2 → 0.5.4

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.
Files changed (81) hide show
  1. package/chat.syn +17 -12
  2. package/cli.syn +8 -1
  3. package/hub.tpl.syn +4 -4
  4. package/lampson.ps1 +9 -7
  5. package/lampson.sh +22 -8
  6. package/lib/agents.syn +35 -27
  7. package/lib/api.syn +37 -35
  8. package/lib/apikeys.syn +8 -8
  9. package/lib/approvals.syn +11 -7
  10. package/lib/apptools.syn +27 -24
  11. package/lib/channels.syn +38 -36
  12. package/lib/computer.syn +20 -20
  13. package/lib/diagnose.syn +9 -7
  14. package/lib/fs.syn +11 -11
  15. package/lib/judge.syn +4 -4
  16. package/lib/loop.syn +46 -21
  17. package/lib/lsp.syn +13 -13
  18. package/lib/mailbox.syn +34 -24
  19. package/lib/mcp.syn +25 -17
  20. package/lib/mcp_server.syn +34 -26
  21. package/lib/permission.syn +3 -1
  22. package/lib/plugins.syn +48 -40
  23. package/lib/prompt.syn +5 -5
  24. package/lib/provider.syn +25 -11
  25. package/lib/remotetools.syn +3 -1
  26. package/lib/runtime.syn +112 -85
  27. package/lib/sched_run.syn +19 -13
  28. package/lib/schedule.syn +25 -23
  29. package/lib/session.syn +6 -6
  30. package/lib/settings.syn +10 -10
  31. package/lib/skills.syn +9 -9
  32. package/lib/teamrun.syn +75 -28
  33. package/lib/teams.syn +190 -115
  34. package/lib/term.syn +2 -2
  35. package/lib/tools/bash.syn +2 -2
  36. package/lib/tools/common.syn +3 -3
  37. package/lib/tools/edit.syn +1 -1
  38. package/lib/tools/fetch.syn +7 -3
  39. package/lib/tools/find.syn +1 -1
  40. package/lib/tools/grep.syn +2 -2
  41. package/lib/tools/ls.syn +1 -1
  42. package/lib/tools/memo.syn +7 -7
  43. package/lib/tools/proc.syn +10 -10
  44. package/lib/tools/process.syn +1 -1
  45. package/lib/tools/read.syn +2 -2
  46. package/lib/tools/todo.syn +3 -3
  47. package/lib/tools/write.syn +1 -1
  48. package/lib/tools.syn +17 -15
  49. package/lib/trace.syn +5 -5
  50. package/lib/tree.syn +3 -3
  51. package/lib/update.syn +6 -0
  52. package/lib/workspaces.syn +76 -62
  53. package/lib/worktree.syn +323 -24
  54. package/package.json +2 -2
  55. package/plugins/chatwoot/plugin.syn +2 -0
  56. package/plugins/orders/plugin.json +1 -1
  57. package/plugins/orders/plugin.syn +1 -1
  58. package/plugins/telegram/plugin.syn +2 -0
  59. package/public/css/inbox.css +100 -0
  60. package/public/css/mobile.css +0 -13
  61. package/public/css/panel.css +21 -0
  62. package/public/css/teams.css +20 -52
  63. package/public/hub.html +3 -0
  64. package/public/index.html +3 -0
  65. package/public/js/config.js +3 -3
  66. package/public/js/devices.js +1 -1
  67. package/public/js/hub.js +3 -2
  68. package/public/js/inbox.js +234 -0
  69. package/public/js/navtabs.js +1 -6
  70. package/public/js/objlive.js +11 -3
  71. package/public/js/panel.js +12 -6
  72. package/public/js/teams-home.js +3 -33
  73. package/public/js/teams.js +35 -114
  74. package/public/js/workspaces.js +1 -1
  75. package/public/plugins-home.html +3 -0
  76. package/public/tasks-home.html +3 -0
  77. package/public/teams-home.html +3 -1
  78. package/public/teams.html +3 -2
  79. package/run.syn +17 -12
  80. package/skills/synsema/SKILL.md +3 -3
  81. package/web.syn +10 -7
package/lib/worktree.syn CHANGED
@@ -6,7 +6,7 @@
6
6
  -- quién hizo cada commit. La copia principal (la de la persona, con main) no se toca.
7
7
  -- * .lampson/ queda en .git/info/exclude (exclusión local: no cambia ningún archivo del repo)
8
8
  -- * lib/loop.syn traduce: las tools de archivos y bash del agente operan en su copia; para él es la raíz
9
- -- * un merge/push que sale de su copia (toca la historia compartida) pide aprobación a la persona (lib/loop.syn)
9
+ -- * la regla del asiento (abajo): autonomía total en su copia; integrar a main y el push los aprueba la persona
10
10
  use "./tools/common.syn" as c
11
11
 
12
12
  export let DIR be ".lampson/worktrees"
@@ -16,7 +16,7 @@ task git(args, cwd)
16
16
  require exec
17
17
  require time
18
18
  require file("workspace")
19
- require file("workspace/*")
19
+ require file("workspace/**")
20
20
  try
21
21
  let r be run(G, args, 30, {"cwd": cwd})
22
22
  give {"ok": r["exit_code"] == 0, "out": trim(r["stdout"] + "\n" + r["stderr"])}
@@ -28,7 +28,7 @@ export task is_repo()
28
28
  require exec
29
29
  require time
30
30
  require file("workspace")
31
- require file("workspace/*")
31
+ require file("workspace/**")
32
32
  give git(["rev-parse", "--verify", "HEAD"], c.ROOT)["ok"]
33
33
 
34
34
  -- la copia de `agent` (la crea si falta). → {ok, root, branch, error}; root es relativa al workspace
@@ -36,7 +36,7 @@ export task ensure(team_id, agent, author)
36
36
  require exec
37
37
  require time
38
38
  require file("workspace")
39
- require file("workspace/*")
39
+ require file("workspace/**")
40
40
  let rel be DIR + "/" + agent
41
41
  let branch be "team/" + team_id + "/" + agent
42
42
  when not is_repo()
@@ -61,6 +61,40 @@ export task ensure(team_id, agent, author)
61
61
  git(["config", "--worktree", "user.email", author["email"]], c.ROOT + "/" + rel)
62
62
  give {"ok": true, "root": rel, "branch": branch, "error": ""}
63
63
 
64
+ -- la copia de un asiento, al día con la rama principal antes de su turno. Sin trabajo propio pendiente (nada suyo
65
+ -- que main no tenga, nada sin commitear) avanza sola a main; si tiene, se le avisa cuánto quedó atrás. (Visto en O-16:
66
+ -- las copias estaban 8 a 22 commits detrás, el CPO leyó un CHANGELOG de tres versiones atrás y propuso features que ya
67
+ -- estaban: un tercio del gasto en rehacerlo.) → {behind, ahead, moved, note} (note: lo que el agente tiene que saber)
68
+ export task sync(team_id, agent)
69
+ require exec
70
+ require time
71
+ require file("workspace")
72
+ require file("workspace/**")
73
+ let rel be DIR + "/" + agent
74
+ let branch be "team/" + team_id + "/" + agent
75
+ let out be {"behind": 0, "ahead": 0, "moved": false, "note": ""}
76
+ when not is_repo() or not git(["rev-parse", "--verify", "--quiet", "refs/heads/" + branch], c.ROOT)["ok"]
77
+ give out
78
+ let into be main_branch()
79
+ when into == branch or into == "HEAD"
80
+ give out
81
+ let bh be git(["rev-list", "--count", branch + ".." + into], c.ROOT)
82
+ let ah be git(["rev-list", "--count", into + ".." + branch], c.ROOT)
83
+ set out["behind"] to when bh["ok"] then int(bh["out"]) otherwise 0
84
+ set out["ahead"] to when ah["ok"] then int(ah["out"]) otherwise 0
85
+ when out["behind"] == 0
86
+ give out
87
+ let has_copy be file_exists(c.ROOT + "/" + rel + "/.git")
88
+ let dirty be when has_copy then git(["status", "--porcelain"], c.ROOT + "/" + rel)["out"] != "" otherwise false
89
+ when out["ahead"] == 0 and not dirty
90
+ let mv be when has_copy then git(["merge", "--ff-only", "-q", into], c.ROOT + "/" + rel) otherwise git(["branch", "-f", branch, into], c.ROOT)
91
+ when mv["ok"]
92
+ set out["moved"] to true
93
+ set out["note"] to "Lampson brought your copy up to date with " + into + " before this turn (" + text(out["behind"]) + " new commit" + (when out["behind"] == 1 then "" otherwise "s") + " integrated by the team)."
94
+ give out
95
+ set out["note"] to "Your branch is " + text(out["behind"]) + " commit" + (when out["behind"] == 1 then "" otherwise "s") + " behind " + into + " (the team integrated work since you branched)" + (when out["ahead"] > 0 then " and has " + text(out["ahead"]) + " of your own not in it" otherwise "") + (when dirty then ", with uncommitted changes" otherwise "") + ". Before you read or build on the project, bring " + into + " in: `git merge " + into + "` in your copy" + (when dirty then " (commit or stash first)" otherwise "") + "."
96
+ give out
97
+
64
98
  -- el asiento de un equipo que se borra: su copia se va (lo que tenía sin commitear queda en un commit «wip»); su rama
65
99
  -- se borra si ya está en la rama principal, y si no, se renombra a archive/<equipo>/<agente>-<fecha>: el trabajo no se
66
100
  -- pierde, pero un equipo nuevo con el mismo nombre arranca de cero. → {copy, branch} (qué pasó con cada una)
@@ -68,7 +102,7 @@ export task retire(team_id, agent)
68
102
  require exec
69
103
  require time
70
104
  require file("workspace")
71
- require file("workspace/*")
105
+ require file("workspace/**")
72
106
  let rel be DIR + "/" + agent
73
107
  let branch be "team/" + team_id + "/" + agent
74
108
  let out be {"copy": "", "branch": ""}
@@ -95,7 +129,7 @@ export task main_branch()
95
129
  require exec
96
130
  require time
97
131
  require file("workspace")
98
- require file("workspace/*")
132
+ require file("workspace/**")
99
133
  let r be git(["rev-parse", "--abbrev-ref", "HEAD"], c.ROOT)
100
134
  give when r["ok"] then r["out"] otherwise "main"
101
135
 
@@ -106,7 +140,7 @@ export task preview(command)
106
140
  require exec
107
141
  require time
108
142
  require file("workspace")
109
- require file("workspace/*")
143
+ require file("workspace/**")
110
144
  let cmd be " " + replace(text(command), "\n", " ") + " "
111
145
  when not is_repo()
112
146
  give nothing
@@ -156,7 +190,7 @@ task with_diff(o, a, b)
156
190
  require exec
157
191
  require time
158
192
  require file("workspace")
159
- require file("workspace/*")
193
+ require file("workspace/**")
160
194
  let out be o
161
195
  let commits be []
162
196
  let lg be git(["log", "--no-merges", "--format=%h%x09%an%x09%s", "-n", "12", a + ".." + b], c.ROOT)
@@ -179,35 +213,300 @@ task with_diff(o, a, b)
179
213
  give out
180
214
 
181
215
  -- las tools que operan en la copia del agente, y cómo se traducen sus args
182
- export let FILE_TOOLS be ["read", "write", "edit", "ls", "find", "grep"]
216
+ export let FILE_TOOLS be ["read", "write", "edit", "ls", "find", "grep", "lsp"]
183
217
 
184
218
  export task rooted(name, args, root)
185
219
  let a be args
186
- when name == "bash"
187
- set a["command"] to "cd \"" + root + "\" && " + text(args["command"])
220
+ when name == "bash" or name == "process"
221
+ when contains(args, "command") and args["command"] != nothing and text(args["command"]) != ""
222
+ set a["command"] to "cd \"" + root + "\" && " + text(args["command"])
188
223
  give a
189
224
  let p be when contains(args, "path") and args["path"] != nothing then replace(text(args["path"]), "\\", "/") otherwise "."
190
225
  while starts_with(p, "./")
191
226
  set p to slice(p, 2, length(p))
192
227
  when p == "." or p == ""
193
228
  set a["path"] to root
194
- otherwise when starts_with(p, root + "/") or p == root or starts_with(p, ".lampson/spill/")
229
+ otherwise when starts_with(p, root + "/") or p == root or starts_with(p, ".lampson/spill/") or absolute_path(p) != ""
195
230
  set a["path"] to p
196
231
  otherwise
197
232
  set a["path"] to root + "/" + p
198
233
  give a
199
234
 
200
- -- ¿este comando toca la historia compartida desde una copia de agente? push siempre; merge/rebase/update-ref/branch -f
201
- -- cuando sale de su copia (-C, cd o ../): adentro de su copia puede traer main a su rama sin pedir nada
202
- export task touches_shared(command)
203
- let cmd be " " + lower(replace(text(command), "\n", " ")) + " "
204
- when not contains(cmd, "git")
235
+ -- ---------- la regla del asiento (equipos con git) ----------
236
+ -- Un equipo es una organización: cada asiento tiene TODAS las herramientas y autonomía total en su copia (su puesto) y
237
+ -- en las de la gente a su cargo (un jefe arregla lo de los suyos; el líder, lo de todos). La persona es el directorio:
238
+ -- aprueba solo lo que cruza el borde — tocar su copia del proyecto (integrar a main, una vez por objetivo) y cada push
239
+ -- — y nada sale del proyecto. bash no lo encierra el sistema operativo: acá se lee el comando como lo leería el shell
240
+ -- (sin el texto entre comillas ni los heredocs, siguiendo cada cd) y se frena lo que cae fuera de su puesto, con un
241
+ -- mensaje que dice que es una regla del equipo y no un error del comando (si no, el modelo cree que se equivocó de
242
+ -- sintaxis y prueba variantes o inventa la causa).
243
+ export let GIT_READ be ["log", "diff", "show", "status", "branch", "rev-parse", "merge-base", "ls-files", "ls-tree", "blame", "shortlog", "describe", "cat-file", "rev-list", "grep", "for-each-ref", "fetch", "tag", "reflog", "help", "version"]
244
+ -- comandos que solo miran: con ellos un asiento lee en todo el proyecto
245
+ export let READ_CMDS be ["cat", "head", "tail", "less", "more", "ls", "dir", "tree", "pwd", "echo", "printf", "grep", "egrep", "fgrep", "rg", "find", "wc", "diff", "cmp", "stat", "file", "du", "df", "sort", "uniq", "cut", "tr", "jq", "basename", "dirname", "realpath", "readlink", "which", "type", "test", "[", "true", "false", "sleep", "date", "env", "printenv", "nl", "od", "xxd", "md5sum", "sha1sum", "sha256sum", "column", "fold", "cd", "pushd", "popd", "exit"]
246
+ let RULE be "NOT RUN — your command is fine (this is not a syntax or tool error): it breaks a team rule. "
247
+
248
+ -- hasta dónde sube una ruta relativa desde la copia: «../dev» 1, «../../..» 3 (la copia principal), 4 o más sale del
249
+ -- proyecto. Un rango de git (main..HEAD) no es una ruta: los «..» tienen que estar sueltos o entre separadores.
250
+ export task climbs(cmd)
251
+ let most be 0
252
+ each m in regex_find_all(cmd, "(^|[\\s\"'=:(<>])((\\.\\.[\\\\/])*\\.\\.)([\\\\/]|$|[\\s\"';&|)])")
253
+ let n be length(split(m, "..")) - 1
254
+ when n > most
255
+ set most to n
256
+ give most
257
+
258
+ -- la primera ruta absoluta del comando ("" si no hay): /algo, C:\…, ~, $HOME. /dev/null y las URLs no cuentan.
259
+ export task absolute_path(cmd)
260
+ let t be regex_replace(" " + lower(cmd) + " ", "/dev/(null|stdout|stderr)", " ")
261
+ set t to regex_replace(t, "[a-z][a-z0-9+.-]*://\\S*", " ")
262
+ let m be regex_find_all(t,"(^|[\\s\"'=<>(;&|])(/[a-z0-9_.~$-]|/\\s|[a-z]:[\\\\/]|~[\\\\/\\s]|\\$home\\b|\\$\\{home\\}|%userprofile%)")
263
+ give when length(m) == 0 then "" otherwise trim(regex_replace(m[0], "^[\\s\"'=<>(;&|]", ""))
264
+
265
+ -- el comando sin lo que es texto y no ruta: el cuerpo de un heredoc, y lo que va entre comillas con espacios (un
266
+ -- mensaje de commit, un patrón de grep, el código de un python -c: «PATCH /tasks/:id» no es una ruta). Entre comillas
267
+ -- sin espacios («"../dev"») sí puede ser una ruta y queda, sin las comillas. Los saltos de línea separan comandos.
268
+ export task plain(cmd)
269
+ let lines be split(replace(text(cmd), "\r", ""), "\n")
270
+ let kept be []
271
+ let endtag be ""
272
+ each l in lines
273
+ when endtag != ""
274
+ when trim(l) == endtag
275
+ set endtag to ""
276
+ otherwise
277
+ set kept to append(kept, l)
278
+ let h be regex_find_all(l, "(^|[^<])<<-?\\s*['\"]?[A-Za-z_][A-Za-z0-9_]*")
279
+ when length(h) > 0
280
+ set endtag to regex_replace(h[0], "^[^<]?<<-?\\s*['\"]?", "")
281
+ let s be join(kept, " ; ")
282
+ let out be ""
283
+ let i be 0
284
+ let n be length(s)
285
+ while i < n
286
+ let ch be slice(s, i, i + 1)
287
+ when ch == "'" or ch == "\""
288
+ let j be i + 1
289
+ let body be ""
290
+ while j < n and slice(s, j, j + 1) != ch
291
+ when ch == "\"" and slice(s, j, j + 1) == "\\" and j + 1 < n
292
+ set body to body + slice(s, j, j + 2)
293
+ set j to j + 2
294
+ otherwise
295
+ set body to body + slice(s, j, j + 1)
296
+ set j to j + 1
297
+ -- «tr '\n' ','»: un escape solo no es una ruta (con \ → / se leería «/n», absoluta); un patrón con |
298
+ -- tampoco («grep "x\|/done"»): ninguna ruta lleva |
299
+ set out to out + (when matches(body, ".*\\s.*") or body == "" or matches(body, "^(\\\\[a-z0-9]+)+$") or contains(body, "|") then " Q " otherwise body)
300
+ set i to j + 1
301
+ otherwise
302
+ set out to out + ch
303
+ set i to i + 1
304
+ give out
305
+
306
+ -- los comandos de una línea de shell (&&, ||, ; y |)
307
+ export task segments(cmd)
308
+ give where(apply(split(regex_replace(cmd, "&&|\\|\\||;|\\|", "\n"), "\n"), (s) => trim(s)), (s) => s != "")
309
+
310
+ -- el subcomando de git de un segmento ("git -C ../dev --no-pager diff x" → "diff"); "" si no es git
311
+ export task git_sub(seg)
312
+ let w be where(split(regex_replace(trim(seg), "\\s+", " "), " "), (x) => x != "")
313
+ when length(w) == 0 or w[0] != "git"
205
314
  give ""
206
- when matches(cmd, ".*\\bgit\\b.*\\bpush\\b.*")
207
- give "git push"
208
- let leaves be contains(cmd, " -c ") or contains(cmd, "../") or contains(cmd, "..\\") or matches(cmd, ".*\\bcd\\b.*")
209
- when leaves and matches(cmd, ".*\\bgit\\b.*\\b(merge|rebase|update-ref|cherry-pick|reset)\\b.*")
210
- give "git merge/rebase/reset outside your working copy"
211
- when matches(cmd, ".*\\bgit\\b.*\\bbranch\\b.*\\s-(f|d|D)\\b.*") or matches(cmd, ".*\\bgit\\b.*\\bupdate-ref\\b.*")
212
- give "git branch -f/-d or update-ref"
315
+ let i be 1
316
+ while i < length(w)
317
+ let t be w[i]
318
+ when t == "-c" or t == "-C" or t == "--git-dir" or t == "--work-tree"
319
+ set i to i + 2
320
+ otherwise when starts_with(t, "-")
321
+ set i to i + 1
322
+ otherwise
323
+ give t
213
324
  give ""
325
+
326
+ -- una ruta desde un lugar del proyecto. Un lugar es la lista de carpetas desde la raíz de la copia principal ([] es la
327
+ -- raíz; [".lampson", "worktrees", "dev"] la copia de dev); si empieza con «..» quedó fuera del proyecto.
328
+ -- «@root» es la raíz del proyecto (así se reescribe su ruta absoluta).
329
+ export task walk(start, p)
330
+ let out be start
331
+ let q be replace(p, "\\", "/")
332
+ when starts_with(q, "@root")
333
+ set out to []
334
+ set q to slice(q, 5, length(q))
335
+ each part in split(q, "/")
336
+ when part == ".."
337
+ when length(out) > 0 and out[length(out) - 1] != ".."
338
+ set out to slice(out, 0, length(out) - 1)
339
+ otherwise
340
+ set out to append(out, "..")
341
+ otherwise when part != "" and part != "."
342
+ set out to append(out, part)
343
+ give out
344
+
345
+ -- qué es un lugar: {kind: mine | peer | lampson | main | outside, agent}
346
+ export task zone(loc, me)
347
+ when length(loc) > 0 and loc[0] == ".."
348
+ give {"kind": "outside", "agent": ""}
349
+ when length(loc) >= 3 and loc[0] == ".lampson" and loc[1] == "worktrees"
350
+ give {"kind": when loc[2] == lower(me["agent"]) then "mine" otherwise "peer", "agent": loc[2]}
351
+ when length(loc) > 0 and loc[0] == ".lampson"
352
+ give {"kind": "lampson", "agent": ""}
353
+ give {"kind": "main", "agent": ""}
354
+
355
+ -- ¿la palabra es una ruta? (tiene separadores o es «..»/«.»); un rango de git (main..HEAD) o una URL no
356
+ task pathish(w)
357
+ when w == ".." or w == "." or starts_with(w, "@root")
358
+ give true
359
+ when contains(w, "://") or not (contains(w, "/") or contains(w, "\\"))
360
+ give false
361
+ give true
362
+
363
+ -- los que dependen de un asiento, directa o indirectamente (me.below lo arma runtime.syn con teams.below)
364
+ task below(me)
365
+ give when contains(me, "below") and me["below"] != nothing then apply(me["below"], (x) => lower(text(x))) otherwise []
366
+
367
+ task seat_deny(why, note)
368
+ give {"decision": "deny", "reason": "team rule: " + why, "note": RULE + note, "grant": false}
369
+
370
+ -- ¿puede cambiar algo en ese lugar? → nothing (sí) o el veredicto (deny / ask para integrar)
371
+ task may_change(z, me, what)
372
+ let mine be "team/" + lower(me["team"]) + "/" + lower(me["agent"])
373
+ when z["kind"] == "mine"
374
+ give nothing
375
+ when z["kind"] == "peer"
376
+ when me["lead"] or contains(below(me), z["agent"])
377
+ give nothing
378
+ give seat_deny("not your copy", "`" + what + "` would change " + z["agent"] + "'s copy (../" + z["agent"] + "), and " + z["agent"] + " does not work under you. Read it as much as you want; to change it, bring their branch into your copy (git merge team/" + lower(me["team"]) + "/" + z["agent"] + "), or tell " + z["agent"] + " what to fix with `send`.")
379
+ when z["kind"] == "main"
380
+ when not me["lead"] and length(below(me)) == 0
381
+ give seat_deny("the person's copy", "`" + what + "` would change the main checkout (../../..), the person's own copy. Whoever leads or reviews integrates into it. Commit on your branch (" + mine + ") and `send` " + (when me["boss"] != "" then me["boss"] otherwise "your lead") + " that it is ready.")
382
+ when me["integration_ok"]
383
+ give nothing
384
+ give {"decision": "ask", "reason": "works in the person's own copy of the project (" + me["main"] + ": integrating, fixing, tagging) — the person approves once per objective: after that, this objective doesn't ask again", "note": "", "grant": true}
385
+ when z["kind"] == "lampson"
386
+ give seat_deny("Lampson's folder", "`" + what + "` would change Lampson's own folder (.lampson). The copies are ../<agent> and the main checkout is ../../..")
387
+ give seat_deny("outside the project", "`" + what + "` points outside the project, and nobody in a team works outside the project. Bash starts in your copy; use paths relative to it (other copies: ../<agent>, the main checkout: ../../..).")
388
+
389
+ -- qué hace un asiento con un comando de bash. me = {agent, team, lead (bool), below (los que dependen de él), boss,
390
+ -- main (rama principal), home (ruta absoluta del proyecto, opcional), integration_ok (bool: la persona ya aprobó
391
+ -- trabajar en su copia en este objetivo)} → {decision: allow|ask|deny, reason, note (lo que lee el modelo si no corre),
392
+ -- grant (aprobarlo vale para el resto del objetivo)}
393
+ export task seat_bash(command, me)
394
+ let mine be "team/" + lower(me["team"]) + "/" + lower(me["agent"])
395
+ let cmd be " " + lower(replace(plain(command), "\\", "/")) + " "
396
+ let home be when contains(me, "home") and me["home"] != nothing then lower(replace(text(me["home"]), "\\", "/")) otherwise ""
397
+ when home != ""
398
+ set home to regex_replace(home, "/+$", "")
399
+ set cmd to replace(cmd, home, "@root")
400
+ -- git bash escribe C:/x como /c/x
401
+ when matches(home, "^[a-z]:/.*")
402
+ set cmd to replace(cmd, "/" + slice(home, 0, 1) + slice(home, 2, length(home)), "@root")
403
+ let abs be absolute_path(regex_replace(cmd, "@root\\S*", " "))
404
+ when abs != ""
405
+ give seat_deny("outside the project", "Your working copy is your workplace: bash starts there and relative paths are relative to it. This command names an absolute path outside the project (" + abs + "), and nobody in a team works outside the project. Use paths relative to your copy (other copies: ../<agent>, the main checkout: ../../..).")
406
+ when matches(cmd, ".*\\bgit\\b.*\\bpush\\b.*")
407
+ when not me["lead"]
408
+ give seat_deny("push is the lead's", "Only the lead pushes, with the person's approval. Commit on your branch (" + mine + ") and `send` " + (when me["boss"] != "" then me["boss"] otherwise "your lead") + " that it is ready.")
409
+ give {"decision": "ask", "reason": "git push — leaves this machine (the person approves each push)", "note": "", "grant": false}
410
+ -- desde su copia, .lampson/worktrees/… no existe: lo nombra quien cree estar en la raíz del proyecto
411
+ when contains(regex_replace(cmd, "@root\\S*", " "), ".lampson/worktrees")
412
+ give seat_deny("wrong path", "You are already inside your own copy (bash starts there), so `.lampson/worktrees/…` does not exist from here. The other copies are ../<agent> and the main checkout is ../../..")
413
+ -- cada segmento desde donde lo dejó el cd anterior: «cd ../../.. && git merge x» trabaja en la copia principal
414
+ let here be [".lampson", "worktrees", lower(me["agent"])]
415
+ let pending be nothing
416
+ each s in segments(cmd)
417
+ let w be where(split(regex_replace(s, "\\s+", " "), " "), (x) => x != "")
418
+ -- X=1 cmd: el comando es el que sigue a las variables
419
+ while length(w) > 0 and matches(w[0], "^[a-z_][a-z0-9_]*=.*")
420
+ set w to slice(w, 1, length(w))
421
+ when length(w) > 0
422
+ let cmd0 be w[0]
423
+ when cmd0 == "cd" or cmd0 == "pushd"
424
+ let dest be when length(w) > 1 then w[1] otherwise "~"
425
+ when dest == "~" or starts_with(dest, "$home")
426
+ give seat_deny("outside the project", "`cd` alone goes to your home folder, outside the project. Bash starts in your copy; use paths relative to it.")
427
+ when dest != "-" and not starts_with(dest, "$")
428
+ set here to walk(here, dest)
429
+ when zone(here, me)["kind"] == "outside"
430
+ give seat_deny("outside the project", "`" + s + "` leaves the project. Bash starts in your copy; the other copies are ../<agent> and the main checkout is ../../.. — nothing above it.")
431
+ otherwise
432
+ -- dónde actúa: donde está parado y cada ruta que nombra
433
+ let places be [here]
434
+ each x in slice(w, 1, length(w))
435
+ let vx be regex_replace(regex_replace(x, "^-[a-z-]*=", ""), "^[0-9]*[<>]+&?", "")
436
+ when pathish(vx)
437
+ set places to append(places, walk(here, vx))
438
+ let sub be git_sub(s)
439
+ let redirect be contains(regex_replace(s, "[0-9]*>&[0-9-]+|&?[0-9]*>>?\\s*/dev/(null|stdout|stderr)", " "), ">")
440
+ let reads be not redirect and ((cmd0 == "git" and contains(GIT_READ, sub) and not matches(" " + s + " ", ".*\\s-(d|D|f|m|M|-delete|-force)\\s.*")) or (cmd0 != "git" and contains(READ_CMDS, cmd0) and not (cmd0 == "find" and matches(s, ".*-(delete|exec|execdir|ok)\\b.*"))) or (cmd0 == "sed" and not matches(s, ".*\\s-[a-z]*i.*")))
441
+ each loc in places
442
+ let z be zone(loc, me)
443
+ when z["kind"] == "outside"
444
+ give seat_deny("outside the project", "`" + s + "` points outside the project, and nobody in a team works outside the project. Use paths relative to your copy (other copies: ../<agent>, the main checkout: ../../..).")
445
+ when not reads
446
+ let vc be may_change(z, me, s)
447
+ when vc != nothing
448
+ when vc["decision"] == "deny"
449
+ give vc
450
+ set pending to vc
451
+ -- ramas: mover o borrar la de alguien que no depende de vos, no; la principal es integrar
452
+ when (sub == "update-ref" or sub == "branch") and not reads
453
+ each b in regex_find_all(s, "team/[a-z0-9._-]+/[a-z0-9._-]+")
454
+ let owner be split(b, "/")[2]
455
+ when b != mine and not me["lead"] and not contains(below(me), owner)
456
+ give seat_deny("not your branch", "`" + b + "` is " + owner + "'s branch, and " + owner + " does not work under you. You move or delete your own branches (" + mine + ") and those of whoever works under you.")
457
+ when matches(" " + s + " ", ".*[\\s/]" + lower(me["main"]) + "\\s.*")
458
+ let vb be may_change({"kind": "main", "agent": ""}, me, s)
459
+ when vb != nothing
460
+ when vb["decision"] == "deny"
461
+ give vb
462
+ set pending to vb
463
+ when pending != nothing
464
+ give pending
465
+ give {"decision": "allow", "reason": "within your seat", "note": "", "grant": false}
466
+
467
+ -- las tools de archivos de un asiento: leer en todo el proyecto; cambiar donde puede cambiar bash
468
+ export task seat_file(name, args, me)
469
+ when name != "write" and name != "edit"
470
+ give {"decision": "allow", "reason": "reading", "note": "", "grant": false}
471
+ let p be when contains(args, "path") and args["path"] != nothing then replace(text(args["path"]), "\\", "/") otherwise "."
472
+ let home be when contains(me, "home") and me["home"] != nothing then regex_replace(replace(text(me["home"]), "\\", "/"), "/+$", "") otherwise ""
473
+ when home != "" and starts_with(lower(p), lower(home))
474
+ set p to "@root" + slice(p, length(home), length(p))
475
+ when absolute_path(p) != "" and not starts_with(p, "@root")
476
+ give seat_deny("outside the project", "`" + text(args["path"]) + "` is outside the project. Paths are relative to your copy (other copies: ../<agent>, the main checkout: ../../..).")
477
+ let v be may_change(zone(walk([".lampson", "worktrees", lower(me["agent"])], p), me), me, name + " " + text(args["path"]))
478
+ when v != nothing
479
+ give v
480
+ give {"decision": "allow", "reason": "within your seat", "note": "", "grant": false}
481
+
482
+ -- integrar a la rama principal: la persona lo aprueba una vez por objetivo (me.objective); sin objetivo, cada vez.
483
+ -- En un archivo y no en state_*: la regla corre también en la terminal y en los tests, no solo en serve
484
+ export let GRANTS_FILE be ".lampson/team-integrations.json"
485
+
486
+ task grants()
487
+ require file(".lampson")
488
+ require file(".lampson/**")
489
+ try
490
+ let g be json_decode(read_file(GRANTS_FILE))
491
+ give when type_of(g) == "map" then g otherwise {}
492
+ recover err
493
+ give {}
494
+
495
+ task grant_key(me)
496
+ give me["team"] + ":" + text(me["objective"])
497
+
498
+ export task integration_ok(me)
499
+ require file(".lampson")
500
+ require file(".lampson/**")
501
+ when not contains(me, "objective") or me["objective"] == 0
502
+ give false
503
+ give contains(grants(), grant_key(me))
504
+
505
+ export task grant_integration(me)
506
+ require file(".lampson")
507
+ require file(".lampson/**")
508
+ require time
509
+ when contains(me, "objective") and me["objective"] != 0
510
+ let g be grants()
511
+ set g[grant_key(me)] to now()
512
+ write_file(GRANTS_FILE, json_encode(g))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lampson",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
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": {
@@ -47,7 +47,7 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "dependencies": {
50
- "synsema": "^0.6.44"
50
+ "synsema": "0.6.64"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "pwsh -NoProfile -File tests/run.ps1"
@@ -16,6 +16,8 @@ intent: "lampson channel plugin: Chatwoot inbox ↔ Lampson agent"
16
16
 
17
17
  require env("PLUGIN_*")
18
18
  require net
19
+ require net("0.0.0.0/0")
20
+ require net("::/0")
19
21
  require time
20
22
 
21
23
  let action be env("PLUGIN_TOOL", "")
@@ -3,7 +3,7 @@
3
3
  "description": "Take orders by chat: catalog, quotes with promos and delivery, orders saved with customer and address (and changed or cancelled while still new), stock kept up to date. Data in .lampson/orders/ of the project.",
4
4
  "kind": "syn",
5
5
  "entry": "plugin.syn",
6
- "caps": "file=workspace/.lampson/orders,file=workspace/.lampson/orders/*",
6
+ "caps": "file=workspace/.lampson/orders,file=workspace/.lampson/orders/**",
7
7
  "timeout": 20,
8
8
  "instructions": "INSTRUCTIONS.md",
9
9
  "tools": [
@@ -11,7 +11,7 @@ intent: "lampson plugin: take orders against a catalog — quote, place, custome
11
11
  require env("PLUGIN_*")
12
12
  require time
13
13
  require file("workspace/.lampson/orders")
14
- require file("workspace/.lampson/orders/*")
14
+ require file("workspace/.lampson/orders/**")
15
15
 
16
16
  let DIR be "workspace/.lampson/orders"
17
17
  let CATALOG be DIR + "/catalog.json"
@@ -22,6 +22,8 @@ intent: "lampson channel plugin: Telegram bot ↔ Lampson agent"
22
22
 
23
23
  require env("PLUGIN_*")
24
24
  require net
25
+ require net("0.0.0.0/0")
26
+ require net("::/0")
25
27
  require time
26
28
 
27
29
  let action be env("PLUGIN_TOOL", "")
@@ -0,0 +1,100 @@
1
+ /* inbox.css — lo que te espera (preguntas, aprobaciones, merges, pases a otro equipo), igual en todas las pantallas:
2
+ la bandeja (⚑ en la cabecera → panel a la derecha, a pantalla completa en el celular) y el aviso de un objetivo en
3
+ su propia página. Lo dibuja js/inbox.js. */
4
+
5
+ /* un aviso: el ícono de lo que es, quién y qué quiere, y la respuesta a mano */
6
+ .aviso { --k:var(--accent); display:grid; grid-template-columns:36px minmax(0, 1fr); gap:12px; padding:12px 14px 12px 12px; background:var(--surface); border:1px solid var(--rule-2); border-radius:var(--r-lg); box-shadow:inset 3px 0 0 var(--k); }
7
+ .aviso.k-ask { --k:var(--amber); }
8
+ .aviso.k-ok { --k:var(--rubric); }
9
+ .aviso.k-pass, .aviso.k-git { --k:var(--accent); }
10
+ .aviso.fresh { animation:avin .45s cubic-bezier(.2,.8,.2,1); }
11
+ .aviso.going { opacity:.55; transition:opacity .2s; }
12
+ @keyframes avin { from { opacity:0; translate:0 -8px; } }
13
+ .av-ico { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; background:color-mix(in srgb, var(--k) 16%, transparent); }
14
+ .av-ico .ico { width:20px; height:20px; fill:none; stroke:var(--k); stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
15
+ .av-ico .ico circle.dot, .av-ico .ico circle.bit { fill:var(--k); stroke:none; }
16
+ .av-body { min-width:0; display:flex; flex-direction:column; gap:8px; }
17
+ /* el header del aviso no es la cabecera de la página: sin lo que cada pantalla le pone a `header` */
18
+ .aviso .av-body > header { position:static; height:auto; margin:0; padding:0; background:none; border:0; box-shadow:none; }
19
+ .av-body header { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:2px 12px; }
20
+ .av-who { font:400 14.5px/1.35 var(--serif); color:var(--ink-2); }
21
+ .av-who b { font-weight:600; color:var(--ink); }
22
+ .av-meta { font:400 11.5px/1.3 var(--mono); color:var(--ink-3); }
23
+ .av-meta a { color:var(--ink-2); }
24
+ .av-q { font:400 14px/1.5 var(--serif); color:var(--ink); max-height:9.5em; overflow:auto; }
25
+ .av-q p { margin:0 0 4px; } .av-q ul { margin:0 0 4px; padding-left:18px; }
26
+ .aviso .av-q b { font:inherit; font-weight:600; color:inherit; letter-spacing:normal; text-transform:none; }
27
+ blockquote.av-q { margin:0; padding:8px 12px; border-left:2px solid var(--rule-2); background:var(--paper-2); border-radius:0 var(--r-sm) var(--r-sm) 0; }
28
+ .av-lbl { margin:0; font:600 12px/1.3 var(--mono); color:var(--ink-3); }
29
+ .av-why { margin:0; font:400 13px/1.45 var(--serif); color:var(--ink-2); }
30
+ .av-cmd { margin:0; padding:8px 10px; font:400 12px/1.5 var(--mono); color:var(--ink); background:var(--paper-2); border-radius:var(--r-sm); white-space:pre-wrap; word-break:break-word; max-height:7.5em; overflow:auto; }
31
+ .av-acts { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
32
+ .av-acts input { flex:1 1 200px; min-width:0; font:400 13.5px/1.4 var(--serif); background:var(--paper); color:var(--ink); border:1px solid var(--rule-2); border-radius:var(--r); padding:7px 10px; }
33
+ .av-acts input:focus { outline:none; border-color:var(--ink-3); box-shadow:0 0 0 3px var(--accent-bg); }
34
+ .av-exp { margin-left:auto; font:400 11.5px/1 var(--mono); color:var(--ink-3); }
35
+ /* el merge: qué rama entra a cuál, y qué trae */
36
+ .av-merge { display:flex; flex-direction:column; gap:6px; }
37
+ .av-flow { display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; }
38
+ .av-flow code { font:600 12.5px/1.2 var(--mono); color:var(--ink); background:var(--paper-2); border:1px solid var(--rule); border-radius:var(--r-sm); padding:3px 7px; }
39
+ .av-flow .arr { width:22px; height:11px; fill:none; stroke:var(--ink-3); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
40
+ .av-badge { margin-left:auto; font:600 11.5px/1 var(--mono); padding:4px 8px; border-radius:var(--r-pill); }
41
+ .av-badge.ok { color:var(--ok); background:color-mix(in srgb, var(--ok) 14%, transparent); }
42
+ .av-badge.bad { color:var(--rubric); background:color-mix(in srgb, var(--rubric) 14%, transparent); }
43
+ .av-stat { margin:0; font:400 12.5px/1.4 var(--mono); color:var(--ink-2); }
44
+ .av-merge .add { color:var(--ok); } .av-merge .del { color:var(--rubric); }
45
+ .av-commits { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:3px; }
46
+ .av-commits li { display:flex; gap:8px; align-items:baseline; font:400 13.5px/1.4 var(--serif); color:var(--ink); min-width:0; }
47
+ .av-commits .sha { flex:none; font:400 11.5px/1 var(--mono); color:var(--ink-3); }
48
+ .av-commits .sj { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
49
+ .av-commits .by { flex:none; margin-left:auto; font:400 11.5px/1 var(--mono); color:var(--ink-3); }
50
+ .av-commits .more { color:var(--ink-3); font-size:12.5px; }
51
+ .av-files summary { cursor:pointer; font:400 12px/1.4 var(--mono); color:var(--ink-2); }
52
+ .av-files ul { list-style:none; margin:6px 0; padding:0; display:flex; flex-direction:column; gap:2px; max-height:9em; overflow:auto; }
53
+ .av-files li { display:flex; gap:8px; font:400 12px/1.4 var(--mono); }
54
+ .av-files .fp { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--ink); }
55
+ .av-warn { margin:0; font:400 13px/1.45 var(--serif); color:var(--rubric); }
56
+ .av-warn code { font-family:var(--mono); font-size:12px; }
57
+ @media (prefers-reduced-motion: reduce) { .aviso.fresh { animation:none; } }
58
+ .aviso button.ok { color:var(--paper); background:var(--ok); border-color:var(--ok); }
59
+ .aviso button.no { color:var(--rubric); border-color:var(--rubric); }
60
+
61
+ /* el botón de la cabecera: solo aparece si algo te espera */
62
+ .inbox-btn { display:inline-flex; align-items:center; gap:6px; font:600 12px/1 var(--mono); color:var(--paper); background:var(--rubric); border:1px solid var(--rubric); border-radius:var(--r-pill); padding:6px 11px; cursor:pointer; }
63
+ .inbox-btn:hover { opacity:.88; color:var(--paper); background:var(--rubric); border-color:var(--rubric); }
64
+ .inbox-btn[hidden] { display:none; }
65
+ @media (max-width:640px) { .inbox-btn .t { display:none; } }
66
+
67
+ /* la bandeja */
68
+ .inbox-veil { position:fixed; inset:0; z-index:60; background:rgba(0,0,0,.28); }
69
+ .inbox-veil[hidden], .inbox[hidden] { display:none; }
70
+ .inbox { position:fixed; z-index:61; top:0; right:0; bottom:0; width:min(560px, 100vw); display:flex; flex-direction:column; background:var(--paper); border-left:1px solid var(--rule); box-shadow:-12px 0 40px rgba(0,0,0,.18); }
71
+ .inbox-head { flex:none; display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--rule); }
72
+ .inbox-head h2 { margin:0; flex:1; font:600 18px/1.2 var(--serif); color:var(--ink); }
73
+ .inbox-head h2 small { font:400 12px/1 var(--mono); color:var(--ink-3); margin-left:6px; }
74
+ .inbox-head button { padding:6px 10px; }
75
+ .inbox-list { flex:1; overflow:auto; padding:12px 16px 24px; display:flex; flex-direction:column; gap:10px; }
76
+ .inbox-ws { margin:8px 0 0; font:600 11.5px/1 var(--mono); letter-spacing:.04em; text-transform:uppercase; color:var(--ink-3); }
77
+ .inbox-ws:first-child { margin-top:0; }
78
+ .inbox .av-q { max-height:18em; }
79
+ .inbox-empty { margin:24px 0; font:400 14px/1.5 var(--serif); color:var(--ink-3); text-align:center; }
80
+ @media (max-width:640px) { .inbox { width:100vw; border-left:0; } .inbox-head { padding:calc(12px + env(safe-area-inset-top)) 14px 12px; } .inbox-list { padding:12px 12px calc(20px + env(safe-area-inset-bottom)); } }
81
+
82
+ /* en la página de un objetivo: su pregunta, en el lugar */
83
+ .ob-ask { margin:14px 0 0; }
84
+ .ob-ask .av-q { max-height:none; }
85
+
86
+ /* en la pantalla en vivo: la misma pregunta en una línea (el grafo y el tablero no se corren); tocarla abre la bandeja
87
+ en ese aviso */
88
+ .ob-strip { --k:var(--amber); display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:6px 12px 6px 6px; background:var(--surface); border:1px solid var(--rule-2); border-radius:var(--r-lg); box-shadow:inset 3px 0 0 var(--k); cursor:pointer; color:var(--ink-2); }
89
+ .ob-strip:hover { border-color:var(--k); background:var(--surface); color:var(--ink-2); }
90
+ .ob-strip.k-ok { --k:var(--rubric); }
91
+ .ob-strip.k-pass { --k:var(--accent); }
92
+ .ob-strip .av-ico { flex:none; width:30px; height:30px; }
93
+ .ob-strip .sx { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font:400 14px/1.4 var(--serif); }
94
+ .ob-strip .sx b { font-weight:600; color:var(--ink); }
95
+ .ob-strip .g { color:var(--ink); }
96
+ .ob-strip .go { flex:none; font:600 12.5px/1 var(--mono); color:var(--paper); background:var(--ink); border-radius:var(--r); padding:7px 11px; }
97
+ @media (max-width:640px) { .ob-strip .go { padding:7px 9px; } .ob-strip .sx { white-space:normal; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; font-size:13.5px; } }
98
+ /* al llegar desde la línea, el aviso se marca un momento */
99
+ .aviso.lit { animation:avlit 1.6s ease-out; }
100
+ @keyframes avlit { 0%, 30% { box-shadow:inset 3px 0 0 var(--k), 0 0 0 3px color-mix(in srgb, var(--k) 45%, transparent); } 100% { box-shadow:inset 3px 0 0 var(--k), 0 0 0 3px transparent; } }
@@ -76,19 +76,6 @@
76
76
  .msheet button:active { background:var(--paper-2); }
77
77
  .msheet .mcancel { text-align:center; color:var(--ink-3); font:400 12px/1 var(--mono); margin-top:4px; border-top:1px solid var(--rule); border-radius:0; }
78
78
 
79
- /* modales (configuración, sesiones, plugins…): pantalla completa; en «browse» la lista arriba y el detalle abajo */
80
- .modal { align-items:stretch; justify-content:stretch; }
81
- .panel, .panel.lg, .panel.md, .panel.sm { width:100vw; height:100dvh; max-height:none; border:0; border-radius:0; box-shadow:none; padding:calc(10px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom)); }
82
- .panel .browse { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,38%) minmax(0,1fr); }
83
- .panel .blist { border-right:0; border-bottom:1px solid var(--rule); padding:10px 0 8px; }
84
- .panel .bdetail { padding:12px 2px 8px; }
85
- .panel input, .panel select, .panel textarea { font-size:16px; }
86
- .panel .pghost { width:36px; height:36px; flex:none; }
87
- /* cabecera del modal: la ✕ siempre a la vista (la ruta de «sub» la empujaba fuera de la pantalla) */
88
- .panel .phead { gap:8px; min-width:0; }
89
- .panel .phead .sub { display:none; }
90
- .panel .phead h3 { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
91
-
92
79
  /* terminal y visor de archivos: el ancho de la pantalla */
93
80
  #termpane .vh { overflow-x:auto; }
94
81
  #viewer pre { font-size:12px; }