@astryxdesign/cli 0.7.3-canary.f94e962 → 0.7.3
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/CHANGELOG.md +115 -0
- package/README.md +68 -68
- package/api/build/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -18
- package/api/build/blocks/blocks.mjs +475 -116
- package/api/build/blocks/blocks.test.mjs +191 -61
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +9 -5
- package/api/build/kit/answer.mjs +123 -13
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +19 -0
- package/api/build/kit/signals.mjs +18 -7
- package/api/build/kit/weights.d.mts +8 -22
- package/api/build/kit/weights.mjs +87 -8
- package/api/build/kit/weights.test.mjs +96 -0
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +37 -29
- package/api/component/_adapter.mjs +39 -5
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +1 -1
- package/api/component/doc-links.test.mjs +2 -2
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +65 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/_adapter.d.mts +33 -13
- package/api/doctor/_adapter.mjs +55 -25
- package/api/doctor/doctor.d.mts +23 -5
- package/api/doctor/doctor.mjs +97 -28
- package/api/doctor/doctor.test.mjs +67 -9
- package/api/hook/hook.mjs +1 -1
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +12 -1
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +48 -7
- package/api/integration/validate-integration.type.d.mts +36 -5
- package/api/integration/validate-integration.type.mjs +27 -6
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +35 -17
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/template/template.mjs +5 -1
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +5 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/outside-project.test.mjs +99 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/index.mjs +35 -93
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +7 -6
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +135 -8
- package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/release/cache.test.mjs +24 -21
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
|
@@ -392,6 +392,97 @@ describe('doctor: the computer-level agent text', () => {
|
|
|
392
392
|
const A = '/home/me/.agents/skills/astryx/SKILL.md';
|
|
393
393
|
const C = '/home/me/.claude/skills/astryx';
|
|
394
394
|
|
|
395
|
+
it('a skill naming `astryx` with no Astryx CLI on the search path: says whether it is current, and names the step it records', () => {
|
|
396
|
+
const check = (/** @type {Record<string, any>} */ over) =>
|
|
397
|
+
checkComputerAgentText({
|
|
398
|
+
nodeVersion: '22.13.0',
|
|
399
|
+
answeredBy: {cli: '1.2.0', core: '1.2.0', copy: 'carried'},
|
|
400
|
+
latest: null,
|
|
401
|
+
agentText: [{path: A, state: 'current'}],
|
|
402
|
+
agentTextCommand: 'astryx',
|
|
403
|
+
searchPathCommands: [],
|
|
404
|
+
cwd: os.tmpdir(),
|
|
405
|
+
...over,
|
|
406
|
+
});
|
|
407
|
+
const recorded = check({agentTextInstall: 'pnpm add -g @astryxdesign/cli'});
|
|
408
|
+
// A package runner's own copy first on the search path does not count.
|
|
409
|
+
expect(
|
|
410
|
+
check({
|
|
411
|
+
agentTextInstall: 'pnpm add -g @astryxdesign/cli',
|
|
412
|
+
searchPathCommands: [
|
|
413
|
+
/** @type {any} */ ({
|
|
414
|
+
file: '/tmp/_npx/r/node_modules/.bin/astryx',
|
|
415
|
+
astryx: true,
|
|
416
|
+
runner: true,
|
|
417
|
+
}),
|
|
418
|
+
],
|
|
419
|
+
}).fix,
|
|
420
|
+
).toBe(
|
|
421
|
+
'Run `pnpm add -g @astryxdesign/cli`, the step the skill names for when `astryx` is not found.',
|
|
422
|
+
);
|
|
423
|
+
expect(recorded.status).toBe('info');
|
|
424
|
+
expect(recorded.message).toContain(
|
|
425
|
+
`The computer-level agent text matches this release: ${A}. It tells agents to run \`astryx\`, but no \`astryx\` command is on the search path`,
|
|
426
|
+
);
|
|
427
|
+
expect(recorded.fix).toBe(
|
|
428
|
+
'Run `pnpm add -g @astryxdesign/cli`, the step the skill names for when `astryx` is not found.',
|
|
429
|
+
);
|
|
430
|
+
// A skill from an earlier release records no step: npm's, worded as
|
|
431
|
+
// cli-on-path words it.
|
|
432
|
+
const older = check({
|
|
433
|
+
agentText: [{path: A, state: 'differs'}],
|
|
434
|
+
agentTextInstall: null,
|
|
435
|
+
});
|
|
436
|
+
expect(older.message).toContain(
|
|
437
|
+
"The computer-level agent text differs from this release's",
|
|
438
|
+
);
|
|
439
|
+
expect(older.fix).toBe(
|
|
440
|
+
'Install it for the computer: `npm i -g @astryxdesign/cli`.',
|
|
441
|
+
);
|
|
442
|
+
// With the Astryx CLI anywhere on the search path, even behind another
|
|
443
|
+
// program (cli-on-path's to report), or a skill naming a host's command,
|
|
444
|
+
// there is nothing to restore.
|
|
445
|
+
for (const over of [
|
|
446
|
+
{
|
|
447
|
+
searchPathCommands: [
|
|
448
|
+
/** @type {any} */ ({
|
|
449
|
+
file: '/usr/bin/astryx',
|
|
450
|
+
astryx: true,
|
|
451
|
+
version: '1.2.0',
|
|
452
|
+
}),
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
searchPathCommands: [
|
|
457
|
+
/** @type {any} */ ({file: '/opt/other/astryx', astryx: false}),
|
|
458
|
+
/** @type {any} */ ({
|
|
459
|
+
file: '/usr/bin/astryx',
|
|
460
|
+
astryx: true,
|
|
461
|
+
version: '1.2.0',
|
|
462
|
+
}),
|
|
463
|
+
],
|
|
464
|
+
},
|
|
465
|
+
{agentTextCommand: 'acme astryx'},
|
|
466
|
+
// An `astryx` the scan cannot trace (a Volta, asdf or mise shim, or
|
|
467
|
+
// another program): it may run the CLI, so no report here.
|
|
468
|
+
{
|
|
469
|
+
searchPathCommands: [
|
|
470
|
+
/** @type {any} */ ({
|
|
471
|
+
file: '/home/me/.volta/bin/astryx',
|
|
472
|
+
astryx: false,
|
|
473
|
+
runner: false,
|
|
474
|
+
}),
|
|
475
|
+
],
|
|
476
|
+
},
|
|
477
|
+
// Only a package runner's own copy: the CLI is still gone.
|
|
478
|
+
]) {
|
|
479
|
+
const other = check(over);
|
|
480
|
+
expect(other.message).toBe(
|
|
481
|
+
`The computer-level agent text matches this release: ${A}.`,
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
395
486
|
it('present and current, linked: no fix', () => {
|
|
396
487
|
const check = at([
|
|
397
488
|
{path: A, state: 'current'},
|
|
@@ -460,6 +551,14 @@ describe('doctor: the computer-level agent text', () => {
|
|
|
460
551
|
const home = tmpDir('home');
|
|
461
552
|
vi.stubEnv('HOME', home);
|
|
462
553
|
vi.stubEnv('USERPROFILE', home);
|
|
554
|
+
// The CLI installed for the computer, first on the search path, as the
|
|
555
|
+
// skill expects.
|
|
556
|
+
const bin = tmpDir('bin');
|
|
557
|
+
fs.symlinkSync(
|
|
558
|
+
path.join(CLI_ROOT, 'clients', 'cli', 'bin', 'astryx.mjs'),
|
|
559
|
+
path.join(bin, 'astryx'),
|
|
560
|
+
);
|
|
561
|
+
vi.stubEnv('PATH', `${bin}${path.delimiter}${process.env.PATH ?? ''}`);
|
|
463
562
|
try {
|
|
464
563
|
const find = r =>
|
|
465
564
|
r.envelope.data.checks.find(c => c.id === 'computer-agent-text');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for `astryx postinstall`. A hidden, CLI-only hook with no
|
|
5
|
+
* wrapped API function (so no `fn`): it prints the welcome box.
|
|
6
|
+
* @position packages/cli/clients/cli/commands — command documentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
10
|
+
export const doc = {
|
|
11
|
+
type: 'command',
|
|
12
|
+
name: 'postinstall',
|
|
13
|
+
displayName: 'astryx postinstall',
|
|
14
|
+
namespace: 'cli/commands',
|
|
15
|
+
summary: 'Print the welcome message shown after install',
|
|
16
|
+
description:
|
|
17
|
+
'Prints a short welcome box that names the first commands to run. It is hidden ' +
|
|
18
|
+
'from help and the manifest, looks nothing up, and does not support --json.',
|
|
19
|
+
examples: [{label: 'Print the welcome box', cli: 'astryx postinstall'}],
|
|
20
|
+
outsideProject: 'same',
|
|
21
|
+
exitCodes: [{code: 0, when: 'success'}],
|
|
22
|
+
related: ['init'],
|
|
23
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file postinstall command — the hidden `astryx postinstall` hook.
|
|
5
|
+
*
|
|
6
|
+
* Prints the welcome box (lib/welcome-box.mjs). Hidden from help and the
|
|
7
|
+
* manifest; it looks nothing up and does not support --json.
|
|
8
|
+
*
|
|
9
|
+
* The command surface comes from the colocated CommandDoc via `defineCommand`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
13
|
+
import {emit, code} from '../formatters/index.mjs';
|
|
14
|
+
import {defineCommand} from '../lib/define-command.mjs';
|
|
15
|
+
import {welcomeBox} from '../lib/welcome-box.mjs';
|
|
16
|
+
import {NO_RESULT_SET} from '../../../foundation/debug/index.mjs';
|
|
17
|
+
import {doc as postinstallCommand} from './postinstall.doc.mjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {import('commander').Command} program
|
|
21
|
+
*/
|
|
22
|
+
export function registerPostinstall(program) {
|
|
23
|
+
defineCommand(program, postinstallCommand, {
|
|
24
|
+
hidden: true,
|
|
25
|
+
action: () => {
|
|
26
|
+
emit(code(welcomeBox(getCliInvocation())));
|
|
27
|
+
// Prints the welcome box. Nothing is looked up.
|
|
28
|
+
return NO_RESULT_SET;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -202,6 +202,23 @@ describe('enforcement layer 3 — per-command setup nudge', () => {
|
|
|
202
202
|
expect(r.stderr).toMatch(NUDGE);
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
+
// A nested package.json that is not the project's (spec AST-040 FR9): the
|
|
206
|
+
// reminder sends the person to the project's folder, never adds the CLI to
|
|
207
|
+
// the nested package.json (spec AST-081 FR2).
|
|
208
|
+
it("in a nested package whose package.json is not the project's, says to run from the project's folder", async () => {
|
|
209
|
+
write('package.json', JSON.stringify({name: 'app', dependencies: {'@astryxdesign/core': '0.7.0'}}));
|
|
210
|
+
write('package-lock.json', '{}');
|
|
211
|
+
write('functions/package.json', '{"name":"functions"}');
|
|
212
|
+
const r = await runCli(['docs', 'tokens'], path.join(tmp, 'functions'));
|
|
213
|
+
// Only `cd` comes first, so the app has no CLI of its own yet: the
|
|
214
|
+
// command is the scoped package at the answering release, never the bare
|
|
215
|
+
// `astryx` name a package runner would fetch from the registry.
|
|
216
|
+
const {version} = JSON.parse(fs.readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));
|
|
217
|
+
expect(r.stderr.trim()).toBe(
|
|
218
|
+
`Next step: run \`cd ${tmp}\`, then \`npx @astryxdesign/cli@${version} init\` to finish setup and install the Astryx agent prompt.`,
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
|
|
205
222
|
// Inside a git repository the project-root check above adds nothing to the
|
|
206
223
|
// walk up to the repository root: the same outcomes as without it.
|
|
207
224
|
it('inside a repository, is quiet in a nested package once init has written the docs at the project root', async () => {
|
|
@@ -96,7 +96,7 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
|
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Path to this CLI's real entry (clients/cli/bin/astryx.mjs), resolved from
|
|
99
|
-
* this module's location (clients/cli/commands/
|
|
99
|
+
* this module's location (clients/cli/commands/theme.mjs → ../bin/
|
|
100
100
|
* astryx.mjs). Used to re-invoke `theme build` as a child process in watch mode.
|
|
101
101
|
*/
|
|
102
102
|
function resolveCliBin() {
|
package/clients/cli/index.mjs
CHANGED
|
@@ -16,22 +16,19 @@ import {Command, Option} from 'commander';
|
|
|
16
16
|
import {fileURLToPath} from 'node:url';
|
|
17
17
|
import * as fs from 'node:fs';
|
|
18
18
|
import * as path from 'node:path';
|
|
19
|
-
import {formatCliCommand, getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
19
|
+
import {formatCliCommand, getCliInvocation, quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
|
|
20
20
|
import {hasRecordedProject} from '../../foundation/env/cli-command.mjs';
|
|
21
21
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
22
22
|
import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
|
|
23
23
|
import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';
|
|
24
|
-
import {
|
|
25
|
-
import {projectRootOf} from '../../foundation/release/choose.mjs';
|
|
26
|
-
import {readReleaseFacts} from '../../foundation/release/project.mjs';
|
|
24
|
+
import {cliInstallAdvice, installFolder} from '../../foundation/release/notices.mjs';
|
|
27
25
|
import {buildManifest} from './lib/manifest.mjs';
|
|
28
26
|
import {cliError} from './lib/cli-error.mjs';
|
|
29
|
-
import {
|
|
27
|
+
import {section, text, records} from './formatters/index.mjs';
|
|
30
28
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
31
29
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
32
30
|
import {installJsonShim} from './lib/json-shim.mjs';
|
|
33
|
-
import {
|
|
34
|
-
import {doc as manifestDoc} from './commands/manifest.doc.mjs';
|
|
31
|
+
import {markReportsResult} from './lib/define-command.mjs';
|
|
35
32
|
import {
|
|
36
33
|
agentDocsTargetDir,
|
|
37
34
|
assertAgentDocsTarget,
|
|
@@ -297,7 +294,7 @@ function captureInvocation(actionCommand, root) {
|
|
|
297
294
|
*/
|
|
298
295
|
const commands = [
|
|
299
296
|
{name: 'init', path: './commands/init.mjs', register: 'registerInit'},
|
|
300
|
-
{name: 'component', path: './commands/component
|
|
297
|
+
{name: 'component', path: './commands/component.mjs', register: 'registerComponent'},
|
|
301
298
|
{name: 'docs', path: './commands/docs.mjs', register: 'registerDocs'},
|
|
302
299
|
{name: 'blog', path: './commands/blog.mjs', register: 'registerBlog'},
|
|
303
300
|
{name: 'swizzle', path: './commands/swizzle.mjs', register: 'registerSwizzle'},
|
|
@@ -305,13 +302,17 @@ const commands = [
|
|
|
305
302
|
// agent-docs folded into init — functions still importable from agent-docs.mjs
|
|
306
303
|
{name: 'template', path: './commands/template.mjs', register: 'registerTemplate'},
|
|
307
304
|
{name: 'upgrade', path: './commands/upgrade.mjs', register: 'registerUpgrade'},
|
|
308
|
-
{name: 'theme', path: './commands/
|
|
305
|
+
{name: 'theme', path: './commands/theme.mjs', register: 'registerTheme'},
|
|
309
306
|
{name: 'integration', path: './commands/integration.mjs', register: 'registerIntegration'},
|
|
310
|
-
{name: 'hook', path: './commands/hook
|
|
307
|
+
{name: 'hook', path: './commands/hook.mjs', register: 'registerHook'},
|
|
311
308
|
{name: 'discover', path: './commands/discover.mjs', register: 'registerDiscover'},
|
|
312
309
|
{name: 'search', path: './commands/search.mjs', register: 'registerSearch'},
|
|
313
310
|
{name: 'build', path: './commands/build.mjs', register: 'registerBuild'},
|
|
314
311
|
{name: 'doctor', path: './commands/doctor.mjs', register: 'registerDoctor'},
|
|
312
|
+
// Registered after every other command: the manifest lists the commands in
|
|
313
|
+
// registration order.
|
|
314
|
+
{name: 'manifest', path: './commands/manifest.mjs', register: 'registerManifest'},
|
|
315
|
+
{name: 'postinstall', path: './commands/postinstall.mjs', register: 'registerPostinstall'},
|
|
315
316
|
];
|
|
316
317
|
|
|
317
318
|
const SETUP_NUDGE_EXEMPT = new Set(['init', 'agent-docs']);
|
|
@@ -660,14 +661,33 @@ export async function createProgram() {
|
|
|
660
661
|
// A project with no CLI of its own, answered by another release than its
|
|
661
662
|
// Core's: add the CLI at Core's version first, as the daily hint says,
|
|
662
663
|
// then run that CLI's init (spec AST-081 FR2).
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
// A folder that belongs to no project spec:AST-040 FR9 defines gets no
|
|
665
|
+
// reminder, as outside a project.
|
|
666
|
+
const target = installFolder(cwd);
|
|
667
|
+
if (target == null) return;
|
|
668
|
+
// From a folder inside the project whose package.json is not the
|
|
669
|
+
// project's, init runs from the project's folder. Only `cd` comes
|
|
670
|
+
// before it, so the command is the picker's for that folder, never the
|
|
671
|
+
// bare `astryx` name a package runner would fetch from the registry
|
|
672
|
+
// (spec AST-081 FR5).
|
|
673
|
+
if (target.moved) {
|
|
666
674
|
console.error(
|
|
667
|
-
setupNudge(getCliInvocation(
|
|
675
|
+
setupNudge(getCliInvocation(target.dir), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),
|
|
668
676
|
);
|
|
669
677
|
return;
|
|
670
678
|
}
|
|
679
|
+
const choice = runChoice(cwd);
|
|
680
|
+
if (choice.copy === 'starting' && choice.coreVersion && choice.coreVersion !== choice.version) {
|
|
681
|
+
// The daily hint's comparison and command: add the CLI at Core's
|
|
682
|
+
// version, then run that CLI's init.
|
|
683
|
+
const add = cliInstallAdvice({cwd, core: choice.coreVersion});
|
|
684
|
+
if (add?.command) {
|
|
685
|
+
console.error(
|
|
686
|
+
setupNudge(getCliInvocation(add.root, {installed: true}), {before: add.command}).trimEnd(),
|
|
687
|
+
);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
671
691
|
console.error(setupNudge(getCliInvocation(cwd)).trimEnd());
|
|
672
692
|
} catch {
|
|
673
693
|
// Never let the nudge break a command.
|
|
@@ -677,7 +697,7 @@ export async function createProgram() {
|
|
|
677
697
|
for (const cmd of commands) {
|
|
678
698
|
try {
|
|
679
699
|
const mod = await import(cmd.path);
|
|
680
|
-
mod[cmd.register](program);
|
|
700
|
+
mod[cmd.register](program, {jsonSupported: JSON_SUPPORTED, version: pkg.version});
|
|
681
701
|
} catch (e) {
|
|
682
702
|
// Command fails to load but CLI still works
|
|
683
703
|
const reason = /** @type {any} */ (e).message;
|
|
@@ -697,84 +717,6 @@ export async function createProgram() {
|
|
|
697
717
|
}
|
|
698
718
|
}
|
|
699
719
|
|
|
700
|
-
// Capability manifest — a single, self-describing view of the whole CLI so
|
|
701
|
-
// agents can discover every command, argument, flag, and response type without
|
|
702
|
-
// scraping `--help`. `astryx manifest --json` is the dedicated surface; the bare
|
|
703
|
-
// `xds --json` embeds the same payload under data.manifest for convenience.
|
|
704
|
-
// Intentionally CLI-special — no `api/manifest`. It introspects the live
|
|
705
|
-
// Commander `program`, so extracting it to `api/` would create the `api → cli`
|
|
706
|
-
// cycle from #4302. `buildManifest(program)` lives in lib/; see its header.
|
|
707
|
-
const manifestCommand = program
|
|
708
|
-
.command('manifest')
|
|
709
|
-
.description('Print the full CLI capability manifest (use with --json)')
|
|
710
|
-
.action(() => {
|
|
711
|
-
const manifest = buildManifest(program, {
|
|
712
|
-
jsonSupported: JSON_SUPPORTED,
|
|
713
|
-
version: pkg.version,
|
|
714
|
-
});
|
|
715
|
-
// The manifest IS a result set: one entry per command the CLI ships.
|
|
716
|
-
debug.recordCommandResult(
|
|
717
|
-
debug.resultSet({
|
|
718
|
-
count: manifest.commands.length,
|
|
719
|
-
resultKind: 'command',
|
|
720
|
-
}),
|
|
721
|
-
);
|
|
722
|
-
if (program.opts().json) {
|
|
723
|
-
process.__xdsJsonHandled = true;
|
|
724
|
-
console.log(JSON.stringify({apiVersion: API_VERSION, type: 'manifest', data: manifest, meta: {answeredBy: answeredBy()}}, null, 2));
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
// Human-readable summary as greppable records (agents should use --json).
|
|
728
|
-
// One record per command: name, whether it supports --json, and the
|
|
729
|
-
// description. Field names are the manifest entry's own keys.
|
|
730
|
-
emit(
|
|
731
|
-
section(`${manifest.name} v${manifest.version} (${manifest.commands.length} commands)`),
|
|
732
|
-
records(
|
|
733
|
-
manifest.commands.map(c => ({
|
|
734
|
-
name: c.name,
|
|
735
|
-
json: c.json ? 'yes' : '',
|
|
736
|
-
description: c.description || '',
|
|
737
|
-
})),
|
|
738
|
-
{fields: ['name', 'json', 'description']},
|
|
739
|
-
),
|
|
740
|
-
text(`Run \`${getCliInvocation()} manifest --json\` for the full structured manifest.`),
|
|
741
|
-
);
|
|
742
|
-
});
|
|
743
|
-
addDocHelp(manifestCommand, manifestDoc);
|
|
744
|
-
markReportsResult(manifestCommand);
|
|
745
|
-
|
|
746
|
-
// Hidden command used by package.json postinstall scripts
|
|
747
|
-
const postinstallCommand = program
|
|
748
|
-
.command('postinstall', {hidden: true})
|
|
749
|
-
.action(() => {
|
|
750
|
-
// Prints the welcome box. Nothing is looked up.
|
|
751
|
-
debug.recordCommandResult(debug.NO_RESULT_SET);
|
|
752
|
-
const r = getCliInvocation();
|
|
753
|
-
const pad = (/** @type {string} */ s, /** @type {number} */ len) => s + ' '.repeat(Math.max(0, len - s.length));
|
|
754
|
-
const W = 49; // inner width of the box
|
|
755
|
-
const line = (/** @type {string} */ s) => ` │ ${pad(s, W)}│`;
|
|
756
|
-
console.log(`
|
|
757
|
-
╭${'─'.repeat(W + 2)}╮
|
|
758
|
-
${line('')}
|
|
759
|
-
${line(' Design system installed!')}
|
|
760
|
-
${line('')}
|
|
761
|
-
${line(' Get started:')}
|
|
762
|
-
${line(` ${r} init Setup + AI agent docs`)}
|
|
763
|
-
${line(` ${r} --help See all commands`)}
|
|
764
|
-
${line('')}
|
|
765
|
-
${line(' Or run directly:')}
|
|
766
|
-
${line(` ${r} init Setup + AI agent docs`)}
|
|
767
|
-
${line(` ${r} component Browse component docs`)}
|
|
768
|
-
${line(` ${r} hook Browse hook docs`)}
|
|
769
|
-
${line(` ${r} docs Design system reference`)}
|
|
770
|
-
${line(` ${r} swizzle Customize a component`)}
|
|
771
|
-
${line(` ${r} template Add a page template`)}
|
|
772
|
-
${line('')}
|
|
773
|
-
╰${'─'.repeat(W + 2)}╯
|
|
774
|
-
`);
|
|
775
|
-
});
|
|
776
|
-
markReportsResult(postinstallCommand);
|
|
777
|
-
|
|
778
720
|
// Install the JSON shim AFTER all commands are registered so we can
|
|
779
721
|
// patch outputHelp on every command (root + subcommands). The shim
|
|
780
722
|
// extends the --json contract to cover Commander's parse-time short
|
|
@@ -21,7 +21,7 @@ import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
|
21
21
|
* (→ `.astryx-table-cell`), and `astryx-button` → key `button`.
|
|
22
22
|
*
|
|
23
23
|
* Keep the `astryx-` literal in sync with packages/core/src/naming.ts
|
|
24
|
-
* (NAMESPACE / classPrefix), the same way
|
|
24
|
+
* (NAMESPACE / classPrefix), the same way commands/theme.mjs mirrors it.
|
|
25
25
|
* <!-- SYNC: packages/core/src/naming.ts (namespace prefix source of truth) -->
|
|
26
26
|
* @param {import('@astryxdesign/cli/authoring').ComponentThemingTarget} target
|
|
27
27
|
* @returns {string}
|
|
@@ -63,10 +63,10 @@ export function reportsResultVia(cmd) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Mark a hand-registered command as reporting its result.
|
|
65
65
|
*
|
|
66
|
-
* For
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
* For what does not come from a CommandDoc: the root program, and the stub
|
|
67
|
+
* left behind when a command module fails to load. Every command, `manifest`
|
|
68
|
+
* and the hidden `postinstall` hook included, registers through
|
|
69
|
+
* {@link defineCommand}. These call {@link recordCommandResult} themselves; this
|
|
70
70
|
* says so, and the coverage test pins the set of commands allowed to, so the
|
|
71
71
|
* mark cannot become a quiet way around the contract.
|
|
72
72
|
*
|
|
@@ -105,10 +105,12 @@ export function commandDocsOf(cmd) {
|
|
|
105
105
|
* fn?: import('@astryxdesign/cli/authoring').FunctionDoc,
|
|
106
106
|
* action?: (...args: any[]) => import('../../../foundation/debug/command-result.mjs').CommandResult
|
|
107
107
|
* | Promise<import('../../../foundation/debug/command-result.mjs').CommandResult>,
|
|
108
|
-
*
|
|
108
|
+
* hidden?: boolean,
|
|
109
|
+
* }} [impl] `hidden` keeps the command out of help and the manifest (a
|
|
110
|
+
* package-script hook, not a command for people or agents).
|
|
109
111
|
* @returns {import('commander').Command} the created command.
|
|
110
112
|
*/
|
|
111
|
-
export function defineCommand(parent, doc, {fn, action} = {}) {
|
|
113
|
+
export function defineCommand(parent, doc, {fn, action, hidden} = {}) {
|
|
112
114
|
// The command token is the last path segment ("theme build" -> "build"),
|
|
113
115
|
// since subcommands are added to their group command, not the program.
|
|
114
116
|
const token = doc.name.split(' ').pop() ?? doc.name;
|
|
@@ -119,7 +121,10 @@ export function defineCommand(parent, doc, {fn, action} = {}) {
|
|
|
119
121
|
})
|
|
120
122
|
.join(' ');
|
|
121
123
|
|
|
122
|
-
const cmd = parent.command(
|
|
124
|
+
const cmd = parent.command(
|
|
125
|
+
argSpec ? `${token} ${argSpec}` : token,
|
|
126
|
+
hidden ? {hidden: true} : {},
|
|
127
|
+
);
|
|
123
128
|
Object.defineProperty(cmd, COMMAND_DOCS, {value: {doc, fn}, configurable: true});
|
|
124
129
|
if (doc.summary) cmd.description(doc.summary);
|
|
125
130
|
if (doc.deprecated) {
|
|
@@ -24,6 +24,10 @@ for (const file of fs.readdirSync(COMMANDS).sort()) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const manifest = buildManifest(program, {jsonSupported: JSON_SUPPORTED, version: '0.0.0-test'});
|
|
27
|
+
/** Hidden commands (a package-script hook): documented, never in the manifest. */
|
|
28
|
+
const HIDDEN = new Set(
|
|
29
|
+
program.commands.filter((c) => /** @type {any} */ (c)._hidden).map((c) => c.name()),
|
|
30
|
+
);
|
|
27
31
|
/** @type {Map<string, any>} */
|
|
28
32
|
const entries = new Map();
|
|
29
33
|
const walk = (/** @type {any} */ c) => {
|
|
@@ -98,6 +102,7 @@ describe('command exit codes', () => {
|
|
|
98
102
|
|
|
99
103
|
it('the manifest carries every command exit code', () => {
|
|
100
104
|
for (const doc of commandDocs) {
|
|
105
|
+
if (HIDDEN.has(doc.name)) continue;
|
|
101
106
|
expect(entries.get(doc.name)?.exitCodes, doc.name).toEqual(
|
|
102
107
|
doc.exitCodes.map(({code, when}) => ({code, when})),
|
|
103
108
|
);
|
|
@@ -55,6 +55,10 @@ const CLI_LAYER_TYPES = {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const manifest = buildManifest(program, {jsonSupported: JSON_SUPPORTED, version: '0.0.0-test'});
|
|
58
|
+
/** Hidden commands (a package-script hook): documented, never in the manifest. */
|
|
59
|
+
const HIDDEN = new Set(
|
|
60
|
+
program.commands.filter((c) => /** @type {any} */ (c)._hidden).map((c) => c.name()),
|
|
61
|
+
);
|
|
58
62
|
|
|
59
63
|
/** Flatten the manifest command tree into fully-qualified names. */
|
|
60
64
|
function flatten(cmds, out = []) {
|
|
@@ -116,12 +120,19 @@ describe('manifest: drift guards', () => {
|
|
|
116
120
|
|
|
117
121
|
it('takes every command example from its CommandDoc', () => {
|
|
118
122
|
for (const [name, doc] of commandDocs) {
|
|
123
|
+
if (HIDDEN.has(name)) continue;
|
|
119
124
|
const entry = allEntries.find((c) => c.name === name);
|
|
120
125
|
expect(entry, `CommandDoc "${name}" has no manifest entry`).toBeDefined();
|
|
121
126
|
expect(entry.examples ?? [], name).toEqual((doc.examples ?? []).map((e) => e.cli));
|
|
122
127
|
}
|
|
123
128
|
});
|
|
124
129
|
|
|
130
|
+
it('documents the hidden postinstall hook and keeps it out of the manifest', () => {
|
|
131
|
+
expect([...HIDDEN]).toEqual(['postinstall']);
|
|
132
|
+
expect(commandDocs.has('postinstall')).toBe(true);
|
|
133
|
+
expect(allNames.has('postinstall')).toBe(false);
|
|
134
|
+
});
|
|
135
|
+
|
|
125
136
|
it('lists every response type the wrapped API function returns', () => {
|
|
126
137
|
for (const [name, doc] of commandDocs) {
|
|
127
138
|
if (!doc.fn) continue;
|
|
@@ -152,6 +163,7 @@ describe('manifest: drift guards', () => {
|
|
|
152
163
|
|
|
153
164
|
it('takes response types from the wrapped FunctionDoc, plus CLI-layer envelopes', () => {
|
|
154
165
|
for (const [name, doc] of commandDocs) {
|
|
166
|
+
if (HIDDEN.has(name)) continue;
|
|
155
167
|
const entry = allEntries.find((c) => c.name === name);
|
|
156
168
|
const returns = doc.fn ? functionDocs.get(doc.fn).returns.map((r) => r.type) : [];
|
|
157
169
|
const expected = [...returns, ...(CLI_LAYER_TYPES[name] ?? [])];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The welcome box `astryx postinstall` prints after the package installs.
|
|
5
|
+
*
|
|
6
|
+
* A fixed banner, not tabular output, so it is drawn here rather than with the
|
|
7
|
+
* formatter kit; the command prints it verbatim through `emit(code(...))`.
|
|
8
|
+
* @input The CLI invocation for this project (e.g. `pnpm exec astryx`).
|
|
9
|
+
* @output {@link welcomeBox}
|
|
10
|
+
* @position clients/cli/lib — presentation helper for commands/postinstall.mjs
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Inner width of the box. */
|
|
14
|
+
const W = 49;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} s
|
|
18
|
+
* @param {number} len
|
|
19
|
+
*/
|
|
20
|
+
const pad = (s, len) => s + ' '.repeat(Math.max(0, len - s.length));
|
|
21
|
+
|
|
22
|
+
/** @param {string} s */
|
|
23
|
+
const line = s => ` │ ${pad(s, W)}│`;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The welcome box, with a blank line before and after it.
|
|
27
|
+
* @param {string} r the CLI invocation, e.g. `pnpm exec astryx`
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
export function welcomeBox(r) {
|
|
31
|
+
return `
|
|
32
|
+
╭${'─'.repeat(W + 2)}╮
|
|
33
|
+
${line('')}
|
|
34
|
+
${line(' Design system installed!')}
|
|
35
|
+
${line('')}
|
|
36
|
+
${line(' Get started:')}
|
|
37
|
+
${line(` ${r} init Setup + AI agent docs`)}
|
|
38
|
+
${line(` ${r} --help See all commands`)}
|
|
39
|
+
${line('')}
|
|
40
|
+
${line(' Or run directly:')}
|
|
41
|
+
${line(` ${r} init Setup + AI agent docs`)}
|
|
42
|
+
${line(` ${r} component Browse component docs`)}
|
|
43
|
+
${line(` ${r} hook Browse hook docs`)}
|
|
44
|
+
${line(` ${r} docs Design system reference`)}
|
|
45
|
+
${line(` ${r} swizzle Customize a component`)}
|
|
46
|
+
${line(` ${r} template Add a page template`)}
|
|
47
|
+
${line('')}
|
|
48
|
+
╰${'─'.repeat(W + 2)}╯
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
@@ -82,6 +82,18 @@ export const GEMINI_MD: "GEMINI.md";
|
|
|
82
82
|
export const CURSOR_RULES: ".cursorrules";
|
|
83
83
|
export const HERMES_DOT_MD: ".hermes.md";
|
|
84
84
|
export const HERMES_MD: "HERMES.md";
|
|
85
|
+
/**
|
|
86
|
+
* The page workflow every Astryx agent text gives, written with the command
|
|
87
|
+
* name `astryx`: the project agent docs and the computer-level skill both
|
|
88
|
+
* render these lines, so the two never drift.
|
|
89
|
+
*/
|
|
90
|
+
export const WORKFLOW_TITLE: "WORKFLOW \u2014 start every page from a template, never from scratch:";
|
|
91
|
+
export const WORKFLOW_STEPS: readonly string[];
|
|
92
|
+
/**
|
|
93
|
+
* The self-check's fix for a project with no StyleX or Tailwind compiler,
|
|
94
|
+
* and for an agent outside a project.
|
|
95
|
+
*/
|
|
96
|
+
export const SELF_CHECK_CSS: "replace any raw <div>/<span>, imported .css/@apply, or hardcoded #hex/px with the component or a token";
|
|
85
97
|
export const MARKER_START: "<!-- ASTRYX:START -->";
|
|
86
98
|
export const MARKER_END: "<!-- ASTRYX:END -->";
|
|
87
99
|
export const LEGACY_MARKER_START: "<!-- XDS:START -->";
|
|
@@ -34,6 +34,26 @@ export const CURSOR_RULES = '.cursorrules';
|
|
|
34
34
|
export const HERMES_DOT_MD = '.hermes.md';
|
|
35
35
|
export const HERMES_MD = 'HERMES.md';
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The page workflow every Astryx agent text gives, written with the command
|
|
39
|
+
* name `astryx`: the project agent docs and the computer-level skill both
|
|
40
|
+
* render these lines, so the two never drift.
|
|
41
|
+
*/
|
|
42
|
+
export const WORKFLOW_TITLE =
|
|
43
|
+
'WORKFLOW — start every page from a template, never from scratch:';
|
|
44
|
+
export const WORKFLOW_STEPS = Object.freeze([
|
|
45
|
+
'1. `astryx build "<idea>"` — names the template to scaffold from and the parts it lacks.',
|
|
46
|
+
'2. `astryx template <name> <path>` — scaffold it; keep its frame, gap and padding; replace the content.',
|
|
47
|
+
'3. `astryx template <Block>` for parts it lacks; `astryx component <Name>` to read props before using one.',
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The self-check's fix for a project with no StyleX or Tailwind compiler,
|
|
52
|
+
* and for an agent outside a project.
|
|
53
|
+
*/
|
|
54
|
+
export const SELF_CHECK_CSS =
|
|
55
|
+
'replace any raw <div>/<span>, imported .css/@apply, or hardcoded #hex/px with the component or a token';
|
|
56
|
+
|
|
37
57
|
export const MARKER_START = '<!-- ASTRYX:START -->';
|
|
38
58
|
export const MARKER_END = '<!-- ASTRYX:END -->';
|
|
39
59
|
// Legacy markers — read during migration so the script finds existing XDS blocks
|
|
@@ -91,7 +111,9 @@ export function holdsAstryxBlock(content) {
|
|
|
91
111
|
while (at !== -1) {
|
|
92
112
|
const from = at + marker.length;
|
|
93
113
|
const end = content.indexOf('<!--', from);
|
|
94
|
-
const inner = (
|
|
114
|
+
const inner = (
|
|
115
|
+
end === -1 ? content.slice(from) : content.slice(from, end)
|
|
116
|
+
).trim();
|
|
95
117
|
if (!/^@\S+$/.test(inner)) return true;
|
|
96
118
|
at = content.indexOf(marker, from);
|
|
97
119
|
}
|
|
@@ -153,7 +175,7 @@ export function isAstryxPromptInReach(startDir = process.cwd()) {
|
|
|
153
175
|
* @returns {string | null}
|
|
154
176
|
*/
|
|
155
177
|
function findRepositoryRoot(start) {
|
|
156
|
-
for (let dir = start; ;
|
|
178
|
+
for (let dir = start; ;) {
|
|
157
179
|
if (fs.existsSync(path.join(dir, '.git'))) return dir;
|
|
158
180
|
const parent = path.dirname(dir);
|
|
159
181
|
if (parent === dir) return null;
|