tryharness 0.7.34 → 0.7.35

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/cli.mjs +24 -2
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -1786,6 +1786,24 @@ async function agents() {
1786
1786
  ui.outro("Done.");
1787
1787
  }
1788
1788
 
1789
+ // The pairing link carries a public key, so its code is large: drawn two characters per module it
1790
+ // was 130 columns and wrapped into noise. Half blocks put two rows in one line at one column per
1791
+ // module (61 columns), and fixed black and white keep it scannable on light and dark themes.
1792
+ async function terminalQr(text) {
1793
+ const { default: encodeQR } = await import("qr");
1794
+ const rows = encodeQR(text, "raw", { ecc: "low", border: 4 });
1795
+ const lines = [];
1796
+ for (let y = 0; y < rows.length; y += 2) {
1797
+ const cells = rows[y].map((top, x) => {
1798
+ const foreground = top ? 30 : 97;
1799
+ const background = rows[y + 1]?.[x] ? 40 : 107;
1800
+ return `\x1b[${foreground};${background}m▀`;
1801
+ });
1802
+ lines.push(`${cells.join("")}\x1b[0m`);
1803
+ }
1804
+ return { lines, width: rows[0].length };
1805
+ }
1806
+
1789
1807
  async function phone() {
1790
1808
  const sub = argv[0] || "pair";
1791
1809
  if (sub === "pair") {
@@ -1794,11 +1812,15 @@ async function phone() {
1794
1812
  throw new Error(
1795
1813
  response.error || "the daemon could not make a pairing code"
1796
1814
  );
1797
- const { default: encodeQR } = await import("qr");
1815
+ const qr = await terminalQr(response.url);
1798
1816
  console.log(
1799
1817
  "Scan this with your phone's camera. The code works once, for 10 minutes.\n"
1800
1818
  );
1801
- console.log(encodeQR(response.url, "term"));
1819
+ console.log(qr.lines.join("\n"));
1820
+ if (process.stdout.columns && process.stdout.columns < qr.width)
1821
+ console.log(
1822
+ `\nThis window is narrower than the code (${qr.width} columns), so it may not scan. Widen it and run this again, or add --link to print the link.`
1823
+ );
1802
1824
  if (has("--link"))
1803
1825
  console.log(
1804
1826
  `\n${response.url}\n\nThis link is the pairing secret: open it only on your own phone.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tryharness",
3
- "version": "0.7.34",
3
+ "version": "0.7.35",
4
4
  "description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
5
5
  "bin": {
6
6
  "tryharness": "cli.mjs"