@harborppm/cli 0.120.0 → 0.121.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/app.mjs +60 -12
  2. package/package.json +1 -1
package/dist/app.mjs CHANGED
@@ -3224,7 +3224,43 @@ function trialDaysLeft(trialEndsAt, now = /* @__PURE__ */ new Date()) {
3224
3224
  return Math.ceil(ms / 864e5);
3225
3225
  }
3226
3226
 
3227
+ // src/lib/roles.ts
3228
+ /** Anything stored that is not a known role reads as a member, as before roles existed. */
3229
+ function normalizeRole(raw) {
3230
+ return raw === "owner" || raw === "admin" || raw === "viewer" ? raw : "member";
3231
+ }
3232
+ /** Who may invite, take back an invite, switch roles and remove someone: the owner and admins. */
3233
+ function runsCrew(role) {
3234
+ return role === "owner" || role === "admin";
3235
+ }
3236
+ /**
3237
+ * The roles `actor` may set on someone who is `target` now. The owner never
3238
+ * changes here (that's a handover). The owner may set any crew role; an
3239
+ * admin only moves members and viewers between editing and viewing, so an
3240
+ * admin can't make more admins or undo another's.
3241
+ */
3242
+ function rolesToOffer(actor, target) {
3243
+ const them = normalizeRole(target);
3244
+ if (them === "owner") return [];
3245
+ if (actor === "owner") return [...CREW_ROLES];
3246
+ if (actor === "admin" && (them === "member" || them === "viewer")) return ["member", "viewer"];
3247
+ return [];
3248
+ }
3249
+ /** Whether `actor` may set `target` (someone else) to `to`. */
3250
+ function mayChangeRole(actor, target, to) {
3251
+ return rolesToOffer(actor, target).includes(to);
3252
+ }
3253
+ var CREW_ROLES;
3254
+ var init_roles = __esmMin((() => {
3255
+ CREW_ROLES = [
3256
+ "admin",
3257
+ "member",
3258
+ "viewer"
3259
+ ];
3260
+ }));
3261
+
3227
3262
  // src/lib/forecast.ts
3263
+ init_roles();
3228
3264
  init_date_fns();
3229
3265
  const day$11 = (iso) => /* @__PURE__ */ new Date(`${iso}T12:00:00`);
3230
3266
  /**
@@ -5784,6 +5820,7 @@ function charterNote(project, tasks, today) {
5784
5820
  }
5785
5821
  const ROLE_LABEL = {
5786
5822
  owner: "Owner",
5823
+ admin: "Admin",
5787
5824
  member: "Can edit",
5788
5825
  viewer: "View only"
5789
5826
  };
@@ -5797,6 +5834,7 @@ const bare = (url) => url.replace(/^https?:\/\//, "");
5797
5834
  */
5798
5835
  function crewRows(crew, data, now) {
5799
5836
  const owner = crew.harbor.role === "owner";
5837
+ const lead = runsCrew(crew.harbor.role);
5800
5838
  const rows = [];
5801
5839
  const nameWidth = Math.min(24, Math.max(0, ...crew.members.map((m) => (m.name ?? "").length)));
5802
5840
  rows.push({
@@ -5813,9 +5851,9 @@ function crewRows(crew, data, now) {
5813
5851
  ].filter(Boolean).join(" · "),
5814
5852
  userId: m.userId,
5815
5853
  role: m.role,
5816
- changeable: owner && m.role !== "owner"
5854
+ changeable: m.userId !== crew.you && mayChangeRole(crew.harbor.role, m.role, "member") && mayChangeRole(crew.harbor.role, m.role, "viewer")
5817
5855
  });
5818
- if (!owner) {
5856
+ if (!lead) {
5819
5857
  const by = crew.members.find((m) => m.role === "owner");
5820
5858
  rows.push({
5821
5859
  kind: "note",
@@ -5837,6 +5875,15 @@ function crewRows(crew, data, now) {
5837
5875
  token: i.token,
5838
5876
  url: i.url
5839
5877
  });
5878
+ }
5879
+ if (lead && !owner) {
5880
+ const by = crew.members.find((m) => m.role === "owner");
5881
+ rows.push({
5882
+ kind: "note",
5883
+ text: `${by?.name || "The owner"} makes share links and intake forms.`
5884
+ });
5885
+ }
5886
+ if (owner) {
5840
5887
  rows.push({
5841
5888
  kind: "heading",
5842
5889
  text: "Share links: a portfolio, read-only, for anyone with the link"
@@ -12916,6 +12963,7 @@ function CalendarView({ active, width, height, go }) {
12916
12963
  * opening and after each change (mcp/app.server.ts answerCrew).
12917
12964
  */
12918
12965
  init_clock();
12966
+ init_roles();
12919
12967
  const actionable = (r) => r.kind !== "heading" && r.kind !== "note";
12920
12968
  /** What the chosen line's keys do, for the line along the bottom. */
12921
12969
  function rowHints(r, owner) {
@@ -12967,6 +13015,7 @@ function CrewView({ active, width, height, go }) {
12967
13015
  const chosen = picks.length ? picks[Math.min(at, picks.length - 1)] : -1;
12968
13016
  const row = chosen >= 0 ? rows[chosen] : void 0;
12969
13017
  const owner = crew?.harbor.role === "owner";
13018
+ const lead = runsCrew(crew?.harbor.role);
12970
13019
  /** One change, then the screen as Harbor now has it; `said` words the notice. */
12971
13020
  const run = (act, said) => {
12972
13021
  if (!workspaceId || busy) return;
@@ -13015,7 +13064,7 @@ function CrewView({ active, width, height, go }) {
13015
13064
  if (key.pageDown) return setAt((i) => Math.min(picks.length - 1, i + 10));
13016
13065
  if (key.pageUp) return setAt((i) => Math.max(0, i - 10));
13017
13066
  if (!crew) return;
13018
- if (owner && input === "i") return invite();
13067
+ if (lead && input === "i") return invite();
13019
13068
  if (owner && input === "s") {
13020
13069
  if (!portfolios.length) return go.notify("There's no portfolio to share yet.");
13021
13070
  return go.pick("Share which portfolio, read-only?", portfolios.map((p) => ({
@@ -13135,7 +13184,7 @@ function CrewView({ active, width, height, go }) {
13135
13184
  "i invite",
13136
13185
  "s share link",
13137
13186
  "f intake form"
13138
- ] : []];
13187
+ ] : lead ? ["i invite"] : []];
13139
13188
  const view = windowOf(rows, Math.max(0, chosen), Math.max(3, height - 3));
13140
13189
  return /* @__PURE__ */ jsxs(Box, {
13141
13190
  flexDirection: "column",
@@ -13144,7 +13193,7 @@ function CrewView({ active, width, height, go }) {
13144
13193
  paddingX: 1,
13145
13194
  children: [
13146
13195
  /* @__PURE__ */ jsx(Heading, {
13147
- right: owner ? "you're the owner" : `you ${crew.harbor.role === "viewer" ? "can view" : "can edit"}`,
13196
+ right: owner ? "you're the owner" : lead ? "you're an admin" : `you ${crew.harbor.role === "viewer" ? "can view" : "can edit"}`,
13148
13197
  children: "Crew"
13149
13198
  }),
13150
13199
  view.items.map((r, n) => {
@@ -31494,6 +31543,12 @@ function tasksSlice({ set, get, write }) {
31494
31543
  for (const mark of marks) have.add(mark);
31495
31544
  set({ readPingIds: [...have] });
31496
31545
  },
31546
+ forgetReads: (marks) => {
31547
+ const drop = new Set(marks);
31548
+ const ids = get().readPingIds ?? [];
31549
+ if (!ids.some((id) => drop.has(id))) return;
31550
+ set({ readPingIds: ids.filter((id) => !drop.has(id)) });
31551
+ },
31497
31552
  tickVoyage: (ids) => {
31498
31553
  const ticked = get().tasks.filter((t) => ids.includes(t.id) && t.status !== "done" && !isExternal(t));
31499
31554
  if (ticked.length === 0) return;
@@ -32936,13 +32991,6 @@ var init_live_changes = __esmMin((() => {
32936
32991
  NOT_WHOLE = [...ROW_COLLECTIONS, "currentUserId"];
32937
32992
  }));
32938
32993
 
32939
- // src/lib/roles.ts
32940
- /** Anything stored that is not a known role reads as a member, as before roles existed. */
32941
- function normalizeRole(raw) {
32942
- return raw === "owner" || raw === "viewer" ? raw : "member";
32943
- }
32944
- var init_roles = __esmMin((() => {}));
32945
-
32946
32994
  // src/lib/sync-state.ts
32947
32995
  /** Wait before the nth retry (0-based): 2 s, 4 s, 8 s, 16 s, then every 30 s. */
32948
32996
  function retryDelay(attempt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harborppm/cli",
3
- "version": "0.120.0",
3
+ "version": "0.121.0",
4
4
  "description": "Harbor from the terminal: a full-screen app with everything, plus commands for scripts and agents.",
5
5
  "keywords": [
6
6
  "harbor",