ReadonlydirThe .polyman folder.
ReadonlypathThe ai.json file.
Private ReadonlyenvReads the settings. A missing file gives empty settings. A broken file throws, without its content in the message.
Writes the settings. It creates the folder with mode 0700 when it is
missing, writes a temp file with mode 0600, then renames it, so a
crash never leaves a half-written file.
The mode of the .polyman folder when it already exists and group or
others have any permission on it (mode & 0o077), so the caller can warn.
Returns undefined when the folder is missing or private, and always on
Windows, where modes mean nothing. It never changes the mode.
Changes the settings with change, then writes them.
The key of a provider: the env var first, then ai.json.
Saves a key, after keyProblem accepts it.
Removes a saved key. Returns false when there was none.
Sets the default provider and model.
The base URL keys of this provider may go to: the preset one, or the one
saved for custom.
The key to send with a request to url. It throws when url is not
under the base URL of the provider, so a key never goes to another
server. Returns undefined when the provider has no key.
Every key we know, from env vars and the file, for redact. A broken file still gives the env var keys.
Reads and writes
~/.polyman/ai.json.