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
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsdoc',
version: '2.0.3',
version: '2.0.4',
description: 'A comprehensive TypeScript documentation tool that leverages AI to generate and enhance project documentation, including dynamic README creation, API docs via TypeDoc, and smart commit message generation.'
}
+1 -1
View File
@@ -226,7 +226,7 @@ Analyze these changes and output the JSON commit message object.
const resultObject: INextCommitObject = JSON.parse(jsonString);
const previousChangelogPath = plugins.path.join(this.projectDir, 'changelog.md');
let previousChangelog: plugins.smartfile.SmartFile;
let previousChangelog: plugins.smartfile.SmartFile | undefined;
if (await plugins.fsInstance.file(previousChangelogPath).exists()) {
previousChangelog = await plugins.smartfileFactory.fromFilePath(previousChangelogPath);
}
+1 -1
View File
@@ -80,7 +80,7 @@ Don't wrap the JSON in \`\`\`json\`\`\` - just return the raw JSON object.
const files = await projectContext.gatherFiles();
// Update smartconfig.json
const smartconfigJson = files.smartfilesNpmextraJSON;
const smartconfigJson = files.smartfilesSmartconfigJSON;
const smartconfigJsonContent = JSON.parse(smartconfigJson.contents.toString());
smartconfigJsonContent['gitzone'].module.description = resultObject.description;
+3 -3
View File
@@ -26,7 +26,7 @@ export class ProjectContext {
plugins.path.join(this.projectDir, 'readme.hints.md'),
this.projectDir,
);
const smartfilesNpmextraJSON = await plugins.smartfileFactory.fromFilePath(
const smartfilesSmartconfigJSON = await plugins.smartfileFactory.fromFilePath(
plugins.path.join(this.projectDir, '.smartconfig.json'),
this.projectDir,
);
@@ -40,7 +40,7 @@ export class ProjectContext {
smartfilePackageJSON,
smartfilesReadme,
smartfilesReadmeHints,
smartfilesNpmextraJSON,
smartfilesSmartconfigJSON,
smartfilesMod,
smartfilesTest,
};
@@ -80,7 +80,7 @@ ${smartfile.contents.toString()}
files.smartfilePackageJSON,
files.smartfilesReadme,
files.smartfilesReadmeHints,
files.smartfilesNpmextraJSON,
files.smartfilesSmartconfigJSON,
...files.smartfilesMod,
...files.smartfilesTest,
]);
+1 -1
View File
@@ -20,7 +20,7 @@ export class Readme {
// First check legal info before introducing any cost
const projectContext = new ProjectContext(this.projectDir);
const smartconfigJson = JSON.parse(
(await projectContext.gatherFiles()).smartfilesNpmextraJSON.contents.toString()
(await projectContext.gatherFiles()).smartfilesSmartconfigJSON.contents.toString()
);
const legalInfo = smartconfigJson?.['tsdoc']?.legal;
if (!legalInfo) {
+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');
+2 -3
View File
@@ -14,7 +14,7 @@ export class TypeDoc {
// Instance
public typedocDirectory: string;
constructor(dirPathArg) {
constructor(dirPathArg: string) {
this.typedocDirectory = dirPathArg;
}
@@ -28,9 +28,8 @@ export class TypeDoc {
moduleResolution: 'NodeNext',
esModuleInterop: true,
verbatimModuleSyntax: true,
skipLibCheck: true,
},
include: [],
include: [] as string[],
};
let startDirectory = '';
if (await plugins.fsInstance.directory(plugins.path.join(paths.cwd, './ts')).exists()) {