@haenah/u1z 0.1.0 → 0.1.2

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": "@haenah/u1z",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AI 집 비서 — Raspberry Pi home assistant powered by Claude + Discord",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
+
4
5
  import { c } from "../utils/color";
5
6
 
6
7
  type CheckResult = { label: string; ok: boolean; hint?: string; optional?: boolean };
@@ -78,8 +79,8 @@ async function checks(): Promise<CheckResult[]> {
78
79
  hint: u1zHome ? `u1z init 실행 필요 (${promptDir} 없음)` : "U1Z_HOME 환경변수 미설정",
79
80
  });
80
81
 
81
- // 8. .env 필수 변수
82
- const envPath = u1zHome ? join(u1zHome, ".env") : "";
82
+ // 8. 설정 파일 필수 변수
83
+ const configPath = join(home, ".config", "u1z", "config");
83
84
  const requiredVars = [
84
85
  "DISCORD_BOT_TOKEN",
85
86
  "OPENAI_API_KEY",
@@ -88,12 +89,9 @@ async function checks(): Promise<CheckResult[]> {
88
89
  ];
89
90
  const missingVars = requiredVars.filter((k) => !process.env[k]);
90
91
  results.push({
91
- label: ".env 필수 변수",
92
+ label: "설정 파일 필수 변수",
92
93
  ok: missingVars.length === 0,
93
- hint:
94
- missingVars.length > 0
95
- ? `누락: ${missingVars.join(", ")} — ${envPath || "U1Z_HOME/.env"}`
96
- : undefined,
94
+ hint: missingVars.length > 0 ? `누락: ${missingVars.join(", ")} — ${configPath}` : undefined,
97
95
  });
98
96
 
99
97
  // 9. systemd u1z.service 등록 여부
@@ -58,13 +58,15 @@ export async function init(): Promise<void> {
58
58
  }
59
59
  });
60
60
 
61
- // 3. .env 설정
62
- const envPath = join(u1zHome, ".env");
63
- await step(".env 설정", async () => {
64
- if (existsSync(envPath)) {
65
- const overwrite = await confirm(".env 파일이 이미 존재합니다. 덮어쓸까요?", false);
61
+ // 3. 설정 파일
62
+ const configDir = join(homedir(), ".config", "u1z");
63
+ const configPath = join(configDir, "config");
64
+ await step("설정 파일 생성 (~/.config/u1z/config)", async () => {
65
+ ensureDir(configDir);
66
+ if (existsSync(configPath)) {
67
+ const overwrite = await confirm("설정 파일이 이미 존재합니다. 덮어쓸까요?", false);
66
68
  if (!overwrite) {
67
- console.log(c.dim(" 기존 .env 유지"));
69
+ console.log(c.dim(" 기존 설정 파일 유지"));
68
70
  return;
69
71
  }
70
72
  }
@@ -87,8 +89,8 @@ export async function init(): Promise<void> {
87
89
  const content = Object.entries(vars)
88
90
  .map(([k, v]) => `${k}="${v.replace(/"/g, '\\"')}"`)
89
91
  .join("\n");
90
- writeFileSync(envPath, `${content}\n`, "utf-8");
91
- console.log(c.dim(` wrote ${envPath}`));
92
+ writeFileSync(configPath, `${content}\n`, "utf-8");
93
+ console.log(c.dim(` wrote ${configPath}`));
92
94
  });
93
95
 
94
96
  // 4. systemd unit 파일 설정
@@ -108,7 +110,7 @@ After=network.target
108
110
  Type=simple
109
111
  WorkingDirectory=${u1zHome}
110
112
  ExecStart=${u1zBin} server
111
- EnvironmentFile=${envPath}
113
+ EnvironmentFile=${configPath}
112
114
  Restart=on-failure
113
115
  RestartSec=5s
114
116
 
package/src/cli/index.ts CHANGED
@@ -2,8 +2,11 @@
2
2
  import yargs from "yargs";
3
3
  import { hideBin } from "yargs/helpers";
4
4
 
5
+ const { version } = await import("../../package.json");
6
+
5
7
  yargs(hideBin(process.argv))
6
8
  .scriptName("u1z")
9
+ .version(version)
7
10
  .command("init", "대화형 초기 셋업 및 systemd 서비스 등록", {}, () =>
8
11
  import("./commands/init").then((m) => m.init()),
9
12
  )