guideline-manage 0.16.0 → 0.16.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.
@@ -14,6 +14,36 @@ async function readAll(stream) {
14
14
  return s;
15
15
  }
16
16
 
17
+ /**
18
+ * 터미널에서 토큰 한 줄을 읽는다. 입력한 글자는 화면에 보이지 않는다.
19
+ * 파이프가 아닌 터미널은 EOF 가 오지 않아서, readAll 로는 아무 안내 없이 멈춘 것처럼 보인다.
20
+ * @returns {Promise<string | null>} Ctrl-C 면 null
21
+ */
22
+ function readHiddenLine(stdin, write) {
23
+ return new Promise(resolve => {
24
+ let s = '';
25
+ const done = value => {
26
+ stdin.removeListener('data', onData);
27
+ stdin.setRawMode?.(false);
28
+ stdin.pause();
29
+ write('\n');
30
+ resolve(value);
31
+ };
32
+ const onData = chunk => {
33
+ for (const ch of String(chunk)) {
34
+ if (ch === '\r' || ch === '\n' || ch === '\u0004') return done(s);
35
+ if (ch === '\u0003') return done(null);
36
+ if (ch === '\u007f' || ch === '\b') s = s.slice(0, -1);
37
+ else s += ch;
38
+ }
39
+ };
40
+ stdin.setRawMode?.(true);
41
+ stdin.setEncoding?.('utf8');
42
+ stdin.on('data', onData);
43
+ stdin.resume();
44
+ });
45
+ }
46
+
17
47
  /** 127.0.0.1 의 임시 포트에서 /cb 한 번을 기다린다. */
18
48
  async function callbackServer() {
19
49
  let resolve;
@@ -45,6 +75,7 @@ async function callbackServer() {
45
75
  export async function login({
46
76
  server, tokenStdin = false, env = process.env, out = console.log, err = console.error, open = openBrowser, fetchImpl = fetch,
47
77
  home, stdin = process.stdin, hostname = os.hostname(), timeoutMs = LOGIN_TIMEOUT_MS,
78
+ prompt = s => process.stderr.write(s),
48
79
  }) {
49
80
  const url = serverOf({ flag: server, env });
50
81
  if (!url) {
@@ -52,7 +83,15 @@ export async function login({
52
83
  return 2;
53
84
  }
54
85
  if (tokenStdin) {
55
- const token = (await readAll(stdin)).trim();
86
+ let token;
87
+ if (stdin.isTTY) {
88
+ prompt(t('login.pasteToken'));
89
+ token = await readHiddenLine(stdin, prompt);
90
+ if (token === null) return 130;
91
+ } else {
92
+ token = await readAll(stdin);
93
+ }
94
+ token = token.trim();
56
95
  if (!token) {
57
96
  err(t('login.noStdinToken'));
58
97
  return 2;
@@ -91,6 +91,7 @@
91
91
  "login.callbackPage": "Login received. You can close this tab.",
92
92
  "login.done": "Logged in: {url} ({name})",
93
93
  "login.loggedOut": "Logged out: {url}",
94
+ "login.pasteToken": "Paste the token and press Enter (it is not shown): ",
94
95
  "login.noStdinToken": "No token on standard input",
95
96
  "login.notLoggedIn": "Not logged in",
96
97
  "login.openUrl": "Log in: {url}",
@@ -91,6 +91,7 @@
91
91
  "login.callbackPage": "로그인 정보를 받았다. 이 탭은 닫아도 된다.",
92
92
  "login.done": "로그인했다: {url} ({name})",
93
93
  "login.loggedOut": "로그아웃했다: {url}",
94
+ "login.pasteToken": "토큰을 붙여 넣고 Enter (화면에 보이지 않는다): ",
94
95
  "login.noStdinToken": "표준 입력에 토큰이 없다",
95
96
  "login.notLoggedIn": "로그인돼 있지 않다",
96
97
  "login.openUrl": "로그인: {url}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guideline-manage",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Keep shared coding-agent guidelines on a guideline server and pick them into ruler projects",
5
5
  "keywords": [
6
6
  "ai",