fix(core): update

This commit is contained in:
Philipp Kunz 2024-04-03 13:34:26 +02:00
parent a0969912eb
commit 8d4b278a5d
19 changed files with 436 additions and 145 deletions

View File

@ -14,5 +14,9 @@
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -26,10 +26,11 @@
"@push.rocks/early": "^4.0.3",
"@push.rocks/npmextra": "^5.0.10",
"@push.rocks/qenv": "^6.0.5",
"@push.rocks/smartai": "^0.0.6",
"@push.rocks/smartai": "^0.0.8",
"@push.rocks/smartcli": "^4.0.6",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartinteract": "^2.0.14",
"@push.rocks/smartinteract": "^2.0.15",
"@push.rocks/smartlog": "^3.0.1",
"@push.rocks/smartlog-destination-local": "^9.0.1",
"@push.rocks/smartpath": "^5.0.5",

View File

@ -15,17 +15,20 @@ dependencies:
specifier: ^6.0.5
version: 6.0.5
'@push.rocks/smartai':
specifier: ^0.0.6
version: 0.0.6
specifier: ^0.0.8
version: 0.0.8
'@push.rocks/smartcli':
specifier: ^4.0.6
version: 4.0.8
'@push.rocks/smartdelay':
specifier: ^3.0.5
version: 3.0.5
'@push.rocks/smartfile':
specifier: ^11.0.4
version: 11.0.4
'@push.rocks/smartinteract':
specifier: ^2.0.14
version: 2.0.14
specifier: ^2.0.15
version: 2.0.15
'@push.rocks/smartlog':
specifier: ^3.0.1
version: 3.0.3
@ -644,8 +647,8 @@ packages:
'@push.rocks/smartpath': 5.0.11
dev: false
/@push.rocks/smartai@0.0.6:
resolution: {integrity: sha512-6T6KYdqZdebvKGuB6qYKOv0nptc8l/2h8DoYwadiIPGKXzt7oKb8kQZZyOxGSd76Bzk1vDYM+pHc200jRzAYBg==}
/@push.rocks/smartai@0.0.8:
resolution: {integrity: sha512-OvNXUv9m+qMdzYvReYzDm7hdBCisB3vb+AiLCGkxmLseh/VVe7hcC/5OrPMncstinm1SDl6mL7wDyoh43u8K1w==}
dependencies:
'@push.rocks/qenv': 6.0.5
'@push.rocks/smartfile': 11.0.4
@ -754,7 +757,7 @@ packages:
'@types/glob': 8.1.0
'@types/js-yaml': 4.0.9
fs-extra: 11.2.0
glob: 10.3.10
glob: 10.3.12
js-yaml: 4.1.0
dev: true
@ -786,8 +789,8 @@ packages:
'@types/through2': 2.0.41
through2: 4.0.2
/@push.rocks/smartinteract@2.0.14:
resolution: {integrity: sha512-WumEXkFpGr67yf2as5IOaQDXxeisQF1eocNN2mTXSxfFMcM0D4Z2xFZ0L3z0JDMjBJixsPP8lag2sMrn7X/oEQ==}
/@push.rocks/smartinteract@2.0.15:
resolution: {integrity: sha512-x+fsvGPjwTwCooL83ygNT4DTPOr38eP2k2n33//HCRvBlXsdyR2qmrFwMTg5y38641k8VeBTdbnDoJ/xgv+/RA==}
dependencies:
'@push.rocks/lik': 6.0.14
'@push.rocks/smartobject': 1.0.12
@ -874,7 +877,7 @@ packages:
deprecated: deprecated in favour of @push.rocks/smartobject
dependencies:
'@push.rocks/smartpromise': 4.0.3
minimatch: 9.0.3
minimatch: 9.0.4
/@push.rocks/smartpath@5.0.11:
resolution: {integrity: sha512-dqdd7KTby0AdaWYC9gVoHDTUIixFhEvo+mmdaTdNshZsfHNkm/EDV25dA+9gJ8/yoyuCYmrwmByNYy9a+xFUeQ==}
@ -1586,8 +1589,11 @@ packages:
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
dev: true
/@types/mime@3.0.4:
resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==}
/@types/mime@4.0.0:
resolution: {integrity: sha512-5eEkJZ/BLvTE3vXGKkWlyTSUVZuzj23Wj8PoyOq2lt5I3CYbiLBOPb3XmCW6QcuOibIUE6emHXHt9E/F/rCa6w==}
deprecated: This is a stub types definition. mime provides its own type definitions, so you do not need this installed.
dependencies:
mime: 4.0.1
dev: true
/@types/minimatch@3.0.5:
@ -1649,7 +1655,7 @@ packages:
resolution: {integrity: sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==}
dependencies:
'@types/http-errors': 2.0.4
'@types/mime': 3.0.4
'@types/mime': 4.0.0
'@types/node': 20.12.2
dev: true
@ -2047,7 +2053,7 @@ packages:
engines: {node: '>= 6.0.0'}
dependencies:
mime-types: 2.1.35
ylru: 1.3.2
ylru: 1.4.0
dev: true
/cacheable-lookup@7.0.0:
@ -2912,18 +2918,6 @@ packages:
is-glob: 4.0.3
dev: true
/glob@10.3.10:
resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==}
engines: {node: '>=16 || 14 >=14.17'}
hasBin: true
dependencies:
foreground-child: 3.1.1
jackspeak: 2.3.6
minimatch: 9.0.3
minipass: 7.0.4
path-scurry: 1.10.1
dev: true
/glob@10.3.12:
resolution: {integrity: sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==}
engines: {node: '>=16 || 14 >=14.17'}
@ -3695,6 +3689,12 @@ packages:
hasBin: true
dev: true
/mime@4.0.1:
resolution: {integrity: sha512-5lZ5tyrIfliMXzFtkYyekWbtRXObT9OWa8IwQ5uxTBDHucNNwniRqo0yInflj+iYi5CBa6qxadGzGarDfuEOxA==}
engines: {node: '>=16'}
hasBin: true
dev: true
/mimic-fn@2.1.0:
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
engines: {node: '>=6'}
@ -3719,12 +3719,6 @@ packages:
brace-expansion: 1.1.11
dev: true
/minimatch@9.0.3:
resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==}
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
brace-expansion: 2.0.1
/minimatch@9.0.4:
resolution: {integrity: sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==}
engines: {node: '>=16 || 14 >=14.17'}
@ -3997,14 +3991,6 @@ packages:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'}
/path-scurry@1.10.1:
resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==}
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
lru-cache: 10.2.0
minipass: 7.0.4
dev: true
/path-scurry@1.10.2:
resolution: {integrity: sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==}
engines: {node: '>=16 || 14 >=14.17'}
@ -5043,8 +5029,8 @@ packages:
fd-slicer: 1.1.0
dev: true
/ylru@1.3.2:
resolution: {integrity: sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==}
/ylru@1.4.0:
resolution: {integrity: sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==}
engines: {node: '>= 4.0.0'}
dev: true

View File

@ -1,39 +1,57 @@
# @git.zone/tsdoc
a tool for better documentation
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tsdoc)
* [gitlab.com (source)](https://gitlab.com/gitzone/tsdoc)
* [github.com (source mirror)](https://github.com/gitzone/tsdoc)
* [docs (typedoc)](https://gitzone.gitlab.io/tsdoc/)
## Install
To install `@git.zone/tsdoc`, you will need Node.js and npm (Node Package Manager) installed on your system. Once you have those prerequisites, open your terminal or command prompt and run the following command:
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/gitzone/tsdoc/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/gitzone/tsdoc/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@git.zone/tsdoc)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/gitzone/tsdoc)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@git.zone/tsdoc)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@git.zone/tsdoc)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@git.zone/tsdoc)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
```bash
npm install @git.zone/tsdoc --save
```
This command tells npm to download the `@git.zone/tsdoc` package and add it as a dependency to your project's `package.json` file.
## Usage
To use `@git.zone/tsdoc` effectively in your TypeScript projects, we must delve deep into its functionalities and elaborate on the possibilities it offers. Remember, TypeScript is a statically typed superset of JavaScript, and ESM (ECMAScript Module) syntax is preferred for module import/export operations. Throughout this section, we'll maintain strict adherence to these standards.
Use TypeScript for best in class intellisense.
### Getting Started
Before anything else, ensure you import the necessary functionalities from `@git.zone/tsdoc` at the top of your TypeScript file:
## Contribution
```typescript
import { runCli } from '@git.zone/tsdoc';
```
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
The `runCli` function is a pivotal part of `@git.zone/tsdoc`, serving as an entry point for leveraging its capabilities.
For further information read the linked docs at the top of this readme.
### Leveraging TypeScript for Documentation
TypeScript's rich type system can significantly enhance your documentation process. By providing detailed type annotations, you allow `tsdoc` to generate more informative and useful documentation.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
Consider the following TypeScript interface example:
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
```typescript
interface Person {
name: string;
age: number;
}
```
By explicitly stating that `name` is a `string` and `age` is a `number`, you make your code self-descriptive. `@git.zone/tsdoc` can use this information to generate documentation that is immediately understandable to other developers.
### Generating Documentation
To generate documentation, `@git.zone/tsdoc` provides a CLI tool. Use the `npm run` script from your `package.json` or directly invoke the CLI command if `@git.zone/tsdoc` is installed globally. Here's a sample command to generate documentation:
```bash
tsdoc
```
This command scans your TypeScript project for type annotations, comments, and other relevant information to generate comprehensive documentation.
### Advanced Usage: Ensuring Documentation Quality
It's critical to ensure the completeness and quality of your documentation. `@git.zone/tsdoc` encourages a workflow that includes regular documentation generation and review. This practice helps identify areas lacking sufficient documentation and areas where the documentation can be improved for better clarity.
In projects with multiple contributors, consider setting up continuous integration (CI) tasks that include documentation generation and linting. This setup can help maintain high documentation standards by automatically flagging issues for correction before merging code changes.
### Conclusion
`@git.zone/tsdoc` is a versatile tool that, when used to its full potential, significantly enhances the quality and usability of your project's documentation. By following TypeScript best practices and integrating documentation generation into your development workflow, you can achieve a well-documented codebase that is welcoming to new contributors and beneficial to your project's long-term success.
Please refer to the official `@git.zone/tsdoc` documentation and TypeScript guidelines for more in-depth coverage of the features and best practices discussed here.
(Note: This guide has been crafted to showcase the usage of `@git.zone/tsdoc` in diverse scenarios comprehensively. Ensure to adapt and extend the examples provided to fit the specific needs and complexities of your projects.)

27
test/test.aidocs.nonci.ts Normal file
View File

@ -0,0 +1,27 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as qenv from '@push.rocks/qenv';
let testQenv = new qenv.Qenv('./', '.nogit/');
import * as tsdocs from '../ts/index.js';
let aidocs: tsdocs.AiDoc;
tap.test('should create an AIdocs class', async () => {
aidocs = new tsdocs.AiDoc({
'OPENAI_TOKEN': await testQenv.getEnvVarOnDemand('OPENAI_TOKEN')
});
expect(aidocs).toBeInstanceOf(tsdocs.AiDoc);
});
tap.test('should start AIdocs', async () => {
await aidocs.start();
await aidocs.buildReadme('./');
})
tap.test('should start AIdocs', async () => {
await aidocs.start();
await aidocs.buildDescription('./');
})
tap.start();

View File

@ -1,15 +0,0 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as tsdocs from '../ts/index.js';
let aidocs: tsdocs.AiDocs;
tap.test('should create an AIdocs class', async () => {
aidocs = new tsdocs.AiDocs();
expect(aidocs).toBeInstanceOf(tsdocs.AiDocs);
});
tap.test('should start AIdocs', async () => {})
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsdoc',
version: '1.1.14',
version: '1.1.15',
description: 'a tool for better documentation'
}

View File

@ -0,0 +1,73 @@
import type { AiDoc } from '../classes.aidoc.js';
import * as plugins from '../plugins.js';
import { ProjectContext } from './projectcontext.js';
interface IDescriptionInterface {
description: string;
keywords: string[];
}
export class Description {
// INSTANCE
private aiDocsRef: AiDoc;
private projectDir: string;
constructor(aiDocsRef: AiDoc, projectDirArg: string) {
this.aiDocsRef = aiDocsRef;
this.projectDir = projectDirArg;
}
public async build() {
// we can now assemble the directory structure.
const projectContext = new ProjectContext(this.projectDir);
const contextString = await projectContext.update();
let result = await this.aiDocsRef.openaiInstance.chat(
`
You create a json adhering the following interface:
{
description: string; // a sensible short, one sentence description of the project
keywords: string[]; // an array of tags that describe the project
}
The description should be based on what you understand from the project's files.
The keywords should be based on use cases you see from the files.
Don't be cheap about the way you think.
Important: Answer only in valid JSON.
You answer should be parseable with JSON.parse() without modifying anything.
Don't wrap the JSON in three ticks json!!!
`,
contextString,
[]
);
console.log(result.message.content);
const resultObject: IDescriptionInterface = JSON.parse(result.message.content.replace('```json', '').replace('```', ''));
const npmextraJson = (await projectContext.gatherFiles()).smartfilesNpmextraJSON;
const npmextraJsonContent = JSON.parse(npmextraJson.contents.toString());
npmextraJsonContent.gitzone.module.description = resultObject.description;
npmextraJsonContent.gitzone.module.keywords = resultObject.keywords;
npmextraJson.contents = Buffer.from(JSON.stringify(npmextraJsonContent, null, 2));
await npmextraJson.write();
// do the same with packageJson
const packageJson = (await projectContext.gatherFiles()).smartfilePackageJSON;
const packageJsonContent = JSON.parse(packageJson.contents.toString());
packageJsonContent.description = resultObject.description;
packageJsonContent.keywords = resultObject.keywords;
packageJson.contents = Buffer.from(JSON.stringify(packageJsonContent, null, 2));
await packageJson.write();
console.log(`\n======================\n`);
console.log(JSON.stringify(resultObject, null, 2));
console.log(`\n======================\n`);
return result.message.content;
}
}

View File

@ -0,0 +1,3 @@
export * from './description.js';
export * from './projectcontext.js';
export * from './readme.js';

View File

@ -0,0 +1,73 @@
import * as plugins from '../plugins.js';
export class ProjectContext {
public static async fromDir(dirArg: string) {}
// INSTANCE
public projectDir: string;
constructor(projectDirArg: string) {
this.projectDir = projectDirArg;
}
public async gatherFiles() {
const smartfilePackageJSON = await plugins.smartfile.SmartFile.fromFilePath(
plugins.path.join(this.projectDir, 'package.json'),
this.projectDir
);
const smartfilesReadme = await plugins.smartfile.SmartFile.fromFilePath(
plugins.path.join(this.projectDir, 'readme.md'),
this.projectDir
);
const smartfilesNpmextraJSON = await plugins.smartfile.SmartFile.fromFilePath(
plugins.path.join(this.projectDir, 'npmextra.json'),
this.projectDir
);
const smartfilesMod = await plugins.smartfile.fs.fileTreeToObject(
this.projectDir,
'ts/**/*.ts'
);
const smartfilesTest = await plugins.smartfile.fs.fileTreeToObject(
this.projectDir,
'test/**/*.ts'
);
return {
smartfilePackageJSON,
smartfilesReadme,
smartfilesNpmextraJSON,
smartfilesMod,
smartfilesTest,
};
}
public async convertFilesToContext(filesArg: plugins.smartfile.SmartFile[]) {
return filesArg
.map((smartfile) => {
return `
====== START OF FILE ${smartfile.relative} ======
${smartfile.contents.toString()}
====== END OF FILE ${smartfile.relative} ======
`;
})
.join('\n');
}
private async buildContext(dirArg: string) {
const files = await this.gatherFiles();
let context = await this.convertFilesToContext([
files.smartfilePackageJSON,
files.smartfilesReadme,
files.smartfilesNpmextraJSON,
...files.smartfilesMod,
...files.smartfilesTest,
]);
return context;
}
public async update() {
const result = await this.buildContext(this.projectDir);
return result;
}
}

View File

@ -0,0 +1,84 @@
import type { AiDoc } from '../classes.aidoc.js';
import * as plugins from '../plugins.js';
import { ProjectContext } from './projectcontext.js';
export class Readme {
// INSTANCE
private aiDocsRef: AiDoc;
private projectDir: string;
constructor(aiDocsRef: AiDoc, projectDirArg: string) {
this.aiDocsRef = aiDocsRef;
this.projectDir = projectDirArg;
}
public async build() {
let finalReadmeString = ``;
// we can now assemble the directory structure.
const projectContext = new ProjectContext(this.projectDir);
const contextString = await projectContext.update();
// lets first check legal before introducung any cost
const npmExtraJson = JSON.parse(((await projectContext.gatherFiles()).smartfilesNpmextraJSON).contents.toString());
const legalInfo = npmExtraJson?.tsdoc?.legal
if (!legalInfo) {
const error = new Error(`No legal information found in npmextra.json`);
console.log(error);
}
let result = await this.aiDocsRef.openaiInstance.chat(
`
You create markdown readmes for npm projects. You only output the markdown readme.
The Readme should follow the following template:
# Project Name
[
The name is the module name of package.json
The description is in the description field of package.json
]
## Install
[
Write a short text on how to install the project
]
## Usage
[
Give code examples here.
Construct sensible scenarios for the user.
Make sure to show a complete set of features of the module.
Don't omit use cases.
It does not matter how much time you need.
ALWAYS USE ESM SYNTAX AND TYPESCRIPT.
DON'T CHICKEN OUT. Write at least 4000 words. More if necessary.
If there is already a readme, take the Usage section as base. Remove outdated content, and expand and improve upon the valid parts.
Super important: Check for completenes.
Don't include any licensing information. This will be added in a later step.
Avoid "in conclusions".
npmextra.json has a tsdocs section that provides valuable information about module ideas.
]
`,
contextString,
[]
);
finalReadmeString += result.message.content + '\n' + legalInfo;
console.log(`\n======================\n`);
console.log(result.message.content);
console.log(`\n======================\n`);
const readme = (await projectContext.gatherFiles()).smartfilesReadme;
readme.contents = Buffer.from(finalReadmeString);
await readme.write();
return result.message.content;
}
}

80
ts/classes.aidoc.ts Normal file
View File

@ -0,0 +1,80 @@
import * as plugins from './plugins.js';
import * as aiDocsClasses from './aidocs_classes/index.js';
export class AiDoc {
private openaiToken: string;
public npmextraKV: plugins.npmextra.KeyValueStore;
public qenvInstance: plugins.qenv.Qenv;
public smartinteractInstance: plugins.smartinteract.SmartInteract;
public openaiInstance: plugins.smartai.OpenAiProvider;
argvArg: any;
constructor(argvArg?: any) {
this.argvArg = argvArg;
}
private printSanitizedToken() {
// Check if the token length is greater than the sum of startLength and endLength
let printToken: string;
if (this.openaiToken.length > 6) {
// Extract the beginning and end parts of the token
const start = this.openaiToken.substring(0, 3);
const end = this.openaiToken.substring(this.openaiToken.length - 3);
printToken = `${start}...${end}`;
} else {
// If the token is not long enough, return it as is
printToken = this.openaiToken;
}
console.log(`OpenAI Token on record: ${printToken}`);
}
public async start() {
// lets care about prerequisites
this.smartinteractInstance = new plugins.smartinteract.SmartInteract();
this.qenvInstance = new plugins.qenv.Qenv();
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
this.npmextraKV = new plugins.npmextra.KeyValueStore({
typeArg: 'userHomeDir',
identityArg: 'tsdoc',
mandatoryKeys: ['OPENAI_TOKEN'],
});
const missingKeys = this.npmextraKV.getMissingMandatoryKeys();
if (missingKeys.length > 0) {
// lets try argv
if (this.argvArg?.OPENAI_TOKEN) {
this.openaiToken = this.argvArg.OPENAI_TOKEN;
} else {
// lets try smartinteract
const answerObject = await this.smartinteractInstance.askQuestion({
type: 'input',
message: `Please provide your OpenAI token`,
name: 'OPENAI_TOKEN',
default: '',
});
this.openaiToken = answerObject.value;
}
this.printSanitizedToken();
// await this.npmextraKV.writeKey('OPENAI_TOKEN', this.openaiToken);
}
}
// lets assume we have an OPENAI_Token now
this.openaiInstance = new plugins.smartai.OpenAiProvider(this.openaiToken);
await this.openaiInstance.start();
}
public async buildReadme(projectDirArg: string) {
const readmeInstance = new aiDocsClasses.Readme(this, projectDirArg);
return await readmeInstance.build();
}
public async buildDescription(projectDirArg: string) {
const descriptionInstance = new aiDocsClasses.Description(this, projectDirArg);
return await descriptionInstance.build();
}
}

View File

@ -1,5 +1,5 @@
import * as plugins from './tsdoc.plugins.js';
import * as paths from './tsdoc.paths.js';
import * as plugins from './plugins.js';
import * as paths from './paths.js';
export class TypeDoc {
public smartshellInstance = new plugins.smartshell.Smartshell({

View File

@ -1,9 +1,9 @@
import * as plugins from './tsdoc.plugins.js';
import * as paths from './tsdoc.paths.js';
import { logger } from './tsdoc.logging.js';
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { logger } from './logging.js';
import { TypeDoc } from './tsdoc.classes.typedoc.js';
import { AiDocs } from './tsdoc.classes.aidocs.js';
import { TypeDoc } from './classes.typedoc.js';
import { AiDoc } from './classes.aidoc.js';
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
@ -28,7 +28,7 @@ export const run = async () => {
});
tsdocCli.addCommand('aidocs').subscribe(async (argvArg) => {
const aidocs = new AiDocs();
const aidocs = new AiDoc();
})
tsdocCli.addCommand('test').subscribe((argvArg) => {

View File

@ -1,7 +1,7 @@
import * as early from '@push.rocks/early';
early.start('tsdoc');
import * as plugins from './tsdoc.plugins.js';
import * as cli from './tsdoc.cli.js';
import * as plugins from './plugins.js';
import * as cli from './cli.js';
early.stop();
export const runCli = async () => {
@ -9,4 +9,4 @@ export const runCli = async () => {
};
// exports
export * from './tsdoc.classes.aidocs.js';
export * from './classes.aidoc.js';

View File

@ -1,4 +1,4 @@
import * as plugins from './tsdoc.plugins.js';
import * as plugins from './plugins.js';
export const logger = new plugins.smartlog.Smartlog({
logContext: {

View File

@ -1,4 +1,4 @@
import * as plugins from './tsdoc.plugins.js';
import * as plugins from './plugins.js';
// dirs
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');

View File

@ -8,6 +8,7 @@ import * as npmextra from '@push.rocks/npmextra';
import * as qenv from '@push.rocks/qenv';
import * as smartai from '@push.rocks/smartai';
import * as smartcli from '@push.rocks/smartcli';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartfile from '@push.rocks/smartfile';
import * as smartinteract from '@push.rocks/smartinteract';
import * as smartlog from '@push.rocks/smartlog';
@ -15,7 +16,7 @@ import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-loca
import * as smartpath from '@push.rocks/smartpath';
import * as smartshell from '@push.rocks/smartshell';
export { npmextra, qenv, smartai, smartcli, smartfile, smartinteract, smartlog, smartlogDestinationLocal, smartpath, smartshell };
export { npmextra, qenv, smartai, smartcli, smartdelay, smartfile, smartinteract, smartlog, smartlogDestinationLocal, smartpath, smartshell };
// third party scope
import * as typedoc from 'typedoc';

View File

@ -1,44 +0,0 @@
import * as plugins from './tsdoc.plugins.js';
export class AiDocs {
private openaiToken: string;
public npmextraKV: plugins.npmextra.KeyValueStore;
public qenvInstance: plugins.qenv.Qenv;
public smartinteractInstance: plugins.smartinteract.SmartInteract;
public openaiInstance: plugins.smartai.OpenAiProvider;
constructor() {}
public async start() {
// lets care about prerequisites
this.smartinteractInstance = new plugins.smartinteract.SmartInteract();
this.qenvInstance = new plugins.qenv.Qenv()
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
this.npmextraKV = new plugins.npmextra.KeyValueStore({
typeArg: 'userHomeDir',
identityArg: 'tsdoc',
mandatoryKeys: ['OPENAI_TOKEN']
});
const missingKeys = this.npmextraKV.getMissingMandatoryKeys();
if (missingKeys.length > 0) {
const answerObject = await this.smartinteractInstance.askQuestion({
type: 'input',
message: `Please provide your OpenAI token`,
name: 'OPENAI_TOKEN',
default: '',
});
this.openaiToken = answerObject.value
await this.npmextraKV.writeKey('OPENAI_TOKEN', this.openaiToken);
}
}
// lets assume we have an OPENAI_Token now
// we can now assemble the directory structure.
const smartfilesMod = plugins.smartfile.fs.fileTreeToObject(process.cwd(), 'ts/**/*.ts');
const smartfilesTest = plugins.smartfile.fs.fileTreeToObject(process.cwd(), 'test/**/*.ts');
console.log(smartfilesMod);
console.log(smartfilesTest);
}
}