@repolensai/cli 0.1.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.
@@ -0,0 +1,21 @@
1
+ export type StoredCliAuthConfig = {
2
+ appUrl: string | null;
3
+ token: string | null;
4
+ user?: { email?: string | null } | null;
5
+ loggedInAt?: string | null;
6
+ tokenStore?: {
7
+ type: "keychain" | "file";
8
+ service?: string | null;
9
+ account?: string | null;
10
+ } | null;
11
+ };
12
+
13
+ export function buildCliKeychainDescriptor(
14
+ appUrl: string | null | undefined,
15
+ email: string | null | undefined,
16
+ ): {
17
+ service: string;
18
+ account: string;
19
+ };
20
+
21
+ export function normalizeStoredCliAuthConfig(raw: unknown): StoredCliAuthConfig | null;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @typedef {{
3
+ * appUrl: string | null;
4
+ * token: string | null;
5
+ * user?: { email?: string | null } | null;
6
+ * loggedInAt?: string | null;
7
+ * tokenStore?: {
8
+ * type: "keychain" | "file";
9
+ * service?: string | null;
10
+ * account?: string | null;
11
+ * } | null;
12
+ * }} StoredCliAuthConfig
13
+ */
14
+
15
+ const KEYCHAIN_SERVICE_PREFIX = "com.repolens.cli";
16
+
17
+ /**
18
+ * @param {string | null | undefined} appUrl
19
+ * @param {string | null | undefined} email
20
+ */
21
+ export function buildCliKeychainDescriptor(appUrl, email) {
22
+ const normalizedAppUrl = (appUrl ?? "").trim().replace(/\/$/, "");
23
+ const normalizedEmail = (email ?? "").trim().toLowerCase() || "default";
24
+
25
+ return {
26
+ service: normalizedAppUrl
27
+ ? `${KEYCHAIN_SERVICE_PREFIX}:${normalizedAppUrl}`
28
+ : KEYCHAIN_SERVICE_PREFIX,
29
+ account: normalizedEmail,
30
+ };
31
+ }
32
+
33
+ /**
34
+ * @param {unknown} raw
35
+ * @returns {StoredCliAuthConfig | null}
36
+ */
37
+ export function normalizeStoredCliAuthConfig(raw) {
38
+ if (!raw || typeof raw !== "object") {
39
+ return null;
40
+ }
41
+
42
+ const candidate = /** @type {Record<string, unknown>} */ (raw);
43
+ const tokenStore = candidate.tokenStore && typeof candidate.tokenStore === "object"
44
+ ? /** @type {Record<string, unknown>} */ (candidate.tokenStore)
45
+ : null;
46
+
47
+ return {
48
+ appUrl: typeof candidate.appUrl === "string" ? candidate.appUrl : null,
49
+ token: typeof candidate.token === "string" ? candidate.token : null,
50
+ user: candidate.user && typeof candidate.user === "object"
51
+ ? /** @type {{email?: string | null}} */ (candidate.user)
52
+ : null,
53
+ loggedInAt: typeof candidate.loggedInAt === "string" ? candidate.loggedInAt : null,
54
+ tokenStore: tokenStore && tokenStore.type === "keychain"
55
+ ? {
56
+ type: "keychain",
57
+ service: typeof tokenStore.service === "string" ? tokenStore.service : null,
58
+ account: typeof tokenStore.account === "string" ? tokenStore.account : null,
59
+ }
60
+ : tokenStore && tokenStore.type === "file"
61
+ ? {
62
+ type: "file",
63
+ service: null,
64
+ account: null,
65
+ }
66
+ : null,
67
+ };
68
+ }
@@ -0,0 +1,214 @@
1
+ export interface EvolutionCommit {
2
+ sha: string;
3
+ date: string;
4
+ author: string;
5
+ subject: string;
6
+ }
7
+
8
+ export interface EvolutionAuthorStat {
9
+ author: string;
10
+ commits: number;
11
+ }
12
+
13
+ export interface CommitTheme {
14
+ label: string;
15
+ commits: number;
16
+ examples: string[];
17
+ }
18
+
19
+ export interface HotspotFileStat {
20
+ filePath: string;
21
+ additions: number;
22
+ deletions: number;
23
+ touchedCommits: number;
24
+ score: number;
25
+ }
26
+
27
+ export interface DirectoryStat {
28
+ directoryPath: string;
29
+ fileCount: number;
30
+ touchedCommits: number;
31
+ additions: number;
32
+ deletions: number;
33
+ score: number;
34
+ }
35
+
36
+ export interface RenameHistoryEntry {
37
+ commit: string;
38
+ fromPath: string;
39
+ toPath: string;
40
+ }
41
+
42
+ export interface OwnershipAuthorStat {
43
+ author: string;
44
+ commits: number;
45
+ lastTouchedAt: string;
46
+ lastSubject: string;
47
+ }
48
+
49
+ export interface BlameOwnerStat {
50
+ author: string;
51
+ lines: number;
52
+ commits: number;
53
+ }
54
+
55
+ export interface FileOwnerStat {
56
+ filePath: string;
57
+ primaryOwner: string;
58
+ ownerCommits: number;
59
+ touchedCommits: number;
60
+ lastTouchedAt: string;
61
+ lastSubject: string;
62
+ additions: number;
63
+ deletions: number;
64
+ }
65
+
66
+ export interface ReadingOrderEntry {
67
+ path: string;
68
+ reason: string;
69
+ }
70
+
71
+ export interface TraceScoreBreakdown {
72
+ path: number;
73
+ content: number;
74
+ symbol: number;
75
+ definition: number;
76
+ hotspot: number;
77
+ history: number;
78
+ ownership: number;
79
+ blame: number;
80
+ rename: number;
81
+ total: number;
82
+ }
83
+
84
+ export interface TraceMatchLine {
85
+ filePath: string;
86
+ lineNumber: number;
87
+ preview: string;
88
+ }
89
+
90
+ export function collectEvolutionReport(params: {
91
+ cwd: string;
92
+ targetPath: string;
93
+ sinceRef?: string | null;
94
+ limit?: number;
95
+ exec: (args: string[], runtimeOptions?: { allowFailure?: boolean }) => string;
96
+ }): {
97
+ targetPath: string;
98
+ pathKind: "file" | "directory";
99
+ sinceRef: string | null;
100
+ generatedAt: string;
101
+ trackedFileCount: number;
102
+ commitCount: number;
103
+ commits: EvolutionCommit[];
104
+ authors: EvolutionAuthorStat[];
105
+ fileStats: HotspotFileStat[];
106
+ topFiles: HotspotFileStat[];
107
+ directoryStats: DirectoryStat[];
108
+ commitThemes: CommitTheme[];
109
+ whyChanged: string;
110
+ renameHistory: RenameHistoryEntry[];
111
+ };
112
+
113
+ export function collectHotspotReport(params: {
114
+ sinceRef?: string;
115
+ limit?: number;
116
+ exec: (args: string[], runtimeOptions?: { allowFailure?: boolean }) => string;
117
+ }): {
118
+ sinceRef: string;
119
+ generatedAt: string;
120
+ files: HotspotFileStat[];
121
+ };
122
+
123
+ export function collectOwnershipReport(params: {
124
+ cwd: string;
125
+ targetPath: string;
126
+ sinceRef?: string | null;
127
+ limit?: number;
128
+ exec: (args: string[], runtimeOptions?: { allowFailure?: boolean }) => string;
129
+ }): {
130
+ targetPath: string;
131
+ pathKind: "file" | "directory";
132
+ sinceRef: string | null;
133
+ generatedAt: string;
134
+ trackedFileCount: number;
135
+ owners: OwnershipAuthorStat[];
136
+ blameOwners: BlameOwnerStat[];
137
+ fileOwners: FileOwnerStat[];
138
+ renameHistory: RenameHistoryEntry[];
139
+ };
140
+
141
+ export function collectStartHereReport(params: {
142
+ cwd: string;
143
+ targetPath: string;
144
+ sinceRef?: string | null;
145
+ limit?: number;
146
+ exec: (args: string[], runtimeOptions?: { allowFailure?: boolean }) => string;
147
+ }): {
148
+ targetPath: string;
149
+ pathKind: "file" | "directory";
150
+ sinceRef: string | null;
151
+ generatedAt: string;
152
+ trackedFileCount: number;
153
+ summary: string;
154
+ commitThemes: CommitTheme[];
155
+ whyChanged: string;
156
+ readingOrder: ReadingOrderEntry[];
157
+ hotspotFiles: HotspotFileStat[];
158
+ directoryStats: DirectoryStat[];
159
+ owners: OwnershipAuthorStat[];
160
+ fileOwners: FileOwnerStat[];
161
+ recentCommits: EvolutionCommit[];
162
+ renameHistory: RenameHistoryEntry[];
163
+ };
164
+
165
+ export function collectTraceReport(params: {
166
+ cwd: string;
167
+ query: string;
168
+ sinceRef?: string | null;
169
+ limit?: number;
170
+ exec: (args: string[], runtimeOptions?: { allowFailure?: boolean }) => string;
171
+ }): {
172
+ query: string;
173
+ sinceRef: string | null;
174
+ generatedAt: string;
175
+ matches: Array<{
176
+ filePath: string;
177
+ score: number;
178
+ matchType: string;
179
+ matchSignals: string[];
180
+ matchedLines: TraceMatchLine[];
181
+ scoreBreakdown: TraceScoreBreakdown;
182
+ evolution: ReturnType<typeof collectEvolutionReport>;
183
+ ownership: ReturnType<typeof collectOwnershipReport>;
184
+ }>;
185
+ };
186
+
187
+ export function parseCommitLog(raw: string): EvolutionCommit[];
188
+ export function parseNumstatLog(raw: string): Array<{
189
+ commit: string;
190
+ filePath: string;
191
+ additions: number;
192
+ deletions: number;
193
+ }>;
194
+ export function parseBlamePorcelain(raw: string): Array<{
195
+ commit: string;
196
+ author: string;
197
+ lineCount: number;
198
+ }>;
199
+ export function parseGrepResults(raw: string): TraceMatchLine[];
200
+ export function parseNameStatusLog(raw: string): Array<{
201
+ commit: string;
202
+ status: string;
203
+ fromPath: string;
204
+ toPath: string | null;
205
+ }>;
206
+ export function parseDetailedNumstatLog(raw: string): Array<{
207
+ commit: string;
208
+ date: string;
209
+ author: string;
210
+ subject: string;
211
+ filePath: string;
212
+ additions: number;
213
+ deletions: number;
214
+ }>;