@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50
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 +32 -18
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +11 -2
- package/api/component/component.mjs +29 -0
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +17 -7
- package/api/component/component.type.mjs +27 -20
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +30 -27
- package/api/docs/_adapter.mjs +154 -124
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- package/api/doctor/doctor.mjs +3 -7
- package/api/gap-report/gap-report.doc.mjs +7 -4
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/init/init.doc.mjs +4 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +16 -3
- package/api/integration/add-contribution.test.mjs +84 -4
- package/api/integration/integrationAdd.doc.mjs +7 -4
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- package/api/integration/validate-integration.mjs +2 -0
- package/api/integration/validate-integration.test.mjs +91 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +5 -1
- package/api/search/search.mjs +15 -8
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/add/add.binary.test.mjs +91 -0
- package/api/theme/add/add.mjs +15 -2
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeTemplate.doc.mjs +4 -1
- package/api/upgrade/_adapter.mjs +27 -4
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.type.d.mts +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +40 -2
- package/assets/codemods/integration-discovery.test.mjs +58 -0
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +9 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +6 -1
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +3 -2
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +4 -0
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +1 -1
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +1 -1
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +18 -18
- package/authoring/doctypes/parse.mjs +9 -9
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +6 -2
- package/authoring/doctypes/reference/type.ts +1 -1
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +2 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/types.ts +10 -10
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.ts +19 -19
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +4 -1
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +18 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +4 -2
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +16 -5
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +19 -8
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +21 -5
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +14 -3
- package/clients/cli/commands/layout-expand.doc.mjs +21 -4
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +5 -2
- package/clients/cli/commands/search.mjs +13 -2
- package/clients/cli/commands/search.test.mjs +61 -0
- package/clients/cli/commands/swizzle.doc.mjs +2 -1
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +28 -6
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +7 -6
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +17 -6
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project.mjs +123 -9
- package/foundation/config/project.test.mjs +126 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/docs-discovery.d.mts +4 -0
- package/foundation/discovery/docs-discovery.mjs +16 -2
- package/foundation/discovery/docs-discovery.test.mjs +47 -11
- package/foundation/discovery/template-adapter.d.mts +14 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +292 -25
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/compile.d.mts +162 -0
- package/foundation/doc-compiler/compile.mjs +262 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
- package/foundation/doc-compiler/ir.d.mts +9 -0
- package/foundation/doc-compiler/ir.mjs +287 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.mjs +6 -1
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +1 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +3 -3
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Every shipped topic compiles to a plain-JSON node that answers every
|
|
5
|
+
* docs read exactly as the live one does, and no read can change another read
|
|
6
|
+
* of the same catalog.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, expect, it} from 'vitest';
|
|
10
|
+
import {parseCompiledReferenceNode} from '../../foundation/doc-compiler/ir.mjs';
|
|
11
|
+
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
12
|
+
import {
|
|
13
|
+
compileTopic,
|
|
14
|
+
loadDocsCatalog,
|
|
15
|
+
lowerTopic,
|
|
16
|
+
overlayLanguages,
|
|
17
|
+
} from './_adapter.mjs';
|
|
18
|
+
|
|
19
|
+
const SLOW = 60_000;
|
|
20
|
+
|
|
21
|
+
describe('every shipped topic compiles to plain JSON', () => {
|
|
22
|
+
it(
|
|
23
|
+
'survives a JSON round trip with identical responses in every language',
|
|
24
|
+
async () => {
|
|
25
|
+
const catalog = await loadDocsCatalog();
|
|
26
|
+
let compiled = 0;
|
|
27
|
+
for (const entry of catalog.entries()) {
|
|
28
|
+
for (const lang of [null, ...overlayLanguages(entry)]) {
|
|
29
|
+
const lowered = await lowerTopic(catalog, entry, lang);
|
|
30
|
+
expect(parseCompiledReferenceNode(lowered)).toBe(lowered);
|
|
31
|
+
const node = await compileTopic(catalog, entry, lang);
|
|
32
|
+
expect(parseCompiledReferenceNode(node)).toBe(node);
|
|
33
|
+
const copy = parseCompiledReferenceNode(
|
|
34
|
+
JSON.parse(JSON.stringify(node)),
|
|
35
|
+
);
|
|
36
|
+
expect(JSON.stringify(detailView(copy))).toBe(
|
|
37
|
+
JSON.stringify(detailView(node)),
|
|
38
|
+
);
|
|
39
|
+
expect(JSON.stringify(indexView(copy))).toBe(
|
|
40
|
+
JSON.stringify(indexView(node)),
|
|
41
|
+
);
|
|
42
|
+
compiled += 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
expect(compiled).toBeGreaterThan(catalog.entries().length);
|
|
46
|
+
},
|
|
47
|
+
SLOW,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('reads that share a catalog', () => {
|
|
52
|
+
it(
|
|
53
|
+
'never let one read change another',
|
|
54
|
+
async () => {
|
|
55
|
+
const catalog = await loadDocsCatalog();
|
|
56
|
+
const tokens = catalog.resolve('tokens');
|
|
57
|
+
const first = detailView(await compileTopic(catalog, tokens));
|
|
58
|
+
for (const section of first.sections) {
|
|
59
|
+
section.title = 'EDITED';
|
|
60
|
+
for (const block of section.content) {
|
|
61
|
+
if (typeof block.text === 'string') block.text = 'EDITED';
|
|
62
|
+
if (Array.isArray(block.rows)) block.rows.push(['EDITED']);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const again = detailView(await compileTopic(catalog, tokens));
|
|
66
|
+
const index = indexView(await lowerTopic(catalog, tokens));
|
|
67
|
+
const spacing = detailView(
|
|
68
|
+
await compileTopic(catalog, catalog.resolve('spacing')),
|
|
69
|
+
);
|
|
70
|
+
for (const read of [again, index, spacing]) {
|
|
71
|
+
expect(JSON.stringify(read)).not.toContain('EDITED');
|
|
72
|
+
}
|
|
73
|
+
const lowered = await lowerTopic(catalog, tokens);
|
|
74
|
+
expect(Object.isFrozen(lowered.doc.sections[0].content)).toBe(true);
|
|
75
|
+
},
|
|
76
|
+
SLOW,
|
|
77
|
+
);
|
|
78
|
+
});
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Resolve token-ref blocks by inlining the referenced section's table.
|
|
6
|
-
* This allows section docs to reference token tables without duplicating data.
|
|
7
|
-
*
|
|
8
|
-
* The reference is resolved through the catalog, so a topic may point at one
|
|
9
|
-
* an integration contributed (or replaced) rather than only at a built-in. It
|
|
10
|
-
* names the section by key or authored title, so it resolves in every language.
|
|
11
|
-
* @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
|
|
12
|
-
* @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
|
|
13
|
-
* @param {{lang?: string | null}} [options]
|
|
14
|
-
* @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
|
|
15
|
-
*/
|
|
16
|
-
export function resolveTokenRefs(docsData: import("../docs.type.mjs").DocsDetailResponse["data"], catalog: import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, { lang }?: {
|
|
17
|
-
lang?: string | null;
|
|
18
|
-
}): Promise<import("../docs.type.mjs").DocsDetailResponse["data"]>;
|
|
19
4
|
/**
|
|
20
5
|
* @param {string} topic
|
|
21
6
|
* @param {object} [options]
|
|
@@ -3,84 +3,17 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file docs.detail leaf — load one topic's full reference doc.
|
|
5
5
|
*
|
|
6
|
-
* @input A topic name plus optional {lang, zh, dense}. Resolves
|
|
7
|
-
*
|
|
6
|
+
* @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
|
|
7
|
+
* via the shared adapter and compiles it with its token references linked.
|
|
8
8
|
* @output { type: 'docs.detail', data: ReferenceDoc } — the full doc with
|
|
9
|
-
* token-refs
|
|
10
|
-
* @position Leaf under api/docs.
|
|
11
|
-
*
|
|
9
|
+
* token-refs inlined, matching `astryx --json docs <topic>`.
|
|
10
|
+
* @position Leaf under api/docs. Reads the compiled node through the detail
|
|
11
|
+
* lens; resolution, overlays and extensions happen in the compiler.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
sourceTitle,
|
|
18
|
-
withSourceTitle,
|
|
19
|
-
} from '../../../foundation/discovery/docs-section-key.mjs';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Resolve token-ref blocks by inlining the referenced section's table.
|
|
23
|
-
* This allows section docs to reference token tables without duplicating data.
|
|
24
|
-
*
|
|
25
|
-
* The reference is resolved through the catalog, so a topic may point at one
|
|
26
|
-
* an integration contributed (or replaced) rather than only at a built-in. It
|
|
27
|
-
* names the section by key or authored title, so it resolves in every language.
|
|
28
|
-
* @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
|
|
29
|
-
* @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
|
|
30
|
-
* @param {{lang?: string | null}} [options]
|
|
31
|
-
* @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
|
|
32
|
-
*/
|
|
33
|
-
export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
|
|
34
|
-
const resolved = {...docsData, sections: [...docsData.sections]};
|
|
35
|
-
for (let si = 0; si < resolved.sections.length; si++) {
|
|
36
|
-
const section = resolved.sections[si];
|
|
37
|
-
/** @type {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} */
|
|
38
|
-
const newContent = [];
|
|
39
|
-
for (const block of section.content) {
|
|
40
|
-
if (block.type === 'token-ref') {
|
|
41
|
-
const refEntry = catalog.resolve(block.topic);
|
|
42
|
-
if (!refEntry) {
|
|
43
|
-
newContent.push({type: 'prose', text: `[token-ref: unknown topic "${block.topic}"]`});
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
const refDocs = await loadTopicDoc(refEntry, {lang});
|
|
47
|
-
const wanted = block.section.toLowerCase();
|
|
48
|
-
const refSection = refDocs.sections.find(
|
|
49
|
-
(/** @type {import('@astryxdesign/cli/authoring').ReferenceSection} */ s) =>
|
|
50
|
-
sectionKey(s) === block.section ||
|
|
51
|
-
sourceTitle(s).toLowerCase() === wanted,
|
|
52
|
-
);
|
|
53
|
-
if (!refSection) {
|
|
54
|
-
newContent.push({type: 'prose', text: `[token-ref: section "${block.section}" not found in "${block.topic}"]`});
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
// Inline the referenced section's content blocks (tables, prose, etc.)
|
|
58
|
-
// and carry over the previewType
|
|
59
|
-
for (const refBlock of refSection.content) {
|
|
60
|
-
newContent.push(refBlock);
|
|
61
|
-
}
|
|
62
|
-
// If the referenced section has a previewType, attach it to our section
|
|
63
|
-
if (refSection.previewType && !section.previewType) {
|
|
64
|
-
resolved.sections[si] = withSourceTitle(
|
|
65
|
-
{...section, previewType: refSection.previewType, content: newContent},
|
|
66
|
-
sourceTitle(section),
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
newContent.push(block);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (resolved.sections[si] === section) {
|
|
74
|
-
resolved.sections[si] = withSourceTitle(
|
|
75
|
-
{...section, content: newContent},
|
|
76
|
-
sourceTitle(section),
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
resolved.sections[si].content = newContent;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return resolved;
|
|
83
|
-
}
|
|
14
|
+
import {linkReferenceTopic} from '../../../foundation/doc-compiler/compile.mjs';
|
|
15
|
+
import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
|
|
16
|
+
import {referenceTargets, resolveTopicDocs} from '../_adapter.mjs';
|
|
84
17
|
|
|
85
18
|
/**
|
|
86
19
|
* @param {string} topic
|
|
@@ -92,7 +25,10 @@ export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
|
|
|
92
25
|
* @returns {Promise<import('../docs.type.mjs').DocsDetailResponse>}
|
|
93
26
|
*/
|
|
94
27
|
export async function detail(topic, options = {}) {
|
|
95
|
-
const {catalog,
|
|
96
|
-
const
|
|
97
|
-
|
|
28
|
+
const {catalog, node, lang} = await resolveTopicDocs(topic, options);
|
|
29
|
+
const linked = await linkReferenceTopic(
|
|
30
|
+
node,
|
|
31
|
+
referenceTargets(catalog, lang),
|
|
32
|
+
);
|
|
33
|
+
return {type: 'docs.detail', data: detailView(linked)};
|
|
98
34
|
}
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
* @file docs.detail.section leaf — load a single section of a topic.
|
|
5
5
|
*
|
|
6
6
|
* @input A topic name, a section query, and optional {lang, zh, dense}. Resolves
|
|
7
|
-
*
|
|
8
|
-
* stable key, then by exact title, then by a title that contains
|
|
7
|
+
* the topic via the shared adapter, finds the section in its lowered compiled
|
|
8
|
+
* node by its stable key, then by exact title, then by a title that contains
|
|
9
|
+
* the query, and links only that section.
|
|
9
10
|
* @output { type: 'docs.detail.section', data: ReferenceSection } with any
|
|
10
11
|
* token-ref blocks inlined — matching `astryx --json docs <topic> <section>`.
|
|
11
12
|
* Throws ERR_UNKNOWN_SECTION when nothing matches, or when the query matches
|
|
12
13
|
* more than one section (the candidates come back as suggestions).
|
|
13
|
-
* @position Leaf nested under api/docs/detail. Shares
|
|
14
|
-
*
|
|
14
|
+
* @position Leaf nested under api/docs/detail. Shares topic resolution with the
|
|
15
|
+
* detail leaf via _adapter.mjs and reads through the compiler's lenses.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import {AstryxError} from '../../../error.mjs';
|
|
@@ -20,8 +21,12 @@ import {
|
|
|
20
21
|
findDocSection,
|
|
21
22
|
sectionKey,
|
|
22
23
|
} from '../../../../foundation/discovery/docs-section-key.mjs';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
24
|
+
import {linkReferenceSection} from '../../../../foundation/doc-compiler/compile.mjs';
|
|
25
|
+
import {
|
|
26
|
+
readerSections,
|
|
27
|
+
sectionView,
|
|
28
|
+
} from '../../../../foundation/doc-compiler/lenses.mjs';
|
|
29
|
+
import {referenceTargets, resolveTopicDocs} from '../../_adapter.mjs';
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* @param {string} topic
|
|
@@ -44,31 +49,30 @@ export async function section(topic, sectionName, options = {}) {
|
|
|
44
49
|
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
45
50
|
);
|
|
46
51
|
}
|
|
47
|
-
const {catalog, docsData, lang} = await resolveTopicDocs(topic, options);
|
|
48
52
|
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
+
const {catalog, node, lang} = await resolveTopicDocs(topic, options);
|
|
54
|
+
const sections = readerSections(node);
|
|
55
|
+
const {section: match, candidates} = findDocSection(sections, sectionName);
|
|
53
56
|
if (!match) {
|
|
54
57
|
const ambiguous = candidates.length > 1;
|
|
55
58
|
throw new AstryxError(
|
|
56
59
|
ambiguous
|
|
57
60
|
? `Section "${sectionName}" matches ${candidates.length} sections in "${topic}". Read one by its key.`
|
|
58
61
|
: `Section "${sectionName}" not found in "${topic}"`,
|
|
59
|
-
(ambiguous ? candidates :
|
|
62
|
+
(ambiguous ? candidates : sections).map(s => ({
|
|
60
63
|
name: sectionKey(s),
|
|
61
64
|
reason: s.title,
|
|
62
65
|
})),
|
|
63
66
|
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
64
67
|
);
|
|
65
68
|
}
|
|
69
|
+
|
|
66
70
|
// A section read on its own inlines its token refs, as the whole topic does;
|
|
67
|
-
// otherwise a section that is only a token-ref prints blank.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
// otherwise a section that is only a token-ref prints blank. Only this
|
|
72
|
+
// section is linked, so a broken reference elsewhere cannot fail the read.
|
|
73
|
+
const linked = await linkReferenceSection(
|
|
74
|
+
match,
|
|
75
|
+
referenceTargets(catalog, lang),
|
|
72
76
|
);
|
|
73
|
-
return {type: 'docs.detail.section', data:
|
|
77
|
+
return {type: 'docs.detail.section', data: sectionView(node, linked)};
|
|
74
78
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import {describe, it, expect} from 'vitest';
|
|
11
11
|
import {section} from './section.mjs';
|
|
12
12
|
import {AstryxError} from '../../../error.mjs';
|
|
13
|
-
import {loadDocsCatalog,
|
|
13
|
+
import {loadDocsCatalog, lowerTopic} from '../../_adapter.mjs';
|
|
14
14
|
|
|
15
15
|
const SLOW = 30_000;
|
|
16
16
|
|
|
@@ -42,7 +42,8 @@ describe('docs.detail.section leaf', () => {
|
|
|
42
42
|
}, SLOW);
|
|
43
43
|
|
|
44
44
|
it('reads a section by its stable key', async () => {
|
|
45
|
-
const
|
|
45
|
+
const catalog = await loadDocsCatalog();
|
|
46
|
+
const {doc} = await lowerTopic(catalog, catalog.resolve('theme'));
|
|
46
47
|
const target = doc.sections[doc.sections.length - 1];
|
|
47
48
|
const res = await section('theme', target.id);
|
|
48
49
|
expect(res.data.title).toBe(target.title);
|
|
@@ -63,7 +64,7 @@ describe('docs.detail.section leaf', () => {
|
|
|
63
64
|
const catalog = await loadDocsCatalog();
|
|
64
65
|
let checked = 0;
|
|
65
66
|
for (const entry of catalog.entries()) {
|
|
66
|
-
const doc = await
|
|
67
|
+
const {doc} = await lowerTopic(catalog, entry);
|
|
67
68
|
for (const own of doc.sections) {
|
|
68
69
|
if (!own.content.some(block => block.type === 'token-ref')) continue;
|
|
69
70
|
const res = await section(entry.name, own.id, lang ? {lang} : {});
|
package/api/docs/docs.type.d.mts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json docs
|
|
6
6
|
*/
|
|
7
7
|
export type DocsListResponse = {
|
|
8
8
|
type: "docs.list";
|
|
@@ -23,14 +23,14 @@ export type DocsListEntry = {
|
|
|
23
23
|
replaces?: string | undefined;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* astryx --json docs <topic> --index
|
|
27
27
|
*/
|
|
28
28
|
export type DocsIndexResponse = {
|
|
29
29
|
type: "docs.index";
|
|
30
30
|
data: DocsIndex;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* astryx --json docs <topic>
|
|
34
34
|
*/
|
|
35
35
|
export type DocsDetailResponse = {
|
|
36
36
|
type: "docs.detail";
|
|
@@ -62,7 +62,7 @@ export type DocsIndexSection = {
|
|
|
62
62
|
summary: string;
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* astryx --json docs <topic> <section>
|
|
66
66
|
*/
|
|
67
67
|
export type DocsDetailSectionResponse = {
|
|
68
68
|
type: "docs.detail.section";
|
package/api/docs/docs.type.mjs
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* @file Colocated types for the `docs` command — source of truth for the docs
|
|
5
5
|
* command JSON responses. `types/docs.d.ts` re-exports these.
|
|
6
6
|
*
|
|
7
|
-
* Invocation
|
|
7
|
+
* Invocation -> type discriminator
|
|
8
8
|
* ------------------------------------------------------------
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (unknown topic/section)
|
|
9
|
+
* astryx --json docs -> docs.list
|
|
10
|
+
* astryx --json docs <topic> -> docs.detail
|
|
11
|
+
* astryx --json docs <topic> --index -> docs.index
|
|
12
|
+
* astryx --json docs <topic> <section> -> docs.detail.section
|
|
13
|
+
* (unknown topic/section) -> CLIError
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* astryx --json docs
|
|
18
18
|
* @typedef {object} DocsListResponse
|
|
19
19
|
* @property {'docs.list'} type
|
|
20
20
|
* @property {DocsListEntry[]} data
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* astryx --json docs <topic> --index
|
|
35
35
|
* @typedef {object} DocsIndexResponse
|
|
36
36
|
* @property {'docs.index'} type
|
|
37
37
|
* @property {DocsIndex} data
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* astryx --json docs <topic>
|
|
42
42
|
* @typedef {object} DocsDetailResponse
|
|
43
43
|
* @property {'docs.detail'} type
|
|
44
44
|
* @property {import('@astryxdesign/cli/authoring').ReferenceDoc} data
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
*/
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* astryx --json docs <topic> <section>
|
|
67
67
|
* @typedef {object} DocsDetailSectionResponse
|
|
68
68
|
* @property {'docs.detail.section'} type
|
|
69
69
|
* @property {import('@astryxdesign/cli/authoring').ReferenceSection} data
|
package/api/docs/index/index.mjs
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file docs.index leaf — the section index of one topic.
|
|
5
5
|
*
|
|
6
|
-
* @input A topic name plus optional {lang, zh, dense, cwd}. Resolves
|
|
7
|
-
*
|
|
6
|
+
* @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
|
|
7
|
+
* via the shared adapter and reads its lowered compiled node; nothing is
|
|
8
|
+
* linked, since the index never inlines a token reference.
|
|
8
9
|
* @output { type: 'docs.index', data: DocsIndex } — the topic's name, title and
|
|
9
10
|
* description and, for each section, the key it is read by, its title, and a
|
|
10
11
|
* one-line summary. Matches `astryx --json docs <topic> --index`.
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
* read, is the detail leaf.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
|
-
import {
|
|
17
|
+
import {indexView} from '../../../foundation/doc-compiler/lenses.mjs';
|
|
17
18
|
import {resolveTopicDocs} from '../_adapter.mjs';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -26,6 +27,6 @@ import {resolveTopicDocs} from '../_adapter.mjs';
|
|
|
26
27
|
* @returns {Promise<import('../docs.type.mjs').DocsIndexResponse>}
|
|
27
28
|
*/
|
|
28
29
|
export async function index(topic, options = {}) {
|
|
29
|
-
const {
|
|
30
|
-
return {type: 'docs.index', data:
|
|
30
|
+
const {node} = await resolveTopicDocs(topic, options);
|
|
31
|
+
return {type: 'docs.index', data: indexView(node)};
|
|
31
32
|
}
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -34,8 +34,8 @@ import {
|
|
|
34
34
|
docsIndexBytes,
|
|
35
35
|
oversizedDocSections,
|
|
36
36
|
} from '../../foundation/discovery/docs-output-budget.mjs';
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
37
|
+
import {compileTopic, overlayLanguages} from '../docs/_adapter.mjs';
|
|
38
|
+
import {detailView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
39
39
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -798,11 +798,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
|
|
|
798
798
|
for (const lang of [null, ...overlayLanguages(entry)]) {
|
|
799
799
|
const where = lang ? `${entry.name} [${lang}]` : entry.name;
|
|
800
800
|
try {
|
|
801
|
-
const doc = await
|
|
802
|
-
await loadTopicDoc(entry, {lang}),
|
|
803
|
-
catalog,
|
|
804
|
-
{lang},
|
|
805
|
-
);
|
|
801
|
+
const doc = detailView(await compileTopic(catalog, entry, lang));
|
|
806
802
|
if (lang == null) topics += 1;
|
|
807
803
|
const indexBytes = docsIndexBytes(buildDocsIndexData(doc));
|
|
808
804
|
if (indexBytes > DOC_OUTPUT_BUDGET_BYTES) {
|
|
@@ -32,17 +32,19 @@ export const doc = {
|
|
|
32
32
|
name: 'component',
|
|
33
33
|
type: 'string',
|
|
34
34
|
description:
|
|
35
|
-
'Component or general design-system area. Required unless listCategories is true.',
|
|
35
|
+
'Component or general design-system area, up to 120 characters. Required unless listCategories is true.',
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
name: 'options.category',
|
|
39
39
|
type: 'GapReportCategory',
|
|
40
|
-
description:
|
|
40
|
+
description:
|
|
41
|
+
'Fixed category from the reported category vocabulary. Required unless listCategories is true.',
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
44
|
name: 'options.reason',
|
|
44
45
|
type: 'string',
|
|
45
|
-
description:
|
|
46
|
+
description:
|
|
47
|
+
'What capability was missing or difficult, up to 2000 characters. Required unless listCategories is true.',
|
|
46
48
|
},
|
|
47
49
|
{
|
|
48
50
|
name: 'options.detail',
|
|
@@ -65,7 +67,8 @@ export const doc = {
|
|
|
65
67
|
{
|
|
66
68
|
name: 'options.listCategories',
|
|
67
69
|
type: 'boolean',
|
|
68
|
-
description:
|
|
70
|
+
description:
|
|
71
|
+
'Return categories without resolving a route or writing; the component and every other option are ignored.',
|
|
69
72
|
default: 'false',
|
|
70
73
|
},
|
|
71
74
|
{
|
package/api/hook/hook.type.d.mts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type HookDoc = import("@astryxdesign/cli/authoring").HookDoc;
|
|
5
5
|
export type HookParamDoc = import("@astryxdesign/cli/authoring").HookParamDoc;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* astryx --json hook [--list] [--category X] [--detail names|compact|full]
|
|
8
8
|
*
|
|
9
9
|
* The list view emits ONE `hook.list` type across all three detail levels; the
|
|
10
10
|
* depth is carried in `data.detail` and `data.components` holds the grouped map
|
|
@@ -39,14 +39,14 @@ export type HookBriefEntry = {
|
|
|
39
39
|
import: string;
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* astryx --json hook <name>
|
|
43
43
|
*/
|
|
44
44
|
export type HookDetailResponse = {
|
|
45
45
|
type: "hook.detail";
|
|
46
46
|
data: HookDoc;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* astryx --json hook <name> --params
|
|
50
50
|
*/
|
|
51
51
|
export type HookDetailParamsResponse = {
|
|
52
52
|
type: "hook.detail.params";
|
package/api/hook/hook.type.mjs
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Invocation -> type discriminator
|
|
13
13
|
* ------------------------------------------------------------------
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* (not found)
|
|
14
|
+
* astryx --json hook -> hook.list (data.detail='names')
|
|
15
|
+
* astryx --json hook --list -> hook.list (data.detail='names')
|
|
16
|
+
* astryx --json hook --category State -> hook.list (filtered)
|
|
17
|
+
* astryx --json hook --list --detail compact -> hook.list (data.detail='compact')
|
|
18
|
+
* astryx --json hook --list --detail full -> hook.list (data.detail='full')
|
|
19
|
+
* astryx --json hook useMediaQuery -> hook.detail
|
|
20
|
+
* astryx --json hook useMediaQuery --params -> hook.detail.params
|
|
21
|
+
* (not found) -> CLIError
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
// Re-export the authored-doc types from core so the hook leaves reference these
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
/** @typedef {import('@astryxdesign/cli/authoring').HookParamDoc} HookParamDoc */
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* astryx --json hook [--list] [--category X] [--detail names|compact|full]
|
|
32
32
|
*
|
|
33
33
|
* The list view emits ONE `hook.list` type across all three detail levels; the
|
|
34
34
|
* depth is carried in `data.detail` and `data.components` holds the grouped map
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* astryx --json hook <name>
|
|
60
60
|
* @typedef {object} HookDetailResponse
|
|
61
61
|
* @property {'hook.detail'} type
|
|
62
62
|
* @property {HookDoc} data
|
|
63
63
|
*/
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* astryx --json hook <name> --params
|
|
67
67
|
* @typedef {object} HookDetailParamsResponse
|
|
68
68
|
* @property {'hook.detail.params'} type
|
|
69
69
|
* @property {HookParamDoc[]} data
|
package/api/init/init.doc.mjs
CHANGED
|
@@ -90,6 +90,10 @@ export const doc = {
|
|
|
90
90
|
code: 'ERR_FILE_EXISTS',
|
|
91
91
|
when: 'scaffolding a template would overwrite an existing page.tsx',
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
code: 'ERR_PATH_TRAVERSAL',
|
|
95
|
+
when: 'the template output path resolves outside cwd, for example through a symlinked src directory',
|
|
96
|
+
},
|
|
93
97
|
],
|
|
94
98
|
examples: [
|
|
95
99
|
{label: 'Default setup', code: 'const r = await init();'},
|
package/api/init/init.test.mjs
CHANGED
|
@@ -230,13 +230,40 @@ describe('init() — logger', () => {
|
|
|
230
230
|
errSpy.mockRestore();
|
|
231
231
|
}
|
|
232
232
|
const text = lines.join('\n');
|
|
233
|
-
expect(text).toContain('
|
|
233
|
+
expect(text).toContain('[ok] AI agent docs installed -> AGENTS.md');
|
|
234
234
|
expect(text).toContain(' Next steps:');
|
|
235
235
|
// The exact next-steps block the CLI prints comes from getNextSteps().
|
|
236
236
|
expect(text).toContain(getNextSteps('npx astryx')[2].slice(0, 20));
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
+
describe('init() — ASCII output', () => {
|
|
241
|
+
it('prints only ASCII on the default, all-features, re-run, template, and remove paths', async () => {
|
|
242
|
+
/** @type {string[]} */
|
|
243
|
+
const lines = [];
|
|
244
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation((...a) => lines.push(a.join(' ')));
|
|
245
|
+
const errSpy = vi.spyOn(console, 'error').mockImplementation((...a) => lines.push(a.join(' ')));
|
|
246
|
+
const empty = fs.mkdtempSync(path.join(process.cwd(), '.astryx-init-remove-'));
|
|
247
|
+
logger.setSilent(false);
|
|
248
|
+
try {
|
|
249
|
+
await init({}, {cwd: tmpDir});
|
|
250
|
+
await init({all: true}, {cwd: tmpDir});
|
|
251
|
+
await init({all: true}, {cwd: tmpDir});
|
|
252
|
+
await init({features: 'template', templateName: 'blank'}, {cwd: tmpDir});
|
|
253
|
+
await init({removeAgents: true}, {cwd: tmpDir});
|
|
254
|
+
await init({removeAgents: true}, {cwd: empty});
|
|
255
|
+
} finally {
|
|
256
|
+
logger.setSilent(true);
|
|
257
|
+
logSpy.mockRestore();
|
|
258
|
+
errSpy.mockRestore();
|
|
259
|
+
fs.rmSync(empty, {recursive: true, force: true});
|
|
260
|
+
}
|
|
261
|
+
expect(lines.length).toBeGreaterThan(0);
|
|
262
|
+
expect(lines.some(line => line.startsWith('[ok] Removed'))).toBe(true);
|
|
263
|
+
expect(lines.filter(line => /[\u0080-\uFFFF]/.test(line))).toEqual([]);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
240
267
|
describe('init() — write-path safety', () => {
|
|
241
268
|
it('template scaffold refuses to clobber an existing page.tsx', async () => {
|
|
242
269
|
const dest = path.join(tmpDir, 'src', 'pages', 'blank');
|
|
@@ -260,4 +287,17 @@ describe('init() — write-path safety', () => {
|
|
|
260
287
|
init({features: 'template', templateName: '../../etc/evil'}, {cwd: tmpDir}),
|
|
261
288
|
).rejects.toMatchObject({code: ERROR_CODES.ERR_UNKNOWN_TEMPLATE});
|
|
262
289
|
});
|
|
290
|
+
|
|
291
|
+
it('refuses a template write that a symlinked src would carry outside cwd (ERR_PATH_TRAVERSAL)', async () => {
|
|
292
|
+
const outside = fs.mkdtempSync(path.join(process.cwd(), '.astryx-init-outside-'));
|
|
293
|
+
try {
|
|
294
|
+
fs.symlinkSync(outside, path.join(tmpDir, 'src'), 'dir');
|
|
295
|
+
await expect(
|
|
296
|
+
init({features: 'template', templateName: 'blank'}, {cwd: tmpDir}),
|
|
297
|
+
).rejects.toMatchObject({code: ERROR_CODES.ERR_PATH_TRAVERSAL});
|
|
298
|
+
expect(fs.readdirSync(outside)).toEqual([]);
|
|
299
|
+
} finally {
|
|
300
|
+
fs.rmSync(outside, {recursive: true, force: true});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
263
303
|
});
|
|
@@ -24,6 +24,6 @@ import {logger} from '../../logger.mjs';
|
|
|
24
24
|
*/
|
|
25
25
|
export async function remove({cwd = process.cwd()} = {}) {
|
|
26
26
|
removeAgentDocs(cwd);
|
|
27
|
-
logger.log('
|
|
27
|
+
logger.log('[ok] AI agent docs removed.');
|
|
28
28
|
return {type: 'init.remove', data: {removed: true}};
|
|
29
29
|
}
|