fix(aidocs): correct smartconfig file handling and tighten TypeScript typings

This commit is contained in:
2026-05-09 12:34:16 +00:00
parent 5eed13258a
commit abe7717eed
11 changed files with 1027 additions and 881 deletions
+9 -6
View File
@@ -3,12 +3,12 @@ import * as plugins from './plugins.js';
import * as aiDocsClasses from './aidocs_classes/index.js';
export class AiDoc {
private openaiToken: string;
private openaiToken = '';
public smartconfigKV: plugins.smartconfig.KeyValueStore;
public qenvInstance: plugins.qenv.Qenv;
public aidocInteract: plugins.smartinteract.SmartInteract;
public model: plugins.smartai.LanguageModelV3;
public smartconfigKV?: plugins.smartconfig.KeyValueStore<{ OPENAI_TOKEN: string }>;
public qenvInstance!: plugins.qenv.Qenv;
public aidocInteract!: plugins.smartinteract.SmartInteract;
public model!: plugins.smartai.LanguageModelV3;
argvArg: any;
@@ -35,7 +35,10 @@ export class AiDoc {
// lets care about prerequisites
this.aidocInteract = new plugins.smartinteract.SmartInteract();
this.qenvInstance = new plugins.qenv.Qenv();
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
const openaiTokenFromEnv = await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN');
if (openaiTokenFromEnv) {
this.openaiToken = openaiTokenFromEnv;
} else {
// Migrate old KV store path to new path if needed
const homeDir = plugins.smartpath.get.home();
const oldKvPath = plugins.path.join(homeDir, '.smartconfig/kv/tsdoc.json');