TLDR: the add command (static generation) should allow receiving optional instructions for customization (prompt-based generation). This should be implemented as an optional --prompt flag, which sends code+prompt as text for LLM API to process. User should then be able to preview the result, confirm it, keep prompting for updates, or cancel it altogether.
Initial idea taken from @feathershq/pinion (when reading thread) which could also be used (in combination with unjs/giget) for generating/scaffolding files more easily based on template-literal syntax. Some examples of how this could work:
E.g. generating a new model based on an example
import { generator, fromFile, toFile, prompt, gpt } from '@feathershq/pinion'
export const generate = generator()
.then(prompt([{
type: 'input',
name: 'name',
message: 'What is the name of your model?'
}])
.then(gpt(
({ name }) => `generate model for ${name} based on the following example`,
fromFile('examples/model.ts'),
toFile(({ name }) => `models/${name}.ts`)
))
E.g. combining static templates with prompts:
import { generator, fromFile, toFile, prompt, gpt } from '@feathershq/pinion'
const readme = ({ name, description }) => `
# ${name}
This is my awesome app that does:
${description}
Copyright ${new Date().getFullYear()} Feathers Contributors
`
export const generate = generator()
.then(prompt([{
type: 'input',
name: 'name',
message: 'What is the name of your app?'
}, {
type: 'input',
name: 'description',
message: 'Write a short description'
}]))
.then(renderTemplate(readme, toFile('readme.md')))
.then(gpt('translate to German', fromFile('readme.md'), toFile('readme.de.md')))
.then(gpt('translate values to German', fromFile('i18n.en.json'), toFile('i18n.de.json')))
TLDR: the
add
command (static generation) should allow receiving optional instructions for customization (prompt-based generation). This should be implemented as an optional--prompt
flag, which sends code+prompt as text for LLM API to process. User should then be able to preview the result, confirm it, keep prompting for updates, or cancel it altogether.Initial idea taken from @feathershq/pinion (when reading thread) which could also be used (in combination with unjs/giget) for generating/scaffolding files more easily based on template-literal syntax. Some examples of how this could work:
E.g. generating a new model based on an example
E.g. combining static templates with prompts: