@nanocollective/roster 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (96) hide show
  1. package/README.md +70 -84
  2. package/dist/cli.js +4775 -2495
  3. package/docs/README.md +19 -11
  4. package/docs/agents.md +328 -13
  5. package/docs/architecture.md +13 -5
  6. package/docs/charters/cmo.md +69 -0
  7. package/docs/charters/cto.md +71 -0
  8. package/docs/charters/support.md +60 -0
  9. package/docs/commands.md +95 -11
  10. package/docs/concepts.md +64 -12
  11. package/docs/cost.md +39 -3
  12. package/docs/developing.md +16 -21
  13. package/docs/doctor-codes.md +21 -6
  14. package/docs/export.md +2 -1
  15. package/docs/extending.md +13 -4
  16. package/docs/getting-started.md +121 -80
  17. package/docs/images/brain.jpg +0 -0
  18. package/docs/images/org.jpg +0 -0
  19. package/docs/images/prompt.jpg +0 -0
  20. package/docs/images/setup-org.jpg +0 -0
  21. package/docs/images/setup-plan.jpg +0 -0
  22. package/docs/images/staff.jpg +0 -0
  23. package/docs/manual-steps.md +94 -101
  24. package/docs/memory.md +29 -8
  25. package/docs/org-yaml.md +76 -11
  26. package/docs/portal.md +261 -47
  27. package/docs/prompts.md +77 -11
  28. package/docs/security.md +51 -7
  29. package/docs/session-workflow.md +51 -21
  30. package/docs/staff-yaml.md +16 -7
  31. package/docs/troubleshooting.md +23 -20
  32. package/docs/upgrading.md +9 -3
  33. package/docs/writing-a-charter.md +33 -17
  34. package/package.json +1 -1
  35. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +7 -0
  36. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +16 -4
  37. package/templates/brain/CHARTER.md +3 -3
  38. package/templates/brain/README.md +1 -0
  39. package/templates/brain/log/decisions.md +3 -0
  40. package/templates/brain/staff.yaml +0 -1
  41. package/templates/brain/strategy/ideas.md +7 -0
  42. package/templates/ops/.github/workflows/session.yaml +117 -40
  43. package/templates/ops/agents.mjs +127 -8
  44. package/templates/ops/compose.mjs +77 -7
  45. package/templates/ops/inflight.mjs +157 -0
  46. package/templates/ops/org/operating.md +21 -7
  47. package/templates/ops/org/voice.md +9 -0
  48. package/templates/ops/prompts/_identity.md +8 -1
  49. package/templates/ops/prompts/_inflight.md +14 -0
  50. package/templates/ops/prompts/_paths.md +2 -1
  51. package/templates/ops/prompts/daily.md +16 -7
  52. package/templates/ops/prompts/mention.md +18 -2
  53. package/templates/ops/run-record.mjs +144 -0
  54. package/templates/portal/css/base.css +238 -64
  55. package/templates/portal/css/brain.css +30 -20
  56. package/templates/portal/css/diff.css +15 -10
  57. package/templates/portal/css/graph.css +12 -7
  58. package/templates/portal/css/health.css +32 -11
  59. package/templates/portal/css/inbox.css +117 -14
  60. package/templates/portal/css/layout.css +93 -41
  61. package/templates/portal/css/markdown.css +57 -15
  62. package/templates/portal/css/runs.css +13 -0
  63. package/templates/portal/css/setup.css +83 -39
  64. package/templates/portal/index.html +24 -3
  65. package/templates/portal/js/api.js +65 -4
  66. package/templates/portal/js/app.js +112 -12
  67. package/templates/portal/js/dialog.js +94 -4
  68. package/templates/portal/js/dom.js +25 -0
  69. package/templates/portal/js/icons.js +8 -1
  70. package/templates/portal/js/lightbox.js +273 -0
  71. package/templates/portal/js/md.js +23 -6
  72. package/templates/portal/js/mdedit.js +84 -0
  73. package/templates/portal/js/mention.js +264 -0
  74. package/templates/portal/js/refresh.js +136 -6
  75. package/templates/portal/js/state.js +55 -8
  76. package/templates/portal/js/views/app.js +23 -5
  77. package/templates/portal/js/views/checklist.js +29 -10
  78. package/templates/portal/js/views/credential.js +98 -0
  79. package/templates/portal/js/views/docs.js +94 -4
  80. package/templates/portal/js/views/files.js +58 -14
  81. package/templates/portal/js/views/graph.js +1 -1
  82. package/templates/portal/js/views/health.js +178 -37
  83. package/templates/portal/js/views/inbox.js +938 -98
  84. package/templates/portal/js/views/memory.js +16 -1
  85. package/templates/portal/js/views/org.js +124 -104
  86. package/templates/portal/js/views/orgedit.js +213 -0
  87. package/templates/portal/js/views/paste.js +33 -7
  88. package/templates/portal/js/views/prompt.js +61 -67
  89. package/templates/portal/js/views/repos.js +20 -15
  90. package/templates/portal/js/views/runonce.js +94 -0
  91. package/templates/portal/js/views/runs.js +165 -0
  92. package/templates/portal/js/views/setup.js +311 -83
  93. package/templates/portal/js/views/staff.js +139 -22
  94. package/templates/portal/js/yaml.js +134 -0
  95. package/templates/brain/.github/workflows/%%STAFF%%-pr-mention.yaml +0 -50
  96. package/templates/ops/prompts/pr-mention.md +0 -57
@@ -1,53 +1,63 @@
1
1
  /* The setup screen, and the copy-a-prompt panel it shares with the authoring screens. */
2
2
 
3
- .step{background:var(--panel);border:1px solid var(--line);border-radius:10px;
4
- padding:18px 20px 20px;margin-bottom:14px}
5
- .step.done{border-color:var(--accent-dim)}
3
+ .step{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-lg);
4
+ padding:20px 22px 22px;margin-bottom:14px;box-shadow:var(--shadow-sm)}
5
+ .step.done{border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}
6
6
  .stephead{display:flex;align-items:center;gap:11px;margin-bottom:10px}
7
- .stephead h2{margin:0;font:600 16px var(--sans);letter-spacing:-.01em}
8
- .stepn{flex:none;width:23px;height:23px;border-radius:50%;display:grid;place-items:center;
9
- background:var(--panel-2);border:1px solid var(--line);color:var(--ink-faint);
7
+ .stephead h2{margin:0;font:600 16px var(--sans);letter-spacing:-.018em}
8
+ .stepn{flex:none;width:24px;height:24px;border-radius:50%;display:grid;place-items:center;
9
+ background:var(--surface-2);border:1px solid transparent;color:var(--ink-dim);
10
10
  font:600 11px var(--mono)}
11
- .step.done .stepn{background:var(--accent-dim);border-color:var(--accent-dim);color:var(--bg)}
11
+ .step.done .stepn{background:var(--accent-fill);border-color:transparent;color:var(--accent-ink)}
12
12
 
13
13
  /* ---------- the form ---------- */
14
14
 
15
15
  .setupform{display:grid;gap:13px;margin:14px 0 18px;max-width:520px}
16
16
  .field{display:grid;gap:4px}
17
17
  .field>span{font:600 12px var(--sans);color:var(--ink-dim)}
18
- .field input,.field select{background:var(--panel-2);border:1px solid var(--line);color:var(--ink);
19
- border-radius:7px;padding:8px 11px;font:13px var(--sans);outline:none;width:100%}
20
- .field input:focus,.field select:focus{border-color:var(--accent-dim)}
18
+ .field input,.field select{background:var(--bg-elev);border:1px solid var(--border-strong);color:var(--ink);
19
+ border-radius:var(--r);padding:8px 11px;font:13px var(--sans);outline:none;width:100%;
20
+ transition:border-color .15s var(--ease),box-shadow .15s var(--ease)}
21
+ .field input:focus,.field select:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
21
22
  .field small{color:var(--ink-faint);font-size:11.5px;line-height:1.45}
22
23
 
23
24
  .choices{display:grid;gap:8px;margin:10px 0 4px;max-width:640px}
24
25
  .choice{display:grid;grid-template-columns:auto 1fr;gap:3px 10px;align-items:start;
25
- background:var(--panel-2);border:1px solid var(--line);border-radius:8px;
26
- padding:11px 13px;cursor:pointer}
27
- .choice:has(input:checked){border-color:var(--accent-dim)}
26
+ background:var(--bg-elev);border:1px solid var(--line);border-radius:var(--r);
27
+ padding:12px 14px;cursor:pointer;
28
+ transition:border-color .15s var(--ease),background .15s var(--ease),box-shadow .15s var(--ease)}
29
+ .choice:hover{border-color:var(--border-strong)}
30
+ .choice:has(input:checked){border-color:var(--accent-dim);background:var(--accent-soft)}
28
31
  .choice input{grid-row:1/3;margin-top:3px;accent-color:var(--accent)}
29
32
  .choice b{font:600 13px var(--sans)}
30
33
  .choice small{color:var(--ink-dim);font-size:12px;line-height:1.45}
31
34
  .choice code{grid-column:2;font:10.5px var(--mono);color:var(--ink-faint)}
32
35
 
33
36
  .row{display:flex;gap:9px;align-items:center;flex-wrap:wrap;margin-top:6px}
34
- .btn{background:var(--panel-2);border:1px solid var(--line);color:var(--ink);border-radius:7px;
35
- padding:8px 13px;font:13px var(--sans);cursor:pointer;text-decoration:none;display:inline-block}
36
- .btn:hover{border-color:var(--accent-dim)}
37
- .btn.primary{background:var(--accent-dim);border-color:var(--accent-dim);color:var(--bg);font-weight:600}
38
- .btn[disabled]{opacity:.5;cursor:default}
39
-
40
- .cmd{background:var(--panel-2);border:1px solid var(--line);border-radius:7px;padding:10px 12px;
37
+ .btn{background:var(--surface-2);border:1px solid transparent;color:var(--ink);border-radius:8px;
38
+ padding:7px 14px;font:500 13px var(--sans);cursor:pointer;text-decoration:none;display:inline-block;
39
+ transition:background .15s var(--ease),opacity .15s var(--ease)}
40
+ .btn:hover{background:color-mix(in srgb,var(--surface-2) 88%,var(--ink) 12%)}
41
+ .btn:active{opacity:.8}
42
+ /* The full accent, not the dim one. Dim on the page background is pale-green-on-white with
43
+ near-white text: the button that does the main thing on the screen read as disabled. */
44
+ .btn.primary{background:var(--accent-fill);border-color:transparent;color:var(--accent-ink);font-weight:600}
45
+ .btn.primary:hover{background:var(--accent-fill);opacity:.88}
46
+ .btn[disabled]{opacity:.45;cursor:default}
47
+
48
+ .cmd{background:var(--bg);border:1px solid var(--line);border-radius:var(--r);padding:10px 12px;
41
49
  font:12px/1.6 var(--mono);color:var(--ink);overflow-x:auto;white-space:pre-wrap;
42
50
  word-break:break-word;margin:9px 0}
43
51
 
44
52
  .planout{margin-top:12px}
45
- .filelist{display:grid;gap:2px;margin:9px 0;max-height:240px;overflow-y:auto;
46
- background:var(--panel-2);border:1px solid var(--line);border-radius:7px;padding:10px 12px}
53
+ .filelist{display:grid;gap:2px;margin:9px 0;
54
+ background:var(--bg);border:1px solid var(--line);border-radius:var(--r);padding:10px 12px}
47
55
  .filelist code{font:11px var(--mono);color:var(--ink-dim)}
48
56
 
49
- .manual{background:var(--panel-2);border:1px solid var(--line);border-radius:8px;
57
+ .manual{background:var(--bg-elev);border:1px solid var(--line);border-radius:var(--r);
50
58
  padding:13px 15px;margin:11px 0}
59
+ /* A file step that is written says so in the border too, the way a finished step does. */
60
+ .manual.done{border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}
51
61
  .manual b{display:block;font:600 13px var(--sans);margin-bottom:4px}
52
62
  .manual p{margin:0 0 6px;font-size:13px}
53
63
  .manual small{display:block;color:var(--ink-faint);font-size:11.5px;line-height:1.5;margin-bottom:9px}
@@ -56,32 +66,33 @@
56
66
 
57
67
  .paste{border-top:1px solid var(--line);margin-top:16px;padding-top:15px}
58
68
  .paste h3{margin:0 0 5px;font:600 14px var(--sans)}
59
- .briefpreview{background:var(--panel-2);border:1px solid var(--line);border-radius:7px;
69
+ .briefpreview{background:var(--bg);border:1px solid var(--line);border-radius:var(--r);
60
70
  padding:12px 14px;font:11.5px/1.6 var(--mono);max-height:340px;overflow:auto;
61
71
  white-space:pre-wrap;word-break:break-word;margin:10px 0}
62
- .pastebox{width:100%;background:var(--panel-2);border:1px solid var(--line);color:var(--ink);
63
- border-radius:7px;padding:10px 12px;font:12px/1.6 var(--mono);outline:none;resize:vertical;
72
+ .pastebox{width:100%;background:var(--bg-elev);border:1px solid var(--border-strong);color:var(--ink);
73
+ border-radius:var(--r);padding:10px 12px;font:12px/1.6 var(--mono);outline:none;resize:vertical;
64
74
  margin:4px 0}
65
- .pastebox:focus{border-color:var(--accent-dim)}
75
+ .pastebox:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
66
76
 
67
77
  .pasteresult{margin-top:12px}
68
78
  /* A model that replied in prose is the common case and not the person's mistake, so this reads
69
79
  as a next step rather than as a failure. */
70
- .problem{background:var(--panel-2);border:1px solid var(--warn);border-radius:8px;
80
+ .problem{background:color-mix(in srgb,var(--warn) 9%,transparent);
81
+ border:1px solid transparent;border-radius:var(--r);
71
82
  padding:12px 14px;margin-bottom:10px}
72
83
  .problem b{display:block;font:600 13px var(--sans);margin-bottom:7px}
73
84
 
74
- .pastefile{background:var(--panel-2);border:1px solid var(--line);border-radius:8px;
85
+ .pastefile{background:var(--bg-elev);border:1px solid var(--line);border-radius:var(--r);
75
86
  padding:12px 14px;margin-bottom:10px}
76
87
  .pastefile.saved{border-color:var(--accent-dim)}
77
88
  .pastefile b{font:600 13px var(--mono)}
78
89
  .pastefile .meta{margin-left:9px}
79
- .pastefile .diff{max-height:300px;overflow:auto;margin:9px 0}
90
+ .pastefile .diff{margin:9px 0}
80
91
 
81
92
  /* ---------- the doctor checklist ---------- */
82
93
 
83
- .check{display:grid;grid-template-columns:auto 1fr;gap:2px 10px;align-items:start;
84
- padding:10px 0;border-top:1px solid var(--line)}
94
+ .check{display:grid;grid-template-columns:auto 1fr;gap:2px 12px;align-items:start;
95
+ padding:12px 0;border-top:1px solid var(--line)}
85
96
  .check:first-child{border-top:none}
86
97
  .checkmark{font:600 13px var(--mono);line-height:1.5}
87
98
  .check.fail .checkmark{color:var(--err)}
@@ -92,15 +103,48 @@
92
103
  /* ---------- the repo picker ---------- */
93
104
 
94
105
  .repolist{display:grid;gap:1px;max-height:280px;overflow-y:auto;
95
- border:1px solid var(--line);border-radius:7px;background:var(--line)}
96
- .repo{display:flex;align-items:center;justify-content:space-between;gap:12px;
106
+ border:1px solid var(--line);border-radius:var(--r);background:var(--line)}
107
+ /* Scoped to the picker. Bare `.repo` also matched the project label on every inbox row,
108
+ which is where the white box and the stray padding behind MARKETING came from. */
109
+ .repolist .repo{display:flex;align-items:center;justify-content:space-between;gap:12px;
97
110
  background:var(--panel);padding:9px 12px}
98
- .repo.added{background:var(--panel-2)}
99
- .repo b{font:600 12.5px var(--mono)}
100
- .repo .meta{margin-left:8px}
101
- .repo .sub{margin:2px 0 0;font-size:11.5px}
111
+ .repolist .repo.added{background:var(--panel-2)}
112
+ .repolist .repo b{font:600 12.5px var(--mono)}
113
+ .repolist .repo .meta{margin-left:8px}
114
+ .repolist .repo .sub{margin:2px 0 0;font-size:11.5px}
102
115
 
103
116
  /* Which of the two things this is: a new org, or one that already runs roster. */
104
- .verdict{background:var(--panel-2);border:1px solid var(--line);border-radius:7px;
117
+ .verdict{background:var(--accent-soft);border:1px solid transparent;border-radius:var(--r);
105
118
  padding:9px 12px;font-size:12.5px}
106
119
  .verdict p{margin:0}
120
+
121
+ .plansteps{margin:6px 0 12px;padding-left:20px;font-size:13.5px;line-height:1.7}
122
+ .planfiles{margin:0 0 12px}
123
+ .planfiles summary{cursor:pointer;color:var(--ink-dim);font-size:12.5px}
124
+
125
+ /* ---------- the numbered to-do list ---------- */
126
+
127
+ .todos{display:grid;gap:10px;margin-bottom:14px}
128
+ .todo{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px 18px}
129
+ .todo.done{padding:11px 18px;border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}
130
+ .todohead{display:flex;align-items:center;gap:11px}
131
+ .todohead h3{margin:0;font:600 14.5px var(--sans);flex:1}
132
+ .todon{flex:none;width:24px;height:24px;border-radius:50%;display:grid;place-items:center;
133
+ background:var(--surface-2);color:var(--ink-dim);font:600 11px var(--mono)}
134
+ .todo.done .todon{background:var(--accent-fill);color:var(--accent-ink)}
135
+ .todopill{font:600 11px var(--sans);padding:2px 8px;border-radius:99px;background:var(--surface-2);color:var(--ink-dim)}
136
+ .todo.done .todopill{background:var(--accent-soft);color:var(--accent)}
137
+ .todohint{margin:8px 0 0 35px}
138
+ .todobody{margin:12px 0 0 35px}
139
+ .todobody .row{margin-top:10px}
140
+ .qfield{display:grid;gap:5px;margin:0 0 12px}
141
+ .qfield span{font:600 12.5px var(--sans)}
142
+ .qfield input{background:var(--bg-elev);border:1px solid var(--border-strong);color:var(--ink);
143
+ border-radius:var(--r);padding:8px 10px;font:13px var(--sans)}
144
+ .modes{display:inline-flex;gap:2px;padding:3px;margin:0 0 14px;background:var(--surface-2);
145
+ border-radius:var(--r);flex-wrap:wrap}
146
+ .mode{border:0;background:none;color:var(--ink-dim);font:600 12.5px var(--sans);padding:6px 12px;
147
+ border-radius:calc(var(--r) - 2px);cursor:pointer}
148
+ .mode:hover{color:var(--ink)}
149
+ .mode.on{background:var(--bg-elev);color:var(--ink);box-shadow:var(--shadow-sm)}
150
+ .modes + div > .paste{border-top:0;margin-top:0;padding-top:0}
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>roster</title>
7
7
  <!-- Inline, so a local page with no network still has a tab icon and the console stays clean. -->
8
- <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%237cc7a4'/%3E%3C/svg%3E">
8
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%2334c759'/%3E%3C/svg%3E">
9
9
  <!-- Stylesheets and modules are served from /assets by `roster portal`. No build step:
10
10
  editing one of these files and reloading is the whole edit loop. -->
11
11
  <link rel="stylesheet" href="/assets/css/base.css">
@@ -16,20 +16,34 @@
16
16
  <link rel="stylesheet" href="/assets/css/graph.css">
17
17
  <link rel="stylesheet" href="/assets/css/diff.css">
18
18
  <link rel="stylesheet" href="/assets/css/health.css">
19
+ <link rel="stylesheet" href="/assets/css/runs.css">
19
20
  <link rel="stylesheet" href="/assets/css/setup.css">
20
21
  </head>
21
22
  <body>
22
23
  <div class="app">
23
24
  <aside class="side">
24
- <div class="brand">roster<small id="orgname">loading…</small></div>
25
+ <div class="brand"><span class="mark"></span>roster<small id="orgname">loading…</small></div>
25
26
  <button class="refreshall" id="refreshall" title="Reload everything from disk (r)">
26
27
  <span class="sync" data-icon="refresh"></span><span id="loaded">data now</span>
27
28
  </button>
28
29
 
30
+ <!-- Only while something is left to set up; app.js decides. -->
31
+ <button class="nav top" id="setupnav" data-view="setup" hidden>
32
+ <span class="ic" data-icon="task-done"></span> Getting started
33
+ </button>
29
34
  <button class="nav top" id="inboxnav" data-view="inbox">
30
35
  <span class="ic" data-icon="inbox"></span> Inbox
31
36
  <span class="n" id="inboxcount"></span>
32
37
  </button>
38
+ <!-- "Pending work", not "Pull requests": what is behind it is finished work waiting on you,
39
+ and the word for how it is delivered is not the word for what it is. -->
40
+ <button class="nav" id="prsnav" data-view="prs" title="Finished work waiting on you to merge">
41
+ <span class="ic" data-icon="merged"></span> Pending work
42
+ <span class="n" id="prcount"></span>
43
+ </button>
44
+ <button class="nav" id="runsnav" data-view="runs" title="What ran, how it ended, and what it cost">
45
+ <span class="ic" data-icon="play"></span> Runs
46
+ </button>
33
47
  <button class="nav" id="orgnav" data-view="org">
34
48
  <span class="ic" data-icon="file"></span> Org
35
49
  </button>
@@ -40,7 +54,14 @@
40
54
  <span class="ic" data-icon="docs"></span> Docs
41
55
  </button>
42
56
 
43
- <div class="sect">Staff</div>
57
+ <!-- The heading is the fold. Collapsed, it carries the count, because a hidden list still
58
+ has to say how much it is hiding. -->
59
+ <!-- Named apart from the Staff screen above it: two controls both called "Staff" is how a
60
+ click meant for the screen landed on the fold, for people and for automation alike. -->
61
+ <button class="sect sectfold" id="stafffold" aria-expanded="false" aria-controls="stafflist"
62
+ aria-label="Staff list" title="Show or hide each staff member's own screens">
63
+ <span class="caret" data-icon="chevron"></span>Staff<span class="n" id="staffcount" hidden></span>
64
+ </button>
44
65
  <div id="stafflist"></div>
45
66
 
46
67
  <div class="sidefoot">
@@ -7,6 +7,21 @@ export const getDocs = () => json("/api/docs");
7
7
  export const getInbox = (force) => json("/api/inbox" + (force ? "?refresh=1" : ""));
8
8
  export const getSync = () => json("/api/sync").catch(() => null);
9
9
 
10
+ /** Every staff member's recent runs and 30-day spend. Online only; offline it says so. */
11
+ export const getRuns = (force) => json("/api/runs" + (force ? "?refresh=1" : ""));
12
+
13
+ /** The repos org.yaml lists. Off disk, so the new-issue form does not wait on the inbox. */
14
+ export const getRepos = () => json("/api/repos");
15
+
16
+ /** What one repo's labels actually are, so they can be offered rather than typed. */
17
+ export const getLabels = (repo) => json("/api/labels?repo=" + encodeURIComponent(repo));
18
+
19
+ /** Full-text across the docs. Titles are not enough: what you want is usually a paragraph. */
20
+ export const searchDocs = (q) => json("/api/docsearch?q=" + encodeURIComponent(q));
21
+
22
+ /** Every file in the org layer that the portal may write, off disk rather than hardcoded. */
23
+ export const getOrgLayer = () => json("/api/orglayer");
24
+
10
25
  export const getDoc = (page) =>
11
26
  fetch("/api/doc?page=" + encodeURIComponent(page), { cache: "no-store" }).then((r) => r.text());
12
27
 
@@ -18,6 +33,10 @@ export const getThread = (repo, number, kind) =>
18
33
  "/api/thread?repo=" + encodeURIComponent(repo) + "&number=" + number + "&kind=" + kind,
19
34
  );
20
35
 
36
+ /** A pull request's commits and its diff. Asked for on the Files or Commits tab, not before. */
37
+ export const getPr = (repo, number) =>
38
+ json("/api/pr?repo=" + encodeURIComponent(repo) + "&number=" + number);
39
+
21
40
  export const diffUrl = (dir, sha, path) =>
22
41
  "/api/diff?dir=" + encodeURIComponent(dir) + "&sha=" + encodeURIComponent(sha) +
23
42
  (path ? "&path=" + encodeURIComponent(path) : "");
@@ -31,10 +50,32 @@ export async function post(payload, url = "/api/act") {
31
50
  body: JSON.stringify(payload),
32
51
  });
33
52
  const data = await res.json().catch(() => ({}));
34
- if (!res.ok || data.error) throw new Error(data.error || "failed with " + res.status);
53
+ if (!res.ok || data.error) {
54
+ // The body travels with the error: a refusal often carries the next step, like a link.
55
+ const err = new Error(data.error || "failed with " + res.status);
56
+ err.data = data;
57
+ throw err;
58
+ }
35
59
  return data;
36
60
  }
37
61
 
62
+ /**
63
+ * Put a file in the repo an issue lives in, and get back the path and the link.
64
+ *
65
+ * Read here rather than posted as a form because everything else on this server speaks JSON,
66
+ * and a file small enough to belong in a repo is small enough to base64.
67
+ */
68
+ export async function upload(repo, file) {
69
+ const data = await new Promise((ok, no) => {
70
+ const r = new FileReader();
71
+ r.onerror = () => no(new Error("could not read " + file.name));
72
+ // A data URL is "data:<type>;base64,<payload>"; only the payload travels.
73
+ r.onload = () => ok(String(r.result).split(",")[1] ?? "");
74
+ r.readAsDataURL(file);
75
+ });
76
+ return post({ repo, name: file.name, data }, "/api/upload");
77
+ }
78
+
38
79
  /* ------------------------------- setup and authoring ------------------------------- */
39
80
 
40
81
  export const getSetup = () => json("/api/setup/status");
@@ -45,8 +86,12 @@ export const planTenant = (params) =>
45
86
  export const createTenant = (params) => post(params, "/api/setup/apply");
46
87
 
47
88
  /** The copyable prompt, with every file it refers to carried inside it. */
48
- export const getBrief = (kind, staff) =>
49
- json("/api/brief?kind=" + encodeURIComponent(kind) + (staff ? "&staff=" + encodeURIComponent(staff) : ""));
89
+ export const getBrief = (kind, staff, example) =>
90
+ json(
91
+ "/api/brief?kind=" + encodeURIComponent(kind) +
92
+ (staff ? "&staff=" + encodeURIComponent(staff) : "") +
93
+ (example ? "&example=" + encodeURIComponent(example) : ""),
94
+ );
50
95
 
51
96
  /** Parse what came back from the model. Reads only: saving is a second, deliberate step. */
52
97
  export const parsePaste = (kind, staff, answer) =>
@@ -65,10 +110,26 @@ export const getDoctor = (offline) => json("/api/doctor" + (offline ? "?offline=
65
110
  export const getFix = (offline) => json("/api/fix" + (offline ? "?offline=1" : ""));
66
111
 
67
112
  export const listRepos = (org) => json("/api/setup/repos?org=" + encodeURIComponent(org));
68
- export const addRepo = (name, role) => post({ name, role }, "/api/setup/add-repo");
113
+ /** Commits org.yaml and pushes, as every other write here does. */
114
+ export const addRepo = (name, role, visibility) =>
115
+ post({ name, role, visibility }, "/api/setup/add-repo");
69
116
  export const startApp = (staff, scope) => post({ staff, scope }, "/api/setup/app");
70
117
  export const appResult = (state) => json("/api/setup/app-result?state=" + encodeURIComponent(state));
71
118
 
72
119
  /** Does this org already run roster. "Create" and "join" are different answers. */
73
120
  export const checkOrg = (org) => json("/api/setup/check-org?org=" + encodeURIComponent(org));
74
121
  export const joinOrg = (org) => post({ org }, "/api/setup/join");
122
+
123
+ /** The ops repo's Actions access: read it, or ask the server to set it. */
124
+ export const getAccess = () => json("/api/setup/access");
125
+ export const setAccess = () => post({}, "/api/setup/access");
126
+
127
+ /** Where the agent credential goes, and storing it. The value only ever travels in a POST. */
128
+ export const getCredential = () => json("/api/setup/credential");
129
+ export const storeCredential = (value, repoSecrets) =>
130
+ post({ value, repoSecrets }, "/api/setup/credential");
131
+
132
+ /** One daily run, now, and where it has got to. */
133
+ export const startRun = (staff) => post({ staff }, "/api/run/start");
134
+ export const runStatus = (staff, id) =>
135
+ json("/api/run/state?staff=" + encodeURIComponent(staff) + "&id=" + encodeURIComponent(id));
@@ -3,23 +3,35 @@
3
3
  import { getOrg } from "./api.js";
4
4
  import { $, el, store } from "./dom.js";
5
5
  import { icon, iconHTML } from "./icons.js";
6
+ import { installLightbox } from "./lightbox.js";
6
7
  import { setPeople } from "./md.js";
7
- import { refreshAll, stampLoaded, syncNotice } from "./refresh.js";
8
+ import {
9
+ countInBackground,
10
+ refreshAll,
11
+ refreshQuietly,
12
+ stampCounts,
13
+ stampLoaded,
14
+ syncNotice,
15
+ } from "./refresh.js";
8
16
  import { onRender } from "./router.js";
9
- import { ORG_WIDE, S, VIEWS, applyHash, openCount, writeHash } from "./state.js";
17
+ import { ORG_WIDE, S, VIEWS, applyHash, readHash, writeHash } from "./state.js";
10
18
  import { viewBrain } from "./views/brain.js";
11
19
  import { viewChanged } from "./views/changed.js";
12
20
  import { viewDocs } from "./views/docs.js";
13
21
  import { viewGraph } from "./views/graph.js";
14
22
  import { viewHealth } from "./views/health.js";
15
- import { viewInbox } from "./views/inbox.js";
23
+ import { viewInbox, viewPrs } from "./views/inbox.js";
16
24
  import { viewOrg } from "./views/org.js";
17
25
  import { viewPrompt } from "./views/prompt.js";
18
- import { viewSetup } from "./views/setup.js";
26
+ import { viewRuns } from "./views/runs.js";
27
+ import { paintSetupNav, viewGettingStarted, viewSetup } from "./views/setup.js";
19
28
  import { viewStaff } from "./views/staff.js";
20
29
 
21
30
  const SCREEN = {
31
+ setup: viewGettingStarted,
22
32
  inbox: viewInbox,
33
+ prs: viewPrs,
34
+ runs: viewRuns,
23
35
  org: viewOrg,
24
36
  staff: viewStaff,
25
37
  docs: viewDocs,
@@ -41,9 +53,42 @@ const SCREEN = {
41
53
  */
42
54
  const NEEDS = ["org", "name", "opsName", "staff"];
43
55
 
56
+ /** The org-wide screens in the sidebar, by button. */
57
+ const NAV = [
58
+ ["#setupnav", "setup"],
59
+ ["#inboxnav", "inbox"],
60
+ ["#prsnav", "prs"],
61
+ ["#runsnav", "runs"],
62
+ ["#staffnav", "staff"],
63
+ ["#orgnav", "org"],
64
+ ["#docsnav", "docs"],
65
+ ];
66
+
44
67
  export async function boot() {
45
68
  initTheme();
46
69
 
70
+ /* Bound before the first request rather than after it. The sidebar is markup, so it is on
71
+ screen and clickable while /api/org is still building the export, and a click in that
72
+ window used to do nothing at all: the first click on Staff after a load was simply lost.
73
+ Now it is remembered and honoured once there is something to render. */
74
+ let early = null;
75
+ for (const [id, view] of NAV) {
76
+ const b = $(id);
77
+ if (!b) continue;
78
+ b.onclick = () => {
79
+ if (!S.data) {
80
+ early = view;
81
+ return;
82
+ }
83
+ S.view = view;
84
+ render();
85
+ };
86
+ }
87
+
88
+ /* Before the first render, and once: it is delegated, so it covers every image any screen
89
+ draws from here on, including the setup screen. */
90
+ installLightbox();
91
+
47
92
  /* Before there is a tenant the server answers every data route with `mode: setup`. That is
48
93
  not an error state: it is the first thing a new user ever sees, and the whole page becomes
49
94
  the thing that fixes it. */
@@ -51,6 +96,12 @@ export async function boot() {
51
96
  if (first && first.mode === "setup") {
52
97
  document.body.dataset.setup = "1";
53
98
  $("#orgname").textContent = "no org yet";
99
+ /* Every one of these reads a tenant, so during setup they answer 409 and the sidebar is a
100
+ row of four dead ends beside an empty Staff heading. There is one thing to do on this
101
+ screen; the navigation comes back with the org. */
102
+ for (const el of document.querySelectorAll("#inboxnav, #prsnav, #runsnav, #orgnav, #staffnav, #docsnav, #refreshall, .sect, #stafflist")) {
103
+ el.hidden = true;
104
+ }
54
105
  for (const slot of document.querySelectorAll("[data-icon]")) {
55
106
  slot.innerHTML = iconHTML(slot.dataset.icon);
56
107
  }
@@ -70,18 +121,23 @@ export async function boot() {
70
121
  slot.innerHTML = iconHTML(slot.dataset.icon);
71
122
  }
72
123
  onRender(render);
124
+ const linked = readHash() !== null;
73
125
  applyHash();
126
+ /* An org nobody has been hired into has an empty Inbox, which says nothing about what to do
127
+ next. It opens on what is left instead, unless a link or a click asked for somewhere else. */
128
+ if (early) S.view = early;
129
+ else if (!linked && (S.data.unfinished ?? []).includes("hire")) S.view = "setup";
130
+ initStaffFold();
74
131
  paintSidebar();
75
132
 
76
- $("#inboxnav").onclick = () => { S.view = "inbox"; render(); };
77
- $("#staffnav").onclick = () => { S.view = "staff"; render(); };
78
- $("#orgnav").onclick = () => { S.view = "org"; render(); };
79
- $("#docsnav").onclick = () => { S.view = "docs"; render(); };
80
133
  $("#refreshall").onclick = () => refreshAll(false);
81
134
 
82
- // Coming back to the tab after a run should show the run.
135
+ /* Coming back to the tab after a run should show the run — and coming back to it thirty
136
+ seconds after leaving it should show nothing at all. Clicking into the window used to
137
+ re-read every repo on GitHub and repaint the screen under you; now it looks first and
138
+ only repaints when something actually moved. */
83
139
  addEventListener("focus", () => {
84
- if (S.loadedAt && Date.now() - S.loadedAt > 30000) refreshAll(false);
140
+ if (S.loadedAt && Date.now() - S.loadedAt > 60000) refreshQuietly();
85
141
  });
86
142
  addEventListener("keydown", (e) => {
87
143
  if (e.key === "r" && !e.metaKey && !e.ctrlKey &&
@@ -92,6 +148,11 @@ export async function boot() {
92
148
  });
93
149
  setInterval(stampLoaded, 30000);
94
150
 
151
+ /* What is waiting on you is the first thing this page should be able to tell you, and it used
152
+ to be the one thing it would not say until you clicked Inbox. One request, shared with
153
+ whichever screen renders next. */
154
+ countInBackground();
155
+
95
156
  // Only the state changes here. This used to re-run half of boot on every navigation,
96
157
  // which stacked up a focus listener, a keydown listener and an interval each time.
97
158
  addEventListener("hashchange", () => {
@@ -153,6 +214,42 @@ function learnPeople() {
153
214
  */
154
215
  let paintedRoster = null;
155
216
 
217
+ /**
218
+ * The Staff heading is a fold, and folded it carries the count.
219
+ *
220
+ * It starts folded, so the count is not decoration: a bare "STAFF" heading over nothing is how
221
+ * a loaded org would look if the export came back empty, and those two states have to be
222
+ * tellable apart at a glance. The count sits on the heading rather than beside it so there is
223
+ * one thing to click.
224
+ */
225
+ let staffOpen = true;
226
+
227
+ function paintStaffFold() {
228
+ const b = $("#stafffold");
229
+ if (b) b.setAttribute("aria-expanded", String(staffOpen));
230
+ const list = $("#stafflist");
231
+ if (list) list.hidden = !staffOpen;
232
+ const n = $("#staffcount");
233
+ if (n) {
234
+ n.textContent = "(" + (S.data?.staff?.length ?? 0) + ")";
235
+ n.hidden = staffOpen;
236
+ }
237
+ }
238
+
239
+ function initStaffFold() {
240
+ // Folded until you say otherwise: the count on the heading is enough to know the roster is
241
+ // there, and the four org-wide screens above it are where a session starts.
242
+ staffOpen = store("roster.staffopen") === "1";
243
+ paintStaffFold();
244
+ const b = $("#stafffold");
245
+ if (!b) return;
246
+ b.onclick = () => {
247
+ staffOpen = !staffOpen;
248
+ store("roster.staffopen", staffOpen ? "1" : "0");
249
+ paintStaffFold();
250
+ };
251
+ }
252
+
156
253
  function paintSidebar() {
157
254
  const host = $("#stafflist");
158
255
  host.replaceChildren();
@@ -201,6 +298,9 @@ function paintSidebar() {
201
298
 
202
299
  host.append(head, views);
203
300
  }
301
+
302
+ // A refresh can hire or retire someone, and the folded heading is where that number shows.
303
+ paintStaffFold();
204
304
  }
205
305
 
206
306
  /** Which rows are lit, and which staff member is unfolded. */
@@ -229,9 +329,9 @@ function render() {
229
329
  // A refresh can add or remove a staff member, and the sidebar is built once.
230
330
  const roster = S.data.staff.map((s) => s.handle).join(" ");
231
331
  if (roster !== paintedRoster) paintSidebar();
332
+ paintSetupNav();
232
333
  markSidebar();
233
- const ic = $("#inboxcount");
234
- if (ic) ic.textContent = S.inbox ? String(openCount()) : "";
334
+ stampCounts();
235
335
  writeHash(true);
236
336
  stampLoaded();
237
337