@devness/useai-cli 0.4.4 → 0.4.6

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +546 -278
  3. package/package.json +11 -12
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/index.ts
9
- import { Command as Command10 } from "commander";
9
+ import { Command as Command11 } from "commander";
10
10
 
11
11
  // ../shared/dist/constants/paths.js
12
12
  import { join } from "path";
@@ -20,6 +20,7 @@ var CONFIG_FILE = join(USEAI_DIR, "config.json");
20
20
  var SESSIONS_FILE = join(DATA_DIR, "sessions.json");
21
21
  var MILESTONES_FILE = join(DATA_DIR, "milestones.json");
22
22
  var DAEMON_PID_FILE = join(USEAI_DIR, "daemon.pid");
23
+ var USEAI_HOOKS_DIR = join(USEAI_DIR, "hooks");
23
24
  var DAEMON_PORT = 19200;
24
25
  var DAEMON_LOG_FILE = join(USEAI_DIR, "daemon.log");
25
26
  var DAEMON_MCP_URL = `http://127.0.0.1:${DAEMON_PORT}/mcp`;
@@ -29,7 +30,7 @@ var SYSTEMD_SERVICE_PATH = join(homedir(), ".config", "systemd", "user", "useai-
29
30
  var WINDOWS_STARTUP_SCRIPT_PATH = join(process.env["APPDATA"] ?? join(homedir(), "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "useai-daemon.vbs");
30
31
 
31
32
  // ../shared/dist/constants/version.js
32
- var VERSION = "0.4.4";
33
+ var VERSION = "0.4.6";
33
34
 
34
35
  // ../shared/dist/constants/defaults.js
35
36
  var DEFAULT_CONFIG = {
@@ -1078,41 +1079,41 @@ var ZodType = class {
1078
1079
  get description() {
1079
1080
  return this._def.description;
1080
1081
  }
1081
- _getType(input) {
1082
- return getParsedType(input.data);
1082
+ _getType(input2) {
1083
+ return getParsedType(input2.data);
1083
1084
  }
1084
- _getOrReturnCtx(input, ctx) {
1085
+ _getOrReturnCtx(input2, ctx) {
1085
1086
  return ctx || {
1086
- common: input.parent.common,
1087
- data: input.data,
1088
- parsedType: getParsedType(input.data),
1087
+ common: input2.parent.common,
1088
+ data: input2.data,
1089
+ parsedType: getParsedType(input2.data),
1089
1090
  schemaErrorMap: this._def.errorMap,
1090
- path: input.path,
1091
- parent: input.parent
1091
+ path: input2.path,
1092
+ parent: input2.parent
1092
1093
  };
1093
1094
  }
1094
- _processInputParams(input) {
1095
+ _processInputParams(input2) {
1095
1096
  return {
1096
1097
  status: new ParseStatus(),
1097
1098
  ctx: {
1098
- common: input.parent.common,
1099
- data: input.data,
1100
- parsedType: getParsedType(input.data),
1099
+ common: input2.parent.common,
1100
+ data: input2.data,
1101
+ parsedType: getParsedType(input2.data),
1101
1102
  schemaErrorMap: this._def.errorMap,
1102
- path: input.path,
1103
- parent: input.parent
1103
+ path: input2.path,
1104
+ parent: input2.parent
1104
1105
  }
1105
1106
  };
1106
1107
  }
1107
- _parseSync(input) {
1108
- const result = this._parse(input);
1108
+ _parseSync(input2) {
1109
+ const result = this._parse(input2);
1109
1110
  if (isAsync(result)) {
1110
1111
  throw new Error("Synchronous parse encountered promise.");
1111
1112
  }
1112
1113
  return result;
1113
1114
  }
1114
- _parseAsync(input) {
1115
- const result = this._parse(input);
1115
+ _parseAsync(input2) {
1116
+ const result = this._parse(input2);
1116
1117
  return Promise.resolve(result);
1117
1118
  }
1118
1119
  parse(data, params) {
@@ -1438,13 +1439,13 @@ function isValidCidr(ip, version) {
1438
1439
  return false;
1439
1440
  }
1440
1441
  var ZodString = class _ZodString extends ZodType {
1441
- _parse(input) {
1442
+ _parse(input2) {
1442
1443
  if (this._def.coerce) {
1443
- input.data = String(input.data);
1444
+ input2.data = String(input2.data);
1444
1445
  }
1445
- const parsedType = this._getType(input);
1446
+ const parsedType = this._getType(input2);
1446
1447
  if (parsedType !== ZodParsedType.string) {
1447
- const ctx2 = this._getOrReturnCtx(input);
1448
+ const ctx2 = this._getOrReturnCtx(input2);
1448
1449
  addIssueToContext(ctx2, {
1449
1450
  code: ZodIssueCode.invalid_type,
1450
1451
  expected: ZodParsedType.string,
@@ -1456,8 +1457,8 @@ var ZodString = class _ZodString extends ZodType {
1456
1457
  let ctx = void 0;
1457
1458
  for (const check of this._def.checks) {
1458
1459
  if (check.kind === "min") {
1459
- if (input.data.length < check.value) {
1460
- ctx = this._getOrReturnCtx(input, ctx);
1460
+ if (input2.data.length < check.value) {
1461
+ ctx = this._getOrReturnCtx(input2, ctx);
1461
1462
  addIssueToContext(ctx, {
1462
1463
  code: ZodIssueCode.too_small,
1463
1464
  minimum: check.value,
@@ -1469,8 +1470,8 @@ var ZodString = class _ZodString extends ZodType {
1469
1470
  status.dirty();
1470
1471
  }
1471
1472
  } else if (check.kind === "max") {
1472
- if (input.data.length > check.value) {
1473
- ctx = this._getOrReturnCtx(input, ctx);
1473
+ if (input2.data.length > check.value) {
1474
+ ctx = this._getOrReturnCtx(input2, ctx);
1474
1475
  addIssueToContext(ctx, {
1475
1476
  code: ZodIssueCode.too_big,
1476
1477
  maximum: check.value,
@@ -1482,10 +1483,10 @@ var ZodString = class _ZodString extends ZodType {
1482
1483
  status.dirty();
1483
1484
  }
1484
1485
  } else if (check.kind === "length") {
1485
- const tooBig = input.data.length > check.value;
1486
- const tooSmall = input.data.length < check.value;
1486
+ const tooBig = input2.data.length > check.value;
1487
+ const tooSmall = input2.data.length < check.value;
1487
1488
  if (tooBig || tooSmall) {
1488
- ctx = this._getOrReturnCtx(input, ctx);
1489
+ ctx = this._getOrReturnCtx(input2, ctx);
1489
1490
  if (tooBig) {
1490
1491
  addIssueToContext(ctx, {
1491
1492
  code: ZodIssueCode.too_big,
@@ -1508,8 +1509,8 @@ var ZodString = class _ZodString extends ZodType {
1508
1509
  status.dirty();
1509
1510
  }
1510
1511
  } else if (check.kind === "email") {
1511
- if (!emailRegex.test(input.data)) {
1512
- ctx = this._getOrReturnCtx(input, ctx);
1512
+ if (!emailRegex.test(input2.data)) {
1513
+ ctx = this._getOrReturnCtx(input2, ctx);
1513
1514
  addIssueToContext(ctx, {
1514
1515
  validation: "email",
1515
1516
  code: ZodIssueCode.invalid_string,
@@ -1521,8 +1522,8 @@ var ZodString = class _ZodString extends ZodType {
1521
1522
  if (!emojiRegex) {
1522
1523
  emojiRegex = new RegExp(_emojiRegex, "u");
1523
1524
  }
1524
- if (!emojiRegex.test(input.data)) {
1525
- ctx = this._getOrReturnCtx(input, ctx);
1525
+ if (!emojiRegex.test(input2.data)) {
1526
+ ctx = this._getOrReturnCtx(input2, ctx);
1526
1527
  addIssueToContext(ctx, {
1527
1528
  validation: "emoji",
1528
1529
  code: ZodIssueCode.invalid_string,
@@ -1531,8 +1532,8 @@ var ZodString = class _ZodString extends ZodType {
1531
1532
  status.dirty();
1532
1533
  }
1533
1534
  } else if (check.kind === "uuid") {
1534
- if (!uuidRegex.test(input.data)) {
1535
- ctx = this._getOrReturnCtx(input, ctx);
1535
+ if (!uuidRegex.test(input2.data)) {
1536
+ ctx = this._getOrReturnCtx(input2, ctx);
1536
1537
  addIssueToContext(ctx, {
1537
1538
  validation: "uuid",
1538
1539
  code: ZodIssueCode.invalid_string,
@@ -1541,8 +1542,8 @@ var ZodString = class _ZodString extends ZodType {
1541
1542
  status.dirty();
1542
1543
  }
1543
1544
  } else if (check.kind === "nanoid") {
1544
- if (!nanoidRegex.test(input.data)) {
1545
- ctx = this._getOrReturnCtx(input, ctx);
1545
+ if (!nanoidRegex.test(input2.data)) {
1546
+ ctx = this._getOrReturnCtx(input2, ctx);
1546
1547
  addIssueToContext(ctx, {
1547
1548
  validation: "nanoid",
1548
1549
  code: ZodIssueCode.invalid_string,
@@ -1551,8 +1552,8 @@ var ZodString = class _ZodString extends ZodType {
1551
1552
  status.dirty();
1552
1553
  }
1553
1554
  } else if (check.kind === "cuid") {
1554
- if (!cuidRegex.test(input.data)) {
1555
- ctx = this._getOrReturnCtx(input, ctx);
1555
+ if (!cuidRegex.test(input2.data)) {
1556
+ ctx = this._getOrReturnCtx(input2, ctx);
1556
1557
  addIssueToContext(ctx, {
1557
1558
  validation: "cuid",
1558
1559
  code: ZodIssueCode.invalid_string,
@@ -1561,8 +1562,8 @@ var ZodString = class _ZodString extends ZodType {
1561
1562
  status.dirty();
1562
1563
  }
1563
1564
  } else if (check.kind === "cuid2") {
1564
- if (!cuid2Regex.test(input.data)) {
1565
- ctx = this._getOrReturnCtx(input, ctx);
1565
+ if (!cuid2Regex.test(input2.data)) {
1566
+ ctx = this._getOrReturnCtx(input2, ctx);
1566
1567
  addIssueToContext(ctx, {
1567
1568
  validation: "cuid2",
1568
1569
  code: ZodIssueCode.invalid_string,
@@ -1571,8 +1572,8 @@ var ZodString = class _ZodString extends ZodType {
1571
1572
  status.dirty();
1572
1573
  }
1573
1574
  } else if (check.kind === "ulid") {
1574
- if (!ulidRegex.test(input.data)) {
1575
- ctx = this._getOrReturnCtx(input, ctx);
1575
+ if (!ulidRegex.test(input2.data)) {
1576
+ ctx = this._getOrReturnCtx(input2, ctx);
1576
1577
  addIssueToContext(ctx, {
1577
1578
  validation: "ulid",
1578
1579
  code: ZodIssueCode.invalid_string,
@@ -1582,9 +1583,9 @@ var ZodString = class _ZodString extends ZodType {
1582
1583
  }
1583
1584
  } else if (check.kind === "url") {
1584
1585
  try {
1585
- new URL(input.data);
1586
+ new URL(input2.data);
1586
1587
  } catch {
1587
- ctx = this._getOrReturnCtx(input, ctx);
1588
+ ctx = this._getOrReturnCtx(input2, ctx);
1588
1589
  addIssueToContext(ctx, {
1589
1590
  validation: "url",
1590
1591
  code: ZodIssueCode.invalid_string,
@@ -1594,9 +1595,9 @@ var ZodString = class _ZodString extends ZodType {
1594
1595
  }
1595
1596
  } else if (check.kind === "regex") {
1596
1597
  check.regex.lastIndex = 0;
1597
- const testResult = check.regex.test(input.data);
1598
+ const testResult = check.regex.test(input2.data);
1598
1599
  if (!testResult) {
1599
- ctx = this._getOrReturnCtx(input, ctx);
1600
+ ctx = this._getOrReturnCtx(input2, ctx);
1600
1601
  addIssueToContext(ctx, {
1601
1602
  validation: "regex",
1602
1603
  code: ZodIssueCode.invalid_string,
@@ -1605,10 +1606,10 @@ var ZodString = class _ZodString extends ZodType {
1605
1606
  status.dirty();
1606
1607
  }
1607
1608
  } else if (check.kind === "trim") {
1608
- input.data = input.data.trim();
1609
+ input2.data = input2.data.trim();
1609
1610
  } else if (check.kind === "includes") {
1610
- if (!input.data.includes(check.value, check.position)) {
1611
- ctx = this._getOrReturnCtx(input, ctx);
1611
+ if (!input2.data.includes(check.value, check.position)) {
1612
+ ctx = this._getOrReturnCtx(input2, ctx);
1612
1613
  addIssueToContext(ctx, {
1613
1614
  code: ZodIssueCode.invalid_string,
1614
1615
  validation: { includes: check.value, position: check.position },
@@ -1617,12 +1618,12 @@ var ZodString = class _ZodString extends ZodType {
1617
1618
  status.dirty();
1618
1619
  }
1619
1620
  } else if (check.kind === "toLowerCase") {
1620
- input.data = input.data.toLowerCase();
1621
+ input2.data = input2.data.toLowerCase();
1621
1622
  } else if (check.kind === "toUpperCase") {
1622
- input.data = input.data.toUpperCase();
1623
+ input2.data = input2.data.toUpperCase();
1623
1624
  } else if (check.kind === "startsWith") {
1624
- if (!input.data.startsWith(check.value)) {
1625
- ctx = this._getOrReturnCtx(input, ctx);
1625
+ if (!input2.data.startsWith(check.value)) {
1626
+ ctx = this._getOrReturnCtx(input2, ctx);
1626
1627
  addIssueToContext(ctx, {
1627
1628
  code: ZodIssueCode.invalid_string,
1628
1629
  validation: { startsWith: check.value },
@@ -1631,8 +1632,8 @@ var ZodString = class _ZodString extends ZodType {
1631
1632
  status.dirty();
1632
1633
  }
1633
1634
  } else if (check.kind === "endsWith") {
1634
- if (!input.data.endsWith(check.value)) {
1635
- ctx = this._getOrReturnCtx(input, ctx);
1635
+ if (!input2.data.endsWith(check.value)) {
1636
+ ctx = this._getOrReturnCtx(input2, ctx);
1636
1637
  addIssueToContext(ctx, {
1637
1638
  code: ZodIssueCode.invalid_string,
1638
1639
  validation: { endsWith: check.value },
@@ -1642,8 +1643,8 @@ var ZodString = class _ZodString extends ZodType {
1642
1643
  }
1643
1644
  } else if (check.kind === "datetime") {
1644
1645
  const regex = datetimeRegex(check);
1645
- if (!regex.test(input.data)) {
1646
- ctx = this._getOrReturnCtx(input, ctx);
1646
+ if (!regex.test(input2.data)) {
1647
+ ctx = this._getOrReturnCtx(input2, ctx);
1647
1648
  addIssueToContext(ctx, {
1648
1649
  code: ZodIssueCode.invalid_string,
1649
1650
  validation: "datetime",
@@ -1653,8 +1654,8 @@ var ZodString = class _ZodString extends ZodType {
1653
1654
  }
1654
1655
  } else if (check.kind === "date") {
1655
1656
  const regex = dateRegex;
1656
- if (!regex.test(input.data)) {
1657
- ctx = this._getOrReturnCtx(input, ctx);
1657
+ if (!regex.test(input2.data)) {
1658
+ ctx = this._getOrReturnCtx(input2, ctx);
1658
1659
  addIssueToContext(ctx, {
1659
1660
  code: ZodIssueCode.invalid_string,
1660
1661
  validation: "date",
@@ -1664,8 +1665,8 @@ var ZodString = class _ZodString extends ZodType {
1664
1665
  }
1665
1666
  } else if (check.kind === "time") {
1666
1667
  const regex = timeRegex(check);
1667
- if (!regex.test(input.data)) {
1668
- ctx = this._getOrReturnCtx(input, ctx);
1668
+ if (!regex.test(input2.data)) {
1669
+ ctx = this._getOrReturnCtx(input2, ctx);
1669
1670
  addIssueToContext(ctx, {
1670
1671
  code: ZodIssueCode.invalid_string,
1671
1672
  validation: "time",
@@ -1674,8 +1675,8 @@ var ZodString = class _ZodString extends ZodType {
1674
1675
  status.dirty();
1675
1676
  }
1676
1677
  } else if (check.kind === "duration") {
1677
- if (!durationRegex.test(input.data)) {
1678
- ctx = this._getOrReturnCtx(input, ctx);
1678
+ if (!durationRegex.test(input2.data)) {
1679
+ ctx = this._getOrReturnCtx(input2, ctx);
1679
1680
  addIssueToContext(ctx, {
1680
1681
  validation: "duration",
1681
1682
  code: ZodIssueCode.invalid_string,
@@ -1684,8 +1685,8 @@ var ZodString = class _ZodString extends ZodType {
1684
1685
  status.dirty();
1685
1686
  }
1686
1687
  } else if (check.kind === "ip") {
1687
- if (!isValidIP(input.data, check.version)) {
1688
- ctx = this._getOrReturnCtx(input, ctx);
1688
+ if (!isValidIP(input2.data, check.version)) {
1689
+ ctx = this._getOrReturnCtx(input2, ctx);
1689
1690
  addIssueToContext(ctx, {
1690
1691
  validation: "ip",
1691
1692
  code: ZodIssueCode.invalid_string,
@@ -1694,8 +1695,8 @@ var ZodString = class _ZodString extends ZodType {
1694
1695
  status.dirty();
1695
1696
  }
1696
1697
  } else if (check.kind === "jwt") {
1697
- if (!isValidJWT(input.data, check.alg)) {
1698
- ctx = this._getOrReturnCtx(input, ctx);
1698
+ if (!isValidJWT(input2.data, check.alg)) {
1699
+ ctx = this._getOrReturnCtx(input2, ctx);
1699
1700
  addIssueToContext(ctx, {
1700
1701
  validation: "jwt",
1701
1702
  code: ZodIssueCode.invalid_string,
@@ -1704,8 +1705,8 @@ var ZodString = class _ZodString extends ZodType {
1704
1705
  status.dirty();
1705
1706
  }
1706
1707
  } else if (check.kind === "cidr") {
1707
- if (!isValidCidr(input.data, check.version)) {
1708
- ctx = this._getOrReturnCtx(input, ctx);
1708
+ if (!isValidCidr(input2.data, check.version)) {
1709
+ ctx = this._getOrReturnCtx(input2, ctx);
1709
1710
  addIssueToContext(ctx, {
1710
1711
  validation: "cidr",
1711
1712
  code: ZodIssueCode.invalid_string,
@@ -1714,8 +1715,8 @@ var ZodString = class _ZodString extends ZodType {
1714
1715
  status.dirty();
1715
1716
  }
1716
1717
  } else if (check.kind === "base64") {
1717
- if (!base64Regex.test(input.data)) {
1718
- ctx = this._getOrReturnCtx(input, ctx);
1718
+ if (!base64Regex.test(input2.data)) {
1719
+ ctx = this._getOrReturnCtx(input2, ctx);
1719
1720
  addIssueToContext(ctx, {
1720
1721
  validation: "base64",
1721
1722
  code: ZodIssueCode.invalid_string,
@@ -1724,8 +1725,8 @@ var ZodString = class _ZodString extends ZodType {
1724
1725
  status.dirty();
1725
1726
  }
1726
1727
  } else if (check.kind === "base64url") {
1727
- if (!base64urlRegex.test(input.data)) {
1728
- ctx = this._getOrReturnCtx(input, ctx);
1728
+ if (!base64urlRegex.test(input2.data)) {
1729
+ ctx = this._getOrReturnCtx(input2, ctx);
1729
1730
  addIssueToContext(ctx, {
1730
1731
  validation: "base64url",
1731
1732
  code: ZodIssueCode.invalid_string,
@@ -1737,7 +1738,7 @@ var ZodString = class _ZodString extends ZodType {
1737
1738
  util.assertNever(check);
1738
1739
  }
1739
1740
  }
1740
- return { status: status.value, value: input.data };
1741
+ return { status: status.value, value: input2.data };
1741
1742
  }
1742
1743
  _regex(regex, validation, message) {
1743
1744
  return this.refinement((data) => regex.test(data), {
@@ -1998,13 +1999,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
1998
1999
  this.max = this.lte;
1999
2000
  this.step = this.multipleOf;
2000
2001
  }
2001
- _parse(input) {
2002
+ _parse(input2) {
2002
2003
  if (this._def.coerce) {
2003
- input.data = Number(input.data);
2004
+ input2.data = Number(input2.data);
2004
2005
  }
2005
- const parsedType = this._getType(input);
2006
+ const parsedType = this._getType(input2);
2006
2007
  if (parsedType !== ZodParsedType.number) {
2007
- const ctx2 = this._getOrReturnCtx(input);
2008
+ const ctx2 = this._getOrReturnCtx(input2);
2008
2009
  addIssueToContext(ctx2, {
2009
2010
  code: ZodIssueCode.invalid_type,
2010
2011
  expected: ZodParsedType.number,
@@ -2016,8 +2017,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
2016
2017
  const status = new ParseStatus();
2017
2018
  for (const check of this._def.checks) {
2018
2019
  if (check.kind === "int") {
2019
- if (!util.isInteger(input.data)) {
2020
- ctx = this._getOrReturnCtx(input, ctx);
2020
+ if (!util.isInteger(input2.data)) {
2021
+ ctx = this._getOrReturnCtx(input2, ctx);
2021
2022
  addIssueToContext(ctx, {
2022
2023
  code: ZodIssueCode.invalid_type,
2023
2024
  expected: "integer",
@@ -2027,9 +2028,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
2027
2028
  status.dirty();
2028
2029
  }
2029
2030
  } else if (check.kind === "min") {
2030
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2031
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
2031
2032
  if (tooSmall) {
2032
- ctx = this._getOrReturnCtx(input, ctx);
2033
+ ctx = this._getOrReturnCtx(input2, ctx);
2033
2034
  addIssueToContext(ctx, {
2034
2035
  code: ZodIssueCode.too_small,
2035
2036
  minimum: check.value,
@@ -2041,9 +2042,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
2041
2042
  status.dirty();
2042
2043
  }
2043
2044
  } else if (check.kind === "max") {
2044
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2045
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
2045
2046
  if (tooBig) {
2046
- ctx = this._getOrReturnCtx(input, ctx);
2047
+ ctx = this._getOrReturnCtx(input2, ctx);
2047
2048
  addIssueToContext(ctx, {
2048
2049
  code: ZodIssueCode.too_big,
2049
2050
  maximum: check.value,
@@ -2055,8 +2056,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
2055
2056
  status.dirty();
2056
2057
  }
2057
2058
  } else if (check.kind === "multipleOf") {
2058
- if (floatSafeRemainder(input.data, check.value) !== 0) {
2059
- ctx = this._getOrReturnCtx(input, ctx);
2059
+ if (floatSafeRemainder(input2.data, check.value) !== 0) {
2060
+ ctx = this._getOrReturnCtx(input2, ctx);
2060
2061
  addIssueToContext(ctx, {
2061
2062
  code: ZodIssueCode.not_multiple_of,
2062
2063
  multipleOf: check.value,
@@ -2065,8 +2066,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
2065
2066
  status.dirty();
2066
2067
  }
2067
2068
  } else if (check.kind === "finite") {
2068
- if (!Number.isFinite(input.data)) {
2069
- ctx = this._getOrReturnCtx(input, ctx);
2069
+ if (!Number.isFinite(input2.data)) {
2070
+ ctx = this._getOrReturnCtx(input2, ctx);
2070
2071
  addIssueToContext(ctx, {
2071
2072
  code: ZodIssueCode.not_finite,
2072
2073
  message: check.message
@@ -2077,7 +2078,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
2077
2078
  util.assertNever(check);
2078
2079
  }
2079
2080
  }
2080
- return { status: status.value, value: input.data };
2081
+ return { status: status.value, value: input2.data };
2081
2082
  }
2082
2083
  gte(value, message) {
2083
2084
  return this.setLimit("min", value, true, errorUtil.toString(message));
@@ -2229,25 +2230,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
2229
2230
  this.min = this.gte;
2230
2231
  this.max = this.lte;
2231
2232
  }
2232
- _parse(input) {
2233
+ _parse(input2) {
2233
2234
  if (this._def.coerce) {
2234
2235
  try {
2235
- input.data = BigInt(input.data);
2236
+ input2.data = BigInt(input2.data);
2236
2237
  } catch {
2237
- return this._getInvalidInput(input);
2238
+ return this._getInvalidInput(input2);
2238
2239
  }
2239
2240
  }
2240
- const parsedType = this._getType(input);
2241
+ const parsedType = this._getType(input2);
2241
2242
  if (parsedType !== ZodParsedType.bigint) {
2242
- return this._getInvalidInput(input);
2243
+ return this._getInvalidInput(input2);
2243
2244
  }
2244
2245
  let ctx = void 0;
2245
2246
  const status = new ParseStatus();
2246
2247
  for (const check of this._def.checks) {
2247
2248
  if (check.kind === "min") {
2248
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2249
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
2249
2250
  if (tooSmall) {
2250
- ctx = this._getOrReturnCtx(input, ctx);
2251
+ ctx = this._getOrReturnCtx(input2, ctx);
2251
2252
  addIssueToContext(ctx, {
2252
2253
  code: ZodIssueCode.too_small,
2253
2254
  type: "bigint",
@@ -2258,9 +2259,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
2258
2259
  status.dirty();
2259
2260
  }
2260
2261
  } else if (check.kind === "max") {
2261
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2262
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
2262
2263
  if (tooBig) {
2263
- ctx = this._getOrReturnCtx(input, ctx);
2264
+ ctx = this._getOrReturnCtx(input2, ctx);
2264
2265
  addIssueToContext(ctx, {
2265
2266
  code: ZodIssueCode.too_big,
2266
2267
  type: "bigint",
@@ -2271,8 +2272,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
2271
2272
  status.dirty();
2272
2273
  }
2273
2274
  } else if (check.kind === "multipleOf") {
2274
- if (input.data % check.value !== BigInt(0)) {
2275
- ctx = this._getOrReturnCtx(input, ctx);
2275
+ if (input2.data % check.value !== BigInt(0)) {
2276
+ ctx = this._getOrReturnCtx(input2, ctx);
2276
2277
  addIssueToContext(ctx, {
2277
2278
  code: ZodIssueCode.not_multiple_of,
2278
2279
  multipleOf: check.value,
@@ -2284,10 +2285,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
2284
2285
  util.assertNever(check);
2285
2286
  }
2286
2287
  }
2287
- return { status: status.value, value: input.data };
2288
+ return { status: status.value, value: input2.data };
2288
2289
  }
2289
- _getInvalidInput(input) {
2290
- const ctx = this._getOrReturnCtx(input);
2290
+ _getInvalidInput(input2) {
2291
+ const ctx = this._getOrReturnCtx(input2);
2291
2292
  addIssueToContext(ctx, {
2292
2293
  code: ZodIssueCode.invalid_type,
2293
2294
  expected: ZodParsedType.bigint,
@@ -2396,13 +2397,13 @@ ZodBigInt.create = (params) => {
2396
2397
  });
2397
2398
  };
2398
2399
  var ZodBoolean = class extends ZodType {
2399
- _parse(input) {
2400
+ _parse(input2) {
2400
2401
  if (this._def.coerce) {
2401
- input.data = Boolean(input.data);
2402
+ input2.data = Boolean(input2.data);
2402
2403
  }
2403
- const parsedType = this._getType(input);
2404
+ const parsedType = this._getType(input2);
2404
2405
  if (parsedType !== ZodParsedType.boolean) {
2405
- const ctx = this._getOrReturnCtx(input);
2406
+ const ctx = this._getOrReturnCtx(input2);
2406
2407
  addIssueToContext(ctx, {
2407
2408
  code: ZodIssueCode.invalid_type,
2408
2409
  expected: ZodParsedType.boolean,
@@ -2410,7 +2411,7 @@ var ZodBoolean = class extends ZodType {
2410
2411
  });
2411
2412
  return INVALID;
2412
2413
  }
2413
- return OK(input.data);
2414
+ return OK(input2.data);
2414
2415
  }
2415
2416
  };
2416
2417
  ZodBoolean.create = (params) => {
@@ -2421,13 +2422,13 @@ ZodBoolean.create = (params) => {
2421
2422
  });
2422
2423
  };
2423
2424
  var ZodDate = class _ZodDate extends ZodType {
2424
- _parse(input) {
2425
+ _parse(input2) {
2425
2426
  if (this._def.coerce) {
2426
- input.data = new Date(input.data);
2427
+ input2.data = new Date(input2.data);
2427
2428
  }
2428
- const parsedType = this._getType(input);
2429
+ const parsedType = this._getType(input2);
2429
2430
  if (parsedType !== ZodParsedType.date) {
2430
- const ctx2 = this._getOrReturnCtx(input);
2431
+ const ctx2 = this._getOrReturnCtx(input2);
2431
2432
  addIssueToContext(ctx2, {
2432
2433
  code: ZodIssueCode.invalid_type,
2433
2434
  expected: ZodParsedType.date,
@@ -2435,8 +2436,8 @@ var ZodDate = class _ZodDate extends ZodType {
2435
2436
  });
2436
2437
  return INVALID;
2437
2438
  }
2438
- if (Number.isNaN(input.data.getTime())) {
2439
- const ctx2 = this._getOrReturnCtx(input);
2439
+ if (Number.isNaN(input2.data.getTime())) {
2440
+ const ctx2 = this._getOrReturnCtx(input2);
2440
2441
  addIssueToContext(ctx2, {
2441
2442
  code: ZodIssueCode.invalid_date
2442
2443
  });
@@ -2446,8 +2447,8 @@ var ZodDate = class _ZodDate extends ZodType {
2446
2447
  let ctx = void 0;
2447
2448
  for (const check of this._def.checks) {
2448
2449
  if (check.kind === "min") {
2449
- if (input.data.getTime() < check.value) {
2450
- ctx = this._getOrReturnCtx(input, ctx);
2450
+ if (input2.data.getTime() < check.value) {
2451
+ ctx = this._getOrReturnCtx(input2, ctx);
2451
2452
  addIssueToContext(ctx, {
2452
2453
  code: ZodIssueCode.too_small,
2453
2454
  message: check.message,
@@ -2459,8 +2460,8 @@ var ZodDate = class _ZodDate extends ZodType {
2459
2460
  status.dirty();
2460
2461
  }
2461
2462
  } else if (check.kind === "max") {
2462
- if (input.data.getTime() > check.value) {
2463
- ctx = this._getOrReturnCtx(input, ctx);
2463
+ if (input2.data.getTime() > check.value) {
2464
+ ctx = this._getOrReturnCtx(input2, ctx);
2464
2465
  addIssueToContext(ctx, {
2465
2466
  code: ZodIssueCode.too_big,
2466
2467
  message: check.message,
@@ -2477,7 +2478,7 @@ var ZodDate = class _ZodDate extends ZodType {
2477
2478
  }
2478
2479
  return {
2479
2480
  status: status.value,
2480
- value: new Date(input.data.getTime())
2481
+ value: new Date(input2.data.getTime())
2481
2482
  };
2482
2483
  }
2483
2484
  _addCheck(check) {
@@ -2530,10 +2531,10 @@ ZodDate.create = (params) => {
2530
2531
  });
2531
2532
  };
2532
2533
  var ZodSymbol = class extends ZodType {
2533
- _parse(input) {
2534
- const parsedType = this._getType(input);
2534
+ _parse(input2) {
2535
+ const parsedType = this._getType(input2);
2535
2536
  if (parsedType !== ZodParsedType.symbol) {
2536
- const ctx = this._getOrReturnCtx(input);
2537
+ const ctx = this._getOrReturnCtx(input2);
2537
2538
  addIssueToContext(ctx, {
2538
2539
  code: ZodIssueCode.invalid_type,
2539
2540
  expected: ZodParsedType.symbol,
@@ -2541,7 +2542,7 @@ var ZodSymbol = class extends ZodType {
2541
2542
  });
2542
2543
  return INVALID;
2543
2544
  }
2544
- return OK(input.data);
2545
+ return OK(input2.data);
2545
2546
  }
2546
2547
  };
2547
2548
  ZodSymbol.create = (params) => {
@@ -2551,10 +2552,10 @@ ZodSymbol.create = (params) => {
2551
2552
  });
2552
2553
  };
2553
2554
  var ZodUndefined = class extends ZodType {
2554
- _parse(input) {
2555
- const parsedType = this._getType(input);
2555
+ _parse(input2) {
2556
+ const parsedType = this._getType(input2);
2556
2557
  if (parsedType !== ZodParsedType.undefined) {
2557
- const ctx = this._getOrReturnCtx(input);
2558
+ const ctx = this._getOrReturnCtx(input2);
2558
2559
  addIssueToContext(ctx, {
2559
2560
  code: ZodIssueCode.invalid_type,
2560
2561
  expected: ZodParsedType.undefined,
@@ -2562,7 +2563,7 @@ var ZodUndefined = class extends ZodType {
2562
2563
  });
2563
2564
  return INVALID;
2564
2565
  }
2565
- return OK(input.data);
2566
+ return OK(input2.data);
2566
2567
  }
2567
2568
  };
2568
2569
  ZodUndefined.create = (params) => {
@@ -2572,10 +2573,10 @@ ZodUndefined.create = (params) => {
2572
2573
  });
2573
2574
  };
2574
2575
  var ZodNull = class extends ZodType {
2575
- _parse(input) {
2576
- const parsedType = this._getType(input);
2576
+ _parse(input2) {
2577
+ const parsedType = this._getType(input2);
2577
2578
  if (parsedType !== ZodParsedType.null) {
2578
- const ctx = this._getOrReturnCtx(input);
2579
+ const ctx = this._getOrReturnCtx(input2);
2579
2580
  addIssueToContext(ctx, {
2580
2581
  code: ZodIssueCode.invalid_type,
2581
2582
  expected: ZodParsedType.null,
@@ -2583,7 +2584,7 @@ var ZodNull = class extends ZodType {
2583
2584
  });
2584
2585
  return INVALID;
2585
2586
  }
2586
- return OK(input.data);
2587
+ return OK(input2.data);
2587
2588
  }
2588
2589
  };
2589
2590
  ZodNull.create = (params) => {
@@ -2597,8 +2598,8 @@ var ZodAny = class extends ZodType {
2597
2598
  super(...arguments);
2598
2599
  this._any = true;
2599
2600
  }
2600
- _parse(input) {
2601
- return OK(input.data);
2601
+ _parse(input2) {
2602
+ return OK(input2.data);
2602
2603
  }
2603
2604
  };
2604
2605
  ZodAny.create = (params) => {
@@ -2612,8 +2613,8 @@ var ZodUnknown = class extends ZodType {
2612
2613
  super(...arguments);
2613
2614
  this._unknown = true;
2614
2615
  }
2615
- _parse(input) {
2616
- return OK(input.data);
2616
+ _parse(input2) {
2617
+ return OK(input2.data);
2617
2618
  }
2618
2619
  };
2619
2620
  ZodUnknown.create = (params) => {
@@ -2623,8 +2624,8 @@ ZodUnknown.create = (params) => {
2623
2624
  });
2624
2625
  };
2625
2626
  var ZodNever = class extends ZodType {
2626
- _parse(input) {
2627
- const ctx = this._getOrReturnCtx(input);
2627
+ _parse(input2) {
2628
+ const ctx = this._getOrReturnCtx(input2);
2628
2629
  addIssueToContext(ctx, {
2629
2630
  code: ZodIssueCode.invalid_type,
2630
2631
  expected: ZodParsedType.never,
@@ -2640,10 +2641,10 @@ ZodNever.create = (params) => {
2640
2641
  });
2641
2642
  };
2642
2643
  var ZodVoid = class extends ZodType {
2643
- _parse(input) {
2644
- const parsedType = this._getType(input);
2644
+ _parse(input2) {
2645
+ const parsedType = this._getType(input2);
2645
2646
  if (parsedType !== ZodParsedType.undefined) {
2646
- const ctx = this._getOrReturnCtx(input);
2647
+ const ctx = this._getOrReturnCtx(input2);
2647
2648
  addIssueToContext(ctx, {
2648
2649
  code: ZodIssueCode.invalid_type,
2649
2650
  expected: ZodParsedType.void,
@@ -2651,7 +2652,7 @@ var ZodVoid = class extends ZodType {
2651
2652
  });
2652
2653
  return INVALID;
2653
2654
  }
2654
- return OK(input.data);
2655
+ return OK(input2.data);
2655
2656
  }
2656
2657
  };
2657
2658
  ZodVoid.create = (params) => {
@@ -2661,8 +2662,8 @@ ZodVoid.create = (params) => {
2661
2662
  });
2662
2663
  };
2663
2664
  var ZodArray = class _ZodArray extends ZodType {
2664
- _parse(input) {
2665
- const { ctx, status } = this._processInputParams(input);
2665
+ _parse(input2) {
2666
+ const { ctx, status } = this._processInputParams(input2);
2666
2667
  const def = this._def;
2667
2668
  if (ctx.parsedType !== ZodParsedType.array) {
2668
2669
  addIssueToContext(ctx, {
@@ -2802,10 +2803,10 @@ var ZodObject = class _ZodObject extends ZodType {
2802
2803
  this._cached = { shape, keys };
2803
2804
  return this._cached;
2804
2805
  }
2805
- _parse(input) {
2806
- const parsedType = this._getType(input);
2806
+ _parse(input2) {
2807
+ const parsedType = this._getType(input2);
2807
2808
  if (parsedType !== ZodParsedType.object) {
2808
- const ctx2 = this._getOrReturnCtx(input);
2809
+ const ctx2 = this._getOrReturnCtx(input2);
2809
2810
  addIssueToContext(ctx2, {
2810
2811
  code: ZodIssueCode.invalid_type,
2811
2812
  expected: ZodParsedType.object,
@@ -2813,7 +2814,7 @@ var ZodObject = class _ZodObject extends ZodType {
2813
2814
  });
2814
2815
  return INVALID;
2815
2816
  }
2816
- const { status, ctx } = this._processInputParams(input);
2817
+ const { status, ctx } = this._processInputParams(input2);
2817
2818
  const { shape, keys: shapeKeys } = this._getCached();
2818
2819
  const extraKeys = [];
2819
2820
  if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
@@ -3126,8 +3127,8 @@ ZodObject.lazycreate = (shape, params) => {
3126
3127
  });
3127
3128
  };
3128
3129
  var ZodUnion = class extends ZodType {
3129
- _parse(input) {
3130
- const { ctx } = this._processInputParams(input);
3130
+ _parse(input2) {
3131
+ const { ctx } = this._processInputParams(input2);
3131
3132
  const options = this._def.options;
3132
3133
  function handleResults(results) {
3133
3134
  for (const result of results) {
@@ -3248,8 +3249,8 @@ var getDiscriminator = (type) => {
3248
3249
  }
3249
3250
  };
3250
3251
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3251
- _parse(input) {
3252
- const { ctx } = this._processInputParams(input);
3252
+ _parse(input2) {
3253
+ const { ctx } = this._processInputParams(input2);
3253
3254
  if (ctx.parsedType !== ZodParsedType.object) {
3254
3255
  addIssueToContext(ctx, {
3255
3256
  code: ZodIssueCode.invalid_type,
@@ -3362,8 +3363,8 @@ function mergeValues(a, b) {
3362
3363
  }
3363
3364
  }
3364
3365
  var ZodIntersection = class extends ZodType {
3365
- _parse(input) {
3366
- const { status, ctx } = this._processInputParams(input);
3366
+ _parse(input2) {
3367
+ const { status, ctx } = this._processInputParams(input2);
3367
3368
  const handleParsed = (parsedLeft, parsedRight) => {
3368
3369
  if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3369
3370
  return INVALID;
@@ -3415,8 +3416,8 @@ ZodIntersection.create = (left, right, params) => {
3415
3416
  });
3416
3417
  };
3417
3418
  var ZodTuple = class _ZodTuple extends ZodType {
3418
- _parse(input) {
3419
- const { status, ctx } = this._processInputParams(input);
3419
+ _parse(input2) {
3420
+ const { status, ctx } = this._processInputParams(input2);
3420
3421
  if (ctx.parsedType !== ZodParsedType.array) {
3421
3422
  addIssueToContext(ctx, {
3422
3423
  code: ZodIssueCode.invalid_type,
@@ -3488,8 +3489,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
3488
3489
  get valueSchema() {
3489
3490
  return this._def.valueType;
3490
3491
  }
3491
- _parse(input) {
3492
- const { status, ctx } = this._processInputParams(input);
3492
+ _parse(input2) {
3493
+ const { status, ctx } = this._processInputParams(input2);
3493
3494
  if (ctx.parsedType !== ZodParsedType.object) {
3494
3495
  addIssueToContext(ctx, {
3495
3496
  code: ZodIssueCode.invalid_type,
@@ -3541,8 +3542,8 @@ var ZodMap = class extends ZodType {
3541
3542
  get valueSchema() {
3542
3543
  return this._def.valueType;
3543
3544
  }
3544
- _parse(input) {
3545
- const { status, ctx } = this._processInputParams(input);
3545
+ _parse(input2) {
3546
+ const { status, ctx } = this._processInputParams(input2);
3546
3547
  if (ctx.parsedType !== ZodParsedType.map) {
3547
3548
  addIssueToContext(ctx, {
3548
3549
  code: ZodIssueCode.invalid_type,
@@ -3601,8 +3602,8 @@ ZodMap.create = (keyType, valueType, params) => {
3601
3602
  });
3602
3603
  };
3603
3604
  var ZodSet = class _ZodSet extends ZodType {
3604
- _parse(input) {
3605
- const { status, ctx } = this._processInputParams(input);
3605
+ _parse(input2) {
3606
+ const { status, ctx } = this._processInputParams(input2);
3606
3607
  if (ctx.parsedType !== ZodParsedType.set) {
3607
3608
  addIssueToContext(ctx, {
3608
3609
  code: ZodIssueCode.invalid_type,
@@ -3690,8 +3691,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
3690
3691
  super(...arguments);
3691
3692
  this.validate = this.implement;
3692
3693
  }
3693
- _parse(input) {
3694
- const { ctx } = this._processInputParams(input);
3694
+ _parse(input2) {
3695
+ const { ctx } = this._processInputParams(input2);
3695
3696
  if (ctx.parsedType !== ZodParsedType.function) {
3696
3697
  addIssueToContext(ctx, {
3697
3698
  code: ZodIssueCode.invalid_type,
@@ -3794,8 +3795,8 @@ var ZodLazy = class extends ZodType {
3794
3795
  get schema() {
3795
3796
  return this._def.getter();
3796
3797
  }
3797
- _parse(input) {
3798
- const { ctx } = this._processInputParams(input);
3798
+ _parse(input2) {
3799
+ const { ctx } = this._processInputParams(input2);
3799
3800
  const lazySchema = this._def.getter();
3800
3801
  return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3801
3802
  }
@@ -3808,9 +3809,9 @@ ZodLazy.create = (getter, params) => {
3808
3809
  });
3809
3810
  };
3810
3811
  var ZodLiteral = class extends ZodType {
3811
- _parse(input) {
3812
- if (input.data !== this._def.value) {
3813
- const ctx = this._getOrReturnCtx(input);
3812
+ _parse(input2) {
3813
+ if (input2.data !== this._def.value) {
3814
+ const ctx = this._getOrReturnCtx(input2);
3814
3815
  addIssueToContext(ctx, {
3815
3816
  received: ctx.data,
3816
3817
  code: ZodIssueCode.invalid_literal,
@@ -3818,7 +3819,7 @@ var ZodLiteral = class extends ZodType {
3818
3819
  });
3819
3820
  return INVALID;
3820
3821
  }
3821
- return { status: "valid", value: input.data };
3822
+ return { status: "valid", value: input2.data };
3822
3823
  }
3823
3824
  get value() {
3824
3825
  return this._def.value;
@@ -3839,9 +3840,9 @@ function createZodEnum(values, params) {
3839
3840
  });
3840
3841
  }
3841
3842
  var ZodEnum = class _ZodEnum extends ZodType {
3842
- _parse(input) {
3843
- if (typeof input.data !== "string") {
3844
- const ctx = this._getOrReturnCtx(input);
3843
+ _parse(input2) {
3844
+ if (typeof input2.data !== "string") {
3845
+ const ctx = this._getOrReturnCtx(input2);
3845
3846
  const expectedValues = this._def.values;
3846
3847
  addIssueToContext(ctx, {
3847
3848
  expected: util.joinValues(expectedValues),
@@ -3853,8 +3854,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
3853
3854
  if (!this._cache) {
3854
3855
  this._cache = new Set(this._def.values);
3855
3856
  }
3856
- if (!this._cache.has(input.data)) {
3857
- const ctx = this._getOrReturnCtx(input);
3857
+ if (!this._cache.has(input2.data)) {
3858
+ const ctx = this._getOrReturnCtx(input2);
3858
3859
  const expectedValues = this._def.values;
3859
3860
  addIssueToContext(ctx, {
3860
3861
  received: ctx.data,
@@ -3863,7 +3864,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
3863
3864
  });
3864
3865
  return INVALID;
3865
3866
  }
3866
- return OK(input.data);
3867
+ return OK(input2.data);
3867
3868
  }
3868
3869
  get options() {
3869
3870
  return this._def.values;
@@ -3904,9 +3905,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
3904
3905
  };
3905
3906
  ZodEnum.create = createZodEnum;
3906
3907
  var ZodNativeEnum = class extends ZodType {
3907
- _parse(input) {
3908
+ _parse(input2) {
3908
3909
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3909
- const ctx = this._getOrReturnCtx(input);
3910
+ const ctx = this._getOrReturnCtx(input2);
3910
3911
  if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3911
3912
  const expectedValues = util.objectValues(nativeEnumValues);
3912
3913
  addIssueToContext(ctx, {
@@ -3919,7 +3920,7 @@ var ZodNativeEnum = class extends ZodType {
3919
3920
  if (!this._cache) {
3920
3921
  this._cache = new Set(util.getValidEnumValues(this._def.values));
3921
3922
  }
3922
- if (!this._cache.has(input.data)) {
3923
+ if (!this._cache.has(input2.data)) {
3923
3924
  const expectedValues = util.objectValues(nativeEnumValues);
3924
3925
  addIssueToContext(ctx, {
3925
3926
  received: ctx.data,
@@ -3928,7 +3929,7 @@ var ZodNativeEnum = class extends ZodType {
3928
3929
  });
3929
3930
  return INVALID;
3930
3931
  }
3931
- return OK(input.data);
3932
+ return OK(input2.data);
3932
3933
  }
3933
3934
  get enum() {
3934
3935
  return this._def.values;
@@ -3945,8 +3946,8 @@ var ZodPromise = class extends ZodType {
3945
3946
  unwrap() {
3946
3947
  return this._def.type;
3947
3948
  }
3948
- _parse(input) {
3949
- const { ctx } = this._processInputParams(input);
3949
+ _parse(input2) {
3950
+ const { ctx } = this._processInputParams(input2);
3950
3951
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3951
3952
  addIssueToContext(ctx, {
3952
3953
  code: ZodIssueCode.invalid_type,
@@ -3978,8 +3979,8 @@ var ZodEffects = class extends ZodType {
3978
3979
  sourceType() {
3979
3980
  return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3980
3981
  }
3981
- _parse(input) {
3982
- const { status, ctx } = this._processInputParams(input);
3982
+ _parse(input2) {
3983
+ const { status, ctx } = this._processInputParams(input2);
3983
3984
  const effect = this._def.effect || null;
3984
3985
  const checkCtx = {
3985
3986
  addIssue: (arg) => {
@@ -4111,12 +4112,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4111
4112
  });
4112
4113
  };
4113
4114
  var ZodOptional = class extends ZodType {
4114
- _parse(input) {
4115
- const parsedType = this._getType(input);
4115
+ _parse(input2) {
4116
+ const parsedType = this._getType(input2);
4116
4117
  if (parsedType === ZodParsedType.undefined) {
4117
4118
  return OK(void 0);
4118
4119
  }
4119
- return this._def.innerType._parse(input);
4120
+ return this._def.innerType._parse(input2);
4120
4121
  }
4121
4122
  unwrap() {
4122
4123
  return this._def.innerType;
@@ -4130,12 +4131,12 @@ ZodOptional.create = (type, params) => {
4130
4131
  });
4131
4132
  };
4132
4133
  var ZodNullable = class extends ZodType {
4133
- _parse(input) {
4134
- const parsedType = this._getType(input);
4134
+ _parse(input2) {
4135
+ const parsedType = this._getType(input2);
4135
4136
  if (parsedType === ZodParsedType.null) {
4136
4137
  return OK(null);
4137
4138
  }
4138
- return this._def.innerType._parse(input);
4139
+ return this._def.innerType._parse(input2);
4139
4140
  }
4140
4141
  unwrap() {
4141
4142
  return this._def.innerType;
@@ -4149,8 +4150,8 @@ ZodNullable.create = (type, params) => {
4149
4150
  });
4150
4151
  };
4151
4152
  var ZodDefault = class extends ZodType {
4152
- _parse(input) {
4153
- const { ctx } = this._processInputParams(input);
4153
+ _parse(input2) {
4154
+ const { ctx } = this._processInputParams(input2);
4154
4155
  let data = ctx.data;
4155
4156
  if (ctx.parsedType === ZodParsedType.undefined) {
4156
4157
  data = this._def.defaultValue();
@@ -4174,8 +4175,8 @@ ZodDefault.create = (type, params) => {
4174
4175
  });
4175
4176
  };
4176
4177
  var ZodCatch = class extends ZodType {
4177
- _parse(input) {
4178
- const { ctx } = this._processInputParams(input);
4178
+ _parse(input2) {
4179
+ const { ctx } = this._processInputParams(input2);
4179
4180
  const newCtx = {
4180
4181
  ...ctx,
4181
4182
  common: {
@@ -4227,10 +4228,10 @@ ZodCatch.create = (type, params) => {
4227
4228
  });
4228
4229
  };
4229
4230
  var ZodNaN = class extends ZodType {
4230
- _parse(input) {
4231
- const parsedType = this._getType(input);
4231
+ _parse(input2) {
4232
+ const parsedType = this._getType(input2);
4232
4233
  if (parsedType !== ZodParsedType.nan) {
4233
- const ctx = this._getOrReturnCtx(input);
4234
+ const ctx = this._getOrReturnCtx(input2);
4234
4235
  addIssueToContext(ctx, {
4235
4236
  code: ZodIssueCode.invalid_type,
4236
4237
  expected: ZodParsedType.nan,
@@ -4238,7 +4239,7 @@ var ZodNaN = class extends ZodType {
4238
4239
  });
4239
4240
  return INVALID;
4240
4241
  }
4241
- return { status: "valid", value: input.data };
4242
+ return { status: "valid", value: input2.data };
4242
4243
  }
4243
4244
  };
4244
4245
  ZodNaN.create = (params) => {
@@ -4249,8 +4250,8 @@ ZodNaN.create = (params) => {
4249
4250
  };
4250
4251
  var BRAND = /* @__PURE__ */ Symbol("zod_brand");
4251
4252
  var ZodBranded = class extends ZodType {
4252
- _parse(input) {
4253
- const { ctx } = this._processInputParams(input);
4253
+ _parse(input2) {
4254
+ const { ctx } = this._processInputParams(input2);
4254
4255
  const data = ctx.data;
4255
4256
  return this._def.type._parse({
4256
4257
  data,
@@ -4263,8 +4264,8 @@ var ZodBranded = class extends ZodType {
4263
4264
  }
4264
4265
  };
4265
4266
  var ZodPipeline = class _ZodPipeline extends ZodType {
4266
- _parse(input) {
4267
- const { status, ctx } = this._processInputParams(input);
4267
+ _parse(input2) {
4268
+ const { status, ctx } = this._processInputParams(input2);
4268
4269
  if (ctx.common.async) {
4269
4270
  const handleAsync = async () => {
4270
4271
  const inResult = await this._def.in._parseAsync({
@@ -4318,8 +4319,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
4318
4319
  }
4319
4320
  };
4320
4321
  var ZodReadonly = class extends ZodType {
4321
- _parse(input) {
4322
- const result = this._def.innerType._parse(input);
4322
+ _parse(input2) {
4323
+ const result = this._def.innerType._parse(input2);
4323
4324
  const freeze = (data) => {
4324
4325
  if (isValid(data)) {
4325
4326
  data.value = Object.freeze(data.value);
@@ -4875,11 +4876,126 @@ function isAutostartInstalled() {
4875
4876
  }
4876
4877
  }
4877
4878
 
4879
+ // ../shared/dist/hooks/claude-code.js
4880
+ import { existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, unlinkSync as unlinkSync3, chmodSync } from "fs";
4881
+ import { join as join3 } from "path";
4882
+ import { homedir as homedir3 } from "os";
4883
+ var STOP_GUARD_PATH = join3(USEAI_HOOKS_DIR, "stop-guard.js");
4884
+ var CLAUDE_SETTINGS_PATH = join3(homedir3(), ".claude", "settings.json");
4885
+ var STOP_GUARD_SCRIPT = `#!/usr/bin/env node
4886
+ 'use strict';
4887
+ const { readFileSync } = require('node:fs');
4888
+ let input = '';
4889
+ process.stdin.setEncoding('utf-8');
4890
+ process.stdin.on('data', chunk => input += chunk);
4891
+ process.stdin.on('end', () => {
4892
+ try {
4893
+ const hook = JSON.parse(input);
4894
+ if (hook.stop_hook_active) process.exit(0);
4895
+ if (!hook.transcript_path) process.exit(0);
4896
+ let transcript;
4897
+ try { transcript = readFileSync(hook.transcript_path, 'utf-8'); } catch { process.exit(0); }
4898
+ if (!transcript.includes('useai_session_start')) process.exit(0);
4899
+ if (transcript.includes('useai_session_end')) process.exit(0);
4900
+ process.stdout.write(JSON.stringify({
4901
+ decision: 'block',
4902
+ reason: 'Before ending, call useai_session_end with milestones (generic descriptions of accomplishments), languages used, and files_touched_count.'
4903
+ }));
4904
+ } catch { process.exit(0); }
4905
+ });
4906
+ `;
4907
+ function readSettings() {
4908
+ if (!existsSync7(CLAUDE_SETTINGS_PATH))
4909
+ return {};
4910
+ try {
4911
+ return JSON.parse(readFileSync3(CLAUDE_SETTINGS_PATH, "utf-8"));
4912
+ } catch {
4913
+ return {};
4914
+ }
4915
+ }
4916
+ function writeSettings(settings) {
4917
+ mkdirSync3(join3(homedir3(), ".claude"), { recursive: true });
4918
+ writeFileSync3(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n");
4919
+ }
4920
+ function installClaudeCodeHooks() {
4921
+ mkdirSync3(USEAI_HOOKS_DIR, { recursive: true });
4922
+ writeFileSync3(STOP_GUARD_PATH, STOP_GUARD_SCRIPT);
4923
+ try {
4924
+ chmodSync(STOP_GUARD_PATH, "755");
4925
+ } catch {
4926
+ }
4927
+ const settings = readSettings();
4928
+ const hooks = settings["hooks"] ?? {};
4929
+ const stopCmd = `node "${STOP_GUARD_PATH}"`;
4930
+ const sealCmd = `curl -sf -X POST http://127.0.0.1:${DAEMON_PORT}/api/seal-active --max-time 3 2>/dev/null || true`;
4931
+ let changed = false;
4932
+ if (!hooks["Stop"])
4933
+ hooks["Stop"] = [];
4934
+ const stopArr = hooks["Stop"];
4935
+ const hasStop = stopArr.some((g) => {
4936
+ const inner = g["hooks"];
4937
+ return inner?.some((h) => h["command"]?.includes("stop-guard"));
4938
+ });
4939
+ if (!hasStop) {
4940
+ stopArr.push({ hooks: [{ type: "command", command: stopCmd, timeout: 10 }] });
4941
+ changed = true;
4942
+ }
4943
+ if (!hooks["SessionEnd"])
4944
+ hooks["SessionEnd"] = [];
4945
+ const endArr = hooks["SessionEnd"];
4946
+ const hasEnd = endArr.some((g) => {
4947
+ const inner = g["hooks"];
4948
+ return inner?.some((h) => h["command"]?.includes("seal-active"));
4949
+ });
4950
+ if (!hasEnd) {
4951
+ endArr.push({ hooks: [{ type: "command", command: sealCmd, timeout: 5 }] });
4952
+ changed = true;
4953
+ }
4954
+ settings["hooks"] = hooks;
4955
+ writeSettings(settings);
4956
+ return changed;
4957
+ }
4958
+ function removeClaudeCodeHooks() {
4959
+ if (existsSync7(CLAUDE_SETTINGS_PATH)) {
4960
+ try {
4961
+ const settings = readSettings();
4962
+ const hooks = settings["hooks"];
4963
+ if (hooks) {
4964
+ if (hooks["Stop"]) {
4965
+ hooks["Stop"] = hooks["Stop"].filter((g) => {
4966
+ const inner = g["hooks"];
4967
+ return !inner?.some((h) => h["command"]?.includes("stop-guard"));
4968
+ });
4969
+ if (hooks["Stop"].length === 0)
4970
+ delete hooks["Stop"];
4971
+ }
4972
+ if (hooks["SessionEnd"]) {
4973
+ hooks["SessionEnd"] = hooks["SessionEnd"].filter((g) => {
4974
+ const inner = g["hooks"];
4975
+ return !inner?.some((h) => h["command"]?.includes("seal-active"));
4976
+ });
4977
+ if (hooks["SessionEnd"].length === 0)
4978
+ delete hooks["SessionEnd"];
4979
+ }
4980
+ if (Object.keys(hooks).length === 0)
4981
+ delete settings["hooks"];
4982
+ }
4983
+ writeSettings(settings);
4984
+ } catch {
4985
+ }
4986
+ }
4987
+ try {
4988
+ if (existsSync7(STOP_GUARD_PATH))
4989
+ unlinkSync3(STOP_GUARD_PATH);
4990
+ } catch {
4991
+ }
4992
+ }
4993
+
4878
4994
  // src/services/tools.ts
4879
4995
  import { execSync as execSync3 } from "child_process";
4880
- import { existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, unlinkSync as unlinkSync3 } from "fs";
4881
- import { dirname as dirname2, join as join3 } from "path";
4882
- import { homedir as homedir3 } from "os";
4996
+ import { existsSync as existsSync8, readFileSync as readFileSync4, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, unlinkSync as unlinkSync4 } from "fs";
4997
+ import { dirname as dirname2, join as join4 } from "path";
4998
+ import { homedir as homedir4 } from "os";
4883
4999
  import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
4884
5000
  import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
4885
5001
  var USEAI_INSTRUCTIONS_TEXT = [
@@ -4895,7 +5011,7 @@ var MCP_ENTRY = {
4895
5011
  };
4896
5012
  var MCP_HTTP_URL = DAEMON_MCP_URL;
4897
5013
  var MCP_HTTP_ENTRY = { type: "http", url: MCP_HTTP_URL };
4898
- var home = homedir3();
5014
+ var home = homedir4();
4899
5015
  function installStandardHttp(configPath) {
4900
5016
  const config = readJsonFile(configPath);
4901
5017
  const servers = config["mcpServers"] ?? {};
@@ -4921,9 +5037,9 @@ function hasBinary(name) {
4921
5037
  }
4922
5038
  }
4923
5039
  function readJsonFile(path) {
4924
- if (!existsSync7(path)) return {};
5040
+ if (!existsSync8(path)) return {};
4925
5041
  try {
4926
- const raw = readFileSync3(path, "utf-8").trim();
5042
+ const raw = readFileSync4(path, "utf-8").trim();
4927
5043
  if (!raw) return {};
4928
5044
  return JSON.parse(raw);
4929
5045
  } catch {
@@ -4931,8 +5047,8 @@ function readJsonFile(path) {
4931
5047
  }
4932
5048
  }
4933
5049
  function writeJsonFile(path, data) {
4934
- mkdirSync3(dirname2(path), { recursive: true });
4935
- writeFileSync3(path, JSON.stringify(data, null, 2) + "\n");
5050
+ mkdirSync4(dirname2(path), { recursive: true });
5051
+ writeFileSync4(path, JSON.stringify(data, null, 2) + "\n");
4936
5052
  }
4937
5053
  function isConfiguredStandard(configPath) {
4938
5054
  const config = readJsonFile(configPath);
@@ -5013,9 +5129,9 @@ function removeZed(configPath) {
5013
5129
  }
5014
5130
  }
5015
5131
  function readTomlFile(path) {
5016
- if (!existsSync7(path)) return {};
5132
+ if (!existsSync8(path)) return {};
5017
5133
  try {
5018
- const raw = readFileSync3(path, "utf-8").trim();
5134
+ const raw = readFileSync4(path, "utf-8").trim();
5019
5135
  if (!raw) return {};
5020
5136
  return parseToml(raw);
5021
5137
  } catch {
@@ -5023,8 +5139,8 @@ function readTomlFile(path) {
5023
5139
  }
5024
5140
  }
5025
5141
  function writeTomlFile(path, data) {
5026
- mkdirSync3(dirname2(path), { recursive: true });
5027
- writeFileSync3(path, stringifyToml(data) + "\n");
5142
+ mkdirSync4(dirname2(path), { recursive: true });
5143
+ writeFileSync4(path, stringifyToml(data) + "\n");
5028
5144
  }
5029
5145
  function isConfiguredToml(configPath) {
5030
5146
  const config = readTomlFile(configPath);
@@ -5052,9 +5168,9 @@ function removeToml(configPath) {
5052
5168
  }
5053
5169
  }
5054
5170
  function readYamlFile(path) {
5055
- if (!existsSync7(path)) return {};
5171
+ if (!existsSync8(path)) return {};
5056
5172
  try {
5057
- const raw = readFileSync3(path, "utf-8").trim();
5173
+ const raw = readFileSync4(path, "utf-8").trim();
5058
5174
  if (!raw) return {};
5059
5175
  return parseYaml(raw) ?? {};
5060
5176
  } catch {
@@ -5062,8 +5178,8 @@ function readYamlFile(path) {
5062
5178
  }
5063
5179
  }
5064
5180
  function writeYamlFile(path, data) {
5065
- mkdirSync3(dirname2(path), { recursive: true });
5066
- writeFileSync3(path, stringifyYaml(data));
5181
+ mkdirSync4(dirname2(path), { recursive: true });
5182
+ writeFileSync4(path, stringifyYaml(data));
5067
5183
  }
5068
5184
  function isConfiguredYaml(configPath) {
5069
5185
  const config = readYamlFile(configPath);
@@ -5109,49 +5225,49 @@ var USEAI_INSTRUCTIONS_BLOCK = `${INSTRUCTIONS_START}
5109
5225
  ${USEAI_INSTRUCTIONS}
5110
5226
  ${INSTRUCTIONS_END}`;
5111
5227
  function hasInstructionsBlock(filePath) {
5112
- if (!existsSync7(filePath)) return false;
5228
+ if (!existsSync8(filePath)) return false;
5113
5229
  try {
5114
- return readFileSync3(filePath, "utf-8").includes(INSTRUCTIONS_START);
5230
+ return readFileSync4(filePath, "utf-8").includes(INSTRUCTIONS_START);
5115
5231
  } catch {
5116
5232
  return false;
5117
5233
  }
5118
5234
  }
5119
5235
  function injectInstructions(config) {
5120
- mkdirSync3(dirname2(config.path), { recursive: true });
5236
+ mkdirSync4(dirname2(config.path), { recursive: true });
5121
5237
  if (config.method === "create") {
5122
- writeFileSync3(config.path, USEAI_INSTRUCTIONS + "\n");
5238
+ writeFileSync4(config.path, USEAI_INSTRUCTIONS + "\n");
5123
5239
  return;
5124
5240
  }
5125
5241
  if (hasInstructionsBlock(config.path)) return;
5126
5242
  let existing = "";
5127
- if (existsSync7(config.path)) {
5128
- existing = readFileSync3(config.path, "utf-8");
5243
+ if (existsSync8(config.path)) {
5244
+ existing = readFileSync4(config.path, "utf-8");
5129
5245
  }
5130
5246
  const separator = existing && !existing.endsWith("\n") ? "\n\n" : existing ? "\n" : "";
5131
- writeFileSync3(config.path, existing + separator + USEAI_INSTRUCTIONS_BLOCK + "\n");
5247
+ writeFileSync4(config.path, existing + separator + USEAI_INSTRUCTIONS_BLOCK + "\n");
5132
5248
  }
5133
5249
  function removeInstructions(config) {
5134
5250
  if (config.method === "create") {
5135
- if (existsSync7(config.path)) {
5251
+ if (existsSync8(config.path)) {
5136
5252
  try {
5137
- unlinkSync3(config.path);
5253
+ unlinkSync4(config.path);
5138
5254
  } catch {
5139
5255
  }
5140
5256
  }
5141
5257
  return;
5142
5258
  }
5143
- if (!existsSync7(config.path)) return;
5259
+ if (!existsSync8(config.path)) return;
5144
5260
  try {
5145
- const content = readFileSync3(config.path, "utf-8");
5261
+ const content = readFileSync4(config.path, "utf-8");
5146
5262
  const escaped = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5147
5263
  const regex = new RegExp(
5148
5264
  `\\n?${escaped(INSTRUCTIONS_START)}[\\s\\S]*?${escaped(INSTRUCTIONS_END)}\\n?`
5149
5265
  );
5150
5266
  const cleaned = content.replace(regex, "").trim();
5151
5267
  if (cleaned) {
5152
- writeFileSync3(config.path, cleaned + "\n");
5268
+ writeFileSync4(config.path, cleaned + "\n");
5153
5269
  } else {
5154
- unlinkSync3(config.path);
5270
+ unlinkSync4(config.path);
5155
5271
  }
5156
5272
  } catch {
5157
5273
  }
@@ -5195,7 +5311,7 @@ function createTool(def) {
5195
5311
  getManualHint: () => def.instructions ? null : def.manualHint ?? null
5196
5312
  };
5197
5313
  }
5198
- var appSupport = join3(home, "Library", "Application Support");
5314
+ var appSupport = join4(home, "Library", "Application Support");
5199
5315
  function matchesTool(tool, query) {
5200
5316
  const q = query.toLowerCase().replace(/[\s-_]+/g, "");
5201
5317
  const id = tool.id.toLowerCase().replace(/[\s-_]+/g, "");
@@ -5222,17 +5338,17 @@ var AI_TOOLS = [
5222
5338
  id: "claude-code",
5223
5339
  name: "Claude Code",
5224
5340
  configFormat: "standard",
5225
- configPath: join3(home, ".claude.json"),
5226
- detect: () => hasBinary("claude") || existsSync7(join3(home, ".claude.json")),
5227
- instructions: { method: "append", path: join3(home, ".claude", "CLAUDE.md") },
5341
+ configPath: join4(home, ".claude.json"),
5342
+ detect: () => hasBinary("claude") || existsSync8(join4(home, ".claude.json")),
5343
+ instructions: { method: "append", path: join4(home, ".claude", "CLAUDE.md") },
5228
5344
  supportsUrl: true
5229
5345
  }),
5230
5346
  createTool({
5231
5347
  id: "cursor",
5232
5348
  name: "Cursor",
5233
5349
  configFormat: "standard",
5234
- configPath: join3(home, ".cursor", "mcp.json"),
5235
- detect: () => existsSync7(join3(home, ".cursor")),
5350
+ configPath: join4(home, ".cursor", "mcp.json"),
5351
+ detect: () => existsSync8(join4(home, ".cursor")),
5236
5352
  manualHint: "Open Cursor Settings \u2192 Rules \u2192 User Rules and paste the instructions below.",
5237
5353
  supportsUrl: true
5238
5354
  }),
@@ -5240,51 +5356,51 @@ var AI_TOOLS = [
5240
5356
  id: "windsurf",
5241
5357
  name: "Windsurf",
5242
5358
  configFormat: "standard",
5243
- configPath: join3(home, ".codeium", "windsurf", "mcp_config.json"),
5244
- detect: () => existsSync7(join3(home, ".codeium", "windsurf")),
5245
- instructions: { method: "append", path: join3(home, ".codeium", "windsurf", "memories", "global_rules.md") },
5359
+ configPath: join4(home, ".codeium", "windsurf", "mcp_config.json"),
5360
+ detect: () => existsSync8(join4(home, ".codeium", "windsurf")),
5361
+ instructions: { method: "append", path: join4(home, ".codeium", "windsurf", "memories", "global_rules.md") },
5246
5362
  supportsUrl: true
5247
5363
  }),
5248
5364
  createTool({
5249
5365
  id: "vscode",
5250
5366
  name: "VS Code",
5251
5367
  configFormat: "vscode",
5252
- configPath: join3(appSupport, "Code", "User", "mcp.json"),
5253
- detect: () => existsSync7(join3(appSupport, "Code")),
5254
- instructions: { method: "create", path: join3(appSupport, "Code", "User", "prompts", "useai.instructions.md") },
5368
+ configPath: join4(appSupport, "Code", "User", "mcp.json"),
5369
+ detect: () => existsSync8(join4(appSupport, "Code")),
5370
+ instructions: { method: "create", path: join4(appSupport, "Code", "User", "prompts", "useai.instructions.md") },
5255
5371
  supportsUrl: true
5256
5372
  }),
5257
5373
  createTool({
5258
5374
  id: "vscode-insiders",
5259
5375
  name: "VS Code Insiders",
5260
5376
  configFormat: "vscode",
5261
- configPath: join3(appSupport, "Code - Insiders", "User", "mcp.json"),
5262
- detect: () => existsSync7(join3(appSupport, "Code - Insiders")),
5263
- instructions: { method: "create", path: join3(appSupport, "Code - Insiders", "User", "prompts", "useai.instructions.md") },
5377
+ configPath: join4(appSupport, "Code - Insiders", "User", "mcp.json"),
5378
+ detect: () => existsSync8(join4(appSupport, "Code - Insiders")),
5379
+ instructions: { method: "create", path: join4(appSupport, "Code - Insiders", "User", "prompts", "useai.instructions.md") },
5264
5380
  supportsUrl: true
5265
5381
  }),
5266
5382
  createTool({
5267
5383
  id: "gemini-cli",
5268
5384
  name: "Gemini CLI",
5269
5385
  configFormat: "standard",
5270
- configPath: join3(home, ".gemini", "settings.json"),
5386
+ configPath: join4(home, ".gemini", "settings.json"),
5271
5387
  detect: () => hasBinary("gemini"),
5272
- instructions: { method: "append", path: join3(home, ".gemini", "GEMINI.md") },
5388
+ instructions: { method: "append", path: join4(home, ".gemini", "GEMINI.md") },
5273
5389
  supportsUrl: true
5274
5390
  }),
5275
5391
  createTool({
5276
5392
  id: "zed",
5277
5393
  name: "Zed",
5278
5394
  configFormat: "zed",
5279
- configPath: join3(appSupport, "Zed", "settings.json"),
5280
- detect: () => existsSync7(join3(appSupport, "Zed")),
5395
+ configPath: join4(appSupport, "Zed", "settings.json"),
5396
+ detect: () => existsSync8(join4(appSupport, "Zed")),
5281
5397
  manualHint: "Open Rules Library (\u2318\u2325L) \u2192 click + \u2192 paste the instructions below."
5282
5398
  }),
5283
5399
  createTool({
5284
5400
  id: "cline",
5285
5401
  name: "Cline",
5286
5402
  configFormat: "standard",
5287
- configPath: join3(
5403
+ configPath: join4(
5288
5404
  appSupport,
5289
5405
  "Code",
5290
5406
  "User",
@@ -5293,17 +5409,17 @@ var AI_TOOLS = [
5293
5409
  "settings",
5294
5410
  "cline_mcp_settings.json"
5295
5411
  ),
5296
- detect: () => existsSync7(
5297
- join3(appSupport, "Code", "User", "globalStorage", "saoudrizwan.claude-dev")
5412
+ detect: () => existsSync8(
5413
+ join4(appSupport, "Code", "User", "globalStorage", "saoudrizwan.claude-dev")
5298
5414
  ),
5299
- instructions: { method: "create", path: join3(home, "Documents", "Cline", "Rules", "useai.md") },
5415
+ instructions: { method: "create", path: join4(home, "Documents", "Cline", "Rules", "useai.md") },
5300
5416
  supportsUrl: true
5301
5417
  }),
5302
5418
  createTool({
5303
5419
  id: "roo-code",
5304
5420
  name: "Roo Code",
5305
5421
  configFormat: "standard",
5306
- configPath: join3(
5422
+ configPath: join4(
5307
5423
  appSupport,
5308
5424
  "Code",
5309
5425
  "User",
@@ -5312,59 +5428,59 @@ var AI_TOOLS = [
5312
5428
  "settings",
5313
5429
  "cline_mcp_settings.json"
5314
5430
  ),
5315
- detect: () => existsSync7(
5316
- join3(appSupport, "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline")
5431
+ detect: () => existsSync8(
5432
+ join4(appSupport, "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline")
5317
5433
  ),
5318
- instructions: { method: "create", path: join3(home, ".roo", "rules", "useai.md") },
5434
+ instructions: { method: "create", path: join4(home, ".roo", "rules", "useai.md") },
5319
5435
  supportsUrl: true
5320
5436
  }),
5321
5437
  createTool({
5322
5438
  id: "amazon-q-cli",
5323
5439
  name: "Amazon Q CLI",
5324
5440
  configFormat: "standard",
5325
- configPath: join3(home, ".aws", "amazonq", "mcp.json"),
5326
- detect: () => hasBinary("q") || existsSync7(join3(home, ".aws", "amazonq")),
5441
+ configPath: join4(home, ".aws", "amazonq", "mcp.json"),
5442
+ detect: () => hasBinary("q") || existsSync8(join4(home, ".aws", "amazonq")),
5327
5443
  manualHint: "Create .amazonq/rules/useai.md in your project root with the instructions below."
5328
5444
  }),
5329
5445
  createTool({
5330
5446
  id: "amazon-q-ide",
5331
5447
  name: "Amazon Q IDE",
5332
5448
  configFormat: "standard",
5333
- configPath: join3(home, ".aws", "amazonq", "default.json"),
5334
- detect: () => existsSync7(join3(home, ".amazonq")) || existsSync7(join3(home, ".aws", "amazonq")),
5449
+ configPath: join4(home, ".aws", "amazonq", "default.json"),
5450
+ detect: () => existsSync8(join4(home, ".amazonq")) || existsSync8(join4(home, ".aws", "amazonq")),
5335
5451
  manualHint: "Create .amazonq/rules/useai.md in your project root with the instructions below."
5336
5452
  }),
5337
5453
  createTool({
5338
5454
  id: "codex",
5339
5455
  name: "Codex",
5340
5456
  configFormat: "toml",
5341
- configPath: join3(home, ".codex", "config.toml"),
5342
- detect: () => hasBinary("codex") || existsSync7(join3(home, ".codex")) || existsSync7("/Applications/Codex.app"),
5343
- instructions: { method: "append", path: join3(home, ".codex", "AGENTS.md") }
5457
+ configPath: join4(home, ".codex", "config.toml"),
5458
+ detect: () => hasBinary("codex") || existsSync8(join4(home, ".codex")) || existsSync8("/Applications/Codex.app"),
5459
+ instructions: { method: "append", path: join4(home, ".codex", "AGENTS.md") }
5344
5460
  }),
5345
5461
  createTool({
5346
5462
  id: "goose",
5347
5463
  name: "Goose",
5348
5464
  configFormat: "yaml",
5349
- configPath: join3(home, ".config", "goose", "config.yaml"),
5350
- detect: () => existsSync7(join3(home, ".config", "goose")),
5351
- instructions: { method: "append", path: join3(home, ".config", "goose", ".goosehints") }
5465
+ configPath: join4(home, ".config", "goose", "config.yaml"),
5466
+ detect: () => existsSync8(join4(home, ".config", "goose")),
5467
+ instructions: { method: "append", path: join4(home, ".config", "goose", ".goosehints") }
5352
5468
  }),
5353
5469
  createTool({
5354
5470
  id: "opencode",
5355
5471
  name: "OpenCode",
5356
5472
  configFormat: "standard",
5357
- configPath: join3(home, ".config", "opencode", "opencode.json"),
5358
- detect: () => hasBinary("opencode") || existsSync7(join3(home, ".config", "opencode")),
5359
- instructions: { method: "append", path: join3(home, ".config", "opencode", "AGENTS.md") },
5473
+ configPath: join4(home, ".config", "opencode", "opencode.json"),
5474
+ detect: () => hasBinary("opencode") || existsSync8(join4(home, ".config", "opencode")),
5475
+ instructions: { method: "append", path: join4(home, ".config", "opencode", "AGENTS.md") },
5360
5476
  supportsUrl: true
5361
5477
  }),
5362
5478
  createTool({
5363
5479
  id: "junie",
5364
5480
  name: "Junie",
5365
5481
  configFormat: "standard",
5366
- configPath: join3(home, ".junie", "mcp", "mcp.json"),
5367
- detect: () => existsSync7(join3(home, ".junie")),
5482
+ configPath: join4(home, ".junie", "mcp", "mcp.json"),
5483
+ detect: () => existsSync8(join4(home, ".junie")),
5368
5484
  manualHint: "Add the instructions below to .junie/guidelines.md in your project root."
5369
5485
  })
5370
5486
  ];
@@ -5458,6 +5574,14 @@ async function daemonInstallFlow(tools, explicit) {
5458
5574
  console.log(error(`\u2717 ${tool.name.padEnd(18)} \u2014 ${e.message}`));
5459
5575
  }
5460
5576
  }
5577
+ try {
5578
+ const hooksInstalled = installClaudeCodeHooks();
5579
+ if (hooksInstalled) {
5580
+ console.log(success("\u2713 Claude Code hooks installed (Stop + SessionEnd)"));
5581
+ }
5582
+ } catch {
5583
+ console.log(chalk6.yellow(" \u26A0 Could not install Claude Code hooks"));
5584
+ }
5461
5585
  showManualHints(targetTools);
5462
5586
  const mode = useDaemon ? "daemon mode" : "stdio mode";
5463
5587
  console.log(`
@@ -5632,6 +5756,11 @@ async function fullRemoveFlow(tools, autoYes, explicit) {
5632
5756
  }
5633
5757
  }
5634
5758
  }
5759
+ try {
5760
+ removeClaudeCodeHooks();
5761
+ console.log(success("\u2713 Claude Code hooks removed"));
5762
+ } catch {
5763
+ }
5635
5764
  console.log();
5636
5765
  try {
5637
5766
  await killDaemon();
@@ -5815,8 +5944,145 @@ var serveCommand = new Command9("serve").description("Open the local UseAI dashb
5815
5944
  process.on("SIGTERM", shutdown);
5816
5945
  });
5817
5946
 
5947
+ // src/commands/login.ts
5948
+ import { Command as Command10 } from "commander";
5949
+ import chalk9 from "chalk";
5950
+ import { input } from "@inquirer/prompts";
5951
+ var API_URL = "https://api.useai.dev";
5952
+ async function apiCall(endpoint, body) {
5953
+ const res = await fetch(`${API_URL}${endpoint}`, {
5954
+ method: "POST",
5955
+ headers: { "Content-Type": "application/json" },
5956
+ body: JSON.stringify(body)
5957
+ });
5958
+ const data = await res.json();
5959
+ if (!res.ok) {
5960
+ throw new Error(data.message ?? `Request failed (${res.status})`);
5961
+ }
5962
+ return data;
5963
+ }
5964
+ var loginCommand = new Command10("login").description("Login to useai.dev").action(async () => {
5965
+ try {
5966
+ const config = getConfig();
5967
+ if (config.auth?.token) {
5968
+ console.log(chalk9.dim(` Already logged in as ${chalk9.bold(config.auth.user.email)}`));
5969
+ console.log(chalk9.dim(" Run `useai logout` to switch accounts."));
5970
+ return;
5971
+ }
5972
+ const email = await input({
5973
+ message: "Email:",
5974
+ validate: (v) => v.includes("@") || "Please enter a valid email"
5975
+ });
5976
+ console.log(chalk9.dim(" Sending verification code..."));
5977
+ try {
5978
+ await apiCall("/api/auth/send-otp", { email });
5979
+ } catch (err) {
5980
+ if (err.message.includes("rate") || err.message.includes("Too many")) {
5981
+ console.log(chalk9.red(" Too many requests. Please wait a minute and try again."));
5982
+ return;
5983
+ }
5984
+ throw err;
5985
+ }
5986
+ console.log(chalk9.green(" \u2713 Code sent to your email"));
5987
+ console.log("");
5988
+ let attempts = 0;
5989
+ const maxAttempts = 3;
5990
+ let success2 = false;
5991
+ while (attempts < maxAttempts && !success2) {
5992
+ const code = await input({
5993
+ message: 'Enter 6-digit code (or "resend"):',
5994
+ validate: (v) => {
5995
+ if (v.toLowerCase() === "resend") return true;
5996
+ return /^\d{6}$/.test(v) || 'Code must be 6 digits (or type "resend")';
5997
+ }
5998
+ });
5999
+ if (code.toLowerCase() === "resend") {
6000
+ console.log(chalk9.dim(" Resending code..."));
6001
+ try {
6002
+ await apiCall("/api/auth/send-otp", { email });
6003
+ console.log(chalk9.green(" \u2713 New code sent"));
6004
+ console.log("");
6005
+ continue;
6006
+ } catch (err) {
6007
+ if (err.message.includes("rate") || err.message.includes("Too many")) {
6008
+ console.log(chalk9.yellow(" Please wait before requesting a new code."));
6009
+ continue;
6010
+ }
6011
+ throw err;
6012
+ }
6013
+ }
6014
+ try {
6015
+ const result = await apiCall("/api/auth/verify-otp", { email, code });
6016
+ if (result?.token) {
6017
+ updateConfig({
6018
+ auth: {
6019
+ token: result.token,
6020
+ user: {
6021
+ id: result.user.id,
6022
+ email: result.user.email,
6023
+ username: result.user.username
6024
+ }
6025
+ }
6026
+ });
6027
+ console.log("");
6028
+ console.log(chalk9.green(` \u2713 Logged in as ${chalk9.bold(result.user.email)}`));
6029
+ if (result.user.username) {
6030
+ console.log(chalk9.dim(` username: ${result.user.username}`));
6031
+ }
6032
+ console.log("");
6033
+ console.log(chalk9.dim(" Your sessions and milestones will sync to useai.dev"));
6034
+ success2 = true;
6035
+ }
6036
+ } catch (err) {
6037
+ attempts++;
6038
+ if (err.message.includes("expired") || err.message.includes("No valid OTP")) {
6039
+ console.log(chalk9.red(" Code expired. Sending a new one..."));
6040
+ await apiCall("/api/auth/send-otp", { email });
6041
+ console.log(chalk9.green(" \u2713 New code sent"));
6042
+ attempts = 0;
6043
+ continue;
6044
+ }
6045
+ if (err.message.includes("Too many attempts")) {
6046
+ console.log(chalk9.red(" Too many attempts. Sending a new code..."));
6047
+ await apiCall("/api/auth/send-otp", { email });
6048
+ console.log(chalk9.green(" \u2713 New code sent"));
6049
+ attempts = 0;
6050
+ continue;
6051
+ }
6052
+ const remaining = maxAttempts - attempts;
6053
+ if (remaining > 0) {
6054
+ console.log(chalk9.red(` Invalid code. ${remaining} attempt(s) remaining.`));
6055
+ } else {
6056
+ console.log(chalk9.red(" Too many invalid attempts. Please try again later."));
6057
+ return;
6058
+ }
6059
+ }
6060
+ }
6061
+ if (!success2) {
6062
+ console.log(chalk9.red(" Login failed. Please try again."));
6063
+ }
6064
+ } catch (err) {
6065
+ if (err.name === "ExitPromptError" || err.message?.includes("force closed")) {
6066
+ console.log("");
6067
+ console.log(chalk9.dim(" Cancelled."));
6068
+ return;
6069
+ }
6070
+ console.log(chalk9.red(` Login failed: ${err.message}`));
6071
+ }
6072
+ });
6073
+ var logoutCommand = new Command10("logout").description("Logout from useai.dev").action(() => {
6074
+ const config = getConfig();
6075
+ if (!config.auth) {
6076
+ console.log(chalk9.dim(" Not logged in."));
6077
+ return;
6078
+ }
6079
+ const email = config.auth.user.email;
6080
+ updateConfig({ auth: void 0 });
6081
+ console.log(chalk9.green(` \u2713 Logged out from ${email}`));
6082
+ });
6083
+
5818
6084
  // src/index.ts
5819
- var program = new Command10();
6085
+ var program = new Command11();
5820
6086
  program.name("useai").description("useai.dev \u2014 Track your AI-assisted development workflow").version(VERSION);
5821
6087
  program.addCommand(statsCommand);
5822
6088
  program.addCommand(statusCommand);
@@ -5827,4 +6093,6 @@ program.addCommand(purgeCommand);
5827
6093
  program.addCommand(mcpCommand);
5828
6094
  program.addCommand(daemonCommand);
5829
6095
  program.addCommand(serveCommand);
6096
+ program.addCommand(loginCommand);
6097
+ program.addCommand(logoutCommand);
5830
6098
  program.parse();