anhedral 0.19.0 → 0.21.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.
- package/README.md +11 -7
- package/dist/capability-catalog.d.ts +1 -1
- package/dist/capability-catalog.js +1 -1
- package/dist/capability-command.d.ts +8 -0
- package/dist/capability-command.js +3 -3
- package/dist/capability-editor.js +21 -1
- package/dist/cli-arguments.js +2 -0
- package/dist/cli-commands.js +4 -4
- package/dist/cli-errors.js +3 -5
- package/dist/command-schema.js +35 -39
- package/dist/completion.js +0 -3
- package/dist/credential-helper.d.ts +2 -0
- package/dist/credential-helper.js +44 -0
- package/dist/launch.js +4 -2
- package/dist/platform-state.d.ts +2 -1
- package/dist/platform-state.js +5 -4
- package/dist/platforms/tanstack.js +0 -3
- package/dist/registry/usage.js +2 -1
- package/dist/release-artifact.d.ts +18 -0
- package/dist/release-artifact.js +169 -0
- package/dist/stack-update.d.ts +39 -0
- package/dist/stack-update.js +346 -0
- package/dist/transaction.d.ts +1 -0
- package/dist/transaction.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +1 -1
- package/docs/software-factory.md +29 -1
- package/docs/stack-standard.md +1 -1
- package/docs/ui.md +10 -13
- package/package.json +1 -4
- package/assets/ui/LICENSE.react-native-reusables +0 -21
- package/assets/ui/catalog.json +0 -603
- package/assets/ui/extensions/registry.json +0 -6
- package/dist/ui-catalog.d.ts +0 -24
- package/dist/ui-catalog.js +0 -15
- package/dist/ui-command.d.ts +0 -5
- package/dist/ui-command.js +0 -221
- package/dist/ui-project.d.ts +0 -24
- package/dist/ui-project.js +0 -112
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ cd my-app
|
|
|
13
13
|
pnpm dev
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Init creates `apps/web` and shared tooling with OJ and TanStack Start server rendering/server functions and
|
|
16
|
+
Init creates `apps/web` and shared tooling with OJ and TanStack Start server rendering/server functions and editable shadcn starter components. It does not add an API, database, authentication, storage or payments. Preview with `anhedral init my-app --dry-run --json`; use `--skip-install --no-git` for offline source generation.
|
|
17
17
|
|
|
18
18
|
## Add services
|
|
19
19
|
|
|
@@ -30,16 +30,20 @@ After adding backend, configure `apps/api/.dev.vars` from its example, review th
|
|
|
30
30
|
|
|
31
31
|
Use `anhedral stack list`, `status` and `doctor` to inspect the Anhedral Stack and its additions. These checks describe source completeness, not live provider readiness. Current public generation is web-only. OJ runs development and builds. Historical generators and framework aliases are removed.
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Update an existing project
|
|
34
|
+
|
|
35
|
+
Update your agent plugin through its host and select the matching published CLI version. Preview `anhedral stack update --dry-run --json`, review the returned diffs/conflicts, then apply `anhedral stack update --expect-plan <planId> --json`. Updates preserve authored source and stop on customized-file conflicts or a changed plan. They refresh generated runtime/configuration and deployment provenance without running project scripts or installing dependencies. Validate dependencies and the application separately before upload/deployment. See [the operating workflow](docs/software-factory.md).
|
|
36
|
+
|
|
37
|
+
## Web UI
|
|
38
|
+
|
|
39
|
+
Init includes shadcn Button, Input and Label source with standard `components.json` configuration. Use upstream shadcn directly for more components, or replace the UI with any library. There is no Anhedral UI catalog or CLI wrapper.
|
|
34
40
|
|
|
35
41
|
```sh
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
anhedral ui diff card --web
|
|
39
|
-
anhedral ui doctor --web
|
|
42
|
+
cd apps/web
|
|
43
|
+
pnpm dlx shadcn@4.22.1 add card
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
Review diffs and preserve local edits and required upstream notices. The generated `LICENSE.shadcn` accompanies the bundled starter source. See [web UI](docs/ui.md).
|
|
43
47
|
|
|
44
48
|
## Optional Platform access
|
|
45
49
|
|
|
@@ -34,7 +34,7 @@ export declare const ANHEDRAL_STACK: {
|
|
|
34
34
|
readonly name: "Anhedral Stack";
|
|
35
35
|
readonly foundation: {
|
|
36
36
|
readonly id: "tanstack-start";
|
|
37
|
-
readonly name: "TanStack Start +
|
|
37
|
+
readonly name: "TanStack Start + shadcn";
|
|
38
38
|
readonly targets: readonly ["apps/web/package.json", "apps/web/src/router.tsx", "apps/web/src/server.ts", "apps/web/src/routes/__root.tsx", "apps/web/src/routes/index.tsx"];
|
|
39
39
|
};
|
|
40
40
|
readonly additions: {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { type OutputOptions } from './cli-output.js';
|
|
2
|
+
import { CapabilityEditor } from './capability-editor.js';
|
|
2
3
|
import type { CommandRunner } from './command-types.js';
|
|
4
|
+
export declare function projectRoot(cwd: string, allowRecovery?: boolean): string;
|
|
5
|
+
export declare function readState(e: CapabilityEditor): {
|
|
6
|
+
installed: ("hono" | "database-auth" | "r2" | "stripe")[];
|
|
7
|
+
managedFiles: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
/** Identify the source before any recovery or source mutation. One missing manifest can be an interrupted add. */
|
|
10
|
+
export declare function assertPublicWorkspace(root: string, allowRecovery?: boolean, command?: 'add' | 'stack'): void;
|
|
3
11
|
export declare function runCapabilityCommand(command: 'add' | 'stack', args: string[], output: OutputOptions, run?: CommandRunner): Promise<void>;
|
|
@@ -13,7 +13,7 @@ import { execFile } from './util.js';
|
|
|
13
13
|
import { capabilityReferences } from './capability-references.js';
|
|
14
14
|
import { configureDependencyPatches } from './dependency-patches.js';
|
|
15
15
|
import { composeSourceProvenance } from './composition.js';
|
|
16
|
-
function projectRoot(cwd, allowRecovery = false) {
|
|
16
|
+
export function projectRoot(cwd, allowRecovery = false) {
|
|
17
17
|
let root = realpathSync(cwd);
|
|
18
18
|
for (;;) {
|
|
19
19
|
if (existsSync(path.join(root, 'anhedral.json')) ||
|
|
@@ -28,7 +28,7 @@ function projectRoot(cwd, allowRecovery = false) {
|
|
|
28
28
|
}
|
|
29
29
|
throw Error('No Anhedral workspace found. Select a generated project with --cwd.');
|
|
30
30
|
}
|
|
31
|
-
function readState(e) {
|
|
31
|
+
export function readState(e) {
|
|
32
32
|
const project = e.json('anhedral.json');
|
|
33
33
|
const state = project.capabilities ?? { schemaVersion: 1, installed: [], managedFiles: {} };
|
|
34
34
|
if (state.schemaVersion !== 1 ||
|
|
@@ -54,7 +54,7 @@ function publicScopeError(command = 'add') {
|
|
|
54
54
|
return commandArgumentError(command, 'The CLI edits only the Anhedral Stack: TanStack Start with OJ and shadcn.');
|
|
55
55
|
}
|
|
56
56
|
/** Identify the source before any recovery or source mutation. One missing manifest can be an interrupted add. */
|
|
57
|
-
function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
57
|
+
export function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
58
58
|
const editor = new CapabilityEditor(root, {});
|
|
59
59
|
const recovering = allowRecovery && existsSync(path.join(root, '.anhedral-journal.json'));
|
|
60
60
|
const hasWeb = existsSync(path.join(root, 'apps/web/package.json'));
|
|
@@ -2,7 +2,7 @@ import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { existsSync, lstatSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { parse, modify, applyEdits } from 'jsonc-parser';
|
|
5
|
+
import { parse, visit, modify, applyEdits } from 'jsonc-parser';
|
|
6
6
|
export const fingerprint = (source) => createHash('sha256').update(source).digest('hex');
|
|
7
7
|
/** A bounded, read-only overlay until every capability has passed preflight. */
|
|
8
8
|
export class CapabilityEditor {
|
|
@@ -52,6 +52,26 @@ export class CapabilityEditor {
|
|
|
52
52
|
const value = parse(source, errors, { allowTrailingComma: true });
|
|
53
53
|
if (errors.length || !value || typeof value !== 'object' || Array.isArray(value))
|
|
54
54
|
throw Error(`Invalid JSON/JSONC in ${relative}.`);
|
|
55
|
+
// JSON modification targets the first property while runtime parsers use the last.
|
|
56
|
+
// Compare decoded keys in each object so escaped aliases cannot bypass this guard.
|
|
57
|
+
const objects = [];
|
|
58
|
+
let duplicate = false;
|
|
59
|
+
visit(source, {
|
|
60
|
+
onObjectBegin() {
|
|
61
|
+
objects.push(new Set());
|
|
62
|
+
},
|
|
63
|
+
onObjectProperty(property) {
|
|
64
|
+
const keys = objects.at(-1);
|
|
65
|
+
if (keys.has(property))
|
|
66
|
+
duplicate = true;
|
|
67
|
+
keys.add(property);
|
|
68
|
+
},
|
|
69
|
+
onObjectEnd() {
|
|
70
|
+
objects.pop();
|
|
71
|
+
},
|
|
72
|
+
}, { allowTrailingComma: true });
|
|
73
|
+
if (duplicate)
|
|
74
|
+
throw Error(`Duplicate JSON object keys in ${relative}; preserve and reconcile them before editing source.`);
|
|
55
75
|
return value;
|
|
56
76
|
}
|
|
57
77
|
create(relative, source) {
|
package/dist/cli-arguments.js
CHANGED
|
@@ -75,6 +75,8 @@ export function globalArguments(input) {
|
|
|
75
75
|
function definitionFor(command) {
|
|
76
76
|
const definition = commandDefinition(command);
|
|
77
77
|
if (!definition) {
|
|
78
|
+
if (command === 'ui')
|
|
79
|
+
throw new CliArgumentError('The Anhedral UI command has been retired. Use shadcn directly or your preferred UI library.', 'Run pnpm dlx shadcn@4.22.1 add <component> from apps/web, or see https://ui.shadcn.com/docs/installation/tanstack.', 'UNKNOWN_COMMAND');
|
|
78
80
|
const recommendation = suggest(command, [...Object.keys(COMMANDS), 'help']);
|
|
79
81
|
const name = /^[a-z-]{1,32}$/.test(command) ? `: ${command}` : '';
|
|
80
82
|
throw new CliArgumentError(`Unknown command${name}.${recommendation ? ` Did you mean ${recommendation}?` : ''}`, 'Run anhedral --help.', 'UNKNOWN_COMMAND');
|
package/dist/cli-commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runPlatformCommand } from './platform-command.js';
|
|
2
|
+
import { runStackUpdate } from './stack-update.js';
|
|
2
3
|
import { runCapabilityCommand } from './capability-command.js';
|
|
3
|
-
import { runAnhedralUiCommand } from './ui-command.js';
|
|
4
4
|
import { commandArgumentError } from './cli-arguments.js';
|
|
5
5
|
import { createReporter } from './cli-output.js';
|
|
6
6
|
import { scaffoldLaunchProject, parseAnhedralStackOptions } from './launch.js';
|
|
@@ -29,12 +29,12 @@ export async function runCommand(command, args, output) {
|
|
|
29
29
|
'logs',
|
|
30
30
|
].includes(command))
|
|
31
31
|
return runPlatformCommand(command, args, output);
|
|
32
|
+
if (command === 'stack' && commandArguments('stack', args).positional[0] === 'update')
|
|
33
|
+
return runStackUpdate(args, output);
|
|
32
34
|
if (command === 'add' || command === 'stack')
|
|
33
35
|
return runCapabilityCommand(command, args, output);
|
|
34
|
-
if (command === 'ui')
|
|
35
|
-
return runAnhedralUiCommand(args, output);
|
|
36
36
|
if (command !== 'init')
|
|
37
|
-
throw commandArgumentError(command, 'Use init, add
|
|
37
|
+
throw commandArgumentError(command, 'Use init, add or stack. Run anhedral --help.');
|
|
38
38
|
let options;
|
|
39
39
|
try {
|
|
40
40
|
options = parseAnhedralStackOptions(args);
|
package/dist/cli-errors.js
CHANGED
|
@@ -48,11 +48,9 @@ export function describeFailure(error, command) {
|
|
|
48
48
|
? 'GENERATION_FAILED'
|
|
49
49
|
: command === 'add' || command === 'stack'
|
|
50
50
|
? 'CAPABILITY_COMMAND_FAILED'
|
|
51
|
-
: command
|
|
52
|
-
? '
|
|
53
|
-
:
|
|
54
|
-
? 'PLATFORM_COMMAND_FAILED'
|
|
55
|
-
: 'INTERNAL_ERROR';
|
|
51
|
+
: ['login', 'logout', 'whoami', 'link', 'unlink', 'source', 'deploy'].includes(command ?? '')
|
|
52
|
+
? 'PLATFORM_COMMAND_FAILED'
|
|
53
|
+
: 'INTERNAL_ERROR';
|
|
56
54
|
return {
|
|
57
55
|
error: error instanceof Error ? error.message : String(error),
|
|
58
56
|
code,
|
package/dist/command-schema.js
CHANGED
|
@@ -463,9 +463,42 @@ export const COMMANDS = {
|
|
|
463
463
|
},
|
|
464
464
|
stack: {
|
|
465
465
|
description: 'Inspect the Anhedral Stack and its three optional additions.',
|
|
466
|
-
usage: 'stack <list|status|doctor>',
|
|
467
|
-
options: [
|
|
466
|
+
usage: 'stack <list|status|doctor|update>',
|
|
467
|
+
options: [
|
|
468
|
+
{ flag: '--dry-run', description: 'Preview bounded source updates without writes.' },
|
|
469
|
+
{
|
|
470
|
+
flag: '--offline',
|
|
471
|
+
description: 'Update source without resolving a published deployment artifact.',
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
flag: '--expect-plan',
|
|
475
|
+
arity: 'required',
|
|
476
|
+
value: 'sha256',
|
|
477
|
+
description: 'Apply only the reviewed source update plan.',
|
|
478
|
+
},
|
|
479
|
+
],
|
|
468
480
|
children: {
|
|
481
|
+
update: {
|
|
482
|
+
description: 'Preview or apply bounded source updates without executing project scripts.',
|
|
483
|
+
usage: 'stack update [--dry-run] [--expect-plan <sha256>]',
|
|
484
|
+
options: [
|
|
485
|
+
{
|
|
486
|
+
flag: '--dry-run',
|
|
487
|
+
description: 'Show exact source changes and conflicts without writes.',
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
flag: '--offline',
|
|
491
|
+
description: 'Skip published artifact resolution; leave deployment provenance pending.',
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
flag: '--expect-plan',
|
|
495
|
+
arity: 'required',
|
|
496
|
+
value: 'sha256',
|
|
497
|
+
description: 'Apply only if the reviewed update plan still matches.',
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
examples: ['stack update --dry-run --json', 'stack update --json'],
|
|
501
|
+
},
|
|
469
502
|
list: {
|
|
470
503
|
description: 'Show the Anhedral Stack foundation and optional additions.',
|
|
471
504
|
usage: 'stack list',
|
|
@@ -488,43 +521,6 @@ export const COMMANDS = {
|
|
|
488
521
|
examples: ['stack list', 'stack status --json', 'stack doctor'],
|
|
489
522
|
note: 'Installed source is not proof of live provider activation.',
|
|
490
523
|
},
|
|
491
|
-
ui: {
|
|
492
|
-
description: 'Source-owned web UI for the Anhedral Stack.',
|
|
493
|
-
usage: 'ui <init|add|list|diff|doctor> [components...] [options]',
|
|
494
|
-
options: [
|
|
495
|
-
{ flag: '--web', description: 'Select the Anhedral Stack web application.' },
|
|
496
|
-
{ flag: '--dry-run', description: 'Show the installer plan without writes or network.' },
|
|
497
|
-
],
|
|
498
|
-
children: Object.fromEntries(['init', 'add', 'list', 'diff', 'doctor'].map((action) => [
|
|
499
|
-
action,
|
|
500
|
-
{
|
|
501
|
-
description: {
|
|
502
|
-
init: 'Initialize Anhedral UI configuration.',
|
|
503
|
-
add: 'Install selected UI components.',
|
|
504
|
-
list: 'List available Anhedral Stack web components.',
|
|
505
|
-
diff: 'Inspect differences for selected UI components.',
|
|
506
|
-
doctor: 'Check UI configuration.',
|
|
507
|
-
}[action],
|
|
508
|
-
usage: `ui ${action}${['add', 'diff'].includes(action) ? ' <components...>' : ''} [options]`,
|
|
509
|
-
options: [
|
|
510
|
-
{ flag: '--web', description: 'Select the Anhedral Stack web application.' },
|
|
511
|
-
{ flag: '--dry-run', description: 'Preview without writes or network.' },
|
|
512
|
-
],
|
|
513
|
-
positional: {
|
|
514
|
-
name: 'components',
|
|
515
|
-
min: ['add', 'diff'].includes(action) ? 1 : 0,
|
|
516
|
-
max: ['add', 'diff'].includes(action) ? 50 : 0,
|
|
517
|
-
kind: 'component',
|
|
518
|
-
},
|
|
519
|
-
examples: [
|
|
520
|
-
`ui ${action}${['add', 'diff'].includes(action) ? ' button --web' : ''}`,
|
|
521
|
-
`ui ${action}${['add', 'diff'].includes(action) ? ' button --web' : ''} --json`,
|
|
522
|
-
],
|
|
523
|
-
},
|
|
524
|
-
])),
|
|
525
|
-
examples: ['ui list', 'ui add button --web', 'ui diff button', 'ui doctor'],
|
|
526
|
-
note: 'Web component installation uses the pinned official shadcn CLI. No automatic overwrite or provider operations.',
|
|
527
|
-
},
|
|
528
524
|
init: {
|
|
529
525
|
description: 'Create the Anhedral Stack: web UI first, then add backend, storage and payments.',
|
|
530
526
|
usage: 'init [directory] [options]',
|
package/dist/completion.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { COMMANDS, GLOBAL_OPTIONS, commandOptions, commandTopic, } from './command-schema.js';
|
|
2
2
|
import { PUBLIC_STACK_ADDITIONS } from './capability-catalog.js';
|
|
3
|
-
import { UI_CATALOG } from './ui-catalog.js';
|
|
4
3
|
/** Quote data for shell source. Completion never evaluates user input. */
|
|
5
4
|
function quote(value) {
|
|
6
5
|
return "'" + value.replaceAll("'", "'\"'\"'") + "'";
|
|
@@ -25,8 +24,6 @@ function choices(definition) {
|
|
|
25
24
|
const positional = definition.positional;
|
|
26
25
|
if (positional?.kind === 'capability')
|
|
27
26
|
return PUBLIC_STACK_ADDITIONS;
|
|
28
|
-
if (positional?.kind === 'component')
|
|
29
|
-
return UI_CATALOG.components.filter((entry) => entry.web).map((entry) => entry.name);
|
|
30
27
|
return positional?.choices ?? [];
|
|
31
28
|
}
|
|
32
29
|
function optionCase(context, option) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { lstat, realpath } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, join, parse } from 'node:path';
|
|
3
|
+
import { CliFailure } from './cli-errors.js';
|
|
4
|
+
const unavailable = () => new CliFailure('A trusted Linux Secret Service helper is unavailable.', 'PLATFORM_ACCESS_FAILED', 'Install a system-owned secret-tool, explicitly select a trusted system helper with ANHEDRAL_CLI_SECRET_TOOL_PATH, or use --credential-file.', 'context', false);
|
|
5
|
+
async function safePath(path, executable) {
|
|
6
|
+
// Validate the original chain as well as the canonical chain: an untrusted
|
|
7
|
+
// symlink or writable parent must not redirect a privileged helper lookup.
|
|
8
|
+
let current = parse(path).root;
|
|
9
|
+
const parts = path.slice(current.length).split('/').filter(Boolean);
|
|
10
|
+
for (const [index, part] of parts.entries()) {
|
|
11
|
+
current = join(current, part);
|
|
12
|
+
const entry = await lstat(current);
|
|
13
|
+
if (entry.uid !== 0 || (!entry.isSymbolicLink() && (entry.mode & 0o022) !== 0))
|
|
14
|
+
throw unavailable();
|
|
15
|
+
const last = index === parts.length - 1;
|
|
16
|
+
if (!entry.isSymbolicLink() && !(last && executable ? entry.isFile() : entry.isDirectory()))
|
|
17
|
+
throw unavailable();
|
|
18
|
+
if (last && executable && !entry.isSymbolicLink() && (entry.mode & 0o111) === 0)
|
|
19
|
+
throw unavailable();
|
|
20
|
+
}
|
|
21
|
+
const root = await lstat(parse(path).root);
|
|
22
|
+
if (root.uid !== 0 || (root.mode & 0o022) !== 0)
|
|
23
|
+
throw unavailable();
|
|
24
|
+
}
|
|
25
|
+
/** Never resolve credential infrastructure from project/package-manager PATH. */
|
|
26
|
+
export async function trustedLinuxCredentialHelper(explicit = process.env.ANHEDRAL_CLI_SECRET_TOOL_PATH) {
|
|
27
|
+
const candidates = explicit === undefined ? ['/usr/bin/secret-tool', '/bin/secret-tool'] : [explicit];
|
|
28
|
+
for (const candidate of candidates) {
|
|
29
|
+
try {
|
|
30
|
+
if (!isAbsolute(candidate) || /[\0\r\n]/.test(candidate) || dirname(candidate) === candidate)
|
|
31
|
+
throw unavailable();
|
|
32
|
+
await safePath(candidate, true);
|
|
33
|
+
const canonical = await realpath(candidate);
|
|
34
|
+
await safePath(canonical, true);
|
|
35
|
+
return canonical;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// An explicit selection never silently falls back to a different helper.
|
|
39
|
+
if (explicit !== undefined)
|
|
40
|
+
throw unavailable();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
throw unavailable();
|
|
44
|
+
}
|
package/dist/launch.js
CHANGED
|
@@ -102,7 +102,7 @@ function documentation(root, name) {
|
|
|
102
102
|
put(root, 'README.md', `# ${name}
|
|
103
103
|
|
|
104
104
|
Anhedral Stack: web UI powered by OJ and TanStack Start server rendering/server functions
|
|
105
|
-
and
|
|
105
|
+
and editable shadcn components.
|
|
106
106
|
Only the web application is created initially. No backend or provider is provisioned.
|
|
107
107
|
|
|
108
108
|
## Develop
|
|
@@ -110,7 +110,9 @@ Only the web application is created initially. No backend or provider is provisi
|
|
|
110
110
|
Use the Node/pnpm versions in package.json. Run pnpm install if generation skipped
|
|
111
111
|
installation, then pnpm dev and open http://localhost:3000. Run pnpm check and
|
|
112
112
|
pnpm audit:deps before deployment. Editable routes live in apps/web/src/routes.
|
|
113
|
-
Use
|
|
113
|
+
Use cd apps/web && pnpm dlx shadcn@4.22.1 add card for more shadcn components.
|
|
114
|
+
Shadcn is the default, not a restriction: use any UI library and preserve local edits.
|
|
115
|
+
Keep LICENSE.shadcn with the copied starter components.
|
|
114
116
|
|
|
115
117
|
## Add services progressively
|
|
116
118
|
|
package/dist/platform-state.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliFailure } from './cli-errors.js';
|
|
2
|
+
import { trustedLinuxCredentialHelper } from './credential-helper.js';
|
|
2
3
|
export type PlatformFailureCategory = ConstructorParameters<typeof CliFailure>[3];
|
|
3
4
|
export declare const platformFailure: (message: string, nextAction?: string, category?: PlatformFailureCategory, retryable?: boolean) => CliFailure;
|
|
4
5
|
export declare function platformOrigin(value?: string): string;
|
|
@@ -12,4 +13,4 @@ export interface SecretStore {
|
|
|
12
13
|
clear(): Promise<void>;
|
|
13
14
|
}
|
|
14
15
|
export declare function runCredentialProcess(binary: string, args: string[], input?: string, timeoutMs?: number): Promise<string>;
|
|
15
|
-
export declare function secretStore(origin: string, file?: string, runProcess?: typeof runCredentialProcess, platform?: NodeJS.Platform): SecretStore;
|
|
16
|
+
export declare function secretStore(origin: string, file?: string, runProcess?: typeof runCredentialProcess, platform?: NodeJS.Platform, linuxHelper?: typeof trustedLinuxCredentialHelper): SecretStore;
|
package/dist/platform-state.js
CHANGED
|
@@ -4,6 +4,7 @@ import { dirname, join } from 'node:path';
|
|
|
4
4
|
import { lstat, mkdir, open, readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { CliArgumentError } from './cli-arguments.js';
|
|
6
6
|
import { CliFailure } from './cli-errors.js';
|
|
7
|
+
import { trustedLinuxCredentialHelper } from './credential-helper.js';
|
|
7
8
|
export const platformFailure = (message, nextAction = 'Run anhedral login --help.', category = 'context', retryable = false) => new CliFailure(message, 'PLATFORM_ACCESS_FAILED', nextAction, category, retryable);
|
|
8
9
|
export function platformOrigin(value = 'https://platform.anhedral.com') {
|
|
9
10
|
let url;
|
|
@@ -140,7 +141,7 @@ export function runCredentialProcess(binary, args, input = '', timeoutMs = 30000
|
|
|
140
141
|
child.stdin.end(input);
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
export function secretStore(origin, file, runProcess = runCredentialProcess, platform = process.platform) {
|
|
144
|
+
export function secretStore(origin, file, runProcess = runCredentialProcess, platform = process.platform, linuxHelper = trustedLinuxCredentialHelper) {
|
|
144
145
|
if (file && platform === 'win32')
|
|
145
146
|
throw platformFailure('Secure Windows credential storage is not implemented. Use macOS Keychain or Linux Secret Service for this preview.');
|
|
146
147
|
if (file)
|
|
@@ -203,7 +204,7 @@ export function secretStore(origin, file, runProcess = runCredentialProcess, pla
|
|
|
203
204
|
if (platform === 'linux')
|
|
204
205
|
return {
|
|
205
206
|
read: async () => {
|
|
206
|
-
const value = await runProcess(
|
|
207
|
+
const value = await runProcess(await linuxHelper(), [
|
|
207
208
|
'lookup',
|
|
208
209
|
'service',
|
|
209
210
|
'dev.anhedral.cli.v1',
|
|
@@ -213,10 +214,10 @@ export function secretStore(origin, file, runProcess = runCredentialProcess, pla
|
|
|
213
214
|
return value ? JSON.parse(value) : null;
|
|
214
215
|
},
|
|
215
216
|
write: async (data) => {
|
|
216
|
-
await runProcess(
|
|
217
|
+
await runProcess(await linuxHelper(), ['store', '--label=Anhedral CLI', 'service', 'dev.anhedral.cli.v1', 'origin', account], JSON.stringify(data));
|
|
217
218
|
},
|
|
218
219
|
clear: async () => {
|
|
219
|
-
await runProcess(
|
|
220
|
+
await runProcess(await linuxHelper(), [
|
|
220
221
|
'clear',
|
|
221
222
|
'service',
|
|
222
223
|
'dev.anhedral.cli.v1',
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
2
|
import { ANHEDRAL_STACK_DEPENDENCIES, WEB_DEPENDENCIES } from '../dependencies.js';
|
|
4
3
|
import { CapabilityEditor, fingerprint } from '../capability-editor.js';
|
|
5
4
|
import { resourceName } from '../render.js';
|
|
6
5
|
import { json, put, workerConfig } from '../scaffold/files.js';
|
|
7
|
-
import { initializeUiMetadata } from '../ui-project.js';
|
|
8
6
|
const template = (name) => readFileSync(new URL(`../../assets/launch/${name}`, import.meta.url), 'utf8');
|
|
9
7
|
/** The launch foundation is a web service; Hono owns application services and data. */
|
|
10
8
|
export function scaffoldTanstack(root, name) {
|
|
@@ -98,7 +96,6 @@ export default [...config, { ignores: ['dist/**', '.wrangler/**', 'src/routeTree
|
|
|
98
96
|
},
|
|
99
97
|
iconLibrary: 'lucide',
|
|
100
98
|
});
|
|
101
|
-
initializeUiMetadata(path.join(root, app), 'web');
|
|
102
99
|
put(root, `${app}/src/lib/utils.ts`, `import { clsx, type ClassValue } from 'clsx';
|
|
103
100
|
import { twMerge } from 'tailwind-merge';
|
|
104
101
|
export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
|
package/dist/registry/usage.js
CHANGED
|
@@ -35,7 +35,7 @@ Start a project:
|
|
|
35
35
|
add Add backend, private storage or payments.
|
|
36
36
|
|
|
37
37
|
Inspect source and UI:
|
|
38
|
-
stack Inspect the Anhedral Stack
|
|
38
|
+
stack Inspect, update or diagnose the Anhedral Stack.
|
|
39
39
|
ui Initialize, add, list, diff or check UI components.
|
|
40
40
|
|
|
41
41
|
Optional Platform access:
|
|
@@ -47,6 +47,7 @@ Optional Platform access:
|
|
|
47
47
|
deploy Plan, prepare or inspect a candidate; never activates it.
|
|
48
48
|
env Import private configuration or list variable metadata.
|
|
49
49
|
staging Deploy verified candidates to persistent staging.
|
|
50
|
+
production Publish ready candidates with current project permissions.
|
|
50
51
|
logs Read redacted runtime logs for a linked project.
|
|
51
52
|
|
|
52
53
|
Shell setup:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CliArtifact } from './contracts/deployment.js';
|
|
2
|
+
declare const publishedArtifact: unique symbol;
|
|
3
|
+
export type PublishedCliArtifact = Readonly<CliArtifact> & {
|
|
4
|
+
readonly [publishedArtifact]: true;
|
|
5
|
+
};
|
|
6
|
+
export type ReleaseArtifactOptions = {
|
|
7
|
+
fetch?: typeof globalThis.fetch;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class ArtifactUnavailableError extends Error {
|
|
12
|
+
readonly code = "ARTIFACT_UNAVAILABLE";
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare function isPublishedCliArtifact(value: unknown): value is PublishedCliArtifact;
|
|
16
|
+
/** Only fixed official public release endpoints may supply provenance. No project context is read. */
|
|
17
|
+
export declare function resolvePublishedCliArtifact(options?: ReleaseArtifactOptions): Promise<PublishedCliArtifact>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { cliArtifactSchema } from './contracts/deployment.js';
|
|
2
|
+
import { GENERATOR_VERSION } from './version.js';
|
|
3
|
+
const MAX_JSON_BYTES = 256 * 1024;
|
|
4
|
+
const MAX_TIMEOUT_MS = 15000;
|
|
5
|
+
const sourceRevision = /^[a-f0-9]{40}$/;
|
|
6
|
+
const releaseVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
7
|
+
const verified = new WeakSet();
|
|
8
|
+
export class ArtifactUnavailableError extends Error {
|
|
9
|
+
code = 'ARTIFACT_UNAVAILABLE';
|
|
10
|
+
constructor() {
|
|
11
|
+
super('The running CLI release artifact could not be verified from official GitHub and npm metadata. Retry after publication or use --offline for a source-only update; deployment will remain unavailable.');
|
|
12
|
+
this.name = 'ArtifactUnavailableError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function isPublishedCliArtifact(value) {
|
|
16
|
+
return typeof value === 'object' && value !== null && verified.has(value);
|
|
17
|
+
}
|
|
18
|
+
function object(value) {
|
|
19
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
20
|
+
throw new ArtifactUnavailableError();
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function abortable(signal, operation) {
|
|
24
|
+
signal.throwIfAborted();
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const abort = () => reject(new ArtifactUnavailableError());
|
|
27
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
28
|
+
Promise.resolve()
|
|
29
|
+
.then(operation)
|
|
30
|
+
.then((value) => {
|
|
31
|
+
signal.removeEventListener('abort', abort);
|
|
32
|
+
resolve(value);
|
|
33
|
+
}, (error) => {
|
|
34
|
+
signal.removeEventListener('abort', abort);
|
|
35
|
+
reject(error);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function readJson(response, signal) {
|
|
40
|
+
if (!response.ok || !response.body) {
|
|
41
|
+
void response.body?.cancel().catch(() => undefined);
|
|
42
|
+
throw new ArtifactUnavailableError();
|
|
43
|
+
}
|
|
44
|
+
const length = response.headers.get('content-length');
|
|
45
|
+
if (length !== null && Number(length) > MAX_JSON_BYTES) {
|
|
46
|
+
void response.body.cancel().catch(() => undefined);
|
|
47
|
+
throw new ArtifactUnavailableError();
|
|
48
|
+
}
|
|
49
|
+
const reader = response.body.getReader();
|
|
50
|
+
const chunks = [];
|
|
51
|
+
let size = 0;
|
|
52
|
+
try {
|
|
53
|
+
for (;;) {
|
|
54
|
+
signal.throwIfAborted();
|
|
55
|
+
const result = await abortable(signal, () => reader.read());
|
|
56
|
+
if (result.done)
|
|
57
|
+
break;
|
|
58
|
+
size += result.value.byteLength;
|
|
59
|
+
if (size > MAX_JSON_BYTES)
|
|
60
|
+
throw new ArtifactUnavailableError();
|
|
61
|
+
chunks.push(result.value);
|
|
62
|
+
}
|
|
63
|
+
const bytes = new Uint8Array(size);
|
|
64
|
+
let offset = 0;
|
|
65
|
+
for (const chunk of chunks) {
|
|
66
|
+
bytes.set(chunk, offset);
|
|
67
|
+
offset += chunk.byteLength;
|
|
68
|
+
}
|
|
69
|
+
return object(JSON.parse(new TextDecoder('utf8', { fatal: true }).decode(bytes)));
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
void reader.cancel().catch(() => undefined);
|
|
73
|
+
reader.releaseLock();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Only fixed official public release endpoints may supply provenance. No project context is read. */
|
|
77
|
+
export async function resolvePublishedCliArtifact(options = {}) {
|
|
78
|
+
const timeout = options.timeoutMs ?? MAX_TIMEOUT_MS;
|
|
79
|
+
if (!Number.isInteger(timeout) ||
|
|
80
|
+
timeout < 1 ||
|
|
81
|
+
timeout > MAX_TIMEOUT_MS ||
|
|
82
|
+
!releaseVersion.test(GENERATOR_VERSION))
|
|
83
|
+
throw new ArtifactUnavailableError();
|
|
84
|
+
const controller = new AbortController();
|
|
85
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
86
|
+
const signal = AbortSignal.any([controller.signal, ...(options.signal ? [options.signal] : [])]);
|
|
87
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
88
|
+
async function request(url, redirects = false) {
|
|
89
|
+
for (let count = 0;; count++) {
|
|
90
|
+
signal.throwIfAborted();
|
|
91
|
+
const response = await abortable(signal, () => fetcher(url.href, {
|
|
92
|
+
method: 'GET',
|
|
93
|
+
redirect: 'manual',
|
|
94
|
+
credentials: 'omit',
|
|
95
|
+
cache: 'no-store',
|
|
96
|
+
referrerPolicy: 'no-referrer',
|
|
97
|
+
signal,
|
|
98
|
+
headers: { accept: 'application/json', 'user-agent': 'anhedral-cli' },
|
|
99
|
+
}));
|
|
100
|
+
if (response.redirected || (response.url && new URL(response.url).href !== url.href))
|
|
101
|
+
throw new ArtifactUnavailableError();
|
|
102
|
+
if (response.status >= 300 && response.status < 400) {
|
|
103
|
+
const location = response.headers.get('location');
|
|
104
|
+
void response.body?.cancel().catch(() => undefined);
|
|
105
|
+
if (!redirects || count >= 2 || !location)
|
|
106
|
+
throw new ArtifactUnavailableError();
|
|
107
|
+
const next = new URL(location, url);
|
|
108
|
+
if (next.protocol !== 'https:' ||
|
|
109
|
+
next.hostname !== 'release-assets.githubusercontent.com' ||
|
|
110
|
+
next.port ||
|
|
111
|
+
next.username ||
|
|
112
|
+
next.password ||
|
|
113
|
+
next.hash)
|
|
114
|
+
throw new ArtifactUnavailableError();
|
|
115
|
+
url = next;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
return readJson(response, signal);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const version = GENERATOR_VERSION;
|
|
123
|
+
const metadata = await request(new URL(`https://github.com/anhedral/anhedral-cli/releases/download/v${version}/metadata.json`), true);
|
|
124
|
+
if (metadata.schemaVersion !== 1 ||
|
|
125
|
+
metadata.name !== 'anhedral' ||
|
|
126
|
+
metadata.version !== version ||
|
|
127
|
+
metadata.filename !== `anhedral-${version}.tgz` ||
|
|
128
|
+
typeof metadata.sourceRevision !== 'string' ||
|
|
129
|
+
!sourceRevision.test(metadata.sourceRevision))
|
|
130
|
+
throw new ArtifactUnavailableError();
|
|
131
|
+
const artifact = cliArtifactSchema.parse({
|
|
132
|
+
version,
|
|
133
|
+
sourceRevision: metadata.sourceRevision,
|
|
134
|
+
packageIntegrity: metadata.integrity,
|
|
135
|
+
});
|
|
136
|
+
const registry = await request(new URL(`https://registry.npmjs.org/anhedral/${version}`));
|
|
137
|
+
const dist = object(registry.dist);
|
|
138
|
+
if (registry.name !== 'anhedral' ||
|
|
139
|
+
registry.version !== version ||
|
|
140
|
+
dist.integrity !== artifact.packageIntegrity ||
|
|
141
|
+
dist.tarball !== `https://registry.npmjs.org/anhedral/-/anhedral-${version}.tgz`)
|
|
142
|
+
throw new ArtifactUnavailableError();
|
|
143
|
+
if (registry.gitHead !== undefined && registry.gitHead !== artifact.sourceRevision)
|
|
144
|
+
throw new ArtifactUnavailableError();
|
|
145
|
+
const ref = await request(new URL(`https://api.github.com/repos/anhedral/anhedral-cli/git/ref/tags/v${version}`));
|
|
146
|
+
if (ref.ref !== `refs/tags/v${version}`)
|
|
147
|
+
throw new ArtifactUnavailableError();
|
|
148
|
+
let target = object(ref.object);
|
|
149
|
+
if (target.type === 'tag') {
|
|
150
|
+
if (typeof target.sha !== 'string' || !sourceRevision.test(target.sha))
|
|
151
|
+
throw new ArtifactUnavailableError();
|
|
152
|
+
const tag = await request(new URL(`https://api.github.com/repos/anhedral/anhedral-cli/git/tags/${target.sha}`));
|
|
153
|
+
if (tag.tag !== `v${version}`)
|
|
154
|
+
throw new ArtifactUnavailableError();
|
|
155
|
+
target = object(tag.object);
|
|
156
|
+
}
|
|
157
|
+
if (target.type !== 'commit' || target.sha !== artifact.sourceRevision)
|
|
158
|
+
throw new ArtifactUnavailableError();
|
|
159
|
+
const result = Object.freeze(artifact);
|
|
160
|
+
verified.add(result);
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
throw new ArtifactUnavailableError();
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
clearTimeout(timer);
|
|
168
|
+
}
|
|
169
|
+
}
|