@astryxdesign/cli 0.7.0-canary.450c68d → 0.7.0-canary.4ec1f4e

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 (168) hide show
  1. package/README.md +30 -33
  2. package/api/doctor/doctor.doc.mjs +1 -1
  3. package/api/doctor/doctor.test.mjs +28 -0
  4. package/api/doctor/theme-checks.mjs +10 -10
  5. package/api/doctor/theme-checks.test.mjs +5 -4
  6. package/api/gap-report/gap-report.doc.mjs +1 -1
  7. package/api/gap-report/gap-report.mjs +15 -0
  8. package/api/gap-report/gap-report.test.mjs +1 -1
  9. package/api/index.d.mts +0 -2
  10. package/api/index.mjs +0 -2
  11. package/api/init/init.doc.mjs +5 -1
  12. package/api/init/init.mjs +22 -0
  13. package/api/init/init.type.d.mts +4 -1
  14. package/api/init/init.type.mjs +1 -1
  15. package/api/init/remove/remove.mjs +8 -3
  16. package/api/init/remove/remove.test.mjs +12 -0
  17. package/api/init/run/run.d.mts +1 -1
  18. package/api/init/run/run.mjs +3 -3
  19. package/api/integration/validate-integration.d.mts +4 -0
  20. package/api/integration/validate-integration.mjs +5 -2
  21. package/api/integration/validateIntegration.doc.mjs +1 -1
  22. package/api/json/index.ts +0 -1
  23. package/api/search/search.doc.mjs +1 -1
  24. package/api/search/search.mjs +1 -1
  25. package/api/search/search.test.mjs +1 -1
  26. package/api/search/search.type.d.mts +1 -1
  27. package/api/search/search.type.mjs +1 -1
  28. package/api/template/template-integration.test.mjs +37 -100
  29. package/api/template/template.doc.mjs +5 -1
  30. package/api/template/template.mjs +45 -0
  31. package/api/theme/_adapter.mjs +3 -3
  32. package/api/theme/add/add.d.mts +11 -5
  33. package/api/theme/add/add.mjs +19 -192
  34. package/api/theme/add/add.test.mjs +68 -258
  35. package/api/theme/add/add.types.test.mjs +0 -1
  36. package/api/theme/build/build.d.mts +3 -3
  37. package/api/theme/build/build.mjs +22 -36
  38. package/api/theme/build/build.test.mjs +11 -24
  39. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  40. package/api/theme/integration-themes.test.mjs +3 -3
  41. package/api/theme/remove/remove.test.mjs +1 -1
  42. package/api/theme/targets/targets.test.mjs +0 -4
  43. package/api/theme/template/template.mjs +1 -1
  44. package/api/theme/theme.type.d.mts +1 -30
  45. package/api/theme/theme.type.mjs +3 -13
  46. package/api/theme/themeAdd.doc.mjs +19 -27
  47. package/api/theme/themeTargets.doc.mjs +3 -4
  48. package/api/theme/themeTemplate.doc.mjs +1 -1
  49. package/api/theme/use/use.test.mjs +1 -1
  50. package/api/upgrade/upgrade.doc.mjs +1 -1
  51. package/api/upgrade/upgrade.mjs +19 -0
  52. package/assets/codemods/transforms/next/README.md +15 -17
  53. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  54. package/assets/codemods/transforms/next/index.mjs +11 -1
  55. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  56. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  57. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  58. package/assets/docs/author-a-theme.doc.mjs +1 -1
  59. package/assets/docs/getting-started.doc.mjs +2 -2
  60. package/assets/docs/theme.doc.dense.mjs +1 -1
  61. package/assets/docs/theme.doc.mjs +2 -2
  62. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  63. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  64. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  65. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  66. package/assets/docs/tree/themes.doc.mjs +1 -1
  67. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  68. package/assets/docs/tree/versioning.doc.mjs +1 -4
  69. package/assets/docs/use-a-theme.doc.mjs +16 -16
  70. package/authoring/debug/type.ts +2 -2
  71. package/authoring/doctypes/base/type.ts +0 -9
  72. package/authoring/integration/integration.doc.mjs +1 -1
  73. package/clients/cli/command-result-coverage.test.mjs +1 -1
  74. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  75. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  76. package/clients/cli/commands/build-theme.mjs +31 -67
  77. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  78. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  79. package/clients/cli/commands/discover.mjs +2 -1
  80. package/clients/cli/commands/doctor.mjs +5 -2
  81. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  82. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  83. package/clients/cli/commands/gap-report.test.mjs +2 -2
  84. package/clients/cli/commands/init.doc.mjs +4 -4
  85. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  86. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  87. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  88. package/clients/cli/commands/search.test.mjs +1 -1
  89. package/clients/cli/commands/swizzle.mjs +4 -1
  90. package/clients/cli/commands/template.doc.mjs +3 -3
  91. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  92. package/clients/cli/commands/template.mjs +7 -1
  93. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  94. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  95. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  96. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  97. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  98. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  99. package/clients/cli/commands/theme.doc.mjs +2 -2
  100. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  101. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  102. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  103. package/clients/cli/index.mjs +0 -4
  104. package/clients/cli/lib/cli-error.mjs +19 -0
  105. package/clients/cli/lib/component-format.mjs +111 -57
  106. package/clients/cli/lib/component-format.test.mjs +28 -39
  107. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  108. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  109. package/clients/cli/lib/json-shim.test.mjs +0 -24
  110. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  111. package/foundation/agent-docs/agent-docs.mjs +6 -1
  112. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  113. package/foundation/config/theme-state.mjs +3 -3
  114. package/foundation/debug/debug-fields.test.mjs +13 -35
  115. package/foundation/debug/event.mjs +13 -78
  116. package/foundation/debug/privacy-contract.test.mjs +20 -12
  117. package/foundation/debug/redact.d.mts +2 -2
  118. package/foundation/debug/redact.mjs +2 -2
  119. package/foundation/discovery/theme-imports.mjs +1 -1
  120. package/foundation/discovery/theming-targets.d.mts +1 -20
  121. package/foundation/discovery/theming-targets.mjs +1 -38
  122. package/foundation/discovery/theming-targets.test.mjs +9 -175
  123. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  124. package/foundation/response/error-codes.doc.mjs +1 -1
  125. package/foundation/response/response-types.doc.mjs +11 -30
  126. package/foundation/response/response-types.doc.test.mjs +36 -14
  127. package/foundation/response/response.doc.mjs +1 -1
  128. package/foundation/xle/browser.d.mts +2 -2
  129. package/foundation/xle/browser.mjs +2 -2
  130. package/foundation/xle/expand.mjs +1 -1
  131. package/foundation/xle/print.mjs +1 -1
  132. package/package.json +9 -9
  133. package/api/layout/_adapter.d.mts +0 -34
  134. package/api/layout/_adapter.mjs +0 -148
  135. package/api/layout/check/check.d.mts +0 -17
  136. package/api/layout/check/check.mjs +0 -41
  137. package/api/layout/expand/expand.d.mts +0 -23
  138. package/api/layout/expand/expand.mjs +0 -161
  139. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  140. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  141. package/api/layout/grammar/grammar.d.mts +0 -14
  142. package/api/layout/grammar/grammar.mjs +0 -88
  143. package/api/layout/layout.d.mts +0 -6
  144. package/api/layout/layout.mjs +0 -17
  145. package/api/layout/layout.test.mjs +0 -297
  146. package/api/layout/layout.type.d.mts +0 -90
  147. package/api/layout/layout.type.mjs +0 -104
  148. package/api/layout/layoutCheck.doc.d.mts +0 -11
  149. package/api/layout/layoutCheck.doc.mjs +0 -85
  150. package/api/layout/layoutExpand.doc.d.mts +0 -11
  151. package/api/layout/layoutExpand.doc.mjs +0 -107
  152. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  153. package/api/layout/layoutGrammar.doc.mjs +0 -57
  154. package/api/theme/add/add.binary.test.mjs +0 -157
  155. package/api/theme/add/add.rollback.test.mjs +0 -158
  156. package/api/theme/add/add.staging.test.mjs +0 -83
  157. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  158. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  159. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  160. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  161. package/clients/cli/commands/layout.doc.mjs +0 -36
  162. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  163. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  164. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  165. package/clients/cli/commands/layout.mjs +0 -327
  166. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  167. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  168. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -20,9 +20,6 @@ import {captureEnv} from './event.mjs';
20
20
  import {parseDebugEvent} from '../../authoring/debug/parse.mjs';
21
21
 
22
22
  const ATTRIBUTION_ENV_KEYS = [
23
- 'ASTRYX_AGENT_ID',
24
- 'ASTRYX_AGENT_SESSION_ID',
25
- 'ASTRYX_AGENT_METADATA',
26
23
  'AGENT',
27
24
  'AGENT_SESSION_ID',
28
25
  'CURSOR_TRACE_ID',
@@ -262,14 +259,14 @@ describe('DebugEvent additive fields', () => {
262
259
  describe('environment attribution', () => {
263
260
  it('detects an explicit agent and hashes its session id', () => {
264
261
  clearAttributionEnv();
265
- vi.stubEnv('ASTRYX_AGENT_ID', 'test-agent');
266
- vi.stubEnv('ASTRYX_AGENT_SESSION_ID', 'agent-session-123');
262
+ vi.stubEnv('AGENT', 'test-agent');
263
+ vi.stubEnv('AGENT_SESSION_ID', 'agent-session-123');
267
264
  const env = captureEnv();
268
265
  expect(env).toMatchObject({
269
266
  agent: 'test-agent',
270
267
  agentIdentity: 'test-agent',
271
268
  agentSessionId: null,
272
- agentSessionIdSource: 'ASTRYX_AGENT_SESSION_ID',
269
+ agentSessionIdSource: 'AGENT_SESSION_ID',
273
270
  invocationSource: 'ai',
274
271
  });
275
272
  expect(env.agentSessionIdHash).toBe(
@@ -287,40 +284,21 @@ describe('environment attribution', () => {
287
284
  });
288
285
  });
289
286
 
290
- it('parses comma-separated metadata', () => {
287
+ it('reads no Astryx-owned or metadata variable for attribution', () => {
291
288
  clearAttributionEnv();
289
+ // The removed variables, set: none of them attributes the run.
290
+ vi.stubEnv('ASTRYX_AGENT_ID', 'old-agent');
291
+ vi.stubEnv('ASTRYX_AGENT_SESSION_ID', 'old-session');
292
292
  vi.stubEnv(
293
293
  'ASTRYX_AGENT_METADATA',
294
- 'id=future-agent,invocation_id=future-session,malformed',
294
+ 'id=old-agent,session_id=old-session,invocation_id=old-invocation',
295
295
  );
296
- const env = captureEnv();
297
- expect(env).toMatchObject({
298
- agentIdentity: 'future-agent',
299
- agentSessionId: null,
300
- agentSessionIdSource: 'ASTRYX_AGENT_METADATA.invocation_id',
301
- invocationSource: 'ai',
302
- });
303
- expect(env.agentSessionIdHash).toBe(
304
- createHash('sha256').update('future-session', 'utf8').digest('hex'),
305
- );
306
- });
307
-
308
- it('parses JSON metadata', () => {
309
- clearAttributionEnv();
310
- vi.stubEnv(
311
- 'ASTRYX_AGENT_METADATA',
312
- JSON.stringify({id: 'json-agent', session_id: 'json-session'}),
313
- );
314
- const env = captureEnv();
315
- expect(env).toMatchObject({
316
- agentIdentity: 'json-agent',
317
- agentSessionId: null,
318
- agentSessionIdSource: 'ASTRYX_AGENT_METADATA.session_id',
319
- invocationSource: 'ai',
296
+ vi.stubEnv('AGENT_METADATA', JSON.stringify({id: 'meta-agent'}));
297
+ expect(captureEnv()).toMatchObject({
298
+ agentIdentity: null,
299
+ agentSessionIdHash: null,
300
+ agentSessionIdSource: null,
320
301
  });
321
- expect(env.agentSessionIdHash).toBe(
322
- createHash('sha256').update('json-session', 'utf8').digest('hex'),
323
- );
324
302
  });
325
303
 
326
304
  it('leaves agent fields null without a signal', () => {
@@ -123,56 +123,12 @@ function nonEmptyString(value) {
123
123
  }
124
124
 
125
125
  /**
126
- * ASTRYX_AGENT_METADATA accepts both JSON and comma-separated key=value
127
- * forms. Unknown or malformed entries are ignored so a producer cannot break
128
- * command recording.
129
- *
130
- * @param {unknown} value
131
- * @returns {Record<string, string>}
126
+ * Agent identity: the generic AGENT variable, else the first positive
127
+ * coding-agent signal. ASTRYX_AGENT_ID and ASTRYX_AGENT_METADATA are not read
128
+ * (spec:AST-017 FR14), and no replacement metadata variable is introduced.
129
+ * @returns {string | null}
132
130
  */
133
- function parseCodingAgentMetadata(value) {
134
- const raw = nonEmptyString(value);
135
- if (!raw) return {};
136
-
137
- try {
138
- const decoded = JSON.parse(raw);
139
- if (decoded && typeof decoded === 'object' && !Array.isArray(decoded)) {
140
- /** @type {Record<string, string>} */
141
- const metadata = Object.create(null);
142
- for (const [key, entry] of Object.entries(decoded)) {
143
- if (
144
- typeof entry !== 'string' &&
145
- typeof entry !== 'number' &&
146
- typeof entry !== 'boolean'
147
- ) {
148
- continue;
149
- }
150
- const item = nonEmptyString(entry);
151
- if (item) metadata[key] = item;
152
- }
153
- return metadata;
154
- }
155
- } catch {
156
- // The compact form is comma-separated key=value, not JSON.
157
- }
158
-
159
- /** @type {Record<string, string>} */
160
- const metadata = Object.create(null);
161
- for (const entry of raw.split(',')) {
162
- const separator = entry.indexOf('=');
163
- if (separator <= 0) continue;
164
- const key = entry.slice(0, separator).trim();
165
- const item = nonEmptyString(entry.slice(separator + 1));
166
- if (key && item) metadata[key] = item;
167
- }
168
- return metadata;
169
- }
170
-
171
- /** @param {Record<string, string>} metadata @returns {string | null} */
172
- function detectAgentIdentity(metadata) {
173
- const astryxAgent = nonEmptyString(process.env.ASTRYX_AGENT_ID);
174
- if (astryxAgent) return astryxAgent.toLowerCase();
175
-
131
+ function detectAgentIdentity() {
176
132
  const genericAgent = nonEmptyString(process.env.AGENT);
177
133
  if (genericAgent) return genericAgent.toLowerCase();
178
134
 
@@ -182,9 +138,7 @@ function detectAgentIdentity(metadata) {
182
138
  )) {
183
139
  if (process.env[key]) return name;
184
140
  }
185
-
186
- const metadataId = nonEmptyString(metadata.id);
187
- return metadataId ? metadataId.toLowerCase() : null;
141
+ return null;
188
142
  }
189
143
 
190
144
  /** @param {string | null} identity @returns {string | null} */
@@ -199,29 +153,13 @@ function detectAgent(identity) {
199
153
  }
200
154
 
201
155
  /**
202
- * @param {Record<string, string>} metadata
156
+ * Agent session: the generic AGENT_SESSION_ID variable. ASTRYX_AGENT_SESSION_ID
157
+ * and ASTRYX_AGENT_METADATA are not read (spec:AST-017 FR14).
203
158
  * @returns {{id: string | null, source: string | null}}
204
159
  */
205
- function detectAgentSession(metadata) {
206
- /** @type {Array<[unknown, string]>} */
207
- const candidates = [
208
- [process.env.ASTRYX_AGENT_SESSION_ID, 'ASTRYX_AGENT_SESSION_ID'],
209
- [process.env.AGENT_SESSION_ID, 'AGENT_SESSION_ID'],
210
- [
211
- metadata.session_id ?? metadata.sessionId,
212
- 'ASTRYX_AGENT_METADATA.session_id',
213
- ],
214
- [
215
- metadata.invocation_id ?? metadata.invocationId,
216
- 'ASTRYX_AGENT_METADATA.invocation_id',
217
- ],
218
- ];
219
-
220
- for (const [value, source] of candidates) {
221
- const id = nonEmptyString(value);
222
- if (id) return {id, source};
223
- }
224
- return {id: null, source: null};
160
+ function detectAgentSession() {
161
+ const id = nonEmptyString(process.env.AGENT_SESSION_ID);
162
+ return id ? {id, source: 'AGENT_SESSION_ID'} : {id: null, source: null};
225
163
  }
226
164
 
227
165
  /** @param {string | null} id @returns {string | null} */
@@ -254,11 +192,8 @@ function detectInvocationSource({agentIdentity, agentSessionId, ci}) {
254
192
  */
255
193
  export function captureEnv({cliVersion} = {}) {
256
194
  const {ci, ciName} = detectCi();
257
- const agentMetadata = parseCodingAgentMetadata(
258
- process.env.ASTRYX_AGENT_METADATA,
259
- );
260
- const agentIdentity = detectAgentIdentity(agentMetadata);
261
- const agentSession = detectAgentSession(agentMetadata);
195
+ const agentIdentity = detectAgentIdentity();
196
+ const agentSession = detectAgentSession();
262
197
  return {
263
198
  cliVersion: cliVersion ?? null,
264
199
  nodeVersion: process.versions.node,
@@ -61,30 +61,38 @@ afterEach(() => {
61
61
 
62
62
  describe('no raw stable identifier is recorded', () => {
63
63
  it('hands the handler the hash and never the session id itself', () => {
64
- vi.stubEnv('ASTRYX_AGENT_ID', 'astryx-test-agent');
65
- vi.stubEnv('ASTRYX_AGENT_SESSION_ID', RAW_SESSION);
64
+ vi.stubEnv('AGENT', 'astryx-test-agent');
65
+ vi.stubEnv('AGENT_SESSION_ID', RAW_SESSION);
66
66
  const event = collectEvent();
67
67
 
68
68
  expect(event.env.agentSessionId).toBe(null);
69
69
  expect(event.env.agentSessionIdHash).toBe(RAW_SESSION_HASH);
70
- expect(event.env.agentSessionIdSource).toBe('ASTRYX_AGENT_SESSION_ID');
70
+ expect(event.env.agentSessionIdSource).toBe('AGENT_SESSION_ID');
71
71
  // Not just the field: nowhere in the record at all.
72
72
  expect(JSON.stringify(event)).not.toContain(RAW_SESSION);
73
73
  });
74
74
 
75
- it('never records one from the metadata env var either', () => {
75
+ it('reads no Astryx-owned variable, so a session left in one is never recorded', () => {
76
+ // spec:AST-017 FR14: the CLI reads no Astryx-owned environment variable.
77
+ // A value left in a removed one records nothing, raw or hashed.
78
+ vi.stubEnv('AGENT', '');
79
+ vi.stubEnv('AGENT_SESSION_ID', '');
80
+ vi.stubEnv('ASTRYX_AGENT_ID', 'metadata-agent');
81
+ vi.stubEnv('ASTRYX_AGENT_SESSION_ID', RAW_SESSION);
76
82
  vi.stubEnv(
77
83
  'ASTRYX_AGENT_METADATA',
78
84
  JSON.stringify({id: 'metadata-agent', session_id: RAW_SESSION}),
79
85
  );
80
86
  const event = collectEvent();
81
87
  expect(event.env.agentSessionId).toBe(null);
82
- expect(event.env.agentSessionIdHash).toBe(RAW_SESSION_HASH);
88
+ expect(event.env.agentSessionIdHash).toBe(null);
89
+ expect(event.env.agentSessionIdSource).toBe(null);
83
90
  expect(JSON.stringify(event)).not.toContain(RAW_SESSION);
91
+ expect(JSON.stringify(event)).not.toContain('metadata-agent');
84
92
  });
85
93
 
86
94
  it('still joins runs of one session, which is what the raw value was for', () => {
87
- vi.stubEnv('ASTRYX_AGENT_SESSION_ID', RAW_SESSION);
95
+ vi.stubEnv('AGENT_SESSION_ID', RAW_SESSION);
88
96
  const first = collectEvent().env.agentSessionIdHash;
89
97
  resetRecorder();
90
98
  const second = collectEvent().env.agentSessionIdHash;
@@ -101,9 +109,9 @@ describe('no raw stable identifier is recorded', () => {
101
109
 
102
110
  describe('environment free text is scrubbed', () => {
103
111
  it('scrubs a credential pasted into the agent identity', () => {
104
- // ASTRYX_AGENT_ID is free text: whatever the invoking tool exports lands
112
+ // AGENT is free text: whatever the invoking tool exports lands
105
113
  // here, and `env` used to skip the scrubbing pass entirely.
106
- vi.stubEnv('ASTRYX_AGENT_ID', 'ghp_abcdefghijklmnopqrstuvwxyz01');
114
+ vi.stubEnv('AGENT', 'ghp_abcdefghijklmnopqrstuvwxyz01');
107
115
  const event = collectEvent();
108
116
  expect(event.env.agentIdentity).toBe(REDACTED);
109
117
  expect(event.env.agent).toBe(REDACTED);
@@ -117,7 +125,7 @@ describe('environment free text is scrubbed', () => {
117
125
  });
118
126
 
119
127
  it('rewrites an absolute path in the agent identity', () => {
120
- vi.stubEnv('ASTRYX_AGENT_ID', '/users/someone/tools/my-agent');
128
+ vi.stubEnv('AGENT', '/users/someone/tools/my-agent');
121
129
  const event = collectEvent();
122
130
  expect(event.env.agentIdentity).not.toContain('/users/someone');
123
131
  expect(event.env.agentIdentity).toContain('…');
@@ -125,7 +133,7 @@ describe('environment free text is scrubbed', () => {
125
133
 
126
134
  it('keeps ordinary free text readable', () => {
127
135
  // Scrubbing that ate every agent name would make the field worthless.
128
- vi.stubEnv('ASTRYX_AGENT_ID', 'astryx-test-agent');
136
+ vi.stubEnv('AGENT', 'astryx-test-agent');
129
137
  expect(collectEvent().env.agentIdentity).toBe('astryx-test-agent');
130
138
  });
131
139
  });
@@ -135,11 +143,11 @@ describe('derived environment facts survive verbatim', () => {
135
143
  // `isSensitiveKey` matches the substring "session", so a key-based pass
136
144
  // over `env` would blank the hash — and with it the only way to join the
137
145
  // runs of one session, which is the whole reason the raw id can go.
138
- vi.stubEnv('ASTRYX_AGENT_SESSION_ID', RAW_SESSION);
146
+ vi.stubEnv('AGENT_SESSION_ID', RAW_SESSION);
139
147
  const event = collectEvent();
140
148
  expect(event.env.agentSessionIdHash).toBe(RAW_SESSION_HASH);
141
149
  expect(event.env.agentSessionIdHash).not.toBe(REDACTED);
142
- expect(event.env.agentSessionIdSource).toBe('ASTRYX_AGENT_SESSION_ID');
150
+ expect(event.env.agentSessionIdSource).toBe('AGENT_SESSION_ID');
143
151
  });
144
152
 
145
153
  it('keeps the machine and runtime facts exactly as captured', () => {
@@ -70,8 +70,8 @@ export const MAX_VALUE_CHARS: 2048;
70
70
  * and their exact values are the whole reason the snapshot is useful.
71
71
  *
72
72
  * Everything else in `env` is free text handed to us by the invoking
73
- * environment — an agent name from `ASTRYX_AGENT_ID`, `AGENT`, or
74
- * `ASTRYX_AGENT_METADATA` — so it goes through the same content rules as argv.
73
+ * environment — an agent name from `AGENT` or a known agent signal — so it
74
+ * goes through the same content rules as argv.
75
75
  * The list is a positive allowlist rather than a denylist of risky fields: a
76
76
  * field added to the snapshot later is scrubbed until someone decides
77
77
  * otherwise, which is the safe direction to be wrong in.
@@ -407,8 +407,8 @@ export function createRedactor({
407
407
  * and their exact values are the whole reason the snapshot is useful.
408
408
  *
409
409
  * Everything else in `env` is free text handed to us by the invoking
410
- * environment — an agent name from `ASTRYX_AGENT_ID`, `AGENT`, or
411
- * `ASTRYX_AGENT_METADATA` — so it goes through the same content rules as argv.
410
+ * environment — an agent name from `AGENT` or a known agent signal — so it
411
+ * goes through the same content rules as argv.
412
412
  * The list is a positive allowlist rather than a denylist of risky fields: a
413
413
  * field added to the snapshot later is scrubbed until someone decides
414
414
  * otherwise, which is the safe direction to be wrong in.
@@ -130,7 +130,7 @@ function resolvePackageTheme(theme, cwd, ownerThemeCount) {
130
130
  findInstalledPackage(cwd, importPackage);
131
131
  if (!packageDir) {
132
132
  throw new ThemeImportError(
133
- `Theme package "${importPackage}" is not installed. Run \`npm install ${importPackage}\` (or yarn/pnpm/bun), then run \`astryx theme add ${theme.slug} --import\`.`,
133
+ `Theme package "${importPackage}" is not installed. Run \`npm install ${importPackage}\` (or yarn/pnpm/bun), then run \`astryx theme add ${theme.slug}\`.`,
134
134
  );
135
135
  }
136
136
  const pkg = readPackage(path.join(packageDir, 'package.json'));
@@ -12,12 +12,9 @@
12
12
  * not take out theme validation or the listing.
13
13
  *
14
14
  * @param {string} coreSrc - absolute path to `<core>/src`
15
- * @param {{includeDeprecated?: boolean}} [options] - preserve the CLI's full listing by default; ownership checks can request active targets only
16
15
  * @returns {Promise<ThemingTarget[]>}
17
16
  */
18
- export function collectThemingTargets(coreSrc: string, { includeDeprecated }?: {
19
- includeDeprecated?: boolean;
20
- }): Promise<ThemingTarget[]>;
17
+ export function collectThemingTargets(coreSrc: string): Promise<ThemingTarget[]>;
21
18
  /**
22
19
  * One public custom property a theme may set on a component's target.
23
20
  * @typedef {object} ThemingVar
@@ -43,18 +40,6 @@ export function collectThemingVars(coreSrc: string): Promise<ThemingVar[]>;
43
40
  * @returns {Record<string, string[]>}
44
41
  */
45
42
  export function targetsByKey(targets: ThemingTarget[]): Record<string, string[]>;
46
- /**
47
- * Build the component-validation registry from the same target rows used by
48
- * `theme targets`. Deprecated keys stay accepted during their compatibility
49
- * window, while the replacement map lets theme build issue exact guidance.
50
- *
51
- * @param {ThemingTarget[]} targets
52
- * @returns {{propsByKey: Record<string, string[]>, deprecatedByKey: Record<string, string>}}
53
- */
54
- export function targetValidationRegistry(targets: ThemingTarget[]): {
55
- propsByKey: Record<string, string[]>;
56
- deprecatedByKey: Record<string, string>;
57
- };
58
43
  /**
59
44
  * One theming target, as a theme author has to write it.
60
45
  */
@@ -79,10 +64,6 @@ export type ThemingTarget = {
79
64
  * - runtime states the target reflects (bare-name keys)
80
65
  */
81
66
  states: string[];
82
- /**
83
- * - canonical replacement key for a deprecated target
84
- */
85
- deprecatedFor?: string | undefined;
86
67
  };
87
68
  /**
88
69
  * One public custom property a theme may set on a component's target.
@@ -28,7 +28,6 @@ const SKIP_DIRS = new Set(['node_modules', '__tests__']);
28
28
  * @property {string} component - the component whose doc declares it
29
29
  * @property {string[]} props - visual props the target reflects (`variant:value` keys)
30
30
  * @property {string[]} states - runtime states the target reflects (bare-name keys)
31
- * @property {string} [deprecatedFor] - canonical replacement key for a deprecated target
32
31
  */
33
32
 
34
33
  /**
@@ -55,13 +54,9 @@ function targetKey(className) {
55
54
  * not take out theme validation or the listing.
56
55
  *
57
56
  * @param {string} coreSrc - absolute path to `<core>/src`
58
- * @param {{includeDeprecated?: boolean}} [options] - preserve the CLI's full listing by default; ownership checks can request active targets only
59
57
  * @returns {Promise<ThemingTarget[]>}
60
58
  */
61
- export async function collectThemingTargets(
62
- coreSrc,
63
- {includeDeprecated = true} = {},
64
- ) {
59
+ export async function collectThemingTargets(coreSrc) {
65
60
  if (!coreSrc || !fs.existsSync(coreSrc)) return [];
66
61
 
67
62
  /** @type {Array<ThemingTarget & {parent: string|null}>} */
@@ -92,7 +87,6 @@ export async function collectThemingTargets(
92
87
  : path.basename(path.dirname(full));
93
88
 
94
89
  for (const target of doc?.theming?.targets || []) {
95
- if (!includeDeprecated && target?.deprecatedFor != null) continue;
96
90
  const className = target?.className;
97
91
  if (typeof className !== 'string') continue;
98
92
  const key = targetKey(className);
@@ -105,9 +99,6 @@ export async function collectThemingTargets(
105
99
  typeof doc?.subComponentOf === 'string' ? doc.subComponentOf : null,
106
100
  props: stringList(target.visualProps),
107
101
  states: stringList(target.states),
108
- ...(typeof target.deprecatedFor === 'string'
109
- ? {deprecatedFor: target.deprecatedFor}
110
- : {}),
111
102
  });
112
103
  }
113
104
  }
@@ -158,7 +149,6 @@ function canonicalizeParentTargets(targets) {
158
149
  const canonical = roots[0];
159
150
  canonical.props = [...new Set([...canonical.props, ...target.props])];
160
151
  canonical.states = [...new Set([...canonical.states, ...target.states])];
161
- canonical.deprecatedFor ??= target.deprecatedFor;
162
152
  duplicates.add(target);
163
153
  }
164
154
 
@@ -252,33 +242,6 @@ export function targetsByKey(targets) {
252
242
  return byKey;
253
243
  }
254
244
 
255
- /**
256
- * Build the component-validation registry from the same target rows used by
257
- * `theme targets`. Deprecated keys stay accepted during their compatibility
258
- * window, while the replacement map lets theme build issue exact guidance.
259
- *
260
- * @param {ThemingTarget[]} targets
261
- * @returns {{propsByKey: Record<string, string[]>, deprecatedByKey: Record<string, string>}}
262
- */
263
- export function targetValidationRegistry(targets) {
264
- const propsByKey = targetsByKey(targets);
265
- /** @type {Record<string, string>} */
266
- const deprecatedByKey = {};
267
-
268
- for (const target of targets) {
269
- if (target.deprecatedFor == null) continue;
270
- const existing = deprecatedByKey[target.key];
271
- if (existing != null && existing !== target.deprecatedFor) {
272
- throw new Error(
273
- `Deprecated theme target "${target.key}" has conflicting replacements: "${existing}" and "${target.deprecatedFor}".`,
274
- );
275
- }
276
- deprecatedByKey[target.key] = target.deprecatedFor;
277
- }
278
-
279
- return {propsByKey, deprecatedByKey};
280
- }
281
-
282
245
  /**
283
246
  * @param {unknown} value
284
247
  * @returns {string[]}
@@ -25,6 +25,7 @@ import {describe, it, expect} from 'vitest';
25
25
  import * as fs from 'node:fs';
26
26
  import * as path from 'node:path';
27
27
  import {findCoreDir} from '../fs/paths.mjs';
28
+ import {DEPRECATED_THEME_TARGETS} from '../../assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs';
28
29
  import {
29
30
  discoverComponents,
30
31
  findComponentReadme,
@@ -34,69 +35,13 @@ import {
34
35
  collectThemingTargets,
35
36
  collectThemingVars,
36
37
  targetsByKey,
37
- targetValidationRegistry,
38
38
  } from './theming-targets.mjs';
39
39
 
40
40
  const coreDir = /** @type {string} */ (findCoreDir(process.cwd()));
41
41
  const coreSrc = path.join(coreDir, 'src');
42
- const repoRoot = path.resolve(coreDir, '../..');
43
-
44
- const DEPRECATED_TARGETS = {
45
- 'base-table': 'table',
46
- checkbox: 'checkbox-indicator',
47
- codeblock: 'code-block',
48
- 'codeblock-copy-button': 'code-block-copy-button',
49
- 'codeblock-header': 'code-block-header',
50
- 'codeblock-title': 'code-block-title',
51
- 'date-input-clear-icon': 'input-clear-icon',
52
- 'date-range-input-clear-icon': 'input-clear-icon',
53
- hovercard: 'hover-card',
54
- 'multi-selector-clear-icon': 'input-clear-icon',
55
- navicon: 'nav-icon',
56
- 'popover-surface': 'popover',
57
- progressbar: 'progress-bar',
58
- 'progressbar-fill': 'progress-bar-fill',
59
- 'progressbar-mark': 'progress-bar-mark',
60
- 'progressbar-track': 'progress-bar-track',
61
- radio: 'radio-indicator',
62
- 'radio-dot': 'radio-indicator-dot',
63
- 'selector-clear-icon': 'input-clear-icon',
64
- statusdot: 'status-dot',
65
- textarea: 'text-area',
66
- };
67
-
68
- /** Return the source text inside a static `components: {…}` object. */
69
- function componentsObjectSource(source) {
70
- const match = /\bcomponents\s*:\s*\{/.exec(source);
71
- if (match == null) return '';
72
- const start = match.index + match[0].length - 1;
73
- let depth = 0;
74
- let quote = null;
75
- let escaped = false;
76
- for (let index = start; index < source.length; index++) {
77
- const char = source[index];
78
- if (quote != null) {
79
- if (escaped) escaped = false;
80
- else if (char === '\\') escaped = true;
81
- else if (char === quote) quote = null;
82
- continue;
83
- }
84
- if (char === "'" || char === '"' || char === '`') {
85
- quote = char;
86
- continue;
87
- }
88
- if (char === '{') depth++;
89
- if (char === '}' && --depth === 0) return source.slice(start + 1, index);
90
- }
91
- return '';
92
- }
93
42
 
94
43
  /** @type {Promise<import('./theming-targets.mjs').ThemingTarget[]>} */
95
44
  const enumerated = collectThemingTargets(coreSrc);
96
- /** @type {Promise<import('./theming-targets.mjs').ThemingTarget[]>} */
97
- const activeEnumerated = collectThemingTargets(coreSrc, {
98
- includeDeprecated: false,
99
- });
100
45
 
101
46
  describe('collectThemingTargets', () => {
102
47
  it('enumerates the whole surface, not a handful', async () => {
@@ -112,126 +57,15 @@ describe('collectThemingTargets', () => {
112
57
  }
113
58
  });
114
59
 
115
- it('can limit ownership checks to active targets', async () => {
116
- const all = await enumerated;
117
- const active = await activeEnumerated;
118
- expect(
119
- all.some(t => t.component === 'CodeBlock' && t.key === 'codeblock'),
120
- ).toBe(true);
121
- expect(
122
- active.some(t => t.component === 'CodeBlock' && t.key === 'codeblock'),
123
- ).toBe(false);
124
- expect(
125
- active.some(t => t.component === 'CodeBlock' && t.key === 'code-block'),
126
- ).toBe(true);
127
- });
128
-
129
- it('keeps the deprecated Popover alias enumerable but out of active ownership', async () => {
130
- const allPopoverKeys = (await enumerated)
131
- .filter(target => target.component === 'Popover')
132
- .map(target => target.key);
133
- const activePopoverKeys = (await activeEnumerated)
134
- .filter(target => target.component === 'Popover')
135
- .map(target => target.key);
136
- const doc = await loadComponentDoc(
137
- path.join(coreSrc, 'Popover', 'Popover.doc.mjs'),
138
- );
139
-
140
- expect(allPopoverKeys).toEqual(['popover', 'popover-surface']);
141
- expect(activePopoverKeys).toEqual(['popover']);
142
- expect(doc.theming.targets).toContainEqual({
143
- className: 'astryx-popover-surface',
144
- deprecatedFor: 'popover',
145
- });
146
- });
147
-
148
- it('keeps every deprecated target discoverable with its exact replacement', async () => {
149
- const targets = await enumerated;
150
- for (const [key, deprecatedFor] of Object.entries(DEPRECATED_TARGETS)) {
151
- expect(
152
- targets.some(
153
- target =>
154
- target.key === key && target.deprecatedFor === deprecatedFor,
155
- ),
156
- `${key} should remain discoverable as deprecated for ${deprecatedFor}`,
157
- ).toBe(true);
158
- }
159
- });
160
-
161
- it('keeps maintained themes and copyable sources on canonical keys', () => {
162
- const themeFiles = [
163
- 'packages/themes/butter/src/butterTheme.ts',
164
- 'packages/themes/chocolate/src/chocolateTheme.ts',
165
- 'packages/themes/gothic/src/gothicTheme.ts',
166
- 'packages/themes/matcha/src/matchaTheme.ts',
167
- 'packages/themes/neutral/src/neutralTheme.ts',
168
- 'packages/themes/stone/src/stoneTheme.ts',
169
- 'packages/themes/y2k/src/y2kTheme.ts',
170
- 'packages/cli/assets/templates/themes/butter/butterTheme.ts',
171
- 'packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts',
172
- 'packages/cli/assets/templates/themes/gothic/gothicTheme.ts',
173
- 'packages/cli/assets/templates/themes/matcha/matchaTheme.ts',
174
- 'packages/cli/assets/templates/themes/neutral/neutralTheme.ts',
175
- 'packages/cli/assets/templates/themes/stone/stoneTheme.ts',
176
- 'packages/cli/assets/templates/themes/y2k/y2kTheme.ts',
177
- ];
178
- for (const relativePath of themeFiles) {
179
- const components = componentsObjectSource(
180
- fs.readFileSync(path.join(repoRoot, relativePath), 'utf8'),
60
+ it('does not enumerate any removed target alias', async () => {
61
+ const keys = new Set((await enumerated).map(target => target.key));
62
+ for (const removed of Object.keys(DEPRECATED_THEME_TARGETS)) {
63
+ expect(keys, `${removed} must not remain discoverable`).not.toContain(
64
+ removed,
181
65
  );
182
- for (const key of Object.keys(DEPRECATED_TARGETS)) {
183
- const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
184
- expect(components, `${relativePath} still uses ${key}`).not.toMatch(
185
- new RegExp(`(?:^|[,\\n]\\s*)(?:['"]${escaped}['"]|${escaped})\\s*:`),
186
- );
187
- }
188
- }
189
-
190
- const editorSource = fs.readFileSync(
191
- path.join(
192
- repoRoot,
193
- 'apps/docsite/src/app/playground/themeEditor/constants.ts',
194
- ),
195
- 'utf8',
196
- );
197
- for (const key of Object.keys(DEPRECATED_TARGETS)) {
198
- expect(editorSource, `theme editor still exposes ${key}`).not.toContain(
199
- `'${key}'`,
200
- );
201
- }
202
- });
203
-
204
- it('keeps deprecated replacements in the validation registry', async () => {
205
- const registry = targetValidationRegistry(await enumerated);
206
- for (const [key, replacement] of Object.entries(DEPRECATED_TARGETS)) {
207
- expect(registry.propsByKey).toHaveProperty(key);
208
- expect(registry.deprecatedByKey[key]).toBe(replacement);
209
66
  }
210
67
  });
211
68
 
212
- it('rejects conflicting canonical replacements for one deprecated key', () => {
213
- expect(() =>
214
- targetValidationRegistry([
215
- {
216
- key: 'old-target',
217
- className: 'astryx-old-target',
218
- component: 'One',
219
- props: [],
220
- states: [],
221
- deprecatedFor: 'first-target',
222
- },
223
- {
224
- key: 'old-target',
225
- className: 'astryx-old-target',
226
- component: 'Two',
227
- props: [],
228
- states: [],
229
- deprecatedFor: 'second-target',
230
- },
231
- ]),
232
- ).toThrow(/conflicting replacements/);
233
- });
234
-
235
69
  it('carries the props and states a target reflects', async () => {
236
70
  const targets = await enumerated;
237
71
  expect(targets.find(t => t.key === 'switch-thumb')).toEqual({
@@ -318,13 +152,13 @@ describe('collectThemingTargets', () => {
318
152
  it('collapses to the override keys, merging the components that share one', async () => {
319
153
  const byKey = targetsByKey(await enumerated);
320
154
  expect(byKey['switch']).toEqual(['size', 'checked', 'disabled']);
321
- // `radio` is documented by two unrelated owners. Parent/child
155
+ // `radio-indicator` is documented by two unrelated owners. Parent/child
322
156
  // canonicalization must not collapse a shared target across families.
323
- const radio = (await enumerated).filter(t => t.key === 'radio');
157
+ const radio = (await enumerated).filter(t => t.key === 'radio-indicator');
324
158
  expect(radio.map(t => t.component)).toEqual(['Indicator', 'RadioList']);
325
159
  for (const t of radio) {
326
160
  for (const name of [...t.props, ...t.states]) {
327
- expect(byKey['radio']).toContain(name);
161
+ expect(byKey['radio-indicator']).toContain(name);
328
162
  }
329
163
  }
330
164
  });