diff --git a/.dev/build-bin.mjs b/.dev/build-bin.mjs new file mode 100644 index 0000000..7101323 --- /dev/null +++ b/.dev/build-bin.mjs @@ -0,0 +1,18 @@ +import { build } from '@backan/builder' + +import { + cliDistPath, + getPkg, +} from './core.mjs' + +const run = async () => { + + const pkg = await getPkg() + + await build( { + input : cliDistPath, + name : pkg.extra.id, + } ) + +} +run() diff --git a/rsbuild.config.js b/.dev/build-lib.mjs similarity index 57% rename from rsbuild.config.js rename to .dev/build-lib.mjs index ce138d9..1332be6 100644 --- a/rsbuild.config.js +++ b/.dev/build-lib.mjs @@ -1,11 +1,16 @@ import { defineConfig } from '@rsbuild/core' +import { + distPathOnly, + cliSrcPath, +} from './core.mjs' + export const distPath = 'build/in' export default defineConfig( { - source : { entry: { cli: './src/cli.js' } }, + source : { entry: { cli: cliSrcPath } }, output : { - distPath : { root: distPath }, + distPath : { root: distPathOnly }, target : 'node', filename : { js: '[name].cjs' }, }, diff --git a/.dev/core.mjs b/.dev/core.mjs new file mode 100644 index 0000000..769a2b4 --- /dev/null +++ b/.dev/core.mjs @@ -0,0 +1,18 @@ +import { createRequire } from 'module' +import { + dirname, + join as joinPath, +} from 'path' +import { fileURLToPath } from 'url' + +export { joinPath } + +export const workspacePath = joinPath( dirname( fileURLToPath( import.meta.url ) ), '..' ) +export const pkgPath = joinPath( workspacePath, 'package.json' ) +export const cliSrcPath = joinPath( workspacePath, 'src', 'cli.js' ) +export const distPathOnly = joinPath( 'build', 'in' ) +export const cliDistDir = joinPath( workspacePath, distPathOnly ) +export const cliDistPath = joinPath( workspacePath, distPathOnly, 'cli.cjs' ) + +const require = createRequire( import.meta.url ) +export const getPkg = async () => require( pkgPath ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 201d5cb..3f0293e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # create-personality +## 0.2.3 + +### Patch Changes + +- update env and fix cache from selectedModel opt + ## 0.2.2 ### Patch Changes diff --git a/build.js b/build.js deleted file mode 100644 index 24454b8..0000000 --- a/build.js +++ /dev/null @@ -1,21 +0,0 @@ -import { build } from '@backan/builder' -import { createRequire } from 'module' -import { - resolve as resolvePath, - join, -} from 'node:path' - -import { distPath } from './rsbuild.config.js' - -const run = async () => { - - const require = createRequire( import.meta.url ) - const pkg = require( './package.json' ) - - await build( { - input : resolvePath( join( distPath, 'cli' ) ), - name : pkg.extra.id, - } ) - -} -run() diff --git a/docs/todo/v1.md b/docs/todo/v1.md index 96e7a35..2b63721 100644 --- a/docs/todo/v1.md +++ b/docs/todo/v1.md @@ -6,10 +6,10 @@ ## ☀️ Core -- [ ] Save user configuration in a local folder. -- [ ] List saved configurations in the prompt line if they exist. -- [ ] Provide default configurations that the user can choose from. -- [ ] Add an option/flag "config" to set the configurations. +- [ ] Save user configuration in a local folder. +- [ ] List saved configurations in the prompt line if they exist. +- [ ] Provide default configurations that the user can choose from. +- [ ] Add an option/flag "config" to set the configurations. - [ ] Add jsdoc in build ## 💡 Ideas diff --git a/package.json b/package.json index 0613dcd..a937c34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-personality", - "version": "0.2.2", + "version": "0.2.3", "description": "Library for crafting and sustaining AI personalities", "keywords": [ "ia", @@ -43,9 +43,9 @@ "packageManager": "pnpm@9.7.0", "scripts": { "dev": "vite build && node dist/cli.js", - "build": "pnpm run --sequential \"/^build:.*/\"", + "build": "pnpm run --sequential \"/build:.*/\"", "build:lib": "vite build", - "build:bins": "rsbuild build && node ./build.js", + "build:bins": "rsbuild build -c .dev/build-lib.mjs && node .dev/build-bin.mjs", "update-version": "changeset && changeset version", "push": "git add . && cz && git push -f origin $@", "push:main": "pnpm push main" @@ -60,14 +60,14 @@ ], "license": "GPL-3.0", "devDependencies": { - "@backan/builder": "0.0.16", + "@backan/builder": "0.0.19", "@changesets/changelog-github": "0.5.0", "@changesets/cli": "2.27.8", - "@chialab/esbuild-plugin-babel": "^0.18.0", - "@chialab/esbuild-plugin-meta-url": "^0.18.2", + "@chialab/esbuild-plugin-babel": "0.18.0", + "@chialab/esbuild-plugin-meta-url": "0.18.2", "@commitlint/cli": "19.5.0", "@pigeon-posse/eslint-config": "1.0.1", - "@rsbuild/core": "^1.0.2", + "@rsbuild/core": "1.0.5", "@typescript-eslint/eslint-plugin": "8.2.0", "@typescript-eslint/parser": "8.2.0", "commitizen": "4.3.0", @@ -88,7 +88,7 @@ "eslint-plugin-promise": "6.1.1", "eslint-plugin-yaml": "0.5.0", "typescript": "5.6.2", - "vite": "^5.4.4" + "vite": "5.4.6" }, "dependencies": { "@clack/prompts": "0.7.0", diff --git a/src/personality.js b/src/personality.js index 26d487a..9c5e1ee 100644 --- a/src/personality.js +++ b/src/personality.js @@ -356,7 +356,7 @@ done if ( !( this.props.selectedModel && this.props.selectedModel.length > 0 ) ) throw Error( this.texts.errorNoModels ) const successRes = ( id, initValue ) => log.success( this.questions[ id ] + ':\n' + gray( initValue ) ) - const choiceFN = id => async () => { + const choiceFN = ( id, cache = true ) => async () => { const initValue = this.flags[ id ] || this.answers[ id ] if( initValue !== undefined ) { @@ -372,7 +372,7 @@ done label : model, value : model, } ) ), - initialValue : this.cache.get( id ), + initialValue : cache ? this.cache.get( id ) : undefined, } ) } @@ -387,7 +387,7 @@ done ) }, - [ this.ID.selectedModel ] : choiceFN( this.ID.selectedModel ), + [ this.ID.selectedModel ] : choiceFN( this.ID.selectedModel, false ), [ this.ID.tone ] : choiceFN( this.ID.tone ), [ this.ID.formality ] : choiceFN( this.ID.formality ), [ this.ID.topics ] : choiceFN( this.ID.topics ),