Scaffold a Project

easy5 minscaffold-project.ts

You want a ready-to-run project — package.json, tsconfig, an agent and a tool — generated from code, e.g. inside your own tooling.

What it shows

  • Call scaffold() from create-cogitator-app with a template, provider and package manager

The code

scaffold-project.ts
import { scaffold } from 'create-cogitator-app';
import { readFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';

const projectDir = join(process.cwd(), 'my-agent');

await scaffold({
  name: 'my-agent',
  path: projectDir,
  template: 'basic',
  provider: 'ollama',
  packageManager: 'pnpm',
  docker: false,
  git: false,
});

console.log(readdirSync(projectDir).sort());

const pkg = JSON.parse(readFileSync(join(projectDir, 'package.json'), 'utf-8')) as {
  dependencies: Record<string, string>;
};
console.log('Dependencies:', Object.keys(pkg.dependencies).join(', '));

Run it

install · bash
pnpm add create-cogitator-app
run · bash
npx tsx scaffold-project.ts

Or run the full example from a clone of the repository (keys in .env):

repository · bash
npx tsx examples/create-cogitator-app/scaffold-programmatic.ts

Learn more