@blogic-cz/agent-tools 0.8.5 → 0.8.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.8.5",
3
+ "version": "0.8.10",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, sessions, and audit",
5
5
  "keywords": [
6
6
  "agent",
@@ -4,7 +4,7 @@
4
4
  "title": "Agent Tools Configuration",
5
5
  "description": "Root configuration for the agent-tools package. Tool-specific sections (azure, kubernetes, database, logs) are maps of named profiles keyed by profile name. Tools choose a profile via --profile <name> (default key is 'default', single-entry maps can be auto-selected). session, audit, and credentialGuard are global sections.",
6
6
  "type": "object",
7
- "additionalProperties": false,
7
+ "additionalProperties": true,
8
8
  "properties": {
9
9
  "$schema": {
10
10
  "description": "Optional self-reference URL to this JSON Schema.",
@@ -64,6 +64,19 @@ const GitHubRepoConfigSchema = Schema.Struct({
64
64
  repo: Schema.String,
65
65
  });
66
66
 
67
+ const KNOWN_TOP_LEVEL_KEYS = new Set([
68
+ "$schema",
69
+ "azure",
70
+ "kubernetes",
71
+ "database",
72
+ "logs",
73
+ "session",
74
+ "audit",
75
+ "credentialGuard",
76
+ "defaultEnvironment",
77
+ "github",
78
+ ]);
79
+
67
80
  const AgentToolsConfigSchema = Schema.Struct({
68
81
  $schema: Schema.optionalKey(Schema.String),
69
82
  azure: Schema.optionalKey(Schema.Record(Schema.String, AzureConfigSchema)),
@@ -81,6 +94,35 @@ const AgentToolsConfigSchema = Schema.Struct({
81
94
  github: Schema.optionalKey(Schema.Record(Schema.String, GitHubRepoConfigSchema)),
82
95
  });
83
96
 
97
+ function stripUnknownTopLevelKeys(parsed: unknown): unknown {
98
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
99
+ return parsed;
100
+ }
101
+
102
+ return Object.fromEntries(
103
+ Object.entries(parsed).filter(([key]) => KNOWN_TOP_LEVEL_KEYS.has(key)),
104
+ );
105
+ }
106
+
107
+ export function decodeConfig(
108
+ parsed: unknown,
109
+ configPath: string = "agent-tools.json5",
110
+ ): AgentToolsConfig {
111
+ const sanitized = stripUnknownTopLevelKeys(parsed);
112
+
113
+ try {
114
+ const decoded = Schema.decodeUnknownSync(AgentToolsConfigSchema)(sanitized);
115
+ return decoded as AgentToolsConfig;
116
+ } catch (error) {
117
+ throw new Error(
118
+ `Invalid agent-tools config at ${configPath}: ${
119
+ error instanceof Error ? error.message : String(error)
120
+ }`,
121
+ { cause: error },
122
+ );
123
+ }
124
+ }
125
+
84
126
  async function findConfigFile(startDirectory: string = process.cwd()): Promise<string | undefined> {
85
127
  let currentDirectory = startDirectory;
86
128
 
@@ -114,17 +156,7 @@ export async function loadConfig(): Promise<AgentToolsConfig | undefined> {
114
156
  const fileContent = await Bun.file(configPath).text();
115
157
  const parsed = Bun.JSON5.parse(fileContent);
116
158
 
117
- try {
118
- const decoded = Schema.decodeUnknownSync(AgentToolsConfigSchema)(parsed);
119
- return decoded as AgentToolsConfig;
120
- } catch (error) {
121
- throw new Error(
122
- `Invalid agent-tools config at ${configPath}: ${
123
- error instanceof Error ? error.message : String(error)
124
- }`,
125
- { cause: error },
126
- );
127
- }
159
+ return decodeConfig(parsed, configPath);
128
160
  }
129
161
 
130
162
  export class ConfigService extends ServiceMap.Service<