Table of Contents

Class AtomicConfigStore

Namespace
JD.AI.Core.Config
Assembly
JD.AI.Core.dll

Multi-process-safe JSON configuration file manager for JD.AI. Uses file-level locking for cross-process safety and a SemaphoreSlim for in-process concurrency. Writes are atomic: data is written to a temporary file then moved into place.

public sealed class AtomicConfigStore : IDisposable
Inheritance
AtomicConfigStore
Implements
Inherited Members

Constructors

AtomicConfigStore(string?)

Creates a new AtomicConfigStore.

public AtomicConfigStore(string? configPath = null)

Parameters

configPath string

Full path to the JSON config file, or null to use the default ~/.jdai/config.json.

Methods

AddToolPermissionRuleAsync(string, bool, bool, string?, CancellationToken)

Adds an allow/deny rule for tool execution in global or project scope.

public Task AddToolPermissionRuleAsync(string toolPattern, bool allow, bool projectScope, string? projectPath = null, CancellationToken ct = default)

Parameters

toolPattern string
allow bool
projectScope bool
projectPath string
ct CancellationToken

Returns

Task

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetDefaultModelAsync(string?, CancellationToken)

Gets the default model, optionally scoped to a project path.

public Task<string?> GetDefaultModelAsync(string? projectPath = null, CancellationToken ct = default)

Parameters

projectPath string
ct CancellationToken

Returns

Task<string>

GetDefaultProviderAsync(string?, CancellationToken)

Gets the default provider, optionally scoped to a project path.

public Task<string?> GetDefaultProviderAsync(string? projectPath = null, CancellationToken ct = default)

Parameters

projectPath string
ct CancellationToken

Returns

Task<string>

GetDefaultShellAsync(string?, CancellationToken)

Gets the default shell, optionally scoped to a project path.

public Task<string?> GetDefaultShellAsync(string? projectPath = null, CancellationToken ct = default)

Parameters

projectPath string
ct CancellationToken

Returns

Task<string>

GetToolPermissionProfileAsync(string?, CancellationToken)

Gets explicit tool permissions resolved for global + project scope.

public Task<ToolPermissionProfile> GetToolPermissionProfileAsync(string? projectPath = null, CancellationToken ct = default)

Parameters

projectPath string
ct CancellationToken

Returns

Task<ToolPermissionProfile>

ReadAsync(CancellationToken)

Reads the current configuration, returning an empty config when the file does not exist.

public Task<JdAiConfig> ReadAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<JdAiConfig>

SetDefaultModelAsync(string, string?, CancellationToken)

Sets the default model, optionally scoped to a project path.

public Task SetDefaultModelAsync(string model, string? projectPath = null, CancellationToken ct = default)

Parameters

model string
projectPath string
ct CancellationToken

Returns

Task

SetDefaultProviderAsync(string, string?, CancellationToken)

Sets the default provider, optionally scoped to a project path.

public Task SetDefaultProviderAsync(string provider, string? projectPath = null, CancellationToken ct = default)

Parameters

provider string
projectPath string
ct CancellationToken

Returns

Task

SetDefaultShellAsync(string, string?, CancellationToken)

Sets the default shell, optionally scoped to a project path.

public Task SetDefaultShellAsync(string shell, string? projectPath = null, CancellationToken ct = default)

Parameters

shell string
projectPath string
ct CancellationToken

Returns

Task

WriteAsync(Action<JdAiConfig>, CancellationToken)

Atomically mutates the configuration. The mutate action receives the current config (read under lock) and should apply changes in-place.

public Task WriteAsync(Action<JdAiConfig> mutate, CancellationToken ct = default)

Parameters

mutate Action<JdAiConfig>
ct CancellationToken

Returns

Task