mira-cli-ts 0.26.7 → 0.26.9

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/cli.js +30 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -74,8 +74,37 @@ function apiUrl() {
74
74
  return `http://127.0.0.1:${port}`;
75
75
  return DEFAULT_API.replace(/\/$/, "");
76
76
  }
77
+ function readMiraEnvFile() {
78
+ try {
79
+ const { readFileSync, existsSync } = __require("fs");
80
+ const { homedir } = __require("os");
81
+ const { join } = __require("path");
82
+ const cands = [
83
+ process.env.MIRA_DIR?.trim() ? join(process.env.MIRA_DIR.trim(), "mira.env") : null,
84
+ process.env.XDG_CONFIG_HOME?.trim() ? join(process.env.XDG_CONFIG_HOME.trim(), "mira", "mira.env") : null,
85
+ join(homedir(), ".mira", "mira.env")
86
+ ].filter(Boolean);
87
+ for (const p of cands) {
88
+ try {
89
+ if (!existsSync(p))
90
+ continue;
91
+ for (const line of readFileSync(p, "utf-8").split(`
92
+ `)) {
93
+ const m = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$/);
94
+ const k = m?.[1];
95
+ if (k === "MIRA_TOKEN") {
96
+ const v = (m?.[2] ?? "").replace(/^(['"])(.*)\1$/, "$2").trim();
97
+ if (v)
98
+ return v;
99
+ }
100
+ }
101
+ } catch {}
102
+ }
103
+ } catch {}
104
+ return;
105
+ }
77
106
  function token() {
78
- return process.env.MIRA_TOKEN ?? "";
107
+ return process.env.MIRA_TOKEN ?? readMiraEnvFile() ?? "";
79
108
  }
80
109
  function authHeaders() {
81
110
  const t = token();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mira-cli-ts",
3
- "version": "0.26.7",
3
+ "version": "0.26.9",
4
4
  "description": "Mira CLI — thin wrapper around @mira/server (serve + session/agent/complete)",
5
5
  "type": "module",
6
6
  "bin": {