@lbdudc/linea-core 0.1.0 → 0.1.2

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 (253) hide show
  1. package/README.md +230 -358
  2. package/dist/analysis/analyze.d.ts +0 -54
  3. package/dist/analysis/analyze.js +1 -70
  4. package/dist/analysis/analyze.js.map +1 -1
  5. package/dist/analysis/runtime.d.ts +4 -73
  6. package/dist/analysis/runtime.js +7 -100
  7. package/dist/analysis/runtime.js.map +1 -1
  8. package/dist/analysis/uvl-text.d.ts +8 -0
  9. package/dist/analysis/uvl-text.js +70 -0
  10. package/dist/analysis/uvl-text.js.map +1 -0
  11. package/dist/assets.d.ts +0 -12
  12. package/dist/assets.js +0 -25
  13. package/dist/assets.js.map +1 -1
  14. package/dist/ci/annotations.d.ts +6 -0
  15. package/dist/ci/annotations.js +12 -0
  16. package/dist/ci/annotations.js.map +1 -0
  17. package/dist/ci/leftovers.d.ts +25 -0
  18. package/dist/ci/leftovers.js +50 -0
  19. package/dist/ci/leftovers.js.map +1 -0
  20. package/dist/ci/pairwise.d.ts +11 -0
  21. package/dist/ci/pairwise.js +35 -0
  22. package/dist/ci/pairwise.js.map +1 -0
  23. package/dist/ci/pipeline.d.ts +18 -0
  24. package/dist/ci/pipeline.js +26 -0
  25. package/dist/ci/pipeline.js.map +1 -0
  26. package/dist/ci/select.d.ts +28 -0
  27. package/dist/ci/select.js +43 -0
  28. package/dist/ci/select.js.map +1 -0
  29. package/dist/ci/validate-specs.d.ts +52 -0
  30. package/dist/ci/validate-specs.js +212 -0
  31. package/dist/ci/validate-specs.js.map +1 -0
  32. package/dist/constants.d.ts +1 -60
  33. package/dist/constants.js +1 -58
  34. package/dist/constants.js.map +1 -1
  35. package/dist/derivation/derive.d.ts +0 -56
  36. package/dist/derivation/derive.js +21 -72
  37. package/dist/derivation/derive.js.map +1 -1
  38. package/dist/derivation/engine.d.ts +10 -42
  39. package/dist/derivation/engine.js +37 -68
  40. package/dist/derivation/engine.js.map +1 -1
  41. package/dist/derivation/selection-error.d.ts +7 -0
  42. package/dist/derivation/selection-error.js +13 -0
  43. package/dist/derivation/selection-error.js.map +1 -0
  44. package/dist/errors.d.ts +19 -47
  45. package/dist/errors.js +28 -47
  46. package/dist/errors.js.map +1 -1
  47. package/dist/feature-model/uvl.d.ts +52 -0
  48. package/dist/feature-model/uvl.js +191 -0
  49. package/dist/feature-model/uvl.js.map +1 -0
  50. package/dist/fs/archive.d.ts +0 -16
  51. package/dist/fs/archive.js +0 -36
  52. package/dist/fs/archive.js.map +1 -1
  53. package/dist/fs/diff.d.ts +0 -30
  54. package/dist/fs/diff.js +4 -65
  55. package/dist/fs/diff.js.map +1 -1
  56. package/dist/fs/format.d.ts +0 -16
  57. package/dist/fs/format.js +0 -52
  58. package/dist/fs/format.js.map +1 -1
  59. package/dist/fs/workspace.d.ts +0 -52
  60. package/dist/fs/workspace.js +0 -56
  61. package/dist/fs/workspace.js.map +1 -1
  62. package/dist/index.d.ts +23 -29
  63. package/dist/index.js +15 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/guards.d.ts +0 -13
  66. package/dist/internal/guards.js +0 -13
  67. package/dist/internal/guards.js.map +1 -1
  68. package/dist/line/deletion.d.ts +33 -0
  69. package/dist/line/deletion.js +23 -0
  70. package/dist/line/deletion.js.map +1 -0
  71. package/dist/line/platform-files.d.ts +15 -64
  72. package/dist/line/platform-files.js +18 -94
  73. package/dist/line/platform-files.js.map +1 -1
  74. package/dist/line/restoration.d.ts +27 -0
  75. package/dist/line/restoration.js +27 -0
  76. package/dist/line/restoration.js.map +1 -0
  77. package/dist/line/scaffold.d.ts +26 -57
  78. package/dist/line/scaffold.js +32 -93
  79. package/dist/line/scaffold.js.map +1 -1
  80. package/dist/line/templates/core/extra.js +54 -54
  81. package/dist/line/templates/core/transformation.js +208 -196
  82. package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
  83. package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
  84. package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
  85. package/dist/line/templates/pipeline/github-ci.yml +50 -0
  86. package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
  87. package/dist/modules/configuration/configure.d.ts +52 -0
  88. package/dist/modules/configuration/configure.js +101 -0
  89. package/dist/modules/configuration/configure.js.map +1 -0
  90. package/dist/modules/configuration/constants.d.ts +17 -0
  91. package/dist/modules/configuration/constants.js +14 -0
  92. package/dist/modules/configuration/constants.js.map +1 -0
  93. package/dist/modules/configuration/index.d.ts +6 -0
  94. package/dist/modules/configuration/index.js +5 -0
  95. package/dist/modules/configuration/index.js.map +1 -0
  96. package/dist/modules/configuration/names.d.ts +9 -0
  97. package/dist/modules/configuration/names.js +7 -0
  98. package/dist/modules/configuration/names.js.map +1 -0
  99. package/dist/modules/configuration/selection.d.ts +32 -0
  100. package/dist/modules/configuration/selection.js +49 -0
  101. package/dist/modules/configuration/selection.js.map +1 -0
  102. package/dist/modules/diagnostics.d.ts +2 -0
  103. package/dist/modules/diagnostics.js +2 -0
  104. package/dist/modules/diagnostics.js.map +1 -0
  105. package/dist/modules/index.d.ts +18 -0
  106. package/dist/modules/index.js +18 -0
  107. package/dist/modules/index.js.map +1 -0
  108. package/dist/modules/metamodels/engine.d.ts +93 -0
  109. package/dist/modules/metamodels/engine.js +10 -0
  110. package/dist/modules/metamodels/engine.js.map +1 -0
  111. package/dist/modules/metamodels/files.d.ts +40 -0
  112. package/dist/modules/metamodels/files.js +58 -0
  113. package/dist/modules/metamodels/files.js.map +1 -0
  114. package/dist/modules/metamodels/index.d.ts +8 -0
  115. package/dist/modules/metamodels/index.js +5 -0
  116. package/dist/modules/metamodels/index.js.map +1 -0
  117. package/dist/modules/metamodels/layout.d.ts +23 -0
  118. package/dist/modules/metamodels/layout.js +29 -0
  119. package/dist/modules/metamodels/layout.js.map +1 -0
  120. package/dist/modules/metamodels/offered.d.ts +15 -0
  121. package/dist/modules/metamodels/offered.js +14 -0
  122. package/dist/modules/metamodels/offered.js.map +1 -0
  123. package/dist/modules/metamodels/prepare.d.ts +20 -0
  124. package/dist/modules/metamodels/prepare.js +155 -0
  125. package/dist/modules/metamodels/prepare.js.map +1 -0
  126. package/dist/modules/packages/index.d.ts +4 -0
  127. package/dist/modules/packages/index.js +4 -0
  128. package/dist/modules/packages/index.js.map +1 -0
  129. package/dist/modules/packages/location.d.ts +21 -0
  130. package/dist/modules/packages/location.js +34 -0
  131. package/dist/modules/packages/location.js.map +1 -0
  132. package/dist/modules/packages/manifests.d.ts +33 -0
  133. package/dist/modules/packages/manifests.js +231 -0
  134. package/dist/modules/packages/manifests.js.map +1 -0
  135. package/dist/modules/packages/source.d.ts +34 -0
  136. package/dist/modules/packages/source.js +128 -0
  137. package/dist/modules/packages/source.js.map +1 -0
  138. package/dist/modules/products/check.d.ts +28 -0
  139. package/dist/modules/products/check.js +61 -0
  140. package/dist/modules/products/check.js.map +1 -0
  141. package/dist/modules/products/derive.d.ts +30 -0
  142. package/dist/modules/products/derive.js +56 -0
  143. package/dist/modules/products/derive.js.map +1 -0
  144. package/dist/modules/products/index.d.ts +5 -0
  145. package/dist/modules/products/index.js +4 -0
  146. package/dist/modules/products/index.js.map +1 -0
  147. package/dist/modules/products/seed.d.ts +18 -0
  148. package/dist/modules/products/seed.js +23 -0
  149. package/dist/modules/products/seed.js.map +1 -0
  150. package/dist/modules/registry/catalog.d.ts +64 -0
  151. package/dist/modules/registry/catalog.js +91 -0
  152. package/dist/modules/registry/catalog.js.map +1 -0
  153. package/dist/modules/registry/index.d.ts +5 -0
  154. package/dist/modules/registry/index.js +4 -0
  155. package/dist/modules/registry/index.js.map +1 -0
  156. package/dist/modules/registry/registry.d.ts +34 -0
  157. package/dist/modules/registry/registry.js +37 -0
  158. package/dist/modules/registry/registry.js.map +1 -0
  159. package/dist/modules/registry/routing.d.ts +8 -0
  160. package/dist/modules/registry/routing.js +23 -0
  161. package/dist/modules/registry/routing.js.map +1 -0
  162. package/dist/modules/resolution/closure.d.ts +28 -0
  163. package/dist/modules/resolution/closure.js +105 -0
  164. package/dist/modules/resolution/closure.js.map +1 -0
  165. package/dist/modules/resolution/index.d.ts +4 -0
  166. package/dist/modules/resolution/index.js +3 -0
  167. package/dist/modules/resolution/index.js.map +1 -0
  168. package/dist/modules/resolution/resolve.d.ts +33 -0
  169. package/dist/modules/resolution/resolve.js +59 -0
  170. package/dist/modules/resolution/resolve.js.map +1 -0
  171. package/dist/modules/resolution/resolvers.d.ts +23 -0
  172. package/dist/modules/resolution/resolvers.js +34 -0
  173. package/dist/modules/resolution/resolvers.js.map +1 -0
  174. package/dist/modules/spl/check.d.ts +25 -0
  175. package/dist/modules/spl/check.js +21 -0
  176. package/dist/modules/spl/check.js.map +1 -0
  177. package/dist/modules/spl/cip.d.ts +67 -0
  178. package/dist/modules/spl/cip.js +98 -0
  179. package/dist/modules/spl/cip.js.map +1 -0
  180. package/dist/modules/spl/feature-model.d.ts +39 -0
  181. package/dist/modules/spl/feature-model.js +106 -0
  182. package/dist/modules/spl/feature-model.js.map +1 -0
  183. package/dist/modules/spl/index.d.ts +6 -0
  184. package/dist/modules/spl/index.js +4 -0
  185. package/dist/modules/spl/index.js.map +1 -0
  186. package/dist/modules/spl/platform.d.ts +49 -0
  187. package/dist/modules/spl/platform.js +316 -0
  188. package/dist/modules/spl/platform.js.map +1 -0
  189. package/dist/modules/types.d.ts +132 -0
  190. package/dist/modules/types.js +2 -0
  191. package/dist/modules/types.js.map +1 -0
  192. package/dist/product/engine-spec.d.ts +0 -16
  193. package/dist/product/engine-spec.js +4 -50
  194. package/dist/product/engine-spec.js.map +1 -1
  195. package/dist/product/spec.d.ts +0 -82
  196. package/dist/product/spec.js +0 -79
  197. package/dist/product/spec.js.map +1 -1
  198. package/dist/product/version.d.ts +0 -23
  199. package/dist/product/version.js +0 -28
  200. package/dist/product/version.js.map +1 -1
  201. package/dist/products-index/products-index.d.ts +0 -165
  202. package/dist/products-index/products-index.js +0 -176
  203. package/dist/products-index/products-index.js.map +1 -1
  204. package/dist/workspace/context.d.ts +25 -0
  205. package/dist/workspace/context.js +43 -0
  206. package/dist/workspace/context.js.map +1 -0
  207. package/dist/workspace/gitExclude.d.ts +2 -0
  208. package/dist/workspace/gitExclude.js +19 -0
  209. package/dist/workspace/gitExclude.js.map +1 -0
  210. package/dist/workspace/host.d.ts +14 -0
  211. package/dist/workspace/host.js +13 -0
  212. package/dist/workspace/host.js.map +1 -0
  213. package/dist/workspace/index.d.ts +12 -0
  214. package/dist/workspace/index.js +12 -0
  215. package/dist/workspace/index.js.map +1 -0
  216. package/dist/workspace/local.d.ts +81 -0
  217. package/dist/workspace/local.js +287 -0
  218. package/dist/workspace/local.js.map +1 -0
  219. package/dist/workspace/modular.d.ts +95 -0
  220. package/dist/workspace/modular.js +301 -0
  221. package/dist/workspace/modular.js.map +1 -0
  222. package/dist/workspace/operations.d.ts +35 -0
  223. package/dist/workspace/operations.js +57 -0
  224. package/dist/workspace/operations.js.map +1 -0
  225. package/dist/workspace/origin.d.ts +20 -0
  226. package/dist/workspace/origin.js +19 -0
  227. package/dist/workspace/origin.js.map +1 -0
  228. package/package.json +82 -67
  229. package/dist/feature-model/convert.d.ts +0 -35
  230. package/dist/feature-model/convert.js +0 -47
  231. package/dist/feature-model/convert.js.map +0 -1
  232. package/dist/feature-model/engine.d.ts +0 -60
  233. package/dist/feature-model/engine.js +0 -139
  234. package/dist/feature-model/engine.js.map +0 -1
  235. package/dist/feature-model/inspect.d.ts +0 -67
  236. package/dist/feature-model/inspect.js +0 -113
  237. package/dist/feature-model/inspect.js.map +0 -1
  238. package/dist/feature-model/io.d.ts +0 -66
  239. package/dist/feature-model/io.js +0 -92
  240. package/dist/feature-model/io.js.map +0 -1
  241. package/dist/feature-model/parse.d.ts +0 -30
  242. package/dist/feature-model/parse.js +0 -36
  243. package/dist/feature-model/parse.js.map +0 -1
  244. package/dist/feature-model/text.d.ts +0 -54
  245. package/dist/feature-model/text.js +0 -126
  246. package/dist/feature-model/text.js.map +0 -1
  247. package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
  248. package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
  249. package/dist/line/templates/metamodels/sensor/extra.js +0 -36
  250. package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
  251. package/dist/selection/selection.d.ts +0 -126
  252. package/dist/selection/selection.js +0 -152
  253. package/dist/selection/selection.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/feature-model/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAA;AAEvE;;;GAGG;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IAChD,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK;IAC9E,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW;IAC5E,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CACnD,CAAC,CAAA;AAEF,8EAA8E;AAC9E,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAY,EAAE;IACrD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAC/B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC7E,gDAAgD;QAChD,IAA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AAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;AACvF,CAAC,CAAA;AAUD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,KAAK,EAGN,EAA2B,EAAE;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,oBAAoB,CAAC,0DAA0D,CAAC,CAAA;IAC5F,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC3C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;IAC3C,CAAC;AACH,CAAC,CAAA","sourcesContent":["/**\r\n * Read-only inspection of feature models.\r\n *\r\n * Migrated from `linea/server/src/agents/tools/fmAnalysis.js`\r\n * (`extractFeaturesFromModel`, `computeMandatoryFeatures`). The aggregate\r\n * portfolio helpers of that file (`computePortfolioAnomalies`,\r\n * `computePairCoverage`, `findCouplingSmells`) work over product verdicts, not\r\n * over the model, and belong with the product operations.\r\n */\r\nimport { isFeatureModelType, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\nimport { completeSelection, type FeatureModelValue } from './engine.js'\r\n\r\n/**\r\n * UVL tokens that are never feature names.\r\n * Verbatim from `fmAnalysis.js:UVL_KEYWORDS`.\r\n */\r\nconst UVL_KEYWORDS: ReadonlySet<string> = new Set([\r\n 'features', 'constraints', 'mandatory', 'optional', 'alternative', 'or', 'and',\r\n 'as', 'type', 'String', 'Integer', 'Real', 'Boolean', 'include', 'namespace',\r\n 'cardinality', 'abstract', 'true', 'false', 'null'\r\n])\r\n\r\n/** Port of `fmAnalysis.js:parseUvlFeatureNames`; same tokens, same output. */\r\nconst parseUvlFeatureNames = (uvl: string): string[] => {\r\n const names = new Set<string>()\r\n for (const line of uvl.split('\\n')) {\r\n const trimmed = line.trim()\r\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\r\n // Namespace declarations are not feature lines.\r\n if (trimmed.startsWith('namespace')) continue\r\n for (const match of trimmed.matchAll(/\\b([A-Za-z_][A-Za-z0-9_]*)\\b/g)) {\r\n const name = match[1]\r\n if (name !== undefined && !UVL_KEYWORDS.has(name)) names.add(name)\r\n }\r\n }\r\n return [...names]\r\n}\r\n\r\n/** Port of `fmAnalysis.js:parseXmlFeatureNames`; same regex, same output. */\r\nconst parseXmlFeatureNames = (xml: string): string[] => {\r\n const names = new Set<string>()\r\n for (const match of xml.matchAll(/\\bname=\"([^\"]+)\"/g)) {\r\n const name = match[1]\r\n if (name !== undefined) names.add(name)\r\n }\r\n return [...names]\r\n}\r\n\r\n/**\r\n * Extracts feature names from a model document without parsing it.\r\n *\r\n * Conservative by design, exactly as the monolith documents it: it prefers false\r\n * positives over false negatives, so a few extra identifiers (type names, for\r\n * instance) may show up. Callers that need exact names should parse the model\r\n * and use the engine instead.\r\n *\r\n * HARDENED PORT, not a verbatim one. `fmAnalysis.js:extractFeaturesFromModel`\r\n * coerces the notation with `(type ?? 'UVL').toUpperCase()`, defaulting a\r\n * missing or lowercase value to UVL. This function requires an exact `'UVL'` or\r\n * `'XML'` and throws otherwise.\r\n *\r\n * That matters when migrating callers: `line.featureModelType` can be\r\n * `undefined` for lines created before the field existed, which is why\r\n * `LineService.js:284,401,432` all write `(line.featureModelType ?? 'UVL')`.\r\n * Applying that same default is now the CALLER's responsibility — whoever ports\r\n * `lineHealthAgent.js:89` must pass `line.featureModelType ?? 'UVL'` explicitly\r\n * or they will get an `InvalidArgumentError` on legacy lines.\r\n *\r\n * @param params.content Model document as plain text.\r\n * @param params.type Notation of `content`. Exact, never coerced.\r\n * @returns Feature names, de-duplicated, in order of first appearance.\r\n * @throws {InvalidArgumentError} when `content` is not a string or `type` is unknown.\r\n */\r\nexport const extractFeatureNames = ({\r\n content,\r\n type\r\n}: {\r\n content: string\r\n type: FeatureModelType\r\n}): string[] => {\r\n if (typeof content !== 'string') {\r\n throw new InvalidArgumentError('\"content\" must be a string.')\r\n }\r\n if (!isFeatureModelType(type)) {\r\n throw new InvalidArgumentError(`Unknown feature model type \"${String(type)}\". Use \"UVL\" or \"XML\".`)\r\n }\r\n return type === 'XML' ? parseXmlFeatureNames(content) : parseUvlFeatureNames(content)\r\n}\r\n\r\n/** Outcome of probing a model with an empty selection. */\r\nexport interface MandatoryFeaturesResult {\r\n /** `true` when the model admits no valid configuration at all. */\r\n readonly voidModel: boolean\r\n /** Features implied even by an empty selection. */\r\n readonly mandatory: string[]\r\n}\r\n\r\n/**\r\n * Probes a model with an empty selection to detect the void-model case and the\r\n * features that are always present.\r\n *\r\n * Port of `fmAnalysis.js:computeMandatoryFeatures`, keeping its\r\n * degrade-gracefully contract intact: any failure from the ENGINE is reported as\r\n * `voidModel: true` with an empty `mandatory`, never as a thrown error.\r\n *\r\n * HARDENED on one point: the monolith would happily accept a non-model and\r\n * return `{ voidModel: true }` because its `try` swallows the `TypeError` too.\r\n * Here an argument that is not a parsed model is a caller bug and throws, so it\r\n * cannot masquerade as an unsatisfiable model.\r\n *\r\n * @param params.model A model returned by `parseFeatureModel`.\r\n * @returns Whether the model is void, and its mandatory features.\r\n * @throws {InvalidArgumentError} when `model` did not come from `parseFeatureModel`.\r\n */\r\nexport const computeMandatoryFeatures = ({\r\n model\r\n}: {\r\n model: FeatureModelValue\r\n}): MandatoryFeaturesResult => {\r\n if (model === null || typeof model !== 'object') {\r\n throw new InvalidArgumentError('\"model\" must be a value returned by parseFeatureModel().')\r\n }\r\n try {\r\n const result = completeSelection(model, [])\r\n return { voidModel: false, mandatory: Array.isArray(result) ? result : [] }\r\n } catch {\r\n return { voidModel: true, mandatory: [] }\r\n }\r\n}\r\n"]}
@@ -1,66 +0,0 @@
1
- import { type FeatureModelType } from '../constants.js';
2
- /**
3
- * Where a line's feature model lives and in which notation.
4
- *
5
- * There is no `exists` flag: the function throws `LinePlatformNotFoundError`
6
- * when no model is there, so a flag could only ever be `true`. Widening a public
7
- * type later is cheap; narrowing it is a breaking change.
8
- */
9
- export interface FeatureModelLocation {
10
- /** Notation of the model found. */
11
- readonly type: FeatureModelType;
12
- /** Absolute path of the model file. */
13
- readonly path: string;
14
- }
15
- /**
16
- * Detects which feature model a line working directory holds.
17
- *
18
- * UVL wins when both files are present, matching the monolith: `readLineModel`
19
- * tries `model.uvl` first, and `reconcileLines` only settles on XML when the
20
- * UVL lookup fails.
21
- *
22
- * @param params.lineDir Root of the line working directory.
23
- * @returns Notation and absolute path of the model found.
24
- * @throws {LinePlatformNotFoundError} when neither `src/platform/model.uvl` nor
25
- * `src/platform/model.xml` exists.
26
- */
27
- export declare const detectFeatureModelType: ({ lineDir }: {
28
- lineDir: string;
29
- }) => FeatureModelLocation;
30
- /**
31
- * Reads the platform feature model of a line working directory.
32
- *
33
- * @param params.lineDir Root of the line working directory.
34
- * @returns Notation, absolute path and contents of the model.
35
- * @throws {LinePlatformNotFoundError} when the line has no platform model.
36
- */
37
- export declare const readFeatureModel: ({ lineDir }: {
38
- lineDir: string;
39
- }) => {
40
- type: FeatureModelType;
41
- path: string;
42
- content: string;
43
- };
44
- /**
45
- * Writes the platform feature model of a line working directory, creating
46
- * `src/platform` if needed.
47
- *
48
- * Mirrors the model half of `saveFeatureModel`: it overwrites the file for the
49
- * given notation and nothing else. It deliberately does NOT delete the model of
50
- * the other notation — that only happens in the convert flow, where the monolith
51
- * issues a single GitLab commit with a `create` plus a `delete`
52
- * (`LineService.js:convertFeatureModel`). That flow is a line-level operation
53
- * and belongs to a later batch.
54
- *
55
- * @param params.lineDir Root of the line working directory.
56
- * @param params.content Model document as plain text.
57
- * @param params.type Notation of `content`.
58
- * @returns The absolute path written.
59
- */
60
- export declare const writeFeatureModel: ({ lineDir, content, type }: {
61
- lineDir: string;
62
- content: string;
63
- type: FeatureModelType;
64
- }) => {
65
- path: string;
66
- };
@@ -1,92 +0,0 @@
1
- /**
2
- * Reading and writing the platform feature model of a line working directory.
3
- *
4
- * Migrated from:
5
- * - `linea/server/src/model/services/LineService.js:getFeatureModel` (~277-293)
6
- * and `saveFeatureModel` (~391-419) — domain logic only; permissions, the
7
- * GitLab round-trip, the version bump and the Mongo transaction stay in
8
- * linea-server (ADR-003).
9
- * - `linea/server/src/agents/tools/harvest.js:readLineModel` (~97-107), which
10
- * is where the "UVL preferred, XML fallback" rule comes from.
11
- * - `linea/server/src/model/services/LineService.js:reconcileLines` (~152-156),
12
- * which resolves the same ambiguity for repositories that are not in the DB:
13
- * XML only when the XML file is there and the UVL one is not.
14
- *
15
- * The monolith decodes base64 (`atob(file.content)`) because files arrive from
16
- * the GitLab API. Here everything is plain text on disk.
17
- */
18
- import path from 'node:path';
19
- import { PLATFORM_PATHS, isFeatureModelType } from '../constants.js';
20
- import { InvalidArgumentError, LinePlatformNotFoundError } from '../errors.js';
21
- import { fileExists, readTextFile, writeTextFile } from '../fs/workspace.js';
22
- /** Absolute path of the model file of `lineDir` for a given notation. */
23
- const modelPathFor = (lineDir, type) => path.join(path.resolve(lineDir), type === 'XML' ? PLATFORM_PATHS.modelXml : PLATFORM_PATHS.model);
24
- const assertLineDir = (lineDir) => {
25
- if (typeof lineDir !== 'string' || lineDir.trim() === '') {
26
- throw new InvalidArgumentError('"lineDir" must be a non-empty path.');
27
- }
28
- };
29
- /**
30
- * Detects which feature model a line working directory holds.
31
- *
32
- * UVL wins when both files are present, matching the monolith: `readLineModel`
33
- * tries `model.uvl` first, and `reconcileLines` only settles on XML when the
34
- * UVL lookup fails.
35
- *
36
- * @param params.lineDir Root of the line working directory.
37
- * @returns Notation and absolute path of the model found.
38
- * @throws {LinePlatformNotFoundError} when neither `src/platform/model.uvl` nor
39
- * `src/platform/model.xml` exists.
40
- */
41
- export const detectFeatureModelType = ({ lineDir }) => {
42
- assertLineDir(lineDir);
43
- const uvlPath = modelPathFor(lineDir, 'UVL');
44
- if (fileExists({ filePath: uvlPath }))
45
- return { type: 'UVL', path: uvlPath };
46
- const xmlPath = modelPathFor(lineDir, 'XML');
47
- if (fileExists({ filePath: xmlPath }))
48
- return { type: 'XML', path: xmlPath };
49
- throw new LinePlatformNotFoundError(`No feature model found in "${path.resolve(lineDir)}": expected "${PLATFORM_PATHS.model}" or "${PLATFORM_PATHS.modelXml}".`);
50
- };
51
- /**
52
- * Reads the platform feature model of a line working directory.
53
- *
54
- * @param params.lineDir Root of the line working directory.
55
- * @returns Notation, absolute path and contents of the model.
56
- * @throws {LinePlatformNotFoundError} when the line has no platform model.
57
- */
58
- export const readFeatureModel = ({ lineDir }) => {
59
- const location = detectFeatureModelType({ lineDir });
60
- return {
61
- type: location.type,
62
- path: location.path,
63
- content: readTextFile({ filePath: location.path })
64
- };
65
- };
66
- /**
67
- * Writes the platform feature model of a line working directory, creating
68
- * `src/platform` if needed.
69
- *
70
- * Mirrors the model half of `saveFeatureModel`: it overwrites the file for the
71
- * given notation and nothing else. It deliberately does NOT delete the model of
72
- * the other notation — that only happens in the convert flow, where the monolith
73
- * issues a single GitLab commit with a `create` plus a `delete`
74
- * (`LineService.js:convertFeatureModel`). That flow is a line-level operation
75
- * and belongs to a later batch.
76
- *
77
- * @param params.lineDir Root of the line working directory.
78
- * @param params.content Model document as plain text.
79
- * @param params.type Notation of `content`.
80
- * @returns The absolute path written.
81
- */
82
- export const writeFeatureModel = ({ lineDir, content, type }) => {
83
- assertLineDir(lineDir);
84
- if (typeof content !== 'string') {
85
- throw new InvalidArgumentError('"content" must be a string.');
86
- }
87
- if (!isFeatureModelType(type)) {
88
- throw new InvalidArgumentError(`Unknown feature model type "${String(type)}". Use "UVL" or "XML".`);
89
- }
90
- return { path: writeTextFile({ filePath: modelPathFor(lineDir, type), content }) };
91
- };
92
- //# sourceMappingURL=io.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"io.js","sourceRoot":"","sources":["../../src/feature-model/io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3F,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAgB5E,yEAAyE;AACzE,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,IAAsB,EAAU,EAAE,CACvE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAEnG,MAAM,aAAa,GAAG,CAAC,OAAe,EAAQ,EAAE;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,CAAC,CAAA;IACvE,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAwB,EAAE;IAC/F,aAAa,CAAC,OAAO,CAAC,CAAA;IAEtB,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5C,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,E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EAAE,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;AACpF,CAAC,CAAA","sourcesContent":["/**\r\n * Reading and writing the platform feature model of a line working directory.\r\n *\r\n * Migrated from:\r\n * - `linea/server/src/model/services/LineService.js:getFeatureModel` (~277-293)\r\n * and `saveFeatureModel` (~391-419) — domain logic only; permissions, the\r\n * GitLab round-trip, the version bump and the Mongo transaction stay in\r\n * linea-server (ADR-003).\r\n * - `linea/server/src/agents/tools/harvest.js:readLineModel` (~97-107), which\r\n * is where the \"UVL preferred, XML fallback\" rule comes from.\r\n * - `linea/server/src/model/services/LineService.js:reconcileLines` (~152-156),\r\n * which resolves the same ambiguity for repositories that are not in the DB:\r\n * XML only when the XML file is there and the UVL one is not.\r\n *\r\n * The monolith decodes base64 (`atob(file.content)`) because files arrive from\r\n * the GitLab API. Here everything is plain text on disk.\r\n */\r\nimport path from 'node:path'\r\nimport { PLATFORM_PATHS, isFeatureModelType, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError, LinePlatformNotFoundError } from '../errors.js'\r\nimport { fileExists, readTextFile, writeTextFile } from '../fs/workspace.js'\r\n\r\n/**\r\n * Where a line's feature model lives and in which notation.\r\n *\r\n * There is no `exists` flag: the function throws `LinePlatformNotFoundError`\r\n * when no model is there, so a flag could only ever be `true`. Widening a public\r\n * type later is cheap; narrowing it is a breaking change.\r\n */\r\nexport interface FeatureModelLocation {\r\n /** Notation of the model found. */\r\n readonly type: FeatureModelType\r\n /** Absolute path of the model file. */\r\n readonly path: string\r\n}\r\n\r\n/** Absolute path of the model file of `lineDir` for a given notation. */\r\nconst modelPathFor = (lineDir: string, type: FeatureModelType): string =>\r\n path.join(path.resolve(lineDir), type === 'XML' ? PLATFORM_PATHS.modelXml : PLATFORM_PATHS.model)\r\n\r\nconst assertLineDir = (lineDir: string): void => {\r\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\r\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\r\n }\r\n}\r\n\r\n/**\r\n * Detects which feature model a line working directory holds.\r\n *\r\n * UVL wins when both files are present, matching the monolith: `readLineModel`\r\n * tries `model.uvl` first, and `reconcileLines` only settles on XML when the\r\n * UVL lookup fails.\r\n *\r\n * @param params.lineDir Root of the line working directory.\r\n * @returns Notation and absolute path of the model found.\r\n * @throws {LinePlatformNotFoundError} when neither `src/platform/model.uvl` nor\r\n * `src/platform/model.xml` exists.\r\n */\r\nexport const detectFeatureModelType = ({ lineDir }: { lineDir: string }): FeatureModelLocation => {\r\n assertLineDir(lineDir)\r\n\r\n const uvlPath = modelPathFor(lineDir, 'UVL')\r\n if (fileExists({ filePath: uvlPath })) return { type: 'UVL', path: uvlPath }\r\n\r\n const xmlPath = modelPathFor(lineDir, 'XML')\r\n if (fileExists({ filePath: xmlPath })) return { type: 'XML', path: xmlPath }\r\n\r\n throw new LinePlatformNotFoundError(\r\n `No feature model found in \"${path.resolve(lineDir)}\": expected \"${PLATFORM_PATHS.model}\" or \"${PLATFORM_PATHS.modelXml}\".`\r\n )\r\n}\r\n\r\n/**\r\n * Reads the platform feature model of a line working directory.\r\n *\r\n * @param params.lineDir Root of the line working directory.\r\n * @returns Notation, absolute path and contents of the model.\r\n * @throws {LinePlatformNotFoundError} when the line has no platform model.\r\n */\r\nexport const readFeatureModel = ({\r\n lineDir\r\n}: {\r\n lineDir: string\r\n}): { type: FeatureModelType, path: string, content: string } => {\r\n const location = detectFeatureModelType({ lineDir })\r\n return {\r\n type: location.type,\r\n path: location.path,\r\n content: readTextFile({ filePath: location.path })\r\n }\r\n}\r\n\r\n/**\r\n * Writes the platform feature model of a line working directory, creating\r\n * `src/platform` if needed.\r\n *\r\n * Mirrors the model half of `saveFeatureModel`: it overwrites the file for the\r\n * given notation and nothing else. It deliberately does NOT delete the model of\r\n * the other notation — that only happens in the convert flow, where the monolith\r\n * issues a single GitLab commit with a `create` plus a `delete`\r\n * (`LineService.js:convertFeatureModel`). That flow is a line-level operation\r\n * and belongs to a later batch.\r\n *\r\n * @param params.lineDir Root of the line working directory.\r\n * @param params.content Model document as plain text.\r\n * @param params.type Notation of `content`.\r\n * @returns The absolute path written.\r\n */\r\nexport const writeFeatureModel = ({\r\n lineDir,\r\n content,\r\n type\r\n}: {\r\n lineDir: string\r\n content: string\r\n type: FeatureModelType\r\n}): { path: string } => {\r\n assertLineDir(lineDir)\r\n if (typeof content !== 'string') {\r\n throw new InvalidArgumentError('\"content\" must be a string.')\r\n }\r\n if (!isFeatureModelType(type)) {\r\n throw new InvalidArgumentError(`Unknown feature model type \"${String(type)}\". Use \"UVL\" or \"XML\".`)\r\n }\r\n return { path: writeTextFile({ filePath: modelPathFor(lineDir, type), content }) }\r\n}\r\n"]}
@@ -1,30 +0,0 @@
1
- /**
2
- * Feature model parsing.
3
- *
4
- * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`
5
- * (~42-46), minus two things:
6
- *
7
- * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the
8
- * monolith models arrive from the GitLab API, in linea-core everything is
9
- * plain text on disk. Decoding is linea-server's problem (ADR-003).
10
- * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:
11
- * linea-core keeps no state between calls. Callers that want caching own it.
12
- */
13
- import { type FeatureModelType } from '../constants.js';
14
- import { type FeatureModelValue } from './engine.js';
15
- export type { FeatureModelValue } from './engine.js';
16
- /**
17
- * Parses a feature model document.
18
- *
19
- * @param params.content Model document as plain text (UVL or XML).
20
- * @param params.type Notation of `content`. Always explicit — linea-core never
21
- * sniffs the notation from the content itself.
22
- * @returns An opaque model value, to be handed back to other linea-core functions.
23
- * @throws {InvalidArgumentError} if `content` is not a non-empty string, if
24
- * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.
25
- * @throws {UvlParseError} if a UVL document cannot be parsed.
26
- */
27
- export declare const parseFeatureModel: ({ content, type }: {
28
- content: string;
29
- type: FeatureModelType;
30
- }) => FeatureModelValue;
@@ -1,36 +0,0 @@
1
- /**
2
- * Feature model parsing.
3
- *
4
- * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`
5
- * (~42-46), minus two things:
6
- *
7
- * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the
8
- * monolith models arrive from the GitLab API, in linea-core everything is
9
- * plain text on disk. Decoding is linea-server's problem (ADR-003).
10
- * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:
11
- * linea-core keeps no state between calls. Callers that want caching own it.
12
- */
13
- import { isFeatureModelType } from '../constants.js';
14
- import { InvalidArgumentError } from '../errors.js';
15
- import { parseModel } from './engine.js';
16
- /**
17
- * Parses a feature model document.
18
- *
19
- * @param params.content Model document as plain text (UVL or XML).
20
- * @param params.type Notation of `content`. Always explicit — linea-core never
21
- * sniffs the notation from the content itself.
22
- * @returns An opaque model value, to be handed back to other linea-core functions.
23
- * @throws {InvalidArgumentError} if `content` is not a non-empty string, if
24
- * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.
25
- * @throws {UvlParseError} if a UVL document cannot be parsed.
26
- */
27
- export const parseFeatureModel = ({ content, type }) => {
28
- if (typeof content !== 'string' || content.trim() === '') {
29
- throw new InvalidArgumentError('A feature model needs non-empty "content".');
30
- }
31
- if (!isFeatureModelType(type)) {
32
- throw new InvalidArgumentError(`Unknown feature model type "${String(type)}". Use "UVL" or "XML".`);
33
- }
34
- return parseModel(content, type);
35
- };
36
- //# sourceMappingURL=parse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/feature-model/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAA;AAIhE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,OAAO,EACP,IAAI,EAIL,EAAqB,EAAE;IACtB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,4CAA4C,CAAC,CAAA;IAC9E,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,oBAAoB,CAAC,+BAA+B,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IACrG,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA","sourcesContent":["/**\r\n * Feature model parsing.\r\n *\r\n * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`\r\n * (~42-46), minus two things:\r\n *\r\n * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the\r\n * monolith models arrive from the GitLab API, in linea-core everything is\r\n * plain text on disk. Decoding is linea-server's problem (ADR-003).\r\n * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:\r\n * linea-core keeps no state between calls. Callers that want caching own it.\r\n */\r\nimport { isFeatureModelType, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\nimport { parseModel, type FeatureModelValue } from './engine.js'\r\n\r\nexport type { FeatureModelValue } from './engine.js'\r\n\r\n/**\r\n * Parses a feature model document.\r\n *\r\n * @param params.content Model document as plain text (UVL or XML).\r\n * @param params.type Notation of `content`. Always explicit — linea-core never\r\n * sniffs the notation from the content itself.\r\n * @returns An opaque model value, to be handed back to other linea-core functions.\r\n * @throws {InvalidArgumentError} if `content` is not a non-empty string, if\r\n * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.\r\n * @throws {UvlParseError} if a UVL document cannot be parsed.\r\n */\r\nexport const parseFeatureModel = ({\r\n content,\r\n type\r\n}: {\r\n content: string\r\n type: FeatureModelType\r\n}): FeatureModelValue => {\r\n if (typeof content !== 'string' || content.trim() === '') {\r\n throw new InvalidArgumentError('A feature model needs non-empty \"content\".')\r\n }\r\n if (!isFeatureModelType(type)) {\r\n throw new InvalidArgumentError(`Unknown feature model type \"${String(type)}\". Use \"UVL\" or \"XML\".`)\r\n }\r\n return parseModel(content, type)\r\n}\r\n"]}
@@ -1,54 +0,0 @@
1
- /**
2
- * Normalises line endings and expands tabs so the UVL parser always gets clean
3
- * input.
4
- *
5
- * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its
6
- * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave
7
- * mixed tabs and spaces that the UVL language server tolerates but the parser
8
- * does not.
9
- *
10
- * @param params.uvl Raw UVL document.
11
- * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).
12
- * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a
13
- * non-string would let a caller bug flow into `estimateFeatureCount` and
14
- * silently flip an `ANALYSIS_THRESHOLDS` decision.
15
- */
16
- export declare const normalizeUvl: ({ uvl }: {
17
- uvl: string;
18
- }) => string;
19
- /**
20
- * Counts features in a UVL document without parsing it.
21
- *
22
- * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`
23
- * (~11-28), which is itself the twin of
24
- * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting
25
- * loop is byte-compatible with both: everything after the `constraints` keyword
26
- * is ignored, and a line counts as a feature when it is indented at least 2
27
- * columns and its first token is not a group keyword.
28
- *
29
- * Normalise first: with tab indentation the root feature sits at indent 1 and is
30
- * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before
31
- * counting.
32
- *
33
- * @param params.uvl Raw UVL document.
34
- * @returns Estimated number of features.
35
- * @throws {InvalidArgumentError} if `uvl` is not a string.
36
- */
37
- export declare const estimateFeatureCount: ({ uvl }: {
38
- uvl: string;
39
- }) => number;
40
- /**
41
- * Builds the seed UVL model of a brand new line.
42
- *
43
- * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:
44
- * `` `features\n\t${line.name}\n\t\tmandatory\n\t\t\tvoid` ``.
45
- * Tabs and the absence of a trailing newline are part of the contract — a test
46
- * asserts the exact string.
47
- *
48
- * @param params.name Line name; used as the root feature.
49
- * @returns The seed UVL document.
50
- * @throws {InvalidArgumentError} if `name` is not a non-empty string.
51
- */
52
- export declare const emptyFeatureModelUvl: ({ name }: {
53
- name: string;
54
- }) => string;
@@ -1,126 +0,0 @@
1
- /**
2
- * Pure text helpers over UVL documents. No parsing, no I/O.
3
- */
4
- import { InvalidArgumentError } from '../errors.js';
5
- /** UVL keywords that introduce a group instead of naming a feature. */
6
- const UVL_GROUP_KEYWORDS = new Set([
7
- 'mandatory',
8
- 'optional',
9
- 'alternative',
10
- 'or',
11
- 'features',
12
- 'constraints'
13
- ]);
14
- const assertUvlString = (uvl, parameter) => {
15
- if (typeof uvl !== 'string') {
16
- throw new InvalidArgumentError(`"${parameter}" must be a string.`);
17
- }
18
- return uvl;
19
- };
20
- /**
21
- * Faithful port of Python's `str.expandtabs(tabsize)`.
22
- *
23
- * NOT the same as replacing each tab with N spaces: a tab advances to the next
24
- * multiple of `tabSize`. Getting this wrong would silently change the indentation
25
- * of every UVL model, which is significant in UVL.
26
- */
27
- const expandTabs = (line, tabSize = 4) => {
28
- let out = '';
29
- let column = 0;
30
- for (const char of line) {
31
- if (char === '\t') {
32
- const width = tabSize - (column % tabSize);
33
- out += ' '.repeat(width);
34
- column += width;
35
- }
36
- else {
37
- out += char;
38
- column += 1;
39
- }
40
- }
41
- return out;
42
- };
43
- /**
44
- * Normalises line endings and expands tabs so the UVL parser always gets clean
45
- * input.
46
- *
47
- * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its
48
- * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave
49
- * mixed tabs and spaces that the UVL language server tolerates but the parser
50
- * does not.
51
- *
52
- * @param params.uvl Raw UVL document.
53
- * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).
54
- * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a
55
- * non-string would let a caller bug flow into `estimateFeatureCount` and
56
- * silently flip an `ANALYSIS_THRESHOLDS` decision.
57
- */
58
- export const normalizeUvl = ({ uvl }) => {
59
- const unified = assertUvlString(uvl, 'uvl').trim().replace(/\r\n/g, '\n').replace(/\r/g, '\n');
60
- return unified
61
- .split('\n')
62
- .map((line) => expandTabs(line, 4))
63
- .join('\n');
64
- };
65
- /**
66
- * Counts features in a UVL document without parsing it.
67
- *
68
- * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`
69
- * (~11-28), which is itself the twin of
70
- * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting
71
- * loop is byte-compatible with both: everything after the `constraints` keyword
72
- * is ignored, and a line counts as a feature when it is indented at least 2
73
- * columns and its first token is not a group keyword.
74
- *
75
- * Normalise first: with tab indentation the root feature sits at indent 1 and is
76
- * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before
77
- * counting.
78
- *
79
- * @param params.uvl Raw UVL document.
80
- * @returns Estimated number of features.
81
- * @throws {InvalidArgumentError} if `uvl` is not a string.
82
- */
83
- export const estimateFeatureCount = ({ uvl }) => {
84
- const document = assertUvlString(uvl, 'uvl');
85
- let inConstraints = false;
86
- let count = 0;
87
- for (const line of document.split('\n')) {
88
- const trimmed = line.trim();
89
- if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#'))
90
- continue;
91
- if (trimmed === 'constraints') {
92
- inConstraints = true;
93
- continue;
94
- }
95
- if (inConstraints)
96
- continue;
97
- if (trimmed === 'features')
98
- continue;
99
- const indent = line.length - line.trimStart().length;
100
- if (indent >= 2) {
101
- const name = trimmed.split(/[\s{[]/)[0];
102
- if (name && !UVL_GROUP_KEYWORDS.has(name))
103
- count += 1;
104
- }
105
- }
106
- return count;
107
- };
108
- /**
109
- * Builds the seed UVL model of a brand new line.
110
- *
111
- * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:
112
- * `` `features\n\t${line.name}\n\t\tmandatory\n\t\t\tvoid` ``.
113
- * Tabs and the absence of a trailing newline are part of the contract — a test
114
- * asserts the exact string.
115
- *
116
- * @param params.name Line name; used as the root feature.
117
- * @returns The seed UVL document.
118
- * @throws {InvalidArgumentError} if `name` is not a non-empty string.
119
- */
120
- export const emptyFeatureModelUvl = ({ name }) => {
121
- if (typeof name !== 'string' || name.trim() === '') {
122
- throw new InvalidArgumentError('"name" must be a non-empty string.');
123
- }
124
- return `features\n\t${name}\n\t\tmandatory\n\t\t\tvoid`;
125
- };
126
- //# sourceMappingURL=text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/feature-model/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,uEAAuE;AACvE,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,UAAU;IACV,aAAa;IACb,IAAI;IACJ,UAAU;IACV,aAAa;CACd,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,SAAiB,EAAU,EAAE;IAClE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,qBAAqB,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,CAAC,EAAU,EAAE;IACvD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,KAAK,GAAG,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AAE,SAAQ;QAC7E,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,aAAa,GAAG,IAAI,CAAA;YACpB,SAAQ;QACV,CAAC;QACD,IAAI,aAAa;YAAE,SAAQ;QAC3B,IAAI,OAAO,KAAK,UAAU;YAAE,SAAQ;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACpD,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YACvC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE;IACzE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,eAAe,IAAI,6BAA6B,CAAA;AACzD,CAAC,CAAA","sourcesContent":["/**\r\n * Pure text helpers over UVL documents. No parsing, no I/O.\r\n */\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/** UVL keywords that introduce a group instead of naming a feature. */\r\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\r\n 'mandatory',\r\n 'optional',\r\n 'alternative',\r\n 'or',\r\n 'features',\r\n 'constraints'\r\n])\r\n\r\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\r\n if (typeof uvl !== 'string') {\r\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\r\n }\r\n return uvl\r\n}\r\n\r\n/**\r\n * Faithful port of Python's `str.expandtabs(tabsize)`.\r\n *\r\n * NOT the same as replacing each tab with N spaces: a tab advances to the next\r\n * multiple of `tabSize`. Getting this wrong would silently change the indentation\r\n * of every UVL model, which is significant in UVL.\r\n */\r\nconst expandTabs = (line: string, tabSize = 4): string => {\r\n let out = ''\r\n let column = 0\r\n for (const char of line) {\r\n if (char === '\\t') {\r\n const width = tabSize - (column % tabSize)\r\n out += ' '.repeat(width)\r\n column += width\r\n } else {\r\n out += char\r\n column += 1\r\n }\r\n }\r\n return out\r\n}\r\n\r\n/**\r\n * Normalises line endings and expands tabs so the UVL parser always gets clean\r\n * input.\r\n *\r\n * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its\r\n * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave\r\n * mixed tabs and spaces that the UVL language server tolerates but the parser\r\n * does not.\r\n *\r\n * @param params.uvl Raw UVL document.\r\n * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).\r\n * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a\r\n * non-string would let a caller bug flow into `estimateFeatureCount` and\r\n * silently flip an `ANALYSIS_THRESHOLDS` decision.\r\n */\r\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\r\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\r\n return unified\r\n .split('\\n')\r\n .map((line) => expandTabs(line, 4))\r\n .join('\\n')\r\n}\r\n\r\n/**\r\n * Counts features in a UVL document without parsing it.\r\n *\r\n * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`\r\n * (~11-28), which is itself the twin of\r\n * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting\r\n * loop is byte-compatible with both: everything after the `constraints` keyword\r\n * is ignored, and a line counts as a feature when it is indented at least 2\r\n * columns and its first token is not a group keyword.\r\n *\r\n * Normalise first: with tab indentation the root feature sits at indent 1 and is\r\n * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before\r\n * counting.\r\n *\r\n * @param params.uvl Raw UVL document.\r\n * @returns Estimated number of features.\r\n * @throws {InvalidArgumentError} if `uvl` is not a string.\r\n */\r\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\r\n const document = assertUvlString(uvl, 'uvl')\r\n let inConstraints = false\r\n let count = 0\r\n for (const line of document.split('\\n')) {\r\n const trimmed = line.trim()\r\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\r\n if (trimmed === 'constraints') {\r\n inConstraints = true\r\n continue\r\n }\r\n if (inConstraints) continue\r\n if (trimmed === 'features') continue\r\n const indent = line.length - line.trimStart().length\r\n if (indent >= 2) {\r\n const name = trimmed.split(/[\\s{[]/)[0]\r\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\r\n }\r\n }\r\n return count\r\n}\r\n\r\n/**\r\n * Builds the seed UVL model of a brand new line.\r\n *\r\n * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:\r\n * `` `features\\n\\t${line.name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid` ``.\r\n * Tabs and the absence of a trailing newline are part of the contract — a test\r\n * asserts the exact string.\r\n *\r\n * @param params.name Line name; used as the root feature.\r\n * @returns The seed UVL document.\r\n * @throws {InvalidArgumentError} if `name` is not a non-empty string.\r\n */\r\nexport const emptyFeatureModelUvl = ({ name }: { name: string }): string => {\r\n if (typeof name !== 'string' || name.trim() === '') {\r\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\r\n }\r\n return `features\\n\\t${name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid`\r\n}\r\n"]}