@astryxdesign/cli 0.7.2-canary.081ccea → 0.7.2-canary.0d5d64e
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 +104 -84
- package/api/build/_adapter.d.mts +8 -0
- package/api/build/_adapter.mjs +12 -1
- package/api/build/build.doc.mjs +4 -0
- package/api/build/kit/kit.mjs +3 -11
- package/api/component/_adapter.mjs +3 -11
- package/api/component/component.doc.mjs +6 -1
- package/api/discover/_adapter.d.mts +13 -0
- package/api/discover/_adapter.mjs +39 -17
- package/api/discover/discover.doc.mjs +3 -2
- package/api/discover/discover.mjs +22 -8
- package/api/discover/discover.type.d.mts +5 -3
- package/api/discover/discover.type.mjs +5 -3
- package/api/docs/_adapter.mjs +3 -2
- package/api/docs/docs.doc.mjs +2 -1
- package/api/docs/docs.mjs +2 -1
- package/api/docs/docs.test.mjs +5 -2
- package/api/docs/reference-blocks.test.mjs +1 -3
- package/api/doctor/_adapter.d.mts +108 -0
- package/api/doctor/_adapter.mjs +223 -4
- package/api/doctor/doctor.d.mts +199 -0
- package/api/doctor/doctor.doc.mjs +3 -2
- package/api/doctor/doctor.mjs +503 -31
- package/api/doctor/doctor.test.mjs +137 -14
- package/api/doctor/release-checks.test.mjs +156 -0
- package/api/doctor/theme-checks.mjs +16 -3
- package/api/doctor/theme-checks.test.mjs +87 -7
- package/api/error.d.mts +10 -0
- package/api/error.mjs +25 -0
- package/api/hook/_adapter.mjs +3 -11
- package/api/hook/hook.doc.mjs +4 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/init/_adapter.d.mts +22 -0
- package/api/init/_adapter.mjs +59 -0
- package/api/init/init.d.mts +7 -5
- package/api/init/init.doc.mjs +28 -7
- package/api/init/init.mjs +28 -4
- package/api/init/init.type.d.mts +48 -3
- package/api/init/init.type.mjs +37 -3
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +15 -4
- package/api/init/user/user.d.mts +14 -0
- package/api/init/user/user.mjs +87 -0
- package/api/init/user/user.test.mjs +232 -0
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +10 -9
- package/api/integration/pack-check.test.mjs +9 -15
- package/api/integration/validate-integration.d.mts +8 -0
- package/api/integration/validate-integration.mjs +27 -6
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +3 -1
- package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +11 -0
- package/api/search/_adapter.mjs +25 -0
- package/api/search/search.d.mts +1 -1
- package/api/search/search.doc.mjs +8 -3
- package/api/search/search.mjs +38 -14
- package/api/search/search.test.mjs +4 -1
- package/api/search/search.type.d.mts +14 -1
- package/api/search/search.type.mjs +6 -1
- package/api/swizzle/_adapter.mjs +2 -2
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/template/template-integration.test.mjs +1 -1
- package/api/theme/_adapter.d.mts +16 -0
- package/api/theme/_adapter.mjs +32 -5
- package/api/theme/build/build.d.mts +2 -1
- package/api/theme/build/build.mjs +70 -14
- package/api/theme/build/build.packed-old-core.test.mjs +20 -3
- package/api/theme/build/font-warning.mjs +5 -3
- package/api/theme/build/font-warning.test.mjs +2 -1
- package/api/theme/remove/remove.test.mjs +2 -2
- package/api/theme/targets/targets.mjs +3 -10
- package/api/theme/themeTargets.doc.mjs +4 -0
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/_adapter.mjs +1 -1
- package/api/upgrade/run/run.mjs +5 -1
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.mjs +5 -1
- package/assets/docs/getting-started.doc.mjs +23 -3
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +12 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +43 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +18 -4
- package/assets/docs/tree/building-blocks.doc.mjs +4 -0
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +5 -5
- package/assets/docs/tree/checks.doc.mjs +9 -9
- package/assets/docs/tree/ci-and-containers.doc.mjs +88 -0
- package/assets/docs/tree/cli-command.doc.mjs +142 -0
- package/assets/docs/tree/cli.doc.mjs +6 -0
- package/assets/docs/tree/codemods.doc.mjs +13 -3
- package/assets/docs/tree/commands.doc.mjs +7 -1
- package/assets/docs/tree/component-imports.doc.mjs +11 -1
- package/assets/docs/tree/components.doc.mjs +6 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
- package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
- package/assets/docs/tree/configuration.doc.mjs +7 -3
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +11 -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 +6 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +13 -3
- package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
- package/assets/docs/tree/global-integrations.doc.mjs +124 -0
- package/assets/docs/tree/global.doc.mjs +131 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/install-once.doc.mjs +105 -0
- package/assets/docs/tree/integrations.doc.mjs +5 -1
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/monorepos.doc.mjs +84 -0
- package/assets/docs/tree/problems.doc.mjs +205 -0
- package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
- package/assets/docs/tree/publishing.doc.mjs +2 -2
- package/assets/docs/tree/quick-start.doc.mjs +15 -5
- package/assets/docs/tree/reference.doc.mjs +192 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +11 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +13 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +3 -3
- package/assets/docs/tree/start-a-template.doc.mjs +15 -5
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +6 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +4 -4
- package/assets/docs/tree/test-template-in-app.doc.mjs +4 -4
- package/assets/docs/tree/themes.doc.mjs +4 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +15 -7
- package/assets/docs/tree/uninstall.doc.mjs +109 -0
- package/assets/docs/tree/updates.doc.mjs +92 -0
- package/assets/docs/tree/upgrading.doc.mjs +2 -2
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +11 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +2 -2
- package/assets/docs/tree/versioning.doc.mjs +3 -3
- package/assets/docs/tree/who-answers.doc.mjs +119 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +3 -3
- package/assets/docs/working-with-ai.doc.mjs +23 -9
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/discover/discover.doc.mjs +6 -0
- package/authoring/doctypes/_schema.d.mts +8 -3
- package/authoring/doctypes/_schema.mjs +1 -0
- package/authoring/doctypes/command/command.doc.mjs +6 -0
- package/authoring/doctypes/command/type.ts +14 -0
- package/authoring/doctypes/reference/reference.doc.mjs +1 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +18 -2
- package/authoring/integration/parse.test.mjs +11 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +33 -2
- package/authoring/integration/type.ts +8 -0
- package/clients/cli/bin/astryx.mjs +20 -3
- package/clients/cli/cli-command.test.mjs +166 -0
- package/clients/cli/commands/blog.doc.mjs +1 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +14 -2
- package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +25 -12
- package/clients/cli/commands/build.doc.mjs +1 -0
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +7 -6
- package/clients/cli/commands/discover.doc.mjs +8 -0
- package/clients/cli/commands/discover.no-source.test.mjs +1 -0
- package/clients/cli/commands/docs.doc.mjs +1 -0
- package/clients/cli/commands/docs.mjs +49 -19
- package/clients/cli/commands/docs.test.mjs +2 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +10 -1
- package/clients/cli/commands/doctor-integration.test.mjs +4 -3
- package/clients/cli/commands/doctor.doc.mjs +12 -2
- package/clients/cli/commands/doctor.mjs +12 -3
- package/clients/cli/commands/doctor.test.mjs +10 -4
- package/clients/cli/commands/gap-report.doc.mjs +1 -0
- package/clients/cli/commands/hook.doc.mjs +1 -0
- package/clients/cli/commands/init.behavior.test.mjs +5 -0
- package/clients/cli/commands/init.doc.mjs +29 -3
- package/clients/cli/commands/integration-add.doc.mjs +7 -0
- package/clients/cli/commands/integration-authoring.test.mjs +3 -3
- package/clients/cli/commands/integration-check.doc.mjs +10 -2
- package/clients/cli/commands/integration-check.test.mjs +31 -1
- package/clients/cli/commands/integration-pack.doc.mjs +8 -1
- package/clients/cli/commands/integration-verify.doc.mjs +8 -1
- package/clients/cli/commands/integration.mjs +3 -2
- package/clients/cli/commands/json-contract.test.mjs +6 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -0
- package/clients/cli/commands/outside-project.test.mjs +774 -0
- package/clients/cli/commands/search.doc.mjs +1 -0
- package/clients/cli/commands/search.mjs +16 -11
- package/clients/cli/commands/search.test.mjs +429 -296
- package/clients/cli/commands/setup-nudge.test.mjs +26 -4
- package/clients/cli/commands/swizzle.doc.mjs +7 -0
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
- package/clients/cli/commands/theme-add.doc.mjs +8 -1
- package/clients/cli/commands/theme-build.doc.mjs +1 -0
- package/clients/cli/commands/theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
- package/clients/cli/commands/theme-list.doc.mjs +1 -0
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
- package/clients/cli/commands/theme-remove.doc.mjs +7 -0
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +7 -0
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.doc.mjs +8 -1
- package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
- package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
- package/clients/cli/index.mjs +84 -13
- package/clients/cli/lib/cli-error.mjs +4 -1
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +2 -2
- package/clients/cli/lib/json-shim.mjs +3 -1
- package/clients/cli/lib/manifest.d.ts +9 -0
- package/clients/cli/lib/manifest.mjs +17 -1
- package/clients/cli/lib/manifest.test.mjs +25 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +21 -6
- package/foundation/agent-docs/agent-doc-state.mjs +29 -7
- package/foundation/agent-docs/agent-docs.d.mts +2 -2
- package/foundation/agent-docs/agent-docs.mjs +3 -3
- package/foundation/agent-docs/computer-agent-text.d.mts +133 -0
- package/foundation/agent-docs/computer-agent-text.mjs +623 -0
- package/foundation/agent-docs/computer-agent-text.test.mjs +602 -0
- package/foundation/config/project.d.mts +35 -3
- package/foundation/config/project.mjs +145 -8
- package/foundation/config/project.test.mjs +66 -0
- package/foundation/config/theme-state.mjs +5 -4
- package/foundation/discovery/cli-self-docs.mjs +20 -3
- package/foundation/discovery/cli-self-docs.test.mjs +3 -2
- package/foundation/discovery/component-replacement.mjs +2 -1
- package/foundation/discovery/runner-allowlist.d.mts +40 -0
- package/foundation/discovery/runner-allowlist.mjs +53 -0
- package/foundation/discovery/template-needs.mjs +5 -2
- package/foundation/discovery/theme-imports.mjs +8 -4
- package/foundation/discovery/theme-imports.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +20 -0
- package/foundation/doc-compiler/inputs.mjs +4 -1
- package/foundation/doc-compiler/read.d.mts +1 -1
- package/foundation/doc-compiler/tree.test.mjs +1 -1
- package/foundation/env/cli-command.d.mts +83 -0
- package/foundation/env/cli-command.mjs +152 -0
- package/foundation/env/cli-command.test.mjs +129 -0
- package/foundation/env/node-version.test.mjs +15 -3
- package/foundation/env/package-manager.d.mts +61 -9
- package/foundation/env/package-manager.global.test.mjs +66 -0
- package/foundation/env/package-manager.mjs +137 -13
- package/foundation/env/package-manager.test.mjs +148 -9
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +33 -0
- package/foundation/env/search-path.d.mts +42 -0
- package/foundation/env/search-path.mjs +205 -0
- package/foundation/env/search-path.test.mjs +122 -0
- package/foundation/env/user-dirs.d.mts +39 -0
- package/foundation/env/user-dirs.mjs +93 -0
- package/foundation/env/user-dirs.test.mjs +72 -0
- package/foundation/env/user-settings.d.mts +46 -0
- package/foundation/env/user-settings.mjs +106 -0
- package/foundation/env/user-settings.test.mjs +64 -0
- package/foundation/fs/file-protection.mjs +15 -1
- package/foundation/fs/module-loader.stdout.test.mjs +3 -2
- package/foundation/fs/path-compare.d.mts +33 -0
- package/foundation/fs/path-compare.mjs +73 -0
- package/foundation/fs/paths.d.mts +57 -1
- package/foundation/fs/paths.mjs +131 -3
- package/foundation/fs/paths.test.mjs +10 -1
- package/foundation/integrations/computer-integrations.d.mts +78 -0
- package/foundation/integrations/computer-integrations.mjs +316 -0
- package/foundation/integrations/computer-integrations.test.mjs +292 -0
- package/foundation/integrations/integration-warnings.mjs +3 -2
- package/foundation/integrations/integration-warnings.test.mjs +8 -9
- package/foundation/integrations/integrations.d.mts +25 -1
- package/foundation/integrations/integrations.mjs +46 -3
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +11 -0
- package/foundation/release/agent-text-worker.d.mts +4 -0
- package/foundation/release/agent-text-worker.mjs +52 -0
- package/foundation/release/cache.d.mts +310 -0
- package/foundation/release/cache.mjs +1216 -0
- package/foundation/release/cache.test.mjs +920 -0
- package/foundation/release/choose.d.mts +207 -0
- package/foundation/release/choose.mjs +677 -0
- package/foundation/release/choose.test.mjs +427 -0
- package/foundation/release/core-worker.d.mts +4 -0
- package/foundation/release/core-worker.mjs +38 -0
- package/foundation/release/global-state.d.mts +259 -0
- package/foundation/release/global-state.mjs +472 -0
- package/foundation/release/global-state.test.mjs +381 -0
- package/foundation/release/handoff.d.mts +60 -0
- package/foundation/release/handoff.e2e.test.mjs +278 -0
- package/foundation/release/handoff.mjs +357 -0
- package/foundation/release/lock-lease.d.mts +23 -0
- package/foundation/release/lock-lease.mjs +80 -0
- package/foundation/release/notices.d.mts +253 -0
- package/foundation/release/notices.mjs +596 -0
- package/foundation/release/notices.test.mjs +565 -0
- package/foundation/release/npm-guard.d.mts +4 -0
- package/foundation/release/npm-guard.mjs +126 -0
- package/foundation/release/project.d.mts +141 -0
- package/foundation/release/project.mjs +466 -0
- package/foundation/release/project.test.mjs +288 -0
- package/foundation/release/refresh-worker.d.mts +4 -0
- package/foundation/release/refresh-worker.mjs +27 -0
- package/foundation/release/run-context.d.mts +47 -0
- package/foundation/release/run-context.mjs +149 -0
- package/foundation/release/update-notice-env.d.mts +28 -0
- package/foundation/release/update-notice-env.mjs +39 -0
- package/foundation/response/base.d.ts +26 -3
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.doc.mjs +12 -0
- package/foundation/response/error-codes.mjs +17 -0
- package/foundation/response/error-codes.test.mjs +2 -0
- package/foundation/response/json-contract.test.mjs +7 -2
- package/foundation/response/json.mjs +4 -1
- package/foundation/response/response-types.doc.mjs +8 -3
- package/foundation/response/response-types.doc.test.mjs +46 -0
- package/foundation/response/response.doc.mjs +3 -3
- package/foundation/xle/browser-imports.test.mjs +74 -0
- package/package.json +9 -9
- package/scripts/postinstall.mjs +21 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Reading the `astryx` commands on the search path (spec AST-081
|
|
5
|
+
* FR11): links, and each package manager's shim, down to the CLI package and
|
|
6
|
+
* its version.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import {astryxCommandsOnSearchPath, astryxCliRootOf} from './search-path.mjs';
|
|
13
|
+
import {
|
|
14
|
+
cleanupFixtures,
|
|
15
|
+
tempDir,
|
|
16
|
+
writeJson,
|
|
17
|
+
} from '../../test-utils/release-fixtures.mjs';
|
|
18
|
+
|
|
19
|
+
afterEach(cleanupFixtures);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A CLI package at `dir`, with or without the hand-off.
|
|
23
|
+
* @param {string} dir
|
|
24
|
+
* @param {string} version
|
|
25
|
+
* @param {boolean} [handsOff]
|
|
26
|
+
*/
|
|
27
|
+
function cliPackage(dir, version, handsOff = false) {
|
|
28
|
+
writeJson(path.join(dir, 'package.json'), {
|
|
29
|
+
name: '@astryxdesign/cli',
|
|
30
|
+
version,
|
|
31
|
+
});
|
|
32
|
+
if (handsOff) {
|
|
33
|
+
fs.mkdirSync(path.join(dir, 'foundation', 'release'), {recursive: true});
|
|
34
|
+
fs.writeFileSync(path.join(dir, 'foundation', 'release', 'choose.mjs'), '');
|
|
35
|
+
}
|
|
36
|
+
return dir;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An executable shim at `file` with `text`.
|
|
41
|
+
* @param {string} file
|
|
42
|
+
* @param {string} text
|
|
43
|
+
*/
|
|
44
|
+
function shim(file, text) {
|
|
45
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
46
|
+
fs.writeFileSync(file, text);
|
|
47
|
+
fs.chmodSync(file, 0o755);
|
|
48
|
+
return file;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe.skipIf(process.platform === 'win32')('astryxCliRootOf', () => {
|
|
52
|
+
it('reads a pnpm 10 shim ($basedir)', () => {
|
|
53
|
+
const home = tempDir('pnpm');
|
|
54
|
+
const pkg = cliPackage(
|
|
55
|
+
path.join(home, 'global', '5', 'node_modules', '@astryxdesign', 'cli'),
|
|
56
|
+
'0.6.8',
|
|
57
|
+
);
|
|
58
|
+
const bin = shim(
|
|
59
|
+
path.join(home, 'astryx'),
|
|
60
|
+
'#!/bin/sh\nbasedir=$(dirname "$0")\nexec node "$basedir/global/5/node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs" "$@"\n',
|
|
61
|
+
);
|
|
62
|
+
expect(astryxCliRootOf(bin)).toBe(pkg);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('reads a pnpm 12 shim ($basedir_abs, a folder above the shim)', () => {
|
|
66
|
+
const home = tempDir('pnpm12');
|
|
67
|
+
const pkg = cliPackage(
|
|
68
|
+
path.join(
|
|
69
|
+
home,
|
|
70
|
+
'global',
|
|
71
|
+
'v11',
|
|
72
|
+
'3f2a',
|
|
73
|
+
'node_modules',
|
|
74
|
+
'@astryxdesign',
|
|
75
|
+
'cli',
|
|
76
|
+
),
|
|
77
|
+
'0.6.8',
|
|
78
|
+
);
|
|
79
|
+
const bin = shim(
|
|
80
|
+
path.join(home, 'bin', 'astryx'),
|
|
81
|
+
[
|
|
82
|
+
'#!/bin/sh',
|
|
83
|
+
'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")',
|
|
84
|
+
'basedir_abs=$(cd "$basedir" && pwd)',
|
|
85
|
+
'exec node "$basedir_abs/../global/v11/3f2a/node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs" "$@"',
|
|
86
|
+
'',
|
|
87
|
+
].join('\n'),
|
|
88
|
+
);
|
|
89
|
+
expect(astryxCliRootOf(bin)).toBe(pkg);
|
|
90
|
+
const [row] = astryxCommandsOnSearchPath({
|
|
91
|
+
searchPath: path.dirname(bin),
|
|
92
|
+
platform: 'linux',
|
|
93
|
+
});
|
|
94
|
+
expect(row).toEqual({
|
|
95
|
+
file: bin,
|
|
96
|
+
astryx: true,
|
|
97
|
+
cliRoot: pkg,
|
|
98
|
+
version: '0.6.8',
|
|
99
|
+
handsOff: false,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('reads a cmd-shim-target comment with an absolute target', () => {
|
|
104
|
+
const elsewhere = tempDir('target');
|
|
105
|
+
const pkg = cliPackage(
|
|
106
|
+
path.join(elsewhere, 'node_modules', '@astryxdesign', 'cli'),
|
|
107
|
+
'0.8.0',
|
|
108
|
+
true,
|
|
109
|
+
);
|
|
110
|
+
const bin = shim(
|
|
111
|
+
path.join(tempDir('bin'), 'astryx'),
|
|
112
|
+
`#!/bin/sh\n# cmd-shim-target=${path.join(pkg, 'clients', 'cli', 'bin', 'astryx.mjs')}\nexec node "$TARGET" "$@"\n`,
|
|
113
|
+
);
|
|
114
|
+
expect(astryxCliRootOf(bin)).toBe(pkg);
|
|
115
|
+
expect(
|
|
116
|
+
astryxCommandsOnSearchPath({
|
|
117
|
+
searchPath: path.dirname(bin),
|
|
118
|
+
platform: 'linux',
|
|
119
|
+
})[0],
|
|
120
|
+
).toMatchObject({version: '0.8.0', handsOff: true});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An environment folder setting, when it names an absolute path.
|
|
6
|
+
* @param {string | undefined} value
|
|
7
|
+
* @returns {string | null}
|
|
8
|
+
*/
|
|
9
|
+
export function absoluteDirSetting(value: string | undefined): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} UserDirOptions
|
|
12
|
+
* @property {string} [home] the home folder; defaults to the current user's
|
|
13
|
+
* @property {NodeJS.Platform} [platform]
|
|
14
|
+
* @property {Record<string, string | undefined>} [env]
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The CLI's per-user cache folder: `~/.cache/astryx` on Linux (or
|
|
18
|
+
* `$XDG_CACHE_HOME/astryx`), `~/Library/Caches/astryx` on macOS, and
|
|
19
|
+
* `%LOCALAPPDATA%\astryx\Cache` on Windows.
|
|
20
|
+
* @param {UserDirOptions} [options]
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
export function userCacheDir({ home, platform, env, }?: UserDirOptions): string;
|
|
24
|
+
/**
|
|
25
|
+
* The CLI's per-user configuration folder: `~/.config/astryx` on Linux (or
|
|
26
|
+
* `$XDG_CONFIG_HOME/astryx`), `~/Library/Application Support/astryx` on
|
|
27
|
+
* macOS, and `%APPDATA%\astryx` on Windows.
|
|
28
|
+
* @param {UserDirOptions} [options]
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function userConfigDir({ home, platform, env, }?: UserDirOptions): string;
|
|
32
|
+
export type UserDirOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* the home folder; defaults to the current user's
|
|
35
|
+
*/
|
|
36
|
+
home?: string | undefined;
|
|
37
|
+
platform?: NodeJS.Platform | undefined;
|
|
38
|
+
env?: Record<string, string | undefined> | undefined;
|
|
39
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The per-user folders the CLI may write to (spec AST-081 FR7): the
|
|
5
|
+
* platform's cache directory and its configuration directory, each with an
|
|
6
|
+
* `astryx` folder of its own.
|
|
7
|
+
*
|
|
8
|
+
* A folder named by the platform's own environment setting
|
|
9
|
+
* (`XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, `LOCALAPPDATA`, `APPDATA`) is used
|
|
10
|
+
* only when it is an absolute path; a relative one is ignored, as the XDG
|
|
11
|
+
* base directory rules require, so a run never writes into the folder it
|
|
12
|
+
* starts in.
|
|
13
|
+
*
|
|
14
|
+
* @input the home folder, the platform, and those standard settings
|
|
15
|
+
* @output absolute folder paths
|
|
16
|
+
* @position packages/cli/foundation/env
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as os from 'node:os';
|
|
20
|
+
import * as path from 'node:path';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An environment folder setting, when it names an absolute path.
|
|
24
|
+
* @param {string | undefined} value
|
|
25
|
+
* @returns {string | null}
|
|
26
|
+
*/
|
|
27
|
+
export function absoluteDirSetting(value) {
|
|
28
|
+
return typeof value === 'string' && value !== '' && path.isAbsolute(value)
|
|
29
|
+
? value
|
|
30
|
+
: null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} UserDirOptions
|
|
35
|
+
* @property {string} [home] the home folder; defaults to the current user's
|
|
36
|
+
* @property {NodeJS.Platform} [platform]
|
|
37
|
+
* @property {Record<string, string | undefined>} [env]
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The CLI's per-user cache folder: `~/.cache/astryx` on Linux (or
|
|
42
|
+
* `$XDG_CACHE_HOME/astryx`), `~/Library/Caches/astryx` on macOS, and
|
|
43
|
+
* `%LOCALAPPDATA%\astryx\Cache` on Windows.
|
|
44
|
+
* @param {UserDirOptions} [options]
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
export function userCacheDir({
|
|
48
|
+
home = os.homedir(),
|
|
49
|
+
platform = process.platform,
|
|
50
|
+
env = process.env,
|
|
51
|
+
} = {}) {
|
|
52
|
+
const join = platform === 'win32' ? path.win32.join : path.join;
|
|
53
|
+
if (platform === 'win32') {
|
|
54
|
+
return join(
|
|
55
|
+
absoluteDirSetting(env.LOCALAPPDATA) ?? join(home, 'AppData', 'Local'),
|
|
56
|
+
'astryx',
|
|
57
|
+
'Cache',
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (platform === 'darwin') return join(home, 'Library', 'Caches', 'astryx');
|
|
61
|
+
return join(
|
|
62
|
+
absoluteDirSetting(env.XDG_CACHE_HOME) ?? join(home, '.cache'),
|
|
63
|
+
'astryx',
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The CLI's per-user configuration folder: `~/.config/astryx` on Linux (or
|
|
69
|
+
* `$XDG_CONFIG_HOME/astryx`), `~/Library/Application Support/astryx` on
|
|
70
|
+
* macOS, and `%APPDATA%\astryx` on Windows.
|
|
71
|
+
* @param {UserDirOptions} [options]
|
|
72
|
+
* @returns {string}
|
|
73
|
+
*/
|
|
74
|
+
export function userConfigDir({
|
|
75
|
+
home = os.homedir(),
|
|
76
|
+
platform = process.platform,
|
|
77
|
+
env = process.env,
|
|
78
|
+
} = {}) {
|
|
79
|
+
const join = platform === 'win32' ? path.win32.join : path.join;
|
|
80
|
+
if (platform === 'win32') {
|
|
81
|
+
return join(
|
|
82
|
+
absoluteDirSetting(env.APPDATA) ?? join(home, 'AppData', 'Roaming'),
|
|
83
|
+
'astryx',
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (platform === 'darwin') {
|
|
87
|
+
return join(home, 'Library', 'Application Support', 'astryx');
|
|
88
|
+
}
|
|
89
|
+
return join(
|
|
90
|
+
absoluteDirSetting(env.XDG_CONFIG_HOME) ?? join(home, '.config'),
|
|
91
|
+
'astryx',
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import {describe, expect, it} from 'vitest';
|
|
5
|
+
import {absoluteDirSetting, userCacheDir, userConfigDir} from './user-dirs.mjs';
|
|
6
|
+
|
|
7
|
+
const home = path.join(path.sep, 'home', 'ada');
|
|
8
|
+
|
|
9
|
+
describe('per-user folders (spec AST-081 FR7)', () => {
|
|
10
|
+
it('uses the platform defaults', () => {
|
|
11
|
+
expect(userCacheDir({home, platform: 'linux', env: {}})).toBe(
|
|
12
|
+
path.join(home, '.cache', 'astryx'),
|
|
13
|
+
);
|
|
14
|
+
expect(userConfigDir({home, platform: 'linux', env: {}})).toBe(
|
|
15
|
+
path.join(home, '.config', 'astryx'),
|
|
16
|
+
);
|
|
17
|
+
expect(userCacheDir({home, platform: 'darwin', env: {}})).toBe(
|
|
18
|
+
path.join(home, 'Library', 'Caches', 'astryx'),
|
|
19
|
+
);
|
|
20
|
+
expect(userConfigDir({home, platform: 'darwin', env: {}})).toBe(
|
|
21
|
+
path.join(home, 'Library', 'Application Support', 'astryx'),
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('uses an absolute XDG setting and ignores a relative or empty one', () => {
|
|
26
|
+
const xdg = path.join(path.sep, 'xdg');
|
|
27
|
+
expect(
|
|
28
|
+
userCacheDir({home, platform: 'linux', env: {XDG_CACHE_HOME: xdg}}),
|
|
29
|
+
).toBe(path.join(xdg, 'astryx'));
|
|
30
|
+
expect(
|
|
31
|
+
userConfigDir({home, platform: 'linux', env: {XDG_CONFIG_HOME: xdg}}),
|
|
32
|
+
).toBe(path.join(xdg, 'astryx'));
|
|
33
|
+
for (const value of ['rel-cache', './cache', '']) {
|
|
34
|
+
expect(
|
|
35
|
+
userCacheDir({home, platform: 'linux', env: {XDG_CACHE_HOME: value}}),
|
|
36
|
+
).toBe(path.join(home, '.cache', 'astryx'));
|
|
37
|
+
expect(
|
|
38
|
+
userConfigDir({home, platform: 'linux', env: {XDG_CONFIG_HOME: value}}),
|
|
39
|
+
).toBe(path.join(home, '.config', 'astryx'));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it.skipIf(process.platform !== 'win32')(
|
|
44
|
+
'uses LOCALAPPDATA and APPDATA on Windows only when absolute',
|
|
45
|
+
() => {
|
|
46
|
+
const winHome = 'C:\\Users\\ada';
|
|
47
|
+
expect(
|
|
48
|
+
userCacheDir({
|
|
49
|
+
home: winHome,
|
|
50
|
+
platform: 'win32',
|
|
51
|
+
env: {LOCALAPPDATA: 'D:\\Local'},
|
|
52
|
+
}),
|
|
53
|
+
).toBe('D:\\Local\\astryx\\Cache');
|
|
54
|
+
expect(
|
|
55
|
+
userConfigDir({
|
|
56
|
+
home: winHome,
|
|
57
|
+
platform: 'win32',
|
|
58
|
+
env: {APPDATA: 'Roaming'},
|
|
59
|
+
}),
|
|
60
|
+
).toBe('C:\\Users\\ada\\AppData\\Roaming\\astryx');
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
it('reads only absolute folder settings', () => {
|
|
65
|
+
expect(absoluteDirSetting(undefined)).toBeNull();
|
|
66
|
+
expect(absoluteDirSetting('')).toBeNull();
|
|
67
|
+
expect(absoluteDirSetting('cache')).toBeNull();
|
|
68
|
+
expect(absoluteDirSetting(path.resolve('cache'))).toBe(
|
|
69
|
+
path.resolve('cache'),
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} ComputerAgentTextSettings
|
|
6
|
+
* @property {boolean} install Whether the computer-level text is wanted.
|
|
7
|
+
* @property {string[]} links The links to its skill folder Astryx made, so
|
|
8
|
+
* removal removes exactly those.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The settings file's path.
|
|
12
|
+
* @param {string} [configDir]
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function settingsFile(configDir?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The whole settings object; `{}` when the file is missing or unreadable.
|
|
18
|
+
* @param {string} [configDir]
|
|
19
|
+
* @returns {Record<string, unknown>}
|
|
20
|
+
*/
|
|
21
|
+
export function readSettings(configDir?: string): Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* The person's choices about the computer-level agent text.
|
|
24
|
+
* @param {string} [configDir]
|
|
25
|
+
* @returns {ComputerAgentTextSettings}
|
|
26
|
+
*/
|
|
27
|
+
export function computerAgentTextSettings(configDir?: string): ComputerAgentTextSettings;
|
|
28
|
+
/**
|
|
29
|
+
* Record the person's choices about the computer-level agent text, keeping
|
|
30
|
+
* every other setting. Returns whether the file was written.
|
|
31
|
+
* @param {ComputerAgentTextSettings} choice
|
|
32
|
+
* @param {string} [configDir]
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function recordComputerAgentTextSettings(choice: ComputerAgentTextSettings, configDir?: string): boolean;
|
|
36
|
+
export type ComputerAgentTextSettings = {
|
|
37
|
+
/**
|
|
38
|
+
* Whether the computer-level text is wanted.
|
|
39
|
+
*/
|
|
40
|
+
install: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The links to its skill folder Astryx made, so
|
|
43
|
+
* removal removes exactly those.
|
|
44
|
+
*/
|
|
45
|
+
links: string[];
|
|
46
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The CLI's per-user settings file (spec AST-081 FR8):
|
|
5
|
+
* `astryx/settings.json` in the platform's per-user configuration folder.
|
|
6
|
+
*
|
|
7
|
+
* It holds the person's choices about the computer-level agent text:
|
|
8
|
+
*
|
|
9
|
+
* ```json
|
|
10
|
+
* {"computerAgentText": {"install": true, "links": ["/home/me/.claude/skills/astryx"]}}
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* - `computerAgentText.install`: `false` after `astryx init --user
|
|
14
|
+
* --remove-agents`, `true` after `astryx init --user`. A missing file or
|
|
15
|
+
* value means install.
|
|
16
|
+
* - `computerAgentText.links`: the links to the skill folder Astryx made, so
|
|
17
|
+
* removal removes exactly those.
|
|
18
|
+
*
|
|
19
|
+
* Only `astryx init --user` and the global copy's refresh change it. No environment variable or option
|
|
20
|
+
* does. A file that cannot be read or parsed counts as missing, and one that
|
|
21
|
+
* cannot be written never fails a run.
|
|
22
|
+
*
|
|
23
|
+
* @input the per-user configuration folder
|
|
24
|
+
* @output the settings, and writes to them
|
|
25
|
+
* @position packages/cli/foundation/env
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import * as fs from 'node:fs';
|
|
29
|
+
import * as path from 'node:path';
|
|
30
|
+
import {userConfigDir} from './user-dirs.mjs';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {object} ComputerAgentTextSettings
|
|
34
|
+
* @property {boolean} install Whether the computer-level text is wanted.
|
|
35
|
+
* @property {string[]} links The links to its skill folder Astryx made, so
|
|
36
|
+
* removal removes exactly those.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The settings file's path.
|
|
41
|
+
* @param {string} [configDir]
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
export function settingsFile(configDir = userConfigDir()) {
|
|
45
|
+
return path.join(configDir, 'settings.json');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The whole settings object; `{}` when the file is missing or unreadable.
|
|
50
|
+
* @param {string} [configDir]
|
|
51
|
+
* @returns {Record<string, unknown>}
|
|
52
|
+
*/
|
|
53
|
+
export function readSettings(configDir = userConfigDir()) {
|
|
54
|
+
try {
|
|
55
|
+
const value = JSON.parse(fs.readFileSync(settingsFile(configDir), 'utf8'));
|
|
56
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
57
|
+
? value
|
|
58
|
+
: {};
|
|
59
|
+
} catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The person's choices about the computer-level agent text.
|
|
66
|
+
* @param {string} [configDir]
|
|
67
|
+
* @returns {ComputerAgentTextSettings}
|
|
68
|
+
*/
|
|
69
|
+
export function computerAgentTextSettings(configDir = userConfigDir()) {
|
|
70
|
+
const raw = readSettings(configDir).computerAgentText;
|
|
71
|
+
const value =
|
|
72
|
+
raw && typeof raw === 'object' && !Array.isArray(raw)
|
|
73
|
+
? /** @type {Record<string, unknown>} */ (raw)
|
|
74
|
+
: {};
|
|
75
|
+
const links = Array.isArray(value.links)
|
|
76
|
+
? value.links.filter(link => typeof link === 'string')
|
|
77
|
+
: [];
|
|
78
|
+
return {install: value.install !== false, links};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Record the person's choices about the computer-level agent text, keeping
|
|
83
|
+
* every other setting. Returns whether the file was written.
|
|
84
|
+
* @param {ComputerAgentTextSettings} choice
|
|
85
|
+
* @param {string} [configDir]
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
export function recordComputerAgentTextSettings(
|
|
89
|
+
choice,
|
|
90
|
+
configDir = userConfigDir(),
|
|
91
|
+
) {
|
|
92
|
+
const next = {
|
|
93
|
+
...readSettings(configDir),
|
|
94
|
+
computerAgentText: {install: choice.install, links: choice.links},
|
|
95
|
+
};
|
|
96
|
+
const file = settingsFile(configDir);
|
|
97
|
+
try {
|
|
98
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
99
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
100
|
+
fs.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`);
|
|
101
|
+
fs.renameSync(tmp, file);
|
|
102
|
+
return true;
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
7
|
+
import {
|
|
8
|
+
computerAgentTextSettings,
|
|
9
|
+
readSettings,
|
|
10
|
+
recordComputerAgentTextSettings,
|
|
11
|
+
settingsFile,
|
|
12
|
+
} from './user-settings.mjs';
|
|
13
|
+
|
|
14
|
+
/** @type {string[]} */
|
|
15
|
+
const dirs = [];
|
|
16
|
+
const tmp = () => {
|
|
17
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-settings-'));
|
|
18
|
+
dirs.push(dir);
|
|
19
|
+
return dir;
|
|
20
|
+
};
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
for (const dir of dirs.splice(0)) {
|
|
23
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('the settings file (spec AST-081 FR8)', () => {
|
|
28
|
+
it('means install, with no links, when missing or unreadable', () => {
|
|
29
|
+
const dir = tmp();
|
|
30
|
+
expect(computerAgentTextSettings(dir)).toEqual({install: true, links: []});
|
|
31
|
+
fs.writeFileSync(settingsFile(dir), 'not json');
|
|
32
|
+
expect(readSettings(dir)).toEqual({});
|
|
33
|
+
expect(computerAgentTextSettings(dir)).toEqual({install: true, links: []});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('records and reads the choice and the links Astryx made, keeping other settings', () => {
|
|
37
|
+
const dir = tmp();
|
|
38
|
+
fs.writeFileSync(settingsFile(dir), '{"other":true}');
|
|
39
|
+
expect(
|
|
40
|
+
recordComputerAgentTextSettings(
|
|
41
|
+
{install: true, links: ['/h/.claude/skills/astryx']},
|
|
42
|
+
dir,
|
|
43
|
+
),
|
|
44
|
+
).toBe(true);
|
|
45
|
+
expect(JSON.parse(fs.readFileSync(settingsFile(dir), 'utf8'))).toEqual({
|
|
46
|
+
other: true,
|
|
47
|
+
computerAgentText: {install: true, links: ['/h/.claude/skills/astryx']},
|
|
48
|
+
});
|
|
49
|
+
expect(computerAgentTextSettings(dir)).toEqual({
|
|
50
|
+
install: true,
|
|
51
|
+
links: ['/h/.claude/skills/astryx'],
|
|
52
|
+
});
|
|
53
|
+
recordComputerAgentTextSettings({install: false, links: []}, dir);
|
|
54
|
+
expect(computerAgentTextSettings(dir)).toEqual({install: false, links: []});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('never fails when the folder cannot be written', () => {
|
|
58
|
+
const file = path.join(tmp(), 'file');
|
|
59
|
+
fs.writeFileSync(file, '');
|
|
60
|
+
expect(
|
|
61
|
+
recordComputerAgentTextSettings({install: false, links: []}, file),
|
|
62
|
+
).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -9,8 +9,22 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import * as fs from 'node:fs';
|
|
12
|
+
import {createRequire} from 'node:module';
|
|
12
13
|
import * as path from 'node:path';
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The `ignore` matcher factory, loaded on first use: this module is reached
|
|
17
|
+
* from every CLI run through the agent-docs helpers, and only a run that
|
|
18
|
+
* classifies a file needs the matcher.
|
|
19
|
+
* @type {typeof import('ignore') | undefined}
|
|
20
|
+
*/
|
|
21
|
+
let ignoreFactory;
|
|
22
|
+
|
|
23
|
+
/** @param {import('ignore').Options} [options] */
|
|
24
|
+
function ignore(options) {
|
|
25
|
+
ignoreFactory ??= createRequire(import.meta.url)('ignore');
|
|
26
|
+
return /** @type {typeof import('ignore')} */ (ignoreFactory)(options);
|
|
27
|
+
}
|
|
14
28
|
|
|
15
29
|
const DEPENDENCY_DIRS = new Set([
|
|
16
30
|
'node_modules',
|
|
@@ -14,6 +14,7 @@ import * as fs from 'node:fs';
|
|
|
14
14
|
import * as os from 'node:os';
|
|
15
15
|
import * as path from 'node:path';
|
|
16
16
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
17
|
+
import {CLI_VERSION} from '../../test-utils/release-fixtures.mjs';
|
|
17
18
|
|
|
18
19
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
19
20
|
const LOADER_URL = pathToFileURL(path.join(HERE, 'module-loader.mjs')).href;
|
|
@@ -268,7 +269,7 @@ describe('--json stdout stays one envelope when project modules print', () => {
|
|
|
268
269
|
write('package.json', JSON.stringify({name: 'consumer', private: true}));
|
|
269
270
|
write(
|
|
270
271
|
'node_modules/@astryxdesign/core/package.json',
|
|
271
|
-
JSON.stringify({name: '@astryxdesign/core', version:
|
|
272
|
+
JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
|
|
272
273
|
);
|
|
273
274
|
write(
|
|
274
275
|
'astryx.config.js',
|
|
@@ -289,7 +290,7 @@ describe('--json stdout stays one envelope when project modules print', () => {
|
|
|
289
290
|
);
|
|
290
291
|
write(
|
|
291
292
|
'node_modules/@astryxdesign/core/package.json',
|
|
292
|
-
JSON.stringify({name: '@astryxdesign/core', version:
|
|
293
|
+
JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
|
|
293
294
|
);
|
|
294
295
|
write(
|
|
295
296
|
'astryx.config.mjs',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether the platform's file systems ignore letter case by default.
|
|
6
|
+
* @param {NodeJS.Platform} [platform]
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export function ignoresCase(platform?: NodeJS.Platform): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A path in the form two spellings of one folder share.
|
|
12
|
+
* @param {string} p
|
|
13
|
+
* @param {NodeJS.Platform} [platform]
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function pathKey(p: string, platform?: NodeJS.Platform): string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether two paths name the same folder or file.
|
|
19
|
+
* @param {string} a
|
|
20
|
+
* @param {string} b
|
|
21
|
+
* @param {NodeJS.Platform} [platform]
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export function samePath(a: string, b: string, platform?: NodeJS.Platform): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* `child` relative to `parent`, compared the way the file system compares
|
|
27
|
+
* names; `null` when `child` is not inside `parent` (or is `parent`).
|
|
28
|
+
* @param {string} parent
|
|
29
|
+
* @param {string} child
|
|
30
|
+
* @param {NodeJS.Platform} [platform]
|
|
31
|
+
* @returns {string | null}
|
|
32
|
+
*/
|
|
33
|
+
export function relativeWithin(parent: string, child: string, platform?: NodeJS.Platform): string | null;
|