@blogic-cz/agent-tools 0.1.0 → 0.2.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.
- package/README.md +68 -30
- package/package.json +7 -4
- package/schemas/agent-tools.schema.json +4 -0
- package/src/az-tool/build.ts +5 -0
- package/src/az-tool/errors.ts +12 -0
- package/src/az-tool/index.ts +129 -105
- package/src/az-tool/service.ts +13 -4
- package/src/config/index.ts +7 -1
- package/src/config/loader.ts +8 -0
- package/src/config/types.ts +2 -0
- package/src/credential-guard/index.ts +2 -1
- package/src/db-tool/config-service.ts +2 -2
- package/src/db-tool/errors.ts +15 -0
- package/src/db-tool/index.ts +47 -8
- package/src/db-tool/types.ts +1 -1
- package/src/gh-tool/errors.ts +15 -0
- package/src/gh-tool/index.ts +5 -1
- package/src/gh-tool/issue.ts +1 -1
- package/src/gh-tool/pr/commands.ts +58 -3
- package/src/gh-tool/pr/core.ts +28 -7
- package/src/gh-tool/pr/helpers.ts +1 -1
- package/src/gh-tool/pr/index.ts +2 -0
- package/src/gh-tool/pr/review.ts +10 -6
- package/src/gh-tool/repo.ts +1 -1
- package/src/gh-tool/service.ts +5 -0
- package/src/gh-tool/workflow.ts +5 -1
- package/src/k8s-tool/errors.ts +9 -0
- package/src/k8s-tool/index.ts +318 -66
- package/src/k8s-tool/service.ts +2 -2
- package/src/k8s-tool/types.ts +4 -0
- package/src/logs-tool/errors.ts +12 -0
- package/src/logs-tool/index.ts +73 -11
- package/src/logs-tool/service.ts +4 -4
- package/src/logs-tool/types.ts +4 -1
- package/src/session-tool/config.ts +1 -1
- package/src/session-tool/index.ts +1 -1
- package/src/session-tool/service.ts +16 -3
- package/src/session-tool/types.ts +1 -1
- package/src/shared/bun.ts +1 -1
- package/src/shared/error-renderer.ts +21 -11
- package/src/shared/index.ts +1 -0
- package/src/shared/types.ts +3 -0
|
@@ -51,8 +51,10 @@ const readJsonFilesInTree = (parentDir: string): Effect.Effect<FileEntry[], Sess
|
|
|
51
51
|
const subPath = `${parentDir}/${subDir}`;
|
|
52
52
|
let files: string[];
|
|
53
53
|
try {
|
|
54
|
+
// eslint-disable-next-line eslint/no-await-in-loop -- sequential directory walk, each iteration may short-circuit
|
|
54
55
|
files = await readdir(subPath);
|
|
55
56
|
} catch {
|
|
57
|
+
/* ignore unreadable files */
|
|
56
58
|
continue;
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -63,8 +65,11 @@ const readJsonFilesInTree = (parentDir: string): Effect.Effect<FileEntry[], Sess
|
|
|
63
65
|
try {
|
|
64
66
|
const content = await Bun.file(filePath).text();
|
|
65
67
|
results.push({ filePath, content });
|
|
66
|
-
} catch {
|
|
68
|
+
} catch {
|
|
69
|
+
/* ignore unreadable files */
|
|
70
|
+
}
|
|
67
71
|
});
|
|
72
|
+
// eslint-disable-next-line eslint/no-await-in-loop -- sequential directory walk, each iteration may short-circuit
|
|
68
73
|
await Promise.all(reads);
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -90,7 +95,9 @@ const readJsonFilesFlat = (dir: string): Effect.Effect<FileEntry[], SessionError
|
|
|
90
95
|
try {
|
|
91
96
|
const content = await Bun.file(filePath).text();
|
|
92
97
|
results.push({ filePath, content });
|
|
93
|
-
} catch {
|
|
98
|
+
} catch {
|
|
99
|
+
/* ignore unreadable files */
|
|
100
|
+
}
|
|
94
101
|
});
|
|
95
102
|
await Promise.all(reads);
|
|
96
103
|
|
|
@@ -191,7 +198,13 @@ export class SessionService extends ServiceMap.Service<
|
|
|
191
198
|
}
|
|
192
199
|
}
|
|
193
200
|
|
|
194
|
-
return
|
|
201
|
+
return (
|
|
202
|
+
summaries as MessageSummary[] & {
|
|
203
|
+
toSorted(
|
|
204
|
+
compareFn: (left: MessageSummary, right: MessageSummary) => number,
|
|
205
|
+
): MessageSummary[];
|
|
206
|
+
}
|
|
207
|
+
).toSorted((left, right) => right.created - left.created);
|
|
195
208
|
}),
|
|
196
209
|
|
|
197
210
|
searchSummaries: (summaries: MessageSummary[], query: string): MessageSummary[] => {
|
package/src/shared/bun.ts
CHANGED
|
@@ -11,12 +11,21 @@ const formatError = (error: unknown): string => {
|
|
|
11
11
|
) {
|
|
12
12
|
const tag = (error as Record<string, unknown>)._tag as string;
|
|
13
13
|
const message = (error as Record<string, unknown>).message;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const hint = (error as Record<string, unknown>).hint;
|
|
15
|
+
let result = "";
|
|
16
|
+
if (typeof message === "string") {
|
|
17
|
+
result = `${tag}: ${message}`;
|
|
18
|
+
} else {
|
|
19
|
+
const details = Object.entries(error as Record<string, unknown>)
|
|
20
|
+
.filter(([key, val]) => typeof val === "string" && key !== "_tag" && key !== "hint")
|
|
21
|
+
.map(([key, val]) => `${key}=${String(val)}`)
|
|
22
|
+
.join(", ");
|
|
23
|
+
result = details ? `${tag}: ${details}` : tag;
|
|
24
|
+
}
|
|
25
|
+
if (typeof hint === "string") {
|
|
26
|
+
result += `\n Hint: ${hint}`;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
20
29
|
}
|
|
21
30
|
if (error instanceof Error) return error.message;
|
|
22
31
|
return String(error);
|
|
@@ -24,14 +33,15 @@ const formatError = (error: unknown): string => {
|
|
|
24
33
|
|
|
25
34
|
const formatCause = (cause: Cause.Cause<unknown>): string => {
|
|
26
35
|
const failures = cause.reasons.filter(Cause.isFailReason);
|
|
27
|
-
const firstFailure =
|
|
28
|
-
if (firstFailure !== undefined) return formatError(firstFailure);
|
|
36
|
+
const firstFailure = failures[0];
|
|
37
|
+
if (firstFailure !== undefined) return formatError(firstFailure.error);
|
|
29
38
|
|
|
30
39
|
const defects = cause.reasons.filter(Cause.isDieReason);
|
|
31
|
-
const firstDefect =
|
|
40
|
+
const firstDefect = defects[0];
|
|
32
41
|
if (firstDefect !== undefined) {
|
|
33
|
-
if (firstDefect instanceof Error)
|
|
34
|
-
|
|
42
|
+
if (firstDefect.defect instanceof Error)
|
|
43
|
+
return `Unexpected error: ${firstDefect.defect.message}`;
|
|
44
|
+
return `Unexpected error: ${String(firstDefect.defect)}`;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
if (Cause.hasInterruptsOnly(cause)) return "Interrupted";
|
package/src/shared/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { commonArgOptions, parseCommonArgs } from "./cli";
|
|
|
8
8
|
|
|
9
9
|
export { renderCauseToStderr } from "./error-renderer";
|
|
10
10
|
|
|
11
|
+
// eslint-disable-next-line import/no-relative-parent-imports -- package.json lives at project root, outside src/
|
|
11
12
|
import pkg from "../../package.json" with { type: "json" };
|
|
12
13
|
export const VERSION = pkg.version;
|
|
13
14
|
|