create-gentiq-app 1.0.0-alpha.13 → 1.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -27,6 +27,7 @@ ${color.bold('Options')}
27
27
  --no-install Scaffold only; skip \`uv sync\` and the frontend install
28
28
  --openai-key <k> Write this OPENAI_API_KEY into backend/.env
29
29
  -y, --yes Accept every default; never prompt (for CI)
30
+ -v, --version Show CLI version
30
31
  -h, --help Show this message
31
32
  `;
32
33
 
@@ -134,7 +135,7 @@ async function restoreGitignores(dir) {
134
135
  function setEnvValue(content, key, value) {
135
136
  const line = new RegExp(`^#?[ \\t]*${key}=.*$`, 'm');
136
137
  return line.test(content)
137
- ? content.replace(line, `${key}=${value}`)
138
+ ? content.replace(line, () => `${key}=${value}`)
138
139
  : `${content.trimEnd()}\n${key}=${value}\n`;
139
140
  }
140
141
 
@@ -249,11 +250,12 @@ async function installFrontend(projectPath, packageManager, results) {
249
250
  // ---------------------------------------------------------------------------
250
251
 
251
252
  function parseArgs(argv) {
252
- const options = { targetDir: null, install: null, packageManager: null, openaiKey: null, yes: false, help: false };
253
+ const options = { targetDir: null, install: null, packageManager: null, openaiKey: null, yes: false, help: false, version: false };
253
254
 
254
255
  for (let i = 0; i < argv.length; i++) {
255
256
  const arg = argv[i];
256
257
  if (arg === '-h' || arg === '--help') options.help = true;
258
+ else if (arg === '-v' || arg === '--version') options.version = true;
257
259
  else if (arg === '-y' || arg === '--yes') options.yes = true;
258
260
  else if (arg === '--install') options.install = true;
259
261
  else if (arg === '--no-install' || arg === '--skip-install') options.install = false;
@@ -288,10 +290,16 @@ async function main() {
288
290
  return;
289
291
  }
290
292
 
293
+ if (options.version) {
294
+ const { version } = await fs.readJson(path.join(__dirname, 'package.json'));
295
+ console.log(version);
296
+ return;
297
+ }
298
+
291
299
  // Prompting requires a TTY on both ends; CI gets the defaults instead.
292
300
  const interactive = !options.yes && process.stdin.isTTY && process.stdout.isTTY;
293
301
 
294
- console.clear();
302
+ if (interactive) console.clear();
295
303
  p.intro(`${color.bgBlue(color.black(' create-gentiq-app '))}`);
296
304
 
297
305
  let targetDir = options.targetDir;
@@ -310,19 +318,30 @@ async function main() {
310
318
 
311
319
  const projectPath = path.resolve(process.cwd(), targetDir);
312
320
 
313
- if (fs.existsSync(projectPath) && fs.readdirSync(projectPath).length > 0) {
314
- const overwrite = interactive
315
- ? bail(
316
- await p.confirm({
317
- message: `Directory ${targetDir} is not empty. Continue anyway?`,
318
- initialValue: false,
319
- }),
320
- )
321
- : false;
322
-
323
- if (!overwrite) {
324
- p.cancel('Operation cancelled');
325
- process.exit(0);
321
+ if (fs.existsSync(projectPath)) {
322
+ const stat = fs.statSync(projectPath);
323
+ if (!stat.isDirectory()) {
324
+ console.error(`Target path ${targetDir} already exists and is not a directory.`);
325
+ process.exit(1);
326
+ }
327
+ if (fs.readdirSync(projectPath).length > 0) {
328
+ const overwrite = interactive
329
+ ? bail(
330
+ await p.confirm({
331
+ message: `Directory ${targetDir} is not empty. Continue anyway?`,
332
+ initialValue: false,
333
+ }),
334
+ )
335
+ : false;
336
+
337
+ if (!overwrite) {
338
+ if (!interactive) {
339
+ console.error(`Directory ${targetDir} already exists and is not empty.`);
340
+ process.exit(1);
341
+ }
342
+ p.cancel('Operation cancelled');
343
+ process.exit(0);
344
+ }
326
345
  }
327
346
  }
328
347
 
@@ -472,6 +491,9 @@ async function main() {
472
491
  p.note(steps.join('\n'), 'Next Steps');
473
492
 
474
493
  p.outro(`Good luck with your Gentiq app! Need help? Visit our docs.`);
494
+ if (installResults.some((r) => r.status === 'failed')) {
495
+ process.exitCode = 1;
496
+ }
475
497
  }
476
498
 
477
499
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gentiq-app",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.14",
4
4
  "license": "Apache-2.0",
5
5
  "description": "CLI to scaffold a new Gentiq application",
6
6
  "type": "module",
@@ -15,6 +15,7 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "start": "node index.js",
18
+ "test": "node --test index.test.js",
18
19
  "prepublishOnly": "node copy-template.js",
19
20
  "postpublish": "rm -rf templates"
20
21
  },
@@ -41,8 +41,9 @@ uv run uvicorn main:app.api --reload --port 8000
41
41
  | --- | --- |
42
42
  | `OPENAI_API_KEY` | Or the key for whichever provider the model string in `main.py` names. `main.py` builds the provider client as it defines the agent, so the server doesn't start without it. |
43
43
  | `JWT_SECRET_KEY` | Signs user tokens. Generate one with `python -c "import secrets; print(secrets.token_hex(32))"`. The server won't start without it. |
44
- | `BACKEND_API_KEY` | Guards the server-to-server endpoints, such as `POST /api/auth/user`. They reject every request while it is unset. |
44
+ | `BACKEND_API_KEY` | Root key for legacy server-to-server endpoints (minimum 16 characters when set); routes reject every request while it is unset. Prefer scoped integration keys for `/api/integration/v1`. |
45
45
  | `ADMIN_SETUP_TOKEN` | The admin panel asks for it once, to create the first admin at `/admin`. Generate it like `JWT_SECRET_KEY`. |
46
+ | `ENCRYPTION_KEY` | Fernet key for encrypting stored user credentials when using the `Connectors` plugin (`python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"`). |
46
47
 
47
48
  The API docs are at `http://localhost:8000/docs`.
48
49
 
@@ -174,7 +175,7 @@ A field can also depend on another field's value (`condition`); the `dev` templa
174
175
 
175
176
  **Add your own API routes**: `app.add_router(...)` in `main.py`. Depend on `get_current_user` to put a route behind the same JWT auth the chat endpoints use.
176
177
 
177
- **Go to production**: switch `db_engine` to `"mongodb"` and `storage_engine` to `"minio"`, fill in the matching variables in `.env`, and set real secrets. Gentiq installs no CORS middleware unless you pass `cors=CORSConfig(...)`. The template passes `CORSConfig(allow_origins=["http://localhost:5173"])`; replace that with the origins your frontend is served from if it is not same-origin with the API.
178
+ **Go to production**: switch `StorageConfig` in `main.py` to `StorageConfig(db="mongodb", files="minio")`, fill in the matching variables in `.env` (and set `MINIO_SECURE=true` over TLS), and set strong secrets. Gentiq installs no CORS middleware unless you pass `cors=CORSConfig(...)`. The template passes `CORSConfig(allow_origins=["http://localhost:5173"])`; replace that with the origins your frontend is served from if it is not same-origin with the API.
178
179
 
179
180
  ---
180
181
 
@@ -1,6 +1,11 @@
1
1
  # Frontend
2
2
 
3
- A [Vite](https://vite.dev/) + React app built on the `gentiq` React SDK. `src/App.tsx` holds the whole configuration: `GentiqProvider` with app, theme and i18n config, and `GentiqUI` inside it with history, welcome, composer, disclaimer and settings config, wrapping the routes that render `ChatLayout` (behind `RequireAuth`, with its thread in the URL through `useRouterThread` from `gentiq/react-router`), `AdminPanel` (from `gentiq/admin`), `UserLoginPage` and `SharedChatView`.
3
+ A [Vite](https://vite.dev/) + React app built on the Gentiq React SDK (`@gentiq/ui`, `@gentiq/react`, and `@gentiq/admin`, or `gentiq` if you prefer the umbrella package).
4
+
5
+ - `src/App.tsx` mounts `<GentiqChatApp url="/api" admin={<AdminPanel />} {...options} />`, which handles routing (`/chat`, `/chat/:id`, `/login`, `/shared/:id`, `/admin`), auth, streaming, history, settings, and the lazy-loaded admin panel.
6
+ - `src/options.ts` holds all frontend configuration (app name, theme, `i18n.resources`, history, welcome prompts, composer attachments, settings sections).
7
+ - `src/theme.css` overrides `--gentiq-*` tokens inside `.gentiq`.
8
+ - `src/index.css` styles the host page outside Gentiq's `.gentiq` roots (`html`, `body`, `#root`).
4
9
 
5
10
  ## Run it
6
11
 
@@ -13,18 +18,18 @@ The dev server proxies `/api` to `http://localhost:8000` (see `vite.config.ts`),
13
18
 
14
19
  ## Customising
15
20
 
16
- **Theme**: `theme={{ accent, radius, typography }}` on the provider. Gentiq sets these as `--gentiq-primary`, `--gentiq-radius` and `--gentiq-font-family` on its root element, the `.gentiq` element its screens render in; to restyle further, set `--gentiq-*` tokens on `.gentiq` in `src/index.css`. Gentiq styles nothing outside its roots, so the page itself (the body's margin, a full-height `#root`) is styled in `src/index.css`, and `<DocumentSync />` in `src/App.tsx` keeps the page's language, direction, theme class, title and favicon in step with the chat.
21
+ **Theme**: `theme={{ accent, radius, typography }}` in `src/options.ts`, or `--gentiq-*` CSS variables in `src/theme.css`. Gentiq styles only inside its `.gentiq` root elements (and `GentiqChatApp` syncs document theme/direction/title on page routes).
17
22
 
18
- **Tool rendering**: `components.parts` maps `tool-<name>` to a React component (typed with `defineToolUI`), so a tool can render as whatever you like instead of Gentiq's generic card. Tools without an entry keep the generic card. The same map takes `text`, `file`, `data-<name>` for custom parts and other part types, and `components` also replaces the welcome screen, the composer and other pieces; the project README has a worked example.
23
+ **Tool rendering**: pass `components.parts` in `src/options.ts` to map `tool-<name>` (or `data-<name>`) to a React component typed with `defineToolUI`. Tools without an entry render Gentiq's generic tool card.
19
24
 
20
- **Copy and languages**: every user-visible string is an i18n key. `i18n.resources` in `App.tsx` adds to and overrides Gentiq's own translations, which cover 13 languages. Right-to-left languages such as Persian and Arabic switch the layout direction automatically.
25
+ **Copy and languages**: every user-visible string is an i18n key. `i18n.resources` in `src/options.ts` adds to and overrides Gentiq's 13 bundled languages (including RTL support for Arabic, Persian, and Urdu).
21
26
 
22
- **Auth**: with no `api.authAdapter`, Gentiq keeps the JWT in `localStorage`, under a key namespaced by `app.cacheNamespace`. Pass `api={{ authAdapter }}` to authenticate another way: a token from your identity provider (`getToken` may return a promise), or a session cookie your backend reads (an adapter with no token, and `credentials: 'include'` for another origin). See the `gentiq` README's Authentication section.
27
+ **Auth**: with no `api.authAdapter`, Gentiq keeps the JWT in `localStorage` under a key namespaced by `app.cacheNamespace`. Pass `api={{ authAdapter }}` when your session lives elsewhere (external IdP token or HttpOnly session cookie).
23
28
 
24
- **Math**: the SDK loads KaTeX and its stylesheet the first time a message contains `$$` math, so nothing needs importing. `katex` is in `package.json` for that; remove it if your agent never writes math.
29
+ **Math**: the SDK lazy-loads KaTeX and its stylesheet the first time a message contains `$$` math. `katex` is listed in `package.json`; remove it if your agent never emits math.
25
30
 
26
- **Admin panel**: `App.tsx` loads `AdminPanel` with `lazy()`, so its code is a separate file that only `/admin` downloads.
31
+ **Admin panel**: `src/App.tsx` loads `AdminPanel` with `React.lazy()`, so `/admin` code is only downloaded by admins who visit `/admin`.
27
32
 
28
33
  ## Package manager notes
29
34
 
30
- `gentiq` declares React, React DOM, React Router, `ai`, `@ai-sdk/react`, `@tanstack/react-query`, `i18next`, `react-i18next`, `sonner` and (optionally) `katex` as peer dependencies, because a second copy of any of them would break a shared React context or module singleton. They are all in `package.json`, so npm, pnpm, yarn and bun all install correctly.
35
+ Gentiq declares `react`, `react-dom`, `@tanstack/react-query`, `i18next`, `sonner`, and optional `react-router-dom` and `katex` as peer dependencies so your app owns a single shared instance of each context/singleton. They are all listed in `package.json`, so npm, pnpm, yarn, and bun install cleanly.