@alicesystems/cli 0.0.0-stage → 0.1.0-alpha.0

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -2
  3. package/dist/apps/cli/package.json +17 -0
  4. package/dist/apps/cli/src/commands/init/index.mjs +45 -0
  5. package/dist/apps/cli/src/commands/init/prompts.mjs +38 -0
  6. package/dist/apps/cli/src/helpers/validation.mjs +53 -0
  7. package/dist/apps/cli/src/index.mjs +37 -0
  8. package/dist/index.mjs +2 -0
  9. package/dist/packages/template-generator/src/foundation.mjs +128 -0
  10. package/dist/packages/template-generator/templates/README.md +7 -0
  11. package/dist/packages/template-generator/templates/base/.editorconfig +12 -0
  12. package/dist/packages/template-generator/templates/base/.env.example +2 -0
  13. package/dist/packages/template-generator/templates/base/.gitattributes +3 -0
  14. package/dist/packages/template-generator/templates/base/.github/workflows/ci.yml +31 -0
  15. package/dist/packages/template-generator/templates/base/.gitleaks.toml +7 -0
  16. package/dist/packages/template-generator/templates/base/.husky/pre-commit +2 -0
  17. package/dist/packages/template-generator/templates/base/.husky/pre-push +2 -0
  18. package/dist/packages/template-generator/templates/base/.node-version +1 -0
  19. package/dist/packages/template-generator/templates/base/AGENTS.md +11 -0
  20. package/dist/packages/template-generator/templates/base/README.md +26 -0
  21. package/dist/packages/template-generator/templates/base/alice.json +38 -0
  22. package/dist/packages/template-generator/templates/base/biome.json +27 -0
  23. package/dist/packages/template-generator/templates/base/documentation/architecture.md +13 -0
  24. package/dist/packages/template-generator/templates/base/documentation/environment.md +24 -0
  25. package/dist/packages/template-generator/templates/base/documentation/infisical.md +39 -0
  26. package/dist/packages/template-generator/templates/base/documentation/validation-results.md +25 -0
  27. package/dist/packages/template-generator/templates/base/documentation/validation.md +21 -0
  28. package/dist/packages/template-generator/templates/base/lint-staged.config.mjs +3 -0
  29. package/dist/packages/template-generator/templates/base/package.json +42 -0
  30. package/dist/packages/template-generator/templates/base/packages/env/README.md +9 -0
  31. package/dist/packages/template-generator/templates/base/packages/env/package.json +32 -0
  32. package/dist/packages/template-generator/templates/base/packages/env/src/client.ts +5 -0
  33. package/dist/packages/template-generator/templates/base/packages/env/src/policy.ts +9 -0
  34. package/dist/packages/template-generator/templates/base/packages/env/src/server.ts +15 -0
  35. package/dist/packages/template-generator/templates/base/packages/env/tests/env.test.ts +66 -0
  36. package/dist/packages/template-generator/templates/base/packages/env/tsconfig.json +10 -0
  37. package/dist/packages/template-generator/templates/base/packages/env/tsconfig.tooling.json +9 -0
  38. package/dist/packages/template-generator/templates/base/packages/env/tsdown.config.ts +11 -0
  39. package/dist/packages/template-generator/templates/base/packages/env/vitest.config.ts +16 -0
  40. package/dist/packages/template-generator/templates/base/packages/typescript/README.md +7 -0
  41. package/dist/packages/template-generator/templates/base/packages/typescript/base.json +15 -0
  42. package/dist/packages/template-generator/templates/base/packages/typescript/bundler.json +9 -0
  43. package/dist/packages/template-generator/templates/base/packages/typescript/nextjs.json +12 -0
  44. package/dist/packages/template-generator/templates/base/packages/typescript/node.json +6 -0
  45. package/dist/packages/template-generator/templates/base/packages/typescript/package.json +12 -0
  46. package/dist/packages/template-generator/templates/base/packages/typescript/react.json +8 -0
  47. package/dist/packages/template-generator/templates/base/pnpm-lock.yaml +1664 -0
  48. package/dist/packages/template-generator/templates/base/pnpm-workspace.yaml +10 -0
  49. package/dist/packages/template-generator/templates/base/scripts/check-presets.mjs +14 -0
  50. package/dist/packages/template-generator/templates/base/scripts/e2e.mjs +8 -0
  51. package/dist/packages/template-generator/templates/base/scripts/infisical-connect.mjs +119 -0
  52. package/dist/packages/template-generator/templates/base/scripts/infisical-local.mjs +509 -0
  53. package/dist/packages/template-generator/templates/base/scripts/prepare.mjs +15 -0
  54. package/dist/packages/template-generator/templates/base/scripts/secrets.mjs +68 -0
  55. package/dist/packages/template-generator/templates/base/scripts/security-tools.mjs +58 -0
  56. package/dist/packages/template-generator/templates/base/scripts/setup-infisical-local.mjs +115 -0
  57. package/dist/packages/template-generator/templates/base/scripts/setup-local.mjs +8 -0
  58. package/dist/packages/template-generator/templates/base/tests/fixtures/browser/boundary.ts +13 -0
  59. package/dist/packages/template-generator/templates/base/tests/fixtures/browser/tsconfig.json +8 -0
  60. package/dist/packages/template-generator/templates/base/tests/fixtures/node/boundary.ts +4 -0
  61. package/dist/packages/template-generator/templates/base/tests/fixtures/node/tsconfig.json +4 -0
  62. package/dist/packages/template-generator/templates/base/tests/foundation.test.mjs +39 -0
  63. package/dist/packages/template-generator/templates/base/tooling/ultracite/LICENSE +7 -0
  64. package/dist/packages/template-generator/templates/base/tooling/ultracite/README.md +10 -0
  65. package/dist/packages/template-generator/templates/base/tooling/ultracite/core/biome.jsonc +706 -0
  66. package/dist/packages/template-generator/templates/base/tsconfig.json +1 -0
  67. package/dist/packages/template-generator/templates/base/turbo.json +28 -0
  68. package/package.json +15 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Scott Jones, trading as Alice Systems
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Temporary Holding Version
1
+ # Alice Systems CLI (alpha)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Package: `@alicesystems/cli`. Executable: `alice`.
4
+
5
+ This first alpha includes help, version and experimental foundation init.
6
+ It does not implement add/setup/generate/doctor/status/replace or complete
7
+ Infisical sync and crash recovery. Node 24 is required; validation also needs
8
+ pnpm 12.9.1. There are no CLI runtime dependencies on unpublished packages.
9
+
10
+ After publication:
11
+
12
+ ```sh
13
+ pnpm dlx @alicesystems/cli@alpha --help
14
+ pnpm dlx @alicesystems/cli@alpha init --target ./my-project
15
+ ```
16
+
17
+ The second command previews only. Add `--write --validate` to create and check
18
+ the foundation; `alice init` without flags starts the interactive wizard.
19
+ Targets must be absent or empty. The initial project has no apps and only
20
+ TypeScript/env packages. Read https://cli.alicesystems.co.uk/docs for scope.
21
+
22
+ The release includes third-party preset attribution inside the bundled
23
+ templates. Alice's original code is MIT licensed, copyright Scott Jones,
24
+ trading as Alice Systems. It is free to use, including commercially, and is
25
+ provided as is without warranty under the licence. Third-party code retains
26
+ its respective licences.
27
+
28
+ Users should review and test generated code, secure their credentials and
29
+ manage their own infrastructure and deployments. The alpha does not provide
30
+ a guarantee of production readiness or a support/service commitment.
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@alicesystems/cli",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Alice Systems CLI — early development foundation generator",
5
+ "license": "MIT",
6
+ "bin": { "alice": "dist/index.mjs" },
7
+ "files": ["dist", "README.md", "LICENSE"],
8
+ "engines": { "node": ">=24 <25" },
9
+ "repository": { "type": "git", "url": "git+https://github.com/alice-systems-uk/alice-cli.git", "directory": "apps/cli" },
10
+ "publishConfig": { "access": "public", "tag": "alpha" },
11
+ "type": "module",
12
+ "scripts": {
13
+ "dev": "node src/index.mjs",
14
+ "build": "node ../../tools/build-cli.mjs",
15
+ "prepack": "node ../../tools/build-cli.mjs"
16
+ }
17
+ }
@@ -0,0 +1,45 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { createInterface } from 'node:readline/promises';
3
+ import { generateFoundation, planFoundation } from '../../../../../packages/template-generator/src/foundation.mjs';
4
+ import { collectInitOptions } from './prompts.mjs';
5
+ import { validateInstallation, validationPrerequisites } from '../../helpers/validation.mjs';
6
+ import { runLocalSetup } from '../../../../../packages/template-generator/templates/base/scripts/setup-infisical-local.mjs';
7
+
8
+ try {
9
+ const { values } = parseArgs({ options: { target: { type: 'string' }, name: { type: 'string' }, scope: { type: 'string' }, write: { type: 'boolean', default: false }, validate: { type: 'boolean', default: false }, interactive: { type: 'boolean', default: false } } });
10
+ if (values.interactive && (values.target || values.name || values.scope || values.write || values.validate)) throw new Error('Use --interactive on its own; its screens collect the complete operation.');
11
+ if (values.validate && !values.write) throw new Error('--validate requires --write.');
12
+ let options;
13
+ let write = values.write;
14
+ let validation = values.validate;
15
+ if (values.interactive) {
16
+ if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error('Interactive setup requires a terminal. Use explicit --target flags for automation.');
17
+ const terminal = createInterface({ input: process.stdin, output: process.stdout });
18
+ try { options = await collectInitOptions({ ask: (question) => terminal.question(question) }); }
19
+ finally { terminal.close(); }
20
+ if (!options) { console.log('Cancelled. No project files were written.'); process.exitCode = 0; }
21
+ write = true;
22
+ validation = true;
23
+ } else {
24
+ if (!values.target) throw new Error('Usage: node scripts/init-reference.mjs --interactive OR --target <directory> [--name <name>] [--scope @scope] [--write [--validate]]');
25
+ options = { target: values.target, name: values.name, scope: values.scope };
26
+ }
27
+ if (options) {
28
+ // Preflight both the complete plan and runtime tools before writes.
29
+ await planFoundation(options);
30
+ const entry = validation ? await validationPrerequisites() : undefined;
31
+ const plan = write ? await generateFoundation(options, { validate: validation ? (target, candidate) => validateInstallation(target, candidate, { entry }) : undefined }) : await planFoundation(options);
32
+ console.log(`${write ? 'Created' : 'Preview only:'} ${plan.project.name} (${plan.project.scope}) at ${plan.target}`);
33
+ console.log(`${plan.files.length} files; no apps; TypeScript and env packages only.`);
34
+ console.log(validation ? 'Local installation, build, types, tests and security checks passed before manifest commit.' : 'Installation and validation have not been run by this operation.');
35
+ console.log('Development reference only. Git hooks, Infisical, and hosted CI remain unconfigured.');
36
+ if (!write) console.log('Review the target and identity, then use --write --validate to create and check the reference.');
37
+ if (values.interactive && options.setupIntent.infisical === 'local-docker') {
38
+ console.log('Foundation complete. Next: review and confirm the separate local Infisical setup.');
39
+ await runLocalSetup(['--target', plan.target, '--interactive']);
40
+ }
41
+ }
42
+ } catch (error) {
43
+ console.error(error.message);
44
+ process.exitCode = 1;
45
+ }
@@ -0,0 +1,38 @@
1
+ import path from 'node:path';
2
+ import { identity, planFoundation } from '../../../../../packages/template-generator/src/foundation.mjs';
3
+
4
+ export async function collectInitOptions({ ask, say = console.log, cwd = process.cwd() }) {
5
+ say('Welcome to Alice — foundation setup (development preview).');
6
+ const choose = async (question, options, defaultIndex = 0) => {
7
+ while (true) {
8
+ say(question);
9
+ options.forEach((option, index) => say(` ${index + 1}. ${option}`));
10
+ const answer = await ask(`Choose [${defaultIndex + 1}]: `);
11
+ const selected = answer.trim() ? Number(answer) - 1 : defaultIndex;
12
+ if (Number.isInteger(selected) && selected >= 0 && selected < options.length) return selected;
13
+ say('Choose one of the listed numbers.');
14
+ }
15
+ };
16
+ const location = await choose('Where would you like to create your project?', ['Create a new folder', 'Use the current folder', 'Cancel']);
17
+ if (location === 2) return null;
18
+ const defaultName = location === 1 ? path.basename(cwd) : '';
19
+ const name = (await ask(`What is your project called?${defaultName ? ` [${defaultName}]` : ''}: `)).trim() || defaultName;
20
+ const project = identity(name);
21
+ const folder = location === 0 ? (await ask(`Folder name [${project.slug}]: `)).trim() || project.slug : null;
22
+ if (folder && (!/^[a-z0-9][a-z0-9-]{0,99}$/.test(folder) || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(folder))) throw new Error('Choose a simple lowercase folder name without path separators or reserved device names.');
23
+ const scope = (await ask(`Package scope [${project.scope}]: `)).trim() || project.scope;
24
+ const options = { target: location === 1 ? cwd : path.join(cwd, folder), name, scope };
25
+ await planFoundation(options);
26
+ say(`Project: ${name}; scope: ${scope}; target: ${options.target}`);
27
+ say('Foundation: pnpm, Turborepo, TypeScript and env packages, code quality, testing, security checks and CI. No apps or product services.');
28
+ if (await choose('Continue with this foundation?', ['Continue', 'Cancel']) === 1) return null;
29
+ const preference = await choose('Default service preference (each service can override this):', ['Local Docker', 'External hosted services']);
30
+ const infisical = await choose('Infisical setup destination:', ['Create a local Docker instance', 'Connect an existing self-hosted instance', 'Use Infisical Cloud'], preference === 0 ? 0 : 2);
31
+ options.setupIntent = { infrastructurePreference: preference === 0 ? 'local' : 'hosted', infisical: ['local-docker', 'existing-self-hosted', 'cloud'][infisical] };
32
+ const plan = await planFoundation(options);
33
+ say(`Selected service preference: ${options.setupIntent.infrastructurePreference}; Infisical: ${options.setupIntent.infisical} (pending setup).`);
34
+ say(`${plan.files.length} files. One ignored root .env with NODE_ENV=development; safe .env.example.`);
35
+ say('Infisical remains pending until setup succeeds. The local Docker path offers a separate stack review and confirmation after the foundation completes; account creation stays in the browser.');
36
+ say('Continuing installs pinned dependencies, downloads the checksum-verified workspace secret scanner, and runs quality/build/type/test/security checks before committing alice.json.');
37
+ return await choose('Create and validate the local foundation now?', ['Continue', 'Cancel']) === 0 ? options : null;
38
+ }
@@ -0,0 +1,53 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { promises as fs } from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+
6
+ export async function findPnpm() {
7
+ // Invoke a JS entry point with Node; never interpolate project paths into a shell.
8
+ for (const directory of (process.env.PATH ?? '').split(path.delimiter)) {
9
+ if (!directory) continue;
10
+ for (const relative of ['node_modules/corepack/dist/pnpm.js', 'node_modules/pnpm/bin/pnpm.cjs', 'pnpm.cjs']) {
11
+ const entry = path.resolve(directory, relative);
12
+ try { if ((await fs.stat(entry)).isFile()) return entry; } catch (error) { if (error.code !== 'ENOENT') throw error; }
13
+ }
14
+ }
15
+ throw new Error('A supported pnpm JavaScript entry point was not found on PATH. Install the selected pnpm version before continuing.');
16
+ }
17
+
18
+ export function runPnpm(entry, args, { cwd, env = process.env, capture = false } = {}) {
19
+ return new Promise((resolve, reject) => {
20
+ const child = spawn(process.execPath, [entry, ...args], { cwd, env, shell: false, windowsHide: true, stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit' });
21
+ let output = '';
22
+ if (capture) {
23
+ child.stdout.on('data', (data) => { output += data; });
24
+ child.stderr.on('data', () => {});
25
+ }
26
+ child.once('error', () => reject(new Error('Could not start pnpm.')));
27
+ child.once('close', (code, signal) => code === 0 ? resolve(output.trim()) : reject(new Error(`pnpm ${args.join(' ')} failed (${signal ?? code}).`)));
28
+ });
29
+ }
30
+
31
+ export async function validationPrerequisites() {
32
+ const [major, minor] = process.versions.node.split('.').map(Number);
33
+ if (major !== 24 || minor < 21) throw new Error('This reference requires Node 24.21 or later within Node 24.');
34
+ if (!['win32', 'linux'].includes(process.platform) || process.arch !== 'x64') throw new Error('Validated scanner support currently requires Windows/Linux x64.');
35
+ const entry = await findPnpm();
36
+ if (await runPnpm(entry, ['--version'], { capture: true }) !== '12.9.1') throw new Error('This reference requires pnpm 12.9.1; no tool is installed automatically.');
37
+ return entry;
38
+ }
39
+
40
+ export async function validateInstallation(target, plan, { entry, run = runPnpm } = {}) {
41
+ const temporary = await fs.mkdtemp(path.join(os.tmpdir(), 'alice-candidate-'));
42
+ const candidate = path.join(temporary, 'alice.json');
43
+ try {
44
+ await fs.writeFile(candidate, plan.files.find((file) => file.path === 'alice.json').content, { flag: 'wx' });
45
+ const env = { ...process.env, HUSKY: '0', ALICE_INIT_CANDIDATE_MANIFEST: candidate };
46
+ for (const args of [['install', '--frozen-lockfile'], ['validate'], ['security:tools'], ['validate:security']]) {
47
+ await run(entry, args, { cwd: target, env });
48
+ }
49
+ } finally {
50
+ await fs.unlink(candidate).catch((error) => { if (error.code !== 'ENOENT') throw error; });
51
+ await fs.rmdir(temporary);
52
+ }
53
+ }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+
4
+ const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
5
+ const args = process.argv.slice(2);
6
+ const help = `Alice Systems CLI ${pkg.version} (alpha)
7
+
8
+ Usage: alice <command>
9
+
10
+ init Experimental foundation setup
11
+ init --target <path> Preview without writing
12
+ init --target <path> --write --validate
13
+ Create and validate the foundation
14
+ --help Show help
15
+ --version Show version
16
+
17
+ init options: --name <name>, --scope @scope, --interactive
18
+ No arguments after init starts the interactive wizard.
19
+ add, setup, generate, doctor, status and replace are not implemented.
20
+ This alpha is not a complete production CLI. Provider sync and crash recovery
21
+ remain unfinished. It requires Node 24 and pnpm 12.9.1 for validation.
22
+ `;
23
+
24
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
25
+ console.log(help);
26
+ } else if (args[0] === '--version' || args[0] === '-v') {
27
+ console.log(pkg.version);
28
+ } else if (args[0] === 'init') {
29
+ if (args.includes('--help') || args.includes('-h')) console.log(help);
30
+ else {
31
+ process.argv = [...process.argv.slice(0, 2), ...(args.length === 1 ? ['--interactive'] : args.slice(1))];
32
+ await import('./commands/init/index.mjs');
33
+ }
34
+ } else {
35
+ console.error(`Command ${JSON.stringify(args[0])} is not available. Run alice --help.`);
36
+ process.exitCode = 1;
37
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './apps/cli/src/index.mjs';
@@ -0,0 +1,128 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { promises as fs } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const template = fileURLToPath(new URL('../templates/base/', import.meta.url));
7
+ const excluded = new Set(['node_modules', 'dist', 'coverage', '.turbo', '.tools', '.cache', '.git', 'playwright-report', 'test-results']);
8
+ const digest = (data) => createHash('sha256').update(data).digest('hex');
9
+
10
+ export function identity(name, scope) {
11
+ if (typeof name !== 'string' || !name.trim() || /[\x00-\x1f\x7f]/.test(name)) throw new Error('Provide a non-empty project name without control characters.');
12
+ const slug = name.trim().toLowerCase().replace(/[\s_]+/g, '-').replace(/[^a-z0-9-]/g, '').replace(/-+/g, '-').replace(/^-|-$/g, '');
13
+ if (!slug || slug.length > 100) throw new Error('Project name must produce a valid slug of at most 100 characters.');
14
+ const selectedScope = scope ?? `@${slug}`;
15
+ if (!/^@[a-z0-9][a-z0-9-]{0,99}$/.test(selectedScope)) throw new Error('Scope must be @ followed by a lowercase alphanumeric/hyphen name.');
16
+ return { name: name.trim(), slug, scope: selectedScope };
17
+ }
18
+
19
+ async function assertTarget(target) {
20
+ const parent = path.dirname(target);
21
+ if (await fs.realpath(parent) !== parent) throw new Error('Target parent must not contain symlink aliases.');
22
+ const parentStat = await fs.stat(parent);
23
+ if (!parentStat.isDirectory()) throw new Error('Target parent must be an existing directory.');
24
+ try {
25
+ const stat = await fs.lstat(target);
26
+ if (!stat.isDirectory() || stat.isSymbolicLink() || (await fs.readdir(target)).length) throw new Error('Target must be absent or an empty directory. Existing content is never overwritten.');
27
+ return true;
28
+ } catch (error) {
29
+ if (error.code === 'ENOENT') return false;
30
+ throw error;
31
+ }
32
+ }
33
+
34
+ export async function planFoundation({ target, name, scope, setupIntent }) {
35
+ const destination = path.resolve(target);
36
+ const project = identity(name ?? path.basename(destination), scope);
37
+ await assertTarget(destination);
38
+ const files = [];
39
+ async function walk(relative = '') {
40
+ const entries = await fs.readdir(path.join(template, relative), { withFileTypes: true });
41
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name, 'en'))) {
42
+ if (excluded.has(entry.name) || (entry.name.startsWith('.env') && entry.name !== '.env.example') || entry.name.endsWith('.tsbuildinfo')) continue;
43
+ const file = path.join(relative, entry.name);
44
+ if (entry.isSymbolicLink()) throw new Error('Template symlinks are unsupported.');
45
+ if (entry.isDirectory()) { await walk(file); continue; }
46
+ let content = await fs.readFile(path.join(template, file), 'utf8');
47
+ // These tokens belong only to the bundled reference, never to user files.
48
+ content = content.replaceAll('@alice-reference/', `${project.scope}/`);
49
+ if (file === 'package.json') {
50
+ const pkg = JSON.parse(content);
51
+ pkg.name = project.slug;
52
+ for (const section of ['dependencies', 'devDependencies', 'peerDependencies']) {
53
+ if (pkg[section]) pkg[section] = Object.fromEntries(Object.entries(pkg[section]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
54
+ }
55
+ content = `${JSON.stringify(pkg, null, 2)}\n`;
56
+ }
57
+ if (file === 'alice.json') {
58
+ const manifest = JSON.parse(content);
59
+ manifest.project = project;
60
+ content = `${JSON.stringify(manifest, null, 2).replace(/\[\s+"development"\s+\]/g, '["development"]')}\n`;
61
+ }
62
+ files.push({ path: file, content });
63
+ }
64
+ }
65
+ await walk();
66
+ files.push({ path: '.env', content: 'NODE_ENV=development\n' });
67
+ if (setupIntent) {
68
+ if (!['local', 'hosted'].includes(setupIntent.infrastructurePreference) || !['local-docker', 'existing-self-hosted', 'cloud'].includes(setupIntent.infisical)) throw new Error('Unsupported setup intent.');
69
+ files.push({ path: path.join('documentation', 'setup-intent.json'), content: `${JSON.stringify({ status: 'pending-setup', infrastructurePreference: setupIntent.infrastructurePreference, infisical: setupIntent.infisical }, null, 2)}\n` });
70
+ }
71
+ const manifest = files.find((file) => file.path === 'alice.json');
72
+ if (!manifest) throw new Error('Reference manifest is missing.');
73
+ const packageNames = files.filter((file) => /^packages[/\\][^/\\]+[/\\]package.json$/.test(file.path)).map((file) => JSON.parse(file.content).name).sort();
74
+ if (JSON.stringify(packageNames) !== JSON.stringify([`${project.scope}/env`, `${project.scope}/typescript`].sort())) throw new Error('Template must contain exactly the two foundation packages.');
75
+ return { target: destination, project, files: [...files.filter((file) => file !== manifest), manifest] };
76
+ }
77
+
78
+ export async function generateFoundation(options, { validate = async () => {} } = {}) {
79
+ const plan = await planFoundation(options);
80
+ const targetExisted = await assertTarget(plan.target);
81
+ const written = [];
82
+ const directories = [];
83
+ async function ensureDirectory(directory) {
84
+ if (directory === path.dirname(plan.target)) return;
85
+ try { await fs.mkdir(directory); directories.push(directory); }
86
+ catch (error) {
87
+ if (error.code === 'ENOENT') { await ensureDirectory(path.dirname(directory)); await ensureDirectory(directory); }
88
+ else if (error.code === 'EEXIST') {
89
+ const stat = await fs.lstat(directory);
90
+ if (!stat.isDirectory() || stat.isSymbolicLink() || await fs.realpath(directory) !== directory) throw new Error('Generation directory changed or contains a symlink.');
91
+ } else throw error;
92
+ }
93
+ }
94
+ try {
95
+ if (!targetExisted) { await fs.mkdir(plan.target); directories.push(plan.target); }
96
+ for (const file of plan.files) {
97
+ if (file.path === 'alice.json') {
98
+ for (const created of written) {
99
+ if (digest(await fs.readFile(created.destination)) !== created.hash) throw new Error('Generated foundation changed before manifest commit.');
100
+ }
101
+ await validate(plan.target, plan);
102
+ for (const created of written) {
103
+ if (digest(await fs.readFile(created.destination)) !== created.hash) throw new Error('Generated foundation changed during validation.');
104
+ }
105
+ }
106
+ const destination = path.join(plan.target, file.path);
107
+ await ensureDirectory(path.dirname(destination));
108
+ // Exclusive creation prevents overwriting content introduced after planning.
109
+ const handle = await fs.open(destination, 'wx', file.path === '.env' ? 0o600 : 0o644);
110
+ written.push({ destination, hash: digest(file.content) });
111
+ try { await handle.writeFile(file.content); } finally { await handle.close(); }
112
+ }
113
+ return plan;
114
+ } catch (error) {
115
+ const retained = [];
116
+ for (const file of written.reverse()) {
117
+ try {
118
+ if (digest(await fs.readFile(file.destination)) === file.hash) await fs.unlink(file.destination);
119
+ else retained.push(file.destination);
120
+ } catch (recovery) { if (recovery.code !== 'ENOENT') retained.push(file.destination); }
121
+ }
122
+ for (const directory of directories.reverse()) {
123
+ try { await fs.rmdir(directory); } catch (recovery) { if (recovery.code !== 'ENOENT') retained.push(directory); }
124
+ }
125
+ if (retained.length) throw new Error('Generation failed; recovery retained changed or non-empty paths. Inspect the target before retrying.', { cause: error });
126
+ throw error;
127
+ }
128
+ }
@@ -0,0 +1,7 @@
1
+ # Alice reference templates
2
+
3
+ `base/` is the standalone minimal foundation reference for `alice init`. It contains no apps and exactly the TypeScript and env workspace packages. Run its commands from inside that folder; Alice CLI's documentation site remains a separate workspace under `docs/`.
4
+
5
+ The reference has a concrete `@alice-reference` identity and a frozen lockfile. The internal generator in `scripts/` can preview and create a renamed reference with caught-failure recovery and manifest-last creation. The final manifest schema, interactive onboarding, crash recovery, and provider setup remain CLI work. See [generator boundaries](../scripts/README.md).
6
+
7
+ Start with [the base README](base/README.md) and [validation notes](base/documentation/validation.md).
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
@@ -0,0 +1,2 @@
1
+ # Local runtime mode. Never commit real credentials.
2
+ NODE_ENV=development
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.png binary
3
+ *.jpg binary
@@ -0,0 +1,31 @@
1
+ name: Foundation validation
2
+ on:
3
+ pull_request:
4
+ push:
5
+ workflow_dispatch:
6
+ permissions:
7
+ contents: read
8
+ concurrency:
9
+ group: foundation-${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+ jobs:
12
+ validate:
13
+ runs-on: ubuntu-24.04
14
+ timeout-minutes: 15
15
+ env:
16
+ HUSKY: "0"
17
+ TURBO_TELEMETRY_DISABLED: "1"
18
+ steps:
19
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20
+ with:
21
+ persist-credentials: false
22
+ - uses: pnpm/action-setup@7088e561eb65bb68695d245aa206f005ef30921d # v4.1.0
23
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
24
+ with:
25
+ node-version-file: .node-version
26
+ cache: pnpm
27
+ - run: pnpm install --frozen-lockfile
28
+ - run: pnpm setup:local
29
+ - run: pnpm validate
30
+ - run: pnpm security:tools
31
+ - run: pnpm validate:security
@@ -0,0 +1,7 @@
1
+ title = "Alice reference secret detection"
2
+ [extend]
3
+ useDefault = true
4
+
5
+ [[allowlists]]
6
+ description = "Third-party dependencies and verified external tool cache"
7
+ paths = ['''(^|/)node_modules/''', '''(^|/)\.tools/''']
@@ -0,0 +1,2 @@
1
+ pnpm exec lint-staged
2
+ pnpm security:staged
@@ -0,0 +1,2 @@
1
+ pnpm typecheck
2
+ pnpm test
@@ -0,0 +1,11 @@
1
+ # Reference workspace instructions
2
+
3
+ This is the minimal repository Alice init should create. Keep exactly two initial packages: typescript and env. Add no product apps/services without explicit selection.
4
+
5
+ Use pnpm, Turbo, TypeScript, and Ultracite/Biome. Do not add ESLint or Prettier. Use project-scoped workspace imports and local @/ aliases. Node types belong only to Node/tooling configs.
6
+
7
+ The shared env package contains base helpers only. Define capability keys beside their owning app/package, compose the base there, and pass explicit runtime values. Keep server and public entry points separate. Never put secrets into tracked files, output, or alice.json.
8
+
9
+ Read documentation/architecture.md and documentation/validation.md before changes. Preserve user source and unrelated configuration. Run applicable checks; do not label unconfigured Infisical, unavailable checks, or absent app E2E as verified production features.
10
+
11
+ This is a reference template, not an implementation of the Alice CLI. The manifest is a candidate fixture pending the final CLI schema.
@@ -0,0 +1,26 @@
1
+ # Alice reference foundation
2
+
3
+ A standalone reference for the minimal workspace generated by Alice init: no apps and exactly two packages, @alice-reference/typescript and @alice-reference/env.
4
+
5
+ Use Node 24.21.0 and pnpm 12.9.1. From this directory:
6
+
7
+ ~~~sh
8
+ pnpm install --frozen-lockfile
9
+ pnpm setup:local
10
+ pnpm security:tools
11
+ pnpm validate
12
+ pnpm validate:security
13
+ ~~~
14
+
15
+ The local setup creates one ignored root .env with NODE_ENV=development and preserves an existing file. The committed .env.example contains no secrets. A Git repository is needed for hooks; this template is deliberately not a nested Git repository inside Alice CLI. Run git init when using it as a standalone checkout, then pnpm prepare.
16
+
17
+ ## Packages
18
+
19
+ - packages/typescript: strict shared JSON presets, explicit runtime types and local aliases.
20
+ - packages/env: runtime-neutral shared creation policy and server base helper. No database/auth/email schema is centralized here.
21
+
22
+ There is no dev server or deployable product yet. Browser E2E is explicitly not applicable. Future app adapters register their own Playwright suites; they must not inherit a successful empty-suite result.
23
+
24
+ See documentation/architecture.md, documentation/environment.md, documentation/infisical.md, and documentation/validation.md. Alice.json describes the proposed reference identity, not provider connection readiness or a finalized machine schema. Infisical has not been connected and no services are deployed.
25
+
26
+ Recorded checks and limitations are in [validation results](documentation/validation-results.md).
@@ -0,0 +1,38 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "project": {
4
+ "name": "Alice Reference",
5
+ "slug": "alice-reference",
6
+ "scope": "@alice-reference"
7
+ },
8
+ "workspace": {
9
+ "packageManager": "pnpm",
10
+ "implementation": "pnpm",
11
+ "taskRunner": "turbo",
12
+ "language": "typescript"
13
+ },
14
+ "tooling": {
15
+ "quality": "ultracite-biome",
16
+ "gitHooks": "husky",
17
+ "stagedChecks": "lint-staged",
18
+ "unitTesting": "vitest",
19
+ "e2eTesting": "playwright",
20
+ "ci": "github-actions"
21
+ },
22
+ "apps": {},
23
+ "packages": {
24
+ "env": {
25
+ "provider": "infisical",
26
+ "engine": "t3-env",
27
+ "validator": "zod",
28
+ "strategy": "runtime-injection"
29
+ }
30
+ },
31
+ "environments": {
32
+ "default": "development",
33
+ "configured": ["development"]
34
+ },
35
+ "infrastructure": {},
36
+ "integrations": {},
37
+ "deployments": {}
38
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
3
+ "extends": ["./tooling/ultracite/core/biome.jsonc"],
4
+ "files": {
5
+ "includes": [
6
+ "!**/node_modules",
7
+ "!**/dist",
8
+ "!**/coverage",
9
+ "!**/.turbo",
10
+ "!**/.tools",
11
+ "!tooling/ultracite/core",
12
+ "!pnpm-lock.yaml"
13
+ ]
14
+ },
15
+ "formatter": {
16
+ "indentStyle": "space",
17
+ "indentWidth": 2,
18
+ "lineWidth": 100
19
+ },
20
+ "javascript": {
21
+ "formatter": {
22
+ "quoteStyle": "double",
23
+ "semicolons": "always",
24
+ "trailingCommas": "all"
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,13 @@
1
+ # Foundation architecture
2
+
3
+ No apps, database, auth, Redis, Mailpit, or other product capabilities are installed. Exactly packages/typescript and packages/env exist. Root tooling/test/CI files are not extra workspace packages.
4
+
5
+ This reference uses a concrete @alice-reference identity. A future init adapter must substitute validated project names structurally, then regenerate and validate the lockfile/manifest; do not blindly replace strings in user source.
6
+
7
+ Built env server/client exports are separate. Shared source has no Node ambient types. Node is selected for tooling/tests only. Local @/ is resolved by tsdown/Vitest; cross-workspace imports use explicit package exports and declared workspace dependencies.
8
+
9
+ The shared base validates NODE_ENV (development, test, production). Provider secrets contexts (development/testing/staging/production) are independent; staging builds normally use NODE_ENV=production. No ALICE_ENV is introduced.
10
+
11
+ Alice.json is a candidate reference manifest, not a finalized schema. Its env provider identifies the selected direction; it does not mean Infisical authentication or remote environments are configured. No secret values belong in it.
12
+
13
+ For future generation: validate a whole plan before writes, preserve user source, roll back local failures, and write alice.json last. This reference does not implement that CLI transaction engine.
@@ -0,0 +1,24 @@
1
+ # Local definitions and root values
2
+
3
+ Run pnpm setup:local once. It creates an ignored root .env with NODE_ENV=development if absent. It never overwrites existing values. .env.example is committed documentation; do not store real secrets in it.
4
+
5
+ Future server code composes locally:
6
+
7
+ ~~~ts
8
+ import { createBaseEnv, createEnv, envValidationPolicy } from "@alice-reference/env/server";
9
+ import { z } from "zod";
10
+
11
+ const base = createBaseEnv({ NODE_ENV: process.env.NODE_ENV });
12
+ export const env = createEnv({
13
+ extends: [base],
14
+ server: { DATABASE_URL: z.url() },
15
+ runtimeEnvStrict: { DATABASE_URL: process.env.DATABASE_URL },
16
+ ...envValidationPolicy,
17
+ });
18
+ ~~~
19
+
20
+ That example belongs in the future database/server owner, not packages/env. Use the local @/env/server import from application code. Declare the env workspace dependency and Zod where imported. Client definitions use the client entry point, the selected framework's public prefix, and explicit public values only.
21
+
22
+ The root file is a value source, not a global schema. A future runtime adapter loads/scopes the root values or uses Infisical injection; libraries do not independently load plaintext env files. One root file must not result in every process receiving every secret.
23
+
24
+ Use scoped Infisical environments and explicit sync conflicts. Do not add per-app .env files. Infisical bootstrap credentials need a reviewed separate recovery/storage design; no fake credentials are generated here.