project-tiny-context-harness 0.8.4 → 0.8.5

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 (252) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +393 -371
  3. package/assets/README.md +573 -526
  4. package/assets/README.zh-CN.md +333 -311
  5. package/assets/agents/.gitkeep +1 -1
  6. package/assets/agents/AGENTS_CORE.md +44 -25
  7. package/assets/context_templates/architecture.md +28 -28
  8. package/assets/context_templates/area.md +34 -34
  9. package/assets/context_templates/context.toml +30 -30
  10. package/assets/context_templates/deployment.md +35 -35
  11. package/assets/context_templates/global.md +57 -57
  12. package/assets/context_templates/product-surface-contract.md +70 -70
  13. package/assets/context_templates/screen-contract.md +189 -189
  14. package/assets/context_templates/verification.md +32 -32
  15. package/assets/github/.gitkeep +1 -1
  16. package/assets/github/harness.yml +39 -39
  17. package/assets/make/.gitkeep +1 -1
  18. package/assets/make/ty-context.mk +48 -48
  19. package/assets/skills/context_development_engineer/SKILL.md +148 -125
  20. package/assets/skills/context_full_project_export/SKILL.md +28 -28
  21. package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
  22. package/assets/skills/context_product_plan/SKILL.md +99 -79
  23. package/assets/skills/context_surface_contract/SKILL.md +191 -191
  24. package/assets/skills/context_uiux_design/SKILL.md +171 -171
  25. package/assets/skills/design-resource-authoring/SKILL.md +86 -84
  26. package/assets/skills/design-resource-authoring/references/downstream-handoff.md +138 -123
  27. package/assets/skills/design-resource-authoring/references/open-design-provider.md +132 -127
  28. package/assets/skills/design-resource-authoring/references/resource-selection.md +181 -154
  29. package/assets/skills/design-system-authoring/SKILL.md +57 -57
  30. package/assets/skills/design-system-authoring/agents/openai.yaml +6 -6
  31. package/assets/skills/design-system-authoring/references/authority-adoption.md +48 -48
  32. package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +110 -110
  33. package/assets/skills/long-task-workflow/SKILL.md +98 -92
  34. package/assets/skills/long-task-workflow/agents/openai.yaml +3 -1
  35. package/assets/skills/long-task-workflow/references/authority-lifecycle.md +72 -72
  36. package/assets/skills/long-task-workflow/references/contract-authoring.md +122 -101
  37. package/assets/skills/long-task-workflow/references/evidence-design.md +82 -61
  38. package/assets/skills/long-task-workflow/references/source-authoring.md +109 -90
  39. package/assets/skills/source-plan-authoring/SKILL.md +14 -14
  40. package/assets/tools/validate_context.py +442 -442
  41. package/dist/commands/long-task-authoring.js +27 -2
  42. package/dist/lib/context-templates.js +1 -1
  43. package/dist/lib/design-resource-fact-enums.d.ts +20 -0
  44. package/dist/lib/design-resource-fact-enums.js +170 -0
  45. package/dist/lib/design-resource-fact-locator-extractors.d.ts +8 -0
  46. package/dist/lib/design-resource-fact-locator-extractors.js +108 -0
  47. package/dist/lib/design-resource-fact-locator-resolver.d.ts +3 -0
  48. package/dist/lib/design-resource-fact-locator-resolver.js +112 -0
  49. package/dist/lib/design-resource-fact-locator-validation.d.ts +5 -0
  50. package/dist/lib/design-resource-fact-locator-validation.js +16 -0
  51. package/dist/lib/design-resource-fact-manifest-catalog.d.ts +4 -0
  52. package/dist/lib/design-resource-fact-manifest-catalog.js +249 -0
  53. package/dist/lib/design-resource-fact-manifest-model.d.ts +91 -0
  54. package/dist/lib/design-resource-fact-manifest-model.js +21 -0
  55. package/dist/lib/design-resource-fact-manifest-shape-axes.d.ts +6 -0
  56. package/dist/lib/design-resource-fact-manifest-shape-axes.js +159 -0
  57. package/dist/lib/design-resource-fact-manifest-shape-evidence.d.ts +4 -0
  58. package/dist/lib/design-resource-fact-manifest-shape-evidence.js +59 -0
  59. package/dist/lib/design-resource-fact-manifest-shape-facts.d.ts +4 -0
  60. package/dist/lib/design-resource-fact-manifest-shape-facts.js +109 -0
  61. package/dist/lib/design-resource-fact-manifest-shape-inspector.d.ts +5 -0
  62. package/dist/lib/design-resource-fact-manifest-shape-inspector.js +144 -0
  63. package/dist/lib/design-resource-fact-manifest-shape.d.ts +7 -0
  64. package/dist/lib/design-resource-fact-manifest-shape.js +75 -0
  65. package/dist/lib/design-resource-fact-manifest-types.d.ts +3 -0
  66. package/dist/lib/design-resource-fact-manifest-types.js +3 -0
  67. package/dist/lib/design-resource-fact-manifest-universe.d.ts +5 -0
  68. package/dist/lib/design-resource-fact-manifest-universe.js +50 -0
  69. package/dist/lib/design-resource-fact-manifest-validation.d.ts +3 -0
  70. package/dist/lib/design-resource-fact-manifest-validation.js +106 -0
  71. package/dist/lib/design-resource-fact-policy.d.ts +18 -0
  72. package/dist/lib/design-resource-fact-policy.js +72 -1
  73. package/dist/lib/design-resource-fact-property-methods.d.ts +3 -0
  74. package/dist/lib/design-resource-fact-property-methods.js +158 -0
  75. package/dist/lib/design-resource-fact-shape-primitives.d.ts +3 -0
  76. package/dist/lib/design-resource-fact-shape-primitives.js +18 -0
  77. package/dist/lib/design-resource-fact-types.d.ts +164 -0
  78. package/dist/lib/design-resource-fact-types.js +1 -0
  79. package/dist/lib/design-resource-fact-universe-assets.d.ts +4 -0
  80. package/dist/lib/design-resource-fact-universe-assets.js +71 -0
  81. package/dist/lib/design-resource-fact-universe-catalog.d.ts +4 -0
  82. package/dist/lib/design-resource-fact-universe-catalog.js +151 -0
  83. package/dist/lib/design-resource-fact-universe-conditions.d.ts +2 -0
  84. package/dist/lib/design-resource-fact-universe-conditions.js +92 -0
  85. package/dist/lib/design-resource-fact-universe-facts.d.ts +4 -0
  86. package/dist/lib/design-resource-fact-universe-facts.js +108 -0
  87. package/dist/lib/design-resource-fact-universe-helpers.d.ts +30 -0
  88. package/dist/lib/design-resource-fact-universe-helpers.js +167 -0
  89. package/dist/lib/design-resource-fact-universe-inspector.d.ts +7 -0
  90. package/dist/lib/design-resource-fact-universe-inspector.js +119 -0
  91. package/dist/lib/design-resource-fact-universe-proof.d.ts +4 -0
  92. package/dist/lib/design-resource-fact-universe-proof.js +113 -0
  93. package/dist/lib/design-resource-fact-universe-subjects.d.ts +5 -0
  94. package/dist/lib/design-resource-fact-universe-subjects.js +97 -0
  95. package/dist/lib/design-resource-fact-universe-variations.d.ts +2 -0
  96. package/dist/lib/design-resource-fact-universe-variations.js +75 -0
  97. package/dist/lib/design-resource-fact-value-validation.d.ts +2 -0
  98. package/dist/lib/design-resource-fact-value-validation.js +80 -0
  99. package/dist/lib/design-resource-handoff-file-primitives.js +2 -0
  100. package/dist/lib/design-resource-handoff-file-validation.js +13 -100
  101. package/dist/lib/design-resource-handoff-policy.d.ts +1 -0
  102. package/dist/lib/design-resource-handoff-policy.js +118 -11
  103. package/dist/lib/design-resource-handoff-shape-evidence.js +46 -3
  104. package/dist/lib/design-resource-handoff-shape-primitives.d.ts +5 -0
  105. package/dist/lib/design-resource-handoff-shape-primitives.js +28 -0
  106. package/dist/lib/design-resource-handoff-shape-structure.js +143 -22
  107. package/dist/lib/design-resource-handoff-shape.js +25 -0
  108. package/dist/lib/design-resource-handoff-types.d.ts +97 -21
  109. package/dist/lib/design-resource-handoff-types.js +22 -0
  110. package/dist/lib/design-resource-handoff-validation-coverage.d.ts +1 -1
  111. package/dist/lib/design-resource-handoff-validation-coverage.js +145 -118
  112. package/dist/lib/design-resource-handoff-validation-fact-cells.d.ts +2 -0
  113. package/dist/lib/design-resource-handoff-validation-fact-cells.js +60 -0
  114. package/dist/lib/design-resource-handoff-validation-fact-records.d.ts +2 -0
  115. package/dist/lib/design-resource-handoff-validation-fact-records.js +90 -0
  116. package/dist/lib/design-resource-handoff-validation-facts.js +10 -94
  117. package/dist/lib/design-resource-handoff-validation-proofs.d.ts +2 -0
  118. package/dist/lib/design-resource-handoff-validation-proofs.js +67 -0
  119. package/dist/lib/design-resource-handoff-validation-resource-closure.d.ts +3 -0
  120. package/dist/lib/design-resource-handoff-validation-resource-closure.js +88 -0
  121. package/dist/lib/design-resource-handoff-validation-structure.js +43 -14
  122. package/dist/lib/design-resource-handoff-validation.js +32 -0
  123. package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +2 -1
  124. package/dist/lib/design-resource-handoff-web-dependency-validation.js +67 -7
  125. package/dist/lib/execution-target-capabilities.d.ts +1 -1
  126. package/dist/lib/execution-target-capabilities.js +14 -0
  127. package/dist/lib/long-task-activation-validation.js +6 -2
  128. package/dist/lib/long-task-applicability-shape.js +3 -3
  129. package/dist/lib/long-task-authoring-authority-preview.js +1 -0
  130. package/dist/lib/long-task-authority-policy.d.ts +1 -0
  131. package/dist/lib/long-task-authority-policy.js +1 -0
  132. package/dist/lib/long-task-authority.js +13 -0
  133. package/dist/lib/long-task-claim-definitions.js +13 -1
  134. package/dist/lib/long-task-claims.js +23 -1
  135. package/dist/lib/long-task-contract-types.d.ts +3 -0
  136. package/dist/lib/long-task-delivery-compiler.js +1 -0
  137. package/dist/lib/long-task-delivery-parser.js +11 -1
  138. package/dist/lib/long-task-delivery-types.d.ts +1 -0
  139. package/dist/lib/long-task-delivery-types.js +1 -0
  140. package/dist/lib/long-task-delivery-validation.js +17 -0
  141. package/dist/lib/long-task-design-resource-handoff.js +62 -38
  142. package/dist/lib/long-task-design-target-capabilities.d.ts +14 -0
  143. package/dist/lib/long-task-design-target-capabilities.js +126 -0
  144. package/dist/lib/long-task-evidence-capability-codec.d.ts +94 -0
  145. package/dist/lib/long-task-evidence-capability-codec.js +395 -22
  146. package/dist/lib/long-task-evidence-capability-policy.js +18 -0
  147. package/dist/lib/long-task-evidence-capability-runtime.js +78 -0
  148. package/dist/lib/long-task-evidence-capability-types.d.ts +114 -1
  149. package/dist/lib/long-task-outcome-parser.js +4 -0
  150. package/dist/lib/long-task-playwright-capability-records.d.ts +5 -0
  151. package/dist/lib/long-task-playwright-capability-records.js +146 -0
  152. package/dist/lib/long-task-playwright-case-evidence.d.ts +3 -2
  153. package/dist/lib/long-task-playwright-case-evidence.js +10 -79
  154. package/dist/lib/long-task-playwright-case-primitives.d.ts +28 -0
  155. package/dist/lib/long-task-playwright-case-primitives.js +143 -0
  156. package/dist/lib/long-task-playwright-evidence.d.ts +1 -1
  157. package/dist/lib/long-task-playwright-evidence.js +10 -75
  158. package/dist/lib/long-task-runner-freeze.d.ts +2 -2
  159. package/dist/lib/long-task-runner-freeze.js +15 -1
  160. package/dist/lib/long-task-runtime-types.d.ts +4 -1
  161. package/dist/lib/long-task-semantic-contract-types.d.ts +1 -1
  162. package/dist/lib/long-task-semantic-drift-migration.js +2 -2
  163. package/dist/lib/long-task-semantic-fact-binding-types.d.ts +57 -0
  164. package/dist/lib/long-task-semantic-fact-binding-types.js +1 -0
  165. package/dist/lib/long-task-semantic-fact-closure-primitives.d.ts +5 -0
  166. package/dist/lib/long-task-semantic-fact-closure-primitives.js +43 -0
  167. package/dist/lib/long-task-semantic-fact-closure.d.ts +13 -0
  168. package/dist/lib/long-task-semantic-fact-closure.js +48 -0
  169. package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +4 -0
  170. package/dist/lib/long-task-semantic-fact-contract-closure.js +24 -0
  171. package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +4 -0
  172. package/dist/lib/long-task-semantic-fact-contract-facts.js +30 -0
  173. package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +4 -0
  174. package/dist/lib/long-task-semantic-fact-contract-proofs.js +97 -0
  175. package/dist/lib/long-task-semantic-fact-evidence.d.ts +21 -0
  176. package/dist/lib/long-task-semantic-fact-evidence.js +165 -0
  177. package/dist/lib/long-task-semantic-fact-input-closure.d.ts +4 -0
  178. package/dist/lib/long-task-semantic-fact-input-closure.js +101 -0
  179. package/dist/lib/long-task-semantic-fact-provenance-closure.d.ts +4 -0
  180. package/dist/lib/long-task-semantic-fact-provenance-closure.js +140 -0
  181. package/dist/lib/long-task-semantic-fact-shape.d.ts +3 -0
  182. package/dist/lib/long-task-semantic-fact-shape.js +89 -0
  183. package/dist/lib/long-task-semantic-fact-value-closure.d.ts +3 -0
  184. package/dist/lib/long-task-semantic-fact-value-closure.js +110 -0
  185. package/dist/lib/long-task-shape-primitives.d.ts +2 -1
  186. package/dist/lib/long-task-shape-primitives.js +7 -0
  187. package/dist/lib/long-task-source-item-parser.js +25 -6
  188. package/dist/lib/long-task-source-target-continuity.js +4 -1
  189. package/dist/lib/long-task-source-target-index.d.ts +1 -1
  190. package/dist/lib/long-task-source-target-index.js +5 -1
  191. package/dist/lib/long-task-ui-design-policy.js +8 -4
  192. package/dist/lib/long-task-ui-surface-shape.js +83 -1
  193. package/dist/lib/long-task-ui-surface-types.d.ts +29 -0
  194. package/dist/lib/modularity.js +7 -1
  195. package/dist/lib/semantic-fact-base-types.d.ts +14 -0
  196. package/dist/lib/semantic-fact-base-types.js +1 -0
  197. package/dist/lib/semantic-fact-catalog.d.ts +8 -0
  198. package/dist/lib/semantic-fact-catalog.js +191 -0
  199. package/dist/lib/semantic-fact-condition-shape.d.ts +48 -0
  200. package/dist/lib/semantic-fact-condition-shape.js +111 -0
  201. package/dist/lib/semantic-fact-input-shape.d.ts +34 -0
  202. package/dist/lib/semantic-fact-input-shape.js +111 -0
  203. package/dist/lib/semantic-fact-inventory-types.d.ts +147 -0
  204. package/dist/lib/semantic-fact-inventory-types.js +1 -0
  205. package/dist/lib/semantic-fact-manifest-shape.d.ts +4 -0
  206. package/dist/lib/semantic-fact-manifest-shape.js +135 -0
  207. package/dist/lib/semantic-fact-manifest-types.d.ts +58 -0
  208. package/dist/lib/semantic-fact-manifest-types.js +19 -0
  209. package/dist/lib/semantic-fact-policy-authority.d.ts +8 -0
  210. package/dist/lib/semantic-fact-policy-authority.js +79 -0
  211. package/dist/lib/semantic-fact-policy-census.d.ts +2 -0
  212. package/dist/lib/semantic-fact-policy-census.js +80 -0
  213. package/dist/lib/semantic-fact-policy-condition-references.d.ts +7 -0
  214. package/dist/lib/semantic-fact-policy-condition-references.js +19 -0
  215. package/dist/lib/semantic-fact-policy-conditions.d.ts +2 -0
  216. package/dist/lib/semantic-fact-policy-conditions.js +105 -0
  217. package/dist/lib/semantic-fact-policy-facts.d.ts +3 -0
  218. package/dist/lib/semantic-fact-policy-facts.js +73 -0
  219. package/dist/lib/semantic-fact-policy-primitives.d.ts +26 -0
  220. package/dist/lib/semantic-fact-policy-primitives.js +169 -0
  221. package/dist/lib/semantic-fact-policy-proofs.d.ts +2 -0
  222. package/dist/lib/semantic-fact-policy-proofs.js +75 -0
  223. package/dist/lib/semantic-fact-policy-properties.d.ts +3 -0
  224. package/dist/lib/semantic-fact-policy-properties.js +84 -0
  225. package/dist/lib/semantic-fact-policy-units.d.ts +4 -0
  226. package/dist/lib/semantic-fact-policy-units.js +103 -0
  227. package/dist/lib/semantic-fact-policy.d.ts +17 -0
  228. package/dist/lib/semantic-fact-policy.js +41 -0
  229. package/dist/lib/semantic-fact-proof-shape.d.ts +51 -0
  230. package/dist/lib/semantic-fact-proof-shape.js +121 -0
  231. package/dist/lib/semantic-fact-proof-types.d.ts +74 -0
  232. package/dist/lib/semantic-fact-proof-types.js +1 -0
  233. package/dist/lib/semantic-fact-property-shape.d.ts +29 -0
  234. package/dist/lib/semantic-fact-property-shape.js +77 -0
  235. package/dist/lib/semantic-fact-shape-constants.d.ts +3 -0
  236. package/dist/lib/semantic-fact-shape-constants.js +38 -0
  237. package/dist/lib/semantic-fact-shape-primitives.d.ts +15 -0
  238. package/dist/lib/semantic-fact-shape-primitives.js +68 -0
  239. package/dist/lib/semantic-fact-source-parser.d.ts +9 -0
  240. package/dist/lib/semantic-fact-source-parser.js +46 -0
  241. package/dist/lib/semantic-fact-support-shape.d.ts +21 -0
  242. package/dist/lib/semantic-fact-support-shape.js +59 -0
  243. package/dist/lib/semantic-fact-types.d.ts +5 -0
  244. package/dist/lib/semantic-fact-types.js +5 -0
  245. package/dist/lib/semantic-fact-unit-shape.d.ts +34 -0
  246. package/dist/lib/semantic-fact-unit-shape.js +89 -0
  247. package/dist/lib/semantic-fact-value-shape.d.ts +12 -0
  248. package/dist/lib/semantic-fact-value-shape.js +39 -0
  249. package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +1339 -131
  250. package/migrations/README.md +15 -15
  251. package/package.json +84 -84
  252. package/source-mappings.yaml +25 -25
@@ -24,6 +24,7 @@ export function compactLongTaskTemplate() {
24
24
  }
25
25
  function template() {
26
26
  return `schema_version: long-task-delivery-v2
27
+ semantic_fact_manifest: {key: replace-semantic-facts, source_path: plans/replace-me.md, sha256: "1111111111111111111111111111111111111111111111111111111111111111"}
27
28
  task:
28
29
  id: replace-me
29
30
  title: Replace me
@@ -76,6 +77,21 @@ outcomes:
76
77
  dimensions: [{key: delivery-state, value: ready}]
77
78
  given_refs: [source-ready]
78
79
  when_refs: [inspect-result]
80
+ semantic_fact_bindings:
81
+ manifest_ref: replace-semantic-facts
82
+ facts:
83
+ - fact_ref: replace.result.observable
84
+ claim_ref: semantic_fact.replace.result.observable
85
+ applicability_ref: root-success
86
+ proofs:
87
+ - proof_ref: replace.result.observable.runtime
88
+ fact_ref: replace.result.observable
89
+ method: exact_value
90
+ proof_surface: runtime_behavior
91
+ evidence_capabilities: [semantic_fact]
92
+ authority: machine
93
+ check_ref: replace-check
94
+ assertion_ref: replace-semantic-fact
79
95
  product:
80
96
  observable_result: Describe what a user or system can observe.
81
97
  result_applicability_refs: [root-success]
@@ -123,6 +139,7 @@ outcomes:
123
139
  verification_inputs: ["tests/replace-oracle.mjs"]
124
140
  input_paths: [src/replace-me.ts]
125
141
  expected_output_paths: [src/replace-me.ts]
142
+ artifact_globs: [artifacts/replace-semantic-fact.json]
126
143
  positive_assertions:
127
144
  - key: replace-result
128
145
  criterion: The declared outcome is observable.
@@ -132,6 +149,14 @@ outcomes:
132
149
  evidence_capabilities: [state_delta, target_runtime]
133
150
  operator: equals
134
151
  expected: true
152
+ - key: replace-semantic-fact
153
+ criterion: The exact Source-indexed semantic Fact passes its frozen comparison on the current target.
154
+ claims: [semantic_fact.replace.result.observable]
155
+ applicability_ref: root-success
156
+ observation: semantic_fact_replace_result_observable
157
+ evidence_capabilities: [semantic_fact]
158
+ operator: equals
159
+ expected: true
135
160
  - key: replace-requirement
136
161
  criterion: The atomic Source requirement is observable.
137
162
  claims: [requirement.replace-requirement]
@@ -167,14 +192,14 @@ outcomes:
167
192
  counterfactual_controls:
168
193
  - key: replace-semantic-carrier
169
194
  binding_key: replace-carrier
170
- claims: [result, requirement.replace-requirement, obligation.architecture]
195
+ claims: [result, requirement.replace-requirement, obligation.architecture, semantic_fact.replace.result.observable]
171
196
  check_key: replace-check
172
197
  mutation:
173
198
  type: replace_text
174
199
  path: src/replace-me.ts
175
200
  match: IMPLEMENTED_STATE
176
201
  replacement: SEMANTIC_FAILURE_STATE
177
- expected_assertion_failures: [replace-result, replace-requirement, replace-architecture]
202
+ expected_assertion_failures: [replace-result, replace-requirement, replace-architecture, replace-semantic-fact]
178
203
  preserved_assertions: [replace-liveness]
179
204
  - key: replace-relation-applicability
180
205
  binding_key: replace-carrier
@@ -46,7 +46,7 @@ export function globalContextTemplate() {
46
46
  "",
47
47
  "## Next Safe Action",
48
48
  "",
49
- "- State the safest next step for a fresh agent, including whether the next change should update Context before code.",
49
+ "- State a stable safe re-entry rule for a fresh agent, including when Context must be updated before code. Do not store task-local progress or a one-off next edit here.",
50
50
  "",
51
51
  "## Context Index",
52
52
  "",
@@ -0,0 +1,20 @@
1
+ export declare const DESIGN_RESOURCE_STANDARD_CONDITION_AXES: readonly ["platform", "os_version", "device_profile", "form_factor", "viewport", "orientation", "density", "safe_area", "window_state", "fold_state", "display_mode", "color_scheme", "locale", "language", "script", "direction", "pseudo_localization", "content_case", "data_case", "text_scale", "input_method", "assistive_technology", "motion", "transparency", "contrast", "bold_text", "button_shapes", "system_ui", "ime", "permission", "capability", "connectivity", "lifecycle"];
2
+ export type DesignResourceStandardConditionAxis = (typeof DESIGN_RESOURCE_STANDARD_CONDITION_AXES)[number];
3
+ export declare const DESIGN_RESOURCE_VARIATION_AXES: readonly ["variant", "state", "interaction_phase", "presence_phase", "instance_case"];
4
+ export type DesignResourceVariationAxis = (typeof DESIGN_RESOURCE_VARIATION_AXES)[number];
5
+ export declare const DESIGN_RESOURCE_SUBJECT_KINDS: readonly ["surface", "flow", "region", "overlay", "system_ui", "component_family", "component_instance", "control", "anatomy_part", "slot", "primitive", "text", "icon", "media", "asset", "relation"];
6
+ export type DesignResourceSubjectKind = (typeof DESIGN_RESOURCE_SUBJECT_KINDS)[number];
7
+ export declare const DESIGN_RESOURCE_SUBJECT_PRESENCE_KINDS: readonly ["always", "conditional", "lazy", "virtualized", "portal", "overlay", "system_presented"];
8
+ export type DesignResourceSubjectPresenceKind = (typeof DESIGN_RESOURCE_SUBJECT_PRESENCE_KINDS)[number];
9
+ export declare const DESIGN_RESOURCE_PROPERTY_FAMILIES: readonly ["geometry", "layout", "scroll", "typography", "color", "decoration", "content", "icon", "media", "interaction", "navigation", "motion", "feedback", "responsive", "accessibility", "asset", "system", "relation"];
10
+ export type DesignResourcePropertyFamily = (typeof DESIGN_RESOURCE_PROPERTY_FAMILIES)[number];
11
+ export declare const DESIGN_RESOURCE_VALUE_KINDS: readonly ["boolean", "color", "digest", "enum", "length", "list", "locator", "number", "ratio", "relation", "semantic", "string", "timeline", "token_ref", "trace"];
12
+ export type DesignResourceValueKind = (typeof DESIGN_RESOURCE_VALUE_KINDS)[number];
13
+ export declare const DESIGN_RESOURCE_LINEAGE_NODE_KINDS: readonly ["base_token", "alias_token", "semantic_token", "component_token", "platform_override", "mode_override", "state_override", "instance_override", "slot_override", "direct_value"];
14
+ export type DesignResourceLineageNodeKind = (typeof DESIGN_RESOURCE_LINEAGE_NODE_KINDS)[number];
15
+ export declare const DESIGN_RESOURCE_COMPARATORS: readonly ["exact_value", "numeric_delta", "geometry_delta", "pixel_diff", "token_resolution", "content_equal", "state_equal", "trace_equal", "timeline_equal", "reflow_equal", "semantic_equal", "asset_equal"];
16
+ export type DesignResourceComparator = (typeof DESIGN_RESOURCE_COMPARATORS)[number];
17
+ export declare const DESIGN_RESOURCE_INSPECTOR_CAPABILITIES: readonly ["html_dom", "css_cascade", "javascript_static", "json", "svg", "markdown", "assets", "design_tokens", "component_anatomy", "prototype_transitions", "responsive_rules", "input_rules", "accessibility", "motion", "localization", "system_ui", "haptics", "audio", "render_capture", "geometry_measurement", "custom_properties", "relations", "dynamic_population"];
18
+ export type DesignResourceInspectorCapability = (typeof DESIGN_RESOURCE_INSPECTOR_CAPABILITIES)[number];
19
+ export declare const DESIGN_RESOURCE_CENSUS_KINDS: readonly ["resource", "node", "declaration", "token", "asset_reference", "relation", "custom_property", "variant", "state", "interaction_phase", "dynamic_population"];
20
+ export type DesignResourceCensusKind = (typeof DESIGN_RESOURCE_CENSUS_KINDS)[number];
@@ -0,0 +1,170 @@
1
+ export const DESIGN_RESOURCE_STANDARD_CONDITION_AXES = [
2
+ "platform",
3
+ "os_version",
4
+ "device_profile",
5
+ "form_factor",
6
+ "viewport",
7
+ "orientation",
8
+ "density",
9
+ "safe_area",
10
+ "window_state",
11
+ "fold_state",
12
+ "display_mode",
13
+ "color_scheme",
14
+ "locale",
15
+ "language",
16
+ "script",
17
+ "direction",
18
+ "pseudo_localization",
19
+ "content_case",
20
+ "data_case",
21
+ "text_scale",
22
+ "input_method",
23
+ "assistive_technology",
24
+ "motion",
25
+ "transparency",
26
+ "contrast",
27
+ "bold_text",
28
+ "button_shapes",
29
+ "system_ui",
30
+ "ime",
31
+ "permission",
32
+ "capability",
33
+ "connectivity",
34
+ "lifecycle",
35
+ ];
36
+ export const DESIGN_RESOURCE_VARIATION_AXES = [
37
+ "variant",
38
+ "state",
39
+ "interaction_phase",
40
+ "presence_phase",
41
+ "instance_case",
42
+ ];
43
+ export const DESIGN_RESOURCE_SUBJECT_KINDS = [
44
+ "surface",
45
+ "flow",
46
+ "region",
47
+ "overlay",
48
+ "system_ui",
49
+ "component_family",
50
+ "component_instance",
51
+ "control",
52
+ "anatomy_part",
53
+ "slot",
54
+ "primitive",
55
+ "text",
56
+ "icon",
57
+ "media",
58
+ "asset",
59
+ "relation",
60
+ ];
61
+ export const DESIGN_RESOURCE_SUBJECT_PRESENCE_KINDS = [
62
+ "always",
63
+ "conditional",
64
+ "lazy",
65
+ "virtualized",
66
+ "portal",
67
+ "overlay",
68
+ "system_presented",
69
+ ];
70
+ export const DESIGN_RESOURCE_PROPERTY_FAMILIES = [
71
+ "geometry",
72
+ "layout",
73
+ "scroll",
74
+ "typography",
75
+ "color",
76
+ "decoration",
77
+ "content",
78
+ "icon",
79
+ "media",
80
+ "interaction",
81
+ "navigation",
82
+ "motion",
83
+ "feedback",
84
+ "responsive",
85
+ "accessibility",
86
+ "asset",
87
+ "system",
88
+ "relation",
89
+ ];
90
+ export const DESIGN_RESOURCE_VALUE_KINDS = [
91
+ "boolean",
92
+ "color",
93
+ "digest",
94
+ "enum",
95
+ "length",
96
+ "list",
97
+ "locator",
98
+ "number",
99
+ "ratio",
100
+ "relation",
101
+ "semantic",
102
+ "string",
103
+ "timeline",
104
+ "token_ref",
105
+ "trace",
106
+ ];
107
+ export const DESIGN_RESOURCE_LINEAGE_NODE_KINDS = [
108
+ "base_token",
109
+ "alias_token",
110
+ "semantic_token",
111
+ "component_token",
112
+ "platform_override",
113
+ "mode_override",
114
+ "state_override",
115
+ "instance_override",
116
+ "slot_override",
117
+ "direct_value",
118
+ ];
119
+ export const DESIGN_RESOURCE_COMPARATORS = [
120
+ "exact_value",
121
+ "numeric_delta",
122
+ "geometry_delta",
123
+ "pixel_diff",
124
+ "token_resolution",
125
+ "content_equal",
126
+ "state_equal",
127
+ "trace_equal",
128
+ "timeline_equal",
129
+ "reflow_equal",
130
+ "semantic_equal",
131
+ "asset_equal",
132
+ ];
133
+ export const DESIGN_RESOURCE_INSPECTOR_CAPABILITIES = [
134
+ "html_dom",
135
+ "css_cascade",
136
+ "javascript_static",
137
+ "json",
138
+ "svg",
139
+ "markdown",
140
+ "assets",
141
+ "design_tokens",
142
+ "component_anatomy",
143
+ "prototype_transitions",
144
+ "responsive_rules",
145
+ "input_rules",
146
+ "accessibility",
147
+ "motion",
148
+ "localization",
149
+ "system_ui",
150
+ "haptics",
151
+ "audio",
152
+ "render_capture",
153
+ "geometry_measurement",
154
+ "custom_properties",
155
+ "relations",
156
+ "dynamic_population",
157
+ ];
158
+ export const DESIGN_RESOURCE_CENSUS_KINDS = [
159
+ "resource",
160
+ "node",
161
+ "declaration",
162
+ "token",
163
+ "asset_reference",
164
+ "relation",
165
+ "custom_property",
166
+ "variant",
167
+ "state",
168
+ "interaction_phase",
169
+ "dynamic_population",
170
+ ];
@@ -0,0 +1,8 @@
1
+ export declare function cssRuleBody(content: string, selector: string, detail: string): string;
2
+ export declare function htmlOpeningTag(content: string, selector: string, detail: string): string;
3
+ export declare function htmlAttribute(content: string, selector: string, attribute: string, detail: string): string;
4
+ export declare function elementInnerContent(content: string, selector: string, detail: string): string;
5
+ export declare function markdownSection(content: string, anchor: string, detail: string): string;
6
+ export declare function javascriptExport(content: string, identifier: string, detail: string): string;
7
+ export declare function uniqueCapture(content: string, expression: RegExp, detail: string): string;
8
+ export declare function escapeRegExp(value: string): string;
@@ -0,0 +1,108 @@
1
+ import { htmlAttributes } from "./design-resource-handoff-file-primitives.js";
2
+ import { invalidDesignResourceHandoff } from "./design-resource-handoff-validation-primitives.js";
3
+ export function cssRuleBody(content, selector, detail) {
4
+ const bodies = [];
5
+ for (const match of content.matchAll(/(?:^|\})\s*([^@{}][^{}]*)\{([^{}]*)\}/gmu)) {
6
+ if (match[1]
7
+ .split(",")
8
+ .map((item) => item.trim())
9
+ .includes(selector))
10
+ bodies.push(match[2]);
11
+ }
12
+ if (bodies.length !== 1)
13
+ invalidDesignResourceHandoff(bodies.length ? "locator_ambiguous" : "locator_not_found", detail);
14
+ return bodies[0];
15
+ }
16
+ export function htmlOpeningTag(content, selector, detail) {
17
+ const matches = matchingHtmlTags(content, selector, detail);
18
+ if (matches.length !== 1)
19
+ invalidDesignResourceHandoff(matches.length ? "locator_ambiguous" : "locator_not_found", detail);
20
+ return matches[0].tag;
21
+ }
22
+ export function htmlAttribute(content, selector, attribute, detail) {
23
+ const matches = matchingHtmlTags(content, selector, detail);
24
+ if (matches.length !== 1)
25
+ invalidDesignResourceHandoff(matches.length ? "locator_ambiguous" : "locator_not_found", detail);
26
+ const attributes = htmlAttributes(matches[0].attributes);
27
+ const value = attributes.get(attribute.toLowerCase());
28
+ if (value === undefined)
29
+ invalidDesignResourceHandoff("locator_not_found", detail);
30
+ return value;
31
+ }
32
+ export function elementInnerContent(content, selector, detail) {
33
+ const opening = htmlOpeningTag(content, selector, detail);
34
+ const tagName = /^<([A-Za-z][A-Za-z0-9:-]*)\b/u.exec(opening)?.[1];
35
+ if (!tagName || /\/\s*>$/u.test(opening))
36
+ invalidDesignResourceHandoff("locator_element_has_no_content", detail);
37
+ const start = content.indexOf(opening);
38
+ const close = new RegExp(`</${escapeRegExp(tagName)}\\s*>`, "giu");
39
+ close.lastIndex = start + opening.length;
40
+ const match = close.exec(content);
41
+ if (!match)
42
+ invalidDesignResourceHandoff("locator_element_close_missing", detail);
43
+ const inner = content.slice(start + opening.length, match.index);
44
+ if (new RegExp(`<${escapeRegExp(tagName)}\\b`, "iu").test(inner))
45
+ invalidDesignResourceHandoff("locator_nested_same_tag_unsupported", detail);
46
+ return inner.trim();
47
+ }
48
+ function matchingHtmlTags(content, selector, detail) {
49
+ const parsed = /^(?:([A-Za-z][A-Za-z0-9:-]*))?(?:#([A-Za-z][A-Za-z0-9_.:-]*))?(?:\[([A-Za-z_:][A-Za-z0-9_.:-]*)(?:=(?:"([^"]*)"|'([^']*)'|([^\]\s]+)))?\])?$/u.exec(selector);
50
+ if (!parsed || (!parsed[1] && !parsed[2] && !parsed[3]))
51
+ invalidDesignResourceHandoff("locator_html_selector_unsupported", detail);
52
+ const result = [];
53
+ for (const match of content.matchAll(/<([A-Za-z][A-Za-z0-9:-]*)\b([^<>]*)>/gu)) {
54
+ if (parsed[1] && match[1].toLowerCase() !== parsed[1].toLowerCase())
55
+ continue;
56
+ const attributes = htmlAttributes(match[2]);
57
+ if (parsed[2] && attributes.get("id") !== parsed[2])
58
+ continue;
59
+ if (parsed[3]) {
60
+ const expected = parsed[4] ?? parsed[5] ?? parsed[6];
61
+ const actual = attributes.get(parsed[3].toLowerCase());
62
+ if (actual === undefined ||
63
+ (expected !== undefined && actual !== expected))
64
+ continue;
65
+ }
66
+ result.push({ tag: match[0], attributes: match[2] });
67
+ }
68
+ return result;
69
+ }
70
+ export function markdownSection(content, anchor, detail) {
71
+ const lines = content.split(/\r?\n/u);
72
+ const slug = (value) => value
73
+ .trim()
74
+ .toLowerCase()
75
+ .replace(/[^\p{Letter}\p{Number}\s-]/gu, "")
76
+ .replace(/\s+/gu, "-");
77
+ const start = lines.findIndex((line) => {
78
+ const match = /^(#{1,6})\s+(.+)$/u.exec(line);
79
+ return match ? slug(match[2]) === anchor : false;
80
+ });
81
+ if (start < 0)
82
+ invalidDesignResourceHandoff("locator_not_found", detail);
83
+ const level = /^(#{1,6})\s/u.exec(lines[start])[1].length;
84
+ let end = lines.length;
85
+ for (let index = start + 1; index < lines.length; index += 1) {
86
+ const match = /^(#{1,6})\s/u.exec(lines[index]);
87
+ if (match && match[1].length <= level) {
88
+ end = index;
89
+ break;
90
+ }
91
+ }
92
+ return lines.slice(start, end).join("\n").trim();
93
+ }
94
+ export function javascriptExport(content, identifier, detail) {
95
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(identifier))
96
+ invalidDesignResourceHandoff("locator_javascript_export_invalid", detail);
97
+ const expression = new RegExp(`(?:export\\s+)?(?:const|let|var)\\s+${escapeRegExp(identifier)}\\s*=\\s*([^;]+);`, "gu");
98
+ return uniqueCapture(content, expression, detail).trim();
99
+ }
100
+ export function uniqueCapture(content, expression, detail) {
101
+ const values = [...content.matchAll(expression)].map((match) => match[1]);
102
+ if (values.length !== 1)
103
+ invalidDesignResourceHandoff(values.length ? "locator_ambiguous" : "locator_not_found", detail);
104
+ return values[0];
105
+ }
106
+ export function escapeRegExp(value) {
107
+ return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
108
+ }
@@ -0,0 +1,3 @@
1
+ import type { DesignResourceTypedLocatorV1 } from "./design-resource-fact-manifest-types.js";
2
+ import { type DesignResource } from "./design-resource-handoff-file-primitives.js";
3
+ export declare function resolveDesignResourceLocatorValue(locator: DesignResourceTypedLocatorV1, resource: DesignResource, bytes: Buffer, label: string): Buffer;
@@ -0,0 +1,112 @@
1
+ import { isTextResource, } from "./design-resource-handoff-file-primitives.js";
2
+ import { invalidDesignResourceHandoff } from "./design-resource-handoff-validation-primitives.js";
3
+ import { cssRuleBody, elementInnerContent, escapeRegExp, htmlAttribute, htmlOpeningTag, javascriptExport, markdownSection, uniqueCapture, } from "./design-resource-fact-locator-extractors.js";
4
+ export function resolveDesignResourceLocatorValue(locator, resource, bytes, label) {
5
+ const detail = `${label}:${resource.key}:${locator.kind}:${locator.value}`;
6
+ if (locator.kind === "whole_resource") {
7
+ if (locator.value !== ".")
8
+ invalidDesignResourceHandoff("locator_whole_resource_value", detail);
9
+ return bytes;
10
+ }
11
+ if (!isTextResource(resource))
12
+ invalidDesignResourceHandoff("located_value_text_resource_required", `${detail}:${resource.media_type}`);
13
+ const content = bytes.toString("utf8");
14
+ return resolveTextLocator(locator, resource, content, detail);
15
+ }
16
+ function resolveTextLocator(locator, resource, content, detail) {
17
+ switch (locator.kind) {
18
+ case "json_pointer":
19
+ requireMediaType(resource, ["application/json"], detail);
20
+ return Buffer.from(resolveJsonPointer(content, locator.value, detail));
21
+ case "css_custom_property":
22
+ requireMediaType(resource, ["text/css"], detail);
23
+ return Buffer.from(uniqueCapture(content, new RegExp(`${escapeRegExp(locator.value)}\\s*:\\s*([^;{}]+)`, "gu"), detail).trim());
24
+ case "css_declaration":
25
+ return cssDeclaration(content, locator.value, resource, detail);
26
+ case "css_selector":
27
+ requireMediaType(resource, ["text/css"], detail);
28
+ return Buffer.from(cssRuleBody(content, locator.value, detail).trim());
29
+ case "html_attribute":
30
+ case "svg_attribute":
31
+ return markupAttribute(content, locator, resource, detail);
32
+ case "html_selector":
33
+ case "svg_selector":
34
+ requireMarkupMediaType(locator.kind, resource, detail);
35
+ return Buffer.from(htmlOpeningTag(content, locator.value, detail));
36
+ case "html_inner_html":
37
+ case "svg_inner_xml":
38
+ requireMarkupMediaType(locator.kind, resource, detail);
39
+ return Buffer.from(elementInnerContent(content, locator.value, detail));
40
+ case "markdown_anchor":
41
+ requireMediaType(resource, ["text/markdown"], detail);
42
+ return Buffer.from(markdownSection(content, locator.value, detail));
43
+ case "javascript_export":
44
+ requireMediaType(resource, [
45
+ "text/javascript",
46
+ "application/javascript",
47
+ "text/typescript",
48
+ "application/typescript",
49
+ ], detail);
50
+ return Buffer.from(javascriptExport(content, locator.value, detail));
51
+ default:
52
+ invalidDesignResourceHandoff("located_value_locator_unsupported", detail);
53
+ }
54
+ }
55
+ function cssDeclaration(content, value, resource, detail) {
56
+ requireMediaType(resource, ["text/css"], detail);
57
+ const [selector, property] = splitCompoundLocator(value, detail);
58
+ const body = cssRuleBody(content, selector, detail);
59
+ return Buffer.from(uniqueCapture(body, new RegExp(`(?:^|;)\\s*${escapeRegExp(property)}\\s*:\\s*([^;]+)`, "gu"), detail).trim());
60
+ }
61
+ function markupAttribute(content, locator, resource, detail) {
62
+ requireMarkupMediaType(locator.kind, resource, detail);
63
+ const [selector, attribute] = splitCompoundLocator(locator.value, detail);
64
+ return Buffer.from(htmlAttribute(content, selector, attribute, detail));
65
+ }
66
+ function requireMarkupMediaType(kind, resource, detail) {
67
+ requireMediaType(resource, kind.startsWith("svg_")
68
+ ? ["image/svg+xml"]
69
+ : ["text/html", "application/xhtml+xml"], detail);
70
+ }
71
+ function resolveJsonPointer(content, pointer, detail) {
72
+ if (!pointer.startsWith("/"))
73
+ invalidDesignResourceHandoff("locator_json_pointer_invalid", detail);
74
+ let current;
75
+ try {
76
+ current = JSON.parse(content);
77
+ }
78
+ catch {
79
+ invalidDesignResourceHandoff("locator_json_resource_invalid", detail);
80
+ }
81
+ for (const token of pointer
82
+ .slice(1)
83
+ .split("/")
84
+ .map((part) => part.replace(/~1/gu, "/").replace(/~0/gu, "~"))) {
85
+ if (current === null ||
86
+ typeof current !== "object" ||
87
+ !Object.hasOwn(current, token))
88
+ invalidDesignResourceHandoff("locator_not_found", detail);
89
+ current = current[token];
90
+ }
91
+ return typeof current === "string" ? current : stableJson(current);
92
+ }
93
+ function stableJson(value) {
94
+ if (Array.isArray(value))
95
+ return `[${value.map((item) => stableJson(item)).join(",")}]`;
96
+ if (value && typeof value === "object")
97
+ return `{${Object.entries(value)
98
+ .sort(([left], [right]) => left.localeCompare(right))
99
+ .map(([key, entry]) => `${JSON.stringify(key)}:${stableJson(entry)}`)
100
+ .join(",")}}`;
101
+ return JSON.stringify(value);
102
+ }
103
+ function splitCompoundLocator(value, detail) {
104
+ const parts = value.split("@@");
105
+ if (parts.length !== 2 || parts.some((part) => !part.trim()))
106
+ invalidDesignResourceHandoff("locator_compound_value_invalid", detail);
107
+ return [parts[0].trim(), parts[1].trim()];
108
+ }
109
+ function requireMediaType(resource, expected, detail) {
110
+ if (!expected.includes(resource.media_type))
111
+ invalidDesignResourceHandoff("locator_media_type_incompatible", `${detail}:${resource.media_type}`);
112
+ }
@@ -0,0 +1,5 @@
1
+ import type { DesignResourceLocatedDigestV1 } from "./design-resource-fact-manifest-types.js";
2
+ import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
3
+ export { resolveDesignResourceLocatorValue } from "./design-resource-fact-locator-resolver.js";
4
+ export { validateDesignResourceValueKind } from "./design-resource-fact-value-validation.js";
5
+ export declare function validateDesignResourceLocatedDigest(located: DesignResourceLocatedDigestV1, resources: Map<string, DesignResource>, contents: Map<string, Buffer>, label: string): Buffer;
@@ -0,0 +1,16 @@
1
+ import { invalidDesignResourceHandoff } from "./design-resource-handoff-validation-primitives.js";
2
+ import { resolveDesignResourceLocatorValue } from "./design-resource-fact-locator-resolver.js";
3
+ import { sha256Hex } from "./strict-codec.js";
4
+ export { resolveDesignResourceLocatorValue } from "./design-resource-fact-locator-resolver.js";
5
+ export { validateDesignResourceValueKind } from "./design-resource-fact-value-validation.js";
6
+ export function validateDesignResourceLocatedDigest(located, resources, contents, label) {
7
+ const resource = resources.get(located.locator.resource_ref);
8
+ const bytes = contents.get(located.locator.resource_ref);
9
+ if (!resource || !bytes)
10
+ invalidDesignResourceHandoff("located_value_resource_unknown", `${label}:${located.locator.resource_ref}`);
11
+ const value = resolveDesignResourceLocatorValue(located.locator, resource, bytes, label);
12
+ const actual = sha256Hex(value);
13
+ if (actual !== located.sha256)
14
+ invalidDesignResourceHandoff("located_value_digest_mismatch", `${label}:${located.sha256}:${actual}`);
15
+ return value;
16
+ }
@@ -0,0 +1,4 @@
1
+ import { type DesignResourcePropertyDefinitionV1 } from "./design-resource-fact-manifest-types.js";
2
+ export declare const DESIGN_RESOURCE_STANDARD_PROPERTIES: DesignResourcePropertyDefinitionV1[];
3
+ export declare const DESIGN_RESOURCE_STANDARD_PROPERTY_KEYS: readonly string[];
4
+ export declare const DESIGN_RESOURCE_STANDARD_PROPERTY_BY_KEY: ReadonlyMap<string, DesignResourcePropertyDefinitionV1>;