@aigencydev/cli 0.3.4 → 0.3.5
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/dist/api-client/auth.js +13 -0
- package/dist/commands/chat.js +21 -3
- package/dist/ui/WelcomeBox.js +47 -54
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/api-client/auth.js
CHANGED
|
@@ -23,6 +23,19 @@ export async function refreshAccessToken(refreshToken) {
|
|
|
23
23
|
});
|
|
24
24
|
return res.data;
|
|
25
25
|
}
|
|
26
|
+
export async function fetchMe(accessToken) {
|
|
27
|
+
try {
|
|
28
|
+
const res = await apiRequest("/api/cli/me", {
|
|
29
|
+
method: "GET",
|
|
30
|
+
bearer: accessToken,
|
|
31
|
+
maxRetries: 0,
|
|
32
|
+
});
|
|
33
|
+
return res.data;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
26
39
|
export async function revokeSession(token, reason) {
|
|
27
40
|
await apiRequest("/api/cli/auth/revoke", {
|
|
28
41
|
method: "POST",
|
package/dist/commands/chat.js
CHANGED
|
@@ -2,11 +2,12 @@ import React from "react";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { render } from "ink";
|
|
5
|
-
import { requireActiveSession } from "../auth/session.js";
|
|
5
|
+
import { requireActiveSession, saveSession } from "../auth/session.js";
|
|
6
6
|
import { loadSettings } from "../config/settings.js";
|
|
7
7
|
import { loadMemorySnapshot } from "../agent/memory.js";
|
|
8
8
|
import { loadInstructions } from "../agent/instructions.js";
|
|
9
9
|
import { ensureProjectDataDirs } from "../config/bootstrap.js";
|
|
10
|
+
import { fetchMe } from "../api-client/auth.js";
|
|
10
11
|
import { App } from "../ui/App.js";
|
|
11
12
|
import { log } from "../utils/logger.js";
|
|
12
13
|
async function findProjectRoot(cwd) {
|
|
@@ -37,13 +38,30 @@ async function findProjectRoot(cwd) {
|
|
|
37
38
|
return cwd;
|
|
38
39
|
}
|
|
39
40
|
export async function runChatCommand(options = {}) {
|
|
40
|
-
|
|
41
|
+
let session = await requireActiveSession();
|
|
41
42
|
const cwd = process.cwd();
|
|
42
43
|
const projectRoot = await findProjectRoot(cwd);
|
|
43
44
|
const settings = await loadSettings({ cwd: projectRoot });
|
|
44
45
|
await ensureProjectDataDirs(projectRoot);
|
|
46
|
+
if (!session.user.tier) {
|
|
47
|
+
const me = await fetchMe(session.access_token);
|
|
48
|
+
if (me) {
|
|
49
|
+
session = {
|
|
50
|
+
...session,
|
|
51
|
+
user: {
|
|
52
|
+
...session.user,
|
|
53
|
+
name: me.name || session.user.name,
|
|
54
|
+
tier: me.tier,
|
|
55
|
+
monthly_tokens: me.monthly_tokens,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
await saveSession(session);
|
|
59
|
+
log.debug(`Tier backend'den alındı: ${me.tier}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
45
62
|
const mode = options.mode || settings.mode;
|
|
46
|
-
const
|
|
63
|
+
const userTier = session.user.tier === "max" ? "max" : "pro";
|
|
64
|
+
const model = options.model || userTier;
|
|
47
65
|
const memory = await loadMemorySnapshot(projectRoot);
|
|
48
66
|
if (memory.entries.length > 0 || memory.indexContent) {
|
|
49
67
|
log.debug(`memory: ${memory.entries.length} kayıt, index ${memory.indexContent.length} karakter`);
|
package/dist/ui/WelcomeBox.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
|
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { palette, symbols } from "./theme.js";
|
|
5
|
-
import { listSessions } from "../agent/session-store.js";
|
|
5
|
+
import { listSessions, readSessionTranscript } from "../agent/session-store.js";
|
|
6
6
|
function relativeTime(date) {
|
|
7
7
|
const diff = Date.now() - date.getTime();
|
|
8
8
|
if (diff < 60_000)
|
|
@@ -17,11 +17,11 @@ function relativeTime(date) {
|
|
|
17
17
|
}
|
|
18
18
|
async function buildActivityPreview(sessionId, cwd) {
|
|
19
19
|
try {
|
|
20
|
-
const { readSessionTranscript } = await import("../agent/session-store.js");
|
|
21
20
|
const events = await readSessionTranscript(sessionId, cwd);
|
|
22
21
|
const firstUser = events.find((e) => e.type === "user");
|
|
23
22
|
if (firstUser && firstUser.type === "user") {
|
|
24
|
-
|
|
23
|
+
const clean = firstUser.content.replace(/\s+/g, " ").trim();
|
|
24
|
+
return clean.slice(0, 56) + (clean.length > 56 ? "…" : "");
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
catch {
|
|
@@ -43,7 +43,6 @@ export function WelcomeBox({ userName, userEmail, modelLabel, cwd, cliVersion, p
|
|
|
43
43
|
sessionId: s.sessionId,
|
|
44
44
|
preview,
|
|
45
45
|
whenLabel: relativeTime(s.lastActivityAt),
|
|
46
|
-
messageCount: s.userMessageCount,
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
if (!cancelled)
|
|
@@ -58,66 +57,60 @@ export function WelcomeBox({ userName, userEmail, modelLabel, cwd, cliVersion, p
|
|
|
58
57
|
}, [projectRoot]);
|
|
59
58
|
const projectName = path.basename(cwd) || cwd;
|
|
60
59
|
const displayName = userName.trim() || userEmail || "Geliştirici";
|
|
61
|
-
|
|
60
|
+
const tierColor = modelLabel.includes("Max") ? palette.accent : palette.brand;
|
|
61
|
+
return (React.createElement(Box, { borderStyle: "round", borderColor: palette.brand, flexDirection: "column", paddingX: 1, marginBottom: 1 },
|
|
62
62
|
React.createElement(Box, null,
|
|
63
63
|
React.createElement(Text, { color: palette.brand, bold: true },
|
|
64
64
|
symbols.sparkle,
|
|
65
65
|
" AIGENCY CLI"),
|
|
66
66
|
React.createElement(Text, { color: palette.textFaint },
|
|
67
67
|
" v",
|
|
68
|
-
cliVersion)
|
|
68
|
+
cliVersion),
|
|
69
|
+
React.createElement(Text, { color: palette.textFaint }, " \u00B7 "),
|
|
70
|
+
React.createElement(Text, { color: tierColor, bold: true }, modelLabel)),
|
|
69
71
|
React.createElement(Box, { marginTop: 1 },
|
|
70
|
-
React.createElement(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
React.createElement(Text, { color: palette.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
React.createElement(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
React.createElement(Text, { color: palette.textMuted },
|
|
105
|
-
React.createElement(Text, { color: palette.brand }, "Shift+Tab"),
|
|
106
|
-
" \u2014 izin modu de\u011Fi\u015Ftir"),
|
|
107
|
-
React.createElement(Text, { color: palette.textMuted },
|
|
108
|
-
React.createElement(Text, { color: palette.brand }, "ESC"),
|
|
109
|
-
" \u2014 aktif i\u015Flemi iptal et")))),
|
|
72
|
+
React.createElement(Text, { color: palette.accent },
|
|
73
|
+
symbols.star,
|
|
74
|
+
" "),
|
|
75
|
+
React.createElement(Text, { color: palette.textPrimary, bold: true },
|
|
76
|
+
"Ho\u015F geldin",
|
|
77
|
+
displayName !== "Geliştirici" ? `, ${displayName}` : "",
|
|
78
|
+
"!")),
|
|
79
|
+
React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
80
|
+
React.createElement(Box, null,
|
|
81
|
+
React.createElement(Text, { color: palette.textDim },
|
|
82
|
+
symbols.bullet,
|
|
83
|
+
" Dizin: "),
|
|
84
|
+
React.createElement(Text, { color: palette.textSecondary }, projectName)),
|
|
85
|
+
userEmail && (React.createElement(Box, null,
|
|
86
|
+
React.createElement(Text, { color: palette.textDim },
|
|
87
|
+
symbols.bullet,
|
|
88
|
+
" Hesap: "),
|
|
89
|
+
React.createElement(Text, { color: palette.textMuted }, userEmail)))),
|
|
90
|
+
React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
91
|
+
React.createElement(Text, { color: palette.accent, bold: true },
|
|
92
|
+
symbols.lightning,
|
|
93
|
+
" Ba\u015Flang\u0131\u00E7 ipu\u00E7lar\u0131"),
|
|
94
|
+
React.createElement(Box, { marginTop: 0 },
|
|
95
|
+
React.createElement(Text, { color: palette.brand }, " /init"),
|
|
96
|
+
React.createElement(Text, { color: palette.textMuted }, " \u2014 proje i\u00E7in AIGENCY.md olu\u015Ftur")),
|
|
97
|
+
React.createElement(Box, null,
|
|
98
|
+
React.createElement(Text, { color: palette.brand }, " /help"),
|
|
99
|
+
React.createElement(Text, { color: palette.textMuted }, " \u2014 komut listesi")),
|
|
100
|
+
React.createElement(Box, null,
|
|
101
|
+
React.createElement(Text, { color: palette.brand }, " Shift+Tab"),
|
|
102
|
+
React.createElement(Text, { color: palette.textMuted }, " \u2014 izin modu de\u011Fi\u015Ftir")),
|
|
103
|
+
React.createElement(Box, null,
|
|
104
|
+
React.createElement(Text, { color: palette.brand }, " ESC"),
|
|
105
|
+
React.createElement(Text, { color: palette.textMuted }, " \u2014 aktif i\u015Flemi iptal et"))),
|
|
110
106
|
recent.length > 0 && (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
111
107
|
React.createElement(Text, { color: palette.success, bold: true },
|
|
112
108
|
symbols.triangle,
|
|
113
109
|
" Son aktiviteler"),
|
|
114
110
|
recent.map((r) => (React.createElement(Box, { key: r.sessionId },
|
|
115
|
-
React.createElement(Text, { color: palette.textFaint },
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
" Mesaj yazmaya ba\u015Fla veya ",
|
|
121
|
-
React.createElement(Text, { color: palette.brand }, "/help"),
|
|
122
|
-
" ile komutlar\u0131 ke\u015Ffet"))));
|
|
111
|
+
React.createElement(Text, { color: palette.textFaint },
|
|
112
|
+
" ",
|
|
113
|
+
r.whenLabel),
|
|
114
|
+
React.createElement(Text, { color: palette.textFaint }, " \u00B7 "),
|
|
115
|
+
React.createElement(Text, { color: palette.textSecondary }, r.preview))))))));
|
|
123
116
|
}
|
package/dist/version.js
CHANGED