@astryxdesign/cli 0.7.3-canary.ca48bb7 → 0.7.3-canary.cac3d8d
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/api/build/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -20
- package/api/build/blocks/blocks.mjs +472 -196
- package/api/build/blocks/blocks.test.mjs +185 -168
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +4 -1
- package/api/build/kit/answer.mjs +11 -3
- package/api/build/kit/signals.d.mts +11 -0
- package/api/build/kit/signals.mjs +8 -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 +27 -27
- package/api/component/_adapter.mjs +39 -5
- 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.mjs +4 -0
- 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 +81 -16
- package/api/doctor/doctor.test.mjs +58 -0
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/template/template.mjs +5 -1
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/outside-project.test.mjs +99 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/index.mjs +25 -8
- 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 +5 -5
- 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/integrations/public-imports.mjs +1 -1
- 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/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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file An integration's own block answers a query that names it, though no
|
|
5
|
+
* learned table lists it: its authored display name is a title search reads,
|
|
6
|
+
* so "rich text editor" finds the rich text package's block first and build
|
|
7
|
+
* offers it, while a variant label that does not name the block (Lab's "Inside
|
|
8
|
+
* a card") captures nothing.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import {fileURLToPath} from 'node:url';
|
|
15
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
16
|
+
import {search} from './search.mjs';
|
|
17
|
+
import {build} from '../build/build.mjs';
|
|
18
|
+
|
|
19
|
+
const SLOW = 60_000;
|
|
20
|
+
const packages = path.resolve(
|
|
21
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
22
|
+
'../../..',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
describe('an integration block found by its display name', () => {
|
|
26
|
+
/** @type {string} */
|
|
27
|
+
let dir;
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-integration-block-'));
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
path.join(dir, 'package.json'),
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
name: 'consumer',
|
|
34
|
+
dependencies: {
|
|
35
|
+
'@astryxdesign/core': '*',
|
|
36
|
+
'@astryxdesign/richtext': '*',
|
|
37
|
+
'@astryxdesign/lab': '*',
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
const scope = path.join(dir, 'node_modules', '@astryxdesign');
|
|
42
|
+
fs.mkdirSync(scope, {recursive: true});
|
|
43
|
+
for (const name of ['core', 'richtext', 'lab'])
|
|
44
|
+
fs.symlinkSync(path.join(packages, name), path.join(scope, name), 'dir');
|
|
45
|
+
});
|
|
46
|
+
afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
47
|
+
|
|
48
|
+
it.each(['rich text editor', 'rich text', 'text editor'])(
|
|
49
|
+
'`%s` ranks the rich text block first among templates',
|
|
50
|
+
async query => {
|
|
51
|
+
const {results} = (await search(query, {cwd: dir, type: 'template'}))
|
|
52
|
+
.data;
|
|
53
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
54
|
+
name: 'RichTextEditorShowcase',
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
SLOW,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
it(
|
|
61
|
+
'a whole display name names the block outright',
|
|
62
|
+
async () => {
|
|
63
|
+
const {results} = (
|
|
64
|
+
await search('rich text editor', {cwd: dir, type: 'template'})
|
|
65
|
+
).data;
|
|
66
|
+
expect(results[0]).toMatchObject({
|
|
67
|
+
name: 'RichTextEditorShowcase',
|
|
68
|
+
reason: 'exact name',
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
SLOW,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
it(
|
|
75
|
+
"a variant label that does not name the block's subject is no title",
|
|
76
|
+
async () => {
|
|
77
|
+
const {results} = (
|
|
78
|
+
await search('table inside a card', {cwd: dir, type: 'template'})
|
|
79
|
+
).data;
|
|
80
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
81
|
+
name: 'TableInCard',
|
|
82
|
+
});
|
|
83
|
+
const kit = (await build('a settings form inside a card', {cwd: dir}))
|
|
84
|
+
.data;
|
|
85
|
+
expect(kit.blocks[0]?.name).not.toBe('CommentsInCard');
|
|
86
|
+
},
|
|
87
|
+
SLOW,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
it(
|
|
91
|
+
'build offers the rich text block for a request that names it',
|
|
92
|
+
async () => {
|
|
93
|
+
const kit = (
|
|
94
|
+
await build('a comment box with a rich text editor', {cwd: dir})
|
|
95
|
+
).data;
|
|
96
|
+
expect(kit.blocks.map(b => b.name)).toContain('RichTextEditorShowcase');
|
|
97
|
+
},
|
|
98
|
+
SLOW,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '../../foundation/discovery/template-adapter.mjs';
|
|
25
25
|
import {AstryxError} from '../error.mjs';
|
|
26
26
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
27
|
+
import {orderByAffinity} from '../../foundation/text/suggest-order.mjs';
|
|
27
28
|
import {templateList} from './list/list.mjs';
|
|
28
29
|
import {templateShow} from './show/show.mjs';
|
|
29
30
|
import {templateSkeleton} from './skeleton/skeleton.mjs';
|
|
@@ -188,7 +189,10 @@ export async function template(name, options = {}) {
|
|
|
188
189
|
if (name && candidates.length === 0) {
|
|
189
190
|
throw new AstryxError(
|
|
190
191
|
`Unknown template "${name}"`,
|
|
191
|
-
templates
|
|
192
|
+
orderByAffinity(name, templates, t => [t.dirName, t.name]).map(t => ({
|
|
193
|
+
name: t.dirName,
|
|
194
|
+
reason: `${t.type} template`,
|
|
195
|
+
})),
|
|
192
196
|
ERROR_CODES.ERR_UNKNOWN_TEMPLATE,
|
|
193
197
|
);
|
|
194
198
|
}
|
|
@@ -24,6 +24,9 @@ export const docs = {
|
|
|
24
24
|
'docker',
|
|
25
25
|
'read-only home',
|
|
26
26
|
'cache the release cache',
|
|
27
|
+
'agent machine',
|
|
28
|
+
'restart',
|
|
29
|
+
'ephemeral machine',
|
|
27
30
|
],
|
|
28
31
|
description:
|
|
29
32
|
"What Astryx does in CI and containers: no update checks or notices, the project's version as always, and how to cache versions or work with a read-only home folder.",
|
|
@@ -74,6 +77,16 @@ export const docs = {
|
|
|
74
77
|
},
|
|
75
78
|
],
|
|
76
79
|
},
|
|
80
|
+
{
|
|
81
|
+
id: 'short-lived',
|
|
82
|
+
title: 'Machines that keep only the home folder',
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'prose',
|
|
86
|
+
text: 'Some agent machines keep the home folder across restarts but not system folders. A global install there disappears on restart while the agent guide in the home folder stays, so agents are told to run a global astryx command that is gone; the guide says to run the command that installed the CLI, such as `npm i -g @astryxdesign/cli`, when that command is not found, and `astryx doctor` names the same step. To keep the CLI across restarts, install it into a folder in your home and put its `bin` folder on your PATH, as for a permission error ({@link generic:install-once}), or run that command when the machine starts.',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
77
90
|
{
|
|
78
91
|
id: 'more',
|
|
79
92
|
title: 'More on global mode',
|
|
@@ -21,7 +21,7 @@ export const doc = {
|
|
|
21
21
|
"the docs the CLI reads, the newest release the computer knows of, with the install and upgrade commands when the project's release is older, and every `astryx` command on the search path, warning when the first one is not the Astryx CLI or predates the hand-off. It writes nothing, but loading astryx.config runs that file's code. " +
|
|
22
22
|
'The `integration` subcommands provide authoring checks for one integration package. ' +
|
|
23
23
|
'Outside a project it checks the computer instead: the Node version, the release that answered, ' +
|
|
24
|
-
|
|
24
|
+
"the newest release this computer knows of, with the command that upgrades the CLI installed for the computer when it is older, the astryx commands on the search path, the integrations installed for the computer (warning about one it skips), and whether the computer-level agent text (`astryx init --user`) is present, matches this release, was edited, or is turned off (info only); when that text names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, it says so and names the install step the text records, or npm's when it records none. " +
|
|
25
25
|
'It never fails a check because the folder has no project.',
|
|
26
26
|
fn: 'doctor',
|
|
27
27
|
subcommands: ['integration'],
|
|
@@ -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');
|
|
@@ -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 () => {
|
package/clients/cli/index.mjs
CHANGED
|
@@ -16,14 +16,12 @@ 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
27
|
import {section, text, records} from './formatters/index.mjs';
|
|
@@ -663,14 +661,33 @@ export async function createProgram() {
|
|
|
663
661
|
// A project with no CLI of its own, answered by another release than its
|
|
664
662
|
// Core's: add the CLI at Core's version first, as the daily hint says,
|
|
665
663
|
// then run that CLI's init (spec AST-081 FR2).
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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) {
|
|
669
674
|
console.error(
|
|
670
|
-
setupNudge(getCliInvocation(
|
|
675
|
+
setupNudge(getCliInvocation(target.dir), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),
|
|
671
676
|
);
|
|
672
677
|
return;
|
|
673
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
|
+
}
|
|
674
691
|
console.error(setupNudge(getCliInvocation(cwd)).trimEnd());
|
|
675
692
|
} catch {
|
|
676
693
|
// Never let the nudge break a command.
|
|
@@ -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;
|
|
@@ -58,6 +58,9 @@ import {
|
|
|
58
58
|
discoverAgentDocs,
|
|
59
59
|
isAstryxInitialized,
|
|
60
60
|
isAstryxPromptInReach,
|
|
61
|
+
SELF_CHECK_CSS,
|
|
62
|
+
WORKFLOW_STEPS,
|
|
63
|
+
WORKFLOW_TITLE,
|
|
61
64
|
} from './agent-doc-state.mjs';
|
|
62
65
|
|
|
63
66
|
// The agent-doc locations, markers, and the setup-state predicates
|
|
@@ -762,10 +765,7 @@ export function generateCompressedIndex(
|
|
|
762
765
|
// Workflow — `build` is the front door, and every page starts from the
|
|
763
766
|
// template it names. build/template/component are covered here, so they are
|
|
764
767
|
// intentionally omitted from the command reference below.
|
|
765
|
-
lines.push(
|
|
766
|
-
lines.push('1. `astryx build "<idea>"` — names the template to scaffold from and the parts it lacks.');
|
|
767
|
-
lines.push('2. `astryx template <name> <path>` — scaffold it; keep its frame, gap and padding; replace the content.');
|
|
768
|
-
lines.push('3. `astryx template <Block>` for parts it lacks; `astryx component <Name>` to read props before using one.');
|
|
768
|
+
lines.push(WORKFLOW_TITLE, ...WORKFLOW_STEPS);
|
|
769
769
|
lines.push('Changing an existing page? Keep it: skip step 2 and add blocks/components inside its sections.');
|
|
770
770
|
lines.push('');
|
|
771
771
|
|
|
@@ -793,7 +793,7 @@ export function generateCompressedIndex(
|
|
|
793
793
|
'replace any className=, style={{…}}, raw <div>/<span>, imported .css/@apply, or hardcoded #hex/px with the component or the xstyle prop + a token',
|
|
794
794
|
tailwind:
|
|
795
795
|
'replace any style={{…}}, raw <div>/<span>, imported .css/@apply, or hardcoded/arbitrary value (bg-[#fff], p-[13px]) with the component or a token-backed utility',
|
|
796
|
-
css:
|
|
796
|
+
css: SELF_CHECK_CSS,
|
|
797
797
|
};
|
|
798
798
|
lines.push(
|
|
799
799
|
`- SELF-CHECK: re-read the file; ${selfCheckFix[stylingSystem] ?? selfCheckFix.css}.`,
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* What to do when the `astryx` command the text names is not found, as on a
|
|
6
|
+
* machine whose home folder outlives its system folders: the skill file
|
|
7
|
+
* survives a restart while the CLI installed for the computer does not.
|
|
8
|
+
* @param {string} install the install step
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function computerRestoreLine(install: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The install step the text names. `judge`: the step a file is judged by, the
|
|
14
|
+
* one it records first, so every copy of one release, two global installs
|
|
15
|
+
* included, finds the same text current. `write`: the step a write records,
|
|
16
|
+
* the global copy's own first, since only the CLI installed for the computer
|
|
17
|
+
* chooses it. Either way npm's when there is no other.
|
|
18
|
+
* @param {{cliRoot?: string, home?: string, for?: 'judge' | 'write'}} [options]
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function computerInstallStep({ cliRoot, home, for: use, }?: {
|
|
22
|
+
cliRoot?: string;
|
|
23
|
+
home?: string;
|
|
24
|
+
for?: "judge" | "write";
|
|
25
|
+
}): string;
|
|
26
|
+
/**
|
|
27
|
+
* The install step a skill file's text records, or null when it records
|
|
28
|
+
* none.
|
|
29
|
+
* @param {string} content
|
|
30
|
+
* @returns {string | null}
|
|
31
|
+
*/
|
|
32
|
+
export function skillInstallStepOf(content: string): string | null;
|
|
4
33
|
/**
|
|
5
34
|
* A home-folder path as a person reads it: `~/.claude/skills/astryx`.
|
|
6
35
|
* @param {string} file
|
|
@@ -32,13 +61,21 @@ export function computerSkillLinks(home?: string): Array<{
|
|
|
32
61
|
* @returns {string}
|
|
33
62
|
*/
|
|
34
63
|
export function computerAgentCommand(): string;
|
|
64
|
+
/**
|
|
65
|
+
* The command a skill file's text names: the one in its "Start with" line,
|
|
66
|
+
* or null when the text has none.
|
|
67
|
+
* @param {string} content
|
|
68
|
+
* @returns {string | null}
|
|
69
|
+
*/
|
|
70
|
+
export function skillCommandOf(content: string): string | null;
|
|
35
71
|
/**
|
|
36
72
|
* The full skill file.
|
|
37
|
-
* @param {{command?: string}} [options]
|
|
73
|
+
* @param {{command?: string, install?: string}} [options]
|
|
38
74
|
* @returns {string}
|
|
39
75
|
*/
|
|
40
|
-
export function renderComputerAgentText({ command, }?: {
|
|
76
|
+
export function renderComputerAgentText({ command, install, }?: {
|
|
41
77
|
command?: string;
|
|
78
|
+
install?: string;
|
|
42
79
|
}): string;
|
|
43
80
|
/**
|
|
44
81
|
* Read-only: the state of the skill file against this release's rendering,
|