@astryxdesign/cli 0.6.1 → 0.6.2-canary.a4bcbeb

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 (60) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -1
  3. package/api/component/_adapter.mjs +64 -23
  4. package/api/component/component.doc.mjs +1 -1
  5. package/api/component/component.type.d.mts +8 -2
  6. package/api/component/component.type.mjs +5 -2
  7. package/api/component/integration-import-agreement.test.mjs +162 -6
  8. package/api/component/list/list.mjs +91 -15
  9. package/api/doctor/doctor.mjs +5 -16
  10. package/api/init/init.doc.mjs +2 -2
  11. package/api/init/init.type.d.mts +1 -1
  12. package/api/init/init.type.mjs +1 -1
  13. package/api/init/run/run.mjs +1 -1
  14. package/api/integration/add-helpers.mjs +2 -1
  15. package/api/integration/pack-check.mjs +9 -3
  16. package/api/search/search.d.mts +1 -1
  17. package/api/search/search.mjs +135 -41
  18. package/api/theme/build/build.d.mts +45 -17
  19. package/api/theme/build/build.family.test.mjs +435 -0
  20. package/api/theme/build/build.mjs +681 -121
  21. package/api/theme/build/build.packed-old-core.test.mjs +25 -9
  22. package/api/theme/build/build.test.mjs +142 -0
  23. package/api/theme/build/core-interception.d.mts +14 -2
  24. package/api/theme/build/core-interception.mjs +38 -14
  25. package/api/theme/build/family.d.mts +15 -0
  26. package/api/theme/build/family.mjs +442 -0
  27. package/api/theme/palette/generate/generate.mjs +2 -1
  28. package/assets/docs/theme.doc.dense.mjs +12 -0
  29. package/assets/docs/theme.doc.mjs +37 -0
  30. package/assets/docs/working-with-ai.doc.mjs +2 -1
  31. package/clients/cli/commands/build-theme.mjs +63 -5
  32. package/clients/cli/commands/component/index.mjs +4 -1
  33. package/clients/cli/commands/init.doc.mjs +2 -2
  34. package/clients/cli/commands/theme-build.doc.mjs +28 -10
  35. package/foundation/agent-docs/agent-doc-state.mjs +1 -1
  36. package/foundation/agent-docs/agent-docs.d.mts +2 -2
  37. package/foundation/agent-docs/agent-docs.mjs +8 -6
  38. package/foundation/agent-docs/agent-docs.test.mjs +14 -0
  39. package/foundation/discovery/__fixtures__/component-both-exports.doc.d.mts +24 -0
  40. package/foundation/discovery/__fixtures__/component-both-exports.doc.mjs +19 -0
  41. package/foundation/discovery/__fixtures__/component-default-export.doc.d.mts +14 -0
  42. package/foundation/discovery/__fixtures__/component-default-export.doc.mjs +13 -0
  43. package/foundation/discovery/__fixtures__/component-named-export.doc.d.mts +13 -0
  44. package/foundation/discovery/__fixtures__/component-named-export.doc.mjs +11 -0
  45. package/foundation/discovery/component-discovery.d.mts +5 -3
  46. package/foundation/discovery/component-discovery.mjs +25 -9
  47. package/foundation/discovery/component-loader.mjs +4 -1
  48. package/foundation/discovery/component-loader.test.mjs +48 -0
  49. package/foundation/discovery/theming-targets.test.mjs +29 -0
  50. package/foundation/fs/paths.d.mts +19 -0
  51. package/foundation/fs/paths.mjs +54 -0
  52. package/foundation/fs/paths.test.mjs +102 -1
  53. package/foundation/fs/publish-file-eperm-mutation.test.mjs +62 -0
  54. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +107 -0
  55. package/foundation/fs/publish-file.d.mts +22 -0
  56. package/foundation/fs/publish-file.mjs +68 -0
  57. package/foundation/fs/publish-file.test.mjs +136 -0
  58. package/foundation/integrations/manifest-writer.mjs +2 -1
  59. package/foundation/response/response-types.doc.mjs +1 -1
  60. package/package.json +15 -10
@@ -4,7 +4,7 @@ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
4
4
  import * as fs from 'node:fs';
5
5
  import * as path from 'node:path';
6
6
  import * as os from 'node:os';
7
- import {findCoreDir, findProjectRoot, listComponents, discoverExternalPackages, existsCaseExact} from './paths.mjs';
7
+ import {findCoreDir, findProjectRoot, listComponents, discoverExternalPackages, existsCaseExact, findInstalledPackage} from './paths.mjs';
8
8
 
9
9
  let tmpDir;
10
10
 
@@ -43,6 +43,107 @@ describe('findCoreDir', () => {
43
43
  });
44
44
  });
45
45
 
46
+ describe('findInstalledPackage', () => {
47
+ /** @param {string} root @param {string} name @param {string} version */
48
+ function install(root, name, version) {
49
+ const dir = path.join(root, 'node_modules', ...name.split('/'));
50
+ fs.mkdirSync(dir, {recursive: true});
51
+ fs.writeFileSync(
52
+ path.join(dir, 'package.json'),
53
+ JSON.stringify({name, version}),
54
+ );
55
+ return dir;
56
+ }
57
+
58
+ it('finds a package in the node_modules chain above startDir', () => {
59
+ const installed = install(tmpDir, '@astryxdesign/core', '0.6.0');
60
+ const nested = path.join(tmpDir, 'src', 'deep');
61
+ fs.mkdirSync(nested, {recursive: true});
62
+
63
+ expect(findInstalledPackage(nested, '@astryxdesign/core')).toBe(installed);
64
+ });
65
+
66
+ it('reports a package the project never installed as missing', () => {
67
+ expect(findInstalledPackage(tmpDir, '@astryxdesign/core')).toBeNull();
68
+ });
69
+
70
+ // The regression this lookup exists for: `require.resolve` folds NODE_PATH in
71
+ // even when `paths` is given, so a package reachable only from the ambient
72
+ // environment read as installed in the user's project.
73
+ it('does not answer from a package that is only on NODE_PATH', () => {
74
+ const ambient = path.join(tmpDir, 'ambient');
75
+ install(ambient, '@astryxdesign/core', '0.6.0');
76
+ const project = path.join(tmpDir, 'project');
77
+ fs.mkdirSync(project, {recursive: true});
78
+
79
+ const previous = process.env.NODE_PATH;
80
+ process.env.NODE_PATH = path.join(ambient, 'node_modules');
81
+ try {
82
+ expect(findInstalledPackage(project, '@astryxdesign/core')).toBeNull();
83
+ } finally {
84
+ if (previous === undefined) delete process.env.NODE_PATH;
85
+ else process.env.NODE_PATH = previous;
86
+ }
87
+ });
88
+
89
+ describe('under Yarn Plug\'n\'Play, which has no node_modules', () => {
90
+ /**
91
+ * Stand in for the runtime a PnP process exposes: `process.versions.pnp`
92
+ * plus a requirable `pnpapi`. The package itself lives outside any
93
+ * node_modules, the way Yarn stores it.
94
+ * @param {Record<string, string>} resolved name -> package directory
95
+ */
96
+ function withPnp(resolved) {
97
+ const runtime = path.join(tmpDir, 'runtime');
98
+ const api = path.join(runtime, 'node_modules', 'pnpapi');
99
+ fs.mkdirSync(api, {recursive: true});
100
+ fs.writeFileSync(
101
+ path.join(api, 'package.json'),
102
+ JSON.stringify({name: 'pnpapi', version: '1.0.0', main: 'index.js'}),
103
+ );
104
+ fs.writeFileSync(
105
+ path.join(api, 'index.js'),
106
+ `const resolved = ${JSON.stringify(resolved)};\n` +
107
+ 'module.exports = {\n' +
108
+ ' resolveToUnqualified(name) {\n' +
109
+ ' if (!(name in resolved)) {\n' +
110
+ " const e = new Error(name); e.code = 'MODULE_NOT_FOUND'; throw e;\n" +
111
+ ' }\n' +
112
+ ' return resolved[name];\n' +
113
+ ' },\n' +
114
+ '};\n',
115
+ );
116
+ Object.defineProperty(process.versions, 'pnp', {
117
+ value: '3',
118
+ configurable: true,
119
+ });
120
+ return runtime;
121
+ }
122
+
123
+ afterEach(() => {
124
+ delete process.versions.pnp;
125
+ });
126
+
127
+ it('falls back to the PnP runtime when there is no chain to walk', () => {
128
+ const store = path.join(tmpDir, 'store', '@astryxdesign-core');
129
+ fs.mkdirSync(store, {recursive: true});
130
+ fs.writeFileSync(
131
+ path.join(store, 'package.json'),
132
+ JSON.stringify({name: '@astryxdesign/core', version: '0.6.0'}),
133
+ );
134
+ const project = withPnp({'@astryxdesign/core': store});
135
+
136
+ expect(findInstalledPackage(project, '@astryxdesign/core')).toBe(store);
137
+ });
138
+
139
+ it('still reports a package the PnP project never declared', () => {
140
+ const project = withPnp({});
141
+
142
+ expect(findInstalledPackage(project, '@astryxdesign/core')).toBeNull();
143
+ });
144
+ });
145
+ });
146
+
46
147
  describe('findProjectRoot', () => {
47
148
  it('finds root with workspaces in package.json', () => {
48
149
  fs.writeFileSync(
@@ -0,0 +1,62 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Mutation test that forces fs.linkSync to throw EPERM so the fallback
5
+ * path is exercised even when the destination already exists. Proves
6
+ * COPYFILE_EXCL is the no-clobber gate.
7
+ *
8
+ * Separate file because vi.mock is hoisted and affects the whole module.
9
+ */
10
+
11
+ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
12
+ import * as path from 'node:path';
13
+ import * as os from 'node:os';
14
+ import * as realFs from 'node:fs';
15
+
16
+ vi.mock('node:fs', async importOriginal => {
17
+ const actual = await importOriginal();
18
+ return {
19
+ ...actual,
20
+ linkSync: vi.fn(() => {
21
+ const err = new Error('EPERM: operation not permitted, link');
22
+ err.code = 'EPERM';
23
+ throw err;
24
+ }),
25
+ };
26
+ });
27
+
28
+ const {publishNewFile} = await import('./publish-file.mjs');
29
+ const fs = await import('node:fs');
30
+
31
+ let tmpDir;
32
+ beforeEach(() => {
33
+ tmpDir = realFs.mkdtempSync(path.join(os.tmpdir(), 'astryx-publish-eperm-'));
34
+ });
35
+ afterEach(() => {
36
+ realFs.rmSync(tmpDir, {recursive: true, force: true});
37
+ });
38
+
39
+ describe('publishNewFile — forced EPERM fallback', () => {
40
+ it('preserves an existing destination through COPYFILE_EXCL', () => {
41
+ const tmp = path.join(tmpDir, '.tmp-src');
42
+ const dest = path.join(tmpDir, 'victim.txt');
43
+ realFs.writeFileSync(tmp, 'attacker-content');
44
+ realFs.writeFileSync(dest, 'victim-content');
45
+
46
+ expect(() => publishNewFile(tmp, dest)).toThrow(
47
+ expect.objectContaining({code: 'EEXIST'}),
48
+ );
49
+ expect(realFs.readFileSync(dest, 'utf-8')).toBe('victim-content');
50
+ expect(fs.linkSync).toHaveBeenCalledOnce();
51
+ });
52
+
53
+ it('publishes a new destination through the fallback', () => {
54
+ const tmp = path.join(tmpDir, '.tmp-src');
55
+ const dest = path.join(tmpDir, 'new-file.txt');
56
+ realFs.writeFileSync(tmp, 'new-content');
57
+
58
+ expect(() => publishNewFile(tmp, dest)).not.toThrow();
59
+ expect(realFs.readFileSync(dest, 'utf-8')).toBe('new-content');
60
+ expect(fs.linkSync).toHaveBeenCalled();
61
+ });
62
+ });
@@ -0,0 +1,107 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Optional integration proof for filesystems that reject hard links.
5
+ * Set ASTRYX_HARDLINK_UNAVAILABLE_TEST_ROOT to a writable directory on such a
6
+ * filesystem to exercise the real fallback end to end.
7
+ */
8
+
9
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import {applyWrites} from '../../api/integration/add-helpers.mjs';
13
+
14
+ const testRoot = process.env.ASTRYX_HARDLINK_UNAVAILABLE_TEST_ROOT ?? null;
15
+
16
+ describe.skipIf(!testRoot)(
17
+ 'hard-link-unavailable filesystem integration proof',
18
+ () => {
19
+ let testDir;
20
+
21
+ beforeEach(() => {
22
+ testDir = fs.mkdtempSync(path.join(testRoot, '.astryx-publish-proof-'));
23
+ });
24
+
25
+ afterEach(() => {
26
+ fs.rmSync(testDir, {recursive: true, force: true});
27
+ });
28
+
29
+ it('confirms the configured filesystem rejects hard links', () => {
30
+ const source = path.join(testDir, '.tmp-source');
31
+ const destination = path.join(testDir, '.tmp-destination');
32
+ fs.writeFileSync(source, 'link-test');
33
+
34
+ expect(() => fs.linkSync(source, destination)).toThrow(
35
+ expect.objectContaining({code: expect.stringMatching(/^(EPERM|EXDEV)$/)}),
36
+ );
37
+ });
38
+
39
+ it('applyWrites creates files through the fallback', () => {
40
+ const plans = [
41
+ {
42
+ path: path.join(testDir, 'MyComponent.tsx'),
43
+ contents: '// MyComponent\nexport default function MyComponent() {}\n',
44
+ createOnly: true,
45
+ },
46
+ {
47
+ path: path.join(testDir, 'MyComponent.test.tsx'),
48
+ contents: '// test\nimport MyComponent from "./MyComponent";\n',
49
+ createOnly: true,
50
+ },
51
+ ];
52
+
53
+ const rollback = applyWrites(plans);
54
+ expect(typeof rollback).toBe('function');
55
+ expect(fs.readFileSync(plans[0].path, 'utf-8')).toContain('MyComponent');
56
+ expect(fs.readFileSync(plans[1].path, 'utf-8')).toContain('test');
57
+ });
58
+
59
+ it('applyWrites preserves no-clobber behavior', () => {
60
+ const target = path.join(testDir, 'existing.tsx');
61
+ fs.writeFileSync(target, '// original\n');
62
+
63
+ expect(() =>
64
+ applyWrites([
65
+ {
66
+ path: target,
67
+ contents: '// replacement\n',
68
+ createOnly: true,
69
+ },
70
+ ]),
71
+ ).toThrow(/overwrite|exists/i);
72
+ expect(fs.readFileSync(target, 'utf-8')).toBe('// original\n');
73
+ });
74
+
75
+ it('applyWrites rolls back partial publication', () => {
76
+ const good = path.join(testDir, 'good.tsx');
77
+ const bad = path.join(testDir, 'bad.tsx');
78
+ fs.writeFileSync(bad, '// preexisting\n');
79
+
80
+ expect(() =>
81
+ applyWrites([
82
+ {path: good, contents: '// good file\n', createOnly: true},
83
+ {path: bad, contents: '// replacement\n', createOnly: true},
84
+ ]),
85
+ ).toThrow();
86
+ expect(fs.existsSync(good)).toBe(false);
87
+ expect(fs.readFileSync(bad, 'utf-8')).toBe('// preexisting\n');
88
+ });
89
+
90
+ it('applyWrites keeps compare-and-swap replacement behavior', () => {
91
+ const target = path.join(testDir, 'config.json');
92
+ const original = '{"version": 1}\n';
93
+ fs.writeFileSync(target, original);
94
+
95
+ const rollback = applyWrites([
96
+ {
97
+ path: target,
98
+ contents: '{"version": 2}\n',
99
+ createOnly: false,
100
+ expectedOriginal: Buffer.from(original),
101
+ },
102
+ ]);
103
+ expect(typeof rollback).toBe('function');
104
+ expect(fs.readFileSync(target, 'utf-8')).toBe('{"version": 2}\n');
105
+ });
106
+ },
107
+ );
@@ -0,0 +1,22 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Publish a fully written temporary file to a new destination path.
6
+ *
7
+ * Semantics:
8
+ * - **Create-only**: if `destination` already exists, throws with
9
+ * `code === 'EEXIST'` and leaves the existing file untouched.
10
+ * - **Concurrent-creator safe**: two racing publishers to the same
11
+ * destination — at most one wins; the loser gets EEXIST.
12
+ * - **Symlink-neutral**: this function does not follow or reject
13
+ * symlinks at `destination`; callers that need symlink rejection
14
+ * must check before calling.
15
+ *
16
+ * The temporary file is NOT removed by this function — the caller
17
+ * owns cleanup so that rollback paths can still read it.
18
+ *
19
+ * @param {string} temporary Fully written source (temp) file path.
20
+ * @param {string} destination Target path that must not yet exist.
21
+ */
22
+ export function publishNewFile(temporary: string, destination: string): void;
@@ -0,0 +1,68 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Portable create-only file publication.
5
+ *
6
+ * @input A fully written temporary file and a destination path.
7
+ * @output The destination exists with the temporary's content, or an error
8
+ * is thrown and nothing is created.
9
+ * @position foundation/fs — used by every write transaction that creates a
10
+ * new file without overwriting (integration add, palette generation,
11
+ * manifest creation).
12
+ *
13
+ * The ideal primitive is `fs.linkSync`: it is a single atomic directory-entry
14
+ * operation that fails with EEXIST when the destination already exists, giving
15
+ * concurrent-creator safety for free.
16
+ *
17
+ * Some virtual, network, and cross-device filesystems reject hard links with
18
+ * EPERM or EXDEV. When that happens, we fall back to `fs.copyFileSync` with
19
+ * `COPYFILE_EXCL`, which creates the destination with O_EXCL (still fails
20
+ * EEXIST on collision) and copies the content.
21
+ *
22
+ * SYNC: residual crash-atomicity tradeoff — `linkSync` adds a directory
23
+ * entry in a single metadata operation, so a crash cannot produce a partial
24
+ * file. `copyFileSync` writes data, so a crash mid-copy could leave a
25
+ * truncated destination. Callers that need crash-atomic guarantees on
26
+ * link-hostile filesystems would need `fsync` + rename, which conflicts
27
+ * with the no-clobber requirement. For CLI-driven interactive writes the
28
+ * window is negligible and the tradeoff is accepted.
29
+ */
30
+
31
+ import * as fs from 'node:fs';
32
+
33
+ /**
34
+ * Publish a fully written temporary file to a new destination path.
35
+ *
36
+ * Semantics:
37
+ * - **Create-only**: if `destination` already exists, throws with
38
+ * `code === 'EEXIST'` and leaves the existing file untouched.
39
+ * - **Concurrent-creator safe**: two racing publishers to the same
40
+ * destination — at most one wins; the loser gets EEXIST.
41
+ * - **Symlink-neutral**: this function does not follow or reject
42
+ * symlinks at `destination`; callers that need symlink rejection
43
+ * must check before calling.
44
+ *
45
+ * The temporary file is NOT removed by this function — the caller
46
+ * owns cleanup so that rollback paths can still read it.
47
+ *
48
+ * @param {string} temporary Fully written source (temp) file path.
49
+ * @param {string} destination Target path that must not yet exist.
50
+ */
51
+ export function publishNewFile(temporary, destination) {
52
+ try {
53
+ fs.linkSync(temporary, destination);
54
+ } catch (linkError) {
55
+ if (
56
+ linkError &&
57
+ typeof linkError === 'object' &&
58
+ 'code' in linkError &&
59
+ (linkError.code === 'EPERM' || linkError.code === 'EXDEV')
60
+ ) {
61
+ // Hard links unavailable (EPERM) or cross-device (EXDEV).
62
+ // Fall back to exclusive-create copy: O_EXCL guarantees no-clobber.
63
+ fs.copyFileSync(temporary, destination, fs.constants.COPYFILE_EXCL);
64
+ return;
65
+ }
66
+ throw linkError;
67
+ }
68
+ }
@@ -0,0 +1,136 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
4
+ import * as fs from 'node:fs';
5
+ import * as path from 'node:path';
6
+ import * as os from 'node:os';
7
+ import {publishNewFile} from './publish-file.mjs';
8
+
9
+ let tmpDir;
10
+ beforeEach(() => {
11
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-publish-file-'));
12
+ });
13
+ afterEach(() => {
14
+ fs.rmSync(tmpDir, {recursive: true, force: true});
15
+ });
16
+
17
+ describe('publishNewFile', () => {
18
+ it('publishes a new file from a temporary', () => {
19
+ const tmp = path.join(tmpDir, '.tmp-src');
20
+ const dest = path.join(tmpDir, 'output.txt');
21
+ fs.writeFileSync(tmp, 'hello');
22
+ publishNewFile(tmp, dest);
23
+ expect(fs.readFileSync(dest, 'utf-8')).toBe('hello');
24
+ });
25
+
26
+ it('preserves content fidelity for binary data', () => {
27
+ const tmp = path.join(tmpDir, '.tmp-bin');
28
+ const dest = path.join(tmpDir, 'output.bin');
29
+ const buf = Buffer.from([0x00, 0xff, 0x80, 0x01, 0xfe]);
30
+ fs.writeFileSync(tmp, buf);
31
+ publishNewFile(tmp, dest);
32
+ expect(fs.readFileSync(dest).equals(buf)).toBe(true);
33
+ });
34
+
35
+ it('does not remove the temporary file', () => {
36
+ const tmp = path.join(tmpDir, '.tmp-keep');
37
+ const dest = path.join(tmpDir, 'output.txt');
38
+ fs.writeFileSync(tmp, 'data');
39
+ publishNewFile(tmp, dest);
40
+ expect(fs.existsSync(tmp)).toBe(true);
41
+ });
42
+
43
+ it('throws EEXIST when the destination already exists', () => {
44
+ const tmp = path.join(tmpDir, '.tmp-src');
45
+ const dest = path.join(tmpDir, 'existing.txt');
46
+ fs.writeFileSync(tmp, 'new');
47
+ fs.writeFileSync(dest, 'old');
48
+ expect(() => publishNewFile(tmp, dest)).toThrow(
49
+ expect.objectContaining({code: 'EEXIST'}),
50
+ );
51
+ expect(fs.readFileSync(dest, 'utf-8')).toBe('old');
52
+ });
53
+
54
+ it('protects existing content on collision', () => {
55
+ const tmp = path.join(tmpDir, '.tmp-src');
56
+ const dest = path.join(tmpDir, 'existing.txt');
57
+ fs.writeFileSync(tmp, 'attacker');
58
+ fs.writeFileSync(dest, 'victim');
59
+ expect(() => publishNewFile(tmp, dest)).toThrow();
60
+ expect(fs.readFileSync(dest, 'utf-8')).toBe('victim');
61
+ });
62
+
63
+ it('allows exactly one of two creators to publish', () => {
64
+ const tmp1 = path.join(tmpDir, '.tmp-a');
65
+ const tmp2 = path.join(tmpDir, '.tmp-b');
66
+ const dest = path.join(tmpDir, 'contested.txt');
67
+ fs.writeFileSync(tmp1, 'creator-a');
68
+ fs.writeFileSync(tmp2, 'creator-b');
69
+
70
+ publishNewFile(tmp1, dest);
71
+ expect(() => publishNewFile(tmp2, dest)).toThrow(
72
+ expect.objectContaining({code: 'EEXIST'}),
73
+ );
74
+ expect(fs.readFileSync(dest, 'utf-8')).toBe('creator-a');
75
+ });
76
+
77
+ it('re-throws ENOENT when the temporary does not exist', () => {
78
+ const tmp = path.join(tmpDir, '.tmp-missing');
79
+ const dest = path.join(tmpDir, 'output.txt');
80
+ expect(() => publishNewFile(tmp, dest)).toThrow(
81
+ expect.objectContaining({code: 'ENOENT'}),
82
+ );
83
+ });
84
+
85
+ it('does not follow a symlink destination', () => {
86
+ const tmp = path.join(tmpDir, '.tmp-src');
87
+ const real = path.join(tmpDir, 'real.txt');
88
+ const sym = path.join(tmpDir, 'sym.txt');
89
+ fs.writeFileSync(tmp, 'data');
90
+ fs.writeFileSync(real, 'original');
91
+ fs.symlinkSync(real, sym);
92
+ expect(() => publishNewFile(tmp, sym)).toThrow();
93
+ expect(fs.readFileSync(real, 'utf-8')).toBe('original');
94
+ });
95
+
96
+ it('publishes a readable file', () => {
97
+ const tmp = path.join(tmpDir, '.tmp-src');
98
+ const dest = path.join(tmpDir, 'readable.txt');
99
+ fs.writeFileSync(tmp, 'check-perms');
100
+ publishNewFile(tmp, dest);
101
+ const stat = fs.statSync(dest);
102
+ expect(stat.mode & 0o444).toBeGreaterThan(0);
103
+ });
104
+
105
+ const hasWritableVarTmp = (() => {
106
+ try {
107
+ return os.platform() === 'linux' && fs.existsSync('/var/tmp');
108
+ } catch {
109
+ return false;
110
+ }
111
+ })();
112
+
113
+ it.skipIf(!hasWritableVarTmp)(
114
+ 'falls back to COPYFILE_EXCL when a cross-device link returns EXDEV',
115
+ () => {
116
+ const source = path.join(tmpDir, '.cross-src');
117
+ fs.writeFileSync(source, 'cross-device-content');
118
+
119
+ let otherDir;
120
+ try {
121
+ otherDir = fs.mkdtempSync('/var/tmp/astryx-xdev-');
122
+ } catch {
123
+ return;
124
+ }
125
+ try {
126
+ const destination = path.join(otherDir, 'output.txt');
127
+ publishNewFile(source, destination);
128
+ expect(fs.readFileSync(destination, 'utf-8')).toBe(
129
+ 'cross-device-content',
130
+ );
131
+ } finally {
132
+ fs.rmSync(otherDir, {recursive: true, force: true});
133
+ }
134
+ },
135
+ );
136
+ });
@@ -12,6 +12,7 @@
12
12
  import * as fs from 'node:fs';
13
13
  import * as path from 'node:path';
14
14
  import {randomUUID} from 'node:crypto';
15
+ import {publishNewFile} from '../fs/publish-file.mjs';
15
16
  import jscodeshift from 'jscodeshift';
16
17
  import {assertWithin} from '../fs/path-safety.mjs';
17
18
  import {findManifestPaths, loadManifestObject} from './integrations.mjs';
@@ -181,7 +182,7 @@ function createFile(file, contents) {
181
182
  fs.writeFileSync(descriptor, contents, 'utf-8');
182
183
  fs.closeSync(descriptor);
183
184
  descriptor = undefined;
184
- fs.linkSync(temporary, file);
185
+ publishNewFile(temporary, file);
185
186
  linked = true;
186
187
  removeTemporary(temporary);
187
188
  } catch (error) {
@@ -31,7 +31,7 @@ export const doc = {
31
31
  {
32
32
  value: 'component.list',
33
33
  description:
34
- 'The component catalog grouped by category: `detail` (the level: names | compact | full) and `components`, the grouped map of names+package, brief entries, or a full ComponentDoc per entry.',
34
+ 'The component catalog grouped by category: `detail` (the level: names | compact | full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry.',
35
35
  },
36
36
  {
37
37
  value: 'component.detail',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2-canary.a4bcbeb",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -100,10 +100,10 @@
100
100
  "zod": "^4.4.3"
101
101
  },
102
102
  "peerDependencies": {
103
- "@astryxdesign/charts": "*",
104
- "@astryxdesign/core": "*",
105
- "@astryxdesign/lab": "*",
106
- "@astryxdesign/theme-neutral": "*",
103
+ "@astryxdesign/charts": "0.6.2-canary.a4bcbeb",
104
+ "@astryxdesign/core": "0.6.2-canary.a4bcbeb",
105
+ "@astryxdesign/lab": "0.6.2-canary.a4bcbeb",
106
+ "@astryxdesign/theme-neutral": "0.6.2-canary.a4bcbeb",
107
107
  "gpt-tokenizer": "^3.4.0"
108
108
  },
109
109
  "peerDependenciesMeta": {
@@ -121,11 +121,16 @@
121
121
  }
122
122
  },
123
123
  "devDependencies": {
124
- "@astryxdesign/charts": "*",
125
- "@astryxdesign/core": "*",
126
- "@astryxdesign/lab": "*",
127
- "@astryxdesign/theme-neutral": "*",
128
- "gpt-tokenizer": "^3.4.0"
124
+ "@astryxdesign/charts": "0.6.2-canary.a4bcbeb",
125
+ "@astryxdesign/core": "0.6.2-canary.a4bcbeb",
126
+ "@astryxdesign/lab": "0.6.2-canary.a4bcbeb",
127
+ "@astryxdesign/theme-neutral": "0.6.2-canary.a4bcbeb",
128
+ "@heroicons/react": "^2.2.0",
129
+ "@stylexjs/stylex": "^0.19.0",
130
+ "@types/babel__core": "^7.20.5",
131
+ "gpt-tokenizer": "^3.4.0",
132
+ "lucide-react": "^1.18.0",
133
+ "recharts": "^3.9.2"
129
134
  },
130
135
  "scripts": {
131
136
  "astryx": "node clients/cli/bin/astryx.mjs",