@uknows/setup 0.0.0-stage → 0.2.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 (53) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +209 -2
  3. package/bin/uknows-setup.mjs +14 -0
  4. package/lib/automate.mjs +1299 -0
  5. package/lib/check.mjs +327 -0
  6. package/lib/ci.mjs +21 -0
  7. package/lib/cli.mjs +251 -0
  8. package/lib/cloudid.mjs +456 -0
  9. package/lib/code.mjs +147 -0
  10. package/lib/context.mjs +126 -0
  11. package/lib/contract-docs.mjs +2736 -0
  12. package/lib/contract.mjs +149 -0
  13. package/lib/detect.mjs +627 -0
  14. package/lib/diff.mjs +147 -0
  15. package/lib/doc.mjs +98 -0
  16. package/lib/dockerfile.mjs +455 -0
  17. package/lib/endpoint.mjs +81 -0
  18. package/lib/engine.mjs +1753 -0
  19. package/lib/existing.mjs +562 -0
  20. package/lib/git.mjs +100 -0
  21. package/lib/hooks/UknowsOpenTelemetry.cs +118 -0
  22. package/lib/hooks/pins.mjs +28 -0
  23. package/lib/hooks/uknows-otel.cjs +82 -0
  24. package/lib/hooks/uknows_otel.py +179 -0
  25. package/lib/hosts.mjs +650 -0
  26. package/lib/locks.mjs +353 -0
  27. package/lib/manifest.mjs +132 -0
  28. package/lib/members.mjs +269 -0
  29. package/lib/plan.mjs +130 -0
  30. package/lib/settings.mjs +468 -0
  31. package/lib/signin.mjs +259 -0
  32. package/lib/stacks/azure.mjs +345 -0
  33. package/lib/stacks/channel.mjs +125 -0
  34. package/lib/stacks/dotnet.mjs +472 -0
  35. package/lib/stacks/functions-hooks.mjs +228 -0
  36. package/lib/stacks/functions.mjs +148 -0
  37. package/lib/stacks/guided.mjs +227 -0
  38. package/lib/stacks/index.mjs +18 -0
  39. package/lib/stacks/java.mjs +57 -0
  40. package/lib/stacks/k8s.mjs +31 -0
  41. package/lib/stacks/node.mjs +358 -0
  42. package/lib/stacks/otel.mjs +63 -0
  43. package/lib/stacks/python-bootstrap.mjs +71 -0
  44. package/lib/stacks/python-lock.mjs +105 -0
  45. package/lib/stacks/python-sets.mjs +143 -0
  46. package/lib/stacks/python.mjs +632 -0
  47. package/lib/toml.mjs +64 -0
  48. package/lib/types.mjs +208 -0
  49. package/lib/ui.mjs +225 -0
  50. package/lib/updates.mjs +398 -0
  51. package/lib/versions.mjs +115 -0
  52. package/lib/workspace.mjs +201 -0
  53. package/package.json +37 -4
@@ -0,0 +1,149 @@
1
+ /*
2
+ * The UKNOWS install contract. Data only.
3
+ *
4
+ * Everything the docs page shows comes from contract-docs.mjs, which
5
+ * tools/sync-contract.mjs generates from src/docs/install.ts. Import those
6
+ * values from here and never copy their text into other modules, so a
7
+ * re-sync updates the whole CLI.
8
+ *
9
+ * PINS and CLI below are values the CLI needs that the docs page does not
10
+ * show. Upstream facts checked on 2026-10-12.
11
+ */
12
+
13
+ export * from './contract-docs.mjs'
14
+ import { GO_RELEASES, NODE_REGISTER, PING_URL } from './contract-docs.mjs'
15
+
16
+ /** The node options that load a register file: --require, or for ES modules the loader hook and --import. */
17
+ const nodeFlag = (esm, register = NODE_REGISTER) => (esm ? `--experimental-loader=@opentelemetry/instrumentation/hook.mjs --import ${register}`
18
+ : `--require ${register}`)
19
+
20
+ /**
21
+ * Known-good OpenTelemetry sets for Python, newest first. core: opentelemetry-sdk and the OTLP exporter. contrib:
22
+ * opentelemetry-distro and each opentelemetry-instrumentation-* package. minPython: the lowest Python of that
23
+ * release. protobuf: [lowest, below] that opentelemetry-proto of that release allows. Checked on PyPI on
24
+ * 2026-10-18 with tools/check-python-sets.mjs (not shipped). 1.27.0 is the last release for protobuf below 5:
25
+ * uv pip compile with protobuf<5 picks 1.27.0 and 0.48b0.
26
+ */
27
+ const PYTHON_SETS = [
28
+ { core: '1.45.1', contrib: '0.66b1', minPython: [3, 10], protobuf: ['5.0', '8.0'] },
29
+ { core: '1.41.1', contrib: '0.62b1', minPython: [3, 9], protobuf: ['5.0', '7.0'] },
30
+ { core: '1.27.0', contrib: '0.48b0', minPython: [3, 8], protobuf: ['3.19', '5.0'] },
31
+ ]
32
+
33
+ export const PINS = {
34
+ node: {
35
+ /** Same 2 packages as the docs install line. The package manager picks the versions. */
36
+ packages: ['@opentelemetry/api', '@opentelemetry/auto-instrumentations-node'],
37
+ /** ESM apps also need this one as a direct dependency (pnpm cannot resolve hook.mjs otherwise). */
38
+ esmPackage: '@opentelemetry/instrumentation',
39
+ /** The upstream register line: for a start that this tool cannot give the start file, and in printed steps. */
40
+ requireFlag: nodeFlag(false),
41
+ esmFlag: nodeFlag(true),
42
+ /**
43
+ * The same options with the start file of this tool (install.ts NODE_REGISTER_FILE): its absolute path in an
44
+ * image, or ./uknows-otel.cjs in a start script. The ESM loader hook stays: it gives each request its route.
45
+ */
46
+ flag: nodeFlag,
47
+ /**
48
+ * The npm major version that each Node.js release comes with, from https://nodejs.org/dist/index.json on 18 Oct
49
+ * 2026: [lowest Node.js version, npm major], newest first. The official node images use that npm. npm on this
50
+ * computer writes package-lock.json, and npm ci in the image reads it, so a newer npm here stops the run.
51
+ */
52
+ npm: [[[24, 0], 11], [[20, 7], 10], [[20, 0], 9], [[19, 3], 9], [[19, 0], 8], [[18, 19], 10], [[18, 14], 9], [[18, 0], 8]],
53
+ },
54
+ python: {
55
+ /** Same 2 packages as the docs install line, pinned like pip freeze would: the newest set. */
56
+ distro: `opentelemetry-distro==${PYTHON_SETS[0].contrib}`,
57
+ exporter: `opentelemetry-exporter-otlp-proto-http==${PYTHON_SETS[0].core}`,
58
+ /** Version of each opentelemetry-instrumentation-* package that opentelemetry-bootstrap prints. */
59
+ contrib: PYTHON_SETS[0].contrib,
60
+ /** opentelemetry-distro 0.66b1 needs Python 3.10 or later. */
61
+ minPython: PYTHON_SETS[0].minPython,
62
+ /**
63
+ * requirements.txt and other files with no lock: exact pins from the first set that fits the direct limits of
64
+ * the file (protobuf, opentelemetry-*) and the Python of the image. The plan says why it is not the newest.
65
+ */
66
+ sets: PYTHON_SETS,
67
+ /**
68
+ * uv and Poetry projects: floors, not pins, so their resolver picks the newest release that the app allows.
69
+ * The floors are the oldest set and name a pre-release on purpose, so uv and Poetry allow the b releases.
70
+ */
71
+ floors: { core: PYTHON_SETS.at(-1).core, contrib: PYTHON_SETS.at(-1).contrib },
72
+ },
73
+ dotnet: {
74
+ package: 'OpenTelemetry.AutoInstrumentation',
75
+ version: '1.17.0',
76
+ /** 1.17.0 targets net8.0 and net462 only. */
77
+ minNet: 8,
78
+ /** The build fails when an app uses StackExchange.Redis [2.6.122, 4.0.0) without this package. */
79
+ redis: { library: 'StackExchange.Redis', package: 'OpenTelemetry.Instrumentation.StackExchangeRedis', version: '1.19.0-beta.1',
80
+ /** The range of StackExchange.Redis that the build check of OpenTelemetry.AutoInstrumentation 1.17.0 asks for: [min, below). */
81
+ range: ['2.6.122', '4.0.0'],
82
+ /**
83
+ * Packages that bring StackExchange.Redis in. With no packages.lock.json or obj/project.assets.json, 1 of them
84
+ * in the project counts as StackExchange.Redis. With a lock or assets file, the resolved version decides.
85
+ */
86
+ carriers: ['NRedisStack', 'Microsoft.Extensions.Caching.StackExchangeRedis', 'Microsoft.AspNetCore.SignalR.StackExchangeRedis',
87
+ 'Microsoft.AspNetCore.DataProtection.StackExchangeRedis', 'Hangfire.Redis.StackExchange'] },
88
+ /**
89
+ * For apps with Azure Monitor and no lock or assets file: the OTLP exporter at the OpenTelemetry version that
90
+ * OpenTelemetry.AutoInstrumentation 1.17.0 uses. With a lock, the exporter takes the resolved OpenTelemetry version.
91
+ */
92
+ otlpExporter: { package: 'OpenTelemetry.Exporter.OpenTelemetryProtocol', version: '1.19.1' },
93
+ },
94
+ /**
95
+ * The OpenTelemetry SDK package of each language, and the lowest version of it that the packages of this tool
96
+ * need. A package that limits the SDK below this version stops the run (the wrapper stop). Checked on 2026-10-18:
97
+ * OpenTelemetry.AutoInstrumentation.Runtime.Managed 1.17.0 needs OpenTelemetry 1.19.1.
98
+ */
99
+ sdk: {
100
+ python: { package: 'opentelemetry-sdk', need: '1.45.1' },
101
+ dotnet: { package: 'OpenTelemetry', need: '1.19.1' },
102
+ node: { package: '@opentelemetry/sdk-trace-base', need: null },
103
+ },
104
+ go: {
105
+ /**
106
+ * go get takes the latest modules. go.opentelemetry.io/otel v1.47.0 and otelhttp declare go 1.26.0, so older Go
107
+ * builders fail (golang images set GOTOOLCHAIN=local). Checked upstream on 2026-10-12.
108
+ */
109
+ minGo: [1, 26],
110
+ /** Below minGo, the go get lines name the versions of install.ts GO_RELEASES. Below the oldest row, Go is too old. */
111
+ oldestGo: GO_RELEASES.at(-1).go.split('.').map(Number),
112
+ },
113
+ php: {
114
+ /** The 6th setting for PHP. The docs PHP Dockerfile adds it with the 5. */
115
+ autoload: { name: 'OTEL_PHP_AUTOLOAD_ENABLED', value: 'true' },
116
+ },
117
+ }
118
+
119
+ /** The agent channels (--channel), and the form of the registry setting: a host and a path, no scheme and no tag. */
120
+ export const AGENT_CHANNELS = ['stable', 'early']
121
+ /**
122
+ * The public store of the UKNOWS agent images, a host and a path under a uknows.my name: setup builds
123
+ * <registry>/agent-<lang>:<channel> from it, for example registry.uknows.my/uknows/agent-node:stable. Anyone can pull
124
+ * from it without signing in. UKNOWS_AGENT_REGISTRY overrides it. If it were empty, setup would use the agent channel
125
+ * only when UKNOWS_AGENT_REGISTRY is set, and the publish gate (tools/prepublish.mjs) would stop.
126
+ */
127
+ export const DEFAULT_AGENT_REGISTRY = 'registry.uknows.my/uknows'
128
+ export const AGENT_REGISTRY = /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:\d{1,5})?(\/[a-z0-9]+([._-][a-z0-9]+)*)*$/
129
+
130
+ export const CLI = {
131
+ /** Records what setup changed so remove can undo it exactly. Never holds secrets. */
132
+ manifest: '.uknows/setup.json',
133
+ /** Override for the ingest address, for a test environment. setup writes it and check sends to it (endpoint.mjs). */
134
+ endpointEnv: 'UKNOWS_INGEST_ENDPOINT',
135
+ /** Override for the site address (where check asks which workspace a key sends to), for a test environment. */
136
+ siteEnv: 'UKNOWS_SITE_URL',
137
+ /** Override for the app address (where the user watches an app connect), for a test environment. */
138
+ appEnv: 'UKNOWS_APP_URL',
139
+ /** The registry and path of the UKNOWS agent images, for --channel. For example registry.example.com/uknows. */
140
+ agentRegistryEnv: 'UKNOWS_AGENT_REGISTRY',
141
+ /** The route of the site that says which workspace and environment a key sends to. */
142
+ pingPath: new URL(PING_URL).pathname,
143
+ exit: { ok: 0, error: 1, usage: 2, manual: 3 },
144
+ /**
145
+ * A run counts as CI when one of these is set and not empty. CI also must not be 0 or false.
146
+ * --allow-ci lets a bot or an AI agent that opens a pull request apply anyway.
147
+ */
148
+ ciEnv: ['CI', 'GITHUB_ACTIONS', 'TF_BUILD', 'GITLAB_CI', 'BUILDKITE', 'CIRCLECI', 'JENKINS_URL', 'TEAMCITY_VERSION', 'BITBUCKET_BUILD_NUMBER', 'CODEBUILD_BUILD_ID'],
149
+ }