@blogic-cz/agent-tools 1.14.4 → 1.14.6

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.
Files changed (64) hide show
  1. package/README.md +12 -11
  2. package/dist/api-tool/main.d.ts +6 -1
  3. package/dist/api-tool/main.d.ts.map +1 -1
  4. package/dist/audit-tool/main.d.ts +6 -1
  5. package/dist/audit-tool/main.d.ts.map +1 -1
  6. package/dist/az-tool/main.d.ts +6 -1
  7. package/dist/az-tool/main.d.ts.map +1 -1
  8. package/dist/azdo-tool/main.d.ts +6 -1
  9. package/dist/azdo-tool/main.d.ts.map +1 -1
  10. package/dist/credential-guard/issue-227.test.d.ts +2 -0
  11. package/dist/credential-guard/issue-227.test.d.ts.map +1 -0
  12. package/dist/credential-guard/policy.d.ts.map +1 -1
  13. package/dist/credential-guard/registry.d.ts.map +1 -1
  14. package/dist/db-tool/main.d.ts +8 -1
  15. package/dist/db-tool/main.d.ts.map +1 -1
  16. package/dist/db-tool/service.d.ts +1 -0
  17. package/dist/db-tool/service.d.ts.map +1 -1
  18. package/dist/gh-tool/main.d.ts +4 -1
  19. package/dist/gh-tool/main.d.ts.map +1 -1
  20. package/dist/gh-tool/pr/commands.d.ts +13 -0
  21. package/dist/gh-tool/pr/commands.d.ts.map +1 -1
  22. package/dist/gh-tool/pr/review.d.ts +1 -1
  23. package/dist/gh-tool/pr/review.d.ts.map +1 -1
  24. package/dist/gh-tool/read/store.d.ts +4 -1
  25. package/dist/gh-tool/read/store.d.ts.map +1 -1
  26. package/dist/k8s-tool/main.d.ts +8 -1
  27. package/dist/k8s-tool/main.d.ts.map +1 -1
  28. package/dist/logs-tool/main.d.ts +4 -0
  29. package/dist/logs-tool/main.d.ts.map +1 -1
  30. package/dist/observability-tool/main.d.ts +6 -1
  31. package/dist/observability-tool/main.d.ts.map +1 -1
  32. package/dist/session-tool/main.d.ts +4 -0
  33. package/dist/session-tool/main.d.ts.map +1 -1
  34. package/dist/shared/secret-env.d.ts +9 -0
  35. package/dist/shared/secret-env.d.ts.map +1 -1
  36. package/package.json +10 -11
  37. package/src/api-tool/index.ts +1 -1
  38. package/src/api-tool/main.ts +19 -6
  39. package/src/audit-tool/index.ts +1 -1
  40. package/src/audit-tool/main.ts +13 -4
  41. package/src/az-tool/index.ts +1 -1
  42. package/src/az-tool/main.ts +10 -4
  43. package/src/azdo-tool/index.ts +1 -1
  44. package/src/azdo-tool/main.ts +13 -4
  45. package/src/credential-guard/issue-227.test.ts +69 -0
  46. package/src/credential-guard/policy.ts +23 -20
  47. package/src/credential-guard/registry.ts +99 -11
  48. package/src/db-tool/index.ts +1 -1
  49. package/src/db-tool/main.ts +10 -4
  50. package/src/db-tool/service.ts +6 -1
  51. package/src/gh-tool/index.ts +1 -1
  52. package/src/gh-tool/main.ts +5 -4
  53. package/src/gh-tool/pr/commands.ts +85 -10
  54. package/src/gh-tool/pr/review.ts +2 -1
  55. package/src/gh-tool/read/store.ts +8 -2
  56. package/src/k8s-tool/index.ts +1 -1
  57. package/src/k8s-tool/main.ts +10 -4
  58. package/src/logs-tool/index.ts +1 -1
  59. package/src/logs-tool/main.ts +13 -4
  60. package/src/observability-tool/index.ts +1 -1
  61. package/src/observability-tool/main.ts +10 -2
  62. package/src/session-tool/index.ts +1 -1
  63. package/src/session-tool/main.ts +10 -13
  64. package/src/shared/secret-env.ts +108 -88
@@ -221,7 +221,7 @@ const readCommand = Command.make(
221
221
 
222
222
  const commandsCommand = makeSchemaCommand(() => mainCommand);
223
223
 
224
- const mainCommand = Command.make("logs-tool", {}).pipe(
224
+ export const mainCommand = Command.make("logs-tool", {}).pipe(
225
225
  Command.withDescription("Application Logs Tool for Coding Agents"),
226
226
  Command.withSubcommands([listCommand, readCommand, commandsCommand]),
227
227
  );
@@ -249,6 +249,15 @@ const program = withRedactedOutput(withAudit("logs", cli)).pipe(
249
249
  Effect.tapCause(renderCauseToStderr),
250
250
  );
251
251
 
252
- BunRuntime.runMain(program, {
253
- disableErrorReporting: true,
254
- });
252
+ export const runMain = () =>
253
+ BunRuntime.runMain(program, {
254
+ disableErrorReporting: true,
255
+ });
256
+
257
+ export const runProgram = (args: readonly string[]) =>
258
+ withRedactedOutput(
259
+ withAudit(
260
+ "logs",
261
+ Command.runWith(mainCommand, { version: VERSION, renderErrors: false })(args),
262
+ ),
263
+ ).pipe(Effect.provide(MainLayer), Effect.tapCause(renderCauseToStderr));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  import { checkEffectVersion } from "#shared/effect-version";
3
3
 
4
- if (await checkEffectVersion()) await import("./main");
4
+ if (await checkEffectVersion()) (await import("./main")).runMain();
5
5
  else process.exitCode = 1;
@@ -16,7 +16,7 @@ import { traceCommand } from "./trace";
16
16
 
17
17
  const commandsCommand = makeSchemaCommand(() => mainCommand);
18
18
 
19
- const mainCommand = Command.make("observability-tool", {}).pipe(
19
+ export const mainCommand = Command.make("observability-tool", {}).pipe(
20
20
  Command.withDescription(
21
21
  "LGTM observability queries — Tempo traces, Loki logs, Prometheus metrics",
22
22
  ),
@@ -37,4 +37,12 @@ const program = withRedactedOutput(withAudit("observability", cli)).pipe(
37
37
  Effect.tapCause(renderCauseToStderr),
38
38
  );
39
39
 
40
- BunRuntime.runMain(program, { disableErrorReporting: true });
40
+ export const runMain = () => BunRuntime.runMain(program, { disableErrorReporting: true });
41
+
42
+ export const runProgram = (args: readonly string[]) =>
43
+ withRedactedOutput(
44
+ withAudit(
45
+ "observability",
46
+ Command.runWith(mainCommand, { version: VERSION, renderErrors: false })(args),
47
+ ),
48
+ ).pipe(Effect.provide(MainLayer), Effect.tapCause(renderCauseToStderr));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  import { checkEffectVersion } from "#shared/effect-version";
3
3
 
4
- if (await checkEffectVersion()) await import("./main");
4
+ if (await checkEffectVersion()) (await import("./main")).runMain();
5
5
  else process.exitCode = 1;
@@ -322,16 +322,11 @@ const readCommand = Command.make(
322
322
 
323
323
  const commandsCommand = makeSchemaCommand(() => mainCommand);
324
324
 
325
- const mainCommand = Command.make("session-tool", {}).pipe(
325
+ export const mainCommand = Command.make("session-tool", {}).pipe(
326
326
  Command.withDescription("OpenCode session history tool"),
327
327
  Command.withSubcommands([listCommand, readCommand, searchCommand, commandsCommand]),
328
328
  );
329
329
 
330
- const cli = Command.run(mainCommand, {
331
- version: VERSION,
332
- renderErrors: false,
333
- });
334
-
335
330
  const runWithErrorsDisabled = Command.runWith(mainCommand, {
336
331
  version: VERSION,
337
332
  renderErrors: false,
@@ -344,11 +339,13 @@ const MainLayer = AppLayer.pipe(
344
339
  Layer.provideMerge(AuditServiceLayer),
345
340
  );
346
341
 
347
- const program = withRedactedOutput(withAudit("session", cli)).pipe(
348
- Effect.provide(MainLayer),
349
- Effect.tapCause(renderCauseToStderr),
350
- );
342
+ export const runProgram = (args: readonly string[]) =>
343
+ withRedactedOutput(withAudit("session", runWithErrorsDisabled(args))).pipe(
344
+ Effect.provide(MainLayer),
345
+ Effect.tapCause(renderCauseToStderr),
346
+ );
351
347
 
352
- BunRuntime.runMain(program, {
353
- disableErrorReporting: true,
354
- });
348
+ export const runMain = () =>
349
+ BunRuntime.runMain(runProgram(process.argv.slice(2)), {
350
+ disableErrorReporting: true,
351
+ });
@@ -1,4 +1,4 @@
1
- import { spawn } from "node:child_process";
1
+ import { spawn, type SpawnOptions } from "node:child_process";
2
2
  import { tmpdir } from "node:os";
3
3
  import { relative, resolve as resolvePath } from "node:path";
4
4
  import { Context, Layer } from "effect";
@@ -75,101 +75,121 @@ const inspectFrame = (frame: Buffer): FrameInspection => {
75
75
  };
76
76
  };
77
77
 
78
- const runInteractiveZsh: ZshRunner = (name, timeoutMs) =>
79
- new Promise((resolve) => {
80
- if (process.env.VITEST !== undefined) {
81
- const home = process.env.HOME;
82
- const zdotdir = process.env.ZDOTDIR;
83
- const relativeZdotdir = zdotdir ? relative(tmpdir(), resolvePath(zdotdir)) : "..";
84
- if (
85
- !home ||
86
- !zdotdir ||
87
- resolvePath(home) !== resolvePath(zdotdir) ||
88
- relativeZdotdir === ".." ||
89
- relativeZdotdir.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)
90
- ) {
91
- resolve(failed(name));
92
- return;
78
+ type ZshProcess = Pick<ReturnType<typeof spawn>, "pid" | "stdio" | "kill"> & {
79
+ on: {
80
+ (event: "error", listener: () => void): unknown;
81
+ (event: "exit", listener: (code: number | null) => void): unknown;
82
+ };
83
+ };
84
+ export type ZshLauncher = (
85
+ command: string,
86
+ args: readonly string[],
87
+ options: SpawnOptions,
88
+ ) => ZshProcess;
89
+ export const makeZshRunner =
90
+ (
91
+ launch: ZshLauncher = spawn,
92
+ terminate: (pid: number) => void = (pid) => {
93
+ process.kill(pid, "SIGKILL");
94
+ },
95
+ ): ZshRunner =>
96
+ (name, timeoutMs) =>
97
+ new Promise((resolve) => {
98
+ if (process.env.VITEST !== undefined) {
99
+ const home = process.env.HOME;
100
+ const zdotdir = process.env.ZDOTDIR;
101
+ const relativeZdotdir = zdotdir ? relative(tmpdir(), resolvePath(zdotdir)) : "..";
102
+ if (
103
+ !home ||
104
+ !zdotdir ||
105
+ resolvePath(home) !== resolvePath(zdotdir) ||
106
+ relativeZdotdir === ".." ||
107
+ relativeZdotdir.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)
108
+ ) {
109
+ resolve(failed(name));
110
+ return;
111
+ }
93
112
  }
94
- }
95
113
 
96
- const childEnv = Object.fromEntries(
97
- STARTUP_ENV_NAMES.flatMap((key) => {
98
- const value = process.env[key];
99
- return value === undefined ? [] : [[key, value]];
100
- }),
101
- );
102
- const script = `export LC_ALL=C; if (( \${+parameters[$1]} )); then value=\${(P)1}; print -ru3 -- "set"; print -ru3 -- "\${#value}"; print -rn -- "$value" >&3; else print -ru3 -- "unset"; fi`;
103
-
104
- let child: ReturnType<typeof spawn>;
105
- try {
106
- child = spawn("zsh", ["-i", "-c", script, "agent-tools-secret-env", name], {
107
- detached: true,
108
- env: childEnv,
109
- stdio: ["ignore", "ignore", "ignore", "pipe"],
110
- });
111
- } catch {
112
- resolve(failed(name));
113
- return;
114
- }
114
+ const childEnv = Object.fromEntries(
115
+ STARTUP_ENV_NAMES.flatMap((key) => {
116
+ const value = process.env[key];
117
+ return value === undefined ? [] : [[key, value]];
118
+ }),
119
+ );
120
+ const script = `export LC_ALL=C; if (( \${+parameters[$1]} )); then value=\${(P)1}; print -ru3 -- "set"; print -ru3 -- "\${#value}"; print -rn -- "$value" >&3; else print -ru3 -- "unset"; fi`;
115
121
 
116
- const stream = child.stdio[3];
117
- if (!stream || typeof stream === "number") {
118
- child.kill("SIGKILL");
119
- resolve(failed(name));
120
- return;
121
- }
122
-
123
- const chunks: Buffer[] = [];
124
- let exited = false;
125
- let ended = false;
126
- let exitCode: number | null = null;
127
- let settled = false;
128
- const killProcessGroup = () => {
129
- if (child.pid === undefined) return;
122
+ let child: ZshProcess;
130
123
  try {
131
- process.kill(-child.pid, "SIGKILL");
124
+ child = launch("zsh", ["-i", "-c", script, "agent-tools-secret-env", name], {
125
+ detached: true,
126
+ env: childEnv,
127
+ stdio: ["ignore", "ignore", "ignore", "pipe"],
128
+ });
132
129
  } catch {
133
- // The process group may already have exited.
130
+ resolve(failed(name));
131
+ return;
134
132
  }
135
- };
136
- const finish = (result: LookupResult) => {
137
- if (settled) return;
138
- settled = true;
139
- clearTimeout(timer);
140
- stream.destroy();
141
- killProcessGroup();
142
- resolve(result);
143
- };
144
- const checkFrame = () => {
145
- if (settled) return;
146
- const inspection = inspectFrame(Buffer.concat(chunks));
147
- if (inspection._tag === "malformed") return finish(failed(name));
148
- if (!exited) return;
149
- if (exitCode !== 0) return finish(failed(name));
150
- if (inspection._tag === "complete") finish(inspection.result);
151
- else if (ended) finish(failed(name));
152
- };
153
- const timer = setTimeout(() => {
154
- finish(failed(name));
155
- }, timeoutMs);
156
133
 
157
- stream.on("data", (chunk: Buffer | string) => {
158
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
159
- checkFrame();
160
- });
161
- stream.on("end", () => {
162
- ended = true;
163
- checkFrame();
164
- });
165
- stream.on("error", () => finish(failed(name)));
166
- child.on("error", () => finish(failed(name)));
167
- child.on("exit", (code) => {
168
- exited = true;
169
- exitCode = code;
170
- checkFrame();
134
+ const stream = child.stdio[3];
135
+ if (!stream || typeof stream === "number") {
136
+ child.kill("SIGKILL");
137
+ resolve(failed(name));
138
+ return;
139
+ }
140
+
141
+ const chunks: Buffer[] = [];
142
+ let exited = false;
143
+ let ended = false;
144
+ let exitCode: number | null = null;
145
+ let settled = false;
146
+ const killProcessGroup = () => {
147
+ if (child.pid === undefined) return;
148
+ try {
149
+ terminate(-child.pid);
150
+ } catch {
151
+ // The process group may already have exited.
152
+ }
153
+ };
154
+ const finish = (result: LookupResult) => {
155
+ if (settled) return;
156
+ settled = true;
157
+ clearTimeout(timer);
158
+ stream.destroy();
159
+ killProcessGroup();
160
+ resolve(result);
161
+ };
162
+ const checkFrame = () => {
163
+ if (settled) return;
164
+ const inspection = inspectFrame(Buffer.concat(chunks));
165
+ if (inspection._tag === "malformed") return finish(failed(name));
166
+ if (!exited) return;
167
+ if (exitCode !== 0) return finish(failed(name));
168
+ if (inspection._tag === "complete") finish(inspection.result);
169
+ else if (ended) finish(failed(name));
170
+ };
171
+ const timer = setTimeout(() => {
172
+ finish(failed(name));
173
+ }, timeoutMs);
174
+
175
+ stream.on("data", (chunk: Buffer | string) => {
176
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
177
+ checkFrame();
178
+ });
179
+ stream.on("end", () => {
180
+ ended = true;
181
+ checkFrame();
182
+ });
183
+ stream.on("error", () => finish(failed(name)));
184
+ child.on("error", () => finish(failed(name)));
185
+ child.on("exit", (code) => {
186
+ exited = true;
187
+ exitCode = code;
188
+ checkFrame();
189
+ });
171
190
  });
172
- });
191
+
192
+ const runInteractiveZsh = makeZshRunner();
173
193
 
174
194
  export class SecretEnvResolver extends Context.Service<
175
195
  SecretEnvResolver,