@astryxdesign/cli 0.6.5-canary.5d39f31 → 0.6.5-canary.5e7c207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +14 -13
  2. package/api/error.d.mts +22 -0
  3. package/api/error.mjs +42 -0
  4. package/api/integration/add-contribution.test.mjs +3 -3
  5. package/api/integration/authoring-checks.mjs +10 -7
  6. package/api/integration/authoring-checks.type.d.mts +8 -0
  7. package/api/integration/authoring-checks.type.mjs +7 -3
  8. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  9. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  10. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  11. package/api/integration/pack-check.test.mjs +7 -1
  12. package/api/integration/validate-integration.d.mts +4 -2
  13. package/api/integration/validate-integration.mjs +7 -2
  14. package/api/integration/validate-integration.test.mjs +55 -0
  15. package/api/integration/validate-integration.type.d.mts +5 -0
  16. package/api/integration/validate-integration.type.mjs +5 -1
  17. package/api/integration/validateIntegration.doc.mjs +1 -1
  18. package/api/layout/expand/expand.mjs +12 -7
  19. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  20. package/api/layout/layout.type.d.mts +1 -0
  21. package/api/layout/layout.type.mjs +1 -0
  22. package/api/layout/layoutExpand.doc.mjs +1 -1
  23. package/api/swizzle/copy/copy.mjs +66 -3
  24. package/api/swizzle/swizzle.doc.mjs +4 -0
  25. package/api/template/copy/copy.mjs +14 -8
  26. package/api/template/copy/copy.receipt.test.mjs +77 -0
  27. package/api/template/show/show.mjs +15 -4
  28. package/api/template/show/show.test.mjs +76 -0
  29. package/api/template/template.d.mts +1 -1
  30. package/api/template/template.doc.mjs +6 -2
  31. package/api/template/template.mjs +1 -0
  32. package/api/template/template.type.d.mts +2 -0
  33. package/api/template/template.type.mjs +2 -0
  34. package/api/upgrade/run/run.mjs +20 -3
  35. package/api/upgrade/run/run.test.mjs +45 -1
  36. package/api/upgrade/upgrade.doc.mjs +1 -1
  37. package/api/upgrade/upgrade.type.d.mts +1 -0
  38. package/api/upgrade/upgrade.type.mjs +1 -0
  39. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  40. package/assets/docs/tree/checks.doc.mjs +1 -1
  41. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  42. package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
  43. package/assets/docs/tree/versioning.doc.mjs +4 -4
  44. package/clients/cli/commands/doctor.mjs +4 -4
  45. package/clients/cli/commands/layout-expand.doc.mjs +3 -1
  46. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  47. package/clients/cli/commands/layout.mjs +16 -0
  48. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  49. package/clients/cli/commands/template.mjs +19 -5
  50. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  51. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  52. package/clients/cli/commands/write-failure.test.mjs +175 -0
  53. package/clients/cli/lib/manifest.mjs +44 -165
  54. package/clients/cli/lib/manifest.test.mjs +98 -7
  55. package/foundation/discovery/template-adapter.d.mts +13 -0
  56. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  57. package/foundation/discovery/template-adapter.mjs +16 -1
  58. package/foundation/integrations/cli-requirement.d.mts +14 -11
  59. package/foundation/integrations/cli-requirement.mjs +24 -19
  60. package/foundation/integrations/cli-requirement.test.mjs +60 -16
  61. package/foundation/response/response-types.doc.d.mts +5 -5
  62. package/foundation/response/response-types.doc.mjs +13 -13
  63. package/package.json +9 -9
package/README.md CHANGED
@@ -303,11 +303,12 @@ Shape:
303
303
  ```
304
304
 
305
305
  The manifest is **derived from Commander metadata** (commands, arguments, options)
306
- so it can't drift from the real command definitions. The two facts Commander
307
- doesn't track (`--json` support and emitted response types) are layered on from
308
- the `JSON_SUPPORTED` allowlist and a small declarative `RESPONSE_TYPES` map in
309
- `src/lib/manifest.mjs`, guarded by a drift test (`manifest.test.mjs`) so adding a
310
- command without describing it fails CI.
306
+ so it can't drift from the real command definitions. The facts Commander doesn't
307
+ track come from each command's docs: examples from its CommandDoc, and emitted
308
+ response types from the returns of the FunctionDoc it wraps (plus the few
309
+ envelopes the CLI layer builds itself). `--json` support comes from the
310
+ `JSON_SUPPORTED` allowlist. Drift tests (`manifest.test.mjs`) fail CI when a
311
+ command is added without describing it.
311
312
 
312
313
  **Backwards-compat:** the bare `astryx --json` envelope keeps `type: "help"` and its
313
314
  original shallow fields (`name`, `version`, `commands` as a `string[]` of names,
@@ -450,9 +451,9 @@ Every response has a `type` discriminant. The full set is below (generated from
450
451
  | `gap-report.categories` | The fixed gap category values and human-readable labels. |
451
452
  | `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals. |
452
453
  | `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
453
- | `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
454
+ | `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
454
455
  | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
455
- | `template.copy` | A scaffold receipt: template id, output directory, written file name, and file count. |
456
+ | `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
456
457
  | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
457
458
  | `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. |
458
459
  | `hook.detail` | One hook's full authored HookDoc. |
@@ -468,18 +469,18 @@ Every response has a `type` discriminant. The full set is below (generated from
468
469
  | `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything. |
469
470
  | `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
470
471
  | `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. |
471
- | `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, and (apply mode) filesChanged, transformsApplied, and per-codemod errors. |
472
+ | `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. |
472
473
  | `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], subcommands?), jsonSupported, and the flat responseTypes index. |
473
474
  | `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |
474
475
  | `version` | The CLI version, for `astryx --version --json`: {version}. |
475
476
  | `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |
476
477
  | `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
477
478
  | `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
478
- | `integration.validate` | The validation result: the package name and version (both null when no local manifest is found) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. |
479
- | `integration.template-conflicts` | The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
480
- | `integration.component-conflicts` | The integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. |
481
- | `integration.doc-conflicts` | The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
482
- | `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the output path, or null when nothing was written). |
479
+ | `integration.validate` | The validation result: validated (false when no integration manifest was found, so nothing was checked and the empty issues list proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. |
480
+ | `integration.template-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
481
+ | `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. |
482
+ | `integration.doc-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
483
+ | `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written), and demoMediaReplaced (count of demo media placeholders). |
483
484
  | `layout.check` | The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline). |
484
485
  | `layout.grammar` | The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry. |
485
486
 
package/api/error.d.mts CHANGED
@@ -1,6 +1,28 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The error for a write that failed on the filesystem: no permission, a
6
+ * read-only mount, a full disk, a path component that is not a directory.
7
+ *
8
+ * A raw Node errno error reached the envelope as
9
+ * `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
10
+ * "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
11
+ * registry for exactly this) and an absolute host path in the message. This
12
+ * keeps the errno, which is the part that tells you what to fix, and reports
13
+ * the target the way every other Astryx message does: relative to the project.
14
+ *
15
+ * A caller that wrote files before the failure must undo them first and pass
16
+ * the ones it could not restore as `unrestored`, so the message never says
17
+ * nothing was written when something was.
18
+ *
19
+ * @param {string} target absolute path the write was aimed at
20
+ * @param {string} cwd project root, for the relative form
21
+ * @param {unknown} cause the error the filesystem call threw
22
+ * @param {string[]} [unrestored] absolute paths an undo could not put back
23
+ * @returns {AstryxError}
24
+ */
25
+ export function writeFailed(target: string, cwd: string, cause: unknown, unrestored?: string[]): AstryxError;
4
26
  export class AstryxError extends Error {
5
27
  /**
6
28
  * @param {string} message
package/api/error.mjs CHANGED
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
15
+ import * as path from 'node:path';
15
16
 
16
17
  export class AstryxError extends Error {
17
18
  /** @type {import('../foundation/response/base').Suggestion[] | undefined} */
@@ -36,3 +37,44 @@ export class AstryxError extends Error {
36
37
  if (Array.isArray(suggestions) && suggestions.length) this.suggestions = suggestions;
37
38
  }
38
39
  }
40
+
41
+ /**
42
+ * The error for a write that failed on the filesystem: no permission, a
43
+ * read-only mount, a full disk, a path component that is not a directory.
44
+ *
45
+ * A raw Node errno error reached the envelope as
46
+ * `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
47
+ * "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
48
+ * registry for exactly this) and an absolute host path in the message. This
49
+ * keeps the errno, which is the part that tells you what to fix, and reports
50
+ * the target the way every other Astryx message does: relative to the project.
51
+ *
52
+ * A caller that wrote files before the failure must undo them first and pass
53
+ * the ones it could not restore as `unrestored`, so the message never says
54
+ * nothing was written when something was.
55
+ *
56
+ * @param {string} target absolute path the write was aimed at
57
+ * @param {string} cwd project root, for the relative form
58
+ * @param {unknown} cause the error the filesystem call threw
59
+ * @param {string[]} [unrestored] absolute paths an undo could not put back
60
+ * @returns {AstryxError}
61
+ */
62
+ export function writeFailed(target, cwd, cause, unrestored = []) {
63
+ const rel = path.relative(cwd, target) || target;
64
+ const errno =
65
+ typeof (/** @type {any} */ (cause)?.code) === 'string'
66
+ ? /** @type {any} */ (cause).code
67
+ : null;
68
+ const why = errno === 'EACCES' || errno === 'EPERM' ? ' (no permission)' : '';
69
+ const outcome =
70
+ unrestored.length === 0
71
+ ? 'Nothing was written.'
72
+ : `Earlier writes could not all be undone: ${unrestored
73
+ .map(file => path.relative(cwd, file) || file)
74
+ .join(', ')}.`;
75
+ return new AstryxError(
76
+ `Could not write ${rel}${errno ? `: ${errno}` : ''}${why}. ${outcome}`,
77
+ undefined,
78
+ ERROR_CODES.ERR_WRITE_FAILED,
79
+ );
80
+ }
@@ -12,7 +12,7 @@ import {
12
12
  integrationAddTemplate,
13
13
  } from './add-contribution.mjs';
14
14
  import {validateLocalIntegration} from './validate-integration.mjs';
15
- import {DOCS_TREE_CLI} from '../../foundation/integrations/cli-requirement.mjs';
15
+ import {NAMESPACE_DOCS_CLI} from '../../foundation/integrations/cli-requirement.mjs';
16
16
 
17
17
  let tmpDir;
18
18
 
@@ -355,7 +355,7 @@ describe('integrationAdd doc', () => {
355
355
 
356
356
  // The namespace doc needs a CLI that reads it, declared as an optional peer.
357
357
  const pkg = JSON.parse(fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'));
358
- expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli': `>=${DOCS_TREE_CLI}`});
358
+ expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli': '>=0.6.4'});
359
359
  expect(pkg.peerDependenciesMeta).toEqual({'@astryxdesign/cli': {optional: true}});
360
360
 
361
361
  const second = await integrationAdd('doc', 'upgrading', {
@@ -429,7 +429,7 @@ describe('integrationAdd doc', () => {
429
429
  write('^0.6.0');
430
430
  await integrationAdd('doc', 'deploying', {cwd: tmpDir, parent: 'acme'});
431
431
  expect(JSON.parse(fs.readFileSync(file, 'utf-8')).peerDependencies).toEqual({
432
- '@astryxdesign/cli': `>=${DOCS_TREE_CLI}`,
432
+ '@astryxdesign/cli': `>=${NAMESPACE_DOCS_CLI}`,
433
433
  });
434
434
  write('^9.1.0');
435
435
  await integrationAdd('doc', 'upgrading', {cwd: tmpDir, parent: 'acme'});
@@ -92,6 +92,7 @@ function addErrors(issues, errors, code) {
92
92
  export async function integrationTemplateConflicts(pkg, options = {}) {
93
93
  const {cwd = process.cwd()} = options;
94
94
  const resolved = await resolveIntegration(pkg, cwd);
95
+ const validated = resolved.found;
95
96
  const name = resolved.found ? (resolved.name ?? null) : null;
96
97
  const version = resolved.found ? (resolved.version ?? null) : null;
97
98
  const issues = [...resolved.issues];
@@ -99,7 +100,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
99
100
  if (!resolved.integration || name == null) {
100
101
  return {
101
102
  type: 'integration.template-conflicts',
102
- data: {name, version, conflicts: [], issues},
103
+ data: {validated, name, version, conflicts: [], issues},
103
104
  };
104
105
  }
105
106
 
@@ -215,7 +216,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
215
216
 
216
217
  return {
217
218
  type: 'integration.template-conflicts',
218
- data: {name, version, conflicts, issues},
219
+ data: {validated, name, version, conflicts, issues},
219
220
  };
220
221
  }
221
222
 
@@ -228,6 +229,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
228
229
  export async function integrationComponentConflicts(pkg, options = {}) {
229
230
  const {cwd = process.cwd()} = options;
230
231
  const resolved = await resolveIntegration(pkg, cwd);
232
+ const validated = resolved.found;
231
233
  const name = resolved.found ? (resolved.name ?? null) : null;
232
234
  const version = resolved.found ? (resolved.version ?? null) : null;
233
235
  const issues = [...resolved.issues];
@@ -235,7 +237,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
235
237
  if (!resolved.integration?.components || name == null) {
236
238
  return {
237
239
  type: 'integration.component-conflicts',
238
- data: {name, version, conflicts: [], issues},
240
+ data: {validated, name, version, conflicts: [], issues},
239
241
  };
240
242
  }
241
243
 
@@ -249,7 +251,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
249
251
  });
250
252
  return {
251
253
  type: 'integration.component-conflicts',
252
- data: {name, version, conflicts: [], issues},
254
+ data: {validated, name, version, conflicts: [], issues},
253
255
  };
254
256
  }
255
257
 
@@ -274,7 +276,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
274
276
 
275
277
  return {
276
278
  type: 'integration.component-conflicts',
277
- data: {name, version, conflicts, issues},
279
+ data: {validated, name, version, conflicts, issues},
278
280
  };
279
281
  }
280
282
 
@@ -287,6 +289,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
287
289
  export async function integrationDocConflicts(pkg, options = {}) {
288
290
  const {cwd = process.cwd()} = options;
289
291
  const resolved = await resolveIntegration(pkg, cwd);
292
+ const validated = resolved.found;
290
293
  const name = resolved.found ? (resolved.name ?? null) : null;
291
294
  const version = resolved.found ? (resolved.version ?? null) : null;
292
295
  const issues = [...resolved.issues];
@@ -294,7 +297,7 @@ export async function integrationDocConflicts(pkg, options = {}) {
294
297
  if (!resolved.integration?.docs || name == null) {
295
298
  return {
296
299
  type: 'integration.doc-conflicts',
297
- data: {name, version, findings: [], issues},
300
+ data: {validated, name, version, findings: [], issues},
298
301
  };
299
302
  }
300
303
 
@@ -388,6 +391,6 @@ export async function integrationDocConflicts(pkg, options = {}) {
388
391
 
389
392
  return {
390
393
  type: 'integration.doc-conflicts',
391
- data: {name, version, findings, issues},
394
+ data: {validated, name, version, findings, issues},
392
395
  };
393
396
  }
@@ -32,9 +32,15 @@ export type IntegrationDocFinding = {
32
32
  coreTopic: string;
33
33
  message: string;
34
34
  };
35
+ /**
36
+ * Each of the three authoring checks reports `validated`: false means no
37
+ * integration manifest was found, so nothing was inspected and the empty
38
+ * conflicts/findings list carries no information about the package.
39
+ */
35
40
  export type IntegrationTemplateConflictResponse = {
36
41
  type: "integration.template-conflicts";
37
42
  data: {
43
+ validated: boolean;
38
44
  name: string | null;
39
45
  version: string | null;
40
46
  conflicts: IntegrationTemplateConflict[];
@@ -44,6 +50,7 @@ export type IntegrationTemplateConflictResponse = {
44
50
  export type IntegrationComponentConflictResponse = {
45
51
  type: "integration.component-conflicts";
46
52
  data: {
53
+ validated: boolean;
47
54
  name: string | null;
48
55
  version: string | null;
49
56
  conflicts: IntegrationComponentConflict[];
@@ -53,6 +60,7 @@ export type IntegrationComponentConflictResponse = {
53
60
  export type IntegrationDocConflictResponse = {
54
61
  type: "integration.doc-conflicts";
55
62
  data: {
63
+ validated: boolean;
56
64
  name: string | null;
57
65
  version: string | null;
58
66
  findings: IntegrationDocFinding[];
@@ -49,21 +49,25 @@
49
49
  */
50
50
 
51
51
  /**
52
+ * Each of the three authoring checks reports `validated`: false means no
53
+ * integration manifest was found, so nothing was inspected and the empty
54
+ * conflicts/findings list carries no information about the package.
55
+ *
52
56
  * @typedef {object} IntegrationTemplateConflictResponse
53
57
  * @property {'integration.template-conflicts'} type
54
- * @property {{name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
58
+ * @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
55
59
  */
56
60
 
57
61
  /**
58
62
  * @typedef {object} IntegrationComponentConflictResponse
59
63
  * @property {'integration.component-conflicts'} type
60
- * @property {{name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
64
+ * @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
61
65
  */
62
66
 
63
67
  /**
64
68
  * @typedef {object} IntegrationDocConflictResponse
65
69
  * @property {'integration.doc-conflicts'} type
66
- * @property {{name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
70
+ * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
67
71
  */
68
72
 
69
73
  export {};
@@ -26,7 +26,7 @@ export const doc = {
26
26
  {
27
27
  type: 'integration.component-conflicts',
28
28
  description:
29
- 'Integration identity, structural issues, and Core component-name conflicts with package-qualified commands.',
29
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and Core component-name conflicts with package-qualified commands.',
30
30
  },
31
31
  ],
32
32
  examples: [
@@ -26,7 +26,7 @@ export const doc = {
26
26
  {
27
27
  type: 'integration.doc-conflicts',
28
28
  description:
29
- 'Integration identity, structural issues, and classified Core doc relationships.',
29
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and classified Core doc relationships.',
30
30
  },
31
31
  ],
32
32
  examples: [
@@ -41,7 +41,7 @@ export const doc = {
41
41
  {
42
42
  type: 'integration.template-conflicts',
43
43
  description:
44
- 'The integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
44
+ '`validated` (false when no integration manifest was found, so nothing was inspected and the empty conflict list carries no information), the integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
45
45
  },
46
46
  ],
47
47
  examples: [
@@ -374,7 +374,10 @@ describe('integrationPackCheck', () => {
374
374
  expect(await codes()).toContain('docs_tree_needs_cli');
375
375
  peer('^0.6.0 || >=0.7.0');
376
376
  expect(await codes()).toContain('docs_tree_needs_cli');
377
- peer('>=0.7.0');
377
+ peer('>=0.6.3');
378
+ expect(await codes()).toContain('docs_tree_needs_cli');
379
+ // Published 0.6.4 reads the docs tree.
380
+ peer('>=0.6.4');
378
381
  expect(await codes()).not.toContain('docs_tree_needs_cli');
379
382
  }, 120_000);
380
383
 
@@ -465,6 +468,9 @@ describe('integrationPackCheck', () => {
465
468
  expect(await codes()).toContain('replaces_needs_cli');
466
469
  peer('^0.6.0');
467
470
  expect(await codes()).toContain('replaces_needs_cli');
471
+ // `replaces` still needs 0.7.0.
472
+ peer('>=0.6.4');
473
+ expect(await codes()).toContain('replaces_needs_cli');
468
474
  peer('>=0.7.0');
469
475
  expect(await codes()).not.toContain('replaces_needs_cli');
470
476
  }, 120_000);
@@ -19,8 +19,10 @@ export function validateInstalledIntegration(spec: string, cwd?: string): Promis
19
19
  /**
20
20
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
21
21
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
22
- * local case is guidance, not an error — it comes back with `name: null` and no
23
- * issues so the CLI can print a hint and stay exit-0.
22
+ * local case is guidance, not an error — it comes back with `validated: false`,
23
+ * `name: null` and no issues so the CLI can print a hint and stay exit-0.
24
+ * `validated` is what tells a machine consumer that empty `issues` means
25
+ * "nothing was checked" rather than "checked and healthy".
24
26
  *
25
27
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
26
28
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -427,8 +427,10 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
427
427
  /**
428
428
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
429
429
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
430
- * local case is guidance, not an error — it comes back with `name: null` and no
431
- * issues so the CLI can print a hint and stay exit-0.
430
+ * local case is guidance, not an error — it comes back with `validated: false`,
431
+ * `name: null` and no issues so the CLI can print a hint and stay exit-0.
432
+ * `validated` is what tells a machine consumer that empty `issues` means
433
+ * "nothing was checked" rather than "checked and healthy".
432
434
  *
433
435
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
434
436
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -445,6 +447,9 @@ export async function validateIntegration(pkg, options = {}) {
445
447
  return {
446
448
  type: 'integration.validate',
447
449
  data: {
450
+ // The one bit that separates "checked and clean" from "never checked":
451
+ // with no manifest there is nothing to validate, and issues stays [].
452
+ validated: result.found,
448
453
  name: result.found ? (result.name ?? null) : null,
449
454
  version: result.found ? (result.version ?? null) : null,
450
455
  issues: result.issues,
@@ -625,3 +625,58 @@ describe('integration diagnostics are read-only', () => {
625
625
  expect({pkg: snapshot(pkgDir), consumer: snapshot(consumer)}).toEqual(before);
626
626
  });
627
627
  });
628
+
629
+ describe('validated separates "checked and clean" from "never checked"', () => {
630
+ // `doctor integration validate --json` from a directory with no manifest
631
+ // returned {name: null, version: null, issues: []} and exit 0 — the same
632
+ // envelope a healthy, fully validated integration produces. Wire that into
633
+ // CI from the wrong directory and it is green forever.
634
+ it('is false for every check when no manifest is found', async () => {
635
+ const dir = path.join(tmpDir, 'plain');
636
+ fs.mkdirSync(dir, {recursive: true});
637
+ fs.writeFileSync(
638
+ path.join(dir, 'package.json'),
639
+ JSON.stringify({name: 'plain-app', version: '1.0.0'}),
640
+ );
641
+
642
+ const validate = await validateIntegration(undefined, {cwd: dir});
643
+ expect(validate.data.validated).toBe(false);
644
+ expect(validate.data.issues).toEqual([]);
645
+
646
+ const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
647
+ const components = await integrationComponentConflicts(undefined, {cwd: dir});
648
+ const docs = await integrationDocConflicts(undefined, {cwd: dir});
649
+ expect(templates.data.validated).toBe(false);
650
+ expect(components.data.validated).toBe(false);
651
+ expect(docs.data.validated).toBe(false);
652
+ });
653
+
654
+ it('is true for a real integration, whose empty issue list then means healthy', async () => {
655
+ const dir = path.join(tmpDir, 'integration');
656
+ writePackage(dir, {manifest: 'export default {};\n'});
657
+
658
+ const validate = await validateIntegration(undefined, {cwd: dir});
659
+ expect(validate.data.validated).toBe(true);
660
+ expect(validate.data.name).toBe('@acme/widgets');
661
+
662
+ const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
663
+ const components = await integrationComponentConflicts(undefined, {cwd: dir});
664
+ const docs = await integrationDocConflicts(undefined, {cwd: dir});
665
+ expect(templates.data.validated).toBe(true);
666
+ expect(components.data.validated).toBe(true);
667
+ expect(docs.data.validated).toBe(true);
668
+ });
669
+
670
+ it('is true for an installed package that could not be found — that is a real finding', async () => {
671
+ const consumer = path.join(tmpDir, 'consumer');
672
+ fs.mkdirSync(consumer, {recursive: true});
673
+ fs.writeFileSync(
674
+ path.join(consumer, 'package.json'),
675
+ JSON.stringify({name: 'consumer', version: '1.0.0'}),
676
+ );
677
+
678
+ const res = await validateIntegration('@acme/nope', {cwd: consumer});
679
+ expect(res.data.validated).toBe(true);
680
+ expect(summarizeIssues(res.data.issues).errors).toBeGreaterThan(0);
681
+ });
682
+ });
@@ -27,10 +27,15 @@ export type ValidateIntegrationOptions = {
27
27
  };
28
28
  /**
29
29
  * `astryx --json doctor integration validate [package]`.
30
+ *
31
+ * `validated` is false in exactly one case: no integration manifest was found,
32
+ * so nothing was checked. An empty `issues` then means "not looked at", not
33
+ * "healthy" — the two are otherwise byte-identical.
30
34
  */
31
35
  export type ValidateIntegrationResponse = {
32
36
  type: "integration.validate";
33
37
  data: {
38
+ validated: boolean;
34
39
  name: string | null;
35
40
  version: string | null;
36
41
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
@@ -32,9 +32,13 @@
32
32
 
33
33
  /**
34
34
  * `astryx --json doctor integration validate [package]`.
35
+ *
36
+ * `validated` is false in exactly one case: no integration manifest was found,
37
+ * so nothing was checked. An empty `issues` then means "not looked at", not
38
+ * "healthy" — the two are otherwise byte-identical.
35
39
  * @typedef {object} ValidateIntegrationResponse
36
40
  * @property {'integration.validate'} type
37
- * @property {{name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
41
+ * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
38
42
  */
39
43
 
40
44
  export {};
@@ -46,7 +46,7 @@ export const doc = {
46
46
  {
47
47
  type: 'integration.validate',
48
48
  description:
49
- 'The result envelope: `data.name` and `data.version` of the validated package (both null only when no local manifest is found; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
49
+ 'The result envelope: `data.validated`, false only when no integration manifest was found — nothing was checked, so the empty `data.issues` means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
50
50
  },
51
51
  ],
52
52
  examples: [
@@ -18,7 +18,7 @@ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
18
18
  import {assertWithin, isFilePathArg, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
19
19
  import {detectForm} from '../../../foundation/xle/parse.mjs';
20
20
  import {expand} from '../../../foundation/xle/expand.mjs';
21
- import {stripTemplateAssetRefs} from '../../template/template.mjs';
21
+ import {replaceDemoMedia} from '../../template/template.mjs';
22
22
  import {analyze, formatIssue} from '../_adapter.mjs';
23
23
 
24
24
  /** @param {string} name */
@@ -59,28 +59,32 @@ function collectHintNames(doc) {
59
59
  /**
60
60
  * Build the blockModules map expand() needs: import-mode for app components,
61
61
  * splice-mode (reading + asset-stripping the block source) for template blocks.
62
- * Only blocks actually referenced are read.
62
+ * Only blocks actually referenced are read. Also returns how many demo media
63
+ * references the splice-mode sources had replaced.
63
64
  *
64
65
  * @param {import('../../../foundation/xle/xle-ast').XLEDoc} doc
65
66
  * @param {import('../_adapter.mjs').LayoutBlock[]} blocks
66
- * @returns {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>}
67
+ * @returns {{modules: Map<string, import('../../../foundation/xle/xle-ast').BlockModule>, demoMediaReplaced: number}}
67
68
  */
68
69
  function buildBlockModules(doc, blocks) {
69
70
  const referenced = collectHintNames(doc);
70
- if (referenced.size === 0) return new Map();
71
+ if (referenced.size === 0) return {modules: new Map(), demoMediaReplaced: 0};
71
72
  const byKey = new Map(blocks.map(b => [normKey(b.dirName), b]));
72
73
  /** @type {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>} */
73
74
  const modules = new Map();
75
+ let demoMediaReplaced = 0;
74
76
  for (const name of referenced) {
75
77
  const block = byKey.get(normKey(name));
76
78
  if (!block) continue;
77
79
  if (block.kind === 'component') {
78
80
  modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ (/** @type {unknown} */ ({mode: 'import', componentName: block.name, importPath: block.importPath, isDefault: block.isDefault})));
79
81
  } else if (block.filePath && fs.existsSync(block.filePath)) {
80
- modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: stripTemplateAssetRefs(fs.readFileSync(block.filePath, 'utf-8'))}));
82
+ const spliced = replaceDemoMedia(fs.readFileSync(block.filePath, 'utf-8'));
83
+ demoMediaReplaced += spliced.demoMediaReplaced;
84
+ modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: spliced.source}));
81
85
  }
82
86
  }
83
- return modules;
87
+ return {modules, demoMediaReplaced};
84
88
  }
85
89
 
86
90
  /**
@@ -115,7 +119,7 @@ export async function layoutExpand(expression, options = {}) {
115
119
  ERROR_CODES.ERR_INVALID_ARGUMENT,
116
120
  );
117
121
  }
118
- const blockModules = buildBlockModules(doc, blocks);
122
+ const {modules: blockModules, demoMediaReplaced} = buildBlockModules(doc, blocks);
119
123
  const result = expand(doc, registry, {componentName, blockModules});
120
124
 
121
125
  let written = null;
@@ -150,6 +154,7 @@ export async function layoutExpand(expression, options = {}) {
150
154
  blocksReferenced: [...blockModules.entries()].map(([name, m]) => ({name, mode: m.mode})),
151
155
  warnings: warnings.map(formatIssue),
152
156
  written,
157
+ demoMediaReplaced,
153
158
  },
154
159
  };
155
160
  }