@prestack/thread 0.0.3 → 0.1.0

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 (183) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/dist/core/{asking.d.ts → answers.d.ts} +6 -14
  3. package/dist/core/{asking.js → answers.js} +13 -332
  4. package/dist/core/{asking.ts → answers.ts} +14 -357
  5. package/dist/core/attach.js +2 -2
  6. package/dist/core/attach.ts +2 -3
  7. package/dist/core/chain.js +4 -11
  8. package/dist/core/chain.ts +4 -3
  9. package/dist/core/client.d.ts +57 -0
  10. package/dist/core/client.js +186 -0
  11. package/dist/core/client.ts +227 -0
  12. package/dist/core/descend.d.ts +2 -0
  13. package/dist/core/descend.js +109 -16
  14. package/dist/core/descend.ts +120 -16
  15. package/dist/core/files.d.ts +45 -0
  16. package/dist/core/files.js +95 -0
  17. package/dist/core/files.ts +137 -0
  18. package/dist/core/init.d.ts +1 -0
  19. package/dist/core/init.js +10 -2
  20. package/dist/core/init.ts +8 -2
  21. package/dist/core/invoked.js +1 -1
  22. package/dist/core/invoked.ts +1 -1
  23. package/dist/core/rows.d.ts +2 -0
  24. package/dist/core/rows.js +65 -0
  25. package/dist/core/rows.ts +58 -0
  26. package/dist/core/tree.js +1 -1
  27. package/dist/core/tree.ts +1 -1
  28. package/dist/derivation/attach.js +0 -12
  29. package/dist/derivation/attach.ts +0 -12
  30. package/dist/derivation/generators/build.js +8 -7
  31. package/dist/derivation/generators/build.ts +8 -7
  32. package/dist/derivation/generators/release.d.ts +1 -1
  33. package/dist/derivation/generators/release.js +15 -23
  34. package/dist/derivation/generators/release.ts +15 -15
  35. package/dist/integrations/attach.js +1 -19
  36. package/dist/integrations/attach.ts +1 -19
  37. package/dist/integrations/generators/read.js +2 -2
  38. package/dist/integrations/generators/read.ts +4 -4
  39. package/dist/integrations/generators/vault.js +4 -12
  40. package/dist/integrations/generators/vault.ts +4 -4
  41. package/dist/integrations/module.js +5 -3
  42. package/dist/integrations/module.ts +5 -3
  43. package/dist/integrations/vault.js +5 -5
  44. package/dist/integrations/vault.ts +5 -5
  45. package/dist/integrity/attach.js +0 -12
  46. package/dist/integrity/attach.ts +0 -12
  47. package/dist/integrity/check-threads.js +1 -1
  48. package/dist/integrity/check-threads.ts +1 -1
  49. package/dist/integrity/constraint.d.ts +11 -2
  50. package/dist/integrity/constraint.js +163 -20
  51. package/dist/integrity/constraint.ts +174 -22
  52. package/dist/integrity/generators/compiler.js +1 -1
  53. package/dist/integrity/generators/compiler.ts +1 -1
  54. package/dist/integrity/generators/gate.js +8 -16
  55. package/dist/integrity/generators/gate.ts +8 -7
  56. package/dist/integrity/generators/publish.js +14 -26
  57. package/dist/integrity/generators/publish.ts +14 -17
  58. package/dist/integrity/generators/trial.d.ts +2 -2
  59. package/dist/integrity/generators/trial.js +108 -50
  60. package/dist/integrity/generators/trial.ts +107 -48
  61. package/dist/integrity/lint.js +3 -3
  62. package/dist/integrity/lint.ts +3 -3
  63. package/dist/integrity/lsp/diagnostics.js +1 -1
  64. package/dist/integrity/lsp/diagnostics.ts +1 -1
  65. package/dist/integrity/lsp/lint.js +1 -1
  66. package/dist/integrity/lsp/lint.ts +1 -1
  67. package/dist/integrity/slopnator.d.ts +1 -14
  68. package/dist/integrity/slopnator.js +8 -40
  69. package/dist/integrity/slopnator.ts +9 -51
  70. package/dist/integrity/slopnators/sl_broken_lineage.js +4 -2
  71. package/dist/integrity/slopnators/sl_broken_lineage.ts +4 -2
  72. package/dist/integrity/slopnators/sl_declared_elsewhere.js +24 -3
  73. package/dist/integrity/slopnators/sl_declared_elsewhere.ts +24 -3
  74. package/dist/integrity/slopnators/sl_derived_drift.js +10 -4
  75. package/dist/integrity/slopnators/sl_derived_drift.ts +10 -4
  76. package/dist/integrity/slopnators/sl_inert_island.js +7 -13
  77. package/dist/integrity/slopnators/sl_inert_island.ts +7 -16
  78. package/dist/integrity/slopnators/sl_inert_slopnator.js +8 -8
  79. package/dist/integrity/slopnators/sl_inert_slopnator.ts +8 -8
  80. package/dist/integrity/slopnators/sl_missing_row.js +14 -9
  81. package/dist/integrity/slopnators/sl_missing_row.ts +14 -10
  82. package/dist/integrity/slopnators/sl_no_child_process.js +8 -8
  83. package/dist/integrity/slopnators/sl_no_child_process.ts +8 -8
  84. package/dist/integrity/slopnators/sl_no_import_cycle.js +1 -1
  85. package/dist/integrity/slopnators/sl_no_import_cycle.ts +1 -1
  86. package/dist/integrity/slopnators/sl_no_such_command.js +20 -5
  87. package/dist/integrity/slopnators/sl_no_such_command.ts +22 -5
  88. package/dist/integrity/slopnators/sl_only_takes_a_literal.js +8 -8
  89. package/dist/integrity/slopnators/sl_only_takes_a_literal.ts +8 -8
  90. package/dist/integrity/slopnators/sl_stale_path.js +91 -18
  91. package/dist/integrity/slopnators/sl_stale_path.ts +97 -18
  92. package/dist/integrity/slopnators/sl_twice_meant.js +25 -2
  93. package/dist/integrity/slopnators/sl_twice_meant.ts +28 -2
  94. package/dist/integrity/slopnators/sl_twice_parented.js +26 -5
  95. package/dist/integrity/slopnators/sl_twice_parented.ts +26 -5
  96. package/dist/integrity/slopnators/sl_undeclared_node.js +18 -2
  97. package/dist/integrity/slopnators/sl_undeclared_node.ts +18 -2
  98. package/dist/integrity/slopnators/sl_undeclared_operation.js +3 -1
  99. package/dist/integrity/slopnators/sl_undeclared_operation.ts +3 -1
  100. package/dist/integrity/slopnators/sl_undeclared_variant.js +6 -2
  101. package/dist/integrity/slopnators/sl_undeclared_variant.ts +6 -2
  102. package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -4
  103. package/dist/integrity/slopnators/sl_ungoverned_island.ts +3 -4
  104. package/dist/integrity/slopnators/sl_unkept_rows.js +1 -1
  105. package/dist/integrity/slopnators/sl_unkept_rows.ts +1 -1
  106. package/dist/integrity/slopnators/sl_unpaired_member.js +13 -8
  107. package/dist/integrity/slopnators/sl_unpaired_member.ts +16 -8
  108. package/dist/integrity/slopnators/sl_unpaired_slopnator.js +16 -3
  109. package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +16 -3
  110. package/dist/integrity/slopnators/sl_unthreaded.d.ts +1 -0
  111. package/dist/integrity/slopnators/sl_unthreaded.js +18 -10
  112. package/dist/integrity/slopnators/sl_unthreaded.ts +19 -11
  113. package/dist/integrity/slopnators/sl_untranslated_key.js +1 -1
  114. package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -1
  115. package/dist/integrity/slopnators/sl_unversioned.js +16 -2
  116. package/dist/integrity/slopnators/sl_unversioned.ts +16 -2
  117. package/dist/integrity/sweep.js +17 -3
  118. package/dist/integrity/sweep.ts +20 -3
  119. package/dist/knowledge/attach.js +0 -6
  120. package/dist/knowledge/attach.ts +0 -6
  121. package/dist/knowledge/generators/docsgen.js +12 -3
  122. package/dist/knowledge/generators/docsgen.ts +12 -2
  123. package/dist/knowledge/generators/glossary.js +1 -1
  124. package/dist/knowledge/generators/glossary.ts +1 -1
  125. package/dist/operations/attach.js +2 -26
  126. package/dist/operations/attach.ts +2 -27
  127. package/dist/operations/dispatch.js +2 -3
  128. package/dist/operations/dispatch.ts +2 -3
  129. package/dist/operations/generators/capability.js +4 -7
  130. package/dist/operations/generators/capability.ts +3 -6
  131. package/dist/operations/generators/compile.js +8 -13
  132. package/dist/operations/generators/compile.ts +8 -4
  133. package/dist/operations/generators/permits.js +4 -13
  134. package/dist/operations/generators/permits.ts +3 -3
  135. package/dist/operations/generators/seed.js +5 -2
  136. package/dist/operations/generators/seed.ts +6 -2
  137. package/dist/operations/generators/trial.js +10 -10
  138. package/dist/operations/generators/trial.ts +10 -10
  139. package/dist/operations/http.js +4 -1
  140. package/dist/operations/http.ts +6 -1
  141. package/package.json +2 -2
  142. package/dist/core/cli.d.ts +0 -2
  143. package/dist/core/cli.js +0 -1761
  144. package/dist/core/cli.ts +0 -2004
  145. package/dist/core/generators/meta.d.ts +0 -2
  146. package/dist/core/generators/meta.js +0 -829
  147. package/dist/core/generators/meta.ts +0 -1006
  148. package/dist/derivation/generators/derivation.d.ts +0 -3
  149. package/dist/derivation/generators/derivation.js +0 -273
  150. package/dist/derivation/generators/derivation.ts +0 -347
  151. package/dist/derivation/makers/release.d.ts +0 -1
  152. package/dist/derivation/makers/release.js +0 -107
  153. package/dist/derivation/makers/release.ts +0 -135
  154. package/dist/integrations/generators/secret.d.ts +0 -1
  155. package/dist/integrations/generators/secret.js +0 -233
  156. package/dist/integrations/generators/secret.ts +0 -289
  157. package/dist/integrations/generators/target.d.ts +0 -1
  158. package/dist/integrations/generators/target.js +0 -775
  159. package/dist/integrations/generators/target.ts +0 -944
  160. package/dist/integrity/generators/rule.d.ts +0 -2
  161. package/dist/integrity/generators/rule.js +0 -213
  162. package/dist/integrity/generators/rule.ts +0 -271
  163. package/dist/integrity/generators/seal.d.ts +0 -4
  164. package/dist/integrity/generators/seal.js +0 -101
  165. package/dist/integrity/generators/seal.ts +0 -117
  166. package/dist/integrity/sealed.d.ts +0 -1
  167. package/dist/integrity/sealed.js +0 -56
  168. package/dist/integrity/sealed.ts +0 -56
  169. package/dist/knowledge/generators/skills.d.ts +0 -1
  170. package/dist/knowledge/generators/skills.js +0 -222
  171. package/dist/knowledge/generators/skills.ts +0 -263
  172. package/dist/operations/generators/grant.d.ts +0 -1
  173. package/dist/operations/generators/grant.js +0 -267
  174. package/dist/operations/generators/grant.ts +0 -336
  175. package/dist/operations/generators/operation.d.ts +0 -1
  176. package/dist/operations/generators/operation.js +0 -811
  177. package/dist/operations/generators/operation.ts +0 -972
  178. package/dist/operations/makers/capability.d.ts +0 -1
  179. package/dist/operations/makers/capability.js +0 -117
  180. package/dist/operations/makers/capability.ts +0 -166
  181. package/dist/operations/makers/trial.d.ts +0 -1
  182. package/dist/operations/makers/trial.js +0 -413
  183. package/dist/operations/makers/trial.ts +0 -520
@@ -1,117 +0,0 @@
1
- import { createHash } from 'node:crypto'
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs'
3
- import { basename, dirname, join, relative, resolve } from 'node:path'
4
- import { argv, stderr, stdout } from 'node:process'
5
- import { fileURLToPath, pathToFileURL } from 'node:url'
6
-
7
- import { runChecker, type Finding } from '../../core/finding.ts'
8
- import { exit, invoked } from '../../core/invoked.ts'
9
- import { findTree, inTree } from '../../core/tree.ts'
10
- import { SEALED } from '../sealed.ts'
11
-
12
- export const SEALED_AT = 'sealed.ts'
13
-
14
- const HERE = fileURLToPath(import.meta.url)
15
-
16
- const FROM_SOURCE = HERE.endsWith('.ts')
17
-
18
- const ROOT = FROM_SOURCE ? findTree().at : resolve(HERE, '../..')
19
-
20
- const DOMAIN = basename(resolve(HERE, '../..'))
21
-
22
- const WRITTEN = join(dirname(HERE), '..', SEALED_AT)
23
-
24
- const BUILT = SEALED_AT.replace(/\.ts$/, '.js')
25
-
26
- const CODE = /\.js$/
27
-
28
- const SHEET = 'packaging.ts'
29
-
30
- interface Packaged {
31
- readonly id?: string
32
- readonly folder?: string
33
- }
34
-
35
- async function declared(): Promise<readonly Packaged[]> {
36
- const sheet = inTree(findTree(), SHEET)
37
- if (!existsSync(sheet)) return []
38
- const loaded = (await import(pathToFileURL(sheet).href)) as { readonly PACKAGES?: readonly Packaged[] }
39
- return loaded.PACKAGES ?? []
40
- }
41
-
42
- const PACKAGES: readonly Packaged[] = FROM_SOURCE ? await declared() : []
43
-
44
- function built(): string {
45
- if (!FROM_SOURCE) return ROOT
46
- const folders = PACKAGES.map((one) => one.folder ?? '').filter((one) => one !== '')
47
- const holder = folders.find((folder) => existsSync(join(ROOT, folder, 'dist', DOMAIN)))
48
- if (holder === undefined) {
49
- stderr.write(
50
- `seal: no package built here holds \`${DOMAIN}\` — ${folders.length === 0 ? '_threads/packaging.ts declares no package' : `none of ${folders.join(', ')} has a dist/${DOMAIN}`}. ` +
51
- `Run \`thread packaged --build\` first, and if no package row carries the ${DOMAIN} words, put them on one in _threads/packaging.ts.\n`,
52
- )
53
- exit(1)
54
- }
55
- return join(ROOT, holder, 'dist', DOMAIN)
56
- }
57
-
58
- export function sealable(home: string = built()): readonly string[] {
59
- const found: string[] = []
60
- const step = (at: string): void => {
61
- for (const entry of readdirSync(at).sort()) {
62
- const here = join(at, entry)
63
- if (statSync(here).isDirectory()) step(here)
64
- else if (CODE.test(entry) && relative(home, here) !== BUILT) found.push(here)
65
- }
66
- }
67
- step(home)
68
- return found.sort()
69
- }
70
-
71
- export function sealOf(home: string = built()): Readonly<Record<string, string>> {
72
- const held: Record<string, string> = {}
73
- for (const file of sealable(home)) {
74
- held[relative(home, file)] = createHash('sha256').update(readFileSync(file)).digest('hex')
75
- }
76
- return held
77
- }
78
-
79
- export function content(seal: Readonly<Record<string, string>>): string {
80
- const rows = Object.entries(seal).map(([at, hash]) => ` '${at}': '${hash}',`)
81
- return [
82
- 'export const SEALED: Readonly<Record<string, string>> = {',
83
- ...rows,
84
- '}',
85
- '',
86
- ].join('\n')
87
- }
88
-
89
- if (invoked(import.meta.url)) {
90
- const seal = sealOf()
91
- const emitted = content(seal)
92
-
93
- if (argv.includes('--check')) {
94
- const sealed = Object.keys(seal).length
95
- const findings: Finding[] =
96
- content(SEALED) === emitted
97
- ? []
98
- : [
99
- {
100
- detail: `${SEALED_AT} is not the bytes this package is made of`,
101
- instead: 'run `thread seal` and commit what it writes — the seal is what proves an installed copy is the one that shipped',
102
- file: relative(ROOT, WRITTEN),
103
- },
104
- ]
105
- runChecker('seal', findings, `${String(sealed)} file(s) sealed`)
106
- exit(findings.length === 0 ? 0 : 1)
107
- }
108
-
109
- if (!FROM_SOURCE) {
110
- stderr.write('seal: this copy is installed, and a seal is written where the package is made. Nothing was rewritten — `thread seal --check` says whether this copy is the one that shipped.\n')
111
- exit(1)
112
- }
113
-
114
- mkdirSync(dirname(WRITTEN), { recursive: true })
115
- writeFileSync(WRITTEN, emitted)
116
- stdout.write(`seal: wrote ${SEALED_AT} — ${String(Object.keys(seal).length)} file(s).\n`)
117
- }
@@ -1 +0,0 @@
1
- export declare const SEALED: Readonly<Record<string, string>>;
@@ -1,56 +0,0 @@
1
- export const SEALED = {
2
- 'attach.js': 'e879e49449a3b90118335ab4d2ea6666956da92203438fac7b88ff3a65a79103',
3
- 'check-threads.js': '3c943a890af508bfeb0071974ab74ff3f90ff3ce5e7cd1ffa2e2580c6214b3e2',
4
- 'constraint.js': 'c6eebad19fc11c42c095d82f5658c204f322d136bcbaab98aa9fc06dfa625afb',
5
- 'generators/compiler.js': 'c6db73bfd31513d8334ef5cd063fb5f12b89c56739ff0f2b73249252d1817cdc',
6
- 'generators/gate.js': 'f865f469f13b9e3b2eb120bd233b3e286c0df30a4cdf15cd20be4cb995854f88',
7
- 'generators/issues.js': '21cd7349d3375f15cb8b1a0c31714ab645b021b952275046b56357fba68478b8',
8
- 'generators/publish.js': 'f19114019854ace16fd5ca94c42cbffd838894ce9e7679d6afd4cf26e2bdddd5',
9
- 'generators/rule.js': '82bdfefbf394528fa4e7994a60eb423b3188277571937e161648f72666728aa4',
10
- 'generators/seal.js': '39fb8ab5c95b9c0fd1d3d38090785b2e1890653bb1d0454868426b67b28abe3a',
11
- 'generators/trial.js': 'a2ef8fda83bb2894ae088a0d7887a4e49b9693fa1a7e1345879aaa63041914b0',
12
- 'lint.js': '63f9957725a94498d7e5a49544da343c5f2e1b3b9c2778000dae4a4f39036ef9',
13
- 'lsp/bin.js': 'b71d5da40c137dbe87083ad29bf1a54e30a190113b8811602263f4c5a4d5a11c',
14
- 'lsp/diagnostics.js': '0fd15477b4df60e5ec065bb1a85c5daab6b9b433e730cb836b8ddc747554e0b9',
15
- 'lsp/findings.js': '72f7d80645c0941926a1cc029417fed93eca87e7d53bf2d032f4ef647fb1f168',
16
- 'lsp/lint.js': '159b07ffa100a62b2cd445d621606ae0d6b68aacc342cb5fdb3a2f4cadd7f508',
17
- 'lsp/protocol.js': 'd0ad8650307bf563bd058dc2bbbbc0ec9d4fd6dc2c9120bdc261d57c076ddc5d',
18
- 'lsp/server.js': 'a9f76280e395a47521973a14f3769c4df9e8c1153d29dedc535f56276e5a2e2e',
19
- 'slopnator.js': '804adba20c269c1134fd09e075d354db73b79cfd00c4b4ce66c1e40279670905',
20
- 'slopnators/sl_broken_lineage.js': '6d0ee15127166d9792b365e8a4623b5770a57e2ff92c2accf196afbb85052112',
21
- 'slopnators/sl_declared_elsewhere.js': '394da91ac84369217b4a02bc078ab98f62bf6d522042d84bec82b9705d621751',
22
- 'slopnators/sl_derived_drift.js': 'f7fb0e26cd6bff9dfe7392e1b1593a51741a6f6fac408bdafbb783e04141cf2f',
23
- 'slopnators/sl_hardcoded_style.js': 'a2b006990bc33150733645f3c17942ff497e7b3a6565af1331263df36d3b5e0a',
24
- 'slopnators/sl_inert_island.js': '0900de73ab7439b02a3321a6459e53882cfba6267dc8ef45d630ebe40f4bfa84',
25
- 'slopnators/sl_inert_slopnator.js': 'e3c35cfa2b094e1e2fd6824b75138cf44e8edb5ec396375d67e47897d84c45d7',
26
- 'slopnators/sl_missing_row.js': 'd942940388a873bebeff72d93cdb5fef20ba88e4fe29c1aa68e2f42389714a4a',
27
- 'slopnators/sl_no_barrel.js': '7df2a763d4b4ab16d945341b844271380b25774491bfa9c204dc252910951bc6',
28
- 'slopnators/sl_no_child_process.js': '24d4f89a1493c95db12e92a34dc4281a422226f638a47c795f26447090e056a1',
29
- 'slopnators/sl_no_comment.js': '4c4b9b502d6b33ed00d653d0b190d8f95b02bc5ef10da87f97913ca425f59f40',
30
- 'slopnators/sl_no_dispatch_bypass.js': '1def29fca350861b7185129180edd4727199e0f2bba92a0e0a8c0af437cbb382',
31
- 'slopnators/sl_no_import_cycle.js': '7ab70e4c182e88f73b4af75cddef9655a49996b8c70fcc2dcebd5f4aeb5fef92',
32
- 'slopnators/sl_no_such_command.js': 'fe037c2ad6891fd3c0338dd84c7007110c0bcd272a12bd8f1cb85ec779df7a8b',
33
- 'slopnators/sl_only_takes_a_literal.js': '3d5074f9c6a9bb581c80af8aa6d4a6793e29ac93c793367a67326acc1612c8fe',
34
- 'slopnators/sl_secret_literal.js': 'bc3987627f3b2892eec169d775771b6309d47b2c93e98c1bccad3f3ed5c5d2b6',
35
- 'slopnators/sl_stale_path.js': '3cc4050cb9ca2875afbb69c818d20d06e82f36a762ec48bd033c342a7023ff8a',
36
- 'slopnators/sl_twice_meant.js': '6fc5aaf29b635335bd4963931475e7334110439f8305737786c01be39f81230c',
37
- 'slopnators/sl_twice_parented.js': 'caa590bc4c11dbebe971f5a611a1712a529cc5a2900f37ba43cfa6b67a0a722b',
38
- 'slopnators/sl_undeclared_crossing.js': '47e41a38334a4b5a3eb0616d675dc46c5e4d6ce1138710b4470acc276e6ddec5',
39
- 'slopnators/sl_undeclared_destination.js': '3bbf07029a31eb31fa6556b686d067aae0cd5bf9487fe6ca1896984a55970a5c',
40
- 'slopnators/sl_undeclared_element.js': '2aa469ffdd58f104936904cbee2c95cb38182a2ac1057e0caa4db3d85e81331c',
41
- 'slopnators/sl_undeclared_node.js': '84c069a7d1bdec3d3c950ad40e016c129f280796b63a196a7866232e14995443',
42
- 'slopnators/sl_undeclared_operation.js': 'bc3fa4efc83bf5641020373d0f1506856c6272c3d59e4c4d261e3076f69a155e',
43
- 'slopnators/sl_undeclared_variant.js': 'e41ec11c9f4baf52dbea1aa7828238e5738de609ea47cdcac793cbe6198df770',
44
- 'slopnators/sl_undescribed.js': '15c6139a4afc3a4dc1a6196ec1acc2af5066a3330343074f6e2b321291cdbbd0',
45
- 'slopnators/sl_ungoverned_island.js': '555ae51adf994c5fce4ce51701af7d022be8824c001eeb132403fd6342a12a49',
46
- 'slopnators/sl_unkept_rows.js': '8abd67e8b8347a6dd9abd20fb7719d4f10553d6f329001a34ccc3e063d448e1d',
47
- 'slopnators/sl_unnamed_island.js': '0c92c5b6fdf59fb97448f24d72b883cd64317c23280316e043f993e7b75ac1da',
48
- 'slopnators/sl_unpaired_member.js': 'aafba4f829ef038289176b6e5ea6622494eba1982268d8d52b44f8c9889943e9',
49
- 'slopnators/sl_unpaired_slopnator.js': '2fa5b8c3c8b6a8a71466086f1d3ae32ea16fd22c49b113225e3c9a7e76eda45e',
50
- 'slopnators/sl_unprefixed_member.js': '67640331089c55ac59e7950e3c919144740309fb4a91cf0af87c41edb761f75d',
51
- 'slopnators/sl_unseamed_reach.js': 'd27a64c85b221e7c5bac99ab9d36955ad4945520d2b9e5ec75927574ca454cda',
52
- 'slopnators/sl_unthreaded.js': 'b686212f3515eb2769030979f7141d236677c9f3c1802e436f254ea5410a2361',
53
- 'slopnators/sl_untranslated_key.js': '224e80a4f34ce760502ee256347c9191e8d103e8b0ff58ef995c10111ddf2854',
54
- 'slopnators/sl_unversioned.js': 'df73b3186e42e6b58e7fb3fd48c3146a2d3902a337861a6ccb52f433a569e392',
55
- 'sweep.js': '2402ba042f87e693bf785d8e81b40870dd2fec539a70a9593d7ecba767dcda2c',
56
- };
@@ -1,56 +0,0 @@
1
- export const SEALED: Readonly<Record<string, string>> = {
2
- 'attach.js': 'e879e49449a3b90118335ab4d2ea6666956da92203438fac7b88ff3a65a79103',
3
- 'check-threads.js': '3c943a890af508bfeb0071974ab74ff3f90ff3ce5e7cd1ffa2e2580c6214b3e2',
4
- 'constraint.js': 'c6eebad19fc11c42c095d82f5658c204f322d136bcbaab98aa9fc06dfa625afb',
5
- 'generators/compiler.js': 'c6db73bfd31513d8334ef5cd063fb5f12b89c56739ff0f2b73249252d1817cdc',
6
- 'generators/gate.js': 'f865f469f13b9e3b2eb120bd233b3e286c0df30a4cdf15cd20be4cb995854f88',
7
- 'generators/issues.js': '21cd7349d3375f15cb8b1a0c31714ab645b021b952275046b56357fba68478b8',
8
- 'generators/publish.js': 'f19114019854ace16fd5ca94c42cbffd838894ce9e7679d6afd4cf26e2bdddd5',
9
- 'generators/rule.js': '82bdfefbf394528fa4e7994a60eb423b3188277571937e161648f72666728aa4',
10
- 'generators/seal.js': '39fb8ab5c95b9c0fd1d3d38090785b2e1890653bb1d0454868426b67b28abe3a',
11
- 'generators/trial.js': 'a2ef8fda83bb2894ae088a0d7887a4e49b9693fa1a7e1345879aaa63041914b0',
12
- 'lint.js': '63f9957725a94498d7e5a49544da343c5f2e1b3b9c2778000dae4a4f39036ef9',
13
- 'lsp/bin.js': 'b71d5da40c137dbe87083ad29bf1a54e30a190113b8811602263f4c5a4d5a11c',
14
- 'lsp/diagnostics.js': '0fd15477b4df60e5ec065bb1a85c5daab6b9b433e730cb836b8ddc747554e0b9',
15
- 'lsp/findings.js': '72f7d80645c0941926a1cc029417fed93eca87e7d53bf2d032f4ef647fb1f168',
16
- 'lsp/lint.js': '159b07ffa100a62b2cd445d621606ae0d6b68aacc342cb5fdb3a2f4cadd7f508',
17
- 'lsp/protocol.js': 'd0ad8650307bf563bd058dc2bbbbc0ec9d4fd6dc2c9120bdc261d57c076ddc5d',
18
- 'lsp/server.js': 'a9f76280e395a47521973a14f3769c4df9e8c1153d29dedc535f56276e5a2e2e',
19
- 'slopnator.js': '804adba20c269c1134fd09e075d354db73b79cfd00c4b4ce66c1e40279670905',
20
- 'slopnators/sl_broken_lineage.js': '6d0ee15127166d9792b365e8a4623b5770a57e2ff92c2accf196afbb85052112',
21
- 'slopnators/sl_declared_elsewhere.js': '394da91ac84369217b4a02bc078ab98f62bf6d522042d84bec82b9705d621751',
22
- 'slopnators/sl_derived_drift.js': 'f7fb0e26cd6bff9dfe7392e1b1593a51741a6f6fac408bdafbb783e04141cf2f',
23
- 'slopnators/sl_hardcoded_style.js': 'a2b006990bc33150733645f3c17942ff497e7b3a6565af1331263df36d3b5e0a',
24
- 'slopnators/sl_inert_island.js': '0900de73ab7439b02a3321a6459e53882cfba6267dc8ef45d630ebe40f4bfa84',
25
- 'slopnators/sl_inert_slopnator.js': 'e3c35cfa2b094e1e2fd6824b75138cf44e8edb5ec396375d67e47897d84c45d7',
26
- 'slopnators/sl_missing_row.js': 'd942940388a873bebeff72d93cdb5fef20ba88e4fe29c1aa68e2f42389714a4a',
27
- 'slopnators/sl_no_barrel.js': '7df2a763d4b4ab16d945341b844271380b25774491bfa9c204dc252910951bc6',
28
- 'slopnators/sl_no_child_process.js': '24d4f89a1493c95db12e92a34dc4281a422226f638a47c795f26447090e056a1',
29
- 'slopnators/sl_no_comment.js': '4c4b9b502d6b33ed00d653d0b190d8f95b02bc5ef10da87f97913ca425f59f40',
30
- 'slopnators/sl_no_dispatch_bypass.js': '1def29fca350861b7185129180edd4727199e0f2bba92a0e0a8c0af437cbb382',
31
- 'slopnators/sl_no_import_cycle.js': '7ab70e4c182e88f73b4af75cddef9655a49996b8c70fcc2dcebd5f4aeb5fef92',
32
- 'slopnators/sl_no_such_command.js': 'fe037c2ad6891fd3c0338dd84c7007110c0bcd272a12bd8f1cb85ec779df7a8b',
33
- 'slopnators/sl_only_takes_a_literal.js': '3d5074f9c6a9bb581c80af8aa6d4a6793e29ac93c793367a67326acc1612c8fe',
34
- 'slopnators/sl_secret_literal.js': 'bc3987627f3b2892eec169d775771b6309d47b2c93e98c1bccad3f3ed5c5d2b6',
35
- 'slopnators/sl_stale_path.js': '3cc4050cb9ca2875afbb69c818d20d06e82f36a762ec48bd033c342a7023ff8a',
36
- 'slopnators/sl_twice_meant.js': '6fc5aaf29b635335bd4963931475e7334110439f8305737786c01be39f81230c',
37
- 'slopnators/sl_twice_parented.js': 'caa590bc4c11dbebe971f5a611a1712a529cc5a2900f37ba43cfa6b67a0a722b',
38
- 'slopnators/sl_undeclared_crossing.js': '47e41a38334a4b5a3eb0616d675dc46c5e4d6ce1138710b4470acc276e6ddec5',
39
- 'slopnators/sl_undeclared_destination.js': '3bbf07029a31eb31fa6556b686d067aae0cd5bf9487fe6ca1896984a55970a5c',
40
- 'slopnators/sl_undeclared_element.js': '2aa469ffdd58f104936904cbee2c95cb38182a2ac1057e0caa4db3d85e81331c',
41
- 'slopnators/sl_undeclared_node.js': '84c069a7d1bdec3d3c950ad40e016c129f280796b63a196a7866232e14995443',
42
- 'slopnators/sl_undeclared_operation.js': 'bc3fa4efc83bf5641020373d0f1506856c6272c3d59e4c4d261e3076f69a155e',
43
- 'slopnators/sl_undeclared_variant.js': 'e41ec11c9f4baf52dbea1aa7828238e5738de609ea47cdcac793cbe6198df770',
44
- 'slopnators/sl_undescribed.js': '15c6139a4afc3a4dc1a6196ec1acc2af5066a3330343074f6e2b321291cdbbd0',
45
- 'slopnators/sl_ungoverned_island.js': '555ae51adf994c5fce4ce51701af7d022be8824c001eeb132403fd6342a12a49',
46
- 'slopnators/sl_unkept_rows.js': '8abd67e8b8347a6dd9abd20fb7719d4f10553d6f329001a34ccc3e063d448e1d',
47
- 'slopnators/sl_unnamed_island.js': '0c92c5b6fdf59fb97448f24d72b883cd64317c23280316e043f993e7b75ac1da',
48
- 'slopnators/sl_unpaired_member.js': 'aafba4f829ef038289176b6e5ea6622494eba1982268d8d52b44f8c9889943e9',
49
- 'slopnators/sl_unpaired_slopnator.js': '2fa5b8c3c8b6a8a71466086f1d3ae32ea16fd22c49b113225e3c9a7e76eda45e',
50
- 'slopnators/sl_unprefixed_member.js': '67640331089c55ac59e7950e3c919144740309fb4a91cf0af87c41edb761f75d',
51
- 'slopnators/sl_unseamed_reach.js': 'd27a64c85b221e7c5bac99ab9d36955ad4945520d2b9e5ec75927574ca454cda',
52
- 'slopnators/sl_unthreaded.js': 'b686212f3515eb2769030979f7141d236677c9f3c1802e436f254ea5410a2361',
53
- 'slopnators/sl_untranslated_key.js': '224e80a4f34ce760502ee256347c9191e8d103e8b0ff58ef995c10111ddf2854',
54
- 'slopnators/sl_unversioned.js': 'df73b3186e42e6b58e7fb3fd48c3146a2d3902a337861a6ccb52f433a569e392',
55
- 'sweep.js': '2402ba042f87e693bf785d8e81b40870dd2fec539a70a9593d7ecba767dcda2c',
56
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,222 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
3
- import { dirname, join, relative } from 'node:path';
4
- import { argv, cwd, env, execPath, stdout } from 'node:process';
5
- import { fileURLToPath } from 'node:url';
6
- import { SKILLS_AT, declared, nouns, skillOf } from "../../core/asking.js";
7
- import { generators } from "../../core/chain.js";
8
- import { TREE } from "../../core/descend.js";
9
- import { LOADER, exit, invoked } from "../../core/invoked.js";
10
- import { ORGANISATION, named } from "../../core/scope.js";
11
- import { findTree } from "../../core/tree.js";
12
- const WHERE = SKILLS_AT;
13
- const RECEIPT_LINE = /^[a-z]+: receipt .*$/gm;
14
- const NONCE = /--receipt [0-9a-f]{6,}/g;
15
- const CRLF = /\r\n/g;
16
- const META = fileURLToPath(new URL('../../core/generators/meta.ts', import.meta.url));
17
- const fileFor = (noun) => skillOf(noun);
18
- async function offering(tree) {
19
- const answers = relative(tree.at, META).split('\\').join('/');
20
- const found = new Map(nouns(await generators(tree)));
21
- found.set('meta', answers);
22
- for (const noun of (await declared(tree)).keys())
23
- if (!found.has(noun))
24
- found.set(noun, answers);
25
- return found;
26
- }
27
- function printed(root, at, noun) {
28
- if (at === '')
29
- return { refused: `nothing in this tree is written by \`thread create ${noun}\``, body: '' };
30
- const ran = spawnSync(execPath, [...LOADER, join(root, at)], {
31
- cwd: root,
32
- encoding: 'utf8',
33
- env: { ...env, THREAD_NOUN: noun },
34
- stdio: ['ignore', 'pipe', 'pipe'],
35
- });
36
- const body = String(ran.stdout ?? '').replace(CRLF, '\n').replace(RECEIPT_LINE, '').trimEnd();
37
- const said = String(ran.stderr ?? '').replace(CRLF, '\n').trim().split('\n')[0] ?? '';
38
- return { refused: body === '' ? said || 'it printed nothing' : '', body };
39
- }
40
- function skill(noun, body) {
41
- return [
42
- `# ${noun}`,
43
- '',
44
- `Everything \`npx thread create ${noun}\` knows, written out by \`npx thread skills\`.`,
45
- '',
46
- '**Do not edit this file.** It is derived from the tree, so an edit here is reverted the next',
47
- 'time the command runs, and `npx thread skills --check` fails until it is. If something below is',
48
- 'wrong or missing, the command that printed it is what to change.',
49
- '',
50
- `**Read this before you declare a ${noun}.** What follows is what already exists. The reason it`,
51
- 'exists is that things get built twice by people who did not look — thirteen elements were once',
52
- 'declared in one app that every one of them already shipped, and the cost was two days of fixes',
53
- 'landing on a page nobody was looking at. Open what it names before you add to it.',
54
- '',
55
- 'When you are ready to write, run the command yourself for a live receipt. The one printed here',
56
- 'has been removed on purpose: a receipt is spent by one run and goes stale the moment its sheet',
57
- 'changes, so a copy kept in a file is always the wrong one.',
58
- '',
59
- '```',
60
- body.replace(NONCE, '--receipt <receipt>'),
61
- '```',
62
- '',
63
- ].join('\n');
64
- }
65
- const SHEET = `${TREE}_generated/skills.ts`;
66
- function sheet(files) {
67
- const rows = files.map((at) => {
68
- const noun = at.slice(WHERE.length + 1, -'.md'.length);
69
- return [
70
- ' {',
71
- ` id: 'skill-${noun}',`,
72
- ` at: '${at}',`,
73
- ` describes: 'What \`thread create ${noun}\` teaches: the ${noun}s this tree already has, with the sentence each one states, and the rules for declaring another. Written from what that command prints about itself, so the skill and the command cannot disagree.',`,
74
- ' version: 1,',
75
- " by: 'thread skills',",
76
- " runs: 'thread skills --check',",
77
- ' },',
78
- ].join('\n');
79
- });
80
- return [
81
- "import type { Threaded } from '../../thread/core/thread.ts'",
82
- '',
83
- 'export const SKILLS: Threaded = {',
84
- " id: 'skills',",
85
- ` at: '${SHEET}',`,
86
- " describes: 'One row per skill `thread skills` writes, so every `skills/<noun>.md` is declared by the command that wrote it instead of being refused as a file nothing named. It sits beside the files it names because the nouns are not known until the tree is read, and a list somebody keeps by hand would go stale the first time a package brings a new maker.',",
87
- ' version: 1,',
88
- ' derives: [',
89
- ...rows,
90
- ' ],',
91
- '}',
92
- '',
93
- ].join('\n');
94
- }
95
- const HERE = () => cwd();
96
- const COINS = /by:\s*'thread create ([a-z][a-z0-9-]*)'/g;
97
- const ANSWERS_AT = new RegExp(`at:\\s*'node_modules/${ORGANISATION}/[^/]+/(dist/[^']+)'`, 'g');
98
- function ownMakers(root) {
99
- const found = new Map();
100
- let names;
101
- try {
102
- names = readdirSync(join(root, 'src'), { recursive: true });
103
- }
104
- catch {
105
- return found;
106
- }
107
- for (const one of names) {
108
- const path = String(one).split('\\').join('/');
109
- if (!path.endsWith('attach.ts'))
110
- continue;
111
- let text;
112
- try {
113
- text = readFileSync(join(root, 'src', String(one)), 'utf8');
114
- }
115
- catch {
116
- continue;
117
- }
118
- for (const row of text.split(/\{\s*$/m)) {
119
- const noun = [...row.matchAll(COINS)].at(0)?.[1];
120
- const at = [...row.matchAll(ANSWERS_AT)].at(-1)?.[1];
121
- if (noun === undefined || at === undefined || found.has(noun))
122
- continue;
123
- found.set(noun, join(root, at));
124
- }
125
- }
126
- return found;
127
- }
128
- function printedOwn(at) {
129
- const ran = spawnSync(execPath, ['--experimental-strip-types', at, '--own'], {
130
- encoding: 'utf8',
131
- stdio: ['ignore', 'pipe', 'pipe'],
132
- });
133
- const body = String(ran.stdout ?? '').replace(CRLF, '\n').replace(RECEIPT_LINE, '').trimEnd();
134
- const said = String(ran.stderr ?? '').replace(CRLF, '\n').trim().split('\n')[0] ?? '';
135
- return { refused: ran.status === 0 && body !== '' ? '' : said || 'it printed nothing', body };
136
- }
137
- async function run() {
138
- const own = argv.includes('--own');
139
- const checking = argv.includes('--check');
140
- const root = own ? HERE() : findTree().at;
141
- const mine = own ? ownMakers(root) : new Map();
142
- const theirs = own ? new Map() : await offering(findTree());
143
- const known = [...(own ? mine : theirs).keys()].sort();
144
- if (known.length === 0) {
145
- stdout.write(own
146
- ? 'skills: this package ships no maker, so it coins no noun and has no skill to write.\n'
147
- : 'skills: this tree declares no `create` command yet, so there is no method to write down. ' +
148
- `Attach a package that brings one — \`npx thread attach ${named('ui')}\` — and run this again.\n`);
149
- return 0;
150
- }
151
- const wanted = new Map();
152
- const skipped = [];
153
- for (const noun of known) {
154
- const { refused, body } = own ? printedOwn(mine.get(noun) ?? '') : printed(root, theirs.get(noun) ?? '', noun);
155
- if (refused !== '') {
156
- skipped.push(` ${noun} — ${refused}`);
157
- continue;
158
- }
159
- wanted.set(fileFor(noun), skill(noun, body));
160
- }
161
- if (wanted.size === 0) {
162
- stdout.write(`skills: every \`create\` this tree declares refused, so there is no method to write down yet:\n${skipped.join('\n')}\n`);
163
- return 1;
164
- }
165
- const made = wanted.size;
166
- const sheetAt = own ? '' : SHEET;
167
- if (sheetAt !== '')
168
- wanted.set(sheetAt, sheet([...wanted.keys()].sort()));
169
- const held = new Map();
170
- try {
171
- for (const name of readdirSync(join(root, WHERE))) {
172
- if (!name.endsWith('.md'))
173
- continue;
174
- held.set(join(WHERE, name), readFileSync(join(root, WHERE, name), 'utf8').replace(CRLF, '\n'));
175
- }
176
- }
177
- catch {
178
- }
179
- if (sheetAt !== '') {
180
- try {
181
- held.set(sheetAt, readFileSync(join(root, sheetAt), 'utf8').replace(CRLF, '\n'));
182
- }
183
- catch {
184
- }
185
- }
186
- const stale = [...held.keys()].filter((one) => !wanted.has(one)).sort();
187
- const differs = [...wanted.entries()].filter(([one, text]) => held.get(one) !== text).map(([one]) => one).sort();
188
- if (checking) {
189
- if (stale.length === 0 && differs.length === 0) {
190
- stdout.write(`skills: ${String(made)} skill(s), each matching what its own command prints` +
191
- (sheetAt === '' ? '' : `, and each declared by a row in ${sheetAt}`) +
192
- '.\n');
193
- return 0;
194
- }
195
- for (const one of differs) {
196
- stdout.write(`skills: ${one} is not what \`npx thread skills\` writes. A skill is derived from the command ` +
197
- 'it describes, so an edit here is a second statement of the method and will drift from the ' +
198
- 'first. Change the command, then run `npx thread skills`.\n');
199
- }
200
- for (const one of stale) {
201
- stdout.write(`skills: ${one} names a \`create\` this tree no longer declares, so it teaches a command that ` +
202
- 'will refuse. Run `npx thread skills`.\n');
203
- }
204
- return 1;
205
- }
206
- for (const [one, text] of wanted) {
207
- mkdirSync(dirname(join(root, one)), { recursive: true });
208
- writeFileSync(join(root, one), text, 'utf8');
209
- }
210
- for (const one of stale)
211
- rmSync(join(root, one), { force: true });
212
- stdout.write(`skills: wrote ${String(made)} skill(s) into ${WHERE}/` +
213
- (sheetAt === '' ? '' : `, and the ${String(made)} row(s) declaring them into ${sheetAt}`) +
214
- (stale.length === 0
215
- ? ''
216
- : `, and removed ${String(stale.length)} naming a command this tree no longer has`) +
217
- '.\n' +
218
- (skipped.length === 0 ? '' : `skills: no method to keep yet for:\n${skipped.join('\n')}\n`));
219
- return 0;
220
- }
221
- if (invoked(import.meta.url))
222
- exit(await run());