kcg-code 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kcg-code",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Control CLI AI agents (OpenCode / Claude Code) from your phone — mobile PWA + local headless bridge.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5,12 +5,16 @@
5
5
  */
6
6
  import { networkInterfaces } from "node:os";
7
7
  import { Box, render, renderToString, Text, useInput } from "ink";
8
- import { type ReactNode, useEffect, useReducer, useRef, useState } from "react";
8
+ import type { ReactNode } from "react";
9
9
  import { renderUnicodeCompact } from "uqr";
10
10
  import type { KcgServer } from "../server/app";
11
+ import { InkReact } from "./ink-react";
11
12
  import type { KeepAwake } from "./keep-awake";
12
13
  import { logoLines, readPackageVersion } from "./theme";
13
14
 
15
+ // Hook wajib dari instance React milik Ink — lihat ink-react.ts.
16
+ const { useEffect, useReducer, useRef, useState } = InkReact;
17
+
14
18
  export type TunnelProviderId = "kcg" | "lhr";
15
19
 
16
20
  interface KcgTunnelStatus {
@@ -0,0 +1,26 @@
1
+ /**
2
+ * React yang sama dengan yang dipakai renderer Ink.
3
+ *
4
+ * Pada install global (`bun i -g kcg-code`), `ink` bisa di-hoist ke
5
+ * node_modules global bersama React milik paket lain, sementara kcg-code
6
+ * mendapat salinan React sendiri (`kcg-code/node_modules/react`). Hook dari
7
+ * salinan itu tidak dikenali reconciler Ink → "Invalid hook call".
8
+ *
9
+ * Solusinya: ambil React dari lokasi `react-reconciler` milik Ink, sehingga
10
+ * hook dan reconciler selalu memakai instance yang sama.
11
+ */
12
+ import { createRequire } from "node:module";
13
+ import * as LocalReact from "react";
14
+
15
+ function resolveInkReact(): typeof LocalReact {
16
+ try {
17
+ const inkRequire = createRequire(Bun.resolveSync("ink", import.meta.dir));
18
+ const reconcilerRequire = createRequire(inkRequire.resolve("react-reconciler"));
19
+ return reconcilerRequire("react") as typeof LocalReact;
20
+ } catch {
21
+ // Layout tak terduga — pakai React milik paket ini.
22
+ return LocalReact;
23
+ }
24
+ }
25
+
26
+ export const InkReact = resolveInkReact();