@orkestrel/scaffold 0.0.85 → 0.0.87

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 (33) hide show
  1. package/README.md +2 -2
  2. package/dist/agents/skills/orkestrel-publish/scripts/wave.js +16 -2
  3. package/dist/bin/main.js +173 -23
  4. package/dist/bin/main.js.map +1 -1
  5. package/dist/host/agents/skills/orkestrel-publish/SKILL.md +6 -6
  6. package/dist/host/agents/skills/orkestrel-publish/references/wave.md +3 -2
  7. package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +20 -7
  8. package/dist/host/claude/agents/orkestrel.md +2 -2
  9. package/dist/host/claude/rules/architecture.md +15 -6
  10. package/dist/host/claude/rules/names.md +13 -11
  11. package/dist/host/configs/policy.ts +86 -27
  12. package/dist/host/dotfiles/oxlintrc.json +1 -0
  13. package/dist/host/guides/guide.md +13 -8
  14. package/dist/host/guides/scaffold.md +32 -7
  15. package/dist/host/manifest.json +12 -12
  16. package/dist/host/scripts/codex.sh +0 -0
  17. package/dist/host/scripts/cursor.sh +0 -0
  18. package/dist/host/scripts/deps.sh +0 -0
  19. package/dist/host/scripts/ollama.sh +0 -0
  20. package/dist/host/tests/config.test.ts +142 -0
  21. package/dist/src/core/index.cjs +182 -2
  22. package/dist/src/core/index.cjs.map +1 -1
  23. package/dist/src/core/index.d.cts +39 -0
  24. package/dist/src/core/index.d.ts +39 -0
  25. package/dist/src/core/index.js +182 -3
  26. package/dist/src/core/index.js.map +1 -1
  27. package/dist/src/server/index.cjs +31 -7
  28. package/dist/src/server/index.cjs.map +1 -1
  29. package/dist/src/server/index.d.cts +19 -6
  30. package/dist/src/server/index.d.ts +19 -6
  31. package/dist/src/server/index.js +32 -8
  32. package/dist/src/server/index.js.map +1 -1
  33. package/package.json +2 -2
@@ -352,7 +352,7 @@
352
352
  "storage": "agents/skills/orkestrel-publish/SKILL.md",
353
353
  "destination": ".agents/skills/orkestrel-publish/SKILL.md",
354
354
  "executable": false,
355
- "digest": "b79e81c49a5b89f8418fc751eaf6d02c68c5dd9f26a4a0678f9025b1915ebda2"
355
+ "digest": "f4bcc24e910bbd40de268ba6a9d4ba57b3e5f9ce69075dea395479a45ec0f9d4"
356
356
  },
357
357
  {
358
358
  "storage": "agents/skills/orkestrel-publish/agents/openai.yaml",
@@ -370,7 +370,7 @@
370
370
  "storage": "agents/skills/orkestrel-publish/references/wave.md",
371
371
  "destination": ".agents/skills/orkestrel-publish/references/wave.md",
372
372
  "executable": false,
373
- "digest": "e519a148a47dbf3271bf3f8a57428a4182afedf9230b56774a97ba5449208325"
373
+ "digest": "2d5479e0d3ed0529015f5f1f21345fb389f8119333b6c5530d2320be432fe1e1"
374
374
  },
375
375
  {
376
376
  "storage": "agents/skills/orkestrel-publish/references/window.md",
@@ -394,7 +394,7 @@
394
394
  "storage": "agents/skills/orkestrel-publish/scripts/wave.ts",
395
395
  "destination": ".agents/skills/orkestrel-publish/scripts/wave.ts",
396
396
  "executable": false,
397
- "digest": "53a85584203346325df82b2b2b20a77a86b64dbbf017afc1fdfc58d782e4f85c"
397
+ "digest": "e7a492aee9f3c63fcb22e3ab6a90f7a1a292a408d1824d75e3de26ea07a3f3e9"
398
398
  },
399
399
  {
400
400
  "storage": "agents/skills/orkestrel-publish/scripts/window.ts",
@@ -496,7 +496,7 @@
496
496
  "storage": "claude/agents/orkestrel.md",
497
497
  "destination": ".claude/agents/orkestrel.md",
498
498
  "executable": false,
499
- "digest": "9a093f83f23cc1f0d1fe1ba139e97afa0d1a38ab45522cc3e150fffc796c3ae3"
499
+ "digest": "02c8bfcfa26ee23e91cef48771e5a3038bdb8d4018f0510bef5cd17db82f5893"
500
500
  },
501
501
  {
502
502
  "storage": "claude/agents/planner.md",
@@ -538,7 +538,7 @@
538
538
  "storage": "claude/rules/architecture.md",
539
539
  "destination": ".claude/rules/architecture.md",
540
540
  "executable": false,
541
- "digest": "e30f034c8de38ce7c86506dfaa51844201d745181caed45ef427d0325e80afd3"
541
+ "digest": "6d8936e85dd3c01e915a91a5b7bb9aaafa9b09a899b0cf8ff6bb8f9e8ff8e629"
542
542
  },
543
543
  {
544
544
  "storage": "claude/rules/browser.md",
@@ -556,7 +556,7 @@
556
556
  "storage": "claude/rules/names.md",
557
557
  "destination": ".claude/rules/names.md",
558
558
  "executable": false,
559
- "digest": "1c9aeda4a47d94ef174e1f513da7b2710fe2a162e56a450270572ad942c95a7d"
559
+ "digest": "6606f4f8b219c6631029235f4081f29b055952a635e76477dfd6febdbe61afe2"
560
560
  },
561
561
  {
562
562
  "storage": "claude/rules/patterns.md",
@@ -772,7 +772,7 @@
772
772
  "storage": "configs/policy.ts",
773
773
  "destination": "configs/policy.ts",
774
774
  "executable": false,
775
- "digest": "2ba8395040b41b30245a0e09de3a87b10546f29eab359a2884b5cde76aff4fc8"
775
+ "digest": "de238996682d2eb35a40941214dc5c1d6427c57159afc3055f243bf93a5e8f83"
776
776
  },
777
777
  {
778
778
  "storage": "cursor/mcp.json",
@@ -826,7 +826,7 @@
826
826
  "storage": "dotfiles/oxlintrc.json",
827
827
  "destination": ".oxlintrc.json",
828
828
  "executable": false,
829
- "digest": "8deab17f02176cb061f4c80a068eead4ac44ffc62cbb388587a962dc6afd8431"
829
+ "digest": "043a5c3eb0fb52d6cd841590e77c94ce03797b4b6a742fd57127bc9b9242153c"
830
830
  },
831
831
  {
832
832
  "storage": "dotfiles/prettierignore",
@@ -916,7 +916,7 @@
916
916
  "storage": "guides/guide.md",
917
917
  "destination": "guides/guide.md",
918
918
  "executable": false,
919
- "digest": "1cdcd2e03b005cd8e7e12319f083ef31847a96682b4f9e33a084ea249c6a857c"
919
+ "digest": "4749d6a2a7da1d8d89a8c3ee3b60c5f21fcfb112074db80d7b1a2edcdef93afd"
920
920
  },
921
921
  {
922
922
  "storage": "guides/html.md",
@@ -1042,7 +1042,7 @@
1042
1042
  "storage": "guides/scaffold.md",
1043
1043
  "destination": "guides/scaffold.md",
1044
1044
  "executable": false,
1045
- "digest": "116e87dd3c9b5c23451bb53a2365f7df8982e6782f60a3466070c8058c099700"
1045
+ "digest": "9d6ea9f86610e3237d6ddbe120aabdec137f022092fc5311ca18e87d4b4e6212"
1046
1046
  },
1047
1047
  {
1048
1048
  "storage": "guides/sea.md",
@@ -1168,7 +1168,7 @@
1168
1168
  "storage": "tests/config.test.ts",
1169
1169
  "destination": "tests/config.test.ts",
1170
1170
  "executable": false,
1171
- "digest": "6550d3edb31603777ce713985b6648063e105c1ce2bee82c66570382faed7c67"
1171
+ "digest": "395ac8782ae05c678c13e460de654e32140125f159fcb882053340ab193bb5f3"
1172
1172
  },
1173
1173
  {
1174
1174
  "storage": "tests/policy.test.ts",
@@ -2144,5 +2144,5 @@
2144
2144
  ]
2145
2145
  }
2146
2146
  ],
2147
- "digest": "f8711433145a8b302c5c8c626c1be5ddbdd2e5a44c1f971fb6fce1ed4f5703b6"
2147
+ "digest": "5c7e45000c69dd7340b13478851fcfaeaa972f3f25311e230def9b740dc82e15"
2148
2148
  }
File without changes
File without changes
File without changes
File without changes
@@ -36,6 +36,7 @@ import policyPlugin, {
36
36
  MOCKING_RULE,
37
37
  NESTED_RULE,
38
38
  PARSER_RULE,
39
+ PLUGIN_RULE,
39
40
  POLICY_BANNED_TERMS,
40
41
  POLICY_ENDING_GLOBS,
41
42
  POLICY_JUDGED_TERMS,
@@ -1614,6 +1615,12 @@ createSomething({
1614
1615
  code: 'const COUNT = 1',
1615
1616
  errors: [{ messageId: 'hidden' }],
1616
1617
  },
1618
+ {
1619
+ name: 'rejects a hidden plugin factory [membership: declarations in a centralized file without an export]',
1620
+ filename: 'src/worker/plugins.ts',
1621
+ code: 'function createModalPlugin(): void {}',
1622
+ errors: [{ messageId: 'hidden' }],
1623
+ },
1617
1624
  ],
1618
1625
  })
1619
1626
 
@@ -1721,6 +1728,11 @@ createSomething({
1721
1728
  filename: 'src/worker/helpers.ts',
1722
1729
  code: 'export function buildValue(): void {}',
1723
1730
  },
1731
+ {
1732
+ name: 'accepts a plugin factory in plugins.ts',
1733
+ filename: 'src/worker/plugins.ts',
1734
+ code: 'export function createModalPlugin(): void {}',
1735
+ },
1724
1736
  {
1725
1737
  name: 'accepts a module in a registered function domain',
1726
1738
  filename: 'app/browser/composables/useTheme.ts',
@@ -1871,6 +1883,12 @@ createSomething({
1871
1883
  code: 'export const coerceValue = () => undefined',
1872
1884
  errors: [{ messageId: 'parser' }],
1873
1885
  },
1886
+ {
1887
+ name: 'rejects an unprefixed export alias [membership: parsers.ts functions whose name does not start with parse]',
1888
+ filename: 'app/edge/parsers.ts',
1889
+ code: 'function parseValue(): void {}\nexport { parseValue as coerceValue }',
1890
+ errors: [{ messageId: 'parser' }],
1891
+ },
1874
1892
  ],
1875
1893
  })
1876
1894
 
@@ -1900,6 +1918,122 @@ createSomething({
1900
1918
  code: 'export const buildValue = () => undefined',
1901
1919
  errors: [{ messageId: 'factory' }],
1902
1920
  },
1921
+ {
1922
+ name: 'rejects an unprefixed export alias [membership: factories.ts functions whose name does not start with create]',
1923
+ filename: 'app/edge/factories.ts',
1924
+ code: 'function createValue(): void {}\nexport { createValue as buildValue }',
1925
+ errors: [{ messageId: 'factory' }],
1926
+ },
1927
+ ],
1928
+ })
1929
+
1930
+ tester.run('no-misnamed-plugin', PLUGIN_RULE, {
1931
+ valid: [
1932
+ {
1933
+ name: 'accepts a create-prefixed plugin factory',
1934
+ filename: 'src/edge/plugins.ts',
1935
+ code: 'export function createModalPlugin(): void {}',
1936
+ },
1937
+ {
1938
+ name: 'accepts a create-prefixed plugin collection factory',
1939
+ filename: 'src/edge/plugins.ts',
1940
+ code: 'export const createBootstrapPlugins = () => undefined',
1941
+ },
1942
+ {
1943
+ name: 'accepts a plugin-suffixed name outside plugins.ts',
1944
+ filename: 'src/edge/helpers.ts',
1945
+ code: 'export function registerPlugin(): void {}',
1946
+ },
1947
+ {
1948
+ name: 'reads no binding nested inside a plugin factory',
1949
+ filename: 'src/edge/plugins.ts',
1950
+ code: 'export function createModalPlugin(): void {\n\tfunction build(): void {}\n\tbuild()\n}',
1951
+ },
1952
+ {
1953
+ name: 'accepts an export specifier in the plugin form',
1954
+ filename: 'src/edge/plugins.ts',
1955
+ code: 'function createModalPlugin(): void {}\nexport { createModalPlugin as createDialogPlugin }',
1956
+ },
1957
+ ],
1958
+ invalid: [
1959
+ {
1960
+ name: 'rejects a plugin-suffixed name without the create prefix [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1961
+ filename: 'src/edge/plugins.ts',
1962
+ code: 'export function registerModalPlugin(): void {}',
1963
+ errors: [{ messageId: 'plugin' }],
1964
+ },
1965
+ {
1966
+ name: 'rejects a lowercase segment before the plugin suffix [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1967
+ filename: 'src/edge/plugins.ts',
1968
+ code: 'export function createmodalPlugin(): void {}',
1969
+ errors: [{ messageId: 'plugin' }],
1970
+ },
1971
+ {
1972
+ name: 'rejects a name that runs past the plugin suffix [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1973
+ filename: 'src/edge/plugins.ts',
1974
+ code: 'export function createModalPluginHost(): void {}',
1975
+ errors: [{ messageId: 'plugin' }],
1976
+ },
1977
+ {
1978
+ name: 'rejects a plugin factory with no entity segment [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1979
+ filename: 'src/edge/plugins.ts',
1980
+ code: 'export function createPlugin(): void {}',
1981
+ errors: [{ messageId: 'plugin' }],
1982
+ },
1983
+ {
1984
+ name: 'rejects a misnamed declared signature [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1985
+ filename: 'src/edge/plugins.ts',
1986
+ code: 'export declare function registerModal(): void',
1987
+ errors: [{ messageId: 'plugin' }],
1988
+ },
1989
+ {
1990
+ name: 'rejects an anonymous default function [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1991
+ filename: 'src/edge/plugins.ts',
1992
+ code: 'export default function (): void {}',
1993
+ errors: [{ messageId: 'plugin' }],
1994
+ },
1995
+ {
1996
+ name: 'rejects an export alias outside the plugin form [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
1997
+ filename: 'src/edge/plugins.ts',
1998
+ code: 'function createModalPlugin(): void {}\nexport { createModalPlugin as registerModal }',
1999
+ errors: [{ messageId: 'plugin' }],
2000
+ },
2001
+ {
2002
+ name: 'rejects a re-export outside the plugin form [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2003
+ filename: 'src/edge/plugins.ts',
2004
+ code: "export { registerModal } from './modal.js'",
2005
+ errors: [{ messageId: 'plugin' }],
2006
+ },
2007
+ {
2008
+ name: 'rejects a star re-export whose names the form cannot read [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2009
+ filename: 'src/edge/plugins.ts',
2010
+ code: "export * from './modal.js'",
2011
+ errors: [{ messageId: 'plugin' }],
2012
+ },
2013
+ {
2014
+ name: 'rejects a register-prefixed plugin factory [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2015
+ filename: 'src/edge/plugins.ts',
2016
+ code: 'export function registerModal(): void {}',
2017
+ errors: [{ messageId: 'plugin' }],
2018
+ },
2019
+ {
2020
+ name: 'rejects a create-prefixed name without the plugin suffix [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2021
+ filename: 'src/edge/plugins.ts',
2022
+ code: 'export const createModal = () => undefined',
2023
+ errors: [{ messageId: 'plugin' }],
2024
+ },
2025
+ {
2026
+ name: 'rejects a bare plugin-suffixed name [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2027
+ filename: 'src/edge/plugins.ts',
2028
+ code: 'export function modalPlugin(): void {}',
2029
+ errors: [{ messageId: 'plugin' }],
2030
+ },
2031
+ {
2032
+ name: 'rejects a lowercase entity after create [membership: plugins.ts functions whose name is not create…Plugin or create…Plugins]',
2033
+ filename: 'src/edge/plugins.ts',
2034
+ code: 'export function createplugin(): void {}',
2035
+ errors: [{ messageId: 'plugin' }],
2036
+ },
1903
2037
  ],
1904
2038
  })
1905
2039
 
@@ -2385,6 +2519,12 @@ createSomething({
2385
2519
  expect(CENTRAL_SOURCE_FILES).toContain('handlers.ts')
2386
2520
  })
2387
2521
 
2522
+ it('registers plugins as a central function kind', () => {
2523
+ expect(FUNCTION_SOURCE_FILES).toContain('plugins.ts')
2524
+ expect(CENTRAL_SOURCE_FILES).toContain('plugins.ts')
2525
+ expect(DATA_SOURCE_FILES).not.toContain('plugins.ts')
2526
+ })
2527
+
2388
2528
  it('matches every isolated import pattern with refused and admitted fixtures', () => {
2389
2529
  const fixture = createPolicyScratch({ prefix: 'propagation-patterns-' })
2390
2530
  const scratch = fixture.path
@@ -2734,6 +2874,7 @@ createSomething({
2734
2874
  )
2735
2875
  scratch.write('src/violations/parsers.ts', 'export function coerceValue(): void {}\n')
2736
2876
  scratch.write('src/violations/factories.ts', 'export function buildValue(): void {}\n')
2877
+ scratch.write('src/violations/plugins.ts', 'export function registerModal(): void {}\n')
2737
2878
  scratch.write('src/violations/constants.ts', 'export const values = []\n')
2738
2879
  scratch.write('src/violations/composables.ts', "export const READY = 'yes'\n")
2739
2880
  scratch.write('app/browser/composables/useTheme.ts', 'export function useMode(): void {}\n')
@@ -2837,6 +2978,7 @@ createSomething({
2837
2978
  { code: 'policy(no-hidden-declaration)', filename: 'src/violations/helpers.ts' },
2838
2979
  { code: 'policy(no-misnamed-parser)', filename: 'src/violations/parsers.ts' },
2839
2980
  { code: 'policy(no-misnamed-factory)', filename: 'src/violations/factories.ts' },
2981
+ { code: 'policy(no-misnamed-plugin)', filename: 'src/violations/plugins.ts' },
2840
2982
  { code: 'policy(no-malformed-constant)', filename: 'src/violations/constants.ts' },
2841
2983
  { code: 'policy(no-malformed-domain)', filename: 'src/violations/composables.ts' },
2842
2984
  {
@@ -4,7 +4,7 @@ let _orkestrel_template = require("@orkestrel/template");
4
4
  let _orkestrel_emitter = require("@orkestrel/emitter");
5
5
  var package_default = {
6
6
  name: "@orkestrel/scaffold",
7
- version: "0.0.85",
7
+ version: "0.0.87",
8
8
  description: "Scaffold workspaces with commands: new, audit, repair, catalog, and overwrite.",
9
9
  keywords: [
10
10
  "audit",
@@ -104,7 +104,7 @@ var package_default = {
104
104
  devDependencies: {
105
105
  "@microsoft/api-extractor": "^7.59.3",
106
106
  "@orkestrel/browser": "^0.0.20",
107
- "@orkestrel/guide": "^0.0.22",
107
+ "@orkestrel/guide": "^0.0.24",
108
108
  "@orkestrel/html": "^0.0.12",
109
109
  "@orkestrel/probe": "^0.0.19",
110
110
  "@orkestrel/test": "^0.0.24",
@@ -7361,6 +7361,185 @@ function replaceManifestRanges(manifest, pins) {
7361
7361
  return declaredRuntime && declaredDevelopment ? compiled : void 0;
7362
7362
  }
7363
7363
  /**
7364
+ * Inserts dependencies a package manifest does not declare into the section each one names.
7365
+ *
7366
+ * @param manifest - The manifest text to compile.
7367
+ * @param additions - The runtime and development names and ranges to declare.
7368
+ * @returns The manifest declaring every addition, or `undefined` when the text is not a
7369
+ * manifest, an addition's section is not an object or holds a value that is not a range, a name
7370
+ * is repeated, or `dependencies` or `devDependencies` already declares a name.
7371
+ *
7372
+ * @remarks
7373
+ * Runtime additions enter `dependencies` and development additions enter `devDependencies`. The
7374
+ * compiler inserts text instead of serializing the manifest, so every declared byte survives.
7375
+ * Each addition lands before the first declared key that sorts after it, or after the last
7376
+ * declared key when none does, so a section kept in key order stays in key order. An addition
7377
+ * copies the indentation of the section's first entry; an empty section takes its entries one
7378
+ * level inside the indentation of its opening line. An absent section is created as one
7379
+ * top-level key holding its additions: `devDependencies` after `dependencies`, `dependencies`
7380
+ * before `devDependencies`, and either one last in the manifest object when its sibling is
7381
+ * absent. The created key copies the indentation of the manifest's first key, and its entries sit
7382
+ * one level further in. A name either writable section already declares is the caller's mistake
7383
+ * rather than an addition, so the compiler refuses it instead of declaring a package twice.
7384
+ *
7385
+ * @example
7386
+ * ```ts
7387
+ * import { insertManifestDependencies } from '@orkestrel/scaffold'
7388
+ *
7389
+ * insertManifestDependencies('{\n\t"devDependencies": {\n\t\t"vite": "^8.3.2"\n\t}\n}\n', {
7390
+ * runtime: [],
7391
+ * development: [{ name: 'typescript', range: '^6.0.3' }],
7392
+ * })
7393
+ * // '{\n\t"devDependencies": {\n\t\t"typescript": "^6.0.3",\n\t\t"vite": "^8.3.2"\n\t}\n}\n'
7394
+ * ```
7395
+ */
7396
+ function insertManifestDependencies(manifest, additions) {
7397
+ const requested = [...additions.runtime, ...additions.development];
7398
+ if (requested.length === 0) return manifest;
7399
+ const parsed = (0, _orkestrel_contract.parseJSON)(manifest);
7400
+ if (!(0, _orkestrel_contract.isRecord)(parsed)) return void 0;
7401
+ const declared = /* @__PURE__ */ new Set();
7402
+ for (const section of ["dependencies", "devDependencies"]) {
7403
+ const entries = parsed[section];
7404
+ if ((0, _orkestrel_contract.isRecord)(entries)) for (const name of Object.keys(entries)) declared.add(name);
7405
+ }
7406
+ const names = new Set(requested.map(({ name }) => name));
7407
+ if (names.size !== requested.length || [...names].some((name) => declared.has(name))) return;
7408
+ let compiled = manifest;
7409
+ const sections = [{
7410
+ name: "dependencies",
7411
+ dependencies: additions.runtime
7412
+ }, {
7413
+ name: "devDependencies",
7414
+ dependencies: additions.development
7415
+ }];
7416
+ for (const section of sections) {
7417
+ if (section.dependencies.length === 0) continue;
7418
+ const entries = parsed[section.name];
7419
+ if (entries !== void 0 && (!(0, _orkestrel_contract.isRecord)(entries) || !Object.values(entries).every(_orkestrel_contract.isString))) return;
7420
+ const ordered = [...section.dependencies].sort((left, right) => (0, _orkestrel_contract.compareValues)(left.name, right.name));
7421
+ const lines = ordered.map(({ name, range }) => `${JSON.stringify(name)}: ${JSON.stringify(range)}`);
7422
+ const sibling = section.name === "dependencies" ? "devDependencies" : "dependencies";
7423
+ const located = /* @__PURE__ */ new Map();
7424
+ let current;
7425
+ let head = -1;
7426
+ let root = -1;
7427
+ let depth = 0;
7428
+ let cursor = 0;
7429
+ while (cursor < compiled.length && root < 0) {
7430
+ const character = compiled.charAt(cursor);
7431
+ if (character === "\"") {
7432
+ const start = cursor;
7433
+ let quote = cursor + 1;
7434
+ while (quote < compiled.length && compiled.charAt(quote) !== "\"") quote += compiled.charAt(quote) === "\\" ? 2 : 1;
7435
+ if (quote >= compiled.length) return void 0;
7436
+ let colon = quote + 1;
7437
+ while (/\s/u.test(compiled.charAt(colon))) colon += 1;
7438
+ cursor = quote + 1;
7439
+ if (depth !== 1 || compiled.charAt(colon) !== ":") continue;
7440
+ if (head < 0) head = start;
7441
+ const name = (0, _orkestrel_contract.parseJSON)(compiled.slice(start, quote + 1));
7442
+ if (!(0, _orkestrel_contract.isString)(name) || name !== section.name && name !== sibling) continue;
7443
+ if (located.has(name)) continue;
7444
+ let brace = colon + 1;
7445
+ while (/\s/u.test(compiled.charAt(brace))) brace += 1;
7446
+ if (compiled.charAt(brace) !== "{") {
7447
+ if (name === section.name) return void 0;
7448
+ continue;
7449
+ }
7450
+ current = {
7451
+ name,
7452
+ start,
7453
+ open: brace
7454
+ };
7455
+ depth += 1;
7456
+ cursor = brace + 1;
7457
+ continue;
7458
+ }
7459
+ if (character === "{") depth += 1;
7460
+ else if (character === "}") {
7461
+ depth -= 1;
7462
+ if (depth === 1 && current !== void 0) {
7463
+ located.set(current.name, {
7464
+ ...current,
7465
+ close: cursor
7466
+ });
7467
+ current = void 0;
7468
+ }
7469
+ if (depth === 0) root = cursor;
7470
+ }
7471
+ cursor += 1;
7472
+ }
7473
+ const bounds = located.get(section.name);
7474
+ if (bounds === void 0) {
7475
+ if (entries !== void 0 || root < 0) return void 0;
7476
+ const breaking = head < 0 ? -1 : compiled.lastIndexOf("\n", head);
7477
+ const margin = breaking < 0 ? "" : compiled.slice(breaking + 1, head);
7478
+ const gap = breaking < 0 || /\S/u.test(margin) ? "" : `\n${margin}`;
7479
+ const block = `${JSON.stringify(section.name)}: {${lines.map((line) => `${gap === "" ? "" : `${gap}${margin}`}${line}`).join(",")}${gap}}`;
7480
+ const neighbor = located.get(sibling);
7481
+ let tail = root - 1;
7482
+ while (tail > 0 && /\s/u.test(compiled.charAt(tail))) tail -= 1;
7483
+ const [position, insertion] = neighbor === void 0 ? [tail + 1, compiled.charAt(tail) === "{" ? block : `,${gap}${block}`] : section.name === "devDependencies" ? [neighbor.close + 1, `,${gap}${block}`] : [neighbor.start, `${block},${gap}`];
7484
+ compiled = compiled.slice(0, position) + insertion + compiled.slice(position);
7485
+ continue;
7486
+ }
7487
+ const { open, close } = bounds;
7488
+ const declarations = [];
7489
+ let key;
7490
+ let scan = open + 1;
7491
+ while (scan < close) {
7492
+ if (compiled.charAt(scan) !== "\"") {
7493
+ scan += 1;
7494
+ continue;
7495
+ }
7496
+ let quote = scan + 1;
7497
+ while (quote < close && compiled.charAt(quote) !== "\"") quote += compiled.charAt(quote) === "\\" ? 2 : 1;
7498
+ if (quote >= close) return void 0;
7499
+ if (key === void 0) {
7500
+ const name = (0, _orkestrel_contract.parseJSON)(compiled.slice(scan, quote + 1));
7501
+ if (!(0, _orkestrel_contract.isString)(name)) return void 0;
7502
+ key = {
7503
+ name,
7504
+ start: scan
7505
+ };
7506
+ } else {
7507
+ declarations.push({
7508
+ ...key,
7509
+ end: quote + 1
7510
+ });
7511
+ key = void 0;
7512
+ }
7513
+ scan = quote + 1;
7514
+ }
7515
+ const first = declarations[0];
7516
+ const last = declarations.at(-1);
7517
+ const edits = /* @__PURE__ */ new Map();
7518
+ if (first === void 0 || last === void 0) {
7519
+ const opening = compiled.lastIndexOf("\n", open);
7520
+ let column = opening + 1;
7521
+ while (column < open && /\s/u.test(compiled.charAt(column))) column += 1;
7522
+ const level = opening < 0 ? "" : compiled.slice(opening + 1, column);
7523
+ const separator = opening < 0 ? "" : `\n${level}${level}`;
7524
+ const ending = opening < 0 ? "" : `\n${level}`;
7525
+ compiled = `${compiled.slice(0, open + 1)}${lines.map((line) => `${separator}${line}`).join(",")}${ending}${compiled.slice(close)}`;
7526
+ continue;
7527
+ }
7528
+ const newline = compiled.lastIndexOf("\n", first.start);
7529
+ const indent = newline < 0 ? "" : compiled.slice(newline + 1, first.start);
7530
+ const separator = newline < 0 || /\S/u.test(indent) ? "" : `\n${indent}`;
7531
+ for (const [index, dependency] of ordered.entries()) {
7532
+ const line = lines[index] ?? "";
7533
+ const anchor = declarations.find((declaration) => (0, _orkestrel_contract.compareValues)(declaration.name, dependency.name) > 0);
7534
+ const position = anchor?.start ?? last.end;
7535
+ const text = anchor === void 0 ? `,${separator}${line}` : `${line},${separator}`;
7536
+ edits.set(position, `${edits.get(position) ?? ""}${text}`);
7537
+ }
7538
+ for (const [position, text] of [...edits].sort(([left], [right]) => right - left)) compiled = compiled.slice(0, position) + text + compiled.slice(position);
7539
+ }
7540
+ return compiled;
7541
+ }
7542
+ /**
7364
7543
  * Replaces named script values in package manifest text.
7365
7544
  *
7366
7545
  * @param manifest - The manifest text to compile.
@@ -8570,6 +8749,7 @@ exports.extractRangeMajor = extractRangeMajor;
8570
8749
  exports.extractVersion = extractVersion;
8571
8750
  exports.inferDrift = inferDrift;
8572
8751
  exports.inferGroup = inferGroup;
8752
+ exports.insertManifestDependencies = insertManifestDependencies;
8573
8753
  exports.isArtifact = isArtifact;
8574
8754
  exports.isAudit = isAudit;
8575
8755
  exports.isBlueprint = isBlueprint;