@gapi/gcli 1.8.269 → 1.8.271

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,12 @@
1
+ ## 2026-11-18 - local-workspaces: list returns mtimeMs (the browser's file cache key)
2
+
3
+ **Feature:** local-workspaces · **Type:** feat
4
+
5
+ - `WorkspaceFiles.list`: every file entry carries `mtimeMs` next to `size`
6
+ (the same `stat`). The Lambforge editor caches a local workspace's files
7
+ in the browser and serves one from there only while size + mtime match.
8
+ - **Test:** `npx jest test/workspace-gitignore.spec.ts --coverage=false`
9
+ (the listing has size + mtimeMs).
10
+ - **Debug:** the browser never caches contents -> this gcli is older (no
11
+ `mtimeMs` in `list`).
12
+ - **Verification:** tsc clean, `npm run lint`, jest workspace specs 49/49.
@@ -0,0 +1,17 @@
1
+ ## 2026-11-18 - local-workspaces: watch/open + watch/close: the browser editor watches files without a terminal
2
+
3
+ **Feature:** local-workspaces · **Type:** feat
4
+
5
+ - Found by the owner: a file edited in his own IDE did not update in the
6
+ Lambforge editor - changes were only watched while a browser terminal
7
+ was open.
8
+ - `TerminalManager.watch()` / `unwatch()`: a watch of its own (recursive
9
+ fs.watch, 150 ms batches, .gitignore'd paths dropped) pushing `changed`
10
+ events under its sessionId; terminals are shells only now. Ops
11
+ `watch/open`, `watch/close` - no `--allow-terminal` needed (names only,
12
+ what `list` shows anyway). Max 4 watches.
13
+ - **Test:** `npx jest test/workspace-terminals.spec.ts --coverage=false`
14
+ (a watch reports changes; watch/open works without the flag).
15
+ - **Debug:** no updates in the browser -> the gcli log shows "the browser
16
+ editor watches the files" when the editor opens; older gcli has no watch.
17
+ - **Verification:** tsc clean, `npm run lint`, jest workspace specs 50/50.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/gcli",
3
- "version": "1.8.269",
3
+ "version": "1.8.271",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
package/release/index.js CHANGED
@@ -324033,7 +324033,9 @@ var init_files = __esm({
324033
324033
  entries = entries.slice(0, limit);
324034
324034
  await Promise.all(
324035
324035
  entries.filter((e2) => e2.type === "file").map(async (e2) => {
324036
- e2.size = await import_fs12.promises.stat((0, import_path7.join)(this.root, e2.path)).then((s2) => s2.size).catch(() => void 0);
324036
+ const stat2 = await import_fs12.promises.stat((0, import_path7.join)(this.root, e2.path)).catch(() => void 0);
324037
+ e2.size = stat2?.size;
324038
+ e2.mtimeMs = stat2 ? Math.floor(stat2.mtimeMs) : void 0;
324037
324039
  })
324038
324040
  );
324039
324041
  return {
@@ -324640,7 +324642,10 @@ var init_terminals = __esm({
324640
324642
  this.env = env;
324641
324643
  this.notIgnored = notIgnored;
324642
324644
  this.events$ = new import_rxjs70.Subject();
324645
+ /** shells (`terminal/*`) */
324643
324646
  this.sessions = /* @__PURE__ */ new Map();
324647
+ /** file watches (`watch/*`) - the open editor, terminal or not */
324648
+ this.watches = /* @__PURE__ */ new Map();
324644
324649
  }
324645
324650
  open(size) {
324646
324651
  if (this.sessions.size >= MAX_SESSIONS) {
@@ -324677,46 +324682,66 @@ var init_terminals = __esm({
324677
324682
  ${e2.message}\r
324678
324683
  ` })
324679
324684
  );
324685
+ this.sessions.set(sessionId, child);
324686
+ return { sessionId, pty: command === "script" };
324687
+ }
324688
+ input(sessionId, data) {
324689
+ const child = this.sessions.get(sessionId);
324690
+ if (!child) {
324691
+ throw new WorkspaceError("This terminal is closed.", 404);
324692
+ }
324693
+ child.stdin?.write(data);
324694
+ return { written: data.length };
324695
+ }
324696
+ close(sessionId) {
324697
+ const child = this.sessions.get(sessionId);
324698
+ if (child) {
324699
+ kill(child);
324700
+ this.forget(sessionId);
324701
+ }
324702
+ return { closed: !!child };
324703
+ }
324704
+ /**
324705
+ * Watch the root for the browser editor (no shell, no --allow-terminal:
324706
+ * only the names of changed files, which `list` shows anyway). Changes
324707
+ * are batched, de-duplicated and `.gitignore`d ones dropped, then sent as
324708
+ * `changed` events of this watch.
324709
+ */
324710
+ watch() {
324711
+ if (this.watches.size >= MAX_SESSIONS) {
324712
+ throw new WorkspaceError(
324713
+ `At most ${MAX_SESSIONS} editors watching at a time.`,
324714
+ 429
324715
+ );
324716
+ }
324717
+ const sessionId = (0, import_crypto3.randomUUID)();
324680
324718
  const changed$ = new import_rxjs70.Subject();
324681
324719
  const changes = changed$.pipe(
324682
324720
  (0, import_operators59.bufferTime)(WATCH_BATCH_MS),
324683
324721
  (0, import_operators59.filter)((paths) => paths.length > 0),
324684
324722
  (0, import_operators59.concatMap)((paths) => (0, import_rxjs70.from)(this.notIgnored([...new Set(paths)]))),
324685
324723
  (0, import_operators59.mergeMap)((paths) => (0, import_rxjs70.from)(paths))
324686
- ).subscribe((path2) => emit({ kind: "changed", data: path2 }));
324687
- this.sessions.set(sessionId, {
324688
- child,
324724
+ ).subscribe(
324725
+ (path2) => this.events$.next({ sessionId, kind: "changed", data: path2 })
324726
+ );
324727
+ this.watches.set(sessionId, {
324689
324728
  watcher: this.watchRoot((path2) => changed$.next(path2)),
324690
324729
  changes
324691
324730
  });
324692
- return { sessionId, pty: command === "script" };
324731
+ return { sessionId };
324693
324732
  }
324694
- input(sessionId, data) {
324695
- this.session(sessionId).child.stdin?.write(data);
324696
- return { written: data.length };
324697
- }
324698
- close(sessionId) {
324699
- const session = this.sessions.get(sessionId);
324700
- if (session) {
324701
- kill(session.child);
324702
- this.forget(sessionId);
324703
- }
324704
- return { closed: !!session };
324733
+ unwatch(sessionId) {
324734
+ const watch3 = this.watches.get(sessionId);
324735
+ watch3?.watcher?.close();
324736
+ watch3?.changes.unsubscribe();
324737
+ this.watches.delete(sessionId);
324738
+ return { closed: !!watch3 };
324705
324739
  }
324706
324740
  closeAll() {
324707
324741
  [...this.sessions.keys()].forEach((id) => this.close(id));
324708
- }
324709
- session(sessionId) {
324710
- const session = this.sessions.get(sessionId);
324711
- if (!session) {
324712
- throw new WorkspaceError("This terminal is closed.", 404);
324713
- }
324714
- return session;
324742
+ [...this.watches.keys()].forEach((id) => this.unwatch(id));
324715
324743
  }
324716
324744
  forget(sessionId) {
324717
- const session = this.sessions.get(sessionId);
324718
- session?.watcher?.close();
324719
- session?.changes.unsubscribe();
324720
324745
  this.sessions.delete(sessionId);
324721
324746
  }
324722
324747
  /** Recursive watch of the root (Node >= 20 on Linux, macOS, Windows). */
@@ -324765,7 +324790,10 @@ var init_connection2 = __esm({
324765
324790
  // browser terminals (--allow-terminal, plan 36)
324766
324791
  "terminal/open",
324767
324792
  "terminal/input",
324768
- "terminal/close"
324793
+ "terminal/close",
324794
+ // the browser editor's file watch (no --allow-terminal needed)
324795
+ "watch/open",
324796
+ "watch/close"
324769
324797
  ];
324770
324798
  HEARTBEAT_MUTATION2 = `mutation localWorkspaceHeartbeat($info: LocalWorkspaceHeartbeatInput) {
324771
324799
  localWorkspaceHeartbeat(info: $info) { id name }
@@ -324998,6 +325026,11 @@ var init_connection2 = __esm({
324998
325026
  str(args.sessionId) ?? "",
324999
325027
  str(args.data) ?? ""
325000
325028
  );
325029
+ case "watch/open":
325030
+ log2("\u25C9 the browser editor watches the files");
325031
+ return this.terminals.watch();
325032
+ case "watch/close":
325033
+ return this.terminals.unwatch(str(args.sessionId) ?? "");
325001
325034
  case "terminal/close":
325002
325035
  log2("\u25A3 terminal closed");
325003
325036
  return this.terminals.close(str(args.sessionId) ?? "");
@@ -326139,7 +326172,7 @@ if (!isWebContainer) {
326139
326172
  } else {
326140
326173
  }
326141
326174
  }
326142
- var version2 = true ? "1.8.268" : "development";
326175
+ var version2 = true ? "1.8.270" : "development";
326143
326176
  var main = (argv) => {
326144
326177
  import_commander.program.name("gcli").version(version2);
326145
326178
  commands.map((command) => command(import_commander.program));